@appthen/cli 1.2.13 → 1.2.14

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/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@appthen/cli",
3
- "version": "1.2.13",
3
+ "version": "1.2.14",
4
4
  "description": "Appthen Cli Tool",
5
5
  "files": [
6
6
  "dist",
7
+ "scripts",
7
8
  "tests",
8
9
  "jest.config.js",
9
10
  ".editorconfig",
@@ -0,0 +1,73 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ /**
5
+ * Fixes execution permissions for node-pty spawn-helper.
6
+ * This is required because some package managers (like pnpm) might lose the executable bit,
7
+ * causing "posix_spawnp failed" errors on macOS/Linux.
8
+ */
9
+ function fixPtyPermissions() {
10
+ try {
11
+ // 1. Attempt to resolve node-pty location dynamically to handle hoisting
12
+ let ptyRoot;
13
+ try {
14
+ const ptyEntry = require.resolve('node-pty');
15
+ // Navigate up to find package root containing prebuilds
16
+ // Typically: node_modules/node-pty/lib/index.js -> node_modules/node-pty
17
+ let current = path.dirname(ptyEntry);
18
+ while (current !== path.parse(current).root) {
19
+ if (fs.existsSync(path.join(current, 'package.json')) &&
20
+ fs.existsSync(path.join(current, 'prebuilds'))) {
21
+ ptyRoot = current;
22
+ break;
23
+ }
24
+ current = path.dirname(current);
25
+ }
26
+ } catch (e) {
27
+ // Fallback to local node_modules if require.resolve fails (e.g. dev environment)
28
+ ptyRoot = path.join(__dirname, '..', 'node_modules', 'node-pty');
29
+ }
30
+
31
+ if (!ptyRoot || !fs.existsSync(ptyRoot)) {
32
+ console.log('[fix-permissions] node-pty not found, skipping.');
33
+ return;
34
+ }
35
+
36
+ const prebuildsDir = path.join(ptyRoot, 'prebuilds');
37
+ if (!fs.existsSync(prebuildsDir)) return;
38
+
39
+ console.log(`[fix-permissions] Checking permissions in ${prebuildsDir}`);
40
+
41
+ const platforms = fs.readdirSync(prebuildsDir);
42
+ let fixedCount = 0;
43
+
44
+ platforms.forEach(platform => {
45
+ // spawn-helper is the binary name on Unix-like systems
46
+ const helperPath = path.join(prebuildsDir, platform, 'spawn-helper');
47
+
48
+ if (fs.existsSync(helperPath)) {
49
+ try {
50
+ // Check current permissions
51
+ const stats = fs.statSync(helperPath);
52
+ // Check if executable bit is set (0o111)
53
+ if ((stats.mode & 0o111) === 0) {
54
+ fs.chmodSync(helperPath, 0o755);
55
+ console.log(`[fix-permissions] Fixed +x for: ${platform}/spawn-helper`);
56
+ fixedCount++;
57
+ }
58
+ } catch (err) {
59
+ console.warn(`[fix-permissions] Failed to fix ${platform}: ${err.message}`);
60
+ }
61
+ }
62
+ });
63
+
64
+ if (fixedCount > 0) {
65
+ console.log(`[fix-permissions] Successfully fixed ${fixedCount} binaries.`);
66
+ }
67
+
68
+ } catch (error) {
69
+ console.warn('[fix-permissions] Error:', error.message);
70
+ }
71
+ }
72
+
73
+ fixPtyPermissions();