@strapi/generators 4.9.0-alpha.0 → 4.9.0-beta.1
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/lib/files/js/plugin/admin/src/components/PluginIcon/index.js +1 -1
- package/lib/files/ts/plugin/admin/src/components/Initializer/index.tsx +1 -1
- package/lib/files/ts/plugin/admin/src/components/PluginIcon/index.tsx +1 -1
- package/lib/files/ts/plugin/admin/src/index.tsx +6 -5
- package/lib/files/ts/plugin/admin/src/pages/App/index.tsx +1 -1
- package/lib/files/ts/plugin/admin/src/pages/HomePage/index.tsx +1 -1
- package/lib/files/ts/plugin/custom.d.ts +5 -0
- package/lib/files/ts/plugin/tsconfig.json +6 -11
- package/lib/files/ts/plugin/tsconfig.server.json +25 -0
- package/lib/plopfile.js +2 -0
- package/lib/plops/migration.js +33 -0
- package/lib/plops/utils/get-formatted-date.js +8 -0
- package/lib/plops/utils/validate-file-name-input.js +11 -0
- package/lib/templates/js/migration.js.hbs +15 -0
- package/lib/templates/js/plugin-package.json.hbs +18 -1
- package/lib/templates/ts/migration.ts.hbs +11 -0
- package/lib/templates/ts/plugin-package.json.hbs +21 -3
- package/package.json +4 -4
- package/lib/files/js/plugin/admin/src/utils/axiosInstance.js +0 -42
- package/lib/files/ts/plugin/admin/src/utils/axiosInstance.ts +0 -42
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { prefixPluginTranslations } from '@strapi/helper-plugin';
|
|
2
|
+
|
|
3
3
|
import pluginPkg from '../../package.json';
|
|
4
4
|
import pluginId from './pluginId';
|
|
5
5
|
import Initializer from './components/Initializer';
|
|
@@ -8,7 +8,7 @@ import PluginIcon from './components/PluginIcon';
|
|
|
8
8
|
const name = pluginPkg.strapi.name;
|
|
9
9
|
|
|
10
10
|
export default {
|
|
11
|
-
register(app) {
|
|
11
|
+
register(app: any) {
|
|
12
12
|
app.addMenuLink({
|
|
13
13
|
to: `/plugins/${pluginId}`,
|
|
14
14
|
icon: PluginIcon,
|
|
@@ -39,12 +39,13 @@ export default {
|
|
|
39
39
|
app.registerPlugin(plugin);
|
|
40
40
|
},
|
|
41
41
|
|
|
42
|
-
bootstrap(app) {},
|
|
43
|
-
|
|
42
|
+
bootstrap(app: any) {},
|
|
43
|
+
|
|
44
|
+
async registerTrads(app: any) {
|
|
44
45
|
const { locales } = app;
|
|
45
46
|
|
|
46
47
|
const importedTrads = await Promise.all(
|
|
47
|
-
locales.map(locale => {
|
|
48
|
+
(locales as any[]).map((locale) => {
|
|
48
49
|
return import(`./translations/${locale}.json`)
|
|
49
50
|
.then(({ default: data }) => {
|
|
50
51
|
return {
|
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "@strapi/typescript-utils/tsconfigs/
|
|
2
|
+
"extends": "@strapi/typescript-utils/tsconfigs/admin",
|
|
3
3
|
|
|
4
4
|
"compilerOptions": {
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"strict": true
|
|
7
7
|
},
|
|
8
8
|
|
|
9
|
-
"include": [
|
|
10
|
-
// Include the root directory
|
|
11
|
-
"server",
|
|
12
|
-
// Force the JSON files in the src folder to be included
|
|
13
|
-
"server/**/*.json"
|
|
14
|
-
],
|
|
9
|
+
"include": ["admin", "custom.d.ts"],
|
|
15
10
|
|
|
16
11
|
"exclude": [
|
|
17
12
|
"node_modules/",
|
|
18
13
|
"dist/",
|
|
19
14
|
|
|
20
|
-
// Do not include
|
|
21
|
-
"
|
|
15
|
+
// Do not include server files in the server compilation
|
|
16
|
+
"server/",
|
|
22
17
|
// Do not include test files
|
|
23
18
|
"**/*.test.ts"
|
|
24
19
|
]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@strapi/typescript-utils/tsconfigs/server",
|
|
3
|
+
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"outDir": "dist",
|
|
6
|
+
"rootDir": "."
|
|
7
|
+
},
|
|
8
|
+
|
|
9
|
+
"include": [
|
|
10
|
+
// Include the root directory
|
|
11
|
+
"server",
|
|
12
|
+
// Force the JSON files in the src folder to be included
|
|
13
|
+
"server/**/*.json"
|
|
14
|
+
],
|
|
15
|
+
|
|
16
|
+
"exclude": [
|
|
17
|
+
"node_modules/",
|
|
18
|
+
"dist/",
|
|
19
|
+
|
|
20
|
+
// Do not include admin files in the server compilation
|
|
21
|
+
"admin/",
|
|
22
|
+
// Do not include test files
|
|
23
|
+
"**/*.test.ts"
|
|
24
|
+
]
|
|
25
|
+
}
|
package/lib/plopfile.js
CHANGED
|
@@ -8,6 +8,7 @@ const generateContentType = require('./plops/content-type');
|
|
|
8
8
|
const generatePlugin = require('./plops/plugin');
|
|
9
9
|
const generatePolicy = require('./plops/policy');
|
|
10
10
|
const generateMiddleware = require('./plops/middleware');
|
|
11
|
+
const generateMigration = require('./plops/migration');
|
|
11
12
|
const generateService = require('./plops/service');
|
|
12
13
|
|
|
13
14
|
module.exports = (plop) => {
|
|
@@ -22,5 +23,6 @@ module.exports = (plop) => {
|
|
|
22
23
|
generatePlugin(plop);
|
|
23
24
|
generatePolicy(plop);
|
|
24
25
|
generateMiddleware(plop);
|
|
26
|
+
generateMigration(plop);
|
|
25
27
|
generateService(plop);
|
|
26
28
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const tsUtils = require('@strapi/typescript-utils');
|
|
4
|
+
const validateFileNameInput = require('./utils/validate-file-name-input');
|
|
5
|
+
const getFormattedDate = require('./utils/get-formatted-date');
|
|
6
|
+
|
|
7
|
+
module.exports = (plop) => {
|
|
8
|
+
// Migration generator
|
|
9
|
+
plop.setGenerator('migration', {
|
|
10
|
+
description: 'Generate a migration',
|
|
11
|
+
prompts: [
|
|
12
|
+
{
|
|
13
|
+
type: 'input',
|
|
14
|
+
name: 'name',
|
|
15
|
+
message: 'Migration name',
|
|
16
|
+
validate: (input) => validateFileNameInput(input),
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
actions() {
|
|
20
|
+
const currentDir = process.cwd();
|
|
21
|
+
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
|
22
|
+
const timestamp = getFormattedDate();
|
|
23
|
+
|
|
24
|
+
return [
|
|
25
|
+
{
|
|
26
|
+
type: 'add',
|
|
27
|
+
path: `${currentDir}/database/migrations/${timestamp}.{{ name }}.${language}`,
|
|
28
|
+
templateFile: `templates/${language}/migration.${language}.hbs`,
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
};
|
|
@@ -8,7 +8,24 @@
|
|
|
8
8
|
"kind": "plugin",
|
|
9
9
|
"displayName": "{{titleCase pluginName }}"
|
|
10
10
|
},
|
|
11
|
-
"dependencies": {
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@strapi/design-system": "^1.6.3",
|
|
13
|
+
"@strapi/helper-plugin": "^4.6.0",
|
|
14
|
+
"@strapi/icons": "^1.6.3",
|
|
15
|
+
"prop-types": "^15.7.2"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"react": "^17.0.2",
|
|
19
|
+
"react-dom": "^17.0.2",
|
|
20
|
+
"react-router-dom": "^5.3.4",
|
|
21
|
+
"styled-components": "^5.3.6"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"react": "^17.0.2",
|
|
25
|
+
"react-dom": "^17.0.2",
|
|
26
|
+
"react-router-dom": "^5.3.4",
|
|
27
|
+
"styled-components": "^5.3.6"
|
|
28
|
+
},
|
|
12
29
|
"author": {
|
|
13
30
|
"name": "A Strapi developer"
|
|
14
31
|
},
|
|
@@ -8,11 +8,29 @@
|
|
|
8
8
|
"kind": "plugin"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@strapi/
|
|
11
|
+
"@strapi/design-system": "^1.6.3",
|
|
12
|
+
"@strapi/helper-plugin": "^4.6.0",
|
|
13
|
+
"@strapi/icons": "^1.6.3",
|
|
14
|
+
"prop-types": "^15.7.2"
|
|
12
15
|
},
|
|
13
16
|
"devDependencies": {
|
|
17
|
+
"@strapi/typescript-utils": "^4.6.0",
|
|
18
|
+
"@types/react": "^17.0.53",
|
|
19
|
+
"@types/react-dom": "^17.0.18",
|
|
20
|
+
"@types/react-router-dom": "^5.3.3",
|
|
21
|
+
"@types/styled-components": "^5.1.26",
|
|
22
|
+
"react": "^17.0.2",
|
|
23
|
+
"react-dom": "^17.0.2",
|
|
24
|
+
"react-router-dom": "^5.3.4",
|
|
25
|
+
"styled-components": "^5.3.6",
|
|
14
26
|
"typescript": "4.6.3"
|
|
15
27
|
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"react": "^17.0.2",
|
|
30
|
+
"react-dom": "^17.0.2",
|
|
31
|
+
"react-router-dom": "^5.3.4",
|
|
32
|
+
"styled-components": "^5.3.6"
|
|
33
|
+
},
|
|
16
34
|
"author": {
|
|
17
35
|
"name": "A Strapi developer"
|
|
18
36
|
},
|
|
@@ -26,8 +44,8 @@
|
|
|
26
44
|
"npm": ">=6.0.0"
|
|
27
45
|
},
|
|
28
46
|
"scripts": {
|
|
29
|
-
"develop": "tsc -w",
|
|
30
|
-
"build": "tsc"
|
|
47
|
+
"develop": "tsc -p tsconfig.server.json -w",
|
|
48
|
+
"build": "tsc -p tsconfig.server.json"
|
|
31
49
|
},
|
|
32
50
|
"license": "MIT"
|
|
33
51
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/generators",
|
|
3
|
-
"version": "4.9.0-
|
|
3
|
+
"version": "4.9.0-beta.1",
|
|
4
4
|
"description": "Interactive API generator.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"main": "lib/index.js",
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@sindresorhus/slugify": "1.1.0",
|
|
33
|
-
"@strapi/typescript-utils": "4.9.0-
|
|
34
|
-
"@strapi/utils": "4.9.0-
|
|
33
|
+
"@strapi/typescript-utils": "4.9.0-beta.1",
|
|
34
|
+
"@strapi/utils": "4.9.0-beta.1",
|
|
35
35
|
"chalk": "4.1.2",
|
|
36
36
|
"fs-extra": "10.0.0",
|
|
37
37
|
"node-plop": "0.26.3",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"node": ">=14.19.1 <=18.x.x",
|
|
43
43
|
"npm": ">=6.0.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "ff37d666d0634fc84827e3d6419d916618275572"
|
|
46
46
|
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* axios with a custom config.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import axios from 'axios';
|
|
6
|
-
import { auth, wrapAxiosInstance } from '@strapi/helper-plugin';
|
|
7
|
-
|
|
8
|
-
const instance = axios.create({
|
|
9
|
-
baseURL: process.env.STRAPI_ADMIN_BACKEND_URL,
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
instance.interceptors.request.use(
|
|
13
|
-
async (config) => {
|
|
14
|
-
config.headers = {
|
|
15
|
-
Authorization: `Bearer ${auth.getToken()}`,
|
|
16
|
-
Accept: 'application/json',
|
|
17
|
-
'Content-Type': 'application/json',
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
return config;
|
|
21
|
-
},
|
|
22
|
-
(error) => {
|
|
23
|
-
Promise.reject(error);
|
|
24
|
-
}
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
instance.interceptors.response.use(
|
|
28
|
-
(response) => response,
|
|
29
|
-
(error) => {
|
|
30
|
-
// whatever you want to do with the error
|
|
31
|
-
if (error.response?.status === 401) {
|
|
32
|
-
auth.clearAppStorage();
|
|
33
|
-
window.location.reload();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
const wrapper = wrapAxiosInstance(instance);
|
|
41
|
-
|
|
42
|
-
export default wrapper;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* axios with a custom config.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import axios from 'axios';
|
|
6
|
-
import { auth, wrapAxiosInstance } from '@strapi/helper-plugin';
|
|
7
|
-
|
|
8
|
-
const instance = axios.create({
|
|
9
|
-
baseURL: process.env.STRAPI_ADMIN_BACKEND_URL,
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
instance.interceptors.request.use(
|
|
13
|
-
async (config) => {
|
|
14
|
-
config.headers = {
|
|
15
|
-
Authorization: `Bearer ${auth.getToken()}`,
|
|
16
|
-
Accept: 'application/json',
|
|
17
|
-
'Content-Type': 'application/json',
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
return config;
|
|
21
|
-
},
|
|
22
|
-
(error) => {
|
|
23
|
-
Promise.reject(error);
|
|
24
|
-
}
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
instance.interceptors.response.use(
|
|
28
|
-
(response) => response,
|
|
29
|
-
(error) => {
|
|
30
|
-
// whatever you want to do with the error
|
|
31
|
-
if (error.response?.status === 401) {
|
|
32
|
-
auth.clearAppStorage();
|
|
33
|
-
window.location.reload();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
const wrapper = wrapAxiosInstance(instance);
|
|
41
|
-
|
|
42
|
-
export default wrapper;
|