fix(cli): resolve package updates on Windows
This commit is contained in:
@@ -292,7 +292,7 @@
|
|||||||
},
|
},
|
||||||
"packages/cli": {
|
"packages/cli": {
|
||||||
"name": "@wrnexus/cli",
|
"name": "@wrnexus/cli",
|
||||||
"version": "0.8.63",
|
"version": "0.8.64",
|
||||||
"bin": {
|
"bin": {
|
||||||
"wrnexus": "src/index.ts",
|
"wrnexus": "src/index.ts",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@wrnexus/cli",
|
"name": "@wrnexus/cli",
|
||||||
"version": "0.8.63",
|
"version": "0.8.64",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -63,14 +63,16 @@ const execFileAsync = promisify(execFile);
|
|||||||
|
|
||||||
/** Resolve every installed WRNexus dependency independently and in parallel. */
|
/** Resolve every installed WRNexus dependency independently and in parallel. */
|
||||||
export async function latestPackageVersions(names: string[]): Promise<Map<string, string>> {
|
export async function latestPackageVersions(names: string[]): Promise<Map<string, string>> {
|
||||||
const npm = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
||||||
const unique = [...new Set(names.filter((name) => name.startsWith("@wrnexus/")))];
|
const unique = [...new Set(names.filter((name) => name.startsWith("@wrnexus/")))];
|
||||||
const entries = await Promise.all(
|
const entries = await Promise.all(
|
||||||
unique.map(async (name) => {
|
unique.map(async (name) => {
|
||||||
try {
|
try {
|
||||||
const { stdout } = await execFileAsync(npm, ["view", name, "version", "--json"], {
|
const command = process.platform === "win32" ? (process.env.ComSpec ?? "cmd.exe") : "npm";
|
||||||
encoding: "utf8",
|
const args =
|
||||||
});
|
process.platform === "win32"
|
||||||
|
? ["/d", "/s", "/c", "npm", "view", name, "version", "--json"]
|
||||||
|
: ["view", name, "version", "--json"];
|
||||||
|
const { stdout } = await execFileAsync(command, args, { encoding: "utf8" });
|
||||||
const parsed = JSON.parse(stdout.trim()) as string | string[];
|
const parsed = JSON.parse(stdout.trim()) as string | string[];
|
||||||
const version = Array.isArray(parsed) ? parsed.at(-1) : parsed;
|
const version = Array.isArray(parsed) ? parsed.at(-1) : parsed;
|
||||||
return typeof version === "string" && /^\d+\.\d+\.\d+/.test(version)
|
return typeof version === "string" && /^\d+\.\d+\.\d+/.test(version)
|
||||||
@@ -1274,6 +1276,13 @@ export async function runUpdate(dir: string, args: string[]): Promise<void> {
|
|||||||
? new Map<string, string>()
|
? new Map<string, string>()
|
||||||
: await latestPackageVersions(dependencyNames);
|
: await latestPackageVersions(dependencyNames);
|
||||||
|
|
||||||
|
if (!versionArg && dependencyNames.length > 0 && packageVersions.size === 0) {
|
||||||
|
throw new Error(
|
||||||
|
`Unable to resolve any of ${new Set(dependencyNames).size} installed WRNexus package ` +
|
||||||
|
`version(s) from npm. Check the @wrnexus registry and authentication before retrying.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
console.log(`\n ⚡ wrnexus update → migrations ${target}${dryRun ? " (dry run)" : ""}`);
|
console.log(`\n ⚡ wrnexus update → migrations ${target}${dryRun ? " (dry run)" : ""}`);
|
||||||
if (!versionArg) {
|
if (!versionArg) {
|
||||||
console.log(
|
console.log(
|
||||||
|
|||||||
Reference in New Issue
Block a user