@appthen/cli 1.2.12 → 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/dist/index.js +22 -23
- package/package.json +2 -4
- package/scripts/fix-permissions.js +73 -0
package/dist/index.js
CHANGED
|
@@ -29,7 +29,6 @@ require('prettier');
|
|
|
29
29
|
var fs$1 = require('fs-extra');
|
|
30
30
|
var io = require('socket.io-client');
|
|
31
31
|
var fs$2 = require('fs/promises');
|
|
32
|
-
var chokidar = require('chokidar');
|
|
33
32
|
var pty = require('node-pty');
|
|
34
33
|
|
|
35
34
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -80,7 +79,6 @@ var fs__namespace = /*#__PURE__*/_interopNamespace(fs$1);
|
|
|
80
79
|
var fs__default$2 = /*#__PURE__*/_interopDefaultLegacy(fs$1);
|
|
81
80
|
var io__default = /*#__PURE__*/_interopDefaultLegacy(io);
|
|
82
81
|
var fs__default$1 = /*#__PURE__*/_interopDefaultLegacy(fs$2);
|
|
83
|
-
var chokidar__default = /*#__PURE__*/_interopDefaultLegacy(chokidar);
|
|
84
82
|
var pty__namespace = /*#__PURE__*/_interopNamespace(pty);
|
|
85
83
|
|
|
86
84
|
/******************************************************************************
|
|
@@ -32790,6 +32788,7 @@ function regExpEscape (s) {
|
|
|
32790
32788
|
return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
|
|
32791
32789
|
}
|
|
32792
32790
|
|
|
32791
|
+
// import chokidar, { FSWatcher } from 'chokidar';
|
|
32793
32792
|
var logger = function () {
|
|
32794
32793
|
var args = [];
|
|
32795
32794
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -34173,27 +34172,27 @@ var ShadowSpace = /** @class */ (function () {
|
|
|
34173
34172
|
logger('[ShadowSpace] 监听目录:', this.config.projectRoot);
|
|
34174
34173
|
try {
|
|
34175
34174
|
// 🔥 使用轮询模式 + ignored 函数过滤
|
|
34176
|
-
this.watcher =
|
|
34177
|
-
|
|
34178
|
-
|
|
34179
|
-
|
|
34180
|
-
|
|
34181
|
-
|
|
34182
|
-
|
|
34183
|
-
|
|
34184
|
-
|
|
34185
|
-
|
|
34186
|
-
|
|
34187
|
-
|
|
34188
|
-
|
|
34189
|
-
|
|
34190
|
-
|
|
34191
|
-
|
|
34192
|
-
|
|
34193
|
-
|
|
34194
|
-
|
|
34195
|
-
|
|
34196
|
-
});
|
|
34175
|
+
// this.watcher = chokidar.watch(this.config.projectRoot, {
|
|
34176
|
+
// ignored: (filePath: string) => {
|
|
34177
|
+
// const relativePath = path.relative(this.config.projectRoot, filePath);
|
|
34178
|
+
// // 忽略根目录本身
|
|
34179
|
+
// if (!relativePath || relativePath === '.') {
|
|
34180
|
+
// return true;
|
|
34181
|
+
// }
|
|
34182
|
+
// // 使用白名单过滤
|
|
34183
|
+
// return this.shouldIgnoreFile(relativePath);
|
|
34184
|
+
// },
|
|
34185
|
+
// persistent: true,
|
|
34186
|
+
// ignoreInitial: true, // 忽略初始扫描
|
|
34187
|
+
// usePolling: true, // 🔥 macOS 上使用轮询模式(fsevents 在某些环境下不可靠)
|
|
34188
|
+
// interval: 2000, // 轮询间隔 2 秒(降低 CPU 占用)
|
|
34189
|
+
// binaryInterval: 3000, // 二进制文件轮询间隔 3 秒
|
|
34190
|
+
// depth: 99, // 监听所有子目录
|
|
34191
|
+
// awaitWriteFinish: {
|
|
34192
|
+
// stabilityThreshold: 500, // 文件稳定后 500ms 才触发
|
|
34193
|
+
// pollInterval: 100,
|
|
34194
|
+
// },
|
|
34195
|
+
// });
|
|
34197
34196
|
logger('[ShadowSpace] chokidar.watch 已调用,等待 ready 事件...');
|
|
34198
34197
|
}
|
|
34199
34198
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appthen/cli",
|
|
3
|
-
"version": "1.2.
|
|
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",
|
|
@@ -76,10 +77,8 @@
|
|
|
76
77
|
"babel-plugin-import": "^1.13.8",
|
|
77
78
|
"babel-plugin-module-resolver": "^4.1.0",
|
|
78
79
|
"base-64": "^1.0.0",
|
|
79
|
-
"bufferutil": "^4.0.8",
|
|
80
80
|
"chalk": "^4.0.0",
|
|
81
81
|
"change-case": "^3.1.0",
|
|
82
|
-
"chokidar": "^4.0.3",
|
|
83
82
|
"commander": "^6.1.0",
|
|
84
83
|
"cssjson": "^2.1.3",
|
|
85
84
|
"execa": "9.3.1",
|
|
@@ -87,7 +86,6 @@
|
|
|
87
86
|
"form-data": "^4.0.0",
|
|
88
87
|
"fp-ts": "^2.11.9",
|
|
89
88
|
"fs-extra": "^11.2.0",
|
|
90
|
-
"fsevents": "^2.3.3",
|
|
91
89
|
"getpinyin": "^1.1.4",
|
|
92
90
|
"glob": "^7.1.6",
|
|
93
91
|
"http-proxy": "^1.18.1",
|
|
@@ -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();
|