@harnessed-ts/config 0.2.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/CHANGELOG.md ADDED
@@ -0,0 +1,22 @@
1
+ # @harnessed-ts/config
2
+
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - The packages publish under the `@harnessed-ts` scope. Nothing shipped under the
8
+ previous `@harnessed` scope, so there is no migration to perform.
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+ - @harnessed-ts/core@0.2.0
14
+
15
+ ## 0.1.0
16
+
17
+ First release.
18
+
19
+ Loads `harnessed.config.ts` from disk, via jiti, so the file can stay TypeScript
20
+ for callers that have no bundler — the ESLint plugin and the Claude CLI. Resolves
21
+ by walking up from the file being checked rather than from the working directory,
22
+ which is what makes it correct in a monorepo.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Joe Gaudet, Jay Seo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.cjs ADDED
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ var fs = require('fs');
4
+ var path = require('path');
5
+ var jiti = require('jiti');
6
+
7
+ // src/index.ts
8
+ var FILENAMES = [
9
+ "harnessed.config.ts",
10
+ "harnessed.config.mts",
11
+ "harnessed.config.js",
12
+ "harnessed.config.mjs"
13
+ ];
14
+ var cache = /* @__PURE__ */ new Map();
15
+ function findConfig(root = process.cwd()) {
16
+ return FILENAMES.map((name) => path.join(root, name)).find(fs.existsSync);
17
+ }
18
+ function loadConfig(root = process.cwd()) {
19
+ if (cache.has(root)) return cache.get(root);
20
+ const file = findConfig(root);
21
+ let config;
22
+ if (file !== void 0) {
23
+ const jiti$1 = jiti.createJiti(root, { interopDefault: true });
24
+ const loaded = jiti$1(file);
25
+ config = "default" in loaded && loaded.default !== void 0 ? loaded.default : loaded;
26
+ }
27
+ cache.set(root, config);
28
+ return config;
29
+ }
30
+ function loadConfigFor(filename) {
31
+ const { root } = path.parse(filename);
32
+ let dir = path.dirname(filename);
33
+ for (; ; ) {
34
+ if (findConfig(dir) !== void 0) return loadConfig(dir);
35
+ if (dir === root) return void 0;
36
+ const parent = path.dirname(dir);
37
+ if (parent === dir) return void 0;
38
+ dir = parent;
39
+ }
40
+ }
41
+ function clearConfigCache() {
42
+ cache.clear();
43
+ }
44
+
45
+ exports.clearConfigCache = clearConfigCache;
46
+ exports.findConfig = findConfig;
47
+ exports.loadConfig = loadConfig;
48
+ exports.loadConfigFor = loadConfigFor;
49
+ //# sourceMappingURL=index.cjs.map
50
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":["join","existsSync","jiti","createJiti","parse","dirname"],"mappings":";;;;;;;AAQA,IAAM,SAAA,GAAY;AAAA,EAChB,qBAAA;AAAA,EACA,sBAAA;AAAA,EACA,qBAAA;AAAA,EACA;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A;AAC3B,IAAA,GAAA,GAAM,MAAA;AAAA,EACR;AACF;AAGO,SAAS,gBAAA,GAAyB;AACvC,EAAA,KAAA,CAAM,KAAA,EAAM;AACd","file":"index.cjs","sourcesContent":["import { existsSync } from 'node:fs'\nimport { dirname, join, parse } from 'node:path'\nimport type { HarnessedConfig } from '@harnessed-ts/core'\nimport { createJiti } from 'jiti'\n\nexport type { HarnessedConfig }\n\n/** Tried in order; the first that exists wins. */\nconst FILENAMES = [\n 'harnessed.config.ts',\n 'harnessed.config.mts',\n 'harnessed.config.js',\n 'harnessed.config.mjs',\n]\n\nconst cache = new Map<string, HarnessedConfig | undefined>()\n\n/** The config file's path, if a repo has one. */\nexport function findConfig(root: string = process.cwd()): string | undefined {\n return FILENAMES.map(name => join(root, name)).find(existsSync)\n}\n\n/**\n * Reads `harnessed.config.ts` from disk.\n *\n * Synchronous and TypeScript-capable, because the callers are an ESLint rule and\n * a CLI — neither of which runs inside a bundler that would transform the file\n * for them. That is what `jiti` is for, and why this is a separate package:\n * `@harnessed-ts/core` stays dependency-free and usable in a browser.\n *\n * Cached per root: an ESLint run asks once per file, and the answer cannot change\n * within a run.\n */\nexport function loadConfig(root: string = process.cwd()): HarnessedConfig | undefined {\n if (cache.has(root)) return cache.get(root)\n\n const file = findConfig(root)\n let config: HarnessedConfig | undefined\n if (file !== undefined) {\n const jiti = createJiti(root, { interopDefault: true })\n const loaded = jiti(file) as HarnessedConfig | { default?: HarnessedConfig }\n config =\n 'default' in loaded && loaded.default !== undefined\n ? loaded.default\n : (loaded as HarnessedConfig)\n }\n\n cache.set(root, config)\n return config\n}\n\n/**\n * The config governing a particular file, found by walking up from it.\n *\n * Resolving from the file rather than the process's working directory is what\n * makes this correct for a monorepo, and for an editor or a lint run started from\n * anywhere other than the repo root — `cwd` says where the tool was invoked,\n * which is not a fact about the code being checked.\n */\nexport function loadConfigFor(filename: string): HarnessedConfig | undefined {\n const { root } = parse(filename)\n let dir = dirname(filename)\n for (;;) {\n if (findConfig(dir) !== undefined) return loadConfig(dir)\n if (dir === root) return undefined\n const parent = dirname(dir)\n if (parent === dir) return undefined\n dir = parent\n }\n}\n\n/** Forgets what was loaded. For tests, and for a long-lived editor process. */\nexport function clearConfigCache(): void {\n cache.clear()\n}\n"]}
@@ -0,0 +1,28 @@
1
+ import type { HarnessedConfig } from '@harnessed-ts/core';
2
+ export type { HarnessedConfig };
3
+ /** The config file's path, if a repo has one. */
4
+ export declare function findConfig(root?: string): string | undefined;
5
+ /**
6
+ * Reads `harnessed.config.ts` from disk.
7
+ *
8
+ * Synchronous and TypeScript-capable, because the callers are an ESLint rule and
9
+ * a CLI — neither of which runs inside a bundler that would transform the file
10
+ * for them. That is what `jiti` is for, and why this is a separate package:
11
+ * `@harnessed-ts/core` stays dependency-free and usable in a browser.
12
+ *
13
+ * Cached per root: an ESLint run asks once per file, and the answer cannot change
14
+ * within a run.
15
+ */
16
+ export declare function loadConfig(root?: string): HarnessedConfig | undefined;
17
+ /**
18
+ * The config governing a particular file, found by walking up from it.
19
+ *
20
+ * Resolving from the file rather than the process's working directory is what
21
+ * makes this correct for a monorepo, and for an editor or a lint run started from
22
+ * anywhere other than the repo root — `cwd` says where the tool was invoked,
23
+ * which is not a fact about the code being checked.
24
+ */
25
+ export declare function loadConfigFor(filename: string): HarnessedConfig | undefined;
26
+ /** Forgets what was loaded. For tests, and for a long-lived editor process. */
27
+ export declare function clearConfigCache(): void;
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAGzD,YAAY,EAAE,eAAe,EAAE,CAAA;AAY/B,iDAAiD;AACjD,wBAAgB,UAAU,CAAC,IAAI,GAAE,MAAsB,GAAG,MAAM,GAAG,SAAS,CAE3E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,IAAI,GAAE,MAAsB,GAAG,eAAe,GAAG,SAAS,CAgBpF;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAU3E;AAED,+EAA+E;AAC/E,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC"}
package/dist/index.js ADDED
@@ -0,0 +1,45 @@
1
+ import { existsSync } from 'fs';
2
+ import { join, parse, dirname } from 'path';
3
+ import { createJiti } from 'jiti';
4
+
5
+ // src/index.ts
6
+ var FILENAMES = [
7
+ "harnessed.config.ts",
8
+ "harnessed.config.mts",
9
+ "harnessed.config.js",
10
+ "harnessed.config.mjs"
11
+ ];
12
+ var cache = /* @__PURE__ */ new Map();
13
+ function findConfig(root = process.cwd()) {
14
+ return FILENAMES.map((name) => join(root, name)).find(existsSync);
15
+ }
16
+ function loadConfig(root = process.cwd()) {
17
+ if (cache.has(root)) return cache.get(root);
18
+ const file = findConfig(root);
19
+ let config;
20
+ if (file !== void 0) {
21
+ const jiti = createJiti(root, { interopDefault: true });
22
+ const loaded = jiti(file);
23
+ config = "default" in loaded && loaded.default !== void 0 ? loaded.default : loaded;
24
+ }
25
+ cache.set(root, config);
26
+ return config;
27
+ }
28
+ function loadConfigFor(filename) {
29
+ const { root } = parse(filename);
30
+ let dir = dirname(filename);
31
+ for (; ; ) {
32
+ if (findConfig(dir) !== void 0) return loadConfig(dir);
33
+ if (dir === root) return void 0;
34
+ const parent = dirname(dir);
35
+ if (parent === dir) return void 0;
36
+ dir = parent;
37
+ }
38
+ }
39
+ function clearConfigCache() {
40
+ cache.clear();
41
+ }
42
+
43
+ export { clearConfigCache, findConfig, loadConfig, loadConfigFor };
44
+ //# sourceMappingURL=index.js.map
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAQA,IAAM,SAAA,GAAY;AAAA,EAChB,qBAAA;AAAA,EACA,sBAAA;AAAA,EACA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AK,OAAO,MAAA;AAC3B,IAAA,GAAA,GAAM,MAAA;AAAA,EACR;AACF;AAGO,SAAS,gBAAA,GAAyB;AACvC,EAAA,KAAA,CAAM,KAAA,EAAM;AACd","file":"index.js","sourcesContent":["import { existsSync } from 'node:fs'\nimport { dirname, join, parse } from 'node:path'\nimport type { HarnessedConfig } from '@harnessed-ts/core'\nimport { createJiti } from 'jiti'\n\nexport type { HarnessedConfig }\n\n/** Tried in order; the first that exists wins. */\nconst FILENAMES = [\n 'harnessed.config.ts',\n 'harnessed.config.mts',\n 'harnessed.config.js',\n 'harnessed.config.mjs',\n]\n\nconst cache = new Map<string, HarnessedConfig | undefined>()\n\n/** The config file's path, if a repo has one. */\nexport function findConfig(root: string = process.cwd()): string | undefined {\n return FILENAMES.map(name => join(root, name)).find(existsSync)\n}\n\n/**\n * Reads `harnessed.config.ts` from disk.\n *\n * Synchronous and TypeScript-capable, because the callers are an ESLint rule and\n * a CLI — neither of which runs inside a bundler that would transform the file\n * for them. That is what `jiti` is for, and why this is a separate package:\n * `@harnessed-ts/core` stays dependency-free and usable in a browser.\n *\n * Cached per root: an ESLint run asks once per file, and the answer cannot change\n * within a run.\n */\nexport function loadConfig(root: string = process.cwd()): HarnessedConfig | undefined {\n if (cache.has(root)) return cache.get(root)\n\n const file = findConfig(root)\n let config: HarnessedConfig | undefined\n if (file !== undefined) {\n const jiti = createJiti(root, { interopDefault: true })\n const loaded = jiti(file) as HarnessedConfig | { default?: HarnessedConfig }\n config =\n 'default' in loaded && loaded.default !== undefined\n ? loaded.default\n : (loaded as HarnessedConfig)\n }\n\n cache.set(root, config)\n return config\n}\n\n/**\n * The config governing a particular file, found by walking up from it.\n *\n * Resolving from the file rather than the process's working directory is what\n * makes this correct for a monorepo, and for an editor or a lint run started from\n * anywhere other than the repo root — `cwd` says where the tool was invoked,\n * which is not a fact about the code being checked.\n */\nexport function loadConfigFor(filename: string): HarnessedConfig | undefined {\n const { root } = parse(filename)\n let dir = dirname(filename)\n for (;;) {\n if (findConfig(dir) !== undefined) return loadConfig(dir)\n if (dir === root) return undefined\n const parent = dirname(dir)\n if (parent === dir) return undefined\n dir = parent\n }\n}\n\n/** Forgets what was loaded. For tests, and for a long-lived editor process. */\nexport function clearConfigCache(): void {\n cache.clear()\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@harnessed-ts/config",
3
+ "version": "0.2.0",
4
+ "description": "Loads harnessed.config.ts, so the runtime, the linter, and the docs generator read one file.",
5
+ "keywords": [
6
+ "testing",
7
+ "harness",
8
+ "config"
9
+ ],
10
+ "license": "MIT",
11
+ "contributors": [
12
+ {
13
+ "name": "Joe Gaudet",
14
+ "url": "https://github.com/joegaudet"
15
+ },
16
+ {
17
+ "name": "Jay Seo",
18
+ "url": "https://github.com/jayseo5953"
19
+ }
20
+ ],
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/joegaudet/harnessed.git",
24
+ "directory": "packages/config"
25
+ },
26
+ "homepage": "https://github.com/joegaudet/harnessed#readme",
27
+ "bugs": "https://github.com/joegaudet/harnessed/issues",
28
+ "type": "module",
29
+ "main": "./dist/index.cjs",
30
+ "module": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "exports": {
33
+ ".": {
34
+ "types": "./dist/index.d.ts",
35
+ "import": "./dist/index.js",
36
+ "require": "./dist/index.cjs"
37
+ },
38
+ "./package.json": "./package.json"
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "CHANGELOG.md",
43
+ "README.md",
44
+ "LICENSE"
45
+ ],
46
+ "engines": {
47
+ "node": ">=22.12.0"
48
+ },
49
+ "dependencies": {
50
+ "@harnessed-ts/core": "^0.2.0",
51
+ "jiti": "^2.4.2"
52
+ },
53
+ "publishConfig": {
54
+ "access": "public",
55
+ "provenance": true
56
+ },
57
+ "scripts": {
58
+ "build": "tsup",
59
+ "clean": "rm -rf dist *.tsbuildinfo"
60
+ }
61
+ }