fix: fix hot-api for not build in bun app.mjs
This commit is contained in:
@@ -6,6 +6,7 @@ import fs from 'node:fs';
|
||||
// bun run src/index.ts --
|
||||
import { fileURLToPath } from 'node:url';
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const external = ['pm2', '@kevisual/hot-api'];
|
||||
/**
|
||||
*
|
||||
* @param {string} p
|
||||
@@ -20,11 +21,10 @@ await Bun.build({
|
||||
naming: {
|
||||
entry: 'assistant.js',
|
||||
},
|
||||
external: ['pm2'],
|
||||
external,
|
||||
define: {
|
||||
ENVISION_VERSION: JSON.stringify(pkg.version),
|
||||
},
|
||||
env: 'ENVISION_*',
|
||||
});
|
||||
|
||||
await Bun.build({
|
||||
@@ -38,8 +38,7 @@ await Bun.build({
|
||||
define: {
|
||||
ENVISION_VERSION: JSON.stringify(pkg.version),
|
||||
},
|
||||
external: ['pm2'],
|
||||
env: 'ENVISION_*',
|
||||
external,
|
||||
});
|
||||
// const copyDist = ['dist', 'bin'];
|
||||
const copyDist = ['dist'];
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "bun run src/run.ts ",
|
||||
"dev:server": "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 bun --watch src/run-server.ts --home ",
|
||||
"dev:share": "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 bun --watch src/test/remote-app.ts ",
|
||||
"dev:server": "bun --watch src/run-server.ts ",
|
||||
"dev:share": "bun --watch src/test/remote-app.ts ",
|
||||
"build:lib": "bun run bun-lib.config.mjs",
|
||||
"postbuild:lib": "dts -i src/lib.ts -o assistant-lib.d.ts -d libs -t",
|
||||
"build": "rimraf dist && bun run bun.config.mjs",
|
||||
@@ -45,7 +45,7 @@
|
||||
"@kevisual/load": "^0.0.6",
|
||||
"@kevisual/local-app-manager": "^0.1.32",
|
||||
"@kevisual/logger": "^0.0.4",
|
||||
"@kevisual/query": "0.0.30",
|
||||
"@kevisual/query": "0.0.31",
|
||||
"@kevisual/query-login": "0.0.7",
|
||||
"@kevisual/router": "^0.0.33",
|
||||
"@kevisual/types": "^0.0.10",
|
||||
@@ -75,7 +75,7 @@
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"@kevisual/hot-api": "^0.0.2",
|
||||
"@kevisual/hot-api": "^0.0.3",
|
||||
"@nut-tree-fork/nut-js": "^4.2.6",
|
||||
"eventemitter3": "^5.0.1",
|
||||
"lowdb": "^7.0.1",
|
||||
|
||||
@@ -4,10 +4,10 @@ import { spawnSync } from 'node:child_process';
|
||||
const command = new Command('server')
|
||||
.description('启动服务')
|
||||
.option('-d, --daemon', '是否以守护进程方式运行')
|
||||
.option('-n, --name <name>', '服务名称')
|
||||
.option('-n, --name <name>', '服务名称', 'assistant-server')
|
||||
.option('-p, --port <port>', '服务端口')
|
||||
.option('-s, --start', '是否启动服务')
|
||||
.option('-i, --home', '是否以home方式运行')
|
||||
.option('-e, --interpreter <interpreter>', '指定使用的解释器', 'bun')
|
||||
.action((options) => {
|
||||
const { port } = options;
|
||||
const [_interpreter, execPath] = process.argv;
|
||||
@@ -24,8 +24,8 @@ const command = new Command('server')
|
||||
if (port) {
|
||||
shellCommands.push(`-p ${port}`);
|
||||
}
|
||||
if (options.home) {
|
||||
shellCommands.push('--home');
|
||||
if (options.interpreter) {
|
||||
shellCommands.push(`-e ${options.interpreter}`);
|
||||
}
|
||||
const basename = _interpreter.split('/').pop();
|
||||
|
||||
|
||||
19
assistant/src/routes/hot-api/key-sender/index.ts
Normal file
19
assistant/src/routes/hot-api/key-sender/index.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { app } from '@/app.ts';
|
||||
import { Hotkeys } from '@kevisual/hot-api';
|
||||
import { useContextKey } from '@kevisual/context';
|
||||
app.route({
|
||||
path: 'key-sender',
|
||||
middleware: ['admin-auth']
|
||||
}).define(async (ctx) => {
|
||||
let keys = ctx.query.keys;
|
||||
if (keys.includes(' ')) {
|
||||
keys = keys.replace(/\s+/g, '+');
|
||||
}
|
||||
const hotKeys: Hotkeys = useContextKey('hotkeys', () => new Hotkeys());
|
||||
if (typeof keys === 'string') {
|
||||
await hotKeys.pressHotkey({
|
||||
hotkey: keys,
|
||||
});
|
||||
}
|
||||
ctx.body = 'ok';
|
||||
}).addTo(app);
|
||||
@@ -2,8 +2,10 @@ import { app, assistantConfig } from '../app.ts';
|
||||
import './config/index.ts';
|
||||
import './shop-install/index.ts';
|
||||
import './ai/index.ts';
|
||||
import './light-code/index.ts';
|
||||
// TODO:
|
||||
// import './light-code/index.ts';
|
||||
import './user/index.ts';
|
||||
import './hot-api/key-sender/index.ts';
|
||||
|
||||
import os from 'node:os';
|
||||
import { authCache } from '@/module/cache/auth.ts';
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { app, assistantConfig } from '@/app.ts';
|
||||
import { AppDownload } from '@/services/app/index.ts';
|
||||
import { AssistantApp } from '@/module/assistant/index.ts';
|
||||
import { shopDefine } from './define.ts';
|
||||
app
|
||||
.route({
|
||||
...shopDefine.get('getRegistry'),
|
||||
middleware: ['admin-auth'],
|
||||
path: 'shop',
|
||||
key: 'get-registry',
|
||||
description: '获取应用商店注册表信息',
|
||||
middleware: ['admin-auth'],
|
||||
metadata: {
|
||||
admin: true,
|
||||
}
|
||||
@@ -19,7 +20,9 @@ app
|
||||
|
||||
app
|
||||
.route({
|
||||
...shopDefine.get('listInstalled'),
|
||||
path: 'shop',
|
||||
key: 'list-installed',
|
||||
description: '列出当前已安装的所有应用',
|
||||
middleware: ['admin-auth'],
|
||||
metadata: {
|
||||
admin: true,
|
||||
@@ -35,7 +38,9 @@ app
|
||||
|
||||
app
|
||||
.route({
|
||||
...shopDefine.get('install'),
|
||||
path: 'shop',
|
||||
key: 'install',
|
||||
description: '安装指定的应用,可以指定 id、type、force 和 yes 参数',
|
||||
middleware: ['admin-auth'],
|
||||
metadata: {
|
||||
admin: true,
|
||||
@@ -60,7 +65,9 @@ app
|
||||
|
||||
app
|
||||
.route({
|
||||
...shopDefine.get('uninstall'),
|
||||
path: 'shop',
|
||||
key: 'uninstall',
|
||||
description: '卸载指定的应用,可以指定 id 和 type 参数',
|
||||
middleware: ['admin-auth'],
|
||||
metadata: {
|
||||
admin: true,
|
||||
|
||||
@@ -7,7 +7,7 @@ app.route({
|
||||
}).define(async (ctx) => {
|
||||
const { username, password } = ctx.query;
|
||||
const query = assistantConfig.query;
|
||||
const auth = assistantConfig.getConfig().auth;
|
||||
const auth = assistantConfig.getConfig().auth || {};
|
||||
const res = await query.post({
|
||||
path: 'user',
|
||||
key: 'login',
|
||||
@@ -25,7 +25,7 @@ app.route({
|
||||
}
|
||||
if (!auth.username) {
|
||||
// 初始管理员账号
|
||||
auth.username = 'admin';
|
||||
auth.username = loginUser;
|
||||
assistantConfig.setConfig({ auth });
|
||||
}
|
||||
// 保存配置
|
||||
|
||||
13
package.json
13
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@kevisual/cli",
|
||||
"version": "0.0.71",
|
||||
"version": "0.0.73",
|
||||
"description": "envision 命令行工具",
|
||||
"type": "module",
|
||||
"basename": "/root/cli",
|
||||
@@ -28,6 +28,7 @@
|
||||
"scripts": {
|
||||
"dev": "bun src/run.ts ",
|
||||
"dev:tsx": "tsx src/run.ts ",
|
||||
"dev:server": "cd assistant && bun --watch src/run-server.ts ",
|
||||
"build": "rimraf dist && bun run bun.config.mjs",
|
||||
"deploy": "ev pack -u -p -m no",
|
||||
"pub:me": "npm publish --registry https://npm.xiongxiao.me --tag beta",
|
||||
@@ -41,15 +42,21 @@
|
||||
"author": "abearxiong",
|
||||
"dependencies": {
|
||||
"@kevisual/context": "^0.0.4",
|
||||
"@kevisual/hot-api": "^0.0.3",
|
||||
"@nut-tree-fork/nut-js": "^4.2.6",
|
||||
"eventemitter3": "^5.0.1",
|
||||
"lowdb": "^7.0.1",
|
||||
"lru-cache": "^11.2.4",
|
||||
"micromatch": "^4.0.8",
|
||||
"pm2": "^6.0.14",
|
||||
"semver": "^7.7.3"
|
||||
"semver": "^7.7.3",
|
||||
"unstorage": "^1.17.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kevisual/dts": "^0.0.3",
|
||||
"@kevisual/load": "^0.0.6",
|
||||
"@kevisual/logger": "^0.0.4",
|
||||
"@kevisual/query": "0.0.30",
|
||||
"@kevisual/query": "0.0.31",
|
||||
"@kevisual/query-login": "0.0.7",
|
||||
"@types/bun": "^1.3.3",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
|
||||
51
pnpm-lock.yaml
generated
51
pnpm-lock.yaml
generated
@@ -11,6 +11,21 @@ importers:
|
||||
'@kevisual/context':
|
||||
specifier: ^0.0.4
|
||||
version: 0.0.4
|
||||
'@kevisual/hot-api':
|
||||
specifier: ^0.0.3
|
||||
version: 0.0.3(dotenv@17.2.3)(supports-color@10.2.2)
|
||||
'@nut-tree-fork/nut-js':
|
||||
specifier: ^4.2.6
|
||||
version: 4.2.6
|
||||
eventemitter3:
|
||||
specifier: ^5.0.1
|
||||
version: 5.0.1
|
||||
lowdb:
|
||||
specifier: ^7.0.1
|
||||
version: 7.0.1
|
||||
lru-cache:
|
||||
specifier: ^11.2.4
|
||||
version: 11.2.4
|
||||
micromatch:
|
||||
specifier: ^4.0.8
|
||||
version: 4.0.8
|
||||
@@ -20,6 +35,9 @@ importers:
|
||||
semver:
|
||||
specifier: ^7.7.3
|
||||
version: 7.7.3
|
||||
unstorage:
|
||||
specifier: ^1.17.3
|
||||
version: 1.17.3(idb-keyval@6.2.1)
|
||||
devDependencies:
|
||||
'@kevisual/dts':
|
||||
specifier: ^0.0.3
|
||||
@@ -31,11 +49,11 @@ importers:
|
||||
specifier: ^0.0.4
|
||||
version: 0.0.4
|
||||
'@kevisual/query':
|
||||
specifier: 0.0.30
|
||||
version: 0.0.30
|
||||
specifier: 0.0.31
|
||||
version: 0.0.31
|
||||
'@kevisual/query-login':
|
||||
specifier: 0.0.7
|
||||
version: 0.0.7(@kevisual/query@0.0.30)
|
||||
version: 0.0.7(@kevisual/query@0.0.31)
|
||||
'@types/bun':
|
||||
specifier: ^1.3.3
|
||||
version: 1.3.3
|
||||
@@ -91,8 +109,8 @@ importers:
|
||||
assistant:
|
||||
dependencies:
|
||||
'@kevisual/hot-api':
|
||||
specifier: ^0.0.2
|
||||
version: 0.0.2(dotenv@17.2.3)(supports-color@10.2.2)
|
||||
specifier: ^0.0.3
|
||||
version: 0.0.3(dotenv@17.2.3)(supports-color@10.2.2)
|
||||
'@nut-tree-fork/nut-js':
|
||||
specifier: ^4.2.6
|
||||
version: 4.2.6
|
||||
@@ -125,11 +143,11 @@ importers:
|
||||
specifier: ^0.0.4
|
||||
version: 0.0.4
|
||||
'@kevisual/query':
|
||||
specifier: 0.0.30
|
||||
version: 0.0.30
|
||||
specifier: 0.0.31
|
||||
version: 0.0.31
|
||||
'@kevisual/query-login':
|
||||
specifier: 0.0.7
|
||||
version: 0.0.7(@kevisual/query@0.0.30)
|
||||
version: 0.0.7(@kevisual/query@0.0.31)
|
||||
'@kevisual/router':
|
||||
specifier: ^0.0.33
|
||||
version: 0.0.33(supports-color@10.2.2)
|
||||
@@ -527,8 +545,8 @@ packages:
|
||||
resolution: {integrity: sha512-4T/m2LqhtwWEW+lWmg7jLxKFW7VtIAftsWFDDZvh10bZunqFf8iXxChHcVSQWikghJb4cq1IkWzPkvc2l+Asdw==}
|
||||
hasBin: true
|
||||
|
||||
'@kevisual/hot-api@0.0.2':
|
||||
resolution: {integrity: sha512-DUWfTScVmRx11f45rjoTjvs6b0LtZVT/EZfEw0l2rzx2vZWgRlYivIrYiH9QIV6dajVWNsth1xyjeNcu9+UfQA==}
|
||||
'@kevisual/hot-api@0.0.3':
|
||||
resolution: {integrity: sha512-qZ4CNK08StZP4+DR1vWwJhKVDoSXXC+PBFG4ZxtkXF5vO2rybE055zp1n3dg5jo8GwW5wxpqMIG3KBp3pYSTkg==}
|
||||
|
||||
'@kevisual/load@0.0.6':
|
||||
resolution: {integrity: sha512-+3YTFehRcZ1haGel5DKYMUwmi5i6f2psyaPZlfkKU/cOXgkpwoG9/BEqPCnPjicKqqnksEpixVRkyHJ+5bjLVA==}
|
||||
@@ -550,6 +568,9 @@ packages:
|
||||
'@kevisual/query@0.0.30':
|
||||
resolution: {integrity: sha512-mDPEaLX9LdTRgi9anmWQ4EJ491umsASu/gs6K85J5nJqtUN/kfnZ3x5IouUr6aNbgAhrNLv/vTqpQTBsQhEYHQ==}
|
||||
|
||||
'@kevisual/query@0.0.31':
|
||||
resolution: {integrity: sha512-bBdepjmMICLpcj/a9fnn82/0CGGYUZiCV+usWsJZKAwVlZcnj+WtKmbgKT09KpP6g3jjYzYOaXHiNFB8N0bQAQ==}
|
||||
|
||||
'@kevisual/router@0.0.33':
|
||||
resolution: {integrity: sha512-9z7TkSzCIGbXn9SuHPBdZpGwHlAuwA8iN5jNAZBUvbEvBRkBxlrbdCSe9fBYiAHueLm2AceFNrW74uulOiAkqA==}
|
||||
|
||||
@@ -2736,10 +2757,10 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- typescript
|
||||
|
||||
'@kevisual/hot-api@0.0.2(dotenv@17.2.3)(supports-color@10.2.2)':
|
||||
'@kevisual/hot-api@0.0.3(dotenv@17.2.3)(supports-color@10.2.2)':
|
||||
dependencies:
|
||||
'@kevisual/ai': 0.0.16
|
||||
'@kevisual/query': 0.0.30
|
||||
'@kevisual/query': 0.0.31
|
||||
'@kevisual/router': 0.0.33(supports-color@10.2.2)
|
||||
'@kevisual/use-config': 1.0.21(dotenv@17.2.3)
|
||||
'@nut-tree-fork/nut-js': 4.2.6
|
||||
@@ -2771,14 +2792,16 @@ snapshots:
|
||||
|
||||
'@kevisual/permission@0.0.3': {}
|
||||
|
||||
'@kevisual/query-login@0.0.7(@kevisual/query@0.0.30)':
|
||||
'@kevisual/query-login@0.0.7(@kevisual/query@0.0.31)':
|
||||
dependencies:
|
||||
'@kevisual/cache': 0.0.3
|
||||
'@kevisual/query': 0.0.30
|
||||
'@kevisual/query': 0.0.31
|
||||
dotenv: 17.2.3
|
||||
|
||||
'@kevisual/query@0.0.30': {}
|
||||
|
||||
'@kevisual/query@0.0.31': {}
|
||||
|
||||
'@kevisual/router@0.0.33(supports-color@10.2.2)':
|
||||
dependencies:
|
||||
path-to-regexp: 8.3.0
|
||||
|
||||
Reference in New Issue
Block a user