avo 3.2.9-beta.2 → 3.2.10
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/cli.js +42 -21
- package/package.json +3 -2
package/cli.js
CHANGED
|
@@ -113,7 +113,10 @@ let accessToken;
|
|
|
113
113
|
let refreshToken;
|
|
114
114
|
/// //////////////////////////////////////////////////////////////////////
|
|
115
115
|
// REQUEST HANDLING
|
|
116
|
-
function responseToError(response) {
|
|
116
|
+
function responseToError(response, error) {
|
|
117
|
+
if (!response) {
|
|
118
|
+
return new AvoError(error, {});
|
|
119
|
+
}
|
|
117
120
|
let { body } = response;
|
|
118
121
|
if (typeof body === 'string' && response.statusCode === 404) {
|
|
119
122
|
body = {
|
|
@@ -174,15 +177,12 @@ function _request(options) {
|
|
|
174
177
|
got(options)
|
|
175
178
|
.then((response) => {
|
|
176
179
|
if (response.statusCode >= 400) {
|
|
177
|
-
return reject(responseToError(response));
|
|
178
|
-
}
|
|
179
|
-
if (response && response.body) {
|
|
180
|
-
return resolve(JSON.parse(response.body));
|
|
180
|
+
return reject(responseToError(response, null));
|
|
181
181
|
}
|
|
182
|
-
return
|
|
182
|
+
return resolve(JSON.parse(response.body));
|
|
183
183
|
})
|
|
184
184
|
.catch((err) => {
|
|
185
|
-
report.error(`${responseToError(err.response)}\n`);
|
|
185
|
+
report.error(`${responseToError(err.response, err)}\n`);
|
|
186
186
|
reject(new AvoError(`Server Error. ${err.message}`, {
|
|
187
187
|
original: err,
|
|
188
188
|
exit: 2,
|
|
@@ -201,7 +201,7 @@ const _appendQueryData = (urlPath, data) => {
|
|
|
201
201
|
function _refreshAccessToken(refreshToken) {
|
|
202
202
|
return api // eslint-disable-line
|
|
203
203
|
.request('POST', '/auth/refresh', {
|
|
204
|
-
origin: api.apiOrigin,
|
|
204
|
+
origin: api.apiOrigin, // eslint-disable-line
|
|
205
205
|
json: {
|
|
206
206
|
token: refreshToken,
|
|
207
207
|
},
|
|
@@ -1035,7 +1035,7 @@ function findMatches(data, regex) {
|
|
|
1035
1035
|
lastIndex += lines.length;
|
|
1036
1036
|
return fileMatches;
|
|
1037
1037
|
}
|
|
1038
|
-
function getEventMap(data) {
|
|
1038
|
+
function getEventMap(data, verbose) {
|
|
1039
1039
|
const searchFor = 'AVOEVENTMAP:';
|
|
1040
1040
|
const lines = data.split('\n').filter((line) => line.indexOf(searchFor) > -1);
|
|
1041
1041
|
if (lines.length === 1) {
|
|
@@ -1044,9 +1044,12 @@ function getEventMap(data) {
|
|
|
1044
1044
|
const eventMap = JSON.parse(line);
|
|
1045
1045
|
return eventMap;
|
|
1046
1046
|
}
|
|
1047
|
+
if (verbose) {
|
|
1048
|
+
report.error('No event map found');
|
|
1049
|
+
}
|
|
1047
1050
|
return null;
|
|
1048
1051
|
}
|
|
1049
|
-
function getModuleMap(data) {
|
|
1052
|
+
function getModuleMap(data, verbose) {
|
|
1050
1053
|
const searchFor = 'AVOMODULEMAP:';
|
|
1051
1054
|
const lines = data.split('\n').filter((line) => line.indexOf(searchFor) > -1);
|
|
1052
1055
|
if (lines.length === 1) {
|
|
@@ -1055,6 +1058,9 @@ function getModuleMap(data) {
|
|
|
1055
1058
|
const moduleMap = JSON.parse(line);
|
|
1056
1059
|
return moduleMap;
|
|
1057
1060
|
}
|
|
1061
|
+
if (verbose) {
|
|
1062
|
+
report.error('No module map found');
|
|
1063
|
+
}
|
|
1058
1064
|
return null;
|
|
1059
1065
|
}
|
|
1060
1066
|
function getSource(argv, json) {
|
|
@@ -1090,21 +1096,30 @@ function status(source, json, argv) {
|
|
|
1090
1096
|
follow: false,
|
|
1091
1097
|
}).then((results) => Promise.all(results
|
|
1092
1098
|
.filter((result) => !result.startsWith('.git'))
|
|
1093
|
-
.map((resultPath) => pify(fs.lstat)(resultPath)
|
|
1099
|
+
.map((resultPath) => pify(fs.lstat)(resultPath)
|
|
1100
|
+
.then((stats) => {
|
|
1094
1101
|
if (stats.isSymbolicLink()) {
|
|
1095
1102
|
return [];
|
|
1096
1103
|
}
|
|
1097
|
-
return pify(fs.readFile)(resultPath, 'utf8')
|
|
1098
|
-
resultPath,
|
|
1099
|
-
|
|
1100
|
-
|
|
1104
|
+
return pify(fs.readFile)(resultPath, 'utf8')
|
|
1105
|
+
.then((data) => [resultPath, data])
|
|
1106
|
+
.catch((error) => {
|
|
1107
|
+
if (argv.verbose) {
|
|
1108
|
+
report.warn(`Failed to parse file: ${resultPath}`, error);
|
|
1109
|
+
}
|
|
1110
|
+
});
|
|
1111
|
+
})
|
|
1112
|
+
.catch((error) => {
|
|
1113
|
+
if (argv.verbose) {
|
|
1114
|
+
report.warn(`Failed to read file stats: ${resultPath}`, error);
|
|
1115
|
+
}
|
|
1101
1116
|
}))).then((cachePairs) => Object.fromEntries(cachePairs)));
|
|
1102
1117
|
fileCache
|
|
1103
1118
|
.then((cache) => {
|
|
1104
1119
|
sources = Promise.all(sources.map((source) => pify(fs.readFile)(source.path, 'utf8').then((data) => {
|
|
1105
|
-
const eventMap = getEventMap(data);
|
|
1120
|
+
const eventMap = getEventMap(data, argv.verbose);
|
|
1106
1121
|
if (eventMap !== null) {
|
|
1107
|
-
const moduleMap = getModuleMap(data);
|
|
1122
|
+
const moduleMap = getModuleMap(data, argv.verbose);
|
|
1108
1123
|
const sourcePath = path.parse(source.path);
|
|
1109
1124
|
const moduleName = source.analysis?.module ??
|
|
1110
1125
|
moduleMap ??
|
|
@@ -1148,13 +1163,19 @@ function status(source, json, argv) {
|
|
|
1148
1163
|
lookup[cachePath] = value;
|
|
1149
1164
|
}
|
|
1150
1165
|
});
|
|
1166
|
+
if (argv.verbose) {
|
|
1167
|
+
const combinedPaths = [];
|
|
1168
|
+
Object.entries(lookup).forEach(([path, _data]) => {
|
|
1169
|
+
combinedPaths.push(path);
|
|
1170
|
+
});
|
|
1171
|
+
report.info(`Looking for events: ${eventMap.join('\n')}`);
|
|
1172
|
+
report.info(`Looking in module: ${moduleName}`);
|
|
1173
|
+
report.info(`Looking in files: ${combinedPaths.join('\n')}`);
|
|
1174
|
+
}
|
|
1151
1175
|
return Promise.all(eventMap.map((eventName) => {
|
|
1152
1176
|
const re = new RegExp(`(${moduleName}\\.${eventName}|\\[${moduleName} ${eventName})`);
|
|
1153
1177
|
const results = Object.entries(lookup)
|
|
1154
1178
|
.map(([path, data]) => {
|
|
1155
|
-
if (argv.verbose) {
|
|
1156
|
-
report.info(`Looking for events in ${path}`);
|
|
1157
|
-
}
|
|
1158
1179
|
const results = findMatches(data, re);
|
|
1159
1180
|
return results.length ? [[path, results]] : [];
|
|
1160
1181
|
})
|
|
@@ -1870,7 +1891,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
|
|
|
1870
1891
|
.catch(() => {
|
|
1871
1892
|
Avo.signInFailed({
|
|
1872
1893
|
userId_: conf.get('avo_install_id'),
|
|
1873
|
-
emailInput: '',
|
|
1894
|
+
emailInput: '', // XXX this is not passed back here
|
|
1874
1895
|
signInError: Avo.SignInError.UNKNOWN,
|
|
1875
1896
|
});
|
|
1876
1897
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "avo",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The command-line interface for Avo",
|
|
6
6
|
"author": "Avo (https://www.avo.app)",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"node": ">=14.16"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
|
+
"postinstall": "node cli.js track-install",
|
|
20
21
|
"prepublishOnly": "npm run compile",
|
|
21
22
|
"lint": "eslint cli.ts",
|
|
22
23
|
"format": "prettier --write cli.ts",
|
|
@@ -63,7 +64,7 @@
|
|
|
63
64
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
64
65
|
"eslint-config-prettier": "^9.0.0",
|
|
65
66
|
"eslint-plugin-import": "^2.25.2",
|
|
66
|
-
"prettier": "3.
|
|
67
|
+
"prettier": "3.2.5",
|
|
67
68
|
"typescript": "^5.0.2"
|
|
68
69
|
}
|
|
69
70
|
}
|