Loading CHANGES.md +5 −0 Original line number Diff line number Diff line Loading @@ -8,10 +8,15 @@ Version 1.0.16 To be released. - Fixed a bug where the `fedify init` command had failed to locate package managers on Windows. [[#210]] - The `fedify` command became aware of `FEDIFY_LOG_FILE` environment variable to log messages to a file. If the variable is set, the command logs messages to the file specified by the variable. [#210]: https://github.com/fedify-dev/fedify/issues/210 Version 1.0.15 -------------- Loading cli/init.ts +21 −8 Original line number Diff line number Diff line Loading @@ -69,11 +69,11 @@ const packageManagers: Record<PackageManager, PackageManagerDescription> = { }, }; const packageManagerAvailabilities: Record<PackageManager, boolean> = Object .fromEntries( const packageManagerLocations: Record<PackageManager, string | undefined> = Object.fromEntries( await Promise.all( (Object.keys(packageManagers) as PackageManager[]) .map(async (pm) => [pm, await isPackageManagerAvailable(pm)]), .map(async (pm) => [pm, await locatePackageManager(pm)]), ), ); Loading Loading @@ -557,7 +557,7 @@ export const command = new Command() "package-manager", new EnumType( (Object.keys(packageManagers) as PackageManager[]).filter((pm) => packageManagerAvailabilities[pm] packageManagerLocations[pm] ), ), ) Loading Loading @@ -739,7 +739,7 @@ export const command = new Command() ); Deno.exit(1); } if (runtime === "node" && !packageManagerAvailabilities[packageManager]) { if (runtime === "node" && !packageManagerLocations[packageManager]) { console.error(`The ${packageManager} is not available on this system.`); Deno.exit(1); } Loading Loading @@ -1297,8 +1297,21 @@ function isRuntimeAvailable(runtime: Runtime): Promise<boolean> { return isCommandAvailable(runtimes[runtime]); } function isPackageManagerAvailable(pm: PackageManager): Promise<boolean> { return isCommandAvailable(packageManagers[pm]); async function locatePackageManager( pm: PackageManager, ): Promise<string | undefined> { if (await isCommandAvailable(packageManagers[pm])) { return packageManagers[pm].checkCommand[0]; } if (Deno.build.os !== "windows") return undefined; const cmd: [string, ...string[]] = [ packageManagers[pm].checkCommand[0] + ".cmd", ...packageManagers[pm].checkCommand.slice(1), ]; if (await isCommandAvailable({ ...packageManagers[pm], checkCommand: cmd })) { return cmd[0]; } return undefined; } async function addDependencies( Loading @@ -1324,7 +1337,7 @@ async function addDependencies( ); if (deps.length < 1) return; const cmd = new Deno.Command( runtime === "node" ? pm : runtime, runtime === "node" ? (packageManagerLocations[pm] ?? pm) : runtime, { args: [ "add", Loading Loading
CHANGES.md +5 −0 Original line number Diff line number Diff line Loading @@ -8,10 +8,15 @@ Version 1.0.16 To be released. - Fixed a bug where the `fedify init` command had failed to locate package managers on Windows. [[#210]] - The `fedify` command became aware of `FEDIFY_LOG_FILE` environment variable to log messages to a file. If the variable is set, the command logs messages to the file specified by the variable. [#210]: https://github.com/fedify-dev/fedify/issues/210 Version 1.0.15 -------------- Loading
cli/init.ts +21 −8 Original line number Diff line number Diff line Loading @@ -69,11 +69,11 @@ const packageManagers: Record<PackageManager, PackageManagerDescription> = { }, }; const packageManagerAvailabilities: Record<PackageManager, boolean> = Object .fromEntries( const packageManagerLocations: Record<PackageManager, string | undefined> = Object.fromEntries( await Promise.all( (Object.keys(packageManagers) as PackageManager[]) .map(async (pm) => [pm, await isPackageManagerAvailable(pm)]), .map(async (pm) => [pm, await locatePackageManager(pm)]), ), ); Loading Loading @@ -557,7 +557,7 @@ export const command = new Command() "package-manager", new EnumType( (Object.keys(packageManagers) as PackageManager[]).filter((pm) => packageManagerAvailabilities[pm] packageManagerLocations[pm] ), ), ) Loading Loading @@ -739,7 +739,7 @@ export const command = new Command() ); Deno.exit(1); } if (runtime === "node" && !packageManagerAvailabilities[packageManager]) { if (runtime === "node" && !packageManagerLocations[packageManager]) { console.error(`The ${packageManager} is not available on this system.`); Deno.exit(1); } Loading Loading @@ -1297,8 +1297,21 @@ function isRuntimeAvailable(runtime: Runtime): Promise<boolean> { return isCommandAvailable(runtimes[runtime]); } function isPackageManagerAvailable(pm: PackageManager): Promise<boolean> { return isCommandAvailable(packageManagers[pm]); async function locatePackageManager( pm: PackageManager, ): Promise<string | undefined> { if (await isCommandAvailable(packageManagers[pm])) { return packageManagers[pm].checkCommand[0]; } if (Deno.build.os !== "windows") return undefined; const cmd: [string, ...string[]] = [ packageManagers[pm].checkCommand[0] + ".cmd", ...packageManagers[pm].checkCommand.slice(1), ]; if (await isCommandAvailable({ ...packageManagers[pm], checkCommand: cmd })) { return cmd[0]; } return undefined; } async function addDependencies( Loading @@ -1324,7 +1337,7 @@ async function addDependencies( ); if (deps.length < 1) return; const cmd = new Deno.Command( runtime === "node" ? pm : runtime, runtime === "node" ? (packageManagerLocations[pm] ?? pm) : runtime, { args: [ "add", Loading