stackpatch 1.1.9 → 1.2.0

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/bin/stackpatch ADDED
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+ const { spawnSync } = require('child_process');
3
+ const path = require('path');
4
+ const fs = require('fs');
5
+
6
+ // Get the directory of this script (CommonJS)
7
+ // In CommonJS, __filename is available, but if not, use require.main
8
+ const scriptPath = typeof __filename !== 'undefined' ? __filename : (require.main && require.main.filename) || process.argv[1];
9
+ const __dirname = path.dirname(scriptPath);
10
+
11
+ // Path to the TypeScript file
12
+ const tsFile = path.join(__dirname, 'stackpatch.ts');
13
+ const args = process.argv.slice(2);
14
+
15
+ // Try to find tsx in node_modules
16
+ const tsxPaths = [
17
+ path.join(__dirname, '../node_modules/.bin/tsx'),
18
+ path.join(__dirname, '../../node_modules/.bin/tsx'),
19
+ ];
20
+
21
+ let tsxCommand = null;
22
+ for (const tsxPath of tsxPaths) {
23
+ try {
24
+ if (fs.existsSync(tsxPath)) {
25
+ tsxCommand = tsxPath;
26
+ break;
27
+ }
28
+ } catch (e) {
29
+ // Continue
30
+ }
31
+ }
32
+
33
+ // Execute with tsx or npx
34
+ if (tsxCommand) {
35
+ const result = spawnSync(tsxCommand, [tsFile, ...args], {
36
+ stdio: 'inherit',
37
+ shell: true,
38
+ env: process.env,
39
+ });
40
+ process.exit(result.status || 0);
41
+ } else {
42
+ // Use npx as fallback
43
+ const result = spawnSync('npx', ['-y', 'tsx', tsFile, ...args], {
44
+ stdio: 'inherit',
45
+ shell: true,
46
+ env: process.env,
47
+ });
48
+ process.exit(result.status || 0);
49
+ }
package/bin/stackpatch.ts CHANGED
@@ -1,5 +1,4 @@
1
- #!/bin/sh
2
- ":" //; exec /usr/bin/env node -e "const {spawnSync} = require('child_process'); const result = spawnSync('npx', ['-y', 'tsx', process.argv[1], ...process.argv.slice(2)], {stdio: 'inherit'}); process.exit(result.status || 0);" "$0" "$@"
1
+ // This file is executed via bin/stackpatch wrapper
3
2
 
4
3
  import fs from "fs";
5
4
  import path from "path";
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "stackpatch",
3
- "version": "1.1.9",
3
+ "version": "1.2.0",
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.ts",
9
- "create-stackpatch": "bin/stackpatch.ts"
8
+ "stackpatch": "bin/stackpatch",
9
+ "create-stackpatch": "bin/stackpatch"
10
10
  },
11
11
  "files": [
12
12
  "bin",
@@ -17,6 +17,8 @@
17
17
  "test": "vitest run",
18
18
  "test:watch": "vitest",
19
19
  "test:coverage": "vitest run --coverage",
20
+ "test:cli": "node scripts/test-cli-execution.js",
21
+ "prepublishOnly": "node scripts/prepare-publish.js && npm run test:cli",
20
22
  "dev": "bun run bin/stackpatch.ts",
21
23
  "create": "bun run bin/stackpatch.ts"
22
24
  },