Skip to content

Commit

Permalink
Add deployment: allow specifying deployment key (#60)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
grav and gravsg authored Jan 6, 2025
1 parent 720dc66 commit 08e97d7
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
6 changes: 6 additions & 0 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <appName> <deploymentName>
```

If you want to re-use an existing deployment key, you can do this with:

```
code-push-standalone deployment add <appName> <deploymentName> -k <existing-deployment-key>
```

Just like with apps, you can remove and rename deployments as well, using the following commands respectively:

```
Expand Down
2 changes: 1 addition & 1 deletion cli/script/command-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ function deleteFolder(folderPath: string): Promise<void> {
}

function deploymentAdd(command: cli.IDeploymentAddCommand): Promise<void> {
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 +
Expand Down
13 changes: 12 additions & 1 deletion cli/script/command-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,14 @@ yargs
yargs
.usage(USAGE_PREFIX + " deployment add <appName> <deploymentName>")
.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);
})
Expand Down Expand Up @@ -1046,6 +1053,10 @@ export function createCommand(): cli.ICommand {

deploymentAddCommand.appName = arg2;
deploymentAddCommand.deploymentName = arg3;
if(argv["key"]){
deploymentAddCommand.key = argv["key"] as any;
}

}
break;

Expand Down
4 changes: 2 additions & 2 deletions cli/script/management-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ class AccountManager {
}

// Deployments
public addDeployment(appName: string, deploymentName: string): Promise<Deployment> {
const deployment = <Deployment>{ name: deploymentName };
public addDeployment(appName: string, deploymentName: string, deploymentKey?: string): Promise<Deployment> {
const deployment = <Deployment>{ name: deploymentName, key: deploymentKey };
return this.post(urlEncode([`/apps/${appName}/deployments/`]), JSON.stringify(deployment), /*expectResponseBody=*/ true).then(
(res: JsonResponse) => res.body.deployment
);
Expand Down
1 change: 1 addition & 0 deletions cli/script/types/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export interface IDebugCommand extends ICommand {
export interface IDeploymentAddCommand extends ICommand {
appName: string;
deploymentName: string;
key?: string;
default: boolean;
}

Expand Down

0 comments on commit 08e97d7

Please sign in to comment.