@sfmc-bds/cli 0.4.3 → 0.4.5
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/daemon/client.d.ts.map +1 -1
- package/dist/daemon/client.js +5 -2
- package/dist/daemon/client.js.map +2 -2
- package/dist/daemon/server.d.ts.map +1 -1
- package/dist/daemon/server.js +4 -3
- package/dist/daemon/server.js.map +2 -2
- package/dist/i18n/locales/en.d.ts +1 -0
- package/dist/i18n/locales/en.d.ts.map +1 -1
- package/dist/i18n/locales/en.js +1 -0
- package/dist/i18n/locales/en.js.map +2 -2
- package/dist/i18n/locales/zh-CN.d.ts.map +1 -1
- package/dist/i18n/locales/zh-CN.js +1 -0
- package/dist/i18n/locales/zh-CN.js.map +2 -2
- package/dist/management/maintenance.js +3 -4
- package/dist/management/maintenance.js.map +2 -2
- package/dist/management/platform-worker.js +22 -3
- package/dist/management/platform-worker.js.map +2 -2
- package/dist/management/tasks.js +2 -9
- package/dist/management/tasks.js.map +2 -2
- package/dist/module-update/index.d.ts.map +1 -1
- package/dist/module-update/index.js +2 -1
- package/dist/module-update/index.js.map +2 -2
- package/package.json +6 -6
- package/scripts/module-install/lib/module-update.mjs +21 -2
- package/scripts/module-install/test/module-update.test.mjs +94 -0
|
@@ -529,3 +529,97 @@ test("新播种的更新配置在开服时不自动应用,已有文件保持
|
|
|
529
529
|
assert.equal(keptPlan.applyOnStart, true);
|
|
530
530
|
assert.equal(fs.readFileSync(keptFile, "utf8"), before);
|
|
531
531
|
});
|
|
532
|
+
|
|
533
|
+
test("弃用模块不进入升级,依赖它的模块仍可更新", async () => {
|
|
534
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), "sfmc-mod-retired-"));
|
|
535
|
+
const monitor = path.join(root, "modules", "packages", "monitor");
|
|
536
|
+
fs.mkdirSync(path.join(monitor, "sapi"), { recursive: true });
|
|
537
|
+
fs.writeFileSync(path.join(monitor, "package.json"), JSON.stringify({ name: "@sfmc-bds/module-monitor", version: "0.2.1" }));
|
|
538
|
+
fs.writeFileSync(path.join(monitor, "sapi", "manifest.json"), JSON.stringify({ id: "monitor", configKey: "monitor", requires: [] }));
|
|
539
|
+
const chat = path.join(root, "modules", "packages", "chat");
|
|
540
|
+
fs.mkdirSync(path.join(chat, "sapi"), { recursive: true });
|
|
541
|
+
fs.writeFileSync(path.join(chat, "package.json"), JSON.stringify({ name: "@sfmc-bds/module-chat", version: "1.0.0" }));
|
|
542
|
+
fs.writeFileSync(
|
|
543
|
+
path.join(chat, "sapi", "manifest.json"),
|
|
544
|
+
JSON.stringify({ id: "chat", configKey: "chat", requires: ["monitor"] })
|
|
545
|
+
);
|
|
546
|
+
const plan = await planModuleUpdates({
|
|
547
|
+
root,
|
|
548
|
+
hostSdk: "0.2.5",
|
|
549
|
+
ids: ["monitor"],
|
|
550
|
+
fetchIndex: async () => ({
|
|
551
|
+
index: {
|
|
552
|
+
monitor: { npm: "@sfmc-bds/module-monitor", version: "0.5.0", sdk: ">=0.2.0" },
|
|
553
|
+
chat: { npm: "@sfmc-bds/module-chat", version: "1.1.0", sdk: ">=0.2.2" },
|
|
554
|
+
},
|
|
555
|
+
offline: false,
|
|
556
|
+
}),
|
|
557
|
+
fetchDistTag: async () => {
|
|
558
|
+
throw new Error("retired module should not query dist-tag");
|
|
559
|
+
},
|
|
560
|
+
});
|
|
561
|
+
assert.equal(plan.upgrades.length, 0);
|
|
562
|
+
const skipped = plan.skipped.find((item) => item.id === "monitor");
|
|
563
|
+
assert.equal(skipped?.reason, "retired");
|
|
564
|
+
assert.equal(skipped?.fromVersion, "0.2.1");
|
|
565
|
+
assert.equal(skipped?.toVersion, null);
|
|
566
|
+
|
|
567
|
+
const withChat = await planModuleUpdates({
|
|
568
|
+
root,
|
|
569
|
+
hostSdk: "0.2.5",
|
|
570
|
+
fetchIndex: async () => ({
|
|
571
|
+
index: {
|
|
572
|
+
monitor: { npm: "@sfmc-bds/module-monitor", version: "0.5.0", sdk: ">=0.2.0" },
|
|
573
|
+
chat: { npm: "@sfmc-bds/module-chat", version: "1.1.0", sdk: ">=0.2.2" },
|
|
574
|
+
},
|
|
575
|
+
offline: false,
|
|
576
|
+
}),
|
|
577
|
+
fetchDistTag: async () => {
|
|
578
|
+
throw new Error("indexed modules should not query dist-tag");
|
|
579
|
+
},
|
|
580
|
+
});
|
|
581
|
+
assert.deepEqual(withChat.upgrades.map((item) => item.id), ["chat"]);
|
|
582
|
+
assert.equal(withChat.skipped.some((item) => item.reason === "missing-dependency"), false);
|
|
583
|
+
assert.equal(withChat.skipped.find((item) => item.id === "monitor")?.reason, "retired");
|
|
584
|
+
|
|
585
|
+
const dependent = fs.mkdtempSync(path.join(os.tmpdir(), "sfmc-mod-retired-dep-"));
|
|
586
|
+
const onlyChat = path.join(dependent, "modules", "packages", "chat");
|
|
587
|
+
fs.mkdirSync(path.join(onlyChat, "sapi"), { recursive: true });
|
|
588
|
+
fs.writeFileSync(path.join(onlyChat, "package.json"), JSON.stringify({ name: "@sfmc-bds/module-chat", version: "1.0.0" }));
|
|
589
|
+
fs.writeFileSync(
|
|
590
|
+
path.join(onlyChat, "sapi", "manifest.json"),
|
|
591
|
+
JSON.stringify({ id: "chat", configKey: "chat", requires: ["monitor"] })
|
|
592
|
+
);
|
|
593
|
+
const dependentPlan = await planModuleUpdates({
|
|
594
|
+
root: dependent,
|
|
595
|
+
hostSdk: "0.2.5",
|
|
596
|
+
fetchIndex: async () => ({
|
|
597
|
+
index: { chat: { npm: "@sfmc-bds/module-chat", version: "1.1.0", sdk: ">=0.2.2" } },
|
|
598
|
+
offline: false,
|
|
599
|
+
}),
|
|
600
|
+
fetchDistTag: async () => null,
|
|
601
|
+
});
|
|
602
|
+
assert.deepEqual(dependentPlan.upgrades.map((item) => item.id), ["chat"]);
|
|
603
|
+
assert.equal(dependentPlan.skipped.some((item) => item.reason === "missing-dependency"), false);
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
test("换包阶段仍拒绝弃用模块", async () => {
|
|
607
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), "sfmc-mod-retired-apply-"));
|
|
608
|
+
const pkg = path.join(root, "modules", "packages", "monitor");
|
|
609
|
+
fs.mkdirSync(pkg, { recursive: true });
|
|
610
|
+
fs.writeFileSync(path.join(pkg, "marker.txt"), "old");
|
|
611
|
+
const result = await applyModuleUpgrades(
|
|
612
|
+
[{ id: "monitor", fromVersion: "0.2.1", toVersion: "0.5.0", spec: "npm:@sfmc-bds/module-monitor@0.5.0", requires: [] }],
|
|
613
|
+
{
|
|
614
|
+
root,
|
|
615
|
+
failMode: "continue",
|
|
616
|
+
install: async () => {
|
|
617
|
+
throw new Error("retired module must not be installed");
|
|
618
|
+
},
|
|
619
|
+
}
|
|
620
|
+
);
|
|
621
|
+
assert.equal(result.applied.length, 0);
|
|
622
|
+
assert.equal(result.failed.length, 0);
|
|
623
|
+
assert.equal(result.skipped[0]?.reason, "retired");
|
|
624
|
+
assert.equal(fs.readFileSync(path.join(pkg, "marker.txt"), "utf8"), "old");
|
|
625
|
+
});
|