@speleotica/frcsdata 5.0.0-beta.4 → 5.0.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.
- package/cli/{check-survey-correspondence.d.ts → check-correspondence.d.ts} +1 -1
- package/cli/check-correspondence.d.ts.map +1 -0
- package/cli/{check-survey-correspondence.js → check-correspondence.js} +4 -5
- package/cli/check-correspondence.js.map +1 -0
- package/cli/{check-survey.d.ts → check.d.ts} +1 -1
- package/cli/check.d.ts.map +1 -0
- package/cli/{check-survey.js → check.js} +3 -3
- package/cli/check.js.map +1 -0
- package/cli/compareNames.d.ts +2 -0
- package/cli/compareNames.d.ts.map +1 -0
- package/cli/compareNames.js +15 -0
- package/cli/compareNames.js.map +1 -0
- package/cli/formatNamesFile.d.ts +4 -0
- package/cli/formatNamesFile.d.ts.map +1 -0
- package/cli/formatNamesFile.js +13 -0
- package/cli/formatNamesFile.js.map +1 -0
- package/cli/list-names.d.ts +5 -0
- package/cli/list-names.d.ts.map +1 -0
- package/cli/list-names.js +74 -0
- package/cli/list-names.js.map +1 -0
- package/cli/merge-names-files.d.ts +2 -0
- package/cli/merge-names-files.d.ts.map +1 -0
- package/cli/merge-names-files.js +25 -0
- package/cli/merge-names-files.js.map +1 -0
- package/cli/parse-survey.d.ts.map +1 -1
- package/cli/parse-survey.js +3 -2
- package/cli/parse-survey.js.map +1 -1
- package/cli/parseNamesFile.d.ts +4 -0
- package/cli/parseNamesFile.d.ts.map +1 -0
- package/cli/parseNamesFile.js +19 -0
- package/cli/parseNamesFile.js.map +1 -0
- package/cli/readFile.d.ts +2 -0
- package/cli/readFile.d.ts.map +1 -0
- package/cli/readFile.js +13 -0
- package/cli/readFile.js.map +1 -0
- package/cli/replace-names.d.ts +2 -0
- package/cli/replace-names.d.ts.map +1 -0
- package/cli/replace-names.js +45 -0
- package/cli/replace-names.js.map +1 -0
- package/cli/{summarize-survey.d.ts → summarize.d.ts} +1 -1
- package/cli/summarize.d.ts.map +1 -0
- package/cli/{summarize-survey.js → summarize.js} +3 -3
- package/cli/summarize.js.map +1 -0
- package/cli.js +72 -7
- package/cli.js.map +1 -1
- package/index.d.ts +8 -6
- package/index.d.ts.map +1 -1
- package/index.js +7 -28
- package/index.js.map +1 -1
- package/node/index.d.ts +1 -1
- package/node/index.d.ts.map +1 -1
- package/package.json +2 -1
- package/replaceRanges.d.ts +6 -0
- package/replaceRanges.d.ts.map +1 -0
- package/replaceRanges.js +23 -0
- package/replaceRanges.js.map +1 -0
- package/src/cli/{check-survey-correspondence.ts → check-correspondence.ts} +6 -5
- package/src/cli/{check-survey.ts → check.ts} +2 -2
- package/src/cli/compareNames.ts +13 -0
- package/src/cli/formatNamesFile.ts +13 -0
- package/src/cli/list-names.ts +94 -0
- package/src/cli/merge-names-files.ts +18 -0
- package/src/cli/parse-survey.ts +3 -2
- package/src/cli/parseNamesFile.ts +10 -0
- package/src/cli/readFile.ts +6 -0
- package/src/cli/replace-names.ts +41 -0
- package/src/cli/{summarize-survey.ts → summarize.ts} +2 -2
- package/src/cli.ts +67 -7
- package/src/index.ts +22 -7
- package/src/replaceRanges.ts +21 -0
- package/src/survey/FrcsSurveyFile.ts +1 -0
- package/src/survey/ZodFrcsSurveyFileJson.ts +1 -0
- package/src/survey/formatFrcsShot.ts +5 -7
- package/src/survey/normalizeTeamMemberName.ts +15 -3
- package/src/survey/parseFrcsSurveyFile.ts +193 -8
- package/string/index.d.ts +1 -1
- package/string/index.d.ts.map +1 -1
- package/survey/FrcsSurveyFile.d.ts +1 -0
- package/survey/FrcsSurveyFile.d.ts.map +1 -1
- package/survey/FrcsSurveyFile.js.map +1 -1
- package/survey/ZodFrcsSurveyFileJson.d.ts +283 -280
- package/survey/ZodFrcsSurveyFileJson.d.ts.map +1 -1
- package/survey/ZodFrcsSurveyFileJson.js +2 -1
- package/survey/ZodFrcsSurveyFileJson.js.map +1 -1
- package/survey/ZodFrcsSurveyFileToJson.d.ts +280 -280
- package/survey/formatFrcsShot.d.ts.map +1 -1
- package/survey/formatFrcsShot.js +3 -4
- package/survey/formatFrcsShot.js.map +1 -1
- package/survey/normalizeTeamMemberName.d.ts +1 -0
- package/survey/normalizeTeamMemberName.d.ts.map +1 -1
- package/survey/normalizeTeamMemberName.js +11 -1
- package/survey/normalizeTeamMemberName.js.map +1 -1
- package/survey/parseFrcsSurveyFile.d.ts +1 -1
- package/survey/parseFrcsSurveyFile.d.ts.map +1 -1
- package/survey/parseFrcsSurveyFile.js +128 -12
- package/survey/parseFrcsSurveyFile.js.map +1 -1
- package/cli/check-survey-correspondence.d.ts.map +0 -1
- package/cli/check-survey-correspondence.js.map +0 -1
- package/cli/check-survey.d.ts.map +0 -1
- package/cli/check-survey.js.map +0 -1
- package/cli/summarize-survey.d.ts.map +0 -1
- package/cli/summarize-survey.js.map +0 -1
package/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":["_yargs","_interopRequireDefault","require","_getRequireWildcardCache","e","WeakMap","r","t","_interopRequireWildcard","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","yargs","process","argv","slice","command","describe","builder","positional","type","demandOption","handler","file","checkSurvey","Promise","resolve","then","parseSurvey","summarizeSurvey","surveyFile","summaryFile","checkSurveyCorrespondence","demandCommand"],"sources":["src/cli.ts"],"sourcesContent":["import yargs from 'yargs/yargs'\n\nvoid yargs(process.argv.slice(2))\n .command({\n command: 'check
|
|
1
|
+
{"version":3,"file":"cli.js","names":["_yargs","_interopRequireDefault","require","_getRequireWildcardCache","e","WeakMap","r","t","_interopRequireWildcard","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","yargs","process","argv","slice","command","describe","builder","positional","type","demandOption","handler","file","checkSurvey","Promise","resolve","then","parseSurvey","summarizeSurvey","option","alias","counts","suggestReplacements","listSurveyNames","listNames","includeCounts","surveyFile","replacementsFile","replaceSurveyNames","replaceNames","array","namesFiles","mergeNamesFiles","summaryFile","checkSurveyCorrespondence","demandCommand"],"sources":["src/cli.ts"],"sourcesContent":["import yargs from 'yargs/yargs'\n\nvoid yargs(process.argv.slice(2))\n .command({\n command: 'check <file>',\n describe: 'check survey file for errors or warnings',\n builder: (yargs) =>\n yargs.positional('file', {\n type: 'string',\n demandOption: true,\n }),\n handler: async ({ file }) => {\n const { checkSurvey } = await import('./cli/check')\n await checkSurvey(file)\n },\n })\n .command({\n command: 'parse <file>',\n describe: 'parse survey file and output JSON parse tree',\n builder: (yargs) =>\n yargs.positional('file', {\n type: 'string',\n demandOption: true,\n }),\n handler: async ({ file }) => {\n const { parseSurvey } = await import('./cli/parse-survey')\n await parseSurvey(file)\n },\n })\n .command({\n command: 'summarize <file>',\n describe: 'parse survey file and output trip summaries',\n builder: (yargs) =>\n yargs.positional('file', {\n type: 'string',\n demandOption: true,\n }),\n handler: async ({ file }) => {\n const { summarizeSurvey } = await import('./cli/summarize')\n await summarizeSurvey(file)\n },\n })\n .command({\n command: 'list-names <file>',\n describe: 'parse survey file and output surveyor name/count table',\n builder: (yargs) =>\n yargs\n .positional('file', {\n type: 'string',\n demandOption: true,\n })\n .option('counts', {\n alias: 'c',\n type: 'boolean',\n describe: 'count the number of occurrences of each name',\n demandOption: false,\n })\n .option('suggest-replacements', {\n alias: 's',\n type: 'boolean',\n describe: 'output suggested replacements',\n demandOption: false,\n }),\n handler: async ({ file, counts, suggestReplacements }) => {\n const { listSurveyNames: listNames } = await import('./cli/list-names')\n await listNames(file, { includeCounts: counts, suggestReplacements })\n },\n })\n .command({\n command: 'replace-names <surveyFile> <replacementsFile>',\n describe: 'replace names survey file',\n builder: (yargs) =>\n yargs\n .positional('surveyFile', {\n type: 'string',\n demandOption: true,\n })\n .positional('replacementsFile', {\n type: 'string',\n demandOption: true,\n }),\n handler: async ({ surveyFile, replacementsFile }) => {\n const { replaceSurveyNames: replaceNames } = await import(\n './cli/replace-names'\n )\n await replaceNames(surveyFile, replacementsFile)\n },\n })\n .command({\n command: 'merge-names-files <namesFiles..>',\n describe: 'merge two or more names files',\n builder: (yargs) =>\n yargs.positional('namesFiles', {\n type: 'string',\n array: true,\n demandOption: true,\n }),\n handler: async ({ namesFiles }) => {\n const { mergeNamesFiles } = await import('./cli/merge-names-files')\n await mergeNamesFiles(...namesFiles)\n },\n })\n .command({\n command: 'check-correspondence <surveyFile> <summaryFile>',\n describe: 'parse survey file and output trip summaries',\n builder: (yargs) =>\n yargs\n .positional('surveyFile', {\n type: 'string',\n demandOption: true,\n })\n .positional('summaryFile', {\n type: 'string',\n demandOption: true,\n }),\n handler: async ({ surveyFile, summaryFile }) => {\n const { checkSurveyCorrespondence } = await import(\n './cli/check-correspondence'\n )\n await checkSurveyCorrespondence(surveyFile, summaryFile)\n },\n })\n .demandCommand().argv\n"],"mappings":";;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA+B,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAI,wBAAAJ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAM,OAAA,EAAAN,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAI,GAAA,CAAAP,CAAA,UAAAG,CAAA,CAAAK,GAAA,CAAAR,CAAA,OAAAS,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAf,CAAA,oBAAAe,CAAA,OAAAC,cAAA,CAAAC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ACF,CAAC,CAAC,CACD1B,OAAO,CAAC;EACPA,OAAO,EAAE,iDAAiD;EAC1DC,QAAQ,EAAE,6CAA6C;EACvDC,OAAO,EAAGN,KAAK,IACbA,KAAK,CACFO,UAAU,CAAC,YAAY,EAAE;IACxBC,IAAI,EAAE,QAAQ;IACdC,YAAY,EAAE;EAChB,CAAC,CAAC,CACDF,UAAU,CAAC,aAAa,EAAE;IACzBC,IAAI,EAAE,QAAQ;IACdC,YAAY,EAAE;EAChB,CAAC,CAAC;EACNC,OAAO,EAAE,MAAAA,CAAO;IAAEe,UAAU;IAAEO;EAAY,CAAC,KAAK;IAC9C,MAAM;MAAEC;IAA0B,CAAC,GAAG,MAAApB,OAAA,CAAAC,OAAA,GAAAC,IAAA,OAAA/B,uBAAA,CAAAN,OAAA,mCAErC;IACD,MAAMuD,yBAAyB,CAACR,UAAU,EAAEO,WAAW,CAAC;EAC1D;AACF,CAAC,CAAC,CACDE,aAAa,CAAC,CAAC,CAAChC,IAAI","ignoreList":[]}
|
package/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import type { FrcsShot, FrcsSurveyFile, FrcsTrip, FrcsTripHeader } from './survey/FrcsSurveyFile';
|
|
1
|
+
import type { FrcsShot, FrcsSurveyFile, FrcsTrip, FrcsTripHeader, InvalidFrcsShot, InvalidFrcsSurveyFile, InvalidFrcsTrip, InvalidFrcsTripHeader, InvalidFrcsUnits } from './survey/FrcsSurveyFile';
|
|
2
2
|
import parseFrcsSurveyFile from './survey/parseFrcsSurveyFile';
|
|
3
|
-
import { FrcsPlotShot } from './FrcsPlotShot';
|
|
4
|
-
import { FrcsPlotFile } from './FrcsPlotFile';
|
|
3
|
+
import type { FrcsPlotShot } from './FrcsPlotShot';
|
|
4
|
+
import type { FrcsPlotFile } from './FrcsPlotFile';
|
|
5
5
|
import parseFrcsPlotFile from './parseFrcsPlotFile';
|
|
6
|
-
import { FrcsTripSummary } from './FrcsTripSummary';
|
|
7
|
-
import { FrcsTripSummaryFile } from './FrcsTripSummaryFile';
|
|
6
|
+
import type { FrcsTripSummary } from './FrcsTripSummary';
|
|
7
|
+
import { type FrcsTripSummaryFile } from './FrcsTripSummaryFile';
|
|
8
8
|
import parseFrcsTripSummaryFile from './parseFrcsTripSummaryFile';
|
|
9
9
|
import formatFrcsShot from './survey/formatFrcsShot';
|
|
10
10
|
import { formatFrcsSurveyFile } from './survey/formatFrcsSurveyFile';
|
|
11
|
-
|
|
11
|
+
import { formatIssues } from './formatIssues';
|
|
12
|
+
export type { FrcsShot, FrcsSurveyFile, FrcsTrip, FrcsTripHeader, InvalidFrcsShot, InvalidFrcsSurveyFile, InvalidFrcsTrip, InvalidFrcsTripHeader, InvalidFrcsUnits, FrcsPlotShot, FrcsPlotFile, FrcsTripSummary, FrcsTripSummaryFile, };
|
|
13
|
+
export { parseFrcsSurveyFile, parseFrcsPlotFile, parseFrcsTripSummaryFile, formatFrcsShot, formatFrcsSurveyFile, formatIssues, };
|
|
12
14
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,QAAQ,EACR,cAAc,EACf,MAAM,yBAAyB,CAAA;AAChC,OAAO,mBAAmB,MAAM,8BAA8B,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,QAAQ,EACR,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,yBAAyB,CAAA;AAChC,OAAO,mBAAmB,MAAM,8BAA8B,CAAA;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,iBAAiB,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,wBAAwB,MAAM,4BAA4B,CAAA;AACjE,OAAO,cAAc,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,YAAY,EACV,QAAQ,EACR,cAAc,EACd,QAAQ,EACR,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,mBAAmB,GACpB,CAAA;AAED,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,wBAAwB,EACxB,cAAc,EACd,oBAAoB,EACpB,YAAY,GACb,CAAA"}
|
package/index.js
CHANGED
|
@@ -4,30 +4,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
Object.defineProperty(exports, "FrcsPlotFile", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _FrcsPlotFile.FrcsPlotFile;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(exports, "FrcsPlotShot", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () {
|
|
16
|
-
return _FrcsPlotShot.FrcsPlotShot;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports, "FrcsTripSummary", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function () {
|
|
22
|
-
return _FrcsTripSummary.FrcsTripSummary;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(exports, "FrcsTripSummaryFile", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () {
|
|
28
|
-
return _FrcsTripSummaryFile.FrcsTripSummaryFile;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
7
|
Object.defineProperty(exports, "formatFrcsShot", {
|
|
32
8
|
enumerable: true,
|
|
33
9
|
get: function () {
|
|
@@ -40,6 +16,12 @@ Object.defineProperty(exports, "formatFrcsSurveyFile", {
|
|
|
40
16
|
return _formatFrcsSurveyFile.formatFrcsSurveyFile;
|
|
41
17
|
}
|
|
42
18
|
});
|
|
19
|
+
Object.defineProperty(exports, "formatIssues", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _formatIssues.formatIssues;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
43
25
|
Object.defineProperty(exports, "parseFrcsPlotFile", {
|
|
44
26
|
enumerable: true,
|
|
45
27
|
get: function () {
|
|
@@ -59,12 +41,9 @@ Object.defineProperty(exports, "parseFrcsTripSummaryFile", {
|
|
|
59
41
|
}
|
|
60
42
|
});
|
|
61
43
|
var _parseFrcsSurveyFile = _interopRequireDefault(require("./survey/parseFrcsSurveyFile.js"));
|
|
62
|
-
var _FrcsPlotShot = require("./FrcsPlotShot.js");
|
|
63
|
-
var _FrcsPlotFile = require("./FrcsPlotFile.js");
|
|
64
44
|
var _parseFrcsPlotFile = _interopRequireDefault(require("./parseFrcsPlotFile.js"));
|
|
65
|
-
var _FrcsTripSummary = require("./FrcsTripSummary.js");
|
|
66
|
-
var _FrcsTripSummaryFile = require("./FrcsTripSummaryFile.js");
|
|
67
45
|
var _parseFrcsTripSummaryFile = _interopRequireDefault(require("./parseFrcsTripSummaryFile.js"));
|
|
68
46
|
var _formatFrcsShot = _interopRequireDefault(require("./survey/formatFrcsShot.js"));
|
|
69
47
|
var _formatFrcsSurveyFile = require("./survey/formatFrcsSurveyFile.js");
|
|
48
|
+
var _formatIssues = require("./formatIssues.js");
|
|
70
49
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_parseFrcsSurveyFile","_interopRequireDefault","require","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_parseFrcsSurveyFile","_interopRequireDefault","require","_parseFrcsPlotFile","_parseFrcsTripSummaryFile","_formatFrcsShot","_formatFrcsSurveyFile","_formatIssues"],"sources":["src/index.ts"],"sourcesContent":["import type {\n FrcsShot,\n FrcsSurveyFile,\n FrcsTrip,\n FrcsTripHeader,\n InvalidFrcsShot,\n InvalidFrcsSurveyFile,\n InvalidFrcsTrip,\n InvalidFrcsTripHeader,\n InvalidFrcsUnits,\n} from './survey/FrcsSurveyFile'\nimport parseFrcsSurveyFile from './survey/parseFrcsSurveyFile'\nimport type { FrcsPlotShot } from './FrcsPlotShot'\nimport type { FrcsPlotFile } from './FrcsPlotFile'\nimport parseFrcsPlotFile from './parseFrcsPlotFile'\nimport type { FrcsTripSummary } from './FrcsTripSummary'\nimport { type FrcsTripSummaryFile } from './FrcsTripSummaryFile'\nimport parseFrcsTripSummaryFile from './parseFrcsTripSummaryFile'\nimport formatFrcsShot from './survey/formatFrcsShot'\nimport { formatFrcsSurveyFile } from './survey/formatFrcsSurveyFile'\nimport { formatIssues } from './formatIssues'\n\nexport type {\n FrcsShot,\n FrcsSurveyFile,\n FrcsTrip,\n FrcsTripHeader,\n InvalidFrcsShot,\n InvalidFrcsSurveyFile,\n InvalidFrcsTrip,\n InvalidFrcsTripHeader,\n InvalidFrcsUnits,\n FrcsPlotShot,\n FrcsPlotFile,\n FrcsTripSummary,\n FrcsTripSummaryFile,\n}\n\nexport {\n parseFrcsSurveyFile,\n parseFrcsPlotFile,\n parseFrcsTripSummaryFile,\n formatFrcsShot,\n formatFrcsSurveyFile,\n formatIssues,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,IAAAA,oBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,kBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAGA,IAAAE,yBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,eAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,qBAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA","ignoreList":[]}
|
package/node/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const parseFrcsSurveyFile: (file: string, rest_0?: import("../survey/FrcsSurveyFile").ParseFrcsSurveyFileOptions | undefined) => Promise<import("..").FrcsSurveyFile | import("
|
|
1
|
+
export declare const parseFrcsSurveyFile: (file: string, rest_0?: import("../survey/FrcsSurveyFile").ParseFrcsSurveyFileOptions | undefined) => Promise<import("..").FrcsSurveyFile | import("..").InvalidFrcsSurveyFile>;
|
|
2
2
|
export declare const parseFrcsPlotFile: (file: string) => Promise<import("..").FrcsPlotFile>;
|
|
3
3
|
export declare const parseFrcsTripSummaryFile: (file: string, rest_0?: {
|
|
4
4
|
indexBy?: "tripNumber" | "occurrence";
|
package/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AA4BA,eAAO,MAAM,mBAAmB,SAHvB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AA4BA,eAAO,MAAM,mBAAmB,SAHvB,MAAM,kKAG2D,CAAA;AAC1E,eAAO,MAAM,iBAAiB,SAfrB,MAAM,uCAesD,CAAA;AACrE,eAAO,MAAM,wBAAwB,SAhB5B,MAAM;;2DAkBd,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speleotica/frcsdata",
|
|
3
|
-
"version": "5.0.0
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "parser for Chip Hopper's survey data format used in Fisher Ridge Cave System",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"homepage": "https://github.com/speleotica/frcsdata#readme",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@babel/runtime": "^7.18.6",
|
|
24
|
+
"@jcoreio/utils": "0.0.0-development",
|
|
24
25
|
"@speleotica/unitized": "^2.0.0",
|
|
25
26
|
"chalk": "^4",
|
|
26
27
|
"dedent-js": "^1.0.1",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replaceRanges.d.ts","sourceRoot":"","sources":["src/replaceRanges.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,YAAY,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,GAC5D,MAAM,CAiBR"}
|
package/replaceRanges.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.replaceRanges = replaceRanges;
|
|
7
|
+
function replaceRanges(source, replacements) {
|
|
8
|
+
replacements.sort((a, b) => a.start - b.start);
|
|
9
|
+
const parts = [];
|
|
10
|
+
let end = 0;
|
|
11
|
+
for (const r of replacements) {
|
|
12
|
+
if (r.start > end) {
|
|
13
|
+
parts.push(source.substring(end, r.start));
|
|
14
|
+
}
|
|
15
|
+
parts.push(r.value);
|
|
16
|
+
end = r.end;
|
|
17
|
+
}
|
|
18
|
+
if (end < source.length) {
|
|
19
|
+
parts.push(source.substring(end));
|
|
20
|
+
}
|
|
21
|
+
return parts.join('');
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=replaceRanges.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replaceRanges.js","names":["replaceRanges","source","replacements","sort","a","b","start","parts","end","r","push","substring","value","length","join"],"sources":["src/replaceRanges.ts"],"sourcesContent":["export function replaceRanges(\n source: string,\n replacements: { start: number; end: number; value: string }[]\n): string {\n replacements.sort((a, b) => a.start - b.start)\n\n const parts = []\n let end = 0\n for (const r of replacements) {\n if (r.start > end) {\n parts.push(source.substring(end, r.start))\n }\n parts.push(r.value)\n end = r.end\n }\n if (end < source.length) {\n parts.push(source.substring(end))\n }\n\n return parts.join('')\n}\n"],"mappings":";;;;;;AAAO,SAASA,aAAaA,CAC3BC,MAAc,EACdC,YAA6D,EACrD;EACRA,YAAY,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,KAAK,GAAGD,CAAC,CAACC,KAAK,CAAC;EAE9C,MAAMC,KAAK,GAAG,EAAE;EAChB,IAAIC,GAAG,GAAG,CAAC;EACX,KAAK,MAAMC,CAAC,IAAIP,YAAY,EAAE;IAC5B,IAAIO,CAAC,CAACH,KAAK,GAAGE,GAAG,EAAE;MACjBD,KAAK,CAACG,IAAI,CAACT,MAAM,CAACU,SAAS,CAACH,GAAG,EAAEC,CAAC,CAACH,KAAK,CAAC,CAAC;IAC5C;IACAC,KAAK,CAACG,IAAI,CAACD,CAAC,CAACG,KAAK,CAAC;IACnBJ,GAAG,GAAGC,CAAC,CAACD,GAAG;EACb;EACA,IAAIA,GAAG,GAAGP,MAAM,CAACY,MAAM,EAAE;IACvBN,KAAK,CAACG,IAAI,CAACT,MAAM,CAACU,SAAS,CAACH,GAAG,CAAC,CAAC;EACnC;EAEA,OAAOD,KAAK,CAACO,IAAI,CAAC,EAAE,CAAC;AACvB","ignoreList":[]}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import chalk from 'chalk'
|
|
3
|
-
import { parseFrcsSurveyFile } from '../string/index'
|
|
4
|
-
import fs from 'fs/promises'
|
|
3
|
+
import { parseFrcsSurveyFile, parseFrcsTripSummaryFile } from '../string/index'
|
|
5
4
|
import { summarizeSurvey } from '../survey/summarizeSurvey'
|
|
6
|
-
import { parseFrcsTripSummaryFile } from '../node/index.js'
|
|
7
5
|
import { formatFrcsTripSummaryFile } from '../formatFrcsTripSummaryFile.js'
|
|
8
6
|
import { isDeepStrictEqual } from 'util'
|
|
7
|
+
import { readFile } from './readFile'
|
|
9
8
|
|
|
10
9
|
export async function checkSurveyCorrespondence(
|
|
11
10
|
surveyFile: string,
|
|
12
11
|
summaryFile: string
|
|
13
12
|
) {
|
|
14
|
-
const source = await
|
|
13
|
+
const source = await readFile(surveyFile)
|
|
15
14
|
const parsedSurvey = await parseFrcsSurveyFile(surveyFile, source)
|
|
16
15
|
const parsedSummaries = (
|
|
17
|
-
await parseFrcsTripSummaryFile(summaryFile,
|
|
16
|
+
await parseFrcsTripSummaryFile(summaryFile, await readFile(summaryFile), {
|
|
17
|
+
indexBy: 'occurrence',
|
|
18
|
+
})
|
|
18
19
|
).tripSummaries.sort((a, b) => (a?.tripNumber ?? 0) - (b?.tripNumber ?? 0))
|
|
19
20
|
const convertedSummaries = summarizeSurvey(parsedSurvey, {
|
|
20
21
|
ignoreVerticalOfHShots: true,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
import
|
|
2
|
+
import { readFile } from './readFile'
|
|
3
3
|
import parseFrcsSurveyFile from '../survey/parseFrcsSurveyFile'
|
|
4
4
|
import chalk from 'chalk'
|
|
5
5
|
import { formatIssues } from '../formatIssues.js'
|
|
6
6
|
|
|
7
7
|
export async function checkSurvey(file: string) {
|
|
8
|
-
const source = await
|
|
8
|
+
const source = await readFile(file)
|
|
9
9
|
const parsed = await parseFrcsSurveyFile(file, [source])
|
|
10
10
|
|
|
11
11
|
const issues = parsed.issues || []
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const splitName = (name: string) => {
|
|
2
|
+
return /^(.+)\s+(\S+)$/.exec(name)?.slice(1) || ['', name]
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function compareNames(a: string, b: string) {
|
|
6
|
+
const [aFirst, aLast] = splitName(a.toLowerCase())
|
|
7
|
+
const [bFirst, bLast] = splitName(b.toLowerCase())
|
|
8
|
+
return (
|
|
9
|
+
aLast.localeCompare(bLast) ||
|
|
10
|
+
aFirst.localeCompare(bFirst) ||
|
|
11
|
+
a[0].localeCompare(b[0])
|
|
12
|
+
)
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { compareNames } from './compareNames'
|
|
2
|
+
|
|
3
|
+
export function formatNamesFile(names: Map<string, { replacement?: string }>) {
|
|
4
|
+
return (
|
|
5
|
+
[...names.entries()]
|
|
6
|
+
.sort((a, b) => compareNames(a[0], b[0]))
|
|
7
|
+
.map(
|
|
8
|
+
([name, { replacement }]) =>
|
|
9
|
+
`${name}${replacement ? ` => ${replacement}` : ''}`
|
|
10
|
+
)
|
|
11
|
+
.join('\n') + '\n'
|
|
12
|
+
)
|
|
13
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { parseFrcsSurveyFile } from '../string/index'
|
|
3
|
+
import { normalizeNameCapitalization } from '../survey/normalizeTeamMemberName'
|
|
4
|
+
import { ZodValidOrInvalidFrcsSurveyFileToJson } from '../survey/ZodFrcsSurveyFileToJson'
|
|
5
|
+
import { unwrapInvalid } from '../unwrapInvalid'
|
|
6
|
+
import { groupBy } from '@jcoreio/utils/groupBy'
|
|
7
|
+
import { compareNames } from './compareNames'
|
|
8
|
+
import { readFile } from './readFile'
|
|
9
|
+
|
|
10
|
+
export async function listSurveyNames(
|
|
11
|
+
file: string,
|
|
12
|
+
options?: { includeCounts?: boolean; suggestReplacements?: boolean }
|
|
13
|
+
) {
|
|
14
|
+
const parsed = ZodValidOrInvalidFrcsSurveyFileToJson.parse(
|
|
15
|
+
await parseFrcsSurveyFile(file, await readFile(file), {
|
|
16
|
+
normalizeNames: false,
|
|
17
|
+
})
|
|
18
|
+
)
|
|
19
|
+
const nameCounts = new Map<string, number>()
|
|
20
|
+
for (const trip of unwrapInvalid(parsed).trips) {
|
|
21
|
+
const { team } = unwrapInvalid(unwrapInvalid(trip).header)
|
|
22
|
+
if (!team) continue
|
|
23
|
+
for (const name of team) {
|
|
24
|
+
nameCounts.set(name, (nameCounts.get(name) ?? 0) + 1)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const table = [...nameCounts.entries()].sort((a, b) =>
|
|
29
|
+
compareNames(a[0], b[0])
|
|
30
|
+
)
|
|
31
|
+
const maxNameCount = table.reduce((max, [, count]) => Math.max(max, count), 0)
|
|
32
|
+
const countLength = maxNameCount.toFixed().length
|
|
33
|
+
|
|
34
|
+
const includeCounts = options?.includeCounts ?? false
|
|
35
|
+
|
|
36
|
+
const names = [...nameCounts.keys()]
|
|
37
|
+
|
|
38
|
+
const replacements = new Map<string, string>()
|
|
39
|
+
if (options?.suggestReplacements) {
|
|
40
|
+
for (const group of groupBy(names, (name) => name.toLowerCase()).values()) {
|
|
41
|
+
if (group.length === 1) {
|
|
42
|
+
const [name] = group
|
|
43
|
+
const normalized = normalizeNameCapitalization(name)
|
|
44
|
+
if (normalized !== name) replacements.set(name, normalized)
|
|
45
|
+
continue
|
|
46
|
+
}
|
|
47
|
+
const best = group
|
|
48
|
+
.map((name) => normalizeNameCapitalization(name))
|
|
49
|
+
.reduce((a, b) => (countCaps(a) > countCaps(b) ? a : b))
|
|
50
|
+
for (const name of group) {
|
|
51
|
+
if (name !== best) replacements.set(name, best)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const firstInitials = groupBy(
|
|
56
|
+
names.filter((name) => /^\S[. ]/.test(name)),
|
|
57
|
+
(name) => name.toLowerCase().replace(/\.\s*/g, ' ')
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
for (const name of names) {
|
|
61
|
+
if (/^\S[. ]/.test(name)) continue
|
|
62
|
+
const firstInitial = name
|
|
63
|
+
.toLowerCase()
|
|
64
|
+
.replace(/^\S+/, (m) => m.substring(0, 1))
|
|
65
|
+
.replace(/\.\s*/g, ' ')
|
|
66
|
+
const matches = firstInitials.get(firstInitial)
|
|
67
|
+
if (matches) {
|
|
68
|
+
for (const match of matches) {
|
|
69
|
+
replacements.set(match, replacements.get(name) ?? name)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
for (const [name, count] of table) {
|
|
76
|
+
const replacement = replacements.get(name)
|
|
77
|
+
if (includeCounts)
|
|
78
|
+
console.log(
|
|
79
|
+
count.toFixed().padStart(countLength),
|
|
80
|
+
name,
|
|
81
|
+
...(replacement ? ['=>', replacement] : [])
|
|
82
|
+
)
|
|
83
|
+
else console.log(name, ...(replacement ? ['=>', replacement] : []))
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const countCaps = (name: string) => {
|
|
88
|
+
const lower = name.toLowerCase()
|
|
89
|
+
let count = 0
|
|
90
|
+
for (let i = 0; i < name.length; i++) {
|
|
91
|
+
if (name[i] !== lower[i]) count++
|
|
92
|
+
}
|
|
93
|
+
return count
|
|
94
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { parseNamesFile } from './parseNamesFile'
|
|
2
|
+
import { formatNamesFile } from './formatNamesFile'
|
|
3
|
+
import { readFile } from './readFile'
|
|
4
|
+
|
|
5
|
+
export async function mergeNamesFiles(...files: string[]) {
|
|
6
|
+
const names = new Map<string, { replacement?: string }>()
|
|
7
|
+
|
|
8
|
+
for (const file of files) {
|
|
9
|
+
const parsed = parseNamesFile(await readFile(file))
|
|
10
|
+
for (const [name, { replacement }] of parsed) {
|
|
11
|
+
const existing = names.get(name)
|
|
12
|
+
if (!existing) names.set(name, { replacement })
|
|
13
|
+
else if (!existing.replacement) existing.replacement = replacement
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
process.stdout.write(formatNamesFile(names))
|
|
18
|
+
}
|
package/src/cli/parse-survey.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
import { parseFrcsSurveyFile } from '../
|
|
2
|
+
import { parseFrcsSurveyFile } from '../string/index'
|
|
3
3
|
import { ZodValidOrInvalidFrcsSurveyFileToJson } from '../survey/ZodFrcsSurveyFileToJson'
|
|
4
|
+
import { readFile } from './readFile'
|
|
4
5
|
|
|
5
6
|
export async function parseSurvey(file: string) {
|
|
6
7
|
const parsed = ZodValidOrInvalidFrcsSurveyFileToJson.parse(
|
|
7
|
-
await parseFrcsSurveyFile(file)
|
|
8
|
+
await parseFrcsSurveyFile(file, await readFile(file))
|
|
8
9
|
)
|
|
9
10
|
console.log(JSON.stringify(parsed))
|
|
10
11
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function parseNamesFile(content: string) {
|
|
2
|
+
const names = new Map<string, { replacement?: string }>()
|
|
3
|
+
for (const line of content.split(/\r\n?|\n/gm)) {
|
|
4
|
+
const match = /^\s*(.+)\s*(?:=>\s*(.+)\s*)?$/.exec(line)
|
|
5
|
+
if (match) {
|
|
6
|
+
names.set(match[1].trim(), { replacement: match[2]?.trim() })
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return names
|
|
10
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import parseFrcsSurveyFile from '../survey/parseFrcsSurveyFile'
|
|
3
|
+
import { replaceRanges } from '../replaceRanges'
|
|
4
|
+
import { ZodValidOrInvalidFrcsSurveyFileToJson } from '../survey/ZodFrcsSurveyFileToJson'
|
|
5
|
+
import { unwrapInvalid } from '../unwrapInvalid'
|
|
6
|
+
import { parseNamesFile } from './parseNamesFile'
|
|
7
|
+
import { readFile } from './readFile'
|
|
8
|
+
|
|
9
|
+
export async function replaceSurveyNames(
|
|
10
|
+
surveyFile: string,
|
|
11
|
+
replacementsFile: string
|
|
12
|
+
) {
|
|
13
|
+
const source = await readFile(surveyFile)
|
|
14
|
+
const parsed = ZodValidOrInvalidFrcsSurveyFileToJson.parse(
|
|
15
|
+
await parseFrcsSurveyFile(surveyFile, [source], {
|
|
16
|
+
normalizeNames: false,
|
|
17
|
+
includeLocs: true,
|
|
18
|
+
})
|
|
19
|
+
)
|
|
20
|
+
const names = await parseNamesFile(await readFile(replacementsFile))
|
|
21
|
+
|
|
22
|
+
const replacements: { start: number; end: number; value: string }[] = []
|
|
23
|
+
for (const trip of unwrapInvalid(parsed).trips) {
|
|
24
|
+
const { team, locs: { team: teamLocs } = {} } = unwrapInvalid(
|
|
25
|
+
unwrapInvalid(trip).header
|
|
26
|
+
)
|
|
27
|
+
if (!team || !teamLocs) continue
|
|
28
|
+
for (let i = 0; i < team.length; i++) {
|
|
29
|
+
const replacement = names.get(team[i])?.replacement
|
|
30
|
+
if (replacement && teamLocs[i]) {
|
|
31
|
+
replacements.push({
|
|
32
|
+
start: teamLocs[i].start.index,
|
|
33
|
+
end: teamLocs[i].end.index,
|
|
34
|
+
value: replacement,
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
process.stdout.write(replaceRanges(source, replacements))
|
|
41
|
+
}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import chalk from 'chalk'
|
|
3
3
|
import { formatIssues } from '../formatIssues'
|
|
4
4
|
import { parseFrcsSurveyFile } from '../string/index'
|
|
5
|
-
import fs from 'fs/promises'
|
|
6
5
|
import { formatFrcsTripSummaryFile } from '../formatFrcsTripSummaryFile'
|
|
7
6
|
import { summarizeSurvey as baseSummarizeSurvey } from '../survey/summarizeSurvey'
|
|
7
|
+
import { readFile } from './readFile'
|
|
8
8
|
|
|
9
9
|
export async function summarizeSurvey(file: string) {
|
|
10
|
-
const source = await
|
|
10
|
+
const source = await readFile(file)
|
|
11
11
|
const parsed = await parseFrcsSurveyFile(file, source)
|
|
12
12
|
if ('INVALID' in parsed) {
|
|
13
13
|
console.log(
|
package/src/cli.ts
CHANGED
|
@@ -2,7 +2,7 @@ import yargs from 'yargs/yargs'
|
|
|
2
2
|
|
|
3
3
|
void yargs(process.argv.slice(2))
|
|
4
4
|
.command({
|
|
5
|
-
command: 'check
|
|
5
|
+
command: 'check <file>',
|
|
6
6
|
describe: 'check survey file for errors or warnings',
|
|
7
7
|
builder: (yargs) =>
|
|
8
8
|
yargs.positional('file', {
|
|
@@ -10,12 +10,12 @@ void yargs(process.argv.slice(2))
|
|
|
10
10
|
demandOption: true,
|
|
11
11
|
}),
|
|
12
12
|
handler: async ({ file }) => {
|
|
13
|
-
const { checkSurvey } = await import('./cli/check
|
|
13
|
+
const { checkSurvey } = await import('./cli/check')
|
|
14
14
|
await checkSurvey(file)
|
|
15
15
|
},
|
|
16
16
|
})
|
|
17
17
|
.command({
|
|
18
|
-
command: 'parse
|
|
18
|
+
command: 'parse <file>',
|
|
19
19
|
describe: 'parse survey file and output JSON parse tree',
|
|
20
20
|
builder: (yargs) =>
|
|
21
21
|
yargs.positional('file', {
|
|
@@ -28,7 +28,7 @@ void yargs(process.argv.slice(2))
|
|
|
28
28
|
},
|
|
29
29
|
})
|
|
30
30
|
.command({
|
|
31
|
-
command: 'summarize
|
|
31
|
+
command: 'summarize <file>',
|
|
32
32
|
describe: 'parse survey file and output trip summaries',
|
|
33
33
|
builder: (yargs) =>
|
|
34
34
|
yargs.positional('file', {
|
|
@@ -36,12 +36,72 @@ void yargs(process.argv.slice(2))
|
|
|
36
36
|
demandOption: true,
|
|
37
37
|
}),
|
|
38
38
|
handler: async ({ file }) => {
|
|
39
|
-
const { summarizeSurvey } = await import('./cli/summarize
|
|
39
|
+
const { summarizeSurvey } = await import('./cli/summarize')
|
|
40
40
|
await summarizeSurvey(file)
|
|
41
41
|
},
|
|
42
42
|
})
|
|
43
43
|
.command({
|
|
44
|
-
command: '
|
|
44
|
+
command: 'list-names <file>',
|
|
45
|
+
describe: 'parse survey file and output surveyor name/count table',
|
|
46
|
+
builder: (yargs) =>
|
|
47
|
+
yargs
|
|
48
|
+
.positional('file', {
|
|
49
|
+
type: 'string',
|
|
50
|
+
demandOption: true,
|
|
51
|
+
})
|
|
52
|
+
.option('counts', {
|
|
53
|
+
alias: 'c',
|
|
54
|
+
type: 'boolean',
|
|
55
|
+
describe: 'count the number of occurrences of each name',
|
|
56
|
+
demandOption: false,
|
|
57
|
+
})
|
|
58
|
+
.option('suggest-replacements', {
|
|
59
|
+
alias: 's',
|
|
60
|
+
type: 'boolean',
|
|
61
|
+
describe: 'output suggested replacements',
|
|
62
|
+
demandOption: false,
|
|
63
|
+
}),
|
|
64
|
+
handler: async ({ file, counts, suggestReplacements }) => {
|
|
65
|
+
const { listSurveyNames: listNames } = await import('./cli/list-names')
|
|
66
|
+
await listNames(file, { includeCounts: counts, suggestReplacements })
|
|
67
|
+
},
|
|
68
|
+
})
|
|
69
|
+
.command({
|
|
70
|
+
command: 'replace-names <surveyFile> <replacementsFile>',
|
|
71
|
+
describe: 'replace names survey file',
|
|
72
|
+
builder: (yargs) =>
|
|
73
|
+
yargs
|
|
74
|
+
.positional('surveyFile', {
|
|
75
|
+
type: 'string',
|
|
76
|
+
demandOption: true,
|
|
77
|
+
})
|
|
78
|
+
.positional('replacementsFile', {
|
|
79
|
+
type: 'string',
|
|
80
|
+
demandOption: true,
|
|
81
|
+
}),
|
|
82
|
+
handler: async ({ surveyFile, replacementsFile }) => {
|
|
83
|
+
const { replaceSurveyNames: replaceNames } = await import(
|
|
84
|
+
'./cli/replace-names'
|
|
85
|
+
)
|
|
86
|
+
await replaceNames(surveyFile, replacementsFile)
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
.command({
|
|
90
|
+
command: 'merge-names-files <namesFiles..>',
|
|
91
|
+
describe: 'merge two or more names files',
|
|
92
|
+
builder: (yargs) =>
|
|
93
|
+
yargs.positional('namesFiles', {
|
|
94
|
+
type: 'string',
|
|
95
|
+
array: true,
|
|
96
|
+
demandOption: true,
|
|
97
|
+
}),
|
|
98
|
+
handler: async ({ namesFiles }) => {
|
|
99
|
+
const { mergeNamesFiles } = await import('./cli/merge-names-files')
|
|
100
|
+
await mergeNamesFiles(...namesFiles)
|
|
101
|
+
},
|
|
102
|
+
})
|
|
103
|
+
.command({
|
|
104
|
+
command: 'check-correspondence <surveyFile> <summaryFile>',
|
|
45
105
|
describe: 'parse survey file and output trip summaries',
|
|
46
106
|
builder: (yargs) =>
|
|
47
107
|
yargs
|
|
@@ -55,7 +115,7 @@ void yargs(process.argv.slice(2))
|
|
|
55
115
|
}),
|
|
56
116
|
handler: async ({ surveyFile, summaryFile }) => {
|
|
57
117
|
const { checkSurveyCorrespondence } = await import(
|
|
58
|
-
'./cli/check-
|
|
118
|
+
'./cli/check-correspondence'
|
|
59
119
|
)
|
|
60
120
|
await checkSurveyCorrespondence(surveyFile, summaryFile)
|
|
61
121
|
},
|