ts-ag 1.1.26 → 1.2.1
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/browser.d.ts +1 -2
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +3 -3
- package/dist/browser.js.map +1 -1
- package/dist/{cli-CoTTeqrl.mjs → cli-DAs6KeZ2.mjs} +1 -3
- package/dist/index.d.mts +48 -39
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +367 -271
- package/dist/index.mjs.map +1 -1
- package/dist/scripts/check-llrt-worker.mjs +642 -0
- package/dist/scripts/ts-alias.mjs +3 -5
- package/dist/scripts/ts-build-config.mjs +40 -18
- package/dist/utils-DLairfc9.mjs +15 -0
- package/dist/worker.d.mts +1076 -0
- package/dist/worker.d.mts.map +1 -0
- package/dist/worker.mjs +1660 -0
- package/dist/worker.mjs.map +1 -0
- package/package.json +10 -3
- package/dist/cli-CoTTeqrl.mjs.map +0 -1
- package/dist/fs-y6bE7U3-.mjs +0 -40
- package/dist/fs-y6bE7U3-.mjs.map +0 -1
- package/dist/scripts/ts-alias.d.mts +0 -31
- package/dist/scripts/ts-alias.d.mts.map +0 -1
- package/dist/scripts/ts-alias.mjs.map +0 -1
- package/dist/scripts/ts-build-config.d.mts +0 -49
- package/dist/scripts/ts-build-config.d.mts.map +0 -1
- package/dist/scripts/ts-build-config.mjs.map +0 -1
|
@@ -1,14 +1,42 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import {
|
|
3
|
-
import { t as colorText } from "../cli-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
2
|
+
import { t as isDirectExecution } from "../utils-DLairfc9.mjs";
|
|
3
|
+
import { t as colorText } from "../cli-DAs6KeZ2.mjs";
|
|
4
|
+
import { lstat, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
5
|
+
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
6
|
+
import { parseArgs } from "node:util";
|
|
7
|
+
import console$1 from "console";
|
|
7
8
|
import { existsSync, mkdirSync, readFileSync } from "fs";
|
|
8
|
-
import { fileURLToPath } from "url";
|
|
9
9
|
import { watch } from "chokidar";
|
|
10
10
|
import { parseTsconfig } from "get-tsconfig";
|
|
11
11
|
import { format } from "oxfmt";
|
|
12
|
+
import chalk from "chalk";
|
|
13
|
+
//#region src/utils/fs.ts
|
|
14
|
+
/**
|
|
15
|
+
* @returns true if a filepath exists
|
|
16
|
+
*/
|
|
17
|
+
async function exists(filePath) {
|
|
18
|
+
try {
|
|
19
|
+
await lstat(filePath);
|
|
20
|
+
return true;
|
|
21
|
+
} catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Writes data to a filepath if it is different
|
|
27
|
+
* @returns true if the file is written to
|
|
28
|
+
*/
|
|
29
|
+
async function writeIfDifferent(filePath, newData) {
|
|
30
|
+
const directory = dirname(filePath);
|
|
31
|
+
if (!await exists(directory)) await mkdir(directory, { recursive: true });
|
|
32
|
+
if (await exists(filePath)) {
|
|
33
|
+
if (await readFile(filePath, "utf8") === newData) return false;
|
|
34
|
+
}
|
|
35
|
+
await writeFile(filePath, newData, "utf8");
|
|
36
|
+
console.log(chalk.green("Writing to"), filePath);
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
12
40
|
//#region src/scripts/ts-build-config.ts
|
|
13
41
|
const DEFAULT_TEST_EXCLUDES = [
|
|
14
42
|
"**/*.test.ts",
|
|
@@ -21,9 +49,9 @@ const DEFAULT_TEST_EXCLUDES = [
|
|
|
21
49
|
const GENERATED_FILE_HEADER = "// generated by ts-build-config";
|
|
22
50
|
const LABEL = colorText("cyan", "[ts-build-config]");
|
|
23
51
|
const formatPath = (filePath) => colorText("dim", relative(process.cwd(), filePath));
|
|
24
|
-
const logInfo = (message) => console.log(`${LABEL} ${message}`);
|
|
25
|
-
const logWarn = (message) => console.warn(`${LABEL} ${colorText("yellow", message)}`);
|
|
26
|
-
const logError = (message) => console.error(`${LABEL} ${colorText("red", message)}`);
|
|
52
|
+
const logInfo = (message) => console$1.log(`${LABEL} ${message}`);
|
|
53
|
+
const logWarn = (message) => console$1.warn(`${LABEL} ${colorText("yellow", message)}`);
|
|
54
|
+
const logError = (message) => console$1.error(`${LABEL} ${colorText("red", message)}`);
|
|
27
55
|
function unique(items) {
|
|
28
56
|
return Array.from(new Set(items));
|
|
29
57
|
}
|
|
@@ -152,7 +180,7 @@ async function generateBuildConfigs(entry, options) {
|
|
|
152
180
|
else throw new Error("Null returned from getTsConfig");
|
|
153
181
|
} catch (e) {
|
|
154
182
|
logWarn(`Skipping unreadable config: ${formatPath(tsconfigPath)}`);
|
|
155
|
-
if (verbose) console.warn(e);
|
|
183
|
+
if (verbose) console$1.warn(e);
|
|
156
184
|
continue;
|
|
157
185
|
}
|
|
158
186
|
loadedConfigs.set(res.path, res);
|
|
@@ -283,16 +311,10 @@ async function main() {
|
|
|
283
311
|
regenerator.syncWatchedConfigs(watcher);
|
|
284
312
|
});
|
|
285
313
|
}
|
|
286
|
-
|
|
287
|
-
if (!process.argv[1]) return false;
|
|
288
|
-
return resolve(process.argv[1]) === fileURLToPath(import.meta.url);
|
|
289
|
-
}
|
|
290
|
-
if (isDirectExecution()) main().catch((err) => {
|
|
314
|
+
if (isDirectExecution(import.meta.url)) main().catch((err) => {
|
|
291
315
|
logError("Unhandled error");
|
|
292
|
-
console.error(err);
|
|
316
|
+
console$1.error(err);
|
|
293
317
|
process.exit(1);
|
|
294
318
|
});
|
|
295
319
|
//#endregion
|
|
296
320
|
export { GENERATED_FILE_HEADER, computeExtraExcludes, createRegenerator, ensureDotRelative, formatBuildTsconfigJson, generateBuildConfigs, isGeneratedByThisScript, main, replaceRefsWithBuildConfigs, resolveTsConfigPath, shouldUseBuildConfig, unique, withTrailingNewline, writeBuildTsconfig };
|
|
297
|
-
|
|
298
|
-
//# sourceMappingURL=ts-build-config.mjs.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
//#region src/scripts/utils.ts
|
|
5
|
+
function isDirectExecution(importMetaUrl, argv = process.argv) {
|
|
6
|
+
const entrypoint = argv[1];
|
|
7
|
+
if (!entrypoint) return false;
|
|
8
|
+
try {
|
|
9
|
+
return realpathSync.native(resolve(entrypoint)) === realpathSync.native(fileURLToPath(importMetaUrl));
|
|
10
|
+
} catch {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { isDirectExecution as t };
|