avo 3.4.0 → 3.5.0

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 +35 -11
  2. package/package.json +2 -2
package/cli.js CHANGED
@@ -909,6 +909,23 @@ function codegen(json, { schema, sources: targets, warnings, success, errors })
909
909
  function matchesSource(source, filter) {
910
910
  return source.name.toLowerCase() === filter.toLowerCase();
911
911
  }
912
+ // Prompt message helpers — exported for testing
913
+ export function buildFolderMessage(source) {
914
+ const examplePath = source.outputDirExample ?? 'src/analytics';
915
+ const folderDescription = 'Generated telemetry code — place it inside your source tree';
916
+ return `${folderDescription}\n(e.g. ${examplePath})`;
917
+ }
918
+ export function buildInterfaceFolderMessage(source) {
919
+ const examplePath = source.outputDirExample ?? 'src/analytics';
920
+ const interfaceFolderDescription = 'Generated interface file — place it inside your source tree';
921
+ return `${interfaceFolderDescription}\n(e.g. ${examplePath})`;
922
+ }
923
+ export function buildFilenameMessage() {
924
+ return "This file is regenerated on every 'avo pull' — do not edit it manually";
925
+ }
926
+ export function buildInterfaceFilenameMessage() {
927
+ return "This file is regenerated on every 'avo pull' — do not edit it manually";
928
+ }
912
929
  function selectSource(sourceToAdd, json) {
913
930
  wait('Fetching sources');
914
931
  return api
@@ -932,6 +949,14 @@ function selectSource(sourceToAdd, json) {
932
949
  return 1;
933
950
  return 0;
934
951
  });
952
+ // Resolve source early when sourceToAdd is provided, so the folder
953
+ // prompt can show a platform-specific example path
954
+ const resolvedSource = sourceToAdd
955
+ ? sources.find((s) => matchesSource(s, sourceToAdd))
956
+ : null;
957
+ if (sourceToAdd && !resolvedSource) {
958
+ throw new AvoError(`Source ${sourceToAdd} does not exist`);
959
+ }
935
960
  const prompts = [
936
961
  {
937
962
  type: 'fuzzypath',
@@ -940,7 +965,8 @@ function selectSource(sourceToAdd, json) {
940
965
  maybeExcludePath.startsWith('.git'),
941
966
  itemType: 'directory',
942
967
  rootPath: '.',
943
- message: 'Select a folder to save the analytics wrapper in',
968
+ // @ts-ignore — message is a callback to access selected source's outputDirExample
969
+ message: (answers) => buildFolderMessage(answers.source ?? resolvedSource ?? {}),
944
970
  default: '.',
945
971
  suggestOnly: false,
946
972
  depthLimit: 10,
@@ -954,7 +980,7 @@ function selectSource(sourceToAdd, json) {
954
980
  prompts.unshift({
955
981
  type: 'list',
956
982
  name: 'source',
957
- message: 'Select a source to set up',
983
+ message: 'In Avo, a source represents one platform/language target for codegen.\nSelect a source to set up',
958
984
  // @ts-ignore
959
985
  choices,
960
986
  pageSize: 15,
@@ -962,7 +988,7 @@ function selectSource(sourceToAdd, json) {
962
988
  prompts.push({
963
989
  type: 'input',
964
990
  name: 'filename',
965
- message: 'Select a filename for the analytics wrapper',
991
+ message: buildFilenameMessage(),
966
992
  // @ts-ignore
967
993
  default(answers) {
968
994
  return answers.source.filenameHint;
@@ -970,14 +996,11 @@ function selectSource(sourceToAdd, json) {
970
996
  });
971
997
  }
972
998
  else {
973
- const source = sources.find((soruceToFind) => matchesSource(soruceToFind, sourceToAdd));
974
- if (!source) {
975
- throw new AvoError(`Source ${sourceToAdd} does not exist`);
976
- }
999
+ const source = resolvedSource;
977
1000
  prompts.push({
978
1001
  type: 'input',
979
1002
  name: 'filename',
980
- message: 'Select a filename for the library',
1003
+ message: buildFilenameMessage(),
981
1004
  // @ts-ignore
982
1005
  default() {
983
1006
  return source.filenameHint;
@@ -1001,7 +1024,7 @@ function selectSource(sourceToAdd, json) {
1001
1024
  maybeExcludePath.startsWith('.git'),
1002
1025
  itemType: 'directory',
1003
1026
  rootPath: '.',
1004
- message: 'Select a folder to save the analytics wrapper interface file in',
1027
+ message: buildInterfaceFolderMessage(answerSource),
1005
1028
  default: '.',
1006
1029
  suggestOnly: false,
1007
1030
  depthLimit: 10,
@@ -1009,10 +1032,11 @@ function selectSource(sourceToAdd, json) {
1009
1032
  {
1010
1033
  type: 'input',
1011
1034
  name: 'interfaceFilename',
1012
- message: (_answers) => 'Select a filename for the analytics wrapper interface file',
1035
+ message: buildInterfaceFilenameMessage(),
1013
1036
  // @ts-ignore
1014
1037
  default() {
1015
- return answerSource.filenameHint;
1038
+ return (answerSource.interfaceFilenameHint ??
1039
+ answerSource.filenameHint);
1016
1040
  },
1017
1041
  },
1018
1042
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "avo",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "type": "module",
5
5
  "description": "The command-line interface for Avo",
6
6
  "author": "Avo (https://www.avo.app)",
@@ -67,7 +67,7 @@
67
67
  "eslint-config-prettier": "^10.0.1",
68
68
  "eslint-plugin-import": "^2.25.2",
69
69
  "jest": "^29.7.0",
70
- "prettier": "3.6.2",
70
+ "prettier": "3.8.1",
71
71
  "ts-jest": "^29.4.5",
72
72
  "typescript": "^5.0.2"
73
73
  },