stackpatch 1.1.5 → 1.1.6
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 +11 -7
- package/bin/stackpatch.js +79 -0
- package/bin/stackpatch.ts +7 -4
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -72,19 +72,23 @@ The CLI will guide you through an interactive setup:
|
|
|
72
72
|
### Create New Project
|
|
73
73
|
|
|
74
74
|
```bash
|
|
75
|
-
# Using
|
|
76
|
-
npm create stackpatch@latest my-app
|
|
77
|
-
|
|
78
|
-
# Using npx
|
|
79
|
-
npx create-stackpatch@latest my-app
|
|
80
|
-
# or
|
|
75
|
+
# Using npx (recommended - works immediately)
|
|
81
76
|
npx stackpatch create my-app
|
|
82
77
|
|
|
78
|
+
# Or without project name (will prompt)
|
|
79
|
+
npx stackpatch create
|
|
80
|
+
|
|
81
|
+
# Using npm create (requires package to be published)
|
|
82
|
+
npm create stackpatch@latest my-app
|
|
83
|
+
|
|
83
84
|
# Using bunx (Bun's npx equivalent)
|
|
84
85
|
bunx create-stackpatch@latest my-app
|
|
85
86
|
```
|
|
86
87
|
|
|
87
|
-
> **Note:**
|
|
88
|
+
> **Note:**
|
|
89
|
+
> - `npx stackpatch create` works immediately and doesn't require the package to be published
|
|
90
|
+
> - `npm create` and `npx create-stackpatch@latest` require the package to be published to npm first
|
|
91
|
+
> - All commands will prompt you for a project name if not provided
|
|
88
92
|
|
|
89
93
|
### Revert an Installation
|
|
90
94
|
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* StackPatch CLI Wrapper
|
|
4
|
+
*
|
|
5
|
+
* This wrapper detects the runtime (Bun or Node.js) and executes the TypeScript file accordingly.
|
|
6
|
+
* - If Bun is available, uses Bun directly (faster)
|
|
7
|
+
* - Otherwise, uses tsx for Node.js compatibility
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { spawn, spawnSync } from "child_process";
|
|
11
|
+
import { fileURLToPath } from "url";
|
|
12
|
+
import { dirname, join } from "path";
|
|
13
|
+
import { existsSync } from "fs";
|
|
14
|
+
|
|
15
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
+
const __dirname = dirname(__filename);
|
|
17
|
+
const tsFile = join(__dirname, "stackpatch.ts");
|
|
18
|
+
|
|
19
|
+
// Check if Bun is available
|
|
20
|
+
function hasBun() {
|
|
21
|
+
try {
|
|
22
|
+
const result = spawnSync("bun", ["--version"], {
|
|
23
|
+
stdio: "ignore",
|
|
24
|
+
timeout: 1000,
|
|
25
|
+
});
|
|
26
|
+
return result.status === 0;
|
|
27
|
+
} catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Execute with appropriate runtime
|
|
33
|
+
const args = process.argv.slice(2);
|
|
34
|
+
|
|
35
|
+
if (hasBun()) {
|
|
36
|
+
// Use Bun if available
|
|
37
|
+
const bun = spawn("bun", [tsFile, ...args], {
|
|
38
|
+
stdio: "inherit",
|
|
39
|
+
cwd: process.cwd(),
|
|
40
|
+
});
|
|
41
|
+
bun.on("exit", (code) => process.exit(code || 0));
|
|
42
|
+
} else {
|
|
43
|
+
// Use tsx for Node.js
|
|
44
|
+
// Try multiple possible locations for tsx
|
|
45
|
+
const possibleTsxPaths = [
|
|
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
|
+
];
|
|
50
|
+
|
|
51
|
+
let tsxPath = null;
|
|
52
|
+
for (const path of possibleTsxPaths) {
|
|
53
|
+
if (existsSync(path)) {
|
|
54
|
+
tsxPath = path;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (tsxPath) {
|
|
60
|
+
const tsx = spawn(tsxPath, [tsFile, ...args], {
|
|
61
|
+
stdio: "inherit",
|
|
62
|
+
cwd: process.cwd(),
|
|
63
|
+
});
|
|
64
|
+
tsx.on("exit", (code) => process.exit(code || 0));
|
|
65
|
+
} else {
|
|
66
|
+
// Fallback: try tsx from PATH or use npx
|
|
67
|
+
const tsx = spawn("npx", ["-y", "tsx", tsFile, ...args], {
|
|
68
|
+
stdio: "inherit",
|
|
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
|
+
}
|
|
79
|
+
}
|
package/bin/stackpatch.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
// This file works with both Bun and Node.js
|
|
3
|
+
// - Bun can execute TypeScript files directly
|
|
4
|
+
// - Node.js uses tsx (installed as dependency) to execute TypeScript
|
|
2
5
|
|
|
3
6
|
import fs from "fs";
|
|
4
7
|
import path from "path";
|
|
@@ -9,9 +12,9 @@ import { spawnSync } from "child_process";
|
|
|
9
12
|
import Jimp from "jimp";
|
|
10
13
|
|
|
11
14
|
// ---------------- CONFIG ----------------
|
|
12
|
-
// Get directory path - Bun
|
|
13
|
-
//
|
|
14
|
-
const CLI_DIR = import.meta.dir || path.dirname(new URL(import.meta.url).pathname);
|
|
15
|
+
// Get directory path - Works with both Bun and Node.js
|
|
16
|
+
// Bun has import.meta.dir, Node.js doesn't - use fallback
|
|
17
|
+
const CLI_DIR = (import.meta as any).dir || path.dirname(new URL(import.meta.url).pathname);
|
|
15
18
|
// Resolve boilerplate path - use local boilerplate inside CLI package
|
|
16
19
|
const BOILERPLATE_ROOT = path.resolve(CLI_DIR, "../boilerplate");
|
|
17
20
|
const PATCHES: Record<
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stackpatch",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
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.js",
|
|
9
|
+
"create-stackpatch": "bin/stackpatch.js"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"bin",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"homepage": "https://github.com/Darshh09/StackPatch#readme",
|
|
49
49
|
"engines": {
|
|
50
|
+
"node": ">=18.0.0",
|
|
50
51
|
"bun": ">=1.0.0"
|
|
51
52
|
},
|
|
52
53
|
"packageManager": "pnpm@10.28.0",
|