@strapi/generators 4.10.1 → 4.10.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/files/js/plugin/.editorconfig +7 -0
- package/dist/files/js/plugin/.gitattributes +103 -0
- package/dist/files/ts/plugin/.editorconfig +7 -0
- package/dist/files/ts/plugin/.gitattributes +103 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/plopfile.d.ts +3 -0
- package/dist/plopfile.js +29 -0
- package/dist/plopfile.js.map +1 -0
- package/dist/plops/api.d.ts +3 -0
- package/dist/plops/api.js +79 -0
- package/dist/plops/api.js.map +1 -0
- package/dist/plops/content-type.d.ts +3 -0
- package/dist/plops/content-type.js +135 -0
- package/dist/plops/content-type.js.map +1 -0
- package/dist/plops/controller.d.ts +3 -0
- package/dist/plops/controller.js +40 -0
- package/dist/plops/controller.js.map +1 -0
- package/dist/plops/middleware.d.ts +3 -0
- package/dist/plops/middleware.js +40 -0
- package/dist/plops/middleware.js.map +1 -0
- package/dist/plops/migration.d.ts +3 -0
- package/dist/plops/migration.js +35 -0
- package/dist/plops/migration.js.map +1 -0
- package/dist/plops/plugin.d.ts +3 -0
- package/dist/plops/plugin.js +84 -0
- package/dist/plops/plugin.js.map +1 -0
- package/dist/plops/policy.d.ts +3 -0
- package/dist/plops/policy.js +40 -0
- package/dist/plops/policy.js.map +1 -0
- package/dist/plops/prompts/bootstrap-api-prompts.d.ts +3 -0
- package/dist/plops/prompts/bootstrap-api-prompts.js +12 -0
- package/dist/plops/prompts/bootstrap-api-prompts.js.map +1 -0
- package/dist/plops/prompts/ct-names-prompts.d.ts +3 -0
- package/dist/plops/prompts/ct-names-prompts.js +45 -0
- package/dist/plops/prompts/ct-names-prompts.js.map +1 -0
- package/dist/plops/prompts/draft-and-publish-prompts.d.ts +3 -0
- package/dist/plops/prompts/draft-and-publish-prompts.js +12 -0
- package/dist/plops/prompts/draft-and-publish-prompts.js.map +1 -0
- package/dist/plops/prompts/get-attributes-prompts.d.ts +3 -0
- package/dist/plops/prompts/get-attributes-prompts.js +95 -0
- package/dist/plops/prompts/get-attributes-prompts.js.map +1 -0
- package/dist/plops/prompts/get-destination-prompts.d.ts +5 -0
- package/dist/plops/prompts/get-destination-prompts.js +72 -0
- package/dist/plops/prompts/get-destination-prompts.js.map +1 -0
- package/dist/plops/prompts/kind-prompts.d.ts +3 -0
- package/dist/plops/prompts/kind-prompts.js +21 -0
- package/dist/plops/prompts/kind-prompts.js.map +1 -0
- package/dist/plops/service.d.ts +3 -0
- package/dist/plops/service.js +38 -0
- package/dist/plops/service.js.map +1 -0
- package/dist/plops/utils/get-file-path.d.ts +2 -0
- package/dist/plops/utils/get-file-path.js +15 -0
- package/dist/plops/utils/get-file-path.js.map +1 -0
- package/dist/plops/utils/get-formatted-date.d.ts +2 -0
- package/dist/plops/utils/get-formatted-date.js +9 -0
- package/dist/plops/utils/get-formatted-date.js.map +1 -0
- package/dist/plops/utils/validate-attribute-input.d.ts +2 -0
- package/dist/plops/utils/validate-attribute-input.js +10 -0
- package/dist/plops/utils/validate-attribute-input.js.map +1 -0
- package/dist/plops/utils/validate-file-name-input.d.ts +2 -0
- package/dist/plops/utils/validate-file-name-input.js +10 -0
- package/dist/plops/utils/validate-file-name-input.js.map +1 -0
- package/dist/plops/utils/validate-input.d.ts +2 -0
- package/dist/plops/utils/validate-input.js +10 -0
- package/dist/plops/utils/validate-input.js.map +1 -0
- package/package.json +22 -5
- package/.eslintignore +0 -3
- package/.eslintrc.js +0 -4
- package/lib/index.js +0 -37
- package/lib/plopfile.js +0 -28
- package/lib/plops/__tests__/content-type.test.js +0 -179
- package/lib/plops/api.js +0 -82
- package/lib/plops/content-type.js +0 -148
- package/lib/plops/controller.js +0 -36
- package/lib/plops/middleware.js +0 -36
- package/lib/plops/migration.js +0 -33
- package/lib/plops/plugin.js +0 -91
- package/lib/plops/policy.js +0 -36
- package/lib/plops/prompts/bootstrap-api-prompts.js +0 -10
- package/lib/plops/prompts/ct-names-prompts.js +0 -44
- package/lib/plops/prompts/draft-and-publish-prompts.js +0 -10
- package/lib/plops/prompts/get-attributes-prompts.js +0 -105
- package/lib/plops/prompts/get-destination-prompts.js +0 -79
- package/lib/plops/prompts/kind-prompts.js +0 -17
- package/lib/plops/service.js +0 -34
- package/lib/plops/utils/__tests__/get-file-path.test.js +0 -25
- package/lib/plops/utils/get-file-path.js +0 -17
- package/lib/plops/utils/get-formatted-date.js +0 -8
- package/lib/plops/utils/validate-attribute-input.js +0 -11
- package/lib/plops/utils/validate-file-name-input.js +0 -11
- package/lib/plops/utils/validate-input.js +0 -11
- /package/{lib → dist}/files/js/plugin/admin/src/components/Initializer/index.js +0 -0
- /package/{lib → dist}/files/js/plugin/admin/src/components/PluginIcon/index.js +0 -0
- /package/{lib → dist}/files/js/plugin/admin/src/index.js +0 -0
- /package/{lib → dist}/files/js/plugin/admin/src/pages/App/index.js +0 -0
- /package/{lib → dist}/files/js/plugin/admin/src/pages/HomePage/index.js +0 -0
- /package/{lib → dist}/files/js/plugin/admin/src/pluginId.js +0 -0
- /package/{lib → dist}/files/js/plugin/admin/src/translations/en.json +0 -0
- /package/{lib → dist}/files/js/plugin/admin/src/translations/fr.json +0 -0
- /package/{lib → dist}/files/js/plugin/admin/src/utils/getTrad.js +0 -0
- /package/{lib → dist}/files/js/plugin/server/bootstrap.js +0 -0
- /package/{lib → dist}/files/js/plugin/server/config/index.js +0 -0
- /package/{lib → dist}/files/js/plugin/server/content-types/index.js +0 -0
- /package/{lib → dist}/files/js/plugin/server/controllers/index.js +0 -0
- /package/{lib → dist}/files/js/plugin/server/controllers/my-controller.js.hbs +0 -0
- /package/{lib → dist}/files/js/plugin/server/destroy.js +0 -0
- /package/{lib → dist}/files/js/plugin/server/index.js +0 -0
- /package/{lib → dist}/files/js/plugin/server/middlewares/index.js +0 -0
- /package/{lib → dist}/files/js/plugin/server/policies/index.js +0 -0
- /package/{lib → dist}/files/js/plugin/server/register.js +0 -0
- /package/{lib → dist}/files/js/plugin/server/routes/index.js +0 -0
- /package/{lib → dist}/files/js/plugin/server/services/index.js +0 -0
- /package/{lib → dist}/files/js/plugin/server/services/my-service.js +0 -0
- /package/{lib → dist}/files/js/plugin/strapi-admin.js +0 -0
- /package/{lib → dist}/files/js/plugin/strapi-server.js +0 -0
- /package/{lib → dist}/files/ts/plugin/admin/src/components/Initializer/index.tsx +0 -0
- /package/{lib → dist}/files/ts/plugin/admin/src/components/PluginIcon/index.tsx +0 -0
- /package/{lib → dist}/files/ts/plugin/admin/src/index.tsx +0 -0
- /package/{lib → dist}/files/ts/plugin/admin/src/pages/App/index.tsx +0 -0
- /package/{lib → dist}/files/ts/plugin/admin/src/pages/HomePage/index.tsx +0 -0
- /package/{lib → dist}/files/ts/plugin/admin/src/pluginId.ts +0 -0
- /package/{lib → dist}/files/ts/plugin/admin/src/translations/en.json +0 -0
- /package/{lib → dist}/files/ts/plugin/admin/src/translations/fr.json +0 -0
- /package/{lib → dist}/files/ts/plugin/admin/src/utils/getTrad.ts +0 -0
- /package/{lib → dist}/files/ts/plugin/custom.d.ts +0 -0
- /package/{lib → dist}/files/ts/plugin/server/bootstrap.ts +0 -0
- /package/{lib → dist}/files/ts/plugin/server/config/index.ts +0 -0
- /package/{lib → dist}/files/ts/plugin/server/content-types/index.ts +0 -0
- /package/{lib → dist}/files/ts/plugin/server/controllers/index.ts +0 -0
- /package/{lib → dist}/files/ts/plugin/server/controllers/my-controller.ts.hbs +0 -0
- /package/{lib → dist}/files/ts/plugin/server/destroy.ts +0 -0
- /package/{lib → dist}/files/ts/plugin/server/index.ts +0 -0
- /package/{lib → dist}/files/ts/plugin/server/middlewares/index.ts +0 -0
- /package/{lib → dist}/files/ts/plugin/server/policies/index.ts +0 -0
- /package/{lib → dist}/files/ts/plugin/server/register.ts +0 -0
- /package/{lib → dist}/files/ts/plugin/server/routes/index.ts +0 -0
- /package/{lib → dist}/files/ts/plugin/server/services/index.ts +0 -0
- /package/{lib → dist}/files/ts/plugin/server/services/my-service.ts +0 -0
- /package/{lib → dist}/files/ts/plugin/strapi-admin.js +0 -0
- /package/{lib → dist}/files/ts/plugin/strapi-server.js +0 -0
- /package/{lib → dist}/files/ts/plugin/tsconfig.json +0 -0
- /package/{lib → dist}/files/ts/plugin/tsconfig.server.json +0 -0
- /package/{lib → dist}/templates/js/README.md.hbs +0 -0
- /package/{lib → dist}/templates/js/collection-type-routes.js.hbs +0 -0
- /package/{lib → dist}/templates/js/content-type.schema.json.hbs +0 -0
- /package/{lib → dist}/templates/js/controller.js.hbs +0 -0
- /package/{lib → dist}/templates/js/core-controller.js.hbs +0 -0
- /package/{lib → dist}/templates/js/core-router.js.hbs +0 -0
- /package/{lib → dist}/templates/js/core-service.js.hbs +0 -0
- /package/{lib → dist}/templates/js/middleware.js.hbs +0 -0
- /package/{lib → dist}/templates/js/migration.js.hbs +0 -0
- /package/{lib → dist}/templates/js/plugin-package.json.hbs +0 -0
- /package/{lib → dist}/templates/js/policy.js.hbs +0 -0
- /package/{lib → dist}/templates/js/service.js.hbs +0 -0
- /package/{lib → dist}/templates/js/single-route.js.hbs +0 -0
- /package/{lib → dist}/templates/js/single-type-routes.js.hbs +0 -0
- /package/{lib → dist}/templates/ts/README.md.hbs +0 -0
- /package/{lib → dist}/templates/ts/collection-type-routes.ts.hbs +0 -0
- /package/{lib → dist}/templates/ts/content-type.schema.json.hbs +0 -0
- /package/{lib → dist}/templates/ts/controller.ts.hbs +0 -0
- /package/{lib → dist}/templates/ts/core-controller.ts.hbs +0 -0
- /package/{lib → dist}/templates/ts/core-router.ts.hbs +0 -0
- /package/{lib → dist}/templates/ts/core-service.ts.hbs +0 -0
- /package/{lib → dist}/templates/ts/middleware.ts.hbs +0 -0
- /package/{lib → dist}/templates/ts/migration.ts.hbs +0 -0
- /package/{lib → dist}/templates/ts/plugin-package.json.hbs +0 -0
- /package/{lib → dist}/templates/ts/policy.ts.hbs +0 -0
- /package/{lib → dist}/templates/ts/service.ts.hbs +0 -0
- /package/{lib → dist}/templates/ts/single-route.ts.hbs +0 -0
- /package/{lib → dist}/templates/ts/single-type-routes.ts.hbs +0 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# From https://github.com/Danimoth/gitattributes/blob/master/Web.gitattributes
|
|
2
|
+
|
|
3
|
+
# Handle line endings automatically for files detected as text
|
|
4
|
+
# and leave all files detected as binary untouched.
|
|
5
|
+
* text=auto
|
|
6
|
+
|
|
7
|
+
#
|
|
8
|
+
# The above will handle all files NOT found below
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
#
|
|
12
|
+
## These files are text and should be normalized (Convert crlf => lf)
|
|
13
|
+
#
|
|
14
|
+
|
|
15
|
+
# source code
|
|
16
|
+
*.php text
|
|
17
|
+
*.css text
|
|
18
|
+
*.sass text
|
|
19
|
+
*.scss text
|
|
20
|
+
*.less text
|
|
21
|
+
*.styl text
|
|
22
|
+
*.js text eol=lf
|
|
23
|
+
*.coffee text
|
|
24
|
+
*.json text
|
|
25
|
+
*.htm text
|
|
26
|
+
*.html text
|
|
27
|
+
*.xml text
|
|
28
|
+
*.svg text
|
|
29
|
+
*.txt text
|
|
30
|
+
*.ini text
|
|
31
|
+
*.inc text
|
|
32
|
+
*.pl text
|
|
33
|
+
*.rb text
|
|
34
|
+
*.py text
|
|
35
|
+
*.scm text
|
|
36
|
+
*.sql text
|
|
37
|
+
*.sh text
|
|
38
|
+
*.bat text
|
|
39
|
+
|
|
40
|
+
# templates
|
|
41
|
+
*.ejs text
|
|
42
|
+
*.hbt text
|
|
43
|
+
*.jade text
|
|
44
|
+
*.haml text
|
|
45
|
+
*.hbs text
|
|
46
|
+
*.dot text
|
|
47
|
+
*.tmpl text
|
|
48
|
+
*.phtml text
|
|
49
|
+
|
|
50
|
+
# git config
|
|
51
|
+
.gitattributes text
|
|
52
|
+
.gitignore text
|
|
53
|
+
.gitconfig text
|
|
54
|
+
|
|
55
|
+
# code analysis config
|
|
56
|
+
.jshintrc text
|
|
57
|
+
.jscsrc text
|
|
58
|
+
.jshintignore text
|
|
59
|
+
.csslintrc text
|
|
60
|
+
|
|
61
|
+
# misc config
|
|
62
|
+
*.yaml text
|
|
63
|
+
*.yml text
|
|
64
|
+
.editorconfig text
|
|
65
|
+
|
|
66
|
+
# build config
|
|
67
|
+
*.npmignore text
|
|
68
|
+
*.bowerrc text
|
|
69
|
+
|
|
70
|
+
# Heroku
|
|
71
|
+
Procfile text
|
|
72
|
+
.slugignore text
|
|
73
|
+
|
|
74
|
+
# Documentation
|
|
75
|
+
*.md text
|
|
76
|
+
LICENSE text
|
|
77
|
+
AUTHORS text
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
#
|
|
81
|
+
## These files are binary and should be left untouched
|
|
82
|
+
#
|
|
83
|
+
|
|
84
|
+
# (binary is a macro for -text -diff)
|
|
85
|
+
*.png binary
|
|
86
|
+
*.jpg binary
|
|
87
|
+
*.jpeg binary
|
|
88
|
+
*.gif binary
|
|
89
|
+
*.ico binary
|
|
90
|
+
*.mov binary
|
|
91
|
+
*.mp4 binary
|
|
92
|
+
*.mp3 binary
|
|
93
|
+
*.flv binary
|
|
94
|
+
*.fla binary
|
|
95
|
+
*.swf binary
|
|
96
|
+
*.gz binary
|
|
97
|
+
*.zip binary
|
|
98
|
+
*.7z binary
|
|
99
|
+
*.ttf binary
|
|
100
|
+
*.eot binary
|
|
101
|
+
*.woff binary
|
|
102
|
+
*.pyc binary
|
|
103
|
+
*.pdf binary
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# From https://github.com/Danimoth/gitattributes/blob/master/Web.gitattributes
|
|
2
|
+
|
|
3
|
+
# Handle line endings automatically for files detected as text
|
|
4
|
+
# and leave all files detected as binary untouched.
|
|
5
|
+
* text=auto
|
|
6
|
+
|
|
7
|
+
#
|
|
8
|
+
# The above will handle all files NOT found below
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
#
|
|
12
|
+
## These files are text and should be normalized (Convert crlf => lf)
|
|
13
|
+
#
|
|
14
|
+
|
|
15
|
+
# source code
|
|
16
|
+
*.php text
|
|
17
|
+
*.css text
|
|
18
|
+
*.sass text
|
|
19
|
+
*.scss text
|
|
20
|
+
*.less text
|
|
21
|
+
*.styl text
|
|
22
|
+
*.js text eol=lf
|
|
23
|
+
*.coffee text
|
|
24
|
+
*.json text
|
|
25
|
+
*.htm text
|
|
26
|
+
*.html text
|
|
27
|
+
*.xml text
|
|
28
|
+
*.svg text
|
|
29
|
+
*.txt text
|
|
30
|
+
*.ini text
|
|
31
|
+
*.inc text
|
|
32
|
+
*.pl text
|
|
33
|
+
*.rb text
|
|
34
|
+
*.py text
|
|
35
|
+
*.scm text
|
|
36
|
+
*.sql text
|
|
37
|
+
*.sh text
|
|
38
|
+
*.bat text
|
|
39
|
+
|
|
40
|
+
# templates
|
|
41
|
+
*.ejs text
|
|
42
|
+
*.hbt text
|
|
43
|
+
*.jade text
|
|
44
|
+
*.haml text
|
|
45
|
+
*.hbs text
|
|
46
|
+
*.dot text
|
|
47
|
+
*.tmpl text
|
|
48
|
+
*.phtml text
|
|
49
|
+
|
|
50
|
+
# git config
|
|
51
|
+
.gitattributes text
|
|
52
|
+
.gitignore text
|
|
53
|
+
.gitconfig text
|
|
54
|
+
|
|
55
|
+
# code analysis config
|
|
56
|
+
.jshintrc text
|
|
57
|
+
.jscsrc text
|
|
58
|
+
.jshintignore text
|
|
59
|
+
.csslintrc text
|
|
60
|
+
|
|
61
|
+
# misc config
|
|
62
|
+
*.yaml text
|
|
63
|
+
*.yml text
|
|
64
|
+
.editorconfig text
|
|
65
|
+
|
|
66
|
+
# build config
|
|
67
|
+
*.npmignore text
|
|
68
|
+
*.bowerrc text
|
|
69
|
+
|
|
70
|
+
# Heroku
|
|
71
|
+
Procfile text
|
|
72
|
+
.slugignore text
|
|
73
|
+
|
|
74
|
+
# Documentation
|
|
75
|
+
*.md text
|
|
76
|
+
LICENSE text
|
|
77
|
+
AUTHORS text
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
#
|
|
81
|
+
## These files are binary and should be left untouched
|
|
82
|
+
#
|
|
83
|
+
|
|
84
|
+
# (binary is a macro for -text -diff)
|
|
85
|
+
*.png binary
|
|
86
|
+
*.jpg binary
|
|
87
|
+
*.jpeg binary
|
|
88
|
+
*.gif binary
|
|
89
|
+
*.ico binary
|
|
90
|
+
*.mov binary
|
|
91
|
+
*.mp4 binary
|
|
92
|
+
*.mp3 binary
|
|
93
|
+
*.flv binary
|
|
94
|
+
*.fla binary
|
|
95
|
+
*.swf binary
|
|
96
|
+
*.gz binary
|
|
97
|
+
*.zip binary
|
|
98
|
+
*.7z binary
|
|
99
|
+
*.ttf binary
|
|
100
|
+
*.eot binary
|
|
101
|
+
*.woff binary
|
|
102
|
+
*.pyc binary
|
|
103
|
+
*.pdf binary
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generate = exports.runCLI = void 0;
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const plop_1 = require("plop");
|
|
9
|
+
const node_plop_1 = __importDefault(require("node-plop"));
|
|
10
|
+
// Starts the Plop CLI programmatically
|
|
11
|
+
const runCLI = () => {
|
|
12
|
+
plop_1.Plop.launch({ configPath: (0, node_path_1.join)(__dirname, 'plopfile.js') }, (env) => {
|
|
13
|
+
const options = { ...env, dest: (0, node_path_1.join)(process.cwd(), 'src') };
|
|
14
|
+
(0, plop_1.run)(options, undefined, true);
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
exports.runCLI = runCLI;
|
|
18
|
+
// Runs a generator programmatically without prompts
|
|
19
|
+
const generate = async (generatorName, options, { dir = process.cwd(), plopFile = 'plopfile.js' } = {}) => {
|
|
20
|
+
const plop = (0, node_plop_1.default)((0, node_path_1.join)(__dirname, plopFile), {
|
|
21
|
+
destBasePath: (0, node_path_1.join)(dir, 'src'),
|
|
22
|
+
force: false,
|
|
23
|
+
});
|
|
24
|
+
const generator = plop.getGenerator(generatorName);
|
|
25
|
+
await generator.runActions(options, {
|
|
26
|
+
onSuccess() { },
|
|
27
|
+
onFailure() { },
|
|
28
|
+
onComment() { },
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
exports.generate = generate;
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAiC;AACjC,+BAAiC;AACjC,0DAAiC;AAEjC,uCAAuC;AAChC,MAAM,MAAM,GAAG,GAAG,EAAE;IACzB,WAAI,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,IAAA,gBAAI,EAAC,SAAS,EAAE,aAAa,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE;QAClE,MAAM,OAAO,GAAG,EAAE,GAAG,GAAG,EAAE,IAAI,EAAE,IAAA,gBAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,EAAE,CAAC;QAC7D,IAAA,UAAG,EAAC,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AALW,QAAA,MAAM,UAKjB;AAEF,oDAAoD;AAC7C,MAAM,QAAQ,GAAG,KAAK,EAC3B,aAAqB,EACrB,OAAgB,EAChB,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,GAAG,aAAa,EAAE,GAAG,EAAE,EACtD,EAAE;IACF,MAAM,IAAI,GAAG,IAAA,mBAAQ,EAAC,IAAA,gBAAI,EAAC,SAAS,EAAE,QAAQ,CAAC,EAAE;QAC/C,YAAY,EAAE,IAAA,gBAAI,EAAC,GAAG,EAAE,KAAK,CAAC;QAC9B,KAAK,EAAE,KAAK;KACb,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;IACnD,MAAM,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE;QAClC,SAAS,KAAI,CAAC;QACd,SAAS,KAAI,CAAC;QACd,SAAS,KAAI,CAAC;KACf,CAAC,CAAC;AACL,CAAC,CAAC;AAhBW,QAAA,QAAQ,YAgBnB"}
|
package/dist/plopfile.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const pluralize_1 = __importDefault(require("pluralize"));
|
|
7
|
+
const api_1 = __importDefault(require("./plops/api"));
|
|
8
|
+
const controller_1 = __importDefault(require("./plops/controller"));
|
|
9
|
+
const content_type_1 = __importDefault(require("./plops/content-type"));
|
|
10
|
+
const plugin_1 = __importDefault(require("./plops/plugin"));
|
|
11
|
+
const policy_1 = __importDefault(require("./plops/policy"));
|
|
12
|
+
const middleware_1 = __importDefault(require("./plops/middleware"));
|
|
13
|
+
const migration_1 = __importDefault(require("./plops/migration"));
|
|
14
|
+
const service_1 = __importDefault(require("./plops/service"));
|
|
15
|
+
exports.default = (plop) => {
|
|
16
|
+
// Plop config
|
|
17
|
+
plop.setWelcomeMessage('Strapi Generators');
|
|
18
|
+
plop.addHelper('pluralize', (text) => (0, pluralize_1.default)(text));
|
|
19
|
+
// Generators
|
|
20
|
+
(0, api_1.default)(plop);
|
|
21
|
+
(0, controller_1.default)(plop);
|
|
22
|
+
(0, content_type_1.default)(plop);
|
|
23
|
+
(0, plugin_1.default)(plop);
|
|
24
|
+
(0, policy_1.default)(plop);
|
|
25
|
+
(0, middleware_1.default)(plop);
|
|
26
|
+
(0, migration_1.default)(plop);
|
|
27
|
+
(0, service_1.default)(plop);
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=plopfile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plopfile.js","sourceRoot":"","sources":["../src/plopfile.ts"],"names":[],"mappings":";;;;;AAAA,0DAAkC;AAGlC,sDAAsC;AACtC,oEAAoD;AACpD,wEAAuD;AACvD,4DAA4C;AAC5C,4DAA4C;AAC5C,oEAAoD;AACpD,kEAAkD;AAClD,8DAA8C;AAE9C,kBAAe,CAAC,IAAiB,EAAE,EAAE;IACnC,cAAc;IACd,IAAI,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,CAAC;IAC5C,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAA,mBAAS,EAAC,IAAI,CAAC,CAAC,CAAC;IAE/D,aAAa;IACb,IAAA,aAAW,EAAC,IAAI,CAAC,CAAC;IAClB,IAAA,oBAAkB,EAAC,IAAI,CAAC,CAAC;IACzB,IAAA,sBAAmB,EAAC,IAAI,CAAC,CAAC;IAC1B,IAAA,gBAAc,EAAC,IAAI,CAAC,CAAC;IACrB,IAAA,gBAAc,EAAC,IAAI,CAAC,CAAC;IACrB,IAAA,oBAAkB,EAAC,IAAI,CAAC,CAAC;IACzB,IAAA,mBAAiB,EAAC,IAAI,CAAC,CAAC;IACxB,IAAA,iBAAe,EAAC,IAAI,CAAC,CAAC;AACxB,CAAC,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
+
const typescript_utils_1 = __importDefault(require("@strapi/typescript-utils"));
|
|
9
|
+
const validate_input_1 = __importDefault(require("./utils/validate-input"));
|
|
10
|
+
exports.default = (plop) => {
|
|
11
|
+
// API generator
|
|
12
|
+
plop.setGenerator('api', {
|
|
13
|
+
description: 'Generate a basic API',
|
|
14
|
+
prompts: [
|
|
15
|
+
{
|
|
16
|
+
type: 'input',
|
|
17
|
+
name: 'id',
|
|
18
|
+
message: 'API name',
|
|
19
|
+
validate: (input) => (0, validate_input_1.default)(input),
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: 'confirm',
|
|
23
|
+
name: 'isPluginApi',
|
|
24
|
+
message: 'Is this API for a plugin?',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
when: (answers) => answers.isPluginApi,
|
|
28
|
+
type: 'list',
|
|
29
|
+
name: 'plugin',
|
|
30
|
+
message: 'Plugin name',
|
|
31
|
+
async choices() {
|
|
32
|
+
const pluginsPath = (0, path_1.join)(plop.getDestBasePath(), 'plugins');
|
|
33
|
+
const exists = await fs_extra_1.default.pathExists(pluginsPath);
|
|
34
|
+
if (!exists) {
|
|
35
|
+
throw Error('Couldn\'t find a "plugins" directory');
|
|
36
|
+
}
|
|
37
|
+
const pluginsDir = await fs_extra_1.default.readdir(pluginsPath, { withFileTypes: true });
|
|
38
|
+
const pluginsDirContent = pluginsDir.filter((fd) => fd.isDirectory());
|
|
39
|
+
if (pluginsDirContent.length === 0) {
|
|
40
|
+
throw Error('The "plugins" directory is empty');
|
|
41
|
+
}
|
|
42
|
+
return pluginsDirContent;
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
actions(answers) {
|
|
47
|
+
if (!answers) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
const filePath = answers.isPluginApi && answers.plugin ? 'plugins/{{ plugin }}' : 'api/{{ id }}';
|
|
51
|
+
const currentDir = process.cwd();
|
|
52
|
+
const language = typescript_utils_1.default.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
|
53
|
+
const baseActions = [
|
|
54
|
+
{
|
|
55
|
+
type: 'add',
|
|
56
|
+
path: `${filePath}/controllers/{{ id }}.${language}`,
|
|
57
|
+
templateFile: `templates/${language}/controller.${language}.hbs`,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
type: 'add',
|
|
61
|
+
path: `${filePath}/services/{{ id }}.${language}`,
|
|
62
|
+
templateFile: `templates/${language}/service.${language}.hbs`,
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
if (answers.isPluginApi) {
|
|
66
|
+
return baseActions;
|
|
67
|
+
}
|
|
68
|
+
return [
|
|
69
|
+
{
|
|
70
|
+
type: 'add',
|
|
71
|
+
path: `${filePath}/routes/{{ id }}.${language}`,
|
|
72
|
+
templateFile: `templates/${language}/single-route.${language}.hbs`,
|
|
73
|
+
},
|
|
74
|
+
...baseActions,
|
|
75
|
+
];
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/plops/api.ts"],"names":[],"mappings":";;;;;AACA,+BAA4B;AAC5B,wDAA0B;AAC1B,gFAA+C;AAE/C,4EAAmD;AAEnD,kBAAe,CAAC,IAAiB,EAAE,EAAE;IACnC,gBAAgB;IAChB,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE;QACvB,WAAW,EAAE,sBAAsB;QACnC,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,IAAI;gBACV,OAAO,EAAE,UAAU;gBACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,wBAAa,EAAC,KAAK,CAAC;aAC1C;YACD;gBACE,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,aAAa;gBACnB,OAAO,EAAE,2BAA2B;aACrC;Y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E,KAAK;oBACX,IAAI,EAAE,GAAG,QAAQ,yBAAyB,QAAQ,EAAE;oBACpD,YAAY,EAAE,aAAa,QAAQ,eAAe,QAAQ,MAAM;iBACjE;gBACD;oBACE,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,GAAG,QAAQ,sBAAsB,QAAQ,EAAE;oBACjD,YAAY,EAAE,aAAa,QAAQ,YAAY,QAAQ,MAAM;iBAC9D;aACF,CAAC;YAEF,IAAI,OAAO,CAAC,WAAW,EAAE;gBACvB,OAAO,WAAW,CAAC;aACpB;YAED,OAAO;gBACL;oBACE,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,GAAG,QAAQ,oBAAoB,QAAQ,EAAE;oBAC/C,YAAY,EAAE,aAAa,QAAQ,iBAAiB,QAAQ,MAAM;iBACnE;gBACD,GAAG,WAAW;aACf,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const slugify_1 = __importDefault(require("@sindresorhus/slugify"));
|
|
8
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
|
+
const utils_1 = __importDefault(require("@strapi/utils"));
|
|
10
|
+
const typescript_utils_1 = __importDefault(require("@strapi/typescript-utils"));
|
|
11
|
+
const get_destination_prompts_1 = __importDefault(require("./prompts/get-destination-prompts"));
|
|
12
|
+
const get_file_path_1 = __importDefault(require("./utils/get-file-path"));
|
|
13
|
+
const ct_names_prompts_1 = __importDefault(require("./prompts/ct-names-prompts"));
|
|
14
|
+
const kind_prompts_1 = __importDefault(require("./prompts/kind-prompts"));
|
|
15
|
+
const draft_and_publish_prompts_1 = __importDefault(require("./prompts/draft-and-publish-prompts"));
|
|
16
|
+
const get_attributes_prompts_1 = __importDefault(require("./prompts/get-attributes-prompts"));
|
|
17
|
+
const bootstrap_api_prompts_1 = __importDefault(require("./prompts/bootstrap-api-prompts"));
|
|
18
|
+
exports.default = (plop) => {
|
|
19
|
+
// Model generator
|
|
20
|
+
plop.setGenerator('content-type', {
|
|
21
|
+
description: 'Generate a content type for an API',
|
|
22
|
+
async prompts(inquirer) {
|
|
23
|
+
const config = await inquirer.prompt([
|
|
24
|
+
...ct_names_prompts_1.default,
|
|
25
|
+
...kind_prompts_1.default,
|
|
26
|
+
...draft_and_publish_prompts_1.default,
|
|
27
|
+
]);
|
|
28
|
+
const attributes = await (0, get_attributes_prompts_1.default)(inquirer);
|
|
29
|
+
const api = await inquirer.prompt([
|
|
30
|
+
...(0, get_destination_prompts_1.default)('model', plop.getDestBasePath()),
|
|
31
|
+
{
|
|
32
|
+
when: (answers) => answers.destination === 'new',
|
|
33
|
+
type: 'input',
|
|
34
|
+
name: 'id',
|
|
35
|
+
default: config.singularName,
|
|
36
|
+
message: 'Name of the new API?',
|
|
37
|
+
async validate(input) {
|
|
38
|
+
if (!utils_1.default.isKebabCase(input)) {
|
|
39
|
+
return 'Value must be in kebab-case';
|
|
40
|
+
}
|
|
41
|
+
const apiPath = (0, path_1.join)(plop.getDestBasePath(), 'api');
|
|
42
|
+
const exists = await fs_extra_1.default.pathExists(apiPath);
|
|
43
|
+
if (!exists) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
const apiDir = await fs_extra_1.default.readdir(apiPath, { withFileTypes: true });
|
|
47
|
+
const apiDirContent = apiDir.filter((fd) => fd.isDirectory());
|
|
48
|
+
if (apiDirContent.findIndex((dir) => dir.name === input) !== -1) {
|
|
49
|
+
throw new Error('This name is already taken.');
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
...bootstrap_api_prompts_1.default,
|
|
55
|
+
]);
|
|
56
|
+
return {
|
|
57
|
+
...config,
|
|
58
|
+
...api,
|
|
59
|
+
attributes,
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
actions(answers) {
|
|
63
|
+
if (!answers) {
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
const attributes = answers.attributes.reduce((object, answer) => {
|
|
67
|
+
const val = { type: answer.attributeType };
|
|
68
|
+
if (answer.attributeType === 'enumeration') {
|
|
69
|
+
val.enum = answer.enum.split(',').map((item) => item.trim());
|
|
70
|
+
}
|
|
71
|
+
if (answer.attributeType === 'media') {
|
|
72
|
+
val.allowedTypes = ['images', 'files', 'videos', 'audios'];
|
|
73
|
+
val.multiple = answer.multiple;
|
|
74
|
+
}
|
|
75
|
+
return Object.assign(object, { [answer.attributeName]: val }, {});
|
|
76
|
+
}, {});
|
|
77
|
+
const filePath = (0, get_file_path_1.default)(answers.destination);
|
|
78
|
+
// TODO: use basePath instead
|
|
79
|
+
const currentDir = process.cwd();
|
|
80
|
+
const language = typescript_utils_1.default.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
|
81
|
+
const baseActions = [
|
|
82
|
+
{
|
|
83
|
+
type: 'add',
|
|
84
|
+
path: `${filePath}/content-types/{{ singularName }}/schema.json`,
|
|
85
|
+
templateFile: `templates/${language}/content-type.schema.json.hbs`,
|
|
86
|
+
data: {
|
|
87
|
+
collectionName: (0, slugify_1.default)(answers.pluralName, { separator: '_' }),
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
if (Object.entries(attributes).length > 0) {
|
|
92
|
+
baseActions.push({
|
|
93
|
+
type: 'modify',
|
|
94
|
+
path: `${filePath}/content-types/{{ singularName }}/schema.json`,
|
|
95
|
+
transform(template) {
|
|
96
|
+
const parsedTemplate = JSON.parse(template);
|
|
97
|
+
parsedTemplate.attributes = attributes;
|
|
98
|
+
return JSON.stringify(parsedTemplate, null, 2);
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (answers.bootstrapApi) {
|
|
103
|
+
const { singularName } = answers;
|
|
104
|
+
let uid;
|
|
105
|
+
if (answers.destination === 'new') {
|
|
106
|
+
uid = `api::${answers.id}.${singularName}`;
|
|
107
|
+
}
|
|
108
|
+
else if (answers.api) {
|
|
109
|
+
uid = `api::${answers.api}.${singularName}`;
|
|
110
|
+
}
|
|
111
|
+
else if (answers.plugin) {
|
|
112
|
+
uid = `plugin::${answers.plugin}.${singularName}`;
|
|
113
|
+
}
|
|
114
|
+
baseActions.push({
|
|
115
|
+
type: 'add',
|
|
116
|
+
path: `${filePath}/controllers/{{ singularName }}.${language}`,
|
|
117
|
+
templateFile: `templates/${language}/core-controller.${language}.hbs`,
|
|
118
|
+
data: { uid },
|
|
119
|
+
}, {
|
|
120
|
+
type: 'add',
|
|
121
|
+
path: `${filePath}/services/{{ singularName }}.${language}`,
|
|
122
|
+
templateFile: `templates/${language}/core-service.${language}.hbs`,
|
|
123
|
+
data: { uid },
|
|
124
|
+
}, {
|
|
125
|
+
type: 'add',
|
|
126
|
+
path: `${filePath}/routes/{{ singularName }}.${language}`,
|
|
127
|
+
templateFile: `templates/${language}/core-router.${language}.hbs`,
|
|
128
|
+
data: { uid },
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return baseActions;
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=content-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-type.js","sourceRoot":"","sources":["../../src/plops/content-type.ts"],"names":[],"mappings":";;;;;AACA,+BAA4B;AAC5B,oEAA4C;AAC5C,wDAA0B;AAC1B,0DAAkC;AAClC,gFAA+C;AAE/C,gGAAsE;AACtE,0EAAgD;AAChD,kFAAwD;AACxD,0EAAiD;AACjD,oGAAyE;AACzE,8FAAoE;AACpE,4FAAkE;AAElE,kBAAe,CAAC,IAAiB,EAAE,EAAE;IACnC,kBAAkB;IAClB,I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OAAO,CAAC,GAAG,IAAI,YAAY,EAAE,CAAC;iBAC7C;qBAAM,IAAI,OAAO,CAAC,MAAM,EAAE;oBACzB,GAAG,GAAG,WAAW,OAAO,CAAC,MAAM,IAAI,YAAY,EAAE,CAAC;iBACnD;gBAED,WAAW,CAAC,IAAI,CACd;oBACE,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,GAAG,QAAQ,mCAAmC,QAAQ,EAAE;oBAC9D,YAAY,EAAE,aAAa,QAAQ,oBAAoB,QAAQ,MAAM;oBACrE,IAAI,EAAE,EAAE,GAAG,EAAE;iBACd,EACD;oBACE,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,GAAG,QAAQ,gCAAgC,QAAQ,EAAE;oBAC3D,YAAY,EAAE,aAAa,QAAQ,iBAAiB,QAAQ,MAAM;oBAClE,IAAI,EAAE,EAAE,GAAG,EAAE;iBACd,EACD;oBACE,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,GAAG,QAAQ,8BAA8B,QAAQ,EAAE;oBACzD,YAAY,EAAE,aAAa,QAAQ,gBAAgB,QAAQ,MAAM;oBACjE,IAAI,EAAE,EAAE,GAAG,EAAE;iBACd,CACF,CAAC;aACH;YAED,OAAO,WAAW,CAAC;QACrB,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const typescript_utils_1 = __importDefault(require("@strapi/typescript-utils"));
|
|
7
|
+
const get_destination_prompts_1 = __importDefault(require("./prompts/get-destination-prompts"));
|
|
8
|
+
const get_file_path_1 = __importDefault(require("./utils/get-file-path"));
|
|
9
|
+
const validate_input_1 = __importDefault(require("./utils/validate-input"));
|
|
10
|
+
exports.default = (plop) => {
|
|
11
|
+
// Controller generator
|
|
12
|
+
plop.setGenerator('controller', {
|
|
13
|
+
description: 'Generate a controller for an API',
|
|
14
|
+
prompts: [
|
|
15
|
+
{
|
|
16
|
+
type: 'input',
|
|
17
|
+
name: 'id',
|
|
18
|
+
message: 'Controller name',
|
|
19
|
+
validate: (input) => (0, validate_input_1.default)(input),
|
|
20
|
+
},
|
|
21
|
+
...(0, get_destination_prompts_1.default)('controller', plop.getDestBasePath()),
|
|
22
|
+
],
|
|
23
|
+
actions(answers) {
|
|
24
|
+
if (!answers) {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
const filePath = (0, get_file_path_1.default)(answers.destination);
|
|
28
|
+
const currentDir = process.cwd();
|
|
29
|
+
const language = typescript_utils_1.default.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
|
30
|
+
return [
|
|
31
|
+
{
|
|
32
|
+
type: 'add',
|
|
33
|
+
path: `${filePath}/controllers/{{ id }}.${language}`,
|
|
34
|
+
templateFile: `templates/${language}/controller.${language}.hbs`,
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../src/plops/controller.ts"],"names":[],"mappings":";;;;;AACA,gFAA+C;AAE/C,gGAAsE;AACtE,0EAAgD;AAChD,4EAAmD;AAEnD,kBAAe,CAAC,IAAiB,EAAE,EAAE;IACnC,uBAAuB;IACvB,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE;QAC9B,WAAW,EAAE,kCAAkC;QAC/C,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,IAAI;gBACV,OAAO,EAAE,iBAAiB;gBAC1B,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,wBAAa,EAAC,KAAK,CAAC;aAC1C;YACD,GAAG,IAAA,iCAAqB,EAAC,YAAY,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC;SAC/D;QACD,OAAO,CAAC,OAAO;YACb,IAAI,CAAC,OAAO,EAAE;gBACZ,OAAO,EAAE,CAAC;aACX;YAED,MAAM,QAAQ,GAAG,IAAA,uBAAW,EAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAClD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;YACjC,MAAM,QAAQ,GAAG,0BAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;YAEzE,OAAO;gBACL;oBACE,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,GAAG,QAAQ,yBAAyB,QAAQ,EAAE;oBACpD,YAAY,EAAE,aAAa,QAAQ,eAAe,QAAQ,MAAM;iBACjE;aACF,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const typescript_utils_1 = __importDefault(require("@strapi/typescript-utils"));
|
|
7
|
+
const get_destination_prompts_1 = __importDefault(require("./prompts/get-destination-prompts"));
|
|
8
|
+
const validate_input_1 = __importDefault(require("./utils/validate-input"));
|
|
9
|
+
const get_file_path_1 = __importDefault(require("./utils/get-file-path"));
|
|
10
|
+
exports.default = (plop) => {
|
|
11
|
+
// middleware generator
|
|
12
|
+
plop.setGenerator('middleware', {
|
|
13
|
+
description: 'Generate a middleware for an API',
|
|
14
|
+
prompts: [
|
|
15
|
+
{
|
|
16
|
+
type: 'input',
|
|
17
|
+
name: 'name',
|
|
18
|
+
message: 'Middleware name',
|
|
19
|
+
validate: (input) => (0, validate_input_1.default)(input),
|
|
20
|
+
},
|
|
21
|
+
...(0, get_destination_prompts_1.default)('middleware', plop.getDestBasePath(), { rootFolder: true }),
|
|
22
|
+
],
|
|
23
|
+
actions(answers) {
|
|
24
|
+
if (!answers) {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
const filePath = (0, get_file_path_1.default)(answers.destination);
|
|
28
|
+
const currentDir = process.cwd();
|
|
29
|
+
const language = typescript_utils_1.default.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
|
30
|
+
return [
|
|
31
|
+
{
|
|
32
|
+
type: 'add',
|
|
33
|
+
path: `${filePath}/middlewares/{{ name }}.${language}`,
|
|
34
|
+
templateFile: `templates/${language}/middleware.${language}.hbs`,
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/plops/middleware.ts"],"names":[],"mappings":";;;;;AACA,gFAA+C;AAE/C,gGAAsE;AACtE,4EAAmD;AACnD,0EAAgD;AAEhD,kBAAe,CAAC,IAAiB,EAAE,EAAE;IACnC,uBAAuB;IACvB,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE;QAC9B,WAAW,EAAE,kCAAkC;QAC/C,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,iBAAiB;gBAC1B,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,wBAAa,EAAC,KAAK,CAAC;aAC1C;YACD,GAAG,IAAA,iCAAqB,EAAC,YAAY,EAAE,IAAI,CAAC,eAAe,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;SACrF;QACD,OAAO,CAAC,OAAO;YACb,IAAI,CAAC,OAAO,EAAE;gBACZ,OAAO,EAAE,CAAC;aACX;YAED,MAAM,QAAQ,GAAG,IAAA,uBAAW,EAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAClD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;YACjC,MAAM,QAAQ,GAAG,0BAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;YAEzE,OAAO;gBACL;oBACE,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,GAAG,QAAQ,2BAA2B,QAAQ,EAAE;oBACtD,YAAY,EAAE,aAAa,QAAQ,eAAe,QAAQ,MAAM;iBACjE;aACF,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC"}
|