@eggjs/bin 7.2.0 → 7.3.1-beta.3
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/README.md +3 -21
- package/bin/dev.js +0 -0
- package/dist/baseCommand.d.ts +52 -0
- package/dist/baseCommand.js +288 -0
- package/dist/commands/cov.d.ts +27 -0
- package/dist/commands/cov.js +86 -0
- package/dist/commands/dev.d.ts +26 -0
- package/dist/commands/dev.js +86 -0
- package/dist/commands/test.d.ts +28 -0
- package/dist/commands/test.js +168 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8 -0
- package/dist/scripts/postinstall.mjs +14 -7
- package/dist/scripts/start-cluster.cjs +3 -2
- package/dist/scripts/start-cluster.mjs +3 -2
- package/{src/types.ts → dist/types.d.ts} +4 -1
- package/dist/utils.js +34 -0
- package/package.json +48 -68
- package/scripts/postinstall.mjs +14 -7
- package/scripts/start-cluster.cjs +3 -2
- package/scripts/start-cluster.mjs +3 -2
- package/dist/commonjs/baseCommand.d.ts +0 -49
- package/dist/commonjs/baseCommand.js +0 -369
- package/dist/commonjs/commands/cov.d.ts +0 -22
- package/dist/commonjs/commands/cov.js +0 -98
- package/dist/commonjs/commands/dev.d.ts +0 -21
- package/dist/commonjs/commands/dev.js +0 -95
- package/dist/commonjs/commands/test.d.ts +0 -23
- package/dist/commonjs/commands/test.js +0 -222
- package/dist/commonjs/index.d.ts +0 -7
- package/dist/commonjs/index.js +0 -30
- package/dist/commonjs/package.json +0 -3
- package/dist/commonjs/types.d.ts +0 -9
- package/dist/commonjs/types.js +0 -3
- package/dist/commonjs/utils.d.ts +0 -4
- package/dist/commonjs/utils.js +0 -45
- package/dist/esm/baseCommand.d.ts +0 -49
- package/dist/esm/baseCommand.js +0 -361
- package/dist/esm/commands/cov.d.ts +0 -22
- package/dist/esm/commands/cov.js +0 -92
- package/dist/esm/commands/dev.d.ts +0 -21
- package/dist/esm/commands/dev.js +0 -92
- package/dist/esm/commands/test.d.ts +0 -23
- package/dist/esm/commands/test.js +0 -216
- package/dist/esm/index.d.ts +0 -7
- package/dist/esm/index.js +0 -8
- package/dist/esm/package.json +0 -3
- package/dist/esm/types.d.ts +0 -9
- package/dist/esm/types.js +0 -2
- package/dist/esm/utils.d.ts +0 -4
- package/dist/esm/utils.js +0 -36
- package/dist/package.json +0 -4
- package/src/baseCommand.ts +0 -390
- package/src/commands/cov.ts +0 -101
- package/src/commands/dev.ts +0 -99
- package/src/commands/test.ts +0 -236
- package/src/index.ts +0 -9
- package/src/utils.ts +0 -37
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { BaseCommand } from "../baseCommand.js";
|
|
2
|
+
import { debuglog } from "node:util";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import fs from "node:fs/promises";
|
|
6
|
+
import { Args, Flags } from "@oclif/core";
|
|
7
|
+
import globby from "globby";
|
|
8
|
+
import { EggType, detectType, importResolve } from "@eggjs/utils";
|
|
9
|
+
import { getChangedFilesForRoots } from "jest-changed-files";
|
|
10
|
+
import ciParallelVars from "ci-parallel-vars";
|
|
11
|
+
|
|
12
|
+
//#region src/commands/test.ts
|
|
13
|
+
const debug = debuglog("egg-bin/commands/test");
|
|
14
|
+
var Test = class extends BaseCommand {
|
|
15
|
+
static args = { file: Args.string({ description: "file(s) to test" }) };
|
|
16
|
+
static description = "Run the test";
|
|
17
|
+
static examples = [
|
|
18
|
+
"<%= config.bin %> <%= command.id %>",
|
|
19
|
+
"<%= config.bin %> <%= command.id %> test/index.test.ts",
|
|
20
|
+
"<%= config.bin %> <%= command.id %> test/index.test.ts,test/user.test.ts,...",
|
|
21
|
+
"<%= config.bin %> <%= command.id %> --json",
|
|
22
|
+
"<%= config.bin %> <%= command.id %> --log-level debug"
|
|
23
|
+
];
|
|
24
|
+
static flags = {
|
|
25
|
+
bail: Flags.boolean({
|
|
26
|
+
description: "bbort (\"bail\") after first test failure",
|
|
27
|
+
default: false,
|
|
28
|
+
char: "b"
|
|
29
|
+
}),
|
|
30
|
+
timeout: Flags.integer({
|
|
31
|
+
char: "t",
|
|
32
|
+
description: "set test-case timeout in milliseconds",
|
|
33
|
+
default: parseInt(process.env.TEST_TIMEOUT ?? "60000")
|
|
34
|
+
}),
|
|
35
|
+
"no-timeout": Flags.boolean({ description: "disable timeout" }),
|
|
36
|
+
grep: Flags.string({
|
|
37
|
+
char: "g",
|
|
38
|
+
description: "only run tests matching <pattern>"
|
|
39
|
+
}),
|
|
40
|
+
changed: Flags.boolean({
|
|
41
|
+
description: "only test with changed files and match test/**/*.test.(js|ts)",
|
|
42
|
+
char: "c"
|
|
43
|
+
}),
|
|
44
|
+
mochawesome: Flags.boolean({
|
|
45
|
+
description: "[default: true] enable mochawesome reporter",
|
|
46
|
+
default: true,
|
|
47
|
+
allowNo: true
|
|
48
|
+
}),
|
|
49
|
+
parallel: Flags.boolean({
|
|
50
|
+
description: "mocha parallel mode",
|
|
51
|
+
default: false,
|
|
52
|
+
char: "p"
|
|
53
|
+
}),
|
|
54
|
+
jobs: Flags.integer({
|
|
55
|
+
char: "t",
|
|
56
|
+
description: "number of jobs to run in parallel",
|
|
57
|
+
default: os.cpus().length - 1
|
|
58
|
+
}),
|
|
59
|
+
"auto-agent": Flags.boolean({
|
|
60
|
+
description: "[default: true] auto bootstrap agent in mocha master process",
|
|
61
|
+
default: true,
|
|
62
|
+
allowNo: true
|
|
63
|
+
})
|
|
64
|
+
};
|
|
65
|
+
async run() {
|
|
66
|
+
const { flags } = this;
|
|
67
|
+
try {
|
|
68
|
+
await fs.access(flags.base);
|
|
69
|
+
} catch (err) {
|
|
70
|
+
console.error("baseDir: %o not exists", flags.base);
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
const mochaFile = process.env.MOCHA_FILE || importResolve("mocha/bin/_mocha");
|
|
74
|
+
if (flags.parallel) {
|
|
75
|
+
this.env.ENABLE_MOCHA_PARALLEL = "true";
|
|
76
|
+
if (flags["auto-agent"]) this.env.AUTO_AGENT = "true";
|
|
77
|
+
}
|
|
78
|
+
this.env.NODE_ENV = "test";
|
|
79
|
+
if (flags["no-timeout"]) flags.timeout = 0;
|
|
80
|
+
debug("run test: %s %o flags: %o", mochaFile, this.args, flags);
|
|
81
|
+
const mochaArgs = await this.formatMochaArgs();
|
|
82
|
+
if (!mochaArgs) return;
|
|
83
|
+
await this.runMocha(mochaFile, mochaArgs);
|
|
84
|
+
}
|
|
85
|
+
async runMocha(mochaFile, mochaArgs) {
|
|
86
|
+
await this.forkNode(mochaFile, mochaArgs, { execArgv: [...process.execArgv, "--unhandled-rejections=strict"] });
|
|
87
|
+
}
|
|
88
|
+
async formatMochaArgs() {
|
|
89
|
+
const { args, flags } = this;
|
|
90
|
+
const requires = await this.formatRequires();
|
|
91
|
+
const eggType = await detectType(flags.base);
|
|
92
|
+
debug("eggType: %s", eggType);
|
|
93
|
+
if (eggType === EggType.application) try {
|
|
94
|
+
const eggMockRegister = importResolve("@eggjs/mock/register", { paths: [flags.base] });
|
|
95
|
+
requires.push(eggMockRegister);
|
|
96
|
+
debug("auto register @eggjs/mock/register: %o", eggMockRegister);
|
|
97
|
+
} catch (err) {
|
|
98
|
+
debug("auto register @eggjs/mock fail, can not require @eggjs/mock on %o, error: %s", flags.base, err.message);
|
|
99
|
+
}
|
|
100
|
+
let reporter = this.env.TEST_REPORTER;
|
|
101
|
+
let reporterOptions = "";
|
|
102
|
+
if (!reporter && flags.mochawesome) {
|
|
103
|
+
reporter = importResolve("mochawesome-with-mocha", { paths: [flags.base] });
|
|
104
|
+
reporterOptions = "reportDir=node_modules/.mochawesome-reports";
|
|
105
|
+
if (flags.parallel) requires.push(path.join(reporter, "../register.js"));
|
|
106
|
+
}
|
|
107
|
+
const ext = flags.typescript ? "ts" : "js";
|
|
108
|
+
let pattern = args.file ? args.file.split(",") : [];
|
|
109
|
+
if (flags.changed) {
|
|
110
|
+
pattern = await this.getChangedTestFiles(flags.base, ext);
|
|
111
|
+
if (!pattern.length) {
|
|
112
|
+
console.log("No changed test files");
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
debug("changed files: %o", pattern);
|
|
116
|
+
}
|
|
117
|
+
if (!pattern.length && process.env.TESTS) pattern = process.env.TESTS.split(",");
|
|
118
|
+
if (!pattern.length) pattern = [`test/**/*.test.${ext}`];
|
|
119
|
+
pattern = pattern.concat(["!test/fixtures", "!test/node_modules"]);
|
|
120
|
+
let files = globby.sync(pattern, { cwd: flags.base });
|
|
121
|
+
files.sort();
|
|
122
|
+
if (files.length === 0) {
|
|
123
|
+
console.log("No test files found with pattern %o", pattern);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (ciParallelVars) {
|
|
127
|
+
const { index: currentIndex, total: totalRuns } = ciParallelVars;
|
|
128
|
+
const fileCount = files.length;
|
|
129
|
+
const each = Math.floor(fileCount / totalRuns);
|
|
130
|
+
const remainder = fileCount % totalRuns;
|
|
131
|
+
const offset = Math.min(currentIndex, remainder) + currentIndex * each;
|
|
132
|
+
const currentFileCount = each + (currentIndex < remainder ? 1 : 0);
|
|
133
|
+
files = files.slice(offset, offset + currentFileCount);
|
|
134
|
+
console.log("# Split test files in parallel CI jobs: %d/%d, files: %d/%d", currentIndex + 1, totalRuns, files.length, fileCount);
|
|
135
|
+
}
|
|
136
|
+
const setupFile = path.join(flags.base, `test/.setup.${ext}`);
|
|
137
|
+
try {
|
|
138
|
+
await fs.access(setupFile);
|
|
139
|
+
files.unshift(setupFile);
|
|
140
|
+
} catch {}
|
|
141
|
+
const grep = flags.grep ? flags.grep.split(",") : [];
|
|
142
|
+
return [
|
|
143
|
+
"--exit",
|
|
144
|
+
flags.bail ? "--bail" : "",
|
|
145
|
+
grep.map((pattern$1) => `--grep='${pattern$1}'`).join(" "),
|
|
146
|
+
flags.timeout ? `--timeout=${flags.timeout}` : "--no-timeout",
|
|
147
|
+
flags.parallel ? "--parallel" : "",
|
|
148
|
+
flags.parallel && flags.jobs ? `--jobs=${flags.jobs}` : "",
|
|
149
|
+
reporter ? `--reporter=${reporter}` : "",
|
|
150
|
+
reporterOptions ? `--reporter-options=${reporterOptions}` : "",
|
|
151
|
+
...requires.map((r) => `--require=${r}`),
|
|
152
|
+
...files,
|
|
153
|
+
flags["dry-run"] ? "--dry-run" : ""
|
|
154
|
+
].filter((a) => a.trim());
|
|
155
|
+
}
|
|
156
|
+
async getChangedTestFiles(dir, ext) {
|
|
157
|
+
const changedFiles = (await getChangedFilesForRoots([path.join(dir, "test")], {})).changedFiles;
|
|
158
|
+
const files = [];
|
|
159
|
+
for (let cf of changedFiles) if (cf.endsWith(`.test.${ext}`)) {
|
|
160
|
+
if (process.platform === "win32") cf = cf.replace(/\\/g, "/");
|
|
161
|
+
files.push(cf);
|
|
162
|
+
}
|
|
163
|
+
return files;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
//#endregion
|
|
168
|
+
export { Test as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PackageEgg } from "./types.js";
|
|
2
|
+
import { BaseCommand, ForkError, ForkNodeOptions } from "./baseCommand.js";
|
|
3
|
+
import { Test } from "./commands/test.js";
|
|
4
|
+
import { Cov } from "./commands/cov.js";
|
|
5
|
+
import { Dev } from "./commands/dev.js";
|
|
6
|
+
export * from "@oclif/core";
|
|
7
|
+
export { BaseCommand, Cov, Dev, ForkError, ForkNodeOptions, PackageEgg, Test };
|
package/dist/index.js
ADDED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { debuglog } from 'node:util';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
4
5
|
import { runScript } from 'runscript';
|
|
5
6
|
import { readJSON, exists } from 'utility';
|
|
6
7
|
import { importResolve } from '@eggjs/utils';
|
|
7
8
|
|
|
8
|
-
const debug = debuglog('
|
|
9
|
+
const debug = debuglog('egg-bin/scripts/postinstall');
|
|
9
10
|
|
|
10
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
11
12
|
const __dirname = path.dirname(__filename);
|
|
@@ -13,9 +14,11 @@ const rootDir = path.dirname(__dirname);
|
|
|
13
14
|
|
|
14
15
|
async function main() {
|
|
15
16
|
// node postintall.js </path/to/egg-ts-helper/dist/bin> <framework-package-name>
|
|
16
|
-
const etsBinFile =
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const etsBinFile =
|
|
18
|
+
process.argv[2] ||
|
|
19
|
+
importResolve('egg-ts-helper/dist/bin.js', {
|
|
20
|
+
paths: [rootDir],
|
|
21
|
+
});
|
|
19
22
|
const frameworkPackageName = process.argv[3] || 'egg';
|
|
20
23
|
|
|
21
24
|
// try to use INIT_CWD env https://docs.npmjs.com/cli/v9/commands/npm-run-script
|
|
@@ -51,10 +54,14 @@ async function main() {
|
|
|
51
54
|
process.env.ETS_CWD = npmRunRoot;
|
|
52
55
|
// https://github.com/eggjs/egg-ts-helper/pull/104
|
|
53
56
|
process.env.ETS_SCRIPT_FRAMEWORK = frameworkPackageName;
|
|
54
|
-
console.log(
|
|
55
|
-
|
|
57
|
+
console.log(
|
|
58
|
+
'[@eggjs/bin/postinstall] run %s on %s',
|
|
59
|
+
etsBinFile,
|
|
60
|
+
npmRunRoot
|
|
61
|
+
);
|
|
62
|
+
await runScript(`node "${etsBinFile}"`);
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
66
|
|
|
60
|
-
main();
|
|
67
|
+
void main();
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
2
|
const { debuglog } = require('node:util');
|
|
3
|
+
|
|
3
4
|
const { importModule } = require('@eggjs/utils');
|
|
4
5
|
|
|
5
|
-
const debug = debuglog('
|
|
6
|
+
const debug = debuglog('egg-bin/scripts/start-cluster');
|
|
6
7
|
|
|
7
8
|
async function main() {
|
|
8
9
|
debug('argv: %o', process.argv);
|
|
@@ -12,4 +13,4 @@ async function main() {
|
|
|
12
13
|
await startCluster(options);
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
main();
|
|
16
|
+
void main();
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { debuglog } from 'node:util';
|
|
2
|
+
|
|
2
3
|
import { importModule } from '@eggjs/utils';
|
|
3
4
|
|
|
4
|
-
const debug = debuglog('
|
|
5
|
+
const debug = debuglog('egg-bin/scripts/start-cluster');
|
|
5
6
|
|
|
6
7
|
async function main() {
|
|
7
8
|
debug('argv: %o', process.argv);
|
|
@@ -11,4 +12,4 @@ async function main() {
|
|
|
11
12
|
await startCluster(options);
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
main();
|
|
15
|
+
void main();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
interface PackageEgg {
|
|
2
3
|
framework?: boolean;
|
|
3
4
|
typescript?: boolean;
|
|
4
5
|
tscompiler?: string;
|
|
@@ -7,3 +8,5 @@ export interface PackageEgg {
|
|
|
7
8
|
require?: string | string[];
|
|
8
9
|
import?: string | string[];
|
|
9
10
|
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { PackageEgg };
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
//#region src/utils.ts
|
|
6
|
+
async function readPackageJSON(baseDir) {
|
|
7
|
+
const pkgFile = path.join(baseDir, "package.json");
|
|
8
|
+
try {
|
|
9
|
+
const pkgJSON = await fs.readFile(pkgFile, "utf8");
|
|
10
|
+
return JSON.parse(pkgJSON);
|
|
11
|
+
} catch {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
async function hasTsConfig(baseDir) {
|
|
16
|
+
const pkgFile = path.join(baseDir, "tsconfig.json");
|
|
17
|
+
try {
|
|
18
|
+
await fs.access(pkgFile);
|
|
19
|
+
return true;
|
|
20
|
+
} catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function getSourceDirname() {
|
|
25
|
+
if (typeof __dirname === "string") return __dirname;
|
|
26
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
27
|
+
return path.dirname(__filename);
|
|
28
|
+
}
|
|
29
|
+
function getSourceFilename(filename) {
|
|
30
|
+
return path.join(getSourceDirname(), filename);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { getSourceDirname, getSourceFilename, hasTsConfig, readPackageJSON };
|
package/package.json
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eggjs/bin",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.1-beta.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"description": "egg developer tool",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git
|
|
10
|
+
"url": "git://github.com/eggjs/egg.git",
|
|
11
|
+
"directory": "tools/egg-bin"
|
|
11
12
|
},
|
|
12
|
-
"
|
|
13
|
+
"bugs": {
|
|
13
14
|
"url": "https://github.com/eggjs/egg/issues"
|
|
14
15
|
},
|
|
15
|
-
"homepage": "https://github.com/eggjs/bin",
|
|
16
16
|
"author": "fengmk2 <fengmk2@gmail.com> (https://github.com/fengmk2)",
|
|
17
17
|
"engines": {
|
|
18
|
-
"node": ">=
|
|
18
|
+
"node": ">= 20.19.0"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@eggjs/utils": "^4.2.0",
|
|
22
21
|
"@oclif/core": "^4.2.0",
|
|
23
22
|
"@types/mocha": "^10.0.10",
|
|
24
|
-
"
|
|
25
|
-
"c8": "^10.0.0",
|
|
23
|
+
"c8": "10.1.3",
|
|
26
24
|
"ci-parallel-vars": "^1.0.1",
|
|
27
|
-
"detect-port": "^2.
|
|
25
|
+
"detect-port": "^2.1.0",
|
|
28
26
|
"egg-ts-helper": "^3.0.0",
|
|
29
|
-
"globby": "^11.
|
|
27
|
+
"globby": "^11.0.2",
|
|
30
28
|
"jest-changed-files": "^29.4.2",
|
|
31
|
-
"mocha": "
|
|
32
|
-
"mochawesome-with-mocha": "
|
|
33
|
-
"runscript": "^2.0.
|
|
29
|
+
"mocha": "11.7.2",
|
|
30
|
+
"mochawesome-with-mocha": "8.0.0",
|
|
31
|
+
"runscript": "^2.0.1",
|
|
34
32
|
"ts-node": "^10.9.2",
|
|
35
|
-
"tsconfig-paths": "^4.
|
|
36
|
-
"utility": "^2.
|
|
33
|
+
"tsconfig-paths": "^4.2.0",
|
|
34
|
+
"utility": "^2.5.0",
|
|
35
|
+
"@eggjs/utils": "4.5.0-beta.4",
|
|
36
|
+
"@eggjs/supertest": "8.3.0-beta.4"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@eggjs/mock": "6"
|
|
39
|
+
"@eggjs/mock": "6.1.0-beta.4"
|
|
40
40
|
},
|
|
41
41
|
"peerDependenciesMeta": {
|
|
42
42
|
"@eggjs/mock": {
|
|
@@ -44,80 +44,60 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
49
|
-
"@
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"@types/node": "22",
|
|
53
|
-
"assert-file": "^1.0.0",
|
|
54
|
-
"coffee": "^5.5.1",
|
|
47
|
+
"@swc-node/register": "^1.11.1",
|
|
48
|
+
"@swc/core": "^1.13.5",
|
|
49
|
+
"@types/node": "24",
|
|
50
|
+
"assert-file": "1",
|
|
51
|
+
"coffee": "5",
|
|
55
52
|
"cpy": "^8.1.2",
|
|
56
53
|
"cpy-cli": "^5.0.0",
|
|
57
54
|
"cross-env": "^7.0.3",
|
|
58
|
-
"egg": "^4.0.7",
|
|
59
55
|
"esbuild": "^0.25.0",
|
|
60
56
|
"esbuild-register": "^3.6.0",
|
|
61
|
-
"eslint": "8",
|
|
62
|
-
"eslint-config-egg": "14",
|
|
63
57
|
"npminstall": "^7.12.0",
|
|
64
58
|
"rimraf": "6",
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
|
|
70
|
-
"scripts": {
|
|
71
|
-
"postinstall": "node scripts/postinstall.mjs",
|
|
72
|
-
"lint": "eslint --cache src test --ext .ts",
|
|
73
|
-
"pretest": "npm run clean && npm run lint -- --fix && npm run prepublishOnly",
|
|
74
|
-
"test": "node bin/run.js test",
|
|
75
|
-
"cov": "c8 --temp-directory node_modules/.c8_output -r text-summary -r json-summary -r json -r lcov -r cobertura node bin/run.js test",
|
|
76
|
-
"preci": "npm run clean && npm run lint && npm run prepublishOnly",
|
|
77
|
-
"ci": "npm run cov",
|
|
78
|
-
"clean": "rimraf dist",
|
|
79
|
-
"copyScripts": "rimraf dist/scripts && cpy scripts dist",
|
|
80
|
-
"prepublishOnly": "tshy && tshy-after && attw --pack && npm run copyScripts"
|
|
59
|
+
"typescript": "5.9.2",
|
|
60
|
+
"tsdown": "^0.15.0",
|
|
61
|
+
"@eggjs/tsconfig": "3.1.0-beta.4",
|
|
62
|
+
"@eggjs/mock": "6.1.0-beta.4",
|
|
63
|
+
"egg": "4.1.0-beta.4"
|
|
81
64
|
},
|
|
82
65
|
"type": "module",
|
|
83
|
-
"tshy": {
|
|
84
|
-
"exports": {
|
|
85
|
-
".": "./src/index.ts",
|
|
86
|
-
"./package.json": "./package.json"
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
"exports": {
|
|
90
|
-
".": {
|
|
91
|
-
"import": {
|
|
92
|
-
"types": "./dist/esm/index.d.ts",
|
|
93
|
-
"default": "./dist/esm/index.js"
|
|
94
|
-
},
|
|
95
|
-
"require": {
|
|
96
|
-
"types": "./dist/commonjs/index.d.ts",
|
|
97
|
-
"default": "./dist/commonjs/index.js"
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
"./package.json": "./package.json"
|
|
101
|
-
},
|
|
102
66
|
"files": [
|
|
103
67
|
"bin",
|
|
104
68
|
"dist",
|
|
105
|
-
"src",
|
|
106
69
|
"scripts"
|
|
107
70
|
],
|
|
108
71
|
"bin": {
|
|
109
72
|
"egg-bin": "./bin/run.js"
|
|
110
73
|
},
|
|
111
|
-
"types": "./dist/commonjs/index.d.ts",
|
|
112
|
-
"main": "./dist/commonjs/index.js",
|
|
113
|
-
"module": "./dist/esm/index.js",
|
|
114
74
|
"oclif": {
|
|
115
75
|
"bin": "egg-bin",
|
|
116
|
-
"commands": "./dist/
|
|
76
|
+
"commands": "./dist/commands",
|
|
117
77
|
"dirname": "egg-bin",
|
|
118
78
|
"topicSeparator": " ",
|
|
119
79
|
"additionalHelpFlags": [
|
|
120
80
|
"-h"
|
|
121
81
|
]
|
|
82
|
+
},
|
|
83
|
+
"main": "./dist/index.js",
|
|
84
|
+
"module": "./dist/index.js",
|
|
85
|
+
"types": "./dist/index.d.ts",
|
|
86
|
+
"exports": {
|
|
87
|
+
".": "./dist/index.js",
|
|
88
|
+
"./package.json": "./package.json"
|
|
89
|
+
},
|
|
90
|
+
"scripts": {
|
|
91
|
+
"postinstall": "node scripts/postinstall.mjs",
|
|
92
|
+
"lint": "oxlint --type-aware",
|
|
93
|
+
"typecheck": "tsc --noEmit",
|
|
94
|
+
"pretest": "npm run clean && npm run lint -- --fix && npm run prepublishOnly",
|
|
95
|
+
"test": "node bin/run.js test",
|
|
96
|
+
"cov": "c8 --temp-directory node_modules/.c8_output -r text-summary -r json-summary -r json -r lcov -r cobertura node bin/run.js test",
|
|
97
|
+
"preci": "npm run clean && npm run lint && npm run prepublishOnly",
|
|
98
|
+
"ci": "npm run cov",
|
|
99
|
+
"clean": "rimraf dist",
|
|
100
|
+
"copyScripts": "rimraf dist/scripts && cpy scripts dist",
|
|
101
|
+
"build": "tsdown"
|
|
122
102
|
}
|
|
123
|
-
}
|
|
103
|
+
}
|
package/scripts/postinstall.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { debuglog } from 'node:util';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
4
5
|
import { runScript } from 'runscript';
|
|
5
6
|
import { readJSON, exists } from 'utility';
|
|
6
7
|
import { importResolve } from '@eggjs/utils';
|
|
7
8
|
|
|
8
|
-
const debug = debuglog('
|
|
9
|
+
const debug = debuglog('egg-bin/scripts/postinstall');
|
|
9
10
|
|
|
10
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
11
12
|
const __dirname = path.dirname(__filename);
|
|
@@ -13,9 +14,11 @@ const rootDir = path.dirname(__dirname);
|
|
|
13
14
|
|
|
14
15
|
async function main() {
|
|
15
16
|
// node postintall.js </path/to/egg-ts-helper/dist/bin> <framework-package-name>
|
|
16
|
-
const etsBinFile =
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const etsBinFile =
|
|
18
|
+
process.argv[2] ||
|
|
19
|
+
importResolve('egg-ts-helper/dist/bin.js', {
|
|
20
|
+
paths: [rootDir],
|
|
21
|
+
});
|
|
19
22
|
const frameworkPackageName = process.argv[3] || 'egg';
|
|
20
23
|
|
|
21
24
|
// try to use INIT_CWD env https://docs.npmjs.com/cli/v9/commands/npm-run-script
|
|
@@ -51,10 +54,14 @@ async function main() {
|
|
|
51
54
|
process.env.ETS_CWD = npmRunRoot;
|
|
52
55
|
// https://github.com/eggjs/egg-ts-helper/pull/104
|
|
53
56
|
process.env.ETS_SCRIPT_FRAMEWORK = frameworkPackageName;
|
|
54
|
-
console.log(
|
|
55
|
-
|
|
57
|
+
console.log(
|
|
58
|
+
'[@eggjs/bin/postinstall] run %s on %s',
|
|
59
|
+
etsBinFile,
|
|
60
|
+
npmRunRoot
|
|
61
|
+
);
|
|
62
|
+
await runScript(`node "${etsBinFile}"`);
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
66
|
|
|
60
|
-
main();
|
|
67
|
+
void main();
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
2
|
const { debuglog } = require('node:util');
|
|
3
|
+
|
|
3
4
|
const { importModule } = require('@eggjs/utils');
|
|
4
5
|
|
|
5
|
-
const debug = debuglog('
|
|
6
|
+
const debug = debuglog('egg-bin/scripts/start-cluster');
|
|
6
7
|
|
|
7
8
|
async function main() {
|
|
8
9
|
debug('argv: %o', process.argv);
|
|
@@ -12,4 +13,4 @@ async function main() {
|
|
|
12
13
|
await startCluster(options);
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
main();
|
|
16
|
+
void main();
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { debuglog } from 'node:util';
|
|
2
|
+
|
|
2
3
|
import { importModule } from '@eggjs/utils';
|
|
3
4
|
|
|
4
|
-
const debug = debuglog('
|
|
5
|
+
const debug = debuglog('egg-bin/scripts/start-cluster');
|
|
5
6
|
|
|
6
7
|
async function main() {
|
|
7
8
|
debug('argv: %o', process.argv);
|
|
@@ -11,4 +12,4 @@ async function main() {
|
|
|
11
12
|
await startCluster(options);
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
main();
|
|
15
|
+
void main();
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { ForkOptions } from 'node:child_process';
|
|
2
|
-
import { Command, Flags, Interfaces } from '@oclif/core';
|
|
3
|
-
import { PackageEgg } from './types.js';
|
|
4
|
-
export declare class ForkError extends Error {
|
|
5
|
-
code: number | null;
|
|
6
|
-
constructor(message: string, code: number | null);
|
|
7
|
-
}
|
|
8
|
-
export interface ForkNodeOptions extends ForkOptions {
|
|
9
|
-
dryRun?: boolean;
|
|
10
|
-
}
|
|
11
|
-
type Flags<T extends typeof Command> = Interfaces.InferredFlags<typeof BaseCommand['baseFlags'] & T['flags']>;
|
|
12
|
-
type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>;
|
|
13
|
-
export declare abstract class BaseCommand<T extends typeof Command> extends Command {
|
|
14
|
-
#private;
|
|
15
|
-
static enableJsonFlag: boolean;
|
|
16
|
-
static baseFlags: {
|
|
17
|
-
'dry-run': Interfaces.BooleanFlag<boolean>;
|
|
18
|
-
require: Interfaces.OptionFlag<string[] | undefined, Interfaces.CustomOptions>;
|
|
19
|
-
import: Interfaces.OptionFlag<string[] | undefined, Interfaces.CustomOptions>;
|
|
20
|
-
base: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
|
|
21
|
-
tscompiler: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
22
|
-
typescript: Interfaces.BooleanFlag<boolean>;
|
|
23
|
-
ts: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
24
|
-
javascript: Interfaces.BooleanFlag<boolean>;
|
|
25
|
-
declarations: Interfaces.BooleanFlag<boolean>;
|
|
26
|
-
inspect: Interfaces.BooleanFlag<boolean>;
|
|
27
|
-
'inspect-brk': Interfaces.BooleanFlag<boolean>;
|
|
28
|
-
};
|
|
29
|
-
protected flags: Flags<T>;
|
|
30
|
-
protected args: Args<T>;
|
|
31
|
-
protected env: {
|
|
32
|
-
[x: string]: string | undefined;
|
|
33
|
-
TZ?: string;
|
|
34
|
-
};
|
|
35
|
-
protected pkg: Record<string, any>;
|
|
36
|
-
protected isESM: boolean;
|
|
37
|
-
protected pkgEgg: PackageEgg;
|
|
38
|
-
protected globalExecArgv: string[];
|
|
39
|
-
init(): Promise<void>;
|
|
40
|
-
protected catch(err: Error & {
|
|
41
|
-
exitCode?: number;
|
|
42
|
-
}): Promise<any>;
|
|
43
|
-
protected finally(_: Error | undefined): Promise<any>;
|
|
44
|
-
protected formatRequires(): Promise<string[]>;
|
|
45
|
-
protected formatImportModule(modulePath: string): string;
|
|
46
|
-
protected addNodeOptions(options: string): void;
|
|
47
|
-
protected forkNode(modulePath: string, forkArgs: string[], options?: ForkNodeOptions): Promise<void>;
|
|
48
|
-
}
|
|
49
|
-
export {};
|