@kevisual/cli 0.0.67 → 0.0.70
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/assistant-server.js +3 -3
- package/bin/assistant.js +3 -3
- package/bin/envision.js +3 -3
- package/bun.config.mjs +19 -19
- package/dist/assistant-server.js +157 -30
- package/dist/assistant.js +31 -16
- package/dist/envision.js +12 -5
- package/package.json +77 -77
- package/readme.md +8 -8
package/bin/assistant-server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { runParser } from '../dist/assistant-server.js';
|
|
3
|
-
|
|
4
|
-
runParser(process.argv);
|
|
2
|
+
import { runParser } from '../dist/assistant-server.js';
|
|
3
|
+
|
|
4
|
+
runParser(process.argv);
|
package/bin/assistant.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { runParser } from '../dist/assistant.js';
|
|
3
|
-
|
|
4
|
-
runParser(process.argv);
|
|
2
|
+
import { runParser } from '../dist/assistant.js';
|
|
3
|
+
|
|
4
|
+
runParser(process.argv);
|
package/bin/envision.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { runParser } from '../dist/envision.js';
|
|
3
|
-
|
|
4
|
-
runParser(process.argv);
|
|
2
|
+
import { runParser } from '../dist/envision.js';
|
|
3
|
+
|
|
4
|
+
runParser(process.argv);
|
package/bun.config.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
// https://bun.sh/docs/bundler
|
|
3
|
-
// @ts-ignore
|
|
4
|
-
import pkg from './package.json';
|
|
5
|
-
// bun run src/index.ts --
|
|
6
|
-
await Bun.build({
|
|
7
|
-
target: 'node',
|
|
8
|
-
format: 'esm',
|
|
9
|
-
entrypoints: ['./src/index.ts'],
|
|
10
|
-
outdir: './dist',
|
|
11
|
-
naming: {
|
|
12
|
-
entry: 'envision.js',
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
define: {
|
|
16
|
-
ENVISION_VERSION: JSON.stringify(pkg.version),
|
|
17
|
-
},
|
|
18
|
-
env: 'ENVISION_*',
|
|
19
|
-
});
|
|
1
|
+
// @ts-check
|
|
2
|
+
// https://bun.sh/docs/bundler
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import pkg from './package.json';
|
|
5
|
+
// bun run src/index.ts --
|
|
6
|
+
await Bun.build({
|
|
7
|
+
target: 'node',
|
|
8
|
+
format: 'esm',
|
|
9
|
+
entrypoints: ['./src/index.ts'],
|
|
10
|
+
outdir: './dist',
|
|
11
|
+
naming: {
|
|
12
|
+
entry: 'envision.js',
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
define: {
|
|
16
|
+
ENVISION_VERSION: JSON.stringify(pkg.version),
|
|
17
|
+
},
|
|
18
|
+
env: 'ENVISION_*',
|
|
19
|
+
});
|
package/dist/assistant-server.js
CHANGED
|
@@ -67103,7 +67103,7 @@ var wsProxy = (server, config2) => {
|
|
|
67103
67103
|
wssApp.upgrade(request, socket, head);
|
|
67104
67104
|
});
|
|
67105
67105
|
};
|
|
67106
|
-
// ../node_modules/.pnpm/@kevisual+local-app-manager@0.1.
|
|
67106
|
+
// ../node_modules/.pnpm/@kevisual+local-app-manager@0.1.32_supports-color@10.2.2/node_modules/@kevisual/local-app-manager/dist/manager.mjs
|
|
67107
67107
|
var exports_manager = {};
|
|
67108
67108
|
__export(exports_manager, {
|
|
67109
67109
|
onAppShowInfo: () => onAppShowInfo,
|
|
@@ -67180,10 +67180,11 @@ var getConfigFile = (opts) => {
|
|
|
67180
67180
|
return "";
|
|
67181
67181
|
};
|
|
67182
67182
|
|
|
67183
|
-
// ../node_modules/.pnpm/@kevisual+local-app-manager@0.1.
|
|
67183
|
+
// ../node_modules/.pnpm/@kevisual+local-app-manager@0.1.32_supports-color@10.2.2/node_modules/@kevisual/local-app-manager/dist/manager.mjs
|
|
67184
67184
|
import path$1 from "node:path";
|
|
67185
67185
|
import fs$4 from "node:fs";
|
|
67186
67186
|
import { fork } from "node:child_process";
|
|
67187
|
+
import { fileURLToPath } from "node:url";
|
|
67187
67188
|
import require$$02 from "os";
|
|
67188
67189
|
import require$$0$12 from "path";
|
|
67189
67190
|
import require$$0$22 from "util";
|
|
@@ -67239,7 +67240,8 @@ var saveAppInfo = async (data, appsPath, filename = "apps.config.json") => {
|
|
|
67239
67240
|
fs$4.writeFileSync(configFile, JSON.stringify(data, null, 2));
|
|
67240
67241
|
};
|
|
67241
67242
|
var deleteFileAppInfo = async (key, appsPath) => {
|
|
67242
|
-
const
|
|
67243
|
+
const normalizedKey = key.replace(/\//g, path$1.sep);
|
|
67244
|
+
const directory = path$1.join(appsPath, normalizedKey);
|
|
67243
67245
|
if (!fileIsExist2(directory)) {
|
|
67244
67246
|
return;
|
|
67245
67247
|
}
|
|
@@ -73531,6 +73533,12 @@ function requireOut() {
|
|
|
73531
73533
|
}
|
|
73532
73534
|
var outExports = requireOut();
|
|
73533
73535
|
var glob = /* @__PURE__ */ getDefaultExportFromCjs2(outExports);
|
|
73536
|
+
var normalizeScriptPath = (scriptPath) => {
|
|
73537
|
+
if (process.platform === "win32") {
|
|
73538
|
+
return scriptPath.replace(/\\/g, "/");
|
|
73539
|
+
}
|
|
73540
|
+
return scriptPath;
|
|
73541
|
+
};
|
|
73534
73542
|
var connect = async (noDaemonMode = false) => {
|
|
73535
73543
|
return new Promise((resolve, reject) => {
|
|
73536
73544
|
pm2.connect(noDaemonMode, (err) => {
|
|
@@ -73632,9 +73640,10 @@ class Pm2Manager {
|
|
|
73632
73640
|
console.error("script is required");
|
|
73633
73641
|
return;
|
|
73634
73642
|
}
|
|
73643
|
+
const normalizedScript = normalizeScriptPath(script);
|
|
73635
73644
|
const starter = {
|
|
73636
73645
|
name: appName,
|
|
73637
|
-
script,
|
|
73646
|
+
script: normalizedScript,
|
|
73638
73647
|
cwd: process.cwd(),
|
|
73639
73648
|
interpreter,
|
|
73640
73649
|
...options,
|
|
@@ -73791,7 +73800,8 @@ class Manager {
|
|
|
73791
73800
|
app.process = childProcess;
|
|
73792
73801
|
} else if (app.type === "system-app") {
|
|
73793
73802
|
const pathEntryAndTimestamp = path$1.join(app.path, entry2);
|
|
73794
|
-
const
|
|
73803
|
+
const importPath = process.platform === "win32" ? "file:///" + pathEntryAndTimestamp.replace(/\\/g, "/") : pathEntryAndTimestamp;
|
|
73804
|
+
const module = await import(importPath);
|
|
73795
73805
|
if (module.loadApp && mainApp) {
|
|
73796
73806
|
await module.loadApp?.(mainApp, app);
|
|
73797
73807
|
}
|
|
@@ -74068,7 +74078,8 @@ class Manager {
|
|
|
74068
74078
|
}
|
|
74069
74079
|
}
|
|
74070
74080
|
var installAppFromKey = async (key, _appPath) => {
|
|
74071
|
-
const
|
|
74081
|
+
const normalizedKey = key.replace(/\//g, path$1.sep);
|
|
74082
|
+
const directory = path$1.join(_appPath, normalizedKey);
|
|
74072
74083
|
if (!fileIsExist2(directory)) {
|
|
74073
74084
|
console.error("App not found", directory);
|
|
74074
74085
|
throw new Error("App not found");
|
|
@@ -74113,7 +74124,9 @@ var installAppFromKey = async (key, _appPath) => {
|
|
|
74113
74124
|
var getAppPathKeys = async (_appPath) => {
|
|
74114
74125
|
const directory = path$1.resolve(_appPath);
|
|
74115
74126
|
const root3 = directory;
|
|
74116
|
-
const
|
|
74127
|
+
const path1 = "*/package.json";
|
|
74128
|
+
const path22 = "*/*/package.json";
|
|
74129
|
+
const appsPackages = await glob([path1, path22], {
|
|
74117
74130
|
cwd: root3,
|
|
74118
74131
|
onlyFiles: true,
|
|
74119
74132
|
absolute: false,
|
|
@@ -74121,21 +74134,21 @@ var getAppPathKeys = async (_appPath) => {
|
|
|
74121
74134
|
});
|
|
74122
74135
|
const appPathKeys = appsPackages.map((pkg) => {
|
|
74123
74136
|
const dir = path$1.dirname(pkg);
|
|
74124
|
-
|
|
74125
|
-
return relativePath;
|
|
74137
|
+
return dir.replace(/\\/g, "/");
|
|
74126
74138
|
});
|
|
74127
74139
|
return appPathKeys;
|
|
74128
74140
|
};
|
|
74129
74141
|
var clearMicroApp = (link) => {
|
|
74130
74142
|
try {
|
|
74131
|
-
const
|
|
74143
|
+
const moduleUrl = new URL(link, import.meta.url);
|
|
74144
|
+
const modulePath = fileURLToPath(moduleUrl);
|
|
74132
74145
|
delete __require.cache[modulePath];
|
|
74133
74146
|
console.log(`Module ${link} has been unloaded.`);
|
|
74134
74147
|
} catch (error2) {
|
|
74135
74148
|
console.error(`Failed to unload module ${link}:`, error2);
|
|
74136
74149
|
}
|
|
74137
74150
|
};
|
|
74138
|
-
// ../node_modules/.pnpm/@kevisual+local-app-manager@0.1.
|
|
74151
|
+
// ../node_modules/.pnpm/@kevisual+local-app-manager@0.1.32_supports-color@10.2.2/node_modules/@kevisual/local-app-manager/dist/pm2.mjs
|
|
74139
74152
|
import pm22 from "pm2";
|
|
74140
74153
|
import { promisify as promisify2 } from "node:util";
|
|
74141
74154
|
var disconnect = promisify2(pm22.disconnect).bind(pm22);
|
|
@@ -74189,13 +74202,15 @@ class AssistantApp extends Manager {
|
|
|
74189
74202
|
}
|
|
74190
74203
|
async getPageAndAppList() {
|
|
74191
74204
|
const root3 = this.config.configPath.configDir;
|
|
74192
|
-
const
|
|
74205
|
+
const path1 = "apps/*/*/package.json";
|
|
74206
|
+
const path22 = "pages/*/*/package.json";
|
|
74207
|
+
const pages = await import_fast_glob.default([path1, path22], {
|
|
74193
74208
|
cwd: root3,
|
|
74194
74209
|
onlyFiles: true
|
|
74195
74210
|
});
|
|
74196
74211
|
const pagesParse = pages.map((page) => {
|
|
74197
|
-
const relativePath =
|
|
74198
|
-
const contentStr = fs7.readFileSync(path7.join(page), "utf-8");
|
|
74212
|
+
const relativePath = page;
|
|
74213
|
+
const contentStr = fs7.readFileSync(path7.join(root3, page), "utf-8");
|
|
74199
74214
|
const content = parseIfJson2(contentStr);
|
|
74200
74215
|
if (!content.appType) {
|
|
74201
74216
|
const isWeb = relativePath.startsWith("pages/");
|
|
@@ -80490,7 +80505,7 @@ app.route({
|
|
|
80490
80505
|
// src/routes/index.ts
|
|
80491
80506
|
import os4 from "node:os";
|
|
80492
80507
|
|
|
80493
|
-
// ../node_modules/.pnpm/lru-cache@11.2.
|
|
80508
|
+
// ../node_modules/.pnpm/lru-cache@11.2.4/node_modules/lru-cache/dist/esm/index.js
|
|
80494
80509
|
var defaultPerf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
|
|
80495
80510
|
var warned = new Set;
|
|
80496
80511
|
var PROCESS = typeof process === "object" && !!process ? process : {};
|
|
@@ -80614,6 +80629,7 @@ class LRUCache {
|
|
|
80614
80629
|
#sizes;
|
|
80615
80630
|
#starts;
|
|
80616
80631
|
#ttls;
|
|
80632
|
+
#autopurgeTimers;
|
|
80617
80633
|
#hasDispose;
|
|
80618
80634
|
#hasFetchMethod;
|
|
80619
80635
|
#hasDisposeAfter;
|
|
@@ -80622,6 +80638,7 @@ class LRUCache {
|
|
|
80622
80638
|
return {
|
|
80623
80639
|
starts: c.#starts,
|
|
80624
80640
|
ttls: c.#ttls,
|
|
80641
|
+
autopurgeTimers: c.#autopurgeTimers,
|
|
80625
80642
|
sizes: c.#sizes,
|
|
80626
80643
|
keyMap: c.#keyMap,
|
|
80627
80644
|
keyList: c.#keyList,
|
|
@@ -80782,10 +80799,16 @@ class LRUCache {
|
|
|
80782
80799
|
const starts = new ZeroArray(this.#max);
|
|
80783
80800
|
this.#ttls = ttls;
|
|
80784
80801
|
this.#starts = starts;
|
|
80802
|
+
const purgeTimers = this.ttlAutopurge ? new Array(this.#max) : undefined;
|
|
80803
|
+
this.#autopurgeTimers = purgeTimers;
|
|
80785
80804
|
this.#setItemTTL = (index, ttl, start3 = this.#perf.now()) => {
|
|
80786
80805
|
starts[index] = ttl !== 0 ? start3 : 0;
|
|
80787
80806
|
ttls[index] = ttl;
|
|
80788
|
-
if (
|
|
80807
|
+
if (purgeTimers?.[index]) {
|
|
80808
|
+
clearTimeout(purgeTimers[index]);
|
|
80809
|
+
purgeTimers[index] = undefined;
|
|
80810
|
+
}
|
|
80811
|
+
if (ttl !== 0 && purgeTimers) {
|
|
80789
80812
|
const t = setTimeout(() => {
|
|
80790
80813
|
if (this.#isStale(index)) {
|
|
80791
80814
|
this.#delete(this.#keyList[index], "expire");
|
|
@@ -80794,6 +80817,7 @@ class LRUCache {
|
|
|
80794
80817
|
if (t.unref) {
|
|
80795
80818
|
t.unref();
|
|
80796
80819
|
}
|
|
80820
|
+
purgeTimers[index] = t;
|
|
80797
80821
|
}
|
|
80798
80822
|
};
|
|
80799
80823
|
this.#updateItemAge = (index) => {
|
|
@@ -81206,6 +81230,10 @@ class LRUCache {
|
|
|
81206
81230
|
}
|
|
81207
81231
|
}
|
|
81208
81232
|
this.#removeItemSize(head);
|
|
81233
|
+
if (this.#autopurgeTimers?.[head]) {
|
|
81234
|
+
clearTimeout(this.#autopurgeTimers[head]);
|
|
81235
|
+
this.#autopurgeTimers[head] = undefined;
|
|
81236
|
+
}
|
|
81209
81237
|
if (free) {
|
|
81210
81238
|
this.#keyList[head] = undefined;
|
|
81211
81239
|
this.#valList[head] = undefined;
|
|
@@ -81540,6 +81568,10 @@ class LRUCache {
|
|
|
81540
81568
|
if (this.#size !== 0) {
|
|
81541
81569
|
const index = this.#keyMap.get(k);
|
|
81542
81570
|
if (index !== undefined) {
|
|
81571
|
+
if (this.#autopurgeTimers?.[index]) {
|
|
81572
|
+
clearTimeout(this.#autopurgeTimers?.[index]);
|
|
81573
|
+
this.#autopurgeTimers[index] = undefined;
|
|
81574
|
+
}
|
|
81543
81575
|
deleted = true;
|
|
81544
81576
|
if (this.#size === 1) {
|
|
81545
81577
|
this.#clear(reason);
|
|
@@ -81607,6 +81639,11 @@ class LRUCache {
|
|
|
81607
81639
|
if (this.#ttls && this.#starts) {
|
|
81608
81640
|
this.#ttls.fill(0);
|
|
81609
81641
|
this.#starts.fill(0);
|
|
81642
|
+
for (const t of this.#autopurgeTimers ?? []) {
|
|
81643
|
+
if (t !== undefined)
|
|
81644
|
+
clearTimeout(t);
|
|
81645
|
+
}
|
|
81646
|
+
this.#autopurgeTimers?.fill(undefined);
|
|
81610
81647
|
}
|
|
81611
81648
|
if (this.#sizes) {
|
|
81612
81649
|
this.#sizes.fill(0);
|
|
@@ -81871,7 +81908,63 @@ var {
|
|
|
81871
81908
|
} = import__.default;
|
|
81872
81909
|
|
|
81873
81910
|
// src/server.ts
|
|
81874
|
-
import { spawnSync as spawnSync4 } from "child_process";
|
|
81911
|
+
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
81912
|
+
import path14 from "node:path";
|
|
81913
|
+
// src/module/get-bun-path.ts
|
|
81914
|
+
import fs13 from "node:fs";
|
|
81915
|
+
import path13 from "node:path";
|
|
81916
|
+
import { execSync } from "node:child_process";
|
|
81917
|
+
var getBunPath = () => {
|
|
81918
|
+
const isWindows = process.platform === "win32";
|
|
81919
|
+
const bunExecutableName = isWindows ? "bun.exe" : "bun";
|
|
81920
|
+
if (process.env.BUN_PATH) {
|
|
81921
|
+
return process.env.BUN_PATH;
|
|
81922
|
+
}
|
|
81923
|
+
if (isWindows) {
|
|
81924
|
+
try {
|
|
81925
|
+
const globalNodeModules = execSync("npm root -g", { encoding: "utf-8" }).trim();
|
|
81926
|
+
const bunExePath = path13.join(globalNodeModules, "bun", "bin", "bun.exe");
|
|
81927
|
+
if (fs13.existsSync(bunExePath)) {
|
|
81928
|
+
return bunExePath;
|
|
81929
|
+
}
|
|
81930
|
+
} catch (error2) {}
|
|
81931
|
+
try {
|
|
81932
|
+
const bunPath = execSync("where bun", { encoding: "utf-8" }).trim().split(`
|
|
81933
|
+
`)[0];
|
|
81934
|
+
if (bunPath && bunPath.endsWith(".exe")) {
|
|
81935
|
+
return bunPath;
|
|
81936
|
+
}
|
|
81937
|
+
if (bunPath) {
|
|
81938
|
+
const bunDir = path13.dirname(bunPath);
|
|
81939
|
+
const bunExePath = path13.join(bunDir, "node_modules", "bun", "bin", "bun.exe");
|
|
81940
|
+
if (fs13.existsSync(bunExePath)) {
|
|
81941
|
+
return bunExePath;
|
|
81942
|
+
}
|
|
81943
|
+
}
|
|
81944
|
+
} catch (error2) {}
|
|
81945
|
+
} else {
|
|
81946
|
+
try {
|
|
81947
|
+
const bunPath = execSync("which bun", { encoding: "utf-8" }).trim();
|
|
81948
|
+
if (bunPath && fs13.existsSync(bunPath)) {
|
|
81949
|
+
return bunPath;
|
|
81950
|
+
}
|
|
81951
|
+
} catch (error2) {}
|
|
81952
|
+
}
|
|
81953
|
+
const commonPaths = [
|
|
81954
|
+
"/usr/local/bin/bun",
|
|
81955
|
+
"/usr/bin/bun",
|
|
81956
|
+
"C:\\Program Files\\Bun\\bun.exe",
|
|
81957
|
+
"C:\\Bun\\bun.exe"
|
|
81958
|
+
];
|
|
81959
|
+
for (const p of commonPaths) {
|
|
81960
|
+
if (fs13.existsSync(p)) {
|
|
81961
|
+
return p;
|
|
81962
|
+
}
|
|
81963
|
+
}
|
|
81964
|
+
return bunExecutableName;
|
|
81965
|
+
};
|
|
81966
|
+
|
|
81967
|
+
// src/server.ts
|
|
81875
81968
|
var runServer = async (port, listenPath = "127.0.0.1") => {
|
|
81876
81969
|
let _port;
|
|
81877
81970
|
if (port) {
|
|
@@ -81913,32 +82006,66 @@ var runServer = async (port, listenPath = "127.0.0.1") => {
|
|
|
81913
82006
|
port: _port
|
|
81914
82007
|
};
|
|
81915
82008
|
};
|
|
81916
|
-
program.description("启动服务").option("-d, --daemon", "是否以守护进程方式运行").option("-n, --name <name>", "服务名称", "assistant-server").option("-p, --port <port>", "服务端口").option("-s, --start", "是否启动服务").option("-e, --interpreter <interpreter>", "指定使用的解释器", "bun").
|
|
82009
|
+
program.description("启动服务").option("-d, --daemon", "是否以守护进程方式运行").option("-n, --name <name>", "服务名称", "assistant-server").option("-p, --port <port>", "服务端口").option("-s, --start", "是否启动服务").option("-e, --interpreter <interpreter>", "指定使用的解释器", "bun").action(async (options) => {
|
|
81917
82010
|
if (options.daemon) {
|
|
81918
82011
|
const [_interpreter, execPath] = process.argv;
|
|
81919
82012
|
const name = options.name;
|
|
81920
82013
|
const port = options.port;
|
|
81921
|
-
|
|
82014
|
+
const runPath = path14.resolve(execPath);
|
|
82015
|
+
const escapePath = (p) => {
|
|
82016
|
+
let normalized = p.replace(/\\/g, "/");
|
|
82017
|
+
return normalized.includes(" ") ? `"${normalized}"` : normalized;
|
|
82018
|
+
};
|
|
82019
|
+
let interpreterPath = options.interpreter;
|
|
82020
|
+
if (options.interpreter === "bun") {
|
|
82021
|
+
interpreterPath = getBunPath();
|
|
82022
|
+
console.log(source_default.gray("Bun 路径:"), interpreterPath);
|
|
82023
|
+
}
|
|
82024
|
+
let pm2Command = `pm2 start ${escapePath(runPath)} --interpreter ${escapePath(interpreterPath)} --name ${name} -- -s`;
|
|
81922
82025
|
if (port) {
|
|
81923
82026
|
pm2Command += ` -p ${port}`;
|
|
81924
82027
|
}
|
|
81925
|
-
|
|
81926
|
-
|
|
81927
|
-
|
|
81928
|
-
|
|
81929
|
-
|
|
81930
|
-
|
|
81931
|
-
|
|
81932
|
-
|
|
81933
|
-
|
|
82028
|
+
console.log(source_default.gray("执行命令:"), pm2Command);
|
|
82029
|
+
console.log(source_default.gray("脚本路径:"), runPath);
|
|
82030
|
+
try {
|
|
82031
|
+
console.log(source_default.yellow("尝试删除旧进程..."));
|
|
82032
|
+
spawnSync4(`pm2 delete ${name}`, [], {
|
|
82033
|
+
shell: true,
|
|
82034
|
+
stdio: "pipe"
|
|
82035
|
+
});
|
|
82036
|
+
const result = spawnSync4(pm2Command, [], {
|
|
82037
|
+
stdio: "inherit",
|
|
82038
|
+
shell: true,
|
|
82039
|
+
windowsHide: false
|
|
82040
|
+
});
|
|
82041
|
+
if (result.error) {
|
|
82042
|
+
console.error(source_default.red("Error starting server:"), result.error.message);
|
|
82043
|
+
console.log(source_default.yellow(`
|
|
82044
|
+
提示: 请检查:`));
|
|
82045
|
+
console.log(" 1. pm2 是否已安装: npm install -g pm2");
|
|
82046
|
+
console.log(" 2. bun 是否已安装且在 PATH 中");
|
|
82047
|
+
console.log(" 3. 尝试手动执行:", pm2Command);
|
|
82048
|
+
process.exit(1);
|
|
82049
|
+
}
|
|
82050
|
+
if (result.status !== 0) {
|
|
82051
|
+
console.error(source_default.red(`PM2 exited with code ${result.status}`));
|
|
82052
|
+
console.log(source_default.yellow(`
|
|
82053
|
+
查看详细日志:`), `pm2 logs ${name}`);
|
|
82054
|
+
console.log(source_default.yellow("查看进程状态:"), "pm2 list");
|
|
82055
|
+
process.exit(result.status || 1);
|
|
82056
|
+
}
|
|
82057
|
+
console.log(source_default.green("✓ 以守护进程方式运行"));
|
|
82058
|
+
console.log(source_default.gray("查看日志:"), `pm2 logs ${name}`);
|
|
82059
|
+
} catch (error2) {
|
|
82060
|
+
console.error(source_default.red("Error starting server:"), error2.message);
|
|
81934
82061
|
process.exit(1);
|
|
81935
82062
|
}
|
|
81936
|
-
|
|
82063
|
+
process.exit(0);
|
|
81937
82064
|
} else if (options.start) {
|
|
81938
82065
|
console.log("启动服务", source_default.green(assistantConfig2.configDir));
|
|
81939
82066
|
const config3 = assistantConfig2.getCacheAssistantConfig();
|
|
81940
82067
|
const listenPort = options.port || config3?.server?.port;
|
|
81941
|
-
const listenPath = config3?.server?.path || "
|
|
82068
|
+
const listenPath = config3?.server?.path || "::";
|
|
81942
82069
|
const server = await runServer(listenPort, listenPath);
|
|
81943
82070
|
} else {
|
|
81944
82071
|
console.log("请使用 -s 参数启动服务");
|
package/dist/assistant.js
CHANGED
|
@@ -41648,7 +41648,7 @@ var import_websocket_server = __toESM(require_websocket_server(), 1);
|
|
|
41648
41648
|
var wss = new import_websocket_server.default({
|
|
41649
41649
|
noServer: true
|
|
41650
41650
|
});
|
|
41651
|
-
// ../node_modules/.pnpm/@kevisual+local-app-manager@0.1.
|
|
41651
|
+
// ../node_modules/.pnpm/@kevisual+local-app-manager@0.1.32_supports-color@10.2.2/node_modules/@kevisual/local-app-manager/dist/manager.mjs
|
|
41652
41652
|
var exports_manager = {};
|
|
41653
41653
|
__export(exports_manager, {
|
|
41654
41654
|
onAppShowInfo: () => onAppShowInfo,
|
|
@@ -41725,10 +41725,11 @@ var getConfigFile = (opts) => {
|
|
|
41725
41725
|
return "";
|
|
41726
41726
|
};
|
|
41727
41727
|
|
|
41728
|
-
// ../node_modules/.pnpm/@kevisual+local-app-manager@0.1.
|
|
41728
|
+
// ../node_modules/.pnpm/@kevisual+local-app-manager@0.1.32_supports-color@10.2.2/node_modules/@kevisual/local-app-manager/dist/manager.mjs
|
|
41729
41729
|
import path$1 from "node:path";
|
|
41730
41730
|
import fs$4 from "node:fs";
|
|
41731
41731
|
import { fork } from "node:child_process";
|
|
41732
|
+
import { fileURLToPath } from "node:url";
|
|
41732
41733
|
import require$$0 from "os";
|
|
41733
41734
|
import require$$0$1 from "path";
|
|
41734
41735
|
import require$$0$2 from "util";
|
|
@@ -41784,7 +41785,8 @@ var saveAppInfo = async (data, appsPath, filename = "apps.config.json") => {
|
|
|
41784
41785
|
fs$4.writeFileSync(configFile, JSON.stringify(data, null, 2));
|
|
41785
41786
|
};
|
|
41786
41787
|
var deleteFileAppInfo = async (key, appsPath) => {
|
|
41787
|
-
const
|
|
41788
|
+
const normalizedKey = key.replace(/\//g, path$1.sep);
|
|
41789
|
+
const directory = path$1.join(appsPath, normalizedKey);
|
|
41788
41790
|
if (!fileIsExist2(directory)) {
|
|
41789
41791
|
return;
|
|
41790
41792
|
}
|
|
@@ -48076,6 +48078,12 @@ function requireOut() {
|
|
|
48076
48078
|
}
|
|
48077
48079
|
var outExports = requireOut();
|
|
48078
48080
|
var glob = /* @__PURE__ */ getDefaultExportFromCjs(outExports);
|
|
48081
|
+
var normalizeScriptPath = (scriptPath) => {
|
|
48082
|
+
if (process.platform === "win32") {
|
|
48083
|
+
return scriptPath.replace(/\\/g, "/");
|
|
48084
|
+
}
|
|
48085
|
+
return scriptPath;
|
|
48086
|
+
};
|
|
48079
48087
|
var connect = async (noDaemonMode = false) => {
|
|
48080
48088
|
return new Promise((resolve, reject) => {
|
|
48081
48089
|
pm2.connect(noDaemonMode, (err) => {
|
|
@@ -48177,9 +48185,10 @@ class Pm2Manager {
|
|
|
48177
48185
|
console.error("script is required");
|
|
48178
48186
|
return;
|
|
48179
48187
|
}
|
|
48188
|
+
const normalizedScript = normalizeScriptPath(script);
|
|
48180
48189
|
const starter = {
|
|
48181
48190
|
name: appName,
|
|
48182
|
-
script,
|
|
48191
|
+
script: normalizedScript,
|
|
48183
48192
|
cwd: process.cwd(),
|
|
48184
48193
|
interpreter,
|
|
48185
48194
|
...options,
|
|
@@ -48336,7 +48345,8 @@ class Manager {
|
|
|
48336
48345
|
app.process = childProcess;
|
|
48337
48346
|
} else if (app.type === "system-app") {
|
|
48338
48347
|
const pathEntryAndTimestamp = path$1.join(app.path, entry2);
|
|
48339
|
-
const
|
|
48348
|
+
const importPath = process.platform === "win32" ? "file:///" + pathEntryAndTimestamp.replace(/\\/g, "/") : pathEntryAndTimestamp;
|
|
48349
|
+
const module = await import(importPath);
|
|
48340
48350
|
if (module.loadApp && mainApp) {
|
|
48341
48351
|
await module.loadApp?.(mainApp, app);
|
|
48342
48352
|
}
|
|
@@ -48613,7 +48623,8 @@ class Manager {
|
|
|
48613
48623
|
}
|
|
48614
48624
|
}
|
|
48615
48625
|
var installAppFromKey = async (key, _appPath) => {
|
|
48616
|
-
const
|
|
48626
|
+
const normalizedKey = key.replace(/\//g, path$1.sep);
|
|
48627
|
+
const directory = path$1.join(_appPath, normalizedKey);
|
|
48617
48628
|
if (!fileIsExist2(directory)) {
|
|
48618
48629
|
console.error("App not found", directory);
|
|
48619
48630
|
throw new Error("App not found");
|
|
@@ -48658,7 +48669,9 @@ var installAppFromKey = async (key, _appPath) => {
|
|
|
48658
48669
|
var getAppPathKeys = async (_appPath) => {
|
|
48659
48670
|
const directory = path$1.resolve(_appPath);
|
|
48660
48671
|
const root2 = directory;
|
|
48661
|
-
const
|
|
48672
|
+
const path1 = "*/package.json";
|
|
48673
|
+
const path22 = "*/*/package.json";
|
|
48674
|
+
const appsPackages = await glob([path1, path22], {
|
|
48662
48675
|
cwd: root2,
|
|
48663
48676
|
onlyFiles: true,
|
|
48664
48677
|
absolute: false,
|
|
@@ -48666,21 +48679,21 @@ var getAppPathKeys = async (_appPath) => {
|
|
|
48666
48679
|
});
|
|
48667
48680
|
const appPathKeys = appsPackages.map((pkg) => {
|
|
48668
48681
|
const dir = path$1.dirname(pkg);
|
|
48669
|
-
|
|
48670
|
-
return relativePath;
|
|
48682
|
+
return dir.replace(/\\/g, "/");
|
|
48671
48683
|
});
|
|
48672
48684
|
return appPathKeys;
|
|
48673
48685
|
};
|
|
48674
48686
|
var clearMicroApp = (link) => {
|
|
48675
48687
|
try {
|
|
48676
|
-
const
|
|
48688
|
+
const moduleUrl = new URL(link, import.meta.url);
|
|
48689
|
+
const modulePath = fileURLToPath(moduleUrl);
|
|
48677
48690
|
delete __require.cache[modulePath];
|
|
48678
48691
|
console.log(`Module ${link} has been unloaded.`);
|
|
48679
48692
|
} catch (error2) {
|
|
48680
48693
|
console.error(`Failed to unload module ${link}:`, error2);
|
|
48681
48694
|
}
|
|
48682
48695
|
};
|
|
48683
|
-
// ../node_modules/.pnpm/@kevisual+local-app-manager@0.1.
|
|
48696
|
+
// ../node_modules/.pnpm/@kevisual+local-app-manager@0.1.32_supports-color@10.2.2/node_modules/@kevisual/local-app-manager/dist/pm2.mjs
|
|
48684
48697
|
import pm22 from "pm2";
|
|
48685
48698
|
import { promisify as promisify2 } from "node:util";
|
|
48686
48699
|
var disconnect = promisify2(pm22.disconnect).bind(pm22);
|
|
@@ -48734,13 +48747,15 @@ class AssistantApp extends Manager {
|
|
|
48734
48747
|
}
|
|
48735
48748
|
async getPageAndAppList() {
|
|
48736
48749
|
const root2 = this.config.configPath.configDir;
|
|
48737
|
-
const
|
|
48750
|
+
const path1 = "apps/*/*/package.json";
|
|
48751
|
+
const path22 = "pages/*/*/package.json";
|
|
48752
|
+
const pages = await import_fast_glob.default([path1, path22], {
|
|
48738
48753
|
cwd: root2,
|
|
48739
48754
|
onlyFiles: true
|
|
48740
48755
|
});
|
|
48741
48756
|
const pagesParse = pages.map((page) => {
|
|
48742
|
-
const relativePath =
|
|
48743
|
-
const contentStr = fs6.readFileSync(path5.join(page), "utf-8");
|
|
48757
|
+
const relativePath = page;
|
|
48758
|
+
const contentStr = fs6.readFileSync(path5.join(root2, page), "utf-8");
|
|
48744
48759
|
const content = parseIfJson(contentStr);
|
|
48745
48760
|
if (!content.appType) {
|
|
48746
48761
|
const isWeb = relativePath.startsWith("pages/");
|
|
@@ -48984,8 +48999,8 @@ var assistantConfig2 = new AssistantConfig({
|
|
|
48984
48999
|
import fs7 from "fs";
|
|
48985
49000
|
var version = "0.0.1";
|
|
48986
49001
|
try {
|
|
48987
|
-
if ("0.0.
|
|
48988
|
-
version = "0.0.
|
|
49002
|
+
if ("0.0.6")
|
|
49003
|
+
version = "0.0.6";
|
|
48989
49004
|
} catch (e) {}
|
|
48990
49005
|
program.name("asst").description("A CLI tool with envison").version(version, "-v, --version", "output the current version");
|
|
48991
49006
|
var ls = new Command("ls").description("List files in the current directory").action(() => {
|
package/dist/envision.js
CHANGED
|
@@ -40643,8 +40643,8 @@ InitEnv.init();
|
|
|
40643
40643
|
var version = useContextKey("version", () => {
|
|
40644
40644
|
let version2 = "0.0.64";
|
|
40645
40645
|
try {
|
|
40646
|
-
if ("0.0.
|
|
40647
|
-
version2 = "0.0.
|
|
40646
|
+
if ("0.0.70")
|
|
40647
|
+
version2 = "0.0.70";
|
|
40648
40648
|
} catch (e) {}
|
|
40649
40649
|
return version2;
|
|
40650
40650
|
});
|
|
@@ -44137,7 +44137,7 @@ class BaseQuery {
|
|
|
44137
44137
|
}
|
|
44138
44138
|
}
|
|
44139
44139
|
|
|
44140
|
-
// node_modules/.pnpm/@kevisual+query-login@0.0.
|
|
44140
|
+
// node_modules/.pnpm/@kevisual+query-login@0.0.7_73acd6e183c2d11636e1682f8e793fc3/node_modules/@kevisual/query-login/dist/query-login-node.js
|
|
44141
44141
|
import { homedir } from "os";
|
|
44142
44142
|
import { join, dirname } from "path";
|
|
44143
44143
|
import fs3 from "fs";
|
|
@@ -47213,6 +47213,12 @@ var fileIsExist = (filePath) => {
|
|
|
47213
47213
|
return false;
|
|
47214
47214
|
}
|
|
47215
47215
|
};
|
|
47216
|
+
var normalizeScriptPath = (scriptPath) => {
|
|
47217
|
+
if (process.platform === "win32") {
|
|
47218
|
+
return scriptPath.replace(/\\/g, "/");
|
|
47219
|
+
}
|
|
47220
|
+
return scriptPath;
|
|
47221
|
+
};
|
|
47216
47222
|
|
|
47217
47223
|
// src/command/npm.ts
|
|
47218
47224
|
import fs8 from "fs";
|
|
@@ -48554,8 +48560,9 @@ class SyncBase {
|
|
|
48554
48560
|
const replaceKeys = Object.keys(replace);
|
|
48555
48561
|
let newKey = key;
|
|
48556
48562
|
for (let replaceKey of replaceKeys) {
|
|
48557
|
-
|
|
48558
|
-
|
|
48563
|
+
const _replaceKey = normalizeScriptPath(replaceKey);
|
|
48564
|
+
if (newKey.startsWith(_replaceKey)) {
|
|
48565
|
+
newKey = key.replace(_replaceKey, replace[replaceKey]);
|
|
48559
48566
|
}
|
|
48560
48567
|
}
|
|
48561
48568
|
const pathname = path10.join(_registryURL.pathname, newKey);
|
package/package.json
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@kevisual/cli",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "envision 命令行工具",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"basename": "/root/cli",
|
|
7
|
-
"app": {
|
|
8
|
-
"key": "cli",
|
|
9
|
-
"entry": "dist/app.mjs",
|
|
10
|
-
"type": "pm2-system-app",
|
|
11
|
-
"runtime": [
|
|
12
|
-
"cli"
|
|
13
|
-
]
|
|
14
|
-
},
|
|
15
|
-
"bin": {
|
|
16
|
-
"envision": "bin/envision.js",
|
|
17
|
-
"ev": "bin/envision.js",
|
|
18
|
-
"assistant": "bin/assistant.js",
|
|
19
|
-
"assistant-server": "bin/assistant-server.js",
|
|
20
|
-
"asst": "bin/assistant.js",
|
|
21
|
-
"asst-server": "bin/assistant-server.js"
|
|
22
|
-
},
|
|
23
|
-
"files": [
|
|
24
|
-
"dist",
|
|
25
|
-
"bin",
|
|
26
|
-
"bun.config.mjs"
|
|
27
|
-
],
|
|
28
|
-
"scripts": {
|
|
29
|
-
"dev": "bun src/run.ts ",
|
|
30
|
-
"dev:tsx": "tsx src/run.ts ",
|
|
31
|
-
"build": "rimraf dist && bun run bun.config.mjs",
|
|
32
|
-
"deploy": "ev pack -u -p -m no",
|
|
33
|
-
"pub:me": "npm publish --registry https://npm.xiongxiao.me --tag beta",
|
|
34
|
-
"postbuild": "cd assistant && pnpm build ",
|
|
35
|
-
"dts": "dts-bundle-generator --external-inlines=@types/jsonwebtoken src/index.ts -o dist/index.d.ts "
|
|
36
|
-
},
|
|
37
|
-
"keywords": [
|
|
38
|
-
"kevisual",
|
|
39
|
-
"cli"
|
|
40
|
-
],
|
|
41
|
-
"author": "abearxiong",
|
|
42
|
-
"dependencies": {
|
|
43
|
-
"@kevisual/context": "^0.0.4",
|
|
44
|
-
"micromatch": "^4.0.8",
|
|
45
|
-
"pm2": "^6.0.14",
|
|
46
|
-
"semver": "^7.7.3"
|
|
47
|
-
},
|
|
48
|
-
"devDependencies": {
|
|
49
|
-
"@kevisual/dts": "^0.0.3",
|
|
50
|
-
"@kevisual/load": "^0.0.6",
|
|
51
|
-
"@kevisual/logger": "^0.0.4",
|
|
52
|
-
"@kevisual/query": "0.0.29",
|
|
53
|
-
"@kevisual/query-login": "0.0.7",
|
|
54
|
-
"@types/bun": "^1.3.3",
|
|
55
|
-
"@types/crypto-js": "^4.2.2",
|
|
56
|
-
"@types/jsonwebtoken": "^9.0.10",
|
|
57
|
-
"@types/micromatch": "^4.0.10",
|
|
58
|
-
"@types/node": "^24.10.1",
|
|
59
|
-
"@types/semver": "^7.7.1",
|
|
60
|
-
"chalk": "^5.6.2",
|
|
61
|
-
"commander": "^14.0.2",
|
|
62
|
-
"crypto-js": "^4.2.0",
|
|
63
|
-
"fast-glob": "^3.3.3",
|
|
64
|
-
"filesize": "^11.0.13",
|
|
65
|
-
"form-data": "^4.0.5",
|
|
66
|
-
"ignore": "^7.0.5",
|
|
67
|
-
"inquirer": "^13.0.1",
|
|
68
|
-
"jsonwebtoken": "^9.0.2",
|
|
69
|
-
"tar": "^7.5.2",
|
|
70
|
-
"zustand": "^5.0.9"
|
|
71
|
-
},
|
|
72
|
-
"engines": {
|
|
73
|
-
"node": ">=22.0.0"
|
|
74
|
-
},
|
|
75
|
-
"publishConfig": {
|
|
76
|
-
"access": "public"
|
|
77
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@kevisual/cli",
|
|
3
|
+
"version": "0.0.70",
|
|
4
|
+
"description": "envision 命令行工具",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"basename": "/root/cli",
|
|
7
|
+
"app": {
|
|
8
|
+
"key": "cli",
|
|
9
|
+
"entry": "dist/app.mjs",
|
|
10
|
+
"type": "pm2-system-app",
|
|
11
|
+
"runtime": [
|
|
12
|
+
"cli"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"envision": "bin/envision.js",
|
|
17
|
+
"ev": "bin/envision.js",
|
|
18
|
+
"assistant": "bin/assistant.js",
|
|
19
|
+
"assistant-server": "bin/assistant-server.js",
|
|
20
|
+
"asst": "bin/assistant.js",
|
|
21
|
+
"asst-server": "bin/assistant-server.js"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"bin",
|
|
26
|
+
"bun.config.mjs"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"dev": "bun src/run.ts ",
|
|
30
|
+
"dev:tsx": "tsx src/run.ts ",
|
|
31
|
+
"build": "rimraf dist && bun run bun.config.mjs",
|
|
32
|
+
"deploy": "ev pack -u -p -m no",
|
|
33
|
+
"pub:me": "npm publish --registry https://npm.xiongxiao.me --tag beta",
|
|
34
|
+
"postbuild": "cd assistant && pnpm build ",
|
|
35
|
+
"dts": "dts-bundle-generator --external-inlines=@types/jsonwebtoken src/index.ts -o dist/index.d.ts "
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"kevisual",
|
|
39
|
+
"cli"
|
|
40
|
+
],
|
|
41
|
+
"author": "abearxiong",
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@kevisual/context": "^0.0.4",
|
|
44
|
+
"micromatch": "^4.0.8",
|
|
45
|
+
"pm2": "^6.0.14",
|
|
46
|
+
"semver": "^7.7.3"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@kevisual/dts": "^0.0.3",
|
|
50
|
+
"@kevisual/load": "^0.0.6",
|
|
51
|
+
"@kevisual/logger": "^0.0.4",
|
|
52
|
+
"@kevisual/query": "0.0.29",
|
|
53
|
+
"@kevisual/query-login": "0.0.7",
|
|
54
|
+
"@types/bun": "^1.3.3",
|
|
55
|
+
"@types/crypto-js": "^4.2.2",
|
|
56
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
57
|
+
"@types/micromatch": "^4.0.10",
|
|
58
|
+
"@types/node": "^24.10.1",
|
|
59
|
+
"@types/semver": "^7.7.1",
|
|
60
|
+
"chalk": "^5.6.2",
|
|
61
|
+
"commander": "^14.0.2",
|
|
62
|
+
"crypto-js": "^4.2.0",
|
|
63
|
+
"fast-glob": "^3.3.3",
|
|
64
|
+
"filesize": "^11.0.13",
|
|
65
|
+
"form-data": "^4.0.5",
|
|
66
|
+
"ignore": "^7.0.5",
|
|
67
|
+
"inquirer": "^13.0.1",
|
|
68
|
+
"jsonwebtoken": "^9.0.2",
|
|
69
|
+
"tar": "^7.5.2",
|
|
70
|
+
"zustand": "^5.0.9"
|
|
71
|
+
},
|
|
72
|
+
"engines": {
|
|
73
|
+
"node": ">=22.0.0"
|
|
74
|
+
},
|
|
75
|
+
"publishConfig": {
|
|
76
|
+
"access": "public"
|
|
77
|
+
}
|
|
78
78
|
}
|
package/readme.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# 可视化控制台工具
|
|
2
|
-
|
|
3
|
-
## 1. 上传文件
|
|
4
|
-
|
|
5
|
-
## 2. 下载文件
|
|
6
|
-
|
|
7
|
-
## 3. 同步模板
|
|
8
|
-
|
|
1
|
+
# 可视化控制台工具
|
|
2
|
+
|
|
3
|
+
## 1. 上传文件
|
|
4
|
+
|
|
5
|
+
## 2. 下载文件
|
|
6
|
+
|
|
7
|
+
## 3. 同步模板
|
|
8
|
+
|