create-better-t-stack 3.11.0-pr749.7e7198c → 3.11.0-pr749.f5b98a1

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.
@@ -3,20 +3,24 @@
3
3
  /**
4
4
  * Bin stub for create-better-t-stack.
5
5
  * Finds and runs the platform-specific compiled binary.
6
- *
6
+ *
7
7
  * The binary is installed as an optional dependency:
8
8
  * @better-t-stack/cli-{platform}-{arch}
9
- *
9
+ *
10
10
  * This stub searches node_modules for the matching binary package.
11
11
  */
12
12
 
13
- const childProcess = require("child_process");
14
- const fs = require("fs");
15
- const path = require("path");
16
- const os = require("os");
13
+ import { spawnSync } from "node:child_process";
14
+ import { existsSync, realpathSync } from "node:fs";
15
+ import { dirname, join } from "node:path";
16
+ import { platform as osPlatform, arch as osArch } from "node:os";
17
+ import { fileURLToPath } from "node:url";
18
+
19
+ const __filename = fileURLToPath(import.meta.url);
20
+ const __dirname = dirname(__filename);
17
21
 
18
22
  function run(target) {
19
- const result = childProcess.spawnSync(target, process.argv.slice(2), {
23
+ const result = spawnSync(target, process.argv.slice(2), {
20
24
  stdio: "inherit",
21
25
  });
22
26
  if (result.error) {
@@ -33,8 +37,8 @@ if (envPath) {
33
37
  run(envPath);
34
38
  }
35
39
 
36
- const scriptPath = fs.realpathSync(__filename);
37
- const scriptDir = path.dirname(scriptPath);
40
+ const scriptPath = realpathSync(__filename);
41
+ const scriptDir = dirname(scriptPath);
38
42
 
39
43
  const platformMap = {
40
44
  darwin: "darwin",
@@ -47,14 +51,14 @@ const archMap = {
47
51
  arm64: "arm64",
48
52
  };
49
53
 
50
- let platform = platformMap[os.platform()];
54
+ let platform = platformMap[osPlatform()];
51
55
  if (!platform) {
52
- platform = os.platform();
56
+ platform = osPlatform();
53
57
  }
54
58
 
55
- let arch = archMap[os.arch()];
59
+ let arch = archMap[osArch()];
56
60
  if (!arch) {
57
- arch = os.arch();
61
+ arch = osArch();
58
62
  }
59
63
 
60
64
  // Scoped package name: @better-t-stack/cli-{platform}-{arch}
@@ -64,16 +68,16 @@ const binary = platform === "windows" ? "create-better-t-stack.exe" : "create-be
64
68
  function findBinary(startDir) {
65
69
  let current = startDir;
66
70
  for (; ;) {
67
- const modules = path.join(current, "node_modules");
68
- if (fs.existsSync(modules)) {
71
+ const modules = join(current, "node_modules");
72
+ if (existsSync(modules)) {
69
73
  // Check for scoped package: node_modules/@better-t-stack/cli-{platform}-{arch}
70
- const scopedPath = path.join(modules, "@better-t-stack", "cli-" + platform + "-" + arch);
71
- const candidate = path.join(scopedPath, "bin", binary);
72
- if (fs.existsSync(candidate)) {
74
+ const scopedPath = join(modules, "@better-t-stack", "cli-" + platform + "-" + arch);
75
+ const candidate = join(scopedPath, "bin", binary);
76
+ if (existsSync(candidate)) {
73
77
  return candidate;
74
78
  }
75
79
  }
76
- const parent = path.dirname(current);
80
+ const parent = dirname(current);
77
81
  if (parent === current) {
78
82
  return;
79
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-better-t-stack",
3
- "version": "3.11.0-pr749.7e7198c",
3
+ "version": "3.11.0-pr749.f5b98a1",
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",
@@ -41,8 +41,7 @@
41
41
  },
42
42
  "files": [
43
43
  "bin",
44
- "templates",
45
- "scripts/postinstall.mjs"
44
+ "templates"
46
45
  ],
47
46
  "type": "module",
48
47
  "publishConfig": {
@@ -57,11 +56,10 @@
57
56
  "test:watch": "bun test --watch",
58
57
  "test:coverage": "bun test --coverage",
59
58
  "test:ci": "AGENT=1 bun test --bail=5",
60
- "prepublishOnly": "echo 'Build binaries separately before publishing'",
61
- "postinstall": "node ./scripts/postinstall.mjs || true"
59
+ "prepublishOnly": "echo 'Build binaries separately before publishing'"
62
60
  },
63
61
  "dependencies": {
64
- "@better-t-stack/types": "3.11.0-pr749.7e7198c",
62
+ "@better-t-stack/types": "3.11.0-pr749.f5b98a1",
65
63
  "@clack/prompts": "^1.0.0-alpha.8",
66
64
  "commander": "^14.0.2",
67
65
  "consola": "^3.4.2",
@@ -1,129 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Postinstall script for create-better-t-stack.
5
- * Symlinks the platform-specific binary to the bin directory for convenience.
6
- *
7
- * This runs after npm install to set up the binary.
8
- */
9
-
10
- import fs from "fs";
11
- import path from "path";
12
- import os from "os";
13
- import { fileURLToPath } from "url";
14
- import { createRequire } from "module";
15
-
16
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
17
- const require = createRequire(import.meta.url);
18
-
19
- function detectPlatformAndArch() {
20
- let platform;
21
- switch (os.platform()) {
22
- case "darwin":
23
- platform = "darwin";
24
- break;
25
- case "linux":
26
- platform = "linux";
27
- break;
28
- case "win32":
29
- platform = "windows";
30
- break;
31
- default:
32
- platform = os.platform();
33
- break;
34
- }
35
-
36
- let arch;
37
- switch (os.arch()) {
38
- case "x64":
39
- arch = "x64";
40
- break;
41
- case "arm64":
42
- arch = "arm64";
43
- break;
44
- default:
45
- arch = os.arch();
46
- break;
47
- }
48
-
49
- return { platform, arch };
50
- }
51
-
52
- function findBinary() {
53
- const { platform, arch } = detectPlatformAndArch();
54
- // Scoped package: @better-t-stack/cli-{platform}-{arch}
55
- const packageName = `@better-t-stack/cli-${platform}-${arch}`;
56
- const binaryName = platform === "windows" ? "create-better-t-stack.exe" : "create-better-t-stack";
57
-
58
- try {
59
- // Use require.resolve to find the package
60
- const packageJsonPath = require.resolve(`${packageName}/package.json`);
61
- const packageDir = path.dirname(packageJsonPath);
62
- const binaryPath = path.join(packageDir, "bin", binaryName);
63
-
64
- if (!fs.existsSync(binaryPath)) {
65
- throw new Error(`Binary not found at ${binaryPath}`);
66
- }
67
-
68
- return { binaryPath, binaryName };
69
- } catch (error) {
70
- throw new Error(`Could not find package ${packageName}: ${error.message}`);
71
- }
72
- }
73
-
74
- function prepareBinDirectory(binaryName) {
75
- const binDir = path.join(__dirname, "..", "bin");
76
- const targetPath = path.join(binDir, binaryName);
77
-
78
- // Ensure bin directory exists
79
- if (!fs.existsSync(binDir)) {
80
- fs.mkdirSync(binDir, { recursive: true });
81
- }
82
-
83
- // Remove existing binary/symlink if it exists
84
- try {
85
- if (fs.existsSync(targetPath) || fs.lstatSync(targetPath).isSymbolicLink()) {
86
- fs.unlinkSync(targetPath);
87
- }
88
- } catch {
89
- // File doesn't exist, that's fine
90
- }
91
-
92
- return { binDir, targetPath };
93
- }
94
-
95
- function symlinkBinary(sourcePath, binaryName) {
96
- const { targetPath } = prepareBinDirectory(binaryName);
97
-
98
- fs.symlinkSync(sourcePath, targetPath);
99
- console.log(`create-better-t-stack binary symlinked: ${targetPath} -> ${sourcePath}`);
100
-
101
- // Verify the file exists after operation
102
- if (!fs.existsSync(targetPath)) {
103
- throw new Error(`Failed to symlink binary to ${targetPath}`);
104
- }
105
- }
106
-
107
- async function main() {
108
- try {
109
- if (os.platform() === "win32") {
110
- // On Windows, symlinks require admin privileges
111
- // The bin stub will find the binary directly
112
- console.log("Windows detected: skipping symlink (bin stub will find binary directly)");
113
- return;
114
- }
115
-
116
- const { binaryPath, binaryName } = findBinary();
117
- symlinkBinary(binaryPath, binaryName);
118
- } catch (error) {
119
- // Don't fail the install if we can't symlink - the bin stub will still work
120
- console.log(`Note: Could not symlink binary (${error.message}). The CLI will still work.`);
121
- }
122
- }
123
-
124
- try {
125
- main();
126
- } catch (error) {
127
- // Silently continue - postinstall failures shouldn't break the install
128
- console.log("Postinstall completed with warnings.");
129
- }