testeranto 0.110.0 → 0.112.0
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/common/PM/main.js +279 -87
- package/dist/common/run.js +4 -239
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/PM/main.js +280 -88
- package/dist/module/ReportClient.js +46 -46
- package/dist/module/run.js +4 -239
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/prebuild/ReportClient.js +1060 -60
- package/dist/prebuild/run.mjs +297 -334
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/PM/main.d.ts +16 -9
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/utils.d.ts +6 -0
- package/package.json +1 -1
- package/src/PM/main.ts +406 -112
- package/src/ReportClient.tsx +80 -70
- package/src/run.ts +5 -369
- package/src/utils.ts +10 -0
- package/tsc.log +8 -6
package/dist/common/run.js
CHANGED
|
@@ -37,261 +37,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
const ansi_colors_1 = __importDefault(require("ansi-colors"));
|
|
40
|
-
const fs_1 = require("fs");
|
|
41
|
-
const path_1 = __importDefault(require("path"));
|
|
42
|
-
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
43
|
-
const fs_2 = __importDefault(require("fs"));
|
|
44
|
-
const tsc_prog_1 = __importDefault(require("tsc-prog"));
|
|
45
|
-
const eslint_1 = require("eslint");
|
|
46
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
47
40
|
const readline_1 = __importDefault(require("readline"));
|
|
48
41
|
const main_1 = require("./PM/main");
|
|
49
|
-
const utils_1 = require("./utils");
|
|
50
|
-
console.log(ansi_colors_1.default.inverse("Press 'x' to shutdown forcefully."));
|
|
51
42
|
readline_1.default.emitKeypressEvents(process.stdin);
|
|
52
43
|
if (process.stdin.isTTY)
|
|
53
44
|
process.stdin.setRawMode(true);
|
|
45
|
+
console.log(ansi_colors_1.default.inverse("Press 'x' to shutdown forcefully."));
|
|
54
46
|
process.stdin.on("keypress", (str, key) => {
|
|
55
47
|
if (key.name === "x") {
|
|
56
48
|
console.log(ansi_colors_1.default.inverse("Shutting down forcefully..."));
|
|
57
49
|
process.exit(-1);
|
|
58
50
|
}
|
|
59
51
|
});
|
|
60
|
-
async function fileHash(filePath, algorithm = "md5") {
|
|
61
|
-
return new Promise((resolve, reject) => {
|
|
62
|
-
const hash = node_crypto_1.default.createHash(algorithm);
|
|
63
|
-
const fileStream = fs_2.default.createReadStream(filePath);
|
|
64
|
-
fileStream.on("data", (data) => {
|
|
65
|
-
hash.update(data);
|
|
66
|
-
});
|
|
67
|
-
fileStream.on("end", () => {
|
|
68
|
-
const fileHash = hash.digest("hex");
|
|
69
|
-
resolve(fileHash);
|
|
70
|
-
});
|
|
71
|
-
fileStream.on("error", (error) => {
|
|
72
|
-
reject(`Error reading file: ${error.message}`);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
async function filesHash(files, algorithm = "md5") {
|
|
77
|
-
return new Promise((resolve, reject) => {
|
|
78
|
-
resolve(files.reduce(async (mm, f) => {
|
|
79
|
-
return (await mm) + (await fileHash(f));
|
|
80
|
-
}, Promise.resolve("")));
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
const getRunnables = (tests, payload = {
|
|
84
|
-
nodeEntryPoints: {},
|
|
85
|
-
webEntryPoints: {},
|
|
86
|
-
}) => {
|
|
87
|
-
return tests.reduce((pt, cv, cndx, cry) => {
|
|
88
|
-
if (cv[1] === "node") {
|
|
89
|
-
pt.nodeEntryPoints[cv[0]] = path_1.default.resolve(`./docs/node/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`);
|
|
90
|
-
}
|
|
91
|
-
else if (cv[1] === "web") {
|
|
92
|
-
pt.webEntryPoints[cv[0]] = path_1.default.resolve(`./docs/web/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`);
|
|
93
|
-
}
|
|
94
|
-
if (cv[3].length) {
|
|
95
|
-
getRunnables(cv[3], payload);
|
|
96
|
-
}
|
|
97
|
-
return pt;
|
|
98
|
-
}, payload);
|
|
99
|
-
};
|
|
100
|
-
const changes = {};
|
|
101
|
-
const tscCheck = async ({ entrypoint, addableFiles, platform, }) => {
|
|
102
|
-
console.log(ansi_colors_1.default.green(ansi_colors_1.default.inverse(`tsc < ${entrypoint}`)));
|
|
103
|
-
const program = tsc_prog_1.default.createProgramFromConfig({
|
|
104
|
-
basePath: process.cwd(), // always required, used for relative paths
|
|
105
|
-
configFilePath: "tsconfig.json", // config to inherit from (optional)
|
|
106
|
-
compilerOptions: {
|
|
107
|
-
rootDir: "src",
|
|
108
|
-
outDir: (0, utils_1.tscPather)(entrypoint, platform),
|
|
109
|
-
// declaration: true,
|
|
110
|
-
// skipLibCheck: true,
|
|
111
|
-
noEmit: true,
|
|
112
|
-
},
|
|
113
|
-
include: addableFiles, //["src/**/*"],
|
|
114
|
-
// exclude: ["**/*.test.ts", "**/*.spec.ts"],
|
|
115
|
-
});
|
|
116
|
-
const tscPath = (0, utils_1.tscPather)(entrypoint, platform);
|
|
117
|
-
let allDiagnostics = program.getSemanticDiagnostics();
|
|
118
|
-
const d = [];
|
|
119
|
-
allDiagnostics.forEach((diagnostic) => {
|
|
120
|
-
if (diagnostic.file) {
|
|
121
|
-
let { line, character } = typescript_1.default.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
|
122
|
-
let message = typescript_1.default.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
|
123
|
-
d.push(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
d.push(typescript_1.default.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
fs_2.default.writeFileSync(tscPath, d.join("\n"));
|
|
130
|
-
fs_2.default.writeFileSync((0, utils_1.tscExitCodePather)(entrypoint, platform), d.length.toString());
|
|
131
|
-
};
|
|
132
|
-
const eslint = new eslint_1.ESLint();
|
|
133
|
-
const formatter = await eslint.loadFormatter("./node_modules/testeranto/dist/prebuild/esbuildConfigs/eslint-formatter-testeranto.mjs");
|
|
134
|
-
const eslintCheck = async (entrypoint, platform, addableFiles) => {
|
|
135
|
-
console.log(ansi_colors_1.default.green(ansi_colors_1.default.inverse(`eslint < ${entrypoint}`)));
|
|
136
|
-
const results = (await eslint.lintFiles(addableFiles))
|
|
137
|
-
.filter((r) => r.messages.length)
|
|
138
|
-
.filter((r) => {
|
|
139
|
-
return r.messages[0].ruleId !== null;
|
|
140
|
-
})
|
|
141
|
-
.map((r) => {
|
|
142
|
-
delete r.source;
|
|
143
|
-
return r;
|
|
144
|
-
});
|
|
145
|
-
fs_2.default.writeFileSync((0, utils_1.lintPather)(entrypoint, platform), await formatter.format(results));
|
|
146
|
-
fs_2.default.writeFileSync((0, utils_1.lintExitCodePather)(entrypoint, platform), results.length.toString());
|
|
147
|
-
};
|
|
148
|
-
const makePrompt = async (entryPoint, addableFiles, platform) => {
|
|
149
|
-
const promptPath = path_1.default.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `prompt.txt`);
|
|
150
|
-
const testPaths = path_1.default.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `tests.json`);
|
|
151
|
-
const featuresPath = path_1.default.join("./docs/", platform, entryPoint.split(".").slice(0, -1).join("."), `featurePrompt.txt`);
|
|
152
|
-
fs_2.default.writeFileSync(promptPath, `
|
|
153
|
-
${addableFiles
|
|
154
|
-
.map((x) => {
|
|
155
|
-
return `/add ${x}`;
|
|
156
|
-
})
|
|
157
|
-
.join("\n")}
|
|
158
|
-
|
|
159
|
-
/read ${(0, utils_1.lintPather)(entryPoint, platform)}
|
|
160
|
-
/read ${(0, utils_1.tscPather)(entryPoint, platform)}
|
|
161
|
-
/read ${testPaths}
|
|
162
|
-
|
|
163
|
-
/load ${featuresPath}
|
|
164
|
-
|
|
165
|
-
/code Fix the failing tests described in ${testPaths}. Correct any type signature errors described in the files ${(0, utils_1.tscPather)(entryPoint, platform)}. Implement any method which throws "Function not implemented. Resolve the lint errors described in ${(0, utils_1.lintPather)(entryPoint, platform)}"
|
|
166
|
-
`);
|
|
167
|
-
};
|
|
168
|
-
const metafileOutputs = async (platform) => {
|
|
169
|
-
const metafile = JSON.parse(fs_2.default.readFileSync(`docs/${platform}/metafile.json`).toString()).metafile;
|
|
170
|
-
if (!metafile)
|
|
171
|
-
return;
|
|
172
|
-
const outputs = metafile.outputs;
|
|
173
|
-
Object.keys(outputs).forEach(async (k) => {
|
|
174
|
-
const addableFiles = Object.keys(outputs[k].inputs).filter((i) => {
|
|
175
|
-
if (!fs_2.default.existsSync(i))
|
|
176
|
-
return false;
|
|
177
|
-
if (i.startsWith("node_modules"))
|
|
178
|
-
return false;
|
|
179
|
-
return true;
|
|
180
|
-
});
|
|
181
|
-
const f = `${k.split(".").slice(0, -1).join(".")}/`;
|
|
182
|
-
if (!fs_2.default.existsSync(f)) {
|
|
183
|
-
fs_2.default.mkdirSync(f);
|
|
184
|
-
}
|
|
185
|
-
const entrypoint = outputs[k].entryPoint;
|
|
186
|
-
if (entrypoint) {
|
|
187
|
-
const changeDigest = await filesHash(addableFiles);
|
|
188
|
-
if (changeDigest === changes[entrypoint]) {
|
|
189
|
-
// skip
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
changes[entrypoint] = changeDigest;
|
|
193
|
-
tscCheck({ platform, addableFiles, entrypoint });
|
|
194
|
-
eslintCheck(entrypoint, platform, addableFiles);
|
|
195
|
-
makePrompt(entrypoint, addableFiles, platform);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
};
|
|
200
52
|
Promise.resolve(`${process.cwd() + "/" + process.argv[2]}`).then(s => __importStar(require(s))).then(async (module) => {
|
|
201
53
|
const rawConfig = module.default;
|
|
202
54
|
const config = Object.assign(Object.assign({}, rawConfig), { buildDir: process.cwd() + "/" + rawConfig.outdir });
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
let pm = new main_1.PM_Main(config);
|
|
206
|
-
console.log(ansi_colors_1.default.inverse(`Press 'q' to shutdown gracefully`));
|
|
55
|
+
const pm = new main_1.PM_Main(config);
|
|
56
|
+
pm.start();
|
|
207
57
|
process.stdin.on("keypress", (str, key) => {
|
|
208
58
|
if (key.name === "q") {
|
|
209
|
-
|
|
210
|
-
mode = "PROD";
|
|
211
|
-
// onDone();
|
|
212
|
-
nodeMetafileWatcher.close();
|
|
213
|
-
webMetafileWatcher.close();
|
|
214
|
-
pm.shutDown();
|
|
59
|
+
pm.stop();
|
|
215
60
|
}
|
|
216
61
|
});
|
|
217
|
-
metafileOutputs("node");
|
|
218
|
-
const nodeMetafileWatcher = (0, fs_1.watch)("docs/node/metafile.json", async (e, filename) => {
|
|
219
|
-
console.log(ansi_colors_1.default.green(ansi_colors_1.default.inverse(`< ${e} ${filename} (node)`)));
|
|
220
|
-
metafileOutputs("node");
|
|
221
|
-
});
|
|
222
|
-
metafileOutputs("web");
|
|
223
|
-
const webMetafileWatcher = (0, fs_1.watch)("docs/web/metafile.json", async (e, filename) => {
|
|
224
|
-
console.log(ansi_colors_1.default.green(ansi_colors_1.default.inverse(`< ${e} ${filename} (web)`)));
|
|
225
|
-
metafileOutputs("web");
|
|
226
|
-
});
|
|
227
|
-
await pm.startPuppeteer({
|
|
228
|
-
slowMo: 1,
|
|
229
|
-
// timeout: 1,
|
|
230
|
-
waitForInitialPage: false,
|
|
231
|
-
executablePath:
|
|
232
|
-
// process.env.CHROMIUM_PATH || "/opt/homebrew/bin/chromium",
|
|
233
|
-
"/opt/homebrew/bin/chromium",
|
|
234
|
-
headless: true,
|
|
235
|
-
dumpio: true,
|
|
236
|
-
// timeout: 0,
|
|
237
|
-
devtools: true,
|
|
238
|
-
args: [
|
|
239
|
-
"--auto-open-devtools-for-tabs",
|
|
240
|
-
`--remote-debugging-port=3234`,
|
|
241
|
-
// "--disable-features=IsolateOrigins,site-per-process",
|
|
242
|
-
"--disable-site-isolation-trials",
|
|
243
|
-
"--allow-insecure-localhost",
|
|
244
|
-
"--allow-file-access-from-files",
|
|
245
|
-
"--allow-running-insecure-content",
|
|
246
|
-
"--disable-dev-shm-usage",
|
|
247
|
-
"--disable-extensions",
|
|
248
|
-
"--disable-gpu",
|
|
249
|
-
"--disable-setuid-sandbox",
|
|
250
|
-
"--disable-site-isolation-trials",
|
|
251
|
-
"--disable-web-security",
|
|
252
|
-
"--no-first-run",
|
|
253
|
-
"--no-sandbox",
|
|
254
|
-
"--no-startup-window",
|
|
255
|
-
// "--no-zygote",
|
|
256
|
-
"--reduce-security-for-testing",
|
|
257
|
-
"--remote-allow-origins=*",
|
|
258
|
-
"--unsafely-treat-insecure-origin-as-secure=*",
|
|
259
|
-
// "--disable-features=IsolateOrigins",
|
|
260
|
-
// "--remote-allow-origins=ws://localhost:3234",
|
|
261
|
-
// "--single-process",
|
|
262
|
-
// "--unsafely-treat-insecure-origin-as-secure",
|
|
263
|
-
// "--unsafely-treat-insecure-origin-as-secure=ws://192.168.0.101:3234",
|
|
264
|
-
// "--disk-cache-dir=/dev/null",
|
|
265
|
-
// "--disk-cache-size=1",
|
|
266
|
-
// "--start-maximized",
|
|
267
|
-
],
|
|
268
|
-
}, ".");
|
|
269
|
-
const { nodeEntryPoints, webEntryPoints } = getRunnables(config.tests);
|
|
270
|
-
Object.entries(nodeEntryPoints).forEach(([k, outputFile]) => {
|
|
271
|
-
pm.launchNode(k, outputFile);
|
|
272
|
-
try {
|
|
273
|
-
(0, fs_1.watch)(outputFile, async (e, filename) => {
|
|
274
|
-
const hash = await fileHash(outputFile);
|
|
275
|
-
if (fileHashes[k] !== hash) {
|
|
276
|
-
fileHashes[k] = hash;
|
|
277
|
-
console.log(ansi_colors_1.default.green(ansi_colors_1.default.inverse(`< ${e} ${filename}`)));
|
|
278
|
-
pm.launchNode(k, outputFile);
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
catch (e) {
|
|
283
|
-
console.error(e);
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
Object.entries(webEntryPoints).forEach(([k, outputFile]) => {
|
|
287
|
-
pm.launchWeb(k, outputFile);
|
|
288
|
-
(0, fs_1.watch)(outputFile, async (e, filename) => {
|
|
289
|
-
const hash = await fileHash(outputFile);
|
|
290
|
-
if (fileHashes[k] !== hash) {
|
|
291
|
-
fileHashes[k] = hash;
|
|
292
|
-
console.log(ansi_colors_1.default.green(ansi_colors_1.default.inverse(`< ${e} ${filename}`)));
|
|
293
|
-
pm.launchWeb(k, outputFile);
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
62
|
});
|