stackpatch 1.1.6 → 1.1.8
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/README.md +3 -5
- package/bin/stackpatch.js +39 -36
- package/bin/stackpatch.ts +3 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -78,17 +78,15 @@ npx stackpatch create my-app
|
|
|
78
78
|
# Or without project name (will prompt)
|
|
79
79
|
npx stackpatch create
|
|
80
80
|
|
|
81
|
-
# Using
|
|
82
|
-
npm create stackpatch@latest my-app
|
|
83
|
-
|
|
84
|
-
# Using bunx (Bun's npx equivalent)
|
|
81
|
+
# Using bunx (Bun's npx equivalent - if you have Bun installed)
|
|
85
82
|
bunx create-stackpatch@latest my-app
|
|
86
83
|
```
|
|
87
84
|
|
|
88
85
|
> **Note:**
|
|
89
86
|
> - `npx stackpatch create` works immediately and doesn't require the package to be published
|
|
90
|
-
> - `npm create
|
|
87
|
+
> - `npm create stackpatch@latest` will work after the package is published to npm
|
|
91
88
|
> - All commands will prompt you for a project name if not provided
|
|
89
|
+
> - The CLI automatically detects and uses Bun if available, otherwise falls back to Node.js with tsx
|
|
92
90
|
|
|
93
91
|
### Revert an Installation
|
|
94
92
|
|
package/bin/stackpatch.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* This wrapper detects the runtime (Bun or Node.js) and executes the TypeScript file accordingly.
|
|
6
6
|
* - If Bun is available, uses Bun directly (faster)
|
|
7
|
-
* - Otherwise, uses tsx for Node.js compatibility
|
|
7
|
+
* - Otherwise, uses tsx via npx for Node.js compatibility
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { spawn, spawnSync } from "child_process";
|
|
@@ -16,6 +16,12 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
16
16
|
const __dirname = dirname(__filename);
|
|
17
17
|
const tsFile = join(__dirname, "stackpatch.ts");
|
|
18
18
|
|
|
19
|
+
// Verify the TypeScript file exists
|
|
20
|
+
if (!existsSync(tsFile)) {
|
|
21
|
+
console.error(`Error: TypeScript file not found: ${tsFile}`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
19
25
|
// Check if Bun is available
|
|
20
26
|
function hasBun() {
|
|
21
27
|
try {
|
|
@@ -33,47 +39,44 @@ function hasBun() {
|
|
|
33
39
|
const args = process.argv.slice(2);
|
|
34
40
|
|
|
35
41
|
if (hasBun()) {
|
|
36
|
-
// Use Bun if available
|
|
42
|
+
// Use Bun if available - Bun can execute TypeScript directly
|
|
37
43
|
const bun = spawn("bun", [tsFile, ...args], {
|
|
38
44
|
stdio: "inherit",
|
|
39
45
|
cwd: process.cwd(),
|
|
40
46
|
});
|
|
41
|
-
|
|
47
|
+
|
|
48
|
+
bun.on("exit", (code) => {
|
|
49
|
+
process.exit(code || 0);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
bun.on("error", (err) => {
|
|
53
|
+
console.error("Error running Bun:", err.message);
|
|
54
|
+
// Fallback to npx tsx
|
|
55
|
+
console.log("Falling back to Node.js with tsx...");
|
|
56
|
+
runWithTsx();
|
|
57
|
+
});
|
|
42
58
|
} else {
|
|
43
59
|
// Use tsx for Node.js
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
join(__dirname, "../node_modules/.bin/tsx"), // Local installation
|
|
47
|
-
join(__dirname, "../../node_modules/.bin/tsx"), // Monorepo structure
|
|
48
|
-
join(process.cwd(), "node_modules/.bin/tsx"), // Project's node_modules
|
|
49
|
-
];
|
|
60
|
+
runWithTsx();
|
|
61
|
+
}
|
|
50
62
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
function runWithTsx() {
|
|
64
|
+
// Always use npx -y tsx - it's the most reliable method
|
|
65
|
+
// npx will download tsx if needed, and it works in all scenarios
|
|
66
|
+
const tsx = spawn("npx", ["-y", "tsx", tsFile, ...args], {
|
|
67
|
+
stdio: "inherit",
|
|
68
|
+
cwd: process.cwd(),
|
|
69
|
+
shell: true, // Use shell for npx to handle PATH correctly
|
|
70
|
+
});
|
|
58
71
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
cwd: process.cwd(),
|
|
70
|
-
});
|
|
71
|
-
tsx.on("exit", (code) => {
|
|
72
|
-
if (code !== 0) {
|
|
73
|
-
console.error("Error: Could not execute TypeScript file. Please ensure tsx is available.");
|
|
74
|
-
process.exit(1);
|
|
75
|
-
}
|
|
76
|
-
process.exit(code || 0);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
72
|
+
tsx.on("exit", (code) => {
|
|
73
|
+
process.exit(code || 0);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
tsx.on("error", (err) => {
|
|
77
|
+
console.error("Error: Could not execute TypeScript file.");
|
|
78
|
+
console.error("Please ensure Node.js and npm are properly installed.");
|
|
79
|
+
console.error("Original error:", err.message);
|
|
80
|
+
process.exit(1);
|
|
81
|
+
});
|
|
79
82
|
}
|
package/bin/stackpatch.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// This file should be executed via bin/stackpatch.js wrapper
|
|
3
|
+
// Direct execution is not recommended - use the wrapper instead
|
|
2
4
|
// This file works with both Bun and Node.js
|
|
3
5
|
// - Bun can execute TypeScript files directly
|
|
4
6
|
// - Node.js uses tsx (installed as dependency) to execute TypeScript
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stackpatch",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"description": "Composable frontend features for modern React & Next.js apps - Add authentication, UI components, and more with zero configuration",
|
|
5
5
|
"main": "bin/stackpatch.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
|
-
"stackpatch": "bin/stackpatch.
|
|
9
|
-
"create-stackpatch": "bin/stackpatch.
|
|
8
|
+
"stackpatch": "bin/stackpatch.ts",
|
|
9
|
+
"create-stackpatch": "bin/stackpatch.ts"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"bin",
|