@funnelsgrove/cli 0.1.9 → 0.1.10

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/dist/cli.d.ts CHANGED
@@ -12,4 +12,5 @@ export declare function resolveSyncTargetIds(input: SyncTargetIdInput): {
12
12
  workspaceId: string;
13
13
  funnelId?: string;
14
14
  };
15
+ export declare function isCliEntrypoint(invokedPath: string | undefined, modulePath: string, realpath?: (filePath: string) => string): boolean;
15
16
  export {};
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { readFileSync } from 'node:fs';
2
+ import { readFileSync, realpathSync } from 'node:fs';
3
3
  import { cp, mkdir } from 'node:fs/promises';
4
4
  import { createInterface } from 'node:readline/promises';
5
5
  import path from 'node:path';
@@ -50,6 +50,17 @@ export function resolveSyncTargetIds(input) {
50
50
  funnelId: input.explicitFunnelId || input.manifest?.funnelId || input.active?.funnelId,
51
51
  };
52
52
  }
53
+ export function isCliEntrypoint(invokedPath, modulePath, realpath = realpathSync) {
54
+ if (!invokedPath) {
55
+ return false;
56
+ }
57
+ try {
58
+ return realpath(path.resolve(invokedPath)) === realpath(modulePath);
59
+ }
60
+ catch {
61
+ return path.resolve(invokedPath) === path.resolve(modulePath);
62
+ }
63
+ }
53
64
  const getApiUrl = () => {
54
65
  const options = program.opts();
55
66
  return options.apiUrl || process.env.FUNNELSGROVE_API_URL || DEFAULT_API_URL;
@@ -845,7 +856,7 @@ addExamples(program
845
856
  console.log(' npm install');
846
857
  console.log(' npm run dev');
847
858
  });
848
- if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
859
+ if (isCliEntrypoint(process.argv[1], fileURLToPath(import.meta.url))) {
849
860
  program.parseAsync().catch((error) => {
850
861
  console.error(error instanceof Error ? error.message : String(error));
851
862
  process.exitCode = 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/cli",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "FunnelsGrove command-line tools for editing, syncing, and publishing funnels",
5
5
  "type": "module",
6
6
  "bin": {