From 7b27e947fd3990f843beddf93ad5d794da62138c Mon Sep 17 00:00:00 2001 From: Mikkel Gravgaard Date: Thu, 19 Dec 2024 14:05:03 +0100 Subject: [PATCH 1/2] Add deployment: allow specifying deployment key --- cli/script/command-executor.ts | 2 +- cli/script/command-parser.ts | 4 ++++ cli/script/management-sdk.ts | 4 ++-- cli/script/types/cli.ts | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cli/script/command-executor.ts b/cli/script/command-executor.ts index 30b75218c..5e37358cc 100644 --- a/cli/script/command-executor.ts +++ b/cli/script/command-executor.ts @@ -290,7 +290,7 @@ function deleteFolder(folderPath: string): Promise { } function deploymentAdd(command: cli.IDeploymentAddCommand): Promise { - return sdk.addDeployment(command.appName, command.deploymentName).then((deployment: Deployment): void => { + return sdk.addDeployment(command.appName, command.deploymentName, command.key).then((deployment: Deployment): void => { log( 'Successfully added the "' + command.deploymentName + diff --git a/cli/script/command-parser.ts b/cli/script/command-parser.ts index afd641c23..831b62aa3 100644 --- a/cli/script/command-parser.ts +++ b/cli/script/command-parser.ts @@ -1045,6 +1045,10 @@ export function createCommand(): cli.ICommand { deploymentAddCommand.appName = arg2; deploymentAddCommand.deploymentName = arg3; + if(argv["key"]){ + deploymentAddCommand.key = argv["key"] as any; + } + } break; diff --git a/cli/script/management-sdk.ts b/cli/script/management-sdk.ts index 0d5af7a90..6b620a02e 100644 --- a/cli/script/management-sdk.ts +++ b/cli/script/management-sdk.ts @@ -253,8 +253,8 @@ class AccountManager { } // Deployments - public addDeployment(appName: string, deploymentName: string): Promise { - const deployment = { name: deploymentName }; + public addDeployment(appName: string, deploymentName: string, deploymentKey?: string): Promise { + const deployment = { name: deploymentName, key: deploymentKey }; return this.post(urlEncode([`/apps/${appName}/deployments/`]), JSON.stringify(deployment), /*expectResponseBody=*/ true).then( (res: JsonResponse) => res.body.deployment ); diff --git a/cli/script/types/cli.ts b/cli/script/types/cli.ts index fe555200d..359ce1fc4 100644 --- a/cli/script/types/cli.ts +++ b/cli/script/types/cli.ts @@ -107,6 +107,7 @@ export interface IDebugCommand extends ICommand { export interface IDeploymentAddCommand extends ICommand { appName: string; deploymentName: string; + key?: string; default: boolean; } From dea9ba7f9d4a6ad0eef193f06a32513f3fe44f8d Mon Sep 17 00:00:00 2001 From: Mikkel Gravgaard Date: Mon, 30 Dec 2024 13:02:34 +0100 Subject: [PATCH 2/2] Add example usage --- cli/README.md | 6 ++++++ cli/script/command-parser.ts | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cli/README.md b/cli/README.md index a11a33e89..1b82597ca 100644 --- a/cli/README.md +++ b/cli/README.md @@ -204,6 +204,12 @@ If having a staging and production version of your app is enough to meet your ne code-push-standalone deployment add ``` +If you want to re-use an existing deployment key, you can do this with: + +``` +code-push-standalone deployment add -k +``` + Just like with apps, you can remove and rename deployments as well, using the following commands respectively: ``` diff --git a/cli/script/command-parser.ts b/cli/script/command-parser.ts index b29c4409f..43b8b391e 100644 --- a/cli/script/command-parser.ts +++ b/cli/script/command-parser.ts @@ -377,7 +377,14 @@ yargs yargs .usage(USAGE_PREFIX + " deployment add ") .demand(/*count*/ 2, /*max*/ 2) // Require exactly two non-option arguments - .example("deployment add MyApp MyDeployment", 'Adds deployment "MyDeployment" to app "MyApp"'); + .example("deployment add MyApp MyDeployment", 'Adds deployment "MyDeployment" to app "MyApp"') + .example("deployment add MyApp MyDeployment -k abc123", 'Adds deployment key "abc123"') + .option("key", { + alias: "k", + demand: false, + description: "Specify deployment key", + type: "string", + }); addCommonConfiguration(yargs); })