@cmssy/codemod 5.0.1 → 5.1.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.
- package/dist/index.js +17 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -177,11 +177,13 @@ async function main() {
|
|
|
177
177
|
);
|
|
178
178
|
const files = await sourceFiles(target);
|
|
179
179
|
const touched = [];
|
|
180
|
+
let needsCore = false;
|
|
180
181
|
for (const file of files) {
|
|
181
182
|
const source = await readFile(file, "utf8");
|
|
182
183
|
const { code, changed } = transform(source);
|
|
183
184
|
if (!changed) continue;
|
|
184
185
|
touched.push(file);
|
|
186
|
+
if (code.includes('from "@cmssy/core"')) needsCore = true;
|
|
185
187
|
if (!dry) await writeFile(file, code);
|
|
186
188
|
}
|
|
187
189
|
if (touched.length === 0) {
|
|
@@ -194,10 +196,25 @@ async function main() {
|
|
|
194
196
|
for (const file of touched) {
|
|
195
197
|
console.log(` ${file.slice(target.length + 1)}`);
|
|
196
198
|
}
|
|
199
|
+
if (needsCore && !await dependsOnCore(target)) {
|
|
200
|
+
console.log(
|
|
201
|
+
"\nYour code now imports @cmssy/core, which you do not depend on yet:\n npm install @cmssy/core (or pnpm add / yarn add)"
|
|
202
|
+
);
|
|
203
|
+
}
|
|
197
204
|
console.log(
|
|
198
205
|
"\nThe imports moved; the wiring did not. Run your build, then the editor\nsmoke test - a site whose editor is dead still builds:\n https://github.com/cmssy-io/cmssy-sdk/blob/main/docs/testing.md"
|
|
199
206
|
);
|
|
200
207
|
}
|
|
208
|
+
async function dependsOnCore(target) {
|
|
209
|
+
try {
|
|
210
|
+
const manifest = JSON.parse(
|
|
211
|
+
await readFile(join(target, "package.json"), "utf8")
|
|
212
|
+
);
|
|
213
|
+
return Boolean(manifest.dependencies?.["@cmssy/core"]);
|
|
214
|
+
} catch {
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
201
218
|
main().catch((error) => {
|
|
202
219
|
console.error(error);
|
|
203
220
|
process.exitCode = 1;
|