@lovrozagar/grunt 0.11.0 → 0.11.2
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/cli/init.mjs +9 -1
- package/cli/init.test.ts +12 -0
- package/package.json +1 -1
package/cli/init.mjs
CHANGED
|
@@ -371,8 +371,10 @@ export function mergeClaudeSettings(destRoot, pkgRoot) {
|
|
|
371
371
|
fs.writeFileSync(destPath, `${JSON.stringify(destSettings, null, 2)}\n`)
|
|
372
372
|
}
|
|
373
373
|
|
|
374
|
+
// A command grunt wrote: one of its scripts, or a run of a grunt: script. Not any `bun run`, which a
|
|
375
|
+
// repo's own `bun run build && …` would match, and its script would be taken over as grunt's.
|
|
374
376
|
function looksGruntOwnedPrefix(prefix) {
|
|
375
|
-
return /rulesync|sync:globals|^(?:npm|yarn|pnpm|bun) run
|
|
377
|
+
return /rulesync|sync:globals|^(?:npm|yarn|pnpm|bun) run grunt:|guarded-roots\.mjs|hooks-union\.mjs|doctor\.mjs|sync-global-settings\.mjs|check-globals\.mjs|purge-global-mcps\.mjs/.test(
|
|
376
378
|
prefix,
|
|
377
379
|
)
|
|
378
380
|
}
|
|
@@ -529,6 +531,12 @@ export function mergePackageJson(dest, pkgRoot) {
|
|
|
529
531
|
const ownedLegacy =
|
|
530
532
|
legacy != null &&
|
|
531
533
|
(legacy.startsWith(v) || extraOwnedSuffix(legacy, v) != null || looksGruntOwnedPrefix(legacy))
|
|
534
|
+
// A repo that runs its own e2e keeps it as the only one: grunt's would rerun it without the
|
|
535
|
+
// repo's own steps (a build first, say).
|
|
536
|
+
if (k === "test:e2e" && current == null && legacy != null && !ownedLegacy) {
|
|
537
|
+
console.warn(`script \`${k}\` is the repo's own; not writing \`${destKey}\``)
|
|
538
|
+
continue
|
|
539
|
+
}
|
|
532
540
|
if (current != null) {
|
|
533
541
|
destPkg.scripts[destKey] = mergeScriptValue(v, current, historical)
|
|
534
542
|
} else if (ownedLegacy) {
|
package/cli/init.test.ts
CHANGED
|
@@ -1794,6 +1794,18 @@ describe("mergePackageJson", () => {
|
|
|
1794
1794
|
expect(out.scripts["grunt:test:e2e"]).toBe("vitest run -c vitest.e2e.config.ts");
|
|
1795
1795
|
});
|
|
1796
1796
|
|
|
1797
|
+
it("leaves a repo's own test:e2e alone when it runs grunt's command after one of its own", () => {
|
|
1798
|
+
const dest = tmp("pj-e2e-own-");
|
|
1799
|
+
const own = "bun run build && vitest run -c vitest.e2e.config.ts";
|
|
1800
|
+
fs.writeFileSync(path.join(dest, "package.json"), JSON.stringify({ name: "app", scripts: { "test:e2e": own } }));
|
|
1801
|
+
fs.writeFileSync(path.join(dest, E2E_VITEST_CONFIGS[0]), "export default {}\n");
|
|
1802
|
+
mergePackageJson(dest, PKG_ROOT);
|
|
1803
|
+
const out = JSON.parse(fs.readFileSync(path.join(dest, "package.json"), "utf8"));
|
|
1804
|
+
expect(out.scripts["test:e2e"]).toBe(own);
|
|
1805
|
+
// The repo runs its own e2e: a second, grunt's, would run it again without the repo's own steps.
|
|
1806
|
+
expect(out.scripts["grunt:test:e2e"]).toBeUndefined();
|
|
1807
|
+
});
|
|
1808
|
+
|
|
1797
1809
|
it("keeps an existing grunt:test:e2e even without an e2e config", () => {
|
|
1798
1810
|
const dest = tmp("pj-e2e-keep-");
|
|
1799
1811
|
fs.writeFileSync(
|
package/package.json
CHANGED