@speleotica/frcsdata 5.0.0-beta.3 → 5.0.0-beta.5

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 (98) hide show
  1. package/cli/{check-survey-correspondence.d.ts → check-correspondence.d.ts} +1 -1
  2. package/cli/check-correspondence.d.ts.map +1 -0
  3. package/cli/{check-survey-correspondence.js → check-correspondence.js} +4 -5
  4. package/cli/check-correspondence.js.map +1 -0
  5. package/cli/{check-survey.d.ts → check.d.ts} +1 -1
  6. package/cli/check.d.ts.map +1 -0
  7. package/cli/{check-survey.js → check.js} +3 -3
  8. package/cli/check.js.map +1 -0
  9. package/cli/compareNames.d.ts +2 -0
  10. package/cli/compareNames.d.ts.map +1 -0
  11. package/cli/compareNames.js +15 -0
  12. package/cli/compareNames.js.map +1 -0
  13. package/cli/formatNamesFile.d.ts +4 -0
  14. package/cli/formatNamesFile.d.ts.map +1 -0
  15. package/cli/formatNamesFile.js +13 -0
  16. package/cli/formatNamesFile.js.map +1 -0
  17. package/cli/list-names.d.ts +5 -0
  18. package/cli/list-names.d.ts.map +1 -0
  19. package/cli/list-names.js +74 -0
  20. package/cli/list-names.js.map +1 -0
  21. package/cli/merge-names-files.d.ts +2 -0
  22. package/cli/merge-names-files.d.ts.map +1 -0
  23. package/cli/merge-names-files.js +25 -0
  24. package/cli/merge-names-files.js.map +1 -0
  25. package/cli/parse-survey.d.ts.map +1 -1
  26. package/cli/parse-survey.js +3 -2
  27. package/cli/parse-survey.js.map +1 -1
  28. package/cli/parseNamesFile.d.ts +4 -0
  29. package/cli/parseNamesFile.d.ts.map +1 -0
  30. package/cli/parseNamesFile.js +19 -0
  31. package/cli/parseNamesFile.js.map +1 -0
  32. package/cli/readFile.d.ts +2 -0
  33. package/cli/readFile.d.ts.map +1 -0
  34. package/cli/readFile.js +13 -0
  35. package/cli/readFile.js.map +1 -0
  36. package/cli/replace-names.d.ts +2 -0
  37. package/cli/replace-names.d.ts.map +1 -0
  38. package/cli/replace-names.js +45 -0
  39. package/cli/replace-names.js.map +1 -0
  40. package/cli/{summarize-survey.d.ts → summarize.d.ts} +1 -1
  41. package/cli/summarize.d.ts.map +1 -0
  42. package/cli/{summarize-survey.js → summarize.js} +3 -3
  43. package/cli/summarize.js.map +1 -0
  44. package/cli.js +72 -7
  45. package/cli.js.map +1 -1
  46. package/index.d.ts +8 -6
  47. package/index.d.ts.map +1 -1
  48. package/index.js +7 -28
  49. package/index.js.map +1 -1
  50. package/node/index.d.ts +1 -1
  51. package/node/index.d.ts.map +1 -1
  52. package/package.json +2 -1
  53. package/replaceRanges.d.ts +6 -0
  54. package/replaceRanges.d.ts.map +1 -0
  55. package/replaceRanges.js +23 -0
  56. package/replaceRanges.js.map +1 -0
  57. package/src/cli/{check-survey-correspondence.ts → check-correspondence.ts} +6 -5
  58. package/src/cli/{check-survey.ts → check.ts} +2 -2
  59. package/src/cli/compareNames.ts +13 -0
  60. package/src/cli/formatNamesFile.ts +13 -0
  61. package/src/cli/list-names.ts +94 -0
  62. package/src/cli/merge-names-files.ts +18 -0
  63. package/src/cli/parse-survey.ts +3 -2
  64. package/src/cli/parseNamesFile.ts +10 -0
  65. package/src/cli/readFile.ts +6 -0
  66. package/src/cli/replace-names.ts +41 -0
  67. package/src/cli/{summarize-survey.ts → summarize.ts} +2 -2
  68. package/src/cli.ts +67 -7
  69. package/src/index.ts +22 -7
  70. package/src/replaceRanges.ts +21 -0
  71. package/src/survey/FrcsSurveyFile.ts +1 -0
  72. package/src/survey/ZodFrcsSurveyFileJson.ts +1 -0
  73. package/src/survey/normalizeTeamMemberName.ts +15 -3
  74. package/src/survey/parseFrcsSurveyFile.ts +210 -9
  75. package/string/index.d.ts +1 -1
  76. package/string/index.d.ts.map +1 -1
  77. package/survey/FrcsSurveyFile.d.ts +1 -0
  78. package/survey/FrcsSurveyFile.d.ts.map +1 -1
  79. package/survey/FrcsSurveyFile.js.map +1 -1
  80. package/survey/ZodFrcsSurveyFileJson.d.ts +283 -280
  81. package/survey/ZodFrcsSurveyFileJson.d.ts.map +1 -1
  82. package/survey/ZodFrcsSurveyFileJson.js +2 -1
  83. package/survey/ZodFrcsSurveyFileJson.js.map +1 -1
  84. package/survey/ZodFrcsSurveyFileToJson.d.ts +280 -280
  85. package/survey/normalizeTeamMemberName.d.ts +1 -0
  86. package/survey/normalizeTeamMemberName.d.ts.map +1 -1
  87. package/survey/normalizeTeamMemberName.js +11 -1
  88. package/survey/normalizeTeamMemberName.js.map +1 -1
  89. package/survey/parseFrcsSurveyFile.d.ts +1 -1
  90. package/survey/parseFrcsSurveyFile.d.ts.map +1 -1
  91. package/survey/parseFrcsSurveyFile.js +140 -13
  92. package/survey/parseFrcsSurveyFile.js.map +1 -1
  93. package/cli/check-survey-correspondence.d.ts.map +0 -1
  94. package/cli/check-survey-correspondence.js.map +0 -1
  95. package/cli/check-survey.d.ts.map +0 -1
  96. package/cli/check-survey.js.map +0 -1
  97. package/cli/summarize-survey.d.ts.map +0 -1
  98. package/cli/summarize-survey.js.map +0 -1
@@ -1,2 +1,2 @@
1
1
  export declare function checkSurveyCorrespondence(surveyFile: string, summaryFile: string): Promise<void>;
2
- //# sourceMappingURL=check-survey-correspondence.d.ts.map
2
+ //# sourceMappingURL=check-correspondence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-correspondence.d.ts","sourceRoot":"","sources":["../../src/cli/check-correspondence.ts"],"names":[],"mappings":"AAQA,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,iBAuCpB"}
@@ -7,17 +7,16 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.checkSurveyCorrespondence = checkSurveyCorrespondence;
8
8
  var _chalk = _interopRequireDefault(require("chalk"));
9
9
  var _index = require("../string/index.js");
10
- var _promises = _interopRequireDefault(require("fs/promises"));
11
10
  var _summarizeSurvey = require("../survey/summarizeSurvey.js");
12
- var _index2 = require("../node/index.js");
13
11
  var _formatFrcsTripSummaryFile = require("../formatFrcsTripSummaryFile.js");
14
12
  var _util = require("util");
13
+ var _readFile = require("./readFile.js");
15
14
  /* eslint-disable no-console */
