@bongos/core 1.19.376 → 1.19.378
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 +64 -24
- package/clients/bongos-client/index.d.ts +1 -1
- package/docs/api/openapi.json +5 -0
- package/docs/api-reference.md +1 -1
- package/modules/lifecycle/db-tasks.js +8 -1
- package/modules/lifecycle/db.js +2 -0
- package/modules/lifecycle/kickoff-checklist.js +138 -0
- package/modules/lifecycle/kickoff-seed.js +69 -0
- package/modules/lifecycle/module.json +4 -2
- package/modules/lifecycle/routes/kickoff-seed.js +29 -0
- package/modules/lifecycle/routes/task-write-routes.js +17 -2
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/scripts/gds/fitness.js +1 -0
- package/scripts/gds/init.js +9 -79
- package/scripts/gds/test-path-guard.js +99 -0
- package/src/bongos/auth-admission.js +23 -0
- package/src/module-api.js +5 -1
- package/tests/first_admin_kickoff_seed.mjs +56 -0
- package/tests/kickoff_checklist.mjs +107 -0
- package/tests/kickoff_seed.mjs +93 -0
- package/tests/migration_allocation.mjs +11 -0
- package/tests/provisioning_onboard_mode.mjs +3 -4
- package/tests/search_ingest.mjs +3 -2
- package/tests/setup_smoke.mjs +4 -2
- package/tests/test_path_guard.mjs +126 -0
package/tests/setup_smoke.mjs
CHANGED
|
@@ -22,8 +22,9 @@ import { spawnSync } from 'node:child_process';
|
|
|
22
22
|
import fs from 'node:fs';
|
|
23
23
|
import os from 'node:os';
|
|
24
24
|
import path from 'node:path';
|
|
25
|
+
import { fileURLToPath } from 'node:url';
|
|
25
26
|
|
|
26
|
-
const REPO_ROOT = path.resolve(path.dirname(
|
|
27
|
+
const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
27
28
|
const SETUP_JS = path.join(REPO_ROOT, 'scripts/gds/setup.js');
|
|
28
29
|
|
|
29
30
|
const tests = [];
|
|
@@ -36,7 +37,8 @@ function makeFreshHome() {
|
|
|
36
37
|
|
|
37
38
|
function runSetup(args, env = {}) {
|
|
38
39
|
return spawnSync('node', [SETUP_JS, ...args], {
|
|
39
|
-
|
|
40
|
+
// os.homedir() reads USERPROFILE on Windows, so a HOME override alone leaks the real home there.
|
|
41
|
+
env: { ...process.env, ...env, ...(env.HOME ? { USERPROFILE: env.HOME } : {}) },
|
|
40
42
|
encoding: 'utf8',
|
|
41
43
|
timeout: 15000,
|
|
42
44
|
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// tests/test_path_guard.mjs — the guard that keeps a test runnable on a checkout
|
|
2
|
+
// whose path has a space in it (task 1002889).
|
|
3
|
+
//
|
|
4
|
+
// Four tests built their repo root from URL.pathname and threw MODULE_NOT_FOUND at
|
|
5
|
+
// load on the owner's Windows checkout, while CI (no space in its path) stayed
|
|
6
|
+
// green. The guard is tested on synthetic sources, not only the live tree: a scan
|
|
7
|
+
// that passes because the tree is clean today proves nothing about what it REFUSES.
|
|
8
|
+
//
|
|
9
|
+
// The defective form is spelled by concatenation below so this file never trips the
|
|
10
|
+
// guard it tests.
|
|
11
|
+
//
|
|
12
|
+
// Of the four files the task named, tests/provisioning_github_app_routes.mjs had
|
|
13
|
+
// already been converted before this landed (915d273b, task 1003236 — fileURLToPath
|
|
14
|
+
// at its line 17), so it is absent from this change on purpose; the live-tree case
|
|
15
|
+
// at the bottom is what proves all four are clean.
|
|
16
|
+
//
|
|
17
|
+
// Run: node tests/test_path_guard.mjs
|
|
18
|
+
|
|
19
|
+
import { strict as assert } from 'node:assert';
|
|
20
|
+
import { createRequire } from 'node:module';
|
|
21
|
+
|
|
22
|
+
const require = createRequire(import.meta.url);
|
|
23
|
+
const { checkTestsUseFileUrlToPath, scanTests } = require('../scripts/gds/test-path-guard.js');
|
|
24
|
+
|
|
25
|
+
let passed = 0;
|
|
26
|
+
let failed = 0;
|
|
27
|
+
function test(name, fn) {
|
|
28
|
+
try { fn(); passed++; console.log(` ok ${name}`); }
|
|
29
|
+
catch (err) { failed++; console.error(` FAIL ${name}\n ${err.message}`); }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const from = (map) => ({
|
|
33
|
+
files: Object.keys(map),
|
|
34
|
+
read: (rel) => (rel in map ? map[rel] : null),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const BAD_TAIL = 'import.meta.url)' + '.pathname';
|
|
38
|
+
|
|
39
|
+
// --- THE DEFECT ------------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
test('the shipped defect is refused, with its line and the fix', () => {
|
|
42
|
+
const { violations } = scanTests(...Object.values(from({
|
|
43
|
+
'tests/bad.mjs':
|
|
44
|
+
"import { createRequire } from 'node:module';\n"
|
|
45
|
+
+ `const ROOT = new URL('..', ${BAD_TAIL};\n`
|
|
46
|
+
+ 'const mod = require(`${ROOT}/modules/x.js`);\n',
|
|
47
|
+
})));
|
|
48
|
+
assert.equal(violations.length, 1);
|
|
49
|
+
assert.match(violations[0], /bad\.mjs:2/, 'names the file and line');
|
|
50
|
+
assert.match(violations[0], /%20/, 'says WHY it breaks');
|
|
51
|
+
assert.match(violations[0], /fileURLToPath/, 'and what to write instead');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('the dirname form is the same defect', () => {
|
|
55
|
+
const { violations } = scanTests(...Object.values(from({
|
|
56
|
+
'tests/smoke.mjs': `const REPO_ROOT = path.resolve(path.dirname(new URL(${BAD_TAIL}), '..');\n`,
|
|
57
|
+
})));
|
|
58
|
+
assert.equal(violations.length, 1);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('every site in a file is reported, not just the first', () => {
|
|
62
|
+
const { violations } = scanTests(...Object.values(from({
|
|
63
|
+
'tests/two.mjs':
|
|
64
|
+
`const a = path.resolve(new URL('..', ${BAD_TAIL});\n`
|
|
65
|
+
+ 'x();\n'
|
|
66
|
+
+ `const b = path.resolve(new URL('..', ${BAD_TAIL});\n`,
|
|
67
|
+
})));
|
|
68
|
+
assert.equal(violations.length, 2);
|
|
69
|
+
assert.match(violations[1], /two\.mjs:3/);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// --- WHAT IT MUST NOT FLAG -------------------------------------------------
|
|
73
|
+
|
|
74
|
+
test('fileURLToPath and a relative createRequire are the correct forms — never flagged', () => {
|
|
75
|
+
const { violations } = scanTests(...Object.values(from({
|
|
76
|
+
'tests/good_a.mjs':
|
|
77
|
+
"import { fileURLToPath } from 'node:url';\n"
|
|
78
|
+
+ "const ROOT = fileURLToPath(new URL('..', import.meta.url));\n",
|
|
79
|
+
'tests/good_b.mjs':
|
|
80
|
+
"const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');\n",
|
|
81
|
+
'tests/good_c.mjs':
|
|
82
|
+
"const require = createRequire(import.meta.url);\n"
|
|
83
|
+
+ "const mod = require('../modules/x.js');\n",
|
|
84
|
+
})));
|
|
85
|
+
assert.deepEqual(violations, []);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('a request URL parsed for its pathname is not the defect', () => {
|
|
89
|
+
// http tests routinely do this; the guard is about import.meta.url only.
|
|
90
|
+
const { violations } = scanTests(...Object.values(from({
|
|
91
|
+
'tests/routes.mjs': "const { pathname } = new URL(req.url, 'http://x');\nconst p = new URL(req.url, base).pathname;\n",
|
|
92
|
+
})));
|
|
93
|
+
assert.deepEqual(violations, []);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// --- THE SCAN MUST NOT SILENTLY SUCCEED ------------------------------------
|
|
97
|
+
|
|
98
|
+
test('an empty enumeration is a hard FAIL, not a clean pass', () => {
|
|
99
|
+
const r = checkTestsUseFileUrlToPath({ files: [], read: () => null });
|
|
100
|
+
assert.equal(r.hardFail, true);
|
|
101
|
+
assert.match(r.violations[0], /scan defect/);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('an unreadable file is skipped without being counted as scanned', () => {
|
|
105
|
+
const { scanned } = scanTests(['gone.mjs'], () => null);
|
|
106
|
+
assert.equal(scanned, 0);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test('the check reports hardFail so CI actually stops', () => {
|
|
110
|
+
const r = checkTestsUseFileUrlToPath(from({
|
|
111
|
+
'tests/bad.mjs': `const ROOT = new URL('..', ${BAD_TAIL};\n`,
|
|
112
|
+
}));
|
|
113
|
+
assert.equal(r.ok, false);
|
|
114
|
+
assert.equal(r.hardFail, true);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// --- THE LIVE TREE ---------------------------------------------------------
|
|
118
|
+
|
|
119
|
+
test('the tracked tests/ tree is clean (the four sites of task 1002889 are fixed)', () => {
|
|
120
|
+
const r = checkTestsUseFileUrlToPath();
|
|
121
|
+
assert.equal(r.hardFail, false, r.violations.join('\n'));
|
|
122
|
+
assert.ok(/^\d+ test file\(s\) scanned/.test(r.note) && !r.note.startsWith('0 '), r.note);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
console.log(`\ntest_path_guard: ${passed} passed, ${failed} failed`);
|
|
126
|
+
process.exit(failed ? 1 : 0);
|