@zuplo/cli 2.2.0 → 2.3.1

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.
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c4c27bd6-8cfb-5bb5-86f6-e63b05aa573f")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ce8d0e5c-522c-5fe1-8df5-e8925fcb7a3b")}catch(e){}}();
3
3
  import * as Sentry from "@sentry/node";
4
4
  import chalk from "chalk";
5
5
  import { MAX_WAIT_PENDING_TIME_MS } from "./constants.js";
@@ -7,7 +7,7 @@ export function printDiagnosticsToConsole(message) {
7
7
  console.error(chalk.bold.blue(message));
8
8
  }
9
9
  export function printWarningToConsole(message) {
10
- console.error(message);
10
+ console.error(chalk.yellow(message));
11
11
  }
12
12
  export async function printCriticalFailureToConsoleAndExit(message) {
13
13
  console.error(chalk.bold.red(message));
@@ -54,4 +54,4 @@ export function textOrJson(text) {
54
54
  }
55
55
  }
56
56
  //# sourceMappingURL=output.js.map
57
- //# debugId=c4c27bd6-8cfb-5bb5-86f6-e63b05aa573f
57
+ //# debugId=ce8d0e5c-522c-5fe1-8df5-e8925fcb7a3b
@@ -1,10 +1,10 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1bf2cbbf-1e6f-586b-86a8-5ce98e9e2358")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="bbc3a878-c332-5d04-a39e-99fa8ed6ff1c")}catch(e){}}();
3
3
  import { parse } from "jsonc-parser";
4
4
  import { readFile, writeFile } from "node:fs/promises";
5
5
  import { join } from "node:path";
6
6
  import prettier from "prettier";
7
- import ts, { ModuleKind, ModuleResolutionKind, ScriptTarget, } from "typescript";
7
+ import { printWarningToConsole } from "../output.js";
8
8
  import { StandardUpgrader } from "./lib.js";
9
9
  export class FailedToParseTSConfigJson extends Error {
10
10
  constructor() {
@@ -12,6 +12,24 @@ export class FailedToParseTSConfigJson extends Error {
12
12
  Object.setPrototypeOf(this, FailedToParseTSConfigJson.prototype);
13
13
  }
14
14
  }
15
+ const tsConfig = {
16
+ include: ["modules/**/*", ".zuplo/**/*", "tests/**/*"],
17
+ exclude: ["./node_modules", "./dist"],
18
+ compilerOptions: {
19
+ module: "ESNext",
20
+ target: "ES2022",
21
+ moduleResolution: "Bundler",
22
+ lib: ["ESNext", "WebWorker", "Webworker.Iterable"],
23
+ preserveConstEnums: true,
24
+ useUnknownInCatchVariables: false,
25
+ forceConsistentCasingInFileNames: true,
26
+ importHelpers: true,
27
+ removeComments: true,
28
+ esModuleInterop: true,
29
+ strictNullChecks: true,
30
+ noEmit: true,
31
+ },
32
+ };
15
33
  export class InvalidTSConfigJson extends Error {
16
34
  constructor(message) {
17
35
  super(message);
@@ -32,20 +50,28 @@ export class TSConfigUpgrader extends StandardUpgrader {
32
50
  "compilerOptions" in tsConfigJson)) {
33
51
  return true;
34
52
  }
35
- const { options, errors } = ts.convertCompilerOptionsFromJson(tsConfigJson.compilerOptions, this.normalizedDir);
36
53
  const libValue = ["ESNext", "WebWorker", "Webworker.Iterable"];
37
54
  const includesAllLibs = (userLibs) => {
38
55
  const a = libValue.map((item) => item.toLowerCase());
39
56
  const b = userLibs.map((item) => item.toLowerCase());
40
57
  return a.every((item) => b.includes(item));
41
58
  };
42
- return (errors.length > 0 ||
43
- options.module !== ModuleKind.ESNext ||
44
- options.target !== ScriptTarget.ES2022 ||
45
- options.moduleResolution !== ModuleResolutionKind.Bundler ||
46
- !options.lib ||
47
- options.baseUrl !== undefined ||
48
- !includesAllLibs(tsConfigJson.compilerOptions.lib ?? []));
59
+ if (tsConfigJson.extends) {
60
+ printWarningToConsole("This project uses an advanced tsconfig.json setup. You will need to manually upgrade this file.");
61
+ return false;
62
+ }
63
+ else {
64
+ const options = tsConfigJson.compilerOptions;
65
+ return (options.module?.toLowerCase() !==
66
+ tsConfig.compilerOptions.module.toLowerCase() ||
67
+ options.target?.toLowerCase() !==
68
+ tsConfig.compilerOptions.target.toLowerCase() ||
69
+ options.moduleResolution?.toLowerCase() !==
70
+ tsConfig.compilerOptions.moduleResolution.toLowerCase() ||
71
+ !options.lib ||
72
+ options.baseUrl !== undefined ||
73
+ !includesAllLibs(tsConfigJson.compilerOptions.lib ?? []));
74
+ }
49
75
  }
50
76
  catch (err) {
51
77
  return true;
@@ -56,52 +82,11 @@ export class TSConfigUpgrader extends StandardUpgrader {
56
82
  return;
57
83
  }
58
84
  const tsFilePath = join(this.normalizedDir, "tsconfig.json");
59
- const tsConfig = {
60
- include: ["modules/**/*", ".zuplo/**/*", "tests/**/*"],
61
- exclude: ["./node_modules", "./dist"],
62
- compilerOptions: {
63
- module: "ESNext",
64
- target: "ES2022",
65
- moduleResolution: "Bundler",
66
- lib: ["ESNext", "WebWorker", "Webworker.Iterable"],
67
- preserveConstEnums: true,
68
- useUnknownInCatchVariables: false,
69
- forceConsistentCasingInFileNames: true,
70
- importHelpers: true,
71
- removeComments: true,
72
- esModuleInterop: true,
73
- strictNullChecks: true,
74
- noEmit: true,
75
- },
76
- };
77
85
  const formatted = await prettier.format(JSON.stringify(tsConfig), {
78
86
  parser: "json",
79
87
  });
80
88
  await writeFile(tsFilePath, formatted);
81
89
  }
82
90
  }
