@player-tools/cli 0.5.1 → 0.5.2--canary.72.2148
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.
|
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const globby_1 = tslib_1.__importDefault(require("globby"));
|
|
5
5
|
const log_symbols_1 = tslib_1.__importDefault(require("log-symbols"));
|
|
6
|
+
const fs_1 = require("fs");
|
|
6
7
|
const ts = tslib_1.__importStar(require("typescript"));
|
|
7
8
|
const core_1 = require("@oclif/core");
|
|
8
9
|
const base_command_1 = require("../../utils/base-command");
|
|
9
|
-
const
|
|
10
|
+
const fs_2 = require("../../utils/fs");
|
|
10
11
|
const compiler_options_1 = require("../../utils/compiler-options");
|
|
11
12
|
/** A command thay runs TS typechecker against source ts and tsx files */
|
|
12
13
|
class Validate extends base_command_1.BaseCommand {
|
|
@@ -21,12 +22,44 @@ class Validate extends base_command_1.BaseCommand {
|
|
|
21
22
|
inputFiles: Array.isArray(files) ? files : [files],
|
|
22
23
|
};
|
|
23
24
|
}
|
|
25
|
+
async getTSConfig(filePath, compilerOptions = {}) {
|
|
26
|
+
let TSEnvConfig, configFile;
|
|
27
|
+
const EnvTSConfig = globby_1.default.sync(filePath ? filePath : "./tsconfig.json")[0];
|
|
28
|
+
this.log(`Local Typesscript config file found ${EnvTSConfig}`);
|
|
29
|
+
try {
|
|
30
|
+
configFile = await fs_1.promises.readFile(EnvTSConfig);
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
this.error("Error reading the TypeScript configuration file.");
|
|
34
|
+
}
|
|
35
|
+
const compilerConfigObject = configFile && JSON.parse(configFile.toString());
|
|
36
|
+
const configCompilerOpts = compilerConfigObject?.compilerOptions || {};
|
|
37
|
+
if (compilerConfigObject.extends) {
|
|
38
|
+
TSEnvConfig = await this.getTSConfig(compilerConfigObject.extends, {
|
|
39
|
+
...compilerOptions,
|
|
40
|
+
...configCompilerOpts,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
TSEnvConfig = {
|
|
45
|
+
...compilerOptions,
|
|
46
|
+
...configCompilerOpts,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (TSEnvConfig && Object.keys(TSEnvConfig).length > 0) {
|
|
50
|
+
if (!compilerConfigObject.extends)
|
|
51
|
+
this.log(`Enviroment Typescript compiler configurations found: ${JSON.stringify(TSEnvConfig, null, 4)}`);
|
|
52
|
+
return TSEnvConfig;
|
|
53
|
+
}
|
|
54
|
+
this.warn(`No local Typescript compiler configuration could be found on file ${EnvTSConfig}`);
|
|
55
|
+
}
|
|
24
56
|
async run() {
|
|
25
57
|
const { inputFiles } = await this.getOptions();
|
|
26
|
-
const files = await (0, globby_1.default)((0,
|
|
58
|
+
const files = await (0, globby_1.default)((0, fs_2.convertToFileGlob)(inputFiles, "**/*.(tsx|jsx|js|ts)"), {
|
|
27
59
|
expandDirectories: true,
|
|
28
60
|
});
|
|
29
|
-
const
|
|
61
|
+
const TSConfig = (await this.getTSConfig()) || compiler_options_1.DEFAULT_COMPILER_OPTIONS;
|
|
62
|
+
const program = ts.createProgram(files, TSConfig);
|
|
30
63
|
const allDiagnostics = ts.getPreEmitDiagnostics(program);
|
|
31
64
|
let diagnosticsCount = 0;
|
|
32
65
|
const groupedDiagnostics = allDiagnostics.reduce((acc, diagnostic) => {
|
|
@@ -55,7 +88,9 @@ class Validate extends base_command_1.BaseCommand {
|
|
|
55
88
|
});
|
|
56
89
|
});
|
|
57
90
|
if (fileNameList.length) {
|
|
58
|
-
this.log(`${diagnosticsCount} type or syntax errors found in
|
|
91
|
+
this.log(`${diagnosticsCount} type or syntax errors found in
|
|
92
|
+
${fileNameList.length}
|
|
93
|
+
file${fileNameList.length > 1 ? "s" : ""}, exiting program`);
|
|
59
94
|
this.exit(1);
|
|
60
95
|
}
|
|
61
96
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@player-tools/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2--canary.72.2148",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
"@oclif/plugin-plugins"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@player-tools/dsl": "0.5.
|
|
25
|
-
"@player-tools/json-language-service": "0.5.
|
|
26
|
-
"@player-tools/xlr": "0.5.
|
|
27
|
-
"@player-tools/xlr-converters": "0.5.
|
|
28
|
-
"@player-tools/xlr-sdk": "0.5.
|
|
29
|
-
"@player-tools/xlr-utils": "0.5.
|
|
24
|
+
"@player-tools/dsl": "0.5.2--canary.72.2148",
|
|
25
|
+
"@player-tools/json-language-service": "0.5.2--canary.72.2148",
|
|
26
|
+
"@player-tools/xlr": "0.5.2--canary.72.2148",
|
|
27
|
+
"@player-tools/xlr-converters": "0.5.2--canary.72.2148",
|
|
28
|
+
"@player-tools/xlr-sdk": "0.5.2--canary.72.2148",
|
|
29
|
+
"@player-tools/xlr-utils": "0.5.2--canary.72.2148",
|
|
30
30
|
"react": "^18.2.0",
|
|
31
31
|
"tapable-ts": "^0.2.4",
|
|
32
32
|
"@babel/register": "^7.23.3",
|