From c3eeba76ca19a64664d8a2b3d9edfd64c4d6481c Mon Sep 17 00:00:00 2001 From: adrians5j Date: Fri, 21 Feb 2025 16:37:59 +0100 Subject: [PATCH] feat(cli-plugin-deploy-pulumi): add refresh command to manage Pulumi state --- .../src/commands/index.ts | 40 ++++++++++++++++++- .../src/commands/refresh.ts | 10 +++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 packages/cli-plugin-deploy-pulumi/src/commands/refresh.ts diff --git a/packages/cli-plugin-deploy-pulumi/src/commands/index.ts b/packages/cli-plugin-deploy-pulumi/src/commands/index.ts index 9ffcdbb0e3..1ddac0c5b3 100644 --- a/packages/cli-plugin-deploy-pulumi/src/commands/index.ts +++ b/packages/cli-plugin-deploy-pulumi/src/commands/index.ts @@ -488,6 +488,44 @@ export const commands: CliCommandPlugin[] = [ } ); + yargs.command( + "refresh ", + `Refreshes Pulumi state for given project application and environment`, + yargs => { + yargs.example("$0 refresh api --env=dev --json", ""); + yargs.positional("folder", { + describe: `Project application folder`, + type: "string" + }); + yargs + .option("region", { + describe: `Region to target`, + type: "string", + required: false + }) + .check(validateRegion); + yargs.option("env", { + required: true, + describe: `Environment`, + type: "string" + }); + yargs.option("variant", { + describe: `Variant`, + type: "string", + required: false + }); + yargs.option("debug", { + default: false, + describe: `Turn on debug logs`, + type: "boolean" + }); + }, + async argv => { + const { refreshCommand } = require("./refresh"); + return refreshCommand(argv, context); + } + ); + yargs.command( "pulumi ", `Runs a Pulumi command in the provided project application folder. Note: make sure to use "--" before the actual Pulumi command.`, @@ -531,7 +569,7 @@ export const commands: CliCommandPlugin[] = [ yargs.command( "execute-migrations [pattern]", - `Execute data migrations Lambda. If pattern is provided, only the matching migrations will be executed.`, + `Execute data migrations Lambda. If pattern is provided, only the matching migrations will be executed`, () => { yargs.example("$0 execute-migrations --env dev", ""); yargs.example("$0 execute-migrations 5.35.0-001 --env dev", ""); diff --git a/packages/cli-plugin-deploy-pulumi/src/commands/refresh.ts b/packages/cli-plugin-deploy-pulumi/src/commands/refresh.ts new file mode 100644 index 0000000000..dafe4eebb0 --- /dev/null +++ b/packages/cli-plugin-deploy-pulumi/src/commands/refresh.ts @@ -0,0 +1,10 @@ +import { createPulumiCommand } from "~/utils"; +import { pulumiRunCommand } from "./pulumiRun"; + +export const refreshCommand = createPulumiCommand({ + name: "refresh", + createProjectApplicationWorkspace: false, + command: async ({ inputs, context }) => { + return pulumiRunCommand({ ...inputs, _: ["", "refresh", "--yes"] }, context); + } +});