avo 3.0.0-beta.1 → 3.0.0-beta.2
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/Avo.js +771 -1038
- package/cli.js +36 -9
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -25,7 +25,7 @@ import walk from 'ignore-walk';
|
|
|
25
25
|
import writeFile from 'write';
|
|
26
26
|
import { writeJsonFile } from 'write-json-file';
|
|
27
27
|
import Configstore from 'configstore';
|
|
28
|
-
import
|
|
28
|
+
import { AvoInspector, AvoInspectorEnv } from 'node-avo-inspector';
|
|
29
29
|
import yargs from 'yargs';
|
|
30
30
|
import { hideBin } from 'yargs/helpers';
|
|
31
31
|
import httpShutdown from 'http-shutdown';
|
|
@@ -293,7 +293,7 @@ const customAnalyticsDestination = {
|
|
|
293
293
|
make: function make(production) {
|
|
294
294
|
this.production = production;
|
|
295
295
|
},
|
|
296
|
-
logEvent:
|
|
296
|
+
logEvent: (userId, eventName, eventProperties) => {
|
|
297
297
|
api
|
|
298
298
|
.request('POST', '/c/v1/track', {
|
|
299
299
|
origin: api.apiOrigin,
|
|
@@ -306,17 +306,18 @@ const customAnalyticsDestination = {
|
|
|
306
306
|
.catch(() => {
|
|
307
307
|
// don't crash on tracking errors
|
|
308
308
|
});
|
|
309
|
+
return undefined;
|
|
309
310
|
},
|
|
310
|
-
setUserProperties: () =>
|
|
311
|
+
setUserProperties: () => undefined, // noop
|
|
311
312
|
};
|
|
312
|
-
const inspector = new
|
|
313
|
+
const inspector = new AvoInspector({
|
|
313
314
|
apiKey: '3UWtteG9HenZ825cYoYr',
|
|
314
|
-
env:
|
|
315
|
-
version:
|
|
315
|
+
env: AvoInspectorEnv.Prod,
|
|
316
|
+
version: pkg.version,
|
|
316
317
|
appName: 'Avo CLI',
|
|
317
318
|
});
|
|
318
319
|
// setup Avo analytics
|
|
319
|
-
Avo.initAvo({ env:
|
|
320
|
+
Avo.initAvo({ env: Avo.AvoEnv.Prod, inspector }, { client: Avo.Client.CLI, version: pkg.version }, {}, customAnalyticsDestination);
|
|
320
321
|
function isLegacyAvoJson(json) {
|
|
321
322
|
// check if legacy avo.json or un-initialized project
|
|
322
323
|
return json.types ?? !json.schema;
|
|
@@ -1294,6 +1295,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1294
1295
|
userId_: installIdOrUserId(),
|
|
1295
1296
|
cliAction: Avo.CliAction.INIT,
|
|
1296
1297
|
cliInvokedByCi: invokedByCi(),
|
|
1298
|
+
force: undefined,
|
|
1297
1299
|
});
|
|
1298
1300
|
report.info(`Avo is already initialized for workspace ${cyan(json.schema.name)} (${file('avo.json')} exists)`);
|
|
1299
1301
|
return Promise.resolve();
|
|
@@ -1306,6 +1308,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1306
1308
|
userId_: installIdOrUserId(),
|
|
1307
1309
|
cliAction: Avo.CliAction.INIT,
|
|
1308
1310
|
cliInvokedByCi: invokedByCi(),
|
|
1311
|
+
force: undefined,
|
|
1309
1312
|
});
|
|
1310
1313
|
return requireAuth(argv, () => init()
|
|
1311
1314
|
.then(writeAvoJson)
|
|
@@ -1322,6 +1325,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1322
1325
|
userId_: installIdOrUserId(),
|
|
1323
1326
|
cliAction: Avo.CliAction.INIT,
|
|
1324
1327
|
cliInvokedByCi: invokedByCi(),
|
|
1328
|
+
force: undefined,
|
|
1325
1329
|
});
|
|
1326
1330
|
});
|
|
1327
1331
|
},
|
|
@@ -1344,6 +1348,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1344
1348
|
userId_: installIdOrUserId(),
|
|
1345
1349
|
cliAction: Avo.CliAction.PULL,
|
|
1346
1350
|
cliInvokedByCi: invokedByCi(),
|
|
1351
|
+
force: undefined,
|
|
1347
1352
|
});
|
|
1348
1353
|
requireAuth(argv, () => {
|
|
1349
1354
|
if (argv.branch && json.branch.name !== argv.branch) {
|
|
@@ -1364,6 +1369,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1364
1369
|
userId_: installIdOrUserId(),
|
|
1365
1370
|
cliAction: Avo.CliAction.PULL,
|
|
1366
1371
|
cliInvokedByCi: invokedByCi(),
|
|
1372
|
+
force: undefined,
|
|
1367
1373
|
});
|
|
1368
1374
|
throw error;
|
|
1369
1375
|
});
|
|
@@ -1383,6 +1389,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1383
1389
|
userId_: installIdOrUserId(),
|
|
1384
1390
|
cliAction: Avo.CliAction.CHECKOUT,
|
|
1385
1391
|
cliInvokedByCi: invokedByCi(),
|
|
1392
|
+
force: undefined,
|
|
1386
1393
|
});
|
|
1387
1394
|
report.info(`Currently on branch '${json.branch.name}'`);
|
|
1388
1395
|
requireAuth(argv, () => checkout(argv.branch, json).then(writeAvoJson));
|
|
@@ -1396,6 +1403,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1396
1403
|
userId_: installIdOrUserId(),
|
|
1397
1404
|
cliAction: Avo.CliAction.CHECKOUT,
|
|
1398
1405
|
cliInvokedByCi: invokedByCi(),
|
|
1406
|
+
force: undefined,
|
|
1399
1407
|
});
|
|
1400
1408
|
throw error;
|
|
1401
1409
|
}),
|
|
@@ -1419,6 +1427,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1419
1427
|
userId_: installIdOrUserId(),
|
|
1420
1428
|
cliAction: Avo.CliAction.SOURCE,
|
|
1421
1429
|
cliInvokedByCi: invokedByCi(),
|
|
1430
|
+
force: undefined,
|
|
1422
1431
|
});
|
|
1423
1432
|
if (!json.sources || !json.sources.length) {
|
|
1424
1433
|
report.info(`No sources defined in ${file('avo.json')}. Run ${cmd('avo source add')} to add sources`);
|
|
@@ -1439,6 +1448,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1439
1448
|
userId_: installIdOrUserId(),
|
|
1440
1449
|
cliAction: Avo.CliAction.SOURCE,
|
|
1441
1450
|
cliInvokedByCi: invokedByCi(),
|
|
1451
|
+
force: undefined,
|
|
1442
1452
|
});
|
|
1443
1453
|
throw error;
|
|
1444
1454
|
});
|
|
@@ -1458,6 +1468,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1458
1468
|
userId_: installIdOrUserId(),
|
|
1459
1469
|
cliAction: Avo.CliAction.SOURCE_ADD,
|
|
1460
1470
|
cliInvokedByCi: invokedByCi(),
|
|
1471
|
+
force: undefined,
|
|
1461
1472
|
});
|
|
1462
1473
|
requireAuth(argv, () => {
|
|
1463
1474
|
selectSource(argv.source, json).then(writeAvoJson);
|
|
@@ -1472,6 +1483,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1472
1483
|
userId_: installIdOrUserId(),
|
|
1473
1484
|
cliAction: Avo.CliAction.SOURCE_ADD,
|
|
1474
1485
|
cliInvokedByCi: invokedByCi(),
|
|
1486
|
+
force: undefined,
|
|
1475
1487
|
});
|
|
1476
1488
|
throw error;
|
|
1477
1489
|
});
|
|
@@ -1492,6 +1504,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1492
1504
|
userId_: installIdOrUserId(),
|
|
1493
1505
|
cliAction: Avo.CliAction.SOURCE_REMOVE,
|
|
1494
1506
|
cliInvokedByCi: invokedByCi(),
|
|
1507
|
+
force: undefined,
|
|
1495
1508
|
});
|
|
1496
1509
|
if (!json.sources || !json.sources.length) {
|
|
1497
1510
|
report.warn(`No sources defined in ${file('avo.json')}. Run ${cmd('avo source add')} to add sources`);
|
|
@@ -1552,6 +1565,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1552
1565
|
userId_: installIdOrUserId(),
|
|
1553
1566
|
cliAction: Avo.CliAction.SOURCE_REMOVE,
|
|
1554
1567
|
cliInvokedByCi: invokedByCi(),
|
|
1568
|
+
force: undefined,
|
|
1555
1569
|
});
|
|
1556
1570
|
throw error;
|
|
1557
1571
|
});
|
|
@@ -1573,6 +1587,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1573
1587
|
userId_: installIdOrUserId(),
|
|
1574
1588
|
cliAction: Avo.CliAction.STATUS,
|
|
1575
1589
|
cliInvokedByCi: invokedByCi(),
|
|
1590
|
+
force: undefined,
|
|
1576
1591
|
});
|
|
1577
1592
|
report.info(`Currently on branch '${json.branch.name}'`);
|
|
1578
1593
|
return getSource(argv, json);
|
|
@@ -1587,6 +1602,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1587
1602
|
userId_: installIdOrUserId(),
|
|
1588
1603
|
cliAction: Avo.CliAction.STATUS,
|
|
1589
1604
|
cliInvokedByCi: invokedByCi(),
|
|
1605
|
+
force: undefined,
|
|
1590
1606
|
});
|
|
1591
1607
|
throw error;
|
|
1592
1608
|
});
|
|
@@ -1620,6 +1636,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1620
1636
|
userId_: installIdOrUserId(),
|
|
1621
1637
|
cliAction: Avo.CliAction.MERGE,
|
|
1622
1638
|
cliInvokedByCi: invokedByCi(),
|
|
1639
|
+
force: undefined,
|
|
1623
1640
|
});
|
|
1624
1641
|
throw error;
|
|
1625
1642
|
});
|
|
@@ -1644,6 +1661,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1644
1661
|
userId_: installIdOrUserId(),
|
|
1645
1662
|
cliAction: Avo.CliAction.CONFLICT,
|
|
1646
1663
|
cliInvokedByCi: invokedByCi(),
|
|
1664
|
+
force: undefined,
|
|
1647
1665
|
});
|
|
1648
1666
|
pull(null, json);
|
|
1649
1667
|
}));
|
|
@@ -1658,6 +1676,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1658
1676
|
userId_: installIdOrUserId(),
|
|
1659
1677
|
cliAction: Avo.CliAction.CONFLICT,
|
|
1660
1678
|
cliInvokedByCi: invokedByCi(),
|
|
1679
|
+
force: undefined,
|
|
1661
1680
|
});
|
|
1662
1681
|
return Promise.resolve(json);
|
|
1663
1682
|
})
|
|
@@ -1670,6 +1689,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1670
1689
|
userId_: installIdOrUserId(),
|
|
1671
1690
|
cliAction: Avo.CliAction.CONFLICT,
|
|
1672
1691
|
cliInvokedByCi: invokedByCi(),
|
|
1692
|
+
force: undefined,
|
|
1673
1693
|
});
|
|
1674
1694
|
throw error;
|
|
1675
1695
|
}),
|
|
@@ -1688,6 +1708,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1688
1708
|
userId_: installIdOrUserId(),
|
|
1689
1709
|
cliAction: Avo.CliAction.EDIT,
|
|
1690
1710
|
cliInvokedByCi: invokedByCi(),
|
|
1711
|
+
force: undefined,
|
|
1691
1712
|
});
|
|
1692
1713
|
const { schema } = json;
|
|
1693
1714
|
const schemaUrl = `https://www.avo.app/schemas/${schema.id}`;
|
|
@@ -1703,6 +1724,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1703
1724
|
userId_: installIdOrUserId(),
|
|
1704
1725
|
cliAction: Avo.CliAction.EDIT,
|
|
1705
1726
|
cliInvokedByCi: invokedByCi(),
|
|
1727
|
+
force: undefined,
|
|
1706
1728
|
});
|
|
1707
1729
|
throw error;
|
|
1708
1730
|
});
|
|
@@ -1725,7 +1747,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1725
1747
|
Avo.signedIn({
|
|
1726
1748
|
userId_: result.user.user_id,
|
|
1727
1749
|
email: result.user.email,
|
|
1728
|
-
|
|
1750
|
+
authenticationMethod: Avo.AuthenticationMethod.CLI,
|
|
1729
1751
|
});
|
|
1730
1752
|
report.success(`Logged in as ${email(result.user.email)}`);
|
|
1731
1753
|
})
|
|
@@ -1734,7 +1756,6 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1734
1756
|
userId_: conf.get('avo_install_id'),
|
|
1735
1757
|
emailInput: '',
|
|
1736
1758
|
signInError: Avo.SignInError.UNKNOWN,
|
|
1737
|
-
cliInvokedByCi: invokedByCi(),
|
|
1738
1759
|
});
|
|
1739
1760
|
});
|
|
1740
1761
|
};
|
|
@@ -1748,6 +1769,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1748
1769
|
userId_: installIdOrUserId(),
|
|
1749
1770
|
cliAction: Avo.CliAction.LOGIN,
|
|
1750
1771
|
cliInvokedByCi: invokedByCi(),
|
|
1772
|
+
force: undefined,
|
|
1751
1773
|
});
|
|
1752
1774
|
command();
|
|
1753
1775
|
})
|
|
@@ -1760,6 +1782,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1760
1782
|
userId_: installIdOrUserId(),
|
|
1761
1783
|
cliAction: Avo.CliAction.LOGIN,
|
|
1762
1784
|
cliInvokedByCi: invokedByCi(),
|
|
1785
|
+
force: undefined,
|
|
1763
1786
|
});
|
|
1764
1787
|
command();
|
|
1765
1788
|
});
|
|
@@ -1804,6 +1827,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1804
1827
|
userId_: installIdOrUserId(),
|
|
1805
1828
|
cliAction: Avo.CliAction.LOGOUT,
|
|
1806
1829
|
cliInvokedByCi: invokedByCi(),
|
|
1830
|
+
force: undefined,
|
|
1807
1831
|
});
|
|
1808
1832
|
command();
|
|
1809
1833
|
})
|
|
@@ -1816,6 +1840,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1816
1840
|
userId_: installIdOrUserId(),
|
|
1817
1841
|
cliAction: Avo.CliAction.LOGOUT,
|
|
1818
1842
|
cliInvokedByCi: invokedByCi(),
|
|
1843
|
+
force: undefined,
|
|
1819
1844
|
});
|
|
1820
1845
|
command();
|
|
1821
1846
|
});
|
|
@@ -1846,6 +1871,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1846
1871
|
userId_: installIdOrUserId(),
|
|
1847
1872
|
cliAction: Avo.CliAction.WHOAMI,
|
|
1848
1873
|
cliInvokedByCi: invokedByCi(),
|
|
1874
|
+
force: undefined,
|
|
1849
1875
|
});
|
|
1850
1876
|
command();
|
|
1851
1877
|
})
|
|
@@ -1858,6 +1884,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1858
1884
|
userId_: installIdOrUserId(),
|
|
1859
1885
|
cliAction: Avo.CliAction.WHOAMI,
|
|
1860
1886
|
cliInvokedByCi: invokedByCi(),
|
|
1887
|
+
force: undefined,
|
|
1861
1888
|
});
|
|
1862
1889
|
command();
|
|
1863
1890
|
});
|