@bongos/core 1.19.737 → 1.19.739
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/.bongos-core.json +27 -37
- package/docs/module-api-changelog.md +4 -0
- package/docs/recipes/private-npm-distribution.md +11 -11
- package/docs/recipes/upgrading-the-core.md +3 -2
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/scripts/gds/go-live.js +18 -44
- package/scripts/gds/init.js +21 -29
- package/scripts/gds/package-core.js +7 -6
- package/scripts/gds/provision-config.js +0 -8
- package/scripts/gds/provision-repo.js +26 -30
- package/scripts/gds/provision.js +3 -5
- package/scripts/gds/start.js +1 -1
- package/scripts/gds/update-channel.js +3 -3
- package/scripts/gds/upgrade.js +17 -29
- package/src/module-api.js +1 -1
- package/tests/go_live.mjs +20 -19
- package/tests/init.mjs +11 -6
- package/tests/provision.mjs +33 -10
- package/tests/start_env_guard.mjs +8 -3
- package/tests/upgrade.mjs +6 -3
- package/scripts/gds/npmrc.js +0 -124
- package/tests/npmrc.mjs +0 -154
package/tests/npmrc.mjs
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
// tests/npmrc.mjs
|
|
2
|
-
//
|
|
3
|
-
// Unit tests for scripts/gds/npmrc.js (ADR 0134, task 2090) — the single source of the
|
|
4
|
-
// env-fed `.npmrc` used to install the PRIVATE @bongos/core from the npm registry, plus
|
|
5
|
-
// the opt-in / token gates that keep the vendored-tarball path the default/fallback.
|
|
6
|
-
//
|
|
7
|
-
// Run: node tests/npmrc.mjs
|
|
8
|
-
|
|
9
|
-
import { strict as assert } from 'node:assert';
|
|
10
|
-
import { createRequire } from 'node:module';
|
|
11
|
-
import { mkdtempSync, writeFileSync, readFileSync, existsSync, rmSync } from 'node:fs';
|
|
12
|
-
import { tmpdir } from 'node:os';
|
|
13
|
-
import { join } from 'node:path';
|
|
14
|
-
|
|
15
|
-
const require = createRequire(import.meta.url);
|
|
16
|
-
const n = require('../scripts/gds/npmrc.js');
|
|
17
|
-
|
|
18
|
-
let passed = 0, failed = 0;
|
|
19
|
-
function test(name, fn) {
|
|
20
|
-
try { fn(); passed++; console.log(` ok ${name}`); }
|
|
21
|
-
catch (err) { failed++; console.log(` FAIL ${name}`); console.log(` ${err.message}`); }
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// ---- npmrcContent ----------------------------------------------------------
|
|
25
|
-
test('npmrcContent: scopes @bongos to the registry + auth token EXPANDS from the env (literal ${NPM_TOKEN})', () => {
|
|
26
|
-
const body = n.npmrcContent();
|
|
27
|
-
assert.match(body, /@bongos:registry=https:\/\/registry\.npmjs\.org\//);
|
|
28
|
-
assert.match(body, /\/\/registry\.npmjs\.org\/:_authToken=\$\{NPM_TOKEN\}/);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test('npmrcContent: carries NO real secret — only the ${NPM_TOKEN} placeholder', () => {
|
|
32
|
-
const body = n.npmrcContent();
|
|
33
|
-
// the only _authToken= assignment must be the env placeholder, never a concrete value
|
|
34
|
-
const tokenLines = body.split('\n').filter((l) => /_authToken=/.test(l));
|
|
35
|
-
assert.equal(tokenLines.length, 1);
|
|
36
|
-
assert.equal(tokenLines[0].trim(), '//registry.npmjs.org/:_authToken=${NPM_TOKEN}');
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test('npmrcContent: comment lines use the ini `;` comment char', () => {
|
|
40
|
-
const comments = n.npmrcContent().split('\n').filter((l) => l.startsWith(';'));
|
|
41
|
-
assert.ok(comments.length >= 3, 'has explanatory comments');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test('npmrcContent: honors custom scope/host/tokenEnv', () => {
|
|
45
|
-
const body = n.npmrcContent({ scope: '@acme', host: 'npm.acme.dev', tokenEnv: 'ACME_TOKEN' });
|
|
46
|
-
assert.match(body, /@acme:registry=https:\/\/npm\.acme\.dev\//);
|
|
47
|
-
assert.match(body, /\/\/npm\.acme\.dev\/:_authToken=\$\{ACME_TOKEN\}/);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
// ---- gates -----------------------------------------------------------------
|
|
51
|
-
test('hasNpmToken: true only when NPM_TOKEN is a non-empty string', () => {
|
|
52
|
-
assert.equal(n.hasNpmToken({ NPM_TOKEN: 'npm_abc' }), true);
|
|
53
|
-
assert.equal(n.hasNpmToken({ NPM_TOKEN: '' }), false);
|
|
54
|
-
assert.equal(n.hasNpmToken({ NPM_TOKEN: ' ' }), false);
|
|
55
|
-
assert.equal(n.hasNpmToken({}), false);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test('registryCoreRequested: 1/true/yes/on → true; everything else → false', () => {
|
|
59
|
-
for (const v of ['1', 'true', 'TRUE', 'yes', 'on']) assert.equal(n.registryCoreRequested({ PROVISION_CORE_FROM_REGISTRY: v }), true, v);
|
|
60
|
-
for (const v of ['0', 'false', 'no', '', 'off', 'garbage']) assert.equal(n.registryCoreRequested({ PROVISION_CORE_FROM_REGISTRY: v }), false, v);
|
|
61
|
-
assert.equal(n.registryCoreRequested({}), false, 'unset');
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// ---- writeNpmrc ------------------------------------------------------------
|
|
65
|
-
test('writeNpmrc: writes the env-fed .npmrc + returns its path', () => {
|
|
66
|
-
const dir = mkdtempSync(join(tmpdir(), 'npmrc-'));
|
|
67
|
-
try {
|
|
68
|
-
const p = n.writeNpmrc(dir, { log: () => {} });
|
|
69
|
-
assert.equal(p, join(dir, '.npmrc'));
|
|
70
|
-
assert.equal(readFileSync(p, 'utf8'), n.npmrcContent());
|
|
71
|
-
} finally { rmSync(dir, { recursive: true, force: true }); }
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
test('writeNpmrc: dry-run writes nothing but returns the intended path', () => {
|
|
75
|
-
const dir = mkdtempSync(join(tmpdir(), 'npmrc-'));
|
|
76
|
-
try {
|
|
77
|
-
const p = n.writeNpmrc(dir, { dryRun: true, log: () => {} });
|
|
78
|
-
assert.equal(p, join(dir, '.npmrc'));
|
|
79
|
-
assert.equal(existsSync(join(dir, '.npmrc')), false, 'dry-run must not write');
|
|
80
|
-
} finally { rmSync(dir, { recursive: true, force: true }); }
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test('writeNpmrc: overwrite:false leaves a pre-existing .npmrc untouched (returns null)', () => {
|
|
84
|
-
const dir = mkdtempSync(join(tmpdir(), 'npmrc-'));
|
|
85
|
-
try {
|
|
86
|
-
const existing = '@other:registry=https://npm.other.dev/\n';
|
|
87
|
-
writeFileSync(join(dir, '.npmrc'), existing);
|
|
88
|
-
const p = n.writeNpmrc(dir, { overwrite: false, log: () => {} });
|
|
89
|
-
assert.equal(p, null, 'skipped');
|
|
90
|
-
assert.equal(readFileSync(join(dir, '.npmrc'), 'utf8'), existing, 'existing content preserved');
|
|
91
|
-
} finally { rmSync(dir, { recursive: true, force: true }); }
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
test('writeNpmrc: overwrite:true (default) replaces an existing .npmrc', () => {
|
|
95
|
-
const dir = mkdtempSync(join(tmpdir(), 'npmrc-'));
|
|
96
|
-
try {
|
|
97
|
-
writeFileSync(join(dir, '.npmrc'), 'stale\n');
|
|
98
|
-
n.writeNpmrc(dir, { log: () => {} });
|
|
99
|
-
assert.equal(readFileSync(join(dir, '.npmrc'), 'utf8'), n.npmrcContent());
|
|
100
|
-
} finally { rmSync(dir, { recursive: true, force: true }); }
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
// ---- resolveNpmToken (task 1002754) ----------------------------------------
|
|
104
|
-
// The install-time credential resolver that removes the hand-exported-NPM_TOKEN
|
|
105
|
-
// deploy step: env wins, else the user-level ~/.npmrc's LITERAL token; env-fed
|
|
106
|
-
// `${…}` values in the user file are the trap, never a credential.
|
|
107
|
-
test('resolveNpmToken: env NPM_TOKEN wins over everything', () => {
|
|
108
|
-
const home = mkdtempSync(join(tmpdir(), 'npmrc-home-'));
|
|
109
|
-
try {
|
|
110
|
-
writeFileSync(join(home, '.npmrc'), '//registry.npmjs.org/:_authToken=npm_userlevel\n');
|
|
111
|
-
const r = n.resolveNpmToken({ env: { NPM_TOKEN: ' npm_fromenv ' }, homedir: home });
|
|
112
|
-
assert.deepEqual(r, { token: 'npm_fromenv', source: 'env' });
|
|
113
|
-
} finally { rmSync(home, { recursive: true, force: true }); }
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
test('resolveNpmToken: falls back to the user-level ~/.npmrc literal token', () => {
|
|
117
|
-
const home = mkdtempSync(join(tmpdir(), 'npmrc-home-'));
|
|
118
|
-
try {
|
|
119
|
-
writeFileSync(join(home, '.npmrc'),
|
|
120
|
-
'registry=https://registry.npmjs.org/\n//registry.npmjs.org/:_authToken=npm_ABC123\nfund=false\n');
|
|
121
|
-
const r = n.resolveNpmToken({ env: {}, homedir: home });
|
|
122
|
-
assert.deepEqual(r, { token: 'npm_ABC123', source: 'user-npmrc' });
|
|
123
|
-
} finally { rmSync(home, { recursive: true, force: true }); }
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
test('resolveNpmToken: an env-fed ${…} value in the user file is the trap, not a credential', () => {
|
|
127
|
-
const home = mkdtempSync(join(tmpdir(), 'npmrc-home-'));
|
|
128
|
-
try {
|
|
129
|
-
writeFileSync(join(home, '.npmrc'), '//registry.npmjs.org/:_authToken=${NPM_TOKEN}\n');
|
|
130
|
-
const r = n.resolveNpmToken({ env: {}, homedir: home });
|
|
131
|
-
assert.deepEqual(r, { token: null, source: null });
|
|
132
|
-
} finally { rmSync(home, { recursive: true, force: true }); }
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
test('resolveNpmToken: a token for a DIFFERENT host is not borrowed', () => {
|
|
136
|
-
const home = mkdtempSync(join(tmpdir(), 'npmrc-home-'));
|
|
137
|
-
try {
|
|
138
|
-
writeFileSync(join(home, '.npmrc'), '//npm.pkg.github.com/:_authToken=ghp_other\n');
|
|
139
|
-
const r = n.resolveNpmToken({ env: {}, homedir: home });
|
|
140
|
-
assert.deepEqual(r, { token: null, source: null });
|
|
141
|
-
} finally { rmSync(home, { recursive: true, force: true }); }
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
test('resolveNpmToken: no user npmrc at all → null, never a throw', () => {
|
|
145
|
-
const home = mkdtempSync(join(tmpdir(), 'npmrc-home-'));
|
|
146
|
-
try {
|
|
147
|
-
const r = n.resolveNpmToken({ env: {}, homedir: home });
|
|
148
|
-
assert.deepEqual(r, { token: null, source: null });
|
|
149
|
-
} finally { rmSync(home, { recursive: true, force: true }); }
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
console.log('');
|
|
153
|
-
console.log(`npmrc tests: ${passed} passed, ${failed} failed`);
|
|
154
|
-
process.exit(failed ? 1 : 0);
|