Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
boazpoolman committed Jan 2, 2025
0 parents commit 8048e83
Show file tree
Hide file tree
Showing 34 changed files with 10,870 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{package.json,*.yml}]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
138 changes: 138 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

############################
# OS X
############################

.DS_Store
.AppleDouble
.LSOverride
Icon
.Spotlight-V100
.Trashes
._*


############################
# Linux
############################

*~


############################
# Windows
############################

Thumbs.db
ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
*.cab
*.msi
*.msm
*.msp


############################
# Packages
############################

*.7z
*.csv
*.dat
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
*.com
*.class
*.dll
*.exe
*.o
*.seed
*.so
*.swo
*.swp
*.swn
*.swm
*.out
*.pid


############################
# Logs and databases
############################

.tmp
*.log
*.sql
*.sqlite
*.sqlite3


############################
# Misc.
############################

*#
ssl
.idea
nbproject
.tsbuildinfo
.eslintcache
.env


############################
# Strapi
############################

public/uploads/*
!public/uploads/.gitkeep


############################
# Build
############################

dist
build


############################
# Node.js
############################

lib-cov
lcov.info
pids
logs
results
node_modules
.node_history


############################
# Package managers
############################

.yarn/*
!.yarn/cache
!.yarn/unplugged
!.yarn/patches
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.pnp.*
yarn-error.log


############################
# Tests
############################

coverage
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
coverage
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"endOfLine": "lf",
"tabWidth": 2,
"printWidth": 100,
"singleQuote": true,
"trailingComma": "es5"
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# strapi-plugin-boilerplate

A test-driven template for building reliable Strapi Plugins
2 changes: 2 additions & 0 deletions admin/custom.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare module '@strapi/design-system/*';
declare module '@strapi/design-system';
19 changes: 19 additions & 0 deletions admin/src/components/Initializer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { useEffect, useRef } from 'react';

import { PLUGIN_ID } from '../pluginId';

type InitializerProps = {
setPlugin: (id: string) => void;
};

const Initializer = ({ setPlugin }: InitializerProps) => {
const ref = useRef(setPlugin);

useEffect(() => {
ref.current(PLUGIN_ID);
}, []);

return null;
};

export { Initializer };
5 changes: 5 additions & 0 deletions admin/src/components/PluginIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { PuzzlePiece } from '@strapi/icons';

const PluginIcon = () => <PuzzlePiece />;

export { PluginIcon };
43 changes: 43 additions & 0 deletions admin/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { getTranslation } from './utils/getTranslation';
import { PLUGIN_ID } from './pluginId';
import { Initializer } from './components/Initializer';
import { PluginIcon } from './components/PluginIcon';

export default {
register(app: any) {
app.addMenuLink({
to: `plugins/${PLUGIN_ID}`,
icon: PluginIcon,
intlLabel: {
id: `${PLUGIN_ID}.plugin.name`,
defaultMessage: PLUGIN_ID,
},
Component: async () => {
const { App } = await import('./pages/App');

return App;
},
});

app.registerPlugin({
id: PLUGIN_ID,
initializer: Initializer,
isReady: false,
name: PLUGIN_ID,
});
},

async registerTrads({ locales }: { locales: string[] }) {
return Promise.all(
locales.map(async (locale) => {
try {
const { default: data } = await import(`./translations/${locale}.json`);

return { data, locale };
} catch {
return { data: {}, locale };
}
})
);
},
};
15 changes: 15 additions & 0 deletions admin/src/pages/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Page } from '@strapi/strapi/admin';
import { Routes, Route } from 'react-router-dom';

import { HomePage } from './HomePage';

const App = () => {
return (
<Routes>
<Route index element={<HomePage />} />
<Route path="*" element={<Page.Error />} />
</Routes>
);
};

export { App };
16 changes: 16 additions & 0 deletions admin/src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Main } from '@strapi/design-system';
import { useIntl } from 'react-intl';

import { getTranslation } from '../utils/getTranslation';

const HomePage = () => {
const { formatMessage } = useIntl();

return (
<Main>
<h1>Welcome to {formatMessage({ id: getTranslation('plugin.name') })}</h1>
</Main>
);
};

export { HomePage };
1 change: 1 addition & 0 deletions admin/src/pluginId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const PLUGIN_ID = 'boilerplate';
1 change: 1 addition & 0 deletions admin/src/translations/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
5 changes: 5 additions & 0 deletions admin/src/utils/getTranslation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { PLUGIN_ID } from '../pluginId';

const getTranslation = (id: string) => `${PLUGIN_ID}.${id}`;

export { getTranslation };
10 changes: 10 additions & 0 deletions admin/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig",
"include": ["./src", "./custom.d.ts"],
"exclude": ["**/*.test.ts", "**/*.test.tsx"],
"compilerOptions": {
"rootDir": "../",
"baseUrl": ".",
"outDir": "./dist"
}
}
8 changes: 8 additions & 0 deletions admin/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "@strapi/typescript-utils/tsconfigs/admin",
"include": ["./src", "./custom.d.ts"],
"compilerOptions": {
"rootDir": "../",
"baseUrl": "."
}
}
77 changes: 77 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"version": "0.0.0",
"keywords": [],
"type": "commonjs",
"exports": {
"./package.json": "./package.json",
"./strapi-admin": {
"types": "./dist/admin/src/index.d.ts",
"source": "./admin/src/index.ts",
"import": "./dist/admin/index.mjs",
"require": "./dist/admin/index.js",
"default": "./dist/admin/index.js"
},
"./strapi-server": {
"types": "./dist/server/src/index.d.ts",
"source": "./server/src/index.ts",
"import": "./dist/server/index.mjs",
"require": "./dist/server/index.js",
"default": "./dist/server/index.js"
}
},
"files": [
"dist"
],
"scripts": {
"build": "strapi-plugin build",
"watch": "strapi-plugin watch",
"watch:link": "strapi-plugin watch:link",
"verify": "strapi-plugin verify",
"test:ts:front": "run -T tsc -p admin/tsconfig.json",
"test:ts:back": "run -T tsc -p server/tsconfig.json"
},
"dependencies": {
"@strapi/design-system": "^2.0.0-rc.14",
"@strapi/icons": "^2.0.0-rc.14",
"react-intl": "^7.1.0"
},
"devDependencies": {
"@strapi/strapi": "^5.6.0",
"@strapi/sdk-plugin": "^5.2.8",
"prettier": "^3.4.2",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-router-dom": "^7.1.1",
"styled-components": "^6.1.13",
"@types/react": "^19.0.2",
"@types/react-dom": "^19.0.2",
"@strapi/typescript-utils": "^5.6.0",
"typescript": "^5.7.2"
},
"peerDependencies": {
"@strapi/strapi": "^5.6.0",
"@strapi/sdk-plugin": "^5.2.8",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.28.1",
"styled-components": "^6.1.13"
},
"strapi": {
"kind": "plugin",
"name": "strapi-plugin-boilerplate",
"displayName": "Boilerplate",
"description": "A test-driven template for building reliable Strapi Plugins"
},
"name": "strapi-plugin-boilerplate",
"description": "A test-driven template for building reliable Strapi Plugins",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+ssh://[email protected]/pluginpal/strapi-plugin-boilerplate.git"
},
"bugs": {
"url": "https://github.com/pluginpal/strapi-plugin-boilerplate/issues"
},
"homepage": "https://github.com/pluginpal/strapi-plugin-boilerplate#readme",
"author": "Boaz Poolman <[email protected]>"
}
7 changes: 7 additions & 0 deletions server/src/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { Core } from '@strapi/strapi';

const bootstrap = ({ strapi }: { strapi: Core.Strapi }) => {
// bootstrap phase
};

export default bootstrap;
4 changes: 4 additions & 0 deletions server/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
default: {},
validator() {},
};
Loading

0 comments on commit 8048e83

Please sign in to comment.