@strapi/typescript-utils 5.50.1 → 5.50.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/compile.d.ts +5 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +12 -0
- package/dist/compile.js.map +1 -0
- package/dist/compile.mjs +10 -0
- package/dist/compile.mjs.map +1 -0
- package/dist/compilers/basic.d.ts +11 -0
- package/dist/compilers/basic.d.ts.map +1 -0
- package/dist/compilers/basic.js +58 -0
- package/dist/compilers/basic.js.map +1 -0
- package/dist/compilers/basic.mjs +36 -0
- package/dist/compilers/basic.mjs.map +1 -0
- package/dist/compilers/index.d.ts +3 -0
- package/dist/compilers/index.d.ts.map +1 -0
- package/dist/compilers/index.js +8 -0
- package/dist/compilers/index.js.map +1 -0
- package/dist/compilers/index.mjs +3 -0
- package/dist/compilers/index.mjs.map +1 -0
- package/dist/generators/common/imports.d.ts +5 -0
- package/dist/generators/common/imports.d.ts.map +1 -0
- package/dist/generators/common/imports.js +42 -0
- package/dist/generators/common/imports.js.map +1 -0
- package/dist/generators/common/imports.mjs +19 -0
- package/dist/generators/common/imports.mjs.map +1 -0
- package/dist/generators/common/index.d.ts +4 -0
- package/dist/generators/common/index.d.ts.map +1 -0
- package/dist/generators/common/models/attributes.d.ts +17 -0
- package/dist/generators/common/models/attributes.d.ts.map +1 -0
- package/dist/generators/common/models/attributes.js +152 -0
- package/dist/generators/common/models/attributes.js.map +1 -0
- package/dist/generators/common/models/attributes.mjs +124 -0
- package/dist/generators/common/models/attributes.mjs.map +1 -0
- package/dist/generators/common/models/index.d.ts +7 -0
- package/dist/generators/common/models/index.d.ts.map +1 -0
- package/dist/generators/common/models/mappers.d.ts +9 -0
- package/dist/generators/common/models/mappers.d.ts.map +1 -0
- package/dist/generators/common/models/mappers.js +227 -0
- package/dist/generators/common/models/mappers.js.map +1 -0
- package/dist/generators/common/models/mappers.mjs +202 -0
- package/dist/generators/common/models/mappers.mjs.map +1 -0
- package/dist/generators/common/models/schema.d.ts +7 -0
- package/dist/generators/common/models/schema.d.ts.map +1 -0
- package/dist/generators/common/models/schema.js +79 -0
- package/dist/generators/common/models/schema.js.map +1 -0
- package/dist/generators/common/models/schema.mjs +57 -0
- package/dist/generators/common/models/schema.mjs.map +1 -0
- package/dist/generators/common/models/utils.d.ts +54 -0
- package/dist/generators/common/models/utils.d.ts.map +1 -0
- package/dist/generators/common/models/utils.js +109 -0
- package/dist/generators/common/models/utils.js.map +1 -0
- package/dist/generators/common/models/utils.mjs +81 -0
- package/dist/generators/common/models/utils.mjs.map +1 -0
- package/dist/generators/components/index.d.ts +9 -0
- package/dist/generators/components/index.d.ts.map +1 -0
- package/dist/generators/components/index.js +76 -0
- package/dist/generators/components/index.js.map +1 -0
- package/dist/generators/components/index.mjs +54 -0
- package/dist/generators/components/index.mjs.map +1 -0
- package/dist/generators/constants.d.ts +3 -0
- package/dist/generators/constants.d.ts.map +1 -0
- package/dist/generators/constants.js +8 -0
- package/dist/generators/constants.js.map +1 -0
- package/dist/generators/constants.mjs +5 -0
- package/dist/generators/constants.mjs.map +1 -0
- package/dist/generators/content-types/index.d.ts +9 -0
- package/dist/generators/content-types/index.d.ts.map +1 -0
- package/dist/generators/content-types/index.js +76 -0
- package/dist/generators/content-types/index.js.map +1 -0
- package/dist/generators/content-types/index.mjs +54 -0
- package/dist/generators/content-types/index.mjs.map +1 -0
- package/dist/generators/index.d.ts +23 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/index.js +81 -0
- package/dist/generators/index.js.map +1 -0
- package/dist/generators/index.mjs +74 -0
- package/dist/generators/index.mjs.map +1 -0
- package/dist/generators/utils.d.ts +52 -0
- package/dist/generators/utils.d.ts.map +1 -0
- package/dist/generators/utils.js +164 -0
- package/dist/generators/utils.js.map +1 -0
- package/dist/generators/utils.mjs +131 -0
- package/dist/generators/utils.mjs.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +14 -0
- package/dist/index.mjs.map +1 -0
- package/dist/utils/format-host.d.ts +3 -0
- package/dist/utils/format-host.d.ts.map +1 -0
- package/dist/utils/format-host.js +33 -0
- package/dist/utils/format-host.js.map +1 -0
- package/dist/utils/format-host.mjs +11 -0
- package/dist/utils/format-host.mjs.map +1 -0
- package/dist/utils/get-config-path.d.ts +10 -0
- package/dist/utils/get-config-path.d.ts.map +1 -0
- package/dist/utils/get-config-path.js +43 -0
- package/dist/utils/get-config-path.js.map +1 -0
- package/dist/utils/get-config-path.mjs +18 -0
- package/dist/utils/get-config-path.mjs.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/is-using-typescript-sync.d.ts +5 -0
- package/dist/utils/is-using-typescript-sync.d.ts.map +1 -0
- package/dist/utils/is-using-typescript-sync.js +20 -0
- package/dist/utils/is-using-typescript-sync.js.map +1 -0
- package/dist/utils/is-using-typescript-sync.mjs +14 -0
- package/dist/utils/is-using-typescript-sync.mjs.map +1 -0
- package/dist/utils/is-using-typescript.d.ts +5 -0
- package/dist/utils/is-using-typescript.d.ts.map +1 -0
- package/dist/utils/is-using-typescript.js +20 -0
- package/dist/utils/is-using-typescript.js.map +1 -0
- package/dist/utils/is-using-typescript.mjs +14 -0
- package/dist/utils/is-using-typescript.mjs.map +1 -0
- package/dist/utils/report-diagnostics.d.ts +6 -0
- package/dist/utils/report-diagnostics.d.ts.map +1 -0
- package/dist/utils/report-diagnostics.js +37 -0
- package/dist/utils/report-diagnostics.js.map +1 -0
- package/dist/utils/report-diagnostics.mjs +15 -0
- package/dist/utils/report-diagnostics.mjs.map +1 -0
- package/dist/utils/resolve-config-options.d.ts +12 -0
- package/dist/utils/resolve-config-options.d.ts.map +1 -0
- package/dist/utils/resolve-config-options.js +39 -0
- package/dist/utils/resolve-config-options.js.map +1 -0
- package/dist/utils/resolve-config-options.mjs +17 -0
- package/dist/utils/resolve-config-options.mjs.map +1 -0
- package/dist/utils/resolve-outdir-sync.d.ts +5 -0
- package/dist/utils/resolve-outdir-sync.d.ts.map +1 -0
- package/dist/utils/resolve-outdir-sync.js +19 -0
- package/dist/utils/resolve-outdir-sync.js.map +1 -0
- package/dist/utils/resolve-outdir-sync.mjs +13 -0
- package/dist/utils/resolve-outdir-sync.mjs.map +1 -0
- package/dist/utils/resolve-outdir.d.ts +5 -0
- package/dist/utils/resolve-outdir.d.ts.map +1 -0
- package/dist/utils/resolve-outdir.js +19 -0
- package/dist/utils/resolve-outdir.js.map +1 -0
- package/dist/utils/resolve-outdir.mjs +13 -0
- package/dist/utils/resolve-outdir.mjs.map +1 -0
- package/package.json +25 -10
- package/.eslintrc.cjs +0 -16
- package/index.d.ts +0 -5
- package/jest.config.js +0 -6
- package/lib/__tests__/generators/schemas/attributes.test.js +0 -903
- package/lib/__tests__/generators/schemas/imports.test.js +0 -56
- package/lib/__tests__/generators/schemas/utils.test.js +0 -314
- package/lib/__tests__/generators/utils.test.js +0 -43
- package/lib/compile.js +0 -10
- package/lib/compilers/basic.js +0 -50
- package/lib/compilers/index.js +0 -7
- package/lib/generators/common/imports.js +0 -34
- package/lib/generators/common/index.js +0 -9
- package/lib/generators/common/models/attributes.js +0 -198
- package/lib/generators/common/models/index.js +0 -15
- package/lib/generators/common/models/mappers.js +0 -144
- package/lib/generators/common/models/schema.js +0 -93
- package/lib/generators/common/models/utils.js +0 -178
- package/lib/generators/components/index.js +0 -74
- package/lib/generators/constants.js +0 -6
- package/lib/generators/content-types/index.js +0 -74
- package/lib/generators/index.js +0 -122
- package/lib/generators/utils.js +0 -217
- package/lib/index.js +0 -13
- package/lib/utils/format-host.js +0 -15
- package/lib/utils/get-config-path.js +0 -29
- package/lib/utils/index.js +0 -21
- package/lib/utils/is-using-typescript-sync.js +0 -19
- package/lib/utils/is-using-typescript.js +0 -17
- package/lib/utils/report-diagnostics.js +0 -19
- package/lib/utils/resolve-config-options.js +0 -23
- package/lib/utils/resolve-outdir-sync.js +0 -18
- package/lib/utils/resolve-outdir.js +0 -18
- package/lint-staged.config.mjs +0 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ts = require('typescript');
|
|
4
|
+
var _ = require('lodash/fp');
|
|
5
|
+
var schema = require('../common/models/schema.js');
|
|
6
|
+
var imports = require('../common/imports.js');
|
|
7
|
+
require('../common/models/utils.js');
|
|
8
|
+
var utils = require('../utils.js');
|
|
9
|
+
|
|
10
|
+
function _interopNamespace(e) {
|
|
11
|
+
if (e && e.__esModule) return e;
|
|
12
|
+
var n = Object.create(null);
|
|
13
|
+
if (e) {
|
|
14
|
+
Object.keys(e).forEach(function (k) {
|
|
15
|
+
if (k !== 'default') {
|
|
16
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return e[k]; }
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
n.default = e;
|
|
25
|
+
return Object.freeze(n);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var ts__namespace = /*#__PURE__*/_interopNamespace(ts);
|
|
29
|
+
|
|
30
|
+
const { factory } = ts__namespace;
|
|
31
|
+
const NO_CONTENT_TYPE_PLACEHOLDER_COMMENT = `/*
|
|
32
|
+
* The app doesn't have any content-types yet.
|
|
33
|
+
*/
|
|
34
|
+
`;
|
|
35
|
+
/**
|
|
36
|
+
* Generate type definitions for Strapi Content-Types
|
|
37
|
+
*/ const generateContentTypesDefinitions = async (options = {})=>{
|
|
38
|
+
const { strapi } = options;
|
|
39
|
+
const { contentTypes } = strapi;
|
|
40
|
+
const contentTypesDefinitions = _.pipe(_.values, _.sortBy('uid'), _.map((contentType)=>({
|
|
41
|
+
uid: contentType.uid,
|
|
42
|
+
definition: schema.generateSchemaDefinition(contentType)
|
|
43
|
+
})))(contentTypes);
|
|
44
|
+
options.logger.debug(`Found ${contentTypesDefinitions.length} content-types.`);
|
|
45
|
+
if (contentTypesDefinitions.length === 0) {
|
|
46
|
+
return {
|
|
47
|
+
output: NO_CONTENT_TYPE_PLACEHOLDER_COMMENT,
|
|
48
|
+
stats: {}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const formattedSchemasDefinitions = contentTypesDefinitions.reduce((acc, def)=>{
|
|
52
|
+
acc.push(// Definition
|
|
53
|
+
def.definition, // Add a newline between each interface declaration
|
|
54
|
+
factory.createIdentifier('\n'));
|
|
55
|
+
return acc;
|
|
56
|
+
}, []);
|
|
57
|
+
const allDefinitions = [
|
|
58
|
+
// Imports
|
|
59
|
+
...imports.generateImportDefinition(),
|
|
60
|
+
// Add a newline after the import statement
|
|
61
|
+
factory.createIdentifier('\n'),
|
|
62
|
+
// Schemas
|
|
63
|
+
...formattedSchemasDefinitions,
|
|
64
|
+
// Global
|
|
65
|
+
utils.generateSharedExtensionDefinition('ContentTypeSchemas', contentTypesDefinitions)
|
|
66
|
+
];
|
|
67
|
+
const output = utils.emitDefinitions(allDefinitions);
|
|
68
|
+
const formattedOutput = await utils.format(output);
|
|
69
|
+
return {
|
|
70
|
+
output: formattedOutput,
|
|
71
|
+
stats: {}
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
exports.generateContentTypesDefinitions = generateContentTypesDefinitions;
|
|
76
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/generators/content-types/index.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport { values, pipe, map, sortBy } from 'lodash/fp';\n\nimport { models } from '../common';\nimport { emitDefinitions, format, generateSharedExtensionDefinition } from '../utils';\nimport type { GeneratorOptions } from '../utils';\n\nconst { factory } = ts;\n\nconst NO_CONTENT_TYPE_PLACEHOLDER_COMMENT = `/*\n * The app doesn't have any content-types yet.\n */\n`;\n\n/**\n * Generate type definitions for Strapi Content-Types\n */\nexport const generateContentTypesDefinitions = async (\n options: GeneratorOptions = {} as GeneratorOptions\n) => {\n const { strapi } = options;\n\n const { contentTypes } = strapi;\n\n const contentTypesDefinitions = pipe(\n values,\n sortBy('uid'),\n map((contentType: any) => ({\n uid: contentType.uid,\n definition: models.schema.generateSchemaDefinition(contentType),\n }))\n )(contentTypes);\n\n options.logger.debug(`Found ${contentTypesDefinitions.length} content-types.`);\n\n if (contentTypesDefinitions.length === 0) {\n return { output: NO_CONTENT_TYPE_PLACEHOLDER_COMMENT, stats: {} };\n }\n\n const formattedSchemasDefinitions = contentTypesDefinitions.reduce<any[]>((acc, def) => {\n acc.push(\n // Definition\n def.definition,\n\n // Add a newline between each interface declaration\n factory.createIdentifier('\\n')\n );\n\n return acc;\n }, []);\n\n const allDefinitions = [\n // Imports\n ...models.imports.generateImportDefinition(),\n\n // Add a newline after the import statement\n factory.createIdentifier('\\n'),\n\n // Schemas\n ...formattedSchemasDefinitions,\n\n // Global\n generateSharedExtensionDefinition('ContentTypeSchemas', contentTypesDefinitions),\n ];\n\n const output = emitDefinitions(allDefinitions);\n const formattedOutput = await format(output);\n\n return { output: formattedOutput, stats: {} };\n};\n"],"names":["factory","ts","NO_CONTENT_TYPE_PLACEHOLDER_COMMENT","generateContentTypesDefinitions","options","strapi","contentTypes","contentTypesDefinitions","pipe","values","sortBy","map","contentType","uid","definition","models","logger","debug","length","output","stats","formattedSchemasDefinitions","reduce","acc","def","push","createIdentifier","allDefinitions","generateSharedExtensionDefinition","emitDefinitions","formattedOutput","format"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,EAAEA,OAAO,EAAE,GAAGC,aAAAA;AAEpB,MAAMC,sCAAsC,CAAC;;;AAG7C,CAAC;AAED;;AAEC,IACM,MAAMC,+BAAAA,GAAkC,OAC7CC,OAAAA,GAA4B,EAAsB,GAAA;IAElD,MAAM,EAAEC,M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AAAA;AAAiBV,QAAAA,KAAAA,EAAO;AAAG,KAAA;AAC9C;;;;"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as ts from 'typescript';
|
|
2
|
+
import { pipe, values, sortBy, map } from 'lodash/fp';
|
|
3
|
+
import { generateSchemaDefinition } from '../common/models/schema.mjs';
|
|
4
|
+
import { generateImportDefinition } from '../common/imports.mjs';
|
|
5
|
+
import '../common/models/utils.mjs';
|
|
6
|
+
import { generateSharedExtensionDefinition, emitDefinitions, format } from '../utils.mjs';
|
|
7
|
+
|
|
8
|
+
const { factory } = ts;
|
|
9
|
+
const NO_CONTENT_TYPE_PLACEHOLDER_COMMENT = `/*
|
|
10
|
+
* The app doesn't have any content-types yet.
|
|
11
|
+
*/
|
|
12
|
+
`;
|
|
13
|
+
/**
|
|
14
|
+
* Generate type definitions for Strapi Content-Types
|
|
15
|
+
*/ const generateContentTypesDefinitions = async (options = {})=>{
|
|
16
|
+
const { strapi } = options;
|
|
17
|
+
const { contentTypes } = strapi;
|
|
18
|
+
const contentTypesDefinitions = pipe(values, sortBy('uid'), map((contentType)=>({
|
|
19
|
+
uid: contentType.uid,
|
|
20
|
+
definition: generateSchemaDefinition(contentType)
|
|
21
|
+
})))(contentTypes);
|
|
22
|
+
options.logger.debug(`Found ${contentTypesDefinitions.length} content-types.`);
|
|
23
|
+
if (contentTypesDefinitions.length === 0) {
|
|
24
|
+
return {
|
|
25
|
+
output: NO_CONTENT_TYPE_PLACEHOLDER_COMMENT,
|
|
26
|
+
stats: {}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const formattedSchemasDefinitions = contentTypesDefinitions.reduce((acc, def)=>{
|
|
30
|
+
acc.push(// Definition
|
|
31
|
+
def.definition, // Add a newline between each interface declaration
|
|
32
|
+
factory.createIdentifier('\n'));
|
|
33
|
+
return acc;
|
|
34
|
+
}, []);
|
|
35
|
+
const allDefinitions = [
|
|
36
|
+
// Imports
|
|
37
|
+
...generateImportDefinition(),
|
|
38
|
+
// Add a newline after the import statement
|
|
39
|
+
factory.createIdentifier('\n'),
|
|
40
|
+
// Schemas
|
|
41
|
+
...formattedSchemasDefinitions,
|
|
42
|
+
// Global
|
|
43
|
+
generateSharedExtensionDefinition('ContentTypeSchemas', contentTypesDefinitions)
|
|
44
|
+
];
|
|
45
|
+
const output = emitDefinitions(allDefinitions);
|
|
46
|
+
const formattedOutput = await format(output);
|
|
47
|
+
return {
|
|
48
|
+
output: formattedOutput,
|
|
49
|
+
stats: {}
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { generateContentTypesDefinitions };
|
|
54
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/generators/content-types/index.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport { values, pipe, map, sortBy } from 'lodash/fp';\n\nimport { models } from '../common';\nimport { emitDefinitions, format, generateSharedExtensionDefinition } from '../utils';\nimport type { GeneratorOptions } from '../utils';\n\nconst { factory } = ts;\n\nconst NO_CONTENT_TYPE_PLACEHOLDER_COMMENT = `/*\n * The app doesn't have any content-types yet.\n */\n`;\n\n/**\n * Generate type definitions for Strapi Content-Types\n */\nexport const generateContentTypesDefinitions = async (\n options: GeneratorOptions = {} as GeneratorOptions\n) => {\n const { strapi } = options;\n\n const { contentTypes } = strapi;\n\n const contentTypesDefinitions = pipe(\n values,\n sortBy('uid'),\n map((contentType: any) => ({\n uid: contentType.uid,\n definition: models.schema.generateSchemaDefinition(contentType),\n }))\n )(contentTypes);\n\n options.logger.debug(`Found ${contentTypesDefinitions.length} content-types.`);\n\n if (contentTypesDefinitions.length === 0) {\n return { output: NO_CONTENT_TYPE_PLACEHOLDER_COMMENT, stats: {} };\n }\n\n const formattedSchemasDefinitions = contentTypesDefinitions.reduce<any[]>((acc, def) => {\n acc.push(\n // Definition\n def.definition,\n\n // Add a newline between each interface declaration\n factory.createIdentifier('\\n')\n );\n\n return acc;\n }, []);\n\n const allDefinitions = [\n // Imports\n ...models.imports.generateImportDefinition(),\n\n // Add a newline after the import statement\n factory.createIdentifier('\\n'),\n\n // Schemas\n ...formattedSchemasDefinitions,\n\n // Global\n generateSharedExtensionDefinition('ContentTypeSchemas', contentTypesDefinitions),\n ];\n\n const output = emitDefinitions(allDefinitions);\n const formattedOutput = await format(output);\n\n return { output: formattedOutput, stats: {} };\n};\n"],"names":["factory","ts","NO_CONTENT_TYPE_PLACEHOLDER_COMMENT","generateContentTypesDefinitions","options","strapi","contentTypes","contentTypesDefinitions","pipe","values","sortBy","map","contentType","uid","definition","models","logger","debug","length","output","stats","formattedSchemasDefinitions","reduce","acc","def","push","createIdentifier","allDefinitions","generateSharedExtensionDefinition","emitDefinitions","formattedOutput","format"],"mappings":";;;;;;;AAOA,MAAM,EAAEA,OAAO,EAAE,GAAGC,EAAAA;AAEpB,MAAMC,sCAAsC,CAAC;;;AAG7C,CAAC;AAED;;AAEC,IACM,MAAMC,+BAAAA,GAAkC,OAC7CC,OAAAA,GAA4B,EAAsB,GAAA;IAElD,MAAM,EAAEC,MAAM,EAAE,GAAGD,OAAAA;IAEnB,MAAM,EAAEE,YAAY,EAAE,GAAGD,MAAAA;IAEzB,MAAME,uBAAAA,GAA0BC,KAC9BC,MAAAA,EACAC,MAAAA,CAAO,QACPC,GAAAA,CAAI,CAACC,eAAsB;AACzBC,YAAAA,GAAAA,EAAKD,YAAYC,GAAG;AACpBC,YAAAA,UAAAA,EAAYC,wBAAsC,CAACH,WAAAA;AACrD,SAAA,CAAA,CAAA,CAAA,CACAN,YAAAA,CAAAA;IAEFF,OAAAA,CAAQY,MAAM,CAACC,KAAK,CAAC,CAAC,MAAM,EAAEV,uBAAAA,CAAwBW,MAAM,CAAC,eAAe,CAAC,CAAA;IAE7E,IAAIX,uBAAAA,CAAwBW,MAAM,KAAK,CAAA,EAAG;QACxC,OAAO;YAAEC,MAAAA,EAAQjB,mCAAAA;AAAqCkB,YAAAA,KAAAA,EAAO;AAAG,SAAA;AAClE,IAAA;AAEA,IAAA,MAAMC,2BAAAA,GAA8Bd,uBAAAA,CAAwBe,MAAM,CAAQ,CAACC,GAAAA,EAAKC,GAAAA,GAAAA;QAC9ED,GAAAA,CAAIE,IAAI;QAEND,GAAAA,CAAIV,UAAU;AAGdd,QAAAA,OAAAA,CAAQ0B,gBAAgB,CAAC,IAAA,CAAA,CAAA;QAG3B,OAAOH,GAAAA;AACT,IAAA,CAAA,EAAG,EAAE,CAAA;AAEL,IAAA,MAAMI,cAAAA,GAAiB;;WAElBZ,wBAAuC,EAAA;;AAG1Cf,QAAAA,OAAAA,CAAQ0B,gBAAgB,CAAC,IAAA,CAAA;;AAGtBL,QAAAA,GAAAA,2BAAAA;;AAGHO,QAAAA,iCAAAA,CAAkC,oBAAA,EAAsBrB,uBAAAA;AACzD,KAAA;AAED,IAAA,MAAMY,SAASU,eAAAA,CAAgBF,cAAAA,CAAAA;IAC/B,MAAMG,eAAAA,GAAkB,MAAMC,MAAAA,CAAOZ,MAAAA,CAAAA;IAErC,OAAO;QAAEA,MAAAA,EAAQW,eAAAA;AAAiBV,QAAAA,KAAAA,EAAO;AAAG,KAAA;AAC9C;;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface GenerateConfig {
|
|
2
|
+
strapi: any;
|
|
3
|
+
pwd: string;
|
|
4
|
+
rootDir?: string;
|
|
5
|
+
artifacts?: {
|
|
6
|
+
contentTypes?: boolean;
|
|
7
|
+
components?: boolean;
|
|
8
|
+
services?: boolean;
|
|
9
|
+
controllers?: boolean;
|
|
10
|
+
policies?: boolean;
|
|
11
|
+
middlewares?: boolean;
|
|
12
|
+
};
|
|
13
|
+
logger?: {
|
|
14
|
+
silent?: boolean;
|
|
15
|
+
debug?: boolean;
|
|
16
|
+
verbose?: boolean;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Generate types definitions based on the given configuration
|
|
21
|
+
*/
|
|
22
|
+
export declare const generate: (config?: GenerateConfig) => Promise<Record<string, any>>;
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generators/index.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,GAAG,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE;QACV,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,WAAW,CAAC,EAAE,OAAO,CAAC;KACvB,CAAC;IACF,MAAM,CAAC,EAAE;QACP,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;CACH;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAU,SAAQ,cAAqC,iCAmF3E,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('node:path');
|
|
4
|
+
var chalk = require('chalk');
|
|
5
|
+
var constants = require('./constants.js');
|
|
6
|
+
var utils = require('./utils.js');
|
|
7
|
+
var index$1 = require('./content-types/index.js');
|
|
8
|
+
var index = require('./components/index.js');
|
|
9
|
+
|
|
10
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
13
|
+
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
14
|
+
|
|
15
|
+
const GENERATORS = {
|
|
16
|
+
contentTypes: index$1.generateContentTypesDefinitions,
|
|
17
|
+
components: index.generateComponentsDefinitions
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Generate types definitions based on the given configuration
|
|
21
|
+
*/ const generate = async (config = {})=>{
|
|
22
|
+
const { pwd, rootDir = constants.TYPES_ROOT_DIR, strapi, artifacts = {}, logger: loggerConfig } = config;
|
|
23
|
+
const reports = {};
|
|
24
|
+
const logger = utils.createLogger(loggerConfig);
|
|
25
|
+
const psTimer = utils.timer().start();
|
|
26
|
+
const registryPwd = path__default.default.join(pwd, rootDir, constants.GENERATED_OUT_DIR);
|
|
27
|
+
const generatorConfig = {
|
|
28
|
+
strapi,
|
|
29
|
+
pwd: registryPwd,
|
|
30
|
+
logger
|
|
31
|
+
};
|
|
32
|
+
const returnWithMessage = ()=>{
|
|
33
|
+
const nbWarnings = chalk__default.default.yellow(`${logger.warnings} warning(s)`);
|
|
34
|
+
const nbErrors = chalk__default.default.red(`${logger.errors} error(s)`);
|
|
35
|
+
const status = logger.errors > 0 ? chalk__default.default.red('errored') : chalk__default.default.green('completed successfully');
|
|
36
|
+
psTimer.end();
|
|
37
|
+
logger.info(`The task ${status} with ${nbWarnings} and ${nbErrors} in ${psTimer.duration}s.`);
|
|
38
|
+
return reports;
|
|
39
|
+
};
|
|
40
|
+
const enabledArtifacts = Object.keys(artifacts).filter((p)=>artifacts[p] === true);
|
|
41
|
+
logger.info('Starting the type generation process');
|
|
42
|
+
logger.debug(`Enabled artifacts: ${enabledArtifacts.join(', ')}`);
|
|
43
|
+
for (const artifact of enabledArtifacts){
|
|
44
|
+
const boldArtifact = chalk__default.default.bold(artifact); // used for log messages
|
|
45
|
+
logger.info(`Generating types for ${boldArtifact}`);
|
|
46
|
+
if (artifact in GENERATORS) {
|
|
47
|
+
const generator = GENERATORS[artifact];
|
|
48
|
+
try {
|
|
49
|
+
const artifactGenTimer = utils.timer().start();
|
|
50
|
+
reports[artifact] = await generator(generatorConfig);
|
|
51
|
+
artifactGenTimer.end();
|
|
52
|
+
logger.debug(`Generated ${boldArtifact} in ${artifactGenTimer.duration}s`);
|
|
53
|
+
} catch (e) {
|
|
54
|
+
logger.error(`Failed to generate types for ${boldArtifact}: ${e.message ?? e.toString()}. Exiting`);
|
|
55
|
+
return returnWithMessage();
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
logger.warn(`The types generator for ${boldArtifact} is not implemented, skipping`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
for (const artifact of Object.keys(reports)){
|
|
62
|
+
const boldArtifact = chalk__default.default.bold(artifact); // used for log messages
|
|
63
|
+
const artifactFsTimer = utils.timer().start();
|
|
64
|
+
const report = reports[artifact];
|
|
65
|
+
const filename = `${artifact}.d.ts`;
|
|
66
|
+
try {
|
|
67
|
+
const outPath = await utils.saveDefinitionToFileSystem(registryPwd, filename, report.output);
|
|
68
|
+
const relativeOutPath = path__default.default.relative(process.cwd(), outPath);
|
|
69
|
+
artifactFsTimer.end();
|
|
70
|
+
logger.info(`Saved ${boldArtifact} types in ${chalk__default.default.bold(relativeOutPath)}`);
|
|
71
|
+
logger.debug(`Saved ${boldArtifact} in ${artifactFsTimer.duration}s`);
|
|
72
|
+
} catch (e) {
|
|
73
|
+
logger.error(`An error occurred while saving ${boldArtifact} types to the filesystem: ${e.message ?? e.toString()}. Exiting`);
|
|
74
|
+
return returnWithMessage();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return returnWithMessage();
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
exports.generate = generate;
|
|
81
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/generators/index.ts"],"sourcesContent":["import path from 'node:path';\nimport chalk from 'chalk';\n\nimport { TYPES_ROOT_DIR, GENERATED_OUT_DIR } from './constants';\nimport { saveDefinitionToFileSystem, createLogger, timer } from './utils';\nimport { generateContentTypesDefinitions } from './content-types';\nimport { generateComponentsDefinitions } from './components';\n\nconst GENERATORS = {\n contentTypes: generateContentTypesDefinitions,\n components: generateComponentsDefinitions,\n};\n\nexport interface GenerateConfig {\n strapi: any;\n pwd: string;\n rootDir?: string;\n artifacts?: {\n contentTypes?: boolean;\n components?: boolean;\n services?: boolean;\n controllers?: boolean;\n policies?: boolean;\n middlewares?: boolean;\n };\n logger?: {\n silent?: boolean;\n debug?: boolean;\n verbose?: boolean;\n };\n}\n\n/**\n * Generate types definitions based on the given configuration\n */\nexport const generate = async (config: GenerateConfig = {} as GenerateConfig) => {\n const { pwd, rootDir = TYPES_ROOT_DIR, strapi, artifacts = {}, logger: loggerConfig } = config;\n const reports: Record<string, any> = {};\n const logger = createLogger(loggerConfig);\n const psTimer = timer().start();\n\n const registryPwd = path.join(pwd, rootDir, GENERATED_OUT_DIR);\n const generatorConfig = { strapi, pwd: registryPwd, logger };\n\n const returnWithMessage = () => {\n const nbWarnings = chalk.yellow(`${logger.warnings} warning(s)`);\n const nbErrors = chalk.red(`${logger.errors} error(s)`);\n\n const status = logger.errors > 0 ? chalk.red('errored') : chalk.green('completed successfully');\n\n psTimer.end();\n\n logger.info(`The task ${status} with ${nbWarnings} and ${nbErrors} in ${psTimer.duration}s.`);\n\n return reports;\n };\n\n const enabledArtifacts = Object.keys(artifacts).filter(\n (p) => (artifacts as Record<string, boolean>)[p] === true\n );\n\n logger.info('Starting the type generation process');\n logger.debug(`Enabled artifacts: ${enabledArtifacts.join(', ')}`);\n\n for (const artifact of enabledArtifacts) {\n const boldArtifact = chalk.bold(artifact); // used for log messages\n\n logger.info(`Generating types for ${boldArtifact}`);\n\n if (artifact in GENERATORS) {\n const generator = (GENERATORS as any)[artifact];\n\n try {\n const artifactGenTimer = timer().start();\n\n reports[artifact] = await generator(generatorConfig);\n\n artifactGenTimer.end();\n\n logger.debug(`Generated ${boldArtifact} in ${artifactGenTimer.duration}s`);\n } catch (e) {\n logger.error(\n `Failed to generate types for ${boldArtifact}: ${(e as any).message ?? (e as any).toString()}. Exiting`\n );\n return returnWithMessage();\n }\n } else {\n logger.warn(`The types generator for ${boldArtifact} is not implemented, skipping`);\n }\n }\n\n for (const artifact of Object.keys(reports)) {\n const boldArtifact = chalk.bold(artifact); // used for log messages\n\n const artifactFsTimer = timer().start();\n\n const report = reports[artifact];\n const filename = `${artifact}.d.ts`;\n\n try {\n const outPath = await saveDefinitionToFileSystem(registryPwd, filename, report.output);\n const relativeOutPath = path.relative(process.cwd(), outPath);\n\n artifactFsTimer.end();\n\n logger.info(`Saved ${boldArtifact} types in ${chalk.bold(relativeOutPath)}`);\n logger.debug(`Saved ${boldArtifact} in ${artifactFsTimer.duration}s`);\n } catch (e) {\n logger.error(\n `An error occurred while saving ${boldArtifact} types to the filesystem: ${\n (e as any).message ?? (e as any).toString()\n }. Exiting`\n );\n return returnWithMessage();\n }\n }\n\n return returnWithMessage();\n};\n"],"names":["GENERATORS","contentTypes","generateContentTypesDefinitions","components","generateComponentsDefinitions","generate","config","pwd","rootDir","TYPES_ROOT_DIR","strapi","artifacts","logger","loggerConfig","reports","createLogger","psTimer","timer","start","registryPwd","path","join","GENERATED_OUT_DIR","generatorConfig","returnWithMessage","nbWarnings","chalk","yellow","warnings","nbErrors","red","errors","status","green","end","info","duration","enabledArtifacts","Object","keys","filter","p","debug","artifact","boldArtifact","bold","generator","artifactGenTimer","e","error","message","toString","warn","artifactFsTimer","report","filename","outPath","saveDefinitionToFileSystem","output","relativeOutPath","relative","process","cwd"],"mappings":";;;;;;;;;;;;;;AAQA,MAAMA,UAAAA,GAAa;IACjBC,YAAAA,EAAcC,uCAAAA;IACdC,UAAAA,EAAYC;AACd,CAAA;AAqBA;;AAEC,IACM,MAAMC,QAAAA,GAAW,OAAOC,MAAAA,GAAyB,EAAoB,GAAA;AAC1E,IAAA,MAAM,EAAEC,GAAG,EAAEC,OAAAA,GAAUC,wBAAc,EAAEC,MAAM,EAAEC,SAAAA,GAAY,EAAE,EAAEC,MAAAA,EAAQC,YAAY,EAAE,GAAGP,MAAAA;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ogger, timer, saveDefinitionToFileSystem } from './utils.mjs';
|
|
5
|
+
import { generateContentTypesDefinitions } from './content-types/index.mjs';
|
|
6
|
+
import { generateComponentsDefinitions } from './components/index.mjs';
|
|
7
|
+
|
|
8
|
+
const GENERATORS = {
|
|
9
|
+
contentTypes: generateContentTypesDefinitions,
|
|
10
|
+
components: generateComponentsDefinitions
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Generate types definitions based on the given configuration
|
|
14
|
+
*/ const generate = async (config = {})=>{
|
|
15
|
+
const { pwd, rootDir = TYPES_ROOT_DIR, strapi, artifacts = {}, logger: loggerConfig } = config;
|
|
16
|
+
const reports = {};
|
|
17
|
+
const logger = createLogger(loggerConfig);
|
|
18
|
+
const psTimer = timer().start();
|
|
19
|
+
const registryPwd = path.join(pwd, rootDir, GENERATED_OUT_DIR);
|
|
20
|
+
const generatorConfig = {
|
|
21
|
+
strapi,
|
|
22
|
+
pwd: registryPwd,
|
|
23
|
+
logger
|
|
24
|
+
};
|
|
25
|
+
const returnWithMessage = ()=>{
|
|
26
|
+
const nbWarnings = chalk.yellow(`${logger.warnings} warning(s)`);
|
|
27
|
+
const nbErrors = chalk.red(`${logger.errors} error(s)`);
|
|
28
|
+
const status = logger.errors > 0 ? chalk.red('errored') : chalk.green('completed successfully');
|
|
29
|
+
psTimer.end();
|
|
30
|
+
logger.info(`The task ${status} with ${nbWarnings} and ${nbErrors} in ${psTimer.duration}s.`);
|
|
31
|
+
return reports;
|
|
32
|
+
};
|
|
33
|
+
const enabledArtifacts = Object.keys(artifacts).filter((p)=>artifacts[p] === true);
|
|
34
|
+
logger.info('Starting the type generation process');
|
|
35
|
+
logger.debug(`Enabled artifacts: ${enabledArtifacts.join(', ')}`);
|
|
36
|
+
for (const artifact of enabledArtifacts){
|
|
37
|
+
const boldArtifact = chalk.bold(artifact); // used for log messages
|
|
38
|
+
logger.info(`Generating types for ${boldArtifact}`);
|
|
39
|
+
if (artifact in GENERATORS) {
|
|
40
|
+
const generator = GENERATORS[artifact];
|
|
41
|
+
try {
|
|
42
|
+
const artifactGenTimer = timer().start();
|
|
43
|
+
reports[artifact] = await generator(generatorConfig);
|
|
44
|
+
artifactGenTimer.end();
|
|
45
|
+
logger.debug(`Generated ${boldArtifact} in ${artifactGenTimer.duration}s`);
|
|
46
|
+
} catch (e) {
|
|
47
|
+
logger.error(`Failed to generate types for ${boldArtifact}: ${e.message ?? e.toString()}. Exiting`);
|
|
48
|
+
return returnWithMessage();
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
logger.warn(`The types generator for ${boldArtifact} is not implemented, skipping`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
for (const artifact of Object.keys(reports)){
|
|
55
|
+
const boldArtifact = chalk.bold(artifact); // used for log messages
|
|
56
|
+
const artifactFsTimer = timer().start();
|
|
57
|
+
const report = reports[artifact];
|
|
58
|
+
const filename = `${artifact}.d.ts`;
|
|
59
|
+
try {
|
|
60
|
+
const outPath = await saveDefinitionToFileSystem(registryPwd, filename, report.output);
|
|
61
|
+
const relativeOutPath = path.relative(process.cwd(), outPath);
|
|
62
|
+
artifactFsTimer.end();
|
|
63
|
+
logger.info(`Saved ${boldArtifact} types in ${chalk.bold(relativeOutPath)}`);
|
|
64
|
+
logger.debug(`Saved ${boldArtifact} in ${artifactFsTimer.duration}s`);
|
|
65
|
+
} catch (e) {
|
|
66
|
+
logger.error(`An error occurred while saving ${boldArtifact} types to the filesystem: ${e.message ?? e.toString()}. Exiting`);
|
|
67
|
+
return returnWithMessage();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return returnWithMessage();
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export { generate };
|
|
74
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/generators/index.ts"],"sourcesContent":["import path from 'node:path';\nimport chalk from 'chalk';\n\nimport { TYPES_ROOT_DIR, GENERATED_OUT_DIR } from './constants';\nimport { saveDefinitionToFileSystem, createLogger, timer } from './utils';\nimport { generateContentTypesDefinitions } from './content-types';\nimport { generateComponentsDefinitions } from './components';\n\nconst GENERATORS = {\n contentTypes: generateContentTypesDefinitions,\n components: generateComponentsDefinitions,\n};\n\nexport interface GenerateConfig {\n strapi: any;\n pwd: string;\n rootDir?: string;\n artifacts?: {\n contentTypes?: boolean;\n components?: boolean;\n services?: boolean;\n controllers?: boolean;\n policies?: boolean;\n middlewares?: boolean;\n };\n logger?: {\n silent?: boolean;\n debug?: boolean;\n verbose?: boolean;\n };\n}\n\n/**\n * Generate types definitions based on the given configuration\n */\nexport const generate = async (config: GenerateConfig = {} as GenerateConfig) => {\n const { pwd, rootDir = TYPES_ROOT_DIR, strapi, artifacts = {}, logger: loggerConfig } = config;\n const reports: Record<string, any> = {};\n const logger = createLogger(loggerConfig);\n const psTimer = timer().start();\n\n const registryPwd = path.join(pwd, rootDir, GENERATED_OUT_DIR);\n const generatorConfig = { strapi, pwd: registryPwd, logger };\n\n const returnWithMessage = () => {\n const nbWarnings = chalk.yellow(`${logger.warnings} warning(s)`);\n const nbErrors = chalk.red(`${logger.errors} error(s)`);\n\n const status = logger.errors > 0 ? chalk.red('errored') : chalk.green('completed successfully');\n\n psTimer.end();\n\n logger.info(`The task ${status} with ${nbWarnings} and ${nbErrors} in ${psTimer.duration}s.`);\n\n return reports;\n };\n\n const enabledArtifacts = Object.keys(artifacts).filter(\n (p) => (artifacts as Record<string, boolean>)[p] === true\n );\n\n logger.info('Starting the type generation process');\n logger.debug(`Enabled artifacts: ${enabledArtifacts.join(', ')}`);\n\n for (const artifact of enabledArtifacts) {\n const boldArtifact = chalk.bold(artifact); // used for log messages\n\n logger.info(`Generating types for ${boldArtifact}`);\n\n if (artifact in GENERATORS) {\n const generator = (GENERATORS as any)[artifact];\n\n try {\n const artifactGenTimer = timer().start();\n\n reports[artifact] = await generator(generatorConfig);\n\n artifactGenTimer.end();\n\n logger.debug(`Generated ${boldArtifact} in ${artifactGenTimer.duration}s`);\n } catch (e) {\n logger.error(\n `Failed to generate types for ${boldArtifact}: ${(e as any).message ?? (e as any).toString()}. Exiting`\n );\n return returnWithMessage();\n }\n } else {\n logger.warn(`The types generator for ${boldArtifact} is not implemented, skipping`);\n }\n }\n\n for (const artifact of Object.keys(reports)) {\n const boldArtifact = chalk.bold(artifact); // used for log messages\n\n const artifactFsTimer = timer().start();\n\n const report = reports[artifact];\n const filename = `${artifact}.d.ts`;\n\n try {\n const outPath = await saveDefinitionToFileSystem(registryPwd, filename, report.output);\n const relativeOutPath = path.relative(process.cwd(), outPath);\n\n artifactFsTimer.end();\n\n logger.info(`Saved ${boldArtifact} types in ${chalk.bold(relativeOutPath)}`);\n logger.debug(`Saved ${boldArtifact} in ${artifactFsTimer.duration}s`);\n } catch (e) {\n logger.error(\n `An error occurred while saving ${boldArtifact} types to the filesystem: ${\n (e as any).message ?? (e as any).toString()\n }. Exiting`\n );\n return returnWithMessage();\n }\n }\n\n return returnWithMessage();\n};\n"],"names":["GENERATORS","contentTypes","generateContentTypesDefinitions","components","generateComponentsDefinitions","generate","config","pwd","rootDir","TYPES_ROOT_DIR","strapi","artifacts","logger","loggerConfig","reports","createLogger","psTimer","timer","start","registryPwd","path","join","GENERATED_OUT_DIR","generatorConfig","returnWithMessage","nbWarnings","chalk","yellow","warnings","nbErrors","red","errors","status","green","end","info","duration","enabledArtifacts","Object","keys","filter","p","debug","artifact","boldArtifact","bold","generator","artifactGenTimer","e","error","message","toString","warn","artifactFsTimer","report","filename","outPath","saveDefinitionToFileSystem","output","relativeOutPath","relative","process","cwd"],"mappings":";;;;;;;AAQA,MAAMA,UAAAA,GAAa;IACjBC,YAAAA,EAAcC,+BAAAA;IACdC,UAAAA,EAAYC;AACd,CAAA;AAqBA;;AAEC,IACM,MAAMC,QAAAA,GAAW,OAAOC,MAAAA,GAAyB,EAAoB,GAAA;AAC1E,IAAA,MAAM,EAAEC,GAAG,EAAEC,OAAAA,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
/**
|
|
3
|
+
* Aggregate the given TypeScript nodes into a single string
|
|
4
|
+
*/
|
|
5
|
+
export declare const emitDefinitions: (definitions: ts.Node[]) => string;
|
|
6
|
+
/**
|
|
7
|
+
* Save the given string representation of TS nodes in a file
|
|
8
|
+
* If the given directory doesn't exist, it'll be created automatically
|
|
9
|
+
*
|
|
10
|
+
* @return The path of the created file
|
|
11
|
+
*/
|
|
12
|
+
export declare const saveDefinitionToFileSystem: (dir: string, file: string, content: string) => Promise<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Format the given definitions.
|
|
15
|
+
* Uses the existing config if one is defined in the project.
|
|
16
|
+
*/
|
|
17
|
+
export declare const format: (content: string) => Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Generate the extension block for a shared component from strapi/strapi
|
|
20
|
+
*/
|
|
21
|
+
export declare const generateSharedExtensionDefinition: (registry: string, definitions: Array<{
|
|
22
|
+
uid: string;
|
|
23
|
+
definition: ts.InterfaceDeclaration;
|
|
24
|
+
}>) => ts.ModuleDeclaration;
|
|
25
|
+
interface CreateLoggerOptions {
|
|
26
|
+
silent?: boolean;
|
|
27
|
+
debug?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare const createLogger: (options?: CreateLoggerOptions) => {
|
|
30
|
+
readonly warnings: number;
|
|
31
|
+
readonly errors: number;
|
|
32
|
+
debug(...args: any[]): void;
|
|
33
|
+
info(...args: any[]): void;
|
|
34
|
+
warn(...args: any[]): void;
|
|
35
|
+
error(...args: any[]): void;
|
|
36
|
+
};
|
|
37
|
+
export declare const timer: () => {
|
|
38
|
+
start(): /*elided*/ any;
|
|
39
|
+
end(): /*elided*/ any;
|
|
40
|
+
readonly duration: number;
|
|
41
|
+
};
|
|
42
|
+
export type Logger = ReturnType<typeof createLogger>;
|
|
43
|
+
/**
|
|
44
|
+
* Options passed to each artifact generator (content-types, components).
|
|
45
|
+
*/
|
|
46
|
+
export interface GeneratorOptions {
|
|
47
|
+
strapi: any;
|
|
48
|
+
logger: Logger;
|
|
49
|
+
pwd?: string;
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/generators/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AASjC;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,aAAa,EAAE,CAAC,IAAI,EAAE,KAAG,MAcxD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,GACrC,KAAK,MAAM,EACX,MAAM,MAAM,EACZ,SAAS,MAAM,KACd,OAAO,CAAC,MAAM,CAOhB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,MAAM,GAAU,SAAS,MAAM,KAAG,OAAO,CAAC,MAAM,CAiB5D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iCAAiC,GAC5C,UAAU,MAAM,EAChB,aAAa,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,EAAE,CAAC,oBAAoB,CAAA;CAAE,CAAC,KACvE,EAAE,CAAC,iBAqCL,CAAC;AAEF,UAAU,mBAAmB;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,eAAO,MAAM,YAAY,GAAI,UAAS,mBAAwB;;;mBAc3C,GAAG,EAAE;kBAQN,GAAG,EAAE;kBAQL,GAAG,EAAE;mBAUJ,GAAG,EAAE;CAUvB,CAAC;AAEF,eAAO,MAAM,KAAK;;;;CA+BjB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('node:path');
|
|
4
|
+
var assert = require('node:assert');
|
|
5
|
+
var ts = require('typescript');
|
|
6
|
+
var fse = require('fs-extra');
|
|
7
|
+
var chalk = require('chalk');
|
|
8
|
+
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
function _interopNamespace(e) {
|
|
12
|
+
if (e && e.__esModule) return e;
|
|
13
|
+
var n = Object.create(null);
|
|
14
|
+
if (e) {
|
|
15
|
+
Object.keys(e).forEach(function (k) {
|
|
16
|
+
if (k !== 'default') {
|
|
17
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
18
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return e[k]; }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
n.default = e;
|
|
26
|
+
return Object.freeze(n);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
30
|
+
var assert__default = /*#__PURE__*/_interopDefault(assert);
|
|
31
|
+
var ts__namespace = /*#__PURE__*/_interopNamespace(ts);
|
|
32
|
+
var fse__default = /*#__PURE__*/_interopDefault(fse);
|
|
33
|
+
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
34
|
+
|
|
35
|
+
const { factory } = ts__namespace;
|
|
36
|
+
const MODULE_DECLARATION = '@strapi/strapi';
|
|
37
|
+
const PUBLIC_NAMESPACE = 'Public';
|
|
38
|
+
/**
|
|
39
|
+
* Aggregate the given TypeScript nodes into a single string
|
|
40
|
+
*/ const emitDefinitions = (definitions)=>{
|
|
41
|
+
const nodeArray = factory.createNodeArray(definitions);
|
|
42
|
+
const sourceFile = ts__namespace.createSourceFile('placeholder.ts', '', ts__namespace.ScriptTarget.ESNext, true, ts__namespace.ScriptKind.TS);
|
|
43
|
+
const printer = ts__namespace.createPrinter({
|
|
44
|
+
omitTrailingSemicolon: true
|
|
45
|
+
});
|
|
46
|
+
return printer.printList(ts__namespace.ListFormat.MultiLine, nodeArray, sourceFile);
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Save the given string representation of TS nodes in a file
|
|
50
|
+
* If the given directory doesn't exist, it'll be created automatically
|
|
51
|
+
*
|
|
52
|
+
* @return The path of the created file
|
|
53
|
+
*/ const saveDefinitionToFileSystem = async (dir, file, content)=>{
|
|
54
|
+
const filepath = path__default.default.join(dir, file);
|
|
55
|
+
fse__default.default.ensureDirSync(dir);
|
|
56
|
+
await fse__default.default.writeFile(filepath, content);
|
|
57
|
+
return filepath;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Format the given definitions.
|
|
61
|
+
* Uses the existing config if one is defined in the project.
|
|
62
|
+
*/ const format = async (content)=>{
|
|
63
|
+
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
|
64
|
+
const prettier = await import('prettier'); // ESM-only
|
|
65
|
+
const configFile = await prettier.resolveConfigFile();
|
|
66
|
+
const config = configFile ? await prettier.resolveConfig(configFile) : {
|
|
67
|
+
singleQuote: true,
|
|
68
|
+
useTabs: false,
|
|
69
|
+
tabWidth: 2
|
|
70
|
+
};
|
|
71
|
+
Object.assign(config, {
|
|
72
|
+
parser: 'typescript'
|
|
73
|
+
});
|
|
74
|
+
return prettier.format(content, config);
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Generate the extension block for a shared component from strapi/strapi
|
|
78
|
+
*/ const generateSharedExtensionDefinition = (registry, definitions)=>{
|
|
79
|
+
const properties = definitions.map(({ uid, definition })=>factory.createPropertySignature(undefined, factory.createStringLiteral(uid, true), undefined, factory.createTypeReferenceNode(factory.createIdentifier(definition.name.escapedText))));
|
|
80
|
+
return factory.createModuleDeclaration([
|
|
81
|
+
factory.createModifier(ts__namespace.SyntaxKind.DeclareKeyword)
|
|
82
|
+
], factory.createStringLiteral(MODULE_DECLARATION, true), factory.createModuleBlock([
|
|
83
|
+
factory.createModuleDeclaration([
|
|
84
|
+
factory.createModifier(ts__namespace.SyntaxKind.ExportKeyword)
|
|
85
|
+
], factory.createIdentifier(PUBLIC_NAMESPACE), factory.createModuleBlock(properties.length > 0 ? [
|
|
86
|
+
factory.createInterfaceDeclaration([
|
|
87
|
+
factory.createModifier(ts__namespace.SyntaxKind.ExportKeyword)
|
|
88
|
+
], factory.createIdentifier(registry), undefined, undefined, properties)
|
|
89
|
+
] : []), ts__namespace.NodeFlags.Namespace)
|
|
90
|
+
]), ts__namespace.NodeFlags.ExportContext);
|
|
91
|
+
};
|
|
92
|
+
const createLogger = (options = {})=>{
|
|
93
|
+
const { silent = false, debug = false } = options;
|
|
94
|
+
const state = {
|
|
95
|
+
errors: 0,
|
|
96
|
+
warning: 0
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
get warnings () {
|
|
100
|
+
return state.warning;
|
|
101
|
+
},
|
|
102
|
+
get errors () {
|
|
103
|
+
return state.errors;
|
|
104
|
+
},
|
|
105
|
+
debug (...args) {
|
|
106
|
+
if (silent || !debug) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
console.log(chalk__default.default.cyan(`[DEBUG]\t[${new Date().toISOString()}] (Typegen)`), ...args);
|
|
110
|
+
},
|
|
111
|
+
info (...args) {
|
|
112
|
+
if (silent) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
console.info(chalk__default.default.blue(`[INFO]\t[${new Date().toISOString()}] (Typegen)`), ...args);
|
|
116
|
+
},
|
|
117
|
+
warn (...args) {
|
|
118
|
+
state.warning += 1;
|
|
119
|
+
if (silent) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
console.warn(chalk__default.default.yellow(`[WARN]\t[${new Date().toISOString()}] (Typegen)`), ...args);
|
|
123
|
+
},
|
|
124
|
+
error (...args) {
|
|
125
|
+
state.errors += 1;
|
|
126
|
+
if (silent) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
console.error(chalk__default.default.red(`[ERROR]\t[${new Date().toISOString()}] (Typegen)`), ...args);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
const timer = ()=>{
|
|
134
|
+
const state = {
|
|
135
|
+
start: null,
|
|
136
|
+
end: null
|
|
137
|
+
};
|
|
138
|
+
return {
|
|
139
|
+
start () {
|
|
140
|
+
assert__default.default(state.start === null, 'The timer has already been started');
|
|
141
|
+
assert__default.default(state.end === null, 'The timer has already been ended');
|
|
142
|
+
state.start = Date.now();
|
|
143
|
+
return this;
|
|
144
|
+
},
|
|
145
|
+
end () {
|
|
146
|
+
assert__default.default(state.start !== null, 'The timer needs to be started before ending it');
|
|
147
|
+
assert__default.default(state.end === null, 'The timer has already been ended');
|
|
148
|
+
state.end = Date.now();
|
|
149
|
+
return this;
|
|
150
|
+
},
|
|
151
|
+
get duration () {
|
|
152
|
+
assert__default.default(state.start !== null, 'The timer has not been started');
|
|
153
|
+
return ((state.end ?? Date.now) - state.start) / 1000;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
exports.createLogger = createLogger;
|
|
159
|
+
exports.emitDefinitions = emitDefinitions;
|
|
160
|
+
exports.format = format;
|
|
161
|
+
exports.generateSharedExtensionDefinition = generateSharedExtensionDefinition;
|
|
162
|
+
exports.saveDefinitionToFileSystem = saveDefinitionToFileSystem;
|
|
163
|
+
exports.timer = timer;
|
|
164
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../src/generators/utils.ts"],"sourcesContent":["import path from 'node:path';\nimport assert from 'node:assert';\nimport * as ts from 'typescript';\nimport fse from 'fs-extra';\nimport chalk from 'chalk';\n\nconst { factory } = ts;\n\nconst MODULE_DECLARATION = '@strapi/strapi';\nconst PUBLIC_NAMESPACE = 'Public';\n\n/**\n * Aggregate the given TypeScript nodes into a single string\n */\nexport const emitDefinitions = (definitions: ts.Node[]): string => {\n const nodeArray = factory.createNodeArray(definitions);\n\n const sourceFile = ts.createSourceFile(\n 'placeholder.ts',\n '',\n ts.ScriptTarget.ESNext,\n true,\n ts.ScriptKind.TS\n );\n\n const printer = ts.createPrinter({ omitTrailingSemicolon: true });\n\n return printer.printList(ts.ListFormat.MultiLine, nodeArray, sourceFile);\n};\n\n/**\n * Save the given string representation of TS nodes in a file\n * If the given directory doesn't exist, it'll be created automatically\n *\n * @return The path of the created file\n */\nexport const saveDefinitionToFileSystem = async (\n dir: string,\n file: string,\n content: string\n): Promise<string> => {\n const filepath = path.join(dir, file);\n\n fse.ensureDirSync(dir);\n await fse.writeFile(filepath, content);\n\n return filepath;\n};\n\n/**\n * Format the given definitions.\n * Uses the existing config if one is defined in the project.\n */\nexport const format = async (content: string): Promise<string> => {\n // eslint-disable-next-line node/no-unsupported-features/es-syntax\n const prettier = await import('prettier'); // ESM-only\n\n const configFile = await prettier.resolveConfigFile();\n const config: any = configFile\n ? await prettier.resolveConfig(configFile)\n : // Default config\n {\n singleQuote: true,\n useTabs: false,\n tabWidth: 2,\n };\n\n Object.assign(config, { parser: 'typescript' });\n\n return prettier.format(content, config);\n};\n\n/**\n * Generate the extension block for a shared component from strapi/strapi\n */\nexport const generateSharedExtensionDefinition = (\n registry: string,\n definitions: Array<{ uid: string; definition: ts.InterfaceDeclaration }>\n): ts.ModuleDeclaration => {\n const properties = definitions.map(({ uid, definition }) =>\n factory.createPropertySignature(\n undefined,\n factory.createStringLiteral(uid, true),\n undefined,\n factory.createTypeReferenceNode(\n factory.createIdentifier(definition.name.escapedText as string)\n )\n )\n );\n\n return factory.createModuleDeclaration(\n [factory.createModifier(ts.SyntaxKind.DeclareKeyword)],\n factory.createStringLiteral(MODULE_DECLARATION, true),\n factory.createModuleBlock([\n factory.createModuleDeclaration(\n [factory.createModifier(ts.SyntaxKind.ExportKeyword)],\n factory.createIdentifier(PUBLIC_NAMESPACE),\n factory.createModuleBlock(\n properties.length > 0\n ? [\n factory.createInterfaceDeclaration(\n [factory.createModifier(ts.SyntaxKind.ExportKeyword)],\n factory.createIdentifier(registry),\n undefined,\n undefined,\n properties\n ),\n ]\n : []\n ),\n ts.NodeFlags.Namespace\n ),\n ]),\n ts.NodeFlags.ExportContext\n );\n};\n\ninterface CreateLoggerOptions {\n silent?: boolean;\n debug?: boolean;\n}\n\nexport const createLogger = (options: CreateLoggerOptions = {}) => {\n const { silent = false, debug = false } = options;\n\n const state = { errors: 0, warning: 0 };\n\n return {\n get warnings() {\n return state.warning;\n },\n\n get errors() {\n return state.errors;\n },\n\n debug(...args: any[]) {\n if (silent || !debug) {\n return;\n }\n\n console.log(chalk.cyan(`[DEBUG]\\t[${new Date().toISOString()}] (Typegen)`), ...args);\n },\n\n info(...args: any[]) {\n if (silent) {\n return;\n }\n\n console.info(chalk.blue(`[INFO]\\t[${new Date().toISOString()}] (Typegen)`), ...args);\n },\n\n warn(...args: any[]) {\n state.warning += 1;\n\n if (silent) {\n return;\n }\n\n console.warn(chalk.yellow(`[WARN]\\t[${new Date().toISOString()}] (Typegen)`), ...args);\n },\n\n error(...args: any[]) {\n state.errors += 1;\n\n if (silent) {\n return;\n }\n\n console.error(chalk.red(`[ERROR]\\t[${new Date().toISOString()}] (Typegen)`), ...args);\n },\n };\n};\n\nexport const timer = () => {\n const state: { start: number | null; end: number | null } = {\n start: null,\n end: null,\n };\n\n return {\n start() {\n assert(state.start === null, 'The timer has already been started');\n assert(state.end === null, 'The timer has already been ended');\n\n state.start = Date.now();\n\n return this;\n },\n\n end() {\n assert(state.start !== null, 'The timer needs to be started before ending it');\n assert(state.end === null, 'The timer has already been ended');\n\n state.end = Date.now();\n\n return this;\n },\n\n get duration() {\n assert(state.start !== null, 'The timer has not been started');\n\n return (((state.end ?? Date.now) as any) - (state.start as number)) / 1000;\n },\n };\n};\n\nexport type Logger = ReturnType<typeof createLogger>;\n\n/**\n * Options passed to each artifact generator (content-types, components).\n */\nexport interface GeneratorOptions {\n strapi: any;\n logger: Logger;\n pwd?: string;\n}\n"],"names":["factory","ts","MODULE_DECLARATION","PUBLIC_NAMESPACE","emitDefinitions","definitions","nodeArray","createNodeArray","sourceFile","createSourceFile","ScriptTarget","ESNext","ScriptKind","TS","printer","createPrinter","omitTrailingSemicolon","printList","ListFormat","MultiLine","saveDefinitionToFileSystem","dir","file","content","filepath","path","join","fse","ensureDirSync","writeFile","format","prettier","configFile","resolveConfigFile","config","resolveConfig","singleQuote","useTabs","tabWidth","Object","assign","parser","generateSharedExtensionDefinition","registry","properties","map","uid","definition","createPropertySignature","undefined","createStringLiteral","createTypeReferenceNode","createIdentifier","name","escapedText","createModuleDeclaration","createModifier","SyntaxKind","DeclareKeyword","createModuleBlock","ExportKeyword","length","createInterfaceDeclaration","NodeFlags","Namespace","ExportContext","createLogger","options","silent","debug","state","errors","warning","warnings","args","console","log","chalk","cyan","Date","toISOString","info","blue","warn","yellow","error","red","timer","start","end","assert","now","duration"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,EAAEA,OAAO,EAAE,GAAGC,aAAAA;AAEpB,MAAMC,kBAAAA,GAAqB,gBAAA;AAC3B,MAAMC,gBAAAA,GAAmB,QAAA;AAEzB;;IAGO,MAAMC,eAAAA,GAAkB,CAACC,WAAAA,GAAAA;IAC9B,MAAMC,SAAAA,GAAYN,OAAAA,CAAQO,eAAe,CAACF,WAAAA,CAAAA;AAE1C,IAAA,MAAMG,UAAAA,GAAaP,aAAAA,CAAGQ,gBAAgB,CACpC,kBACA,EAAA,EACAR,aAAAA,CAAGS,YAAY,CAACC,MAAM,EACtB,IAAA,EACAV,aAAAA,CAAGW,UAAU,CAACC,EAAE,CAAA;IAGlB,MAAMC,OAAAA,GAAUb,aAAAA,CAAGc,aAAa,CAAC;QAAEC,qBAAAA,EAAuB;AAAK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