Skip to content

Commit

Permalink
ci
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-cn committed Mar 2, 2024
1 parent a261c7d commit 0c00f55
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 177 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ yarn-error.log*
.DS_Store
.idea/
*.iml
/node_modules/
package-lock.json
/test/.*.env
/test/*.yaml
test/*.config.js
test/*.config.ts
/**/*/node_modules/
/**/*/lib/
/test/data
/test/data/

/pnpm-lock.yaml
2 changes: 1 addition & 1 deletion core/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default defineConfig((env)=>{
bots:[],
plugins:[
'commandParser',
env.mode===dev && 'hmr',
env.mode==='dev' && 'hmr',
'pluginManager',
'setup',
Expand Down
61 changes: 30 additions & 31 deletions core/src/worker.ts
Original file line number Diff line number Diff line change
@@ -1,56 +1,55 @@
import dotEnv from 'dotenv'
import {fork, ForkOptions} from "child_process";
import path from "path";
import dotEnv from 'dotenv';
import { fork, ForkOptions } from 'child_process';
import path from 'path';
import * as fs from 'fs';
import { deepMerge } from '@/utils';
interface Message {
type: "start" | "queue";
type: 'start' | 'queue';
body: any;
}

let buffer:any = null,timeStart: number;
const readEnv=(filename:string)=>{
if(fs.existsSync(filename)){
return dotEnv.config({path:filename}).parsed||{}
let buffer: any = null,
timeStart: number;
const readEnv = (filename: string) => {
if (fs.existsSync(filename)) {
return dotEnv.config({ path: filename }).parsed || {};
}
return {}
}
export function startAppWorker(config:string,mode: string) {
const commonEnv=readEnv(path.join(process.cwd(),'.env'))
const modeEnv=deepMerge(commonEnv,readEnv(path.join(process.cwd(),`.env.${mode}`)));
return {};
};
export function startAppWorker(config: string, mode: string) {
const commonEnv = readEnv(path.join(process.cwd(), '.env'));
const modeEnv = deepMerge(commonEnv, readEnv(path.join(process.cwd(), `.env.${mode}`)));
const forkOptions: ForkOptions = {
env: {
...process.env,
mode,
config,
CWD:path.resolve(__dirname,'../'),
...modeEnv
CWD: process.cwd(),
...modeEnv,
},
execArgv: ["-r", "jiti/register", "-r", "tsconfig-paths/register"],
stdio: "inherit",
execArgv: ['-r', 'jiti/register', '-r', 'tsconfig-paths/register'],
stdio: 'inherit',
};
const cp = fork(path.resolve(__dirname,"../start.js"), [
'-p tsconfig.json'
], forkOptions)
cp.stdout?.on("data", data => process.stdout.push(data));
cp.stderr?.on("data", data => process.stderr.push(data));
process.stdin?.on("data", data => cp.stdin?.write(data));
cp.on("message", (message: Message) => {
if (message.type === "start") {
const cp = fork(path.resolve(__dirname, '../start.js'), ['-p tsconfig.json'], forkOptions);
cp.stdout?.on('data', data => process.stdout.push(data));
cp.stderr?.on('data', data => process.stderr.push(data));
process.stdin?.on('data', data => cp.stdin?.write(data));
cp.on('message', (message: Message) => {
if (message.type === 'start') {
if (buffer) {
cp.send({type: "send", body: buffer, times: timeStart});
cp.send({ type: 'send', body: buffer, times: timeStart });
buffer = null;
}
} else if (message.type === "queue") {
} else if (message.type === 'queue') {
buffer = message.body;
}
});
cp.on("exit", code => {
if(!code) return
if (code!==51) {
cp.on('exit', code => {
if (!code) return;
if (code !== 51) {
process.exit(code);
}
timeStart = new Date().getTime();
startAppWorker(config,mode)
startAppWorker(config, mode);
});
}
21 changes: 0 additions & 21 deletions node_modules/.pnpm/husky@8.0.3/node_modules/husky/LICENSE

This file was deleted.

38 changes: 0 additions & 38 deletions node_modules/.pnpm/husky@8.0.3/node_modules/husky/README.md

This file was deleted.

36 changes: 0 additions & 36 deletions node_modules/.pnpm/husky@8.0.3/node_modules/husky/husky.sh

This file was deleted.

40 changes: 0 additions & 40 deletions node_modules/.pnpm/husky@8.0.3/node_modules/husky/package.json

This file was deleted.

17 changes: 9 additions & 8 deletions node_modules/.pnpm/lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion node_modules/husky

This file was deleted.

0 comments on commit 0c00f55

Please sign in to comment.