@appcircle/codepush-cli 0.0.2 → 0.0.3
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 -69
- package/bin/script/command-parser.js +13 -197
- package/bin/script/management-sdk.js +3 -0
- package/bin/script/types/cli.js +20 -27
- package/bin/test/cli.js +0 -198
- package/package.json +1 -1
- package/script/command-executor.ts +20 -87
- package/script/command-parser.ts +15 -243
- package/script/management-sdk.ts +5 -0
- package/script/types/cli.ts +6 -9
- package/script/types/rest-definitions.ts +6 -0
- package/test/cli.ts +0 -249
package/script/command-parser.ts
CHANGED
|
@@ -34,84 +34,6 @@ export function showHelp(showRootDescription?: boolean): void {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
function accessKeyAdd(commandName: string, yargs: yargs.Argv): void {
|
|
38
|
-
isValidCommand = true;
|
|
39
|
-
yargs
|
|
40
|
-
.usage(USAGE_PREFIX + " access-key " + commandName + " <accessKeyName>")
|
|
41
|
-
.demand(/*count*/ 1, /*max*/ 1) // Require exactly one non-option arguments
|
|
42
|
-
.example(
|
|
43
|
-
"access-key " + commandName + ' "VSTS Integration"',
|
|
44
|
-
'Creates a new access key with the name "VSTS Integration", which expires in 60 days'
|
|
45
|
-
)
|
|
46
|
-
.example(
|
|
47
|
-
"access-key " + commandName + ' "One time key" --ttl 5m',
|
|
48
|
-
'Creates a new access key with the name "One time key", which expires in 5 minutes'
|
|
49
|
-
)
|
|
50
|
-
.option("ttl", {
|
|
51
|
-
default: "60d",
|
|
52
|
-
demand: false,
|
|
53
|
-
description: "Duration string which specifies the amount of time that the access key should remain valid for (e.g 5m, 60d, 1y)",
|
|
54
|
-
type: "string",
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
addCommonConfiguration(yargs);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function accessKeyPatch(commandName: string, yargs: yargs.Argv): void {
|
|
61
|
-
isValidCommand = true;
|
|
62
|
-
yargs
|
|
63
|
-
.usage(USAGE_PREFIX + " access-key " + commandName + " <accessKeyName>")
|
|
64
|
-
.demand(/*count*/ 1, /*max*/ 1) // Require exactly one non-option arguments
|
|
65
|
-
.example(
|
|
66
|
-
"access-key " + commandName + ' "Key for build server" --name "Key for CI machine"',
|
|
67
|
-
'Renames the access key named "Key for build server" to "Key for CI machine"'
|
|
68
|
-
)
|
|
69
|
-
.example(
|
|
70
|
-
"access-key " + commandName + ' "Key for build server" --ttl 7d',
|
|
71
|
-
'Updates the access key named "Key for build server" to expire in 7 days'
|
|
72
|
-
)
|
|
73
|
-
.option("name", {
|
|
74
|
-
default: null,
|
|
75
|
-
demand: false,
|
|
76
|
-
description: "Display name for the access key",
|
|
77
|
-
type: "string",
|
|
78
|
-
})
|
|
79
|
-
.option("ttl", {
|
|
80
|
-
default: null,
|
|
81
|
-
demand: false,
|
|
82
|
-
description: "Duration string which specifies the amount of time that the access key should remain valid for (e.g 5m, 60d, 1y)",
|
|
83
|
-
type: "string",
|
|
84
|
-
});
|
|
85
|
-
addCommonConfiguration(yargs);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function accessKeyList(commandName: string, yargs: yargs.Argv): void {
|
|
89
|
-
isValidCommand = true;
|
|
90
|
-
yargs
|
|
91
|
-
.usage(USAGE_PREFIX + " access-key " + commandName + " [options]")
|
|
92
|
-
.demand(/*count*/ 0, /*max*/ 0)
|
|
93
|
-
.example("access-key " + commandName, "Lists your access keys in tabular format")
|
|
94
|
-
.example("access-key " + commandName + " --format json", "Lists your access keys in JSON format")
|
|
95
|
-
.option("format", {
|
|
96
|
-
default: "table",
|
|
97
|
-
demand: false,
|
|
98
|
-
description: 'Output format to display your access keys with ("json" or "table")',
|
|
99
|
-
type: "string",
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
addCommonConfiguration(yargs);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function accessKeyRemove(commandName: string, yargs: yargs.Argv): void {
|
|
106
|
-
isValidCommand = true;
|
|
107
|
-
yargs
|
|
108
|
-
.usage(USAGE_PREFIX + " access-key " + commandName + " <accessKeyName>")
|
|
109
|
-
.demand(/*count*/ 1, /*max*/ 1) // Require exactly one non-option arguments
|
|
110
|
-
.example("access-key " + commandName + ' "VSTS Integration"', 'Removes the "VSTS Integration" access key');
|
|
111
|
-
|
|
112
|
-
addCommonConfiguration(yargs);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
37
|
function addCommonConfiguration(yargs: yargs.Argv): void {
|
|
116
38
|
yargs
|
|
117
39
|
.wrap(/*columnLimit*/ null)
|
|
@@ -146,6 +68,16 @@ function appRemove(commandName: string, yargs: yargs.Argv): void {
|
|
|
146
68
|
addCommonConfiguration(yargs);
|
|
147
69
|
}
|
|
148
70
|
|
|
71
|
+
function appDeploymentKeyList(commandName: string, yargs: yargs.Argv): void {
|
|
72
|
+
isValidCommand = true;
|
|
73
|
+
yargs
|
|
74
|
+
.usage(USAGE_PREFIX + " app " + commandName + " <appName>")
|
|
75
|
+
.demand(/*count*/ 1, /*max*/ 1) // Require exactly one non-option arguments
|
|
76
|
+
.example("app " + commandName + " MyApp", 'Lists the deployment keys for app "MyApp" in tabular format');
|
|
77
|
+
|
|
78
|
+
addCommonConfiguration(yargs);
|
|
79
|
+
}
|
|
80
|
+
|
|
149
81
|
function listCollaborators(commandName: string, yargs: yargs.Argv): void {
|
|
150
82
|
isValidCommand = true;
|
|
151
83
|
yargs
|
|
@@ -173,33 +105,6 @@ function removeCollaborator(commandName: string, yargs: yargs.Argv): void {
|
|
|
173
105
|
addCommonConfiguration(yargs);
|
|
174
106
|
}
|
|
175
107
|
|
|
176
|
-
function sessionList(commandName: string, yargs: yargs.Argv): void {
|
|
177
|
-
isValidCommand = true;
|
|
178
|
-
yargs
|
|
179
|
-
.usage(USAGE_PREFIX + " session " + commandName + " [options]")
|
|
180
|
-
.demand(/*count*/ 0, /*max*/ 0)
|
|
181
|
-
.example("session " + commandName, "Lists your sessions in tabular format")
|
|
182
|
-
.example("session " + commandName + " --format json", "Lists your login sessions in JSON format")
|
|
183
|
-
.option("format", {
|
|
184
|
-
default: "table",
|
|
185
|
-
demand: false,
|
|
186
|
-
description: 'Output format to display your login sessions with ("json" or "table")',
|
|
187
|
-
type: "string",
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
addCommonConfiguration(yargs);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function sessionRemove(commandName: string, yargs: yargs.Argv): void {
|
|
194
|
-
isValidCommand = true;
|
|
195
|
-
yargs
|
|
196
|
-
.usage(USAGE_PREFIX + " session " + commandName + " <machineName>")
|
|
197
|
-
.demand(/*count*/ 1, /*max*/ 1) // Require exactly one non-option arguments
|
|
198
|
-
.example("session " + commandName + ' "John\'s PC"', 'Removes the existing login session from "John\'s PC"');
|
|
199
|
-
|
|
200
|
-
addCommonConfiguration(yargs);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
108
|
function deploymentHistoryClear(commandName: string, yargs: yargs.Argv): void {
|
|
204
109
|
isValidCommand = true;
|
|
205
110
|
yargs
|
|
@@ -279,21 +184,6 @@ function deploymentHistory(commandName: string, yargs: yargs.Argv): void {
|
|
|
279
184
|
yargs
|
|
280
185
|
.usage(USAGE_PREFIX + " <command>")
|
|
281
186
|
.demand(/*count*/ 1, /*max*/ 1) // Require exactly one non-option argument.
|
|
282
|
-
.command("access-key", "View and manage the access keys associated with your account", (yargs: yargs.Argv) => {
|
|
283
|
-
isValidCommandCategory = true;
|
|
284
|
-
yargs
|
|
285
|
-
.usage(USAGE_PREFIX + " access-key <command>")
|
|
286
|
-
.demand(/*count*/ 2, /*max*/ 2) // Require exactly two non-option arguments.
|
|
287
|
-
.command("add", "Create a new access key associated with your account", (yargs: yargs.Argv) => accessKeyAdd("add", yargs))
|
|
288
|
-
.command("patch", "Update the name and/or TTL of an existing access key", (yargs: yargs.Argv) => accessKeyPatch("patch", yargs))
|
|
289
|
-
.command("remove", "Remove an existing access key", (yargs: yargs.Argv) => accessKeyRemove("remove", yargs))
|
|
290
|
-
.command("rm", "Remove an existing access key", (yargs: yargs.Argv) => accessKeyRemove("rm", yargs))
|
|
291
|
-
.command("list", "List the access keys associated with your account", (yargs: yargs.Argv) => accessKeyList("list", yargs))
|
|
292
|
-
.command("ls", "List the access keys associated with your account", (yargs: yargs.Argv) => accessKeyList("ls", yargs))
|
|
293
|
-
.check((argv: any, aliases: { [aliases: string]: string }): any => isValidCommand); // Report unrecognized, non-hyphenated command category.
|
|
294
|
-
|
|
295
|
-
addCommonConfiguration(yargs);
|
|
296
|
-
})
|
|
297
187
|
.command("app", "View and manage your CodePush apps", (yargs: yargs.Argv) => {
|
|
298
188
|
isValidCommandCategory = true;
|
|
299
189
|
yargs
|
|
@@ -321,6 +211,7 @@ yargs
|
|
|
321
211
|
})
|
|
322
212
|
.command("list", "Lists the apps associated with your account", (yargs: yargs.Argv) => appList("list", yargs))
|
|
323
213
|
.command("ls", "Lists the apps associated with your account", (yargs: yargs.Argv) => appList("ls", yargs))
|
|
214
|
+
.command("deployment-keys","Lists the deployment keys for app", (yargs:yargs.Argv) => appDeploymentKeyList("deployment-keys", yargs))
|
|
324
215
|
.command("transfer", "Transfer the ownership of an app to another account", (yargs: yargs.Argv) => {
|
|
325
216
|
isValidCommand = true;
|
|
326
217
|
yargs
|
|
@@ -391,17 +282,6 @@ yargs
|
|
|
391
282
|
|
|
392
283
|
addCommonConfiguration(yargs);
|
|
393
284
|
})
|
|
394
|
-
.command("link", "Link an additional authentication provider (e.g. GitHub) to an existing CodePush account", (yargs: yargs.Argv) => {
|
|
395
|
-
isValidCommandCategory = true;
|
|
396
|
-
isValidCommand = true;
|
|
397
|
-
yargs
|
|
398
|
-
.usage(USAGE_PREFIX + " link")
|
|
399
|
-
.demand(/*count*/ 0, /*max*/ 1) //set 'max' to one to allow usage of serverUrl undocument parameter for testing
|
|
400
|
-
.example("link", "Links an account on the CodePush server")
|
|
401
|
-
.check((argv: any, aliases: { [aliases: string]: string }): any => isValidCommand); // Report unrecognized, non-hyphenated command category.
|
|
402
|
-
|
|
403
|
-
addCommonConfiguration(yargs);
|
|
404
|
-
})
|
|
405
285
|
.command("login", "Authenticate with the CodePush server in order to begin managing your apps", (yargs: yargs.Argv) => {
|
|
406
286
|
isValidCommandCategory = true;
|
|
407
287
|
isValidCommand = true;
|
|
@@ -579,17 +459,6 @@ yargs
|
|
|
579
459
|
|
|
580
460
|
addCommonConfiguration(yargs);
|
|
581
461
|
})
|
|
582
|
-
.command("register", "Register a new CodePush account", (yargs: yargs.Argv) => {
|
|
583
|
-
isValidCommandCategory = true;
|
|
584
|
-
isValidCommand = true;
|
|
585
|
-
yargs
|
|
586
|
-
.usage(USAGE_PREFIX + " register")
|
|
587
|
-
.demand(/*count*/ 0, /*max*/ 1) //set 'max' to one to allow usage of serverUrl undocument parameter for testing
|
|
588
|
-
.example("register", "Registers a new CodePush account")
|
|
589
|
-
.check((argv: any, aliases: { [aliases: string]: string }): any => isValidCommand); // Report unrecognized, non-hyphenated command category.
|
|
590
|
-
|
|
591
|
-
addCommonConfiguration(yargs);
|
|
592
|
-
})
|
|
593
462
|
.command("release", "Release an update to an app deployment", (yargs: yargs.Argv) => {
|
|
594
463
|
yargs
|
|
595
464
|
.usage(USAGE_PREFIX + " release <appName> <updateContentsPath> <targetBinaryVersion> [options]")
|
|
@@ -853,21 +722,6 @@ yargs
|
|
|
853
722
|
|
|
854
723
|
addCommonConfiguration(yargs);
|
|
855
724
|
})
|
|
856
|
-
.command("session", "View and manage the current login sessions associated with your account", (yargs: yargs.Argv) => {
|
|
857
|
-
isValidCommandCategory = true;
|
|
858
|
-
yargs
|
|
859
|
-
.usage(USAGE_PREFIX + " session <command>")
|
|
860
|
-
.demand(/*count*/ 2, /*max*/ 2) // Require exactly two non-option arguments.
|
|
861
|
-
.command("remove", "Remove an existing login session", (yargs: yargs.Argv) => sessionRemove("remove", yargs))
|
|
862
|
-
.command("rm", "Remove an existing login session", (yargs: yargs.Argv) => sessionRemove("rm", yargs))
|
|
863
|
-
.command("list", "List the current login sessions associated with your account", (yargs: yargs.Argv) =>
|
|
864
|
-
sessionList("list", yargs)
|
|
865
|
-
)
|
|
866
|
-
.command("ls", "List the current login sessions associated with your account", (yargs: yargs.Argv) => sessionList("ls", yargs))
|
|
867
|
-
.check((argv: any, aliases: { [aliases: string]: string }): any => isValidCommand); // Report unrecognized, non-hyphenated command category.
|
|
868
|
-
|
|
869
|
-
addCommonConfiguration(yargs);
|
|
870
|
-
})
|
|
871
725
|
.alias("v", "version")
|
|
872
726
|
.version(packageJson.version)
|
|
873
727
|
.wrap(/*columnLimit*/ null)
|
|
@@ -887,56 +741,6 @@ export function createCommand(): cli.ICommand {
|
|
|
887
741
|
const arg4: any = argv._[4];
|
|
888
742
|
|
|
889
743
|
switch (arg0) {
|
|
890
|
-
case "access-key":
|
|
891
|
-
switch (arg1) {
|
|
892
|
-
case "add":
|
|
893
|
-
if (arg2) {
|
|
894
|
-
cmd = { type: cli.CommandType.accessKeyAdd };
|
|
895
|
-
const accessKeyAddCmd = <cli.IAccessKeyAddCommand>cmd;
|
|
896
|
-
accessKeyAddCmd.name = arg2;
|
|
897
|
-
const ttlOption: string = argv["ttl"] as any;
|
|
898
|
-
if (isDefined(ttlOption)) {
|
|
899
|
-
accessKeyAddCmd.ttl = parseDurationMilliseconds(ttlOption);
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
break;
|
|
903
|
-
|
|
904
|
-
case "patch":
|
|
905
|
-
if (arg2) {
|
|
906
|
-
cmd = { type: cli.CommandType.accessKeyPatch };
|
|
907
|
-
const accessKeyPatchCmd = <cli.IAccessKeyPatchCommand>cmd;
|
|
908
|
-
accessKeyPatchCmd.oldName = arg2;
|
|
909
|
-
|
|
910
|
-
const newNameOption: string = argv["name"] as any;
|
|
911
|
-
const ttlOption: string = argv["ttl"] as any;
|
|
912
|
-
if (isDefined(newNameOption)) {
|
|
913
|
-
accessKeyPatchCmd.newName = newNameOption;
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
if (isDefined(ttlOption)) {
|
|
917
|
-
accessKeyPatchCmd.ttl = parseDurationMilliseconds(ttlOption);
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
break;
|
|
921
|
-
|
|
922
|
-
case "list":
|
|
923
|
-
case "ls":
|
|
924
|
-
cmd = { type: cli.CommandType.accessKeyList };
|
|
925
|
-
|
|
926
|
-
(<cli.IAccessKeyListCommand>cmd).format = argv["format"] as any;
|
|
927
|
-
break;
|
|
928
|
-
|
|
929
|
-
case "remove":
|
|
930
|
-
case "rm":
|
|
931
|
-
if (arg2) {
|
|
932
|
-
cmd = { type: cli.CommandType.accessKeyRemove };
|
|
933
|
-
|
|
934
|
-
(<cli.IAccessKeyRemoveCommand>cmd).accessKey = arg2;
|
|
935
|
-
}
|
|
936
|
-
break;
|
|
937
|
-
}
|
|
938
|
-
break;
|
|
939
|
-
|
|
940
744
|
case "app":
|
|
941
745
|
switch (arg1) {
|
|
942
746
|
case "add":
|
|
@@ -953,7 +757,10 @@ export function createCommand(): cli.ICommand {
|
|
|
953
757
|
|
|
954
758
|
(<cli.IAppListCommand>cmd).format = argv["format"] as any;
|
|
955
759
|
break;
|
|
956
|
-
|
|
760
|
+
case "deployment-keys":
|
|
761
|
+
cmd = {type : cli.CommandType.appDeploymentKeyList};
|
|
762
|
+
(<cli.IAppDeploymentKeysCommand>cmd).appName = arg2;
|
|
763
|
+
break;
|
|
957
764
|
case "remove":
|
|
958
765
|
case "rm":
|
|
959
766
|
if (arg2) {
|
|
@@ -1065,13 +872,6 @@ export function createCommand(): cli.ICommand {
|
|
|
1065
872
|
}
|
|
1066
873
|
break;
|
|
1067
874
|
|
|
1068
|
-
case "link":
|
|
1069
|
-
cmd = <cli.ILinkCommand>{
|
|
1070
|
-
type: cli.CommandType.link,
|
|
1071
|
-
serverUrl: getServerUrl(arg1),
|
|
1072
|
-
};
|
|
1073
|
-
break;
|
|
1074
|
-
|
|
1075
875
|
case "login":
|
|
1076
876
|
cmd = { type: cli.CommandType.login };
|
|
1077
877
|
|
|
@@ -1124,14 +924,6 @@ export function createCommand(): cli.ICommand {
|
|
|
1124
924
|
}
|
|
1125
925
|
break;
|
|
1126
926
|
|
|
1127
|
-
case "register":
|
|
1128
|
-
cmd = { type: cli.CommandType.register };
|
|
1129
|
-
|
|
1130
|
-
const registerCommand = <cli.IRegisterCommand>cmd;
|
|
1131
|
-
|
|
1132
|
-
registerCommand.serverUrl = getServerUrl(arg1);
|
|
1133
|
-
break;
|
|
1134
|
-
|
|
1135
927
|
case "release":
|
|
1136
928
|
if (arg1 && arg2 && arg3) {
|
|
1137
929
|
cmd = { type: cli.CommandType.release };
|
|
@@ -1195,26 +987,6 @@ export function createCommand(): cli.ICommand {
|
|
|
1195
987
|
rollbackCommand.targetRelease = argv["targetRelease"] as any;
|
|
1196
988
|
}
|
|
1197
989
|
break;
|
|
1198
|
-
|
|
1199
|
-
case "session":
|
|
1200
|
-
switch (arg1) {
|
|
1201
|
-
case "list":
|
|
1202
|
-
case "ls":
|
|
1203
|
-
cmd = { type: cli.CommandType.sessionList };
|
|
1204
|
-
|
|
1205
|
-
(<cli.ISessionListCommand>cmd).format = argv["format"] as any;
|
|
1206
|
-
break;
|
|
1207
|
-
|
|
1208
|
-
case "remove":
|
|
1209
|
-
case "rm":
|
|
1210
|
-
if (arg2) {
|
|
1211
|
-
cmd = { type: cli.CommandType.sessionRemove };
|
|
1212
|
-
|
|
1213
|
-
(<cli.ISessionRemoveCommand>cmd).machineName = arg2;
|
|
1214
|
-
}
|
|
1215
|
-
break;
|
|
1216
|
-
}
|
|
1217
|
-
break;
|
|
1218
990
|
}
|
|
1219
991
|
|
|
1220
992
|
return cmd;
|
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
|
@@ -4,12 +4,9 @@
|
|
|
4
4
|
import AccountManager = require("../management-sdk");
|
|
5
5
|
|
|
6
6
|
export enum CommandType {
|
|
7
|
-
accessKeyAdd,
|
|
8
|
-
accessKeyPatch,
|
|
9
|
-
accessKeyList,
|
|
10
|
-
accessKeyRemove,
|
|
11
7
|
appAdd,
|
|
12
8
|
appList,
|
|
9
|
+
appDeploymentKeyList,
|
|
13
10
|
appRemove,
|
|
14
11
|
appRename,
|
|
15
12
|
debug,
|
|
@@ -20,17 +17,13 @@ export enum CommandType {
|
|
|
20
17
|
deploymentMetrics,
|
|
21
18
|
deploymentRemove,
|
|
22
19
|
deploymentRename,
|
|
23
|
-
link,
|
|
24
20
|
login,
|
|
25
21
|
logout,
|
|
26
22
|
patch,
|
|
27
23
|
promote,
|
|
28
|
-
register,
|
|
29
24
|
release,
|
|
30
25
|
releaseReact,
|
|
31
|
-
rollback
|
|
32
|
-
sessionList,
|
|
33
|
-
sessionRemove
|
|
26
|
+
rollback
|
|
34
27
|
}
|
|
35
28
|
|
|
36
29
|
export interface ICommand {
|
|
@@ -70,6 +63,10 @@ export interface IAppRemoveCommand extends ICommand {
|
|
|
70
63
|
appName: string;
|
|
71
64
|
}
|
|
72
65
|
|
|
66
|
+
export interface IAppDeploymentKeysCommand extends ICommand {
|
|
67
|
+
appName: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
73
70
|
export interface IAppRenameCommand extends ICommand {
|
|
74
71
|
currentAppName: string;
|
|
75
72
|
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;
|
package/test/cli.ts
CHANGED
|
@@ -298,173 +298,6 @@ describe("CLI", () => {
|
|
|
298
298
|
sandbox.restore();
|
|
299
299
|
});
|
|
300
300
|
|
|
301
|
-
it("accessKeyAdd creates access key with name and default ttl", (done: Mocha.Done): void => {
|
|
302
|
-
var command: cli.IAccessKeyAddCommand = {
|
|
303
|
-
type: cli.CommandType.accessKeyAdd,
|
|
304
|
-
name: "Test name",
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
cmdexec.execute(command).done((): void => {
|
|
308
|
-
sinon.assert.calledTwice(log);
|
|
309
|
-
assert.equal(log.args[0].length, 1);
|
|
310
|
-
|
|
311
|
-
var actual: string = log.args[0][0];
|
|
312
|
-
var expected = `Successfully created the "Test name" access key: key123`;
|
|
313
|
-
assert.equal(actual, expected);
|
|
314
|
-
|
|
315
|
-
actual = log.args[1][0];
|
|
316
|
-
expected = "Make sure to save this key value somewhere safe, since you won't be able to view it from the CLI again!";
|
|
317
|
-
assert.equal(actual, expected);
|
|
318
|
-
|
|
319
|
-
done();
|
|
320
|
-
});
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
it("accessKeyAdd creates access key with name and specified ttl", (done: Mocha.Done): void => {
|
|
324
|
-
var ttl = 10000;
|
|
325
|
-
var command: cli.IAccessKeyAddCommand = {
|
|
326
|
-
type: cli.CommandType.accessKeyAdd,
|
|
327
|
-
name: "Test name",
|
|
328
|
-
ttl,
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
cmdexec.execute(command).done((): void => {
|
|
332
|
-
sinon.assert.calledTwice(log);
|
|
333
|
-
assert.equal(log.args[0].length, 1);
|
|
334
|
-
|
|
335
|
-
var actual: string = log.args[0][0];
|
|
336
|
-
var expected = `Successfully created the "Test name" access key: key123`;
|
|
337
|
-
assert.equal(actual, expected);
|
|
338
|
-
|
|
339
|
-
actual = log.args[1][0];
|
|
340
|
-
expected = "Make sure to save this key value somewhere safe, since you won't be able to view it from the CLI again!";
|
|
341
|
-
assert.equal(actual, expected);
|
|
342
|
-
|
|
343
|
-
done();
|
|
344
|
-
});
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
it("accessKeyPatch updates access key with new name", (done: Mocha.Done): void => {
|
|
348
|
-
var command: cli.IAccessKeyPatchCommand = {
|
|
349
|
-
type: cli.CommandType.accessKeyPatch,
|
|
350
|
-
oldName: "Test name",
|
|
351
|
-
newName: "Updated name",
|
|
352
|
-
};
|
|
353
|
-
|
|
354
|
-
cmdexec.execute(command).done((): void => {
|
|
355
|
-
sinon.assert.calledOnce(log);
|
|
356
|
-
assert.equal(log.args[0].length, 1);
|
|
357
|
-
|
|
358
|
-
var actual: string = log.args[0][0];
|
|
359
|
-
var expected = `Successfully renamed the access key "Test name" to "Updated name".`;
|
|
360
|
-
|
|
361
|
-
assert.equal(actual, expected);
|
|
362
|
-
done();
|
|
363
|
-
});
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
it("accessKeyPatch updates access key with new ttl", (done: Mocha.Done): void => {
|
|
367
|
-
var ttl = 10000;
|
|
368
|
-
var command: cli.IAccessKeyPatchCommand = {
|
|
369
|
-
type: cli.CommandType.accessKeyPatch,
|
|
370
|
-
oldName: "Test name",
|
|
371
|
-
ttl,
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
cmdexec.execute(command).done((): void => {
|
|
375
|
-
sinon.assert.calledOnce(log);
|
|
376
|
-
assert.equal(log.args[0].length, 1);
|
|
377
|
-
|
|
378
|
-
var actual: string = log.args[0][0];
|
|
379
|
-
var expected = `Successfully changed the expiration date of the "Test name" access key to Wednesday, August 17, 2016 12:07 PM.`;
|
|
380
|
-
|
|
381
|
-
assert.equal(actual, expected);
|
|
382
|
-
done();
|
|
383
|
-
});
|
|
384
|
-
});
|
|
385
|
-
|
|
386
|
-
it("accessKeyPatch updates access key with new name and ttl", (done: Mocha.Done): void => {
|
|
387
|
-
var ttl = 10000;
|
|
388
|
-
var command: cli.IAccessKeyPatchCommand = {
|
|
389
|
-
type: cli.CommandType.accessKeyPatch,
|
|
390
|
-
oldName: "Test name",
|
|
391
|
-
newName: "Updated name",
|
|
392
|
-
ttl,
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
cmdexec.execute(command).done((): void => {
|
|
396
|
-
sinon.assert.calledOnce(log);
|
|
397
|
-
assert.equal(log.args[0].length, 1);
|
|
398
|
-
|
|
399
|
-
var actual: string = log.args[0][0];
|
|
400
|
-
var expected = `Successfully renamed the access key "Test name" to "Updated name" and changed its expiration date to Wednesday, August 17, 2016 12:07 PM.`;
|
|
401
|
-
|
|
402
|
-
assert.equal(actual, expected);
|
|
403
|
-
done();
|
|
404
|
-
});
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
it("accessKeyList lists access key name and expires fields", (done: Mocha.Done): void => {
|
|
408
|
-
var command: cli.IAccessKeyListCommand = {
|
|
409
|
-
type: cli.CommandType.accessKeyList,
|
|
410
|
-
format: "json",
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
cmdexec.execute(command).done((): void => {
|
|
414
|
-
sinon.assert.calledOnce(log);
|
|
415
|
-
assert.equal(log.args[0].length, 1);
|
|
416
|
-
|
|
417
|
-
var actual: string = log.args[0][0];
|
|
418
|
-
var expected = [
|
|
419
|
-
{
|
|
420
|
-
createdTime: 0,
|
|
421
|
-
name: "Test name",
|
|
422
|
-
expires: NOW + DEFAULT_ACCESS_KEY_MAX_AGE,
|
|
423
|
-
},
|
|
424
|
-
];
|
|
425
|
-
|
|
426
|
-
assertJsonDescribesObject(actual, expected);
|
|
427
|
-
done();
|
|
428
|
-
});
|
|
429
|
-
});
|
|
430
|
-
|
|
431
|
-
it("accessKeyRemove removes access key", (done: Mocha.Done): void => {
|
|
432
|
-
var command: cli.IAccessKeyRemoveCommand = {
|
|
433
|
-
type: cli.CommandType.accessKeyRemove,
|
|
434
|
-
accessKey: "8",
|
|
435
|
-
};
|
|
436
|
-
|
|
437
|
-
var removeAccessKey: sinon.SinonSpy = sandbox.spy(cmdexec.sdk, "removeAccessKey");
|
|
438
|
-
|
|
439
|
-
cmdexec.execute(command).done((): void => {
|
|
440
|
-
sinon.assert.calledOnce(removeAccessKey);
|
|
441
|
-
sinon.assert.calledWithExactly(removeAccessKey, "8");
|
|
442
|
-
sinon.assert.calledOnce(log);
|
|
443
|
-
sinon.assert.calledWithExactly(log, 'Successfully removed the "8" access key.');
|
|
444
|
-
|
|
445
|
-
done();
|
|
446
|
-
});
|
|
447
|
-
});
|
|
448
|
-
|
|
449
|
-
it("accessKeyRemove does not remove access key if cancelled", (done: Mocha.Done): void => {
|
|
450
|
-
var command: cli.IAccessKeyRemoveCommand = {
|
|
451
|
-
type: cli.CommandType.accessKeyRemove,
|
|
452
|
-
accessKey: "8",
|
|
453
|
-
};
|
|
454
|
-
|
|
455
|
-
var removeAccessKey: sinon.SinonSpy = sandbox.spy(cmdexec.sdk, "removeAccessKey");
|
|
456
|
-
|
|
457
|
-
wasConfirmed = false;
|
|
458
|
-
|
|
459
|
-
cmdexec.execute(command).done((): void => {
|
|
460
|
-
sinon.assert.notCalled(removeAccessKey);
|
|
461
|
-
sinon.assert.calledOnce(log);
|
|
462
|
-
sinon.assert.calledWithExactly(log, "Access key removal cancelled.");
|
|
463
|
-
|
|
464
|
-
done();
|
|
465
|
-
});
|
|
466
|
-
});
|
|
467
|
-
|
|
468
301
|
it("appAdd reports new app name and ID", (done: Mocha.Done): void => {
|
|
469
302
|
var command: cli.IAppAddCommand = {
|
|
470
303
|
type: cli.CommandType.appAdd,
|
|
@@ -1518,88 +1351,6 @@ describe("CLI", () => {
|
|
|
1518
1351
|
.done();
|
|
1519
1352
|
});
|
|
1520
1353
|
|
|
1521
|
-
it("sessionList lists session name and expires fields", (done: Mocha.Done): void => {
|
|
1522
|
-
var command: cli.IAccessKeyListCommand = {
|
|
1523
|
-
type: cli.CommandType.sessionList,
|
|
1524
|
-
format: "json",
|
|
1525
|
-
};
|
|
1526
|
-
|
|
1527
|
-
cmdexec.execute(command).done((): void => {
|
|
1528
|
-
sinon.assert.calledOnce(log);
|
|
1529
|
-
assert.equal(log.args[0].length, 1);
|
|
1530
|
-
|
|
1531
|
-
var actual: string = log.args[0][0];
|
|
1532
|
-
var expected = [
|
|
1533
|
-
{
|
|
1534
|
-
loggedInTime: 0,
|
|
1535
|
-
machineName: TEST_MACHINE_NAME,
|
|
1536
|
-
},
|
|
1537
|
-
];
|
|
1538
|
-
|
|
1539
|
-
assertJsonDescribesObject(actual, expected);
|
|
1540
|
-
done();
|
|
1541
|
-
});
|
|
1542
|
-
});
|
|
1543
|
-
|
|
1544
|
-
it("sessionRemove removes session", (done: Mocha.Done): void => {
|
|
1545
|
-
var machineName = TEST_MACHINE_NAME;
|
|
1546
|
-
var command: cli.ISessionRemoveCommand = {
|
|
1547
|
-
type: cli.CommandType.sessionRemove,
|
|
1548
|
-
machineName: machineName,
|
|
1549
|
-
};
|
|
1550
|
-
|
|
1551
|
-
var removeSession: sinon.SinonSpy = sandbox.spy(cmdexec.sdk, "removeSession");
|
|
1552
|
-
|
|
1553
|
-
cmdexec.execute(command).done((): void => {
|
|
1554
|
-
sinon.assert.calledOnce(removeSession);
|
|
1555
|
-
sinon.assert.calledWithExactly(removeSession, machineName);
|
|
1556
|
-
sinon.assert.calledOnce(log);
|
|
1557
|
-
sinon.assert.calledWithExactly(log, `Successfully removed the login session for "${machineName}".`);
|
|
1558
|
-
|
|
1559
|
-
done();
|
|
1560
|
-
});
|
|
1561
|
-
});
|
|
1562
|
-
|
|
1563
|
-
it("sessionRemove does not remove session if cancelled", (done: Mocha.Done): void => {
|
|
1564
|
-
var machineName = TEST_MACHINE_NAME;
|
|
1565
|
-
var command: cli.ISessionRemoveCommand = {
|
|
1566
|
-
type: cli.CommandType.sessionRemove,
|
|
1567
|
-
machineName: machineName,
|
|
1568
|
-
};
|
|
1569
|
-
|
|
1570
|
-
var removeSession: sinon.SinonSpy = sandbox.spy(cmdexec.sdk, "removeSession");
|
|
1571
|
-
|
|
1572
|
-
wasConfirmed = false;
|
|
1573
|
-
|
|
1574
|
-
cmdexec.execute(command).done((): void => {
|
|
1575
|
-
sinon.assert.notCalled(removeSession);
|
|
1576
|
-
sinon.assert.calledOnce(log);
|
|
1577
|
-
sinon.assert.calledWithExactly(log, "Session removal cancelled.");
|
|
1578
|
-
|
|
1579
|
-
done();
|
|
1580
|
-
});
|
|
1581
|
-
});
|
|
1582
|
-
|
|
1583
|
-
it("sessionRemove does not remove current session", (done: Mocha.Done): void => {
|
|
1584
|
-
var machineName = os.hostname();
|
|
1585
|
-
var command: cli.ISessionRemoveCommand = {
|
|
1586
|
-
type: cli.CommandType.sessionRemove,
|
|
1587
|
-
machineName: machineName,
|
|
1588
|
-
};
|
|
1589
|
-
|
|
1590
|
-
wasConfirmed = false;
|
|
1591
|
-
|
|
1592
|
-
cmdexec
|
|
1593
|
-
.execute(command)
|
|
1594
|
-
.then(() => {
|
|
1595
|
-
done(new Error("Did not throw error."));
|
|
1596
|
-
})
|
|
1597
|
-
.catch(() => {
|
|
1598
|
-
done();
|
|
1599
|
-
})
|
|
1600
|
-
.done();
|
|
1601
|
-
});
|
|
1602
|
-
|
|
1603
1354
|
function releaseHelperFunction(command: cli.IReleaseCommand, done: Mocha.Done, expectedError: string): void {
|
|
1604
1355
|
cmdexec.execute(command).done(
|
|
1605
1356
|
(): void => {
|