@intentius/chant-lexicon-pulumi 0.124.98 → 0.124.99
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/adopt.d.ts +0 -1
- package/dist/capability-plugin.d.ts +0 -1
- package/dist/change-set.d.ts +0 -1
- package/dist/changed-units.d.ts +0 -1
- package/dist/check-step.d.ts +0 -1
- package/dist/ci-setup.d.ts +0 -1
- package/dist/codegen/docs-cli.d.ts +0 -1
- package/dist/codegen/docs.d.ts +0 -1
- package/dist/codegen/package.d.ts +0 -1
- package/dist/composites/pulumi-adopt-op.d.ts +0 -1
- package/dist/composites/pulumi-watch-op.d.ts +0 -1
- package/dist/config.d.ts +0 -1
- package/dist/describe-resources.d.ts +0 -1
- package/dist/drift-read.d.ts +0 -1
- package/dist/drift-record.d.ts +0 -1
- package/dist/engine-events.d.ts +0 -1
- package/dist/engine-graph.d.ts +0 -1
- package/dist/exit-codes.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/init-templates.d.ts +0 -1
- package/dist/integrity.json +2 -2
- package/dist/lint/audit-catalog.d.ts +0 -1
- package/dist/lint/post-synth/index.d.ts +0 -1
- package/dist/lint/post-synth/member-read-helpers.d.ts +0 -1
- package/dist/lint/post-synth/pul001.d.ts +0 -1
- package/dist/lint/post-synth/pul002.d.ts +0 -1
- package/dist/lint/post-synth/pul003.d.ts +0 -1
- package/dist/lint/post-synth/pul004.d.ts +0 -1
- package/dist/lint/post-synth/pul005.d.ts +0 -1
- package/dist/lint/post-synth/pul006.d.ts +0 -1
- package/dist/lint/post-synth/pul007.d.ts +0 -1
- package/dist/lint/post-synth/pul008.d.ts +0 -1
- package/dist/lint/post-synth/pul009.d.ts +0 -1
- package/dist/lint/post-synth/pul010.d.ts +0 -1
- package/dist/lint/post-synth/pul011.d.ts +0 -1
- package/dist/lint/post-synth/pul012.d.ts +0 -1
- package/dist/lint/post-synth/pul013.d.ts +0 -1
- package/dist/lint/post-synth/pul014.d.ts +0 -1
- package/dist/lint/post-synth/pul015.d.ts +0 -1
- package/dist/lint/rules/index.d.ts +0 -1
- package/dist/lint/rules/member-dir-absolute.d.ts +0 -1
- package/dist/lock-rows.d.ts +0 -1
- package/dist/lsp/completions.d.ts +0 -1
- package/dist/lsp/documents.d.ts +0 -1
- package/dist/lsp/hover.d.ts +0 -1
- package/dist/lsp/keys.d.ts +0 -1
- package/dist/lsp/object-path.d.ts +0 -1
- package/dist/lsp/yaml-cursor.d.ts +0 -1
- package/dist/manifest.json +1 -1
- package/dist/member-engine.d.ts +0 -1
- package/dist/member-outputs.d.ts +0 -1
- package/dist/op/activities/index.d.ts +0 -1
- package/dist/op/activities/pulumi-adopt.d.ts +0 -1
- package/dist/op/activities/pulumi.d.ts +0 -1
- package/dist/op/activity-contracts.d.ts +0 -1
- package/dist/op/builders.d.ts +0 -1
- package/dist/package-cli.d.ts +0 -1
- package/dist/plan-shape.d.ts +0 -1
- package/dist/planned-output-changes.d.ts +0 -1
- package/dist/plugin.d.ts +0 -1
- package/dist/plunge-timings.d.ts +0 -1
- package/dist/preview-tips.d.ts +0 -1
- package/dist/pulumi-up.d.ts +0 -1
- package/dist/release-copy.d.ts +0 -1
- package/dist/review-stack.d.ts +0 -1
- package/dist/run.d.ts +0 -1
- package/dist/serializer.d.ts +0 -1
- package/dist/stack-export-snapshot.d.ts +0 -1
- package/dist/stack-ops.d.ts +0 -1
- package/dist/stack-outputs.d.ts +0 -1
- package/dist/stack-references.d.ts +0 -1
- package/dist/trace-facts.d.ts +0 -1
- package/dist/values.d.ts +0 -1
- package/dist/workspace-member.d.ts +0 -1
- package/package.json +3 -4
- package/dist/adopt.d.ts.map +0 -1
- package/dist/capability-plugin.d.ts.map +0 -1
- package/dist/change-set.d.ts.map +0 -1
- package/dist/changed-units.d.ts.map +0 -1
- package/dist/check-step.d.ts.map +0 -1
- package/dist/ci-setup.d.ts.map +0 -1
- package/dist/codegen/docs-cli.d.ts.map +0 -1
- package/dist/codegen/docs.d.ts.map +0 -1
- package/dist/codegen/package.d.ts.map +0 -1
- package/dist/composites/pulumi-adopt-op.d.ts.map +0 -1
- package/dist/composites/pulumi-watch-op.d.ts.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/describe-resources.d.ts.map +0 -1
- package/dist/drift-read.d.ts.map +0 -1
- package/dist/drift-record.d.ts.map +0 -1
- package/dist/engine-events.d.ts.map +0 -1
- package/dist/engine-graph.d.ts.map +0 -1
- package/dist/exit-codes.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/init-templates.d.ts.map +0 -1
- package/dist/lint/audit-catalog.d.ts.map +0 -1
- package/dist/lint/post-synth/index.d.ts.map +0 -1
- package/dist/lint/post-synth/member-read-helpers.d.ts.map +0 -1
- package/dist/lint/post-synth/pul001.d.ts.map +0 -1
- package/dist/lint/post-synth/pul002.d.ts.map +0 -1
- package/dist/lint/post-synth/pul003.d.ts.map +0 -1
- package/dist/lint/post-synth/pul004.d.ts.map +0 -1
- package/dist/lint/post-synth/pul005.d.ts.map +0 -1
- package/dist/lint/post-synth/pul006.d.ts.map +0 -1
- package/dist/lint/post-synth/pul007.d.ts.map +0 -1
- package/dist/lint/post-synth/pul008.d.ts.map +0 -1
- package/dist/lint/post-synth/pul009.d.ts.map +0 -1
- package/dist/lint/post-synth/pul010.d.ts.map +0 -1
- package/dist/lint/post-synth/pul011.d.ts.map +0 -1
- package/dist/lint/post-synth/pul012.d.ts.map +0 -1
- package/dist/lint/post-synth/pul013.d.ts.map +0 -1
- package/dist/lint/post-synth/pul014.d.ts.map +0 -1
- package/dist/lint/post-synth/pul015.d.ts.map +0 -1
- package/dist/lint/rules/index.d.ts.map +0 -1
- package/dist/lint/rules/member-dir-absolute.d.ts.map +0 -1
- package/dist/lock-rows.d.ts.map +0 -1
- package/dist/lsp/completions.d.ts.map +0 -1
- package/dist/lsp/documents.d.ts.map +0 -1
- package/dist/lsp/hover.d.ts.map +0 -1
- package/dist/lsp/keys.d.ts.map +0 -1
- package/dist/lsp/object-path.d.ts.map +0 -1
- package/dist/lsp/yaml-cursor.d.ts.map +0 -1
- package/dist/member-engine.d.ts.map +0 -1
- package/dist/member-outputs.d.ts.map +0 -1
- package/dist/op/activities/index.d.ts.map +0 -1
- package/dist/op/activities/pulumi-adopt.d.ts.map +0 -1
- package/dist/op/activities/pulumi.d.ts.map +0 -1
- package/dist/op/activity-contracts.d.ts.map +0 -1
- package/dist/op/builders.d.ts.map +0 -1
- package/dist/package-cli.d.ts.map +0 -1
- package/dist/plan-shape.d.ts.map +0 -1
- package/dist/planned-output-changes.d.ts.map +0 -1
- package/dist/plugin.d.ts.map +0 -1
- package/dist/plunge-timings.d.ts.map +0 -1
- package/dist/preview-tips.d.ts.map +0 -1
- package/dist/pulumi-up.d.ts.map +0 -1
- package/dist/release-copy.d.ts.map +0 -1
- package/dist/review-stack.d.ts.map +0 -1
- package/dist/run.d.ts.map +0 -1
- package/dist/serializer.d.ts.map +0 -1
- package/dist/stack-export-snapshot.d.ts.map +0 -1
- package/dist/stack-ops.d.ts.map +0 -1
- package/dist/stack-outputs.d.ts.map +0 -1
- package/dist/stack-references.d.ts.map +0 -1
- package/dist/trace-facts.d.ts.map +0 -1
- package/dist/values.d.ts.map +0 -1
- package/dist/workspace-member.d.ts.map +0 -1
- package/src/adopt.ts +0 -202
- package/src/capability-plugin.ts +0 -34
- package/src/change-set.test.ts +0 -245
- package/src/change-set.ts +0 -508
- package/src/changed-units.test.ts +0 -87
- package/src/changed-units.ts +0 -96
- package/src/check-step.test.ts +0 -191
- package/src/check-step.ts +0 -316
- package/src/ci-setup.test.ts +0 -234
- package/src/ci-setup.ts +0 -224
- package/src/codegen/docs-cli.ts +0 -4
- package/src/codegen/docs.ts +0 -58
- package/src/codegen/package.ts +0 -63
- package/src/composites/pulumi-adopt-op.test.ts +0 -258
- package/src/composites/pulumi-adopt-op.ts +0 -193
- package/src/composites/pulumi-watch-op.test.ts +0 -42
- package/src/composites/pulumi-watch-op.ts +0 -85
- package/src/config.ts +0 -43
- package/src/describe-resources.test.ts +0 -112
- package/src/describe-resources.ts +0 -118
- package/src/drift-read.test.ts +0 -178
- package/src/drift-read.ts +0 -94
- package/src/drift-record.test.ts +0 -197
- package/src/drift-record.ts +0 -326
- package/src/engine-events.test.ts +0 -160
- package/src/engine-events.ts +0 -395
- package/src/engine-graph.test.ts +0 -141
- package/src/engine-graph.ts +0 -149
- package/src/exit-codes.test.ts +0 -21
- package/src/exit-codes.ts +0 -71
- package/src/index.ts +0 -139
- package/src/init-templates.ts +0 -85
- package/src/lint/audit-catalog.test.ts +0 -33
- package/src/lint/audit-catalog.ts +0 -174
- package/src/lint/post-synth/index.ts +0 -35
- package/src/lint/post-synth/member-read-helpers.ts +0 -122
- package/src/lint/post-synth/post-synth.test.ts +0 -245
- package/src/lint/post-synth/pul001.ts +0 -38
- package/src/lint/post-synth/pul002.ts +0 -38
- package/src/lint/post-synth/pul003.ts +0 -43
- package/src/lint/post-synth/pul004.ts +0 -32
- package/src/lint/post-synth/pul005.ts +0 -31
- package/src/lint/post-synth/pul006.ts +0 -31
- package/src/lint/post-synth/pul007.ts +0 -35
- package/src/lint/post-synth/pul008.ts +0 -35
- package/src/lint/post-synth/pul009.ts +0 -32
- package/src/lint/post-synth/pul010.ts +0 -42
- package/src/lint/post-synth/pul011.ts +0 -38
- package/src/lint/post-synth/pul012.ts +0 -35
- package/src/lint/post-synth/pul013.ts +0 -35
- package/src/lint/post-synth/pul014.ts +0 -32
- package/src/lint/post-synth/pul015.ts +0 -39
- package/src/lint/rules/index.ts +0 -7
- package/src/lint/rules/member-dir-absolute.test.ts +0 -37
- package/src/lint/rules/member-dir-absolute.ts +0 -83
- package/src/lock-rows.test.ts +0 -60
- package/src/lock-rows.ts +0 -56
- package/src/lsp/completions.test.ts +0 -69
- package/src/lsp/completions.ts +0 -119
- package/src/lsp/documents.ts +0 -48
- package/src/lsp/hover.test.ts +0 -56
- package/src/lsp/hover.ts +0 -83
- package/src/lsp/keys.ts +0 -169
- package/src/lsp/object-path.ts +0 -71
- package/src/lsp/yaml-cursor.ts +0 -85
- package/src/member-engine.test.ts +0 -112
- package/src/member-engine.ts +0 -97
- package/src/member-outputs.test.ts +0 -339
- package/src/member-outputs.ts +0 -157
- package/src/op/activities/index.ts +0 -36
- package/src/op/activities/pulumi-adopt.ts +0 -345
- package/src/op/activities/pulumi.ts +0 -136
- package/src/op/activity-contracts.ts +0 -129
- package/src/op/builders.ts +0 -67
- package/src/package-cli.ts +0 -14
- package/src/plan-shape.test.ts +0 -91
- package/src/plan-shape.ts +0 -105
- package/src/planned-output-changes.test.ts +0 -85
- package/src/planned-output-changes.ts +0 -141
- package/src/plugin.test.ts +0 -96
- package/src/plugin.ts +0 -272
- package/src/plunge-timings.test.ts +0 -241
- package/src/plunge-timings.ts +0 -115
- package/src/plunge-up-failed.test.ts +0 -54
- package/src/pr-note.test.ts +0 -87
- package/src/preview-generated.test.ts +0 -124
- package/src/preview-tips.test.ts +0 -134
- package/src/preview-tips.ts +0 -128
- package/src/pulumi-up.test.ts +0 -581
- package/src/pulumi-up.ts +0 -1102
- package/src/pulumi-urn-node.test.ts +0 -94
- package/src/release-copy.test.ts +0 -162
- package/src/release-copy.ts +0 -223
- package/src/review-stack.test.ts +0 -254
- package/src/review-stack.ts +0 -266
- package/src/run-plan-flags.test.ts +0 -53
- package/src/run.test.ts +0 -540
- package/src/run.ts +0 -1129
- package/src/serializer.test.ts +0 -9
- package/src/serializer.ts +0 -15
- package/src/skills/chant-pulumi-plunge.md +0 -51
- package/src/skills/chant-pulumi-stack-export.md +0 -54
- package/src/skills/chant-pulumi.md +0 -83
- package/src/stack-export-snapshot.test.ts +0 -192
- package/src/stack-export-snapshot.ts +0 -312
- package/src/stack-ops.fake-binary.test.ts +0 -323
- package/src/stack-ops.test.ts +0 -511
- package/src/stack-ops.ts +0 -1082
- package/src/stack-outputs.ts +0 -66
- package/src/stack-references.test.ts +0 -96
- package/src/stack-references.ts +0 -110
- package/src/testdata/plunge-drift/README.md +0 -10
- package/src/testdata/plunge-drift/assets-drifted.ndjson +0 -3
- package/src/testdata/plunge-drift/component-unsupported.ndjson +0 -3
- package/src/testdata/plunge-drift/role-in-sync.ndjson +0 -3
- package/src/testdata/plunge-drift/settled-empty.ndjson +0 -2
- package/src/testdata/plunge-graph/Pulumi.yaml +0 -4
- package/src/testdata/plunge-graph/README.md +0 -12
- package/src/testdata/plunge-graph/engine-graph.json +0 -158
- package/src/testdata/plunge-graph/stack-export.json +0 -49
- package/src/testdata/plunge-member/Pulumi.yaml +0 -4
- package/src/testdata/plunge-member/README.md +0 -3
- package/src/testdata/plunge-member/stack-export.json +0 -480
- package/src/testdata/plunge-outputs/Pulumi.yaml +0 -9
- package/src/testdata/plunge-outputs/README.md +0 -7
- package/src/testdata/plunge-outputs/stack-export.json +0 -2003
- package/src/testdata/plunge-outputs/stack-output.json +0 -19
- package/src/testdata/pulumi-member/Pulumi.yaml +0 -2
- package/src/testdata/pulumi-member/README.md +0 -50
- package/src/testdata/pulumi-member/recording/Pulumi.dev.yaml +0 -19
- package/src/testdata/pulumi-member/recording/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-member/recording/index.js +0 -47
- package/src/testdata/pulumi-member/recording/package-lock.json +0 -2707
- package/src/testdata/pulumi-member/recording/package.json +0 -9
- package/src/testdata/pulumi-member/stack-export.json +0 -746
- package/src/testdata/pulumi-outputs/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-outputs/README.md +0 -9
- package/src/testdata/pulumi-outputs/preview-replaced.json +0 -2894
- package/src/testdata/pulumi-outputs/preview-settled.json +0 -2894
- package/src/testdata/pulumi-outputs/stack-export.json +0 -1919
- package/src/testdata/pulumi-outputs/stack-output.json +0 -19
- package/src/testdata/pulumi-preview/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-preview/README.md +0 -9
- package/src/testdata/pulumi-preview/preview-create.json +0 -992
- package/src/testdata/pulumi-preview/preview.json +0 -2894
- package/src/testdata/pulumi-preview/stack-export.json +0 -1919
- package/src/testdata/pulumi-refresh/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-refresh/README.md +0 -14
- package/src/testdata/pulumi-refresh/all.json +0 -3742
- package/src/testdata/pulumi-refresh/bucket-edited.json +0 -468
- package/src/testdata/pulumi-refresh/policy-deleted.json +0 -95
- package/src/testdata/pulumi-refresh/queue-edited.json +0 -250
- package/src/testdata/pulumi-refresh/role-same.json +0 -242
- package/src/testdata/pulumi-refresh/secret-edited.json +0 -247
- package/src/testdata/pulumi-refresh/stack-export.json +0 -1907
- package/src/testdata/pulumi-stream/README.md +0 -16
- package/src/testdata/pulumi-stream/preview-stream.ndjson +0 -42
- package/src/testdata/pulumi-stream/up-failed-plunge.ndjson +0 -5
- package/src/testdata/pulumi-unexported/Pulumi.yaml +0 -2
- package/src/testdata/pulumi-urn-node/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-urn-node/README.md +0 -9
- package/src/testdata/pulumi-urn-node/preview.json +0 -2894
- package/src/testdata/pulumi-urn-node/stack-export.json +0 -1919
- package/src/trace-facts.test.ts +0 -38
- package/src/trace-facts.ts +0 -83
- package/src/values.ts +0 -147
- package/src/workspace-kinds.test.ts +0 -47
- package/src/workspace-member.test.ts +0 -127
- package/src/workspace-member.ts +0 -304
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pulumi URN to graph node (#4456): the stack-export render and a change set
|
|
3
|
-
* over `pulumi preview --json` put each resource of one program on the same
|
|
4
|
-
* node. The fixtures in `testdata/pulumi-urn-node` are recorded (#4475, see its
|
|
5
|
-
* README): an export of the plunge corpus's aws-ts stack on floci and a
|
|
6
|
-
* `preview --json --show-sames` of a change to it, pulumi 3.272.0. Nothing
|
|
7
|
-
* here runs Pulumi.
|
|
8
|
-
*/
|
|
9
|
-
import { describe, expect, test } from "vitest";
|
|
10
|
-
import { readFileSync } from "node:fs";
|
|
11
|
-
import { join } from "node:path";
|
|
12
|
-
import { pulumiNodeCandidates, pulumiNodeKey, pulumiPreviewNodes } from "@intentius/chant/pulumi-urn";
|
|
13
|
-
import { readPulumiMember } from "./workspace-member";
|
|
14
|
-
|
|
15
|
-
const dir = join(import.meta.dirname, "testdata", "pulumi-urn-node");
|
|
16
|
-
const preview = JSON.parse(readFileSync(join(dir, "preview.json"), "utf-8")) as unknown;
|
|
17
|
-
const exported = (JSON.parse(readFileSync(join(dir, "stack-export.json"), "utf-8")) as { deployment: { resources: { urn: string; type: string }[] } })
|
|
18
|
-
.deployment.resources;
|
|
19
|
-
|
|
20
|
-
/** The node ids the export's render gives, without the workspace in front. */
|
|
21
|
-
function renderedIds(): Set<string> {
|
|
22
|
-
return new Set(readPulumiMember({ member: { dir, label: "site" } }).entities.keys());
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const urn = (type: string, name: string) => `urn:pulumi:floci::corpus-aws-ts::${type}::${name}`;
|
|
26
|
-
|
|
27
|
-
describe("Pulumi URN to graph node (#4456)", () => {
|
|
28
|
-
test("every resource in both the export and the preview maps to the same node", () => {
|
|
29
|
-
const ids = renderedIds();
|
|
30
|
-
const byUrn = new Map<string, Set<string | null>>();
|
|
31
|
-
for (const s of pulumiPreviewNodes(preview, "site")) {
|
|
32
|
-
if (!byUrn.has(s.urn)) byUrn.set(s.urn, new Set());
|
|
33
|
-
byUrn.get(s.urn)!.add(s.node);
|
|
34
|
-
}
|
|
35
|
-
// The preview lists every resource the export holds but the default provider, which preview --json never prints.
|
|
36
|
-
const missing = exported.filter((r) => !byUrn.has(r.urn)).map((r) => r.urn);
|
|
37
|
-
expect(missing).toEqual([expect.stringMatching(/::pulumi:providers:aws::default_/)]);
|
|
38
|
-
for (const r of exported.filter((x) => byUrn.has(x.urn))) {
|
|
39
|
-
const fromPreview = [...byUrn.get(r.urn)!];
|
|
40
|
-
expect(fromPreview, r.urn).toHaveLength(1);
|
|
41
|
-
const node = fromPreview[0];
|
|
42
|
-
if (node === null) {
|
|
43
|
-
// A provider or the stack: the render has no node for it either.
|
|
44
|
-
expect(ids.has(`site/${r.urn.split("::").slice(2).join("::")}`), r.urn).toBe(false);
|
|
45
|
-
} else {
|
|
46
|
-
expect(ids.has(node), `${r.urn} -> ${node}`).toBe(true);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
test("the nodes: the URN tail under the member, providers and the stack on none", () => {
|
|
52
|
-
expect(pulumiPreviewNodes(preview, "site").map((s) => `${s.op} ${s.node}`)).toEqual([
|
|
53
|
-
"same null",
|
|
54
|
-
"same site/corpus:index:Site::docs",
|
|
55
|
-
"same null",
|
|
56
|
-
"replace site/aws:ec2/vpc:Vpc::main",
|
|
57
|
-
"same site/aws:iam/role:Role::app-role",
|
|
58
|
-
"update site/aws:sqs/queue:Queue::events",
|
|
59
|
-
"update site/aws:ssm/parameter:Parameter::db-password",
|
|
60
|
-
"same site/aws:s3/bucket:Bucket::site-bucket",
|
|
61
|
-
"same site/aws:sqs/queue:Queue::worker-1",
|
|
62
|
-
"same site/aws:sqs/queue:Queue::worker-0",
|
|
63
|
-
"same site/corpus:index:Site$aws:s3/bucket:Bucket::docs-assets",
|
|
64
|
-
"same site/corpus:index:Site$aws:sns/topic:Topic::docs-notify",
|
|
65
|
-
"replace site/aws:ec2/securityGroup:SecurityGroup::app-sg",
|
|
66
|
-
"same site/aws:sns/topic:Topic::alerts-west",
|
|
67
|
-
"same site/aws:s3/bucketPolicy:BucketPolicy::site-bucket-policy",
|
|
68
|
-
"delete site/aws:sqs/queue:Queue::worker-2",
|
|
69
|
-
"delete site/aws:ssm/parameter:Parameter::vpc-id",
|
|
70
|
-
]);
|
|
71
|
-
// Every custom resource and the component, the stack and the two providers left out.
|
|
72
|
-
expect(renderedIds().size).toBe(15);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
test("a resource the export does not hold has an id the graph lacks", () => {
|
|
76
|
-
const ids = renderedIds();
|
|
77
|
-
expect(ids.has("site/aws:sqs/queue:Queue::worker-3")).toBe(false);
|
|
78
|
-
expect(ids.has("site/aws:sqs/queue:Queue::worker-2")).toBe(true);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test("a child nests under its component through the parent edge", () => {
|
|
82
|
-
const { entities } = readPulumiMember({ member: { dir, label: "site" } });
|
|
83
|
-
const refs = (key: string) => (entities.get(key) as unknown as { references: { to: string; viaAttr: string }[] }).references;
|
|
84
|
-
expect(refs("site/corpus:index:Site$aws:s3/bucket:Bucket::docs-assets")).toContainEqual({ to: "site/corpus:index:Site::docs", viaAttr: "parent", grain: "instance" });
|
|
85
|
-
expect(refs("site/aws:s3/bucket:Bucket::site-bucket").filter((r) => r.viaAttr === "parent")).toEqual([]);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
test("the key ignores the stack and the project", () => {
|
|
89
|
-
const at = (stack: string, project: string) => `urn:pulumi:${stack}::${project}::corpus:index:Site$aws:s3/bucket:Bucket::docs-assets`;
|
|
90
|
-
expect(pulumiNodeKey(at("floci", "corpus-aws-ts"))).toBe(pulumiNodeKey(at("prod", "other")));
|
|
91
|
-
expect(pulumiNodeKey(urn("aws:s3/bucket:Bucket", "a::b"))).toBe("aws:s3/bucket:Bucket::a::b");
|
|
92
|
-
expect(pulumiNodeCandidates({ member: "site", address: "urn:pulumi:floci::corpus-aws-ts::corpus:index:Site$pulumi:providers:aws::east" })).toEqual([]);
|
|
93
|
-
});
|
|
94
|
-
});
|
package/src/release-copy.test.ts
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A release's copy of a Pulumi program (#4542 item 3): `pulumi install` (or
|
|
3
|
-
* `plunge install`) runs in the copy when its runtime needs one, a Node copy
|
|
4
|
-
* with no lockfile is refused by name, and a directory that is not a copy is
|
|
5
|
-
* left alone by `prepareReleaseCopy`. `prepareProgram` prepares an in-place
|
|
6
|
-
* checkout by the same rule (plywood#22). The runner is a fake, so nothing
|
|
7
|
-
* installs.
|
|
8
|
-
*/
|
|
9
|
-
import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
|
|
10
|
-
import { tmpdir } from "node:os";
|
|
11
|
-
import { join } from "node:path";
|
|
12
|
-
import { beforeEach, describe, expect, test } from "vitest";
|
|
13
|
-
import {
|
|
14
|
-
isReleaseCopy,
|
|
15
|
-
prepareProgram,
|
|
16
|
-
prepareReleaseCopy,
|
|
17
|
-
programNeeds,
|
|
18
|
-
PulumiProgramNotReadyError,
|
|
19
|
-
PulumiReleaseCopyRefusedError,
|
|
20
|
-
releaseCopyNeeds,
|
|
21
|
-
resetPreparedReleaseCopies,
|
|
22
|
-
} from "./release-copy";
|
|
23
|
-
import { runReleaseInstall, type PulumiRunner } from "./run";
|
|
24
|
-
|
|
25
|
-
function copy(pulumiYaml: string, files: Record<string, string> = {}): string {
|
|
26
|
-
const dir = join(mkdtempSync(join(tmpdir(), "release-copy-")), ".chant", "release-templates", "abc123", "infra");
|
|
27
|
-
mkdirSync(dir, { recursive: true });
|
|
28
|
-
writeFileSync(join(dir, "Pulumi.yaml"), pulumiYaml);
|
|
29
|
-
for (const [name, text] of Object.entries(files)) writeFileSync(join(dir, name), text);
|
|
30
|
-
return dir;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function runner(): { run: PulumiRunner; calls: { args: string[]; cwd: string }[] } {
|
|
34
|
-
const calls: { args: string[]; cwd: string }[] = [];
|
|
35
|
-
return { run: async (args, opts) => (calls.push({ args, cwd: opts.cwd }), { stdout: "" }), calls };
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
beforeEach(() => resetPreparedReleaseCopies());
|
|
39
|
-
|
|
40
|
-
describe("a release copy", () => {
|
|
41
|
-
test("is recognised by its path", () => {
|
|
42
|
-
expect(isReleaseCopy(copy("name: shop\nruntime: nodejs\n"))).toBe(true);
|
|
43
|
-
expect(isReleaseCopy(mkdtempSync(join(tmpdir(), "plain-")))).toBe(false);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test("a Node copy with a lockfile and no node_modules gets one install, once", async () => {
|
|
47
|
-
const dir = copy("name: shop\nruntime: nodejs\n", { "package.json": "{}", "package-lock.json": "{}" });
|
|
48
|
-
const { run, calls } = runner();
|
|
49
|
-
expect(await prepareReleaseCopy({ dir, member: "shop/prod", engine: "pulumi", run })).toEqual({ action: "installed", command: "pulumi install" });
|
|
50
|
-
await prepareReleaseCopy({ dir, member: "shop/prod", engine: "pulumi", run });
|
|
51
|
-
expect(calls).toEqual([{ args: ["install"], cwd: dir }]);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test("a Node copy with no lockfile is refused by name, and nothing runs", async () => {
|
|
55
|
-
const dir = copy("name: shop\nruntime: nodejs\n", { "package.json": "{}" });
|
|
56
|
-
const { run, calls } = runner();
|
|
57
|
-
await expect(prepareReleaseCopy({ dir, member: "shop/prod", engine: "plunge", run })).rejects.toThrow(PulumiReleaseCopyRefusedError);
|
|
58
|
-
await expect(prepareReleaseCopy({ dir, member: "shop/prod", engine: "plunge", run })).rejects.toThrow(/recorded no lockfile/);
|
|
59
|
-
expect(calls).toEqual([]);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test("Python installs for a missing virtualenv or a poetry or uv toolchain; Go and YAML never do", () => {
|
|
63
|
-
expect(releaseCopyNeeds(copy("name: a\nruntime:\n name: python\n options:\n virtualenv: venv\n"), "a").install).toBe(true);
|
|
64
|
-
expect(releaseCopyNeeds(copy("name: a\nruntime:\n name: python\n options:\n toolchain: uv\n"), "a").install).toBe(true);
|
|
65
|
-
expect(releaseCopyNeeds(copy("name: a\nruntime: python\n"), "a").install).toBe(false);
|
|
66
|
-
expect(releaseCopyNeeds(copy("name: a\nruntime: go\n"), "a").install).toBe(false);
|
|
67
|
-
expect(releaseCopyNeeds(copy("name: a\nruntime: yaml\n"), "a").install).toBe(false);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test("a directory outside a release copy is never touched", async () => {
|
|
71
|
-
const dir = mkdtempSync(join(tmpdir(), "plain-"));
|
|
72
|
-
writeFileSync(join(dir, "Pulumi.yaml"), "name: shop\nruntime: nodejs\n");
|
|
73
|
-
const { run, calls } = runner();
|
|
74
|
-
expect(await prepareReleaseCopy({ dir, member: "shop/prod", engine: "pulumi", run })).toEqual({ action: "not-a-copy" });
|
|
75
|
-
expect(calls).toEqual([]);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
test("the install argv is exactly install", async () => {
|
|
79
|
-
const { run, calls } = runner();
|
|
80
|
-
for (const args of [["install", "--reinstall"], ["install", "--no-plugins"], ["up"], []]) {
|
|
81
|
-
await expect(runReleaseInstall(run, args, "/tmp")).rejects.toThrow(/only as pulumi install or plunge install/);
|
|
82
|
-
}
|
|
83
|
-
expect(calls).toEqual([]);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
/** An in-place checkout: a directory outside any release copy, with its files. */
|
|
88
|
-
function checkout(pulumiYaml: string, files: Record<string, string> = {}): string {
|
|
89
|
-
const dir = join(mkdtempSync(join(tmpdir(), "checkout-")), "shop");
|
|
90
|
-
mkdirSync(dir, { recursive: true });
|
|
91
|
-
writeFileSync(join(dir, "Pulumi.yaml"), pulumiYaml);
|
|
92
|
-
for (const [name, text] of Object.entries(files)) writeFileSync(join(dir, name), text);
|
|
93
|
-
return dir;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
describe("an in-place checkout (plywood#22)", () => {
|
|
97
|
-
const node = "name: shop\nruntime: nodejs\n";
|
|
98
|
-
const locked = { "package.json": "{}", "package-lock.json": "{}" };
|
|
99
|
-
|
|
100
|
-
test("a Node checkout with a lockfile and no node_modules gets one install, whichever engine asks", async () => {
|
|
101
|
-
const dir = checkout(node, locked);
|
|
102
|
-
const plunge = runner();
|
|
103
|
-
const pulumi = runner();
|
|
104
|
-
const [a, b] = await Promise.all([
|
|
105
|
-
prepareProgram({ dir, member: "shop/dev", engine: "plunge", run: plunge.run }),
|
|
106
|
-
prepareProgram({ dir, member: "shop/staging", engine: "pulumi", run: pulumi.run }),
|
|
107
|
-
]);
|
|
108
|
-
expect(a).toEqual({ place: "checkout", action: "installed", command: "plunge install" });
|
|
109
|
-
expect(b).toEqual(a);
|
|
110
|
-
expect(plunge.calls).toEqual([{ args: ["install"], cwd: dir }]);
|
|
111
|
-
expect(pulumi.calls).toEqual([]);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
test("node_modules here or above, or Yarn's Plug'n'Play loader, counts as installed", () => {
|
|
115
|
-
const here = checkout(node, locked);
|
|
116
|
-
mkdirSync(join(here, "node_modules"));
|
|
117
|
-
expect(programNeeds(here, "shop/dev", "checkout").install).toBe(false);
|
|
118
|
-
|
|
119
|
-
const hoisted = checkout(node, { "package.json": "{}" });
|
|
120
|
-
mkdirSync(join(hoisted, "..", "node_modules"));
|
|
121
|
-
expect(programNeeds(hoisted, "shop/dev", "checkout")).toMatchObject({ install: false, reason: expect.stringContaining("node_modules") });
|
|
122
|
-
|
|
123
|
-
const pnp = checkout(node, { "package.json": "{}", "yarn.lock": "", ".pnp.cjs": "" });
|
|
124
|
-
expect(programNeeds(pnp, "shop/dev", "checkout").install).toBe(false);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
test("a Node checkout with no lockfile is refused by name, and nothing runs", async () => {
|
|
128
|
-
const dir = checkout(node, { "package.json": "{}" });
|
|
129
|
-
const { run, calls } = runner();
|
|
130
|
-
await expect(prepareProgram({ dir, member: "shop/dev", engine: "pulumi", run })).rejects.toThrow(PulumiProgramNotReadyError);
|
|
131
|
-
await expect(prepareProgram({ dir, member: "shop/dev", engine: "pulumi", run })).rejects.toThrow(/no lockfile .* beside its package.json/);
|
|
132
|
-
expect(calls).toEqual([]);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
test("a failed install names the command, and the next call tries again", async () => {
|
|
136
|
-
const dir = checkout(node, locked);
|
|
137
|
-
let fail = true;
|
|
138
|
-
const calls: string[][] = [];
|
|
139
|
-
const run: PulumiRunner = async (args) => {
|
|
140
|
-
calls.push(args);
|
|
141
|
-
if (fail) throw Object.assign(new Error("exit 1"), { code: 1, stderr: "npm error ERESOLVE" });
|
|
142
|
-
return { stdout: "" };
|
|
143
|
-
};
|
|
144
|
-
await expect(prepareProgram({ dir, member: "shop/dev", engine: "pulumi", run })).rejects.toThrow(/pulumi install failed: npm error ERESOLVE/);
|
|
145
|
-
fail = false;
|
|
146
|
-
expect(await prepareProgram({ dir, member: "shop/dev", engine: "pulumi", run })).toMatchObject({ action: "installed" });
|
|
147
|
-
expect(calls).toEqual([["install"], ["install"]]);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
test("Python, Go and YAML follow the copy's rules", () => {
|
|
151
|
-
expect(programNeeds(checkout("name: a\nruntime:\n name: python\n options:\n virtualenv: venv\n"), "a", "checkout").install).toBe(true);
|
|
152
|
-
expect(programNeeds(checkout("name: a\nruntime: python\n"), "a", "checkout").install).toBe(false);
|
|
153
|
-
expect(programNeeds(checkout("name: a\nruntime: go\n"), "a", "checkout").install).toBe(false);
|
|
154
|
-
expect(programNeeds(checkout("name: a\nruntime: yaml\n"), "a", "checkout").install).toBe(false);
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
test("a release copy keeps the copy's rule: node_modules above the copy does not count", () => {
|
|
158
|
-
const dir = copy("name: shop\nruntime: nodejs\n", { "package.json": "{}", "package-lock.json": "{}" });
|
|
159
|
-
mkdirSync(join(dir, "..", "node_modules"));
|
|
160
|
-
expect(releaseCopyNeeds(dir, "shop/prod").install).toBe(true);
|
|
161
|
-
});
|
|
162
|
-
});
|
package/src/release-copy.ts
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A Pulumi program's recorded copy under a release (#4542 item 3).
|
|
3
|
-
*
|
|
4
|
-
* `pulumi-up`'s `releaseInputs` (`./pulumi-up.ts`) answers the stack's
|
|
5
|
-
* directory, so `chant release cut` records it and a `promote --release` or
|
|
6
|
-
* `rollback --release` writes the copy under
|
|
7
|
-
* `.chant/release-templates/<digest>/` and points the step's `dir` at it.
|
|
8
|
-
* The cut records the files git tracks, so the copy has no `node_modules`
|
|
9
|
-
* and no virtualenv, and the program cannot run there as it stands.
|
|
10
|
-
*
|
|
11
|
-
* {@link prepareReleaseCopy} closes that gap before the copy's first
|
|
12
|
-
* preview: it runs `pulumi install` (`plunge install` on plunge) in the
|
|
13
|
-
* copy, the CLI's own install of the program's dependencies and plugins,
|
|
14
|
-
* which follows the runtime's options in `Pulumi.yaml` (`packagemanager`,
|
|
15
|
-
* `toolchain`, `virtualenv`). It runs only when the copy needs it:
|
|
16
|
-
*
|
|
17
|
-
* - `nodejs`: when there is no `node_modules`. A copy with no lockfile
|
|
18
|
-
* (`package-lock.json`, `npm-shrinkwrap.json`, `yarn.lock`,
|
|
19
|
-
* `pnpm-lock.yaml`, `bun.lock`, `bun.lockb`) is refused by name, since an
|
|
20
|
-
* install would take whatever versions resolve today instead of the
|
|
21
|
-
* release's.
|
|
22
|
-
* - `python`: when `options.virtualenv` names a directory that is not there,
|
|
23
|
-
* or `options.toolchain` is `poetry` or `uv`.
|
|
24
|
-
* - `go`, `dotnet`, `java`, `yaml`: never; their tools fetch what the
|
|
25
|
-
* program needs on the run.
|
|
26
|
-
*
|
|
27
|
-
* ## In-place checkouts (plywood#22)
|
|
28
|
-
*
|
|
29
|
-
* A CI job's checkout has the same gap: git cloned the tracked files, and
|
|
30
|
-
* nothing installed the program's dependencies before the step's first
|
|
31
|
-
* preview. {@link prepareProgram}, which `pulumi-up`'s plan and run call,
|
|
32
|
-
* prepares a release copy as above and an in-place directory by the same
|
|
33
|
-
* install and the same lockfile rule, with two differences for a directory
|
|
34
|
-
* that sits in a working tree:
|
|
35
|
-
*
|
|
36
|
-
* - `nodejs`: `node_modules` in the directory or any directory above it (a
|
|
37
|
-
* workspace's hoisted install), or a Yarn Plug'n'Play `.pnp.cjs` or
|
|
38
|
-
* `.pnp.js` there, counts as installed, since Node resolves the SDK
|
|
39
|
-
* from either.
|
|
40
|
-
* - The refusal for a Node program with no lockfile names the checkout, and
|
|
41
|
-
* says to commit a lockfile or install before the run.
|
|
42
|
-
*
|
|
43
|
-
* Preparation runs once per directory per process, whichever engine asks
|
|
44
|
-
* first, so two stacks of one project on different engines never install
|
|
45
|
-
* into the same directory at once.
|
|
46
|
-
*/
|
|
47
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
48
|
-
import { dirname, join, resolve, sep } from "node:path";
|
|
49
|
-
import { parseYAML } from "@intentius/chant/yaml";
|
|
50
|
-
import type { PulumiMemberEngine } from "./member-engine";
|
|
51
|
-
import { pulumiRunFailure, runReleaseInstall, type PulumiRunner } from "./run";
|
|
52
|
-
import { isObject } from "./values";
|
|
53
|
-
|
|
54
|
-
/** Where core writes a release's recorded files, from the member's directory (`RELEASE_TEMPLATES_DIR` in core's release-promote). */
|
|
55
|
-
export const RELEASE_COPY_DIR = ".chant/release-templates";
|
|
56
|
-
|
|
57
|
-
/** The lockfiles that pin a Node program's dependencies. */
|
|
58
|
-
export const NODE_LOCKFILES = ["package-lock.json", "npm-shrinkwrap.json", "yarn.lock", "pnpm-lock.yaml", "bun.lock", "bun.lockb"];
|
|
59
|
-
|
|
60
|
-
/** Whether `dir` sits in a release's recorded copy. */
|
|
61
|
-
export function isReleaseCopy(dir: string): boolean {
|
|
62
|
-
const marker = `${sep}${RELEASE_COPY_DIR.split("/").join(sep)}${sep}`;
|
|
63
|
-
return `${dir}${sep}`.includes(marker);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** The runtime `Pulumi.yaml` names, and its options. */
|
|
67
|
-
export function pulumiRuntime(dir: string): { name?: string; options: Record<string, unknown> } {
|
|
68
|
-
for (const file of ["Pulumi.yaml", "Pulumi.yml"]) {
|
|
69
|
-
const path = join(dir, file);
|
|
70
|
-
if (!existsSync(path)) continue;
|
|
71
|
-
try {
|
|
72
|
-
const runtime = parseYAML(readFileSync(path, "utf-8")).runtime;
|
|
73
|
-
if (typeof runtime === "string") return { name: runtime, options: {} };
|
|
74
|
-
if (isObject(runtime)) return { ...(typeof runtime.name === "string" ? { name: runtime.name } : {}), options: isObject(runtime.options) ? runtime.options : {} };
|
|
75
|
-
} catch {
|
|
76
|
-
// An unreadable Pulumi.yaml fails the preview with the engine's own error.
|
|
77
|
-
}
|
|
78
|
-
return { options: {} };
|
|
79
|
-
}
|
|
80
|
-
return { options: {} };
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/** A copy the program cannot run in, with the reason. */
|
|
84
|
-
export class PulumiReleaseCopyRefusedError extends Error {
|
|
85
|
-
constructor(
|
|
86
|
-
public readonly member: string,
|
|
87
|
-
reason: string,
|
|
88
|
-
) {
|
|
89
|
-
super(`pulumi-up: "${member}": refusing to plan the release's copy: ${reason}`);
|
|
90
|
-
this.name = "PulumiReleaseCopyRefusedError";
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/** An in-place program that cannot be made runnable, with the reason (plywood#22). */
|
|
95
|
-
export class PulumiProgramNotReadyError extends Error {
|
|
96
|
-
constructor(
|
|
97
|
-
public readonly member: string,
|
|
98
|
-
public readonly dir: string,
|
|
99
|
-
reason: string,
|
|
100
|
-
) {
|
|
101
|
-
super(`pulumi-up: "${member}": the program in ${dir} cannot run: ${reason}`);
|
|
102
|
-
this.name = "PulumiProgramNotReadyError";
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/** What preparing a copy did. */
|
|
107
|
-
export type ReleaseCopyPrepared =
|
|
108
|
-
| { action: "not-a-copy" }
|
|
109
|
-
| { action: "none"; reason: string }
|
|
110
|
-
| { action: "installed"; command: string };
|
|
111
|
-
|
|
112
|
-
/** What preparing a program's directory did: a release copy or an in-place checkout. */
|
|
113
|
-
export type ProgramPrepared = { place: "copy" | "checkout" } & ({ action: "none"; reason: string } | { action: "installed"; command: string });
|
|
114
|
-
|
|
115
|
-
/** Whether `dir` or a directory above it holds what Node resolves a package from: `node_modules`, or Yarn Plug'n'Play's loader. */
|
|
116
|
-
function nodeResolvesAbove(dir: string): string | undefined {
|
|
117
|
-
let at = resolve(dir);
|
|
118
|
-
for (;;) {
|
|
119
|
-
for (const f of ["node_modules", ".pnp.cjs", ".pnp.js"]) if (existsSync(join(at, f))) return join(at, f);
|
|
120
|
-
const up = dirname(at);
|
|
121
|
-
if (up === at) return undefined;
|
|
122
|
-
at = up;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/** Why the copy needs an install, or why not; throws when it cannot be prepared. */
|
|
127
|
-
export function releaseCopyNeeds(dir: string, member: string): { install: boolean; reason: string } {
|
|
128
|
-
return programNeeds(dir, member, "copy");
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Why a program's directory needs an install, or why not: a release copy
|
|
133
|
-
* (`copy`) or an in-place checkout (`checkout`). Throws when it cannot be
|
|
134
|
-
* prepared: a Node program with no lockfile beside its package.json.
|
|
135
|
-
*/
|
|
136
|
-
export function programNeeds(dir: string, member: string, place: "copy" | "checkout"): { install: boolean; reason: string } {
|
|
137
|
-
const { name, options } = pulumiRuntime(dir);
|
|
138
|
-
switch (name) {
|
|
139
|
-
case "nodejs": {
|
|
140
|
-
if (place === "copy") {
|
|
141
|
-
if (existsSync(join(dir, "node_modules"))) return { install: false, reason: "the copy has node_modules" };
|
|
142
|
-
} else {
|
|
143
|
-
const found = nodeResolvesAbove(dir);
|
|
144
|
-
if (found) return { install: false, reason: `Node resolves the program's packages from ${found}` };
|
|
145
|
-
}
|
|
146
|
-
if (!NODE_LOCKFILES.some((f) => existsSync(join(dir, f)))) {
|
|
147
|
-
if (place === "checkout") {
|
|
148
|
-
throw new PulumiProgramNotReadyError(
|
|
149
|
-
member,
|
|
150
|
-
dir,
|
|
151
|
-
`the program is Node, nothing installed its dependencies (no node_modules here or above), and there is no lockfile (${NODE_LOCKFILES.join(", ")}) beside its package.json, so an install would take whatever versions resolve today; commit a lockfile, or install the dependencies before the run`,
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
throw new PulumiReleaseCopyRefusedError(
|
|
155
|
-
member,
|
|
156
|
-
`the program is Node, and the release recorded no lockfile (${NODE_LOCKFILES.join(", ")}) beside its package.json, so an install would take today's versions, not the release's; commit a lockfile and cut the release again`,
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
return { install: true, reason: place === "copy" ? "a Node program's copy has no node_modules" : "a Node program's checkout has no node_modules" };
|
|
160
|
-
}
|
|
161
|
-
case "python": {
|
|
162
|
-
const venv = typeof options.virtualenv === "string" ? options.virtualenv : undefined;
|
|
163
|
-
const toolchain = typeof options.toolchain === "string" ? options.toolchain : undefined;
|
|
164
|
-
if (toolchain === "poetry" || toolchain === "uv") return { install: true, reason: `a Python program on ${toolchain} installs its environment` };
|
|
165
|
-
if (venv && !existsSync(join(dir, venv))) return { install: true, reason: `the virtualenv ${venv} is not in the ${place}` };
|
|
166
|
-
return { install: false, reason: "the Python program names no virtualenv to build" };
|
|
167
|
-
}
|
|
168
|
-
default:
|
|
169
|
-
return { install: false, reason: `the ${name ?? "unnamed"} runtime fetches what it needs on the run` };
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const prepared = new Map<string, Promise<ProgramPrepared>>();
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Make a program's directory runnable before its first engine run, once per
|
|
177
|
-
* directory in this process: `install` there when {@link programNeeds} says
|
|
178
|
-
* so. A release copy follows the copy's rules, any other directory the
|
|
179
|
-
* checkout's. Throws for a directory that cannot be prepared, or an install
|
|
180
|
-
* that fails. The first caller's engine runs the install; a second engine
|
|
181
|
-
* asking for the same directory waits on it.
|
|
182
|
-
*/
|
|
183
|
-
export function prepareProgram(opts: { dir: string; member: string; engine: PulumiMemberEngine; run: PulumiRunner }): Promise<ProgramPrepared> {
|
|
184
|
-
const dir = resolve(opts.dir);
|
|
185
|
-
const place = isReleaseCopy(dir) ? "copy" : "checkout";
|
|
186
|
-
let done = prepared.get(dir);
|
|
187
|
-
if (!done) {
|
|
188
|
-
done = (async (): Promise<ProgramPrepared> => {
|
|
189
|
-
const needs = programNeeds(dir, opts.member, place);
|
|
190
|
-
if (!needs.install) return { place, action: "none", reason: needs.reason };
|
|
191
|
-
const command = `${opts.engine} install`;
|
|
192
|
-
try {
|
|
193
|
-
await runReleaseInstall(opts.run, ["install"], dir);
|
|
194
|
-
} catch (err) {
|
|
195
|
-
const f = pulumiRunFailure(err);
|
|
196
|
-
const why = f.missingBinary ? `the ${opts.engine} binary was not found on PATH` : (f.stderr?.trim() || f.message).split("\n").slice(-3).join("\n");
|
|
197
|
-
if (place === "copy") throw new PulumiReleaseCopyRefusedError(opts.member, `${command} in the copy failed: ${why}`);
|
|
198
|
-
throw new PulumiProgramNotReadyError(opts.member, dir, `${command} failed: ${why}`);
|
|
199
|
-
}
|
|
200
|
-
return { place, action: "installed", command };
|
|
201
|
-
})();
|
|
202
|
-
prepared.set(dir, done);
|
|
203
|
-
done.catch(() => prepared.delete(dir));
|
|
204
|
-
}
|
|
205
|
-
return done;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Make a release copy runnable, once per directory in this process: `install`
|
|
210
|
-
* in the copy when {@link releaseCopyNeeds} says so. Throws for a copy that
|
|
211
|
-
* cannot be prepared, or an install that fails. A directory that is not a
|
|
212
|
-
* copy is left alone; {@link prepareProgram} prepares both.
|
|
213
|
-
*/
|
|
214
|
-
export async function prepareReleaseCopy(opts: { dir: string; member: string; engine: PulumiMemberEngine; run: PulumiRunner }): Promise<ReleaseCopyPrepared> {
|
|
215
|
-
if (!isReleaseCopy(opts.dir)) return { action: "not-a-copy" };
|
|
216
|
-
const done = await prepareProgram(opts);
|
|
217
|
-
return done.action === "none" ? { action: "none", reason: done.reason } : { action: "installed", command: done.command };
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/** Forget every prepared directory. For tests. */
|
|
221
|
-
export function resetPreparedReleaseCopies(): void {
|
|
222
|
-
prepared.clear();
|
|
223
|
-
}
|