@appcircle/codepush-cli 0.0.2 → 0.0.3-alpha.1
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/bin/script/command-executor.js +16 -0
- package/bin/script/command-parser.js +13 -0
- package/bin/script/management-sdk.js +3 -0
- package/bin/script/types/cli.js +22 -21
- package/package.json +1 -1
- package/script/command-executor.ts +20 -0
- package/script/command-parser.ts +15 -1
- package/script/management-sdk.ts +5 -0
- package/script/types/cli.ts +5 -0
- package/script/types/rest-definitions.ts +6 -0
|
@@ -133,6 +133,11 @@ function appList(command) {
|
|
|
133
133
|
printAppList(command.format, retrievedApps);
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
+
function appDeploymentKeyList(command) {
|
|
137
|
+
return exports.sdk.getDeploymentKeys(command.appName).then((retrievedKeys) => {
|
|
138
|
+
printAppDeploymentKeyList(retrievedKeys);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
136
141
|
function appRemove(command) {
|
|
137
142
|
return (0, exports.confirm)("Are you sure you want to remove this app? Note that its deployment keys will be PERMANENTLY unrecoverable.").then((wasConfirmed) => {
|
|
138
143
|
if (wasConfirmed) {
|
|
@@ -368,6 +373,8 @@ function execute(command) {
|
|
|
368
373
|
return appAdd(command);
|
|
369
374
|
case cli.CommandType.appList:
|
|
370
375
|
return appList(command);
|
|
376
|
+
case cli.CommandType.appDeploymentKeyList:
|
|
377
|
+
return appDeploymentKeyList(command);
|
|
371
378
|
case cli.CommandType.appRemove:
|
|
372
379
|
return appRemove(command);
|
|
373
380
|
case cli.CommandType.appRename:
|
|
@@ -514,6 +521,15 @@ function printAppList(format, apps) {
|
|
|
514
521
|
});
|
|
515
522
|
}
|
|
516
523
|
}
|
|
524
|
+
function printAppDeploymentKeyList(deploymentKeys) {
|
|
525
|
+
const headers = ["Name", "Deployment Key"];
|
|
526
|
+
printTable(headers, (dataSource) => {
|
|
527
|
+
deploymentKeys.forEach((deploymentKey, index) => {
|
|
528
|
+
const row = [deploymentKey.name, wordwrap(50)(deploymentKey.deploymentKey)];
|
|
529
|
+
dataSource.push(row);
|
|
530
|
+
});
|
|
531
|
+
});
|
|
532
|
+
}
|
|
517
533
|
function getCollaboratorDisplayName(email, collaboratorProperties) {
|
|
518
534
|
return collaboratorProperties.permission === AccountManager.AppPermission.OWNER ? email + chalk.magenta(" (Owner)") : email;
|
|
519
535
|
}
|
|
@@ -120,6 +120,14 @@ function appRemove(commandName, yargs) {
|
|
|
120
120
|
.example("app " + commandName + " MyApp", 'Removes app "MyApp"');
|
|
121
121
|
addCommonConfiguration(yargs);
|
|
122
122
|
}
|
|
123
|
+
function appDeploymentKeyList(commandName, yargs) {
|
|
124
|
+
isValidCommand = true;
|
|
125
|
+
yargs
|
|
126
|
+
.usage(USAGE_PREFIX + " app " + commandName + " <appName>")
|
|
127
|
+
.demand(/*count*/ 1, /*max*/ 1) // Require exactly one non-option arguments
|
|
128
|
+
.example("app " + commandName + " MyApp", 'Lists the deployment keys for app "MyApp" in tabular format');
|
|
129
|
+
addCommonConfiguration(yargs);
|
|
130
|
+
}
|
|
123
131
|
function listCollaborators(commandName, yargs) {
|
|
124
132
|
isValidCommand = true;
|
|
125
133
|
yargs
|
|
@@ -268,6 +276,7 @@ yargs
|
|
|
268
276
|
})
|
|
269
277
|
.command("list", "Lists the apps associated with your account", (yargs) => appList("list", yargs))
|
|
270
278
|
.command("ls", "Lists the apps associated with your account", (yargs) => appList("ls", yargs))
|
|
279
|
+
.command("deployment-keys", "Lists the deployment keys for app", (yargs) => appDeploymentKeyList("deployment-keys", yargs))
|
|
271
280
|
.command("transfer", "Transfer the ownership of an app to another account", (yargs) => {
|
|
272
281
|
isValidCommand = true;
|
|
273
282
|
yargs
|
|
@@ -812,6 +821,10 @@ function createCommand() {
|
|
|
812
821
|
cmd = { type: cli.CommandType.appList };
|
|
813
822
|
cmd.format = argv["format"];
|
|
814
823
|
break;
|
|
824
|
+
case "deployment-keys":
|
|
825
|
+
cmd = { type: cli.CommandType.appDeploymentKeyList };
|
|
826
|
+
cmd.appName = arg2;
|
|
827
|
+
break;
|
|
815
828
|
case "remove":
|
|
816
829
|
case "rm":
|
|
817
830
|
if (arg2) {
|
|
@@ -190,6 +190,9 @@ class AccountManager {
|
|
|
190
190
|
getApp(appName) {
|
|
191
191
|
return this.get(urlEncode([`/apps/${appName}`])).then((res) => res.body.app);
|
|
192
192
|
}
|
|
193
|
+
getDeploymentKeys(appName) {
|
|
194
|
+
return this.get(urlEncode([`/apps/${appName}/deployment-keys`])).then((res) => res.body);
|
|
195
|
+
}
|
|
193
196
|
addApp(appName) {
|
|
194
197
|
const app = { name: appName };
|
|
195
198
|
return this.post(urlEncode(["/apps"]), JSON.stringify(app), /*expectResponseBody=*/ false).then(() => app);
|
package/bin/script/types/cli.js
CHANGED
|
@@ -11,25 +11,26 @@ var CommandType;
|
|
|
11
11
|
CommandType[CommandType["accessKeyRemove"] = 3] = "accessKeyRemove";
|
|
12
12
|
CommandType[CommandType["appAdd"] = 4] = "appAdd";
|
|
13
13
|
CommandType[CommandType["appList"] = 5] = "appList";
|
|
14
|
-
CommandType[CommandType["
|
|
15
|
-
CommandType[CommandType["
|
|
16
|
-
CommandType[CommandType["
|
|
17
|
-
CommandType[CommandType["
|
|
18
|
-
CommandType[CommandType["
|
|
19
|
-
CommandType[CommandType["
|
|
20
|
-
CommandType[CommandType["
|
|
21
|
-
CommandType[CommandType["
|
|
22
|
-
CommandType[CommandType["
|
|
23
|
-
CommandType[CommandType["
|
|
24
|
-
CommandType[CommandType["
|
|
25
|
-
CommandType[CommandType["
|
|
26
|
-
CommandType[CommandType["
|
|
27
|
-
CommandType[CommandType["
|
|
28
|
-
CommandType[CommandType["
|
|
29
|
-
CommandType[CommandType["
|
|
30
|
-
CommandType[CommandType["
|
|
31
|
-
CommandType[CommandType["
|
|
32
|
-
CommandType[CommandType["
|
|
33
|
-
CommandType[CommandType["
|
|
34
|
-
CommandType[CommandType["
|
|
14
|
+
CommandType[CommandType["appDeploymentKeyList"] = 6] = "appDeploymentKeyList";
|
|
15
|
+
CommandType[CommandType["appRemove"] = 7] = "appRemove";
|
|
16
|
+
CommandType[CommandType["appRename"] = 8] = "appRename";
|
|
17
|
+
CommandType[CommandType["debug"] = 9] = "debug";
|
|
18
|
+
CommandType[CommandType["deploymentAdd"] = 10] = "deploymentAdd";
|
|
19
|
+
CommandType[CommandType["deploymentHistory"] = 11] = "deploymentHistory";
|
|
20
|
+
CommandType[CommandType["deploymentHistoryClear"] = 12] = "deploymentHistoryClear";
|
|
21
|
+
CommandType[CommandType["deploymentList"] = 13] = "deploymentList";
|
|
22
|
+
CommandType[CommandType["deploymentMetrics"] = 14] = "deploymentMetrics";
|
|
23
|
+
CommandType[CommandType["deploymentRemove"] = 15] = "deploymentRemove";
|
|
24
|
+
CommandType[CommandType["deploymentRename"] = 16] = "deploymentRename";
|
|
25
|
+
CommandType[CommandType["link"] = 17] = "link";
|
|
26
|
+
CommandType[CommandType["login"] = 18] = "login";
|
|
27
|
+
CommandType[CommandType["logout"] = 19] = "logout";
|
|
28
|
+
CommandType[CommandType["patch"] = 20] = "patch";
|
|
29
|
+
CommandType[CommandType["promote"] = 21] = "promote";
|
|
30
|
+
CommandType[CommandType["register"] = 22] = "register";
|
|
31
|
+
CommandType[CommandType["release"] = 23] = "release";
|
|
32
|
+
CommandType[CommandType["releaseReact"] = 24] = "releaseReact";
|
|
33
|
+
CommandType[CommandType["rollback"] = 25] = "rollback";
|
|
34
|
+
CommandType[CommandType["sessionList"] = 26] = "sessionList";
|
|
35
|
+
CommandType[CommandType["sessionRemove"] = 27] = "sessionRemove";
|
|
35
36
|
})(CommandType || (exports.CommandType = CommandType = {}));
|
package/package.json
CHANGED
|
@@ -49,6 +49,7 @@ import {
|
|
|
49
49
|
isBinaryOrZip,
|
|
50
50
|
fileExists
|
|
51
51
|
} from "./utils/file-utils";
|
|
52
|
+
import { DeploymentKey } from "./types/rest-definitions";
|
|
52
53
|
|
|
53
54
|
const configFilePath: string = path.join(process.env.LOCALAPPDATA || process.env.HOME, ".code-push.config");
|
|
54
55
|
const emailValidator = require("email-validator");
|
|
@@ -196,6 +197,12 @@ function appList(command: cli.IAppListCommand): Promise<void> {
|
|
|
196
197
|
});
|
|
197
198
|
}
|
|
198
199
|
|
|
200
|
+
function appDeploymentKeyList(command: cli.IAppDeploymentKeysCommand): Promise<void> {
|
|
201
|
+
return sdk.getDeploymentKeys(command.appName).then((retrievedKeys: DeploymentKey[]): void => {
|
|
202
|
+
printAppDeploymentKeyList(retrievedKeys);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
199
206
|
function appRemove(command: cli.IAppRemoveCommand): Promise<void> {
|
|
200
207
|
return confirm("Are you sure you want to remove this app? Note that its deployment keys will be PERMANENTLY unrecoverable.").then(
|
|
201
208
|
(wasConfirmed: boolean): Promise<void> => {
|
|
@@ -481,6 +488,9 @@ export function execute(command: cli.ICommand) {
|
|
|
481
488
|
|
|
482
489
|
case cli.CommandType.appList:
|
|
483
490
|
return appList(<cli.IAppListCommand>command);
|
|
491
|
+
|
|
492
|
+
case cli.CommandType.appDeploymentKeyList:
|
|
493
|
+
return appDeploymentKeyList(<cli.IAppDeploymentKeysCommand>command);
|
|
484
494
|
|
|
485
495
|
case cli.CommandType.appRemove:
|
|
486
496
|
return appRemove(<cli.IAppRemoveCommand>command);
|
|
@@ -656,6 +666,16 @@ function printAppList(format: string, apps: App[]): void {
|
|
|
656
666
|
}
|
|
657
667
|
}
|
|
658
668
|
|
|
669
|
+
function printAppDeploymentKeyList(deploymentKeys: DeploymentKey[]): void {
|
|
670
|
+
const headers = ["Name", "Deployment Key"];
|
|
671
|
+
printTable(headers, (dataSource: any[]): void => {
|
|
672
|
+
deploymentKeys.forEach((deploymentKey: DeploymentKey, index: number): void => {
|
|
673
|
+
const row = [deploymentKey.name, wordwrap(50)(deploymentKey.deploymentKey)];
|
|
674
|
+
dataSource.push(row);
|
|
675
|
+
});
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
|
|
659
679
|
function getCollaboratorDisplayName(email: string, collaboratorProperties: CollaboratorProperties): string {
|
|
660
680
|
return collaboratorProperties.permission === AccountManager.AppPermission.OWNER ? email + chalk.magenta(" (Owner)") : email;
|
|
661
681
|
}
|
package/script/command-parser.ts
CHANGED
|
@@ -146,6 +146,16 @@ function appRemove(commandName: string, yargs: yargs.Argv): void {
|
|
|
146
146
|
addCommonConfiguration(yargs);
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
function appDeploymentKeyList(commandName: string, yargs: yargs.Argv): void {
|
|
150
|
+
isValidCommand = true;
|
|
151
|
+
yargs
|
|
152
|
+
.usage(USAGE_PREFIX + " app " + commandName + " <appName>")
|
|
153
|
+
.demand(/*count*/ 1, /*max*/ 1) // Require exactly one non-option arguments
|
|
154
|
+
.example("app " + commandName + " MyApp", 'Lists the deployment keys for app "MyApp" in tabular format');
|
|
155
|
+
|
|
156
|
+
addCommonConfiguration(yargs);
|
|
157
|
+
}
|
|
158
|
+
|
|
149
159
|
function listCollaborators(commandName: string, yargs: yargs.Argv): void {
|
|
150
160
|
isValidCommand = true;
|
|
151
161
|
yargs
|
|
@@ -321,6 +331,7 @@ yargs
|
|
|
321
331
|
})
|
|
322
332
|
.command("list", "Lists the apps associated with your account", (yargs: yargs.Argv) => appList("list", yargs))
|
|
323
333
|
.command("ls", "Lists the apps associated with your account", (yargs: yargs.Argv) => appList("ls", yargs))
|
|
334
|
+
.command("deployment-keys","Lists the deployment keys for app", (yargs:yargs.Argv) => appDeploymentKeyList("deployment-keys", yargs))
|
|
324
335
|
.command("transfer", "Transfer the ownership of an app to another account", (yargs: yargs.Argv) => {
|
|
325
336
|
isValidCommand = true;
|
|
326
337
|
yargs
|
|
@@ -953,7 +964,10 @@ export function createCommand(): cli.ICommand {
|
|
|
953
964
|
|
|
954
965
|
(<cli.IAppListCommand>cmd).format = argv["format"] as any;
|
|
955
966
|
break;
|
|
956
|
-
|
|
967
|
+
case "deployment-keys":
|
|
968
|
+
cmd = {type : cli.CommandType.appDeploymentKeyList};
|
|
969
|
+
(<cli.IAppDeploymentKeysCommand>cmd).appName = arg2;
|
|
970
|
+
break;
|
|
957
971
|
case "remove":
|
|
958
972
|
case "rm":
|
|
959
973
|
if (arg2) {
|
package/script/management-sdk.ts
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
ServerAccessKey,
|
|
29
29
|
Session,
|
|
30
30
|
} from "./types";
|
|
31
|
+
import { DeploymentKey } from "./types/rest-definitions";
|
|
31
32
|
|
|
32
33
|
const packageJson = require("../../package.json");
|
|
33
34
|
|
|
@@ -268,6 +269,10 @@ class AccountManager {
|
|
|
268
269
|
return this.get(urlEncode([`/apps/${appName}`])).then((res: JsonResponse) => res.body.app);
|
|
269
270
|
}
|
|
270
271
|
|
|
272
|
+
public getDeploymentKeys(appName: string): Promise<DeploymentKey[]> {
|
|
273
|
+
return this.get(urlEncode([`/apps/${appName}/deployment-keys`])).then((res: JsonResponse) => res.body);
|
|
274
|
+
}
|
|
275
|
+
|
|
271
276
|
public addApp(appName: string): Promise<App> {
|
|
272
277
|
const app: App = { name: appName };
|
|
273
278
|
return this.post(urlEncode(["/apps"]), JSON.stringify(app), /*expectResponseBody=*/ false).then(() => app);
|
package/script/types/cli.ts
CHANGED
|
@@ -10,6 +10,7 @@ export enum CommandType {
|
|
|
10
10
|
accessKeyRemove,
|
|
11
11
|
appAdd,
|
|
12
12
|
appList,
|
|
13
|
+
appDeploymentKeyList,
|
|
13
14
|
appRemove,
|
|
14
15
|
appRename,
|
|
15
16
|
debug,
|
|
@@ -70,6 +71,10 @@ export interface IAppRemoveCommand extends ICommand {
|
|
|
70
71
|
appName: string;
|
|
71
72
|
}
|
|
72
73
|
|
|
74
|
+
export interface IAppDeploymentKeysCommand extends ICommand {
|
|
75
|
+
appName: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
73
78
|
export interface IAppRenameCommand extends ICommand {
|
|
74
79
|
currentAppName: string;
|
|
75
80
|
newAppName: string;
|
|
@@ -126,6 +126,12 @@ export interface Deployment {
|
|
|
126
126
|
/*generated*/ package?: Package;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
/*out*/
|
|
130
|
+
export interface DeploymentKey {
|
|
131
|
+
/*generated key*/ deploymentKey?: string;
|
|
132
|
+
/*key*/ name: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
129
135
|
/*out*/
|
|
130
136
|
export interface BlobInfo {
|
|
131
137
|
size: number;
|