@cogs/config 0.4.0 → 0.5.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.
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Correlates each key in a raw `.env` file's contents back to the value **as it
3
+ * literally appears in the file**, wrapping quotes intact.
4
+ *
5
+ * Why this module exists: `dotenv.parse` strips wrapping quotes at parse time
6
+ * (`dotenv-with-expand.ts:70`), so a checker fed a parsed value structurally
7
+ * cannot observe the quote-wrapping defect it exists to detect. The checkers
8
+ * need the pre-parse substring, and `dotenv` exports no line splitter to get it
9
+ * (its parser is a single module-private regex).
10
+ *
11
+ * Internal module — deliberately NOT re-exported from `index.ts`.
12
+ */
13
+ /**
14
+ * Vendored, version-pinned adaptation of `dotenv`'s `LINE` regex.
15
+ *
16
+ * Source: `node_modules/.pnpm/dotenv@16.6.1/node_modules/dotenv/lib/main.js:8`
17
+ * as of `dotenv@16.6.1`. Copied byte-for-byte — the whole point is to split
18
+ * lines exactly the way `dotenv` itself does, so `parse()`'s keys and this
19
+ * module's keys can never disagree.
20
+ *
21
+ * ⚠️ VERSION DRIFT: `package.json` depends on `dotenv` at the caret range
22
+ * `^16.6.1`, so a minor/patch bump can land without a code change here. On any
23
+ * `dotenv` version bump, re-read `lib/main.js`'s `LINE` constant and re-verify
24
+ * this copy against it. See
25
+ * `.omc/plans/2026-09-07-config-lint-prevention-at-source.md` (AC3).
26
+ *
27
+ * Structure, for readers who would rather not parse it by eye:
28
+ * - an optional leading `export ` is consumed *outside* both capture groups
29
+ * - group 1 is the key
30
+ * - group 2 is the value: either a quoted alternative (`'…'`, `"…"`, `` `…` ``,
31
+ * each using a `[^X]` character class that matches `\n`, which is what makes
32
+ * multiline quoted values correlate correctly in a single match) or the
33
+ * unquoted alternative `[^#\r\n]+`, which stops at a `#` and therefore already
34
+ * excludes any inline comment
35
+ * - group 2 is optional, so `KEY=` yields `undefined`
36
+ */
37
+ const DOTENV_LINE_SOURCE = '(?:^|^)\\s*(?:export\\s+)?([\\w.-]+)(?:\\s*=\\s*?|:\\s+?)(\\s*\'(?:\\\\\'|[^\'])*\'|\\s*"(?:\\\\"|[^"])*"|\\s*`(?:\\\\`|[^`])*`|[^#\\r\\n]+)?\\s*(?:#.*)?(?:$|$)';
38
+ /** A value that is wrapped in a matched pair of `'`, `"`, or `` ` ``. */
39
+ const MATCHED_QUOTE_PAIR = /^(['"`])[\s\S]*\1$/;
40
+ /**
41
+ * Normalize one raw capture into the `rawValue` contract the value checkers
42
+ * expect.
43
+ *
44
+ * - a missing capture (`KEY=`) becomes `''`, mirroring `main.js:25`'s
45
+ * `(match[2] || '')` — never `undefined`, which would throw in the checkers
46
+ * - the leading whitespace the three quoted alternatives each absorb via their
47
+ * own `\s*` is a regex artifact, not part of the value, and is stripped
48
+ * - a quoted value is then returned **exactly as captured, quotes intact**, with
49
+ * no further trimming: the closing quote already bounds it precisely
50
+ * - an unquoted value has any trailing inline comment and the whitespace before
51
+ * it removed, mirroring `main.js:29`'s unconditional `.trim()` of unquoted
52
+ * captures. (The regex's `[^#\r\n]+` alternative already stops at the `#`, so
53
+ * in practice only the trailing whitespace is left to strip; the explicit
54
+ * comment strip below is belt-and-braces and cannot fire on a capture this
55
+ * regex produced.)
56
+ */
57
+ const normalizeRawValue = (captured) => {
58
+ if (captured === undefined)
59
+ return '';
60
+ const value = captured.trimStart();
61
+ if (MATCHED_QUOTE_PAIR.test(value))
62
+ return value;
63
+ return value.replace(/\s*#[^\n]*$/, '').trimEnd();
64
+ };
65
+ /**
66
+ * Map every key in `contents` to its raw pre-parse value.
67
+ *
68
+ * Duplicate keys resolve **last-match-wins**, matching `dotenv.parse`'s own
69
+ * behavior (verified: parsing `DUP=first\nDUP=second` returns `{DUP:'second'}`).
70
+ *
71
+ * @param contents - The raw text of a `.env` file.
72
+ * @returns Key → raw value, quotes intact. See {@link normalizeRawValue}.
73
+ */
74
+ export const correlateRawValues = (contents) => {
75
+ // Built per call rather than hoisted: a `g`-flagged regex carries mutable
76
+ // `lastIndex`, and a shared instance would make concurrent or aborted scans
77
+ // silently skip entries.
78
+ const line = new RegExp(DOTENV_LINE_SOURCE, 'mg');
79
+ // Normalize line breaks exactly as `main.js:19` does before matching.
80
+ const normalized = contents.replace(/\r\n?/gm, '\n');
81
+ const rawValues = new Map();
82
+ let match = line.exec(normalized);
83
+ while (match !== null) {
84
+ const key = match[1];
85
+ if (key !== undefined) {
86
+ rawValues.set(key, normalizeRawValue(match[2]));
87
+ }
88
+ match = line.exec(normalized);
89
+ }
90
+ return rawValues;
91
+ };
92
+ //# sourceMappingURL=dotenv-correlation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dotenv-correlation.js","sourceRoot":"","sources":["../src/dotenv-correlation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,kBAAkB,GACtB,kKAAkK,CAAA;AAEpK,yEAAyE;AACzE,MAAM,kBAAkB,GAAG,oBAAoB,CAAA;AAE/C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,iBAAiB,GAAG,CAAC,QAA4B,EAAU,EAAE;IACjE,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,EAAE,CAAA;IAErC,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,EAAE,CAAA;IAClC,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IAEhD,OAAO,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAA;AACnD,CAAC,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,QAAgB,EAAuB,EAAE;IAC1E,0EAA0E;IAC1E,4EAA4E;IAC5E,yBAAyB;IACzB,MAAM,IAAI,GAAG,IAAI,MAAM,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAA;IAEjD,sEAAsE;IACtE,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;IAEpD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAA;IAC3C,IAAI,KAAK,GAA2B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACzD,OAAO,KAAK,KAAK,IAAI,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QACpB,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACjD,CAAC;QACD,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAC/B,CAAC;IAED,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Resolve the canonical layered `.env*` file chain, low → high precedence.
3
+ *
4
+ * Extracted verbatim from `envs.ts` so the `config-lint` bin can lint exactly
5
+ * the files `envs()` would load, without reimplementing the precedence order.
6
+ *
7
+ * Internal module — deliberately NOT re-exported from `index.ts`.
8
+ *
9
+ * @param options.appDirectory - App root. Relative entries resolve against it;
10
+ * when empty the chain is empty, matching `envs()`'s existing behavior.
11
+ * @param options.secretsPath - Optional injected-secrets file, slotted between
12
+ * `.env.${env}` and `.env.${env}.local`.
13
+ * @param options.nodeEnv - `NODE_ENV`. `.env.local` is skipped when `'test'` so
14
+ * personal-machine overrides never leak into a deterministic test run.
15
+ * @param options.env - `ENV`, the stage selector.
16
+ * @returns Absolute paths in precedence order (later wins).
17
+ */
18
+ export declare const resolveDotenvFileChain: ({ appDirectory, secretsPath, nodeEnv, env, }: {
19
+ appDirectory?: string;
20
+ secretsPath?: string;
21
+ nodeEnv?: string;
22
+ env?: string;
23
+ }) => string[];
24
+ //# sourceMappingURL=dotenv-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dotenv-files.d.ts","sourceRoot":"","sources":["../src/dotenv-files.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,sBAAsB,GAAI,8CAKpC;IACD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,KAAG,MAAM,EAqBT,CAAA"}
@@ -0,0 +1,40 @@
1
+ import { isAbsolute } from 'node:path';
2
+ import { resolveApp } from './utils.js';
3
+ /**
4
+ * Resolve the canonical layered `.env*` file chain, low → high precedence.
5
+ *
6
+ * Extracted verbatim from `envs.ts` so the `config-lint` bin can lint exactly
7
+ * the files `envs()` would load, without reimplementing the precedence order.
8
+ *
9
+ * Internal module — deliberately NOT re-exported from `index.ts`.
10
+ *
11
+ * @param options.appDirectory - App root. Relative entries resolve against it;
12
+ * when empty the chain is empty, matching `envs()`'s existing behavior.
13
+ * @param options.secretsPath - Optional injected-secrets file, slotted between
14
+ * `.env.${env}` and `.env.${env}.local`.
15
+ * @param options.nodeEnv - `NODE_ENV`. `.env.local` is skipped when `'test'` so
16
+ * personal-machine overrides never leak into a deterministic test run.
17
+ * @param options.env - `ENV`, the stage selector.
18
+ * @returns Absolute paths in precedence order (later wins).
19
+ */
20
+ export const resolveDotenvFileChain = ({ appDirectory = '', secretsPath = '', nodeEnv, env, }) => {
21
+ // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
22
+ const dotenvFiles = [
23
+ '.env',
24
+ // Don't include `.env.local` for `test` environment since normally you
25
+ // expect tests to produce the same results for everyone
26
+ nodeEnv !== 'test' && '.env.local',
27
+ env && `.env.${env}`,
28
+ secretsPath,
29
+ env && `.env.${env}.local`,
30
+ ].filter(Boolean);
31
+ if (!appDirectory) {
32
+ return [];
33
+ }
34
+ return dotenvFiles.reduce((acc, dotenvFile) => {
35
+ return isAbsolute(dotenvFile)
36
+ ? acc.concat(dotenvFile)
37
+ : acc.concat(resolveApp(dotenvFile, appDirectory));
38
+ }, []);
39
+ };
40
+ //# sourceMappingURL=dotenv-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dotenv-files.js","sourceRoot":"","sources":["../src/dotenv-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EACrC,YAAY,GAAG,EAAE,EACjB,WAAW,GAAG,EAAE,EAChB,OAAO,EACP,GAAG,GAMJ,EAAY,EAAE;IACb,oEAAoE;IACpE,MAAM,WAAW,GAAG;QAClB,MAAM;QACN,uEAAuE;QACvE,wDAAwD;QACxD,OAAO,KAAK,MAAM,IAAI,YAAY;QAClC,GAAG,IAAI,QAAQ,GAAG,EAAE;QACpB,WAAW;QACX,GAAG,IAAI,QAAQ,GAAG,QAAQ;KAC3B,CAAC,MAAM,CAAC,OAAO,CAAa,CAAA;IAE7B,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,EAAE,CAAA;IACX,CAAC;IAED,OAAO,WAAW,CAAC,MAAM,CAAW,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE;QACtD,OAAO,UAAU,CAAC,UAAU,CAAC;YAC3B,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC;YACxB,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAA;IACtD,CAAC,EAAE,EAAE,CAAC,CAAA;AACR,CAAC,CAAA"}
@@ -36,7 +36,7 @@ export const lowercaseKeyFixer = (key, line) => {
36
36
  // skips if the value is multiline, contains whitespaces, newline characters or
37
37
  // hash signs:
38
38
  export const quoteCharacterFixer = (key, line) => {
39
- if (!quoteCharacterChecker(line)) {
39
+ if (!quoteCharacterChecker(key, line)) {
40
40
  return [key, line];
41
41
  }
42
42
  const pureVal = line.replace(/"|'/g, '');
@@ -52,7 +52,7 @@ export const trailingWhitespaceFixer = (key, line) => {
52
52
  // Value without quotes: Detects if a value contains whitespaces and at the
53
53
  // same time doesn't contain quote characters (`'` / `"`):
54
54
  export const valueWithoutQuotesFixer = (key, line) => {
55
- if (!valueWithoutQuotesChecker(line)) {
55
+ if (!valueWithoutQuotesChecker(key, line)) {
56
56
  return [key, line];
57
57
  }
58
58
  let pureVal = '';
@@ -1 +1 @@
1
- {"version":3,"file":"dotenv-fixers.js","sourceRoot":"","sources":["../src/dotenv-fixers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACvB,mBAAmB,EACnB,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA;AAEtD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,GAAW,EAAE,IAAY,EAAE,EAAE;IACnE,IAAI,CAAC,yBAAyB,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC;QAC1C,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IACpB,CAAC;IAED,IAAI,UAAU,GAAG,yBAAyB,CAAC,GAAG,CAAC,CAAA;IAC/C,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAA;IAE/C,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAAA;IAC5D,OAAO,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,UAAU,EAAE,EAAE,IAAI,CAAC,CAA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C7B,uBAAuB;IACvB,qBAAqB;IACrB,iBAAiB;CAClB,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,mBAAmB;IACnB,uBAAuB;IACvB,uBAAuB;CACxB,CAAA"}
package/dist/envs.d.ts CHANGED
@@ -9,7 +9,15 @@
9
9
  * @param options - Configuration options.
10
10
  * @param options.appDirectory - The directory of the app.
11
11
  * @param options.secretsPath - The path to an injected secrets file.
12
- * @param options.lint - Whether to perform linting on the loaded variables.
12
+ * @param options.lint - Whether to perform `.env` hygiene linting on the loaded
13
+ * variables. **Defaults to `false`** — linting is opt-in. It used to default
14
+ * to `true` and ran on every consumer's boot via `./preload`, but its output
15
+ * was never correct (three of six checkers were fed the key where a value was
16
+ * expected, and the two quote checkers were fed post-parse values with the
17
+ * wrapping quotes already stripped, so they structurally could not observe the
18
+ * defect they exist to detect). Nothing could have correctly depended on the
19
+ * old default. Pass `lint: true` to run the checkers deliberately, or use the
20
+ * `config-lint` bin.
13
21
  * @param options.override - Whether file values override existing process.env values.
14
22
  * @returns An object containing the loaded environment variables.
15
23
  */
@@ -1 +1 @@
1
- {"version":3,"file":"envs.d.ts","sourceRoot":"","sources":["../src/envs.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,IAAI,GAAI,iDAKlB;IACD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;CACd,KAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CAmD5C,CAAA"}
1
+ {"version":3,"file":"envs.d.ts","sourceRoot":"","sources":["../src/envs.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,IAAI,GAAI,iDAKlB;IACD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;CACd,KAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CAuE5C,CAAA"}
package/dist/envs.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
- import { isAbsolute } from 'node:path';
3
- import { dotenvCheckers } from './dotenv-checkers.js';
2
+ import { incorrectDelimiterChecker, leadingCharacterChecker, lowercaseKeyChecker, quoteCharacterChecker, trailingWhitespaceChecker, valueWithoutQuotesChecker, } from './dotenv-checkers.js';
3
+ import { correlateRawValues } from './dotenv-correlation.js';
4
+ import { resolveDotenvFileChain } from './dotenv-files.js';
4
5
  import { parse, parseJSON } from './dotenv-with-expand.js';
5
- import { mergeAssign, mergeDefaults, resolveApp } from './utils.js';
6
+ import { mergeAssign, mergeDefaults } from './utils.js';
6
7
  /**
7
8
  * Load environment variables from .env* files and optionally perform linting.
8
9
  * Suppress warnings using silent if this file is missing. Dotenv files are
@@ -14,48 +15,74 @@ import { mergeAssign, mergeDefaults, resolveApp } from './utils.js';
14
15
  * @param options - Configuration options.
15
16
  * @param options.appDirectory - The directory of the app.
16
17
  * @param options.secretsPath - The path to an injected secrets file.
17
- * @param options.lint - Whether to perform linting on the loaded variables.
18
+ * @param options.lint - Whether to perform `.env` hygiene linting on the loaded
19
+ * variables. **Defaults to `false`** — linting is opt-in. It used to default
20
+ * to `true` and ran on every consumer's boot via `./preload`, but its output
21
+ * was never correct (three of six checkers were fed the key where a value was
22
+ * expected, and the two quote checkers were fed post-parse values with the
23
+ * wrapping quotes already stripped, so they structurally could not observe the
24
+ * defect they exist to detect). Nothing could have correctly depended on the
25
+ * old default. Pass `lint: true` to run the checkers deliberately, or use the
26
+ * `config-lint` bin.
18
27
  * @param options.override - Whether file values override existing process.env values.
19
28
  * @returns An object containing the loaded environment variables.
20
29
  */
21
- export const envs = ({ appDirectory = '', lint = true, secretsPath = '', override = false, } = {}) => {
22
- let absDotenvFiles = [];
23
- const NODE_ENV = process.env.NODE_ENV;
24
- const ENV = process.env.ENV;
25
- // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
26
- const dotenvFiles = [
27
- '.env',
28
- // Don't include `.env.local` for `test` environment since normally you
29
- // expect tests to produce the same results for everyone
30
- NODE_ENV !== 'test' && '.env.local',
31
- ENV && `.env.${ENV}`,
30
+ export const envs = ({ appDirectory = '', lint = false, secretsPath = '', override = false, } = {}) => {
31
+ const absDotenvFiles = resolveDotenvFileChain({
32
+ appDirectory,
32
33
  secretsPath,
33
- ENV && `.env.${ENV}.local`,
34
- ].filter(Boolean);
35
- if (appDirectory) {
36
- absDotenvFiles = dotenvFiles.reduce((acc, dotenvFile) => {
37
- return isAbsolute(dotenvFile)
38
- ? acc.concat(dotenvFile)
39
- : acc.concat(resolveApp(dotenvFile, appDirectory));
40
- }, []);
41
- }
34
+ nodeEnv: process.env.NODE_ENV,
35
+ env: process.env.ENV,
36
+ });
37
+ const findings = [];
42
38
  const resolvedEnv = absDotenvFiles.reduce((acc, dotenvFile) => {
43
39
  if (!existsSync(dotenvFile)) {
44
40
  return acc;
45
41
  }
46
42
  const contents = readFileSync(dotenvFile, { encoding: 'utf8' });
47
- const envs = dotenvFile.endsWith('.json')
43
+ const isJson = dotenvFile.endsWith('.json');
44
+ const envs = isJson
48
45
  ? parseJSON(contents, false, {})
49
46
  : parse(contents, false, {});
50
47
  if (lint && envs) {
48
+ // Correlate against the `contents` already in scope — no second read.
49
+ // A `.json` secrets file is not dotenv syntax, so the raw-value line
50
+ // checkers do not apply to it; the key checkers still do.
51
+ const rawValues = isJson
52
+ ? new Map()
53
+ : correlateRawValues(contents);
51
54
  Object.entries(envs).forEach(([key, value]) => {
52
- dotenvCheckers.forEach((checker) => {
53
- checker(key, value);
54
- });
55
+ // Key checkers: unchanged call shape, unchanged `console.log` output.
56
+ incorrectDelimiterChecker(key, value);
57
+ leadingCharacterChecker(key);
58
+ lowercaseKeyChecker(key);
59
+ // UNCHANGED, deliberately. Under the previous uniform
60
+ // `checker(key, value)` call this single-parameter checker bound its
61
+ // `line` parameter to the *key*, never the value. Fixing that is an
62
+ // explicit, documented scope cut (see the plan's v3 changelog and
63
+ // follow-up 1), so its behavior is preserved exactly rather than
64
+ // quietly "improved" — zero regression in either direction.
65
+ trailingWhitespaceChecker(key);
66
+ if (isJson) {
67
+ return;
68
+ }
69
+ // Line checkers: fed the raw pre-parse value, wrapping quotes intact.
70
+ const rawValue = rawValues.get(key) ?? '';
71
+ const quoteFinding = quoteCharacterChecker(key, rawValue);
72
+ if (quoteFinding)
73
+ findings.push(quoteFinding);
74
+ const unquotedFinding = valueWithoutQuotesChecker(key, rawValue);
75
+ if (unquotedFinding)
76
+ findings.push(unquotedFinding);
55
77
  });
56
78
  }
57
79
  return mergeAssign(acc, envs);
58
80
  }, {});
81
+ // Sole formatting/printing point for findings. Every message already has its
82
+ // value masked to the last 4 characters by the checker that produced it.
83
+ for (const finding of findings) {
84
+ console.log(`warning: ${finding.message}`);
85
+ }
59
86
  return override
60
87
  ? mergeAssign(process.env, resolvedEnv)
61
88
  : mergeDefaults(process.env, resolvedEnv);
package/dist/envs.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"envs.js","sourceRoot":"","sources":["../src/envs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEnE;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM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`packages/env-doctor/src/redact.ts`'s `maskLast4`, duplicated
5
+ * deliberately rather than imported across packages: `@cogs/config` is the
6
+ * published, dependency-light loader that every app preloads, and
7
+ * `@cogs/env-doctor` is a private tool. A cross-package import would invert that
8
+ * dependency direction for four lines of string slicing.
9
+ */
10
+ /**
11
+ * Mask a value to its last 4 characters so a finding can say *which* value it
12
+ * is about without printing a secret in full.
13
+ *
14
+ * Values of 4 characters or fewer are masked outright rather than shown, and an
15
+ * empty value renders as `(empty)` so a `KEY=` line is still legible.
16
+ */
17
+ export declare const maskLast4: (value: string) => string;
18
+ //# sourceMappingURL=redact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,KAAG,MAIzC,CAAA"}
package/dist/redact.js ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Value masking for lint findings.
3
+ *
4
+ * Local port of `packages/env-doctor/src/redact.ts`'s `maskLast4`, duplicated
5
+ * deliberately rather than imported across packages: `@cogs/config` is the
6
+ * published, dependency-light loader that every app preloads, and
7
+ * `@cogs/env-doctor` is a private tool. A cross-package import would invert that
8
+ * dependency direction for four lines of string slicing.
9
+ */
10
+ /**
11
+ * Mask a value to its last 4 characters so a finding can say *which* value it
12
+ * is about without printing a secret in full.
13
+ *
14
+ * Values of 4 characters or fewer are masked outright rather than shown, and an
15
+ * empty value renders as `(empty)` so a `KEY=` line is still legible.
16
+ */
17
+ export const maskLast4 = (value) => {
18
+ if (value.length === 0)
19
+ return '(empty)';
20
+ if (value.length <= 4)
21
+ return '****';
22
+ return `****${value.slice(-4)}`;
23
+ };
24
+ //# sourceMappingURL=redact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redact.js","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAa,EAAU,EAAE;IACjD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IACxC,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO,MAAM,CAAA;IACpC,OAAO,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AACjC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cogs/config",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Framework-agnostic layered-dotenv loader — resolves the canonical .env file chain, expands ${VAR} references, and folds values into process.env with deploy-injected variables staying authoritative. Dual ESM+CJS so it works from an ESM --import preload or a CJS --require hook (dd-trace and other one-offs)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -9,6 +9,9 @@
9
9
  "directory": "packages/config"
10
10
  },
11
11
  "type": "module",
12
+ "bin": {
13
+ "config-lint": "./dist/cli.js"
14
+ },
12
15
  "main": "./dist/cjs/index.js",
13
16
  "module": "./dist/index.js",
14
17
  "types": "./dist/index.d.ts",
@@ -45,7 +48,7 @@
45
48
  "vitest": "^3.0.0"
46
49
  },
47
50
  "scripts": {
48
- "build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json && node ./scripts/postbuild-cjs.mjs",
51
+ "build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json && node ./scripts/postbuild-cjs.mjs && chmod +x dist/cli.js",
49
52
  "lint": "biome check .",
50
53
  "typecheck": "tsc -p tsconfig.json --noEmit",
51
54
  "test": "vitest run"