@strapi/generators 5.50.0 → 5.50.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/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -3
- package/dist/index.mjs.map +1 -1
- package/dist/plops/api.d.ts.map +1 -1
- package/dist/plops/api.js +5 -9
- package/dist/plops/api.js.map +1 -1
- package/dist/plops/api.mjs +5 -8
- package/dist/plops/api.mjs.map +1 -1
- package/dist/plops/content-type.d.ts.map +1 -1
- package/dist/plops/content-type.js +5 -9
- package/dist/plops/content-type.js.map +1 -1
- package/dist/plops/content-type.mjs +5 -8
- package/dist/plops/content-type.mjs.map +1 -1
- package/dist/plops/controller.d.ts.map +1 -1
- package/dist/plops/controller.js +5 -9
- package/dist/plops/controller.js.map +1 -1
- package/dist/plops/controller.mjs +5 -8
- package/dist/plops/controller.mjs.map +1 -1
- package/dist/plops/middleware.d.ts.map +1 -1
- package/dist/plops/middleware.js +5 -9
- package/dist/plops/middleware.js.map +1 -1
- package/dist/plops/middleware.mjs +5 -8
- package/dist/plops/middleware.mjs.map +1 -1
- package/dist/plops/policy.d.ts.map +1 -1
- package/dist/plops/policy.js +5 -9
- package/dist/plops/policy.js.map +1 -1
- package/dist/plops/policy.mjs +5 -8
- package/dist/plops/policy.mjs.map +1 -1
- package/dist/plops/service.d.ts.map +1 -1
- package/dist/plops/service.js +5 -9
- package/dist/plops/service.js.map +1 -1
- package/dist/plops/service.mjs +5 -8
- package/dist/plops/service.mjs.map +1 -1
- package/dist/plops/utils/get-generator-language.d.ts +15 -0
- package/dist/plops/utils/get-generator-language.d.ts.map +1 -0
- package/dist/plops/utils/get-generator-language.js +26 -0
- package/dist/plops/utils/get-generator-language.js.map +1 -0
- package/dist/plops/utils/get-generator-language.mjs +20 -0
- package/dist/plops/utils/get-generator-language.mjs.map +1 -0
- package/package.json +5 -5
package/dist/plops/service.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import tsUtils from '@strapi/typescript-utils';
|
|
2
1
|
import { join } from 'path';
|
|
3
2
|
import fs from 'fs';
|
|
4
3
|
import getDestinationPrompts from './prompts/get-destination-prompts.mjs';
|
|
5
4
|
import getFilePath from './utils/get-file-path.mjs';
|
|
5
|
+
import getGeneratorLanguage from './utils/get-generator-language.mjs';
|
|
6
6
|
import { appendToFile } from './utils/extend-plugin-index-files.mjs';
|
|
7
7
|
|
|
8
8
|
var generateService = ((plop)=>{
|
|
@@ -22,13 +22,10 @@ var generateService = ((plop)=>{
|
|
|
22
22
|
return [];
|
|
23
23
|
}
|
|
24
24
|
const filePath = getFilePath(answers?.destination);
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const pluginServerDir = join(currentDir, 'src', filePath.replace('{{ plugin }}', answers.plugin), '../');
|
|
30
|
-
language = tsUtils.isUsingTypeScriptSync(pluginServerDir) ? 'ts' : 'js';
|
|
31
|
-
}
|
|
25
|
+
const language = getGeneratorLanguage({
|
|
26
|
+
plugin: answers.plugin,
|
|
27
|
+
filePath
|
|
28
|
+
}, plop);
|
|
32
29
|
const baseActions = [
|
|
33
30
|
{
|
|
34
31
|
type: 'add',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.mjs","sources":["../../src/plops/service.ts"],"sourcesContent":["import type { ActionType, NodePlopAPI } from 'plop';\nimport
|
|
1
|
+
{"version":3,"file":"service.mjs","sources":["../../src/plops/service.ts"],"sourcesContent":["import type { ActionType, NodePlopAPI } from 'plop';\nimport { join } from 'path';\nimport fs from 'fs';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\nimport getGeneratorLanguage from './utils/get-generator-language';\nimport { appendToFile } from './utils/extend-plugin-index-files';\n\nexport default (plop: NodePlopAPI) => {\n // Service generator\n plop.setGenerator('service', {\n description: 'Generate a service for an API',\n prompts: [\n {\n type: 'input',\n name: 'id',\n message: 'Service name',\n },\n ...getDestinationPrompts('service', plop.getDestBasePath()),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const filePath = getFilePath(answers?.destination);\n const language = getGeneratorLanguage({ plugin: answers.plugin, filePath }, plop);\n\n const baseActions: Array<ActionType> = [\n {\n type: 'add',\n path: `${filePath}/services/{{ id }}.${language}`,\n templateFile: `templates/${language}/service.${language}.hbs`,\n },\n ];\n\n if (answers.plugin) {\n const indexPath = join(plop.getDestBasePath(), `${filePath}/services/index.${language}`);\n const exists = fs.existsSync(indexPath);\n\n if (!exists) {\n // Create index file if it doesn't exist\n baseActions.push({\n type: 'add',\n path: `${filePath}/services/index.${language}`,\n templateFile: `templates/${language}/plugin/plugin.index.${language}.hbs`,\n skipIfExists: true,\n });\n }\n\n // Append the new service to the index.ts file\n baseActions.push({\n type: 'modify',\n path: `${filePath}/services/index.${language}`,\n transform(template: string) {\n return appendToFile(template, { type: 'index', singularName: answers.id });\n },\n });\n }\n\n return baseActions;\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","type","name","message","getDestinationPrompts","getDestBasePath","actions","answers","filePath","getFilePath","destination","language","getGeneratorLanguage","plugin","baseActions","path","templateFile","indexPath","join","exists","fs","existsSync","push","skipIfExists","transform","template","appendToFile","singularName","id"],"mappings":";;;;;;;AASA,sBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAAA,CAAKC,YAAY,CAAC,SAAA,EAAW;QAC3BC,WAAAA,EAAa,+BAAA;QACbC,OAAAA,EAAS;AACP,YAAA;gBACEC,IAAAA,EAAM,OAAA;gBACNC,IAAAA,EAAM,IAAA;gBACNC,OAAAA,EAAS;AACX,aAAA;eACGC,qBAAAA,CAAsB,SAAA,EAAWP,KAAKQ,eAAe,EAAA;AACzD,SAAA;AACDC,QAAAA,OAAAA,CAAAA,CAAQC,OAAO,EAAA;AACb,YAAA,IAAI,CAACA,OAAAA,EAAS;AACZ,gBAAA,OAAO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,CAAU;AAC9Ca,oBAAAA,SAAAA,CAAAA,CAAUC,QAAgB,EAAA;AACxB,wBAAA,OAAOC,aAAaD,QAAAA,EAAU;4BAAExB,IAAAA,EAAM,OAAA;AAAS0B,4BAAAA,YAAAA,EAAcpB,QAAQqB;AAAG,yBAAA,CAAA;AAC1E,oBAAA;AACF,iBAAA,CAAA;AACF,YAAA;YAEA,OAAOd,WAAAA;AACT,QAAA;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { NodePlopAPI } from 'plop';
|
|
2
|
+
type GetGeneratorLanguageOptions = {
|
|
3
|
+
plugin?: string;
|
|
4
|
+
filePath: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Detect whether generated files should use TypeScript or JavaScript templates.
|
|
8
|
+
*
|
|
9
|
+
* For plugin generation, the check is scoped to the plugin server directory derived
|
|
10
|
+
* from the generator output path. For everything else, it checks the `dir` option
|
|
11
|
+
* passed to `generate()` (via `getDestBasePath()`).
|
|
12
|
+
*/
|
|
13
|
+
declare const getGeneratorLanguage: ({ plugin, filePath }: GetGeneratorLanguageOptions, plop: Pick<NodePlopAPI, "getDestBasePath">) => "ts" | "js";
|
|
14
|
+
export default getGeneratorLanguage;
|
|
15
|
+
//# sourceMappingURL=get-generator-language.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-generator-language.d.ts","sourceRoot":"","sources":["../../../src/plops/utils/get-generator-language.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAExC,KAAK,2BAA2B,GAAG;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;GAMG;AACH,QAAA,MAAM,oBAAoB,GACxB,sBAAsB,2BAA2B,EACjD,MAAM,IAAI,CAAC,WAAW,EAAE,iBAAiB,CAAC,KACzC,IAAI,GAAG,IAST,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var node_path = require('node:path');
|
|
4
|
+
var tsUtils = require('@strapi/typescript-utils');
|
|
5
|
+
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
var tsUtils__default = /*#__PURE__*/_interopDefault(tsUtils);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Detect whether generated files should use TypeScript or JavaScript templates.
|
|
12
|
+
*
|
|
13
|
+
* For plugin generation, the check is scoped to the plugin server directory derived
|
|
14
|
+
* from the generator output path. For everything else, it checks the `dir` option
|
|
15
|
+
* passed to `generate()` (via `getDestBasePath()`).
|
|
16
|
+
*/ const getGeneratorLanguage = ({ plugin, filePath }, plop)=>{
|
|
17
|
+
if (plugin) {
|
|
18
|
+
const resolvedFilePath = filePath.replace('{{ plugin }}', plugin);
|
|
19
|
+
const pluginServerDir = node_path.join(plop.getDestBasePath(), resolvedFilePath, '..');
|
|
20
|
+
return tsUtils__default.default.isUsingTypeScriptSync(pluginServerDir) ? 'ts' : 'js';
|
|
21
|
+
}
|
|
22
|
+
return tsUtils__default.default.isUsingTypeScriptSync(node_path.dirname(plop.getDestBasePath())) ? 'ts' : 'js';
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
module.exports = getGeneratorLanguage;
|
|
26
|
+
//# sourceMappingURL=get-generator-language.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-generator-language.js","sources":["../../../src/plops/utils/get-generator-language.ts"],"sourcesContent":["import { dirname, join } from 'node:path';\nimport tsUtils from '@strapi/typescript-utils';\nimport type { NodePlopAPI } from 'plop';\n\ntype GetGeneratorLanguageOptions = {\n plugin?: string;\n filePath: string;\n};\n\n/**\n * Detect whether generated files should use TypeScript or JavaScript templates.\n *\n * For plugin generation, the check is scoped to the plugin server directory derived\n * from the generator output path. For everything else, it checks the `dir` option\n * passed to `generate()` (via `getDestBasePath()`).\n */\nconst getGeneratorLanguage = (\n { plugin, filePath }: GetGeneratorLanguageOptions,\n plop: Pick<NodePlopAPI, 'getDestBasePath'>\n): 'ts' | 'js' => {\n if (plugin) {\n const resolvedFilePath = filePath.replace('{{ plugin }}', plugin);\n const pluginServerDir = join(plop.getDestBasePath(), resolvedFilePath, '..');\n\n return tsUtils.isUsingTypeScriptSync(pluginServerDir) ? 'ts' : 'js';\n }\n\n return tsUtils.isUsingTypeScriptSync(dirname(plop.getDestBasePath())) ? 'ts' : 'js';\n};\n\nexport default getGeneratorLanguage;\n"],"names":["getGeneratorLanguage","plugin","filePath","plop","resolvedFilePath","replace","pluginServerDir","join","getDestBasePath","tsUtils","isUsingTypeScriptSync","dirname"],"mappings":";;;;;;;;;AASA;;;;;;IAOA,MAAMA,uBAAuB,CAC3B,EAAEC,MAAM,EAAEC,QAAQ,EAA+B,EACjDC,IAAAA,GAAAA;AAEA,IAAA,IAAIF,MAAAA,EAAQ;AACV,QAAA,MAAMG,gBAAAA,GAAmBF,QAAAA,CAASG,OAAO,CAAC,cAAA,EAAgBJ,MAAAA,CAAAA;AAC1D,QAAA,MAAMK,eAAAA,GAAkBC,cAAAA,CAAKJ,IAAAA,CAAKK,eAAe,IAAIJ,gBAAAA,EAAkB,IAAA,CAAA;AAEvE,QAAA,OAAOK,wBAAAA,CAAQC,qBAAqB,CAACJ,eAAAA,CAAAA,GAAmB,IAAA,GAAO,IAAA;AACjE,IAAA;AAEA,IAAA,OAAOG,yBAAQC,qBAAqB,CAACC,kBAAQR,IAAAA,CAAKK,eAAe,OAAO,IAAA,GAAO,IAAA;AACjF;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { join, dirname } from 'node:path';
|
|
2
|
+
import tsUtils from '@strapi/typescript-utils';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Detect whether generated files should use TypeScript or JavaScript templates.
|
|
6
|
+
*
|
|
7
|
+
* For plugin generation, the check is scoped to the plugin server directory derived
|
|
8
|
+
* from the generator output path. For everything else, it checks the `dir` option
|
|
9
|
+
* passed to `generate()` (via `getDestBasePath()`).
|
|
10
|
+
*/ const getGeneratorLanguage = ({ plugin, filePath }, plop)=>{
|
|
11
|
+
if (plugin) {
|
|
12
|
+
const resolvedFilePath = filePath.replace('{{ plugin }}', plugin);
|
|
13
|
+
const pluginServerDir = join(plop.getDestBasePath(), resolvedFilePath, '..');
|
|
14
|
+
return tsUtils.isUsingTypeScriptSync(pluginServerDir) ? 'ts' : 'js';
|
|
15
|
+
}
|
|
16
|
+
return tsUtils.isUsingTypeScriptSync(dirname(plop.getDestBasePath())) ? 'ts' : 'js';
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { getGeneratorLanguage as default };
|
|
20
|
+
//# sourceMappingURL=get-generator-language.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-generator-language.mjs","sources":["../../../src/plops/utils/get-generator-language.ts"],"sourcesContent":["import { dirname, join } from 'node:path';\nimport tsUtils from '@strapi/typescript-utils';\nimport type { NodePlopAPI } from 'plop';\n\ntype GetGeneratorLanguageOptions = {\n plugin?: string;\n filePath: string;\n};\n\n/**\n * Detect whether generated files should use TypeScript or JavaScript templates.\n *\n * For plugin generation, the check is scoped to the plugin server directory derived\n * from the generator output path. For everything else, it checks the `dir` option\n * passed to `generate()` (via `getDestBasePath()`).\n */\nconst getGeneratorLanguage = (\n { plugin, filePath }: GetGeneratorLanguageOptions,\n plop: Pick<NodePlopAPI, 'getDestBasePath'>\n): 'ts' | 'js' => {\n if (plugin) {\n const resolvedFilePath = filePath.replace('{{ plugin }}', plugin);\n const pluginServerDir = join(plop.getDestBasePath(), resolvedFilePath, '..');\n\n return tsUtils.isUsingTypeScriptSync(pluginServerDir) ? 'ts' : 'js';\n }\n\n return tsUtils.isUsingTypeScriptSync(dirname(plop.getDestBasePath())) ? 'ts' : 'js';\n};\n\nexport default getGeneratorLanguage;\n"],"names":["getGeneratorLanguage","plugin","filePath","plop","resolvedFilePath","replace","pluginServerDir","join","getDestBasePath","tsUtils","isUsingTypeScriptSync","dirname"],"mappings":";;;AASA;;;;;;IAOA,MAAMA,uBAAuB,CAC3B,EAAEC,MAAM,EAAEC,QAAQ,EAA+B,EACjDC,IAAAA,GAAAA;AAEA,IAAA,IAAIF,MAAAA,EAAQ;AACV,QAAA,MAAMG,gBAAAA,GAAmBF,QAAAA,CAASG,OAAO,CAAC,cAAA,EAAgBJ,MAAAA,CAAAA;AAC1D,QAAA,MAAMK,eAAAA,GAAkBC,IAAAA,CAAKJ,IAAAA,CAAKK,eAAe,IAAIJ,gBAAAA,EAAkB,IAAA,CAAA;AAEvE,QAAA,OAAOK,OAAAA,CAAQC,qBAAqB,CAACJ,eAAAA,CAAAA,GAAmB,IAAA,GAAO,IAAA;AACjE,IAAA;AAEA,IAAA,OAAOG,QAAQC,qBAAqB,CAACC,QAAQR,IAAAA,CAAKK,eAAe,OAAO,IAAA,GAAO,IAAA;AACjF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/generators",
|
|
3
|
-
"version": "5.50.
|
|
3
|
+
"version": "5.50.1",
|
|
4
4
|
"description": "Interactive API generator.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@sindresorhus/slugify": "1.1.0",
|
|
53
|
-
"@strapi/typescript-utils": "5.50.
|
|
54
|
-
"@strapi/utils": "5.50.
|
|
53
|
+
"@strapi/typescript-utils": "5.50.1",
|
|
54
|
+
"@strapi/utils": "5.50.1",
|
|
55
55
|
"chalk": "4.1.2",
|
|
56
56
|
"fs-extra": "11.3.4",
|
|
57
57
|
"handlebars": "4.7.9",
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
"@types/fs-extra": "11.0.4",
|
|
65
65
|
"@types/jscodeshift": "17.3.0",
|
|
66
66
|
"copyfiles": "2.4.1",
|
|
67
|
-
"eslint-config-custom": "5.50.
|
|
67
|
+
"eslint-config-custom": "5.50.1",
|
|
68
68
|
"outdent": "^0.8.0",
|
|
69
|
-
"tsconfig": "5.50.
|
|
69
|
+
"tsconfig": "5.50.1"
|
|
70
70
|
},
|
|
71
71
|
"engines": {
|
|
72
72
|
"node": ">=20.0.0 <=26.x.x",
|