16
15
 
17
16
  async function checkSurveyCorrespondence(surveyFile, summaryFile) {
18
- const source = await _promises.default.readFile(surveyFile, 'utf8');
17
+ const source = await (0, _readFile.readFile)(surveyFile);
19
18
  const parsedSurvey = await (0, _index.parseFrcsSurveyFile)(surveyFile, source);
20
- const parsedSummaries = (await (0, _index2.parseFrcsTripSummaryFile)(summaryFile, {
19
+ const parsedSummaries = (await (0, _index.parseFrcsTripSummaryFile)(summaryFile, await (0, _readFile.readFile)(summaryFile), {
21
20
  indexBy: 'occurrence'
22
21
  })).tripSummaries.sort((a, b) => (a?.tripNumber ?? 0) - (b?.tripNumber ?? 0));
23
22
  const convertedSummaries = (0, _summarizeSurvey.summarizeSurvey)(parsedSurvey, {
@@ -41,4 +40,4 @@ async function checkSurveyCorrespondence(surveyFile, summaryFile) {
41
40
  }
42
41
  process.exit(errored ? 1 : 0);
43
42
  }
44
- //# sourceMappingURL=check-survey-correspondence.js.map
43
+ //# sourceMappingURL=check-correspondence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-correspondence.js","names":["_chalk","_interopRequireDefault","require","_index","_summarizeSurvey","_formatFrcsTripSummaryFile","_util","_readFile","checkSurveyCorrespondence","surveyFile","summaryFile","source","readFile","parsedSurvey","parseFrcsSurveyFile","parsedSummaries","parseFrcsTripSummaryFile","indexBy","tripSummaries","sort","a","b","tripNumber","convertedSummaries","summarizeSurvey","ignoreVerticalOfHShots","errored","i","Math","max","length","parsed","converted","parsedLines","formatFrcsTripSummaryFile","slice","convertedLines","isDeepStrictEqual","console","log","map","line","chalk","green","join","red","process","exit"],"sources":["../../src/cli/check-correspondence.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport chalk from 'chalk'\nimport { parseFrcsSurveyFile, parseFrcsTripSummaryFile } from '../string/index'\nimport { summarizeSurvey } from '../survey/summarizeSurvey'\nimport { formatFrcsTripSummaryFile } from '../formatFrcsTripSummaryFile.js'\nimport { isDeepStrictEqual } from 'util'\nimport { readFile } from './readFile'\n\nexport async function checkSurveyCorrespondence(\n surveyFile: string,\n summaryFile: string\n) {\n const source = await readFile(surveyFile)\n const parsedSurvey = await parseFrcsSurveyFile(surveyFile, source)\n const parsedSummaries = (\n await parseFrcsTripSummaryFile(summaryFile, await readFile(summaryFile), {\n indexBy: 'occurrence',\n })\n ).tripSummaries.sort((a, b) => (a?.tripNumber ?? 0) - (b?.tripNumber ?? 0))\n const convertedSummaries = summarizeSurvey(parsedSurvey, {\n ignoreVerticalOfHShots: true,\n }).tripSummaries.sort((a, b) => (a?.tripNumber ?? 0) - (b?.tripNumber ?? 0))\n\n let errored = false\n\n for (\n let i = 0;\n i < Math.max(parsedSummaries.length, convertedSummaries.length);\n i++\n ) {\n const parsed = parsedSummaries[i]\n const converted = convertedSummaries[i]\n\n const parsedLines = [\n ...formatFrcsTripSummaryFile({ tripSummaries: [parsed] }),\n ].slice(0, 2)\n const convertedLines = [\n ...formatFrcsTripSummaryFile({ tripSummaries: [converted] }),\n ].slice(0, 2)\n\n if (!isDeepStrictEqual(parsedLines, convertedLines)) {\n errored = true\n console.log(\n convertedLines.map((line) => chalk.green('+' + line)).join('\\n')\n )\n console.log(parsedLines.map((line) => chalk.red('-' + line)).join('\\n'))\n }\n }\n process.exit(errored ? 1 : 0)\n}\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,0BAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AANA;;AAQO,eAAeM,yBAAyBA,CAC7CC,UAAkB,EAClBC,WAAmB,EACnB;EACA,MAAMC,MAAM,GAAG,MAAM,IAAAC,kBAAQ,EAACH,UAAU,CAAC;EACzC,MAAMI,YAAY,GAAG,MAAM,IAAAC,0BAAmB,EAACL,UAAU,EAAEE,MAAM,CAAC;EAClE,MAAMI,eAAe,GAAG,CACtB,MAAM,IAAAC,+BAAwB,EAACN,WAAW,EAAE,MAAM,IAAAE,kBAAQ,EAACF,WAAW,CAAC,EAAE;IACvEO,OAAO,EAAE;EACX,CAAC,CAAC,EACFC,aAAa,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAK,CAACD,CAAC,EAAEE,UAAU,IAAI,CAAC,KAAKD,CAAC,EAAEC,UAAU,IAAI,CAAC,CAAC,CAAC;EAC3E,MAAMC,kBAAkB,GAAG,IAAAC,gCAAe,EAACX,YAAY,EAAE;IACvDY,sBAAsB,EAAE;EAC1B,CAAC,CAAC,CAACP,aAAa,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAK,CAACD,CAAC,EAAEE,UAAU,IAAI,CAAC,KAAKD,CAAC,EAAEC,UAAU,IAAI,CAAC,CAAC,CAAC;EAE5E,IAAII,OAAO,GAAG,KAAK;EAEnB,KACE,IAAIC,CAAC,GAAG,CAAC,EACTA,CAAC,GAAGC,IAAI,CAACC,GAAG,CAACd,eAAe,CAACe,MAAM,EAAEP,kBAAkB,CAACO,MAAM,CAAC,EAC/DH,CAAC,EAAE,EACH;IACA,MAAMI,MAAM,GAAGhB,eAAe,CAACY,CAAC,CAAC;IACjC,MAAMK,SAAS,GAAGT,kBAAkB,CAACI,CAAC,CAAC;IAEvC,MAAMM,WAAW,GAAG,CAClB,GAAG,IAAAC,oDAAyB,EAAC;MAAEhB,aAAa,EAAE,CAACa,MAAM;IAAE,CAAC,CAAC,CAC1D,CAACI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;IACb,MAAMC,cAAc,GAAG,CACrB,GAAG,IAAAF,oDAAyB,EAAC;MAAEhB,aAAa,EAAE,CAACc,SAAS;IAAE,CAAC,CAAC,CAC7D,CAACG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;IAEb,IAAI,CAAC,IAAAE,uBAAiB,EAACJ,WAAW,EAAEG,cAAc,CAAC,EAAE;MACnDV,OAAO,GAAG,IAAI;MACdY,OAAO,CAACC,GAAG,CACTH,cAAc,CAACI,GAAG,CAAEC,IAAI,IAAKC,cAAK,CAACC,KAAK,CAAC,GAAG,GAAGF,IAAI,CAAC,CAAC,CAACG,IAAI,CAAC,IAAI,CACjE,CAAC;MACDN,OAAO,CAACC,GAAG,CAACN,WAAW,CAACO,GAAG,CAAEC,IAAI,IAAKC,cAAK,CAACG,GAAG,CAAC,GAAG,GAAGJ,IAAI,CAAC,CAAC,CAACG,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1E;EACF;EACAE,OAAO,CAACC,IAAI,CAACrB,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;AAC/B","ignoreList":[]}
@@ -1,2 +1,2 @@
1
1
  export declare function checkSurvey(file: string): Promise<void>;
2
- //# sourceMappingURL=check-survey.d.ts.map
2
+ //# sourceMappingURL=check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/cli/check.ts"],"names":[],"mappings":"AAMA,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,iBAgB7C"}
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.checkSurvey = checkSurvey;
8
- var _promises = _interopRequireDefault(require("fs/promises"));
8
+ var _readFile = require("./readFile.js");
9
9
  var _parseFrcsSurveyFile = _interopRequireDefault(require("../survey/parseFrcsSurveyFile.js"));
10
10
  var _chalk = _interopRequireDefault(require("chalk"));
11
11
  var _formatIssues = require("../formatIssues.js");
12
12
  /* eslint-disable no-console */
13
13
 
14
14
  async function checkSurvey(file) {
15
- const source = await _promises.default.readFile(file, 'utf8');
15
+ const source = await (0, _readFile.readFile)(file);
16
16
  const parsed = await (0, _parseFrcsSurveyFile.default)(file, [source]);
17
17
  const issues = parsed.issues || [];
18
18
  console.log((0, _formatIssues.formatIssues)({
@@ -24,4 +24,4 @@ async function checkSurvey(file) {
24
24
  }));
25
25
  process.exit(issues.some(i => i.type === 'error') ? 1 : 0);
26
26
  }
27
- //# sourceMappingURL=check-survey.js.map
27
+ //# sourceMappingURL=check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.js","names":["_readFile","require","_parseFrcsSurveyFile","_interopRequireDefault","_chalk","_formatIssues","checkSurvey","file","source","readFile","parsed","parseFrcsSurveyFile","issues","console","log","formatIssues","errorStyle","chalk","red","warningStyle","yellow","process","exit","some","i","type"],"sources":["../../src/cli/check.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport { readFile } from './readFile'\nimport parseFrcsSurveyFile from '../survey/parseFrcsSurveyFile'\nimport chalk from 'chalk'\nimport { formatIssues } from '../formatIssues.js'\n\nexport async function checkSurvey(file: string) {\n const source = await readFile(file)\n const parsed = await parseFrcsSurveyFile(file, [source])\n\n const issues = parsed.issues || []\n console.log(\n formatIssues({\n file,\n source,\n parsed,\n errorStyle: chalk.red,\n warningStyle: chalk.yellow,\n })\n )\n\n process.exit(issues.some((i) => i.type === 'error') ? 1 : 0)\n}\n"],"mappings":";;;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAJA;;AAMO,eAAeK,WAAWA,CAACC,IAAY,EAAE;EAC9C,MAAMC,MAAM,GAAG,MAAM,IAAAC,kBAAQ,EAACF,IAAI,CAAC;EACnC,MAAMG,MAAM,GAAG,MAAM,IAAAC,4BAAmB,EAACJ,IAAI,EAAE,CAACC,MAAM,CAAC,CAAC;EAExD,MAAMI,MAAM,GAAGF,MAAM,CAACE,MAAM,IAAI,EAAE;EAClCC,OAAO,CAACC,GAAG,CACT,IAAAC,0BAAY,EAAC;IACXR,IAAI;IACJC,MAAM;IACNE,MAAM;IACNM,UAAU,EAAEC,cAAK,CAACC,GAAG;IACrBC,YAAY,EAAEF,cAAK,CAACG;EACtB,CAAC,CACH,CAAC;EAEDC,OAAO,CAACC,IAAI,CAACV,MAAM,CAACW,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,IAAI,KAAK,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC9D","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export declare function compareNames(a: string, b: string): number;
2
+ //# sourceMappingURL=compareNames.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compareNames.d.ts","sourceRoot":"","sources":["../../src/cli/compareNames.ts"],"names":[],"mappings":"AAIA,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,UAQhD"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.compareNames = compareNames;
7
+ const splitName = name => {
8
+ return /^(.+)\s+(\S+)$/.exec(name)?.slice(1) || ['', name];
9
+ };
10
+ function compareNames(a, b) {
11
+ const [aFirst, aLast] = splitName(a.toLowerCase());
12
+ const [bFirst, bLast] = splitName(b.toLowerCase());
13
+ return aLast.localeCompare(bLast) || aFirst.localeCompare(bFirst) || a[0].localeCompare(b[0]);
14
+ }
15
+ //# sourceMappingURL=compareNames.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compareNames.js","names":["splitName","name","exec","slice","compareNames","a","b","aFirst","aLast","toLowerCase","bFirst","bLast","localeCompare"],"sources":["../../src/cli/compareNames.ts"],"sourcesContent":["const splitName = (name: string) => {\n return /^(.+)\\s+(\\S+)$/.exec(name)?.slice(1) || ['', name]\n}\n\nexport function compareNames(a: string, b: string) {\n const [aFirst, aLast] = splitName(a.toLowerCase())\n const [bFirst, bLast] = splitName(b.toLowerCase())\n return (\n aLast.localeCompare(bLast) ||\n aFirst.localeCompare(bFirst) ||\n a[0].localeCompare(b[0])\n )\n}\n"],"mappings":";;;;;;AAAA,MAAMA,SAAS,GAAIC,IAAY,IAAK;EAClC,OAAO,gBAAgB,CAACC,IAAI,CAACD,IAAI,CAAC,EAAEE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAEF,IAAI,CAAC;AAC5D,CAAC;AAEM,SAASG,YAAYA,CAACC,CAAS,EAAEC,CAAS,EAAE;EACjD,MAAM,CAACC,MAAM,EAAEC,KAAK,CAAC,GAAGR,SAAS,CAACK,CAAC,CAACI,WAAW,CAAC,CAAC,CAAC;EAClD,MAAM,CAACC,MAAM,EAAEC,KAAK,CAAC,GAAGX,SAAS,CAACM,CAAC,CAACG,WAAW,CAAC,CAAC,CAAC;EAClD,OACED,KAAK,CAACI,aAAa,CAACD,KAAK,CAAC,IAC1BJ,MAAM,CAACK,aAAa,CAACF,MAAM,CAAC,IAC5BL,CAAC,CAAC,CAAC,CAAC,CAACO,aAAa,CAACN,CAAC,CAAC,CAAC,CAAC,CAAC;AAE5B","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export declare function formatNamesFile(names: Map<string, {
2
+ replacement?: string;
3
+ }>): string;
4
+ //# sourceMappingURL=formatNamesFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatNamesFile.d.ts","sourceRoot":"","sources":["../../src/cli/formatNamesFile.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,UAU3E"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.formatNamesFile = formatNamesFile;
7
+ var _compareNames = require("./compareNames.js");
8
+ function formatNamesFile(names) {
9
+ return [...names.entries()].sort((a, b) => (0, _compareNames.compareNames)(a[0], b[0])).map(([name, {
10
+ replacement
11
+ }]) => `${name}${replacement ? ` => ${replacement}` : ''}`).join('\n') + '\n';
12
+ }
13
+ //# sourceMappingURL=formatNamesFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatNamesFile.js","names":["_compareNames","require","formatNamesFile","names","entries","sort","a","b","compareNames","map","name","replacement","join"],"sources":["../../src/cli/formatNamesFile.ts"],"sourcesContent":["import { compareNames } from './compareNames'\n\nexport function formatNamesFile(names: Map<string, { replacement?: string }>) {\n return (\n [...names.entries()]\n .sort((a, b) => compareNames(a[0], b[0]))\n .map(\n ([name, { replacement }]) =>\n `${name}${replacement ? ` => ${replacement}` : ''}`\n )\n .join('\\n') + '\\n'\n )\n}\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAEO,SAASC,eAAeA,CAACC,KAA4C,EAAE;EAC5E,OACE,CAAC,GAAGA,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC,CACjBC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAK,IAAAC,0BAAY,EAACF,CAAC,CAAC,CAAC,CAAC,EAAEC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACxCE,GAAG,CACF,CAAC,CAACC,IAAI,EAAE;IAAEC;EAAY,CAAC,CAAC,KACtB,GAAGD,IAAI,GAAGC,WAAW,GAAG,OAAOA,WAAW,EAAE,GAAG,EAAE,EACrD,CAAC,CACAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI;AAExB","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ export declare function listSurveyNames(file: string, options?: {
2
+ includeCounts?: boolean;
3
+ suggestReplacements?: boolean;
4
+ }): Promise<void>;
5
+ //# sourceMappingURL=list-names.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-names.d.ts","sourceRoot":"","sources":["../../src/cli/list-names.ts"],"names":[],"mappings":"AASA,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAAE,iBAyErE"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.listSurveyNames = listSurveyNames;
7
+ var _index = require("../string/index.js");
8
+ var _normalizeTeamMemberName = require("../survey/normalizeTeamMemberName.js");
9
+ var _ZodFrcsSurveyFileToJson = require("../survey/ZodFrcsSurveyFileToJson.js");
10
+ var _unwrapInvalid = require("../unwrapInvalid.js");
11
+ var _groupBy = require("@jcoreio/utils/groupBy");
12
+ var _compareNames = require("./compareNames.js");
13
+ var _readFile = require("./readFile.js");
14
+ /* eslint-disable no-console */
15
+
16
+ async function listSurveyNames(file, options) {
17
+ const parsed = _ZodFrcsSurveyFileToJson.ZodValidOrInvalidFrcsSurveyFileToJson.parse(await (0, _index.parseFrcsSurveyFile)(file, await (0, _readFile.readFile)(file), {
18
+ normalizeNames: false
19
+ }));
20
+ const nameCounts = new Map();
21
+ for (const trip of (0, _unwrapInvalid.unwrapInvalid)(parsed).trips) {
22
+ const {
23
+ team
24
+ } = (0, _unwrapInvalid.unwrapInvalid)((0, _unwrapInvalid.unwrapInvalid)(trip).header);
25
+ if (!team) continue;
26
+ for (const name of team) {
27
+ nameCounts.set(name, (nameCounts.get(name) ?? 0) + 1);
28
+ }
29
+ }
30
+ const table = [...nameCounts.entries()].sort((a, b) => (0, _compareNames.compareNames)(a[0], b[0]));
31
+ const maxNameCount = table.reduce((max, [, count]) => Math.max(max, count), 0);
32
+ const countLength = maxNameCount.toFixed().length;
33
+ const includeCounts = options?.includeCounts ?? false;
34
+ const names = [...nameCounts.keys()];
35
+ const replacements = new Map();
36
+ if (options?.suggestReplacements) {
37
+ for (const group of (0, _groupBy.groupBy)(names, name => name.toLowerCase()).values()) {
38
+ if (group.length === 1) {
39
+ const [name] = group;
40
+ const normalized = (0, _normalizeTeamMemberName.normalizeNameCapitalization)(name);
41
+ if (normalized !== name) replacements.set(name, normalized);
42
+ continue;
43
+ }
44
+ const best = group.map(name => (0, _normalizeTeamMemberName.normalizeNameCapitalization)(name)).reduce((a, b) => countCaps(a) > countCaps(b) ? a : b);
45
+ for (const name of group) {
46
+ if (name !== best) replacements.set(name, best);
47
+ }
48
+ }
49
+ const firstInitials = (0, _groupBy.groupBy)(names.filter(name => /^\S[. ]/.test(name)), name => name.toLowerCase().replace(/\.\s*/g, ' '));
50
+ for (const name of names) {
51
+ if (/^\S[. ]/.test(name)) continue;
52
+ const firstInitial = name.toLowerCase().replace(/^\S+/, m => m.substring(0, 1)).replace(/\.\s*/g, ' ');
53
+ const matches = firstInitials.get(firstInitial);
54
+ if (matches) {
55
+ for (const match of matches) {
56
+ replacements.set(match, replacements.get(name) ?? name);
57
+ }
58
+ }
59
+ }
60
+ }
61
+ for (const [name, count] of table) {
62
+ const replacement = replacements.get(name);
63
+ if (includeCounts) console.log(count.toFixed().padStart(countLength), name, ...(replacement ? ['=>', replacement] : []));else console.log(name, ...(replacement ? ['=>', replacement] : []));
64
+ }
65
+ }
66
+ const countCaps = name => {
67
+ const lower = name.toLowerCase();
68
+ let count = 0;
69
+ for (let i = 0; i < name.length; i++) {
70
+ if (name[i] !== lower[i]) count++;
71
+ }
72
+ return count;
73
+ };
74
+ //# sourceMappingURL=list-names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-names.js","names":["_index","require","_normalizeTeamMemberName","_ZodFrcsSurveyFileToJson","_unwrapInvalid","_groupBy","_compareNames","_readFile","listSurveyNames","file","options","parsed","ZodValidOrInvalidFrcsSurveyFileToJson","parse","parseFrcsSurveyFile","readFile","normalizeNames","nameCounts","Map","trip","unwrapInvalid","trips","team","header","name","set","get","table","entries","sort","a","b","compareNames","maxNameCount","reduce","max","count","Math","countLength","toFixed","length","includeCounts","names","keys","replacements","suggestReplacements","group","groupBy","toLowerCase","values","normalized","normalizeNameCapitalization","best","map","countCaps","firstInitials","filter","test","replace","firstInitial","m","substring","matches","match","replacement","console","log","padStart","lower","i"],"sources":["../../src/cli/list-names.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport { parseFrcsSurveyFile } from '../string/index'\nimport { normalizeNameCapitalization } from '../survey/normalizeTeamMemberName'\nimport { ZodValidOrInvalidFrcsSurveyFileToJson } from '../survey/ZodFrcsSurveyFileToJson'\nimport { unwrapInvalid } from '../unwrapInvalid'\nimport { groupBy } from '@jcoreio/utils/groupBy'\nimport { compareNames } from './compareNames'\nimport { readFile } from './readFile'\n\nexport async function listSurveyNames(\n file: string,\n options?: { includeCounts?: boolean; suggestReplacements?: boolean }\n) {\n const parsed = ZodValidOrInvalidFrcsSurveyFileToJson.parse(\n await parseFrcsSurveyFile(file, await readFile(file), {\n normalizeNames: false,\n })\n )\n const nameCounts = new Map<string, number>()\n for (const trip of unwrapInvalid(parsed).trips) {\n const { team } = unwrapInvalid(unwrapInvalid(trip).header)\n if (!team) continue\n for (const name of team) {\n nameCounts.set(name, (nameCounts.get(name) ?? 0) + 1)\n }\n }\n\n const table = [...nameCounts.entries()].sort((a, b) =>\n compareNames(a[0], b[0])\n )\n const maxNameCount = table.reduce((max, [, count]) => Math.max(max, count), 0)\n const countLength = maxNameCount.toFixed().length\n\n const includeCounts = options?.includeCounts ?? false\n\n const names = [...nameCounts.keys()]\n\n const replacements = new Map<string, string>()\n if (options?.suggestReplacements) {\n for (const group of groupBy(names, (name) => name.toLowerCase()).values()) {\n if (group.length === 1) {\n const [name] = group\n const normalized = normalizeNameCapitalization(name)\n if (normalized !== name) replacements.set(name, normalized)\n continue\n }\n const best = group\n .map((name) => normalizeNameCapitalization(name))\n .reduce((a, b) => (countCaps(a) > countCaps(b) ? a : b))\n for (const name of group) {\n if (name !== best) replacements.set(name, best)\n }\n }\n\n const firstInitials = groupBy(\n names.filter((name) => /^\\S[. ]/.test(name)),\n (name) => name.toLowerCase().replace(/\\.\\s*/g, ' ')\n )\n\n for (const name of names) {\n if (/^\\S[. ]/.test(name)) continue\n const firstInitial = name\n .toLowerCase()\n .replace(/^\\S+/, (m) => m.substring(0, 1))\n .replace(/\\.\\s*/g, ' ')\n const matches = firstInitials.get(firstInitial)\n if (matches) {\n for (const match of matches) {\n replacements.set(match, replacements.get(name) ?? name)\n }\n }\n }\n }\n\n for (const [name, count] of table) {\n const replacement = replacements.get(name)\n if (includeCounts)\n console.log(\n count.toFixed().padStart(countLength),\n name,\n ...(replacement ? ['=>', replacement] : [])\n )\n else console.log(name, ...(replacement ? ['=>', replacement] : []))\n }\n}\n\nconst countCaps = (name: string) => {\n const lower = name.toLowerCase()\n let count = 0\n for (let i = 0; i < name.length; i++) {\n if (name[i] !== lower[i]) count++\n }\n return count\n}\n"],"mappings":"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","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export declare function mergeNamesFiles(...files: string[]): Promise<void>;
2
+ //# sourceMappingURL=merge-names-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-names-files.d.ts","sourceRoot":"","sources":["../../src/cli/merge-names-files.ts"],"names":[],"mappings":"AAIA,wBAAsB,eAAe,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,iBAavD"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.mergeNamesFiles = mergeNamesFiles;
7
+ var _parseNamesFile = require("./parseNamesFile.js");
8
+ var _formatNamesFile = require("./formatNamesFile.js");
9
+ var _readFile = require("./readFile.js");
10
+ async function mergeNamesFiles(...files) {
11
+ const names = new Map();
12
+ for (const file of files) {
13
+ const parsed = (0, _parseNamesFile.parseNamesFile)(await (0, _readFile.readFile)(file));
14
+ for (const [name, {
15
+ replacement
16
+ }] of parsed) {
17
+ const existing = names.get(name);
18
+ if (!existing) names.set(name, {
19
+ replacement
20
+ });else if (!existing.replacement) existing.replacement = replacement;
21
+ }
22
+ }
23
+ process.stdout.write((0, _formatNamesFile.formatNamesFile)(names));
24
+ }
25
+ //# sourceMappingURL=merge-names-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-names-files.js","names":["_parseNamesFile","require","_formatNamesFile","_readFile","mergeNamesFiles","files","names","Map","file","parsed","parseNamesFile","readFile","name","replacement","existing","get","set","process","stdout","write","formatNamesFile"],"sources":["../../src/cli/merge-names-files.ts"],"sourcesContent":["import { parseNamesFile } from './parseNamesFile'\nimport { formatNamesFile } from './formatNamesFile'\nimport { readFile } from './readFile'\n\nexport async function mergeNamesFiles(...files: string[]) {\n const names = new Map<string, { replacement?: string }>()\n\n for (const file of files) {\n const parsed = parseNamesFile(await readFile(file))\n for (const [name, { replacement }] of parsed) {\n const existing = names.get(name)\n if (!existing) names.set(name, { replacement })\n else if (!existing.replacement) existing.replacement = replacement\n }\n }\n\n process.stdout.write(formatNamesFile(names))\n}\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEO,eAAeG,eAAeA,CAAC,GAAGC,KAAe,EAAE;EACxD,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAAmC,CAAC;EAEzD,KAAK,MAAMC,IAAI,IAAIH,KAAK,EAAE;IACxB,MAAMI,MAAM,GAAG,IAAAC,8BAAc,EAAC,MAAM,IAAAC,kBAAQ,EAACH,IAAI,CAAC,CAAC;IACnD,KAAK,MAAM,CAACI,IAAI,EAAE;MAAEC;IAAY,CAAC,CAAC,IAAIJ,MAAM,EAAE;MAC5C,MAAMK,QAAQ,GAAGR,KAAK,CAACS,GAAG,CAACH,IAAI,CAAC;MAChC,IAAI,CAACE,QAAQ,EAAER,KAAK,CAACU,GAAG,CAACJ,IAAI,EAAE;QAAEC;MAAY,CAAC,CAAC,MAC1C,IAAI,CAACC,QAAQ,CAACD,WAAW,EAAEC,QAAQ,CAACD,WAAW,GAAGA,WAAW;IACpE;EACF;EAEAI,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC,IAAAC,gCAAe,EAACd,KAAK,CAAC,CAAC;AAC9C","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"parse-survey.d.ts","sourceRoot":"","sources":["../../src/cli/parse-survey.ts"],"names":[],"mappings":"AAIA,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,iBAK7C"}
1
+ {"version":3,"file":"parse-survey.d.ts","sourceRoot":"","sources":["../../src/cli/parse-survey.ts"],"names":[],"mappings":"AAKA,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,iBAK7C"}
@@ -4,12 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.parseSurvey = parseSurvey;
7
- var _index = require("../node/index.js");
7
+ var _index = require("../string/index.js");
8
8
  var _ZodFrcsSurveyFileToJson = require("../survey/ZodFrcsSurveyFileToJson.js");
9
+ var _readFile = require("./readFile.js");
9
10
  /* eslint-disable no-console */
10
11
 
11
12
  async function parseSurvey(file) {
12
- const parsed = _ZodFrcsSurveyFileToJson.ZodValidOrInvalidFrcsSurveyFileToJson.parse(await (0, _index.parseFrcsSurveyFile)(file));
13
+ const parsed = _ZodFrcsSurveyFileToJson.ZodValidOrInvalidFrcsSurveyFileToJson.parse(await (0, _index.parseFrcsSurveyFile)(file, await (0, _readFile.readFile)(file)));
13
14
  console.log(JSON.stringify(parsed));
14
15
  }
15
16
  //# sourceMappingURL=parse-survey.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-survey.js","names":["_index","require","_ZodFrcsSurveyFileToJson","parseSurvey","file","parsed","ZodValidOrInvalidFrcsSurveyFileToJson","parse","parseFrcsSurveyFile","console","log","JSON","stringify"],"sources":["../../src/cli/parse-survey.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport { parseFrcsSurveyFile } from '../node/index'\nimport { ZodValidOrInvalidFrcsSurveyFileToJson } from '../survey/ZodFrcsSurveyFileToJson'\n\nexport async function parseSurvey(file: string) {\n const parsed = ZodValidOrInvalidFrcsSurveyFileToJson.parse(\n await parseFrcsSurveyFile(file)\n )\n console.log(JSON.stringify(parsed))\n}\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,wBAAA,GAAAD,OAAA;AAFA;;AAIO,eAAeE,WAAWA,CAACC,IAAY,EAAE;EAC9C,MAAMC,MAAM,GAAGC,8DAAqC,CAACC,KAAK,CACxD,MAAM,IAAAC,0BAAmB,EAACJ,IAAI,CAChC,CAAC;EACDK,OAAO,CAACC,GAAG,CAACC,IAAI,CAACC,SAAS,CAACP,MAAM,CAAC,CAAC;AACrC","ignoreList":[]}
1
+ {"version":3,"file":"parse-survey.js","names":["_index","require","_ZodFrcsSurveyFileToJson","_readFile","parseSurvey","file","parsed","ZodValidOrInvalidFrcsSurveyFileToJson","parse","parseFrcsSurveyFile","readFile","console","log","JSON","stringify"],"sources":["../../src/cli/parse-survey.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport { parseFrcsSurveyFile } from '../string/index'\nimport { ZodValidOrInvalidFrcsSurveyFileToJson } from '../survey/ZodFrcsSurveyFileToJson'\nimport { readFile } from './readFile'\n\nexport async function parseSurvey(file: string) {\n const parsed = ZodValidOrInvalidFrcsSurveyFileToJson.parse(\n await parseFrcsSurveyFile(file, await readFile(file))\n )\n console.log(JSON.stringify(parsed))\n}\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,wBAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAHA;;AAKO,eAAeG,WAAWA,CAACC,IAAY,EAAE;EAC9C,MAAMC,MAAM,GAAGC,8DAAqC,CAACC,KAAK,CACxD,MAAM,IAAAC,0BAAmB,EAACJ,IAAI,EAAE,MAAM,IAAAK,kBAAQ,EAACL,IAAI,CAAC,CACtD,CAAC;EACDM,OAAO,CAACC,GAAG,CAACC,IAAI,CAACC,SAAS,CAACR,MAAM,CAAC,CAAC;AACrC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export declare function parseNamesFile(content: string): Map<string, {
2
+ replacement?: string;
3
+ }>;
4
+ //# sourceMappingURL=parseNamesFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseNamesFile.d.ts","sourceRoot":"","sources":["../../src/cli/parseNamesFile.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM;kBACE,MAAM;GAQrD"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.parseNamesFile = parseNamesFile;
7
+ function parseNamesFile(content) {
8
+ const names = new Map();
9
+ for (const line of content.split(/\r\n?|\n/gm)) {
10
+ const match = /^\s*(.+)\s*(?:=>\s*(.+)\s*)?$/.exec(line);
11
+ if (match) {
12
+ names.set(match[1].trim(), {
13
+ replacement: match[2]?.trim()
14
+ });
15
+ }
16
+ }
17
+ return names;
18
+ }
19
+ //# sourceMappingURL=parseNamesFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseNamesFile.js","names":["parseNamesFile","content","names","Map","line","split","match","exec","set","trim","replacement"],"sources":["../../src/cli/parseNamesFile.ts"],"sourcesContent":["export function parseNamesFile(content: string) {\n const names = new Map<string, { replacement?: string }>()\n for (const line of content.split(/\\r\\n?|\\n/gm)) {\n const match = /^\\s*(.+)\\s*(?:=>\\s*(.+)\\s*)?$/.exec(line)\n if (match) {\n names.set(match[1].trim(), { replacement: match[2]?.trim() })\n }\n }\n return names\n}\n"],"mappings":";;;;;;AAAO,SAASA,cAAcA,CAACC,OAAe,EAAE;EAC9C,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAAmC,CAAC;EACzD,KAAK,MAAMC,IAAI,IAAIH,OAAO,CAACI,KAAK,CAAC,YAAY,CAAC,EAAE;IAC9C,MAAMC,KAAK,GAAG,+BAA+B,CAACC,IAAI,CAACH,IAAI,CAAC;IACxD,IAAIE,KAAK,EAAE;MACTJ,KAAK,CAACM,GAAG,CAACF,KAAK,CAAC,CAAC,CAAC,CAACG,IAAI,CAAC,CAAC,EAAE;QAAEC,WAAW,EAAEJ,KAAK,CAAC,CAAC,CAAC,EAAEG,IAAI,CAAC;MAAE,CAAC,CAAC;IAC/D;EACF;EACA,OAAOP,KAAK;AACd","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export declare function readFile(file: string): Promise<string>;
2
+ //# sourceMappingURL=readFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readFile.d.ts","sourceRoot":"","sources":["../../src/cli/readFile.ts"],"names":[],"mappings":"AAGA,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,mBAE1C"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.readFile = readFile;
8
+ var _fs = _interopRequireDefault(require("fs"));
9
+ var _util = require("util");
10
+ async function readFile(file) {
11
+ return await (0, _util.promisify)(cb => _fs.default.readFile(file || 0, 'utf8', cb))();
12
+ }
13
+ //# sourceMappingURL=readFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readFile.js","names":["_fs","_interopRequireDefault","require","_util","readFile","file","promisify","cb","fs"],"sources":["../../src/cli/readFile.ts"],"sourcesContent":["import fs from 'fs'\nimport { promisify } from 'util'\n\nexport async function readFile(file: string) {\n return await promisify<string>((cb) => fs.readFile(file || 0, 'utf8', cb))()\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEO,eAAeE,QAAQA,CAACC,IAAY,EAAE;EAC3C,OAAO,MAAM,IAAAC,eAAS,EAAUC,EAAE,IAAKC,WAAE,CAACJ,QAAQ,CAACC,IAAI,IAAI,CAAC,EAAE,MAAM,EAAEE,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9E","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export declare function replaceSurveyNames(surveyFile: string, replacementsFile: string): Promise<void>;
2
+ //# sourceMappingURL=replace-names.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replace-names.d.ts","sourceRoot":"","sources":["../../src/cli/replace-names.ts"],"names":[],"mappings":"AAQA,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,MAAM,iBA8BzB"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.replaceSurveyNames = replaceSurveyNames;
8
+ var _parseFrcsSurveyFile = _interopRequireDefault(require("../survey/parseFrcsSurveyFile.js"));
9
+ var _replaceRanges = require("../replaceRanges.js");
10
+ var _ZodFrcsSurveyFileToJson = require("../survey/ZodFrcsSurveyFileToJson.js");
11
+ var _unwrapInvalid = require("../unwrapInvalid.js");
12
+ var _parseNamesFile = require("./parseNamesFile.js");
13
+ var _readFile = require("./readFile.js");
14
+ /* eslint-disable no-console */
15
+
16
+ async function replaceSurveyNames(surveyFile, replacementsFile) {
17
+ const source = await (0, _readFile.readFile)(surveyFile);
18
+ const parsed = _ZodFrcsSurveyFileToJson.ZodValidOrInvalidFrcsSurveyFileToJson.parse(await (0, _parseFrcsSurveyFile.default)(surveyFile, [source], {
19
+ normalizeNames: false,
20
+ includeLocs: true
21
+ }));
22
+ const names = await (0, _parseNamesFile.parseNamesFile)(await (0, _readFile.readFile)(replacementsFile));
23
+ const replacements = [];
24
+ for (const trip of (0, _unwrapInvalid.unwrapInvalid)(parsed).trips) {
25
+ const {
26
+ team,
27
+ locs: {
28
+ team: teamLocs
29
+ } = {}
30
+ } = (0, _unwrapInvalid.unwrapInvalid)((0, _unwrapInvalid.unwrapInvalid)(trip).header);
31
+ if (!team || !teamLocs) continue;
32
+ for (let i = 0; i < team.length; i++) {
33
+ const replacement = names.get(team[i])?.replacement;
34
+ if (replacement && teamLocs[i]) {
35
+ replacements.push({
36
+ start: teamLocs[i].start.index,
37
+ end: teamLocs[i].end.index,
38
+ value: replacement
39
+ });
40
+ }
41
+ }
42
+ }
43
+ process.stdout.write((0, _replaceRanges.replaceRanges)(source, replacements));
44
+ }
45
+ //# sourceMappingURL=replace-names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replace-names.js","names":["_parseFrcsSurveyFile","_interopRequireDefault","require","_replaceRanges","_ZodFrcsSurveyFileToJson","_unwrapInvalid","_parseNamesFile","_readFile","replaceSurveyNames","surveyFile","replacementsFile","source","readFile","parsed","ZodValidOrInvalidFrcsSurveyFileToJson","parse","parseFrcsSurveyFile","normalizeNames","includeLocs","names","parseNamesFile","replacements","trip","unwrapInvalid","trips","team","locs","teamLocs","header","i","length","replacement","get","push","start","index","end","value","process","stdout","write","replaceRanges"],"sources":["../../src/cli/replace-names.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport parseFrcsSurveyFile from '../survey/parseFrcsSurveyFile'\nimport { replaceRanges } from '../replaceRanges'\nimport { ZodValidOrInvalidFrcsSurveyFileToJson } from '../survey/ZodFrcsSurveyFileToJson'\nimport { unwrapInvalid } from '../unwrapInvalid'\nimport { parseNamesFile } from './parseNamesFile'\nimport { readFile } from './readFile'\n\nexport async function replaceSurveyNames(\n surveyFile: string,\n replacementsFile: string\n) {\n const source = await readFile(surveyFile)\n const parsed = ZodValidOrInvalidFrcsSurveyFileToJson.parse(\n await parseFrcsSurveyFile(surveyFile, [source], {\n normalizeNames: false,\n includeLocs: true,\n })\n )\n const names = await parseNamesFile(await readFile(replacementsFile))\n\n const replacements: { start: number; end: number; value: string }[] = []\n for (const trip of unwrapInvalid(parsed).trips) {\n const { team, locs: { team: teamLocs } = {} } = unwrapInvalid(\n unwrapInvalid(trip).header\n )\n if (!team || !teamLocs) continue\n for (let i = 0; i < team.length; i++) {\n const replacement = names.get(team[i])?.replacement\n if (replacement && teamLocs[i]) {\n replacements.push({\n start: teamLocs[i].start.index,\n end: teamLocs[i].end.index,\n value: replacement,\n })\n }\n }\n }\n\n process.stdout.write(replaceRanges(source, replacements))\n}\n"],"mappings":";;;;;;;AACA,IAAAA,oBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,wBAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AANA;;AAQO,eAAeM,kBAAkBA,CACtCC,UAAkB,EAClBC,gBAAwB,EACxB;EACA,MAAMC,MAAM,GAAG,MAAM,IAAAC,kBAAQ,EAACH,UAAU,CAAC;EACzC,MAAMI,MAAM,GAAGC,8DAAqC,CAACC,KAAK,CACxD,MAAM,IAAAC,4BAAmB,EAACP,UAAU,EAAE,CAACE,MAAM,CAAC,EAAE;IAC9CM,cAAc,EAAE,KAAK;IACrBC,WAAW,EAAE;EACf,CAAC,CACH,CAAC;EACD,MAAMC,KAAK,GAAG,MAAM,IAAAC,8BAAc,EAAC,MAAM,IAAAR,kBAAQ,EAACF,gBAAgB,CAAC,CAAC;EAEpE,MAAMW,YAA6D,GAAG,EAAE;EACxE,KAAK,MAAMC,IAAI,IAAI,IAAAC,4BAAa,EAACV,MAAM,CAAC,CAACW,KAAK,EAAE;IAC9C,MAAM;MAAEC,IAAI;MAAEC,IAAI,EAAE;QAAED,IAAI,EAAEE;MAAS,CAAC,GAAG,CAAC;IAAE,CAAC,GAAG,IAAAJ,4BAAa,EAC3D,IAAAA,4BAAa,EAACD,IAAI,CAAC,CAACM,MACtB,CAAC;IACD,IAAI,CAACH,IAAI,IAAI,CAACE,QAAQ,EAAE;IACxB,KAAK,IAAIE,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGJ,IAAI,CAACK,MAAM,EAAED,CAAC,EAAE,EAAE;MACpC,MAAME,WAAW,GAAGZ,KAAK,CAACa,GAAG,CAACP,IAAI,CAACI,CAAC,CAAC,CAAC,EAAEE,WAAW;MACnD,IAAIA,WAAW,IAAIJ,QAAQ,CAACE,CAAC,CAAC,EAAE;QAC9BR,YAAY,CAACY,IAAI,CAAC;UAChBC,KAAK,EAAEP,QAAQ,CAACE,CAAC,CAAC,CAACK,KAAK,CAACC,KAAK;UAC9BC,GAAG,EAAET,QAAQ,CAACE,CAAC,CAAC,CAACO,GAAG,CAACD,KAAK;UAC1BE,KAAK,EAAEN;QACT,CAAC,CAAC;MACJ;IACF;EACF;EAEAO,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC,IAAAC,4BAAa,EAAC9B,MAAM,EAAEU,YAAY,CAAC,CAAC;AAC3D","ignoreList":[]}
@@ -1,2 +1,2 @@
1
1
  export declare function summarizeSurvey(file: string): Promise<void>;
2
- //# sourceMappingURL=summarize-survey.d.ts.map
2
+ //# sourceMappingURL=summarize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarize.d.ts","sourceRoot":"","sources":["../../src/cli/summarize.ts"],"names":[],"mappings":"AAQA,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,iBAmBjD"}
@@ -8,13 +8,13 @@ exports.summarizeSurvey = summarizeSurvey;
8
8
  var _chalk = _interopRequireDefault(require("chalk"));
9
9
  var _formatIssues = require("../formatIssues.js");
10
10
  var _index = require("../string/index.js");
11
- var _promises = _interopRequireDefault(require("fs/promises"));
12
11
  var _formatFrcsTripSummaryFile = require("../formatFrcsTripSummaryFile.js");
13
12
  var _summarizeSurvey = require("../survey/summarizeSurvey.js");
13
+ var _readFile = require("./readFile.js");
14
14
  /* eslint-disable no-console */
15
15
 
16
16
  async function summarizeSurvey(file) {
17
- const source = await _promises.default.readFile(file, 'utf8');
17
+ const source = await (0, _readFile.readFile)(file);
18
18
  const parsed = await (0, _index.parseFrcsSurveyFile)(file, source);
19
19
  if ('INVALID' in parsed) {
20
20
  console.log((0, _formatIssues.formatIssues)({
@@ -30,4 +30,4 @@ async function summarizeSurvey(file) {
30
30
  console.log(line);
31
31
  }
32
32
  }
33
- //# sourceMappingURL=summarize-survey.js.map
33
+ //# sourceMappingURL=summarize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarize.js","names":["_chalk","_interopRequireDefault","require","_formatIssues","_index","_formatFrcsTripSummaryFile","_summarizeSurvey","_readFile","summarizeSurvey","file","source","readFile","parsed","parseFrcsSurveyFile","console","log","formatIssues","errorStyle","chalk","red","warningStyle","yellow","process","exit","line","formatFrcsTripSummaryFile","baseSummarizeSurvey"],"sources":["../../src/cli/summarize.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport chalk from 'chalk'\nimport { formatIssues } from '../formatIssues'\nimport { parseFrcsSurveyFile } from '../string/index'\nimport { formatFrcsTripSummaryFile } from '../formatFrcsTripSummaryFile'\nimport { summarizeSurvey as baseSummarizeSurvey } from '../survey/summarizeSurvey'\nimport { readFile } from './readFile'\n\nexport async function summarizeSurvey(file: string) {\n const source = await readFile(file)\n const parsed = await parseFrcsSurveyFile(file, source)\n if ('INVALID' in parsed) {\n console.log(\n formatIssues({\n file,\n source,\n parsed,\n errorStyle: chalk.red,\n warningStyle: chalk.yellow,\n })\n )\n process.exit(1)\n }\n\n for (const line of formatFrcsTripSummaryFile(baseSummarizeSurvey(parsed))) {\n console.log(line)\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,0BAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AANA;;AAQO,eAAeM,eAAeA,CAACC,IAAY,EAAE;EAClD,MAAMC,MAAM,GAAG,MAAM,IAAAC,kBAAQ,EAACF,IAAI,CAAC;EACnC,MAAMG,MAAM,GAAG,MAAM,IAAAC,0BAAmB,EAACJ,IAAI,EAAEC,MAAM,CAAC;EACtD,IAAI,SAAS,IAAIE,MAAM,EAAE;IACvBE,OAAO,CAACC,GAAG,CACT,IAAAC,0BAAY,EAAC;MACXP,IAAI;MACJC,MAAM;MACNE,MAAM;MACNK,UAAU,EAAEC,cAAK,CAACC,GAAG;MACrBC,YAAY,EAAEF,cAAK,CAACG;IACtB,CAAC,CACH,CAAC;IACDC,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC;EACjB;EAEA,KAAK,MAAMC,IAAI,IAAI,IAAAC,oDAAyB,EAAC,IAAAC,gCAAmB,EAACd,MAAM,CAAC,CAAC,EAAE;IACzEE,OAAO,CAACC,GAAG,CAACS,IAAI,CAAC;EACnB;AACF","ignoreList":[]}
package/cli.js CHANGED
@@ -5,7 +5,7 @@ var _yargs = _interopRequireDefault(require("yargs/yargs"));
5
5
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
6
6
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
7
7
  void (0, _yargs.default)(process.argv.slice(2)).command({
8
- command: 'check-survey <file>',
8
+ command: 'check <file>',
9
9
  describe: 'check survey file for errors or warnings',
10
10
  builder: yargs => yargs.positional('file', {
11
11
  type: 'string',
@@ -16,11 +16,11 @@ void (0, _yargs.default)(process.argv.slice(2)).command({
16
16
  }) => {
17
17
  const {
18
18
  checkSurvey
19
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./cli/check-survey.js")));
19
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require("./cli/check.js")));
20
20
  await checkSurvey(file);
21
21
  }
22
22
  }).command({
23
- command: 'parse-survey <file>',
23
+ command: 'parse <file>',
24
24
  describe: 'parse survey file and output JSON parse tree',
25
25
  builder: yargs => yargs.positional('file', {
26
26
  type: 'string',
@@ -35,7 +35,7 @@ void (0, _yargs.default)(process.argv.slice(2)).command({
35
35
  await parseSurvey(file);
36
36
  }
37
37
  }).command({
38
- command: 'summarize-survey <file>',
38
+ command: 'summarize <file>',
39
39
  describe: 'parse survey file and output trip summaries',
40
40
  builder: yargs => yargs.positional('file', {
41
41
  type: 'string',
@@ -46,11 +46,76 @@ void (0, _yargs.default)(process.argv.slice(2)).command({
46
46
  }) => {
47
47
  const {
48
48
  summarizeSurvey
49
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./cli/summarize-survey.js")));
49
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require("./cli/summarize.js")));
50
50
  await summarizeSurvey(file);
51
51
  }
52
52
  }).command({
53
- command: 'check-survey-correspondence <surveyFile> <summaryFile>',
53
+ command: 'list-names <file>',
54
+ describe: 'parse survey file and output surveyor name/count table',
55
+ builder: yargs => yargs.positional('file', {
56
+ type: 'string',
57
+ demandOption: true
58
+ }).option('counts', {
59
+ alias: 'c',
60
+ type: 'boolean',
61
+ describe: 'count the number of occurrences of each name',
62
+ demandOption: false
63
+ }).option('suggest-replacements', {
64
+ alias: 's',
65
+ type: 'boolean',
66
+ describe: 'output suggested replacements',
67
+ demandOption: false
68
+ }),
69
+ handler: async ({
70
+ file,
71
+ counts,
72
+ suggestReplacements
73
+ }) => {
74
+ const {
75
+ listSurveyNames: listNames
76
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require("./cli/list-names.js")));
77
+ await listNames(file, {
78
+ includeCounts: counts,
79
+ suggestReplacements
80
+ });
81
+ }
82
+ }).command({
83
+ command: 'replace-names <surveyFile> <replacementsFile>',
84
+ describe: 'replace names survey file',
85
+ builder: yargs => yargs.positional('surveyFile', {
86
+ type: 'string',
87
+ demandOption: true
88
+ }).positional('replacementsFile', {
89
+ type: 'string',
90
+ demandOption: true
91
+ }),
92
+ handler: async ({
93
+ surveyFile,
94
+ replacementsFile
95
+ }) => {
96
+ const {
97
+ replaceSurveyNames: replaceNames
98
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require("./cli/replace-names.js")));
99
+ await replaceNames(surveyFile, replacementsFile);
100
+ }
101
+ }).command({
102
+ command: 'merge-names-files <namesFiles..>',
103
+ describe: 'merge two or more names files',
104
+ builder: yargs => yargs.positional('namesFiles', {
105
+ type: 'string',
106
+ array: true,
107
+ demandOption: true
108
+ }),
109
+ handler: async ({
110
+ namesFiles
111
+ }) => {
112
+ const {
113
+ mergeNamesFiles
114
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require("./cli/merge-names-files.js")));
115
+ await mergeNamesFiles(...namesFiles);
116
+ }
117
+ }).command({
118
+ command: 'check-correspondence <surveyFile> <summaryFile>',
54
119
  describe: 'parse survey file and output trip summaries',
55
120
  builder: yargs => yargs.positional('surveyFile', {
56
121
  type: 'string',
@@ -65,7 +130,7 @@ void (0, _yargs.default)(process.argv.slice(2)).command({
65
130
  }) => {
66
131
  const {
67
132
  checkSurveyCorrespondence
68
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./cli/check-survey-correspondence.js")));
133
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require("./cli/check-correspondence.js")));
69
134
  await checkSurveyCorrespondence(surveyFile, summaryFile);
70
135
  }
71
136
  }).demandCommand().argv;