avo 3.2.1 → 3.2.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/README.md +12 -21
- package/cli.js +35 -17
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
# Avo CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Better event tracking, **faster**.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
The Avo CLI gives you access to [Avo Codegen](https://www.avo.app/docs/implementation/devs-101) right from your command line. It allows you to pull [your Avo tracking plan](http://avo.app/schemas/default) as type-safe functions for each of your events, making analytics implementation quick and seamless. Avo Codegen supports a variety of [platforms, programming languages and destinations](https://www.avo.app/docs/implementation/supported-programming-languages).
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
4
10
|
|
|
5
11
|
Avo runs on Node `>=14.16`. To install the latest version of Avo CLI, run this command:
|
|
6
12
|
|
|
@@ -15,6 +21,7 @@ $ avo --help
|
|
|
15
21
|
avo command
|
|
16
22
|
|
|
17
23
|
Commands:
|
|
24
|
+
avo login Log into the Avo platform
|
|
18
25
|
avo init Initialize an Avo workspace in the current folder
|
|
19
26
|
avo pull [source] Pull analytics wrappers from Avo workspace
|
|
20
27
|
avo checkout [branch] Switch branches [aliases: branch]
|
|
@@ -23,7 +30,6 @@ Commands:
|
|
|
23
30
|
avo merge main Pull the Avo main branch into your current branch
|
|
24
31
|
avo conflict Resolve git conflicts in Avo files [aliases: resolve, conflicts]
|
|
25
32
|
avo edit Open the Avo workspace in your browser
|
|
26
|
-
avo login Log into the Avo platform
|
|
27
33
|
avo logout Log out from the Avo platform
|
|
28
34
|
avo whoami Shows the currently logged in username
|
|
29
35
|
|
|
@@ -34,24 +40,9 @@ Options:
|
|
|
34
40
|
--help Show help [boolean]
|
|
35
41
|
```
|
|
36
42
|
|
|
37
|
-
For more
|
|
38
|
-
|
|
39
|
-
## Caught a Bug?
|
|
43
|
+
For more documentation, visit [https://www.avo.app/docs/implementation/cli](https://www.avo.app/docs/implementation/cli)
|
|
40
44
|
|
|
41
|
-
Thank you, you are precious to us :hug: Please send an email to friends@avo.app or file an issue here on GitHub.
|
|
42
45
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
Make your changes and add them to the _Unreleased_ section in CHANGELOG.md
|
|
46
|
-
|
|
47
|
-
## How to Create a Release
|
|
48
|
-
|
|
49
|
-
1. Verify that the changes in the _Unrelased_ section in CHANGELOG.md are accurate, create a new heading with the correct semantic version then move the content from the _Unreleased_ section there
|
|
50
|
-
2. Update the semantic version in `package.json` to match the one you just created in the changelog
|
|
51
|
-
3. Commit with the message "Release <version>" and push the changes
|
|
52
|
-
4. Publish the package to npm (you'll need to be a maintainer of the avo project in npm)
|
|
53
|
-
|
|
54
|
-
```
|
|
55
|
-
npm publish
|
|
56
|
-
```
|
|
46
|
+
**Caught a Bug?** Thank you, you are precious to us :hug: Please create a issue on the GitHub repo or send an email to friends@avo.app. We'll do our best to resolve it quickly!
|
|
57
47
|
|
|
48
|
+
**To create a release:** Verify that the changes in the _Unreleased_ section in CHANGELOG.md are accurate, create a new heading with the correct semantic version then move the content from the _Unreleased_ section there • Update the semantic version in `package.json` to match the one you just created in the changelog • Commit with the message "Release <version>" and push the changes • Publish the package to npm (you'll need to be a maintainer of the avo project in npm): `npm publish`
|
package/cli.js
CHANGED
|
@@ -135,8 +135,20 @@ function responseToError(response) {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
if (!body.error) {
|
|
138
|
+
const getMessage = (statusCode) => {
|
|
139
|
+
switch (statusCode) {
|
|
140
|
+
case 401:
|
|
141
|
+
return 'Unauthorized';
|
|
142
|
+
case 403:
|
|
143
|
+
return 'Forbidden. Do you have the required permissions? Some commands require editor or admin access.';
|
|
144
|
+
case 404:
|
|
145
|
+
return 'Not Found';
|
|
146
|
+
default:
|
|
147
|
+
return 'Unknown Error';
|
|
148
|
+
}
|
|
149
|
+
};
|
|
138
150
|
body.error = {
|
|
139
|
-
message: response.statusCode
|
|
151
|
+
message: getMessage(response.statusCode),
|
|
140
152
|
};
|
|
141
153
|
}
|
|
142
154
|
const message = `HTTP Error: ${response.statusCode}, ${body.error.message ?? body.error}`;
|
|
@@ -375,11 +387,14 @@ function extractConflictingFiles(str) {
|
|
|
375
387
|
}
|
|
376
388
|
return [files[0].join('\n'), files[1].join('\n')];
|
|
377
389
|
}
|
|
378
|
-
|
|
379
|
-
|
|
390
|
+
var BranchStatus;
|
|
391
|
+
(function (BranchStatus) {
|
|
392
|
+
BranchStatus["BRANCH_UP_TO_DATE"] = "branch-up-to-date";
|
|
393
|
+
BranchStatus["BRANCH_NOT_UP_TO_DATE"] = "branch-not-up-to-date";
|
|
394
|
+
})(BranchStatus || (BranchStatus = {}));
|
|
380
395
|
function getMasterStatus(json) {
|
|
381
396
|
if (json.branch.id === 'master') {
|
|
382
|
-
return Promise.resolve(BRANCH_UP_TO_DATE);
|
|
397
|
+
return Promise.resolve(BranchStatus.BRANCH_UP_TO_DATE);
|
|
383
398
|
}
|
|
384
399
|
return api
|
|
385
400
|
.request('POST', '/c/v1/master', {
|
|
@@ -390,7 +405,9 @@ function getMasterStatus(json) {
|
|
|
390
405
|
branchId: json.branch.id,
|
|
391
406
|
},
|
|
392
407
|
})
|
|
393
|
-
.then(({ pullRequired }) => pullRequired
|
|
408
|
+
.then(({ pullRequired }) => pullRequired
|
|
409
|
+
? BranchStatus.BRANCH_NOT_UP_TO_DATE
|
|
410
|
+
: BranchStatus.BRANCH_UP_TO_DATE);
|
|
394
411
|
}
|
|
395
412
|
function pullMaster(json) {
|
|
396
413
|
if (json.branch.name === 'main') {
|
|
@@ -419,7 +436,7 @@ function promptPullMaster(json) {
|
|
|
419
436
|
return getMasterStatus(json)
|
|
420
437
|
.then((branchStatus) => {
|
|
421
438
|
cancelWait();
|
|
422
|
-
if (branchStatus === BRANCH_NOT_UP_TO_DATE) {
|
|
439
|
+
if (branchStatus === BranchStatus.BRANCH_NOT_UP_TO_DATE) {
|
|
423
440
|
return inquirer
|
|
424
441
|
.prompt([
|
|
425
442
|
{
|
|
@@ -435,7 +452,7 @@ function promptPullMaster(json) {
|
|
|
435
452
|
return Promise.resolve([branchStatus]);
|
|
436
453
|
})
|
|
437
454
|
.then(([branchStatus, answer]) => {
|
|
438
|
-
if (branchStatus === BRANCH_UP_TO_DATE) {
|
|
455
|
+
if (branchStatus === BranchStatus.BRANCH_UP_TO_DATE) {
|
|
439
456
|
report.success('Branch is up to date with main');
|
|
440
457
|
return Promise.resolve(json);
|
|
441
458
|
}
|
|
@@ -477,7 +494,7 @@ function requireAuth(argv, cb) {
|
|
|
477
494
|
function init() {
|
|
478
495
|
const makeAvoJson = (schema) => {
|
|
479
496
|
report.success(`Initialized for workspace ${cyan(schema.name)}`);
|
|
480
|
-
return {
|
|
497
|
+
return Promise.resolve({
|
|
481
498
|
avo: {
|
|
482
499
|
version: semver.major(pkg.version),
|
|
483
500
|
},
|
|
@@ -489,7 +506,7 @@ function init() {
|
|
|
489
506
|
id: 'master',
|
|
490
507
|
name: 'main',
|
|
491
508
|
},
|
|
492
|
-
};
|
|
509
|
+
});
|
|
493
510
|
};
|
|
494
511
|
wait('Initializing');
|
|
495
512
|
return api
|
|
@@ -533,7 +550,10 @@ function validateAvoJson(json) {
|
|
|
533
550
|
return init();
|
|
534
551
|
}
|
|
535
552
|
// augment the latest major version into avo.json
|
|
536
|
-
return
|
|
553
|
+
return Promise.resolve({
|
|
554
|
+
...json,
|
|
555
|
+
avo: { ...json.avo, version: semver.major(pkg.version) },
|
|
556
|
+
});
|
|
537
557
|
}
|
|
538
558
|
function fetchBranches(json) {
|
|
539
559
|
wait('Fetching open branches');
|
|
@@ -732,7 +752,7 @@ function loadAvoJson() {
|
|
|
732
752
|
}
|
|
733
753
|
});
|
|
734
754
|
}
|
|
735
|
-
function loadAvoJsonOrInit({ argv, skipPullMaster, skipInit }) {
|
|
755
|
+
function loadAvoJsonOrInit({ argv, skipPullMaster, skipInit, }) {
|
|
736
756
|
return pify(fs.readFile)('avo.json', 'utf8')
|
|
737
757
|
.then((avoFile) => {
|
|
738
758
|
if (hasMergeConflicts(avoFile)) {
|
|
@@ -830,7 +850,7 @@ function selectSource(sourceToAdd, json) {
|
|
|
830
850
|
.then((data) => {
|
|
831
851
|
cancelWait();
|
|
832
852
|
const existingSources = json.sources ?? [];
|
|
833
|
-
|
|
853
|
+
const sources = data.sources
|
|
834
854
|
.filter((source) => !existingSources.find(({ id }) => source.id === id))
|
|
835
855
|
.sort((a, b) => {
|
|
836
856
|
if (a.name < b.name)
|
|
@@ -948,8 +968,7 @@ function selectSource(sourceToAdd, json) {
|
|
|
948
968
|
interfacePath: relativeInterfacePath,
|
|
949
969
|
};
|
|
950
970
|
}
|
|
951
|
-
|
|
952
|
-
const newJson = { ...json, sources };
|
|
971
|
+
const newJson = { ...json, sources: [...json.sources, source] };
|
|
953
972
|
report.info(`Added source ${source.name} to the project`);
|
|
954
973
|
report.info(`Run 'avo pull "${source.name}"' to pull the latest analytics wrapper for this source`);
|
|
955
974
|
return newJson;
|
|
@@ -964,7 +983,7 @@ function pull(sourceFilter, json) {
|
|
|
964
983
|
wait(`Pulling ${sourceNames.join(', ')}`);
|
|
965
984
|
return getMasterStatus(json)
|
|
966
985
|
.then((masterStatus) => {
|
|
967
|
-
if (masterStatus === BRANCH_NOT_UP_TO_DATE) {
|
|
986
|
+
if (masterStatus === BranchStatus.BRANCH_NOT_UP_TO_DATE) {
|
|
968
987
|
report.warn(`Your branch '${json.branch.name}' is not up to date with Avo main. To merge latest Avo main into the branch, run 'avo merge main'.`);
|
|
969
988
|
}
|
|
970
989
|
return Promise.resolve();
|
|
@@ -1394,7 +1413,6 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1394
1413
|
builder: (yargs) => yargs
|
|
1395
1414
|
.option('branch', {
|
|
1396
1415
|
describe: 'Name of Avo branch to pull from',
|
|
1397
|
-
default: 'main',
|
|
1398
1416
|
type: 'string',
|
|
1399
1417
|
})
|
|
1400
1418
|
.option('f', {
|
|
@@ -1404,7 +1422,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1404
1422
|
type: 'boolean',
|
|
1405
1423
|
})
|
|
1406
1424
|
.option('forceFeatures', {
|
|
1407
|
-
describe: 'Optional comma separated list of features to force enable',
|
|
1425
|
+
describe: 'Optional comma separated list of features to force enable, pass unsupported name to get the list of available features',
|
|
1408
1426
|
default: undefined,
|
|
1409
1427
|
type: 'string',
|
|
1410
1428
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "avo",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The command-line interface for Avo",
|
|
6
6
|
"author": "Avo (https://www.avo.app)",
|
|
@@ -48,13 +48,16 @@
|
|
|
48
48
|
"portfinder": "^1.0.28",
|
|
49
49
|
"semver": "^7.3.7",
|
|
50
50
|
"update-notifier": "^6.0.2",
|
|
51
|
-
"uuid": "^
|
|
51
|
+
"uuid": "^9.0.0",
|
|
52
52
|
"write": "^2.0.0",
|
|
53
53
|
"write-json-file": "^5.0.0",
|
|
54
54
|
"yargs": "^17.2.1",
|
|
55
55
|
"yurnalist": "^2.1.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
+
"@types/ignore-walk": "^4.0.0",
|
|
59
|
+
"@types/minimatch": "^5.1.2",
|
|
60
|
+
"@types/node": "^18.7.18",
|
|
58
61
|
"@typescript-eslint/eslint-plugin": "^5.30.5",
|
|
59
62
|
"@typescript-eslint/parser": "^5.30.5",
|
|
60
63
|
"eslint": "^7.32.0 || ^8.2.0",
|