Skip to content

Commit 08e97d7

Browse files
gravgravsg
andauthored
Add deployment: allow specifying deployment key (#60)
When migrating an existing app to the stand-alone server, it makes sense to re-use existing deployment keys. The Rest API already allows for explicitly specifying deployment key, so this PR just adds an optional argument to the `deployment add` command. Example usage: ```bash code-push-standalone deployment add my-app prod existing-key-abc123 ``` --------- Co-authored-by: Mikkel Gravgaard <[email protected]>
1 parent 720dc66 commit 08e97d7

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

cli/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@ If having a staging and production version of your app is enough to meet your ne
204204
code-push-standalone deployment add <appName> <deploymentName>
205205
```
206206

207+
If you want to re-use an existing deployment key, you can do this with:
208+
209+
```
210+
code-push-standalone deployment add <appName> <deploymentName> -k <existing-deployment-key>
211+
```
212+
207213
Just like with apps, you can remove and rename deployments as well, using the following commands respectively:
208214

209215
```

cli/script/command-executor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ function deleteFolder(folderPath: string): Promise<void> {
290290
}
291291

292292
function deploymentAdd(command: cli.IDeploymentAddCommand): Promise<void> {
293-
return sdk.addDeployment(command.appName, command.deploymentName).then((deployment: Deployment): void => {
293+
return sdk.addDeployment(command.appName, command.deploymentName, command.key).then((deployment: Deployment): void => {
294294
log(
295295
'Successfully added the "' +
296296
command.deploymentName +

cli/script/command-parser.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,14 @@ yargs
377377
yargs
378378
.usage(USAGE_PREFIX + " deployment add <appName> <deploymentName>")
379379
.demand(/*count*/ 2, /*max*/ 2) // Require exactly two non-option arguments
380-
.example("deployment add MyApp MyDeployment", 'Adds deployment "MyDeployment" to app "MyApp"');
380+
.example("deployment add MyApp MyDeployment", 'Adds deployment "MyDeployment" to app "MyApp"')
381+
.example("deployment add MyApp MyDeployment -k abc123", 'Adds deployment key "abc123"')
382+
.option("key", {
383+
alias: "k",
384+
demand: false,
385+
description: "Specify deployment key",
386+
type: "string",
387+
});
381388

382389
addCommonConfiguration(yargs);
383390
})
@@ -1046,6 +1053,10 @@ export function createCommand(): cli.ICommand {
10461053

10471054
deploymentAddCommand.appName = arg2;
10481055
deploymentAddCommand.deploymentName = arg3;
1056+
if(argv["key"]){
1057+
deploymentAddCommand.key = argv["key"] as any;
1058+
}
1059+
10491060
}
10501061
break;
10511062

cli/script/management-sdk.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ class AccountManager {
253253
}
254254

255255
// Deployments
256-
public addDeployment(appName: string, deploymentName: string): Promise<Deployment> {
257-
const deployment = <Deployment>{ name: deploymentName };
256+
public addDeployment(appName: string, deploymentName: string, deploymentKey?: string): Promise<Deployment> {
257+
const deployment = <Deployment>{ name: deploymentName, key: deploymentKey };
258258
return this.post(urlEncode([`/apps/${appName}/deployments/`]), JSON.stringify(deployment), /*expectResponseBody=*/ true).then(
259259
(res: JsonResponse) => res.body.deployment
260260
);

cli/script/types/cli.ts

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export interface IDebugCommand extends ICommand {
107107
export interface IDeploymentAddCommand extends ICommand {
108108
appName: string;
109109
deploymentName: string;
110+
key?: string;
110111
default: boolean;
111112
}
112113

0 commit comments

Comments
 (0)