@cedarjs/codemods 4.1.1-next.14 → 4.1.1-next.64

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,4 +1,38 @@
1
1
  import fs from "node:fs";
2
+ function transformTsConfigModule(source) {
3
+ if (/["']module["']\s*:\s*["']node20["']/i.test(source)) {
4
+ return source;
5
+ }
6
+ const overwritten = source.replace(/("module"\s*:\s*)"[^"]*"/, '$1"node20"');
7
+ if (overwritten !== source) {
8
+ return overwritten;
9
+ }
10
+ const afterTarget = source.replace(
11
+ /("target"\s*:\s*"[^"]*")(,?)(\s*\n)/,
12
+ (match, prop, comma, ws) => {
13
+ const lineStart = source.lastIndexOf("\n", source.indexOf(match)) + 1;
14
+ const indentMatch = source.slice(lineStart).match(/^([ \t]+)/);
15
+ const indent = indentMatch ? indentMatch[1] : " ";
16
+ const trailingComma = comma || ",";
17
+ return `${prop}${trailingComma}${ws}${indent}"module": "node20",
18
+ `;
19
+ }
20
+ );
21
+ if (afterTarget !== source) {
22
+ return afterTarget;
23
+ }
24
+ return source.replace(
25
+ /("compilerOptions"\s*:\s*\{)(\s*\n)/,
26
+ (match, open, ws) => {
27
+ const lineStart = source.lastIndexOf("\n", source.indexOf(match)) + 1;
28
+ const indentMatch = source.slice(lineStart).match(/^([ \t]+)/);
29
+ const outerIndent = indentMatch ? indentMatch[1] : " ";
30
+ const innerIndent = outerIndent + " ";
31
+ return `${open}${ws}${innerIndent}"module": "node20",
32
+ `;
33
+ }
34
+ );
35
+ }
2
36
  function transformTsConfig(source) {
3
37
  if (/["']allowImportingTsExtensions["']/.test(source)) {
4
38
  return source;
@@ -58,9 +92,22 @@ async function updateTsConfig(tsConfigPath) {
58
92
  fs.writeFileSync(tsConfigPath, transformed, "utf-8");
59
93
  return "updated";
60
94
  }
95
+ async function updateApiTsConfig(tsConfigPath) {
96
+ if (!fs.existsSync(tsConfigPath)) {
97
+ return "skipped";
98
+ }
99
+ const source = fs.readFileSync(tsConfigPath, "utf-8");
100
+ const withExtensions = transformTsConfig(source);
101
+ const withModule = transformTsConfigModule(withExtensions);
102
+ if (withModule === source) {
103
+ return "unmodified";
104
+ }
105
+ fs.writeFileSync(tsConfigPath, withModule, "utf-8");
106
+ return "updated";
107
+ }
61
108
  async function updateTsConfigs(paths) {
62
109
  const [api, scripts, web] = await Promise.all([
63
- updateTsConfig(paths.apiTsConfig),
110
+ updateApiTsConfig(paths.apiTsConfig),
64
111
  updateTsConfig(paths.scriptsTsConfig),
65
112
  updateTsConfig(paths.webTsConfig)
66
113
  ]);
@@ -68,6 +115,8 @@ async function updateTsConfigs(paths) {
68
115
  }
69
116
  export {
70
117
  transformTsConfig,
118
+ transformTsConfigModule,
119
+ updateApiTsConfig,
71
120
  updateTsConfig,
72
121
  updateTsConfigs
73
122
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/codemods",
3
- "version": "4.1.1-next.14+69388bd68a",
3
+ "version": "4.1.1-next.64",
4
4
  "description": "Codemods to ease upgrading a CedarJS Project",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,11 +26,11 @@
26
26
  "dependencies": {
27
27
  "@babel/cli": "7.28.6",
28
28
  "@babel/core": "^7.26.10",
29
- "@babel/parser": "7.29.2",
29
+ "@babel/parser": "7.29.3",
30
30
  "@babel/plugin-transform-typescript": "^7.26.8",
31
31
  "@babel/traverse": "7.29.0",
32
- "@cedarjs/cli-helpers": "4.1.1-next.14+69388bd68a",
33
- "@cedarjs/project-config": "4.1.1-next.14+69388bd68a",
32
+ "@cedarjs/cli-helpers": "4.1.0",
33
+ "@cedarjs/project-config": "4.1.0",
34
34
  "@svgr/core": "8.1.0",
35
35
  "@svgr/plugin-jsx": "8.1.0",
36
36
  "@vscode/ripgrep": "1.17.1",
@@ -48,12 +48,12 @@
48
48
  "yargs": "17.7.2"
49
49
  },
50
50
  "devDependencies": {
51
- "@cedarjs/framework-tools": "4.1.1-next.14",
51
+ "@cedarjs/framework-tools": "4.1.1-next.64",
52
52
  "@types/babel__core": "7.20.5",
53
53
  "@types/jscodeshift": "17.3.0",
54
54
  "@types/yargs": "17.0.35",
55
55
  "memfs": "4.57.2",
56
- "publint": "0.3.18",
56
+ "publint": "0.3.20",
57
57
  "ts-dedent": "2.2.0",
58
58
  "tsx": "4.21.0",
59
59
  "vitest": "3.2.4"
@@ -64,5 +64,5 @@
64
64
  "publishConfig": {
65
65
  "access": "public"
66
66
  },
67
- "gitHead": "69388bd68ad03ce3b1afd399167899369c2c08c1"
67
+ "gitHead": "3905ed045508b861b495f8d5630d76c7a157d8f1"
68
68
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Cedar
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.