"feat: 增加助手应用配置管理功能与服务器守护进程支持"
This commit is contained in:
@@ -1,17 +1,26 @@
|
||||
// @ts-check
|
||||
// https://bun.sh/docs/bundler
|
||||
// @ts-ignore
|
||||
import path from 'node:path';
|
||||
import pkg from './package.json';
|
||||
import fs from 'node:fs';
|
||||
// bun run src/index.ts --
|
||||
import { fileURLToPath } from 'node:url';
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
/**
|
||||
*
|
||||
* @param {string} p
|
||||
* @returns
|
||||
*/
|
||||
export const w = (p) => path.join(__dirname, p);
|
||||
await Bun.build({
|
||||
target: 'node',
|
||||
format: 'esm',
|
||||
entrypoints: ['./src/index.ts'],
|
||||
outdir: './dist',
|
||||
entrypoints: [w('./src/index.ts')],
|
||||
outdir: w('./dist'),
|
||||
naming: {
|
||||
entry: 'assistant.mjs',
|
||||
},
|
||||
|
||||
external: ['pm2'],
|
||||
define: {
|
||||
ENVISION_VERSION: JSON.stringify(pkg.version),
|
||||
},
|
||||
@@ -21,13 +30,33 @@ await Bun.build({
|
||||
await Bun.build({
|
||||
target: 'node',
|
||||
format: 'esm',
|
||||
entrypoints: ['./src/server.ts'],
|
||||
outdir: './dist',
|
||||
entrypoints: [w('./src/server.ts')],
|
||||
outdir: w('./dist'),
|
||||
naming: {
|
||||
entry: 'assistan-server.mjs',
|
||||
},
|
||||
define: {
|
||||
ENVISION_VERSION: JSON.stringify(pkg.version),
|
||||
entry: 'assistant-server.mjs',
|
||||
},
|
||||
external: ['pm2'],
|
||||
env: 'ENVISION_*',
|
||||
});
|
||||
|
||||
export const copyFileToEnvision = async () => {
|
||||
const src = ['dist', 'bin'].map((dir) => {
|
||||
return { absolute: path.join(__dirname, dir), name: dir };
|
||||
});
|
||||
const dest = path.join(__dirname, '..');
|
||||
for (const dir of src) {
|
||||
const files = fs.readdirSync(dir.absolute);
|
||||
for (const file of files) {
|
||||
const srcFile = path.join(dir.absolute, file);
|
||||
const destFile = path.join(dest, dir.name, file);
|
||||
try {
|
||||
fs.copyFileSync(srcFile, destFile);
|
||||
} catch (err) {
|
||||
console.error('Error copying files: origin: ', srcFile, 'dest: ', destFile);
|
||||
console.error('Error copying files:', err);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
await copyFileToEnvision();
|
||||
|
||||
Reference in New Issue
Block a user