@strapi/typescript-utils 0.0.0-next.f7babb775ed9a7e18d8351cb7f74c63e016323c4 → 0.0.0-next.f86041c89a8c1545c6437a881dc613e98bc52bd7
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/LICENSE +18 -3
- package/lib/__tests__/generators/schemas/attributes.test.js +280 -135
- package/lib/__tests__/generators/schemas/utils.test.js +40 -34
- package/lib/compile.js +2 -6
- package/lib/compilers/basic.js +12 -4
- package/lib/compilers/index.js +0 -2
- package/lib/generators/common/imports.js +3 -3
- package/lib/generators/common/models/attributes.js +35 -10
- package/lib/generators/common/models/mappers.js +35 -22
- package/lib/generators/common/models/schema.js +7 -5
- package/lib/generators/common/models/utils.js +13 -8
- package/lib/generators/components/index.js +21 -5
- package/lib/generators/content-types/index.js +21 -5
- package/lib/generators/index.js +1 -1
- package/lib/generators/utils.js +10 -5
- package/lib/index.js +0 -3
- package/lib/utils/index.js +2 -0
- package/lib/utils/resolve-outdir-sync.js +18 -0
- package/package.json +15 -8
- package/tsconfigs/admin.json +18 -19
- package/tsconfigs/server.json +18 -16
- package/lib/admin/create-tsconfig-file.js +0 -37
- package/lib/admin/index.js +0 -5
- package/lib/compilers/watch.js +0 -37
|
@@ -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,11 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/typescript-utils",
|
|
3
|
-
"version": "0.0.0-next.
|
|
3
|
+
"version": "0.0.0-next.f86041c89a8c1545c6437a881dc613e98bc52bd7",
|
|
4
4
|
"description": "Typescript support for Strapi",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
7
7
|
"generators"
|
|
8
8
|
],
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git://github.com/strapi/strapi.git",
|
|
12
|
+
"directory": "packages/utils/typescript"
|
|
13
|
+
},
|
|
9
14
|
"license": "SEE LICENSE IN LICENSE",
|
|
10
15
|
"author": {
|
|
11
16
|
"name": "Strapi Solutions SAS",
|
|
@@ -31,15 +36,17 @@
|
|
|
31
36
|
},
|
|
32
37
|
"dependencies": {
|
|
33
38
|
"chalk": "4.1.2",
|
|
34
|
-
"cli-table3": "0.6.
|
|
35
|
-
"fs-extra": "
|
|
39
|
+
"cli-table3": "0.6.5",
|
|
40
|
+
"fs-extra": "11.2.0",
|
|
36
41
|
"lodash": "4.17.21",
|
|
37
|
-
"prettier": "
|
|
38
|
-
"typescript": "5.
|
|
42
|
+
"prettier": "3.3.3",
|
|
43
|
+
"typescript": "5.4.4"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/fs-extra": "11.0.4"
|
|
39
47
|
},
|
|
40
48
|
"engines": {
|
|
41
|
-
"node": ">=
|
|
49
|
+
"node": ">=20.0.0 <=24.x.x",
|
|
42
50
|
"npm": ">=6.0.0"
|
|
43
|
-
}
|
|
44
|
-
"gitHead": "f7babb775ed9a7e18d8351cb7f74c63e016323c4"
|
|
51
|
+
}
|
|
45
52
|
}
|
package/tsconfigs/admin.json
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
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/tsconfigs/server.json
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"module": "CommonJS",
|
|
6
|
-
"moduleResolution": "Node",
|
|
7
|
-
"lib": ["ES2020"],
|
|
8
|
-
"target": "ES2019",
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
9
3
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"module": "CommonJS",
|
|
6
|
+
"moduleResolution": "Node",
|
|
7
|
+
"lib": ["ES2020"],
|
|
8
|
+
"target": "ES2019",
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
"strict": false,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
|
|
14
|
+
"tsBuildInfoFile": "./.tsbuildinfo",
|
|
15
|
+
"incremental": true,
|
|
16
|
+
"esModuleInterop": true,
|
|
17
|
+
"resolveJsonModule": true,
|
|
18
|
+
"noEmitOnError": true,
|
|
19
|
+
"noImplicitThis": true
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const fs = require('fs-extra');
|
|
5
|
-
|
|
6
|
-
module.exports = async (dest) => {
|
|
7
|
-
const tsConfig = {
|
|
8
|
-
compilerOptions: {
|
|
9
|
-
lib: ['es2019', 'es2020.promise', 'es2020.bigint', 'es2020.string', 'DOM'],
|
|
10
|
-
noImplicitAny: false,
|
|
11
|
-
module: 'es2020',
|
|
12
|
-
target: 'es5',
|
|
13
|
-
jsx: 'react',
|
|
14
|
-
allowJs: true,
|
|
15
|
-
strict: true,
|
|
16
|
-
moduleResolution: 'node',
|
|
17
|
-
skipLibCheck: true,
|
|
18
|
-
esModuleInterop: true,
|
|
19
|
-
allowSyntheticDefaultImports: true,
|
|
20
|
-
resolveJsonModule: true,
|
|
21
|
-
noEmit: false,
|
|
22
|
-
incremental: true,
|
|
23
|
-
},
|
|
24
|
-
include: ['../../../src/admin/*', '../../../src/**/**/admin/src/*'],
|
|
25
|
-
exclude: ['node_modules', '**/*.test.js', '*.js'],
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const filePath = path.join(dest, 'admin', 'src', 'tsconfig.json');
|
|
29
|
-
|
|
30
|
-
try {
|
|
31
|
-
await fs.ensureFile(filePath);
|
|
32
|
-
|
|
33
|
-
await fs.writeJSON(filePath, tsConfig, { spaces: 2 });
|
|
34
|
-
} catch (err) {
|
|
35
|
-
console.log(err);
|
|
36
|
-
}
|
|
37
|
-
};
|
package/lib/admin/index.js
DELETED
package/lib/compilers/watch.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const ts = require('typescript');
|
|
4
|
-
|
|
5
|
-
const reportDiagnostics = require('../utils/report-diagnostics');
|
|
6
|
-
const formatHost = require('../utils/format-host');
|
|
7
|
-
const resolveConfigOptions = require('../utils/resolve-config-options');
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Prints a diagnostic every time the watch status changes.
|
|
11
|
-
* This is mainly for messages like "Starting compilation" or "Compilation completed".
|
|
12
|
-
*/
|
|
13
|
-
const reportWatchStatusChanged = (diagnostic) => {
|
|
14
|
-
console.info(ts.formatDiagnostic(diagnostic, formatHost));
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
module.exports = {
|
|
18
|
-
run(configPath) {
|
|
19
|
-
const createProgram = ts.createSemanticDiagnosticsBuilderProgram;
|
|
20
|
-
|
|
21
|
-
const { fileNames, options, projectReferences, watchOptions } =
|
|
22
|
-
resolveConfigOptions(configPath);
|
|
23
|
-
|
|
24
|
-
const host = ts.createWatchCompilerHost(
|
|
25
|
-
fileNames,
|
|
26
|
-
options,
|
|
27
|
-
ts.sys,
|
|
28
|
-
createProgram,
|
|
29
|
-
reportDiagnostics,
|
|
30
|
-
reportWatchStatusChanged,
|
|
31
|
-
projectReferences,
|
|
32
|
-
watchOptions
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
ts.createWatchProgram(host);
|
|
36
|
-
},
|
|
37
|
-
};
|