@oh-my-tool/cli 0.3.4 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oh-my-tool/cli",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "type": "module",
5
5
  "description": "Oh My Tool CLI - local and enterprise tools for agents",
6
6
  "keywords": [
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "@clack/prompts": "^1.7.0",
31
31
  "@modelcontextprotocol/client": "2.0.0",
32
- "@oh-my-tool/sdk": "0.3.4",
32
+ "@oh-my-tool/sdk": "0.3.5",
33
33
  "open": "11.0.0"
34
34
  },
35
35
  "engines": {
@@ -24,8 +24,21 @@ export interface NpmExtensionSpec {
24
24
 
25
25
  export class ExtensionInstallError extends Error {}
26
26
 
27
+ export function npmExecutableForPlatform(platform: string = process.platform): string {
28
+ return platform === "win32" ? "npm.cmd" : "npm";
29
+ }
30
+
31
+ export function npmShellForPlatform(platform: string = process.platform): boolean {
32
+ return platform === "win32";
33
+ }
34
+
27
35
  export interface NpmInstallDependencies {
28
36
  install(spec: string, tempDir: string): Promise<void>;
37
+ execFile?(
38
+ file: string,
39
+ args: string[],
40
+ options: { cwd: string; shell: boolean; timeout: number; maxBuffer: number },
41
+ ): Promise<unknown>;
29
42
  }
30
43
 
31
44
  export function normalizeNpmExtensionSpec(spec: string): NpmExtensionSpec {
@@ -95,19 +108,23 @@ export async function installNpmExtension(
95
108
  if (dependencies.install !== undefined) {
96
109
  await dependencies.install(normalized.npmSpec, temp);
97
110
  } else {
98
- await execFile("npm", [
111
+ const runNpm: NonNullable<NpmInstallDependencies["execFile"]> = dependencies.execFile ?? (async (file, args, options) => {
112
+ await execFile(file, args, options);
113
+ });
114
+ await runNpm(npmExecutableForPlatform(), [
99
115
  "install",
100
- "--prefix", temp,
116
+ "--prefix", ".",
101
117
  "--ignore-scripts",
102
118
  "--no-save",
103
119
  "--no-package-lock",
104
120
  "--omit=dev",
105
121
  "--registry=https://registry.npmjs.org",
106
122
  "--", normalized.npmSpec,
107
- ], { timeout: 120_000, maxBuffer: 4 * 1024 * 1024 });
123
+ ], { cwd: temp, timeout: 120_000, maxBuffer: 4 * 1024 * 1024, shell: npmShellForPlatform() });
108
124
  }
109
- } catch {
110
- throw new ExtensionInstallError(`failed to download npm extension '${normalized.npmSpec}'`);
125
+ } catch (error) {
126
+ const message = error instanceof Error ? error.message : String(error);
127
+ throw new ExtensionInstallError(`failed to download npm extension '${normalized.npmSpec}': ${message}`);
111
128
  }
112
129
 
113
130
  const packageDir = join(temp, "node_modules", ...normalized.packageName.split("/"));
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = "0.3.4";
1
+ export const VERSION = "0.3.5";