create-better-t-stack 3.11.0-bun-compile-opentui.bd6d873 → 3.11.0-bun-compile-opentui.57b2f37

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.
@@ -19,9 +19,14 @@ import { fileURLToPath } from "node:url";
19
19
  const __filename = fileURLToPath(import.meta.url);
20
20
  const __dirname = dirname(__filename);
21
21
 
22
- function run(target) {
22
+ function run(target, pkgRoot) {
23
23
  const result = spawnSync(target, process.argv.slice(2), {
24
24
  stdio: "inherit",
25
+ env: {
26
+ ...process.env,
27
+ // Pass the package root to the binary so it knows where templates are
28
+ CREATE_BETTER_T_STACK_PKG_ROOT: pkgRoot,
29
+ },
25
30
  });
26
31
  if (result.error) {
27
32
  console.error(result.error.message);
@@ -34,7 +39,9 @@ function run(target) {
34
39
  // Allow override via environment variable
35
40
  const envPath = process.env.CREATE_BETTER_T_STACK_BIN_PATH;
36
41
  if (envPath) {
37
- run(envPath);
42
+ // Use existing PKG_ROOT env var if set, otherwise use parent of this script's dir
43
+ const pkgRoot = process.env.CREATE_BETTER_T_STACK_PKG_ROOT || dirname(__dirname);
44
+ run(envPath, pkgRoot);
38
45
  }
39
46
 
40
47
  const scriptPath = realpathSync(__filename);
@@ -95,4 +102,6 @@ if (!resolved) {
95
102
  process.exit(1);
96
103
  }
97
104
 
98
- run(resolved);
105
+ // The package root is the parent of bin/ (where this script lives)
106
+ const pkgRoot = dirname(scriptDir);
107
+ run(resolved, pkgRoot);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-better-t-stack",
3
- "version": "3.11.0-bun-compile-opentui.bd6d873",
3
+ "version": "3.11.0-bun-compile-opentui.57b2f37",
4
4
  "description": "A modern CLI tool for scaffolding end-to-end type-safe TypeScript projects with best practices and customizable configurations",
5
5
  "keywords": [
6
6
  "better-auth",
@@ -68,7 +68,7 @@
68
68
  "prepublishOnly": "echo 'Build binaries separately before publishing'"
69
69
  },
70
70
  "dependencies": {
71
- "@better-t-stack/types": "3.11.0-bun-compile-opentui.bd6d873",
71
+ "@better-t-stack/types": "3.11.0-bun-compile-opentui.57b2f37",
72
72
  "@clack/prompts": "^1.0.0-alpha.8",
73
73
  "@opentui/core": "^0.1.62",
74
74
  "@opentui/react": "^0.1.62",
@@ -93,11 +93,11 @@
93
93
  "typescript": "^5.9.3"
94
94
  },
95
95
  "optionalDependencies": {
96
- "@better-t-stack/cli-darwin-arm64": "3.11.0-bun-compile-opentui.bd6d873",
97
- "@better-t-stack/cli-darwin-x64": "3.11.0-bun-compile-opentui.bd6d873",
98
- "@better-t-stack/cli-linux-arm64": "3.11.0-bun-compile-opentui.bd6d873",
99
- "@better-t-stack/cli-linux-x64": "3.11.0-bun-compile-opentui.bd6d873",
100
- "@better-t-stack/cli-windows-x64": "3.11.0-bun-compile-opentui.bd6d873",
96
+ "@better-t-stack/cli-darwin-arm64": "3.11.0-bun-compile-opentui.57b2f37",
97
+ "@better-t-stack/cli-darwin-x64": "3.11.0-bun-compile-opentui.57b2f37",
98
+ "@better-t-stack/cli-linux-arm64": "3.11.0-bun-compile-opentui.57b2f37",
99
+ "@better-t-stack/cli-linux-x64": "3.11.0-bun-compile-opentui.57b2f37",
100
+ "@better-t-stack/cli-windows-x64": "3.11.0-bun-compile-opentui.57b2f37",
101
101
  "@opentui/core-darwin-arm64": "0.1.63",
102
102
  "@opentui/core-darwin-x64": "0.1.63",
103
103
  "@opentui/core-linux-arm64": "0.1.63",
package/src/constants.ts CHANGED
@@ -6,58 +6,46 @@ import { getUserPkgManager } from "./utils/get-package-manager";
6
6
  /**
7
7
  * Find the package root directory containing templates.
8
8
  *
9
- * For compiled binaries: The binary runs from @better-t-stack/cli-{platform}-{arch},
10
- * but templates are shipped with the main create-better-t-stack package.
11
- * We need to find that package.
12
- *
13
- * For dev/npm distribution: Uses the current source directory.
14
- *
15
- * Package structure when installed via npm/bunx:
16
- * <cache>/node_modules/create-better-t-stack/
17
- * ├── templates/ <-- templates are here
18
- * ├── bin/ <-- stub is here
19
- * └── node_modules/
20
- * └── @better-t-stack/
21
- * └── cli-darwin-arm64/
22
- * └── bin/ <-- compiled binary runs from here
9
+ * For compiled binaries: Uses CREATE_BETTER_T_STACK_PKG_ROOT env var set by bin stub.
10
+ * For dev mode: Uses the source directory.
23
11
  */
24
12
  function findPackageRoot(): string {
25
- // Get the directory of the current module
13
+ // First, check if the bin stub passed the package root
14
+ const envPkgRoot = process.env.CREATE_BETTER_T_STACK_PKG_ROOT;
15
+ if (envPkgRoot) {
16
+ const templatesPath = path.join(envPkgRoot, "templates");
17
+ if (fs.existsSync(templatesPath)) {
18
+ return envPkgRoot;
19
+ }
20
+ }
21
+
22
+ // In development (running from source), find templates relative to this file
26
23
  const __filename = fileURLToPath(import.meta.url);
27
24
  const __dirname = path.dirname(__filename);
28
-
29
- // In development or when running from source (e.g., `bun run dev`),
30
- // we're already in the right package - just go up from src/constants.ts
31
25
  const devRoot = path.resolve(__dirname, "..");
32
26
  const devTemplatesPath = path.join(devRoot, "templates");
33
27
  if (fs.existsSync(devTemplatesPath)) {
34
28
  return devRoot;
35
29
  }
36
30
 
37
- // For compiled binaries, walk up the directory tree looking for templates
38
- // The binary is typically at:
39
- // .../create-better-t-stack/node_modules/@better-t-stack/cli-{os}-{arch}/bin/
40
- // And we need to find:
41
- // .../create-better-t-stack/templates/
42
- let current = __dirname;
43
- while (current !== path.dirname(current)) {
44
- // Check if this directory has templates (we found create-better-t-stack root)
31
+ // Fallback: try walking up from executable location
32
+ const execDir = path.dirname(process.execPath);
33
+ let current = execDir;
34
+ let iterations = 0;
35
+
36
+ while (current !== path.dirname(current) && iterations < 20) {
37
+ iterations++;
45
38
  const templatesPath = path.join(current, "templates");
46
39
  if (fs.existsSync(templatesPath)) {
47
40
  return current;
48
41
  }
49
-
50
- // Check for create-better-t-stack in node_modules at this level
51
- const nodeModulesPath = path.join(current, "node_modules", "create-better-t-stack");
52
- const nodeModulesTemplatesPath = path.join(nodeModulesPath, "templates");
53
- if (fs.existsSync(nodeModulesTemplatesPath)) {
54
- return nodeModulesPath;
55
- }
56
-
57
42
  current = path.dirname(current);
58
43
  }
59
44
 
60
- // Fallback: return dev root and hope for the best
45
+ // Not found - log error and return dev root as fallback
46
+ console.error(`[PKG_ROOT ERROR] Could not find templates directory!`);
47
+ console.error(`[PKG_ROOT ERROR] Env: ${envPkgRoot || "(not set)"}`);
48
+ console.error(`[PKG_ROOT ERROR] execDir: ${execDir}`);
61
49
  return devRoot;
62
50
  }
63
51