@strapi/generators 0.0.0-e6cac9fe30 → 0.0.0-fd8e4c6bfa
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/ts/plugin/server/bootstrap.ts +1 -1
- package/lib/files/ts/plugin/server/controllers/my-controller.ts.hbs +1 -1
- package/lib/files/ts/plugin/server/destroy.ts +1 -1
- package/lib/files/ts/plugin/server/register.ts +1 -1
- package/lib/files/ts/plugin/server/services/my-service.ts +1 -1
- package/lib/plops/api.js +5 -4
- package/lib/plops/content-type.js +3 -3
- package/lib/plops/policy.js +1 -1
- package/lib/templates/js/collection-type-routes.js.hbs +10 -10
- package/lib/templates/js/controller.js.hbs +1 -1
- package/lib/templates/js/core-controller.js.hbs +1 -1
- package/lib/templates/js/core-router.js.hbs +1 -1
- package/lib/templates/js/core-service.js.hbs +1 -1
- package/lib/templates/js/middleware.js.hbs +1 -1
- package/lib/templates/js/policy.js.hbs +2 -2
- package/lib/templates/js/service.js.hbs +1 -1
- package/lib/templates/js/single-route.js.hbs +2 -2
- package/lib/templates/js/single-type-routes.js.hbs +6 -6
- package/lib/templates/ts/collection-type-routes.ts.hbs +10 -10
- package/lib/templates/ts/controller.ts.hbs +1 -1
- package/lib/templates/ts/core-controller.ts.hbs +1 -1
- package/lib/templates/ts/core-router.ts.hbs +1 -1
- package/lib/templates/ts/core-service.ts.hbs +1 -1
- package/lib/templates/ts/middleware.ts.hbs +2 -2
- package/lib/templates/ts/plugin-package.json.hbs +2 -3
- package/lib/templates/ts/policy.ts.hbs +2 -2
- package/lib/templates/ts/service.ts.hbs +1 -1
- package/lib/templates/ts/single-route.ts.hbs +2 -2
- package/lib/templates/ts/single-type-routes.ts.hbs +6 -6
- package/package.json +4 -4
package/lib/plops/api.js
CHANGED
|
@@ -47,19 +47,20 @@ module.exports = (plop) => {
|
|
|
47
47
|
},
|
|
48
48
|
],
|
|
49
49
|
actions(answers) {
|
|
50
|
-
const filePath =
|
|
50
|
+
const filePath =
|
|
51
|
+
answers.isPluginApi && answers.plugin ? 'plugins/{{ plugin }}' : 'api/{{ id }}';
|
|
51
52
|
const currentDir = process.cwd();
|
|
52
53
|
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
|
53
54
|
|
|
54
55
|
const baseActions = [
|
|
55
56
|
{
|
|
56
57
|
type: 'add',
|
|
57
|
-
path: `${filePath}/controllers/{{id}}.${language}`,
|
|
58
|
+
path: `${filePath}/controllers/{{ id }}.${language}`,
|
|
58
59
|
templateFile: `templates/${language}/controller.${language}.hbs`,
|
|
59
60
|
},
|
|
60
61
|
{
|
|
61
62
|
type: 'add',
|
|
62
|
-
path: `${filePath}/services/{{id}}.${language}`,
|
|
63
|
+
path: `${filePath}/services/{{ id }}.${language}`,
|
|
63
64
|
templateFile: `templates/${language}/service.${language}.hbs`,
|
|
64
65
|
},
|
|
65
66
|
];
|
|
@@ -71,7 +72,7 @@ module.exports = (plop) => {
|
|
|
71
72
|
return [
|
|
72
73
|
{
|
|
73
74
|
type: 'add',
|
|
74
|
-
path: `${filePath}/routes/{{id}}.${language}`,
|
|
75
|
+
path: `${filePath}/routes/{{ id }}.${language}`,
|
|
75
76
|
templateFile: `templates/${language}/single-route.${language}.hbs`,
|
|
76
77
|
},
|
|
77
78
|
...baseActions,
|
|
@@ -123,19 +123,19 @@ module.exports = (plop) => {
|
|
|
123
123
|
baseActions.push(
|
|
124
124
|
{
|
|
125
125
|
type: 'add',
|
|
126
|
-
path: `${filePath}/controllers/{{singularName}}.${language}`,
|
|
126
|
+
path: `${filePath}/controllers/{{ singularName }}.${language}`,
|
|
127
127
|
templateFile: `templates/${language}/core-controller.${language}.hbs`,
|
|
128
128
|
data: { uid },
|
|
129
129
|
},
|
|
130
130
|
{
|
|
131
131
|
type: 'add',
|
|
132
|
-
path: `${filePath}/services/{{singularName}}.${language}`,
|
|
132
|
+
path: `${filePath}/services/{{ singularName }}.${language}`,
|
|
133
133
|
templateFile: `templates/${language}/core-service.${language}.hbs`,
|
|
134
134
|
data: { uid },
|
|
135
135
|
},
|
|
136
136
|
{
|
|
137
137
|
type: 'add',
|
|
138
|
-
path: `${filePath}/routes/{{singularName}}.${language}`,
|
|
138
|
+
path: `${filePath}/routes/{{ singularName }}.${language}`,
|
|
139
139
|
templateFile: `templates/${language}/core-router.${language}.hbs`,
|
|
140
140
|
data: { uid },
|
|
141
141
|
}
|
package/lib/plops/policy.js
CHANGED
|
@@ -2,8 +2,8 @@ module.exports = {
|
|
|
2
2
|
routes: [
|
|
3
3
|
{
|
|
4
4
|
method: 'GET',
|
|
5
|
-
path: '/{{pluralize id}}',
|
|
6
|
-
handler: '{{id}}.find',
|
|
5
|
+
path: '/{{ pluralize id }}',
|
|
6
|
+
handler: '{{ id }}.find',
|
|
7
7
|
config: {
|
|
8
8
|
policies: [],
|
|
9
9
|
middlewares: [],
|
|
@@ -11,8 +11,8 @@ module.exports = {
|
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
13
|
method: 'GET',
|
|
14
|
-
path: '/{{pluralize id}}/:id',
|
|
15
|
-
handler: '{{id}}.findOne',
|
|
14
|
+
path: '/{{ pluralize id }}/:id',
|
|
15
|
+
handler: '{{ id }}.findOne',
|
|
16
16
|
config: {
|
|
17
17
|
policies: [],
|
|
18
18
|
middlewares: [],
|
|
@@ -20,8 +20,8 @@ module.exports = {
|
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
method: 'POST',
|
|
23
|
-
path: '/{{pluralize id}}',
|
|
24
|
-
handler: '{{id}}.create',
|
|
23
|
+
path: '/{{ pluralize id }}',
|
|
24
|
+
handler: '{{ id }}.create',
|
|
25
25
|
config: {
|
|
26
26
|
policies: [],
|
|
27
27
|
middlewares: [],
|
|
@@ -29,8 +29,8 @@ module.exports = {
|
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
method: 'PUT',
|
|
32
|
-
path: '/{{pluralize id}}/:id',
|
|
33
|
-
handler: '{{id}}.update',
|
|
32
|
+
path: '/{{ pluralize id }}/:id',
|
|
33
|
+
handler: '{{ id }}.update',
|
|
34
34
|
config: {
|
|
35
35
|
policies: [],
|
|
36
36
|
middlewares: [],
|
|
@@ -38,8 +38,8 @@ module.exports = {
|
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
40
|
method: 'DELETE',
|
|
41
|
-
path: '/{{pluralize id}}/:id',
|
|
42
|
-
handler: '{{id}}.delete',
|
|
41
|
+
path: '/{{ pluralize id }}/:id',
|
|
42
|
+
handler: '{{ id }}.delete',
|
|
43
43
|
config: {
|
|
44
44
|
policies: [],
|
|
45
45
|
middlewares: [],
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* `{{id}}` policy
|
|
4
|
+
* `{{ id }}` policy
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
module.exports = (policyContext, config, { strapi }) => {
|
|
8
8
|
// Add your own logic here.
|
|
9
|
-
strapi.log.info('In {{id}} policy.');
|
|
9
|
+
strapi.log.info('In {{ id }} policy.');
|
|
10
10
|
|
|
11
11
|
const canDoSomething = true;
|
|
12
12
|
|
|
@@ -4,8 +4,8 @@ module.exports = {
|
|
|
4
4
|
routes: [
|
|
5
5
|
{
|
|
6
6
|
method: 'GET',
|
|
7
|
-
path: '/{{id}}',
|
|
8
|
-
handler: '{{id}}.find',
|
|
7
|
+
path: '/{{ id }}',
|
|
8
|
+
handler: '{{ id }}.find',
|
|
9
9
|
config: {
|
|
10
10
|
policies: [],
|
|
11
11
|
middlewares: [],
|
|
@@ -13,8 +13,8 @@ module.exports = {
|
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
method: 'PUT',
|
|
16
|
-
path: '/{{id}}',
|
|
17
|
-
handler: '{{id}}.update',
|
|
16
|
+
path: '/{{ id }}',
|
|
17
|
+
handler: '{{ id }}.update',
|
|
18
18
|
config: {
|
|
19
19
|
policies: [],
|
|
20
20
|
middlewares: [],
|
|
@@ -22,8 +22,8 @@ module.exports = {
|
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
method: 'DELETE',
|
|
25
|
-
path: '/{{id}}',
|
|
26
|
-
handler: '{{id}}.delete',
|
|
25
|
+
path: '/{{ id }}',
|
|
26
|
+
handler: '{{ id }}.delete',
|
|
27
27
|
config: {
|
|
28
28
|
policies: [],
|
|
29
29
|
middlewares: [],
|
|
@@ -2,8 +2,8 @@ export default {
|
|
|
2
2
|
routes: [
|
|
3
3
|
{
|
|
4
4
|
method: 'GET',
|
|
5
|
-
path: '/{{pluralize id}}',
|
|
6
|
-
handler: '{{id}}.find',
|
|
5
|
+
path: '/{{ pluralize id }}',
|
|
6
|
+
handler: '{{ id }}.find',
|
|
7
7
|
config: {
|
|
8
8
|
policies: [],
|
|
9
9
|
middlewares: [],
|
|
@@ -11,8 +11,8 @@ export default {
|
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
13
|
method: 'GET',
|
|
14
|
-
path: '/{{pluralize id}}/:id',
|
|
15
|
-
handler: '{{id}}.findOne',
|
|
14
|
+
path: '/{{ pluralize id }}/:id',
|
|
15
|
+
handler: '{{ id }}.findOne',
|
|
16
16
|
config: {
|
|
17
17
|
policies: [],
|
|
18
18
|
middlewares: [],
|
|
@@ -20,8 +20,8 @@ export default {
|
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
method: 'POST',
|
|
23
|
-
path: '/{{pluralize id}}',
|
|
24
|
-
handler: '{{id}}.create',
|
|
23
|
+
path: '/{{ pluralize id }}',
|
|
24
|
+
handler: '{{ id }}.create',
|
|
25
25
|
config: {
|
|
26
26
|
policies: [],
|
|
27
27
|
middlewares: [],
|
|
@@ -29,8 +29,8 @@ export default {
|
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
method: 'PUT',
|
|
32
|
-
path: '/{{pluralize id}}/:id',
|
|
33
|
-
handler: '{{id}}.update',
|
|
32
|
+
path: '/{{ pluralize id }}/:id',
|
|
33
|
+
handler: '{{ id }}.update',
|
|
34
34
|
config: {
|
|
35
35
|
policies: [],
|
|
36
36
|
middlewares: [],
|
|
@@ -38,8 +38,8 @@ export default {
|
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
40
|
method: 'DELETE',
|
|
41
|
-
path: '/{{pluralize id}}/:id',
|
|
42
|
-
handler: '{{id}}.delete',
|
|
41
|
+
path: '/{{ pluralize id }}/:id',
|
|
42
|
+
handler: '{{ id }}.delete',
|
|
43
43
|
config: {
|
|
44
44
|
policies: [],
|
|
45
45
|
middlewares: [],
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"typescript": "4.6.3"
|
|
13
|
-
"@strapi/strapi": "4.1.8"
|
|
12
|
+
"typescript": "4.6.3"
|
|
14
13
|
},
|
|
15
14
|
"author": {
|
|
16
15
|
"name": "A Strapi developer"
|
|
@@ -21,7 +20,7 @@
|
|
|
21
20
|
}
|
|
22
21
|
],
|
|
23
22
|
"engines": {
|
|
24
|
-
"node": ">=
|
|
23
|
+
"node": ">=14.19.1 <=16.x.x",
|
|
25
24
|
"npm": ">=6.0.0"
|
|
26
25
|
},
|
|
27
26
|
"scripts": {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* {{ id }} policy
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
export default (policyContext, config, { strapi }) => {
|
|
6
6
|
// Add your own logic here.
|
|
7
|
-
strapi.log.info('In {{id}} policy.');
|
|
7
|
+
strapi.log.info('In {{ id }} policy.');
|
|
8
8
|
|
|
9
9
|
const canDoSomething = true;
|
|
10
10
|
|
|
@@ -2,8 +2,8 @@ export default {
|
|
|
2
2
|
routes: [
|
|
3
3
|
{
|
|
4
4
|
method: 'GET',
|
|
5
|
-
path: '/{{id}}',
|
|
6
|
-
handler: '{{id}}.find',
|
|
5
|
+
path: '/{{ id }}',
|
|
6
|
+
handler: '{{ id }}.find',
|
|
7
7
|
config: {
|
|
8
8
|
policies: [],
|
|
9
9
|
middlewares: [],
|
|
@@ -11,8 +11,8 @@ export default {
|
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
13
|
method: 'PUT',
|
|
14
|
-
path: '/{{id}}',
|
|
15
|
-
handler: '{{id}}.update',
|
|
14
|
+
path: '/{{ id }}',
|
|
15
|
+
handler: '{{ id }}.update',
|
|
16
16
|
config: {
|
|
17
17
|
policies: [],
|
|
18
18
|
middlewares: [],
|
|
@@ -20,8 +20,8 @@ export default {
|
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
method: 'DELETE',
|
|
23
|
-
path: '/{{id}}',
|
|
24
|
-
handler: '{{id}}.delete',
|
|
23
|
+
path: '/{{ id }}',
|
|
24
|
+
handler: '{{ id }}.delete',
|
|
25
25
|
config: {
|
|
26
26
|
policies: [],
|
|
27
27
|
middlewares: [],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/generators",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-fd8e4c6bfa",
|
|
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": "0.0.0-
|
|
34
|
-
"@strapi/utils": "0.0.0-
|
|
33
|
+
"@strapi/typescript-utils": "0.0.0-fd8e4c6bfa",
|
|
34
|
+
"@strapi/utils": "0.0.0-fd8e4c6bfa",
|
|
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 <=16.x.x",
|
|
43
43
|
"npm": ">=6.0.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "fd8e4c6bfa2fd687a3c62f8428e00f3b320c32c2"
|
|
46
46
|
}
|