@antelopejs/tooling-configs 0.2.6 → 0.2.8

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.
@@ -1,376 +0,0 @@
1
- import "./ceilings-BSw9p4YB.mjs";
2
- import { n as IGNORE_PATTERNS, t as AGENT_IGNORE_PATTERNS } from "./shared-CsXIMK3I.mjs";
3
- import { closeSync, existsSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, rmSync, symlinkSync } from "node:fs";
4
- import { dirname, join, matchesGlob, relative, resolve } from "node:path";
5
- import { execFileSync, spawnSync } from "node:child_process";
6
- import { tmpdir } from "node:os";
7
- //#region src/guardrails/cli.ts
8
- function runCli(main) {
9
- try {
10
- process.exitCode = main();
11
- } catch (error) {
12
- process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
13
- process.exitCode = 1;
14
- }
15
- }
16
- //#endregion
17
- //#region src/guardrails/added-entries.ts
18
- function createAddedPolicy(globs) {
19
- return {
20
- globs,
21
- verdicts: /* @__PURE__ */ new Map(),
22
- allowed: /* @__PURE__ */ new Map(),
23
- problems: /* @__PURE__ */ new Set()
24
- };
25
- }
26
- function entryKey(directory, subpath) {
27
- return `${directory}\0${subpath}`;
28
- }
29
- function allowedByGlob(policy, subpath) {
30
- return policy.globs.some((glob) => matchesGlob(subpath, glob));
31
- }
32
- /** Substitutes each export star in order with its capture, as the published target pattern did. */
33
- function fillStars(pattern, captures, format = (capture) => capture) {
34
- let index = 0;
35
- return pattern.replaceAll("*", () => format(captures[index++] ?? captures[0] ?? ""));
36
- }
37
- const INTERNAL_TAG = /@internal\b/u;
38
- const MODULE_TAG = /@(?:packageDocumentation|module|fileoverview)\b/u;
39
- function exportedLocalNames(compiler, source) {
40
- const names = /* @__PURE__ */ new Set();
41
- for (const statement of source.statements) {
42
- if (compiler.isExportDeclaration(statement) && statement.moduleSpecifier === void 0 && statement.exportClause !== void 0 && compiler.isNamedExports(statement.exportClause)) for (const element of statement.exportClause.elements) names.add((element.propertyName ?? element.name).text);
43
- if (compiler.isExportAssignment(statement) && compiler.isIdentifier(statement.expression)) names.add(statement.expression.text);
44
- }
45
- return names;
46
- }
47
- function declaredNames(compiler, statement) {
48
- if (compiler.isVariableStatement(statement)) return statement.declarationList.declarations.flatMap((declaration) => compiler.isIdentifier(declaration.name) ? [declaration.name.text] : []);
49
- if ((compiler.isFunctionDeclaration(statement) || compiler.isClassDeclaration(statement) || compiler.isInterfaceDeclaration(statement) || compiler.isTypeAliasDeclaration(statement) || compiler.isEnumDeclaration(statement) || compiler.isModuleDeclaration(statement)) && statement.name !== void 0 && compiler.isIdentifier(statement.name)) return [statement.name.text];
50
- return [];
51
- }
52
- function isExportedDeclaration(compiler, statement, locals) {
53
- if (compiler.isExportAssignment(statement)) return !compiler.isIdentifier(statement.expression);
54
- if ((compiler.canHaveModifiers(statement) ? compiler.getModifiers(statement) : void 0)?.some((modifier) => modifier.kind === compiler.SyntaxKind.ExportKeyword)) return true;
55
- return declaredNames(compiler, statement).some((name) => locals.has(name));
56
- }
57
- function hasInternalTag(compiler, statement) {
58
- return compiler.getJSDocTags(statement).some((tag) => tag.tagName.text === "internal");
59
- }
60
- /** Whether a module's text carries `@internal` on the module (with `@packageDocumentation`, `@module` or `@fileoverview`) or on every exported declaration. */
61
- function isInternalModule(compiler, text) {
62
- const source = compiler.createSourceFile("module.ts", text, compiler.ScriptTarget.Latest, true);
63
- if ((compiler.getLeadingCommentRanges(text, 0) ?? []).map((range) => text.slice(range.pos, range.end)).some((comment) => comment.startsWith("/**") && INTERNAL_TAG.test(comment) && MODULE_TAG.test(comment))) return true;
64
- const locals = exportedLocalNames(compiler, source);
65
- const exported = source.statements.filter((statement) => isExportedDeclaration(compiler, statement, locals));
66
- return exported.length > 0 && exported.every((statement) => hasInternalTag(compiler, statement));
67
- }
68
- /** Records why an allowed added entry is not internal, or `undefined` when its module is. */
69
- function recordVerdict(policy, compiler, entry) {
70
- const internal = isInternalModule(compiler, readFileSync(entry.module, "utf8"));
71
- policy.verdicts.set(entryKey(entry.directory, entry.subpath), internal ? void 0 : `${entry.label}: added entry ./${entry.subpath} is allowed by --allow-added but is not marked @internal. Add a leading "/** @internal @packageDocumentation */" comment to the file, or tag every exported declaration with "/** @internal */".`);
72
- }
73
- /** Lets matching, `@internal` additions through by removing them from the head output; returns how many files were removed. */
74
- function applyAllowance(policy, base, head, remove) {
75
- const existing = new Set(base.map(({ path }) => path));
76
- let removed = 0;
77
- for (const entry of head) {
78
- if (existing.has(entry.path) || !allowedByGlob(policy, entry.subpath)) continue;
79
- const key = entryKey(entry.directory, entry.subpath);
80
- const problem = policy.verdicts.has(key) ? policy.verdicts.get(key) : `${entry.directory}: added entry ./${entry.subpath} has no emitted declaration, so @internal cannot be verified.`;
81
- if (problem !== void 0) {
82
- policy.problems.add(problem);
83
- continue;
84
- }
85
- remove(entry.path);
86
- removed += 1;
87
- policy.allowed.set(key, {
88
- directory: entry.directory,
89
- subpath: entry.subpath
90
- });
91
- }
92
- return removed;
93
- }
94
- /** The "Added (allowed)" list with its count, or the problems that kept additions from passing. */
95
- function describeAllowance(policy) {
96
- const lines = [...policy.allowed.values()].map(({ directory, subpath }) => ` ${directory}: ./${subpath}\n`).sort();
97
- return `Added (allowed): ${lines.length}\n${lines.join("")}${[...policy.problems].map((problem) => `Not internal: ${problem}\n`).join("")}`;
98
- }
99
- //#endregion
100
- //#region src/guardrails/revisions.ts
101
- function trackedManifests(root) {
102
- return execFileSync("git", ["ls-files", "-z"], {
103
- cwd: root,
104
- encoding: "utf8"
105
- }).split("\0").filter((file) => file === "package.json" || file.endsWith("/package.json"));
106
- }
107
- const DIRECTORY_LINK = process.platform === "win32" ? "junction" : "dir";
108
- function linkDependencies(root, worktree) {
109
- const directories = /* @__PURE__ */ new Set([".", ...trackedManifests(root).map(dirname)]);
110
- for (const directory of directories) {
111
- const source = join(root, directory, "node_modules");
112
- const target = join(worktree, directory, "node_modules");
113
- if (existsSync(source) && existsSync(dirname(target)) && !existsSync(target)) symlinkSync(source, target, DIRECTORY_LINK);
114
- }
115
- }
116
- /** Compares isolated committed revisions and removes both worktrees even when compilation fails; a policy lets matching `@internal` additions through. */
117
- function compareRevisions(root, baseRef, label, emit, policy) {
118
- const temporary = mkdtempSync(join(tmpdir(), "antelope-proof-"));
119
- const worktrees = [];
120
- const results = [];
121
- try {
122
- for (const [side, ref] of [["base", baseRef], ["head", "HEAD"]]) {
123
- const revision = execFileSync("git", [
124
- "rev-parse",
125
- "--verify",
126
- "--end-of-options",
127
- `${ref}^{commit}`
128
- ], {
129
- cwd: root,
130
- encoding: "utf8",
131
- stdio: [
132
- "ignore",
133
- "pipe",
134
- "pipe"
135
- ]
136
- }).trim();
137
- const worktree = join(temporary, "worktrees", side);
138
- execFileSync("git", [
139
- "worktree",
140
- "add",
141
- "--quiet",
142
- "--detach",
143
- worktree,
144
- revision
145
- ], {
146
- cwd: root,
147
- stdio: [
148
- "ignore",
149
- "pipe",
150
- "pipe"
151
- ]
152
- });
153
- worktrees.push(worktree);
154
- linkDependencies(root, worktree);
155
- const output = join(temporary, side);
156
- mkdirSync(output, { recursive: true });
157
- results.push(emit(worktree, output, join(temporary, "emit", side)));
158
- }
159
- const allowedAdditions = policy === void 0 ? 0 : applyAllowance(policy, results[0].published ?? [], results[1].published ?? [], (path) => rmSync(join(temporary, "head", path), { force: true }));
160
- const diff = spawnSync("git", [
161
- "diff",
162
- "--no-index",
163
- "--no-color",
164
- "--no-renames",
165
- "--no-ext-diff",
166
- "--no-textconv",
167
- "--",
168
- "base",
169
- "head"
170
- ], {
171
- cwd: temporary,
172
- encoding: "utf8",
173
- maxBuffer: 67108864
174
- });
175
- if (diff.error) throw diff.error;
176
- if (diff.status !== 0 && diff.status !== 1) throw new Error(diff.stderr || "Could not compare revision outputs.");
177
- const packages = new Set(results.flatMap((result) => result.packages)).size;
178
- return {
179
- different: diff.status === 1,
180
- output: diff.status === 1 ? `${label}: differences against ${baseRef} (committed HEAD).\n${diff.stdout}` : `${label}: ${packages} packages, ${results[1].entries - allowedAdditions} entries unchanged against ${baseRef} (committed HEAD).\n`
181
- };
182
- } finally {
183
- for (const worktree of worktrees.reverse()) execFileSync("git", [
184
- "worktree",
185
- "remove",
186
- "--force",
187
- worktree
188
- ], {
189
- cwd: root,
190
- stdio: "pipe"
191
- });
192
- rmSync(temporary, {
193
- recursive: true,
194
- force: true
195
- });
196
- }
197
- }
198
- const COUNTS = [
199
- ["oxlint-disable / eslint-disable directive lines", /^\s*(?:\/\/|\/\*|\*)\s*(?:oxlint|eslint)-disable\b/u],
200
- ["SAFETY: lines", /^\s*(?:\/\/|\/\*|\*)\s*SAFETY:/u],
201
- ["@ts-expect-error lines", /^\s*(?:\/\/|\/\*|\*)\s*@ts-expect-error\b/u]
202
- ];
203
- const CODE_PATHSPECS = [
204
- "*.ts",
205
- "*.tsx",
206
- "*.mts",
207
- "*.cts",
208
- "*.js",
209
- "*.jsx",
210
- "*.mjs",
211
- "*.cjs",
212
- "*.vue"
213
- ];
214
- function countsAt(root, ref) {
215
- const result = spawnSync("git", [
216
- "grep",
217
- "-h",
218
- "-I",
219
- "-E",
220
- "-e",
221
- "(oxlint|eslint)-disable|SAFETY:|@ts-expect-error",
222
- ref,
223
- "--",
224
- ...CODE_PATHSPECS
225
- ], {
226
- cwd: root,
227
- encoding: "utf8",
228
- maxBuffer: 67108864
229
- });
230
- if (result.error) throw result.error;
231
- if (result.status !== 0 && result.status !== 1) throw new Error(result.stderr);
232
- const lines = result.stdout.split("\n");
233
- return COUNTS.map(([, pattern]) => lines.filter((line) => pattern.test(line)).length);
234
- }
235
- /** Counts directive, `SAFETY:` and `@ts-expect-error` lines in every tracked code file at the base and at committed HEAD, so a PR body copies them instead of typing them. */
236
- function revisionCounts(root, baseRef) {
237
- const base = countsAt(root, baseRef);
238
- const head = countsAt(root, "HEAD");
239
- return `\nCounts in tracked code files (${baseRef} and committed HEAD).\n| Lines | base | HEAD |\n| --- | ---: | ---: |\n${COUNTS.map(([label], index) => `| ${label} | ${base[index]} | ${head[index]} |`).join("\n")}\n`;
240
- }
241
- //#endregion
242
- //#region src/guardrails/files.ts
243
- const SIZE_EXCLUSIONS = [
244
- {
245
- kind: "generated",
246
- patterns: [
247
- ...IGNORE_PATTERNS,
248
- ...AGENT_IGNORE_PATTERNS,
249
- "**/*.generated.*",
250
- "**/generated/**",
251
- "**/__snapshots__/**"
252
- ]
253
- },
254
- {
255
- kind: "fixtures",
256
- patterns: ["**/fixtures/**", "**/__fixtures__/**"]
257
- },
258
- {
259
- kind: "data",
260
- patterns: ["**/*.{json,jsonc,json5}"]
261
- },
262
- {
263
- kind: "lockfiles",
264
- patterns: [
265
- "**/{pnpm-lock.yaml,package-lock.json,npm-shrinkwrap.json,yarn.lock,bun.lock,bun.lockb,Cargo.lock,poetry.lock,uv.lock,Gemfile.lock,composer.lock,go.sum}",
266
- "**/*.lock",
267
- "**/*.lockb"
268
- ]
269
- },
270
- {
271
- kind: "documentation",
272
- patterns: ["**/CHANGELOG.md", "**/*.{md,mdx,markdown,MD}"]
273
- },
274
- {
275
- kind: "assets",
276
- patterns: ["**/*.{png,jpg,jpeg,gif,webp,avif,ico,svg,bmp,tiff,pdf,mp3,wav,ogg,flac,mp4,webm,mov,avi,woff,woff2,ttf,otf,eot,zip,gz,tgz,bz2,xz,7z,tar,rar,wasm,bin,exe,dll,so,dylib,db,sqlite,sqlite3,icns}"]
277
- }
278
- ];
279
- function gitFiles(root) {
280
- return [...new Set(execFileSync("git", [
281
- "ls-files",
282
- "--cached",
283
- "--others",
284
- "--exclude-standard",
285
- "-z"
286
- ], {
287
- cwd: root,
288
- encoding: "utf8"
289
- }).split("\0").filter(Boolean))];
290
- }
291
- function repositoryRoot(cwd = process.cwd()) {
292
- return execFileSync("git", ["rev-parse", "--show-toplevel"], {
293
- cwd,
294
- encoding: "utf8"
295
- }).trim();
296
- }
297
- /** Resolves a user-supplied revision to a commit id, so it can never read as an option. */
298
- function resolveRevision(root, revision) {
299
- return execFileSync("git", [
300
- "rev-parse",
301
- "--verify",
302
- "--end-of-options",
303
- `${revision}^{commit}`
304
- ], {
305
- cwd: root,
306
- encoding: "utf8",
307
- stdio: [
308
- "ignore",
309
- "pipe",
310
- "pipe"
311
- ]
312
- }).trim();
313
- }
314
- function repositoryPath(root, file) {
315
- return relative(root, resolve(root, file)).split("\\").join("/");
316
- }
317
- function fileBytes(root, file, staged = false) {
318
- if (staged) {
319
- const result = spawnSync("git", [
320
- "cat-file",
321
- "-s",
322
- `:${file}`
323
- ], {
324
- cwd: root,
325
- encoding: "utf8"
326
- });
327
- if (result.error) throw result.error;
328
- return result.status === 0 ? Number(result.stdout.trim()) : void 0;
329
- }
330
- const path = join(root, file);
331
- if (!existsSync(path)) return void 0;
332
- const stat = lstatSync(path);
333
- return stat.isFile() ? stat.size : void 0;
334
- }
335
- /** A package root is the directory of a tracked manifest outside every `src` directory; its top-level `build` and `output` are generated output. */
336
- function packageOutputPatterns(root) {
337
- return trackedManifests(root).flatMap((manifest) => {
338
- const directory = dirname(manifest);
339
- if (directory === "." || directory.split("/").includes("src")) return [];
340
- return [`${directory}/build/**`, `${directory}/output/**`];
341
- });
342
- }
343
- /** `path.matchesGlob` never lets `*` or `**` cross a segment starting with a dot, so each path is also tried with those dots removed. */
344
- function isExcluded(file, packageOutputs) {
345
- const undotted = file.replace(/(^|\/)\./gu, "$1");
346
- const matches = (pattern) => matchesGlob(file, pattern) || matchesGlob(undotted, pattern);
347
- return SIZE_EXCLUSIONS.some(({ patterns }) => patterns.some(matches)) || packageOutputs.some(matches);
348
- }
349
- function isBinary(root, file, staged) {
350
- if (staged) return execFileSync("git", ["show", `:${file}`], {
351
- cwd: root,
352
- maxBuffer: fileBytes(root, file, true)
353
- }).subarray(0, 8e3).includes(0);
354
- const descriptor = openSync(join(root, file), "r");
355
- try {
356
- const prefix = Buffer.alloc(8e3);
357
- const length = readSync(descriptor, prefix, 0, prefix.length, 0);
358
- return prefix.subarray(0, length).includes(0);
359
- } finally {
360
- closeSync(descriptor);
361
- }
362
- }
363
- function authoredSizes(root, files = gitFiles(root), staged = false) {
364
- const sizes = /* @__PURE__ */ new Map();
365
- const packageOutputs = packageOutputPatterns(root);
366
- for (const input of files) {
367
- const file = repositoryPath(root, input);
368
- if (isExcluded(file, packageOutputs)) continue;
369
- const size = fileBytes(root, file, staged);
370
- if (size !== void 0 && size > 2e4 && isBinary(root, file, staged)) continue;
371
- if (size !== void 0) sizes.set(file, size);
372
- }
373
- return sizes;
374
- }
375
- //#endregion
376
- export { resolveRevision as a, revisionCounts as c, createAddedPolicy as d, describeAllowance as f, runCli as h, repositoryRoot as i, trackedManifests as l, recordVerdict as m, gitFiles as n, DIRECTORY_LINK as o, fillStars as p, repositoryPath as r, compareRevisions as s, authoredSizes as t, allowedByGlob as u };
@@ -1,169 +0,0 @@
1
- import { l as trackedManifests } from "./files-BOpSsyuD.mjs";
2
- import { createRequire } from "node:module";
3
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
4
- import { dirname, join, matchesGlob, relative, resolve, sep } from "node:path";
5
- //#region src/guardrails/typescript.ts
6
- /** A proof analyses only packages that publish something: not private, and declaring at least one of `exports`, `main`, `types`, `typings` or `typesVersions`. */
7
- function unpublishedReason(manifest) {
8
- if (manifest.private === true) return "private";
9
- return [
10
- manifest.exports,
11
- manifest.main,
12
- manifest.types,
13
- manifest.typings,
14
- manifest.typesVersions
15
- ].some((field) => field != null) ? void 0 : "no exports, main or types";
16
- }
17
- function trackedPackages(root) {
18
- return trackedManifests(root).flatMap((file) => {
19
- const directory = dirname(file);
20
- if (!existsSync(join(root, directory, "tsconfig.json"))) return [];
21
- return [{
22
- directory,
23
- manifest: JSON.parse(readFileSync(join(root, file), "utf8"))
24
- }];
25
- });
26
- }
27
- function packagesAt(root, publishedOnly) {
28
- return trackedPackages(root).filter(({ manifest }) => !publishedOnly || unpublishedReason(manifest) === void 0);
29
- }
30
- /** The packages a published-only proof leaves out, each with the reason, so a skip is reported rather than silent. */
31
- function unpublishedAt(root) {
32
- return trackedPackages(root).flatMap(({ directory, manifest }) => {
33
- const reason = unpublishedReason(manifest);
34
- return reason === void 0 ? [] : [{
35
- directory,
36
- reason
37
- }];
38
- });
39
- }
40
- function packageRoot(file) {
41
- let directory = dirname(file);
42
- while (!existsSync(join(directory, "package.json"))) {
43
- const parent = dirname(directory);
44
- if (parent === directory) return dirname(file);
45
- directory = parent;
46
- }
47
- return directory;
48
- }
49
- /** Loads the compiler a package builds with, including a package-local installation in a workspace, falling back to the one `dts-bundle-generator` brings. A TypeScript without the programmatic API (7 and later) is an error rather than a crash. */
50
- function loadTypeScript(directory) {
51
- const own = createRequire(import.meta.url);
52
- let file;
53
- try {
54
- file = createRequire(join(directory, "package.json")).resolve("typescript");
55
- } catch {
56
- file = createRequire(own.resolve("dts-bundle-generator")).resolve("typescript");
57
- }
58
- const compiler = createRequire(file)("typescript");
59
- const root = packageRoot(file);
60
- if (compiler.sys === void 0 || !("createProgram" in compiler)) throw new Error(`TypeScript ${compiler.version} at ${root} has no programmatic compiler API (sys, createProgram), so this package cannot be analysed. Build it with a TypeScript that has one, or mark the package private.`);
61
- return {
62
- compiler,
63
- root
64
- };
65
- }
66
- const TEST_SOURCE_GLOBS = [
67
- "**/*.test.*",
68
- "**/*.spec.*",
69
- "**/__tests__/**",
70
- "test/**",
71
- "tests/**"
72
- ];
73
- function isTestSource(root, file) {
74
- const path = relative(root, file).split("\\").join("/");
75
- return TEST_SOURCE_GLOBS.some((pattern) => matchesGlob(path, pattern));
76
- }
77
- function failDiagnostics(compiler, diagnostics) {
78
- const errors = diagnostics.filter((item) => item.category === compiler.DiagnosticCategory.Error);
79
- if (errors.length) throw new Error(compiler.formatDiagnostics(errors, {
80
- getCanonicalFileName: (file) => file,
81
- getCurrentDirectory: () => process.cwd(),
82
- getNewLine: () => "\n"
83
- }));
84
- }
85
- /** Declaration inputs are part of the local closure but TypeScript does not emit copies of them. */
86
- function copyDeclarations(program, directory, output) {
87
- const sources = program.getSourceFiles().filter((source) => !program.isSourceFileDefaultLibrary(source) && !program.isSourceFileFromExternalLibrary(source) && !relative(directory, source.fileName).startsWith(`..${sep}`) && !isTestSource(directory, source.fileName));
88
- const authored = sources.filter((source) => !source.isDeclarationFile);
89
- let root = dirname((authored[0] ?? sources[0])?.fileName ?? join(directory, "index.ts"));
90
- for (const source of authored.length ? authored : sources) while (relative(root, source.fileName).startsWith(`..${sep}`)) root = dirname(root);
91
- root = program.getCompilerOptions().rootDir ?? root;
92
- const files = [];
93
- for (const source of sources) {
94
- if (!source.isDeclarationFile) continue;
95
- const path = relative(root, source.fileName);
96
- if (path.startsWith(`..${sep}`)) continue;
97
- const target = join(output, path);
98
- mkdirSync(dirname(target), { recursive: true });
99
- writeFileSync(target, source.text);
100
- files.push(target);
101
- }
102
- return files;
103
- }
104
- function parseConfig(directory) {
105
- const { compiler, root } = loadTypeScript(directory);
106
- const config = compiler.readConfigFile(join(directory, "tsconfig.json"), compiler.sys.readFile);
107
- if (config.error) failDiagnostics(compiler, [config.error]);
108
- const parsed = compiler.parseJsonConfigFileContent(config.config, compiler.sys, directory);
109
- failDiagnostics(compiler, parsed.errors);
110
- return {
111
- compiler,
112
- root,
113
- parsed
114
- };
115
- }
116
- /** The configured `outDir`, the root under which the declaration half already judges a built path as test output. */
117
- function outputRoot(directory) {
118
- return resolve(directory, parseConfig(directory).parsed.options.outDir ?? ".");
119
- }
120
- /** Emits with the package's compiler and config; test roots and outputs never enter either proof. `modules` maps each emitted file to its source module. */
121
- function emitPackage(directory, output, declarations) {
122
- const { compiler, root, parsed } = parseConfig(directory);
123
- const options = {
124
- ...parsed.options,
125
- rootDir: parsed.options.rootDir ?? (parsed.options.outDir ? void 0 : directory),
126
- outDir: output,
127
- declarationDir: declarations ? output : void 0,
128
- declaration: declarations,
129
- emitDeclarationOnly: declarations,
130
- removeComments: true,
131
- declarationMap: false,
132
- sourceMap: false,
133
- inlineSourceMap: false,
134
- noEmit: false,
135
- noEmitOnError: false,
136
- composite: false,
137
- incremental: false,
138
- tsBuildInfoFile: void 0,
139
- outFile: void 0,
140
- allowImportingTsExtensions: declarations ? parsed.options.allowImportingTsExtensions : false
141
- };
142
- const program = compiler.createProgram({
143
- rootNames: parsed.fileNames.filter((file) => !isTestSource(directory, file)),
144
- options,
145
- projectReferences: parsed.projectReferences
146
- });
147
- if (declarations) failDiagnostics(compiler, compiler.getPreEmitDiagnostics(program));
148
- const files = [];
149
- const modules = /* @__PURE__ */ new Map();
150
- const result = program.emit(void 0, (file, text, _bom, _onError, sources) => {
151
- if (sources?.some((source) => isTestSource(directory, source.fileName))) return;
152
- if (declarations ? !/\.d\.[cm]?ts$/.test(file) : !/\.[cm]?jsx?$/.test(file)) return;
153
- mkdirSync(dirname(file), { recursive: true });
154
- writeFileSync(file, text);
155
- files.push(file);
156
- if (sources?.[0] !== void 0) modules.set(resolve(file), sources[0].fileName);
157
- });
158
- if (declarations) failDiagnostics(compiler, result.diagnostics);
159
- if (declarations) files.push(...copyDeclarations(program, directory, output));
160
- return {
161
- compiler,
162
- compilerRoot: root,
163
- files,
164
- modules,
165
- options: parsed.options
166
- };
167
- }
168
- //#endregion
169
- export { unpublishedAt as a, packagesAt as i, isTestSource as n, outputRoot as r, emitPackage as t };