@strapi/typescript-utils 0.0.0-next.ee56af7ae29770097422de95c0d5500908dce15c → 0.0.0-next.eedb036f0a7ac282d2a645d8a40625091bd28b1e
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/generators/common/imports.js +3 -3
- package/lib/generators/common/models/schema.js +5 -3
- package/lib/generators/common/models/utils.js +1 -1
- package/lib/generators/components/index.js +9 -4
- package/lib/generators/content-types/index.js +9 -4
- package/lib/utils/index.js +2 -0
- package/lib/utils/resolve-outdir-sync.js +18 -0
- package/package.json +2 -2
|
@@ -18,9 +18,9 @@ module.exports = {
|
|
|
18
18
|
},
|
|
19
19
|
|
|
20
20
|
generateImportDefinition() {
|
|
21
|
-
const formattedImports = imports
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const formattedImports = imports
|
|
22
|
+
.sort()
|
|
23
|
+
.map((key) => factory.createImportSpecifier(false, undefined, factory.createIdentifier(key)));
|
|
24
24
|
|
|
25
25
|
return [
|
|
26
26
|
factory.createImportDeclaration(
|
|
@@ -22,9 +22,11 @@ const { addImport } = require('../imports');
|
|
|
22
22
|
const generateAttributePropertySignature = (schema) => {
|
|
23
23
|
const { attributes } = schema;
|
|
24
24
|
|
|
25
|
-
const properties = Object.entries(attributes)
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const properties = Object.entries(attributes)
|
|
26
|
+
.sort((a, b) => a[0].localeCompare(b[0]))
|
|
27
|
+
.map(([attributeName, attribute]) => {
|
|
28
|
+
return attributeToPropertySignature(schema, attributeName, attribute);
|
|
29
|
+
});
|
|
28
30
|
|
|
29
31
|
return factory.createPropertySignature(
|
|
30
32
|
undefined,
|
|
@@ -111,7 +111,7 @@ const toTypeLiteral = (data) => {
|
|
|
111
111
|
throw new Error(`Cannot convert to object literal. Unknown type "${typeof data}"`);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
const entries = Object.entries(data);
|
|
114
|
+
const entries = Object.entries(data).sort((a, b) => a[0].localeCompare(b[0]));
|
|
115
115
|
|
|
116
116
|
const props = entries.reduce((acc, [key, value]) => {
|
|
117
117
|
// Handle keys such as content-type-builder & co.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const { factory } = require('typescript');
|
|
4
|
+
const { pipe, values, sortBy, map } = require('lodash/fp');
|
|
4
5
|
|
|
5
6
|
const { models } = require('../common');
|
|
6
7
|
const { emitDefinitions, format, generateSharedExtensionDefinition } = require('../utils');
|
|
@@ -23,10 +24,14 @@ const generateComponentsDefinitions = async (options = {}) => {
|
|
|
23
24
|
|
|
24
25
|
const { components } = strapi;
|
|
25
26
|
|
|
26
|
-
const componentsDefinitions =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const componentsDefinitions = pipe(
|
|
28
|
+
values,
|
|
29
|
+
sortBy('uid'),
|
|
30
|
+
map((component) => ({
|
|
31
|
+
uid: component.uid,
|
|
32
|
+
definition: models.schema.generateSchemaDefinition(component),
|
|
33
|
+
}))
|
|
34
|
+
)(components);
|
|
30
35
|
|
|
31
36
|
options.logger.debug(`Found ${componentsDefinitions.length} components.`);
|
|
32
37
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const { factory } = require('typescript');
|
|
4
|
+
const { values, pipe, map, sortBy } = require('lodash/fp');
|
|
4
5
|
|
|
5
6
|
const { models } = require('../common');
|
|
6
7
|
const { emitDefinitions, format, generateSharedExtensionDefinition } = require('../utils');
|
|
@@ -23,10 +24,14 @@ const generateContentTypesDefinitions = async (options = {}) => {
|
|
|
23
24
|
|
|
24
25
|
const { contentTypes } = strapi;
|
|
25
26
|
|
|
26
|
-
const contentTypesDefinitions =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const contentTypesDefinitions = pipe(
|
|
28
|
+
values,
|
|
29
|
+
sortBy('uid'),
|
|
30
|
+
map((contentType) => ({
|
|
31
|
+
uid: contentType.uid,
|
|
32
|
+
definition: models.schema.generateSchemaDefinition(contentType),
|
|
33
|
+
}))
|
|
34
|
+
)(contentTypes);
|
|
30
35
|
|
|
31
36
|
options.logger.debug(`Found ${contentTypesDefinitions.length} content-types.`);
|
|
32
37
|
|
package/lib/utils/index.js
CHANGED
|
@@ -7,6 +7,7 @@ const reportDiagnostics = require('./report-diagnostics');
|
|
|
7
7
|
const resolveConfigOptions = require('./resolve-config-options');
|
|
8
8
|
const formatHost = require('./format-host');
|
|
9
9
|
const resolveOutDir = require('./resolve-outdir');
|
|
10
|
+
const resolveOutDirSync = require('./resolve-outdir-sync');
|
|
10
11
|
|
|
11
12
|
module.exports = {
|
|
12
13
|
isUsingTypeScript,
|
|
@@ -16,4 +17,5 @@ module.exports = {
|
|
|
16
17
|
resolveConfigOptions,
|
|
17
18
|
formatHost,
|
|
18
19
|
resolveOutDir,
|
|
20
|
+
resolveOutDirSync,
|
|
19
21
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const resolveConfigOptions = require('./resolve-config-options');
|
|
5
|
+
const isUsingTypescriptSync = require('./is-using-typescript-sync');
|
|
6
|
+
|
|
7
|
+
const DEFAULT_TS_CONFIG_FILENAME = 'tsconfig.json';
|
|
8
|
+
/**
|
|
9
|
+
* Gets the outDir value from config file (tsconfig)
|
|
10
|
+
* @param {string} dir
|
|
11
|
+
* @param {string | undefined} configFilename
|
|
12
|
+
* @returns {string | undefined}
|
|
13
|
+
*/
|
|
14
|
+
module.exports = (dir, configFilename = DEFAULT_TS_CONFIG_FILENAME) => {
|
|
15
|
+
return isUsingTypescriptSync(dir)
|
|
16
|
+
? resolveConfigOptions(path.join(dir, configFilename)).options.outDir
|
|
17
|
+
: undefined;
|
|
18
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/typescript-utils",
|
|
3
|
-
"version": "0.0.0-next.
|
|
3
|
+
"version": "0.0.0-next.eedb036f0a7ac282d2a645d8a40625091bd28b1e",
|
|
4
4
|
"description": "Typescript support for Strapi",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"node": ">=18.0.0 <=22.x.x",
|
|
50
50
|
"npm": ">=6.0.0"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "eedb036f0a7ac282d2a645d8a40625091bd28b1e"
|
|
53
53
|
}
|