@strapi/generators 4.10.1-experimental.0 → 4.10.2-alpha.0

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.
Files changed (109) hide show
  1. package/dist/files/js/plugin/.editorconfig +7 -0
  2. package/dist/files/js/plugin/.gitattributes +103 -0
  3. package/dist/files/ts/plugin/.editorconfig +7 -0
  4. package/dist/files/ts/plugin/.gitattributes +103 -0
  5. package/package.json +22 -5
  6. package/.eslintignore +0 -3
  7. package/.eslintrc.js +0 -4
  8. package/lib/files/js/plugin/admin/src/components/Initializer/index.js +0 -26
  9. package/lib/files/js/plugin/admin/src/components/PluginIcon/index.js +0 -12
  10. package/lib/files/js/plugin/admin/src/index.js +0 -63
  11. package/lib/files/js/plugin/admin/src/pages/App/index.js +0 -25
  12. package/lib/files/js/plugin/admin/src/pages/HomePage/index.js +0 -20
  13. package/lib/files/js/plugin/admin/src/pluginId.js +0 -5
  14. package/lib/files/js/plugin/admin/src/translations/en.json +0 -1
  15. package/lib/files/js/plugin/admin/src/translations/fr.json +0 -1
  16. package/lib/files/js/plugin/admin/src/utils/getTrad.js +0 -5
  17. package/lib/files/js/plugin/server/bootstrap.js +0 -5
  18. package/lib/files/js/plugin/server/config/index.js +0 -6
  19. package/lib/files/js/plugin/server/content-types/index.js +0 -3
  20. package/lib/files/js/plugin/server/controllers/index.js +0 -7
  21. package/lib/files/js/plugin/server/controllers/my-controller.js.hbs +0 -10
  22. package/lib/files/js/plugin/server/destroy.js +0 -5
  23. package/lib/files/js/plugin/server/index.js +0 -25
  24. package/lib/files/js/plugin/server/middlewares/index.js +0 -3
  25. package/lib/files/js/plugin/server/policies/index.js +0 -3
  26. package/lib/files/js/plugin/server/register.js +0 -5
  27. package/lib/files/js/plugin/server/routes/index.js +0 -10
  28. package/lib/files/js/plugin/server/services/index.js +0 -7
  29. package/lib/files/js/plugin/server/services/my-service.js +0 -7
  30. package/lib/files/js/plugin/strapi-admin.js +0 -3
  31. package/lib/files/js/plugin/strapi-server.js +0 -3
  32. package/lib/files/ts/plugin/admin/src/components/Initializer/index.tsx +0 -24
  33. package/lib/files/ts/plugin/admin/src/components/PluginIcon/index.tsx +0 -12
  34. package/lib/files/ts/plugin/admin/src/index.tsx +0 -67
  35. package/lib/files/ts/plugin/admin/src/pages/App/index.tsx +0 -25
  36. package/lib/files/ts/plugin/admin/src/pages/HomePage/index.tsx +0 -19
  37. package/lib/files/ts/plugin/admin/src/pluginId.ts +0 -5
  38. package/lib/files/ts/plugin/admin/src/translations/en.json +0 -1
  39. package/lib/files/ts/plugin/admin/src/translations/fr.json +0 -1
  40. package/lib/files/ts/plugin/admin/src/utils/getTrad.ts +0 -5
  41. package/lib/files/ts/plugin/custom.d.ts +0 -5
  42. package/lib/files/ts/plugin/server/bootstrap.ts +0 -5
  43. package/lib/files/ts/plugin/server/config/index.ts +0 -4
  44. package/lib/files/ts/plugin/server/content-types/index.ts +0 -1
  45. package/lib/files/ts/plugin/server/controllers/index.ts +0 -5
  46. package/lib/files/ts/plugin/server/controllers/my-controller.ts.hbs +0 -10
  47. package/lib/files/ts/plugin/server/destroy.ts +0 -5
  48. package/lib/files/ts/plugin/server/index.ts +0 -23
  49. package/lib/files/ts/plugin/server/middlewares/index.ts +0 -1
  50. package/lib/files/ts/plugin/server/policies/index.ts +0 -1
  51. package/lib/files/ts/plugin/server/register.ts +0 -5
  52. package/lib/files/ts/plugin/server/routes/index.ts +0 -10
  53. package/lib/files/ts/plugin/server/services/index.ts +0 -5
  54. package/lib/files/ts/plugin/server/services/my-service.ts +0 -7
  55. package/lib/files/ts/plugin/strapi-admin.js +0 -3
  56. package/lib/files/ts/plugin/strapi-server.js +0 -3
  57. package/lib/files/ts/plugin/tsconfig.json +0 -20
  58. package/lib/files/ts/plugin/tsconfig.server.json +0 -25
  59. package/lib/index.js +0 -37
  60. package/lib/plopfile.js +0 -28
  61. package/lib/plops/__tests__/content-type.test.js +0 -179
  62. package/lib/plops/api.js +0 -82
  63. package/lib/plops/content-type.js +0 -148
  64. package/lib/plops/controller.js +0 -36
  65. package/lib/plops/middleware.js +0 -36
  66. package/lib/plops/migration.js +0 -33
  67. package/lib/plops/plugin.js +0 -91
  68. package/lib/plops/policy.js +0 -36
  69. package/lib/plops/prompts/bootstrap-api-prompts.js +0 -10
  70. package/lib/plops/prompts/ct-names-prompts.js +0 -44
  71. package/lib/plops/prompts/draft-and-publish-prompts.js +0 -10
  72. package/lib/plops/prompts/get-attributes-prompts.js +0 -105
  73. package/lib/plops/prompts/get-destination-prompts.js +0 -79
  74. package/lib/plops/prompts/kind-prompts.js +0 -17
  75. package/lib/plops/service.js +0 -34
  76. package/lib/plops/utils/__tests__/get-file-path.test.js +0 -25
  77. package/lib/plops/utils/get-file-path.js +0 -17
  78. package/lib/plops/utils/get-formatted-date.js +0 -8
  79. package/lib/plops/utils/validate-attribute-input.js +0 -11
  80. package/lib/plops/utils/validate-file-name-input.js +0 -11
  81. package/lib/plops/utils/validate-input.js +0 -11
  82. package/lib/templates/js/README.md.hbs +0 -3
  83. package/lib/templates/js/collection-type-routes.js.hbs +0 -49
  84. package/lib/templates/js/content-type.schema.json.hbs +0 -15
  85. package/lib/templates/js/controller.js.hbs +0 -15
  86. package/lib/templates/js/core-controller.js.hbs +0 -9
  87. package/lib/templates/js/core-router.js.hbs +0 -9
  88. package/lib/templates/js/core-service.js.hbs +0 -9
  89. package/lib/templates/js/middleware.js.hbs +0 -14
  90. package/lib/templates/js/migration.js.hbs +0 -15
  91. package/lib/templates/js/plugin-package.json.hbs +0 -42
  92. package/lib/templates/js/policy.js.hbs +0 -18
  93. package/lib/templates/js/service.js.hbs +0 -7
  94. package/lib/templates/js/single-route.js.hbs +0 -13
  95. package/lib/templates/js/single-type-routes.js.hbs +0 -33
  96. package/lib/templates/ts/README.md.hbs +0 -3
  97. package/lib/templates/ts/collection-type-routes.ts.hbs +0 -49
  98. package/lib/templates/ts/content-type.schema.json.hbs +0 -15
  99. package/lib/templates/ts/controller.ts.hbs +0 -13
  100. package/lib/templates/ts/core-controller.ts.hbs +0 -7
  101. package/lib/templates/ts/core-router.ts.hbs +0 -7
  102. package/lib/templates/ts/core-service.ts.hbs +0 -7
  103. package/lib/templates/ts/middleware.ts.hbs +0 -14
  104. package/lib/templates/ts/migration.ts.hbs +0 -11
  105. package/lib/templates/ts/plugin-package.json.hbs +0 -51
  106. package/lib/templates/ts/policy.ts.hbs +0 -16
  107. package/lib/templates/ts/service.ts.hbs +0 -5
  108. package/lib/templates/ts/single-route.ts.hbs +0 -13
  109. package/lib/templates/ts/single-type-routes.ts.hbs +0 -31
