@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.
- package/bin/script/command-executor.js +1 -71
- package/bin/script/command-parser.js +0 -197
- package/bin/script/types/cli.js +20 -28
- package/bin/test/cli.js +0 -198
- package/package.json +1 -1
- package/script/command-executor.ts +1 -90
- package/script/command-parser.ts +0 -242
- package/script/types/cli.ts +1 -9
- package/test/cli.ts +0 -249
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 => {
|