redlinegate 0.0.1 → 0.0.3
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/README.md +23 -7
- package/dist/bin/redline.js +338 -43
- package/dist/bin/redline.js.map +1 -1
- package/dist/commands/init.js +353 -34
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/remove.js +43 -1
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/status.js +94 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/verify.js +82 -2
- package/dist/commands/verify.js.map +1 -1
- package/dist/config/redline-json.js +63 -2
- package/dist/config/redline-json.js.map +1 -1
- package/dist/core/git.js +50 -3
- package/dist/core/git.js.map +1 -1
- package/dist/core/version.js +6 -0
- package/dist/core/version.js.map +1 -1
- package/dist/detect/existing.js +151 -0
- package/dist/detect/existing.js.map +1 -0
- package/dist/detect/setup.js +200 -0
- package/dist/detect/setup.js.map +1 -0
- package/dist/detect/stack.js +56 -17
- package/dist/detect/stack.js.map +1 -1
- package/dist/exempt/parse.js +8 -1
- package/dist/exempt/parse.js.map +1 -1
- package/dist/metrics/options.js +0 -9
- package/dist/metrics/options.js.map +1 -1
- package/dist/platforms/azure/install.js +9 -9
- package/dist/platforms/azure/install.js.map +1 -1
- package/dist/platforms/azure/verify.js +10 -2
- package/dist/platforms/azure/verify.js.map +1 -1
- package/dist/platforms/github/install.js +192 -26
- package/dist/platforms/github/install.js.map +1 -1
- package/dist/platforms/github/preflight.js +63 -0
- package/dist/platforms/github/preflight.js.map +1 -0
- package/dist/platforms/github/vendor.js +81 -0
- package/dist/platforms/github/vendor.js.map +1 -0
- package/dist/platforms/github/verify.js +79 -7
- package/dist/platforms/github/verify.js.map +1 -1
- package/dist/platforms/types.js +8 -0
- package/dist/platforms/types.js.map +1 -1
- package/dist/policy/diff.js +26 -9
- package/dist/policy/diff.js.map +1 -1
- package/dist/render/contexts.js +39 -0
- package/dist/render/contexts.js.map +1 -0
- package/dist/render/profile.js +44 -10
- package/dist/render/profile.js.map +1 -1
- package/dist/render/standards.js +10 -1
- package/dist/render/standards.js.map +1 -1
- package/dist/render/vendors.js +14 -53
- package/dist/render/vendors.js.map +1 -1
- package/dist/rules/catalogue.js +127 -0
- package/dist/rules/catalogue.js.map +1 -0
- package/dist/ui/facts.js +111 -0
- package/dist/ui/facts.js.map +1 -0
- package/dist/ui/prompt.js +330 -0
- package/dist/ui/prompt.js.map +1 -0
- package/dist/ui/report.js +214 -0
- package/dist/ui/report.js.map +1 -0
- package/dist/ui/tty.js +576 -0
- package/dist/ui/tty.js.map +1 -0
- package/dist/ui/wizard.js +293 -0
- package/dist/ui/wizard.js.map +1 -0
- package/dist/verify/remote.js +33 -0
- package/dist/verify/remote.js.map +1 -1
- package/package.json +13 -1
- package/platforms/azure/gate-template-github.yml +152 -0
- package/platforms/azure/gate-template.yml +59 -6
- package/scripts/check-pins.mjs +84 -1
- package/scripts/fetch-stars.mjs +92 -0
- package/scripts/lib/rules.d.mts +18 -0
- package/scripts/publish-local.mjs +183 -0
- package/standards/contexts/speckit.md +22 -0
- package/standards/contexts/tmf.md +25 -0
- package/standards/manifest.json +78 -7
- package/standards/stacks/angular.md +57 -0
- package/standards/stacks/dom.md +61 -0
- package/standards/stacks/svelte.md +45 -0
- package/standards/stacks/vue.md +54 -0
- package/templates/redline.yml +9 -9
- package/workflows/dashboard.yml +1 -1
- package/workflows/redline-collect.yml +1 -1
- package/workflows/redline-gate.yml +38 -7
- package/workflows/seed-canary.yml +2 -2
- package/workflows/weekly-digest.yml +1 -1
- package/scripts/measure-context.mjs +0 -101
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { RedlineError } from "../core/errors.js";
|
|
4
|
-
import { ADMIN_CAPABILITIES, HOSTS } from "../platforms/types.js";
|
|
4
|
+
import { ADMIN_CAPABILITIES, HOSTS, } from "../platforms/types.js";
|
|
5
5
|
import { isRung } from "../enforce/ladder.js";
|
|
6
6
|
export const CONFIG_FILE = '.redline.json';
|
|
7
7
|
export const CAPABILITY_KEYS = ['gate', 'mergePolicy', 'labels'];
|
|
8
|
+
// What each menu key means when a repository has not recorded one. Lives here
|
|
9
|
+
// rather than in cli/commands/init.ts so the parser can fill an absent key
|
|
10
|
+
// without importing the command that writes it; init re-exports it as
|
|
11
|
+
// DEFAULT_MENU.
|
|
12
|
+
export const MENU_DEFAULTS = {
|
|
13
|
+
blockingGate: false,
|
|
14
|
+
adrForLargeDiffs: true,
|
|
15
|
+
accessibility: true,
|
|
16
|
+
speckit: true,
|
|
17
|
+
tmf: false,
|
|
18
|
+
sensitivePathReviewers: false,
|
|
19
|
+
};
|
|
8
20
|
export const MENU_KEYS = [
|
|
9
21
|
'blockingGate',
|
|
10
22
|
'adrForLargeDiffs',
|
|
11
23
|
'accessibility',
|
|
12
24
|
'speckit',
|
|
25
|
+
'tmf',
|
|
13
26
|
'sensitivePathReviewers',
|
|
14
27
|
];
|
|
15
28
|
// The names an operator types, and where each one is recorded. Review
|
|
@@ -34,6 +47,15 @@ export const MANDATORY_CAPABILITIES = {
|
|
|
34
47
|
'displaced by them',
|
|
35
48
|
};
|
|
36
49
|
export const OPTIONAL_CAPABILITIES = Object.keys(CAPABILITY_NAMES);
|
|
50
|
+
/**
|
|
51
|
+
* The name an operator types, from the key the config stores.
|
|
52
|
+
*
|
|
53
|
+
* `mergePolicy` is an implementation detail of the JSON; `--skip merge-policy`
|
|
54
|
+
* is what the CLI accepts and what its output must therefore say back.
|
|
55
|
+
*/
|
|
56
|
+
export function capabilityName(key) {
|
|
57
|
+
return Object.entries(CAPABILITY_NAMES).find(([, stored]) => stored === key)?.[0] ?? key;
|
|
58
|
+
}
|
|
37
59
|
// The gate install is what creates Redline's labels — GitHub pre-declares the
|
|
38
60
|
// gate's soft-fail labels there, and Azure creates pull request labels on use —
|
|
39
61
|
// so a deselected gate takes the labels with it whatever the operator chose for
|
|
@@ -113,6 +135,17 @@ export function parseConfig(raw) {
|
|
|
113
135
|
const menuObj = menuRaw;
|
|
114
136
|
const menu = {};
|
|
115
137
|
for (const key of MENU_KEYS) {
|
|
138
|
+
// A key this file has never heard of takes its default rather than failing
|
|
139
|
+
// the parse. Every menu key added since a repository was onboarded is
|
|
140
|
+
// absent from its `.redline.json`, and rejecting that made a CLI upgrade
|
|
141
|
+
// invalidate the config of every repository in the estate at once — every
|
|
142
|
+
// `redline verify` reporting "`.redline.json` is invalid" for a key nobody
|
|
143
|
+
// had the chance to write. A value that IS present and is not a boolean is
|
|
144
|
+
// still an error: that is a corrupt file, not an old one.
|
|
145
|
+
if (menuObj[key] === undefined) {
|
|
146
|
+
menu[key] = MENU_DEFAULTS[key];
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
116
149
|
if (typeof menuObj[key] !== 'boolean')
|
|
117
150
|
bad(`menu.${key} must be a boolean`);
|
|
118
151
|
menu[key] = menuObj[key];
|
|
@@ -166,6 +199,11 @@ export function parseConfig(raw) {
|
|
|
166
199
|
localRules: o['localRules'] === true,
|
|
167
200
|
capabilities,
|
|
168
201
|
commandFiles,
|
|
202
|
+
integrations: Array.isArray(o['integrations'])
|
|
203
|
+
? o['integrations'].filter((id) => typeof id === 'string')
|
|
204
|
+
: [],
|
|
205
|
+
gateSource: o['gateSource'] === 'local' ? 'local' : 'org',
|
|
206
|
+
gateVersion: typeof o['gateVersion'] === 'string' ? o['gateVersion'] : '',
|
|
169
207
|
};
|
|
170
208
|
}
|
|
171
209
|
export function readConfig(cwd) {
|
|
@@ -181,7 +219,30 @@ export function readConfig(cwd) {
|
|
|
181
219
|
}
|
|
182
220
|
return parseConfig(raw);
|
|
183
221
|
}
|
|
222
|
+
// JSON has no comments, and this file is the only record of what a repository
|
|
223
|
+
// chose and why. Without something in the file itself, the first person to open
|
|
224
|
+
// it after onboarding finds eleven keys and no way to tell which are theirs to
|
|
225
|
+
// change from which are Redline's bookkeeping. `//` is the convention every
|
|
226
|
+
// JSON tool already ignores, and parseConfig ignores unknown keys, so it costs
|
|
227
|
+
// nothing to carry and is rewritten on every run.
|
|
228
|
+
const EXPLAINER = [
|
|
229
|
+
'Written by `redline init`. Edit with the command, not by hand — the next run rewrites this file.',
|
|
230
|
+
'menu.blockingGate — the gate blocks a merge rather than reporting. `redline init --blocking`.',
|
|
231
|
+
'menu.adrForLargeDiffs — a diff over the threshold needs an ADR link in the pull request body.',
|
|
232
|
+
'menu.accessibility — recorded for a later phase; nothing reads it yet.',
|
|
233
|
+
'menu.speckit — renders the spec-driven development context into the standards artifacts.',
|
|
234
|
+
'menu.tmf — renders the TM Forum context. `redline init --tmf` / `--no-tmf`.',
|
|
235
|
+
'menu.sensitivePathReviewers — writes CODEOWNERS and requires code-owner review on those paths.',
|
|
236
|
+
'capabilities.* — false means "this repository has its own"; Redline does not install or report it.',
|
|
237
|
+
'rung — how hard the gate bites: observe, warn, block-blocker, block-high. Promotion needs evidence.',
|
|
238
|
+
'pendingAdmin — capabilities an administrator still has to grant. Not a failure, a to-do list.',
|
|
239
|
+
'gateSource — org: the gate lives in the organisation .github repo. local: vendored into this',
|
|
240
|
+
' repository, which means a pull request can edit the gate judging it. `--gate-source`.',
|
|
241
|
+
'gateVersion — the redlinegate version the vendored gate was written by. Empty when not vendored.',
|
|
242
|
+
'commandFiles, standardsVersion, cliVersion, onboardedAt, lastRunAt — Redline\'s own bookkeeping.',
|
|
243
|
+
];
|
|
184
244
|
export function writeConfig(cwd, config) {
|
|
185
|
-
|
|
245
|
+
const documented = { '//': EXPLAINER, ...config };
|
|
246
|
+
writeFileSync(join(cwd, CONFIG_FILE), `${JSON.stringify(documented, null, 2)}\n`);
|
|
186
247
|
}
|
|
187
248
|
//# sourceMappingURL=redline-json.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redline-json.js","sourceRoot":"","sources":["../../cli/config/redline-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,E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,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,+EAA+E;AAC/E,kDAAkD;AAClD,MAAM,SAAS,GAAsB;IACnC,kGAAkG;IAClG,+FAA+F;IAC/F,+FAA+F;IAC/F,wEAAwE;IACxE,0FAA0F;IAC1F,6EAA6E;IAC7E,gGAAgG;IAChG,oGAAoG;IACpG,qGAAqG;IACrG,+FAA+F;IAC/F,8FAA8F;IAC9F,yFAAyF;IACzF,kGAAkG;IAClG,kGAAkG;CACnG,CAAC;AAEF,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,MAAqB;IAC5D,MAAM,UAAU,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,CAAC;IAClD,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;AACpF,CAAC"}
|
package/dist/core/git.js
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
2
|
import { RedlineError } from "./errors.js";
|
|
3
|
-
|
|
3
|
+
// Every git call here runs with stdin ignored and stderr captured, so anything
|
|
4
|
+
// git decides to ASK rather than answer has nowhere to print the question and
|
|
5
|
+
// nowhere to read the reply — it simply waits. A real onboarding sat on
|
|
6
|
+
// "committing and opening the pull request" forever because `git push` reached
|
|
7
|
+
// an ssh that wanted a passphrase, and the spinner kept turning over a process
|
|
8
|
+
// that was never going to finish.
|
|
9
|
+
//
|
|
10
|
+
// So the prompts are switched off rather than hidden: git fails immediately and
|
|
11
|
+
// says why, and `push()` below turns that into an error naming the branch the
|
|
12
|
+
// work is already committed on. An operator's own GIT_SSH_COMMAND wins — a
|
|
13
|
+
// repository reached through a custom ssh wrapper is a deliberate arrangement,
|
|
14
|
+
// and overriding it would break a working setup to fix a hanging one.
|
|
15
|
+
const NON_INTERACTIVE = {
|
|
16
|
+
// Suppresses the username/password prompt on an HTTPS remote.
|
|
17
|
+
GIT_TERMINAL_PROMPT: '0',
|
|
18
|
+
// BatchMode stops ssh asking for a passphrase or an unknown host key;
|
|
19
|
+
// ConnectTimeout stops a silently dropped connection replacing the prompt
|
|
20
|
+
// with an equally invisible wait.
|
|
21
|
+
GIT_SSH_COMMAND: 'ssh -o BatchMode=yes -o ConnectTimeout=10',
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The environment git runs in: prompts off, unless the operator has already
|
|
25
|
+
* said otherwise.
|
|
26
|
+
*
|
|
27
|
+
* Exported to be asserted on. Which side of the merge wins is the whole
|
|
28
|
+
* decision — spread the defaults last and a custom ssh wrapper is silently
|
|
29
|
+
* replaced, which breaks a working setup in order to fix a hanging one.
|
|
30
|
+
*/
|
|
31
|
+
export function gitEnv(from = process.env) {
|
|
32
|
+
return { ...NON_INTERACTIVE, ...from };
|
|
33
|
+
}
|
|
34
|
+
export const execGit = (args, cwd) => execFileSync('git', args, {
|
|
35
|
+
cwd,
|
|
36
|
+
encoding: 'utf8',
|
|
37
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
38
|
+
env: gitEnv(),
|
|
39
|
+
}).trim();
|
|
4
40
|
// git is a real system boundary: a rejected push, a protected branch, an
|
|
5
41
|
// expired credential and a failing pre-commit hook are all routine, and
|
|
6
42
|
// execFileSync reports them as a raw "Command failed: git push …" that the
|
|
@@ -111,7 +147,16 @@ export function createGit(cwd, run = execGit) {
|
|
|
111
147
|
stagePaths(paths) {
|
|
112
148
|
if (paths.length === 0)
|
|
113
149
|
return;
|
|
114
|
-
|
|
150
|
+
try {
|
|
151
|
+
g('add', '--', ...paths);
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
// Reached when a caller listed a path nothing actually wrote, which
|
|
155
|
+
// git reports as `fatal: pathspec ... did not match any files`. The
|
|
156
|
+
// raw execFileSync message leaks the whole argv, so it is replaced
|
|
157
|
+
// with the failure and where the run left the operator.
|
|
158
|
+
throw new RedlineError('host', `could not stage the Redline changes: ${gitFailure(error)}`, 'nothing was committed and no pull request was opened — the path above was listed but never written, so re-run and report it if it recurs');
|
|
159
|
+
}
|
|
115
160
|
},
|
|
116
161
|
hasStagedChanges() {
|
|
117
162
|
try {
|
|
@@ -144,7 +189,9 @@ export function createGit(cwd, run = execGit) {
|
|
|
144
189
|
if (NON_FAST_FORWARD.test(stderrText(error))) {
|
|
145
190
|
throw new RedlineError('failed', `origin already has a "${branch}" branch this push cannot fast-forward: ${gitFailure(error)}`, `a previous run left it behind — delete it (git push origin --delete ${branch}) or merge its open pull request, then re-run`);
|
|
146
191
|
}
|
|
147
|
-
throw new RedlineError('permission', `could not push "${branch}" to origin: ${gitFailure(error)}`, `the Redline changes are committed locally on "${branch}" — push that branch and open the pull request yourself, or get push access and re-run`
|
|
192
|
+
throw new RedlineError('permission', `could not push "${branch}" to origin: ${gitFailure(error)}`, `the Redline changes are committed locally on "${branch}" — push that branch and open the pull request yourself, or get push access and re-run. ` +
|
|
193
|
+
'Redline runs ssh in batch mode so a credential prompt cannot hang the run: if the error above is about a key or a host key, ' +
|
|
194
|
+
'add the key to your agent (ssh-add) or accept the host once by hand, then re-run');
|
|
148
195
|
}
|
|
149
196
|
},
|
|
150
197
|
};
|
package/dist/core/git.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../cli/core/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,MAAM,CAAC,MAAM,OAAO,GAAc,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAC9C,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../cli/core/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,E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E,OAAO,CAAC,CAAC;YAC7B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,YAAY,CACpB,MAAM,EACN,yCAAyC,UAAU,CAAC,KAAK,CAAC,EAAE,EAC5D,oCAAoC,aAAa,EAAE,+DAA+D,CACnH,CAAC;YACJ,CAAC;QACH,CAAC;QACD,yEAAyE;QACzE,wEAAwE;QACxE,oEAAoE;QACpE,qEAAqE;QACrE,mEAAmE;QACnE,8DAA8D;QAC9D,IAAI,CAAC,MAAM;YACT,IAAI,CAAC;gBACH,CAAC,CAAC,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;YAChD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;oBAC7C,MAAM,IAAI,YAAY,CACpB,QAAQ,EACR,yBAAyB,MAAM,2CAA2C,UAAU,CAAC,KAAK,CAAC,EAAE,EAC7F,uEAAuE,MAAM,+CAA+C,CAC7H,CAAC;gBACJ,CAAC;gBACD,MAAM,IAAI,YAAY,CACpB,YAAY,EACZ,mBAAmB,MAAM,gBAAgB,UAAU,CAAC,KAAK,CAAC,EAAE,EAC5D,iDAAiD,MAAM,0FAA0F;oBAC/I,8HAA8H;oBAC9H,kFAAkF,CACrF,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/core/version.js
CHANGED
|
@@ -12,4 +12,10 @@ export function parseVersion(raw) {
|
|
|
12
12
|
}
|
|
13
13
|
const pkg = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8'));
|
|
14
14
|
export const CLI_VERSION = parseVersion(pkg);
|
|
15
|
+
// What package.json carries between releases: semantic-release stamps the real
|
|
16
|
+
// version at publish time, so a CLI running from a checkout reports this. Any
|
|
17
|
+
// artifact that pins the CLI has to recognise it, or a development run writes
|
|
18
|
+
// `redlinegate@0.0.0-development` into a real repository's gate — a pin to a
|
|
19
|
+
// version npm has never heard of, which fails every pull request it reaches.
|
|
20
|
+
export const UNPUBLISHED_VERSION = '0.0.0-development';
|
|
15
21
|
//# sourceMappingURL=version.js.map
|
package/dist/core/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../cli/core/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,UAAU,YAAY,CAAC,GAAY;IACvC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QAC5C,MAAM,IAAI,YAAY,CAAC,QAAQ,EAAE,mCAAmC,CAAC,CAAC;IACxE,CAAC;IACD,MAAM,OAAO,GAAI,GAA+B,CAAC,SAAS,CAAC,CAAC;IAC5D,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,MAAM,IAAI,YAAY,CAAC,QAAQ,EAAE,kDAAkD,CAAC,CAAC;IACvF,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,GAAG,GAAY,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAEtG,MAAM,CAAC,MAAM,WAAW,GAAW,YAAY,CAAC,GAAG,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../cli/core/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,UAAU,YAAY,CAAC,GAAY;IACvC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QAC5C,MAAM,IAAI,YAAY,CAAC,QAAQ,EAAE,mCAAmC,CAAC,CAAC;IACxE,CAAC;IACD,MAAM,OAAO,GAAI,GAA+B,CAAC,SAAS,CAAC,CAAC;IAC5D,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,MAAM,IAAI,YAAY,CAAC,QAAQ,EAAE,kDAAkD,CAAC,CAAC;IACvF,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,GAAG,GAAY,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAEtG,MAAM,CAAC,MAAM,WAAW,GAAW,YAAY,CAAC,GAAG,CAAC,CAAC;AAErD,+EAA+E;AAC/E,8EAA8E;AAC9E,8EAA8E;AAC9E,6EAA6E;AAC7E,6EAA6E;AAC7E,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
export const TOOL_PROBES = [
|
|
4
|
+
{
|
|
5
|
+
id: 'sonarqube',
|
|
6
|
+
label: 'SonarQube',
|
|
7
|
+
paths: ['sonar-project.properties', 'sonar-project-enterprise.properties'],
|
|
8
|
+
inCi: ['sonarqube', 'sonarcloud', 'SonarQubePrepare', 'sonar-scanner'],
|
|
9
|
+
// SonarQube is a static analyser: it overlaps Redline's deterministic
|
|
10
|
+
// policy tier, not its secret or dependency scanning.
|
|
11
|
+
standsDown: 'policy',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
id: 'mend',
|
|
15
|
+
label: 'Mend',
|
|
16
|
+
paths: ['.whitesource', '.mend', 'mend.config.json'],
|
|
17
|
+
inCi: ['mend', 'whitesource'],
|
|
18
|
+
standsDown: 'dependencies',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 'snyk',
|
|
22
|
+
label: 'Snyk',
|
|
23
|
+
paths: ['.snyk'],
|
|
24
|
+
inCi: ['snyk'],
|
|
25
|
+
standsDown: 'dependencies',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: 'dependabot',
|
|
29
|
+
label: 'Dependabot',
|
|
30
|
+
paths: ['.github/dependabot.yml', '.github/dependabot.yaml'],
|
|
31
|
+
standsDown: 'dependencies',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: 'renovate',
|
|
35
|
+
label: 'Renovate',
|
|
36
|
+
paths: ['renovate.json', '.renovaterc', '.renovaterc.json', '.github/renovate.json'],
|
|
37
|
+
inCi: ['renovate'],
|
|
38
|
+
// Renovate raises upgrade pull requests; it does not fail a build on a
|
|
39
|
+
// vulnerable dependency entering one. It is reported so the operator knows
|
|
40
|
+
// Redline saw it, and stands nothing down.
|
|
41
|
+
standsDown: null,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: 'gitleaks',
|
|
45
|
+
label: 'gitleaks',
|
|
46
|
+
paths: ['.gitleaks.toml', '.gitleaksignore'],
|
|
47
|
+
inCi: ['gitleaks'],
|
|
48
|
+
standsDown: 'secrets',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'trufflehog',
|
|
52
|
+
label: 'trufflehog',
|
|
53
|
+
inCi: ['trufflehog', 'trufflesecurity'],
|
|
54
|
+
standsDown: 'secrets',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: 'codeql',
|
|
58
|
+
label: 'CodeQL',
|
|
59
|
+
inCi: ['github/codeql-action', 'codeql'],
|
|
60
|
+
standsDown: 'policy',
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
// Where CI definitions live. Azure Pipelines has no fixed location — VOXI keeps
|
|
64
|
+
// its stages under `cicd/` and its pull request template under `.vsts/` — so
|
|
65
|
+
// this is a list of the conventional homes rather than a spec. A repository
|
|
66
|
+
// that keeps its pipelines somewhere else is not detected, reports nothing, and
|
|
67
|
+
// gets the full install: the safe direction, because an undetected tool means
|
|
68
|
+
// Redline offers a check the repository may already have, which the operator
|
|
69
|
+
// can decline, rather than skipping one it does not.
|
|
70
|
+
const CI_DIRS = ['.github/workflows', 'cicd', '.azuredevops', '.vsts', '.pipelines', 'ci'];
|
|
71
|
+
const CI_ROOT_FILES = ['azure-pipelines.yml', 'azure-pipelines.yaml', '.gitlab-ci.yml'];
|
|
72
|
+
// A pipeline definition is YAML and small. The cap is here so that a repository
|
|
73
|
+
// with a generated or vendored file under one of these directories cannot turn
|
|
74
|
+
// onboarding into a full-tree read.
|
|
75
|
+
const MAX_CI_BYTES = 256 * 1024;
|
|
76
|
+
function readCiText(cwd) {
|
|
77
|
+
const parts = [];
|
|
78
|
+
const readFile = (abs) => {
|
|
79
|
+
try {
|
|
80
|
+
if (statSync(abs).size > MAX_CI_BYTES)
|
|
81
|
+
return;
|
|
82
|
+
parts.push(readFileSync(abs, 'utf8').toLowerCase());
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// Unreadable is not a finding about the repository: a probe that cannot
|
|
86
|
+
// read a file reports nothing rather than claiming the tool is absent.
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
for (const dir of CI_DIRS) {
|
|
90
|
+
const abs = join(cwd, dir);
|
|
91
|
+
if (!existsSync(abs))
|
|
92
|
+
continue;
|
|
93
|
+
let entries;
|
|
94
|
+
try {
|
|
95
|
+
entries = readdirSync(abs);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
for (const name of entries) {
|
|
101
|
+
if (!/\.ya?ml$/i.test(name))
|
|
102
|
+
continue;
|
|
103
|
+
readFile(join(abs, name));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
for (const name of CI_ROOT_FILES) {
|
|
107
|
+
const abs = join(cwd, name);
|
|
108
|
+
if (existsSync(abs))
|
|
109
|
+
readFile(abs);
|
|
110
|
+
}
|
|
111
|
+
return parts.join('\n');
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* What the repository already runs, from the checkout alone.
|
|
115
|
+
*
|
|
116
|
+
* Deliberately no host calls: this decides what `redline init --dry-run` offers,
|
|
117
|
+
* and dry-run contacts no host and needs no credential. A survey that needed a
|
|
118
|
+
* token would make the safest way to preview onboarding the one that requires
|
|
119
|
+
* the most trust.
|
|
120
|
+
*/
|
|
121
|
+
export function surveyRepo(cwd) {
|
|
122
|
+
const ci = readCiText(cwd);
|
|
123
|
+
const tools = [];
|
|
124
|
+
for (const probe of TOOL_PROBES) {
|
|
125
|
+
let evidence = null;
|
|
126
|
+
for (const path of probe.paths ?? []) {
|
|
127
|
+
if (existsSync(join(cwd, path))) {
|
|
128
|
+
evidence = path;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (evidence === null && ci !== '') {
|
|
133
|
+
for (const needle of probe.inCi ?? []) {
|
|
134
|
+
if (ci.includes(needle.toLowerCase())) {
|
|
135
|
+
evidence = `"${needle}" in this repository's CI definitions`;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (evidence === null)
|
|
141
|
+
continue;
|
|
142
|
+
tools.push({ id: probe.id, label: probe.label, evidence, standsDown: probe.standsDown });
|
|
143
|
+
}
|
|
144
|
+
const standDown = [
|
|
145
|
+
...new Set(tools
|
|
146
|
+
.map((tool) => tool.standsDown)
|
|
147
|
+
.filter((job) => job !== null)),
|
|
148
|
+
];
|
|
149
|
+
return { tools, standDown };
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=existing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"existing.js","sourceRoot":"","sources":["../../cli/detect/existing.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;YACnC,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;gBACtC,IAAI,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;oBACtC,QAAQ,GAAG,IAAI,MAAM,uCAAuC,CAAC;oBAC7D,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC;QACD,IAAI,QAAQ,KAAK,IAAI;YAAE,SAAS;QAChC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;IAC3F,CAAC;IAED,MAAM,SAAS,GAAG;QAChB,GAAG,IAAI,GAAG,CACR,KAAK;aACF,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC;aAC9B,MAAM,CAAC,CAAC,GAAG,EAAoC,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,CACnE;KACF,CAAC;IACF,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
// Dependabot's ecosystem ids, keyed by the file that proves the ecosystem is
|
|
4
|
+
// used here. A manifest is the only evidence taken: guessing an ecosystem from a
|
|
5
|
+
// file extension produces a config that opens pull requests against nothing.
|
|
6
|
+
const ECOSYSTEMS = [
|
|
7
|
+
['package.json', 'npm', '/'],
|
|
8
|
+
['requirements.txt', 'pip', '/'],
|
|
9
|
+
['pyproject.toml', 'pip', '/'],
|
|
10
|
+
['go.mod', 'gomod', '/'],
|
|
11
|
+
['pom.xml', 'maven', '/'],
|
|
12
|
+
['build.gradle', 'gradle', '/'],
|
|
13
|
+
['build.gradle.kts', 'gradle', '/'],
|
|
14
|
+
['Gemfile', 'bundler', '/'],
|
|
15
|
+
['Cargo.toml', 'cargo', '/'],
|
|
16
|
+
['composer.json', 'composer', '/'],
|
|
17
|
+
['Dockerfile', 'docker', '/'],
|
|
18
|
+
];
|
|
19
|
+
function ecosystemsIn(cwd) {
|
|
20
|
+
const found = new Map();
|
|
21
|
+
for (const [marker, ecosystem, directory] of ECOSYSTEMS) {
|
|
22
|
+
if (existsSync(join(cwd, marker)))
|
|
23
|
+
found.set(ecosystem, directory);
|
|
24
|
+
}
|
|
25
|
+
// Always present on a repository Redline gates: it installs the workflow that
|
|
26
|
+
// the gate runs on, and an unpatched action is as much a dependency as a
|
|
27
|
+
// package is.
|
|
28
|
+
if (existsSync(join(cwd, '.github', 'workflows')))
|
|
29
|
+
found.set('github-actions', '/');
|
|
30
|
+
return [...found].map(([ecosystem, directory]) => ({ ecosystem, directory }));
|
|
31
|
+
}
|
|
32
|
+
// CodeQL's language ids, from the stacks the chosen profile renders. Derived
|
|
33
|
+
// from the profile rather than from a file walk so it matches what the standards
|
|
34
|
+
// are actually reviewing.
|
|
35
|
+
const CODEQL_LANGUAGES = {
|
|
36
|
+
javascript: 'javascript-typescript',
|
|
37
|
+
react: 'javascript-typescript',
|
|
38
|
+
'react-native': 'javascript-typescript',
|
|
39
|
+
angular: 'javascript-typescript',
|
|
40
|
+
vue: 'javascript-typescript',
|
|
41
|
+
svelte: 'javascript-typescript',
|
|
42
|
+
dom: 'javascript-typescript',
|
|
43
|
+
nodejs: 'javascript-typescript',
|
|
44
|
+
python: 'python',
|
|
45
|
+
go: 'go',
|
|
46
|
+
java: 'java-kotlin',
|
|
47
|
+
kotlin: 'java-kotlin',
|
|
48
|
+
csharp: 'csharp',
|
|
49
|
+
swift: 'swift',
|
|
50
|
+
};
|
|
51
|
+
export const INSTALLABLE = [
|
|
52
|
+
{
|
|
53
|
+
id: 'dependabot',
|
|
54
|
+
label: 'Dependabot version updates',
|
|
55
|
+
hint: 'writes .github/dependabot.yml — weekly, minor and patch grouped into one PR',
|
|
56
|
+
hosts: ['github'],
|
|
57
|
+
plan: (cwd) => {
|
|
58
|
+
const ecosystems = ecosystemsIn(cwd);
|
|
59
|
+
if (ecosystems.length === 0)
|
|
60
|
+
return null;
|
|
61
|
+
const blocks = ecosystems
|
|
62
|
+
.map(({ ecosystem, directory }) => [
|
|
63
|
+
` - package-ecosystem: "${ecosystem}"`,
|
|
64
|
+
` directory: "${directory}"`,
|
|
65
|
+
' schedule:',
|
|
66
|
+
' interval: "weekly"',
|
|
67
|
+
' open-pull-requests-limit: 5',
|
|
68
|
+
' groups:',
|
|
69
|
+
// One pull request a week for the routine bumps. Ungrouped, a repo
|
|
70
|
+
// with a real dependency tree gets a dozen, which is how a team
|
|
71
|
+
// learns to close Dependabot pull requests without reading them.
|
|
72
|
+
' minor-and-patch:',
|
|
73
|
+
' update-types:',
|
|
74
|
+
' - "minor"',
|
|
75
|
+
' - "patch"',
|
|
76
|
+
].join('\n'))
|
|
77
|
+
.join('\n\n');
|
|
78
|
+
return {
|
|
79
|
+
path: '.github/dependabot.yml',
|
|
80
|
+
contents: [
|
|
81
|
+
'# Managed by Redline. Security alerts are enabled separately, by the',
|
|
82
|
+
'# security floor — this file is the version updates the floor does not cover.',
|
|
83
|
+
'version: 2',
|
|
84
|
+
'updates:',
|
|
85
|
+
blocks,
|
|
86
|
+
'',
|
|
87
|
+
].join('\n'),
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: 'renovate',
|
|
93
|
+
label: 'Renovate',
|
|
94
|
+
hint: 'writes renovate.json — needs the Renovate app installed on the organisation',
|
|
95
|
+
hosts: ['github'],
|
|
96
|
+
plan: () => ({
|
|
97
|
+
path: 'renovate.json',
|
|
98
|
+
contents: JSON.stringify({
|
|
99
|
+
$schema: 'https://docs.renovatebot.com/renovate-schema.json',
|
|
100
|
+
extends: ['config:recommended'],
|
|
101
|
+
schedule: ['before 9am on monday'],
|
|
102
|
+
packageRules: [
|
|
103
|
+
{
|
|
104
|
+
matchUpdateTypes: ['minor', 'patch'],
|
|
105
|
+
groupName: 'minor and patch',
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
}, null, 2) + '\n',
|
|
109
|
+
}),
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: 'codeql',
|
|
113
|
+
label: 'CodeQL',
|
|
114
|
+
hint: 'writes .github/workflows/codeql.yml — needs Advanced Security on a private repo',
|
|
115
|
+
hosts: ['github'],
|
|
116
|
+
plan: (_cwd, stacks) => {
|
|
117
|
+
const languages = [
|
|
118
|
+
...new Set(stacks.flatMap((stack) => CODEQL_LANGUAGES[stack] ?? [])),
|
|
119
|
+
];
|
|
120
|
+
if (languages.length === 0)
|
|
121
|
+
return null;
|
|
122
|
+
return {
|
|
123
|
+
path: '.github/workflows/codeql.yml',
|
|
124
|
+
contents: [
|
|
125
|
+
'# Managed by Redline.',
|
|
126
|
+
'name: CodeQL',
|
|
127
|
+
'',
|
|
128
|
+
'on:',
|
|
129
|
+
' push:',
|
|
130
|
+
' branches: [main, master]',
|
|
131
|
+
' pull_request:',
|
|
132
|
+
' schedule:',
|
|
133
|
+
" - cron: '0 3 * * 1'",
|
|
134
|
+
'',
|
|
135
|
+
'permissions:',
|
|
136
|
+
' contents: read',
|
|
137
|
+
' security-events: write',
|
|
138
|
+
'',
|
|
139
|
+
'jobs:',
|
|
140
|
+
' analyze:',
|
|
141
|
+
' runs-on: ubuntu-latest',
|
|
142
|
+
' strategy:',
|
|
143
|
+
' fail-fast: false',
|
|
144
|
+
' matrix:',
|
|
145
|
+
` language: [${languages.join(', ')}]`,
|
|
146
|
+
' steps:',
|
|
147
|
+
// Pinned to the major tag, which is what GitHub's own documented
|
|
148
|
+
// workflow uses: a floating v3 takes security fixes to the scanner
|
|
149
|
+
// without a pull request, and a SHA pin here would go stale silently
|
|
150
|
+
// in every onboarded repository at once.
|
|
151
|
+
' - uses: actions/checkout@v4',
|
|
152
|
+
' - uses: github/codeql-action/init@v3',
|
|
153
|
+
' with:',
|
|
154
|
+
' languages: ${{ matrix.language }}',
|
|
155
|
+
' - uses: github/codeql-action/autobuild@v3',
|
|
156
|
+
' - uses: github/codeql-action/analyze@v3',
|
|
157
|
+
'',
|
|
158
|
+
].join('\n'),
|
|
159
|
+
};
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
];
|
|
163
|
+
/** What this host and this checkout can actually be offered. */
|
|
164
|
+
export function offerable(cwd, host, stacks) {
|
|
165
|
+
return INSTALLABLE.flatMap((integration) => {
|
|
166
|
+
if (!integration.hosts.includes(host))
|
|
167
|
+
return [];
|
|
168
|
+
const file = integration.plan(cwd, stacks);
|
|
169
|
+
return file === null ? [] : [{ integration, file }];
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Write the chosen files, skipping any that already exist.
|
|
174
|
+
*
|
|
175
|
+
* Never overwrites: a repository with its own `renovate.json` has a considered
|
|
176
|
+
* one, and replacing it with a generated default is the kind of "help" that
|
|
177
|
+
* loses a team a week of tuning. The caller reports what was skipped.
|
|
178
|
+
*/
|
|
179
|
+
export function applySetup(cwd, chosen, dryRun) {
|
|
180
|
+
const written = [];
|
|
181
|
+
const skipped = [];
|
|
182
|
+
for (const { file } of chosen) {
|
|
183
|
+
const absolute = join(cwd, file.path);
|
|
184
|
+
if (existsSync(absolute)) {
|
|
185
|
+
// Identical content is not a conflict, it is a no-op — a re-run must not
|
|
186
|
+
// report work it is not doing.
|
|
187
|
+
const current = readFileSync(absolute, 'utf8');
|
|
188
|
+
if (current !== file.contents)
|
|
189
|
+
skipped.push(file.path);
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
if (!dryRun) {
|
|
193
|
+
mkdirSync(dirname(absolute), { recursive: true });
|
|
194
|
+
writeFileSync(absolute, file.contents, 'utf8');
|
|
195
|
+
}
|
|
196
|
+
written.push(file.path);
|
|
197
|
+
}
|
|
198
|
+
return { written, skipped };
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../cli/detect/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAkC1C,6EAA6E;AAC7E,iFAAiF;AACjF,6EAA6E;AAC7E,MAAM,UAAU,GAAmD;IACjE,CAAC,cAAc,EAAE,KAAK,EAAE,GAAG,CAAC;IAC5B,CAAC,kBAAkB,EAAE,KAAK,EAAE,GAAG,CAAC;IAChC,CAAC,gBAAgB,EAAE,KAAK,EAAE,GAAG,CAAC;IAC9B,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,CAAC;IACxB,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,CAAC;IACzB,CAAC,cAAc,EAAE,QAAQ,EAAE,GAAG,CAAC;IAC/B,CAAC,kBAAkB,EAAE,QAAQ,EAAE,GAAG,CAAC;IACnC,CAAC,SAAS,EAAE,SAAS,EAAE,GAAG,CAAC;IAC3B,CAAC,YAAY,EAAE,OAAO,EAAE,GAAG,CAAC;IAC5B,CAAC,eAAe,EAAE,UAAU,EAAE,GAAG,CAAC;IAClC,CAAC,YAAY,EAAE,QAAQ,EAAE,GAAG,CAAC;CAC9B,CAAC;AAEF,SAAS,YAAY,CAAC,GAAW;IAC/B,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IACxC,KAAK,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC,IAAI,UAAU,EAAE,CAAC;QACxD,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YAAE,KAAK,CAAC,GAAG,CAAC,SAA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