@cmssy/codemod 6.2.0 → 7.0.0

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.
Files changed (2) hide show
  1. package/dist/index.js +26 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -13,8 +13,8 @@ var SERVER_SYMBOLS = /* @__PURE__ */ new Set([
13
13
  "createCmssyPage",
14
14
  "createCmssyEditPage",
15
15
  "createCmssyNotFound",
16
- "CmssyChrome",
17
- "CmssyChromeProps",
16
+ "CmssyLayoutSlot",
17
+ "CmssyLayoutSlotProps",
18
18
  "CreateCmssyNotFoundOptions",
19
19
  "buildCmssyMetadata",
20
20
  "BuildCmssyMetadataOptions",
@@ -144,7 +144,26 @@ function transform(source) {
144
144
  return { code, changed };
145
145
  }
146
146
 
147
+ // src/v7.ts
148
+ var RENAMES2 = {
149
+ CmssyChrome: "CmssyLayoutSlot",
150
+ CmssyChromeProps: "CmssyLayoutSlotProps"
151
+ };
152
+ function transform2(source) {
153
+ let code = source;
154
+ let changed = false;
155
+ for (const [from, to] of Object.entries(RENAMES2)) {
156
+ const pattern = new RegExp(`\\b${from}\\b`, "g");
157
+ if (pattern.test(code)) {
158
+ code = code.replace(pattern, to);
159
+ changed = true;
160
+ }
161
+ }
162
+ return { code, changed };
163
+ }
164
+
147
165
  // src/index.ts
166
+ var TRANSFORMS = { v5: transform, v7: transform2 };
148
167
  var SKIP = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "out", "coverage"]);
149
168
  var EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs"];
150
169
  function skipDirectory(name) {
@@ -166,21 +185,22 @@ async function sourceFiles(dir) {
166
185
  async function main() {
167
186
  const args = process.argv.slice(2);
168
187
  const version = args[0];
169
- if (version !== "v5") {
170
- console.error("usage: cmssy-codemod v5 [path] [--dry]");
188
+ const transform3 = TRANSFORMS[version];
189
+ if (!transform3) {
190
+ console.error("usage: cmssy-codemod v5|v7 [path] [--dry]");
171
191
  process.exitCode = 1;
172
192
  return;
173
193
  }
174
194
  const dry = args.includes("--dry");
175
195
  const target = resolve(
176
- args.find((a) => !a.startsWith("-") && a !== "v5") ?? "."
196
+ args.find((a) => !a.startsWith("-") && !(a in TRANSFORMS)) ?? "."
177
197
  );
178
198
  const files = await sourceFiles(target);
179
199
  const touched = [];
180
200
  let needsCore = false;
181
201
  for (const file of files) {
182
202
  const source = await readFile(file, "utf8");
183
- const { code, changed } = transform(source);
203
+ const { code, changed } = transform3(source);
184
204
  if (!changed) continue;
185
205
  touched.push(file);
186
206
  if (code.includes('from "@cmssy/core"')) needsCore = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/codemod",
3
- "version": "6.2.0",
3
+ "version": "7.0.0",
4
4
  "description": "Rewrites cmssy imports across major versions, so a breaking release costs minutes instead of an afternoon.",
5
5
  "keywords": [
6
6
  "cmssy",