@cedarjs/cli 3.0.0-canary.13254 → 3.0.0-canary.13256

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.
@@ -20,24 +20,61 @@ function nameVariants(nameArg) {
20
20
  return { name, folderName, packageName, fileName };
21
21
  }
22
22
  async function updateTsconfig(task) {
23
- const tsconfigPath = path.join(getPaths().api.base, "tsconfig.json");
24
- const tsconfig = await fs.promises.readFile(tsconfigPath, "utf8");
25
- const tsconfigLines = tsconfig.split("\n");
26
- const moduleLineIndex = tsconfigLines.findIndex(
27
- (line) => /^\s*"module":\s*"/.test(line)
28
- );
29
- const moduleLine = tsconfigLines[moduleLineIndex];
30
- if (moduleLine.toLowerCase().includes("node20") || // While Cedar doesn't officially endorse the usage of NodeNext, it
31
- // will still work here, so I won't overwrite it
32
- moduleLine.toLowerCase().includes("nodenext")) {
23
+ const targets = [
24
+ {
25
+ name: "api",
26
+ path: path.join(getPaths().api.base, "tsconfig.json"),
27
+ expectedModule: "Node20",
28
+ acceptable: ["node20", "nodenext"]
29
+ },
30
+ {
31
+ name: "web",
32
+ path: path.join(getPaths().web.base, "tsconfig.json"),
33
+ expectedModule: "ESNext",
34
+ acceptable: ["esnext", "es2022"]
35
+ },
36
+ {
37
+ name: "scripts",
38
+ path: path.join(getPaths().scripts, "tsconfig.json"),
39
+ expectedModule: "Node20",
40
+ acceptable: ["node20", "nodenext"]
41
+ }
42
+ ];
43
+ let updatedAny = false;
44
+ for (const target of targets) {
45
+ if (!fs.existsSync(target.path)) {
46
+ continue;
47
+ }
48
+ const tsconfig = await fs.promises.readFile(target.path, "utf8");
49
+ const tsconfigLines = tsconfig.split("\n");
50
+ const moduleLineIndex = tsconfigLines.findIndex(
51
+ (line) => /^\s*"module":\s*"/.test(line)
52
+ );
53
+ if (moduleLineIndex === -1) {
54
+ continue;
55
+ }
56
+ const moduleLine = tsconfigLines[moduleLineIndex];
57
+ const lower = moduleLine.toLowerCase();
58
+ const alreadySet = target.acceptable.some((acc) => {
59
+ if (lower.includes(acc)) {
60
+ return true;
61
+ }
62
+ return false;
63
+ });
64
+ if (alreadySet) {
65
+ continue;
66
+ }
67
+ tsconfigLines[moduleLineIndex] = moduleLine.replace(
68
+ /":\s*"[\w\d]+"/,
69
+ `": "${target.expectedModule}"`
70
+ );
71
+ await fs.promises.writeFile(target.path, tsconfigLines.join("\n"));
72
+ updatedAny = true;
73
+ }
74
+ if (!updatedAny) {
33
75
  task.skip("tsconfig already up to date");
34
76
  return;
35
77
  }
36
- tsconfigLines[moduleLineIndex] = moduleLine.replace(
37
- /":\s*"[\w\d]+"/,
38
- '": "Node20"'
39
- );
40
- await fs.promises.writeFile(tsconfigPath, tsconfigLines.join("\n"));
41
78
  }
42
79
  async function updateGitignore(task) {
43
80
  const gitignorePath = path.join(getPaths().base, ".gitignore");
@@ -129,7 +166,7 @@ const handler = async ({ name, force, ...rest }) => {
129
166
  }
130
167
  },
131
168
  {
132
- title: "Updating api side tsconfig file...",
169
+ title: "Updating tsconfig files...",
133
170
  task: (_ctx, task) => updateTsconfig(task)
134
171
  },
135
172
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/cli",
3
- "version": "3.0.0-canary.13254+82a146ce9",
3
+ "version": "3.0.0-canary.13256+307002d29",
4
4
  "description": "The CedarJS Command Line",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,15 +33,15 @@
33
33
  "dependencies": {
34
34
  "@babel/preset-typescript": "7.28.5",
35
35
  "@babel/runtime-corejs3": "7.28.4",
36
- "@cedarjs/api-server": "3.0.0-canary.13254",
37
- "@cedarjs/cli-helpers": "3.0.0-canary.13254",
38
- "@cedarjs/fastify-web": "3.0.0-canary.13254",
39
- "@cedarjs/internal": "3.0.0-canary.13254",
40
- "@cedarjs/prerender": "3.0.0-canary.13254",
41
- "@cedarjs/project-config": "3.0.0-canary.13254",
42
- "@cedarjs/structure": "3.0.0-canary.13254",
43
- "@cedarjs/telemetry": "3.0.0-canary.13254",
44
- "@cedarjs/web-server": "3.0.0-canary.13254",
36
+ "@cedarjs/api-server": "3.0.0-canary.13256",
37
+ "@cedarjs/cli-helpers": "3.0.0-canary.13256",
38
+ "@cedarjs/fastify-web": "3.0.0-canary.13256",
39
+ "@cedarjs/internal": "3.0.0-canary.13256",
40
+ "@cedarjs/prerender": "3.0.0-canary.13256",
41
+ "@cedarjs/project-config": "3.0.0-canary.13256",
42
+ "@cedarjs/structure": "3.0.0-canary.13256",
43
+ "@cedarjs/telemetry": "3.0.0-canary.13256",
44
+ "@cedarjs/web-server": "3.0.0-canary.13256",
45
45
  "@listr2/prompt-adapter-enquirer": "2.0.16",
46
46
  "@opentelemetry/api": "1.8.0",
47
47
  "@opentelemetry/core": "1.22.0",
@@ -103,5 +103,5 @@
103
103
  "publishConfig": {
104
104
  "access": "public"
105
105
  },
106
- "gitHead": "82a146ce91c523b8c002d28faa947048f8620fc9"
106
+ "gitHead": "307002d2997682205b676dbade27e3a896bdf30c"
107
107
  }