diff --git a/assistant/bin/assistant-server.js b/assistant/bin/assistant-server.js old mode 100644 new mode 100755 index 5668f57..155a5ae --- a/assistant/bin/assistant-server.js +++ b/assistant/bin/assistant-server.js @@ -1,4 +1,4 @@ #!/usr/bin/env node -import { runParser } from '../dist/assistant-server.mjs'; +import { runParser } from '../dist/assistant-server.js'; runParser(process.argv); diff --git a/assistant/bin/assistant.js b/assistant/bin/assistant.js index 603e45f..5db68c2 100755 --- a/assistant/bin/assistant.js +++ b/assistant/bin/assistant.js @@ -1,4 +1,4 @@ #!/usr/bin/env node -import { runParser } from '../dist/assistant.mjs'; +import { runParser } from '../dist/assistant.js'; runParser(process.argv); diff --git a/assistant/bun.config.mjs b/assistant/bun.config.mjs index 6760c99..e8c7d0e 100644 --- a/assistant/bun.config.mjs +++ b/assistant/bun.config.mjs @@ -18,7 +18,7 @@ await Bun.build({ entrypoints: [w('./src/index.ts')], outdir: w('./dist'), naming: { - entry: 'assistant.mjs', + entry: 'assistant.js', }, external: ['pm2'], define: { @@ -33,7 +33,7 @@ await Bun.build({ entrypoints: [w('./src/server.ts')], outdir: w('./dist'), naming: { - entry: 'assistant-server.mjs', + entry: 'assistant-server.js', }, define: { ENVISION_VERSION: JSON.stringify(pkg.version), @@ -41,9 +41,10 @@ await Bun.build({ external: ['pm2'], env: 'ENVISION_*', }); - +// const copyDist = ['dist', 'bin']; +const copyDist = ['dist']; export const copyFileToEnvision = async () => { - const src = ['dist', 'bin'].map((dir) => { + const src = copyDist.map((dir) => { return { absolute: path.join(__dirname, dir), name: dir }; }); const dest = path.join(__dirname, '..'); diff --git a/assistant/package.json b/assistant/package.json index 77a2dff..b6537d8 100644 --- a/assistant/package.json +++ b/assistant/package.json @@ -1,6 +1,6 @@ { "name": "@kevisual/assistant-cli", - "version": "0.0.4", + "version": "0.0.5", "description": "", "main": "dist/assistant.mjs", "keywords": [ @@ -10,7 +10,7 @@ ], "author": "abearxiong (https://www.xiongxiao.me)", "license": "MIT", - "packageManager": "pnpm@10.9.0", + "packageManager": "pnpm@10.11.0", "type": "module", "files": [ "dist", @@ -43,15 +43,16 @@ "@kevisual/ai-center": "^0.0.3", "@kevisual/load": "^0.0.6", "@kevisual/local-app-manager": "^0.1.17", - "@kevisual/query": "0.0.17", + "@kevisual/logger": "^0.0.3", + "@kevisual/query": "0.0.18", "@kevisual/query-login": "0.0.5", - "@kevisual/router": "^0.0.13", - "@kevisual/task-command": "^0.0.2", - "@kevisual/types": "^0.0.7", - "@kevisual/use-config": "^1.0.11", - "@types/bun": "^1.2.10", + "@kevisual/router": "^0.0.20", + "@kevisual/task-command": "^0.0.7", + "@kevisual/types": "^0.0.10", + "@kevisual/use-config": "^1.0.17", + "@types/bun": "^1.2.13", "@types/lodash-es": "^4.17.12", - "@types/node": "^22.15.2", + "@types/node": "^22.15.18", "@types/send": "^0.17.4", "@types/ws": "^8.18.1", "chalk": "^5.4.1", @@ -60,7 +61,7 @@ "dayjs": "^1.11.13", "dotenv": "^16.5.0", "get-port": "^7.1.0", - "inquirer": "^12.6.0", + "inquirer": "^12.6.1", "lodash-es": "^4.17.21", "nanoid": "^5.1.5", "send": "^1.2.0", @@ -74,6 +75,6 @@ "access": "public" }, "dependencies": { - "pm2": "^6.0.5" + "pm2": "^6.0.6" } } \ No newline at end of file diff --git a/assistant/pnpm-lock.yaml b/assistant/pnpm-lock.yaml index 2d8f173..86238d3 100644 --- a/assistant/pnpm-lock.yaml +++ b/assistant/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: pm2: - specifier: ^6.0.5 - version: 6.0.5(supports-color@10.0.0) + specifier: ^6.0.6 + version: 6.0.6(supports-color@10.0.0) devDependencies: '@kevisual/ai-center': specifier: ^0.0.3 @@ -20,34 +20,37 @@ importers: version: 0.0.6 '@kevisual/local-app-manager': specifier: ^0.1.17 - version: 0.1.17(@kevisual/router@0.0.13)(@kevisual/types@0.0.7)(@kevisual/use-config@1.0.11(dotenv@16.5.0))(pm2@6.0.5(supports-color@10.0.0)) + version: 0.1.17(@kevisual/router@0.0.20)(@kevisual/types@0.0.10)(@kevisual/use-config@1.0.17(dotenv@16.5.0))(pm2@6.0.6(supports-color@10.0.0)) + '@kevisual/logger': + specifier: ^0.0.3 + version: 0.0.3 '@kevisual/query': - specifier: 0.0.17 - version: 0.0.17(@kevisual/ws@8.0.0) + specifier: 0.0.18 + version: 0.0.18(@kevisual/ws@8.0.0) '@kevisual/query-login': specifier: 0.0.5 - version: 0.0.5(@kevisual/query@0.0.17(@kevisual/ws@8.0.0))(rollup@4.40.0)(tslib@2.8.1)(typescript@5.8.3) + version: 0.0.5(@kevisual/query@0.0.18(@kevisual/ws@8.0.0))(rollup@4.40.0)(tslib@2.8.1)(typescript@5.8.3) '@kevisual/router': - specifier: ^0.0.13 - version: 0.0.13 + specifier: ^0.0.20 + version: 0.0.20 '@kevisual/task-command': - specifier: ^0.0.2 - version: 0.0.2 - '@kevisual/types': specifier: ^0.0.7 version: 0.0.7 + '@kevisual/types': + specifier: ^0.0.10 + version: 0.0.10 '@kevisual/use-config': - specifier: ^1.0.11 - version: 1.0.11(dotenv@16.5.0) + specifier: ^1.0.17 + version: 1.0.17(dotenv@16.5.0) '@types/bun': - specifier: ^1.2.10 - version: 1.2.10 + specifier: ^1.2.13 + version: 1.2.13 '@types/lodash-es': specifier: ^4.17.12 version: 4.17.12 '@types/node': - specifier: ^22.15.2 - version: 22.15.2 + specifier: ^22.15.18 + version: 22.15.18 '@types/send': specifier: ^0.17.4 version: 0.17.4 @@ -73,8 +76,8 @@ importers: specifier: ^7.1.0 version: 7.1.0 inquirer: - specifier: ^12.6.0 - version: 12.6.0(@types/node@22.15.2) + specifier: ^12.6.1 + version: 12.6.1(@types/node@22.15.18) lodash-es: specifier: ^4.17.21 version: 4.17.21 @@ -120,7 +123,7 @@ importers: version: 16.5.0 inquirer: specifier: ^12.6.0 - version: 12.6.0(@types/node@22.15.2) + version: 12.6.0(@types/node@22.15.18) lodash-es: specifier: ^4.17.21 version: 4.17.21 @@ -147,6 +150,24 @@ packages: '@types/node': optional: true + '@inquirer/checkbox@4.1.6': + resolution: {integrity: sha512-62u896rWCtKKE43soodq5e/QcRsA22I+7/4Ov7LESWnKRO6BVo2A1DFLDmXL9e28TB0CfHc3YtkbPm7iwajqkg==} + engines: {node: '>=18'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + + '@inquirer/confirm@5.1.10': + resolution: {integrity: sha512-FxbQ9giWxUWKUk2O5XZ6PduVnH2CZ/fmMKMBkH71MHJvWr7WL5AHKevhzF1L5uYWB2P548o1RzVxrNd3dpmk6g==} + engines: {node: '>=18'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + '@inquirer/confirm@5.1.9': resolution: {integrity: sha512-NgQCnHqFTjF7Ys2fsqK2WtnA8X1kHyInyG+nMIuHowVTIgIuS10T4AznI/PvbqSpJqjCUqNBlKGh1v3bwLFL4w==} engines: {node: '>=18'} @@ -165,6 +186,15 @@ packages: '@types/node': optional: true + '@inquirer/core@10.1.11': + resolution: {integrity: sha512-BXwI/MCqdtAhzNQlBEFE7CEflhPkl/BqvAuV/aK6lW3DClIfYVDWPP/kXuXHtBWC7/EEbNqd/1BGq2BGBBnuxw==} + engines: {node: '>=18'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + '@inquirer/editor@4.2.10': resolution: {integrity: sha512-5GVWJ+qeI6BzR6TIInLP9SXhWCEcvgFQYmcRG6d6RIlhFjM5TyG18paTGBgRYyEouvCmzeco47x9zX9tQEofkw==} engines: {node: '>=18'} @@ -174,6 +204,15 @@ packages: '@types/node': optional: true + '@inquirer/editor@4.2.11': + resolution: {integrity: sha512-YoZr0lBnnLFPpfPSNsQ8IZyKxU47zPyVi9NLjCWtna52//M/xuL0PGPAxHxxYhdOhnvY2oBafoM+BI5w/JK7jw==} + engines: {node: '>=18'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + '@inquirer/expand@4.0.12': resolution: {integrity: sha512-jV8QoZE1fC0vPe6TnsOfig+qwu7Iza1pkXoUJ3SroRagrt2hxiL+RbM432YAihNR7m7XnU0HWl/WQ35RIGmXHw==} engines: {node: '>=18'} @@ -183,10 +222,28 @@ packages: '@types/node': optional: true + '@inquirer/expand@4.0.13': + resolution: {integrity: sha512-HgYNWuZLHX6q5y4hqKhwyytqAghmx35xikOGY3TcgNiElqXGPas24+UzNPOwGUZa5Dn32y25xJqVeUcGlTv+QQ==} + engines: {node: '>=18'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + '@inquirer/figures@1.0.11': resolution: {integrity: sha512-eOg92lvrn/aRUqbxRyvpEWnrvRuTYRifixHkYVpJiygTgVSBIHDqLh0SrMQXkafvULg3ck11V7xvR+zcgvpHFw==} engines: {node: '>=18'} + '@inquirer/input@4.1.10': + resolution: {integrity: sha512-kV3BVne3wJ+j6reYQUZi/UN9NZGZLxgc/tfyjeK3mrx1QI7RXPxGp21IUTv+iVHcbP4ytZALF8vCHoxyNSC6qg==} + engines: {node: '>=18'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + '@inquirer/input@4.1.9': resolution: {integrity: sha512-mshNG24Ij5KqsQtOZMgj5TwEjIf+F2HOESk6bjMwGWgcH5UBe8UoljwzNFHqdMbGYbgAf6v2wU/X9CAdKJzgOA==} engines: {node: '>=18'} @@ -205,6 +262,15 @@ packages: '@types/node': optional: true + '@inquirer/number@3.0.13': + resolution: {integrity: sha512-IrLezcg/GWKS8zpKDvnJ/YTflNJdG0qSFlUM/zNFsdi4UKW/CO+gaJpbMgQ20Q58vNKDJbEzC6IebdkprwL6ew==} + engines: {node: '>=18'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + '@inquirer/password@4.0.12': resolution: {integrity: sha512-FlOB0zvuELPEbnBYiPaOdJIaDzb2PmJ7ghi/SVwIHDDSQ2K4opGBkF+5kXOg6ucrtSUQdLhVVY5tycH0j0l+0g==} engines: {node: '>=18'} @@ -214,6 +280,15 @@ packages: '@types/node': optional: true + '@inquirer/password@4.0.13': + resolution: {integrity: sha512-NN0S/SmdhakqOTJhDwOpeBEEr8VdcYsjmZHDb0rblSh2FcbXQOr+2IApP7JG4WE3sxIdKytDn4ed3XYwtHxmJQ==} + engines: {node: '>=18'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + '@inquirer/prompts@7.5.0': resolution: {integrity: sha512-tk8Bx7l5AX/CR0sVfGj3Xg6v7cYlFBkEahH+EgBB+cZib6Fc83dwerTbzj7f2+qKckjIUGsviWRI1d7lx6nqQA==} engines: {node: '>=18'} @@ -223,6 +298,15 @@ packages: '@types/node': optional: true + '@inquirer/prompts@7.5.1': + resolution: {integrity: sha512-5AOrZPf2/GxZ+SDRZ5WFplCA2TAQgK3OYrXCYmJL5NaTu4ECcoWFlfUZuw7Es++6Njv7iu/8vpYJhuzxUH76Vg==} + engines: {node: '>=18'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + '@inquirer/rawlist@4.1.0': resolution: {integrity: sha512-6ob45Oh9pXmfprKqUiEeMz/tjtVTFQTgDDz1xAMKMrIvyrYjAmRbQZjMJfsictlL4phgjLhdLu27IkHNnNjB7g==} engines: {node: '>=18'} @@ -232,6 +316,15 @@ packages: '@types/node': optional: true + '@inquirer/rawlist@4.1.1': + resolution: {integrity: sha512-VBUC0jPN2oaOq8+krwpo/mf3n/UryDUkKog3zi+oIi8/e5hykvdntgHUB9nhDM78RubiyR1ldIOfm5ue+2DeaQ==} + engines: {node: '>=18'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + '@inquirer/search@3.0.12': resolution: {integrity: sha512-H/kDJA3kNlnNIjB8YsaXoQI0Qccgf0Na14K1h8ExWhNmUg2E941dyFPrZeugihEa9AZNW5NdsD/NcvUME83OPQ==} engines: {node: '>=18'} @@ -241,6 +334,15 @@ packages: '@types/node': optional: true + '@inquirer/search@3.0.13': + resolution: {integrity: sha512-9g89d2c5Izok/Gw/U7KPC3f9kfe5rA1AJ24xxNZG0st+vWekSk7tB9oE+dJv5JXd0ZSijomvW0KPMoBd8qbN4g==} + engines: {node: '>=18'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + '@inquirer/select@4.2.0': resolution: {integrity: sha512-KkXQ4aSySWimpV4V/TUJWdB3tdfENZUU765GjOIZ0uPwdbGIG6jrxD4dDf1w68uP+DVtfNhr1A92B+0mbTZ8FA==} engines: {node: '>=18'} @@ -250,6 +352,15 @@ packages: '@types/node': optional: true + '@inquirer/select@4.2.1': + resolution: {integrity: sha512-gt1Kd5XZm+/ddemcT3m23IP8aD8rC9drRckWoP/1f7OL46Yy2FGi8DSmNjEjQKtPl6SV96Kmjbl6p713KXJ/Jg==} + engines: {node: '>=18'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + '@inquirer/type@3.0.6': resolution: {integrity: sha512-/mKVCtVpyBu3IDarv0G+59KC4stsD5mDsGpYh+GKs1NZT88Jh52+cuoA1AtLk2Q0r/quNl+1cSUyLRHBFeD0XA==} engines: {node: '>=18'} @@ -279,28 +390,28 @@ packages: '@kevisual/use-config': ^1.0.11 pm2: ^5.4.3 + '@kevisual/logger@0.0.3': + resolution: {integrity: sha512-8emqxg+ab62WAK6VY4FQqetXPSSVKFAjGctD1NDbdnxt7YWuI/PyuDltCpsVz+uvWpV1dO5OKZOoHU7ow59Omw==} + '@kevisual/query-login@0.0.5': resolution: {integrity: sha512-389cMMWAisjQoafxX+cUEa2z41S5koDjiyHkucfCkhRoP4M6g0iqbBMavLKmLOWSKx3R8e3ZmXT6RfsYGBb8Ww==} peerDependencies: '@kevisual/query': ^0.0.17 - '@kevisual/query@0.0.17': - resolution: {integrity: sha512-WMvWM+3pNlPKNhoxPX9fldMp1tOeJrkRM/tXA4bvOnftIoX2yeI4v0wTpbGJXES/bLlo7OC2kV8SeKF0K6dnxQ==} + '@kevisual/query@0.0.18': + resolution: {integrity: sha512-I2vHTu0I6AyD9PJyr+vxyp9jIJ6rd2EZqLVHTv/+zrVKVc2SS76Tg7aGNkmAFqqLSCB8kLLsmMGtSJU1Qb8VVg==} - '@kevisual/router@0.0.13': - resolution: {integrity: sha512-raji8aKXr0jigmJVOKBXb5gpstiAuyoIDy9m6SyPf4lRjCU3pspVI1bpscOUCBlaPICo6TLzPQxXhyTvvvtdWw==} - - '@kevisual/task-command@0.0.2': - resolution: {integrity: sha512-GVGcm2edTdIkiRaO8PoR8MhkHEyqq2xG3knMI6Ba+0YknzRECAzR0tgkHLGRPyIClG0J6gDzo2qaglf2s3ci5w==} + '@kevisual/router@0.0.20': + resolution: {integrity: sha512-uSwDYWh+kvAu6i0m0SJVgcLR/CYz7WvIWGz0nSF8Vg6smJuAgI+laHR4ESO8Fbz+Xn8bPHuSwmM//HHLMLx2FA==} '@kevisual/task-command@0.0.7': resolution: {integrity: sha512-2vkKJVgjCQEeewKeCU7+U5K4mU6by2rWTDEsUrCbZ6K0fgg4QpfvrtXK1YGVNbywKIXuT95ol7QQS+gMN7hgcA==} - '@kevisual/types@0.0.7': - resolution: {integrity: sha512-qU/vg7WilTmxbWQZ4PbYNaTDQO83KaCqoT10FbGg8FCwGG2luuEKTvCYcXfvpl7qA+AHGKcSm0JJc61s4oLCww==} + '@kevisual/types@0.0.10': + resolution: {integrity: sha512-Q73uzzjk9UidumnmCvOpgzqDDvQxsblz22bIFuoiioUFJWwaparx8bpd8ArRyFojicYL1YJoFDzDZ9j9NN8grA==} - '@kevisual/use-config@1.0.11': - resolution: {integrity: sha512-ccilQTRZTpO075L67ZBXhr8Lp3i73/W5cCMT5enMjVrnJT5K0i5JH5IbzBhF6WY5Rj8dmVsAyyjJe24ClyM7Eg==} + '@kevisual/use-config@1.0.17': + resolution: {integrity: sha512-EsuMJ5bhAbdERvpD55td1diRxx4kSxtYVaIHo0vDvnLetuXLfq+j2DPGmWl/oRdO48op0dme5oo1DctCqpgYcQ==} peerDependencies: dotenv: ^16.4.7 @@ -465,8 +576,8 @@ packages: '@tootallnate/quickjs-emscripten@0.23.0': resolution: {integrity: sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==} - '@types/bun@1.2.10': - resolution: {integrity: sha512-eilv6WFM3M0c9ztJt7/g80BDusK98z/FrFwseZgT4bXCq2vPhXD4z8R3oddmAn+R/Nmz9vBn4kweJKmGTZj+lg==} + '@types/bun@1.2.13': + resolution: {integrity: sha512-u6vXep/i9VBxoJl3GjZsl/BFIsvML8DfVDO0RYLEwtSZSp981kEO1V5NwRcO1CPJ7AmvpbnDCiMKo3JvbDEjAg==} '@types/estree@1.0.7': resolution: {integrity: sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==} @@ -489,8 +600,8 @@ packages: '@types/node@18.19.87': resolution: {integrity: sha512-OIAAu6ypnVZHmsHCeJ+7CCSub38QNBS9uceMQeg7K5Ur0Jr+wG9wEOEvvMbhp09pxD5czIUy/jND7s7Tb6Nw7A==} - '@types/node@22.15.2': - resolution: {integrity: sha512-uKXqKN9beGoMdBfcaTY1ecwz6ctxuJAcUlwE55938g0ZJ8lRxwAZqRz2AJ4pzpt5dHdTPMB863UZ0ESiFUcP7A==} + '@types/node@22.15.18': + resolution: {integrity: sha512-v1DKRfUdyW+jJhZNEI1PYy29S2YRxMV5AOO/x/SjKmW0acCIOqmbj6Haf9eHAhsPmrhlHSxEhv/1WszcLWV4cg==} '@types/resolve@1.20.2': resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} @@ -535,6 +646,10 @@ packages: resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} engines: {node: '>=8'} + ansis@4.0.0: + resolution: {integrity: sha512-P8nrHI1EyW9OfBt1X7hMSwGN2vwRuqHSKJAT1gbLWZRzDa24oHjYwGHvEgHeBepupzk878yS/HBZ0NMPYtbolw==} + engines: {node: '>=14'} + anymatch@3.1.3: resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==} engines: {node: '>= 8'} @@ -578,8 +693,8 @@ packages: buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} - bun-types@1.2.10: - resolution: {integrity: sha512-b5ITZMnVdf3m1gMvJHG+gIfeJHiQPJak0f7925Hxu6ZN5VKA8AGy4GZ4lM+Xkn6jtWxg5S3ldWvfmXdvnkp3GQ==} + bun-types@1.2.13: + resolution: {integrity: sha512-rRjA1T6n7wto4gxhAO/ErZEtOXyEZEmnIHQfl0Dt1QQSB4QV0iP6BZ9/YB5fZaHFQ2dwHFrmPaRQ9GGMX01k9Q==} call-bind-apply-helpers@1.0.2: resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==} @@ -927,6 +1042,15 @@ packages: '@types/node': optional: true + inquirer@12.6.1: + resolution: {integrity: sha512-MGFnzHVS3l3oM3cy+LWkyR7UUtVEn3D5U41CZbEY34szToWoJAvaVtCTz1mxsEzZFk/HXWyCArn0HDgloTXMDw==} + engines: {node: '>=18'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + ip-address@9.0.5: resolution: {integrity: sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==} engines: {node: '>= 12'} @@ -1074,8 +1198,8 @@ packages: resolution: {integrity: sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==} engines: {node: '>= 0.8'} - openai@4.96.0: - resolution: {integrity: sha512-dKoW56i02Prv2XQolJ9Rl9Svqubqkzg3QpwEOBuSVZLk05Shelu7s+ErRTwFc1Bs3JZ2qBqBfVpXQiJhwOGG8A==} + openai@4.99.0: + resolution: {integrity: sha512-E2bd6ghsKF6iV6B4vuhREtdpeB/8dNUnWcPIt5VmnM019/mXxOdqisnIcn4e1zWt1H8BpeMY2HwKJ3UIin6baA==} hasBin: true peerDependencies: ws: ^8.18.0 @@ -1154,6 +1278,11 @@ packages: engines: {node: '>=16.0.0'} hasBin: true + pm2@6.0.6: + resolution: {integrity: sha512-6t+I+Gc232dKe0OjwFYlU59JoY8MWBqsBmcZMSfKollByL4q8APUFwWOt7OtPH4lGO4Sb6GiFAqu7xT42QeRBA==} + engines: {node: '>=16.0.0'} + hasBin: true + promptly@2.2.0: resolution: {integrity: sha512-aC9j+BZsRSSzEsXBNBwDnAxujdx19HycZoKgRgzWnS8eOHg1asuf9heuLprfbe739zY3IdUQx+Egv6Jn135WHA==} @@ -1407,27 +1536,44 @@ snapshots: '@babel/helper-validator-identifier@7.25.9': optional: true - '@inquirer/checkbox@4.1.5(@types/node@22.15.2)': + '@inquirer/checkbox@4.1.5(@types/node@22.15.18)': dependencies: - '@inquirer/core': 10.1.10(@types/node@22.15.2) + '@inquirer/core': 10.1.10(@types/node@22.15.18) '@inquirer/figures': 1.0.11 - '@inquirer/type': 3.0.6(@types/node@22.15.2) + '@inquirer/type': 3.0.6(@types/node@22.15.18) ansi-escapes: 4.3.2 yoctocolors-cjs: 2.1.2 optionalDependencies: - '@types/node': 22.15.2 + '@types/node': 22.15.18 - '@inquirer/confirm@5.1.9(@types/node@22.15.2)': + '@inquirer/checkbox@4.1.6(@types/node@22.15.18)': dependencies: - '@inquirer/core': 10.1.10(@types/node@22.15.2) - '@inquirer/type': 3.0.6(@types/node@22.15.2) + '@inquirer/core': 10.1.11(@types/node@22.15.18) + '@inquirer/figures': 1.0.11 + '@inquirer/type': 3.0.6(@types/node@22.15.18) + ansi-escapes: 4.3.2 + yoctocolors-cjs: 2.1.2 optionalDependencies: - '@types/node': 22.15.2 + '@types/node': 22.15.18 - '@inquirer/core@10.1.10(@types/node@22.15.2)': + '@inquirer/confirm@5.1.10(@types/node@22.15.18)': + dependencies: + '@inquirer/core': 10.1.11(@types/node@22.15.18) + '@inquirer/type': 3.0.6(@types/node@22.15.18) + optionalDependencies: + '@types/node': 22.15.18 + + '@inquirer/confirm@5.1.9(@types/node@22.15.18)': + dependencies: + '@inquirer/core': 10.1.10(@types/node@22.15.18) + '@inquirer/type': 3.0.6(@types/node@22.15.18) + optionalDependencies: + '@types/node': 22.15.18 + + '@inquirer/core@10.1.10(@types/node@22.15.18)': dependencies: '@inquirer/figures': 1.0.11 - '@inquirer/type': 3.0.6(@types/node@22.15.2) + '@inquirer/type': 3.0.6(@types/node@22.15.18) ansi-escapes: 4.3.2 cli-width: 4.1.0 mute-stream: 2.0.0 @@ -1435,93 +1581,186 @@ snapshots: wrap-ansi: 6.2.0 yoctocolors-cjs: 2.1.2 optionalDependencies: - '@types/node': 22.15.2 + '@types/node': 22.15.18 - '@inquirer/editor@4.2.10(@types/node@22.15.2)': + '@inquirer/core@10.1.11(@types/node@22.15.18)': dependencies: - '@inquirer/core': 10.1.10(@types/node@22.15.2) - '@inquirer/type': 3.0.6(@types/node@22.15.2) - external-editor: 3.1.0 - optionalDependencies: - '@types/node': 22.15.2 - - '@inquirer/expand@4.0.12(@types/node@22.15.2)': - dependencies: - '@inquirer/core': 10.1.10(@types/node@22.15.2) - '@inquirer/type': 3.0.6(@types/node@22.15.2) + '@inquirer/figures': 1.0.11 + '@inquirer/type': 3.0.6(@types/node@22.15.18) + ansi-escapes: 4.3.2 + cli-width: 4.1.0 + mute-stream: 2.0.0 + signal-exit: 4.1.0 + wrap-ansi: 6.2.0 yoctocolors-cjs: 2.1.2 optionalDependencies: - '@types/node': 22.15.2 + '@types/node': 22.15.18 + + '@inquirer/editor@4.2.10(@types/node@22.15.18)': + dependencies: + '@inquirer/core': 10.1.10(@types/node@22.15.18) + '@inquirer/type': 3.0.6(@types/node@22.15.18) + external-editor: 3.1.0 + optionalDependencies: + '@types/node': 22.15.18 + + '@inquirer/editor@4.2.11(@types/node@22.15.18)': + dependencies: + '@inquirer/core': 10.1.11(@types/node@22.15.18) + '@inquirer/type': 3.0.6(@types/node@22.15.18) + external-editor: 3.1.0 + optionalDependencies: + '@types/node': 22.15.18 + + '@inquirer/expand@4.0.12(@types/node@22.15.18)': + dependencies: + '@inquirer/core': 10.1.10(@types/node@22.15.18) + '@inquirer/type': 3.0.6(@types/node@22.15.18) + yoctocolors-cjs: 2.1.2 + optionalDependencies: + '@types/node': 22.15.18 + + '@inquirer/expand@4.0.13(@types/node@22.15.18)': + dependencies: + '@inquirer/core': 10.1.11(@types/node@22.15.18) + '@inquirer/type': 3.0.6(@types/node@22.15.18) + yoctocolors-cjs: 2.1.2 + optionalDependencies: + '@types/node': 22.15.18 '@inquirer/figures@1.0.11': {} - '@inquirer/input@4.1.9(@types/node@22.15.2)': + '@inquirer/input@4.1.10(@types/node@22.15.18)': dependencies: - '@inquirer/core': 10.1.10(@types/node@22.15.2) - '@inquirer/type': 3.0.6(@types/node@22.15.2) + '@inquirer/core': 10.1.11(@types/node@22.15.18) + '@inquirer/type': 3.0.6(@types/node@22.15.18) optionalDependencies: - '@types/node': 22.15.2 + '@types/node': 22.15.18 - '@inquirer/number@3.0.12(@types/node@22.15.2)': + '@inquirer/input@4.1.9(@types/node@22.15.18)': dependencies: - '@inquirer/core': 10.1.10(@types/node@22.15.2) - '@inquirer/type': 3.0.6(@types/node@22.15.2) + '@inquirer/core': 10.1.10(@types/node@22.15.18) + '@inquirer/type': 3.0.6(@types/node@22.15.18) optionalDependencies: - '@types/node': 22.15.2 + '@types/node': 22.15.18 - '@inquirer/password@4.0.12(@types/node@22.15.2)': + '@inquirer/number@3.0.12(@types/node@22.15.18)': dependencies: - '@inquirer/core': 10.1.10(@types/node@22.15.2) - '@inquirer/type': 3.0.6(@types/node@22.15.2) + '@inquirer/core': 10.1.10(@types/node@22.15.18) + '@inquirer/type': 3.0.6(@types/node@22.15.18) + optionalDependencies: + '@types/node': 22.15.18 + + '@inquirer/number@3.0.13(@types/node@22.15.18)': + dependencies: + '@inquirer/core': 10.1.11(@types/node@22.15.18) + '@inquirer/type': 3.0.6(@types/node@22.15.18) + optionalDependencies: + '@types/node': 22.15.18 + + '@inquirer/password@4.0.12(@types/node@22.15.18)': + dependencies: + '@inquirer/core': 10.1.10(@types/node@22.15.18) + '@inquirer/type': 3.0.6(@types/node@22.15.18) ansi-escapes: 4.3.2 optionalDependencies: - '@types/node': 22.15.2 + '@types/node': 22.15.18 - '@inquirer/prompts@7.5.0(@types/node@22.15.2)': + '@inquirer/password@4.0.13(@types/node@22.15.18)': dependencies: - '@inquirer/checkbox': 4.1.5(@types/node@22.15.2) - '@inquirer/confirm': 5.1.9(@types/node@22.15.2) - '@inquirer/editor': 4.2.10(@types/node@22.15.2) - '@inquirer/expand': 4.0.12(@types/node@22.15.2) - '@inquirer/input': 4.1.9(@types/node@22.15.2) - '@inquirer/number': 3.0.12(@types/node@22.15.2) - '@inquirer/password': 4.0.12(@types/node@22.15.2) - '@inquirer/rawlist': 4.1.0(@types/node@22.15.2) - '@inquirer/search': 3.0.12(@types/node@22.15.2) - '@inquirer/select': 4.2.0(@types/node@22.15.2) + '@inquirer/core': 10.1.11(@types/node@22.15.18) + '@inquirer/type': 3.0.6(@types/node@22.15.18) + ansi-escapes: 4.3.2 optionalDependencies: - '@types/node': 22.15.2 + '@types/node': 22.15.18 - '@inquirer/rawlist@4.1.0(@types/node@22.15.2)': + '@inquirer/prompts@7.5.0(@types/node@22.15.18)': dependencies: - '@inquirer/core': 10.1.10(@types/node@22.15.2) - '@inquirer/type': 3.0.6(@types/node@22.15.2) + '@inquirer/checkbox': 4.1.5(@types/node@22.15.18) + '@inquirer/confirm': 5.1.9(@types/node@22.15.18) + '@inquirer/editor': 4.2.10(@types/node@22.15.18) + '@inquirer/expand': 4.0.12(@types/node@22.15.18) + '@inquirer/input': 4.1.9(@types/node@22.15.18) + '@inquirer/number': 3.0.12(@types/node@22.15.18) + '@inquirer/password': 4.0.12(@types/node@22.15.18) + '@inquirer/rawlist': 4.1.0(@types/node@22.15.18) + '@inquirer/search': 3.0.12(@types/node@22.15.18) + '@inquirer/select': 4.2.0(@types/node@22.15.18) + optionalDependencies: + '@types/node': 22.15.18 + + '@inquirer/prompts@7.5.1(@types/node@22.15.18)': + dependencies: + '@inquirer/checkbox': 4.1.6(@types/node@22.15.18) + '@inquirer/confirm': 5.1.10(@types/node@22.15.18) + '@inquirer/editor': 4.2.11(@types/node@22.15.18) + '@inquirer/expand': 4.0.13(@types/node@22.15.18) + '@inquirer/input': 4.1.10(@types/node@22.15.18) + '@inquirer/number': 3.0.13(@types/node@22.15.18) + '@inquirer/password': 4.0.13(@types/node@22.15.18) + '@inquirer/rawlist': 4.1.1(@types/node@22.15.18) + '@inquirer/search': 3.0.13(@types/node@22.15.18) + '@inquirer/select': 4.2.1(@types/node@22.15.18) + optionalDependencies: + '@types/node': 22.15.18 + + '@inquirer/rawlist@4.1.0(@types/node@22.15.18)': + dependencies: + '@inquirer/core': 10.1.10(@types/node@22.15.18) + '@inquirer/type': 3.0.6(@types/node@22.15.18) yoctocolors-cjs: 2.1.2 optionalDependencies: - '@types/node': 22.15.2 + '@types/node': 22.15.18 - '@inquirer/search@3.0.12(@types/node@22.15.2)': + '@inquirer/rawlist@4.1.1(@types/node@22.15.18)': dependencies: - '@inquirer/core': 10.1.10(@types/node@22.15.2) - '@inquirer/figures': 1.0.11 - '@inquirer/type': 3.0.6(@types/node@22.15.2) + '@inquirer/core': 10.1.11(@types/node@22.15.18) + '@inquirer/type': 3.0.6(@types/node@22.15.18) yoctocolors-cjs: 2.1.2 optionalDependencies: - '@types/node': 22.15.2 + '@types/node': 22.15.18 - '@inquirer/select@4.2.0(@types/node@22.15.2)': + '@inquirer/search@3.0.12(@types/node@22.15.18)': dependencies: - '@inquirer/core': 10.1.10(@types/node@22.15.2) + '@inquirer/core': 10.1.10(@types/node@22.15.18) '@inquirer/figures': 1.0.11 - '@inquirer/type': 3.0.6(@types/node@22.15.2) + '@inquirer/type': 3.0.6(@types/node@22.15.18) + yoctocolors-cjs: 2.1.2 + optionalDependencies: + '@types/node': 22.15.18 + + '@inquirer/search@3.0.13(@types/node@22.15.18)': + dependencies: + '@inquirer/core': 10.1.11(@types/node@22.15.18) + '@inquirer/figures': 1.0.11 + '@inquirer/type': 3.0.6(@types/node@22.15.18) + yoctocolors-cjs: 2.1.2 + optionalDependencies: + '@types/node': 22.15.18 + + '@inquirer/select@4.2.0(@types/node@22.15.18)': + dependencies: + '@inquirer/core': 10.1.10(@types/node@22.15.18) + '@inquirer/figures': 1.0.11 + '@inquirer/type': 3.0.6(@types/node@22.15.18) ansi-escapes: 4.3.2 yoctocolors-cjs: 2.1.2 optionalDependencies: - '@types/node': 22.15.2 + '@types/node': 22.15.18 - '@inquirer/type@3.0.6(@types/node@22.15.2)': + '@inquirer/select@4.2.1(@types/node@22.15.18)': + dependencies: + '@inquirer/core': 10.1.11(@types/node@22.15.18) + '@inquirer/figures': 1.0.11 + '@inquirer/type': 3.0.6(@types/node@22.15.18) + ansi-escapes: 4.3.2 + yoctocolors-cjs: 2.1.2 optionalDependencies: - '@types/node': 22.15.2 + '@types/node': 22.15.18 + + '@inquirer/type@3.0.6(@types/node@22.15.18)': + optionalDependencies: + '@types/node': 22.15.18 '@jridgewell/sourcemap-codec@1.5.0': {} @@ -1543,43 +1782,43 @@ snapshots: dependencies: eventemitter3: 5.0.1 - '@kevisual/local-app-manager@0.1.17(@kevisual/router@0.0.13)(@kevisual/types@0.0.7)(@kevisual/use-config@1.0.11(dotenv@16.5.0))(pm2@6.0.5(supports-color@10.0.0))': + '@kevisual/local-app-manager@0.1.17(@kevisual/router@0.0.20)(@kevisual/types@0.0.10)(@kevisual/use-config@1.0.17(dotenv@16.5.0))(pm2@6.0.6(supports-color@10.0.0))': dependencies: - '@kevisual/router': 0.0.13 - '@kevisual/types': 0.0.7 - '@kevisual/use-config': 1.0.11(dotenv@16.5.0) - pm2: 6.0.5(supports-color@10.0.0) + '@kevisual/router': 0.0.20 + '@kevisual/types': 0.0.10 + '@kevisual/use-config': 1.0.17(dotenv@16.5.0) + pm2: 6.0.6(supports-color@10.0.0) - '@kevisual/query-login@0.0.5(@kevisual/query@0.0.17(@kevisual/ws@8.0.0))(rollup@4.40.0)(tslib@2.8.1)(typescript@5.8.3)': + '@kevisual/logger@0.0.3': {} + + '@kevisual/query-login@0.0.5(@kevisual/query@0.0.18(@kevisual/ws@8.0.0))(rollup@4.40.0)(tslib@2.8.1)(typescript@5.8.3)': dependencies: '@kevisual/cache': 0.0.2(rollup@4.40.0)(tslib@2.8.1)(typescript@5.8.3) - '@kevisual/query': 0.0.17(@kevisual/ws@8.0.0) + '@kevisual/query': 0.0.18(@kevisual/ws@8.0.0) dotenv: 16.5.0 transitivePeerDependencies: - rollup - tslib - typescript - '@kevisual/query@0.0.17(@kevisual/ws@8.0.0)': + '@kevisual/query@0.0.18(@kevisual/ws@8.0.0)': dependencies: - openai: 4.96.0(@kevisual/ws@8.0.0) + openai: 4.99.0(@kevisual/ws@8.0.0) transitivePeerDependencies: - encoding - ws - zod - '@kevisual/router@0.0.13': + '@kevisual/router@0.0.20': dependencies: path-to-regexp: 8.2.0 selfsigned: 2.4.1 - '@kevisual/task-command@0.0.2': {} - '@kevisual/task-command@0.0.7': {} - '@kevisual/types@0.0.7': {} + '@kevisual/types@0.0.10': {} - '@kevisual/use-config@1.0.11(dotenv@16.5.0)': + '@kevisual/use-config@1.0.17(dotenv@16.5.0)': dependencies: '@kevisual/load': 0.0.6 dotenv: 16.5.0 @@ -1737,9 +1976,9 @@ snapshots: '@tootallnate/quickjs-emscripten@0.23.0': {} - '@types/bun@1.2.10': + '@types/bun@1.2.13': dependencies: - bun-types: 1.2.10 + bun-types: 1.2.13 '@types/estree@1.0.7': {} @@ -1753,18 +1992,18 @@ snapshots: '@types/node-fetch@2.6.12': dependencies: - '@types/node': 22.15.2 + '@types/node': 22.15.18 form-data: 4.0.2 '@types/node-forge@1.3.11': dependencies: - '@types/node': 22.15.2 + '@types/node': 22.15.18 '@types/node@18.19.87': dependencies: undici-types: 5.26.5 - '@types/node@22.15.2': + '@types/node@22.15.18': dependencies: undici-types: 6.21.0 @@ -1773,11 +2012,11 @@ snapshots: '@types/send@0.17.4': dependencies: '@types/mime': 1.3.5 - '@types/node': 22.15.2 + '@types/node': 22.15.18 '@types/ws@8.18.1': dependencies: - '@types/node': 22.15.2 + '@types/node': 22.15.18 abort-controller@3.0.0: dependencies: @@ -1807,6 +2046,8 @@ snapshots: dependencies: color-convert: 2.0.1 + ansis@4.0.0: {} + anymatch@3.1.3: dependencies: normalize-path: 3.0.0 @@ -1840,9 +2081,9 @@ snapshots: buffer-from@1.1.2: {} - bun-types@1.2.10: + bun-types@1.2.13: dependencies: - '@types/node': 22.15.2 + '@types/node': 22.15.18 call-bind-apply-helpers@1.0.2: dependencies: @@ -2144,17 +2385,29 @@ snapshots: ini@1.3.8: {} - inquirer@12.6.0(@types/node@22.15.2): + inquirer@12.6.0(@types/node@22.15.18): dependencies: - '@inquirer/core': 10.1.10(@types/node@22.15.2) - '@inquirer/prompts': 7.5.0(@types/node@22.15.2) - '@inquirer/type': 3.0.6(@types/node@22.15.2) + '@inquirer/core': 10.1.10(@types/node@22.15.18) + '@inquirer/prompts': 7.5.0(@types/node@22.15.18) + '@inquirer/type': 3.0.6(@types/node@22.15.18) ansi-escapes: 4.3.2 mute-stream: 2.0.0 run-async: 3.0.0 rxjs: 7.8.2 optionalDependencies: - '@types/node': 22.15.2 + '@types/node': 22.15.18 + + inquirer@12.6.1(@types/node@22.15.18): + dependencies: + '@inquirer/core': 10.1.11(@types/node@22.15.18) + '@inquirer/prompts': 7.5.1(@types/node@22.15.18) + '@inquirer/type': 3.0.6(@types/node@22.15.18) + ansi-escapes: 4.3.2 + mute-stream: 2.0.0 + run-async: 3.0.0 + rxjs: 7.8.2 + optionalDependencies: + '@types/node': 22.15.18 ip-address@9.0.5: dependencies: @@ -2270,7 +2523,7 @@ snapshots: dependencies: ee-first: 1.1.1 - openai@4.96.0(@kevisual/ws@8.0.0): + openai@4.99.0(@kevisual/ws@8.0.0): dependencies: '@types/node': 18.19.87 '@types/node-fetch': 2.6.12 @@ -2401,6 +2654,44 @@ snapshots: - supports-color - utf-8-validate + pm2@6.0.6(supports-color@10.0.0): + dependencies: + '@pm2/agent': 2.1.1(supports-color@10.0.0) + '@pm2/io': 6.1.0(supports-color@10.0.0) + '@pm2/js-api': 0.8.0(supports-color@10.0.0) + '@pm2/pm2-version-check': 1.0.4(supports-color@10.0.0) + ansis: 4.0.0 + async: 3.2.6 + blessed: 0.1.81 + chokidar: 3.6.0 + cli-tableau: 2.0.1 + commander: 2.15.1 + croner: 4.1.97 + dayjs: 1.11.13 + debug: 4.4.0(supports-color@10.0.0) + enquirer: 2.3.6 + eventemitter2: 5.0.1 + fclone: 1.0.11 + js-yaml: 4.1.0 + mkdirp: 1.0.4 + needle: 2.4.0(supports-color@10.0.0) + pidusage: 3.0.2 + pm2-axon: 4.0.1(supports-color@10.0.0) + pm2-axon-rpc: 0.7.1(supports-color@10.0.0) + pm2-deploy: 1.0.2 + pm2-multimeter: 0.1.2 + promptly: 2.2.0 + semver: 7.7.1 + source-map-support: 0.5.21 + sprintf-js: 1.1.2 + vizion: 2.2.1 + optionalDependencies: + pm2-sysmonit: 1.2.8(supports-color@10.0.0) + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + promptly@2.2.0: dependencies: read: 1.0.7 diff --git a/assistant/src/app.ts b/assistant/src/app.ts index 2773ec7..2fadbaa 100644 --- a/assistant/src/app.ts +++ b/assistant/src/app.ts @@ -1,11 +1,15 @@ import { App } from '@kevisual/router'; import { HttpsPem } from '@/module/assistant/https/sign.ts'; // import { AssistantConfig } from '@/module/assistant/index.ts'; -import { AssistantInit } from '@/services/init/index.ts'; -export const configDir = AssistantInit.detectConfigDir(); +import { AssistantInit, parseHomeArg } from '@/services/init/index.ts'; +import { configDir as HomeConfigDir } from '@/module/assistant/config/index.ts'; + +const manualParse = parseHomeArg(HomeConfigDir); +const _configDir = manualParse.configDir; +export const configDir = AssistantInit.detectConfigDir(_configDir); export const assistantConfig = new AssistantInit({ path: configDir, - init: true, + init: manualParse?.options?.help ? false : true, }); const httpsPem = new HttpsPem(assistantConfig); diff --git a/assistant/src/command/app-manager/index.ts b/assistant/src/command/app-manager/index.ts index 1fc9f63..8dfefc3 100644 --- a/assistant/src/command/app-manager/index.ts +++ b/assistant/src/command/app-manager/index.ts @@ -66,3 +66,24 @@ appManagerCommand } console.log('Restart App:', appKey); }); + +const pageListCommand = new Command('page-list') + .alias('pl') + .option('-a, --all', '列出前端页面的所有信息') + .description('列出安装的前端页面') + .action(async (opts) => { + const manager = new AssistantApp(assistantConfig); + await manager.loadConfig(); + const showInfos = manager.pageList(); + if (opts.all) { + console.log('Installed Pages:', showInfos); + } else { + console.log( + 'Installed Pages:', + showInfos.map((item) => { + return { app: item.app, user: item.user, version: item.version }; + }), + ); + } + }); +program.addCommand(pageListCommand); diff --git a/assistant/src/command/asst-server/index.ts b/assistant/src/command/asst-server/index.ts index 7234787..fe7b000 100644 --- a/assistant/src/command/asst-server/index.ts +++ b/assistant/src/command/asst-server/index.ts @@ -7,8 +7,10 @@ const command = new Command('server') .option('-n, --name ', '服务名称') .option('-p, --port ', '服务端口') .option('-s, --start', '是否启动服务') + .option('-i, --home', '是否以home方式运行') .action((options) => { const { port } = options; + const [_interpreter, execPath] = process.argv; const shellCommands = []; if (options.daemon) { shellCommands.push('-d'); @@ -22,10 +24,23 @@ const command = new Command('server') if (port) { shellCommands.push(`-p ${port}`); } - console.log(`Assistant server shell command: asst-server ${shellCommands.join(' ')}`); - const child = spawnSync('asst-server', shellCommands, { - stdio: 'inherit', - shell: true, - }); + if (options.home) { + shellCommands.push('--home'); + } + const basename = _interpreter.split('/').pop(); + + if (basename.includes('bun')) { + console.log(`Assistant server shell command: bun src/run-server.ts server ${shellCommands.join(' ')}`); + const child = spawnSync(_interpreter, ['src/run-server.ts', ...shellCommands], { + stdio: 'inherit', + shell: true, + }); + } else { + console.log(`Assistant server shell command: asst-server ${shellCommands.join(' ')}`); + const child = spawnSync('asst-server', shellCommands, { + stdio: 'inherit', + shell: true, + }); + } }); program.addCommand(command); diff --git a/assistant/src/config.ts b/assistant/src/config.ts index 449055e..132d386 100644 --- a/assistant/src/config.ts +++ b/assistant/src/config.ts @@ -1,34 +1,9 @@ -import { AssistantConfig } from '@/module/assistant/index.ts'; +import { AssistantConfig, parseHomeArg } from '@/module/assistant/index.ts'; import { configDir as HomeConfigDir } from '@/module/assistant/config/index.ts'; -// 手动解析命令行参数 -function parseArgs(args: string[]) { - const result: { root?: string; home?: boolean } = {}; - for (let i = 0; i < args.length; i++) { - const arg = args[i]; - // 处理 root 参数 - if (arg === 'root') { - if (i + 1 < args.length && !args[i + 1].startsWith('-')) { - result.root = args[i + 1]; - i++; // 跳过下一个参数,因为它是值 - } - } - // 处理 home 参数 - if (arg === 'home') { - result.home = true; - } - } - return result; -} -const args = process.argv.slice(2); -const options = parseArgs(args); -let _configDir = undefined; -if (options.home) { - _configDir = HomeConfigDir; -} else if (options.root) { - _configDir = options.root; -} +const _configDir = parseHomeArg(HomeConfigDir).configDir; + // console.log('configDir', _configDir); // process.exit(0); export const configDir = AssistantConfig.detectConfigDir(_configDir); diff --git a/assistant/src/module/assistant/config/index.ts b/assistant/src/module/assistant/config/index.ts index 00c588f..defb54a 100644 --- a/assistant/src/module/assistant/config/index.ts +++ b/assistant/src/module/assistant/config/index.ts @@ -3,7 +3,7 @@ import { homedir } from 'os'; import fs from 'fs'; import { checkFileExists, createDir } from '../file/index.ts'; import { ProxyInfo } from '../proxy/proxy.ts'; - +import dotenv from 'dotenv'; /** * 助手配置文件路径, 全局配置文件目录 */ @@ -18,7 +18,7 @@ export const initConfig = (configRootPath: string) => { const configDir = createDir(path.join(configRootPath, 'assistant-app')); const configPath = path.join(configDir, 'assistant-config.json'); const pageConfigPath = path.join(configDir, 'assistant-page-config.json'); - const pageDir = createDir(path.join(configDir, 'page')); + const pagesDir = createDir(path.join(configDir, 'pages')); const appsDir = createDir(path.join(configDir, 'apps')); const appsConfigPath = path.join(configDir, 'assistant-apps-config.json'); const appPidPath = path.join(configDir, 'assistant-app.pid'); @@ -43,7 +43,7 @@ export const initConfig = (configRootPath: string) => { /** * 应用目录, 前端应用目录 */ - pageDir, + pagesDir, /** * 应用配置文件路径, assistant-page-config.json */ @@ -207,6 +207,20 @@ export class AssistantConfig { getAppList() { return this.getPageConfig().list; } + getEnvConfig() { + const envConfigPath = this.configPath.envConfigPath; + if (!checkFileExists(envConfigPath)) { + return {}; + } + const envConfig = dotenv.parse(fs.readFileSync(envConfigPath)); + return envConfig; + } + setEnvConfig(config: string) { + const envConfigPath = this.configPath.envConfigPath; + fs.writeFileSync(envConfigPath, config); + const envConfig = dotenv.parse(fs.readFileSync(envConfigPath)); + return envConfig; + } /** * process.env.ASSISTANT_CONFIG_DIR || process.cwd() * configDir是助手配置文件目录,文件内部包函 @@ -245,3 +259,58 @@ export class AssistantConfig { type AppConfig = { list: any[]; }; +export function parseArgs(args: string[]) { + const result: { root?: string; home?: boolean; help?: boolean } = {}; + for (let i = 0; i < args.length; i++) { + const arg = args[i]; + // 处理 root 参数 + if (arg === '--root') { + if (i + 1 < args.length && !args[i + 1].startsWith('-')) { + result.root = args[i + 1]; + i++; // 跳过下一个参数,因为它是值 + } + } + // 处理 home 参数 + if (arg === '--home') { + result.home = true; + } + if (arg === '--help' || arg === '-h') { + result.help = true; + } + } + return result; +} +/** + * 手动解析命令行参数 + * @param homedir + * @returns + */ +export const parseHomeArg = (homedir?: string) => { + const args = process.argv.slice(2); + const options = parseArgs(args); + let _configDir = undefined; + if (options.home && homedir) { + _configDir = homedir; + } else if (options.root) { + _configDir = options.root; + } + return { + options, + configDir: _configDir, + }; +}; + +export const parseHelpArg = () => { + const args = process.argv.slice(2); + const options = parseArgs(args); + return !!options?.help; +}; + +export const parseIfJson = (content: string) => { + try { + return JSON.parse(content); + } catch (error) { + console.error('parseIfJson', error); + return {}; + } +}; diff --git a/assistant/src/module/assistant/https/sign.ts b/assistant/src/module/assistant/https/sign.ts index 476d2bd..28ac854 100644 --- a/assistant/src/module/assistant/https/sign.ts +++ b/assistant/src/module/assistant/https/sign.ts @@ -34,6 +34,7 @@ export class HttpsPem { return pemDir; } getCert() { + if (!this.assistantConfig.init) return; const pemDir = this.getPemDir(); const pemPath = { key: path.join(pemDir, 'https-private-key.pem'), diff --git a/assistant/src/module/assistant/local-app-manager/assistant-app.ts b/assistant/src/module/assistant/local-app-manager/assistant-app.ts index 5468b6b..d4995c0 100644 --- a/assistant/src/module/assistant/local-app-manager/assistant-app.ts +++ b/assistant/src/module/assistant/local-app-manager/assistant-app.ts @@ -1,19 +1,41 @@ import { Manager } from '@kevisual/local-app-manager/manager'; -import { AssistantConfig } from '@/module/assistant/index.ts'; +import type { AssistantConfig } from '@/module/assistant/index.ts'; +import { parseIfJson } from '@/module/assistant/index.ts'; import path from 'node:path'; - +import fs from 'node:fs'; +import glob from 'fast-glob'; export class AssistantApp extends Manager { config: AssistantConfig; - + pagesPath: string; constructor(config: AssistantConfig) { config.checkMounted(); const appsPath = config?.configPath?.appsDir || path.join(process.cwd(), 'apps'); + const pagesPath = config?.configPath?.pagesDir || path.join(process.cwd(), 'pages'); const appsConfigPath = config.configPath?.appsConfigPath; const configFimename = path.basename(appsConfigPath || ''); super({ appsPath, configFilename: configFimename, }); + this.pagesPath = pagesPath; this.config = config; } + pageList() { + const pages = glob.sync('*/*/package.json', { + cwd: this.pagesPath, + onlyFiles: true, + }); + const pagesParse = pages.map((page) => { + const [user, app] = page.split('/'); + const contentStr = fs.readFileSync(path.join(this.pagesPath, page), 'utf-8'); + const content = parseIfJson(contentStr); + return { + user, + app, + version: content?.version, + content, + }; + }); + return pagesParse; + } } diff --git a/assistant/src/module/logger.ts b/assistant/src/module/logger.ts index 292046f..b707e36 100644 --- a/assistant/src/module/logger.ts +++ b/assistant/src/module/logger.ts @@ -1,35 +1,6 @@ -export class Logger { - level: string; - constructor(level: string) { - this.level = level; - } - info(message: string, data?: any, ...args: any[]) { - if (this.level === 'info') { - console.log(`INFO: ${message}`, data, ...args); - } - } - error(message: string, data?: any, ...args: any[]) { - if (this.level === 'error') { - console.error(`ERROR: ${message}`, data, ...args); - } - } - warn(message: string, data?: any, ...args: any[]) { - if (this.level === 'warn') { - console.warn(`WARN: ${message}`, data, ...args); - } - } - debug(message: string, data?: any, ...args: any[]) { - if (this.level === 'debug') { - console.debug(`DEBUG: ${message}`, data, ...args); - } - } - log(message: string, ...args: any[]) { - if (this.level === 'log') { - console.log(`LOG: ${message}`, ...args); - } - } -} -const logger = new Logger(process.env.LOG_LEVEL || 'info'); +import { Logger } from '@kevisual/logger'; +const level = process.env.LOG_LEVEL || 'info'; +const logger = new Logger({ level: level as any }); export const console = { log: logger.info, diff --git a/assistant/src/program.ts b/assistant/src/program.ts index 32fc57b..84716ca 100644 --- a/assistant/src/program.ts +++ b/assistant/src/program.ts @@ -16,14 +16,6 @@ const ls = new Command('ls').description('List files in the current directory'). }); program.addCommand(ls); -const home = new Command('home').description('启动以全局目录').action(() => {}); // @ts-ignore -program.addCommand(home); -const root = new Command('root') - .argument('', '自定义启动路径') - .description('自定义启动路径') - .action(() => {}); // @ts-ignore -program.addCommand(root); - export { program, Command, assistantConfig }; /** diff --git a/assistant/src/routes/config/index.ts b/assistant/src/routes/config/index.ts index 10474b0..de147fb 100644 --- a/assistant/src/routes/config/index.ts +++ b/assistant/src/routes/config/index.ts @@ -6,6 +6,7 @@ app .route({ path: 'config', description: '获取配置', + middleware: ['auth'], }) .define(async (ctx) => { ctx.body = assistantConfig.getCacheAssistantConfig(); @@ -17,6 +18,7 @@ app path: 'config', key: 'set', description: '设置配置', + middleware: ['auth'], }) .define(async (ctx) => { const { data } = ctx.query; diff --git a/assistant/src/routes/index.ts b/assistant/src/routes/index.ts index 92d5510..c6e7247 100644 --- a/assistant/src/routes/index.ts +++ b/assistant/src/routes/index.ts @@ -1,2 +1,13 @@ -import './config/index.ts' -import './shop-install/index.ts' \ No newline at end of file +import { app } from '../app.ts'; +import './config/index.ts'; +import './shop-install/index.ts'; + +app + .route({ + path: 'auth', + id: 'auth', + }) + .define(async (ctx) => { + // + }) + .addTo(app); diff --git a/assistant/src/routes/shop-install/index.ts b/assistant/src/routes/shop-install/index.ts index f1ee941..b222198 100644 --- a/assistant/src/routes/shop-install/index.ts +++ b/assistant/src/routes/shop-install/index.ts @@ -23,6 +23,7 @@ app .route({ path: 'shop', key: 'list-installed', + middleware: ['auth'], }) .define(async (ctx) => { // https://localhost:51015/client/router?path=shop&key=list-installed @@ -35,6 +36,7 @@ app .route({ path: 'shop', key: 'install', + middleware: ['auth'], }) .define(async (ctx) => { // https://localhost:51015/client/router?path=shop&key=install @@ -51,6 +53,7 @@ app .route({ path: 'shop', key: 'uninstall', + middleware: ['auth'], }) .define(async (ctx) => { // https://localhost:51015/client/router?path=shop&key=uninstall diff --git a/assistant/src/run-server.ts b/assistant/src/run-server.ts index aeeed2f..8baeb90 100644 --- a/assistant/src/run-server.ts +++ b/assistant/src/run-server.ts @@ -1,3 +1,3 @@ -import { runServer } from "./server.ts"; +import { runParser } from './server.ts'; -runServer(); \ No newline at end of file +runParser(process.argv); diff --git a/assistant/src/server.ts b/assistant/src/server.ts index 55a7e21..3b3e69d 100644 --- a/assistant/src/server.ts +++ b/assistant/src/server.ts @@ -1,10 +1,11 @@ -import { app } from './app.ts'; +import { app, assistantConfig } from './app.ts'; import { proxyRoute, proxyWs } from './services/proxy/proxy-page-index.ts'; import './routes/index.ts'; import getPort, { portNumbers } from 'get-port'; import { program } from 'commander'; import { spawnSync } from 'child_process'; +import chalk from 'chalk'; export const runServer = async (port?: number) => { let _port: number | undefined; if (port) { @@ -39,6 +40,7 @@ program .option('-n, --name ', '服务名称', 'assistant-server') .option('-p, --port ', '服务端口') .option('-s, --start', '是否启动服务') + .option('-i, --home', 'home目录') .action(async (options) => { // console.log('当前执行路径:', execPath, inte); if (options.daemon) { @@ -49,6 +51,9 @@ program if (port) { pm2Command += ` -p ${port}`; } + if (options.home) { + pm2Command += ` --home`; + } const result = spawnSync(pm2Command, { shell: true, stdio: 'inherit', @@ -59,7 +64,7 @@ program } console.log('以守护进程方式运行'); } else if (options.start) { - console.log('启动服务'); + console.log('启动服务', chalk.green(assistantConfig.configDir)); const server = await runServer(options.port); } }); diff --git a/assistant/src/services/app/index.ts b/assistant/src/services/app/index.ts index c40a72b..3a4e5d7 100644 --- a/assistant/src/services/app/index.ts +++ b/assistant/src/services/app/index.ts @@ -57,7 +57,7 @@ export class AppDownload { const configDir = this.config.configDir; this.config?.checkMounted(); const appsDir = this.config.configPath?.appsDir; - const pageDir = this.config.configPath?.pageDir; + const pagesDir = this.config.configPath?.pagesDir; if (!id) { throw new Error('应用名称不能为空'); } @@ -69,7 +69,7 @@ export class AppDownload { } const appName = opts?.appName || id.split('/').pop(); if (type === 'web') { - args.push('-o', pageDir); + args.push('-o', pagesDir); } else if (type === 'app') { args.push('-o', path.join(appsDir, appName)); } else { @@ -96,7 +96,7 @@ export class AppDownload { const appName = opts?.appName || id.split('/').pop(); this.config?.checkMounted(); const appsDir = this.config.configPath?.appsDir; - const pageDir = this.config.configPath?.pageDir; + const pagesDir = this.config.configPath?.pagesDir; if (!id) { throw new Error('应用名称不能为空'); } @@ -104,7 +104,7 @@ export class AppDownload { let isDelete = false; if (type === 'web') { // 直接删除路径就行 - const pagePath = path.join(pageDir, id); + const pagePath = path.join(pagesDir, id); deletePath = pagePath; } else if (type === 'app') { const appPath = path.join(appsDir, appName); diff --git a/assistant/src/services/init/index.ts b/assistant/src/services/init/index.ts index 0c0bf30..76cb5f5 100644 --- a/assistant/src/services/init/index.ts +++ b/assistant/src/services/init/index.ts @@ -1,8 +1,9 @@ import fs from 'node:fs'; import path from 'node:path'; -import { checkFileExists, AssistantConfig, AssistantConfigData } from '@/module/assistant/index.ts'; +import { checkFileExists, AssistantConfig, AssistantConfigData, parseHomeArg, parseHelpArg } from '@/module/assistant/index.ts'; import { chalk } from '@/module/chalk.ts'; import { HttpsPem } from '@/module/assistant/https/sign.ts'; +export { parseHomeArg, parseHelpArg }; export type AssistantInitOptions = { path?: string; init?: boolean; @@ -30,7 +31,8 @@ export class AssistantInit extends AssistantConfig { super.init(); } else { super.init(); - console.log(chalk.yellow('助手路径已存在')); + const assistantConfig = this; + console.log(chalk.yellow('助手路径已存在'), chalk.green(assistantConfig.configDir)); } this.createAssistantConfig(); this.createEnvConfig(); diff --git a/assistant/src/services/proxy/local-proxy.ts b/assistant/src/services/proxy/local-proxy.ts index 70a99f0..68b48e6 100644 --- a/assistant/src/services/proxy/local-proxy.ts +++ b/assistant/src/services/proxy/local-proxy.ts @@ -43,7 +43,7 @@ export class LocalProxy { } } init() { - const frontAppDir = this.assistantConfig.configPath?.pageDir; + const frontAppDir = this.assistantConfig.configPath?.pagesDir; if (frontAppDir) { const userList = fs.readdirSync(frontAppDir); const localProxyProxyList: ProxyType[] = []; diff --git a/assistant/src/services/proxy/proxy-page-index.ts b/assistant/src/services/proxy/proxy-page-index.ts index ff9d966..c35072a 100644 --- a/assistant/src/services/proxy/proxy-page-index.ts +++ b/assistant/src/services/proxy/proxy-page-index.ts @@ -8,7 +8,7 @@ const localProxy = new LocalProxy({ }); export const proxyRoute = async (req: http.IncomingMessage, res: http.ServerResponse) => { const _assistantConfig = assistantConfig.getCacheAssistantConfig(); - const appDir = assistantConfig.configPath?.pageDir; + const appDir = assistantConfig.configPath?.pagesDir; const url = new URL(req.url, 'http://localhost'); const pathname = url.pathname; if (pathname === '/' && _assistantConfig?.home) { diff --git a/bin/assistant-server.js b/bin/assistant-server.js old mode 100644 new mode 100755 index 5668f57..155a5ae --- a/bin/assistant-server.js +++ b/bin/assistant-server.js @@ -1,4 +1,4 @@ #!/usr/bin/env node -import { runParser } from '../dist/assistant-server.mjs'; +import { runParser } from '../dist/assistant-server.js'; runParser(process.argv); diff --git a/bin/assistant.js b/bin/assistant.js index 603e45f..5db68c2 100755 --- a/bin/assistant.js +++ b/bin/assistant.js @@ -1,4 +1,4 @@ #!/usr/bin/env node -import { runParser } from '../dist/assistant.mjs'; +import { runParser } from '../dist/assistant.js'; runParser(process.argv); diff --git a/package.json b/package.json index f5e8256..cac4cdf 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "dev": "NODE_ENV=development bun src/run.ts ", "dev:tsx": "tsx src/run.ts ", "build": "rimraf dist && bun run bun.config.mjs", - "postbuild": "cd assistant && pnpm build", + "postbuild": "cd assistant && pnpm build ", "dts": "dts-bundle-generator --external-inlines=@types/jsonwebtoken src/index.ts -o dist/index.d.ts ", "build:all": "rimraf dist && bun run bun.config.mjs && bun run assistant/bun.config.mjs" }, diff --git a/src/command/app/front-app/index.ts b/src/command/app/front-app/index.ts index e56c5aa..5f1db84 100644 --- a/src/command/app/front-app/index.ts +++ b/src/command/app/front-app/index.ts @@ -66,7 +66,7 @@ const downloadAppCommand = new Command('download') registry = new URL(config.baseURL).origin; } const res = await queryApp(data, { url: getUrl(registry) }); - console.log('registry', registry, data); + console.log('registry', registry, data, options.type); if (res.code === 200) { const app = res.data; let appType: 'app' | 'web' = 'web'; diff --git a/src/module/download/install.ts b/src/module/download/install.ts index 95d4051..a629762 100644 --- a/src/module/download/install.ts +++ b/src/module/download/install.ts @@ -81,23 +81,44 @@ export const installApp = async (app: Package, opts: InstallAppOpts = {}) => { try { let files = _app.data.files || []; const version = _app.version; + let hasPackage = false; const user = _app.user; const key = _app.key; - - const downFiles = files.map((file: any) => { - const noVersionPath = file.path.replace(`/${version}`, ''); - let downloadPath = noVersionPath; - if (appType === 'app') { - downloadPath = noVersionPath.replace(`${user}/${key}/`, ''); - } - return { - ...file, - downloadPath: path.join(appDir, downloadPath), - downloadUrl: `${kevisualUrl}/${noVersionPath}`, - }; - }); + const packagePath = path.join(appDir, appType === 'app' ? 'package.json' : `${user}/${key}/package.json`); + const downFiles = files + .filter((file: any) => file?.path) + .map((file: any) => { + const name = file?.name || ''; + if (name.startsWith('package.json')) { + hasPackage = true; + } + const noVersionPath = file.path.replace(`/${version}`, ''); + let downloadPath = noVersionPath; + let downloadUrl = ''; + if (appType === 'app') { + downloadPath = noVersionPath.replace(`${user}/${key}/`, ''); + } + if (file.path.startsWith('http')) { + downloadUrl = file.path; + } else { + downloadUrl = `${kevisualUrl}/${noVersionPath}`; + } + return { + ...file, + downloadPath: path.join(appDir, downloadPath), + downloadUrl: downloadUrl, + }; + }); const downloadTasks: DownloadTask[] = downFiles as any; console.log('downloadTasks', downloadTasks); + if (!hasPackage) { + console.log('没有package.json文件, 生成一个'); + const pkg = { ..._app }; + if (pkg.data) { + delete pkg.data.permission; + } + fs.writeFileSync(packagePath, JSON.stringify(pkg, null, 2)); + } // return; for (const file of downloadTasks) { const downloadPath = file.downloadPath;