@productbrain/cli 0.1.0-beta.4243 → 0.1.0-beta.4257
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 @@
|
|
|
1
|
+
{"version":3,"file":"gitEnvLeakKeysParity.test.d.ts","sourceRoot":"","sources":["../../src/lib/gitEnvLeakKeysParity.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Parity test for the two hand-synced GIT_ENV_LEAK_KEYS copies in packages/cli (review round 4,
|
|
2
|
+
// PR #632 follow-up, PRRT_kwDORS4ils6YoYoM).
|
|
3
|
+
//
|
|
4
|
+
// packages/cli/src/commands/files.test.ts and packages/cli/src/lib/productbrain-files.test.ts
|
|
5
|
+
// each carry a LOCAL inline copy of scripts/lib/gitFixtureEnv.mjs's canonical GIT_ENV_LEAK_KEYS
|
|
6
|
+
// array — kept local (rather than a cross-package import) per the note on each copy. A future
|
|
7
|
+
// git version bump updates the canonical array (its own superset test,
|
|
8
|
+
// scripts/lib/gitFixtureEnv.node-test.mjs, would fail and prompt the fix there) but nothing
|
|
9
|
+
// previously asserted the two packages/cli copies got updated too — they could silently rot out
|
|
10
|
+
// of sync, each one individually still "passing" its own file's tests while quietly missing a
|
|
11
|
+
// newer git-named env var.
|
|
12
|
+
//
|
|
13
|
+
// Reads all three sources as TEXT and extracts each array by regex (no cross-package import —
|
|
14
|
+
// packages/cli is a separately published package, and scripts/lib/gitFixtureEnv.mjs lives
|
|
15
|
+
// outside its rootDir; importing another *.test.ts file directly would also risk vitest
|
|
16
|
+
// double-collecting its describe/it blocks). This is exactly the "reading the canonical file
|
|
17
|
+
// from repo root is fine in a test" approach.
|
|
18
|
+
import { describe, it, expect } from 'vitest';
|
|
19
|
+
import { readFileSync } from 'node:fs';
|
|
20
|
+
import { resolve, dirname } from 'node:path';
|
|
21
|
+
import { fileURLToPath } from 'node:url';
|
|
22
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
23
|
+
// packages/cli/src/lib -> packages/cli/src -> packages/cli -> packages -> repo root
|
|
24
|
+
const REPO_ROOT = resolve(HERE, '../../../..');
|
|
25
|
+
// Review round 3 (PR #634, PRRT_kwDORS4ils6Yp28g): a commented-out quoted token inside the array
|
|
26
|
+
// span (e.g. `// 'GIT_OLD_VAR', -- retired`) previously counted as a real list entry, since the
|
|
27
|
+
// extraction regex below doesn't distinguish code from comments — making the parity check dishonest
|
|
28
|
+
// (it could pass or fail based on comment text, not the actual arrays). Strips both comment forms
|
|
29
|
+
// from the matched span before extracting; safe in this narrow context (a flat array of ALL-CAPS
|
|
30
|
+
// env-var-name string literals — no regex literals or other content that a naive comment strip
|
|
31
|
+
// could misparse, unlike the general-purpose scripts/lib/gitFixtureTextMask.mjs this repo uses
|
|
32
|
+
// elsewhere for exactly that reason).
|
|
33
|
+
function extractGitEnvLeakKeys(source) {
|
|
34
|
+
const match = /\bGIT_ENV_LEAK_KEYS[^=]*=\s*\[([\s\S]*?)\]/m.exec(source);
|
|
35
|
+
if (!match)
|
|
36
|
+
throw new Error('GIT_ENV_LEAK_KEYS array not found in source');
|
|
37
|
+
const withoutComments = match[1].replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/.*$/gm, '');
|
|
38
|
+
return [...withoutComments.matchAll(/'([^']+)'/g)].map((m) => m[1]);
|
|
39
|
+
}
|
|
40
|
+
describe('GIT_ENV_LEAK_KEYS parity across the canonical source and both packages/cli inline copies', () => {
|
|
41
|
+
const canonicalPath = resolve(REPO_ROOT, 'scripts/lib/gitFixtureEnv.mjs');
|
|
42
|
+
const canonical = extractGitEnvLeakKeys(readFileSync(canonicalPath, 'utf8'));
|
|
43
|
+
it('the canonical list itself is non-empty (sanity check on the extraction regex, not just the comparisons below)', () => {
|
|
44
|
+
expect(canonical.length).toBeGreaterThan(0);
|
|
45
|
+
});
|
|
46
|
+
it('packages/cli/src/commands/files.test.ts stays in sync with the canonical scripts/lib/gitFixtureEnv.mjs list', () => {
|
|
47
|
+
const source = readFileSync(resolve(REPO_ROOT, 'packages/cli/src/commands/files.test.ts'), 'utf8');
|
|
48
|
+
const copy = extractGitEnvLeakKeys(source);
|
|
49
|
+
expect([...copy].sort()).toEqual([...canonical].sort());
|
|
50
|
+
});
|
|
51
|
+
it('packages/cli/src/lib/productbrain-files.test.ts stays in sync with the canonical scripts/lib/gitFixtureEnv.mjs list', () => {
|
|
52
|
+
const source = readFileSync(resolve(REPO_ROOT, 'packages/cli/src/lib/productbrain-files.test.ts'), 'utf8');
|
|
53
|
+
const copy = extractGitEnvLeakKeys(source);
|
|
54
|
+
expect([...copy].sort()).toEqual([...canonical].sort());
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
describe('extractGitEnvLeakKeys ignores commented-out entries (review round 3, PRRT_kwDORS4ils6Yp28g)', () => {
|
|
58
|
+
it('a line-commented-out quoted token inside the array span is NOT counted as a real entry', () => {
|
|
59
|
+
const source = [
|
|
60
|
+
'export const GIT_ENV_LEAK_KEYS = [',
|
|
61
|
+
"\t'GIT_DIR',",
|
|
62
|
+
"\t// 'GIT_RETIRED_VAR', -- no longer needed",
|
|
63
|
+
"\t'GIT_WORK_TREE',",
|
|
64
|
+
'];',
|
|
65
|
+
].join('\n');
|
|
66
|
+
expect(extractGitEnvLeakKeys(source)).toEqual(['GIT_DIR', 'GIT_WORK_TREE']);
|
|
67
|
+
});
|
|
68
|
+
it('a block-commented-out quoted token inside the array span is NOT counted as a real entry', () => {
|
|
69
|
+
const source = ["export const GIT_ENV_LEAK_KEYS = [", "\t'GIT_DIR',", "\t/* 'GIT_RETIRED_VAR', */", "\t'GIT_WORK_TREE',", '];'].join('\n');
|
|
70
|
+
expect(extractGitEnvLeakKeys(source)).toEqual(['GIT_DIR', 'GIT_WORK_TREE']);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=gitEnvLeakKeysParity.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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