@strapi/strapi 5.0.0-beta.1 → 5.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin.d.ts.map +1 -1
- package/dist/admin.js +5 -0
- package/dist/admin.js.map +1 -1
- package/dist/admin.mjs +4 -0
- package/dist/admin.mjs.map +1 -1
- package/dist/cli/commands/admin/create-user.js +2 -2
- package/dist/cli/commands/admin/create-user.js.map +1 -1
- package/dist/cli/commands/admin/create-user.mjs +88 -0
- package/dist/cli/commands/admin/create-user.mjs.map +1 -0
- package/dist/cli/commands/admin/reset-user-password.js +2 -2
- package/dist/cli/commands/admin/reset-user-password.js.map +1 -1
- package/dist/cli/commands/admin/reset-user-password.mjs +44 -0
- package/dist/cli/commands/admin/reset-user-password.mjs.map +1 -0
- package/dist/cli/commands/build.mjs +30 -0
- package/dist/cli/commands/build.mjs.map +1 -0
- package/dist/cli/commands/components/list.js +2 -2
- package/dist/cli/commands/components/list.js.map +1 -1
- package/dist/cli/commands/components/list.mjs +24 -0
- package/dist/cli/commands/components/list.mjs.map +1 -0
- package/dist/cli/commands/configuration/dump.js +2 -2
- package/dist/cli/commands/configuration/dump.js.map +1 -1
- package/dist/cli/commands/configuration/dump.mjs +41 -0
- package/dist/cli/commands/configuration/dump.mjs.map +1 -0
- package/dist/cli/commands/configuration/restore.js +2 -2
- package/dist/cli/commands/configuration/restore.js.map +1 -1
- package/dist/cli/commands/configuration/restore.mjs +140 -0
- package/dist/cli/commands/configuration/restore.mjs.map +1 -0
- package/dist/cli/commands/console.js +2 -2
- package/dist/cli/commands/console.js.map +1 -1
- package/dist/cli/commands/console.mjs +27 -0
- package/dist/cli/commands/console.mjs.map +1 -0
- package/dist/cli/commands/content-types/list.js +2 -2
- package/dist/cli/commands/content-types/list.js.map +1 -1
- package/dist/cli/commands/content-types/list.mjs +24 -0
- package/dist/cli/commands/content-types/list.mjs.map +1 -0
- package/dist/cli/commands/controllers/list.js +2 -2
- package/dist/cli/commands/controllers/list.js.map +1 -1
- package/dist/cli/commands/controllers/list.mjs +24 -0
- package/dist/cli/commands/controllers/list.mjs.map +1 -0
- package/dist/cli/commands/develop.mjs +27 -0
- package/dist/cli/commands/develop.mjs.map +1 -0
- package/dist/cli/commands/export/action.mjs +116 -0
- package/dist/cli/commands/export/action.mjs.map +1 -0
- package/dist/cli/commands/export/command.mjs +24 -0
- package/dist/cli/commands/export/command.mjs.map +1 -0
- package/dist/cli/commands/generate.mjs +13 -0
- package/dist/cli/commands/generate.mjs.map +1 -0
- package/dist/cli/commands/hooks/list.js +2 -2
- package/dist/cli/commands/hooks/list.js.map +1 -1
- package/dist/cli/commands/hooks/list.mjs +24 -0
- package/dist/cli/commands/hooks/list.mjs.map +1 -0
- package/dist/cli/commands/import/action.mjs +105 -0
- package/dist/cli/commands/import/action.mjs.map +1 -0
- package/dist/cli/commands/import/command.mjs +68 -0
- package/dist/cli/commands/import/command.mjs.map +1 -0
- package/dist/cli/commands/index.mjs +71 -0
- package/dist/cli/commands/index.mjs.map +1 -0
- package/dist/cli/commands/middlewares/list.js +2 -2
- package/dist/cli/commands/middlewares/list.js.map +1 -1
- package/dist/cli/commands/middlewares/list.mjs +24 -0
- package/dist/cli/commands/middlewares/list.mjs.map +1 -0
- package/dist/cli/commands/plugin/build.mjs +85 -0
- package/dist/cli/commands/plugin/build.mjs.map +1 -0
- package/dist/cli/commands/plugin/init/action.js +1 -1
- package/dist/cli/commands/plugin/init/action.js.map +1 -1
- package/dist/cli/commands/plugin/init/action.mjs +409 -0
- package/dist/cli/commands/plugin/init/action.mjs.map +1 -0
- package/dist/cli/commands/plugin/init/command.mjs +10 -0
- package/dist/cli/commands/plugin/init/command.mjs.map +1 -0
- package/dist/cli/commands/plugin/init/files/admin.mjs +283 -0
- package/dist/cli/commands/plugin/init/files/admin.mjs.map +1 -0
- package/dist/cli/commands/plugin/init/files/editorConfig.mjs +26 -0
- package/dist/cli/commands/plugin/init/files/editorConfig.mjs.map +1 -0
- package/dist/cli/commands/plugin/init/files/eslint.mjs +11 -0
- package/dist/cli/commands/plugin/init/files/eslint.mjs.map +1 -0
- package/dist/cli/commands/plugin/init/files/gitIgnore.mjs +34 -0
- package/dist/cli/commands/plugin/init/files/gitIgnore.mjs.map +1 -0
- package/dist/cli/commands/plugin/init/files/prettier.mjs +25 -0
- package/dist/cli/commands/plugin/init/files/prettier.mjs.map +1 -0
- package/dist/cli/commands/plugin/init/files/server.mjs +360 -0
- package/dist/cli/commands/plugin/init/files/server.mjs.map +1 -0
- package/dist/cli/commands/plugin/init/files/typescript.mjs +66 -0
- package/dist/cli/commands/plugin/init/files/typescript.mjs.map +1 -0
- package/dist/cli/commands/plugin/link-watch.mjs +82 -0
- package/dist/cli/commands/plugin/link-watch.mjs.map +1 -0
- package/dist/cli/commands/plugin/verify.mjs +34 -0
- package/dist/cli/commands/plugin/verify.mjs.map +1 -0
- package/dist/cli/commands/plugin/watch.mjs +83 -0
- package/dist/cli/commands/plugin/watch.mjs.map +1 -0
- package/dist/cli/commands/policies/list.js +2 -2
- package/dist/cli/commands/policies/list.js.map +1 -1
- package/dist/cli/commands/policies/list.mjs +24 -0
- package/dist/cli/commands/policies/list.mjs.map +1 -0
- package/dist/cli/commands/report.js +2 -2
- package/dist/cli/commands/report.js.map +1 -1
- package/dist/cli/commands/report.mjs +35 -0
- package/dist/cli/commands/report.mjs.map +1 -0
- package/dist/cli/commands/routes/list.js +2 -2
- package/dist/cli/commands/routes/list.js.map +1 -1
- package/dist/cli/commands/routes/list.mjs +28 -0
- package/dist/cli/commands/routes/list.mjs.map +1 -0
- package/dist/cli/commands/services/list.js +2 -2
- package/dist/cli/commands/services/list.js.map +1 -1
- package/dist/cli/commands/services/list.mjs +24 -0
- package/dist/cli/commands/services/list.mjs.map +1 -0
- package/dist/cli/commands/start.js +1 -1
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/start.mjs +24 -0
- package/dist/cli/commands/start.mjs.map +1 -0
- package/dist/cli/commands/telemetry/disable.mjs +67 -0
- package/dist/cli/commands/telemetry/disable.mjs.map +1 -0
- package/dist/cli/commands/telemetry/enable.mjs +86 -0
- package/dist/cli/commands/telemetry/enable.mjs.map +1 -0
- package/dist/cli/commands/templates/generate.mjs +74 -0
- package/dist/cli/commands/templates/generate.mjs.map +1 -0
- package/dist/cli/commands/transfer/action.mjs +131 -0
- package/dist/cli/commands/transfer/action.mjs.map +1 -0
- package/dist/cli/commands/transfer/command.mjs +84 -0
- package/dist/cli/commands/transfer/command.mjs.map +1 -0
- package/dist/cli/commands/ts/generate-types.js +2 -2
- package/dist/cli/commands/ts/generate-types.js.map +1 -1
- package/dist/cli/commands/ts/generate-types.mjs +35 -0
- package/dist/cli/commands/ts/generate-types.mjs.map +1 -0
- package/dist/cli/commands/version.mjs +13 -0
- package/dist/cli/commands/version.mjs.map +1 -0
- package/dist/cli/index.mjs +49 -0
- package/dist/cli/index.mjs.map +1 -0
- package/dist/cli/utils/commander.mjs +109 -0
- package/dist/cli/utils/commander.mjs.map +1 -0
- package/dist/cli/utils/data-transfer.js +2 -2
- package/dist/cli/utils/data-transfer.js.map +1 -1
- package/dist/cli/utils/data-transfer.mjs +339 -0
- package/dist/cli/utils/data-transfer.mjs.map +1 -0
- package/dist/cli/utils/helpers.mjs +100 -0
- package/dist/cli/utils/helpers.mjs.map +1 -0
- package/dist/cli/utils/logger.mjs +80 -0
- package/dist/cli/utils/logger.mjs.map +1 -0
- package/dist/cli/utils/pkg.d.ts.map +1 -1
- package/dist/cli/utils/pkg.js +18 -15
- package/dist/cli/utils/pkg.js.map +1 -1
- package/dist/cli/utils/pkg.mjs +87 -0
- package/dist/cli/utils/pkg.mjs.map +1 -0
- package/dist/cli/utils/telemetry.mjs +22 -0
- package/dist/cli/utils/telemetry.mjs.map +1 -0
- package/dist/cli/utils/tsconfig.mjs +23 -0
- package/dist/cli/utils/tsconfig.mjs.map +1 -0
- package/dist/node/build.mjs +58 -0
- package/dist/node/build.mjs.map +1 -0
- package/dist/node/core/admin-customisations.mjs +22 -0
- package/dist/node/core/admin-customisations.mjs.map +1 -0
- package/dist/node/core/aliases.d.ts.map +1 -1
- package/dist/node/core/aliases.js +3 -1
- package/dist/node/core/aliases.js.map +1 -1
- package/dist/node/core/aliases.mjs +30 -0
- package/dist/node/core/aliases.mjs.map +1 -0
- package/dist/node/core/config.mjs +16 -0
- package/dist/node/core/config.mjs.map +1 -0
- package/dist/node/core/dependencies.mjs +151 -0
- package/dist/node/core/dependencies.mjs.map +1 -0
- package/dist/node/core/env.d.ts.map +1 -1
- package/dist/node/core/env.js +7 -4
- package/dist/node/core/env.js.map +1 -1
- package/dist/node/core/env.mjs +23 -0
- package/dist/node/core/env.mjs.map +1 -0
- package/dist/node/core/errors.mjs +29 -0
- package/dist/node/core/errors.mjs.map +1 -0
- package/dist/node/core/files.mjs +43 -0
- package/dist/node/core/files.mjs.map +1 -0
- package/dist/node/core/managers.mjs +17 -0
- package/dist/node/core/managers.mjs.map +1 -0
- package/dist/node/core/monorepo.mjs +20 -0
- package/dist/node/core/monorepo.mjs.map +1 -0
- package/dist/node/core/plugins.mjs +93 -0
- package/dist/node/core/plugins.mjs.map +1 -0
- package/dist/node/core/timer.mjs +27 -0
- package/dist/node/core/timer.mjs.map +1 -0
- package/dist/node/create-build-context.js +1 -1
- package/dist/node/create-build-context.js.map +1 -1
- package/dist/node/create-build-context.mjs +91 -0
- package/dist/node/create-build-context.mjs.map +1 -0
- package/dist/node/develop.js +1 -1
- package/dist/node/develop.js.map +1 -1
- package/dist/node/develop.mjs +252 -0
- package/dist/node/develop.mjs.map +1 -0
- package/dist/node/staticFiles.d.ts.map +1 -1
- package/dist/node/staticFiles.js +25 -3
- package/dist/node/staticFiles.js.map +1 -1
- package/dist/node/staticFiles.mjs +76 -0
- package/dist/node/staticFiles.mjs.map +1 -0
- package/dist/node/vite/build.mjs +12 -0
- package/dist/node/vite/build.mjs.map +1 -0
- package/dist/node/vite/config.mjs +99 -0
- package/dist/node/vite/config.mjs.map +1 -0
- package/dist/node/vite/plugins.mjs +43 -0
- package/dist/node/vite/plugins.mjs.map +1 -0
- package/dist/node/vite/watch.mjs +52 -0
- package/dist/node/vite/watch.mjs.map +1 -0
- package/dist/node/webpack/build.mjs +39 -0
- package/dist/node/webpack/build.mjs.map +1 -0
- package/dist/node/webpack/config.mjs +228 -0
- package/dist/node/webpack/config.mjs.map +1 -0
- package/dist/node/webpack/watch.mjs +92 -0
- package/dist/node/webpack/watch.mjs.map +1 -0
- package/package.json +24 -24
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { outdent } from "outdent";
|
|
2
|
+
const PLUGIN_ICON_CODE = outdent`
|
|
3
|
+
import { Puzzle } from '@strapi/icons';
|
|
4
|
+
|
|
5
|
+
const PluginIcon = () => <Puzzle />;
|
|
6
|
+
|
|
7
|
+
export { PluginIcon };
|
|
8
|
+
`;
|
|
9
|
+
const APP_CODE = outdent`
|
|
10
|
+
import { Page } from '@strapi/strapi/admin';
|
|
11
|
+
import { Switch, Route } from 'react-router-dom';
|
|
12
|
+
|
|
13
|
+
import { PLUGIN_ID } from '../pluginId';
|
|
14
|
+
|
|
15
|
+
import { HomePage } from './HomePage';
|
|
16
|
+
|
|
17
|
+
const App = () => {
|
|
18
|
+
return (
|
|
19
|
+
<Switch>
|
|
20
|
+
<Route index element={<HomePage />} />
|
|
21
|
+
<Route path="*" element={<Page.Error />} />
|
|
22
|
+
</Switch>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { App };
|
|
27
|
+
`;
|
|
28
|
+
const HOMEPAGE_CODE = outdent`
|
|
29
|
+
import { Main } from '@strapi/design-system';
|
|
30
|
+
import { useIntl } from 'react-intl';
|
|
31
|
+
|
|
32
|
+
import { getTranslation } from '../utils/getTranslation';
|
|
33
|
+
|
|
34
|
+
const HomePage = () => {
|
|
35
|
+
const { formatMessage } = useIntl();
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Main>
|
|
39
|
+
<h1>Welcome to {formatMessage({ id: getTranslation("plugin.name") })}</h1>
|
|
40
|
+
</Main>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { HomePage };
|
|
45
|
+
`;
|
|
46
|
+
const TYPESCRIPT = [
|
|
47
|
+
{
|
|
48
|
+
name: "admin/src/index.ts",
|
|
49
|
+
contents: outdent`
|
|
50
|
+
import { prefixPluginTranslations } from './utils/prefixPluginTranslations';
|
|
51
|
+
import { PLUGIN_ID } from './pluginId';
|
|
52
|
+
import { Initializer } from './components/Initializer';
|
|
53
|
+
import { PluginIcon } from './components/PluginIcon';
|
|
54
|
+
|
|
55
|
+
export default {
|
|
56
|
+
register(app: any) {
|
|
57
|
+
app.addMenuLink({
|
|
58
|
+
to: \`plugins/\${PLUGIN_ID}\`,
|
|
59
|
+
icon: PluginIcon,
|
|
60
|
+
intlLabel: {
|
|
61
|
+
id: \`\${PLUGIN_ID}.plugin.name\`,
|
|
62
|
+
defaultMessage: PLUGIN_ID,
|
|
63
|
+
},
|
|
64
|
+
Component: async () => {
|
|
65
|
+
const { App } = await import('./pages/App');
|
|
66
|
+
|
|
67
|
+
return App;
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
app.registerPlugin({
|
|
72
|
+
id: PLUGIN_ID,
|
|
73
|
+
initializer: Initializer,
|
|
74
|
+
isReady: false,
|
|
75
|
+
name: PLUGIN_ID,
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
async registerTrads(app: any) {
|
|
80
|
+
const { locales } = app;
|
|
81
|
+
|
|
82
|
+
const importedTranslations = await Promise.all(
|
|
83
|
+
(locales as string[]).map((locale) => {
|
|
84
|
+
return import(\`./translations/\${locale}.json\`)
|
|
85
|
+
.then(({ default: data }) => {
|
|
86
|
+
return {
|
|
87
|
+
data: prefixPluginTranslations(data, PLUGIN_ID),
|
|
88
|
+
locale,
|
|
89
|
+
};
|
|
90
|
+
})
|
|
91
|
+
.catch(() => {
|
|
92
|
+
return {
|
|
93
|
+
data: {},
|
|
94
|
+
locale,
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
})
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
return importedTranslations;
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
`
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: "admin/src/components/PluginIcon.tsx",
|
|
107
|
+
contents: PLUGIN_ICON_CODE
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "admin/src/components/Initializer.tsx",
|
|
111
|
+
contents: outdent`
|
|
112
|
+
import { useEffect, useRef } from 'react';
|
|
113
|
+
|
|
114
|
+
import { PLUGIN_ID } from '../pluginId';
|
|
115
|
+
|
|
116
|
+
type InitializerProps = {
|
|
117
|
+
setPlugin: (id: string) => void;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const Initializer = ({ setPlugin }: InitializerProps) => {
|
|
121
|
+
const ref = useRef(setPlugin);
|
|
122
|
+
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
ref.current(PLUGIN_ID);
|
|
125
|
+
}, []);
|
|
126
|
+
|
|
127
|
+
return null;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export { Initializer };
|
|
131
|
+
`
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: "admin/src/pages/App.tsx",
|
|
135
|
+
contents: APP_CODE
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: "admin/src/pages/HomePage.tsx",
|
|
139
|
+
contents: HOMEPAGE_CODE
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "admin/src/utils/getTranslation.ts",
|
|
143
|
+
contents: outdent`
|
|
144
|
+
import { PLUGIN_ID } from '../pluginId';
|
|
145
|
+
|
|
146
|
+
const getTranslation = (id: string) => \`\${PLUGIN_ID}.\${id}\`;
|
|
147
|
+
|
|
148
|
+
export { getTranslation };
|
|
149
|
+
`
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: "admin/src/translations/en.json",
|
|
153
|
+
contents: outdent`
|
|
154
|
+
{}
|
|
155
|
+
`
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
/**
|
|
159
|
+
* TODO: remove this when we release design-system V2
|
|
160
|
+
*/
|
|
161
|
+
name: "admin/custom.d.ts",
|
|
162
|
+
contents: outdent`
|
|
163
|
+
declare module '@strapi/design-system/*';
|
|
164
|
+
declare module '@strapi/design-system';
|
|
165
|
+
`
|
|
166
|
+
}
|
|
167
|
+
];
|
|
168
|
+
const JAVASCRIPT = [
|
|
169
|
+
{
|
|
170
|
+
name: "admin/src/index.js",
|
|
171
|
+
contents: outdent`
|
|
172
|
+
import { prefixPluginTranslations } from './utils/prefixPluginTranslations';
|
|
173
|
+
import { PLUGIN_ID } from './pluginId';
|
|
174
|
+
import { Initializer } from './components/Initializer';
|
|
175
|
+
import { PluginIcon } from './components/PluginIcon';
|
|
176
|
+
|
|
177
|
+
export default {
|
|
178
|
+
register(app) {
|
|
179
|
+
app.addMenuLink({
|
|
180
|
+
to: \`plugins/\${PluginIcon}\`,
|
|
181
|
+
icon: PluginIcon,
|
|
182
|
+
intlLabel: {
|
|
183
|
+
id: \`\${PLUGIN_ID}.plugin.name\`,
|
|
184
|
+
defaultMessage: PLUGIN_ID,
|
|
185
|
+
},
|
|
186
|
+
Component: async () => {
|
|
187
|
+
const { App } = await import('./pages/App');
|
|
188
|
+
|
|
189
|
+
return App;
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
app.registerPlugin({
|
|
194
|
+
id: PLUGIN_ID,
|
|
195
|
+
initializer: Initializer,
|
|
196
|
+
isReady: false,
|
|
197
|
+
name: PLUGIN_ID,
|
|
198
|
+
});
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
async registerTrads(app) {
|
|
202
|
+
const { locales } = app;
|
|
203
|
+
|
|
204
|
+
const importedTranslations = await Promise.all(
|
|
205
|
+
locales.map((locale) => {
|
|
206
|
+
return import(\`./translations/\${locale}.json\`)
|
|
207
|
+
.then(({ default: data }) => {
|
|
208
|
+
return {
|
|
209
|
+
data: prefixPluginTranslations(data, PLUGIN_ID),
|
|
210
|
+
locale,
|
|
211
|
+
};
|
|
212
|
+
})
|
|
213
|
+
.catch(() => {
|
|
214
|
+
return {
|
|
215
|
+
data: {},
|
|
216
|
+
locale,
|
|
217
|
+
};
|
|
218
|
+
});
|
|
219
|
+
})
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
return importedTranslations;
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
`
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
name: "admin/src/components/PluginIcon.jsx",
|
|
229
|
+
contents: PLUGIN_ICON_CODE
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
name: "admin/src/components/Initializer.jsx",
|
|
233
|
+
contents: outdent`
|
|
234
|
+
import { useEffect, useRef } from 'react';
|
|
235
|
+
|
|
236
|
+
import { PLUGIN_ID } from '../pluginId';
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* @type {import('react').FC<{ setPlugin: (id: string) => void }>}
|
|
240
|
+
*/
|
|
241
|
+
const Initializer = ({ setPlugin }) => {
|
|
242
|
+
const ref = useRef(setPlugin);
|
|
243
|
+
|
|
244
|
+
useEffect(() => {
|
|
245
|
+
ref.current(PLUGIN_ID);
|
|
246
|
+
}, []);
|
|
247
|
+
|
|
248
|
+
return null;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
export { Initializer };
|
|
252
|
+
`
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
name: "admin/src/pages/App.jsx",
|
|
256
|
+
contents: APP_CODE
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
name: "admin/src/pages/HomePage.jsx",
|
|
260
|
+
contents: HOMEPAGE_CODE
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
name: "admin/src/utils/getTranslation.js",
|
|
264
|
+
contents: outdent`
|
|
265
|
+
import { PLUGIN_ID } from '../pluginId';
|
|
266
|
+
|
|
267
|
+
const getTranslation = (id) => \`\${PLUGIN_ID}.\${id}\`;
|
|
268
|
+
|
|
269
|
+
export { getTranslation };
|
|
270
|
+
`
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
name: "admin/src/translations/en.json",
|
|
274
|
+
contents: outdent`
|
|
275
|
+
{}
|
|
276
|
+
`
|
|
277
|
+
}
|
|
278
|
+
];
|
|
279
|
+
export {
|
|
280
|
+
JAVASCRIPT as adminJavascriptFiles,
|
|
281
|
+
TYPESCRIPT as adminTypescriptFiles
|
|
282
|
+
};
|
|
283
|
+
//# sourceMappingURL=admin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.mjs","sources":["../../../../../../src/cli/commands/plugin/init/files/admin.ts"],"sourcesContent":["import { TemplateFile } from '@strapi/pack-up';\nimport { outdent } from 'outdent';\n\nconst PLUGIN_ICON_CODE = outdent`\nimport { Puzzle } from '@strapi/icons';\n\nconst PluginIcon = () => <Puzzle />;\n\nexport { PluginIcon };\n`;\n\nconst APP_CODE = outdent`\nimport { Page } from '@strapi/strapi/admin';\nimport { Switch, Route } from 'react-router-dom';\n\nimport { PLUGIN_ID } from '../pluginId';\n\nimport { HomePage } from './HomePage';\n\nconst App = () => {\n return (\n <Switch>\n <Route index element={<HomePage />} />\n <Route path=\"*\" element={<Page.Error />} />\n </Switch>\n );\n};\n\nexport { App };\n`;\n\nconst HOMEPAGE_CODE = outdent`\n import { Main } from '@strapi/design-system';\n import { useIntl } from 'react-intl';\n\n import { getTranslation } from '../utils/getTranslation';\n\n const HomePage = () => {\n const { formatMessage } = useIntl();\n\n return (\n <Main>\n <h1>Welcome to {formatMessage({ id: getTranslation(\"plugin.name\") })}</h1>\n </Main>\n )\n }\n\n export { HomePage };\n`;\n\nconst TYPESCRIPT: TemplateFile[] = [\n {\n name: 'admin/src/index.ts',\n contents: outdent`\n import { prefixPluginTranslations } from './utils/prefixPluginTranslations';\n import { PLUGIN_ID } from './pluginId';\n import { Initializer } from './components/Initializer';\n import { PluginIcon } from './components/PluginIcon';\n \n export default {\n register(app: any) {\n app.addMenuLink({\n to: \\`plugins/\\${PLUGIN_ID}\\`,\n icon: PluginIcon,\n intlLabel: {\n id: \\`\\${PLUGIN_ID}.plugin.name\\`,\n defaultMessage: PLUGIN_ID,\n },\n Component: async () => {\n const { App } = await import('./pages/App');\n \n return App;\n },\n });\n \n app.registerPlugin({\n id: PLUGIN_ID,\n initializer: Initializer,\n isReady: false,\n name: PLUGIN_ID,\n });\n },\n \n async registerTrads(app: any) {\n const { locales } = app;\n \n const importedTranslations = await Promise.all(\n (locales as string[]).map((locale) => {\n return import(\\`./translations/\\${locale}.json\\`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, PLUGIN_ID),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n \n return importedTranslations;\n },\n };\n `,\n },\n {\n name: 'admin/src/components/PluginIcon.tsx',\n contents: PLUGIN_ICON_CODE,\n },\n {\n name: 'admin/src/components/Initializer.tsx',\n contents: outdent`\n import { useEffect, useRef } from 'react';\n\n import { PLUGIN_ID } from '../pluginId';\n \n type InitializerProps = {\n setPlugin: (id: string) => void;\n };\n \n const Initializer = ({ setPlugin }: InitializerProps) => {\n const ref = useRef(setPlugin);\n \n useEffect(() => {\n ref.current(PLUGIN_ID);\n }, []);\n \n return null;\n };\n \n export { Initializer };\n `,\n },\n {\n name: 'admin/src/pages/App.tsx',\n contents: APP_CODE,\n },\n {\n name: 'admin/src/pages/HomePage.tsx',\n contents: HOMEPAGE_CODE,\n },\n {\n name: 'admin/src/utils/getTranslation.ts',\n contents: outdent`\n import { PLUGIN_ID } from '../pluginId';\n\n const getTranslation = (id: string) => \\`\\${PLUGIN_ID}.\\${id}\\`;\n\n export { getTranslation };\n `,\n },\n {\n name: 'admin/src/translations/en.json',\n contents: outdent`\n {}\n `,\n },\n {\n /**\n * TODO: remove this when we release design-system V2\n */\n name: 'admin/custom.d.ts',\n contents: outdent`\n declare module '@strapi/design-system/*';\n declare module '@strapi/design-system';\n `,\n },\n];\n\nconst JAVASCRIPT: TemplateFile[] = [\n {\n name: 'admin/src/index.js',\n contents: outdent`\n import { prefixPluginTranslations } from './utils/prefixPluginTranslations';\n import { PLUGIN_ID } from './pluginId';\n import { Initializer } from './components/Initializer';\n import { PluginIcon } from './components/PluginIcon';\n \n export default {\n register(app) {\n app.addMenuLink({\n to: \\`plugins/\\${PluginIcon}\\`,\n icon: PluginIcon,\n intlLabel: {\n id: \\`\\${PLUGIN_ID}.plugin.name\\`,\n defaultMessage: PLUGIN_ID,\n },\n Component: async () => {\n const { App } = await import('./pages/App');\n \n return App;\n },\n });\n \n app.registerPlugin({\n id: PLUGIN_ID,\n initializer: Initializer,\n isReady: false,\n name: PLUGIN_ID,\n });\n },\n \n async registerTrads(app) {\n const { locales } = app;\n \n const importedTranslations = await Promise.all(\n locales.map((locale) => {\n return import(\\`./translations/\\${locale}.json\\`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, PLUGIN_ID),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n \n return importedTranslations;\n },\n };\n `,\n },\n {\n name: 'admin/src/components/PluginIcon.jsx',\n contents: PLUGIN_ICON_CODE,\n },\n {\n name: 'admin/src/components/Initializer.jsx',\n contents: outdent`\n import { useEffect, useRef } from 'react';\n \n import { PLUGIN_ID } from '../pluginId';\n \n /**\n * @type {import('react').FC<{ setPlugin: (id: string) => void }>}\n */ \n const Initializer = ({ setPlugin }) => {\n const ref = useRef(setPlugin);\n \n useEffect(() => {\n ref.current(PLUGIN_ID);\n }, []);\n \n return null;\n };\n \n export { Initializer };\n `,\n },\n {\n name: 'admin/src/pages/App.jsx',\n contents: APP_CODE,\n },\n {\n name: 'admin/src/pages/HomePage.jsx',\n contents: HOMEPAGE_CODE,\n },\n {\n name: 'admin/src/utils/getTranslation.js',\n contents: outdent`\n import { PLUGIN_ID } from '../pluginId';\n \n const getTranslation = (id) => \\`\\${PLUGIN_ID}.\\${id}\\`;\n \n export { getTranslation };\n `,\n },\n {\n name: 'admin/src/translations/en.json',\n contents: outdent`\n {}\n `,\n },\n];\n\nexport { TYPESCRIPT as adminTypescriptFiles, JAVASCRIPT as adminJavascriptFiles };\n"],"names":[],"mappings":";AAGA,MAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQzB,MAAM,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBjB,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBtB,MAAM,aAA6B;AAAA,EACjC;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuDZ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqBZ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOZ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA;AAAA;AAAA,EAGZ;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,IAIE,MAAM;AAAA,IACN,UAAU;AAAA;AAAA;AAAA;AAAA,EAIZ;AACF;AAEA,MAAM,aAA6B;AAAA,EACjC;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuDZ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBZ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOZ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA;AAAA;AAAA,EAGZ;AACF;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { outdent } from "outdent";
|
|
2
|
+
const editorConfigFile = {
|
|
3
|
+
name: ".editorconfig",
|
|
4
|
+
contents: outdent`
|
|
5
|
+
root = true
|
|
6
|
+
|
|
7
|
+
[*]
|
|
8
|
+
indent_style = space
|
|
9
|
+
indent_size = 2
|
|
10
|
+
end_of_line = lf
|
|
11
|
+
charset = utf-8
|
|
12
|
+
trim_trailing_whitespace = true
|
|
13
|
+
insert_final_newline = true
|
|
14
|
+
|
|
15
|
+
[{package.json,*.yml}]
|
|
16
|
+
indent_style = space
|
|
17
|
+
indent_size = 2
|
|
18
|
+
|
|
19
|
+
[*.md]
|
|
20
|
+
trim_trailing_whitespace = false
|
|
21
|
+
`
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
editorConfigFile
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=editorConfig.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editorConfig.mjs","sources":["../../../../../../src/cli/commands/plugin/init/files/editorConfig.ts"],"sourcesContent":["import { TemplateFile } from '@strapi/pack-up';\nimport { outdent } from 'outdent';\n\nconst editorConfigFile: TemplateFile = {\n name: '.editorconfig',\n contents: outdent`\n root = true\n\n [*]\n indent_style = space\n indent_size = 2\n end_of_line = lf\n charset = utf-8\n trim_trailing_whitespace = true\n insert_final_newline = true\n \n [{package.json,*.yml}]\n indent_style = space\n indent_size = 2\n \n [*.md]\n trim_trailing_whitespace = false\n `,\n};\n\nexport { editorConfigFile };\n"],"names":[],"mappings":";AAGA,MAAM,mBAAiC;AAAA,EACrC,MAAM;AAAA,EACN,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBZ;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eslint.mjs","sources":["../../../../../../src/cli/commands/plugin/init/files/eslint.ts"],"sourcesContent":["import { TemplateFile } from '@strapi/pack-up';\nimport { outdent } from 'outdent';\n\nconst eslintIgnoreFile: TemplateFile = {\n name: '.eslintignore',\n contents: outdent`\n dist\n `,\n};\n\nexport { eslintIgnoreFile };\n"],"names":[],"mappings":";AAGA,MAAM,mBAAiC;AAAA,EACrC,MAAM;AAAA,EACN,UAAU;AAAA;AAAA;AAGZ;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { outdent } from "outdent";
|
|
2
|
+
const gitIgnoreFile = {
|
|
3
|
+
name: ".gitignore",
|
|
4
|
+
contents: outdent`
|
|
5
|
+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
|
6
|
+
|
|
7
|
+
# dependencies
|
|
8
|
+
node_modules
|
|
9
|
+
.pnp
|
|
10
|
+
.pnp.js
|
|
11
|
+
|
|
12
|
+
# testing
|
|
13
|
+
coverage
|
|
14
|
+
|
|
15
|
+
# production
|
|
16
|
+
dist
|
|
17
|
+
|
|
18
|
+
# misc
|
|
19
|
+
.DS_Store
|
|
20
|
+
*.pem
|
|
21
|
+
|
|
22
|
+
# debug
|
|
23
|
+
npm-debug.log*
|
|
24
|
+
yarn-debug.log*
|
|
25
|
+
yarn-error.log*
|
|
26
|
+
|
|
27
|
+
# local env files
|
|
28
|
+
.env
|
|
29
|
+
`
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
gitIgnoreFile
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=gitIgnore.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitIgnore.mjs","sources":["../../../../../../src/cli/commands/plugin/init/files/gitIgnore.ts"],"sourcesContent":["import { TemplateFile } from '@strapi/pack-up';\nimport { outdent } from 'outdent';\n\nconst gitIgnoreFile: TemplateFile = {\n name: '.gitignore',\n contents: outdent`\n # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.\n\n # dependencies\n node_modules\n .pnp\n .pnp.js\n \n # testing\n coverage\n \n # production\n dist\n \n # misc\n .DS_Store\n *.pem\n \n # debug\n npm-debug.log*\n yarn-debug.log*\n yarn-error.log*\n \n # local env files\n .env \n `,\n};\n\nexport { gitIgnoreFile };\n"],"names":[],"mappings":";AAGA,MAAM,gBAA8B;AAAA,EAClC,MAAM;AAAA,EACN,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BZ;"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { outdent } from "outdent";
|
|
2
|
+
const prettierFile = {
|
|
3
|
+
name: ".prettierrc",
|
|
4
|
+
contents: outdent`
|
|
5
|
+
{
|
|
6
|
+
"endOfLine": 'lf',
|
|
7
|
+
"tabWidth": 2,
|
|
8
|
+
"printWidth": 100,
|
|
9
|
+
"singleQuote": true,
|
|
10
|
+
"trailingComma": 'es5',
|
|
11
|
+
}
|
|
12
|
+
`
|
|
13
|
+
};
|
|
14
|
+
const prettierIgnoreFile = {
|
|
15
|
+
name: ".prettierignore",
|
|
16
|
+
contents: outdent`
|
|
17
|
+
dist
|
|
18
|
+
coverage
|
|
19
|
+
`
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
prettierFile,
|
|
23
|
+
prettierIgnoreFile
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=prettier.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prettier.mjs","sources":["../../../../../../src/cli/commands/plugin/init/files/prettier.ts"],"sourcesContent":["import { TemplateFile } from '@strapi/pack-up';\nimport { outdent } from 'outdent';\n\nconst prettierFile: TemplateFile = {\n name: '.prettierrc',\n contents: outdent`\n {\n \"endOfLine\": 'lf',\n \"tabWidth\": 2,\n \"printWidth\": 100,\n \"singleQuote\": true,\n \"trailingComma\": 'es5',\n }\n `,\n};\n\nconst prettierIgnoreFile: TemplateFile = {\n name: '.prettierignore',\n contents: outdent`\n dist\n coverage\n `,\n};\n\nexport { prettierFile, prettierIgnoreFile };\n"],"names":[],"mappings":";AAGA,MAAM,eAA6B;AAAA,EACjC,MAAM;AAAA,EACN,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASZ;AAEA,MAAM,qBAAmC;AAAA,EACvC,MAAM;AAAA,EACN,UAAU;AAAA;AAAA;AAAA;AAIZ;"}
|