@strapi/typescript-utils 0.0.0-experimental.62ce06180fe9a772eaeb3d43d238b26644f39f7c → 0.0.0-experimental.6340da17068c3bed7fb006e7bcc554c71129e282
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/.eslintrc.cjs +16 -0
- package/LICENSE +18 -3
- package/lib/__tests__/generators/schemas/attributes.test.js +18 -23
- package/lib/__tests__/generators/schemas/utils.test.js +37 -31
- package/lib/compilers/basic.js +1 -1
- package/lib/generators/common/imports.js +3 -3
- package/lib/generators/common/models/schema.js +5 -3
- package/lib/generators/common/models/utils.js +7 -2
- package/lib/generators/components/index.js +20 -4
- package/lib/generators/content-types/index.js +20 -4
- package/lib/utils/index.js +2 -0
- package/lib/utils/is-using-typescript-sync.js +3 -1
- package/lib/utils/resolve-outdir-sync.js +18 -0
- package/lint-staged.config.mjs +1 -0
- package/package.json +13 -10
- package/tsconfigs/admin.json +19 -0
- package/.eslintignore +0 -3
- package/.eslintrc.js +0 -4
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/** @type {import('eslint').Linter.Config} */
|
|
4
|
+
const config = {
|
|
5
|
+
root: true,
|
|
6
|
+
extends: ['eslint-config-custom/back'],
|
|
7
|
+
ignorePatterns: [
|
|
8
|
+
'node_modules/',
|
|
9
|
+
'.eslintrc.cjs',
|
|
10
|
+
'index.d.ts',
|
|
11
|
+
'coverage/',
|
|
12
|
+
'lint-staged.config.mjs',
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
module.exports = config;
|
package/LICENSE
CHANGED
|
@@ -2,7 +2,21 @@ Copyright (c) 2015-present Strapi Solutions SAS
|
|
|
2
2
|
|
|
3
3
|
Portions of the Strapi software are licensed as follows:
|
|
4
4
|
|
|
5
|
-
* All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined
|
|
5
|
+
* All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined below.
|
|
6
|
+
|
|
7
|
+
Enterprise License
|
|
8
|
+
|
|
9
|
+
If you or the company you represent has entered into a written agreement referencing the Enterprise Edition of the Strapi source code available at
|
|
10
|
+
https://github.com/strapi/strapi, then such agreement applies to your use of the Enterprise Edition of the Strapi Software. If you or the company you
|
|
11
|
+
represent is using the Enterprise Edition of the Strapi Software in connection with a subscription to our cloud offering, then the agreement you have
|
|
12
|
+
agreed to with respect to our cloud offering and the licenses included in such agreement apply to your use of the Enterprise Edition of the Strapi Software.
|
|
13
|
+
Otherwise, the Strapi Enterprise Software License Agreement (found here https://strapi.io/enterprise-terms) applies to your use of the Enterprise Edition of the Strapi Software.
|
|
14
|
+
|
|
15
|
+
BY ACCESSING OR USING THE ENTERPRISE EDITION OF THE STRAPI SOFTWARE, YOU ARE AGREEING TO BE BOUND BY THE RELEVANT REFERENCED AGREEMENT.
|
|
16
|
+
IF YOU ARE NOT AUTHORIZED TO ACCEPT THESE TERMS ON BEHALF OF THE COMPANY YOU REPRESENT OR IF YOU DO NOT AGREE TO ALL OF THE RELEVANT TERMS AND CONDITIONS REFERENCED AND YOU
|
|
17
|
+
HAVE NOT OTHERWISE EXECUTED A WRITTEN AGREEMENT WITH STRAPI, YOU ARE NOT AUTHORIZED TO ACCESS OR USE OR ALLOW ANY USER TO ACCESS OR USE ANY PART OF
|
|
18
|
+
THE ENTERPRISE EDITION OF THE STRAPI SOFTWARE. YOUR ACCESS RIGHTS ARE CONDITIONAL ON YOUR CONSENT TO THE RELEVANT REFERENCED TERMS TO THE EXCLUSION OF ALL OTHER TERMS;
|
|
19
|
+
IF THE RELEVANT REFERENCED TERMS ARE CONSIDERED AN OFFER BY YOU, ACCEPTANCE IS EXPRESSLY LIMITED TO THE RELEVANT REFERENCED TERMS.
|
|
6
20
|
|
|
7
21
|
* All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below.
|
|
8
22
|
|
|
@@ -18,5 +32,6 @@ furnished to do so, subject to the following conditions:
|
|
|
18
32
|
The above copyright notice and this permission notice shall be included in all
|
|
19
33
|
copies or substantial portions of the Software.
|
|
20
34
|
|
|
21
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
-
|
|
35
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
36
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
37
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -680,18 +680,18 @@ describe('Attributes', () => {
|
|
|
680
680
|
expect(definition.kind).toBe(ts.SyntaxKind.TypeLiteral);
|
|
681
681
|
expect(definition.members).toHaveLength(2);
|
|
682
682
|
|
|
683
|
-
const [
|
|
684
|
-
|
|
685
|
-
expect(min.kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
686
|
-
expect(min.name.escapedText).toBe('min');
|
|
687
|
-
expect(min.type.kind).toBe(ts.SyntaxKind.NumericLiteral);
|
|
688
|
-
expect(min.type.text).toBe('4');
|
|
683
|
+
const [max, min] = definition.members;
|
|
689
684
|
|
|
690
685
|
expect(max.kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
691
686
|
expect(max.name.escapedText).toBe('max');
|
|
692
687
|
expect(max.type.kind).toBe(ts.SyntaxKind.NumericLiteral);
|
|
693
688
|
expect(max.type.text).toBe('12');
|
|
694
689
|
|
|
690
|
+
expect(min.kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
691
|
+
expect(min.name.escapedText).toBe('min');
|
|
692
|
+
expect(min.type.kind).toBe(ts.SyntaxKind.NumericLiteral);
|
|
693
|
+
expect(min.type.text).toBe('4');
|
|
694
|
+
|
|
695
695
|
// Check for number keyword on the second typeArgument
|
|
696
696
|
expect(typeofMinMax.kind).toBe(ts.SyntaxKind.NumberKeyword);
|
|
697
697
|
});
|
|
@@ -830,24 +830,19 @@ describe('Attributes', () => {
|
|
|
830
830
|
expect(modifiers[0].typeArguments[0].kind).toBe(ts.SyntaxKind.TypeLiteral);
|
|
831
831
|
expect(modifiers[0].typeArguments[0].members).toHaveLength(2);
|
|
832
832
|
|
|
833
|
-
|
|
834
|
-
expect(modifiers[0].typeArguments[0].members[0].kind).toBe(
|
|
835
|
-
ts.SyntaxKind.PropertyDeclaration
|
|
836
|
-
);
|
|
837
|
-
expect(modifiers[0].typeArguments[0].members[0].name.escapedText).toBe('minLength');
|
|
838
|
-
expect(modifiers[0].typeArguments[0].members[0].type.kind).toBe(
|
|
839
|
-
ts.SyntaxKind.NumericLiteral
|
|
840
|
-
);
|
|
841
|
-
expect(modifiers[0].typeArguments[0].members[0].type.text).toBe('4');
|
|
833
|
+
const [maxLength, minLength] = modifiers[0].typeArguments[0].members;
|
|
842
834
|
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
);
|
|
846
|
-
expect(
|
|
847
|
-
expect(
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
expect(
|
|
835
|
+
// Max
|
|
836
|
+
expect(maxLength.kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
837
|
+
expect(maxLength.name.escapedText).toBe('maxLength');
|
|
838
|
+
expect(maxLength.type.kind).toBe(ts.SyntaxKind.NumericLiteral);
|
|
839
|
+
expect(maxLength.type.text).toBe('12');
|
|
840
|
+
|
|
841
|
+
// Min
|
|
842
|
+
expect(minLength.kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
843
|
+
expect(minLength.name.escapedText).toBe('minLength');
|
|
844
|
+
expect(minLength.type.kind).toBe(ts.SyntaxKind.NumericLiteral);
|
|
845
|
+
expect(minLength.type.text).toBe('4');
|
|
851
846
|
});
|
|
852
847
|
});
|
|
853
848
|
|
|
@@ -168,10 +168,16 @@ describe('Utils', () => {
|
|
|
168
168
|
});
|
|
169
169
|
|
|
170
170
|
test('Number', () => {
|
|
171
|
-
const
|
|
171
|
+
const nodePositive = toTypeLiteral(42);
|
|
172
|
+
const nodeNegative = toTypeLiteral(-42);
|
|
172
173
|
|
|
173
|
-
expect(
|
|
174
|
-
expect(
|
|
174
|
+
expect(nodePositive.kind).toBe(ts.SyntaxKind.FirstLiteralToken);
|
|
175
|
+
expect(nodePositive.text).toBe('42');
|
|
176
|
+
|
|
177
|
+
expect(nodeNegative.kind).toBe(ts.SyntaxKind.PrefixUnaryExpression);
|
|
178
|
+
expect(nodeNegative.operator).toBe(ts.SyntaxKind.MinusToken);
|
|
179
|
+
expect(nodeNegative.operand.kind).toBe(ts.SyntaxKind.FirstLiteralToken);
|
|
180
|
+
expect(nodeNegative.operand.text).toBe('42');
|
|
175
181
|
});
|
|
176
182
|
|
|
177
183
|
test('Boolean', () => {
|
|
@@ -247,13 +253,13 @@ describe('Utils', () => {
|
|
|
247
253
|
expect(objectNode.members).toHaveLength(2);
|
|
248
254
|
|
|
249
255
|
expect(objectNode.members[0].kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
250
|
-
expect(objectNode.members[0].name.escapedText).toBe('
|
|
251
|
-
expect(objectNode.members[0].type.kind).toBe(ts.SyntaxKind.
|
|
252
|
-
expect(objectNode.members[0].type.text).toBe('bar');
|
|
256
|
+
expect(objectNode.members[0].name.escapedText).toBe('bar');
|
|
257
|
+
expect(objectNode.members[0].type.kind).toBe(ts.SyntaxKind.TrueKeyword);
|
|
253
258
|
|
|
254
259
|
expect(objectNode.members[1].kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
255
|
-
expect(objectNode.members[1].name.escapedText).toBe('
|
|
256
|
-
expect(objectNode.members[1].type.kind).toBe(ts.SyntaxKind.
|
|
260
|
+
expect(objectNode.members[1].name.escapedText).toBe('foo');
|
|
261
|
+
expect(objectNode.members[1].type.kind).toBe(ts.SyntaxKind.StringLiteral);
|
|
262
|
+
expect(objectNode.members[1].type.text).toBe('bar');
|
|
257
263
|
});
|
|
258
264
|
|
|
259
265
|
test('Object', () => {
|
|
@@ -262,20 +268,20 @@ describe('Utils', () => {
|
|
|
262
268
|
expect(node.kind).toBe(ts.SyntaxKind.TypeLiteral);
|
|
263
269
|
expect(node.members).toHaveLength(2);
|
|
264
270
|
|
|
265
|
-
const [
|
|
271
|
+
const [barMember, fooMember] = node.members;
|
|
266
272
|
|
|
267
|
-
expect(
|
|
268
|
-
expect(
|
|
269
|
-
expect(
|
|
270
|
-
expect(
|
|
271
|
-
expect(firstMember.type.elements[0].kind).toBe(ts.SyntaxKind.StringLiteral);
|
|
272
|
-
expect(firstMember.type.elements[1].kind).toBe(ts.SyntaxKind.TrueKeyword);
|
|
273
|
-
expect(firstMember.type.elements[2].kind).toBe(ts.SyntaxKind.FirstLiteralToken);
|
|
273
|
+
expect(barMember.kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
274
|
+
expect(barMember.name.escapedText).toBe('bar');
|
|
275
|
+
expect(barMember.type.kind).toBe(ts.SyntaxKind.LiteralType);
|
|
276
|
+
expect(barMember.type.literal).toBe(ts.SyntaxKind.NullKeyword);
|
|
274
277
|
|
|
275
|
-
expect(
|
|
276
|
-
expect(
|
|
277
|
-
expect(
|
|
278
|
-
expect(
|
|
278
|
+
expect(fooMember.kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
279
|
+
expect(fooMember.name.escapedText).toBe('foo');
|
|
280
|
+
expect(fooMember.type.kind).toBe(ts.SyntaxKind.TupleType);
|
|
281
|
+
expect(fooMember.type.elements).toHaveLength(3);
|
|
282
|
+
expect(fooMember.type.elements[0].kind).toBe(ts.SyntaxKind.StringLiteral);
|
|
283
|
+
expect(fooMember.type.elements[1].kind).toBe(ts.SyntaxKind.TrueKeyword);
|
|
284
|
+
expect(fooMember.type.elements[2].kind).toBe(ts.SyntaxKind.FirstLiteralToken);
|
|
279
285
|
});
|
|
280
286
|
|
|
281
287
|
test('Object with complex keys', () => {
|
|
@@ -284,19 +290,19 @@ describe('Utils', () => {
|
|
|
284
290
|
expect(node.kind).toBe(ts.SyntaxKind.TypeLiteral);
|
|
285
291
|
expect(node.members).toHaveLength(2);
|
|
286
292
|
|
|
287
|
-
const [
|
|
293
|
+
const [fooBar, fooDashBar] = node.members;
|
|
288
294
|
|
|
289
|
-
expect(
|
|
290
|
-
expect(
|
|
291
|
-
expect(
|
|
292
|
-
expect(
|
|
293
|
-
expect(
|
|
295
|
+
expect(fooBar.kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
296
|
+
expect(fooBar.name.kind).toBe(ts.SyntaxKind.Identifier);
|
|
297
|
+
expect(fooBar.name.escapedText).toBe('foo');
|
|
298
|
+
expect(fooBar.type.kind).toBe(ts.SyntaxKind.StringLiteral);
|
|
299
|
+
expect(fooBar.type.text).toBe('bar');
|
|
294
300
|
|
|
295
|
-
expect(
|
|
296
|
-
expect(
|
|
297
|
-
expect(
|
|
298
|
-
expect(
|
|
299
|
-
expect(
|
|
301
|
+
expect(fooDashBar.kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
302
|
+
expect(fooDashBar.name.kind).toBe(ts.SyntaxKind.StringLiteral);
|
|
303
|
+
expect(fooDashBar.name.text).toBe('foo-bar');
|
|
304
|
+
expect(fooDashBar.type.kind).toBe(ts.SyntaxKind.StringLiteral);
|
|
305
|
+
expect(fooDashBar.type.text).toBe('foobar');
|
|
300
306
|
});
|
|
301
307
|
|
|
302
308
|
test('Invalid data type supplied (function)', () => {
|
package/lib/compilers/basic.js
CHANGED
|
@@ -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,
|
|
@@ -92,7 +92,12 @@ const toTypeLiteral = (data) => {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
if (isNumber(data)) {
|
|
95
|
-
return
|
|
95
|
+
return data < 0
|
|
96
|
+
? factory.createPrefixUnaryExpression(
|
|
97
|
+
ts.SyntaxKind.MinusToken,
|
|
98
|
+
factory.createNumericLiteral(-data)
|
|
99
|
+
)
|
|
100
|
+
: factory.createNumericLiteral(data);
|
|
96
101
|
}
|
|
97
102
|
|
|
98
103
|
if (isBoolean(data)) {
|
|
@@ -111,7 +116,7 @@ const toTypeLiteral = (data) => {
|
|
|
111
116
|
throw new Error(`Cannot convert to object literal. Unknown type "${typeof data}"`);
|
|
112
117
|
}
|
|
113
118
|
|
|
114
|
-
const entries = Object.entries(data);
|
|
119
|
+
const entries = Object.entries(data).sort((a, b) => a[0].localeCompare(b[0]));
|
|
115
120
|
|
|
116
121
|
const props = entries.reduce((acc, [key, value]) => {
|
|
117
122
|
// Handle keys such as content-type-builder & co.
|
|
@@ -1,10 +1,16 @@
|
|
|
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');
|
|
7
8
|
|
|
9
|
+
const NO_COMPONENT_PLACEHOLDER_COMMENT = `/*
|
|
10
|
+
* The app doesn't have any components yet.
|
|
11
|
+
*/
|
|
12
|
+
`;
|
|
13
|
+
|
|
8
14
|
/**
|
|
9
15
|
* Generate type definitions for Strapi Components
|
|
10
16
|
*
|
|
@@ -18,10 +24,20 @@ const generateComponentsDefinitions = async (options = {}) => {
|
|
|
18
24
|
|
|
19
25
|
const { components } = strapi;
|
|
20
26
|
|
|
21
|
-
const componentsDefinitions =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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);
|
|
35
|
+
|
|
36
|
+
options.logger.debug(`Found ${componentsDefinitions.length} components.`);
|
|
37
|
+
|
|
38
|
+
if (componentsDefinitions.length === 0) {
|
|
39
|
+
return { output: NO_COMPONENT_PLACEHOLDER_COMMENT, stats: {} };
|
|
40
|
+
}
|
|
25
41
|
|
|
26
42
|
const formattedSchemasDefinitions = componentsDefinitions.reduce((acc, def) => {
|
|
27
43
|
acc.push(
|
|
@@ -1,10 +1,16 @@
|
|
|
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');
|
|
7
8
|
|
|
9
|
+
const NO_CONTENT_TYPE_PLACEHOLDER_COMMENT = `/*
|
|
10
|
+
* The app doesn't have any content-types yet.
|
|
11
|
+
*/
|
|
12
|
+
`;
|
|
13
|
+
|
|
8
14
|
/**
|
|
9
15
|
* Generate type definitions for Strapi Content-Types
|
|
10
16
|
*
|
|
@@ -18,10 +24,20 @@ const generateContentTypesDefinitions = async (options = {}) => {
|
|
|
18
24
|
|
|
19
25
|
const { contentTypes } = strapi;
|
|
20
26
|
|
|
21
|
-
const contentTypesDefinitions =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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);
|
|
35
|
+
|
|
36
|
+
options.logger.debug(`Found ${contentTypesDefinitions.length} content-types.`);
|
|
37
|
+
|
|
38
|
+
if (contentTypesDefinitions.length === 0) {
|
|
39
|
+
return { output: NO_CONTENT_TYPE_PLACEHOLDER_COMMENT, stats: {} };
|
|
40
|
+
}
|
|
25
41
|
|
|
26
42
|
const formattedSchemasDefinitions = contentTypesDefinitions.reduce((acc, def) => {
|
|
27
43
|
acc.push(
|
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
|
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
1
3
|
'use strict';
|
|
2
4
|
|
|
3
5
|
const fse = require('fs-extra');
|
|
@@ -13,5 +15,5 @@ const getConfigPath = require('./get-config-path');
|
|
|
13
15
|
module.exports = (dir, filename = undefined) => {
|
|
14
16
|
const filePath = getConfigPath(dir, { filename });
|
|
15
17
|
|
|
16
|
-
return fse.pathExistsSync(filePath);
|
|
18
|
+
return filePath ? fse.pathExistsSync(filePath) : false;
|
|
17
19
|
};
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../../../lint-staged.shared.mjs';
|
package/package.json
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/typescript-utils",
|
|
3
|
-
"version": "0.0.0-experimental.
|
|
3
|
+
"version": "0.0.0-experimental.6340da17068c3bed7fb006e7bcc554c71129e282",
|
|
4
4
|
"description": "Typescript support for Strapi",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
7
7
|
"generators"
|
|
8
8
|
],
|
|
9
|
+
"homepage": "https://strapi.io",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/strapi/strapi/issues"
|
|
12
|
+
},
|
|
9
13
|
"repository": {
|
|
10
14
|
"type": "git",
|
|
11
|
-
"url": "
|
|
15
|
+
"url": "https://github.com/strapi/strapi.git",
|
|
12
16
|
"directory": "packages/utils/typescript"
|
|
13
17
|
},
|
|
14
18
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -36,18 +40,17 @@
|
|
|
36
40
|
},
|
|
37
41
|
"dependencies": {
|
|
38
42
|
"chalk": "4.1.2",
|
|
39
|
-
"cli-table3": "0.6.
|
|
40
|
-
"fs-extra": "11.
|
|
41
|
-
"lodash": "4.
|
|
42
|
-
"prettier": "3.
|
|
43
|
-
"typescript": "5.3
|
|
43
|
+
"cli-table3": "0.6.5",
|
|
44
|
+
"fs-extra": "11.3.4",
|
|
45
|
+
"lodash": "4.18.1",
|
|
46
|
+
"prettier": "3.3.3",
|
|
47
|
+
"typescript": "5.9.3"
|
|
44
48
|
},
|
|
45
49
|
"devDependencies": {
|
|
46
50
|
"@types/fs-extra": "11.0.4"
|
|
47
51
|
},
|
|
48
52
|
"engines": {
|
|
49
|
-
"node": ">=
|
|
53
|
+
"node": ">=20.19.0 <=26.x.x",
|
|
50
54
|
"npm": ">=6.0.0"
|
|
51
|
-
}
|
|
52
|
-
"gitHead": "62ce06180fe9a772eaeb3d43d238b26644f39f7c"
|
|
55
|
+
}
|
|
53
56
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "ESNext",
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "Bundler",
|
|
7
|
+
"useDefineForClassFields": true,
|
|
8
|
+
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
|
9
|
+
"allowJs": false,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"allowSyntheticDefaultImports": true,
|
|
13
|
+
"strict": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
"noEmit": true,
|
|
17
|
+
"jsx": "react-jsx"
|
|
18
|
+
}
|
|
19
|
+
}
|
package/.eslintignore
DELETED
package/.eslintrc.js
DELETED