node-karin 0.12.2-5.pr.206.ccdb3c6 → 0.12.2-5.pr.206.dad353f
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/dist/cli/index.cjs +178 -54
- package/dist/cli/index.js +179 -56
- package/dist/index.js +3 -3
- package/package.json +13 -7
package/dist/cli/index.cjs
CHANGED
|
@@ -16,7 +16,7 @@ var fs2__default = /*#__PURE__*/_interopDefault(fs2);
|
|
|
16
16
|
var path2__default = /*#__PURE__*/_interopDefault(path2);
|
|
17
17
|
var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var execSync = (cmd, options = {}) => {
|
|
20
20
|
try {
|
|
21
21
|
const result = child_process.execSync(cmd, options);
|
|
22
22
|
return { status: true, error: null, stdout: result.toString(), stderr: "" };
|
|
@@ -24,6 +24,14 @@ var exec = (cmd, options = {}) => {
|
|
|
24
24
|
return { status: false, error, stdout: "", stderr: "" };
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
+
var exec = (cmd, options = {}) => {
|
|
28
|
+
return new Promise((resolve) => {
|
|
29
|
+
child_process.exec(cmd, options, (error, stdout, stderr) => {
|
|
30
|
+
const status = !error;
|
|
31
|
+
resolve({ status, error, stdout, stderr });
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
};
|
|
27
35
|
var pm2Dir = path2__default.default.join(process.cwd(), "./@karinjs/config/pm2.json");
|
|
28
36
|
var start = () => {
|
|
29
37
|
if (!fs2__default.default.existsSync(pm2Dir)) {
|
|
@@ -32,7 +40,7 @@ var start = () => {
|
|
|
32
40
|
process.exit(1);
|
|
33
41
|
}
|
|
34
42
|
console.log("[pm2] \u542F\u52A8\u4E2D...");
|
|
35
|
-
const { error } =
|
|
43
|
+
const { error } = execSync(`pm2 start ${pm2Dir}`, { cwd: process.cwd() });
|
|
36
44
|
if (error) {
|
|
37
45
|
console.log("[pm2] \u542F\u52A8\u5931\u8D25");
|
|
38
46
|
console.log(error);
|
|
@@ -69,7 +77,7 @@ var stop = () => {
|
|
|
69
77
|
process.exit(1);
|
|
70
78
|
}
|
|
71
79
|
const data = JSON.parse(fs2__default.default.readFileSync(pm2Dir, "utf-8"));
|
|
72
|
-
|
|
80
|
+
execSync(`pm2 stop ${data.name}`, { cwd: process.cwd() });
|
|
73
81
|
console.log("[pm2] \u505C\u6B62\u6210\u529F");
|
|
74
82
|
process.exit(0);
|
|
75
83
|
};
|
|
@@ -122,9 +130,9 @@ var createPnpmFile = (dir2) => {
|
|
|
122
130
|
fs2__default.default.writeFileSync(pnpmfile, content);
|
|
123
131
|
};
|
|
124
132
|
var shouldSkipNpmrc = () => {
|
|
125
|
-
const { stdout } =
|
|
133
|
+
const { stdout } = execSync("npm config get registry");
|
|
126
134
|
if (stdout.includes("registry.npmjs.org")) return true;
|
|
127
|
-
const { stdout: proxy } =
|
|
135
|
+
const { stdout: proxy } = execSync("npm config get proxy");
|
|
128
136
|
return !!proxy;
|
|
129
137
|
};
|
|
130
138
|
var createOrUpdateNpmrc = (dir2) => {
|
|
@@ -267,11 +275,24 @@ var createConfig = () => {
|
|
|
267
275
|
};
|
|
268
276
|
var modifyPackageJson = () => {
|
|
269
277
|
const pkg = fs2__default.default.readFileSync(path2__default.default.join(dir, "package.json"), "utf-8");
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
278
|
+
const data = JSON.parse(pkg);
|
|
279
|
+
data.type = "module";
|
|
280
|
+
data.scripts.karin = "karin";
|
|
281
|
+
const list = [
|
|
282
|
+
"app",
|
|
283
|
+
"start",
|
|
284
|
+
"pm2",
|
|
285
|
+
"stop",
|
|
286
|
+
"rs",
|
|
287
|
+
"log",
|
|
288
|
+
"up",
|
|
289
|
+
"init"
|
|
290
|
+
];
|
|
291
|
+
list.forEach((v) => {
|
|
292
|
+
data.scripts[v] = `karin ${v}`;
|
|
293
|
+
});
|
|
294
|
+
fs2__default.default.writeFileSync(path2__default.default.join(dir, "package.json"), JSON.stringify(data, null, 2));
|
|
295
|
+
return data;
|
|
275
296
|
};
|
|
276
297
|
var init = async () => {
|
|
277
298
|
createDir();
|
|
@@ -280,21 +301,31 @@ var init = async () => {
|
|
|
280
301
|
modifyPackageJson();
|
|
281
302
|
process.exit(0);
|
|
282
303
|
};
|
|
283
|
-
var
|
|
304
|
+
var parseEnvFiles = (env) => {
|
|
305
|
+
if (!env) return [".env"];
|
|
306
|
+
return env.split(",").map((file) => file.trim());
|
|
307
|
+
};
|
|
308
|
+
var loadEnv = (env) => {
|
|
284
309
|
const dir2 = process.cwd();
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
310
|
+
const files = parseEnvFiles(env);
|
|
311
|
+
if (!files.includes(".env")) {
|
|
312
|
+
files.unshift(".env");
|
|
313
|
+
}
|
|
314
|
+
files.forEach((file) => {
|
|
315
|
+
if (!fs2__default.default.existsSync(`${dir2}/${file}`)) {
|
|
316
|
+
if (file === ".env") {
|
|
317
|
+
console.error(`\u672A\u627E\u5230${file}\u6587\u4EF6\uFF0C\u8BF7\u4F7F\u7528 pnpm init \u8FDB\u884C\u521D\u59CB\u5316\u9879\u76EE`);
|
|
290
318
|
} else {
|
|
291
|
-
console.error(`\u672A\u627E\u5230${
|
|
319
|
+
console.error(`\u672A\u627E\u5230${file}\u6587\u4EF6\uFF0C\u8BF7\u5C06\u5176\u653E\u7F6E\u5728\u9879\u76EE\u6839\u76EE\u5F55`);
|
|
292
320
|
}
|
|
293
321
|
process.exit(1);
|
|
294
322
|
}
|
|
295
323
|
});
|
|
296
|
-
const
|
|
297
|
-
dotenv__default.default.config({ path:
|
|
324
|
+
const paths = files.map((file) => `${dir2}/${file}`);
|
|
325
|
+
dotenv__default.default.config({ path: paths, override: true });
|
|
326
|
+
};
|
|
327
|
+
var start2 = async (env) => {
|
|
328
|
+
loadEnv(env);
|
|
298
329
|
const index = "../root.js";
|
|
299
330
|
const { karinMain } = await import(index);
|
|
300
331
|
const child = child_process.fork(karinMain);
|
|
@@ -307,10 +338,62 @@ var start2 = async (env = ".env") => {
|
|
|
307
338
|
});
|
|
308
339
|
child.on("exit", (code) => process.exit(code));
|
|
309
340
|
};
|
|
310
|
-
var
|
|
341
|
+
var dev = async (env) => {
|
|
342
|
+
loadEnv(env);
|
|
343
|
+
const index = "../root.js";
|
|
344
|
+
process.env.NODE_ENV = "development";
|
|
345
|
+
const { karinMain } = await import(index);
|
|
346
|
+
await import(karinMain);
|
|
347
|
+
};
|
|
348
|
+
var tsStart = async (env) => {
|
|
349
|
+
loadEnv(env);
|
|
350
|
+
process.env.NODE_ENV = "development";
|
|
351
|
+
const index = "../root.js";
|
|
352
|
+
const { karinMain } = await import(index);
|
|
353
|
+
const nodeOptions = process.env.NODE_OPTIONS ? `${process.env.NODE_OPTIONS} --import tsx` : "--import tsx";
|
|
354
|
+
const child = child_process.spawn("node", [karinMain], {
|
|
355
|
+
env: {
|
|
356
|
+
...process.env,
|
|
357
|
+
NODE_OPTIONS: nodeOptions,
|
|
358
|
+
RUNTIME: "tsx"
|
|
359
|
+
},
|
|
360
|
+
stdio: "inherit"
|
|
361
|
+
});
|
|
362
|
+
child.on("exit", (code) => process.exit(code ?? 0));
|
|
363
|
+
};
|
|
364
|
+
var tsWatch = async (options) => {
|
|
365
|
+
loadEnv(options.env);
|
|
366
|
+
process.env.NODE_ENV = "development";
|
|
367
|
+
const index = "../root.js";
|
|
368
|
+
const { karinMain } = await import(index);
|
|
369
|
+
const args = ["tsx", "watch"];
|
|
370
|
+
if (options.include) {
|
|
371
|
+
options.include.split(",").forEach((pattern) => {
|
|
372
|
+
args.push("--include", pattern.trim());
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
if (options.exclude) {
|
|
376
|
+
options.exclude.split(",").forEach((pattern) => {
|
|
377
|
+
args.push("--exclude", pattern.trim());
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
if (!options.clearScreen) {
|
|
381
|
+
args.push("--clear-screen=false");
|
|
382
|
+
}
|
|
383
|
+
args.push(karinMain);
|
|
384
|
+
const child = child_process.spawn("npx", args, {
|
|
385
|
+
env: {
|
|
386
|
+
...process.env,
|
|
387
|
+
RUNTIME: "tsx"
|
|
388
|
+
},
|
|
389
|
+
stdio: "inherit"
|
|
390
|
+
});
|
|
391
|
+
child.on("exit", (code) => process.exit(code ?? 0));
|
|
392
|
+
};
|
|
393
|
+
var checkGitInstalled = async () => {
|
|
311
394
|
try {
|
|
312
|
-
|
|
313
|
-
return
|
|
395
|
+
const { status } = await exec("git --version");
|
|
396
|
+
return status;
|
|
314
397
|
} catch {
|
|
315
398
|
return false;
|
|
316
399
|
}
|
|
@@ -320,93 +403,134 @@ var updateDependencies = async (packagePath) => {
|
|
|
320
403
|
const packageJson = JSON.parse(fs2.readFileSync(packagePath, "utf-8"));
|
|
321
404
|
const dependencies = packageJson.dependencies || {};
|
|
322
405
|
const packagesToUpdate = [];
|
|
323
|
-
|
|
406
|
+
const checkVersionTasks = Object.entries(dependencies).map(async ([pkg, version]) => {
|
|
324
407
|
if (pkg.startsWith("@types/")) {
|
|
325
|
-
|
|
408
|
+
return;
|
|
326
409
|
}
|
|
327
410
|
try {
|
|
328
|
-
const
|
|
411
|
+
const { stdout: pkgInfoStr } = await exec(`pnpm view ${pkg} --json`);
|
|
412
|
+
const pkgInfo = JSON.parse(pkgInfoStr.trim());
|
|
413
|
+
if (!pkgInfo.karin) return;
|
|
329
414
|
const currentVersion = version.replace(/[\^~]/g, "");
|
|
330
|
-
|
|
331
|
-
|
|
415
|
+
const { stdout: distTagsStr } = await exec(`pnpm view ${pkg} dist-tags --json`);
|
|
416
|
+
const distTags = JSON.parse(distTagsStr.trim());
|
|
417
|
+
const isPreRelease = /[-+]/.test(currentVersion);
|
|
418
|
+
const latestVersion = distTags.latest;
|
|
419
|
+
console.log(`[npm] ${pkg}:`);
|
|
420
|
+
console.log(` \u5F53\u524D\u7248\u672C: ${currentVersion}${isPreRelease ? " (\u9884\u53D1\u5E03\u7248\u672C)" : ""}`);
|
|
421
|
+
console.log(` \u6700\u65B0\u7248\u672C: ${latestVersion}`);
|
|
422
|
+
if (isPreRelease || currentVersion !== latestVersion) {
|
|
423
|
+
console.log(`[npm] \u53D1\u73B0\u65B0\u7248\u672C ${pkg}: ${currentVersion} -> ${latestVersion}`);
|
|
332
424
|
packagesToUpdate.push(`${pkg}@latest`);
|
|
333
425
|
} else {
|
|
334
|
-
console.log(
|
|
426
|
+
console.log(`[npm] ${pkg} \u5DF2\u7ECF\u662F\u6700\u65B0\u7248\u672C`);
|
|
335
427
|
}
|
|
336
428
|
} catch (error) {
|
|
337
|
-
console.error(
|
|
429
|
+
console.error(`[npm] \u68C0\u67E5 ${pkg} \u7248\u672C\u5931\u8D25:`, error);
|
|
338
430
|
}
|
|
339
|
-
}
|
|
431
|
+
});
|
|
432
|
+
await Promise.all(checkVersionTasks);
|
|
340
433
|
if (packagesToUpdate.length > 0) {
|
|
341
|
-
console.log("\
|
|
434
|
+
console.log("[npm] \u5F00\u59CB\u66F4\u65B0\u4EE5\u4E0B\u5305:\n", packagesToUpdate.join("\n"));
|
|
342
435
|
try {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
436
|
+
const { status, error } = await exec(`pnpm update ${packagesToUpdate.join(" ")}`);
|
|
437
|
+
if (status) {
|
|
438
|
+
console.log("[npm] \u6240\u6709\u63D2\u4EF6\u66F4\u65B0\u5B8C\u6210");
|
|
439
|
+
} else {
|
|
440
|
+
console.error("[npm] \u6279\u91CF\u66F4\u65B0\u5931\u8D25:", error);
|
|
441
|
+
}
|
|
347
442
|
} catch (error) {
|
|
348
|
-
console.error("\u6279\u91CF\u66F4\u65B0\u5931\u8D25:", error);
|
|
443
|
+
console.error("[npm] \u6279\u91CF\u66F4\u65B0\u5931\u8D25:", error);
|
|
349
444
|
}
|
|
350
445
|
} else {
|
|
351
|
-
console.log("\
|
|
446
|
+
console.log("[npm] \u6240\u6709\u63D2\u4EF6\u90FD\u5DF2\u7ECF\u662F\u6700\u65B0\u7248\u672C");
|
|
352
447
|
}
|
|
353
448
|
} catch (error) {
|
|
354
|
-
console.error("\u66F4\u65B0\u4F9D\u8D56\u5931\u8D25:", error);
|
|
449
|
+
console.error("[npm] \u66F4\u65B0\u4F9D\u8D56\u5931\u8D25:", error);
|
|
355
450
|
}
|
|
356
451
|
};
|
|
357
452
|
var updatePlugins = async (pluginsPath) => {
|
|
358
|
-
if (!checkGitInstalled()) {
|
|
359
|
-
console.error("\u8BF7\u5148\u5B89\u88C5git");
|
|
453
|
+
if (!await checkGitInstalled()) {
|
|
454
|
+
console.error("[git] \u8BF7\u5148\u5B89\u88C5git");
|
|
360
455
|
return;
|
|
361
456
|
}
|
|
362
457
|
if (!fs2.existsSync(pluginsPath)) {
|
|
363
|
-
console.error("plugins\u76EE\u5F55\u4E0D\u5B58\u5728");
|
|
458
|
+
console.error("[git] plugins\u76EE\u5F55\u4E0D\u5B58\u5728");
|
|
364
459
|
return;
|
|
365
460
|
}
|
|
366
461
|
const isDirectory = (await promises.stat(pluginsPath)).isDirectory();
|
|
367
462
|
if (!isDirectory) {
|
|
368
|
-
console.error("plugins\u8DEF\u5F84\u4E0D\u662F\u4E00\u4E2A\u76EE\u5F55");
|
|
463
|
+
console.error("[git] plugins\u8DEF\u5F84\u4E0D\u662F\u4E00\u4E2A\u76EE\u5F55");
|
|
369
464
|
return;
|
|
370
465
|
}
|
|
371
466
|
const dirs = await promises.readdir(pluginsPath);
|
|
372
|
-
|
|
467
|
+
const updateTasks = dirs.map(async (dir2) => {
|
|
373
468
|
const pluginPath = path2.join(pluginsPath, dir2);
|
|
374
469
|
const gitPath = path2.join(pluginPath, ".git");
|
|
375
470
|
const packageJsonPath = path2.join(pluginPath, "package.json");
|
|
376
471
|
if (!dir2.startsWith("karin-plugin-") || !(await promises.stat(pluginPath)).isDirectory()) {
|
|
377
|
-
|
|
472
|
+
return;
|
|
378
473
|
}
|
|
379
474
|
if (!fs2.existsSync(gitPath)) {
|
|
380
|
-
console.log(
|
|
381
|
-
|
|
475
|
+
console.log(`[git] ${dir2} \u4E0D\u662Fgit\u4ED3\u5E93\uFF0C\u8DF3\u8FC7`);
|
|
476
|
+
return;
|
|
382
477
|
}
|
|
383
478
|
try {
|
|
384
479
|
const packageJson = JSON.parse(fs2.readFileSync(packageJsonPath, "utf-8"));
|
|
385
480
|
if (!packageJson.karin) {
|
|
386
|
-
console.log(
|
|
387
|
-
|
|
481
|
+
console.log(`[git] ${dir2} \u7684package.json\u4E2D\u6CA1\u6709karin\u5B57\u6BB5\uFF0C\u8DF3\u8FC7`);
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
console.log(`[git] \u6B63\u5728\u66F4\u65B0 ${dir2}...`);
|
|
485
|
+
const { status, error } = await exec("git pull", { cwd: pluginPath });
|
|
486
|
+
if (!status) {
|
|
487
|
+
console.error(`[git] \u66F4\u65B0 ${dir2} \u5931\u8D25:`, error);
|
|
388
488
|
}
|
|
389
|
-
console.log(`\u6B63\u5728\u66F4\u65B0 ${dir2}...`);
|
|
390
|
-
child_process.execSync("git pull", { cwd: pluginPath, stdio: "inherit" });
|
|
391
489
|
} catch (error) {
|
|
392
|
-
console.error(
|
|
490
|
+
console.error(`[git] \u66F4\u65B0 ${dir2} \u5931\u8D25:`, error);
|
|
393
491
|
}
|
|
394
|
-
}
|
|
492
|
+
});
|
|
493
|
+
await Promise.all(updateTasks);
|
|
395
494
|
};
|
|
396
495
|
var updateAll = async () => {
|
|
397
496
|
try {
|
|
497
|
+
console.log("[all] \u5F00\u59CB\u6267\u884C\u66F4\u65B0\u4EFB\u52A1\n");
|
|
398
498
|
await Promise.all([updateDependencies("./package.json"), updatePlugins("./plugins")]);
|
|
499
|
+
console.log("\n[all] \u66F4\u65B0\u4EFB\u52A1\u6267\u884C\u5B8C\u6210");
|
|
399
500
|
} finally {
|
|
400
501
|
process.exit(0);
|
|
401
502
|
}
|
|
402
503
|
};
|
|
504
|
+
var _a;
|
|
505
|
+
if (!((_a = process.argv) == null ? undefined : _a[2])) process.argv.push("-h");
|
|
506
|
+
var addEnvOption = (command) => {
|
|
507
|
+
return command.option("-e, --env <files>", "\u6307\u5B9A\u73AF\u5883\u53D8\u91CF\u6587\u4EF6\uFF0C\u591A\u4E2A\u6587\u4EF6\u7528\u9017\u53F7\u5206\u9694");
|
|
508
|
+
};
|
|
403
509
|
commander.program.version(process.env.npm_package_version, "-v, --version", "\u663E\u793A\u7248\u672C\u53F7");
|
|
404
|
-
commander.program.command(".").description("\u524D\u53F0\u542F\u52A8").action(() => start2());
|
|
405
|
-
commander.program.command("start").description("\u524D\u53F0\u542F\u52A8").action(() => start2());
|
|
406
510
|
commander.program.command("pm2").description("\u540E\u53F0\u8FD0\u884C").action(pm2.start);
|
|
407
511
|
commander.program.command("stop").description("\u505C\u6B62\u540E\u53F0\u8FD0\u884C").action(pm2.stop);
|
|
408
512
|
commander.program.command("rs").description("\u91CD\u542Fpm2\u670D\u52A1").action(pm2.restart);
|
|
409
513
|
commander.program.command("log").description("\u67E5\u770B\u65E5\u5FD7").action(pm2.log);
|
|
410
514
|
commander.program.command("up").description("\u66F4\u65B0\u63D2\u4EF6").action(updateAll);
|
|
411
515
|
commander.program.command("init").description("\u521D\u59CB\u5316\u9879\u76EE").action(init);
|
|
516
|
+
addEnvOption(commander.program.command("app").description("\u524D\u53F0\u542F\u52A8")).action((options) => start2(options.env));
|
|
517
|
+
addEnvOption(commander.program.command("start").description("\u524D\u53F0\u542F\u52A8")).action((options) => start2(options.env));
|
|
518
|
+
addEnvOption(commander.program.command("dev").description("JavaScript\u5F00\u53D1\u6A21\u5F0F")).action((options) => dev(options.env));
|
|
519
|
+
addEnvOption(
|
|
520
|
+
commander.program.command("ts").description("TypeScript\u5F00\u53D1\u6A21\u5F0F").option("-e, --env <files>", "\u6307\u5B9A\u73AF\u5883\u53D8\u91CF\u6587\u4EF6\uFF0C\u591A\u4E2A\u6587\u4EF6\u7528\u9017\u53F7\u5206\u9694\uFF0C\u4F8B\u5982\uFF1A.env.dev,.env.local").addHelpText("after", `
|
|
521
|
+
\u793A\u4F8B:
|
|
522
|
+
$ karin ts # \u4F7F\u7528\u9ED8\u8BA4 .env \u6587\u4EF6\u542F\u52A8
|
|
523
|
+
$ karin ts -e .env.dev # \u4F7F\u7528\u6307\u5B9A\u7684\u73AF\u5883\u53D8\u91CF\u6587\u4EF6\u542F\u52A8
|
|
524
|
+
$ karin ts -e .env.dev,.env.local # \u4F7F\u7528\u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u6587\u4EF6\u542F\u52A8
|
|
525
|
+
`)
|
|
526
|
+
).action((options) => tsStart(options.env));
|
|
527
|
+
addEnvOption(
|
|
528
|
+
commander.program.command("watch").description("TypeScript\u76D1\u89C6\u6A21\u5F0F").option("--include <patterns>", "\u6DFB\u52A0\u8981\u76D1\u89C6\u7684\u6587\u4EF6/\u76EE\u5F55\uFF0C\u591A\u4E2A\u7528\u9017\u53F7\u5206\u9694").option("--exclude <patterns>", "\u6392\u9664\u8981\u76D1\u89C6\u7684\u6587\u4EF6/\u76EE\u5F55\uFF0C\u591A\u4E2A\u7528\u9017\u53F7\u5206\u9694").option("--clear-screen", "\u91CD\u65B0\u8FD0\u884C\u65F6\u662F\u5426\u6E05\u5C4F", true).addHelpText("after", `
|
|
529
|
+
\u793A\u4F8B:
|
|
530
|
+
$ karin watch # \u9ED8\u8BA4\u76D1\u89C6\u6A21\u5F0F
|
|
531
|
+
$ karin watch --include src # \u76D1\u89C6 src \u76EE\u5F55
|
|
532
|
+
$ karin watch --exclude node_modules,dist # \u6392\u9664\u6307\u5B9A\u76EE\u5F55
|
|
533
|
+
$ karin watch --no-clear-screen # \u7981\u7528\u6E05\u5C4F
|
|
534
|
+
`)
|
|
535
|
+
).action((options) => tsWatch(options));
|
|
412
536
|
commander.program.parse(process.argv);
|
package/dist/cli/index.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import fs2 from 'node:fs';
|
|
3
3
|
import path2 from 'node:path';
|
|
4
|
-
import { fork, spawn, execSync as execSync$1 } from 'node:child_process';
|
|
4
|
+
import { fork, spawn, execSync as execSync$1, exec as exec$1 } from 'node:child_process';
|
|
5
5
|
import { fileURLToPath, URL } from 'node:url';
|
|
6
6
|
import dotenv from 'dotenv';
|
|
7
7
|
import { join } from 'path';
|
|
8
|
-
import { execSync } from 'child_process';
|
|
9
8
|
import { readFileSync, existsSync } from 'fs';
|
|
10
9
|
import { stat, readdir } from 'fs/promises';
|
|
11
10
|
import { program } from 'commander';
|
|
12
11
|
|
|
13
|
-
var
|
|
12
|
+
var execSync = (cmd, options = {}) => {
|
|
14
13
|
try {
|
|
15
14
|
const result = execSync$1(cmd, options);
|
|
16
15
|
return { status: true, error: null, stdout: result.toString(), stderr: "" };
|
|
@@ -18,6 +17,14 @@ var exec = (cmd, options = {}) => {
|
|
|
18
17
|
return { status: false, error, stdout: "", stderr: "" };
|
|
19
18
|
}
|
|
20
19
|
};
|
|
20
|
+
var exec = (cmd, options = {}) => {
|
|
21
|
+
return new Promise((resolve) => {
|
|
22
|
+
exec$1(cmd, options, (error, stdout, stderr) => {
|
|
23
|
+
const status = !error;
|
|
24
|
+
resolve({ status, error, stdout, stderr });
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
};
|
|
21
28
|
var pm2Dir = path2.join(process.cwd(), "./@karinjs/config/pm2.json");
|
|
22
29
|
var start = () => {
|
|
23
30
|
if (!fs2.existsSync(pm2Dir)) {
|
|
@@ -26,7 +33,7 @@ var start = () => {
|
|
|
26
33
|
process.exit(1);
|
|
27
34
|
}
|
|
28
35
|
console.log("[pm2] \u542F\u52A8\u4E2D...");
|
|
29
|
-
const { error } =
|
|
36
|
+
const { error } = execSync(`pm2 start ${pm2Dir}`, { cwd: process.cwd() });
|
|
30
37
|
if (error) {
|
|
31
38
|
console.log("[pm2] \u542F\u52A8\u5931\u8D25");
|
|
32
39
|
console.log(error);
|
|
@@ -63,7 +70,7 @@ var stop = () => {
|
|
|
63
70
|
process.exit(1);
|
|
64
71
|
}
|
|
65
72
|
const data = JSON.parse(fs2.readFileSync(pm2Dir, "utf-8"));
|
|
66
|
-
|
|
73
|
+
execSync(`pm2 stop ${data.name}`, { cwd: process.cwd() });
|
|
67
74
|
console.log("[pm2] \u505C\u6B62\u6210\u529F");
|
|
68
75
|
process.exit(0);
|
|
69
76
|
};
|
|
@@ -116,9 +123,9 @@ var createPnpmFile = (dir2) => {
|
|
|
116
123
|
fs2.writeFileSync(pnpmfile, content);
|
|
117
124
|
};
|
|
118
125
|
var shouldSkipNpmrc = () => {
|
|
119
|
-
const { stdout } =
|
|
126
|
+
const { stdout } = execSync("npm config get registry");
|
|
120
127
|
if (stdout.includes("registry.npmjs.org")) return true;
|
|
121
|
-
const { stdout: proxy } =
|
|
128
|
+
const { stdout: proxy } = execSync("npm config get proxy");
|
|
122
129
|
return !!proxy;
|
|
123
130
|
};
|
|
124
131
|
var createOrUpdateNpmrc = (dir2) => {
|
|
@@ -261,11 +268,24 @@ var createConfig = () => {
|
|
|
261
268
|
};
|
|
262
269
|
var modifyPackageJson = () => {
|
|
263
270
|
const pkg = fs2.readFileSync(path2.join(dir, "package.json"), "utf-8");
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
271
|
+
const data = JSON.parse(pkg);
|
|
272
|
+
data.type = "module";
|
|
273
|
+
data.scripts.karin = "karin";
|
|
274
|
+
const list = [
|
|
275
|
+
"app",
|
|
276
|
+
"start",
|
|
277
|
+
"pm2",
|
|
278
|
+
"stop",
|
|
279
|
+
"rs",
|
|
280
|
+
"log",
|
|
281
|
+
"up",
|
|
282
|
+
"init"
|
|
283
|
+
];
|
|
284
|
+
list.forEach((v) => {
|
|
285
|
+
data.scripts[v] = `karin ${v}`;
|
|
286
|
+
});
|
|
287
|
+
fs2.writeFileSync(path2.join(dir, "package.json"), JSON.stringify(data, null, 2));
|
|
288
|
+
return data;
|
|
269
289
|
};
|
|
270
290
|
var init = async () => {
|
|
271
291
|
createDir();
|
|
@@ -274,21 +294,31 @@ var init = async () => {
|
|
|
274
294
|
modifyPackageJson();
|
|
275
295
|
process.exit(0);
|
|
276
296
|
};
|
|
277
|
-
var
|
|
297
|
+
var parseEnvFiles = (env) => {
|
|
298
|
+
if (!env) return [".env"];
|
|
299
|
+
return env.split(",").map((file) => file.trim());
|
|
300
|
+
};
|
|
301
|
+
var loadEnv = (env) => {
|
|
278
302
|
const dir2 = process.cwd();
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
303
|
+
const files = parseEnvFiles(env);
|
|
304
|
+
if (!files.includes(".env")) {
|
|
305
|
+
files.unshift(".env");
|
|
306
|
+
}
|
|
307
|
+
files.forEach((file) => {
|
|
308
|
+
if (!fs2.existsSync(`${dir2}/${file}`)) {
|
|
309
|
+
if (file === ".env") {
|
|
310
|
+
console.error(`\u672A\u627E\u5230${file}\u6587\u4EF6\uFF0C\u8BF7\u4F7F\u7528 pnpm init \u8FDB\u884C\u521D\u59CB\u5316\u9879\u76EE`);
|
|
284
311
|
} else {
|
|
285
|
-
console.error(`\u672A\u627E\u5230${
|
|
312
|
+
console.error(`\u672A\u627E\u5230${file}\u6587\u4EF6\uFF0C\u8BF7\u5C06\u5176\u653E\u7F6E\u5728\u9879\u76EE\u6839\u76EE\u5F55`);
|
|
286
313
|
}
|
|
287
314
|
process.exit(1);
|
|
288
315
|
}
|
|
289
316
|
});
|
|
290
|
-
const
|
|
291
|
-
dotenv.config({ path:
|
|
317
|
+
const paths = files.map((file) => `${dir2}/${file}`);
|
|
318
|
+
dotenv.config({ path: paths, override: true });
|
|
319
|
+
};
|
|
320
|
+
var start2 = async (env) => {
|
|
321
|
+
loadEnv(env);
|
|
292
322
|
const index = "../root.js";
|
|
293
323
|
const { karinMain } = await import(index);
|
|
294
324
|
const child = fork(karinMain);
|
|
@@ -301,10 +331,62 @@ var start2 = async (env = ".env") => {
|
|
|
301
331
|
});
|
|
302
332
|
child.on("exit", (code) => process.exit(code));
|
|
303
333
|
};
|
|
304
|
-
var
|
|
334
|
+
var dev = async (env) => {
|
|
335
|
+
loadEnv(env);
|
|
336
|
+
const index = "../root.js";
|
|
337
|
+
process.env.NODE_ENV = "development";
|
|
338
|
+
const { karinMain } = await import(index);
|
|
339
|
+
await import(karinMain);
|
|
340
|
+
};
|
|
341
|
+
var tsStart = async (env) => {
|
|
342
|
+
loadEnv(env);
|
|
343
|
+
process.env.NODE_ENV = "development";
|
|
344
|
+
const index = "../root.js";
|
|
345
|
+
const { karinMain } = await import(index);
|
|
346
|
+
const nodeOptions = process.env.NODE_OPTIONS ? `${process.env.NODE_OPTIONS} --import tsx` : "--import tsx";
|
|
347
|
+
const child = spawn("node", [karinMain], {
|
|
348
|
+
env: {
|
|
349
|
+
...process.env,
|
|
350
|
+
NODE_OPTIONS: nodeOptions,
|
|
351
|
+
RUNTIME: "tsx"
|
|
352
|
+
},
|
|
353
|
+
stdio: "inherit"
|
|
354
|
+
});
|
|
355
|
+
child.on("exit", (code) => process.exit(code ?? 0));
|
|
356
|
+
};
|
|
357
|
+
var tsWatch = async (options) => {
|
|
358
|
+
loadEnv(options.env);
|
|
359
|
+
process.env.NODE_ENV = "development";
|
|
360
|
+
const index = "../root.js";
|
|
361
|
+
const { karinMain } = await import(index);
|
|
362
|
+
const args = ["tsx", "watch"];
|
|
363
|
+
if (options.include) {
|
|
364
|
+
options.include.split(",").forEach((pattern) => {
|
|
365
|
+
args.push("--include", pattern.trim());
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
if (options.exclude) {
|
|
369
|
+
options.exclude.split(",").forEach((pattern) => {
|
|
370
|
+
args.push("--exclude", pattern.trim());
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
if (!options.clearScreen) {
|
|
374
|
+
args.push("--clear-screen=false");
|
|
375
|
+
}
|
|
376
|
+
args.push(karinMain);
|
|
377
|
+
const child = spawn("npx", args, {
|
|
378
|
+
env: {
|
|
379
|
+
...process.env,
|
|
380
|
+
RUNTIME: "tsx"
|
|
381
|
+
},
|
|
382
|
+
stdio: "inherit"
|
|
383
|
+
});
|
|
384
|
+
child.on("exit", (code) => process.exit(code ?? 0));
|
|
385
|
+
};
|
|
386
|
+
var checkGitInstalled = async () => {
|
|
305
387
|
try {
|
|
306
|
-
|
|
307
|
-
return
|
|
388
|
+
const { status } = await exec("git --version");
|
|
389
|
+
return status;
|
|
308
390
|
} catch {
|
|
309
391
|
return false;
|
|
310
392
|
}
|
|
@@ -314,93 +396,134 @@ var updateDependencies = async (packagePath) => {
|
|
|
314
396
|
const packageJson = JSON.parse(readFileSync(packagePath, "utf-8"));
|
|
315
397
|
const dependencies = packageJson.dependencies || {};
|
|
316
398
|
const packagesToUpdate = [];
|
|
317
|
-
|
|
399
|
+
const checkVersionTasks = Object.entries(dependencies).map(async ([pkg, version]) => {
|
|
318
400
|
if (pkg.startsWith("@types/")) {
|
|
319
|
-
|
|
401
|
+
return;
|
|
320
402
|
}
|
|
321
403
|
try {
|
|
322
|
-
const
|
|
404
|
+
const { stdout: pkgInfoStr } = await exec(`pnpm view ${pkg} --json`);
|
|
405
|
+
const pkgInfo = JSON.parse(pkgInfoStr.trim());
|
|
406
|
+
if (!pkgInfo.karin) return;
|
|
323
407
|
const currentVersion = version.replace(/[\^~]/g, "");
|
|
324
|
-
|
|
325
|
-
|
|
408
|
+
const { stdout: distTagsStr } = await exec(`pnpm view ${pkg} dist-tags --json`);
|
|
409
|
+
const distTags = JSON.parse(distTagsStr.trim());
|
|
410
|
+
const isPreRelease = /[-+]/.test(currentVersion);
|
|
411
|
+
const latestVersion = distTags.latest;
|
|
412
|
+
console.log(`[npm] ${pkg}:`);
|
|
413
|
+
console.log(` \u5F53\u524D\u7248\u672C: ${currentVersion}${isPreRelease ? " (\u9884\u53D1\u5E03\u7248\u672C)" : ""}`);
|
|
414
|
+
console.log(` \u6700\u65B0\u7248\u672C: ${latestVersion}`);
|
|
415
|
+
if (isPreRelease || currentVersion !== latestVersion) {
|
|
416
|
+
console.log(`[npm] \u53D1\u73B0\u65B0\u7248\u672C ${pkg}: ${currentVersion} -> ${latestVersion}`);
|
|
326
417
|
packagesToUpdate.push(`${pkg}@latest`);
|
|
327
418
|
} else {
|
|
328
|
-
console.log(
|
|
419
|
+
console.log(`[npm] ${pkg} \u5DF2\u7ECF\u662F\u6700\u65B0\u7248\u672C`);
|
|
329
420
|
}
|
|
330
421
|
} catch (error) {
|
|
331
|
-
console.error(
|
|
422
|
+
console.error(`[npm] \u68C0\u67E5 ${pkg} \u7248\u672C\u5931\u8D25:`, error);
|
|
332
423
|
}
|
|
333
|
-
}
|
|
424
|
+
});
|
|
425
|
+
await Promise.all(checkVersionTasks);
|
|
334
426
|
if (packagesToUpdate.length > 0) {
|
|
335
|
-
console.log("\
|
|
427
|
+
console.log("[npm] \u5F00\u59CB\u66F4\u65B0\u4EE5\u4E0B\u5305:\n", packagesToUpdate.join("\n"));
|
|
336
428
|
try {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
429
|
+
const { status, error } = await exec(`pnpm update ${packagesToUpdate.join(" ")}`);
|
|
430
|
+
if (status) {
|
|
431
|
+
console.log("[npm] \u6240\u6709\u63D2\u4EF6\u66F4\u65B0\u5B8C\u6210");
|
|
432
|
+
} else {
|
|
433
|
+
console.error("[npm] \u6279\u91CF\u66F4\u65B0\u5931\u8D25:", error);
|
|
434
|
+
}
|
|
341
435
|
} catch (error) {
|
|
342
|
-
console.error("\u6279\u91CF\u66F4\u65B0\u5931\u8D25:", error);
|
|
436
|
+
console.error("[npm] \u6279\u91CF\u66F4\u65B0\u5931\u8D25:", error);
|
|
343
437
|
}
|
|
344
438
|
} else {
|
|
345
|
-
console.log("\
|
|
439
|
+
console.log("[npm] \u6240\u6709\u63D2\u4EF6\u90FD\u5DF2\u7ECF\u662F\u6700\u65B0\u7248\u672C");
|
|
346
440
|
}
|
|
347
441
|
} catch (error) {
|
|
348
|
-
console.error("\u66F4\u65B0\u4F9D\u8D56\u5931\u8D25:", error);
|
|
442
|
+
console.error("[npm] \u66F4\u65B0\u4F9D\u8D56\u5931\u8D25:", error);
|
|
349
443
|
}
|
|
350
444
|
};
|
|
351
445
|
var updatePlugins = async (pluginsPath) => {
|
|
352
|
-
if (!checkGitInstalled()) {
|
|
353
|
-
console.error("\u8BF7\u5148\u5B89\u88C5git");
|
|
446
|
+
if (!await checkGitInstalled()) {
|
|
447
|
+
console.error("[git] \u8BF7\u5148\u5B89\u88C5git");
|
|
354
448
|
return;
|
|
355
449
|
}
|
|
356
450
|
if (!existsSync(pluginsPath)) {
|
|
357
|
-
console.error("plugins\u76EE\u5F55\u4E0D\u5B58\u5728");
|
|
451
|
+
console.error("[git] plugins\u76EE\u5F55\u4E0D\u5B58\u5728");
|
|
358
452
|
return;
|
|
359
453
|
}
|
|
360
454
|
const isDirectory = (await stat(pluginsPath)).isDirectory();
|
|
361
455
|
if (!isDirectory) {
|
|
362
|
-
console.error("plugins\u8DEF\u5F84\u4E0D\u662F\u4E00\u4E2A\u76EE\u5F55");
|
|
456
|
+
console.error("[git] plugins\u8DEF\u5F84\u4E0D\u662F\u4E00\u4E2A\u76EE\u5F55");
|
|
363
457
|
return;
|
|
364
458
|
}
|
|
365
459
|
const dirs = await readdir(pluginsPath);
|
|
366
|
-
|
|
460
|
+
const updateTasks = dirs.map(async (dir2) => {
|
|
367
461
|
const pluginPath = join(pluginsPath, dir2);
|
|
368
462
|
const gitPath = join(pluginPath, ".git");
|
|
369
463
|
const packageJsonPath = join(pluginPath, "package.json");
|
|
370
464
|
if (!dir2.startsWith("karin-plugin-") || !(await stat(pluginPath)).isDirectory()) {
|
|
371
|
-
|
|
465
|
+
return;
|
|
372
466
|
}
|
|
373
467
|
if (!existsSync(gitPath)) {
|
|
374
|
-
console.log(
|
|
375
|
-
|
|
468
|
+
console.log(`[git] ${dir2} \u4E0D\u662Fgit\u4ED3\u5E93\uFF0C\u8DF3\u8FC7`);
|
|
469
|
+
return;
|
|
376
470
|
}
|
|
377
471
|
try {
|
|
378
472
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
379
473
|
if (!packageJson.karin) {
|
|
380
|
-
console.log(
|
|
381
|
-
|
|
474
|
+
console.log(`[git] ${dir2} \u7684package.json\u4E2D\u6CA1\u6709karin\u5B57\u6BB5\uFF0C\u8DF3\u8FC7`);
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
console.log(`[git] \u6B63\u5728\u66F4\u65B0 ${dir2}...`);
|
|
478
|
+
const { status, error } = await exec("git pull", { cwd: pluginPath });
|
|
479
|
+
if (!status) {
|
|
480
|
+
console.error(`[git] \u66F4\u65B0 ${dir2} \u5931\u8D25:`, error);
|
|
382
481
|
}
|
|
383
|
-
console.log(`\u6B63\u5728\u66F4\u65B0 ${dir2}...`);
|
|
384
|
-
execSync("git pull", { cwd: pluginPath, stdio: "inherit" });
|
|
385
482
|
} catch (error) {
|
|
386
|
-
console.error(
|
|
483
|
+
console.error(`[git] \u66F4\u65B0 ${dir2} \u5931\u8D25:`, error);
|
|
387
484
|
}
|
|
388
|
-
}
|
|
485
|
+
});
|
|
486
|
+
await Promise.all(updateTasks);
|
|
389
487
|
};
|
|
390
488
|
var updateAll = async () => {
|
|
391
489
|
try {
|
|
490
|
+
console.log("[all] \u5F00\u59CB\u6267\u884C\u66F4\u65B0\u4EFB\u52A1\n");
|
|
392
491
|
await Promise.all([updateDependencies("./package.json"), updatePlugins("./plugins")]);
|
|
492
|
+
console.log("\n[all] \u66F4\u65B0\u4EFB\u52A1\u6267\u884C\u5B8C\u6210");
|
|
393
493
|
} finally {
|
|
394
494
|
process.exit(0);
|
|
395
495
|
}
|
|
396
496
|
};
|
|
497
|
+
var _a;
|
|
498
|
+
if (!((_a = process.argv) == null ? undefined : _a[2])) process.argv.push("-h");
|
|
499
|
+
var addEnvOption = (command) => {
|
|
500
|
+
return command.option("-e, --env <files>", "\u6307\u5B9A\u73AF\u5883\u53D8\u91CF\u6587\u4EF6\uFF0C\u591A\u4E2A\u6587\u4EF6\u7528\u9017\u53F7\u5206\u9694");
|
|
501
|
+
};
|
|
397
502
|
program.version(process.env.npm_package_version, "-v, --version", "\u663E\u793A\u7248\u672C\u53F7");
|
|
398
|
-
program.command(".").description("\u524D\u53F0\u542F\u52A8").action(() => start2());
|
|
399
|
-
program.command("start").description("\u524D\u53F0\u542F\u52A8").action(() => start2());
|
|
400
503
|
program.command("pm2").description("\u540E\u53F0\u8FD0\u884C").action(pm2.start);
|
|
401
504
|
program.command("stop").description("\u505C\u6B62\u540E\u53F0\u8FD0\u884C").action(pm2.stop);
|
|
402
505
|
program.command("rs").description("\u91CD\u542Fpm2\u670D\u52A1").action(pm2.restart);
|
|
403
506
|
program.command("log").description("\u67E5\u770B\u65E5\u5FD7").action(pm2.log);
|
|
404
507
|
program.command("up").description("\u66F4\u65B0\u63D2\u4EF6").action(updateAll);
|
|
405
508
|
program.command("init").description("\u521D\u59CB\u5316\u9879\u76EE").action(init);
|
|
509
|
+
addEnvOption(program.command("app").description("\u524D\u53F0\u542F\u52A8")).action((options) => start2(options.env));
|
|
510
|
+
addEnvOption(program.command("start").description("\u524D\u53F0\u542F\u52A8")).action((options) => start2(options.env));
|
|
511
|
+
addEnvOption(program.command("dev").description("JavaScript\u5F00\u53D1\u6A21\u5F0F")).action((options) => dev(options.env));
|
|
512
|
+
addEnvOption(
|
|
513
|
+
program.command("ts").description("TypeScript\u5F00\u53D1\u6A21\u5F0F").option("-e, --env <files>", "\u6307\u5B9A\u73AF\u5883\u53D8\u91CF\u6587\u4EF6\uFF0C\u591A\u4E2A\u6587\u4EF6\u7528\u9017\u53F7\u5206\u9694\uFF0C\u4F8B\u5982\uFF1A.env.dev,.env.local").addHelpText("after", `
|
|
514
|
+
\u793A\u4F8B:
|
|
515
|
+
$ karin ts # \u4F7F\u7528\u9ED8\u8BA4 .env \u6587\u4EF6\u542F\u52A8
|
|
516
|
+
$ karin ts -e .env.dev # \u4F7F\u7528\u6307\u5B9A\u7684\u73AF\u5883\u53D8\u91CF\u6587\u4EF6\u542F\u52A8
|
|
517
|
+
$ karin ts -e .env.dev,.env.local # \u4F7F\u7528\u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u6587\u4EF6\u542F\u52A8
|
|
518
|
+
`)
|
|
519
|
+
).action((options) => tsStart(options.env));
|
|
520
|
+
addEnvOption(
|
|
521
|
+
program.command("watch").description("TypeScript\u76D1\u89C6\u6A21\u5F0F").option("--include <patterns>", "\u6DFB\u52A0\u8981\u76D1\u89C6\u7684\u6587\u4EF6/\u76EE\u5F55\uFF0C\u591A\u4E2A\u7528\u9017\u53F7\u5206\u9694").option("--exclude <patterns>", "\u6392\u9664\u8981\u76D1\u89C6\u7684\u6587\u4EF6/\u76EE\u5F55\uFF0C\u591A\u4E2A\u7528\u9017\u53F7\u5206\u9694").option("--clear-screen", "\u91CD\u65B0\u8FD0\u884C\u65F6\u662F\u5426\u6E05\u5C4F", true).addHelpText("after", `
|
|
522
|
+
\u793A\u4F8B:
|
|
523
|
+
$ karin watch # \u9ED8\u8BA4\u76D1\u89C6\u6A21\u5F0F
|
|
524
|
+
$ karin watch --include src # \u76D1\u89C6 src \u76EE\u5F55
|
|
525
|
+
$ karin watch --exclude node_modules,dist # \u6392\u9664\u6307\u5B9A\u76EE\u5F55
|
|
526
|
+
$ karin watch --no-clear-screen # \u7981\u7528\u6E05\u5C4F
|
|
527
|
+
`)
|
|
528
|
+
).action((options) => tsWatch(options));
|
|
406
529
|
program.parse(process.argv);
|
package/dist/index.js
CHANGED
|
@@ -4471,8 +4471,8 @@ var init_app = __esm({
|
|
|
4471
4471
|
listen = (port2, host2) => {
|
|
4472
4472
|
server.listen(port2, host2, () => {
|
|
4473
4473
|
logger.info(`[server] express \u5DF2\u542F\u52A8 \u6B63\u5728\u76D1\u542C: http://${host2}:${port2}`);
|
|
4474
|
-
console.log(
|
|
4475
|
-
console.log(
|
|
4474
|
+
console.log(`[server] http\u9274\u6743token: ${logger.green(process.env.HTTP_AUTH_KEY)}`);
|
|
4475
|
+
console.log(`[server] ws\u9274\u6743token: ${logger.green(process.env.WS_SERVER_AUTH_KEY)}`);
|
|
4476
4476
|
});
|
|
4477
4477
|
};
|
|
4478
4478
|
}
|
|
@@ -8892,7 +8892,7 @@ import util from "node:util";
|
|
|
8892
8892
|
var time = Date.now();
|
|
8893
8893
|
var debugEnabled = false;
|
|
8894
8894
|
var isDebugMode = () => {
|
|
8895
|
-
return debugEnabled || process.env.
|
|
8895
|
+
return debugEnabled || typeof process.env.DEBUG === "string" || process.argv.some((arg) => arg.includes("debug"));
|
|
8896
8896
|
};
|
|
8897
8897
|
var createDebug = (prefix) => {
|
|
8898
8898
|
let color = (text2) => chalk.hex("#0cafff")(text2);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-karin",
|
|
3
|
-
"version": "0.12.25.pr.206.
|
|
3
|
+
"version": "0.12.25.pr.206.dad353f",
|
|
4
4
|
"description": "Lightweight, efficient, concise, and stable robot framework.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -26,6 +26,11 @@
|
|
|
26
26
|
"type": "module",
|
|
27
27
|
"main": "./dist/index.js",
|
|
28
28
|
"types": "./dist/index.d.ts",
|
|
29
|
+
"bin": {
|
|
30
|
+
"k": "./dist/cli/index.cjs",
|
|
31
|
+
"karin": "./dist/cli/index.js",
|
|
32
|
+
"kr": "./dist/cli/index.cjs"
|
|
33
|
+
},
|
|
29
34
|
"files": [
|
|
30
35
|
"/dist/**/*.js",
|
|
31
36
|
"/dist/**/*.cjs",
|
|
@@ -47,8 +52,10 @@
|
|
|
47
52
|
"build:dev": "pnpm build && node cli/build.js -dev",
|
|
48
53
|
"build:module": "tsup --tsconfig tsconfig.module.json --config tsup.modules.ts && node cli/module.js",
|
|
49
54
|
"build:prod": "pnpm build:module && pnpm build:cli && pnpm build && node cli/build.js",
|
|
55
|
+
"cli": "node dist/cli/index.cjs",
|
|
50
56
|
"debug": "node lib/index.js --debug",
|
|
51
57
|
"dev": "tsx src/index.ts",
|
|
58
|
+
"dev:cli": "tsx exports/cli/index.ts",
|
|
52
59
|
"dev:w": "tsx watch --include \"./src/**/*.ts\" src/index.ts",
|
|
53
60
|
"dev:watch": "pnpm dev:w",
|
|
54
61
|
"pr": "node cli/pr.js all",
|
|
@@ -59,24 +66,23 @@
|
|
|
59
66
|
"dependencies": {
|
|
60
67
|
"@types/express": "^5.0.0",
|
|
61
68
|
"@types/lodash": "^4.17.10",
|
|
62
|
-
"@types/node": "^22.5.0",
|
|
63
69
|
"@types/node-schedule": "^2.1.7",
|
|
64
70
|
"@types/ws": "^8.5.12",
|
|
65
71
|
"art-template": "4.13.2",
|
|
66
72
|
"axios": "1.7.9",
|
|
67
|
-
"chalk": "5.
|
|
73
|
+
"chalk": "5.4.1",
|
|
68
74
|
"chokidar": "3.6.0",
|
|
69
|
-
"commander": "^
|
|
70
|
-
"dotenv": "^16.
|
|
75
|
+
"commander": "^13.0.0",
|
|
76
|
+
"dotenv": "^16.4.7",
|
|
71
77
|
"express": "4.21.2",
|
|
72
|
-
"level": "
|
|
78
|
+
"level": "9.0.0",
|
|
73
79
|
"lodash": "4.17.21",
|
|
74
80
|
"log4js": "6.9.1",
|
|
75
81
|
"moment": "2.30.1",
|
|
76
82
|
"node-schedule": "2.1.1",
|
|
77
83
|
"redis": "4.7.0",
|
|
78
84
|
"ws": "8.18.0",
|
|
79
|
-
"yaml": "2.
|
|
85
|
+
"yaml": "2.7.0"
|
|
80
86
|
},
|
|
81
87
|
"engines": {
|
|
82
88
|
"node": ">=18"
|