@player-tools/cli 0.5.2-next.0 → 0.5.2-next.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.
@@ -105,8 +105,7 @@ class DSLCompile extends base_command_1.BaseCommand {
105
105
  catch (e) {
106
106
  results.exitCode = 100;
107
107
  this.log("");
108
- this.log(chalk_1.default.red(`${log_symbols_1.default.error} Error compiling ${file}: ${e.message}`));
109
- this.debug(e);
108
+ this.log(chalk_1.default.red(`${log_symbols_1.default.error} Error compiling ${file}: ${e.stack}`));
110
109
  compilerResults.push({
111
110
  state: "completed",
112
111
  error: e,
@@ -4,6 +4,7 @@ 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
6
  const fs_1 = require("fs");
7
+ const path_1 = tslib_1.__importDefault(require("path"));
7
8
  const ts = tslib_1.__importStar(require("typescript"));
8
9
  const core_1 = require("@oclif/core");
9
10
  const base_command_1 = require("../../utils/base-command");
@@ -22,46 +23,38 @@ class Validate extends base_command_1.BaseCommand {
22
23
  inputFiles: Array.isArray(files) ? files : [files],
23
24
  };
24
25
  }
25
- async getTSConfig(filePath, compilerOptions = {}) {
26
- let TSEnvConfig, configFile;
27
- const EnvTSConfigPath = filePath
28
- ? filePath
29
- : globby_1.default.sync("./tsconfig.json")[0];
30
- this.log(`Loading TypeScript config from path ${EnvTSConfigPath}`);
31
- try {
32
- configFile = await fs_1.promises.readFile(EnvTSConfigPath);
33
- }
34
- catch (e) {
35
- this.warn("Error reading TypeScript configuration file, falling back to internal defaults");
26
+ getTSConfig(filePath) {
27
+ const configFileLocation = ts.findConfigFile(filePath ?? ".", (fName) => {
28
+ return (0, fs_1.existsSync)(fName);
29
+ });
30
+ if (!configFileLocation) {
31
+ this.debug(`No TSConfig found`);
36
32
  return;
37
33
  }
38
- const compilerConfigObject = configFile && JSON.parse(configFile.toString());
39
- const configCompilerOpts = compilerConfigObject?.compilerOptions || {};
40
- if (compilerConfigObject.extends) {
41
- TSEnvConfig = await this.getTSConfig(compilerConfigObject.extends, {
42
- ...compilerOptions,
43
- ...configCompilerOpts,
44
- });
45
- }
46
- else {
47
- TSEnvConfig = {
48
- ...compilerOptions,
49
- ...configCompilerOpts,
50
- };
34
+ const configContent = ts.readConfigFile(configFileLocation, (p) => {
35
+ return (0, fs_1.readFileSync)(p, "utf-8");
36
+ });
37
+ if (configContent.error) {
38
+ this.warn(ts.flattenDiagnosticMessageText(configContent.error.messageText, "\n"));
39
+ return;
51
40
  }
52
- if (TSEnvConfig && Object.keys(TSEnvConfig).length > 0) {
53
- if (!compilerConfigObject.extends)
54
- this.debug(`Final effective config: ${JSON.stringify(TSEnvConfig, null, 4)}`);
55
- return TSEnvConfig;
41
+ const basePath = path_1.default.dirname(configFileLocation);
42
+ const parsedConfigContent = ts.parseJsonConfigFileContent(configContent.config, ts.sys, basePath);
43
+ if (parsedConfigContent.errors.length > 0) {
44
+ throw new Error(`Error while parsing tsconfig: ${parsedConfigContent.errors
45
+ .map((d) => {
46
+ return ts.flattenDiagnosticMessageText(d.messageText, "\n");
47
+ })
48
+ .join("\n\n")}`);
56
49
  }
57
- this.log(`No local TypeScript compiler configuration could be found, falling back to internal defaults`);
50
+ return parsedConfigContent.options;
58
51
  }
59
52
  async run() {
60
53
  const { inputFiles } = await this.getOptions();
61
54
  const files = await (0, globby_1.default)((0, fs_2.convertToFileGlob)(inputFiles, "**/*.(tsx|jsx|js|ts)"), {
62
55
  expandDirectories: true,
63
56
  });
64
- const TSConfig = (await this.getTSConfig()) ?? compiler_options_1.DEFAULT_COMPILER_OPTIONS;
57
+ const TSConfig = this.getTSConfig() ?? compiler_options_1.DEFAULT_COMPILER_OPTIONS;
65
58
  const program = ts.createProgram(files, TSConfig);
66
59
  const allDiagnostics = ts.getPreEmitDiagnostics(program);
67
60
  let diagnosticsCount = 0;
@@ -23,7 +23,7 @@ export interface LSPAssetsPluginConfig {
23
23
  */
24
24
  export declare class LSPAssetsPlugin implements PlayerCLIPlugin {
25
25
  private config;
26
- constructor(config: LSPAssetsPluginConfig);
26
+ constructor(config: LSPAssetsPluginConfig | Array<LSPAssetsPluginConfig>);
27
27
  onCreateLanguageService(lsp: PlayerLanguageService, exp: boolean): Promise<void>;
28
28
  }
29
29
  //# sourceMappingURL=LSPAssetsPlugin.d.ts.map
@@ -21,7 +21,12 @@ class LSPAssetsPlugin {
21
21
  this.config = config;
22
22
  }
23
23
  async onCreateLanguageService(lsp, exp) {
24
- await lsp.setAssetTypes([this.config.path]);
24
+ if (Array.isArray(this.config)) {
25
+ await lsp.setAssetTypes(this.config.map((c) => c.path));
26
+ }
27
+ else {
28
+ await lsp.setAssetTypes([this.config.path]);
29
+ }
25
30
  }
26
31
  }
27
32
  exports.LSPAssetsPlugin = LSPAssetsPlugin;
@@ -5,7 +5,7 @@ import type { PlayerCLIPlugin } from "./index";
5
5
  */
6
6
  export declare class LSPPluginPlugin implements PlayerCLIPlugin {
7
7
  private plugin;
8
- constructor(plugin: PlayerLanguageServicePlugin);
8
+ constructor(plugin: PlayerLanguageServicePlugin | Array<PlayerLanguageServicePlugin>);
9
9
  onCreateLanguageService(lsp: PlayerLanguageService, exp: boolean): Promise<void>;
10
10
  }
11
11
  //# sourceMappingURL=LSPPluginPlugin.d.ts.map
@@ -9,7 +9,12 @@ class LSPPluginPlugin {
9
9
  this.plugin = plugin;
10
10
  }
11
11
  async onCreateLanguageService(lsp, exp) {
12
- lsp.addLSPPlugin(this.plugin);
12
+ if (Array.isArray(this.plugin)) {
13
+ this.plugin.forEach((p) => lsp.addLSPPlugin(p));
14
+ }
15
+ else {
16
+ lsp.addLSPPlugin(this.plugin);
17
+ }
13
18
  }
14
19
  }
15
20
  exports.LSPPluginPlugin = LSPPluginPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@player-tools/cli",
3
- "version": "0.5.2-next.0",
3
+ "version": "0.5.2-next.2",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [
@@ -12,21 +12,21 @@
12
12
  "bin": "player",
13
13
  "dirname": "player",
14
14
  "topicSeparator": " ",
15
- "commands": "dist/commands"
15
+ "commands": "dist/commands",
16
+ "plugins": [
17
+ "@oclif/plugin-plugins"
18
+ ]
16
19
  },
17
20
  "bin": {
18
21
  "player": "bin/run"
19
22
  },
20
- "plugins": [
21
- "@oclif/plugin-plugins"
22
- ],
23
23
  "dependencies": {
24
- "@player-tools/dsl": "0.5.2-next.0",
25
- "@player-tools/json-language-service": "0.5.2-next.0",
26
- "@player-tools/xlr": "0.5.2-next.0",
27
- "@player-tools/xlr-converters": "0.5.2-next.0",
28
- "@player-tools/xlr-sdk": "0.5.2-next.0",
29
- "@player-tools/xlr-utils": "0.5.2-next.0",
24
+ "@player-tools/dsl": "0.5.2-next.2",
25
+ "@player-tools/json-language-service": "0.5.2-next.2",
26
+ "@player-tools/xlr": "0.5.2-next.2",
27
+ "@player-tools/xlr-converters": "0.5.2-next.2",
28
+ "@player-tools/xlr-sdk": "0.5.2-next.2",
29
+ "@player-tools/xlr-utils": "0.5.2-next.2",
30
30
  "react": "^18.2.0",
31
31
  "tapable-ts": "^0.2.4",
32
32
  "@babel/register": "^7.23.3",
@@ -36,6 +36,7 @@
36
36
  "@babel/plugin-transform-react-jsx-source": "^7.23.3",
37
37
  "@oclif/core": "1.9.0",
38
38
  "@oclif/plugin-legacy": "^1.2.7",
39
+ "@oclif/plugin-plugins": "^1.9.0",
39
40
  "chalk": "^4.0.1",
40
41
  "cosmiconfig": "^7.0.1",
41
42
  "cross-fetch": "^3.0.5",
@@ -50,7 +51,7 @@
50
51
  "mkdirp": "^1.0.4",
51
52
  "vscode-languageserver-textdocument": "^1.0.1",
52
53
  "vscode-languageserver-types": "^3.15.1",
53
- "typescript": "4.8.4",
54
+ "typescript": "^5.4.4",
54
55
  "tslib": "^2.6.2"
55
56
  },
56
57
  "sideEffects": false,