@flowscripter/dynamic-cli-framework 10.1.0 → 10.1.1

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.
@@ -1,5 +1,6 @@
1
1
  import type { Prompt, PromptResult, SpawnService } from "@flowscripter/dynamic-cli-framework-api";
2
2
  import type { PromptContext } from "./PromptContext.ts";
3
+ export declare function getOpenCommand(platform: string, url: string): string[];
3
4
  export declare function defaultOpenUrl(spawnService: SpawnService, url: string): Promise<void>;
4
5
  export default function promptOpenUrl(ctx: PromptContext, promptDef: Prompt): Promise<PromptResult>;
5
6
  //# sourceMappingURL=promptOpenUrl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"promptOpenUrl.d.ts","sourceRoot":"","sources":["../../../../../src/service/prompter/prompt/promptOpenUrl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAGlG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMxD,wBAAsB,cAAc,CAAC,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB3F;AAED,wBAA8B,aAAa,CACzC,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,YAAY,CAAC,CAkDvB"}
1
+ {"version":3,"file":"promptOpenUrl.d.ts","sourceRoot":"","sources":["../../../../../src/service/prompter/prompt/promptOpenUrl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAGlG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMxD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAQtE;AAED,wBAAsB,cAAc,CAAC,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB3F;AAED,wBAA8B,aAAa,CACzC,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,YAAY,CAAC,CAkDvB"}
@@ -3,21 +3,21 @@ import { getSpawnService, interrupt, renderPromptHeader } from "./PromptContext.
3
3
  function isRemoteSession() {
4
4
  return !!(process.env.SSH_CONNECTION || process.env.SSH_CLIENT || process.env.SSH_TTY);
5
5
  }
6
+ export function getOpenCommand(platform, url) {
7
+ if (platform === "darwin") {
8
+ return ["open", url];
9
+ }
10
+ if (platform === "win32") {
11
+ return ["rundll32", "url.dll,FileProtocolHandler", url];
12
+ }
13
+ return ["xdg-open", url];
14
+ }
6
15
  export async function defaultOpenUrl(spawnService, url) {
7
16
  const parsed = new URL(url);
8
17
  if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
9
18
  throw new Error(`Unsupported URL protocol: ${parsed.protocol}`);
10
19
  }
11
- let cmd;
12
- if (process.platform === "darwin") {
13
- cmd = ["open", url];
14
- }
15
- else if (process.platform === "win32") {
16
- cmd = ["cmd", "/c", "start", "", url];
17
- }
18
- else {
19
- cmd = ["xdg-open", url];
20
- }
20
+ const cmd = getOpenCommand(process.platform, parsed.href);
21
21
  const result = await spawnService.spawn(cmd, { mode: "ignore", longRunning: false });
22
22
  if (result.ok) {
23
23
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowscripter/dynamic-cli-framework",
3
- "version": "10.1.0",
3
+ "version": "10.1.1",
4
4
  "description": "A framework for developing CLI applications which supports dynamic discovery and installation of new commands",
5
5
  "keywords": [
6
6
  "bun",
@@ -7,19 +7,22 @@ function isRemoteSession(): boolean {
7
7
  return !!(process.env.SSH_CONNECTION || process.env.SSH_CLIENT || process.env.SSH_TTY);
8
8
  }
9
9
 
10
+ export function getOpenCommand(platform: string, url: string): string[] {
11
+ if (platform === "darwin") {
12
+ return ["open", url];
13
+ }
14
+ if (platform === "win32") {
15
+ return ["rundll32", "url.dll,FileProtocolHandler", url];
16
+ }
17
+ return ["xdg-open", url];
18
+ }
19
+
10
20
  export async function defaultOpenUrl(spawnService: SpawnService, url: string): Promise<void> {
11
21
  const parsed = new URL(url);
12
22
  if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
13
23
  throw new Error(`Unsupported URL protocol: ${parsed.protocol}`);
14
24
  }
15
- let cmd: string[];
16
- if (process.platform === "darwin") {
17
- cmd = ["open", url];
18
- } else if (process.platform === "win32") {
19
- cmd = ["cmd", "/c", "start", "", url];
20
- } else {
21
- cmd = ["xdg-open", url];
22
- }
25
+ const cmd = getOpenCommand(process.platform, parsed.href);
23
26
  const result = await spawnService.spawn(cmd, { mode: "ignore", longRunning: false });
24
27
  if (result.ok) {
25
28
  return;