@speleotica/frcsdata 5.0.1 → 5.0.2
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/parseNamesFile.d.ts.map +1 -1
- package/cli/parseNamesFile.js +4 -6
- package/cli/parseNamesFile.js.map +1 -1
- package/cli/replace-names.d.ts +3 -1
- package/cli/replace-names.d.ts.map +1 -1
- package/cli/replace-names.js +24 -5
- package/cli/replace-names.js.map +1 -1
- package/cli.js +9 -3
- package/cli.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/parseNamesFile.ts +2 -4
- package/src/cli/replace-names.ts +46 -5
- package/src/cli.ts +7 -2
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"parseNamesFile.d.ts","sourceRoot":"","sources":["../../src/cli/parseNamesFile.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM;kBACE,MAAM;GAMrD"}
|
package/cli/parseNamesFile.js
CHANGED
|
@@ -7,12 +7,10 @@ exports.parseNamesFile = parseNamesFile;
|
|
|
7
7
|
function parseNamesFile(content) {
|
|
8
8
|
const names = new Map();
|
|
9
9
|
for (const line of content.split(/\r\n?|\n/gm)) {
|
|
10
|
-
const
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
});
|
|
15
|
-
}
|
|
10
|
+
const [name, replacement] = line.split('=>').map(s => s.trim());
|
|
11
|
+
if (name) names.set(name, {
|
|
12
|
+
replacement
|
|
13
|
+
});
|
|
16
14
|
}
|
|
17
15
|
return names;
|
|
18
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseNamesFile.js","names":["parseNamesFile","content","names","Map","line","split","
|
|
1
|
+
{"version":3,"file":"parseNamesFile.js","names":["parseNamesFile","content","names","Map","line","split","name","replacement","map","s","trim","set"],"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 [name, replacement] = line.split('=>').map((s) => s.trim())\n if (name) names.set(name, { replacement })\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,MAAM,CAACC,IAAI,EAAEC,WAAW,CAAC,GAAGH,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,CAACG,GAAG,CAAEC,CAAC,IAAKA,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC;IACjE,IAAIJ,IAAI,EAAEJ,KAAK,CAACS,GAAG,CAACL,IAAI,EAAE;MAAEC;IAAY,CAAC,CAAC;EAC5C;EACA,OAAOL,KAAK;AACd","ignoreList":[]}
|
package/cli/replace-names.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export declare function replaceSurveyNames(surveyFile: string, replacementsFile: string
|
|
1
|
+
export declare function replaceSurveyNames(surveyFile: string, replacementsFile: string, options?: {
|
|
2
|
+
verbose?: boolean;
|
|
3
|
+
}): Promise<void>;
|
|
2
4
|
//# sourceMappingURL=replace-names.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replace-names.d.ts","sourceRoot":"","sources":["../../src/cli/replace-names.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"replace-names.d.ts","sourceRoot":"","sources":["../../src/cli/replace-names.ts"],"names":[],"mappings":"AAUA,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,MAAM,EACxB,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,iBAkEF"}
|
package/cli/replace-names.js
CHANGED
|
@@ -11,15 +11,22 @@ var _ZodFrcsSurveyFileToJson = require("../survey/ZodFrcsSurveyFileToJson.js");
|
|
|
11
11
|
var _unwrapInvalid = require("../unwrapInvalid.js");
|
|
12
12
|
var _parseNamesFile = require("./parseNamesFile.js");
|
|
13
13
|
var _readFile = require("./readFile.js");
|
|
14
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
15
|
+
var _compareNames = require("./compareNames.js");
|
|
14
16
|
/* eslint-disable no-console */
|
|
15
17
|
|
|
16
|
-
async function replaceSurveyNames(surveyFile, replacementsFile) {
|
|
18
|
+
async function replaceSurveyNames(surveyFile, replacementsFile, options) {
|
|
17
19
|
const source = await (0, _readFile.readFile)(surveyFile);
|
|
18
20
|
const parsed = _ZodFrcsSurveyFileToJson.ZodValidOrInvalidFrcsSurveyFileToJson.parse(await (0, _parseFrcsSurveyFile.default)(surveyFile, [source], {
|
|
19
21
|
normalizeNames: false,
|
|
20
22
|
includeLocs: true
|
|
21
23
|
}));
|
|
22
24
|
const names = await (0, _parseNamesFile.parseNamesFile)(await (0, _readFile.readFile)(replacementsFile));
|
|
25
|
+
const unreplacedNames = new Set([...names.entries()].flatMap(([name, {
|
|
26
|
+
replacement
|
|
27
|
+
}]) => replacement ? name : []));
|
|
28
|
+
const replacedNames = new Set();
|
|
29
|
+
let replacementCount = 0;
|
|
23
30
|
const replacements = [];
|
|
24
31
|
for (const trip of (0, _unwrapInvalid.unwrapInvalid)(parsed).trips) {
|
|
25
32
|
const {
|
|
@@ -30,16 +37,28 @@ async function replaceSurveyNames(surveyFile, replacementsFile) {
|
|
|
30
37
|
} = (0, _unwrapInvalid.unwrapInvalid)((0, _unwrapInvalid.unwrapInvalid)(trip).header);
|
|
31
38
|
if (!team || !teamLocs) continue;
|
|
32
39
|
for (let i = 0; i < team.length; i++) {
|
|
33
|
-
const
|
|
34
|
-
|
|
40
|
+
const name = team[i];
|
|
41
|
+
const loc = teamLocs[i];
|
|
42
|
+
const replacement = names.get(name)?.replacement;
|
|
43
|
+
if (replacement && loc) {
|
|
44
|
+
unreplacedNames.delete(name);
|
|
45
|
+
replacedNames.add(name);
|
|
46
|
+
replacementCount++;
|
|
35
47
|
replacements.push({
|
|
36
|
-
start:
|
|
37
|
-
end:
|
|
48
|
+
start: loc.start.index,
|
|
49
|
+
end: loc.end.index,
|
|
38
50
|
value: replacement
|
|
39
51
|
});
|
|
40
52
|
}
|
|
41
53
|
}
|
|
42
54
|
}
|
|
43
55
|
process.stdout.write((0, _replaceRanges.replaceRanges)(source, replacements));
|
|
56
|
+
console.error(_chalk.default.yellow(`replaced ${replacedNames.size} ${replacedNames.size === 1 ? '' : 's'} in ${replacementCount} location${replacementCount === 1 ? '' : 's'}`));
|
|
57
|
+
console.error(unreplacedNames.size ? _chalk.default.yellow(`${unreplacedNames.size} name replacement${unreplacedNames.size === 1 ? ' was' : 's were'} unused${options?.verbose ? ':' : ''}`) : _chalk.default.green('all name replacements were used'));
|
|
58
|
+
if (options?.verbose) {
|
|
59
|
+
for (const name of [...unreplacedNames].sort(_compareNames.compareNames)) {
|
|
60
|
+
console.error(_chalk.default.yellow(` ${name} => ${names.get(name)?.replacement}`));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
44
63
|
}
|
|
45
64
|
//# sourceMappingURL=replace-names.js.map
|
package/cli/replace-names.js.map
CHANGED
|
@@ -1 +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","
|
|
1
|
+
{"version":3,"file":"replace-names.js","names":["_parseFrcsSurveyFile","_interopRequireDefault","require","_replaceRanges","_ZodFrcsSurveyFileToJson","_unwrapInvalid","_parseNamesFile","_readFile","_chalk","_compareNames","replaceSurveyNames","surveyFile","replacementsFile","options","source","readFile","parsed","ZodValidOrInvalidFrcsSurveyFileToJson","parse","parseFrcsSurveyFile","normalizeNames","includeLocs","names","parseNamesFile","unreplacedNames","Set","entries","flatMap","name","replacement","replacedNames","replacementCount","replacements","trip","unwrapInvalid","trips","team","locs","teamLocs","header","i","length","loc","get","delete","add","push","start","index","end","value","process","stdout","write","replaceRanges","console","error","chalk","yellow","size","verbose","green","sort","compareNames"],"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'\nimport chalk from 'chalk'\nimport { compareNames } from './compareNames'\n\nexport async function replaceSurveyNames(\n surveyFile: string,\n replacementsFile: string,\n options?: {\n verbose?: boolean\n }\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 unreplacedNames = new Set<string>(\n [...names.entries()].flatMap(([name, { replacement }]) =>\n replacement ? name : []\n )\n )\n const replacedNames = new Set<string>()\n let replacementCount = 0\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 name = team[i]\n const loc = teamLocs[i]\n const replacement = names.get(name)?.replacement\n if (replacement && loc) {\n unreplacedNames.delete(name)\n replacedNames.add(name)\n replacementCount++\n replacements.push({\n start: loc.start.index,\n end: loc.end.index,\n value: replacement,\n })\n }\n }\n }\n\n process.stdout.write(replaceRanges(source, replacements))\n console.error(\n chalk.yellow(\n `replaced ${replacedNames.size} ${\n replacedNames.size === 1 ? '' : 's'\n } in ${replacementCount} location${replacementCount === 1 ? '' : 's'}`\n )\n )\n console.error(\n unreplacedNames.size\n ? chalk.yellow(\n `${unreplacedNames.size} name replacement${\n unreplacedNames.size === 1 ? ' was' : 's were'\n } unused${options?.verbose ? ':' : ''}`\n )\n : chalk.green('all name replacements were used')\n )\n if (options?.verbose) {\n for (const name of [...unreplacedNames].sort(compareNames)) {\n console.error(\n chalk.yellow(` ${name} => ${names.get(name)?.replacement}`)\n )\n }\n }\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;AACA,IAAAM,MAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AARA;;AAUO,eAAeQ,kBAAkBA,CACtCC,UAAkB,EAClBC,gBAAwB,EACxBC,OAEC,EACD;EACA,MAAMC,MAAM,GAAG,MAAM,IAAAC,kBAAQ,EAACJ,UAAU,CAAC;EACzC,MAAMK,MAAM,GAAGC,8DAAqC,CAACC,KAAK,CACxD,MAAM,IAAAC,4BAAmB,EAACR,UAAU,EAAE,CAACG,MAAM,CAAC,EAAE;IAC9CM,cAAc,EAAE,KAAK;IACrBC,WAAW,EAAE;EACf,CAAC,CACH,CAAC;EACD,MAAMC,KAAK,GAAG,MAAM,IAAAC,8B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AEP,GAAG,CAACO,GAAG,CAACD,KAAK;UAClBE,KAAK,EAAErB;QACT,CAAC,CAAC;MACJ;IACF;EACF;EAEAsB,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC,IAAAC,4BAAa,EAACxC,MAAM,EAAEkB,YAAY,CAAC,CAAC;EACzDuB,OAAO,CAACC,KAAK,CACXC,cAAK,CAACC,MAAM,CACV,YAAY5B,aAAa,CAAC6B,IAAI,IAC5B7B,aAAa,CAAC6B,IAAI,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,OAC9B5B,gBAAgB,YAAYA,gBAAgB,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,EACtE,CACF,CAAC;EACDwB,OAAO,CAACC,KAAK,CACXhC,eAAe,CAACmC,IAAI,GAChBF,cAAK,CAACC,MAAM,CACV,GAAGlC,eAAe,CAACmC,IAAI,oBACrBnC,eAAe,CAACmC,IAAI,KAAK,CAAC,GAAG,MAAM,GAAG,QAAQ,UACtC9C,OAAO,EAAE+C,OAAO,GAAG,GAAG,GAAG,EAAE,EACvC,CAAC,GACDH,cAAK,CAACI,KAAK,CAAC,iCAAiC,CACnD,CAAC;EACD,IAAIhD,OAAO,EAAE+C,OAAO,EAAE;IACpB,KAAK,MAAMhC,IAAI,IAAI,CAAC,GAAGJ,eAAe,CAAC,CAACsC,IAAI,CAACC,0BAAY,CAAC,EAAE;MAC1DR,OAAO,CAACC,KAAK,CACXC,cAAK,CAACC,MAAM,CAAC,KAAK9B,IAAI,OAAON,KAAK,CAACqB,GAAG,CAACf,IAAI,CAAC,EAAEC,WAAW,EAAE,CAC7D,CAAC;IACH;EACF;AACF","ignoreList":[]}
|
package/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
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
|
-
void (0, _yargs.default)(process.argv.slice(2)).command({
|
|
7
|
+
void (0, _yargs.default)(process.argv.slice(2)).scriptName('frcsdata').command({
|
|
8
8
|
command: 'check <file>',
|
|
9
9
|
describe: 'check survey file for errors or warnings',
|
|
10
10
|
builder: yargs => yargs.positional('file', {
|
|
@@ -88,15 +88,21 @@ void (0, _yargs.default)(process.argv.slice(2)).command({
|
|
|
88
88
|
}).positional('replacementsFile', {
|
|
89
89
|
type: 'string',
|
|
90
90
|
demandOption: true
|
|
91
|
+
}).option('verbose', {
|
|
92
|
+
alias: 'v',
|
|
93
|
+
type: 'boolean'
|
|
91
94
|
}),
|
|
92
95
|
handler: async ({
|
|
93
96
|
surveyFile,
|
|
94
|
-
replacementsFile
|
|
97
|
+
replacementsFile,
|
|
98
|
+
verbose
|
|
95
99
|
}) => {
|
|
96
100
|
const {
|
|
97
101
|
replaceSurveyNames: replaceNames
|
|
98
102
|
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./cli/replace-names.js")));
|
|
99
|
-
await replaceNames(surveyFile, replacementsFile
|
|
103
|
+
await replaceNames(surveyFile, replacementsFile, {
|
|
104
|
+
verbose
|
|
105
|
+
});
|
|
100
106
|
}
|
|
101
107
|
}).command({
|
|
102
108
|
command: 'merge-names-files <namesFiles..>',
|
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","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,IAAA,CAAAjB,CAAA,EAAAe,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAd,CAAA,EAAAe,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAf,CAAA,CAAAe,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAN,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAgB,GAAA,CAAAnB,CAAA,EAAAS,CAAA,GAAAA,CAAA;AAE/B,KAAK,IAAAW,cAAK,EAACC,OAAO,CAACC,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC,CAC9BC,OAAO,CAAC;EACPA,OAAO,EAAE,cAAc;EACvBC,QAAQ,EAAE,0CAA0C;EACpDC,OAAO,
|
|
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","scriptName","command","describe","builder","positional","type","demandOption","handler","file","checkSurvey","Promise","resolve","then","parseSurvey","summarizeSurvey","option","alias","counts","suggestReplacements","listSurveyNames","listNames","includeCounts","surveyFile","replacementsFile","verbose","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 .scriptName('frcsdata')\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 .option('verbose', {\n alias: 'v',\n type: 'boolean',\n }),\n handler: async ({ surveyFile, replacementsFile, verbose }) => {\n const { replaceSurveyNames: replaceNames } = await import(\n './cli/replace-names'\n )\n await replaceNames(surveyFile, replacementsFile, { verbose })\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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C,OAAO,EAAE,MAAAA,CAAO;IAAEqB;EAAW,CAAC,KAAK;IACjC,MAAM;MAAEC;IAAgB,CAAC,GAAG,MAAAnB,OAAA,CAAAC,OAAA,GAAAC,IAAA,OAAAhC,uBAAA,CAAAN,OAAA,gCAAuC;IACnE,MAAMuD,eAAe,CAAC,GAAGD,UAAU,CAAC;EACtC;AACF,CAAC,CAAC,CACD3B,OAAO,CAAC;EACPA,OAAO,EAAE,iDAAiD;EAC1DC,QAAQ,EAAE,6CAA6C;EACvDC,OAAO,EAAGP,KAAK,IACbA,KAAK,CACFQ,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;IAAEQ;EAAY,CAAC,KAAK;IAC9C,MAAM;MAAEC;IAA0B,CAAC,GAAG,MAAArB,OAAA,CAAAC,OAAA,GAAAC,IAAA,OAAAhC,uBAAA,CAAAN,OAAA,mCAErC;IACD,MAAMyD,yBAAyB,CAACT,UAAU,EAAEQ,WAAW,CAAC;EAC1D;AACF,CAAC,CAAC,CACDE,aAAa,CAAC,CAAC,CAAClC,IAAI","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
export function parseNamesFile(content: string) {
|
|
2
2
|
const names = new Map<string, { replacement?: string }>()
|
|
3
3
|
for (const line of content.split(/\r\n?|\n/gm)) {
|
|
4
|
-
const
|
|
5
|
-
if (
|
|
6
|
-
names.set(match[1].trim(), { replacement: match[2]?.trim() })
|
|
7
|
-
}
|
|
4
|
+
const [name, replacement] = line.split('=>').map((s) => s.trim())
|
|
5
|
+
if (name) names.set(name, { replacement })
|
|
8
6
|
}
|
|
9
7
|
return names
|
|
10
8
|
}
|
package/src/cli/replace-names.ts
CHANGED
|
@@ -5,10 +5,15 @@ import { ZodValidOrInvalidFrcsSurveyFileToJson } from '../survey/ZodFrcsSurveyFi
|
|
|
5
5
|
import { unwrapInvalid } from '../unwrapInvalid'
|
|
6
6
|
import { parseNamesFile } from './parseNamesFile'
|
|
7
7
|
import { readFile } from './readFile'
|
|
8
|
+
import chalk from 'chalk'
|
|
9
|
+
import { compareNames } from './compareNames'
|
|
8
10
|
|
|
9
11
|
export async function replaceSurveyNames(
|
|
10
12
|
surveyFile: string,
|
|
11
|
-
replacementsFile: string
|
|
13
|
+
replacementsFile: string,
|
|
14
|
+
options?: {
|
|
15
|
+
verbose?: boolean
|
|
16
|
+
}
|
|
12
17
|
) {
|
|
13
18
|
const source = await readFile(surveyFile)
|
|
14
19
|
const parsed = ZodValidOrInvalidFrcsSurveyFileToJson.parse(
|
|
@@ -19,6 +24,14 @@ export async function replaceSurveyNames(
|
|
|
19
24
|
)
|
|
20
25
|
const names = await parseNamesFile(await readFile(replacementsFile))
|
|
21
26
|
|
|
27
|
+
const unreplacedNames = new Set<string>(
|
|
28
|
+
[...names.entries()].flatMap(([name, { replacement }]) =>
|
|
29
|
+
replacement ? name : []
|
|
30
|
+
)
|
|
31
|
+
)
|
|
32
|
+
const replacedNames = new Set<string>()
|
|
33
|
+
let replacementCount = 0
|
|
34
|
+
|
|
22
35
|
const replacements: { start: number; end: number; value: string }[] = []
|
|
23
36
|
for (const trip of unwrapInvalid(parsed).trips) {
|
|
24
37
|
const { team, locs: { team: teamLocs } = {} } = unwrapInvalid(
|
|
@@ -26,11 +39,16 @@ export async function replaceSurveyNames(
|
|
|
26
39
|
)
|
|
27
40
|
if (!team || !teamLocs) continue
|
|
28
41
|
for (let i = 0; i < team.length; i++) {
|
|
29
|
-
const
|
|
30
|
-
|
|
42
|
+
const name = team[i]
|
|
43
|
+
const loc = teamLocs[i]
|
|
44
|
+
const replacement = names.get(name)?.replacement
|
|
45
|
+
if (replacement && loc) {
|
|
46
|
+
unreplacedNames.delete(name)
|
|
47
|
+
replacedNames.add(name)
|
|
48
|
+
replacementCount++
|
|
31
49
|
replacements.push({
|
|
32
|
-
start:
|
|
33
|
-
end:
|
|
50
|
+
start: loc.start.index,
|
|
51
|
+
end: loc.end.index,
|
|
34
52
|
value: replacement,
|
|
35
53
|
})
|
|
36
54
|
}
|
|
@@ -38,4 +56,27 @@ export async function replaceSurveyNames(
|
|
|
38
56
|
}
|
|
39
57
|
|
|
40
58
|
process.stdout.write(replaceRanges(source, replacements))
|
|
59
|
+
console.error(
|
|
60
|
+
chalk.yellow(
|
|
61
|
+
`replaced ${replacedNames.size} ${
|
|
62
|
+
replacedNames.size === 1 ? '' : 's'
|
|
63
|
+
} in ${replacementCount} location${replacementCount === 1 ? '' : 's'}`
|
|
64
|
+
)
|
|
65
|
+
)
|
|
66
|
+
console.error(
|
|
67
|
+
unreplacedNames.size
|
|
68
|
+
? chalk.yellow(
|
|
69
|
+
`${unreplacedNames.size} name replacement${
|
|
70
|
+
unreplacedNames.size === 1 ? ' was' : 's were'
|
|
71
|
+
} unused${options?.verbose ? ':' : ''}`
|
|
72
|
+
)
|
|
73
|
+
: chalk.green('all name replacements were used')
|
|
74
|
+
)
|
|
75
|
+
if (options?.verbose) {
|
|
76
|
+
for (const name of [...unreplacedNames].sort(compareNames)) {
|
|
77
|
+
console.error(
|
|
78
|
+
chalk.yellow(` ${name} => ${names.get(name)?.replacement}`)
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
41
82
|
}
|
package/src/cli.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import yargs from 'yargs/yargs'
|
|
2
2
|
|
|
3
3
|
void yargs(process.argv.slice(2))
|
|
4
|
+
.scriptName('frcsdata')
|
|
4
5
|
.command({
|
|
5
6
|
command: 'check <file>',
|
|
6
7
|
describe: 'check survey file for errors or warnings',
|
|
@@ -78,12 +79,16 @@ void yargs(process.argv.slice(2))
|
|
|
78
79
|
.positional('replacementsFile', {
|
|
79
80
|
type: 'string',
|
|
80
81
|
demandOption: true,
|
|
82
|
+
})
|
|
83
|
+
.option('verbose', {
|
|
84
|
+
alias: 'v',
|
|
85
|
+
type: 'boolean',
|
|
81
86
|
}),
|
|
82
|
-
handler: async ({ surveyFile, replacementsFile }) => {
|
|
87
|
+
handler: async ({ surveyFile, replacementsFile, verbose }) => {
|
|
83
88
|
const { replaceSurveyNames: replaceNames } = await import(
|
|
84
89
|
'./cli/replace-names'
|
|
85
90
|
)
|
|
86
|
-
await replaceNames(surveyFile, replacementsFile)
|
|
91
|
+
await replaceNames(surveyFile, replacementsFile, { verbose })
|
|
87
92
|
},
|
|
88
93
|
})
|
|
89
94
|
.command({
|