@appcircle/codepush-cli 0.0.3-alpha.1 → 0.0.4

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.
@@ -122,60 +122,6 @@ export const confirm = (message: string = "Are you sure?"): Promise<boolean> =>
122
122
  });
123
123
  };
124
124
 
125
- function accessKeyAdd(command: cli.IAccessKeyAddCommand): Promise<void> {
126
- return sdk.addAccessKey(command.name, command.ttl).then((accessKey: AccessKey) => {
127
- log(`Successfully created the "${command.name}" access key: ${accessKey.key}`);
128
- log("Make sure to save this key value somewhere safe, since you won't be able to view it from the CLI again!");
129
- });
130
- }
131
-
132
- function accessKeyPatch(command: cli.IAccessKeyPatchCommand): Promise<void> {
133
- const willUpdateName: boolean = isCommandOptionSpecified(command.newName) && command.oldName !== command.newName;
134
- const willUpdateTtl: boolean = isCommandOptionSpecified(command.ttl);
135
-
136
- if (!willUpdateName && !willUpdateTtl) {
137
- throw new Error("A new name and/or TTL must be provided.");
138
- }
139
-
140
- return sdk.patchAccessKey(command.oldName, command.newName, command.ttl).then((accessKey: AccessKey) => {
141
- let logMessage: string = "Successfully ";
142
- if (willUpdateName) {
143
- logMessage += `renamed the access key "${command.oldName}" to "${command.newName}"`;
144
- }
145
-
146
- if (willUpdateTtl) {
147
- const expirationDate = moment(accessKey.expires).format("LLLL");
148
- if (willUpdateName) {
149
- logMessage += ` and changed its expiration date to ${expirationDate}`;
150
- } else {
151
- logMessage += `changed the expiration date of the "${command.oldName}" access key to ${expirationDate}`;
152
- }
153
- }
154
-
155
- log(`${logMessage}.`);
156
- });
157
- }
158
-
159
- function accessKeyList(command: cli.IAccessKeyListCommand): Promise<void> {
160
- throwForInvalidOutputFormat(command.format);
161
-
162
- return sdk.getAccessKeys().then((accessKeys: AccessKey[]): void => {
163
- printAccessKeys(command.format, accessKeys);
164
- });
165
- }
166
-
167
- function accessKeyRemove(command: cli.IAccessKeyRemoveCommand): Promise<void> {
168
- return confirm().then((wasConfirmed: boolean): Promise<void> => {
169
- if (wasConfirmed) {
170
- return sdk.removeAccessKey(command.accessKey).then((): void => {
171
- log(`Successfully removed the "${command.accessKey}" access key.`);
172
- });
173
- }
174
-
175
- log("Access key removal cancelled.");
176
- });
177
- }
178
-
179
125
  function appAdd(command: cli.IAppAddCommand): Promise<void> {
180
126
  return sdk.addApp(command.appName).then((app: App): Promise<void> => {
181
127
  log('Successfully added the "' + command.appName + '" app, along with the following default deployments:');
@@ -446,15 +392,7 @@ export function execute(command: cli.ICommand) {
446
392
  switch (command.type) {
447
393
  // Must not be logged in
448
394
  case cli.CommandType.login:
449
- case cli.CommandType.register:
450
- if (connectionInfo) {
451
- throw new Error("You are already logged in from this machine.");
452
- }
453
- break;
454
-
455
- // It does not matter whether you are logged in or not
456
- case cli.CommandType.link:
457
- break;
395
+ return login(<cli.ILoginCommand>command);
458
396
 
459
397
  // Must be logged in
460
398
  default:
@@ -471,18 +409,6 @@ export function execute(command: cli.ICommand) {
471
409
  }
472
410
 
473
411
  switch (command.type) {
474
- case cli.CommandType.accessKeyAdd:
475
- return accessKeyAdd(<cli.IAccessKeyAddCommand>command);
476
-
477
- case cli.CommandType.accessKeyPatch:
478
- return accessKeyPatch(<cli.IAccessKeyPatchCommand>command);
479
-
480
- case cli.CommandType.accessKeyList:
481
- return accessKeyList(<cli.IAccessKeyListCommand>command);
482
-
483
- case cli.CommandType.accessKeyRemove:
484
- return accessKeyRemove(<cli.IAccessKeyRemoveCommand>command);
485
-
486
412
  case cli.CommandType.appAdd:
487
413
  return appAdd(<cli.IAppAddCommand>command);
488
414
 
@@ -519,12 +445,6 @@ export function execute(command: cli.ICommand) {
519
445
  case cli.CommandType.deploymentRename:
520
446
  return deploymentRename(<cli.IDeploymentRenameCommand>command);
521
447
 
522
- case cli.CommandType.link:
523
- return link(<cli.ILinkCommand>command);
524
-
525
- case cli.CommandType.login:
526
- return login(<cli.ILoginCommand>command);
527
-
528
448
  case cli.CommandType.logout:
529
449
  return logout(command);
530
450
 
@@ -534,9 +454,6 @@ export function execute(command: cli.ICommand) {
534
454
  case cli.CommandType.promote:
535
455
  return promote(<cli.IPromoteCommand>command);
536
456
 
537
- case cli.CommandType.register:
538
- return register(<cli.IRegisterCommand>command);
539
-
540
457
  case cli.CommandType.release:
541
458
  return release(<cli.IReleaseCommand>command);
542
459
 
@@ -546,12 +463,6 @@ export function execute(command: cli.ICommand) {
546
463
  case cli.CommandType.rollback:
547
464
  return rollback(<cli.IRollbackCommand>command);
548
465
 
549
- case cli.CommandType.sessionList:
550
- return sessionList(<cli.ISessionListCommand>command);
551
-
552
- case cli.CommandType.sessionRemove:
553
- return sessionRemove(<cli.ISessionRemoveCommand>command);
554
-
555
466
  default:
556
467
  // We should never see this message as invalid commands should be caught by the argument parser.
557
468
  throw new Error("Invalid command: " + JSON.stringify(command));
@@ -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)
@@ -183,33 +105,6 @@ function removeCollaborator(commandName: string, yargs: yargs.Argv): void {
183
105
  addCommonConfiguration(yargs);
184
106
  }
185
107
 
186
- function sessionList(commandName: string, yargs: yargs.Argv): void {
187
- isValidCommand = true;
188
- yargs
189
- .usage(USAGE_PREFIX + " session " + commandName + " [options]")
190
- .demand(/*count*/ 0, /*max*/ 0)
191
- .example("session " + commandName, "Lists your sessions in tabular format")
192
- .example("session " + commandName + " --format json", "Lists your login sessions in JSON format")
193
- .option("format", {
194
- default: "table",
195
- demand: false,
196
- description: 'Output format to display your login sessions with ("json" or "table")',
197
- type: "string",
198
- });
199
-
200
- addCommonConfiguration(yargs);
201
- }
202
-
203
- function sessionRemove(commandName: string, yargs: yargs.Argv): void {
204
- isValidCommand = true;
205
- yargs
206
- .usage(USAGE_PREFIX + " session " + commandName + " <machineName>")
207
- .demand(/*count*/ 1, /*max*/ 1) // Require exactly one non-option arguments
208
- .example("session " + commandName + ' "John\'s PC"', 'Removes the existing login session from "John\'s PC"');
209
-
210
- addCommonConfiguration(yargs);
211
- }
212
-
213
108
  function deploymentHistoryClear(commandName: string, yargs: yargs.Argv): void {
214
109
  isValidCommand = true;
215
110
  yargs
@@ -289,21 +184,6 @@ function deploymentHistory(commandName: string, yargs: yargs.Argv): void {
289
184
  yargs
290
185
  .usage(USAGE_PREFIX + " <command>")
291
186
  .demand(/*count*/ 1, /*max*/ 1) // Require exactly one non-option argument.
292
- .command("access-key", "View and manage the access keys associated with your account", (yargs: yargs.Argv) => {
293
- isValidCommandCategory = true;
294
- yargs
295
- .usage(USAGE_PREFIX + " access-key <command>")
296
- .demand(/*count*/ 2, /*max*/ 2) // Require exactly two non-option arguments.
297
- .command("add", "Create a new access key associated with your account", (yargs: yargs.Argv) => accessKeyAdd("add", yargs))
298
- .command("patch", "Update the name and/or TTL of an existing access key", (yargs: yargs.Argv) => accessKeyPatch("patch", yargs))
299
- .command("remove", "Remove an existing access key", (yargs: yargs.Argv) => accessKeyRemove("remove", yargs))
300
- .command("rm", "Remove an existing access key", (yargs: yargs.Argv) => accessKeyRemove("rm", yargs))
301
- .command("list", "List the access keys associated with your account", (yargs: yargs.Argv) => accessKeyList("list", yargs))
302
- .command("ls", "List the access keys associated with your account", (yargs: yargs.Argv) => accessKeyList("ls", yargs))
303
- .check((argv: any, aliases: { [aliases: string]: string }): any => isValidCommand); // Report unrecognized, non-hyphenated command category.
304
-
305
- addCommonConfiguration(yargs);
306
- })
307
187
  .command("app", "View and manage your CodePush apps", (yargs: yargs.Argv) => {
308
188
  isValidCommandCategory = true;
309
189
  yargs
@@ -402,17 +282,6 @@ yargs
402
282
 
403
283
  addCommonConfiguration(yargs);
404
284
  })
405
- .command("link", "Link an additional authentication provider (e.g. GitHub) to an existing CodePush account", (yargs: yargs.Argv) => {
406
- isValidCommandCategory = true;
407
- isValidCommand = true;
408
- yargs
409
- .usage(USAGE_PREFIX + " link")
410
- .demand(/*count*/ 0, /*max*/ 1) //set 'max' to one to allow usage of serverUrl undocument parameter for testing
411
- .example("link", "Links an account on the CodePush server")
412
- .check((argv: any, aliases: { [aliases: string]: string }): any => isValidCommand); // Report unrecognized, non-hyphenated command category.
413
-
414
- addCommonConfiguration(yargs);
415
- })
416
285
  .command("login", "Authenticate with the CodePush server in order to begin managing your apps", (yargs: yargs.Argv) => {
417
286
  isValidCommandCategory = true;
418
287
  isValidCommand = true;
@@ -590,17 +459,6 @@ yargs
590
459
 
591
460
  addCommonConfiguration(yargs);
592
461
  })
593
- .command("register", "Register a new CodePush account", (yargs: yargs.Argv) => {
594
- isValidCommandCategory = true;
595
- isValidCommand = true;
596
- yargs
597
- .usage(USAGE_PREFIX + " register")
598
- .demand(/*count*/ 0, /*max*/ 1) //set 'max' to one to allow usage of serverUrl undocument parameter for testing
599
- .example("register", "Registers a new CodePush account")
600
- .check((argv: any, aliases: { [aliases: string]: string }): any => isValidCommand); // Report unrecognized, non-hyphenated command category.
601
-
602
- addCommonConfiguration(yargs);
603
- })
604
462
  .command("release", "Release an update to an app deployment", (yargs: yargs.Argv) => {
605
463
  yargs
606
464
  .usage(USAGE_PREFIX + " release <appName> <updateContentsPath> <targetBinaryVersion> [options]")
@@ -864,21 +722,6 @@ yargs
864
722
 
865
723
  addCommonConfiguration(yargs);
866
724
  })
867
- .command("session", "View and manage the current login sessions associated with your account", (yargs: yargs.Argv) => {
868
- isValidCommandCategory = true;
869
- yargs
870
- .usage(USAGE_PREFIX + " session <command>")
871
- .demand(/*count*/ 2, /*max*/ 2) // Require exactly two non-option arguments.
872
- .command("remove", "Remove an existing login session", (yargs: yargs.Argv) => sessionRemove("remove", yargs))
873
- .command("rm", "Remove an existing login session", (yargs: yargs.Argv) => sessionRemove("rm", yargs))
874
- .command("list", "List the current login sessions associated with your account", (yargs: yargs.Argv) =>
875
- sessionList("list", yargs)
876
- )
877
- .command("ls", "List the current login sessions associated with your account", (yargs: yargs.Argv) => sessionList("ls", yargs))
878
- .check((argv: any, aliases: { [aliases: string]: string }): any => isValidCommand); // Report unrecognized, non-hyphenated command category.
879
-
880
- addCommonConfiguration(yargs);
881
- })
882
725
  .alias("v", "version")
883
726
  .version(packageJson.version)
884
727
  .wrap(/*columnLimit*/ null)
@@ -898,56 +741,6 @@ export function createCommand(): cli.ICommand {
898
741
  const arg4: any = argv._[4];
899
742
 
900
743
  switch (arg0) {
901
- case "access-key":
902
- switch (arg1) {
903
- case "add":
904
- if (arg2) {
905
- cmd = { type: cli.CommandType.accessKeyAdd };
906
- const accessKeyAddCmd = <cli.IAccessKeyAddCommand>cmd;
907
- accessKeyAddCmd.name = arg2;
908
- const ttlOption: string = argv["ttl"] as any;
909
- if (isDefined(ttlOption)) {
910
- accessKeyAddCmd.ttl = parseDurationMilliseconds(ttlOption);
911
- }
912
- }
913
- break;
914
-
915
- case "patch":
916
- if (arg2) {
917
- cmd = { type: cli.CommandType.accessKeyPatch };
918
- const accessKeyPatchCmd = <cli.IAccessKeyPatchCommand>cmd;
919
- accessKeyPatchCmd.oldName = arg2;
920
-
921
- const newNameOption: string = argv["name"] as any;
922
- const ttlOption: string = argv["ttl"] as any;
923
- if (isDefined(newNameOption)) {
924
- accessKeyPatchCmd.newName = newNameOption;
925
- }
926
-
927
- if (isDefined(ttlOption)) {
928
- accessKeyPatchCmd.ttl = parseDurationMilliseconds(ttlOption);
929
- }
930
- }
931
- break;
932
-
933
- case "list":
934
- case "ls":
935
- cmd = { type: cli.CommandType.accessKeyList };
936
-
937
- (<cli.IAccessKeyListCommand>cmd).format = argv["format"] as any;
938
- break;
939
-
940
- case "remove":
941
- case "rm":
942
- if (arg2) {
943
- cmd = { type: cli.CommandType.accessKeyRemove };
944
-
945
- (<cli.IAccessKeyRemoveCommand>cmd).accessKey = arg2;
946
- }
947
- break;
948
- }
949
- break;
950
-
951
744
  case "app":
952
745
  switch (arg1) {
953
746
  case "add":
@@ -1079,13 +872,6 @@ export function createCommand(): cli.ICommand {
1079
872
  }
1080
873
  break;
1081
874
 
1082
- case "link":
1083
- cmd = <cli.ILinkCommand>{
1084
- type: cli.CommandType.link,
1085
- serverUrl: getServerUrl(arg1),
1086
- };
1087
- break;
1088
-
1089
875
  case "login":
1090
876
  cmd = { type: cli.CommandType.login };
1091
877
 
@@ -1138,14 +924,6 @@ export function createCommand(): cli.ICommand {
1138
924
  }
1139
925
  break;
1140
926
 
1141
- case "register":
1142
- cmd = { type: cli.CommandType.register };
1143
-
1144
- const registerCommand = <cli.IRegisterCommand>cmd;
1145
-
1146
- registerCommand.serverUrl = getServerUrl(arg1);
1147
- break;
1148
-
1149
927
  case "release":
1150
928
  if (arg1 && arg2 && arg3) {
1151
929
  cmd = { type: cli.CommandType.release };
@@ -1209,26 +987,6 @@ export function createCommand(): cli.ICommand {
1209
987
  rollbackCommand.targetRelease = argv["targetRelease"] as any;
1210
988
  }
1211
989
  break;
1212
-
1213
- case "session":
1214
- switch (arg1) {
1215
- case "list":
1216
- case "ls":
1217
- cmd = { type: cli.CommandType.sessionList };
1218
-
1219
- (<cli.ISessionListCommand>cmd).format = argv["format"] as any;
1220
- break;
1221
-
1222
- case "remove":
1223
- case "rm":
1224
- if (arg2) {
1225
- cmd = { type: cli.CommandType.sessionRemove };
1226
-
1227
- (<cli.ISessionRemoveCommand>cmd).machineName = arg2;
1228
- }
1229
- break;
1230
- }
1231
- break;
1232
990
  }
1233
991
 
1234
992
  return cmd;
@@ -4,10 +4,6 @@
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,
13
9
  appDeploymentKeyList,
@@ -21,17 +17,13 @@ export enum CommandType {
21
17
  deploymentMetrics,
22
18
  deploymentRemove,
23
19
  deploymentRename,
24
- link,
25
20
  login,
26
21
  logout,
27
22
  patch,
28
23
  promote,
29
- register,
30
24
  release,
31
25
  releaseReact,
32
- rollback,
33
- sessionList,
34
- sessionRemove
26
+ rollback
35
27
  }
36
28
 
37
29
  export interface ICommand {