diff --git a/deno.lock b/deno.lock index ca8684915bac..58eeb7e15b9d 100644 --- a/deno.lock +++ b/deno.lock @@ -239,6 +239,7 @@ "https://deno.land/std@0.208.0/yaml/schema/mod.ts": "4472e827bab5025e92bc2eb2eeefa70ecbefc64b2799b765c69af84822efef32", "https://deno.land/std@0.208.0/yaml/stringify.ts": "fffc09c65c68d3d63f8159e8cbaa3f489bc20a8e55b4fbb61a8c2e9f914d1d02", "https://deno.land/std@0.208.0/yaml/type.ts": "65553da3da3c029b6589c6e4903f0afbea6768be8fca61580711457151f2b30f", + "https://deno.land/std@0.217.0/csv/stringify.ts": "2829533f4a79b8f4b0eba7008607a2640196b6c9adf196a03eb20c523f3c8213", "https://deno.land/x/asynciter@0.0.18/asynciter.ts": "8b0a25e426e0c747dadb15123c450e676b389ac24b480fb075a61f971ebdc673", "https://deno.land/x/asynciter@0.0.18/collect.ts": "dea80ad4df11603912cad276a211671d67539dbcf7e627de99d11b2dd90a66fe", "https://deno.land/x/asynciter@0.0.18/concurrent-map.ts": "8503926d0801981d2041127f5966cb34878ee54ca21a1a85e1e0727950311eaf", @@ -272,6 +273,54 @@ "https://deno.land/x/catjazz@v0.0.3/utils/query.ts": "5605700320323c52fe39f714404877cc565381e39f59d49c0c532fb4441122ba", "https://deno.land/x/catjazz@v0.0.3/utils/timeit.ts": "4cf912ce42eec3ae9e67edf1ef82327c9c138d7ef75c4ec6a4483df796f2a31d", "https://deno.land/x/catjazz@v0.0.3/utils/transform.ts": "1bdc94edbe21ed7b0b579c4504ccf6d6d9f8752c11dc3452f80308a81e0e0393", + "https://deno.land/x/catjazz@v0.0.4/deps/asynciter.ts": "e29a1e4c978e42bf37ace9ba53b9f49920c3ebbcb4c4613c255a06e0968e57fe", + "https://deno.land/x/catjazz@v0.0.4/deps/cliffy.ts": "4032d4b947584a1abcb39ec21530da52873527db51210db9ccafc15ac50d542f", + "https://deno.land/x/catjazz@v0.0.4/deps/copb.ts": "4e1ffe87e0fb052beb2b1154ba86f94ddc72118c87b0bc81ba983f0ea13c2a49", + "https://deno.land/x/catjazz@v0.0.4/deps/std/collection.ts": "7ba6c767ff4b5559e35a8eb3d177eb8744e4c6a17984463db6d1683a600fd9fd", + "https://deno.land/x/catjazz@v0.0.4/deps/std/fmt.ts": "3399169511ac9007d1d5bd0b6199d0762415590f7b51eefb5b93678d1ffdbf9b", + "https://deno.land/x/catjazz@v0.0.4/deps/std/fs.ts": "e17b623a165d7bc125a0206c898810a55ca2de8ed723d50df664a67f9b46c0e3", + "https://deno.land/x/catjazz@v0.0.4/deps/std/path.ts": "7096502d941de6b2b14c7c6790878838c4053bf5f19f562d1ffba88100fe091d", + "https://deno.land/x/catjazz@v0.0.4/deps/ts_pattern.ts": "7526636f48b8e3f873ca434cad40a5eb87e1949e77d414b590a7f7f57300f790", + "https://deno.land/x/catjazz@v0.0.4/deps/typed_regex.ts": "1757469f30a06a206c73e789d9c1e9b7115d505a7edb04be481b2d27425a0aea", + "https://deno.land/x/catjazz@v0.0.4/deps/zod.ts": "767f25e9a6e77e7beeba2c0d7338eef29c5918942da54e797ebc0b683f32e341", + "https://deno.land/x/catjazz@v0.0.4/mod.ts": "c0064d7b65c149ce893a3f52441d85fb8d1f3af685ab3117428b25a7cb9dc4f5", + "https://deno.land/x/catjazz@v0.0.4/units/currency.ts": "2af55063b799cbe96914590363d5199bb17c80d4e5b916c01a24181f100267f4", + "https://deno.land/x/catjazz@v0.0.4/units/energy.ts": "77f15846e5dc805ea1b446d1ba19aee6e5424450083c4267df552f5745d51750", + "https://deno.land/x/catjazz@v0.0.4/units/mod.ts": "a814ea5846aba39ba9efabb24496013efdd4a7e1c9241d7f86bf781b0fdb8f51", + "https://deno.land/x/catjazz@v0.0.4/units/volume.ts": "30338ee115ecdf229da3fb16bbdc7543baab07bffafc1e8e04831912f386b48b", + "https://deno.land/x/catjazz@v0.0.4/units/weight.ts": "6fc6101cb2812c01ac6330632a8070e8310e536e385e87686a21d3ec97f3c714", + "https://deno.land/x/catjazz@v0.0.4/utils/cata_paths.ts": "b0404172460d4b5391c679245b66bec2d412e2c892c437667064161feb40c5db", + "https://deno.land/x/catjazz@v0.0.4/utils/cli.ts": "d2d4454a4db995b7a8dd6fdc489f70556393c18e299eb8f2f469f427f4c7851a", + "https://deno.land/x/catjazz@v0.0.4/utils/id.ts": "d5cb52b03643fa656e47db6c286e587c66a94d247b5214573f0798243540fe93", + "https://deno.land/x/catjazz@v0.0.4/utils/json_fmt.ts": "c1e60944a33866603361a55f1f684db9dc8dfdba77b1b6fb28f8fa8485ff9d6f", + "https://deno.land/x/catjazz@v0.0.4/utils/parse.ts": "bfbe2d5ef6f053ca4917a5354c19ec4d46433b6e4c14097b3950fcdd7715e80c", + "https://deno.land/x/catjazz@v0.0.4/utils/query.ts": "75a9fb1581d6ee1ca9640d9324467513bb6415adbe8eb381f6b97fe1d0b57365", + "https://deno.land/x/catjazz@v0.0.4/utils/timeit.ts": "4cf912ce42eec3ae9e67edf1ef82327c9c138d7ef75c4ec6a4483df796f2a31d", + "https://deno.land/x/catjazz@v0.0.4/utils/transform.ts": "1bdc94edbe21ed7b0b579c4504ccf6d6d9f8752c11dc3452f80308a81e0e0393", + "https://deno.land/x/catjazz@v0.0.5/deps/asynciter.ts": "e29a1e4c978e42bf37ace9ba53b9f49920c3ebbcb4c4613c255a06e0968e57fe", + "https://deno.land/x/catjazz@v0.0.5/deps/cliffy.ts": "4032d4b947584a1abcb39ec21530da52873527db51210db9ccafc15ac50d542f", + "https://deno.land/x/catjazz@v0.0.5/deps/copb.ts": "4e1ffe87e0fb052beb2b1154ba86f94ddc72118c87b0bc81ba983f0ea13c2a49", + "https://deno.land/x/catjazz@v0.0.5/deps/std/collection.ts": "7ba6c767ff4b5559e35a8eb3d177eb8744e4c6a17984463db6d1683a600fd9fd", + "https://deno.land/x/catjazz@v0.0.5/deps/std/fmt.ts": "3399169511ac9007d1d5bd0b6199d0762415590f7b51eefb5b93678d1ffdbf9b", + "https://deno.land/x/catjazz@v0.0.5/deps/std/fs.ts": "e17b623a165d7bc125a0206c898810a55ca2de8ed723d50df664a67f9b46c0e3", + "https://deno.land/x/catjazz@v0.0.5/deps/std/path.ts": "7096502d941de6b2b14c7c6790878838c4053bf5f19f562d1ffba88100fe091d", + "https://deno.land/x/catjazz@v0.0.5/deps/ts_pattern.ts": "7526636f48b8e3f873ca434cad40a5eb87e1949e77d414b590a7f7f57300f790", + "https://deno.land/x/catjazz@v0.0.5/deps/typed_regex.ts": "1757469f30a06a206c73e789d9c1e9b7115d505a7edb04be481b2d27425a0aea", + "https://deno.land/x/catjazz@v0.0.5/deps/zod.ts": "767f25e9a6e77e7beeba2c0d7338eef29c5918942da54e797ebc0b683f32e341", + "https://deno.land/x/catjazz@v0.0.5/mod.ts": "c0064d7b65c149ce893a3f52441d85fb8d1f3af685ab3117428b25a7cb9dc4f5", + "https://deno.land/x/catjazz@v0.0.5/units/currency.ts": "2af55063b799cbe96914590363d5199bb17c80d4e5b916c01a24181f100267f4", + "https://deno.land/x/catjazz@v0.0.5/units/energy.ts": "77f15846e5dc805ea1b446d1ba19aee6e5424450083c4267df552f5745d51750", + "https://deno.land/x/catjazz@v0.0.5/units/mod.ts": "a814ea5846aba39ba9efabb24496013efdd4a7e1c9241d7f86bf781b0fdb8f51", + "https://deno.land/x/catjazz@v0.0.5/units/volume.ts": "30338ee115ecdf229da3fb16bbdc7543baab07bffafc1e8e04831912f386b48b", + "https://deno.land/x/catjazz@v0.0.5/units/weight.ts": "6fc6101cb2812c01ac6330632a8070e8310e536e385e87686a21d3ec97f3c714", + "https://deno.land/x/catjazz@v0.0.5/utils/cata_paths.ts": "b0404172460d4b5391c679245b66bec2d412e2c892c437667064161feb40c5db", + "https://deno.land/x/catjazz@v0.0.5/utils/cli.ts": "d2d4454a4db995b7a8dd6fdc489f70556393c18e299eb8f2f469f427f4c7851a", + "https://deno.land/x/catjazz@v0.0.5/utils/id.ts": "d5cb52b03643fa656e47db6c286e587c66a94d247b5214573f0798243540fe93", + "https://deno.land/x/catjazz@v0.0.5/utils/json_fmt.ts": "c1e60944a33866603361a55f1f684db9dc8dfdba77b1b6fb28f8fa8485ff9d6f", + "https://deno.land/x/catjazz@v0.0.5/utils/parse.ts": "bfbe2d5ef6f053ca4917a5354c19ec4d46433b6e4c14097b3950fcdd7715e80c", + "https://deno.land/x/catjazz@v0.0.5/utils/query.ts": "9fbb8294f9412f66cf99ab6353d355c0c1b6de621cca12b355ffbf0247e153f3", + "https://deno.land/x/catjazz@v0.0.5/utils/timeit.ts": "4cf912ce42eec3ae9e67edf1ef82327c9c138d7ef75c4ec6a4483df796f2a31d", + "https://deno.land/x/catjazz@v0.0.5/utils/transform.ts": "1bdc94edbe21ed7b0b579c4504ccf6d6d9f8752c11dc3452f80308a81e0e0393", "https://deno.land/x/cliffy@v1.0.0-rc.3/_utils/distance.ts": "02af166952c7c358ac83beae397aa2fbca4ad630aecfcd38d92edb1ea429f004", "https://deno.land/x/cliffy@v1.0.0-rc.3/command/_argument_types.ts": "ab269dacea2030f865a07c2a1e953ec437a64419a05bad1f1ddaab3f99752ead", "https://deno.land/x/cliffy@v1.0.0-rc.3/command/_errors.ts": "12d513ff401020287a344e0830e1297ce1c80c077ecb91e0ac5db44d04a6019c", @@ -336,6 +385,7 @@ "https://deno.land/x/copb@v1.0.1/version.ts": "e1ce0be2da17592e301891cbffa0f00490c987be292434b852022c81d4d6800e", "https://deno.land/x/outdent@v0.8.0/mod.ts": "72630e680dcc36d5ae556fbff6900b12706c81a6fd592345fc98bcc0878fb3ca", "https://deno.land/x/outdent@v0.8.0/src/index.ts": "6dc3df4108d5d6fedcdb974844d321037ca81eaaa16be6073235ff3268841a22", + "https://deno.land/x/typed_regex@0.1.0/mod.ts": "8c11c41661caebe7a7672e57ec84f3bafc45bbc77ccbce683fd7bb70986d998e", "https://deno.land/x/zod@v3.22.2/ZodError.ts": "4de18ff525e75a0315f2c12066b77b5c2ae18c7c15ef7df7e165d63536fdf2ea", "https://deno.land/x/zod@v3.22.2/errors.ts": "5285922d2be9700cc0c70c95e4858952b07ae193aa0224be3cbd5cd5567eabef", "https://deno.land/x/zod@v3.22.2/external.ts": "a6cfbd61e9e097d5f42f8a7ed6f92f93f51ff927d29c9fbaec04f03cbce130fe", diff --git a/import_map.json b/import_map.json index b173610673fc..d83dfe5c2ed6 100644 --- a/import_map.json +++ b/import_map.json @@ -3,7 +3,7 @@ "$std/": "https://deno.land/std@0.208.0/", "$asynciter/": "https://deno.land/x/asynciter@0.0.18/", "$zod/": "https://deno.land/x/zod@v3.22.4/", - "$catjazz/": "https://deno.land/x/catjazz@v0.0.3/", + "$catjazz/": "https://deno.land/x/catjazz@v0.0.5/", "$ts-reset/": "https://raw.githubusercontent.com/total-typescript/ts-reset/b2df073b6b0fcb9f9599408d88cf559344c10586/src/", "$outdent/": "https://deno.land/x/outdent@v0.8.0/" }, diff --git a/scripts/migrate_legacy_unit.ts b/scripts/migrate_legacy_unit.ts index a8e82c71b866..a332eb9337b2 100644 --- a/scripts/migrate_legacy_unit.ts +++ b/scripts/migrate_legacy_unit.ts @@ -10,7 +10,7 @@ import { Command } from "$catjazz/deps/cliffy.ts" import { timeit } from "$catjazz/utils/timeit.ts" import { applyRecursively } from "$catjazz/utils/transform.ts" import { fmtJsonRecursively } from "$catjazz/utils/json_fmt.ts" -import { CataEntry, Entry, parseCataJson, readRecursively } from "$catjazz/utils/parse.ts" +import { CataEntry, Entry, parseCataJson, readJSONsRec } from "$catjazz/utils/parse.ts" import { match, P } from "$catjazz/deps/ts_pattern.ts" import { id } from "$catjazz/utils/id.ts" import { deepMerge } from "$catjazz/deps/std/collection.ts" @@ -122,11 +122,11 @@ export const schemasTransformer = (schemas: z.ZodTypeAny[]) => { } const main = () => new Command() - .option(...cliOptions.path) + .option(...cliOptions.paths) .option(...cliOptions.quiet) .option(...cliOptions.format) .description(desc) - .action(async ({ path, format, quiet = false }) => { + .action(async ({ paths, format, quiet = false }) => { const timeIt = timeit(quiet) const transformer = schemasTransformer(schemas) @@ -142,7 +142,7 @@ const main = () => const recursiveTransformer = applyRecursively(mapgenIgnoringTransformer) - const entries = await timeIt({ name: "reading JSON", val: readRecursively(path) }) + const entries = await timeIt({ name: "reading JSON", val: readJSONsRec(paths) }) await timeIt({ name: "transform", val: recursiveTransformer(entries) }) diff --git a/scripts/prices.ts b/scripts/prices.ts new file mode 100644 index 000000000000..0249c965c359 --- /dev/null +++ b/scripts/prices.ts @@ -0,0 +1,33 @@ +/** + * @module + * + * Extracts all item prices from given path recursively. + */ + +import { z } from "https://deno.land/x/catjazz@v0.0.5/deps/zod.ts" +import { queryCli } from "https://deno.land/x/catjazz@v0.0.5/mod.ts" +import { type Currency, toCents } from "https://deno.land/x/catjazz@v0.0.5/units/mod.ts" +import { type Column, stringify } from "https://deno.land/std@0.217.0/csv/stringify.ts" + +const parseCurrency = z.string().transform((c) => toCents(c as Currency)) + +const schema = z.object({ + id: z.string(), + price_postapoc: parseCurrency, +}) + +const columns: Column[] = ["id", "price_postapoc"] + +if (import.meta.main) { + const main = queryCli({ + desc: "item prices", + schema, + map: (xs) => { + console.table(xs) + const csv = stringify(xs, { columns }) + return csv + }, + }) + + await main().parse(Deno.args) +}