@intentius/chant 0.124.104 → 0.124.106
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/dist/bundle-check.d.ts +7 -3
- package/dist/bundle-check.js +61 -10
- package/dist/capabilities/templates.d.ts +66 -3
- package/dist/capabilities/templates.js +220 -81
- package/dist/cli/handlers/release-doctor.js +8 -3
- package/dist/cli/handlers/release-init.js +7 -4
- package/dist/cli/handlers/search.d.ts +1 -1
- package/dist/cli/handlers/search.js +24 -2
- package/dist/cli/main.js +3 -2
- package/dist/cli/parse-args.js +2 -2
- package/dist/cli/release-commands/doctor.js +5 -2
- package/dist/cloud-lister/aws.d.ts +9 -0
- package/dist/cloud-lister/aws.js +20 -0
- package/dist/config.d.ts +10 -0
- package/dist/config.js +2 -0
- package/dist/floor-table.data.js +1 -0
- package/dist/graph-refs.d.ts +13 -0
- package/dist/graph-refs.js +11 -4
- package/dist/lifecycle/derive-edges.d.ts +1 -1
- package/dist/lifecycle/derive-edges.js +5 -3
- package/dist/lifecycle/index-import.d.ts +12 -5
- package/dist/lifecycle/index-import.js +38 -9
- package/dist/lifecycle/release-artifacts.js +3 -1
- package/dist/lifecycle/release-at.d.ts +5 -1
- package/dist/lifecycle/release-at.js +69 -4
- package/dist/lifecycle/release-doctor.d.ts +10 -0
- package/dist/lifecycle/release-doctor.js +84 -14
- package/dist/lifecycle/release-green.d.ts +5 -2
- package/dist/lifecycle/release-green.js +40 -8
- package/dist/lifecycle/release-images.d.ts +7 -1
- package/dist/lifecycle/release-images.js +14 -5
- package/dist/lifecycle/release-init.d.ts +16 -7
- package/dist/lifecycle/release-init.js +212 -45
- package/dist/lifecycle/release-next.d.ts +1 -1
- package/dist/lifecycle/release-next.js +9 -4
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/wave-runtime.mjs +38 -38
- package/dist/workspace/capabilities-contract.d.ts +15 -5
- package/dist/workspace/capabilities-contract.js +7 -4
- package/dist/workspace/capabilities.schema.json +45 -1
- package/dist/workspace/release-changed.d.ts +2 -0
- package/dist/workspace/release-changed.js +7 -2
- package/dist/workspace/release-steps/doctor.js +2 -1
- package/dist/workspace/train-cut.js +2 -2
- package/package.json +1 -1
|
@@ -90,7 +90,7 @@ export declare function printCapabilities(args: {
|
|
|
90
90
|
countBy?: string;
|
|
91
91
|
explain?: boolean;
|
|
92
92
|
show?: string;
|
|
93
|
-
}, query: string, lexicons: string[]): Promise<number>;
|
|
93
|
+
}, query: string, lexicons: string[], dir?: string): Promise<number>;
|
|
94
94
|
/**
|
|
95
95
|
* Answer capability terms over a graph that is not this project's own (#4375):
|
|
96
96
|
* `chant workspace search` composes its members' graphs and views and asks
|
|
@@ -12,6 +12,7 @@ import { replaySnapshots, hasSnapshot } from "../../lifecycle/replay.js";
|
|
|
12
12
|
import { diffLive } from "../../lifecycle/live-diff.js";
|
|
13
13
|
import { formatUnobserved } from "../../observation.js";
|
|
14
14
|
import { readChantPackageVersion } from "../../package-version.js";
|
|
15
|
+
import { applyLiveEndpoint } from "../../live-endpoint.js";
|
|
15
16
|
import { loadChantConfig, matchesDeclaredEnvironment, resolveSourceDir } from "../../config.js";
|
|
16
17
|
import { collectBuildRootContributors, loadPlugins, resolveProjectLexicons } from "../plugins.js";
|
|
17
18
|
import { declaredBuildRootContributors, mergeDeclaredBuildRoots, withLexiconEdges } from "./declared-graph.js";
|
|
@@ -54,6 +55,17 @@ import { countJoins, formatIndexRef, indexOnlyGraph, joinCell, joinDeclaredToInd
|
|
|
54
55
|
* thousands.
|
|
55
56
|
*/
|
|
56
57
|
export async function runSearch(ctx) {
|
|
58
|
+
// The environment's declared endpoint (#5289) lives in the process env for
|
|
59
|
+
// the length of a live read, and is put back on every way out.
|
|
60
|
+
const endpoint = { restore: () => { } };
|
|
61
|
+
try {
|
|
62
|
+
return await searchAnswer(ctx, endpoint);
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
endpoint.restore();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function searchAnswer(ctx, endpoint) {
|
|
57
69
|
const { args } = ctx;
|
|
58
70
|
const query = (args.path ?? "").trim();
|
|
59
71
|
// A refusal (#4367): the error on stderr as always, and under --json the
|
|
@@ -150,6 +162,12 @@ export async function runSearch(ctx) {
|
|
|
150
162
|
return refuse({ code: "build-failed", message: "Build failed — fix errors before searching live state" });
|
|
151
163
|
}
|
|
152
164
|
const observing = plugins.filter((p) => p.describeResources);
|
|
165
|
+
// An environment can declare its own endpoint (#1166, #5289), so a read
|
|
166
|
+
// against an emulator needs no exported AWS_ENDPOINT_URL. Ambient wins.
|
|
167
|
+
const applied = applyLiveEndpoint(config.environments, environment, observing);
|
|
168
|
+
endpoint.restore = applied.restore;
|
|
169
|
+
if (applied.notice)
|
|
170
|
+
console.error(formatWarning({ message: applied.notice }));
|
|
153
171
|
ambientKinds = observing.flatMap((p) => p.ambientKinds?.() ?? []);
|
|
154
172
|
const stacks = (config.stacks ?? []).map((s) => ({ name: s.name, region: s.region, src: s.src }));
|
|
155
173
|
let observations;
|
|
@@ -694,7 +712,7 @@ async function declaredGraph(ctx, projectPath, srcDir, loaded) {
|
|
|
694
712
|
* search` and `chant workspace search`, which differ only in the lexicons
|
|
695
713
|
* they report on.
|
|
696
714
|
*/
|
|
697
|
-
export async function printCapabilities(args, query, lexicons) {
|
|
715
|
+
export async function printCapabilities(args, query, lexicons, dir = resolve(".")) {
|
|
698
716
|
const { capabilitiesDocument, capabilitiesFailure, formatCapabilities } = await import("../../workspace/capabilities-contract.js");
|
|
699
717
|
const extra = [
|
|
700
718
|
// `args.path` is "." when no query was given.
|
|
@@ -714,7 +732,11 @@ export async function printCapabilities(args, query, lexicons) {
|
|
|
714
732
|
console.log(JSON.stringify(await capabilitiesFailure(error)));
|
|
715
733
|
return 1;
|
|
716
734
|
}
|
|
717
|
-
const doc = await capabilitiesDocument(lexicons);
|
|
735
|
+
const doc = await capabilitiesDocument(lexicons, undefined, dir);
|
|
736
|
+
// A project template left out (behold#1142) is said on stderr, so a person
|
|
737
|
+
// sees it under --json too.
|
|
738
|
+
for (const r of doc.refused)
|
|
739
|
+
console.error(`template refused: ${r.message}`);
|
|
718
740
|
if (args.json)
|
|
719
741
|
console.log(JSON.stringify(doc));
|
|
720
742
|
else
|
package/dist/cli/main.js
CHANGED
|
@@ -1490,8 +1490,9 @@ Lexicon development:
|
|
|
1490
1490
|
then dev bundle-check. --reset runs npm ci and checks the pins
|
|
1491
1491
|
dev bundle-check [<package-dir>]
|
|
1492
1492
|
Check a bundle against its package.json chantBundleCheck: imports
|
|
1493
|
-
only Node, its dependencies and chant served as compiled JS,
|
|
1494
|
-
|
|
1493
|
+
only Node, its dependencies and chant served as compiled JS, core
|
|
1494
|
+
on the root's pin, each lexicon's peer range taking that pin, size
|
|
1495
|
+
ceilings, denied inputs
|
|
1495
1496
|
dev local-image [--with <package>]... [-- <docker build args>]
|
|
1496
1497
|
Print the chant an image installs (the pin, or local-<commit>
|
|
1497
1498
|
after dev local), or run docker build with CHANT_VERSION and,
|
package/dist/cli/parse-args.js
CHANGED
|
@@ -308,8 +308,8 @@ export function parseArgs(args) {
|
|
|
308
308
|
else if (arg === "--from") {
|
|
309
309
|
// Shared by `migrate --from <lexicon>`, `import --from <env>`,
|
|
310
310
|
// `components promote --from <env>`, `init --from <repo>@<ref>` and
|
|
311
|
-
// `ci last-green --from <rev>` (#4031)
|
|
312
|
-
// together, so one field carries all
|
|
311
|
+
// `ci last-green --from <rev>` (#4031) and `release doctor --from cut`; the commands never run
|
|
312
|
+
// together, so one field carries all six.
|
|
313
313
|
result.migrateFrom = args[++i];
|
|
314
314
|
}
|
|
315
315
|
else if (arg === "--kustomize") {
|
|
@@ -3,12 +3,15 @@ export const doctorCommand = {
|
|
|
3
3
|
name: "doctor",
|
|
4
4
|
helpOrder: 70,
|
|
5
5
|
help: [
|
|
6
|
-
" release doctor [--json]",
|
|
6
|
+
" release doctor [--from cut] [--json]",
|
|
7
7
|
" Before a cut, ask each release.publish target whether",
|
|
8
8
|
" a publish from here can succeed: credentials, OIDC,",
|
|
9
9
|
" npm trusted publishers and dist-tags, registry and",
|
|
10
10
|
" forge access. Says what it can't observe from here.",
|
|
11
|
+
" --from cut: this is the release workflow's cut job,",
|
|
12
|
+
" which has no OIDC token; the checks that need one",
|
|
13
|
+
" say the publish job holds it instead of failing.",
|
|
11
14
|
" Exits 1 when a check fails.",
|
|
12
15
|
],
|
|
13
|
-
usage: { order: 40, text: "release doctor [--json]" },
|
|
16
|
+
usage: { order: 40, text: "release doctor [--from cut] [--json]" },
|
|
14
17
|
};
|
|
@@ -32,3 +32,12 @@ export declare const DEFAULT_AWS_TYPES: readonly string[];
|
|
|
32
32
|
export declare function isGlobalAwsType(type: string): boolean;
|
|
33
33
|
export declare function cloudControlUrl(target: AwsTarget, region: string): string;
|
|
34
34
|
export declare function listAws(ctx: ListerContext, target: AwsTarget, chains: CredentialChains, retryDelays?: readonly number[]): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* A queue's ARN (#5285). Cloud Control lists an SQS queue by its name or its
|
|
37
|
+
* URL and gives no ARN, while a Lambda environment value or a dead-letter
|
|
38
|
+
* policy names the queue by `arn:<partition>:sqs:<region>:<account>:<name>`.
|
|
39
|
+
* The name is the property when the model has one, else the last path segment
|
|
40
|
+
* of the identifier (a queue URL ends in the name). `scopeId` is the account
|
|
41
|
+
* the read was made in.
|
|
42
|
+
*/
|
|
43
|
+
export declare function sqsQueueArn(account: string, region: string, props: Record<string, unknown>, identifier: string): string | undefined;
|
package/dist/cloud-lister/aws.js
CHANGED
|
@@ -170,6 +170,11 @@ async function listOne(ctx, target, credentials, type, region, location, retryDe
|
|
|
170
170
|
cloudIds.push({ kind: "arn", value: d.Identifier });
|
|
171
171
|
if (typeof props.Arn === "string" && props.Arn.startsWith("arn:"))
|
|
172
172
|
cloudIds.push({ kind: "arn", value: props.Arn });
|
|
173
|
+
if (type === "AWS::SQS::Queue" && cloudIds.length === 0) {
|
|
174
|
+
const queueArn = sqsQueueArn(ctx.scope.scopeId, location, props, d.Identifier);
|
|
175
|
+
if (queueArn)
|
|
176
|
+
cloudIds.push({ kind: "arn", value: queueArn });
|
|
177
|
+
}
|
|
173
178
|
cloudIds.push({ kind: "import-id", value: d.Identifier });
|
|
174
179
|
found.push({ listedType: type, location, nativeId: d.Identifier, cloudIds, tags, properties: props, observedAt, labels: false });
|
|
175
180
|
}
|
|
@@ -181,6 +186,21 @@ async function listOne(ctx, target, credentials, type, region, location, retryDe
|
|
|
181
186
|
ctx.resources.push(buildResource(ctx, r));
|
|
182
187
|
ctx.coverage.push({ listedType: type, location, ...listedVerdict(ctx.scope) });
|
|
183
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* A queue's ARN (#5285). Cloud Control lists an SQS queue by its name or its
|
|
191
|
+
* URL and gives no ARN, while a Lambda environment value or a dead-letter
|
|
192
|
+
* policy names the queue by `arn:<partition>:sqs:<region>:<account>:<name>`.
|
|
193
|
+
* The name is the property when the model has one, else the last path segment
|
|
194
|
+
* of the identifier (a queue URL ends in the name). `scopeId` is the account
|
|
195
|
+
* the read was made in.
|
|
196
|
+
*/
|
|
197
|
+
export function sqsQueueArn(account, region, props, identifier) {
|
|
198
|
+
const name = typeof props.QueueName === "string" && props.QueueName !== "" ? props.QueueName : identifier.split("/").filter(Boolean).pop();
|
|
199
|
+
if (!name || !/^\d{12}$/.test(account))
|
|
200
|
+
return undefined;
|
|
201
|
+
const partition = region.startsWith("cn-") ? "aws-cn" : region.startsWith("us-gov-") ? "aws-us-gov" : "aws";
|
|
202
|
+
return `arn:${partition}:sqs:${region}:${account}:${name}`;
|
|
203
|
+
}
|
|
184
204
|
function recordFailure(ctx, type, location, res) {
|
|
185
205
|
const err = awsError(res);
|
|
186
206
|
const detail = describeFailure(res, err.code, err.message);
|
package/dist/config.d.ts
CHANGED
|
@@ -365,6 +365,7 @@ export declare const ChantConfigSchema: z.ZodObject<{
|
|
|
365
365
|
major: "major";
|
|
366
366
|
minor: "minor";
|
|
367
367
|
}>>;
|
|
368
|
+
sources: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
368
369
|
tag: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
369
370
|
name: z.ZodString;
|
|
370
371
|
floating: z.ZodOptional<z.ZodString>;
|
|
@@ -876,6 +877,15 @@ export interface ChantConfig {
|
|
|
876
877
|
* either way.
|
|
877
878
|
*/
|
|
878
879
|
breakingOnZero?: "minor" | "major";
|
|
880
|
+
/**
|
|
881
|
+
* Paths beside the member's own directory whose changes release it
|
|
882
|
+
* (#5271), relative to the member: a member at `release/web-image` that
|
|
883
|
+
* builds the root's Dockerfile names `["../.."]`. `chant release changed`
|
|
884
|
+
* takes a member whose own directory or any of these paths changed since
|
|
885
|
+
* its last release. A path may leave the member with `..`, inside the
|
|
886
|
+
* repository.
|
|
887
|
+
*/
|
|
888
|
+
sources?: string[];
|
|
879
889
|
/**
|
|
880
890
|
* The tag `chant release cut` makes (#5150), as a template: `v{version}`,
|
|
881
891
|
* `cli-v{version}`, `{member}/v{version}` or `{path}/v{version}`. The
|
package/dist/config.js
CHANGED
|
@@ -190,6 +190,8 @@ export const ChantConfigSchema = z.object({
|
|
|
190
190
|
legacyTags: z.array(z.string().min(1)).optional(),
|
|
191
191
|
// #5191: what a breaking change does to a 0.x version when the label comes from commits.
|
|
192
192
|
breakingOnZero: z.enum(["minor", "major"]).optional(),
|
|
193
|
+
// #5271: paths outside a train member, relative to it, whose changes release it too.
|
|
194
|
+
sources: z.array(z.string().min(1)).min(1).optional(),
|
|
193
195
|
// #5150: the tag a cut makes, as a template, and the floating tag a publish moves.
|
|
194
196
|
tag: z.union([z.string().min(1), z.object({ name: z.string().min(1), floating: z.string().min(1).optional() }).strict()]).optional(),
|
|
195
197
|
// #5164: Sigstore signatures and SLSA provenance at publish; on under the supply-chain group unless false.
|
package/dist/floor-table.data.js
CHANGED
|
@@ -2,6 +2,7 @@ export const FLOOR_ROWS = [
|
|
|
2
2
|
{ name: "CACHE4_PIN_FLOOR", version: "0.124.78", gates: "The first chant whose table has the `cache4` row (#4816).", issue: "#4816", file: "action-pins.ts", modules: ["@intentius/chant/action-pins"] },
|
|
3
3
|
{ name: "AGENT_GUARD_FLOOR", version: "0.124.77", gates: "The first chant with the shared agent guard (#4770).", issue: "#4770", file: "agent-guard.ts", modules: ["@intentius/chant/agent-guard", "@intentius/chant/ci-product"] },
|
|
4
4
|
{ name: "CAPABILITY_TEMPLATES_FLOOR", version: "0.124.54", gates: "The first chant whose capabilities document carries `templates` (#4531).", issue: "#4531", file: "capabilities/templates.ts", modules: ["@intentius/chant/capabilities/templates"] },
|
|
5
|
+
{ name: "PROJECT_TEMPLATES_FLOOR", version: "0.124.105", gates: "The first chant whose capabilities document lists a project's own templates from `.chant/templates.json`, marks each entry's `origin`, may carry `kinds`, and lists refused project entries under `refused` (behold issue 1142).", issue: "behold issue 1142", file: "capabilities/templates.ts", modules: ["@intentius/chant/capabilities/templates"] },
|
|
5
6
|
{ name: "CHANGE_SET_GROUP_FLOOR", version: "0.124.54", gates: "The first chant whose change set can carry a member's `group` (ws-107, #4440).", issue: "#4440", file: "change-set.ts", modules: ["@intentius/chant/change-set"] },
|
|
6
7
|
{ name: "CHANGE_SET_PLACEHOLDERS_FLOOR", version: "0.124.54", gates: "The first chant whose change set can carry a member's `placeholders` (#4463).", issue: "#4463", file: "change-set.ts", modules: ["@intentius/chant/change-set"] },
|
|
7
8
|
{ name: "CHANT_RUN_FLOOR", version: "0.124.88", gates: "The first chant with `runChant`, `lastJsonLine`, `installResolveFallback` and `fallbackImportArgs` in `@intentius/chant/chant-install` (#4889): a product runs chant and reads its `--json` document, and a file with no `node_modules` above it imports the product's packages, with no code of the product's own.", issue: "#4889", file: "chant-install.ts", modules: ["@intentius/chant/chant-install"] },
|
package/dist/graph-refs.d.ts
CHANGED
|
@@ -179,6 +179,17 @@ export interface ReferenceCatalog {
|
|
|
179
179
|
refs: RefRule[];
|
|
180
180
|
/** Typed tag rules, used over indexed nodes only (#4522). */
|
|
181
181
|
tagRefs?: TagRefRule[];
|
|
182
|
+
/**
|
|
183
|
+
* How this lexicon's ids are unique in an index (#5286). `regionless`: an id
|
|
184
|
+
* is unique in the whole account, so a node with no location, or in any
|
|
185
|
+
* location, joins with every node of its account (an ARM id names its
|
|
186
|
+
* subscription). `caseInsensitive`: two ids that differ only in case are one
|
|
187
|
+
* (ARM compares ids that way). Over an index only.
|
|
188
|
+
*/
|
|
189
|
+
indexIds?: {
|
|
190
|
+
regionless?: boolean;
|
|
191
|
+
caseInsensitive?: boolean;
|
|
192
|
+
};
|
|
182
193
|
/** Kinds whose names are scoped by a value on the node, on a declared graph (#5097). */
|
|
183
194
|
scopes?: ScopeRule[];
|
|
184
195
|
/**
|
|
@@ -409,6 +420,8 @@ export interface IndexedNodeScope {
|
|
|
409
420
|
* holder scoped by namespace.
|
|
410
421
|
*/
|
|
411
422
|
member?: string;
|
|
423
|
+
/** Compare values case-insensitively in this scope (#5286). */
|
|
424
|
+
foldCase?: boolean;
|
|
412
425
|
}
|
|
413
426
|
/** The region of a node held by one member (a `ScopeRule` with no `path`). */
|
|
414
427
|
export declare const memberRegion: (member: string) => string;
|
package/dist/graph-refs.js
CHANGED
|
@@ -257,7 +257,7 @@ const byString = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
|
257
257
|
*/
|
|
258
258
|
export function reconstructIndexedEdges(nodes, catalogs, scopeOf) {
|
|
259
259
|
const sorted = [...nodes].sort((a, b) => byString(a.id, b.id));
|
|
260
|
-
const keyOf = (scope, value) => `${scope.account}\u0000${scope.region ?? ""}\u0000${value}`;
|
|
260
|
+
const keyOf = (scope, value) => `${scope.account}\u0000${scope.region ?? ""}\u0000${scope.foldCase ? value.toLowerCase() : value}`;
|
|
261
261
|
const index = new Map();
|
|
262
262
|
// The same nodes by the name of the scope they sit in (the text after the
|
|
263
263
|
// first `:` of a region), for a join that names a scope itself.
|
|
@@ -366,7 +366,8 @@ export function reconstructIndexedEdges(nodes, catalogs, scopeOf) {
|
|
|
366
366
|
if (node.lexicon !== lexicon)
|
|
367
367
|
continue;
|
|
368
368
|
for (const rule of catalog.refs) {
|
|
369
|
-
|
|
369
|
+
// `from: "*"` is a rule that reads every node of the lexicon (#5286); its `join` picks the nodes.
|
|
370
|
+
if (rule.from !== node.kind && !(rule.from === "*" && rule.join))
|
|
370
371
|
continue;
|
|
371
372
|
const spec = {
|
|
372
373
|
id: refRuleId(lexicon, rule.from, rule.path),
|
|
@@ -378,7 +379,13 @@ export function reconstructIndexedEdges(nodes, catalogs, scopeOf) {
|
|
|
378
379
|
...(rule.optional ? { optional: true } : {}),
|
|
379
380
|
};
|
|
380
381
|
if (rule.join) {
|
|
381
|
-
const find = (value, scope) =>
|
|
382
|
+
const find = (value, scope) => {
|
|
383
|
+
if (scope === undefined)
|
|
384
|
+
return [...lookup(node, value).keys()].map((id) => byId.get(id));
|
|
385
|
+
// Over an index a namespace is the whole region (a node's location), so the holder's account and that region name the scope too (#5284).
|
|
386
|
+
const ids = new Map([...(named.get(`${scope}\u0000${value}`) ?? []), ...(index.get(keyOf({ account: scopeOf(node).account, region: scope }, value)) ?? [])]);
|
|
387
|
+
return [...ids.keys()].map((id) => byId.get(id));
|
|
388
|
+
};
|
|
382
389
|
for (const j of rule.join(node, find))
|
|
383
390
|
resolve(node, j.value, { ...spec, via: j.via ?? spec.via }, j);
|
|
384
391
|
continue;
|
|
@@ -490,7 +497,7 @@ function stringLeaves(attrs) {
|
|
|
490
497
|
export function reconstructIdentityEdges(nodes, owners, scopeOf, existing = []) {
|
|
491
498
|
const sorted = [...nodes].sort((a, b) => byString(a.id, b.id));
|
|
492
499
|
const ownerBy = new Map(owners.map((o) => [o.lexicon, o]));
|
|
493
|
-
const keyOf = (scope, value) => `${scope.account}\u0000${scope.region ?? ""}\u0000${value}`;
|
|
500
|
+
const keyOf = (scope, value) => `${scope.account}\u0000${scope.region ?? ""}\u0000${scope.foldCase ? value.toLowerCase() : value}`;
|
|
494
501
|
// key -> node id -> the rule that names it, and the paths it names the node at
|
|
495
502
|
const index = new Map();
|
|
496
503
|
const own = new Map();
|
|
@@ -44,7 +44,7 @@ export interface EdgeLexicon {
|
|
|
44
44
|
indexIdentity?: IndexIdentity;
|
|
45
45
|
}
|
|
46
46
|
/** The scope an indexed node's identifiers are unique in, from its document's stamp and its own location. */
|
|
47
|
-
export declare function indexedNodeScope(doc: IndexDocument, node: IRNode): IndexedNodeScope;
|
|
47
|
+
export declare function indexedNodeScope(doc: IndexDocument, node: IRNode, ids?: ReferenceCatalog["indexIds"]): IndexedNodeScope;
|
|
48
48
|
/** Derived edges over one index document. */
|
|
49
49
|
export declare function deriveEdges(doc: IndexDocument, lexicons: readonly EdgeLexicon[]): IndexDocument;
|
|
50
50
|
/**
|
|
@@ -3,11 +3,12 @@ import { indexDocumentDigest } from "./index-document.js";
|
|
|
3
3
|
/** Locations that hold global types: AWS's `global`, Kubernetes' cluster-scoped objects. */
|
|
4
4
|
const GLOBAL_LOCATIONS = new Set(["global", "cluster", ""]);
|
|
5
5
|
/** The scope an indexed node's identifiers are unique in, from its document's stamp and its own location. */
|
|
6
|
-
export function indexedNodeScope(doc, node) {
|
|
6
|
+
export function indexedNodeScope(doc, node, ids) {
|
|
7
7
|
const scope = doc.stamp.scope;
|
|
8
8
|
const account = scope.kind === "cloud" ? `${scope.substrate}/${scope.scopeId}` : doc.stamp.scopeKey;
|
|
9
9
|
const location = node.location ?? "";
|
|
10
|
-
|
|
10
|
+
const fold = ids?.caseInsensitive ? { foldCase: true } : {};
|
|
11
|
+
return GLOBAL_LOCATIONS.has(location) || ids?.regionless ? { account, ...fold } : { account, region: location, ...fold };
|
|
11
12
|
}
|
|
12
13
|
const byString = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
13
14
|
function noteKey(n) {
|
|
@@ -46,13 +47,14 @@ export function deriveEdgesAcross(docs, lexicons) {
|
|
|
46
47
|
.sort((a, b) => byString(a.name, b.name))
|
|
47
48
|
.map((l) => ({ lexicon: l.name, catalog: l.referenceCatalog }));
|
|
48
49
|
const withCatalog = new Set(named.map((c) => c.lexicon));
|
|
50
|
+
const idsOf = new Map(named.map((c) => [c.lexicon, c.catalog.indexIds]));
|
|
49
51
|
const holderDoc = new Map();
|
|
50
52
|
const scopes = new Map();
|
|
51
53
|
const all = [];
|
|
52
54
|
docs.forEach((d, i) => {
|
|
53
55
|
for (const n of d.graph.nodes) {
|
|
54
56
|
holderDoc.set(n.id, i);
|
|
55
|
-
scopes.set(n.id, indexedNodeScope(d, n));
|
|
57
|
+
scopes.set(n.id, indexedNodeScope(d, n, idsOf.get(n.lexicon)));
|
|
56
58
|
all.push(n);
|
|
57
59
|
}
|
|
58
60
|
});
|
|
@@ -34,9 +34,13 @@ export interface IndexImportCodegen {
|
|
|
34
34
|
* `DeletionPolicy: Retain` on every imported resource, #4536). `notes`
|
|
35
35
|
* go into the file's header comment after the logical id (the k8s
|
|
36
36
|
* lexicon names the keys of a Secret it writes as a referenced secret).
|
|
37
|
-
* `missing` names the
|
|
38
|
-
*
|
|
39
|
-
* {@link requiredParameter}.
|
|
37
|
+
* `missing` names the properties the type requires that the node's
|
|
38
|
+
* attrs do not hold, as dotted paths (`properties.tenantId`); each
|
|
39
|
+
* becomes a parameter from {@link requiredParameter}. `partition` splits
|
|
40
|
+
* the resources of one lexicon and location into groups that deploy
|
|
41
|
+
* apart (the azure lexicon writes a resource group's resources apart from
|
|
42
|
+
* the subscription-scope resource groups themselves); it is a directory
|
|
43
|
+
* name under the location.
|
|
40
44
|
*/
|
|
41
45
|
resource(node: IRNode): {
|
|
42
46
|
type: string;
|
|
@@ -44,6 +48,7 @@ export interface IndexImportCodegen {
|
|
|
44
48
|
attributes?: Record<string, unknown>;
|
|
45
49
|
notes?: readonly string[];
|
|
46
50
|
missing?: readonly string[];
|
|
51
|
+
partition?: string;
|
|
47
52
|
} | {
|
|
48
53
|
unsupported: string;
|
|
49
54
|
};
|
|
@@ -139,15 +144,17 @@ export interface IndexImportReport {
|
|
|
139
144
|
group: string;
|
|
140
145
|
lexicon: string;
|
|
141
146
|
location: string;
|
|
147
|
+
partition?: string;
|
|
142
148
|
resources: number;
|
|
143
149
|
}>;
|
|
144
150
|
}
|
|
145
|
-
/** One output group: a lexicon and a location, written to `dir` under the output. */
|
|
151
|
+
/** One output group: a lexicon and a location (and a partition, when the lexicon names one), written to `dir` under the output. */
|
|
146
152
|
export interface IndexImportGroup {
|
|
147
|
-
/** `""` when the import has one group, else `<lexicon>/<location>`. */
|
|
153
|
+
/** `""` when the import has one group, else `<lexicon>/<location>` or `<lexicon>/<location>/<partition>`. */
|
|
148
154
|
dir: string;
|
|
149
155
|
lexicon: string;
|
|
150
156
|
location: string;
|
|
157
|
+
partition?: string;
|
|
151
158
|
ir: TemplateIR;
|
|
152
159
|
/** Comment lines (without `// `) to put at the top of the group's first file. */
|
|
153
160
|
header: string[];
|
|
@@ -254,6 +254,15 @@ function setExact(tree, parts, value) {
|
|
|
254
254
|
const obj = tree;
|
|
255
255
|
return { ...obj, [head]: setExact(obj[head], rest, value) };
|
|
256
256
|
}
|
|
257
|
+
/** `tree` with `value` at the object path `parts`, making each missing object on the way. */
|
|
258
|
+
function setCreating(tree, parts, value) {
|
|
259
|
+
const [head, ...rest] = parts;
|
|
260
|
+
if (rest.length === 0)
|
|
261
|
+
return { ...tree, [head]: value };
|
|
262
|
+
const child = tree[head];
|
|
263
|
+
const obj = child !== null && typeof child === "object" && !Array.isArray(child) ? child : {};
|
|
264
|
+
return { ...tree, [head]: setCreating(obj, rest, value) };
|
|
265
|
+
}
|
|
257
266
|
function getExact(tree, parts) {
|
|
258
267
|
let cur = tree;
|
|
259
268
|
for (const p of parts) {
|
|
@@ -362,6 +371,7 @@ export function planIndexImport(docs, selection, lexicons, options = {}) {
|
|
|
362
371
|
...(r.attributes ? { attributes: r.attributes } : {}),
|
|
363
372
|
...(r.notes && r.notes.length > 0 ? { notes: r.notes } : {}),
|
|
364
373
|
...(r.missing && r.missing.length > 0 ? { missing: [...new Set(r.missing)].sort(byString) } : {}),
|
|
374
|
+
...(r.partition ? { partition: r.partition } : {}),
|
|
365
375
|
});
|
|
366
376
|
}
|
|
367
377
|
// Groups: lexicon + location. Global nodes join their lexicon's only regional group, when there is one.
|
|
@@ -378,12 +388,17 @@ export function planIndexImport(docs, selection, lexicons, options = {}) {
|
|
|
378
388
|
const regions = regional.get(n.lexicon);
|
|
379
389
|
return regions && regions.size === 1 ? [...regions][0] : loc === "" ? "global" : loc;
|
|
380
390
|
};
|
|
381
|
-
const
|
|
391
|
+
const partitionOf = new Map(writable.map((w) => [w.node.id, w.partition]));
|
|
392
|
+
const groupKey = (n) => {
|
|
393
|
+
const partition = partitionOf.get(n.id);
|
|
394
|
+
return `${n.lexicon}/${groupLocation(n)}${partition ? `/${partition}` : ""}`;
|
|
395
|
+
};
|
|
396
|
+
const groupKeys = [...new Set(writable.map((w) => groupKey(w.node)))].sort(byString);
|
|
382
397
|
const single = groupKeys.length === 1;
|
|
383
|
-
const groupDir = (n) => (single ? "" :
|
|
398
|
+
const groupDir = (n) => (single ? "" : groupKey(n));
|
|
384
399
|
const logicalIds = new Map();
|
|
385
400
|
for (const key of groupKeys) {
|
|
386
|
-
const members = writable.filter((w) =>
|
|
401
|
+
const members = writable.filter((w) => groupKey(w.node) === key);
|
|
387
402
|
const codegen = members[0].codegen;
|
|
388
403
|
const label = (n) => codegen.typeLabel?.(n) ?? defaultTypeLabel(n);
|
|
389
404
|
for (const [id, name] of assignLogicalIds(members.map((m) => m.node), label))
|
|
@@ -392,7 +407,7 @@ export function planIndexImport(docs, selection, lexicons, options = {}) {
|
|
|
392
407
|
const groups = [];
|
|
393
408
|
const parameterReports = [];
|
|
394
409
|
for (const key of groupKeys) {
|
|
395
|
-
const members = writable.filter((w) =>
|
|
410
|
+
const members = writable.filter((w) => groupKey(w.node) === key);
|
|
396
411
|
const dir = groupDir(members[0].node);
|
|
397
412
|
const header = [];
|
|
398
413
|
const resources = [];
|
|
@@ -486,7 +501,8 @@ export function planIndexImport(docs, selection, lexicons, options = {}) {
|
|
|
486
501
|
header.push(`${logicalId}.${at} was masked in the index; fill in the parameter ${name}`);
|
|
487
502
|
}
|
|
488
503
|
for (const at of w.missing ?? []) {
|
|
489
|
-
|
|
504
|
+
const parts = at.split(".");
|
|
505
|
+
if (getExact(props, parts) !== undefined)
|
|
490
506
|
continue;
|
|
491
507
|
if (!w.codegen.requiredParameter) {
|
|
492
508
|
header.push(`${logicalId}.${at} is required and the index listing did not hold it; add it before building`);
|
|
@@ -494,7 +510,7 @@ export function planIndexImport(docs, selection, lexicons, options = {}) {
|
|
|
494
510
|
}
|
|
495
511
|
const name = parameterName(at);
|
|
496
512
|
parameters.push(w.codegen.requiredParameter(name, { node: w.node, logicalId, path: at }));
|
|
497
|
-
props =
|
|
513
|
+
props = setCreating(props, parts, w.codegen.parameterReference(name));
|
|
498
514
|
params.push(name);
|
|
499
515
|
parameterReports.push({ name, node: w.node.id, path: at, group: dir, cause: "missing" });
|
|
500
516
|
header.push(`${logicalId}.${at} is required and the index listing did not hold it; fill in the parameter ${name}`);
|
|
@@ -505,8 +521,15 @@ export function planIndexImport(docs, selection, lexicons, options = {}) {
|
|
|
505
521
|
report.parameters = params;
|
|
506
522
|
resources.push({ logicalId, type: w.type, properties: props, ...(w.attributes && Object.keys(w.attributes).length > 0 ? { attributes: w.attributes } : {}) });
|
|
507
523
|
}
|
|
508
|
-
const
|
|
509
|
-
groups.push({
|
|
524
|
+
const first = members[0];
|
|
525
|
+
groups.push({
|
|
526
|
+
dir,
|
|
527
|
+
lexicon: first.node.lexicon,
|
|
528
|
+
location: groupLocation(first.node),
|
|
529
|
+
...(first.partition ? { partition: first.partition } : {}),
|
|
530
|
+
ir: { resources, parameters },
|
|
531
|
+
header,
|
|
532
|
+
});
|
|
510
533
|
}
|
|
511
534
|
const report = {
|
|
512
535
|
report: "chant-index-import/v1",
|
|
@@ -516,7 +539,13 @@ export function planIndexImport(docs, selection, lexicons, options = {}) {
|
|
|
516
539
|
selection: sel,
|
|
517
540
|
resources: [...reports.values()].sort((a, b) => byString(a.node, b.node)),
|
|
518
541
|
parameters: parameterReports,
|
|
519
|
-
groups: groups.map((g) => ({
|
|
542
|
+
groups: groups.map((g) => ({
|
|
543
|
+
group: g.dir,
|
|
544
|
+
lexicon: g.lexicon,
|
|
545
|
+
location: g.location,
|
|
546
|
+
...(g.partition ? { partition: g.partition } : {}),
|
|
547
|
+
resources: g.ir.resources.length,
|
|
548
|
+
})),
|
|
520
549
|
};
|
|
521
550
|
return { groups, report };
|
|
522
551
|
}
|
|
@@ -218,7 +218,9 @@ export function checkReleaseArtifacts(artifacts, o = {}) {
|
|
|
218
218
|
throw new ReleaseArtifactError("release-artifact-invalid", `${where(a)}: goreleaser.types is empty, so nothing would be recorded`);
|
|
219
219
|
}
|
|
220
220
|
else if (isHelm(a)) {
|
|
221
|
-
|
|
221
|
+
// #5271: the chart is only read, so it may leave the member with `..`; its archive may not.
|
|
222
|
+
if (isAbsolute(a.helm.chart))
|
|
223
|
+
throw new ReleaseArtifactError("release-artifact-outside", `${where(a)}: the chart directory ${a.helm.chart} is an absolute path; name it relative to the member`);
|
|
222
224
|
inside(a, "the chart archive directory", a.helm.dir);
|
|
223
225
|
}
|
|
224
226
|
else if (isNfpm(a)) {
|
|
@@ -12,7 +12,11 @@
|
|
|
12
12
|
* repository's own. The checkout's `node_modules` are linked in, so the
|
|
13
13
|
* compile resolves the packages the checkout already installed; a commit
|
|
14
14
|
* whose lockfile differs from the checkout's would need its own install
|
|
15
|
-
* (inferred, as the cut can't tell).
|
|
15
|
+
* (inferred, as the cut can't tell). An npm, pnpm or yarn workspace links
|
|
16
|
+
* each member into `node_modules` with a relative symlink to the member's
|
|
17
|
+
* directory; those links are pointed at the member's directory in the new
|
|
18
|
+
* worktree, so a build there resolves the worktree's own members (built by
|
|
19
|
+
* the cut's build command) and not the checkout's.
|
|
16
20
|
*/
|
|
17
21
|
export type CutAtCode = "release-at-unknown";
|
|
18
22
|
export declare class CutAtError extends Error {
|
|
@@ -12,12 +12,16 @@
|
|
|
12
12
|
* repository's own. The checkout's `node_modules` are linked in, so the
|
|
13
13
|
* compile resolves the packages the checkout already installed; a commit
|
|
14
14
|
* whose lockfile differs from the checkout's would need its own install
|
|
15
|
-
* (inferred, as the cut can't tell).
|
|
15
|
+
* (inferred, as the cut can't tell). An npm, pnpm or yarn workspace links
|
|
16
|
+
* each member into `node_modules` with a relative symlink to the member's
|
|
17
|
+
* directory; those links are pointed at the member's directory in the new
|
|
18
|
+
* worktree, so a build there resolves the worktree's own members (built by
|
|
19
|
+
* the cut's build command) and not the checkout's.
|
|
16
20
|
*/
|
|
17
21
|
import { execFileSync } from "node:child_process";
|
|
18
|
-
import { existsSync, mkdtempSync, realpathSync, rmSync, symlinkSync } from "node:fs";
|
|
22
|
+
import { existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, realpathSync, rmSync, symlinkSync } from "node:fs";
|
|
19
23
|
import { tmpdir } from "node:os";
|
|
20
|
-
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
24
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
21
25
|
export class CutAtError extends Error {
|
|
22
26
|
constructor(code, message, fix) {
|
|
23
27
|
super(message);
|
|
@@ -38,6 +42,67 @@ export function resolveCutCommit(top, ref) {
|
|
|
38
42
|
throw new CutAtError("release-at-unknown", `--at ${ref} names no commit this clone has`, "Fetch it first (git fetch origin --tags), or name a sha `chant release candidates` lists.");
|
|
39
43
|
}
|
|
40
44
|
}
|
|
45
|
+
/** Where `link` points, relative to `top`, when that is inside `top` and outside any `node_modules`; else null. */
|
|
46
|
+
function workspaceTarget(link, top) {
|
|
47
|
+
try {
|
|
48
|
+
if (!lstatSync(link).isSymbolicLink())
|
|
49
|
+
return null;
|
|
50
|
+
const rel = relative(top, realpathSync(link));
|
|
51
|
+
if (rel === "" || rel.startsWith("..") || isAbsolute(rel) || rel.split(sep).includes("node_modules"))
|
|
52
|
+
return null;
|
|
53
|
+
return rel;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/** Whether `name` in `from` is a directory of entries of its own: a scope or `.bin`. */
|
|
60
|
+
function isGroup(from, name) {
|
|
61
|
+
if (!(name.startsWith("@") || name === ".bin"))
|
|
62
|
+
return false;
|
|
63
|
+
try {
|
|
64
|
+
const st = lstatSync(join(from, name));
|
|
65
|
+
return st.isDirectory() && !st.isSymbolicLink();
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function hasWorkspaceLink(from, top) {
|
|
72
|
+
for (const name of readdirSync(from)) {
|
|
73
|
+
if (isGroup(from, name)) {
|
|
74
|
+
if (hasWorkspaceLink(join(from, name), top))
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
else if (workspaceTarget(join(from, name), top) !== null)
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
function mirror(from, to, top, dir) {
|
|
83
|
+
mkdirSync(to, { recursive: true });
|
|
84
|
+
for (const name of readdirSync(from)) {
|
|
85
|
+
const src = join(from, name);
|
|
86
|
+
const dest = join(to, name);
|
|
87
|
+
if (isGroup(from, name)) {
|
|
88
|
+
mirror(src, dest, top, dir);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const rel = workspaceTarget(src, top);
|
|
92
|
+
symlinkSync(rel === null ? src : join(dir, rel), dest);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Link the checkout's `node_modules` at `to`: as one symlink, or, when it
|
|
97
|
+
* holds workspace links into the checkout, as a directory of per-entry links
|
|
98
|
+
* with those re-pointed into `dir`.
|
|
99
|
+
*/
|
|
100
|
+
function linkNodeModules(from, to, top, dir) {
|
|
101
|
+
if (hasWorkspaceLink(from, top))
|
|
102
|
+
mirror(from, to, top, dir);
|
|
103
|
+
else
|
|
104
|
+
symlinkSync(from, to, "dir");
|
|
105
|
+
}
|
|
41
106
|
/**
|
|
42
107
|
* Check `commit` out in a temporary detached worktree of the repository at
|
|
43
108
|
* `top`, with the checkout's `node_modules` linked at the top and at each
|
|
@@ -72,7 +137,7 @@ export function checkoutCommit(top, cwd, commit) {
|
|
|
72
137
|
const from = join(realTop, level, "node_modules");
|
|
73
138
|
const to = join(dir, level, "node_modules");
|
|
74
139
|
if (existsSync(from) && !existsSync(to) && existsSync(dirname(to)))
|
|
75
|
-
|
|
140
|
+
linkNodeModules(from, to, realTop, dir);
|
|
76
141
|
}
|
|
77
142
|
}
|
|
78
143
|
catch (err) {
|
|
@@ -63,6 +63,13 @@ export interface DoctorEnvironment {
|
|
|
63
63
|
repository: string | null;
|
|
64
64
|
/** The release workflow file, from the repository root: `release.workflow.file` or the forge's default. */
|
|
65
65
|
releaseWorkflow: string | null;
|
|
66
|
+
/**
|
|
67
|
+
* `cut` under `chant release doctor --from cut`: this is the cut job of a
|
|
68
|
+
* release workflow, which runs without OIDC on purpose (it runs the
|
|
69
|
+
* project's build), and the publish job holds the credentials. The checks
|
|
70
|
+
* that need an OIDC token then can't tell from here, rather than fail.
|
|
71
|
+
*/
|
|
72
|
+
from?: "cut";
|
|
66
73
|
}
|
|
67
74
|
export interface DoctorReport {
|
|
68
75
|
environment: DoctorEnvironment;
|
|
@@ -95,6 +102,7 @@ export declare const DEFAULT_NPM_REGISTRY = "https://registry.npmjs.org";
|
|
|
95
102
|
export declare function doctorEnvironment(env: NodeJS.ProcessEnv, req: {
|
|
96
103
|
cwd: string;
|
|
97
104
|
releaseWorkflow: string | null;
|
|
105
|
+
from?: "cut";
|
|
98
106
|
}): DoctorEnvironment;
|
|
99
107
|
/** Check every declared target. Nothing is published, tagged or changed. */
|
|
100
108
|
export declare function releaseDoctor(req: {
|
|
@@ -102,6 +110,8 @@ export declare function releaseDoctor(req: {
|
|
|
102
110
|
publish: readonly PublishDeclaration[];
|
|
103
111
|
env?: NodeJS.ProcessEnv;
|
|
104
112
|
releaseWorkflow: string | null;
|
|
113
|
+
/** `cut` when the doctor runs in the cut job of the release workflow, whose publish job holds the OIDC credentials. */
|
|
114
|
+
from?: "cut";
|
|
105
115
|
/** The cut's green gate (#5149); `forge-checks` adds the check that the forge answers for the commit's checks. */
|
|
106
116
|
green?: import("./release-green.js").ReleaseGreenSource;
|
|
107
117
|
/** The commit whose checks are read under `forge-checks`. Default: HEAD of `cwd`. */
|