infinite-tag 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. package/dist/src/cli.js +21 -3
  2. package/package.json +1 -1
package/dist/src/cli.js CHANGED
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env node
2
+ import { realpathSync } from "node:fs";
2
3
  import { createInterface } from "node:readline";
3
4
  import { resolve } from "node:path";
5
+ import { fileURLToPath } from "node:url";
4
6
  import { applyInstallation } from "./apply.js";
5
7
  import { isSupportedFramework } from "./frameworks/index.js";
6
8
  import { inspectWorkspace } from "./inspect.js";
@@ -141,7 +143,7 @@ function maybePrintCommands(command, packageManager, workspaceId) {
141
143
  return;
142
144
  }
143
145
  const commands = buildPackageManagerCommands(resolved, {
144
- pinnedVersion: "0.1.1",
146
+ pinnedVersion: "0.1.2",
145
147
  workspaceId
146
148
  });
147
149
  if (command === "inspect" || command === "verify") {
@@ -408,8 +410,24 @@ export async function runCli(argv = process.argv.slice(2)) {
408
410
  return 1;
409
411
  }
410
412
  }
411
- const invokedAsScript = process.argv[1] && import.meta.url.endsWith(process.argv[1]);
412
- if (invokedAsScript) {
413
+ // Run as the CLI when invoked directly — robustly. npx and global installs invoke
414
+ // through a node_modules/.bin/<name> symlink, so process.argv[1] is the symlink
415
+ // path, NOT this module's real file path; the old `import.meta.url.endsWith(argv[1])`
416
+ // check failed there and the CLI silently no-op'd (exit 0, no output). Comparing
417
+ // resolved real paths makes npx, global-install, and direct `node cli.js` all work.
418
+ function isMainModule() {
419
+ const invoked = process.argv[1];
420
+ if (!invoked) {
421
+ return false;
422
+ }
423
+ try {
424
+ return realpathSync(invoked) === realpathSync(fileURLToPath(import.meta.url));
425
+ }
426
+ catch {
427
+ return false;
428
+ }
429
+ }
430
+ if (isMainModule()) {
413
431
  void runCli().then((exitCode) => {
414
432
  process.exitCode = exitCode;
415
433
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "infinite-tag",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Founder-run installer that adds analytics (Google Analytics 4, PostHog, X/Twitter Pixel) to your web app — public keys only, idempotent, and reversible.",
5
5
  "keywords": ["analytics","ga4","google-analytics","posthog","twitter-pixel","installer","instrumentation","nextjs","vite","infinite"],
6
6
  "license": "MIT",