@simple-auth-kit/cli 1.0.0 → 1.0.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,17 +1,29 @@
1
1
  #!/usr/bin/env node
2
- // Thin launcher so `npm link` (run once, inside cli/) makes `simple-auth-kit` a real global command —
3
- // matching shadcn's `npx shadcn add <component>` ergonomics: run it from inside any consumer
4
- // project, no `cd` into this repo, no `--into` needed (it already defaults to cwd). Spawns the
5
- // local tsx binary by absolute path so this works regardless of the caller's cwd or global PATH.
2
+ // Thin launcher so `npm link` (or the published @simple-auth-kit/cli via npx) makes
3
+ // `simple-auth-kit` a real command — matching shadcn's `npx shadcn add <component>` ergonomics:
4
+ // run it from inside any consumer project, no `cd` into this repo, no `--into` needed (it
5
+ // already defaults to cwd).
6
+ //
7
+ // Resolves tsx via Node's own module resolution (require.resolve), not a hardcoded
8
+ // "../node_modules/.bin/tsx" relative path — that broke under plain npm/npx installs, which
9
+ // hoist tsx to a shared top-level node_modules rather than nesting it inside this package's own
10
+ // node_modules (pnpm's per-package node_modules made this invisible in monorepo dev). Reading
11
+ // tsx's own package.json "bin" field, rather than hardcoding "dist/cli.mjs", stays correct even
12
+ // if tsx's internal file layout changes in a future version.
6
13
  import { spawnSync } from "node:child_process";
14
+ import { createRequire } from "node:module";
7
15
  import { dirname, join } from "node:path";
8
16
  import { fileURLToPath } from "node:url";
9
17
 
10
18
  const here = dirname(fileURLToPath(import.meta.url));
11
- const tsxBin = join(here, "..", "node_modules", ".bin", "tsx");
12
19
  const entry = join(here, "..", "simple-auth-kit.ts");
13
20
 
14
- const result = spawnSync(tsxBin, [entry, ...process.argv.slice(2)], {
21
+ const require = createRequire(import.meta.url);
22
+ const tsxPkgJson = require.resolve("tsx/package.json");
23
+ const tsxBin = typeof require(tsxPkgJson).bin === "string" ? require(tsxPkgJson).bin : require(tsxPkgJson).bin.tsx;
24
+ const tsxCli = join(dirname(tsxPkgJson), tsxBin);
25
+
26
+ const result = spawnSync(process.execPath, [tsxCli, entry, ...process.argv.slice(2)], {
15
27
  stdio: "inherit",
16
28
  cwd: process.cwd(),
17
29
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simple-auth-kit/cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "license": "MIT",
5
5
  "description": "simple-auth-kit add <combo> — copies registry source (backend combos, admin consoles, mobile apps) into a consumer repo, shadcn-CLI-style. Nothing is ever installed as a runtime dependency of the consumer.",
6
6
  "bin": {