avo 3.1.0 → 3.2.1

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.
Files changed (2) hide show
  1. package/cli.js +56 -8
  2. package/package.json +3 -2
package/cli.js CHANGED
@@ -167,10 +167,13 @@ function _request(options) {
167
167
  }
168
168
  return resolve(JSON.parse(response.body));
169
169
  })
170
- .catch((err) => reject(new AvoError(`Server Error. ${err.message}`, {
171
- original: err,
172
- exit: 2,
173
- })));
170
+ .catch((err) => {
171
+ report.error(`${responseToError(err.response)}\n`);
172
+ reject(new AvoError(`Server Error. ${err.message}`, {
173
+ original: err,
174
+ exit: 2,
175
+ }));
176
+ });
174
177
  });
175
178
  }
176
179
  const _appendQueryData = (urlPath, data) => {
@@ -773,6 +776,7 @@ function codegen(json, { schema, sources: targets, warnings, success, errors })
773
776
  name: target.name,
774
777
  id: target.id,
775
778
  path: source.path,
779
+ interfacePath: source.interfacePath,
776
780
  branchId: target.branchId,
777
781
  updatedAt: target.updatedAt,
778
782
  };
@@ -887,18 +891,61 @@ function selectSource(sourceToAdd, json) {
887
891
  },
888
892
  });
889
893
  }
890
- return inquirer.prompt(prompts).then((answer) => {
891
- const relativePath = path.relative(process.cwd(), path.join(path.resolve(answer.folder), answer.filename));
894
+ return inquirer.prompt(prompts).then(async (answer) => {
895
+ let answerSource;
896
+ if (sourceToAdd) {
897
+ answerSource = sources.find((soruceToFind) => matchesSource(soruceToFind, sourceToAdd));
898
+ }
899
+ else {
900
+ answerSource = answer.source;
901
+ }
902
+ const moreAnswers = await inquirer.prompt(answerSource.canHaveInterfaceFile === true
903
+ ? [
904
+ {
905
+ type: 'fuzzypath',
906
+ name: 'folder',
907
+ excludePath: (maybeExcludePath) => maybeExcludePath.startsWith('node_modules') ||
908
+ maybeExcludePath.startsWith('.git'),
909
+ itemType: 'directory',
910
+ rootPath: '.',
911
+ message: 'Select a folder to save the analytics wrapper interface file in',
912
+ default: '.',
913
+ suggestOnly: false,
914
+ depthLimit: 10,
915
+ },
916
+ {
917
+ type: 'input',
918
+ name: 'interfaceFilename',
919
+ message: (_answers) => 'Select a filename for the analytics wrapper interface file',
920
+ // @ts-ignore
921
+ default() {
922
+ return answerSource.filenameHint;
923
+ },
924
+ },
925
+ ]
926
+ : []);
927
+ const hasMultiPath = moreAnswers.interfaceFilename != null;
928
+ const relativeMainPath = path.relative(process.cwd(), path.join(path.resolve(answer.folder), answer.filename));
929
+ let relativeInterfacePath = relativeMainPath;
930
+ if (hasMultiPath) {
931
+ relativeInterfacePath = path.relative(process.cwd(), path.join(path.resolve(answer.folder), moreAnswers.interfaceFilename));
932
+ }
892
933
  let source;
893
934
  if (sourceToAdd) {
894
935
  source = sources.find((sourceToFind) => matchesSource(sourceToFind, sourceToAdd));
895
- source = { id: source.id, name: source.name, path: relativePath };
936
+ source = {
937
+ id: source.id,
938
+ name: source.name,
939
+ path: relativeMainPath,
940
+ interfacePath: relativeInterfacePath,
941
+ };
896
942
  }
897
943
  else {
898
944
  source = {
899
945
  id: answer.source.id,
900
946
  name: answer.source.name,
901
- path: relativePath,
947
+ path: relativeMainPath,
948
+ interfacePath: relativeInterfacePath,
902
949
  };
903
950
  }
904
951
  sources = (json.sources ?? []).concat([source]);
@@ -931,6 +978,7 @@ function pull(sourceFilter, json) {
931
978
  sources: sources.map((source) => ({
932
979
  id: source.id,
933
980
  path: source.path,
981
+ interfacePath: source.interfacePath,
934
982
  })),
935
983
  force: json.force ?? false,
936
984
  forceFeatures: json.forceFeatures,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "avo",
3
- "version": "3.1.0",
3
+ "version": "3.2.1",
4
4
  "type": "module",
5
5
  "description": "The command-line interface for Avo",
6
6
  "author": "Avo (https://www.avo.app)",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "scripts": {
20
20
  "postinstall": "node cli.js track-install; true",
21
+ "prepublishOnly": "npm run compile",
21
22
  "lint": "eslint cli.ts",
22
23
  "format": "prettier --write cli.ts",
23
24
  "check-format": "prettier --check cli.ts",
@@ -34,7 +35,7 @@
34
35
  "got": "^12.1.0",
35
36
  "http-shutdown": "^1.2.0",
36
37
  "ignore-walk": "^5.0.1",
37
- "inquirer": "^9.0",
38
+ "inquirer": "^8.0.0",
38
39
  "inquirer-fuzzy-path": "^2.3.0",
39
40
  "jsonwebtoken": "^8.4.0",
40
41
  "load-json-file": "^7.0.1",