Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/fix-module-registry-npm-info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@sfmc-bds/cli": patch
"@sfmc-bds/sfmc": patch
---

修正官方模块索引的 npm 来源显示,并按索引的精确版本安装模块。
11 changes: 8 additions & 3 deletions packages/cli/scripts/module-install/fetch-module.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ async function defaultSourceFor(id) {
const { index } = await resolveRegistryIndex();
const entry = index[id];
if (entry?.npm) {
console.log(`[fetch-module] ${id} found in registry → npm:${entry.npm}`);
return `npm:${entry.npm}`;
const spec = `${entry.npm}${entry.version ? `@${entry.version}` : ""}`;
console.log(`[fetch-module] ${id} found in registry → npm:${spec}`);
return `npm:${spec}`;
}
if (entry?.repo && entry?.tag) {
console.log(`[fetch-module] ${id} found in registry (deprecated github) → github:${entry.repo}@${entry.tag}`);
Expand Down Expand Up @@ -1003,7 +1004,11 @@ async function main() {
console.log(`Registry (${DEFAULT_REGISTRY_REPO}@${DEFAULT_REGISTRY_TAG}) — ${ids.length} modules:`);
for (const id of ids) {
const e = index[id];
const src = e.npm ? `npm:${e.npm}` : e.repo ? `github:${e.repo}@${e.tag}` : "?";
const src = e.npm
? `npm:${e.npm}${e.version ? `@${e.version}` : ""}`
: e.repo
? `github:${e.repo}@${e.tag}`
: "?";
console.log(` ${id.padEnd(28)} ${src}`);
}
return;
Expand Down
19 changes: 14 additions & 5 deletions packages/cli/src/module-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ export async function cmdModuleSearch(args: string[]): Promise<string> {
lines.push(c.dim(` ${"id".padEnd(28)}${"source".padEnd(40)}local`));
for (const id of ids) {
const e = index[id]!;
const src = `${e.repo}@${e.tag}`;
const src = e.npm
? `npm:${e.npm}${e.version ? `@${e.version}` : ""}`
: `github:${e.repo}@${e.tag}`;
const local = installed.has(id) ? c.green("●") : c.dim("○");
lines.push(` ${local} ${id.padEnd(26)}${src.padEnd(40)}${installed.has(id) ? "installed" : ""}`);
}
Expand All @@ -268,10 +270,17 @@ export async function cmdModuleSearch(args: string[]): Promise<string> {
const lines: string[] = [c.bold(`\n${query}`)];
if (staleNote) lines.push(staleNote.trimEnd());
lines.push(` registry : ${DEFAULT_REGISTRY_REPO}@${DEFAULT_REGISTRY_TAG}`);
lines.push(` repo : ${entry.repo}`);
lines.push(` tag : ${entry.tag}`);
lines.push(` source : github:${entry.repo}@${entry.tag}`);
lines.push(` github : https://github.com/${entry.repo}/tree/${entry.tag}`);
if (entry.npm) {
lines.push(` npm : ${entry.npm}`);
if (entry.version) lines.push(` version : ${entry.version}`);
lines.push(` source : npm:${entry.npm}${entry.version ? `@${entry.version}` : ""}`);
if (entry.sdk) lines.push(` sdk : ${entry.sdk}`);
} else {
lines.push(` repo : ${entry.repo}`);
lines.push(` tag : ${entry.tag}`);
lines.push(` source : github:${entry.repo}@${entry.tag}`);
lines.push(` github : https://github.com/${entry.repo}/tree/${entry.tag}`);
}
lines.push(
` local : ${isInstalled ? c.green(`installed @ ${installedPath}`) : c.dim("not installed")}`
);
Expand Down
Loading