@intentius/chant-lexicon-pulumi 0.124.55 → 0.124.56

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/src/run.test.ts CHANGED
@@ -464,7 +464,7 @@ describe("the apply entry points (#4541)", () => {
464
464
  test("anything off the list is refused before the runner", async () => {
465
465
  const { run, calls } = fake(() => "");
466
466
  const base = pulumiUpArgs({ stack: "floci" });
467
- for (const extra of [["--skip-preview"], ["--refresh"], ["--show-secrets"], ["--replace", "urn:a"], ["--target-replace", "urn:a"], ["--target-dependents"], ["--exclude", "urn:a"], ["--remote"], ["--continue-on-error"], ["--config", "k=v"], ["--plan", "/tmp/p.json"]]) {
467
+ for (const extra of [["--skip-preview"], ["--show-secrets"], ["--replace", "urn:a"], ["--target-replace", "urn:a"], ["--target-dependents"], ["--exclude", "urn:a"], ["--remote"], ["--continue-on-error"], ["--config", "k=v"], ["--plan", "/tmp/p.json"]]) {
468
468
  await expect(runApplyPulumi(run, [...base, ...extra], "/tmp")).rejects.toThrow(/applies a Pulumi stack only as/);
469
469
  }
470
470
  for (const args of [
package/src/run.ts CHANGED
@@ -28,6 +28,12 @@
28
28
  * - for a review stack alone (`pr-<n>`, INTENTIUS/plywood#15), `stack
29
29
  * init`, `destroy --yes` and `stack rm --yes`, through
30
30
  * {@link runReviewStackPulumi} and {@link runReviewStackPlunge} only;
31
+ * - for the check stage (#4633, `./check-step.ts`), `pulumi install` and
32
+ * `pulumi about --json [--stack <stack>]`, or the same under `plunge`,
33
+ * through {@link runCheckPulumi} alone. The install fetches the program's
34
+ * dependencies and plugins; `about` reads the engine, plugins and backend.
35
+ * Neither writes a stack, and both run with no forge token or cloud
36
+ * credential in their environment;
31
37
  * - for a member on plunge, its engine graph (#4529, ruled on #4520), as
32
38
  * exactly one of `plunge graph --json`, `plunge graph --json --stack
33
39
  * <stack>`, `plunge graph --json --versions` and `plunge graph --json
@@ -294,14 +300,17 @@ export function engineRunnerAt(bin: string): PulumiRunner {
294
300
  * that is not empty and does not start with `-`; `[…]` is optional; `…`
295
301
  * repeats.
296
302
  *
297
- * `up` is refused with `--skip-preview`, `--refresh`, `--show-secrets`,
298
- * `--replace`, `--target-replace`, `--target-dependents`, `--exclude`,
299
- * `--remote`, `--continue-on-error`, `--config` and any flag not here, since
300
- * none of them is in the list.
303
+ * `up` is refused with `--skip-preview`, `--show-secrets`, `--replace`,
304
+ * `--target-replace`, `--exclude`, `--remote`, `--continue-on-error`,
305
+ * `--config` and any flag not here, since none of them is in the list.
306
+ * `--refresh` and `--target-dependents` (#4627) come in the tail's order,
307
+ * `--target-dependents` only after a `--target`. plunge's `up --plan`
308
+ * applies a saved plan whose preview did the refresh, so it takes no
309
+ * `--refresh`.
301
310
  */
302
311
  export const PULUMI_APPLY_COMMANDS: readonly string[] = [
303
- "plunge up --plan <file> --yes --json --stack <stack> [--config-file <file>] [--target <urn>]... [--policy-pack <dir> [--policy-pack-config <file>]]...",
304
- "pulumi up --yes --json --stack <stack> [--config-file <file>] [--target <urn>]... [--policy-pack <dir> [--policy-pack-config <file>]]...",
312
+ "plunge up --plan <file> --yes --json --stack <stack> [--config-file <file>] [--target <urn>... [--target-dependents]] [--policy-pack <dir> [--policy-pack-config <file>]]...",
313
+ "pulumi up --yes --json --stack <stack> [--config-file <file>] [--refresh] [--target <urn>... [--target-dependents]] [--policy-pack <dir> [--policy-pack-config <file>]]...",
305
314
  ];
306
315
 
307
316
  /** A CrossGuard pack the preview and `up` run (ruling 7: in the preview job, feeding chant's gate). */
@@ -317,13 +326,20 @@ export interface PulumiApplyTail {
317
326
  /** A scratch copy of the stack's config file, passed as `--config-file` (#4541): never `--config`, which writes the working tree's file. */
318
327
  configFile?: string;
319
328
  targets?: readonly string[];
329
+ /** `--refresh` (#4627): refresh the stack's state before the preview or `pulumi up`. */
330
+ refresh?: boolean;
331
+ /** `--target-dependents` (#4627): with `targets`, their dependents too. */
332
+ targetDependents?: boolean;
320
333
  policyPacks?: readonly PulumiPolicyPack[];
321
334
  }
322
335
 
323
336
  function tailArgs(t: PulumiApplyTail): string[] {
337
+ const targets = t.targets ?? [];
324
338
  return [
325
339
  ...(t.configFile ? ["--config-file", t.configFile] : []),
326
- ...(t.targets ?? []).flatMap((u) => ["--target", u]),
340
+ ...(t.refresh ? ["--refresh"] : []),
341
+ ...targets.flatMap((u) => ["--target", u]),
342
+ ...(t.targetDependents && targets.length > 0 ? ["--target-dependents"] : []),
327
343
  ...(t.policyPacks ?? []).flatMap((p) => ["--policy-pack", p.dir, ...(p.config ? ["--policy-pack-config", p.config] : [])]),
328
344
  ];
329
345
  }
@@ -350,17 +366,21 @@ export function pulumiUpArgs(opts: { stack: string } & PulumiApplyTail): string[
350
366
 
351
367
  const isValue = (v: string | undefined): v is string => typeof v === "string" && v.length > 0 && !v.startsWith("-");
352
368
 
353
- /** Whether `rest` is exactly an apply tail, in its order. */
354
- function wellFormedTail(rest: string[]): boolean {
369
+ /** Whether `rest` is exactly an apply tail, in its order; `refresh` says whether `--refresh` may stand in it (#4627). */
370
+ function wellFormedTail(rest: string[], refresh = true): boolean {
355
371
  let i = 0;
356
372
  if (rest[i] === "--config-file") {
357
373
  if (!isValue(rest[i + 1])) return false;
358
374
  i += 2;
359
375
  }
376
+ if (refresh && rest[i] === "--refresh") i += 1;
377
+ let targets = 0;
360
378
  while (rest[i] === "--target") {
361
379
  if (!isValue(rest[i + 1])) return false;
362
380
  i += 2;
381
+ targets++;
363
382
  }
383
+ if (targets > 0 && rest[i] === "--target-dependents") i += 1;
364
384
  while (rest[i] === "--policy-pack") {
365
385
  if (!isValue(rest[i + 1])) return false;
366
386
  i += 2;
@@ -382,7 +402,7 @@ function allowedPlungeUp(args: string[]): boolean {
382
402
  args[4] === "--json" &&
383
403
  args[5] === "--stack" &&
384
404
  isValue(args[6]) &&
385
- wellFormedTail(args.slice(7))
405
+ wellFormedTail(args.slice(7), false)
386
406
  );
387
407
  }
388
408
 
@@ -640,6 +660,29 @@ export async function runReleaseInstall(run: PulumiRunner, args: string[], cwd:
640
660
  return run(args, env ? { cwd, env } : { cwd });
641
661
  }
642
662
 
663
+ /**
664
+ * The two argv the check stage runs for a member (#4633, `./check-step.ts`):
665
+ * `install` with no flag, and `about --json`, optionally with `--stack
666
+ * <stack>`. Under `pulumi` or `plunge`; the runner picks the binary.
667
+ */
668
+ export const PULUMI_CHECK_COMMANDS: readonly string[] = ["pulumi install", "pulumi about --json [--stack <stack>]", "plunge install", "plunge about --json [--stack <stack>]"];
669
+
670
+ /** Whether `args` is one of {@link PULUMI_CHECK_COMMANDS}' argv. */
671
+ export function allowedCheck(args: readonly string[]): boolean {
672
+ if (args.length === 1) return args[0] === "install";
673
+ if (args[0] !== "about" || args[1] !== "--json") return false;
674
+ if (args.length === 2) return true;
675
+ return args.length === 4 && args[2] === "--stack" && isValue(args[3]);
676
+ }
677
+
678
+ /** Run a check-stage argv, refusing any other. The runner picks the binary. */
679
+ export async function runCheckPulumi(run: PulumiRunner, args: string[], cwd: string, env?: Record<string, string>): Promise<{ stdout: string }> {
680
+ if (!allowedCheck(args)) {
681
+ throw new Error(`the check stage runs only ${PULUMI_CHECK_COMMANDS.join(", ")} for a Pulumi member, not ${args.join(" ")}`);
682
+ }
683
+ return run(args, env ? { cwd, env } : { cwd });
684
+ }
685
+
643
686
  export { pulumiMemberEngine, readPlywoodEngine, type PulumiMemberEngine, type PulumiMemberEngineSource, type PulumiMemberEngineOptions } from "./member-engine";
644
687
 
645
688
  /** The argv chant runs for a member's applied outputs, after `pulumi` (#4455). Secrets stay blinded. */