83
- export const getZuploTsConfigTemplate = () => ({
84
- include: ["modules/**/*", ".zuplo/**/*", "tests/**/*"],
85
- exclude: ["./node_modules", "./dist"],
86
- compilerOptions: {
87
- baseUrl: ".",
88
- module: ModuleKind.ESNext,
89
- target: ScriptTarget.ESNext,
90
- moduleResolution: ModuleResolutionKind.Bundler,
91
- lib: ["ESNext", "WebWorker", "Webworker.Iterable"],
92
- preserveConstEnums: true,
93
- useUnknownInCatchVariables: false,
94
- forceConsistentCasingInFileNames: true,
95
- importHelpers: true,
96
- removeComments: true,
97
- esModuleInterop: true,
98
- strictNullChecks: true,
99
- experimentalDecorators: true,
100
- noEmit: true,
101
- paths: {
102
- "@app/*": [".zuplo/*"],
103
- },
104
- },
105
- });
106
91
  //# sourceMappingURL=tsconfig-upgrader.js.map
107
- //# debugId=1bf2cbbf-1e6f-586b-86a8-5ce98e9e2358
92
+ //# debugId=bbc3a878-c332-5d04-a39e-99fa8ed6ff1c
@@ -1,17 +1,17 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b240c7b1-8f8c-54c7-b381-3ec9bae18cd4")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1c1c6e29-7b10-5f96-810c-08323d6b3c10")}catch(e){}}();
3
3
  import { confirm } from "@inquirer/prompts";
4
4
  import { printDiagnosticsToConsole, printResultToConsoleAndExitGracefully, } from "../../common/output.js";
5
5
  import { PackageJsonUpgrader } from "../../common/upgraders/package-json-upgrader.js";
6
6
  import { TSConfigUpgrader } from "../../common/upgraders/tsconfig-upgrader.js";
7
7
  import { VsCodeSettingsJsonUpgrader } from "../../common/upgraders/vscode-settings-json-upgrader.js";
8
8
  export async function update(argv) {
9
- let answer = !!argv.prompt;
10
- if (answer) {
9
+ let answer = false;
10
+ if (argv.prompt === true) {
11
11
  printDiagnosticsToConsole("This command will make changes to your source code. Please commit your changes to version control before continuing.");
12
12
  answer = await confirm({ message: "Continue?", default: true });
13
13
  }
14
- if (answer) {
14
+ if (answer || argv.prompt === false) {
15
15
  const u = new PackageJsonUpgrader(argv.dir);
16
16
  if ((await u.isApplicable()).ok) {
17
17
  printDiagnosticsToConsole("Updating your package.json...");
@@ -31,4 +31,4 @@ export async function update(argv) {
31
31
  }
32
32
  }
33
33
  //# sourceMappingURL=handler.js.map
34
- //# debugId=b240c7b1-8f8c-54c7-b381-3ec9bae18cd4
34
+ //# debugId=1c1c6e29-7b10-5f96-810c-08323d6b3c10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/cli",
3
- "version": "2.2.0",
3
+ "version": "2.3.1",
4
4
  "type": "module",
5
5
  "repository": "https://github.com/zuplo/cli",
6
6
  "description": "The command-line interface for Zuplo",