@adamhl8/configs 3.5.1 → 4.1.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/README.md +53 -60
- package/dist/adamhl8-tsconfig/index +43 -0
- package/dist/configs/bask.base.d.ts +1 -2
- package/dist/configs/bask.base.js +20 -11
- package/dist/configs/bask.base.js.map +1 -1
- package/dist/configs/commitlint.base.d.ts +1 -2
- package/dist/configs/commitlint.base.js.map +1 -1
- package/dist/configs/configs.d.ts +7 -0
- package/dist/configs/configs.js +7 -0
- package/dist/configs/gitignore.base +0 -1
- package/dist/configs/knip.base.d.ts +17 -6
- package/dist/configs/knip.base.js +18 -9
- package/dist/configs/knip.base.js.map +1 -1
- package/dist/configs/oxfmt.base.d.ts +1 -2
- package/dist/configs/oxlint.base.d.ts +2 -3
- package/dist/configs/oxlint.base.js +12 -3
- package/dist/configs/oxlint.base.js.map +1 -1
- package/dist/configs/release-it.base.d.ts +1 -2
- package/dist/configs/tsconfig.base.json +1 -1
- package/dist/configs/tsconfig.no-dts.base.json +7 -0
- package/dist/configs/tsdown.base.d.ts +1 -2
- package/dist/configs/tsdown.base.js.map +1 -1
- package/dist/dep-report/dep-report.js +66 -0
- package/dist/dep-report/dep-report.js.map +1 -0
- package/dist/dep-report/prompt.md +28 -0
- package/dist/env/index.d.ts +1 -2
- package/dist/env/utils.d.ts +1 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -0
- package/dist/merge-config/merge-config.d.ts +5 -1
- package/dist/merge-config/merge-config.js +17 -7
- package/dist/merge-config/merge-config.js.map +1 -1
- package/dist/merge-config/merge.types.d.ts +1 -2
- package/dist/test-utils/fixture.d.ts +2 -9
- package/dist/test-utils/fixture.js +2 -3
- package/dist/test-utils/fixture.js.map +1 -1
- package/dist/test-utils/index.d.ts +2 -3
- package/dist/test-utils/index.js +3 -4
- package/dist/test-utils/pack.d.ts +5 -3
- package/dist/test-utils/pack.js +16 -4
- package/dist/test-utils/pack.js.map +1 -1
- package/dist/test-utils/shell/command.d.ts +1 -2
- package/dist/test-utils/shell/command.js +1 -1
- package/dist/test-utils/shell/command.js.map +1 -1
- package/dist/test-utils/shell/env.d.ts +1 -2
- package/dist/test-utils/shell/shell.d.ts +2 -1
- package/dist/test-utils/shell/shell.js +2 -1
- package/dist/test-utils/shell/shell.js.map +1 -1
- package/dist/test-utils/temp-dir.d.ts +2 -3
- package/dist/test-utils/temp-dir.js +5 -3
- package/dist/test-utils/temp-dir.js.map +1 -1
- package/dist/utils.js +11 -2
- package/dist/utils.js.map +1 -1
- package/package.json +28 -48
- package/dist/configs/bask.base.d.ts.map +0 -1
- package/dist/configs/commitlint.base.d.ts.map +0 -1
- package/dist/configs/knip.base.d.ts.map +0 -1
- package/dist/configs/oxfmt.base.d.ts.map +0 -1
- package/dist/configs/oxlint.base.d.ts.map +0 -1
- package/dist/configs/release-it.base.d.ts.map +0 -1
- package/dist/configs/tsdown.base.d.ts.map +0 -1
- package/dist/env/index.d.ts.map +0 -1
- package/dist/env/utils.d.ts.map +0 -1
- package/dist/merge-config/merge-config.d.ts.map +0 -1
- package/dist/merge-config/merge.types.d.ts.map +0 -1
- package/dist/test-utils/fixture.d.ts.map +0 -1
- package/dist/test-utils/pack.d.ts.map +0 -1
- package/dist/test-utils/shell/command.d.ts.map +0 -1
- package/dist/test-utils/shell/env.d.ts.map +0 -1
- package/dist/test-utils/shell/shell.d.ts.map +0 -1
- package/dist/test-utils/subprocess-coverage/child-preload.d.ts +0 -1
- package/dist/test-utils/subprocess-coverage/child-preload.js +0 -73
- package/dist/test-utils/subprocess-coverage/child-preload.js.map +0 -1
- package/dist/test-utils/subprocess-coverage/env.d.ts +0 -7
- package/dist/test-utils/subprocess-coverage/env.d.ts.map +0 -1
- package/dist/test-utils/subprocess-coverage/env.js +0 -19
- package/dist/test-utils/subprocess-coverage/env.js.map +0 -1
- package/dist/test-utils/subprocess-coverage/preload.d.ts +0 -1
- package/dist/test-utils/subprocess-coverage/preload.js +0 -43
- package/dist/test-utils/subprocess-coverage/preload.js.map +0 -1
- package/dist/test-utils/subprocess-coverage/report.js +0 -35
- package/dist/test-utils/subprocess-coverage/report.js.map +0 -1
- package/dist/test-utils/temp-dir.d.ts.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ShellCommand } from "./command.js";
|
|
2
|
+
import { minimalEnv } from "./env.js";
|
|
2
3
|
import process from "node:process";
|
|
3
4
|
import bun from "bun";
|
|
4
5
|
// src/test-utils/shell/shell.ts
|
|
@@ -19,6 +20,6 @@ const createShell = (options = {}) => {
|
|
|
19
20
|
};
|
|
20
21
|
return (strings, ...expressions) => new ShellCommand(bunShell(strings, ...expressions), settings);
|
|
21
22
|
};
|
|
22
|
-
export { createShell };
|
|
23
|
+
export { createShell, minimalEnv };
|
|
23
24
|
|
|
24
25
|
//# sourceMappingURL=shell.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.js","names":[],"sources":["../../../src/test-utils/shell/shell.ts"],"sourcesContent":["import process from \"node:process\"\n\nimport bun from \"bun\"\nimport type { ShellExpression } from \"bun\"\n\nimport { ShellCommand } from \"#test-utils/shell/command.ts\"\n\nexport type ShellEnv = Record<string, string | undefined>\n\nexport interface ShellOptions {\n /**\n * The working directory for commands. Relative paths resolve against `process.cwd()`.\n *\n * @default process.cwd()\n */\n cwd?: string\n /**\n * The environment for commands. Replaces `process.env`.\n *\n * @default process.env without `FORCE_COLOR`\n */\n env?: ShellEnv\n /**\n * Put `node_modules/.bin` of the cwd and each of its parents first on `PATH`.\n *\n * @default true\n */\n localBins?: boolean\n /**\n * Throw Bun's `ShellError` on a non-zero exit code.\n *\n * @default true\n */\n throws?: boolean\n}\n\nexport interface ShellResult {\n stdout: string\n stderr: string\n exitCode: number\n}\n\n/** Runs commands like Bun's `$`, quietly, starting from the shell's options. */\nexport type Shell = (strings: TemplateStringsArray, ...expressions: ShellExpression[]) => ShellCommand\n\n/**\n * Creates a shell that runs each command quietly and returns its output with one trailing newline stripped. Commands\n * read the test runner's stdin, so add `< /dev/null` to a command that might prompt.\n */\nexport const createShell = (options: ShellOptions = {}): Shell => {\n // Use a separate instance so settings on Bun's global `$` don't apply here.\n const bunShell = new bun.$.Shell()\n const settings: Required<ShellOptions> = {\n cwd: options.cwd ?? process.cwd(),\n // Drop `FORCE_COLOR` because `bask` sets it when the tests run in a terminal and CI does not.\n env: options.env ?? { ...process.env, FORCE_COLOR: undefined },\n localBins: options.localBins ?? true,\n throws: options.throws ?? true,\n }\n\n return (strings, ...expressions) => new ShellCommand(bunShell(strings, ...expressions), settings)\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"shell.js","names":[],"sources":["../../../src/test-utils/shell/shell.ts"],"sourcesContent":["import process from \"node:process\"\n\nimport bun from \"bun\"\nimport type { ShellExpression } from \"bun\"\n\nimport { ShellCommand } from \"#test-utils/shell/command.ts\"\n\nexport type { ShellCommand } from \"#test-utils/shell/command.ts\"\nexport { minimalEnv } from \"#test-utils/shell/env.ts\"\n\nexport type ShellEnv = Record<string, string | undefined>\n\nexport interface ShellOptions {\n /**\n * The working directory for commands. Relative paths resolve against `process.cwd()`.\n *\n * @default process.cwd()\n */\n cwd?: string\n /**\n * The environment for commands. Replaces `process.env`.\n *\n * @default process.env without `FORCE_COLOR`\n */\n env?: ShellEnv\n /**\n * Put `node_modules/.bin` of the cwd and each of its parents first on `PATH`.\n *\n * @default true\n */\n localBins?: boolean\n /**\n * Throw Bun's `ShellError` on a non-zero exit code.\n *\n * @default true\n */\n throws?: boolean\n}\n\nexport interface ShellResult {\n stdout: string\n stderr: string\n exitCode: number\n}\n\n/** Runs commands like Bun's `$`, quietly, starting from the shell's options. */\nexport type Shell = (strings: TemplateStringsArray, ...expressions: ShellExpression[]) => ShellCommand\n\n/**\n * Creates a shell that runs each command quietly and returns its output with one trailing newline stripped. Commands\n * read the test runner's stdin, so add `< /dev/null` to a command that might prompt.\n */\nexport const createShell = (options: ShellOptions = {}): Shell => {\n // Use a separate instance so settings on Bun's global `$` don't apply here.\n const bunShell = new bun.$.Shell()\n const settings: Required<ShellOptions> = {\n cwd: options.cwd ?? process.cwd(),\n // Drop `FORCE_COLOR` because `bask` sets it when the tests run in a terminal and CI does not.\n env: options.env ?? { ...process.env, FORCE_COLOR: undefined },\n localBins: options.localBins ?? true,\n throws: options.throws ?? true,\n }\n\n return (strings, ...expressions) => new ShellCommand(bunShell(strings, ...expressions), settings)\n}\n"],"mappings":";;;;;;;;;AAoDA,MAAa,eAAe,UAAwB,CAAC,MAAa;CAEhE,MAAM,WAAW,IAAI,IAAI,EAAE,MAAM;CACjC,MAAM,WAAmC;EACvC,KAAK,QAAQ,OAAO,QAAQ,IAAI;EAEhC,KAAK,QAAQ,OAAO;GAAE,GAAG,QAAQ;GAAK,aAAa,KAAA;EAAU;EAC7D,WAAW,QAAQ,aAAa;EAChC,QAAQ,QAAQ,UAAU;CAC5B;CAEA,QAAQ,SAAS,GAAG,gBAAgB,IAAI,aAAa,SAAS,SAAS,GAAG,WAAW,GAAG,QAAQ;AAClG"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
/** Makes a temp dir
|
|
2
|
-
export declare const makeTempDir: (
|
|
3
|
-
//# sourceMappingURL=temp-dir.d.ts.map
|
|
1
|
+
/** Makes a temp dir named after the current project, and records it for `removeTempDirs`. */
|
|
2
|
+
export declare const makeTempDir: () => Promise<string>;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
|
+
import process from "node:process";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import os from "node:os";
|
|
4
5
|
// src/test-utils/temp-dir.ts
|
|
5
6
|
const tempDirs = [];
|
|
6
|
-
/** Makes a temp dir
|
|
7
|
-
const makeTempDir = async (
|
|
8
|
-
const
|
|
7
|
+
/** Makes a temp dir named after the current project, and records it for `removeTempDirs`. */
|
|
8
|
+
const makeTempDir = async () => {
|
|
9
|
+
const projectName = path.basename(process.cwd());
|
|
10
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), `${projectName}-`));
|
|
9
11
|
tempDirs.push(dir);
|
|
10
12
|
return dir;
|
|
11
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"temp-dir.js","names":[],"sources":["../../src/test-utils/temp-dir.ts"],"sourcesContent":["import fs from \"node:fs/promises\"\nimport os from \"node:os\"\nimport path from \"node:path\"\n\nconst tempDirs: string[] = []\n\n/** Makes a temp dir
|
|
1
|
+
{"version":3,"file":"temp-dir.js","names":[],"sources":["../../src/test-utils/temp-dir.ts"],"sourcesContent":["import fs from \"node:fs/promises\"\nimport os from \"node:os\"\nimport path from \"node:path\"\nimport process from \"node:process\"\n\nconst tempDirs: string[] = []\n\n/** Makes a temp dir named after the current project, and records it for `removeTempDirs`. */\nexport const makeTempDir = async () => {\n // Start the name with the project so a dir left behind by a killed run shows where it came from.\n const projectName = path.basename(process.cwd())\n const dir = await fs.mkdtemp(path.join(os.tmpdir(), `${projectName}-`))\n tempDirs.push(dir)\n return dir\n}\n\n/** Removes every dir made by `makeTempDir`. */\nexport const removeTempDirs = async () => {\n await Promise.all(tempDirs.map(async (dir) => fs.rm(dir, { recursive: true, force: true })))\n}\n"],"mappings":";;;;;AAKA,MAAM,WAAqB,CAAC;;AAG5B,MAAa,cAAc,YAAY;CAErC,MAAM,cAAc,KAAK,SAAS,QAAQ,IAAI,CAAC;CAC/C,MAAM,MAAM,MAAM,GAAG,QAAQ,KAAK,KAAK,GAAG,OAAO,GAAG,GAAG,YAAY,EAAE,CAAC;CACtE,SAAS,KAAK,GAAG;CACjB,OAAO;AACT;;AAGA,MAAa,iBAAiB,YAAY;CACxC,MAAM,QAAQ,IAAI,SAAS,IAAI,OAAO,QAAQ,GAAG,GAAG,KAAK;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC,CAAC,CAAC;AAC7F"}
|
package/dist/utils.js
CHANGED
|
@@ -14,9 +14,17 @@ const configFilePath = (name) => {
|
|
|
14
14
|
/** Returns the absolute path of a package's entry file, resolved from this package's dependencies. */
|
|
15
15
|
const resolvePackagePath = (specifier) => fileURLToPath(import.meta.resolve(specifier));
|
|
16
16
|
const keysOf = (value) => isPlainObject(value) ? Object.keys(value) : [];
|
|
17
|
+
const DECLARATION_FILE = /\.d\.[cm]?ts$/v;
|
|
18
|
+
/** Checks an `exports` value, at any depth, for a `types` condition or a path to a declaration file. */
|
|
19
|
+
const exportsDeclareTypes = (value) => {
|
|
20
|
+
if (typeof value === "string") return DECLARATION_FILE.test(value);
|
|
21
|
+
if (Array.isArray(value)) return value.some(exportsDeclareTypes);
|
|
22
|
+
if (!isPlainObject(value)) return false;
|
|
23
|
+
return "types" in value || Object.values(value).some(exportsDeclareTypes);
|
|
24
|
+
};
|
|
17
25
|
/**
|
|
18
26
|
* Reads the project's `package.json` fields that the base configs branch on. `dependencies` merges the regular, dev,
|
|
19
|
-
* and peer dependency names.
|
|
27
|
+
* and peer dependency names. `publishesTypes` is true when the `package.json` declares types.
|
|
20
28
|
*/
|
|
21
29
|
const readProjectPackageJson = () => {
|
|
22
30
|
const packageJson = existsSync("package.json") ? JSON.parse(readFileSync("package.json", "utf8")) : {};
|
|
@@ -27,7 +35,8 @@ const readProjectPackageJson = () => {
|
|
|
27
35
|
"devDependencies",
|
|
28
36
|
"peerDependencies"
|
|
29
37
|
].flatMap((field) => keysOf(fields[field]))),
|
|
30
|
-
engines: new Set(keysOf(fields["engines"]))
|
|
38
|
+
engines: new Set(keysOf(fields["engines"])),
|
|
39
|
+
publishesTypes: "types" in fields || "typings" in fields || exportsDeclareTypes(fields["exports"])
|
|
31
40
|
};
|
|
32
41
|
};
|
|
33
42
|
const TAILWIND_IMPORT = /@import\s*["']tailwindcss(?:\/[^"']+)?["']/v;
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import { existsSync, globSync, readFileSync } from \"node:fs\"\nimport path from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\n\nimport { isPlainObject } from \"es-toolkit/predicate\"\n\n// Check both folders because a bin bundles this file into `<bin>/index`, one level below `configs`.\nconst CONFIG_DIRS = [\"./configs/\", \"../configs/\"] as const\n\n/** Returns the absolute path of a file in this package's `configs` folder. */\nexport const configFilePath = (name: string) => {\n const filePaths = CONFIG_DIRS.map((dir) => fileURLToPath(new URL(`${dir}${name}`, import.meta.url)))\n const filePath = filePaths.find((candidate) => existsSync(candidate))\n if (!filePath) throw new Error(`Couldn't find config file \"${name}\" in:\\n${filePaths.join(\"\\n\")}`)\n return filePath\n}\n\n/** Returns the absolute path of a package's entry file, resolved from this package's dependencies. */\nexport const resolvePackagePath = (specifier: string) => fileURLToPath(import.meta.resolve(specifier))\n\nconst keysOf = (value: unknown) => (isPlainObject(value) ? Object.keys(value) : [])\n\n/**\n * Reads the project's `package.json` fields that the base configs branch on. `dependencies` merges the regular, dev,\n * and peer dependency names.\n */\nexport const readProjectPackageJson = () => {\n const packageJson: unknown = existsSync(\"package.json\") ? JSON.parse(readFileSync(\"package.json\", \"utf8\")) : {}\n const fields = isPlainObject(packageJson) ? packageJson : {}\n\n const dependencyFields = [\"dependencies\", \"devDependencies\", \"peerDependencies\"]\n const dependencies = new Set(dependencyFields.flatMap((field) => keysOf(fields[field])))\n const engines = new Set(keysOf(fields[\"engines\"]))\n\n return { dependencies, engines }\n}\n\n// Match entry stylesheets the same way `@tailwindcss/language-server` does.\nconst TAILWIND_IMPORT = /@import\\s*[\"']tailwindcss(?:\\/[^\"']+)?[\"']/v\n\n/**\n * Returns the project's Tailwind stylesheet relative to the project root, or `false` when the project doesn't use\n * Tailwind. The stylesheet is the first CSS file, in sorted order, that imports `tailwindcss`.\n */\nexport const resolveProjectTailwind = () => {\n const { dependencies } = readProjectPackageJson()\n if (!dependencies.has(\"tailwindcss\")) return false\n\n const stylesheets = globSync(\"**/*.{css,scss,sass,less,pcss}\", {\n exclude: (filePath) => [\"node_modules\", \".git\"].includes(path.basename(filePath)),\n }).toSorted()\n\n return stylesheets.find((file) => TAILWIND_IMPORT.test(readFileSync(file, \"utf8\"))) ?? false\n}\n"],"mappings":";;;;;AAOA,MAAM,cAAc,CAAC,cAAc,aAAa;;AAGhD,MAAa,kBAAkB,SAAiB;CAC9C,MAAM,YAAY,YAAY,KAAK,QAAQ,cAAc,IAAI,IAAI,GAAG,MAAM,QAAQ,YAAY,GAAG,CAAC,CAAC;CACnG,MAAM,WAAW,UAAU,MAAM,cAAc,WAAW,SAAS,CAAC;CACpE,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,8BAA8B,KAAK,SAAS,UAAU,KAAK,IAAI,GAAG;CACjG,OAAO;AACT;;AAGA,MAAa,sBAAsB,cAAsB,cAAc,YAAY,QAAQ,SAAS,CAAC;AAErG,MAAM,UAAU,UAAoB,cAAc,KAAK,IAAI,OAAO,KAAK,KAAK,IAAI,CAAC;;;;;
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import { existsSync, globSync, readFileSync } from \"node:fs\"\nimport path from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\n\nimport { isPlainObject } from \"es-toolkit/predicate\"\n\n// Check both folders because a bin bundles this file into `<bin>/index`, one level below `configs`.\nconst CONFIG_DIRS = [\"./configs/\", \"../configs/\"] as const\n\n/** Returns the absolute path of a file in this package's `configs` folder. */\nexport const configFilePath = (name: string) => {\n const filePaths = CONFIG_DIRS.map((dir) => fileURLToPath(new URL(`${dir}${name}`, import.meta.url)))\n const filePath = filePaths.find((candidate) => existsSync(candidate))\n if (!filePath) throw new Error(`Couldn't find config file \"${name}\" in:\\n${filePaths.join(\"\\n\")}`)\n return filePath\n}\n\n/** Returns the absolute path of a package's entry file, resolved from this package's dependencies. */\nexport const resolvePackagePath = (specifier: string) => fileURLToPath(import.meta.resolve(specifier))\n\nconst keysOf = (value: unknown) => (isPlainObject(value) ? Object.keys(value) : [])\n\nconst DECLARATION_FILE = /\\.d\\.[cm]?ts$/v\n\n/** Checks an `exports` value, at any depth, for a `types` condition or a path to a declaration file. */\nconst exportsDeclareTypes = (value: unknown): boolean => {\n if (typeof value === \"string\") return DECLARATION_FILE.test(value)\n if (Array.isArray(value)) return value.some(exportsDeclareTypes)\n if (!isPlainObject(value)) return false\n return \"types\" in value || Object.values(value).some(exportsDeclareTypes)\n}\n\n/**\n * Reads the project's `package.json` fields that the base configs branch on. `dependencies` merges the regular, dev,\n * and peer dependency names. `publishesTypes` is true when the `package.json` declares types.\n */\nexport const readProjectPackageJson = () => {\n const packageJson: unknown = existsSync(\"package.json\") ? JSON.parse(readFileSync(\"package.json\", \"utf8\")) : {}\n const fields = isPlainObject(packageJson) ? packageJson : {}\n\n const dependencyFields = [\"dependencies\", \"devDependencies\", \"peerDependencies\"]\n const dependencies = new Set(dependencyFields.flatMap((field) => keysOf(fields[field])))\n const engines = new Set(keysOf(fields[\"engines\"]))\n const publishesTypes = \"types\" in fields || \"typings\" in fields || exportsDeclareTypes(fields[\"exports\"])\n\n return { dependencies, engines, publishesTypes }\n}\n\n// Match entry stylesheets the same way `@tailwindcss/language-server` does.\nconst TAILWIND_IMPORT = /@import\\s*[\"']tailwindcss(?:\\/[^\"']+)?[\"']/v\n\n/**\n * Returns the project's Tailwind stylesheet relative to the project root, or `false` when the project doesn't use\n * Tailwind. The stylesheet is the first CSS file, in sorted order, that imports `tailwindcss`.\n */\nexport const resolveProjectTailwind = () => {\n const { dependencies } = readProjectPackageJson()\n if (!dependencies.has(\"tailwindcss\")) return false\n\n const stylesheets = globSync(\"**/*.{css,scss,sass,less,pcss}\", {\n exclude: (filePath) => [\"node_modules\", \".git\"].includes(path.basename(filePath)),\n }).toSorted()\n\n return stylesheets.find((file) => TAILWIND_IMPORT.test(readFileSync(file, \"utf8\"))) ?? false\n}\n"],"mappings":";;;;;AAOA,MAAM,cAAc,CAAC,cAAc,aAAa;;AAGhD,MAAa,kBAAkB,SAAiB;CAC9C,MAAM,YAAY,YAAY,KAAK,QAAQ,cAAc,IAAI,IAAI,GAAG,MAAM,QAAQ,YAAY,GAAG,CAAC,CAAC;CACnG,MAAM,WAAW,UAAU,MAAM,cAAc,WAAW,SAAS,CAAC;CACpE,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,8BAA8B,KAAK,SAAS,UAAU,KAAK,IAAI,GAAG;CACjG,OAAO;AACT;;AAGA,MAAa,sBAAsB,cAAsB,cAAc,YAAY,QAAQ,SAAS,CAAC;AAErG,MAAM,UAAU,UAAoB,cAAc,KAAK,IAAI,OAAO,KAAK,KAAK,IAAI,CAAC;AAEjF,MAAM,mBAAmB;;AAGzB,MAAM,uBAAuB,UAA4B;CACvD,IAAI,OAAO,UAAU,UAAU,OAAO,iBAAiB,KAAK,KAAK;CACjE,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,KAAK,mBAAmB;CAC/D,IAAI,CAAC,cAAc,KAAK,GAAG,OAAO;CAClC,OAAO,WAAW,SAAS,OAAO,OAAO,KAAK,CAAC,CAAC,KAAK,mBAAmB;AAC1E;;;;;AAMA,MAAa,+BAA+B;CAC1C,MAAM,cAAuB,WAAW,cAAc,IAAI,KAAK,MAAM,aAAa,gBAAgB,MAAM,CAAC,IAAI,CAAC;CAC9G,MAAM,SAAS,cAAc,WAAW,IAAI,cAAc,CAAC;CAO3D,OAAO;EAAE,cAAA,IAJgB,IAAI;GADH;GAAgB;GAAmB;EACjB,CAAC,CAAC,SAAS,UAAU,OAAO,OAAO,MAAM,CAAC,CAIlE;EAAG,SAAA,IAHH,IAAI,OAAO,OAAO,UAAU,CAGnB;EAAG,gBAFT,WAAW,UAAU,aAAa,UAAU,oBAAoB,OAAO,UAAU;CAEzD;AACjD;AAGA,MAAM,kBAAkB;;;;;AAMxB,MAAa,+BAA+B;CAC1C,MAAM,EAAE,iBAAiB,uBAAuB;CAChD,IAAI,CAAC,aAAa,IAAI,aAAa,GAAG,OAAO;CAM7C,OAJoB,SAAS,kCAAkC,EAC7D,UAAU,aAAa,CAAC,gBAAgB,MAAM,CAAC,CAAC,SAAS,KAAK,SAAS,QAAQ,CAAC,EAClF,CAAC,CAAC,CAAC,SAEc,CAAC,CAAC,MAAM,SAAS,gBAAgB,KAAK,aAAa,MAAM,MAAM,CAAC,CAAC,KAAK;AACzF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adamhl8/configs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "My shared configs for TS projects",
|
|
5
5
|
"homepage": "https://github.com/adamhl8/configs",
|
|
6
6
|
"bugs": {
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
},
|
|
19
19
|
"bin": {
|
|
20
20
|
"adamhl8-bunfig": "./dist/adamhl8-bunfig/index",
|
|
21
|
-
"adamhl8-gitignore": "./dist/adamhl8-gitignore/index"
|
|
21
|
+
"adamhl8-gitignore": "./dist/adamhl8-gitignore/index",
|
|
22
|
+
"adamhl8-tsconfig": "./dist/adamhl8-tsconfig/index"
|
|
22
23
|
},
|
|
23
24
|
"files": [
|
|
24
25
|
"dist/"
|
|
@@ -29,6 +30,7 @@
|
|
|
29
30
|
},
|
|
30
31
|
"exports": {
|
|
31
32
|
"./tsconfig": "./dist/configs/tsconfig.base.json",
|
|
33
|
+
"./tsconfig/no-dts": "./dist/configs/tsconfig.no-dts.base.json",
|
|
32
34
|
".": {
|
|
33
35
|
"types": "./dist/index.d.ts",
|
|
34
36
|
"import": "./dist/index.js"
|
|
@@ -48,10 +50,6 @@
|
|
|
48
50
|
"./test/preload": {
|
|
49
51
|
"types": "./dist/test-utils/preload.d.ts",
|
|
50
52
|
"import": "./dist/test-utils/preload.js"
|
|
51
|
-
},
|
|
52
|
-
"./test/subprocess-coverage": {
|
|
53
|
-
"types": "./dist/test-utils/subprocess-coverage/preload.d.ts",
|
|
54
|
-
"import": "./dist/test-utils/subprocess-coverage/preload.js"
|
|
55
53
|
}
|
|
56
54
|
},
|
|
57
55
|
"publishConfig": {
|
|
@@ -61,42 +59,40 @@
|
|
|
61
59
|
"prepare": "bask prepare"
|
|
62
60
|
},
|
|
63
61
|
"dependencies": {
|
|
64
|
-
"@adamhl8/
|
|
62
|
+
"@adamhl8/oxlint-plugin-clean-modules": "^0.2.0",
|
|
63
|
+
"@adamhl8/oxlint-plugin-package-boundaries": "^0.1.0",
|
|
65
64
|
"@commitlint/config-conventional": "^21.2.4",
|
|
66
65
|
"@commitlint/types": "^21.2.3",
|
|
67
66
|
"@e18e/eslint-plugin": "^0.8.1",
|
|
68
67
|
"arkenv": "^0.12.3",
|
|
69
68
|
"arktype": "^2.2.9",
|
|
70
|
-
"es-toolkit": "^1.53.
|
|
69
|
+
"es-toolkit": "^1.53.2",
|
|
71
70
|
"eslint-plugin-bunisms": "^0.11.0",
|
|
72
|
-
"eslint-plugin-hono": "^1.
|
|
73
|
-
"eslint-plugin-react-web-api": "^5.
|
|
74
|
-
"eslint-plugin-react-you-might-not-need-an-effect": "^1.0
|
|
75
|
-
"eslint-plugin-regexp": "^3.3.
|
|
71
|
+
"eslint-plugin-hono": "^1.2.2",
|
|
72
|
+
"eslint-plugin-react-web-api": "^5.30.1",
|
|
73
|
+
"eslint-plugin-react-you-might-not-need-an-effect": "^1.2.0",
|
|
74
|
+
"eslint-plugin-regexp": "^3.3.3",
|
|
76
75
|
"oxlint-plugin-directive-comments": "^0.1.0",
|
|
77
|
-
"oxlint-tailwindcss": "^1.
|
|
78
|
-
"ts-explicit-errors": "^5.0.
|
|
79
|
-
"type-fest": "^5.10.0"
|
|
76
|
+
"oxlint-tailwindcss": "^1.17.1",
|
|
77
|
+
"ts-explicit-errors": "^5.0.1",
|
|
78
|
+
"type-fest": "^5.10.0",
|
|
79
|
+
"verkit": "^0.5.0"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@adamhl8/bask": "^0.6.
|
|
82
|
+
"@adamhl8/bask": "^0.6.1",
|
|
83
83
|
"@adamhl8/configs": "file:.",
|
|
84
84
|
"@arethetypeswrong/core": "^0.18.5",
|
|
85
85
|
"@commitlint/cli": "^21.2.4",
|
|
86
86
|
"@types/bun": "^1.4.4",
|
|
87
|
-
"
|
|
88
|
-
"@vitest/istanbul-lib-instrument": "^2.0.0",
|
|
89
|
-
"@vitest/istanbul-lib-report": "^2.0.0",
|
|
90
|
-
"@vitest/istanbul-lib-source-maps": "^2.0.0",
|
|
91
|
-
"knip": "^6.43.0",
|
|
87
|
+
"knip": "^6.45.0",
|
|
92
88
|
"markdown-toc": "^1.2.0",
|
|
93
|
-
"oxfmt": "^0.
|
|
94
|
-
"oxlint": "^1.
|
|
95
|
-
"oxlint-tsgolint": "^7.0.
|
|
89
|
+
"oxfmt": "^0.78.0",
|
|
90
|
+
"oxlint": "^1.93.0",
|
|
91
|
+
"oxlint-tsgolint": "^7.0.2006",
|
|
96
92
|
"publint": "^0.3.25",
|
|
97
|
-
"release-it": "^21.1.
|
|
98
|
-
"release-it-git-cliff": "^0.2.
|
|
99
|
-
"tsdown": "^0.23.
|
|
93
|
+
"release-it": "^21.1.2",
|
|
94
|
+
"release-it-git-cliff": "^0.2.1",
|
|
95
|
+
"tsdown": "^0.23.7",
|
|
100
96
|
"typescript": "7.1.0-beta"
|
|
101
97
|
},
|
|
102
98
|
"peerDependencies": {
|
|
@@ -105,20 +101,16 @@
|
|
|
105
101
|
"@commitlint/cli": ">=21.2",
|
|
106
102
|
"@commitlint/config-conventional": ">=21.2",
|
|
107
103
|
"@tailwindcss/language-server": ">=0.16",
|
|
108
|
-
"
|
|
109
|
-
"@vitest/istanbul-lib-instrument": ">=2.0",
|
|
110
|
-
"@vitest/istanbul-lib-report": ">=2.0",
|
|
111
|
-
"@vitest/istanbul-lib-source-maps": ">=2.0",
|
|
112
|
-
"knip": ">=6.43",
|
|
104
|
+
"knip": ">=6.45",
|
|
113
105
|
"markdown-toc": ">=1.2",
|
|
114
|
-
"oxfmt": ">=0.
|
|
115
|
-
"oxlint": ">=1.
|
|
116
|
-
"oxlint-tsgolint": ">=7.0.
|
|
106
|
+
"oxfmt": ">=0.78",
|
|
107
|
+
"oxlint": ">=1.93",
|
|
108
|
+
"oxlint-tsgolint": ">=7.0.2006",
|
|
117
109
|
"publint": ">=0.3",
|
|
118
110
|
"release-it": ">=21.1",
|
|
119
111
|
"release-it-git-cliff": ">=0.2",
|
|
120
112
|
"tailwint": ">=1.1",
|
|
121
|
-
"tsdown": ">=0.23.
|
|
113
|
+
"tsdown": ">=0.23.7",
|
|
122
114
|
"typescript": "^7.1.0-beta"
|
|
123
115
|
},
|
|
124
116
|
"peerDependenciesMeta": {
|
|
@@ -128,18 +120,6 @@
|
|
|
128
120
|
"@tailwindcss/language-server": {
|
|
129
121
|
"optional": true
|
|
130
122
|
},
|
|
131
|
-
"@vitest/istanbul-lib-coverage": {
|
|
132
|
-
"optional": true
|
|
133
|
-
},
|
|
134
|
-
"@vitest/istanbul-lib-instrument": {
|
|
135
|
-
"optional": true
|
|
136
|
-
},
|
|
137
|
-
"@vitest/istanbul-lib-report": {
|
|
138
|
-
"optional": true
|
|
139
|
-
},
|
|
140
|
-
"@vitest/istanbul-lib-source-maps": {
|
|
141
|
-
"optional": true
|
|
142
|
-
},
|
|
143
123
|
"publint": {
|
|
144
124
|
"optional": true
|
|
145
125
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bask.base.d.ts","names":[],"sources":["../../src/configs/bask.base.ts"],"mappings":"A,qBAwBa,mCAAS;qBAIT,iCAAO;qBASP,kCAAQ;qBAOR,8BAAI;qBAIJ,8BAAI;qBA0BJ,+BAAK;qBAYL,iCAAO;qBAIP,oCAAU;qBAIV,qCAAW"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commitlint.base.d.ts","names":["_$_merge_config_merge_config_ts0.OptionalMergeConfigFn"],"sources":["../../src/configs/commitlint.base.ts"],"mappings":";;qBAkBa,kBAAgBA,sBAAA;;;aAJzB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"knip.base.d.ts","names":["_$_merge_config_merge_config_ts0.OptionalMergeConfigFn"],"sources":["../../src/configs/knip.base.ts"],"mappings":";;qBAca,YAAUA,sBAAA;;;aAJnB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oxfmt.base.d.ts","names":["_$_merge_config_merge_config_ts0.OptionalMergeConfigFn"],"sources":["../../src/configs/oxfmt.base.ts"],"mappings":";;qBA4Ba,aAAWA,sBAAA;WApBV;;;aAEH;;WACqB;;;aAG5B;;;aASiB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oxlint.base.d.ts","names":["_$_merge_config_merge_config_ts0.OptionalMergeConfigFn"],"sources":["../../src/configs/oxlint.base.ts"],"mappings":";;KAmBK,cAAc,eAAe;qBA4UrB,cAxU4CA,sBAwUhC;;aAhNrB;aACA;aACA;;;aAIA;aACA;aACA;aACA;aACA;aACA;aACA;;;;;;;eA+BI;;;;;eAMA;eACA;;;;;eAMA;;;;;;;;;;;;eAYA;eACA;eACA;;;IA9LiD,QAAA;;;;;;eAwMF;;;eAI9B;eAA2C;;;eAER;eAA4B;eAAiB;;;;iBAKxF;iBAAiB;;;;;;IAON;IACX;IACQ;IACG;IACX;IACa;IACR;IACJ;IACC;IACS;IACF;IACF;IACL;IACI;IACL;IACF;IACI;IACK;IACV;IACA;IACM;IACD;IACH;IAEU;IACC;IACG;IACD;IACE;IACG;IACC;IAET;IACE;IAED;IACD;IACP;IACW;IAEL;IACM;IACK;IAEO;IACR;IACjB;IACI;IACa;IACT;IACE;IACE;IACW;IACV;IACF;IACZ;IAEkB;IACY;IACC;IACC;IACL;IAEF;IACE;IACH;IACX;IACI;IACD;IAEX;IACmB;IACG;IACN;IACO;IACT;IACJ;IACC;IACP;IACQ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"release-it.base.d.ts","names":["_$_merge_config_merge_config_ts0.OptionalMergeConfigFn"],"sources":["../../src/configs/release-it.base.ts"],"mappings":";;KAOK,cAAc,QAAQ;KACtB,kBAAkB;EAAW,QAAQ;;qBA+B7B,iBAAeA,sBAAA;;aA3BxB;aACA;;;aAGA;eACE;eACA;;;;aAIF;aAEA;aACA;aACA;;;aAGA;aACA;;;aAGA;aACA;aACA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tsdown.base.d.ts","names":[],"sources":["../../src/configs/tsdown.base.ts"],"mappings":";;;KAOK,eAAe,YAAY;cAE1B;;WAEM;;;;WAIF;;;;aAIN;;;aAGA;;;aAGA;aACA;;;;;;KAQC,qBAAqB,YAAY;cAGhC;WA1BM;;WAIF;;;;aAON;;;;;;;;;;;aAwBA;eACE;;;;KAMD,kBAAkB,YAAY;cAG7B;;WAzCI;;;;aAON;;;;;;;;;;;aAwBA;eACE;;;WAWM;;aACkB;;;qBAKjB,cAAc,cAAc,qBAAqB;qBAKjD,oBAAoB,cAAc,2BAA2B;qBAK7D,iBAAiB,cAAc,wBAAwB"}
|
package/dist/env/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/env/index.ts"],"mappings":";;KAiBK,gBAAgB;qBAER,UAOP"}
|
package/dist/env/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","names":["arktype"],"sources":["../../src/env/utils.ts"],"mappings":";;;;;;;wBASgB,kBAAkB,KAChC,eACA,MAAMA,KAAQ,SAAS,OACtB,WAAWA,KAAQ,YAAY;wBAClB,kBAAkB,KAChC,eACA,MAAMA,KAAQ,SAAS,MACvB,UAAUA,KAAQ,MAAM,OACvBA,KAAQ,YAAY"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge-config.d.ts","names":[],"sources":["../../src/merge-config/merge-config.ts"],"mappings":";;;;;;;;;;;;YAgCY,cAAc,YAAY,sBAAsB,0BAA0B,aAAa,aACjG,YAAY,sBACT,aAAa,YAAY,8BAEpB,0BAA0B,aAAa,mBACvC,6BAA6B,aAAa,QAAQ,cAExD,YAAY,mBACZ,eAAe,yBACZ,aAAa,aAAa,YAAY,oBAAoB;;YAGrD,sBAAsB,YAAY,cAAc,cAAc,YAAY,qBAC3E,MAAM"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge.types.d.ts","names":[],"sources":["../../src/merge-config/merge.types.ts"],"mappings":"A,KAWK,kBAAkB;;YAGX;;;;;;KAOP;;;;;;KAOA,eAAe,cAAc,OAAO,SAAS;YAAoB,OAAO;;;;;;;;YAQjE,MAAM,GAAG,mCAAmC,YAAY,mBAChE,0CAA0C,kBACxC,UAAU,eACR,iBACa,WAAW,IAAI,MAAM,EAAE,IAAI,qBAC1C,IACF;;;;;KAMC,YACH,WACA,sCACA,kCACA,UAAU,QACR,qBACA,wCACG,MAAM,mBAAmB,SAAS,MAAM,mBAAmB,YAC5D,MAAM,WAAW,SACnB,MAAM,WAAW;;;;;KAMhB,YAAY,WAAW,WAAW,kCAAkC,UAAU,QAAQ,2BACvF,uCACE,YAAY,WAAW,WAAW,OAAO,KACzC,kBAAkB,eAChB,YACA,uCAAuC,eACrC,MAAM,WAAW,SACjB,2BACE,aAAa,WAAW,WAAW,OAAO,KAC1C,MAAM,WAAW,SACzB;;;;;;;;KASC,aAAa,YAAY,YAAY,kCAAkC,UAAU,QAAQ,0CAEnF,+BAGM,WAAW,aAAa,gBAAgB,+BAC7B,WAAW,KAEvB,YAAY,WAAW,IAAI,QAAQ,WAAW,gBAAgB,gBAAgB,KAC9E,MAAM,WAAW,IAAI,kBACzB,YAAY,WAAW,IAAI,WAAW,IAAI,gBAAgB,KAC5D,MAAM,WAAW,IAAI,kCAEd,WAAW,cAAc,gBAAgB,8BAA8B,IAAI,MACpF,WAAW,IACX,kCAEY,aACX,WAAW,SAAS,OAAO,gBAEhC;;;;;YAMQ,aAAa,YAAY,YAAY,UAAU,mBAAmB,aAC5E,YACA,YACA,UACA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fixture.d.ts","names":["_$_test_utils_shell_shell_ts0.Shell"],"sources":["../../src/test-utils/fixture.ts"],"mappings":";iBAOiB;;;;;;EAMf;;EAEA,QAAQ,KAAK;;;qBAIF,cAAW,mBAAyB,QAAA,UAAqB,uBAAkB;;E,KAAlBA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pack.d.ts","names":[],"sources":["../../src/test-utils/pack.ts"],"mappings":";qBAQa,cAAW,iBAAsB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","names":["BunShell"],"sources":["../../../src/test-utils/shell/command.ts"],"mappings":";;;qBAca,wBAAwB,YAAY;;;EAM/C,YAAmB,cAAcA,EAAS,cAAc,UAAU,SAAS;;EAOpE,IAAI;;EAMJ,IAAI,QAAQ;;EAMZ,UAAU;;EAMV;EAMM,KAAK,WAAW,aAAa,kBACxC,gBAAgB,OAAO,gBAAgB,WAAW,YAAY,mBAC9D,eAAe,oBAAoB,WAAW,YAAY,oBAAiB,QAAA,WAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","names":[],"sources":["../../../src/test-utils/shell/env.ts"],"mappings":";;qBAKa,aAAU,QAAW,aAAgB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shell.d.ts","names":[],"sources":["../../../src/test-utils/shell/shell.ts"],"mappings":";;YAOY,WAAW;iBAEN;;;;;;EAMf;;;;;;EAMA,MAAM;;;;;;EAMN;;;;;;EAMA;;iBAGe;EACf;EACA;EACA;;;YAIU,SAAS,SAAS,yBAAyB,aAAa,sBAAsB;;;;;qBAM7E,cAAW,UAAa,iBAAoB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { SUBPROCESS_COVERAGE_SETTINGS_VAR } from "./env.js";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import bun from "bun";
|
|
4
|
-
import crypto from "node:crypto";
|
|
5
|
-
import fs from "node:fs";
|
|
6
|
-
import { createInstrumenter } from "@vitest/istanbul-lib-instrument";
|
|
7
|
-
// src/test-utils/subprocess-coverage/child-preload.ts
|
|
8
|
-
const INSTRUMENTER_COVERAGE_VARIABLE = "subprocessCoverage";
|
|
9
|
-
const isCoverageSettings = (value) => typeof value === "object" && value !== null && "rawDir" in value && typeof value.rawDir === "string" && "root" in value && typeof value.root === "string" && "packageName" in value && typeof value.packageName === "string";
|
|
10
|
-
/** Reads the coverage settings from the environment, and throws when they're missing or invalid. */
|
|
11
|
-
const readCoverageSettings = () => {
|
|
12
|
-
const settings = process.env[SUBPROCESS_COVERAGE_SETTINGS_VAR];
|
|
13
|
-
if (settings === void 0) throw new Error(`the subprocess coverage preload loaded without ${SUBPROCESS_COVERAGE_SETTINGS_VAR}`);
|
|
14
|
-
const parsed = JSON.parse(settings);
|
|
15
|
-
if (!isCoverageSettings(parsed)) throw new Error(`${SUBPROCESS_COVERAGE_SETTINGS_VAR} isn't valid: ${settings}`);
|
|
16
|
-
return parsed;
|
|
17
|
-
};
|
|
18
|
-
const { rawDir, root, packageName } = readCoverageSettings();
|
|
19
|
-
const isSourceMap = (value) => typeof value === "object" && value !== null && "sources" in value && Array.isArray(value.sources);
|
|
20
|
-
/** Points each source in the installed package's map at the same file in the project, so reports name `src/`. */
|
|
21
|
-
const readSourceMap = async (file, packageDir, projectDir) => {
|
|
22
|
-
const sourceMap = await bun.file(`${file}.map`).json();
|
|
23
|
-
if (!isSourceMap(sourceMap)) throw new Error(`no source map for ${file}`);
|
|
24
|
-
const sources = sourceMap.sources.map((source) => {
|
|
25
|
-
const installedSource = path.resolve(path.dirname(file), source ?? "");
|
|
26
|
-
return path.join(projectDir, path.relative(packageDir, installedSource));
|
|
27
|
-
});
|
|
28
|
-
return {
|
|
29
|
-
...sourceMap,
|
|
30
|
-
sources
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
const instrumenter = createInstrumenter({
|
|
34
|
-
esModules: true,
|
|
35
|
-
coverageVariable: INSTRUMENTER_COVERAGE_VARIABLE
|
|
36
|
-
});
|
|
37
|
-
const installedDist = new RegExp(String.raw`^(.*/node_modules/${RegExp.escape(packageName)})/dist/.*\.js$`, "v");
|
|
38
|
-
const sourceMappingUrl = /^\/\/# sourceMappingURL=/mv;
|
|
39
|
-
bun.plugin({
|
|
40
|
-
name: "subprocess-coverage",
|
|
41
|
-
setup: (build) => {
|
|
42
|
-
build.onLoad({ filter: installedDist }, async ({ path: file }) => {
|
|
43
|
-
const [, packageDir = ""] = installedDist.exec(file) ?? [];
|
|
44
|
-
const code = await bun.file(file).text();
|
|
45
|
-
if (!sourceMappingUrl.test(code)) return {
|
|
46
|
-
contents: code,
|
|
47
|
-
loader: "js"
|
|
48
|
-
};
|
|
49
|
-
const sourceMap = await readSourceMap(file, packageDir, root);
|
|
50
|
-
return {
|
|
51
|
-
contents: instrumenter.instrumentSync(code, file, sourceMap),
|
|
52
|
-
loader: "js"
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
const hasCoverage = (value) => INSTRUMENTER_COVERAGE_VARIABLE in value;
|
|
58
|
-
const writeCoverage = () => {
|
|
59
|
-
const globalScope = globalThis;
|
|
60
|
-
if (!hasCoverage(globalScope)) return;
|
|
61
|
-
fs.writeFileSync(path.join(rawDir, `${crypto.randomUUID()}.json`), JSON.stringify(globalScope[INSTRUMENTER_COVERAGE_VARIABLE]));
|
|
62
|
-
};
|
|
63
|
-
process.on("exit", writeCoverage);
|
|
64
|
-
process.on("newListener", (event, listener) => {
|
|
65
|
-
if (event !== "exit" || listener === writeCoverage) return;
|
|
66
|
-
queueMicrotask(() => {
|
|
67
|
-
process.removeListener("exit", writeCoverage);
|
|
68
|
-
process.on("exit", writeCoverage);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
export {};
|
|
72
|
-
|
|
73
|
-
//# sourceMappingURL=child-preload.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"child-preload.js","names":[],"sources":["../../../src/test-utils/subprocess-coverage/child-preload.ts"],"sourcesContent":["// Records coverage of the installed package in every Bun process that a test starts.\n// Tests load this file through `BUN_OPTIONS` once a project imports `subprocess-coverage`.\nimport crypto from \"node:crypto\"\nimport fs from \"node:fs\"\nimport path from \"node:path\"\n\nimport { createInstrumenter } from \"@vitest/istanbul-lib-instrument\"\nimport type { InputSourceMap } from \"@vitest/istanbul-lib-instrument\"\nimport bun from \"bun\"\n\nimport { SUBPROCESS_COVERAGE_SETTINGS_VAR } from \"#test-utils/subprocess-coverage/env.ts\"\nimport type { CoverageSettings } from \"#test-utils/subprocess-coverage/env.ts\"\n\nconst INSTRUMENTER_COVERAGE_VARIABLE = \"subprocessCoverage\"\n\nconst isCoverageSettings = (value: unknown): value is CoverageSettings =>\n typeof value === \"object\"\n && value !== null\n && \"rawDir\" in value\n && typeof value.rawDir === \"string\"\n && \"root\" in value\n && typeof value.root === \"string\"\n && \"packageName\" in value\n && typeof value.packageName === \"string\"\n\n/** Reads the coverage settings from the environment, and throws when they're missing or invalid. */\nconst readCoverageSettings = () => {\n const settings = process.env[SUBPROCESS_COVERAGE_SETTINGS_VAR]\n if (settings === undefined)\n throw new Error(`the subprocess coverage preload loaded without ${SUBPROCESS_COVERAGE_SETTINGS_VAR}`)\n const parsed: unknown = JSON.parse(settings)\n if (!isCoverageSettings(parsed)) throw new Error(`${SUBPROCESS_COVERAGE_SETTINGS_VAR} isn't valid: ${settings}`)\n return parsed\n}\n\nconst { rawDir, root, packageName } = readCoverageSettings()\n\nconst isSourceMap = (value: unknown): value is InputSourceMap =>\n typeof value === \"object\" && value !== null && \"sources\" in value && Array.isArray(value.sources)\n\n/** Points each source in the installed package's map at the same file in the project, so reports name `src/`. */\nconst readSourceMap = async (file: string, packageDir: string, projectDir: string) => {\n const sourceMap: unknown = await bun.file(`${file}.map`).json()\n if (!isSourceMap(sourceMap)) throw new Error(`no source map for ${file}`)\n const sources = sourceMap.sources.map((source) => {\n const installedSource = path.resolve(path.dirname(file), source ?? \"\")\n return path.join(projectDir, path.relative(packageDir, installedSource))\n })\n return { ...sourceMap, sources }\n}\n\nconst instrumenter = createInstrumenter({ esModules: true, coverageVariable: INSTRUMENTER_COVERAGE_VARIABLE })\n// Match the built files of the copy that a test project installs, and capture its package dir.\nconst installedDist = new RegExp(String.raw`^(.*/node_modules/${RegExp.escape(packageName)})/dist/.*\\.js$`, \"v\")\n// Match the comment that a bundler adds to each file it writes a source map for.\nconst sourceMappingUrl = /^\\/\\/# sourceMappingURL=/mv\n\nbun.plugin({\n name: \"subprocess-coverage\",\n setup: (build) => {\n build.onLoad({ filter: installedDist }, async ({ path: file }) => {\n const [, packageDir = \"\"] = installedDist.exec(file) ?? []\n const code = await bun.file(file).text()\n // Pass through a file with no map, like a re-export-only entry, because it has no source of its own to cover.\n // A file whose comment names a missing map still throws, so a broken build doesn't go unnoticed.\n if (!sourceMappingUrl.test(code)) return { contents: code, loader: \"js\" }\n const sourceMap = await readSourceMap(file, packageDir, root)\n return { contents: instrumenter.instrumentSync(code, file, sourceMap), loader: \"js\" }\n })\n },\n})\n\nconst hasCoverage = (value: object): value is Record<typeof INSTRUMENTER_COVERAGE_VARIABLE, unknown> =>\n INSTRUMENTER_COVERAGE_VARIABLE in value\n\nconst writeCoverage = () => {\n // Copy `globalThis` to a local because TypeScript doesn't narrow `globalThis` itself.\n const globalScope: object = globalThis\n // Skip a process that never loaded the package, because only instrumented code creates the global.\n if (!hasCoverage(globalScope)) return\n fs.writeFileSync(\n path.join(rawDir, `${crypto.randomUUID()}.json`),\n JSON.stringify(globalScope[INSTRUMENTER_COVERAGE_VARIABLE]),\n )\n}\n\nprocess.on(\"exit\", writeCoverage)\n\n// Move `writeCoverage` behind each later exit listener so the coverage file includes what those listeners run.\n// Wait a microtask because `newListener` fires before the new listener is added.\n// A listener added in the same tick as a synchronous `process.exit()` still runs after the write.\nprocess.on(\"newListener\", (event, listener) => {\n if (event !== \"exit\" || listener === writeCoverage) return\n queueMicrotask(() => {\n process.removeListener(\"exit\", writeCoverage)\n process.on(\"exit\", writeCoverage)\n })\n})\n"],"mappings":";;;;;;;AAaA,MAAM,iCAAiC;AAEvC,MAAM,sBAAsB,UAC1B,OAAO,UAAU,YACd,UAAU,QACV,YAAY,SACZ,OAAO,MAAM,WAAW,YACxB,UAAU,SACV,OAAO,MAAM,SAAS,YACtB,iBAAiB,SACjB,OAAO,MAAM,gBAAgB;;AAGlC,MAAM,6BAA6B;CACjC,MAAM,WAAW,QAAQ,IAAI;CAC7B,IAAI,aAAa,KAAA,GACf,MAAM,IAAI,MAAM,kDAAkD,kCAAkC;CACtG,MAAM,SAAkB,KAAK,MAAM,QAAQ;CAC3C,IAAI,CAAC,mBAAmB,MAAM,GAAG,MAAM,IAAI,MAAM,GAAG,iCAAiC,gBAAgB,UAAU;CAC/G,OAAO;AACT;AAEA,MAAM,EAAE,QAAQ,MAAM,gBAAgB,qBAAqB;AAE3D,MAAM,eAAe,UACnB,OAAO,UAAU,YAAY,UAAU,QAAQ,aAAa,SAAS,MAAM,QAAQ,MAAM,OAAO;;AAGlG,MAAM,gBAAgB,OAAO,MAAc,YAAoB,eAAuB;CACpF,MAAM,YAAqB,MAAM,IAAI,KAAK,GAAG,KAAK,KAAK,CAAC,CAAC,KAAK;CAC9D,IAAI,CAAC,YAAY,SAAS,GAAG,MAAM,IAAI,MAAM,qBAAqB,MAAM;CACxE,MAAM,UAAU,UAAU,QAAQ,KAAK,WAAW;EAChD,MAAM,kBAAkB,KAAK,QAAQ,KAAK,QAAQ,IAAI,GAAG,UAAU,EAAE;EACrE,OAAO,KAAK,KAAK,YAAY,KAAK,SAAS,YAAY,eAAe,CAAC;CACzE,CAAC;CACD,OAAO;EAAE,GAAG;EAAW;CAAQ;AACjC;AAEA,MAAM,eAAe,mBAAmB;CAAE,WAAW;CAAM,kBAAkB;AAA+B,CAAC;AAE7G,MAAM,gBAAgB,IAAI,OAAO,OAAO,GAAG,qBAAqB,OAAO,OAAO,WAAW,EAAE,iBAAiB,GAAG;AAE/G,MAAM,mBAAmB;AAEzB,IAAI,OAAO;CACT,MAAM;CACN,QAAQ,UAAU;EAChB,MAAM,OAAO,EAAE,QAAQ,cAAc,GAAG,OAAO,EAAE,MAAM,WAAW;GAChE,MAAM,GAAG,aAAa,MAAM,cAAc,KAAK,IAAI,KAAK,CAAC;GACzD,MAAM,OAAO,MAAM,IAAI,KAAK,IAAI,CAAC,CAAC,KAAK;GAGvC,IAAI,CAAC,iBAAiB,KAAK,IAAI,GAAG,OAAO;IAAE,UAAU;IAAM,QAAQ;GAAK;GACxE,MAAM,YAAY,MAAM,cAAc,MAAM,YAAY,IAAI;GAC5D,OAAO;IAAE,UAAU,aAAa,eAAe,MAAM,MAAM,SAAS;IAAG,QAAQ;GAAK;EACtF,CAAC;CACH;AACF,CAAC;AAED,MAAM,eAAe,UACnB,kCAAkC;AAEpC,MAAM,sBAAsB;CAE1B,MAAM,cAAsB;CAE5B,IAAI,CAAC,YAAY,WAAW,GAAG;CAC/B,GAAG,cACD,KAAK,KAAK,QAAQ,GAAG,OAAO,WAAW,EAAE,MAAM,GAC/C,KAAK,UAAU,YAAY,+BAA+B,CAC5D;AACF;AAEA,QAAQ,GAAG,QAAQ,aAAa;AAKhC,QAAQ,GAAG,gBAAgB,OAAO,aAAa;CAC7C,IAAI,UAAU,UAAU,aAAa,eAAe;CACpD,qBAAqB;EACnB,QAAQ,eAAe,QAAQ,aAAa;EAC5C,QAAQ,GAAG,QAAQ,aAAa;CAClC,CAAC;AACH,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ShellEnv } from "../shell/shell.js";
|
|
2
|
-
/**
|
|
3
|
-
* Returns the variables that make child Bun processes record coverage, for a shell that doesn't inherit `process.env`.
|
|
4
|
-
* Returns nothing when the project doesn't import `@adamhl8/configs/test/subprocess-coverage`.
|
|
5
|
-
*/
|
|
6
|
-
export declare const subprocessCoverageEnv: () => ShellEnv;
|
|
7
|
-
//# sourceMappingURL=env.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","names":[],"sources":["../../../src/test-utils/subprocess-coverage/env.ts"],"mappings":";;;;;qBAiBa,6BAA4B"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import process from "node:process";
|
|
2
|
-
// src/test-utils/subprocess-coverage/env.ts
|
|
3
|
-
/** Holds the JSON settings that tell a child's preload where to write coverage and what to instrument. */
|
|
4
|
-
const SUBPROCESS_COVERAGE_SETTINGS_VAR = "ADAMHL8_SUBPROCESS_COVERAGE_SETTINGS";
|
|
5
|
-
/**
|
|
6
|
-
* Returns the variables that make child Bun processes record coverage, for a shell that doesn't inherit `process.env`.
|
|
7
|
-
* Returns nothing when the project doesn't import `@adamhl8/configs/test/subprocess-coverage`.
|
|
8
|
-
*/
|
|
9
|
-
const subprocessCoverageEnv = () => {
|
|
10
|
-
const settings = process.env[SUBPROCESS_COVERAGE_SETTINGS_VAR];
|
|
11
|
-
if (settings === void 0) return {};
|
|
12
|
-
return {
|
|
13
|
-
BUN_OPTIONS: process.env["BUN_OPTIONS"],
|
|
14
|
-
[SUBPROCESS_COVERAGE_SETTINGS_VAR]: settings
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
export { SUBPROCESS_COVERAGE_SETTINGS_VAR, subprocessCoverageEnv };
|
|
18
|
-
|
|
19
|
-
//# sourceMappingURL=env.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","names":[],"sources":["../../../src/test-utils/subprocess-coverage/env.ts"],"sourcesContent":["import process from \"node:process\"\n\nimport type { ShellEnv } from \"#test-utils/shell/shell.ts\"\n\n/** Holds the JSON settings that tell a child's preload where to write coverage and what to instrument. */\nexport const SUBPROCESS_COVERAGE_SETTINGS_VAR = \"ADAMHL8_SUBPROCESS_COVERAGE_SETTINGS\"\n\nexport interface CoverageSettings {\n rawDir: string\n root: string\n packageName: string\n}\n\n/**\n * Returns the variables that make child Bun processes record coverage, for a shell that doesn't inherit `process.env`.\n * Returns nothing when the project doesn't import `@adamhl8/configs/test/subprocess-coverage`.\n */\nexport const subprocessCoverageEnv = (): ShellEnv => {\n const settings = process.env[SUBPROCESS_COVERAGE_SETTINGS_VAR]\n if (settings === undefined) return {}\n return { BUN_OPTIONS: process.env[\"BUN_OPTIONS\"], [SUBPROCESS_COVERAGE_SETTINGS_VAR]: settings }\n}\n"],"mappings":";;;AAKA,MAAa,mCAAmC;;;;;AAYhD,MAAa,8BAAwC;CACnD,MAAM,WAAW,QAAQ,IAAI;CAC7B,IAAI,aAAa,KAAA,GAAW,OAAO,CAAC;CACpC,OAAO;EAAE,aAAa,QAAQ,IAAI;GAAiB,mCAAmC;CAAS;AACjG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { SUBPROCESS_COVERAGE_SETTINGS_VAR } from "./env.js";
|
|
2
|
-
import { reportCoverage } from "./report.js";
|
|
3
|
-
import process from "node:process";
|
|
4
|
-
import fs from "node:fs/promises";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import bun from "bun";
|
|
7
|
-
import os from "node:os";
|
|
8
|
-
import { afterAll } from "bun:test";
|
|
9
|
-
// src/test-utils/subprocess-coverage/preload.ts
|
|
10
|
-
const CHILD_PRELOAD = path.join(import.meta.dir, `child-preload${path.extname(import.meta.path)}`);
|
|
11
|
-
const hasName = (value) => typeof value === "object" && value !== null && "name" in value && typeof value.name === "string";
|
|
12
|
-
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
13
|
-
const root = process.cwd();
|
|
14
|
-
const packageJson = await bun.file(path.join(root, "package.json")).json();
|
|
15
|
-
if (!hasName(packageJson)) throw new Error(`subprocess coverage needs a package name in ${root}/package.json`);
|
|
16
|
-
const REPORT_DIR = path.join(root, "coverage/subprocess");
|
|
17
|
-
/** Returns Bun's `coveragePathIgnorePatterns` while its coverage is on, or `undefined` when it's off. */
|
|
18
|
-
const readBunIgnorePatterns = async () => {
|
|
19
|
-
const bunfigFile = bun.file(path.join(root, "bunfig.toml"));
|
|
20
|
-
const bunfig = await bunfigFile.exists() ? bun.TOML.parse(await bunfigFile.text()) : {};
|
|
21
|
-
const test = isRecord(bunfig) && isRecord(bunfig["test"]) ? bunfig["test"] : {};
|
|
22
|
-
if (!(test["coverage"] === true)) return;
|
|
23
|
-
return [test["coveragePathIgnorePatterns"]].flat().filter((pattern) => typeof pattern === "string");
|
|
24
|
-
};
|
|
25
|
-
const includePatterns = (await readBunIgnorePatterns())?.map((pattern) => path.join(root, pattern));
|
|
26
|
-
const rawDir = await fs.mkdtemp(path.join(os.tmpdir(), "subprocess-coverage-"));
|
|
27
|
-
const settings = {
|
|
28
|
-
rawDir,
|
|
29
|
-
root,
|
|
30
|
-
packageName: packageJson.name
|
|
31
|
-
};
|
|
32
|
-
process.env["BUN_OPTIONS"] = `--preload=${CHILD_PRELOAD}`;
|
|
33
|
-
process.env[SUBPROCESS_COVERAGE_SETTINGS_VAR] = JSON.stringify(settings);
|
|
34
|
-
afterAll(async () => {
|
|
35
|
-
await reportCoverage(rawDir, REPORT_DIR, includePatterns);
|
|
36
|
-
await fs.rm(rawDir, {
|
|
37
|
-
recursive: true,
|
|
38
|
-
force: true
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
export {};
|
|
42
|
-
|
|
43
|
-
//# sourceMappingURL=preload.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preload.js","names":[],"sources":["../../../src/test-utils/subprocess-coverage/preload.ts"],"sourcesContent":["// Turns on coverage for the package's own bins and modules that tests run in child processes.\n// Import it once, from the test preload, in the package's repo.\nimport { afterAll } from \"bun:test\"\nimport fs from \"node:fs/promises\"\nimport os from \"node:os\"\nimport path from \"node:path\"\nimport process from \"node:process\"\n\nimport bun from \"bun\"\n\nimport { SUBPROCESS_COVERAGE_SETTINGS_VAR } from \"#test-utils/subprocess-coverage/env.ts\"\nimport type { CoverageSettings } from \"#test-utils/subprocess-coverage/env.ts\"\nimport { reportCoverage } from \"#test-utils/subprocess-coverage/report.ts\"\n\n// Match this file's extension so the preload is the `.ts` source in this repo and the built `.js` in `dist/`.\nconst CHILD_PRELOAD = path.join(import.meta.dir, `child-preload${path.extname(import.meta.path)}`)\n\nconst hasName = (value: unknown): value is { name: string } =>\n typeof value === \"object\" && value !== null && \"name\" in value && typeof value.name === \"string\"\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => typeof value === \"object\" && value !== null\n\nconst root = process.cwd()\nconst packageJson: unknown = await bun.file(path.join(root, \"package.json\")).json()\nif (!hasName(packageJson)) throw new Error(`subprocess coverage needs a package name in ${root}/package.json`)\n\n// Write to a subdir because Bun writes its own `coverage/lcov.info` after this report.\nconst REPORT_DIR = path.join(root, \"coverage/subprocess\")\n\n/** Returns Bun's `coveragePathIgnorePatterns` while its coverage is on, or `undefined` when it's off. */\nconst readBunIgnorePatterns = async () => {\n const bunfigFile = bun.file(path.join(root, \"bunfig.toml\"))\n const bunfig: unknown = (await bunfigFile.exists()) ? bun.TOML.parse(await bunfigFile.text()) : {}\n const test = isRecord(bunfig) && isRecord(bunfig[\"test\"]) ? bunfig[\"test\"] : {}\n\n const isBunCoverageOn = test[\"coverage\"] === true\n if (!isBunCoverageOn) return\n\n const coverageIgnorePatterns = test[\"coveragePathIgnorePatterns\"]\n return [coverageIgnorePatterns].flat().filter((pattern) => typeof pattern === \"string\")\n}\n\n// Report only the files that Bun's coverage ignores, so each file appears in one report.\n// Join each pattern onto `root` because Bun's patterns are root-relative and the report's paths are absolute.\nconst includePatterns = (await readBunIgnorePatterns())?.map((pattern) => path.join(root, pattern))\n\nconst rawDir = await fs.mkdtemp(path.join(os.tmpdir(), \"subprocess-coverage-\"))\nconst settings: CoverageSettings = { rawDir, root, packageName: packageJson.name }\n\n// Set these on `process.env` so `subprocessCoverageEnv` and shells that inherit `process.env` pass them on.\nprocess.env[\"BUN_OPTIONS\"] = `--preload=${CHILD_PRELOAD}`\nprocess.env[SUBPROCESS_COVERAGE_SETTINGS_VAR] = JSON.stringify(settings)\n\nafterAll(async () => {\n await reportCoverage(rawDir, REPORT_DIR, includePatterns)\n await fs.rm(rawDir, { recursive: true, force: true })\n})\n"],"mappings":";;;;;;;;;AAeA,MAAM,gBAAgB,KAAK,KAAK,YAAY,KAAK,gBAAgB,KAAK,QAAQ,YAAY,IAAI,GAAG;AAEjG,MAAM,WAAW,UACf,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,SAAS,OAAO,MAAM,SAAS;AAE1F,MAAM,YAAY,UAAqD,OAAO,UAAU,YAAY,UAAU;AAE9G,MAAM,OAAO,QAAQ,IAAI;AACzB,MAAM,cAAuB,MAAM,IAAI,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC,CAAC,CAAC,KAAK;AAClF,IAAI,CAAC,QAAQ,WAAW,GAAG,MAAM,IAAI,MAAM,+CAA+C,KAAK,cAAc;AAG7G,MAAM,aAAa,KAAK,KAAK,MAAM,qBAAqB;;AAGxD,MAAM,wBAAwB,YAAY;CACxC,MAAM,aAAa,IAAI,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;CAC1D,MAAM,SAAmB,MAAM,WAAW,OAAO,IAAK,IAAI,KAAK,MAAM,MAAM,WAAW,KAAK,CAAC,IAAI,CAAC;CACjG,MAAM,OAAO,SAAS,MAAM,KAAK,SAAS,OAAO,OAAO,IAAI,OAAO,UAAU,CAAC;CAG9E,IAAI,EADoB,KAAK,gBAAgB,OACvB;CAGtB,OAAO,CADwB,KAAK,6BACN,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,YAAY,OAAO,YAAY,QAAQ;AACxF;AAIA,MAAM,mBAAmB,MAAM,sBAAsB,EAAA,EAAI,KAAK,YAAY,KAAK,KAAK,MAAM,OAAO,CAAC;AAElG,MAAM,SAAS,MAAM,GAAG,QAAQ,KAAK,KAAK,GAAG,OAAO,GAAG,sBAAsB,CAAC;AAC9E,MAAM,WAA6B;CAAE;CAAQ;CAAM,aAAa,YAAY;AAAK;AAGjF,QAAQ,IAAI,iBAAiB,aAAa;AAC1C,QAAQ,IAAI,oCAAoC,KAAK,UAAU,QAAQ;AAEvE,SAAS,YAAY;CACnB,MAAM,eAAe,QAAQ,YAAY,eAAe;CACxD,MAAM,GAAG,GAAG,QAAQ;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC;AACtD,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import bun from "bun";
|
|
4
|
-
import { createCoverageMap } from "@vitest/istanbul-lib-coverage";
|
|
5
|
-
import { create, createContext } from "@vitest/istanbul-lib-report";
|
|
6
|
-
import { createSourceMapStore } from "@vitest/istanbul-lib-source-maps";
|
|
7
|
-
// src/test-utils/subprocess-coverage/report.ts
|
|
8
|
-
const isCoverageMapData = (value) => typeof value === "object" && value !== null;
|
|
9
|
-
/**
|
|
10
|
-
* Merges the coverage from every process in `rawDir`, maps it back to the source, and writes a text and lcov report.
|
|
11
|
-
* Reports only the source files that match a glob in `includePatterns`, or every file when it's `undefined`.
|
|
12
|
-
*/
|
|
13
|
-
const reportCoverage = async (rawDir, reportDir, includePatterns) => {
|
|
14
|
-
const rawFiles = await fs.readdir(rawDir);
|
|
15
|
-
if (rawFiles.length === 0) return;
|
|
16
|
-
const rawCoverages = await Promise.all(rawFiles.map(async (rawFile) => bun.file(path.join(rawDir, rawFile)).json()));
|
|
17
|
-
const coverageMap = createCoverageMap({});
|
|
18
|
-
for (const rawCoverage of rawCoverages) if (isCoverageMapData(rawCoverage)) coverageMap.merge(rawCoverage);
|
|
19
|
-
const sourceCoverageMap = await createSourceMapStore().transformCoverage(coverageMap);
|
|
20
|
-
if (includePatterns) {
|
|
21
|
-
const globs = includePatterns.map((pattern) => new bun.Glob(pattern));
|
|
22
|
-
sourceCoverageMap.filter((file) => globs.some((glob) => glob.match(file)));
|
|
23
|
-
}
|
|
24
|
-
if (sourceCoverageMap.files().length === 0) return;
|
|
25
|
-
console.log("\nSubprocess coverage:");
|
|
26
|
-
const context = createContext({
|
|
27
|
-
dir: reportDir,
|
|
28
|
-
coverageMap: sourceCoverageMap
|
|
29
|
-
});
|
|
30
|
-
create("text").execute(context);
|
|
31
|
-
create("lcovonly").execute(context);
|
|
32
|
-
};
|
|
33
|
-
export { reportCoverage };
|
|
34
|
-
|
|
35
|
-
//# sourceMappingURL=report.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"report.js","names":[],"sources":["../../../src/test-utils/subprocess-coverage/report.ts"],"sourcesContent":["import fs from \"node:fs/promises\"\nimport path from \"node:path\"\n\nimport { createCoverageMap } from \"@vitest/istanbul-lib-coverage\"\nimport type { CoverageMapData } from \"@vitest/istanbul-lib-coverage\"\nimport { create as createReport, createContext } from \"@vitest/istanbul-lib-report\"\nimport { createSourceMapStore } from \"@vitest/istanbul-lib-source-maps\"\nimport bun from \"bun\"\n\nconst isCoverageMapData = (value: unknown): value is CoverageMapData => typeof value === \"object\" && value !== null\n\n/**\n * Merges the coverage from every process in `rawDir`, maps it back to the source, and writes a text and lcov report.\n * Reports only the source files that match a glob in `includePatterns`, or every file when it's `undefined`.\n */\nexport const reportCoverage = async (rawDir: string, reportDir: string, includePatterns?: string[]) => {\n const rawFiles = await fs.readdir(rawDir)\n if (rawFiles.length === 0) return\n\n const rawCoverages = await Promise.all(\n rawFiles.map(async (rawFile): Promise<unknown> => bun.file(path.join(rawDir, rawFile)).json()),\n )\n const coverageMap = createCoverageMap({})\n for (const rawCoverage of rawCoverages) if (isCoverageMapData(rawCoverage)) coverageMap.merge(rawCoverage)\n\n const sourceCoverageMap = await createSourceMapStore().transformCoverage(coverageMap)\n if (includePatterns) {\n const globs = includePatterns.map((pattern) => new bun.Glob(pattern))\n sourceCoverageMap.filter((file) => globs.some((glob) => glob.match(file)))\n }\n if (sourceCoverageMap.files().length === 0) return\n\n // Label the table because Bun's own coverage table can print next to it.\n console.log(\"\\nSubprocess coverage:\")\n const context = createContext({ dir: reportDir, coverageMap: sourceCoverageMap })\n createReport(\"text\").execute(context)\n createReport(\"lcovonly\").execute(context)\n}\n"],"mappings":";;;;;;;AASA,MAAM,qBAAqB,UAA6C,OAAO,UAAU,YAAY,UAAU;;;;;AAM/G,MAAa,iBAAiB,OAAO,QAAgB,WAAmB,oBAA+B;CACrG,MAAM,WAAW,MAAM,GAAG,QAAQ,MAAM;CACxC,IAAI,SAAS,WAAW,GAAG;CAE3B,MAAM,eAAe,MAAM,QAAQ,IACjC,SAAS,IAAI,OAAO,YAA8B,IAAI,KAAK,KAAK,KAAK,QAAQ,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAC/F;CACA,MAAM,cAAc,kBAAkB,CAAC,CAAC;CACxC,KAAK,MAAM,eAAe,cAAc,IAAI,kBAAkB,WAAW,GAAG,YAAY,MAAM,WAAW;CAEzG,MAAM,oBAAoB,MAAM,qBAAqB,CAAC,CAAC,kBAAkB,WAAW;CACpF,IAAI,iBAAiB;EACnB,MAAM,QAAQ,gBAAgB,KAAK,YAAY,IAAI,IAAI,KAAK,OAAO,CAAC;EACpE,kBAAkB,QAAQ,SAAS,MAAM,MAAM,SAAS,KAAK,MAAM,IAAI,CAAC,CAAC;CAC3E;CACA,IAAI,kBAAkB,MAAM,CAAC,CAAC,WAAW,GAAG;CAG5C,QAAQ,IAAI,wBAAwB;CACpC,MAAM,UAAU,cAAc;EAAE,KAAK;EAAW,aAAa;CAAkB,CAAC;CAChF,OAAa,MAAM,CAAC,CAAC,QAAQ,OAAO;CACpC,OAAa,UAAU,CAAC,CAAC,QAAQ,OAAO;AAC1C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"temp-dir.d.ts","names":[],"sources":["../../src/test-utils/temp-dir.ts"],"mappings":";qBAOa,cAAW,mBAAwB"}
|