@@ -1,25 +0,0 @@
1
- 'use strict';
2
-
3
- const getFilePath = require('../get-file-path');
4
-
5
- describe('Get-File-Path util', () => {
6
- test('with destination set as api', () => {
7
- const filePath = getFilePath('api');
8
- expect(filePath).toBe(`api/{{ api }}`);
9
- });
10
-
11
- test('with destination set as plugin', () => {
12
- const filePath = getFilePath('plugin');
13
- expect(filePath).toBe(`plugins/{{ plugin }}/server`);
14
- });
15
-
16
- test('with destination set as root', () => {
17
- const filePath = getFilePath('root');
18
- expect(filePath).toBe(`./`);
19
- });
20
-
21
- test('with empty destination string', () => {
22
- const filePath = getFilePath('');
23
- expect(filePath).toBe(`api/{{ id }}`);
24
- });
25
- });
@@ -1,17 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = (destination) => {
4
- if (destination === 'api') {
5
- return `api/{{ api }}`;
6
- }
7
-
8
- if (destination === 'plugin') {
9
- return `plugins/{{ plugin }}/server`;
10
- }
11
-
12
- if (destination === 'root') {
13
- return './';
14
- }
15
-
16
- return `api/{{ id }}`;
17
- };
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = (date = new Date()) => {
4
- return new Date(date.getTime() - date.getTimezoneOffset() * 60000)
5
- .toJSON()
6
- .replace(/[-:]/g, '.')
7
- .replace(/\....Z/, '');
8
- };
@@ -1,11 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = (input) => {
4
- const regex = /^[A-Za-z-|_]+$/g;
5
-
6
- if (!input) {
7
- return 'You must provide an input';
8
- }
9
-
10
- return regex.test(input) || "Please use only letters, '-', '_', and no spaces";
11
- };
@@ -1,11 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = (input) => {
4
- const regex = /^[A-Za-z-_0-9]+$/g;
5
-
6
- if (!input) {
7
- return 'You must provide an input';
8
- }
9
-
10
- return regex.test(input) || "Please use only letters and number, '-' or '_' and no spaces";
11
- };
@@ -1,11 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = (input) => {
4
- const regex = /^[A-Za-z-]+$/g;
5
-
6
- if (!input) {
7
- return 'You must provide an input';
8
- }
9
-
10
- return regex.test(input) || "Please use only letters, '-' and no spaces";
11
- };
@@ -1,3 +0,0 @@
1
- # Strapi plugin {{ pluginName }}
2
-
3
- A quick description of {{ pluginName }}.
@@ -1,49 +0,0 @@
1
- module.exports = {
2
- routes: [
3
- {
4
- method: 'GET',
5
- path: '/{{ pluralize id }}',
6
- handler: '{{ id }}.find',
7
- config: {
8
- policies: [],
9
- middlewares: [],
10
- },
11
- },
12
- {
13
- method: 'GET',
14
- path: '/{{ pluralize id }}/:id',
15
- handler: '{{ id }}.findOne',
16
- config: {
17
- policies: [],
18
- middlewares: [],
19
- },
20
- },
21
- {
22
- method: 'POST',
23
- path: '/{{ pluralize id }}',
24
- handler: '{{ id }}.create',
25
- config: {
26
- policies: [],
27
- middlewares: [],
28
- },
29
- },
30
- {
31
- method: 'PUT',
32
- path: '/{{ pluralize id }}/:id',
33
- handler: '{{ id }}.update',
34
- config: {
35
- policies: [],
36
- middlewares: [],
37
- },
38
- },
39
- {
40
- method: 'DELETE',
41
- path: '/{{ pluralize id }}/:id',
42
- handler: '{{ id }}.delete',
43
- config: {
44
- policies: [],
45
- middlewares: [],
46
- },
47
- },
48
- ],
49
- };
@@ -1,15 +0,0 @@
1
-
2
- {
3
- "kind": "{{kind}}",
4
- "collectionName": "{{ collectionName }}",
5
- "info": {
6
- "singularName": "{{ singularName }}",
7
- "pluralName": "{{ pluralName }}",
8
- "displayName": "{{ displayName }}"
9
- },
10
- "options": {
11
- "draftAndPublish": {{ useDraftAndPublish }},
12
- "comment": ""
13
- },
14
- "attributes": {}
15
- }
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * A set of functions called "actions" for `{{ id }}`
5
- */
6
-
7
- module.exports = {
8
- // exampleAction: async (ctx, next) => {
9
- // try {
10
- // ctx.body = 'ok';
11
- // } catch (err) {
12
- // ctx.body = err;
13
- // }
14
- // }
15
- };
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * {{ id }} controller
5
- */
6
-
7
- const { createCoreController } = require('@strapi/strapi').factories;
8
-
9
- module.exports = createCoreController('{{ uid }}');
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * {{ id }} router
5
- */
6
-
7
- const { createCoreRouter } = require('@strapi/strapi').factories;
8
-
9
- module.exports = createCoreRouter('{{ uid }}');
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * {{ id }} service
5
- */
6
-
7
- const { createCoreService } = require('@strapi/strapi').factories;
8
-
9
- module.exports = createCoreService('{{ uid }}');
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * `{{ name }}` middleware
5
- */
6
-
7
- module.exports = (config, { strapi }) => {
8
- // Add your own logic here.
9
- return async (ctx, next) => {
10
- strapi.log.info('In {{ name }} middleware.');
11
-
12
- await next();
13
- };
14
- };
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Migration `{{ name }}`
5
- */
6
-
7
- module.exports = {
8
- /**
9
- *
10
- * @param {import('knex').Knex} knex
11
- */
12
- async up(knex) {
13
-
14
- },
15
- };
@@ -1,42 +0,0 @@
1
- {
2
- "name": "{{ pluginName }}",
3
- "version": "0.0.0",
4
- "description": "This is the description of the plugin.",
5
- "strapi": {
6
- "name": "{{ pluginName }}",
7
- "description": "Description of {{titleCase pluginName }} plugin",
8
- "kind": "plugin",
9
- "displayName": "{{titleCase pluginName }}"
10
- },
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
- },
29
- "author": {
30
- "name": "A Strapi developer"
31
- },
32
- "maintainers": [
33
- {
34
- "name": "A Strapi developer"
35
- }
36
- ],
37
- "engines": {
38
- "node": ">=14.19.1 <=18.x.x",
39
- "npm": ">=6.0.0"
40
- },
41
- "license": "MIT"
42
- }
@@ -1,18 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * `{{ id }}` policy
5
- */
6
-
7
- module.exports = (policyContext, config, { strapi }) => {
8
- // Add your own logic here.
9
- strapi.log.info('In {{ id }} policy.');
10
-
11
- const canDoSomething = true;
12
-
13
- if (canDoSomething) {
14
- return true;
15
- }
16
-
17
- return false;
18
- };
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * {{ id }} service
5
- */
6
-
7
- module.exports = () => ({});
@@ -1,13 +0,0 @@
1
- module.exports = {
2
- routes: [
3
- // {
4
- // method: 'GET',
5
- // path: '/{{ id }}',
6
- // handler: '{{ id }}.exampleAction',
7
- // config: {
8
- // policies: [],
9
- // middlewares: [],
10
- // },
11
- // },
12
- ],
13
- };
@@ -1,33 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- routes: [
5
- {
6
- method: 'GET',
7
- path: '/{{ id }}',
8
- handler: '{{ id }}.find',
9
- config: {
10
- policies: [],
11
- middlewares: [],
12
- },
13
- },
14
- {
15
- method: 'PUT',
16
- path: '/{{ id }}',
17
- handler: '{{ id }}.update',
18
- config: {
19
- policies: [],
20
- middlewares: [],
21
- },
22
- },
23
- {
24
- method: 'DELETE',
25
- path: '/{{ id }}',
26
- handler: '{{ id }}.delete',
27
- config: {
28
- policies: [],
29
- middlewares: [],
30
- },
31
- },
32
- ],
33
- };
@@ -1,3 +0,0 @@
1
- # Strapi plugin {{ pluginName }}
2
-
3
- A quick description of {{ pluginName }}.
@@ -1,49 +0,0 @@
1
- export default {
2
- routes: [
3
- {
4
- method: 'GET',
5
- path: '/{{ pluralize id }}',
6
- handler: '{{ id }}.find',
7
- config: {
8
- policies: [],
9
- middlewares: [],
10
- },
11
- },
12
- {
13
- method: 'GET',
14
- path: '/{{ pluralize id }}/:id',
15
- handler: '{{ id }}.findOne',
16
- config: {
17
- policies: [],
18
- middlewares: [],
19
- },
20
- },
21
- {
22
- method: 'POST',
23
- path: '/{{ pluralize id }}',
24
- handler: '{{ id }}.create',
25
- config: {
26
- policies: [],
27
- middlewares: [],
28
- },
29
- },
30
- {
31
- method: 'PUT',
32
- path: '/{{ pluralize id }}/:id',
33
- handler: '{{ id }}.update',
34
- config: {
35
- policies: [],
36
- middlewares: [],
37
- },
38
- },
39
- {
40
- method: 'DELETE',
41
- path: '/{{ pluralize id }}/:id',
42
- handler: '{{ id }}.delete',
43
- config: {
44
- policies: [],
45
- middlewares: [],
46
- },
47
- },
48
- ],
49
- };
@@ -1,15 +0,0 @@
1
-
2
- {
3
- "kind": "{{kind}}",
4
- "collectionName": "{{ collectionName }}",
5
- "info": {
6
- "singularName": "{{ singularName }}",
7
- "pluralName": "{{ pluralName }}",
8
- "displayName": "{{ displayName }}"
9
- },
10
- "options": {
11
- "draftAndPublish": {{ useDraftAndPublish }},
12
- "comment": ""
13
- },
14
- "attributes": {}
15
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * A set of functions called "actions" for `{{ id }}`
3
- */
4
-
5
- export default {
6
- // exampleAction: async (ctx, next) => {
7
- // try {
8
- // ctx.body = 'ok';
9
- // } catch (err) {
10
- // ctx.body = err;
11
- // }
12
- // }
13
- };
@@ -1,7 +0,0 @@
1
- /**
2
- * {{ id }} controller
3
- */
4
-
5
- import { factories } from '@strapi/strapi'
6
-
7
- export default factories.createCoreController('{{ uid }}');
@@ -1,7 +0,0 @@
1
- /**
2
- * {{ id }} router
3
- */
4
-
5
- import { factories } from '@strapi/strapi';
6
-
7
- export default factories.createCoreRouter('{{ uid }}');
@@ -1,7 +0,0 @@
1
- /**
2
- * {{ id }} service
3
- */
4
-
5
- import { factories } from '@strapi/strapi';
6
-
7
- export default factories.createCoreService('{{ uid }}');
@@ -1,14 +0,0 @@
1
- /**
2
- * `{{ name }}` middleware
3
- */
4
-
5
- import { Strapi } from '@strapi/strapi';
6
-
7
- export default (config, { strapi }: { strapi: Strapi }) => {
8
- // Add your own logic here.
9
- return async (ctx, next) => {
10
- strapi.log.info('In {{ name }} middleware.');
11
-
12
- await next();
13
- };
14
- };
@@ -1,11 +0,0 @@
1
- import type { Knex } from 'knex';
2
-
3
- /**
4
- * Migration `{{ name }}`
5
- */
6
-
7
- export default {
8
- up: async (knex: Knex) => {
9
-
10
- },
11
- };
@@ -1,51 +0,0 @@
1
- {
2
- "name": "{{ pluginName }}",
3
- "version": "0.0.0",
4
- "description": "This is the description of the plugin.",
5
- "strapi": {
6
- "name": "{{ pluginName }}",
7
- "description": "Description of {{ pluginName }} plugin",
8
- "kind": "plugin"
9
- },
10
- "dependencies": {
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"
15
- },
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",
26
- "typescript": "5.0.4"
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
- },
34
- "author": {
35
- "name": "A Strapi developer"
36
- },
37
- "maintainers": [
38
- {
39
- "name": "A Strapi developer"
40
- }
41
- ],
42
- "engines": {
43
- "node": ">=14.19.1 <=18.x.x",
44
- "npm": ">=6.0.0"
45
- },
46
- "scripts": {
47
- "develop": "tsc -p tsconfig.server.json -w",
48
- "build": "tsc -p tsconfig.server.json"
49
- },
50
- "license": "MIT"
51
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * {{ id }} policy
3
- */
4
-
5
- export default (policyContext, config, { strapi }) => {
6
- // Add your own logic here.
7
- strapi.log.info('In {{ id }} policy.');
8
-
9
- const canDoSomething = true;
10
-
11
- if (canDoSomething) {
12
- return true;
13
- }
14
-
15
- return false;
16
- };
@@ -1,5 +0,0 @@
1
- /**
2
- * {{ id }} service
3
- */
4
-
5
- export default () => ({});
@@ -1,13 +0,0 @@
1
- export default {
2
- routes: [
3
- // {
4
- // method: 'GET',
5
- // path: '/{{ id }}',
6
- // handler: '{{ id }}.exampleAction',
7
- // config: {
8
- // policies: [],
9
- // middlewares: [],
10
- // },
11
- // },
12
- ],
13
- };
@@ -1,31 +0,0 @@
1
- export default {
2
- routes: [
3
- {
4
- method: 'GET',
5
- path: '/{{ id }}',
6
- handler: '{{ id }}.find',
7
- config: {
8
- policies: [],
9
- middlewares: [],
10
- },
11
- },
12
- {
13
- method: 'PUT',
14
- path: '/{{ id }}',
15
- handler: '{{ id }}.update',
16
- config: {
17
- policies: [],
18
- middlewares: [],
19
- },
20
- },
21
- {
22
- method: 'DELETE',
23
- path: '/{{ id }}',
24
- handler: '{{ id }}.delete',
25
- config: {
26
- policies: [],
27
- middlewares: [],
28
- },
29
- },
30
- ],
31
- };