@strapi/strapi 5.0.0-beta.8 → 5.0.0-beta.9
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/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +1 -14
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/index.mjs +1 -14
- package/dist/cli/commands/index.mjs.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +30 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +30 -0
- package/dist/cli/index.mjs.map +1 -1
- package/package.json +23 -23
- package/dist/cli/commands/plugin/build.d.ts +0 -7
- package/dist/cli/commands/plugin/build.d.ts.map +0 -1
- package/dist/cli/commands/plugin/build.js +0 -88
- package/dist/cli/commands/plugin/build.js.map +0 -1
- package/dist/cli/commands/plugin/build.mjs +0 -85
- package/dist/cli/commands/plugin/build.mjs.map +0 -1
- package/dist/cli/commands/plugin/init/action.d.ts +0 -6
- package/dist/cli/commands/plugin/init/action.d.ts.map +0 -1
- package/dist/cli/commands/plugin/init/action.js +0 -413
- package/dist/cli/commands/plugin/init/action.js.map +0 -1
- package/dist/cli/commands/plugin/init/action.mjs +0 -408
- package/dist/cli/commands/plugin/init/action.mjs.map +0 -1
- package/dist/cli/commands/plugin/init/command.d.ts +0 -7
- package/dist/cli/commands/plugin/init/command.d.ts.map +0 -1
- package/dist/cli/commands/plugin/init/command.js +0 -9
- package/dist/cli/commands/plugin/init/command.js.map +0 -1
- package/dist/cli/commands/plugin/init/command.mjs +0 -10
- package/dist/cli/commands/plugin/init/command.mjs.map +0 -1
- package/dist/cli/commands/plugin/init/files/admin.d.ts +0 -5
- package/dist/cli/commands/plugin/init/files/admin.d.ts.map +0 -1
- package/dist/cli/commands/plugin/init/files/admin.js +0 -283
- package/dist/cli/commands/plugin/init/files/admin.js.map +0 -1
- package/dist/cli/commands/plugin/init/files/admin.mjs +0 -283
- package/dist/cli/commands/plugin/init/files/admin.mjs.map +0 -1
- package/dist/cli/commands/plugin/init/files/editorConfig.d.ts +0 -4
- package/dist/cli/commands/plugin/init/files/editorConfig.d.ts.map +0 -1
- package/dist/cli/commands/plugin/init/files/editorConfig.js +0 -26
- package/dist/cli/commands/plugin/init/files/editorConfig.js.map +0 -1
- package/dist/cli/commands/plugin/init/files/editorConfig.mjs +0 -26
- package/dist/cli/commands/plugin/init/files/editorConfig.mjs.map +0 -1
- package/dist/cli/commands/plugin/init/files/eslint.d.ts +0 -4
- package/dist/cli/commands/plugin/init/files/eslint.d.ts.map +0 -1
- package/dist/cli/commands/plugin/init/files/eslint.js +0 -11
- package/dist/cli/commands/plugin/init/files/eslint.js.map +0 -1
- package/dist/cli/commands/plugin/init/files/eslint.mjs +0 -11
- package/dist/cli/commands/plugin/init/files/eslint.mjs.map +0 -1
- package/dist/cli/commands/plugin/init/files/gitIgnore.d.ts +0 -4
- package/dist/cli/commands/plugin/init/files/gitIgnore.d.ts.map +0 -1
- package/dist/cli/commands/plugin/init/files/gitIgnore.js +0 -34
- package/dist/cli/commands/plugin/init/files/gitIgnore.js.map +0 -1
- package/dist/cli/commands/plugin/init/files/gitIgnore.mjs +0 -34
- package/dist/cli/commands/plugin/init/files/gitIgnore.mjs.map +0 -1
- package/dist/cli/commands/plugin/init/files/prettier.d.ts +0 -5
- package/dist/cli/commands/plugin/init/files/prettier.d.ts.map +0 -1
- package/dist/cli/commands/plugin/init/files/prettier.js +0 -25
- package/dist/cli/commands/plugin/init/files/prettier.js.map +0 -1
- package/dist/cli/commands/plugin/init/files/prettier.mjs +0 -25
- package/dist/cli/commands/plugin/init/files/prettier.mjs.map +0 -1
- package/dist/cli/commands/plugin/init/files/server.d.ts +0 -5
- package/dist/cli/commands/plugin/init/files/server.d.ts.map +0 -1
- package/dist/cli/commands/plugin/init/files/server.js +0 -360
- package/dist/cli/commands/plugin/init/files/server.js.map +0 -1
- package/dist/cli/commands/plugin/init/files/server.mjs +0 -360
- package/dist/cli/commands/plugin/init/files/server.mjs.map +0 -1
- package/dist/cli/commands/plugin/init/files/typescript.d.ts +0 -9
- package/dist/cli/commands/plugin/init/files/typescript.d.ts.map +0 -1
- package/dist/cli/commands/plugin/init/files/typescript.js +0 -66
- package/dist/cli/commands/plugin/init/files/typescript.js.map +0 -1
- package/dist/cli/commands/plugin/init/files/typescript.mjs +0 -66
- package/dist/cli/commands/plugin/init/files/typescript.mjs.map +0 -1
- package/dist/cli/commands/plugin/init/index.d.ts +0 -2
- package/dist/cli/commands/plugin/init/index.d.ts.map +0 -1
- package/dist/cli/commands/plugin/link-watch.d.ts +0 -7
- package/dist/cli/commands/plugin/link-watch.d.ts.map +0 -1
- package/dist/cli/commands/plugin/link-watch.js +0 -89
- package/dist/cli/commands/plugin/link-watch.js.map +0 -1
- package/dist/cli/commands/plugin/link-watch.mjs +0 -82
- package/dist/cli/commands/plugin/link-watch.mjs.map +0 -1
- package/dist/cli/commands/plugin/verify.d.ts +0 -7
- package/dist/cli/commands/plugin/verify.d.ts.map +0 -1
- package/dist/cli/commands/plugin/verify.js +0 -37
- package/dist/cli/commands/plugin/verify.js.map +0 -1
- package/dist/cli/commands/plugin/verify.mjs +0 -34
- package/dist/cli/commands/plugin/verify.mjs.map +0 -1
- package/dist/cli/commands/plugin/watch.d.ts +0 -7
- package/dist/cli/commands/plugin/watch.d.ts.map +0 -1
- package/dist/cli/commands/plugin/watch.js +0 -86
- package/dist/cli/commands/plugin/watch.js.map +0 -1
- package/dist/cli/commands/plugin/watch.mjs +0 -83
- package/dist/cli/commands/plugin/watch.mjs.map +0 -1
- package/dist/cli/utils/pkg.js +0 -111
- package/dist/cli/utils/pkg.js.map +0 -1
- package/dist/cli/utils/pkg.mjs +0 -87
- package/dist/cli/utils/pkg.mjs.map +0 -1
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const outdent = require("outdent");
|
|
4
|
-
const PLUGIN_ICON_CODE = outdent.outdent`
|
|
5
|
-
import { Puzzle } from '@strapi/icons';
|
|
6
|
-
|
|
7
|
-
const PluginIcon = Puzzle;
|
|
8
|
-
|
|
9
|
-
export { PluginIcon };
|
|
10
|
-
`;
|
|
11
|
-
const APP_CODE = outdent.outdent`
|
|
12
|
-
import { Page } from '@strapi/strapi/admin';
|
|
13
|
-
import { Switch, Route } from 'react-router-dom';
|
|
14
|
-
|
|
15
|
-
import { PLUGIN_ID } from '../pluginId';
|
|
16
|
-
|
|
17
|
-
import { HomePage } from './HomePage';
|
|
18
|
-
|
|
19
|
-
const App = () => {
|
|
20
|
-
return (
|
|
21
|
-
<Switch>
|
|
22
|
-
<Route index element={<HomePage />} />
|
|
23
|
-
<Route path="*" element={<Page.Error />} />
|
|
24
|
-
</Switch>
|
|
25
|
-
);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export { App };
|
|
29
|
-
`;
|
|
30
|
-
const HOMEPAGE_CODE = outdent.outdent`
|
|
31
|
-
import { Main } from '@strapi/design-system';
|
|
32
|
-
import { useIntl } from 'react-intl';
|
|
33
|
-
|
|
34
|
-
import { getTranslation } from '../utils/getTranslation';
|
|
35
|
-
|
|
36
|
-
const HomePage = () => {
|
|
37
|
-
const { formatMessage } = useIntl();
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<Main>
|
|
41
|
-
<h1>Welcome to {formatMessage({ id: getTranslation("plugin.name") })}</h1>
|
|
42
|
-
</Main>
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export { HomePage };
|
|
47
|
-
`;
|
|
48
|
-
const TYPESCRIPT = [
|
|
49
|
-
{
|
|
50
|
-
name: "admin/src/index.ts",
|
|
51
|
-
contents: outdent.outdent`
|
|
52
|
-
import { prefixPluginTranslations } from './utils/prefixPluginTranslations';
|
|
53
|
-
import { PLUGIN_ID } from './pluginId';
|
|
54
|
-
import { Initializer } from './components/Initializer';
|
|
55
|
-
import { PluginIcon } from './components/PluginIcon';
|
|
56
|
-
|
|
57
|
-
export default {
|
|
58
|
-
register(app: any) {
|
|
59
|
-
app.addMenuLink({
|
|
60
|
-
to: \`plugins/\${PLUGIN_ID}\`,
|
|
61
|
-
icon: PluginIcon,
|
|
62
|
-
intlLabel: {
|
|
63
|
-
id: \`\${PLUGIN_ID}.plugin.name\`,
|
|
64
|
-
defaultMessage: PLUGIN_ID,
|
|
65
|
-
},
|
|
66
|
-
Component: async () => {
|
|
67
|
-
const { App } = await import('./pages/App');
|
|
68
|
-
|
|
69
|
-
return App;
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
app.registerPlugin({
|
|
74
|
-
id: PLUGIN_ID,
|
|
75
|
-
initializer: Initializer,
|
|
76
|
-
isReady: false,
|
|
77
|
-
name: PLUGIN_ID,
|
|
78
|
-
});
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
async registerTrads(app: any) {
|
|
82
|
-
const { locales } = app;
|
|
83
|
-
|
|
84
|
-
const importedTranslations = await Promise.all(
|
|
85
|
-
(locales as string[]).map((locale) => {
|
|
86
|
-
return import(\`./translations/\${locale}.json\`)
|
|
87
|
-
.then(({ default: data }) => {
|
|
88
|
-
return {
|
|
89
|
-
data: prefixPluginTranslations(data, PLUGIN_ID),
|
|
90
|
-
locale,
|
|
91
|
-
};
|
|
92
|
-
})
|
|
93
|
-
.catch(() => {
|
|
94
|
-
return {
|
|
95
|
-
data: {},
|
|
96
|
-
locale,
|
|
97
|
-
};
|
|
98
|
-
});
|
|
99
|
-
})
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
return importedTranslations;
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
`
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
name: "admin/src/components/PluginIcon.tsx",
|
|
109
|
-
contents: PLUGIN_ICON_CODE
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
name: "admin/src/components/Initializer.tsx",
|
|
113
|
-
contents: outdent.outdent`
|
|
114
|
-
import { useEffect, useRef } from 'react';
|
|
115
|
-
|
|
116
|
-
import { PLUGIN_ID } from '../pluginId';
|
|
117
|
-
|
|
118
|
-
type InitializerProps = {
|
|
119
|
-
setPlugin: (id: string) => void;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
const Initializer = ({ setPlugin }: InitializerProps) => {
|
|
123
|
-
const ref = useRef(setPlugin);
|
|
124
|
-
|
|
125
|
-
useEffect(() => {
|
|
126
|
-
ref.current(PLUGIN_ID);
|
|
127
|
-
}, []);
|
|
128
|
-
|
|
129
|
-
return null;
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
export { Initializer };
|
|
133
|
-
`
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
name: "admin/src/pages/App.tsx",
|
|
137
|
-
contents: APP_CODE
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
name: "admin/src/pages/HomePage.tsx",
|
|
141
|
-
contents: HOMEPAGE_CODE
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
name: "admin/src/utils/getTranslation.ts",
|
|
145
|
-
contents: outdent.outdent`
|
|
146
|
-
import { PLUGIN_ID } from '../pluginId';
|
|
147
|
-
|
|
148
|
-
const getTranslation = (id: string) => \`\${PLUGIN_ID}.\${id}\`;
|
|
149
|
-
|
|
150
|
-
export { getTranslation };
|
|
151
|
-
`
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
name: "admin/src/translations/en.json",
|
|
155
|
-
contents: outdent.outdent`
|
|
156
|
-
{}
|
|
157
|
-
`
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
/**
|
|
161
|
-
* TODO: remove this when we release design-system V2
|
|
162
|
-
*/
|
|
163
|
-
name: "admin/custom.d.ts",
|
|
164
|
-
contents: outdent.outdent`
|
|
165
|
-
declare module '@strapi/design-system/*';
|
|
166
|
-
declare module '@strapi/design-system';
|
|
167
|
-
`
|
|
168
|
-
}
|
|
169
|
-
];
|
|
170
|
-
const JAVASCRIPT = [
|
|
171
|
-
{
|
|
172
|
-
name: "admin/src/index.js",
|
|
173
|
-
contents: outdent.outdent`
|
|
174
|
-
import { prefixPluginTranslations } from './utils/prefixPluginTranslations';
|
|
175
|
-
import { PLUGIN_ID } from './pluginId';
|
|
176
|
-
import { Initializer } from './components/Initializer';
|
|
177
|
-
import { PluginIcon } from './components/PluginIcon';
|
|
178
|
-
|
|
179
|
-
export default {
|
|
180
|
-
register(app) {
|
|
181
|
-
app.addMenuLink({
|
|
182
|
-
to: \`plugins/\${PluginIcon}\`,
|
|
183
|
-
icon: PluginIcon,
|
|
184
|
-
intlLabel: {
|
|
185
|
-
id: \`\${PLUGIN_ID}.plugin.name\`,
|
|
186
|
-
defaultMessage: PLUGIN_ID,
|
|
187
|
-
},
|
|
188
|
-
Component: async () => {
|
|
189
|
-
const { App } = await import('./pages/App');
|
|
190
|
-
|
|
191
|
-
return App;
|
|
192
|
-
},
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
app.registerPlugin({
|
|
196
|
-
id: PLUGIN_ID,
|
|
197
|
-
initializer: Initializer,
|
|
198
|
-
isReady: false,
|
|
199
|
-
name: PLUGIN_ID,
|
|
200
|
-
});
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
-
async registerTrads(app) {
|
|
204
|
-
const { locales } = app;
|
|
205
|
-
|
|
206
|
-
const importedTranslations = await Promise.all(
|
|
207
|
-
locales.map((locale) => {
|
|
208
|
-
return import(\`./translations/\${locale}.json\`)
|
|
209
|
-
.then(({ default: data }) => {
|
|
210
|
-
return {
|
|
211
|
-
data: prefixPluginTranslations(data, PLUGIN_ID),
|
|
212
|
-
locale,
|
|
213
|
-
};
|
|
214
|
-
})
|
|
215
|
-
.catch(() => {
|
|
216
|
-
return {
|
|
217
|
-
data: {},
|
|
218
|
-
locale,
|
|
219
|
-
};
|
|
220
|
-
});
|
|
221
|
-
})
|
|
222
|
-
);
|
|
223
|
-
|
|
224
|
-
return importedTranslations;
|
|
225
|
-
},
|
|
226
|
-
};
|
|
227
|
-
`
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
name: "admin/src/components/PluginIcon.jsx",
|
|
231
|
-
contents: PLUGIN_ICON_CODE
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
name: "admin/src/components/Initializer.jsx",
|
|
235
|
-
contents: outdent.outdent`
|
|
236
|
-
import { useEffect, useRef } from 'react';
|
|
237
|
-
|
|
238
|
-
import { PLUGIN_ID } from '../pluginId';
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* @type {import('react').FC<{ setPlugin: (id: string) => void }>}
|
|
242
|
-
*/
|
|
243
|
-
const Initializer = ({ setPlugin }) => {
|
|
244
|
-
const ref = useRef(setPlugin);
|
|
245
|
-
|
|
246
|
-
useEffect(() => {
|
|
247
|
-
ref.current(PLUGIN_ID);
|
|
248
|
-
}, []);
|
|
249
|
-
|
|
250
|
-
return null;
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
export { Initializer };
|
|
254
|
-
`
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
name: "admin/src/pages/App.jsx",
|
|
258
|
-
contents: APP_CODE
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
name: "admin/src/pages/HomePage.jsx",
|
|
262
|
-
contents: HOMEPAGE_CODE
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
name: "admin/src/utils/getTranslation.js",
|
|
266
|
-
contents: outdent.outdent`
|
|
267
|
-
import { PLUGIN_ID } from '../pluginId';
|
|
268
|
-
|
|
269
|
-
const getTranslation = (id) => \`\${PLUGIN_ID}.\${id}\`;
|
|
270
|
-
|
|
271
|
-
export { getTranslation };
|
|
272
|
-
`
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
name: "admin/src/translations/en.json",
|
|
276
|
-
contents: outdent.outdent`
|
|
277
|
-
{}
|
|
278
|
-
`
|
|
279
|
-
}
|
|
280
|
-
];
|
|
281
|
-
exports.adminJavascriptFiles = JAVASCRIPT;
|
|
282
|
-
exports.adminTypescriptFiles = TYPESCRIPT;
|
|
283
|
-
//# sourceMappingURL=admin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"admin.js","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":["outdent"],"mappings":";;;AAGA,MAAM,mBAAmBA,QAAAA;AAAAA;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AA;AAAAA,EAOZ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,UAAUA,QAAAA;AAAAA;AAAAA;AAAAA,EAGZ;AACF;;;"}
|
|
@@ -1,283 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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 {}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A;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;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"editorConfig.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/plugin/init/files/editorConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,QAAA,MAAM,gBAAgB,EAAE,YAoBvB,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const outdent = require("outdent");
|
|
4
|
-
const editorConfigFile = {
|
|
5
|
-
name: ".editorconfig",
|
|
6
|
-
contents: outdent.outdent`
|
|
7
|
-
root = true
|
|
8
|
-
|
|
9
|
-
[*]
|
|
10
|
-
indent_style = space
|
|
11
|
-
indent_size = 2
|
|
12
|
-
end_of_line = lf
|
|
13
|
-
charset = utf-8
|
|
14
|
-
trim_trailing_whitespace = true
|
|
15
|
-
insert_final_newline = true
|
|
16
|
-
|
|
17
|
-
[{package.json,*.yml}]
|
|
18
|
-
indent_style = space
|
|
19
|
-
indent_size = 2
|
|
20
|
-
|
|
21
|
-
[*.md]
|
|
22
|
-
trim_trailing_whitespace = false
|
|
23
|
-
`
|
|
24
|
-
};
|
|
25
|
-
exports.editorConfigFile = editorConfigFile;
|
|
26
|
-
//# sourceMappingURL=editorConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"editorConfig.js","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":["outdent"],"mappings":";;;AAGA,MAAM,mBAAiC;AAAA,EACrC,MAAM;AAAA,EACN,UAAUA,QAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAkBZ;;"}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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;"}
|