From f09882106957f03ea17c1647d31019b4dd90b581 Mon Sep 17 00:00:00 2001 From: winston Date: Tue, 26 Dec 2023 08:31:56 +0100 Subject: [PATCH 01/18] chore: cleanup test dir --- test/basic/deno.json | 6 ++++++ test/basic/deno.lock | 6 ++++++ test/basic/main.ts | 4 ++-- test/problem-matcher/deno.json | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 test/basic/deno.json create mode 100644 test/basic/deno.lock diff --git a/test/basic/deno.json b/test/basic/deno.json new file mode 100644 index 0000000..aa60bb2 --- /dev/null +++ b/test/basic/deno.json @@ -0,0 +1,6 @@ +{ + "imports": { + "std/": "https://deno.land/std@0.207.0/", + "cliffy/": "https://deno.land/x/cliffy@v1.0.0-rc.3/" + } +} diff --git a/test/basic/deno.lock b/test/basic/deno.lock new file mode 100644 index 0000000..419a6d9 --- /dev/null +++ b/test/basic/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "3", + "remote": { + "https://deno.land/std@0.207.0/fmt/colors.ts": "34b3f77432925eb72cf0bfb351616949746768620b8e5ead66da532f93d10ba2" + } +} diff --git a/test/basic/main.ts b/test/basic/main.ts index 4c89a8b..5ad9052 100755 --- a/test/basic/main.ts +++ b/test/basic/main.ts @@ -1,6 +1,6 @@ -#!/usr/bin/env -S deno run -A +#!/usr/bin/env -S deno run // just get any stdlib for the cache test -import { red, yellow, green, cyan, magenta } from "std/fmt/colors.ts"; +import { cyan, green, magenta, red, yellow } from "std/fmt/colors.ts"; const helloWorld = [ red("He"), diff --git a/test/problem-matcher/deno.json b/test/problem-matcher/deno.json index e69de29..0967ef4 100644 --- a/test/problem-matcher/deno.json +++ b/test/problem-matcher/deno.json @@ -0,0 +1 @@ +{} From f224a129fddd24a539e74f615fbab97fd2d92973 Mon Sep 17 00:00:00 2001 From: winston Date: Tue, 26 Dec 2023 08:54:23 +0100 Subject: [PATCH 02/18] feat: add lock manager --- .vscode/settings.json | 5 +- bundle.ts | 11 +++ cache.ts | 109 ++++++++++++++++++++++++++++ deno.json | 8 +- deno.lock | 165 +++++++++++++++++++++++++++++++++++++++++- 5 files changed, 295 insertions(+), 3 deletions(-) create mode 100755 bundle.ts create mode 100755 cache.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index cbac569..c5d71f6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,6 @@ { - "deno.enable": true + "deno.enable": true, + "[typescript]": { + "editor.defaultFormatter": "denoland.vscode-deno" + } } diff --git a/bundle.ts b/bundle.ts new file mode 100755 index 0000000..57b3eb4 --- /dev/null +++ b/bundle.ts @@ -0,0 +1,11 @@ +#!/usr/bin/env -S deno run --allow-env=HOME,DENO_AUTH_TOKENS,DENO_DIR --allow-read --allow-write=./dist +import { bundle } from "https://deno.land/x/emit@0.32.0/mod.ts"; +import { ensureDir } from "https://deno.land/std@0.209.0/fs/ensure_dir.ts"; + +const bundled = await bundle( + new URL("./cache.ts", import.meta.url), + { minify: true }, +); + +ensureDir("./dist"); +await Deno.writeTextFile("./dist/cache.js", bundled.code); diff --git a/cache.ts b/cache.ts new file mode 100755 index 0000000..dcb4281 --- /dev/null +++ b/cache.ts @@ -0,0 +1,109 @@ +#!/usr/bin/env -S deno run --no-lock --allow-read --allow-run=deno +import { parseArgs } from "https://deno.land/std@0.210.0/cli/parse_args.ts"; +import { encodeHex } from "https://deno.land/std@0.210.0/encoding/hex.ts"; +import { exists, walk } from "https://deno.land/std@0.210.0/fs/mod.ts"; +import * as JSONC from "https://deno.land/std@0.210.0/jsonc/parse.ts"; +import * as log from "https://deno.land/std@0.210.0/log/mod.ts"; +import { relative } from "https://deno.land/std@0.210.0/path/relative.ts"; +import ignore from "https://esm.sh/gh/nekowinston/deno-ignore@v5.3.0/index.js?pin=v135"; + +const args = parseArgs(Deno.args, { + boolean: ["help", "dry-run", "debug"], + string: ["config"], + alias: { help: "h", dryRun: "n" }, + "--": true, +}); + +const logLevel = args.debug ? "DEBUG" : "INFO"; +log.setup({ + handlers: { + console: new log.handlers.ConsoleHandler(logLevel, { + formatter: (logRecord) => + Deno.noColor + ? [logRecord.levelName, logRecord.msg].join(" ") + : logRecord.msg, + }), + }, + loggers: { default: { handlers: ["console"], "level": logLevel } }, +}); + +type Args = typeof args; +type DenoConfig = { + cache: { include?: string[]; exclude?: string[] }; + exclude?: string[]; + [key: string]: unknown; +}; + +const main = async (args: Args) => { + if (args.help) { + console.log("Usage: cache [-n | --dry-run] [--debug] [--] [DENO_ARGS...]"); + Deno.exit(0); + } + + if (args["dry-run"]) log.warning("dry-run mode enabled"); + if (args.config && !await exists(args.config)) { + log.error(`config file ${args.config} not found`); + Deno.exit(1); + } + + // the two-step hash is intentional + const hash = await Deno.readFile("./deno.lock") + .then((data) => crypto.subtle.digest("SHA-256", data)) + .then((data) => crypto.subtle.digest("SHA-256", data)) + .then((data) => encodeHex(new Uint8Array(data))) + .catch((_) => ""); + log.debug(`GitHub actions deno.lock hash: ${hash}`); + + // Deno implementation: `json` takes precedence over `jsonc` + const cfgs = args.config ? [args.config] : ["deno.json", "deno.jsonc"]; + const denoCfg = await Promise.all( + cfgs.map((path) => Deno.readTextFile(path).catch((_) => undefined)), + ).then((v) => JSONC.parse(v.filter(Boolean)[0] ?? "{}")) as DenoConfig; + + // flattening so that a single string doesn't break too much + const patterns = [ + ...[denoCfg?.exclude ?? []].flat(), + ...[denoCfg?.cache?.exclude ?? []].flat(), + ...[denoCfg?.cache?.include ?? []].flatMap((p) => `!${p}`), + ]; + log.debug(`patterns:`, patterns); + patterns.forEach((p) => log.debug(`- ${p}`)); + const ig = ignore().add(patterns); + + const walkIterator = walk(".", { + exts: ["js", ".jsx", ".ts", ".tsx"], + includeDirs: false, + }); + + for await (const entry of walkIterator) { + const relativePath = relative(".", entry.path); + + if (ig.ignores(relativePath)) { + log.debug(`ignored ${relativePath}`); + continue; + } + + log.debug(`caching ${relativePath}`); + const cmd = new Deno.Command(Deno.execPath(), { + args: [ + "cache", + args.config && `--config=${args.config}`, + relativePath, + ...args["--"], + ].filter(Boolean) as string[], + stdout: "inherit", + stderr: "inherit", + }); + + let code = 0; + if (!args["dry-run"]) code = (await cmd.output()).code; + + if (code === 0) { + log.info(`cached ${relativePath}`); + } else { + log.error(`failed to cache ${entry.path}`); + } + } +}; + +if (import.meta.main) main(args); diff --git a/deno.json b/deno.json index c72ea83..a569be6 100644 --- a/deno.json +++ b/deno.json @@ -1,7 +1,13 @@ { + "tasks": { + "cache": "deno run --allow-read --allow-run=deno ./cache.ts" + }, "imports": { "std/": "https://deno.land/std@0.207.0/", "cliffy/": "https://deno.land/x/cliffy@v1.0.0-rc.3/" }, - "exclude": ["test/problem-matcher"] + "exclude": ["dist", "test/problem-matcher/*"], + "cache": { + "include": ["test/problem-matcher/*"] + } } diff --git a/deno.lock b/deno.lock index 4551f92..ead3d03 100644 --- a/deno.lock +++ b/deno.lock @@ -1,6 +1,36 @@ { "version": "3", "remote": { + "https://deno.land/std@0.140.0/_util/assert.ts": "e94f2eb37cebd7f199952e242c77654e43333c1ac4c5c700e929ea3aa5489f74", + "https://deno.land/std@0.140.0/_util/os.ts": "3b4c6e27febd119d36a416d7a97bd3b0251b77c88942c8f16ee5953ea13e2e49", + "https://deno.land/std@0.140.0/bytes/bytes_list.ts": "67eb118e0b7891d2f389dad4add35856f4ad5faab46318ff99653456c23b025d", + "https://deno.land/std@0.140.0/bytes/equals.ts": "fc16dff2090cced02497f16483de123dfa91e591029f985029193dfaa9d894c9", + "https://deno.land/std@0.140.0/bytes/mod.ts": "763f97d33051cc3f28af1a688dfe2830841192a9fea0cbaa55f927b49d49d0bf", + "https://deno.land/std@0.140.0/fmt/colors.ts": "30455035d6d728394781c10755351742dd731e3db6771b1843f9b9e490104d37", + "https://deno.land/std@0.140.0/fs/_util.ts": "0fb24eb4bfebc2c194fb1afdb42b9c3dda12e368f43e8f2321f84fc77d42cb0f", + "https://deno.land/std@0.140.0/fs/ensure_dir.ts": "9dc109c27df4098b9fc12d949612ae5c9c7169507660dcf9ad90631833209d9d", + "https://deno.land/std@0.140.0/io/buffer.ts": "bd0c4bf53db4b4be916ca5963e454bddfd3fcd45039041ea161dbf826817822b", + "https://deno.land/std@0.140.0/path/_constants.ts": "df1db3ffa6dd6d1252cc9617e5d72165cd2483df90e93833e13580687b6083c3", + "https://deno.land/std@0.140.0/path/_interface.ts": "ee3b431a336b80cf445441109d089b70d87d5e248f4f90ff906820889ecf8d09", + "https://deno.land/std@0.140.0/path/_util.ts": "c1e9686d0164e29f7d880b2158971d805b6e0efc3110d0b3e24e4b8af2190d2b", + "https://deno.land/std@0.140.0/path/common.ts": "bee563630abd2d97f99d83c96c2fa0cca7cee103e8cb4e7699ec4d5db7bd2633", + "https://deno.land/std@0.140.0/path/glob.ts": "cb5255638de1048973c3e69e420c77dc04f75755524cb3b2e160fe9277d939ee", + "https://deno.land/std@0.140.0/path/mod.ts": "d3e68d0abb393fb0bf94a6d07c46ec31dc755b544b13144dee931d8d5f06a52d", + "https://deno.land/std@0.140.0/path/posix.ts": "293cdaec3ecccec0a9cc2b534302dfe308adb6f10861fa183275d6695faace44", + "https://deno.land/std@0.140.0/path/separator.ts": "fe1816cb765a8068afb3e8f13ad272351c85cbc739af56dacfc7d93d710fe0f9", + "https://deno.land/std@0.140.0/path/win32.ts": "31811536855e19ba37a999cd8d1b62078235548d67902ece4aa6b814596dd757", + "https://deno.land/std@0.140.0/streams/conversion.ts": "712585bfa0172a97fb68dd46e784ae8ad59d11b88079d6a4ab098ff42e697d21", + "https://deno.land/std@0.186.0/_util/asserts.ts": "178dfc49a464aee693a7e285567b3d0b555dc805ff490505a8aae34f9cfb1462", + "https://deno.land/std@0.186.0/_util/os.ts": "d932f56d41e4f6a6093d56044e29ce637f8dcc43c5a90af43504a889cf1775e3", + "https://deno.land/std@0.186.0/path/_constants.ts": "e49961f6f4f48039c0dfed3c3f93e963ca3d92791c9d478ac5b43183413136e0", + "https://deno.land/std@0.186.0/path/_interface.ts": "6471159dfbbc357e03882c2266d21ef9afdb1e4aa771b0545e90db58a0ba314b", + "https://deno.land/std@0.186.0/path/_util.ts": "d7abb1e0dea065f427b89156e28cdeb32b045870acdf865833ba808a73b576d0", + "https://deno.land/std@0.186.0/path/common.ts": "ee7505ab01fd22de3963b64e46cff31f40de34f9f8de1fff6a1bd2fe79380000", + "https://deno.land/std@0.186.0/path/glob.ts": "d479e0a695621c94d3fd7fe7abd4f9499caf32a8de13f25073451c6ef420a4e1", + "https://deno.land/std@0.186.0/path/mod.ts": "ee161baec5ded6510ee1d1fb6a75a0f5e4b41f3f3301c92c716ecbdf7dae910d", + "https://deno.land/std@0.186.0/path/posix.ts": "8b7c67ac338714b30c816079303d0285dd24af6b284f7ad63da5b27372a2c94d", + "https://deno.land/std@0.186.0/path/separator.ts": "0fb679739d0d1d7bf45b68dacfb4ec7563597a902edbaf3c59b50d5bcadd93b1", + "https://deno.land/std@0.186.0/path/win32.ts": "d186344e5583bcbf8b18af416d13d82b35a317116e6460a5a3953508c3de5bba", "https://deno.land/std@0.196.0/assert/assert.ts": "9a97dad6d98c238938e7540736b826440ad8c1c1e54430ca4c4e623e585607ee", "https://deno.land/std@0.196.0/assert/assertion_error.ts": "4d0bde9b374dfbcbe8ac23f54f567b77024fb67dbb1906a852d67fe050d42f56", "https://deno.land/std@0.196.0/console/_data.json": "cf2cc9d039a192b3adbfe64627167c7e6212704c888c25c769fc8f1709e1e1b8", @@ -8,6 +38,114 @@ "https://deno.land/std@0.196.0/console/unicode_width.ts": "10661c0f2eeab802d16b8b85ed8825bbc573991bbfb6affed32dc1ff994f54f9", "https://deno.land/std@0.196.0/fmt/colors.ts": "a7eecffdf3d1d54db890723b303847b6e0a1ab4b528ba6958b8f2e754cf1b3bc", "https://deno.land/std@0.207.0/fmt/colors.ts": "34b3f77432925eb72cf0bfb351616949746768620b8e5ead66da532f93d10ba2", + "https://deno.land/std@0.209.0/fs/_util.ts": "b03c46be986540a23916918fe0c01e257909e34be371943812001792859e22be", + "https://deno.land/std@0.209.0/fs/ensure_dir.ts": "dc64c4c75c64721d4e3fb681f1382f803ff3d2868f08563ff923fdd20d071c40", + "https://deno.land/std@0.209.0/path/_common/assert_path.ts": "061e4d093d4ba5aebceb2c4da3318bfe3289e868570e9d3a8e327d91c2958946", + "https://deno.land/std@0.209.0/path/_common/basename.ts": "0d978ff818f339cd3b1d09dc914881f4d15617432ae519c1b8fdc09ff8d3789a", + "https://deno.land/std@0.209.0/path/_common/constants.ts": "e49961f6f4f48039c0dfed3c3f93e963ca3d92791c9d478ac5b43183413136e0", + "https://deno.land/std@0.209.0/path/_common/from_file_url.ts": "ef1bf3197d2efbf0297a2bdbf3a61d804b18f2bcce45548ae112313ec5be3c22", + "https://deno.land/std@0.209.0/path/_common/normalize.ts": "2ba7fb4cc9fafb0f38028f434179579ce61d4d9e51296fad22b701c3d3cd7397", + "https://deno.land/std@0.209.0/path/_common/normalize_string.ts": "88c472f28ae49525f9fe82de8c8816d93442d46a30d6bb5063b07ff8a89ff589", + "https://deno.land/std@0.209.0/path/_common/strip_trailing_separators.ts": "7ffc7c287e97bdeeee31b155828686967f222cd73f9e5780bfe7dfb1b58c6c65", + "https://deno.land/std@0.209.0/path/_os.ts": "30b0c2875f360c9296dbe6b7f2d528f0f9c741cecad2e97f803f5219e91b40a2", + "https://deno.land/std@0.209.0/path/basename.ts": "04bb5ef3e86bba8a35603b8f3b69537112cdd19ce64b77f2522006da2977a5f3", + "https://deno.land/std@0.209.0/path/from_file_url.ts": "e7fa233ea1dff9641e8d566153a24d95010110185a6f418dd2e32320926043f8", + "https://deno.land/std@0.209.0/path/normalize.ts": "aa95be9a92c7bd4f9dc0ba51e942a1973e2b93d266cd74f5ca751c136d520b66", + "https://deno.land/std@0.209.0/path/posix/_util.ts": "ecf49560fedd7dd376c6156cc5565cad97c1abe9824f4417adebc7acc36c93e5", + "https://deno.land/std@0.209.0/path/posix/basename.ts": "a630aeb8fd8e27356b1823b9dedd505e30085015407caa3396332752f6b8406a", + "https://deno.land/std@0.209.0/path/posix/from_file_url.ts": "b97287a83e6407ac27bdf3ab621db3fccbf1c27df0a1b1f20e1e1b5acf38a379", + "https://deno.land/std@0.209.0/path/posix/normalize.ts": "11de90a94ab7148cc46e5a288f7d732aade1d616bc8c862f5560fa18ff987b4b", + "https://deno.land/std@0.209.0/path/posix/resolve.ts": "51579d83159d5c719518c9ae50812a63959bbcb7561d79acbdb2c3682236e285", + "https://deno.land/std@0.209.0/path/resolve.ts": "5b184efc87155a0af9fa305ff68a109e28de9aee81fc3e77cd01380f19daf867", + "https://deno.land/std@0.209.0/path/separator.ts": "40a3e9a4ad10bef23bc2cd6c610291b6c502a06237c2c4cd034a15ca78dedc1f", + "https://deno.land/std@0.209.0/path/windows/_util.ts": "f32b9444554c8863b9b4814025c700492a2b57ff2369d015360970a1b1099d54", + "https://deno.land/std@0.209.0/path/windows/basename.ts": "8a9dbf7353d50afbc5b221af36c02a72c2d1b2b5b9f7c65bf6a5a2a0baf88ad3", + "https://deno.land/std@0.209.0/path/windows/from_file_url.ts": "d53335c12b0725893d768be3ac6bf0112cc5b639d2deb0171b35988493b46199", + "https://deno.land/std@0.209.0/path/windows/normalize.ts": "9deebbf40c81ef540b7b945d4ccd7a6a2c5a5992f791e6d3377043031e164e69", + "https://deno.land/std@0.209.0/path/windows/resolve.ts": "5ff441ab18a2346abadf778121128ee71bda4d0898513d4639a6ca04edca366b", + "https://deno.land/std@0.210.0/assert/assert.ts": "e265ad50a9341f3b40e51dd4cb41ab253d976943ba78a977106950e52e0302ab", + "https://deno.land/std@0.210.0/assert/assertion_error.ts": "26ed1863d905005f00785c89750c001c3522c5417e4f58f95044b8143cfc1593", + "https://deno.land/std@0.210.0/bytes/copy.ts": "939d89e302a9761dcf1d9c937c7711174ed74c59eef40a1e4569a05c9de88219", + "https://deno.land/std@0.210.0/cli/parse_args.ts": "9bea02050b3f302e706871ff87ecfa3ad82cc34249adbe0dcddfaac75bdb48ff", + "https://deno.land/std@0.210.0/encoding/_util.ts": "f368920189c4fe6592ab2e93bd7ded8f3065b84f95cd3e036a4a10a75649dcba", + "https://deno.land/std@0.210.0/encoding/hex.ts": "a91232cc15aeb458289d22ed443dc2ba2e6f98080a11db3dfc96a0063c238cbe", + "https://deno.land/std@0.210.0/fmt/colors.ts": "2685c524bef9b16b3059a417daf6860c754eb755e19e812762ef5dff62f24481", + "https://deno.land/std@0.210.0/fs/_create_walk_entry.ts": "7462542d30c53e925b07c4243929434e78a190d31987a3388c8e0bd52ef8e440", + "https://deno.land/std@0.210.0/fs/_get_file_info_type.ts": "9c92ff74f39bfba66b09faf9901af6a944cc71f014d9649e7d3e32eac4aeddfc", + "https://deno.land/std@0.210.0/fs/_is_same_path.ts": "9ba34405c53da1e1bd9635785da85b21e9593698369dbb675dfac33c30f183f4", + "https://deno.land/std@0.210.0/fs/_is_subdir.ts": "65525686538138cdfc7e9bc24d9c8397cd28342f8395f0c472989c6787ff6749", + "https://deno.land/std@0.210.0/fs/_to_path_string.ts": "d963898a0d277b155eefb5c64202de71ca2f5e1348897a2f56d3bce6347fc3cc", + "https://deno.land/std@0.210.0/fs/copy.ts": "2a7ccfd78976fb624699bd8dec214bc492804b29414c80e7c29955526598b57b", + "https://deno.land/std@0.210.0/fs/empty_dir.ts": "a0d35035b604fbbdedee9a8fe28b7436ae0f32a111e9e88fe0469b93b8548940", + "https://deno.land/std@0.210.0/fs/ensure_dir.ts": "f797d9bf39aa2a796923a62b0e10d864998cec396f4712f5c869f3d0d8a6bfd3", + "https://deno.land/std@0.210.0/fs/ensure_file.ts": "2498a930983c33a51152d4a6a47b161711ba3f2290879cd1f89a9a8e23f2fbc1", + "https://deno.land/std@0.210.0/fs/ensure_link.ts": "1121ac4cfd24e6d20206c7d4dbdc6b02ed9b9f6550447b590a077c941e3c456d", + "https://deno.land/std@0.210.0/fs/ensure_symlink.ts": "d01debcdf62a5fdb0b5d70a516713cec3628a8ae5eddd99cb278305a4fd98091", + "https://deno.land/std@0.210.0/fs/eol.ts": "27516caa5b0f703bc67817493d07b9eb861b1a8bb8dfe52f73a011ae6e58e7d5", + "https://deno.land/std@0.210.0/fs/exists.ts": "da38bab3cd416131a2075c1a532c69b0b634c2ce8d75222355aa6d3d15995199", + "https://deno.land/std@0.210.0/fs/expand_glob.ts": "9b68f6146a106c8c2ce8f8794ce07678fcb232536222929dded8acecab6f8782", + "https://deno.land/std@0.210.0/fs/mod.ts": "bc3d0acd488cc7b42627044caf47d72019846d459279544e1934418955ba4898", + "https://deno.land/std@0.210.0/fs/move.ts": "ec2c5ae4a5cbef32c95af7171b4296d4c1ef414fbcebf473f00d1682c6f6c708", + "https://deno.land/std@0.210.0/fs/walk.ts": "78131d81952231f173e01aa1c1d69485e627bf4bb3af020a1c1b2ad490892c12", + "https://deno.land/std@0.210.0/io/buf_writer.ts": "6af65d3e243f8bb4ddbc921542ef8797e3bc128bccc43257fe081d57262ad48c", + "https://deno.land/std@0.210.0/json/common.ts": "ecd5e87d45b5f0df33238ed8b1746e1444da7f5c86ae53d0f0b04280f41a25bb", + "https://deno.land/std@0.210.0/jsonc/parse.ts": "6048912a52d1ee3876a89f57ae6885f3b675bf2708700ef8d3d72acf6ef3342e", + "https://deno.land/std@0.210.0/log/formatters.ts": "23da1a9d28c27fa9880e6b4b36f92726f1989a14c106eb35c23b4281e519395c", + "https://deno.land/std@0.210.0/log/handlers.ts": "682234d655d519d13df9037ab788fc54fcaf676417f4bc7dd37bdbdb99e236ea", + "https://deno.land/std@0.210.0/log/levels.ts": "11566b9982ca7dad854bb6e6d477041ac76da253743eaacc3f20bef410cc4e30", + "https://deno.land/std@0.210.0/log/logger.ts": "fe3e2c4eb187f0f61f2be15ee191e1cc55c0c45c41a26bf4b3274740242121a7", + "https://deno.land/std@0.210.0/log/mod.ts": "72ab0c2a237c8c867d197ae7fe348bfa0c61d7af2b25d986e2896e528f03f94f", + "https://deno.land/std@0.210.0/path/_common/assert_path.ts": "061e4d093d4ba5aebceb2c4da3318bfe3289e868570e9d3a8e327d91c2958946", + "https://deno.land/std@0.210.0/path/_common/basename.ts": "0d978ff818f339cd3b1d09dc914881f4d15617432ae519c1b8fdc09ff8d3789a", + "https://deno.land/std@0.210.0/path/_common/constants.ts": "e49961f6f4f48039c0dfed3c3f93e963ca3d92791c9d478ac5b43183413136e0", + "https://deno.land/std@0.210.0/path/_common/dirname.ts": "2ba7fb4cc9fafb0f38028f434179579ce61d4d9e51296fad22b701c3d3cd7397", + "https://deno.land/std@0.210.0/path/_common/from_file_url.ts": "ef1bf3197d2efbf0297a2bdbf3a61d804b18f2bcce45548ae112313ec5be3c22", + "https://deno.land/std@0.210.0/path/_common/glob_to_reg_exp.ts": "50386887d6041f15741d0013a703ee63ef673983d465d3a0c9c190e95f8da4fe", + "https://deno.land/std@0.210.0/path/_common/normalize.ts": "2ba7fb4cc9fafb0f38028f434179579ce61d4d9e51296fad22b701c3d3cd7397", + "https://deno.land/std@0.210.0/path/_common/normalize_string.ts": "88c472f28ae49525f9fe82de8c8816d93442d46a30d6bb5063b07ff8a89ff589", + "https://deno.land/std@0.210.0/path/_common/relative.ts": "1af19d787a2a84b8c534cc487424fe101f614982ae4851382c978ab2216186b4", + "https://deno.land/std@0.210.0/path/_common/strip_trailing_separators.ts": "7ffc7c287e97bdeeee31b155828686967f222cd73f9e5780bfe7dfb1b58c6c65", + "https://deno.land/std@0.210.0/path/_os.ts": "30b0c2875f360c9296dbe6b7f2d528f0f9c741cecad2e97f803f5219e91b40a2", + "https://deno.land/std@0.210.0/path/basename.ts": "04bb5ef3e86bba8a35603b8f3b69537112cdd19ce64b77f2522006da2977a5f3", + "https://deno.land/std@0.210.0/path/dirname.ts": "88a0a71c21debafc4da7a4cd44fd32e899462df458fbca152390887d41c40361", + "https://deno.land/std@0.210.0/path/from_file_url.ts": "e7fa233ea1dff9641e8d566153a24d95010110185a6f418dd2e32320926043f8", + "https://deno.land/std@0.210.0/path/glob.ts": "a00a81a55c02bbe074ab21a50b6495c6f7795f54cd718c824adaa92c6c9b7419", + "https://deno.land/std@0.210.0/path/glob_to_regexp.ts": "74d7448c471e293d03f05ccb968df4365fed6aaa508506b6325a8efdc01d8271", + "https://deno.land/std@0.210.0/path/is_absolute.ts": "67232b41b860571c5b7537f4954c88d86ae2ba45e883ee37d3dec27b74909d13", + "https://deno.land/std@0.210.0/path/is_glob.ts": "567dce5c6656bdedfc6b3ee6c0833e1e4db2b8dff6e62148e94a917f289c06ad", + "https://deno.land/std@0.210.0/path/join.ts": "3ee91038e3eaa966897eddda43d5207d7cae5c2de8a658bdbd722e8f8f29206a", + "https://deno.land/std@0.210.0/path/join_globs.ts": "9b84d5103b63d3dbed4b2cf8b12477b2ad415c7d343f1488505162dc0e5f4db8", + "https://deno.land/std@0.210.0/path/normalize.ts": "aa95be9a92c7bd4f9dc0ba51e942a1973e2b93d266cd74f5ca751c136d520b66", + "https://deno.land/std@0.210.0/path/normalize_glob.ts": "674baa82e1c00b6cb153bbca36e06f8e0337cb8062db6d905ab5de16076ca46b", + "https://deno.land/std@0.210.0/path/posix/_util.ts": "ecf49560fedd7dd376c6156cc5565cad97c1abe9824f4417adebc7acc36c93e5", + "https://deno.land/std@0.210.0/path/posix/basename.ts": "a630aeb8fd8e27356b1823b9dedd505e30085015407caa3396332752f6b8406a", + "https://deno.land/std@0.210.0/path/posix/dirname.ts": "f48c9c42cc670803b505478b7ef162c7cfa9d8e751b59d278b2ec59470531472", + "https://deno.land/std@0.210.0/path/posix/from_file_url.ts": "b97287a83e6407ac27bdf3ab621db3fccbf1c27df0a1b1f20e1e1b5acf38a379", + "https://deno.land/std@0.210.0/path/posix/glob_to_regexp.ts": "6ed00c71fbfe0ccc35977c35444f94e82200b721905a60bd1278b1b768d68b1a", + "https://deno.land/std@0.210.0/path/posix/is_absolute.ts": "159900a3422d11069d48395568217eb7fc105ceda2683d03d9b7c0f0769e01b8", + "https://deno.land/std@0.210.0/path/posix/join.ts": "0c0d84bdc344876930126640011ec1b888e6facf74153ffad9ef26813aa2a076", + "https://deno.land/std@0.210.0/path/posix/join_globs.ts": "f4838d54b1f60a34a40625a3293f6e583135348be1b2974341ac04743cb26121", + "https://deno.land/std@0.210.0/path/posix/normalize.ts": "11de90a94ab7148cc46e5a288f7d732aade1d616bc8c862f5560fa18ff987b4b", + "https://deno.land/std@0.210.0/path/posix/normalize_glob.ts": "10a1840c628ebbab679254d5fa1c20e59106102354fb648a1765aed72eb9f3f9", + "https://deno.land/std@0.210.0/path/posix/relative.ts": "e2f230608b0f083e6deaa06e063943e5accb3320c28aef8d87528fbb7fe6504c", + "https://deno.land/std@0.210.0/path/posix/resolve.ts": "51579d83159d5c719518c9ae50812a63959bbcb7561d79acbdb2c3682236e285", + "https://deno.land/std@0.210.0/path/posix/separator.ts": "0b6573b5f3269a3164d8edc9cefc33a02dd51003731c561008c8bb60220ebac1", + "https://deno.land/std@0.210.0/path/relative.ts": "23d45ede8b7ac464a8299663a43488aad6b561414e7cbbe4790775590db6349c", + "https://deno.land/std@0.210.0/path/resolve.ts": "5b184efc87155a0af9fa305ff68a109e28de9aee81fc3e77cd01380f19daf867", + "https://deno.land/std@0.210.0/path/separator.ts": "1a21ffd408bfaa317bffff604e5a799f78a7a5571590bde6b9cdce7685953d74", + "https://deno.land/std@0.210.0/path/windows/_util.ts": "f32b9444554c8863b9b4814025c700492a2b57ff2369d015360970a1b1099d54", + "https://deno.land/std@0.210.0/path/windows/basename.ts": "8a9dbf7353d50afbc5b221af36c02a72c2d1b2b5b9f7c65bf6a5a2a0baf88ad3", + "https://deno.land/std@0.210.0/path/windows/dirname.ts": "5c2aa541384bf0bd9aca821275d2a8690e8238fa846198ef5c7515ce31a01a94", + "https://deno.land/std@0.210.0/path/windows/from_file_url.ts": "d53335c12b0725893d768be3ac6bf0112cc5b639d2deb0171b35988493b46199", + "https://deno.land/std@0.210.0/path/windows/glob_to_regexp.ts": "290755e18ec6c1a4f4d711c3390537358e8e3179581e66261a0cf348b1a13395", + "https://deno.land/std@0.210.0/path/windows/is_absolute.ts": "245b56b5f355ede8664bd7f080c910a97e2169972d23075554ae14d73722c53c", + "https://deno.land/std@0.210.0/path/windows/join.ts": "e6600bf88edeeef4e2276e155b8de1d5dec0435fd526ba2dc4d37986b2882f16", + "https://deno.land/std@0.210.0/path/windows/join_globs.ts": "f4838d54b1f60a34a40625a3293f6e583135348be1b2974341ac04743cb26121", + "https://deno.land/std@0.210.0/path/windows/normalize.ts": "9deebbf40c81ef540b7b945d4ccd7a6a2c5a5992f791e6d3377043031e164e69", + "https://deno.land/std@0.210.0/path/windows/normalize_glob.ts": "344ff5ed45430495b9a3d695567291e50e00b1b3b04ea56712a2acf07ab5c128", + "https://deno.land/std@0.210.0/path/windows/relative.ts": "026855cd2c36c8f28f1df3c6fbd8f2449a2aa21f48797a74700c5d872b86d649", + "https://deno.land/std@0.210.0/path/windows/resolve.ts": "5ff441ab18a2346abadf778121128ee71bda4d0898513d4639a6ca04edca366b", + "https://deno.land/std@0.210.0/path/windows/separator.ts": "ae21f27015f10510ed1ac4a0ba9c4c9c967cbdd9d9e776a3e4967553c397bd5d", "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", @@ -66,6 +204,31 @@ "https://deno.land/x/cliffy@v1.0.0-rc.3/table/consume_words.ts": "456e75755fdf6966abdefb8b783df2855e2a8bad6ddbdf21bd748547c5fc1d4b", "https://deno.land/x/cliffy@v1.0.0-rc.3/table/deps.ts": "1226c4d39d53edc81d7c3e661fb8a79f2e704937c276c60355cd4947a0fe9153", "https://deno.land/x/cliffy@v1.0.0-rc.3/table/row.ts": "79eb1468aafdd951e5963898cdafe0752d4ab4c519d5f847f3d8ecb8fe857d4f", - "https://deno.land/x/cliffy@v1.0.0-rc.3/table/table.ts": "298671e72e61f1ab18b42ae36643181993f79e29b39dc411fdc6ffd53aa04684" + "https://deno.land/x/cliffy@v1.0.0-rc.3/table/table.ts": "298671e72e61f1ab18b42ae36643181993f79e29b39dc411fdc6ffd53aa04684", + "https://deno.land/x/deno_cache@0.5.2/auth_tokens.ts": "5d1d56474c54a9d152e44d43ea17c2e6a398dd1e9682c69811a313567c01ee1e", + "https://deno.land/x/deno_cache@0.5.2/cache.ts": "92ce8511e1e5c00fdf53a41619aa77d632ea8e0fc711324322e4d5ebf8133911", + "https://deno.land/x/deno_cache@0.5.2/deno_dir.ts": "1ea355b8ba11c630d076b222b197cfc937dd81e5a4a260938997da99e8ff93a0", + "https://deno.land/x/deno_cache@0.5.2/deps.ts": "26a75905652510b76e54b6d5ef3cf824d1062031e00782efcd768978419224e7", + "https://deno.land/x/deno_cache@0.5.2/dirs.ts": "009c6f54e0b610914d6ce9f72f6f6ccfffd2d47a79a19061e0a9eb4253836069", + "https://deno.land/x/deno_cache@0.5.2/disk_cache.ts": "66a1e604a8d564b6dd0500326cac33d08b561d331036bf7272def80f2f7952aa", + "https://deno.land/x/deno_cache@0.5.2/file_fetcher.ts": "89616c50b6df73fb04e73d0b7cd99e5f2ed7967386913d65b9e8baa4238501f7", + "https://deno.land/x/deno_cache@0.5.2/http_cache.ts": "407135eaf2802809ed373c230d57da7ef8dff923c4abf205410b9b99886491fd", + "https://deno.land/x/deno_cache@0.5.2/lib/deno_cache_dir.generated.js": "18b6526d0c50791a73dd0eb894e99de1ac05ee79dcbd53298ff5b5b6b0757fe6", + "https://deno.land/x/deno_cache@0.5.2/lib/snippets/deno_cache_dir-77bed54ace8005e0/fs.js": "cbe3a976ed63c72c7cb34ef845c27013033a3b11f9d8d3e2c4aa5dda2c0c7af6", + "https://deno.land/x/deno_cache@0.5.2/mod.ts": "0b4d071ad095128bdc2b1bc6e5d2095222dcbae08287261690ee9757e6300db6", + "https://deno.land/x/deno_cache@0.5.2/util.ts": "f3f5a0cfc60051f09162942fb0ee87a0e27b11a12aec4c22076e3006be4cc1e2", + "https://deno.land/x/deno_graph@0.26.0/lib/deno_graph.generated.js": "2f7ca85b2ceb80ec4b3d1b7f3a504956083258610c7b9a1246238c5b7c68f62d", + "https://deno.land/x/deno_graph@0.26.0/lib/loader.ts": "380e37e71d0649eb50176a9786795988fc3c47063a520a54b616d7727b0f8629", + "https://deno.land/x/deno_graph@0.26.0/lib/media_type.ts": "222626d524fa2f9ebcc0ec7c7a7d5dfc74cc401cc46790f7c5e0eab0b0787707", + "https://deno.land/x/deno_graph@0.26.0/lib/snippets/deno_graph-de651bc9c240ed8d/src/deno_apis.js": "41192baaa550a5c6a146280fae358cede917ae16ec4e4315be51bef6631ca892", + "https://deno.land/x/deno_graph@0.26.0/mod.ts": "11131ae166580a1c7fa8506ff553751465a81c263d94443f18f353d0c320bc14", + "https://deno.land/x/dir@1.5.1/data_local_dir/mod.ts": "91eb1c4bfadfbeda30171007bac6d85aadacd43224a5ed721bbe56bc64e9eb66", + "https://deno.land/x/emit@0.32.0/_utils.ts": "98412edc7aa29e77d592b54fbad00bdec1b05d0c25eb772a5f8edc9813e08d88", + "https://deno.land/x/emit@0.32.0/emit.generated.js": "8c8e1fed94f6b742042897312ad223fff0f5d3c92317ff9970a5b7e8b2bd9441", + "https://deno.land/x/emit@0.32.0/mod.ts": "326c48e48f3f3c83c11b089aec803e6270bcd64493f250aeb56f46f6960a8458", + "https://deno.land/x/wasmbuild@0.15.1/cache.ts": "9d01b5cb24e7f2a942bbd8d14b093751fa690a6cde8e21709ddc97667e6669ed", + "https://deno.land/x/wasmbuild@0.15.1/loader.ts": "8c2fc10e21678e42f84c5135d8ab6ab7dc92424c3f05d2354896a29ccfd02a63", + "https://esm.sh/gh/nekowinston/deno-ignore@v5.3.0/index.js?pin=v135": "32c6d8719011b4d107daa65ae81321bc1ef23d098ca3be5420043342b5ea8963", + "https://esm.sh/v135/gh/nekowinston/deno-ignore@v5.3.0/denonext/index.js": "7876800bef2b9928c3f03ce91f4e56eb4936d57d1e35adcbfcc700d3997e6d28" } } From 2c30efd12111183545b6256cb8c2a90b6f1c1196 Mon Sep 17 00:00:00 2001 From: winston Date: Tue, 26 Dec 2023 08:59:56 +0100 Subject: [PATCH 03/18] ci: add build --- .github/workflows/build.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..568c890 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,27 @@ +name: Build + +on: + push: + branches: [main] + pull_request: + +jobs: + main: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + + - name: Setup Deno + uses: ./ + + - run: deno run -A ./bundle.ts + + - name: Push changes + uses: stefanzweifel/git-auto-commit-action@v5 + with: + file_pattern: "dist/*" + commit_message: "chore: build action bundle" + commit_author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" From 7969ebbf687cca1bb8ca0458bc43a0bd76f3ea6c Mon Sep 17 00:00:00 2001 From: winston Date: Tue, 26 Dec 2023 17:56:05 +0100 Subject: [PATCH 04/18] ci: fix build, action, commit bundled JS --- .gitattributes | 4 +++- .github/workflows/build.yml | 3 +++ action.yml | 2 +- dist/cache.js | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 dist/cache.js diff --git a/.gitattributes b/.gitattributes index 62e5cc4..8491364 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,4 @@ # these are just here to test the Action -test/** -linguist-detectable \ No newline at end of file +test/** -linguist-detectable +# ignore in diffs +dist/** -linguist-generated -diff \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 568c890..7bcda3a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,6 +9,9 @@ jobs: main: runs-on: ubuntu-latest + permissions: + contents: write + steps: - uses: actions/checkout@v4 with: diff --git a/action.yml b/action.yml index c72b3fc..e374b67 100644 --- a/action.yml +++ b/action.yml @@ -56,4 +56,4 @@ runs: - name: Restore Deno dependencies shell: bash run: | - find ${{ inputs.directory }} -regex '.*\.[jt]sx*' -exec deno cache ${{ inputs.deno-json-path != '' && '--config=' || '' }}${{ inputs.deno-json-path }} {} \; + ${{ github.action_path }}/dist/cache.js diff --git a/dist/cache.js b/dist/cache.js new file mode 100644 index 0000000..d120a3f --- /dev/null +++ b/dist/cache.js @@ -0,0 +1 @@ +class AssertionError extends Error{constructor(message){super(message);this.name="AssertionError";}}function assert(expr,msg=""){if(!expr){throw new AssertionError(msg);}}const{hasOwn}=Object;function get(obj,key){if(hasOwn(obj,key)){return obj[key];}}function getForce(obj,key){const v=get(obj,key);assert(v!==undefined);return v;}function isNumber(x){if(typeof x==="number")return true;if(/^0x[0-9a-f]+$/i.test(String(x)))return true;return/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(String(x));}function hasKey(obj,keys){let o=obj;keys.slice(0,-1).forEach(key=>{o=get(o,key)??{};});const key=keys[keys.length-1];return hasOwn(o,key);}function parseArgs(args,{"--":doubleDash=false,alias={},boolean:__boolean=false,default:defaults={},stopEarly=false,string=[],collect=[],negatable=[],unknown=i=>i}={}){const aliases={};const flags={bools:{},strings:{},unknownFn:unknown,allBools:false,collect:{},negatable:{}};if(alias!==undefined){for(const key in alias){const val=getForce(alias,key);if(typeof val==="string"){aliases[key]=[val];}else{aliases[key]=val;}for(const alias of getForce(aliases,key)){aliases[alias]=[key].concat(aliases[key].filter(y=>alias!==y));}}}if(__boolean!==undefined){if(typeof __boolean==="boolean"){flags.allBools=!!__boolean;}else{const booleanArgs=typeof __boolean==="string"?[__boolean]:__boolean;for(const key of booleanArgs.filter(Boolean)){flags.bools[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.bools[al]=true;}}}}}if(string!==undefined){const stringArgs=typeof string==="string"?[string]:string;for(const key of stringArgs.filter(Boolean)){flags.strings[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.strings[al]=true;}}}}if(collect!==undefined){const collectArgs=typeof collect==="string"?[collect]:collect;for(const key of collectArgs.filter(Boolean)){flags.collect[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.collect[al]=true;}}}}if(negatable!==undefined){const negatableArgs=typeof negatable==="string"?[negatable]:negatable;for(const key of negatableArgs.filter(Boolean)){flags.negatable[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.negatable[al]=true;}}}}const argv={_:[]};function argDefined(key,arg){return flags.allBools&&/^--[^=]+$/.test(arg)||get(flags.bools,key)||!!get(flags.strings,key)||!!get(aliases,key);}function setKey(obj,name,value,collect=true){let o=obj;const keys=name.split(".");keys.slice(0,-1).forEach(function(key){if(get(o,key)===undefined){o[key]={};}o=get(o,key);});const key=keys[keys.length-1];const collectable=collect&&!!get(flags.collect,name);if(!collectable){o[key]=value;}else if(get(o,key)===undefined){o[key]=[value];}else if(Array.isArray(get(o,key))){o[key].push(value);}else{o[key]=[get(o,key),value];}}function setArg(key,val,arg=undefined,collect){if(arg&&flags.unknownFn&&!argDefined(key,arg)){if(flags.unknownFn(arg,key,val)===false)return;}const value=!get(flags.strings,key)&&isNumber(val)?Number(val):val;setKey(argv,key,value,collect);const alias=get(aliases,key);if(alias){for(const x of alias){setKey(argv,x,value,collect);}}}function aliasIsBoolean(key){return getForce(aliases,key).some(x=>typeof get(flags.bools,x)==="boolean");}let notFlags=[];if(args.includes("--")){notFlags=args.slice(args.indexOf("--")+1);args=args.slice(0,args.indexOf("--"));}for(let i=0;i>4];dst[i*2+1]=hexTable[v&15];}return textDecoder.decode(dst);}const osType=(()=>{const{Deno:Deno1}=globalThis;if(typeof Deno1?.build?.os==="string"){return Deno1.build.os;}const{navigator}=globalThis;if(navigator?.appVersion?.includes?.("Win")){return"windows";}return"linux";})();const isWindows=osType==="windows";function assertPath(path){if(typeof path!=="string"){throw new TypeError(`Path must be a string. Received ${JSON.stringify(path)}`);}}function assertArg(path){assertPath(path);if(path.length===0)return".";}const CHAR_FORWARD_SLASH=47;function normalizeString(path,allowAboveRoot,separator,isPathSeparator){let res="";let lastSegmentLength=0;let lastSlash=-1;let dots=0;let code;for(let i=0,len=path.length;i<=len;++i){if(i2){const lastSlashIndex=res.lastIndexOf(separator);if(lastSlashIndex===-1){res="";lastSegmentLength=0;}else{res=res.slice(0,lastSlashIndex);lastSegmentLength=res.length-1-res.lastIndexOf(separator);}lastSlash=i;dots=0;continue;}else if(res.length===2||res.length===1){res="";lastSegmentLength=0;lastSlash=i;dots=0;continue;}}if(allowAboveRoot){if(res.length>0)res+=`${separator}..`;else res="..";lastSegmentLength=2;}}else{if(res.length>0)res+=separator+path.slice(lastSlash+1,i);else res=path.slice(lastSlash+1,i);lastSegmentLength=i-lastSlash-1;}lastSlash=i;dots=0;}else if(code===46&&dots!==-1){++dots;}else{dots=-1;}}return res;}function isPosixPathSeparator(code){return code===47;}function normalize(path){assertArg(path);const isAbsolute=isPosixPathSeparator(path.charCodeAt(0));const trailingSeparator=isPosixPathSeparator(path.charCodeAt(path.length-1));path=normalizeString(path,!isAbsolute,"/",isPosixPathSeparator);if(path.length===0&&!isAbsolute)path=".";if(path.length>0&&trailingSeparator)path+="/";if(isAbsolute)return`/${path}`;return path;}function join(...paths){if(paths.length===0)return".";let joined;for(let i=0,len=paths.length;i0){if(!joined)joined=path;else joined+=`/${path}`;}}if(!joined)return".";return normalize(joined);}function isPathSeparator(code){return code===47||code===92;}function isWindowsDeviceRoot(code){return code>=97&&code<=122||code>=65&&code<=90;}function normalize1(path){assertArg(path);const len=path.length;let rootEnd=0;let device;let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){return"\\";}let tail;if(rootEnd0&&isPathSeparator(path.charCodeAt(len-1))){tail+="\\";}if(device===undefined){if(isAbsolute){if(tail.length>0)return`\\${tail}`;else return"\\";}else if(tail.length>0){return tail;}else{return"";}}else if(isAbsolute){if(tail.length>0)return`${device}\\${tail}`;else return`${device}\\`;}else if(tail.length>0){return device+tail;}else{return device;}}function join1(...paths){if(paths.length===0)return".";let joined;let firstPart=null;for(let i=0;i0){if(joined===undefined)joined=firstPart=path;else joined+=`\\${path}`;}}if(joined===undefined)return".";let needsReplace=true;let slashCount=0;assert(firstPart!==null);if(isPathSeparator(firstPart.charCodeAt(0))){++slashCount;const firstLen=firstPart.length;if(firstLen>1){if(isPathSeparator(firstPart.charCodeAt(1))){++slashCount;if(firstLen>2){if(isPathSeparator(firstPart.charCodeAt(2)))++slashCount;else{needsReplace=false;}}}}}if(needsReplace){for(;slashCount=2)joined=`\\${joined.slice(slashCount)}`;}return normalize1(joined);}function join2(...paths){return isWindows?join1(...paths):join(...paths);}function assertArg1(url){url=url instanceof URL?url:new URL(url);if(url.protocol!=="file:"){throw new TypeError("Must be a file URL.");}return url;}function fromFileUrl(url){url=assertArg1(url);return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"));}function fromFileUrl1(url){url=assertArg1(url);let path=decodeURIComponent(url.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");if(url.hostname!==""){path=`\\\\${url.hostname}${path}`;}return path;}function fromFileUrl2(url){return isWindows?fromFileUrl1(url):fromFileUrl(url);}function toPathString(pathUrl){return pathUrl instanceof URL?fromFileUrl2(pathUrl):pathUrl;}function stripTrailingSeparators(segment,isSep){if(segment.length<=1){return segment;}let end=segment.length;for(let i=segment.length-1;i>0;i--){if(isSep(segment.charCodeAt(i))){end=i;}else{break;}}return segment.slice(0,end);}function resolve(...pathSegments){let resolvedPath="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1&&!resolvedAbsolute;i--){let path;if(i>=0)path=pathSegments[i];else{const{Deno:Deno1}=globalThis;if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();}assertPath(path);if(path.length===0){continue;}resolvedPath=`${path}/${resolvedPath}`;resolvedAbsolute=isPosixPathSeparator(path.charCodeAt(0));}resolvedPath=normalizeString(resolvedPath,!resolvedAbsolute,"/",isPosixPathSeparator);if(resolvedAbsolute){if(resolvedPath.length>0)return`/${resolvedPath}`;else return"/";}else if(resolvedPath.length>0)return resolvedPath;else return".";}function resolve1(...pathSegments){let resolvedDevice="";let resolvedTail="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1;i--){let path;const{Deno:Deno1}=globalThis;if(i>=0){path=pathSegments[i];}else if(!resolvedDevice){if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a drive-letter-less path without a CWD.");}path=Deno1.cwd();}else{if(typeof Deno1?.env?.get!=="function"||typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();if(path===undefined||path.slice(0,3).toLowerCase()!==`${resolvedDevice.toLowerCase()}\\`){path=`${resolvedDevice}\\`;}}assertPath(path);const len=path.length;if(len===0)continue;let rootEnd=0;let device="";let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){rootEnd=1;isAbsolute=true;}if(device.length>0&&resolvedDevice.length>0&&device.toLowerCase()!==resolvedDevice.toLowerCase()){continue;}if(resolvedDevice.length===0&&device.length>0){resolvedDevice=device;}if(!resolvedAbsolute){resolvedTail=`${path.slice(rootEnd)}\\${resolvedTail}`;resolvedAbsolute=isAbsolute;}if(resolvedAbsolute&&resolvedDevice.length>0)break;}resolvedTail=normalizeString(resolvedTail,!resolvedAbsolute,"\\",isPathSeparator);return resolvedDevice+(resolvedAbsolute?"\\":"")+resolvedTail||".";}Deno.build.os==="windows";async function exists(path,options){try{const stat=await Deno.stat(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if((await Deno.permissions.query({name:"read",path})).state==="granted"){return!options?.isReadable;}}throw error;}}function existsSync(path,options){try{const stat=Deno.statSync(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if(Deno.permissions.querySync({name:"read",path}).state==="granted"){return!options?.isReadable;}}throw error;}}function normalize2(path){return isWindows?normalize1(path):normalize(path);}function stripSuffix(name,suffix){if(suffix.length>=name.length){return name;}const lenDiff=name.length-suffix.length;for(let i=suffix.length-1;i>=0;--i){if(name.charCodeAt(lenDiff+i)!==suffix.charCodeAt(i)){return name;}}return name.slice(0,-suffix.length);}function lastPathSegment(path,isSep,start=0){let matchedNonSeparator=false;let end=path.length;for(let i=path.length-1;i>=start;--i){if(isSep(path.charCodeAt(i))){if(matchedNonSeparator){start=i+1;break;}}else if(!matchedNonSeparator){matchedNonSeparator=true;end=i+1;}}return path.slice(start,end);}function assertArgs(path,suffix){assertPath(path);if(path.length===0)return path;if(typeof suffix!=="string"){throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);}}function basename(path,suffix=""){assertArgs(path,suffix);const lastSegment=lastPathSegment(path,isPosixPathSeparator);const strippedSegment=stripTrailingSeparators(lastSegment,isPosixPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename1(path,suffix=""){assertArgs(path,suffix);let start=0;if(path.length>=2){const drive=path.charCodeAt(0);if(isWindowsDeviceRoot(drive)){if(path.charCodeAt(1)===58)start=2;}}const lastSegment=lastPathSegment(path,isPathSeparator,start);const strippedSegment=stripTrailingSeparators(lastSegment,isPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename2(path,suffix=""){return isWindows?basename1(path,suffix):basename(path,suffix);}async function createWalkEntry(path){path=toPathString(path);path=normalize2(path);const name=basename2(path);const info=await Deno.stat(path);return{path,name,isFile:info.isFile,isDirectory:info.isDirectory,isSymlink:info.isSymlink};}class WalkError extends Error{root;constructor(cause,root){super(`${cause instanceof Error?cause.message:cause} for path "${root}"`);this.cause=cause;this.name="WalkError";this.root=root;}}function include(path,exts,match,skip){if(exts&&!exts.some(ext=>path.endsWith(ext))){return false;}if(match&&!match.some(pattern=>!!path.match(pattern))){return false;}if(skip&&skip.some(pattern=>!!path.match(pattern))){return false;}return true;}function wrapErrorWithPath(err,root){if(err instanceof WalkError)return err;return new WalkError(err,root);}async function*walk(root,{maxDepth=Infinity,includeFiles=true,includeDirs=true,includeSymlinks=true,followSymlinks=false,canonicalize=true,exts=undefined,match=undefined,skip=undefined}={}){if(maxDepth<0){return;}root=toPathString(root);if(includeDirs&&include(root,exts,match,skip)){yield await createWalkEntry(root);}if(maxDepth<1||!include(root,undefined,undefined,skip)){return;}try{for await(const entry of Deno.readDir(root)){let path=join2(root,entry.name);let{isSymlink,isDirectory}=entry;if(isSymlink){if(!followSymlinks){if(includeSymlinks&&include(path,exts,match,skip)){yield{path,...entry};}continue;}const realPath=await Deno.realPath(path);if(canonicalize){path=realPath;}({isSymlink,isDirectory}=await Deno.lstat(realPath));}if(isSymlink||isDirectory){yield*walk(path,{maxDepth:maxDepth-1,includeFiles,includeDirs,includeSymlinks,followSymlinks,exts,match,skip});}else if(includeFiles&&include(path,exts,match,skip)){yield{path,...entry};}}}catch(err){throw wrapErrorWithPath(err,normalize2(root));}}Deno.build.os==="windows";new Deno.errors.AlreadyExists("dest already exists.");Deno.build.os==="windows";const LF="\n";const CRLF="\r\n";Deno?.build.os==="windows"?CRLF:LF;function parse(text,{allowTrailingComma=true}={}){if(new.target){throw new TypeError("parse is not a constructor");}return new JSONCParser(text,{allowTrailingComma}).parse();}const originalJSONParse=globalThis.JSON.parse;class JSONCParser{#whitespace=new Set(" \r\n");#numberEndToken=new Set([..."[]{}:,/",...this.#whitespace]);#text;#length;#tokenized;#options;constructor(text,options){this.#text=`${text}`;this.#length=this.#text.length;this.#tokenized=this.#tokenize();this.#options=options;}parse(){const token=this.#getNext();const res=this.#parseJsonValue(token);const{done,value}=this.#tokenized.next();if(!done){throw new SyntaxError(buildErrorMessage(value));}return res;}#getNext(){const{done,value}=this.#tokenized.next();if(done){throw new SyntaxError("Unexpected end of JSONC input");}return value;}*#tokenize(){for(let i=0;iisNaN(Number(key)));const byLevel={[LogLevels.NOTSET]:"NOTSET",[LogLevels.DEBUG]:"DEBUG",[LogLevels.INFO]:"INFO",[LogLevels.WARNING]:"WARNING",[LogLevels.ERROR]:"ERROR",[LogLevels.CRITICAL]:"CRITICAL"};function getLevelByName(name){const level=LogLevels[name];if(level!==undefined){return level;}throw new Error(`no log level found for name: ${name}`);}function getLevelName(level){const levelName=byLevel[level];if(levelName){return levelName;}throw new Error(`no level name found for level: ${level}`);}class LogRecord{msg;#args;#datetime;level;levelName;loggerName;constructor(options){this.msg=options.msg;this.#args=[...options.args];this.level=options.level;this.loggerName=options.loggerName;this.#datetime=new Date;this.levelName=getLevelName(options.level);}get args(){return[...this.#args];}get datetime(){return new Date(this.#datetime.getTime());}}class Logger{#level;#handlers;#loggerName;constructor(loggerName,levelName,options={}){this.#loggerName=loggerName;this.#level=getLevelByName(levelName);this.#handlers=options.handlers||[];}get level(){return this.#level;}set level(level){try{this.#level=getLevelByName(getLevelName(level));}catch(_){throw new TypeError(`Invalid log level: ${level}`);}}get levelName(){return getLevelName(this.#level);}set levelName(levelName){this.#level=getLevelByName(levelName);}get loggerName(){return this.#loggerName;}set handlers(hndls){this.#handlers=hndls;}get handlers(){return this.#handlers;}#_log(level,msg,...args){if(this.level>level){return msg instanceof Function?undefined:msg;}let fnResult;let logMessage;if(msg instanceof Function){fnResult=msg();logMessage=this.asString(fnResult);}else{logMessage=this.asString(msg);}const record=new LogRecord({msg:logMessage,args:args,level:level,loggerName:this.loggerName});this.#handlers.forEach(handler=>{handler.handle(record);});return msg instanceof Function?fnResult:msg;}asString(data,isProperty=false){if(typeof data==="string"){if(isProperty)return`"${data}"`;return data;}else if(data===null||typeof data==="number"||typeof data==="bigint"||typeof data==="boolean"||typeof data==="undefined"||typeof data==="symbol"){return String(data);}else if(data instanceof Error){return data.stack;}else if(typeof data==="object"){return`{${Object.entries(data).map(([k,v])=>`"${k}":${this.asString(v,true)}`).join(",")}}`;}return"undefined";}debug(msg,...args){return this.#_log(LogLevels.DEBUG,msg,...args);}info(msg,...args){return this.#_log(LogLevels.INFO,msg,...args);}warning(msg,...args){return this.#_log(LogLevels.WARNING,msg,...args);}error(msg,...args){return this.#_log(LogLevels.ERROR,msg,...args);}critical(msg,...args){return this.#_log(LogLevels.CRITICAL,msg,...args);}}const{Deno:Deno1}=globalThis;const noColor=typeof Deno1?.noColor==="boolean"?Deno1.noColor:false;let enabled=!noColor;function code(open,close){return{open:`\x1b[${open.join(";")}m`,close:`\x1b[${close}m`,regexp:new RegExp(`\\x1b\\[${close}m`,"g")};}function run(str,code){return enabled?`${code.open}${str.replace(code.regexp,code.open)}${code.close}`:str;}function bold(str){return run(str,code([1],22));}function red(str){return run(str,code([31],39));}function yellow(str){return run(str,code([33],39));}function blue(str){return run(str,code([34],39));}new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"),"g");function copy(src,dst,off=0){off=Math.max(0,Math.min(off,dst.byteLength));const dstBytesAvailable=dst.byteLength-off;if(src.byteLength>dstBytesAvailable){src=src.subarray(0,dstBytesAvailable);}dst.set(src,off);return src.byteLength;}class AbstractBufBase{buf;usedBufferBytes=0;err=null;constructor(buf){this.buf=buf;}size(){return this.buf.byteLength;}available(){return this.buf.byteLength-this.usedBufferBytes;}buffered(){return this.usedBufferBytes;}}class BufWriterSync extends AbstractBufBase{#writer;static create(writer,size=4096){return writer instanceof BufWriterSync?writer:new BufWriterSync(writer,size);}constructor(writer,size=4096){super(new Uint8Array(size<=0?4096:size));this.#writer=writer;}reset(w){this.err=null;this.usedBufferBytes=0;this.#writer=w;}flush(){if(this.err!==null)throw this.err;if(this.usedBufferBytes===0)return;try{const p=this.buf.subarray(0,this.usedBufferBytes);let nwritten=0;while(nwrittenthis.available()){if(this.buffered()===0){try{numBytesWritten=this.#writer.writeSync(data);}catch(e){if(e instanceof Error){this.err=e;}throw e;}}else{numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;this.flush();}totalBytesWritten+=numBytesWritten;data=data.subarray(numBytesWritten);}numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;totalBytesWritten+=numBytesWritten;return totalBytesWritten;}}const DEFAULT_FORMATTER="{levelName} {msg}";class BaseHandler{level;levelName;formatter;constructor(levelName,options={}){this.level=getLevelByName(levelName);this.levelName=levelName;this.formatter=options.formatter||DEFAULT_FORMATTER;}handle(logRecord){if(this.level>logRecord.level)return;const msg=this.format(logRecord);this.log(msg);}format(logRecord){if(this.formatter instanceof Function){return this.formatter(logRecord);}return this.formatter.replace(/{([^\s}]+)}/g,(match,p1)=>{const value=logRecord[p1];if(value===undefined){return match;}return String(value);});}log(_msg){}setup(){}destroy(){}}class ConsoleHandler extends BaseHandler{#useColors;constructor(levelName,options={}){super(levelName,options);this.#useColors=options.useColors??true;}format(logRecord){let msg=super.format(logRecord);if(this.#useColors){msg=this.applyColors(msg,logRecord.level);}return msg;}applyColors(msg,level){switch(level){case LogLevels.INFO:msg=blue(msg);break;case LogLevels.WARNING:msg=yellow(msg);break;case LogLevels.ERROR:msg=red(msg);break;case LogLevels.CRITICAL:msg=bold(red(msg));break;default:break;}return msg;}log(msg){console.log(msg);}}class WriterHandler extends BaseHandler{_writer;#encoder=new TextEncoder;}class FileHandler extends WriterHandler{_file;_buf;_filename;_mode;_openOptions;_encoder=new TextEncoder;#unloadCallback=(()=>{this.destroy();}).bind(this);constructor(levelName,options){super(levelName,options);this._filename=options.filename;this._mode=options.mode?options.mode:"a";this._openOptions={createNew:this._mode==="x",create:this._mode!=="x",append:this._mode==="a",truncate:this._mode!=="a",write:true};}setup(){this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);addEventListener("unload",this.#unloadCallback);}handle(logRecord){super.handle(logRecord);if(logRecord.level>LogLevels.ERROR){this.flush();}}log(msg){if(this._encoder.encode(msg).byteLength+1>this._buf.available()){this.flush();}this._buf.writeSync(this._encoder.encode(msg+"\n"));}flush(){if(this._buf?.buffered()>0){this._buf.flush();}}destroy(){this.flush();this._file?.close();this._file=undefined;removeEventListener("unload",this.#unloadCallback);}}class RotatingFileHandler extends FileHandler{#maxBytes;#maxBackupCount;#currentFileSize=0;constructor(levelName,options){super(levelName,options);this.#maxBytes=options.maxBytes;this.#maxBackupCount=options.maxBackupCount;}setup(){if(this.#maxBytes<1){this.destroy();throw new Error("maxBytes cannot be less than 1");}if(this.#maxBackupCount<1){this.destroy();throw new Error("maxBackupCount cannot be less than 1");}super.setup();if(this._mode==="w"){for(let i=1;i<=this.#maxBackupCount;i++){try{Deno.removeSync(this._filename+"."+i);}catch(error){if(!(error instanceof Deno.errors.NotFound)){throw error;}}}}else if(this._mode==="x"){for(let i=1;i<=this.#maxBackupCount;i++){if(existsSync(this._filename+"."+i)){this.destroy();throw new Deno.errors.AlreadyExists("Backup log file "+this._filename+"."+i+" already exists");}}}else{this.#currentFileSize=Deno.statSync(this._filename).size;}}log(msg){const msgByteLength=this._encoder.encode(msg).byteLength+1;if(this.#currentFileSize+msgByteLength>this.#maxBytes){this.rotateLogFiles();this.#currentFileSize=0;}super.log(msg);this.#currentFileSize+=msgByteLength;}rotateLogFiles(){this._buf.flush();this._file.close();for(let i=this.#maxBackupCount-1;i>=0;i--){const source=this._filename+(i===0?"":"."+i);const dest=this._filename+"."+(i+1);if(existsSync(source)){Deno.renameSync(source,dest);}}this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);}}const DEFAULT_LEVEL="INFO";const DEFAULT_CONFIG={handlers:{default:new ConsoleHandler(DEFAULT_LEVEL)},loggers:{default:{level:DEFAULT_LEVEL,handlers:["default"]}}};const state={handlers:new Map,loggers:new Map,config:DEFAULT_CONFIG};const handlers={BaseHandler,ConsoleHandler,WriterHandler,FileHandler,RotatingFileHandler};function getLogger(name){if(!name){const d=state.loggers.get("default");assert(d!==undefined,`"default" logger must be set for getting logger without name`);return d;}const result=state.loggers.get(name);if(!result){const logger=new Logger(name,"NOTSET",{handlers:[]});state.loggers.set(name,logger);return logger;}return result;}function debug(msg,...args){if(msg instanceof Function){return getLogger("default").debug(msg,...args);}return getLogger("default").debug(msg,...args);}function info(msg,...args){if(msg instanceof Function){return getLogger("default").info(msg,...args);}return getLogger("default").info(msg,...args);}function warning(msg,...args){if(msg instanceof Function){return getLogger("default").warning(msg,...args);}return getLogger("default").warning(msg,...args);}function error(msg,...args){if(msg instanceof Function){return getLogger("default").error(msg,...args);}return getLogger("default").error(msg,...args);}function setup(config){state.config={handlers:{...DEFAULT_CONFIG.handlers,...config.handlers},loggers:{...DEFAULT_CONFIG.loggers,...config.loggers}};state.handlers.forEach(handler=>{handler.destroy();});state.handlers.clear();const handlers=state.config.handlers||{};for(const handlerName in handlers){const handler=handlers[handlerName];handler.setup();state.handlers.set(handlerName,handler);}state.loggers.clear();const loggers=state.config.loggers||{};for(const loggerName in loggers){const loggerConfig=loggers[loggerName];const handlerNames=loggerConfig.handlers||[];const handlers=[];handlerNames.forEach(handlerName=>{const handler=state.handlers.get(handlerName);if(handler){handlers.push(handler);}});const levelName=loggerConfig.level||DEFAULT_LEVEL;const logger=new Logger(loggerName,levelName,{handlers:handlers});state.loggers.set(loggerName,logger);}}setup(DEFAULT_CONFIG);function assertArgs1(from,to){assertPath(from);assertPath(to);if(from===to)return"";}function relative(from,to){assertArgs1(from,to);from=resolve(from);to=resolve(to);if(from===to)return"";let fromStart=1;const fromEnd=from.length;for(;fromStartlength){if(isPosixPathSeparator(to.charCodeAt(toStart+i))){return to.slice(toStart+i+1);}else if(i===0){return to.slice(toStart+i);}}else if(fromLen>length){if(isPosixPathSeparator(from.charCodeAt(fromStart+i))){lastCommonSep=i;}else if(i===0){lastCommonSep=0;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(isPosixPathSeparator(fromCode))lastCommonSep=i;}let out="";for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||isPosixPathSeparator(from.charCodeAt(i))){if(out.length===0)out+="..";else out+="/..";}}if(out.length>0)return out+to.slice(toStart+lastCommonSep);else{toStart+=lastCommonSep;if(isPosixPathSeparator(to.charCodeAt(toStart)))++toStart;return to.slice(toStart);}}function relative1(from,to){assertArgs1(from,to);const fromOrig=resolve1(from);const toOrig=resolve1(to);if(fromOrig===toOrig)return"";from=fromOrig.toLowerCase();to=toOrig.toLowerCase();if(from===to)return"";let fromStart=0;let fromEnd=from.length;for(;fromStartfromStart;--fromEnd){if(from.charCodeAt(fromEnd-1)!==92)break;}const fromLen=fromEnd-fromStart;let toStart=0;let toEnd=to.length;for(;toStarttoStart;--toEnd){if(to.charCodeAt(toEnd-1)!==92)break;}const toLen=toEnd-toStart;const length=fromLenlength){if(to.charCodeAt(toStart+i)===92){return toOrig.slice(toStart+i+1);}else if(i===2){return toOrig.slice(toStart+i);}}if(fromLen>length){if(from.charCodeAt(fromStart+i)===92){lastCommonSep=i;}else if(i===2){lastCommonSep=3;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(fromCode===92)lastCommonSep=i;}if(i!==length&&lastCommonSep===-1){return toOrig;}let out="";if(lastCommonSep===-1)lastCommonSep=0;for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||from.charCodeAt(i)===92){if(out.length===0)out+="..";else out+="\\..";}}if(out.length>0){return out+toOrig.slice(toStart+lastCommonSep,toEnd);}else{toStart+=lastCommonSep;if(toOrig.charCodeAt(toStart)===92)++toStart;return toOrig.slice(toStart,toEnd);}}function relative2(from,to){return isWindows?relative1(from,to):relative(from,to);}var m=Object.create;var E=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),D=(t,e)=>{for(var s in e)E(t,s,{get:e[s],enumerable:!0});},a=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!b.call(t,n)&&n!==s&&E(t,n,{get:()=>e[n],enumerable:!(r=T(e,n))||r.enumerable});return t;},_=(t,e,s)=>(a(t,e,"default"),s&&a(s,e,"default")),$=(t,e,s)=>(s=t!=null?m(X(t)):{},a(e||!t||!t.__esModule?E(s,"default",{value:t,enumerable:!0}):s,t));var A=w((ct,v)=>{function C(t){return Array.isArray(t)?t:[t];}var N="",P=" ",h="\\",H=/^\s+$/,F=/(?:[^\\]|^)\\$/,k=/^\\!/,z=/^\\#/,B=/\r?\n/g,K=/^\.*\/|^\.+$/,d="/",x="node-ignore";typeof Symbol<"u"&&(x=Symbol.for("node-ignore"));var L=x,V=(t,e,s)=>Object.defineProperty(t,e,{value:s}),j=/([0-z])-([0-z])/g,G=()=>!1,M=t=>t.replace(j,(e,s,r)=>s.charCodeAt(0)<=r.charCodeAt(0)?e:N),Y=t=>{let{length:e}=t;return t.slice(0,e-e%2);},W=[[/\\?\s+$/,t=>t.indexOf("\\")===0?P:N],[/\\\s/g,()=>P],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)";}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,s)=>e+6{let r=s.replace(/\\\*/g,"[^\\/]*");return e+r;}],[/\\\\\\(?=[$.|*+(){^])/g,()=>h],[/\\\\/g,()=>h],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,s,r,n)=>e===h?`\\[${s}${Y(r)}${n}`:n==="]"&&r.length%2===0?`[${M(s)}${r}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],S=Object.create(null),p=(t,e)=>{let s=S[t];return s||(s=W.reduce((r,n)=>r.replace(n[0],n[1].bind(t)),t),S[t]=s),e?new RegExp(s,"i"):new RegExp(s);},R=t=>typeof t=="string",q=t=>t&&R(t)&&!H.test(t)&&!F.test(t)&&t.indexOf("#")!==0,J=t=>t.split(B),f=class{constructor(e,s,r,n){this.origin=e,this.pattern=s,this.negative=r,this.regex=n;}},Q=(t,e)=>{let s=t,r=!1;t.indexOf("!")===0&&(r=!0,t=t.substr(1)),t=t.replace(k,"!").replace(z,"#");let n=p(t,e);return new f(s,t,r,n);},U=(t,e)=>{throw new e(t);},i=(t,e,s)=>R(t)?t?i.isNotRelative(t)?s(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:s("path must not be empty",TypeError):s(`path must be a string, but got \`${e}\``,TypeError),O=t=>K.test(t);i.isNotRelative=O;i.convert=t=>t;var g=class{constructor({ignorecase:e=!0,ignoreCase:s=e,allowRelativePaths:r=!1}={}){V(this,L,!0),this._rules=[],this._ignoreCase=s,this._allowRelativePaths=r,this._initCache();}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null);}_addPattern(e){if(e&&e[L]){this._rules=this._rules.concat(e._rules),this._added=!0;return;}if(q(e)){let s=Q(e,this._ignoreCase);this._added=!0,this._rules.push(s);}}add(e){return this._added=!1,C(R(e)?J(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this;}addPattern(e){return this.add(e);}_testOne(e,s){let r=!1,n=!1;return this._rules.forEach(o=>{let{negative:u}=o;if(n===u&&r!==n||u&&!r&&!n&&!s)return;o.regex.test(e)&&(r=!u,n=u);}),{ignored:r,unignored:n};}_test(e,s,r,n){let o=e&&i.convert(e);return i(o,e,this._allowRelativePaths?G:U),this._t(o,s,r,n);}_t(e,s,r,n){if(e in s)return s[e];if(n||(n=e.split(d)),n.pop(),!n.length)return s[e]=this._testOne(e,r);let o=this._t(n.join(d)+d,s,r,n);return s[e]=o.ignored?o:this._testOne(e,r);}ignores(e){return this._test(e,this._ignoreCache,!1).ignored;}createFilter(){return e=>!this.ignores(e);}filter(e){return C(e).filter(this.createFilter());}test(e){return this._test(e,this._testCache,!0);}},l=t=>new g(t),Z=t=>i(t&&i.convert(t),t,G);l.isPathValid=Z;l.default=l;v.exports=l;var tt=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");i.convert=tt;var et=/^[a-z]:\//i;i.isNotRelative=t=>et.test(t)||O(t);});var c={};D(c,{default:()=>nt});var st=$(A());_(c,$(A()));var{default:I,...rt}=st,nt=I!==void 0?I:rt;const importMeta={url:"file:///Users/winston/Code/winston/setup-deno/cache.ts",main:import.meta.main};const args=parseArgs(Deno.args,{boolean:["help","dry-run","debug"],string:["config"],alias:{help:"h",dryRun:"n"},"--":true});const logLevel=args.debug?"DEBUG":"INFO";setup({handlers:{console:new handlers.ConsoleHandler(logLevel,{formatter:logRecord=>Deno.noColor?[logRecord.levelName,logRecord.msg].join(" "):logRecord.msg})},loggers:{default:{handlers:["console"],"level":logLevel}}});const main=async args=>{if(args.help){console.log("Usage: cache [-n | --dry-run] [--debug] [--] [DENO_ARGS...]");Deno.exit(0);}if(args["dry-run"])warning("dry-run mode enabled");if(args.config&&!await exists(args.config)){error(`config file ${args.config} not found`);Deno.exit(1);}const hash=await Deno.readFile("./deno.lock").then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>encodeHex(new Uint8Array(data))).catch(_=>"");debug(`GitHub actions deno.lock hash: ${hash}`);const cfgs=args.config?[args.config]:["deno.json","deno.jsonc"];const denoCfg=await Promise.all(cfgs.map(path=>Deno.readTextFile(path).catch(_=>undefined))).then(v=>parse(v.filter(Boolean)[0]??"{}"));const patterns=[...[denoCfg?.exclude??[]].flat(),...[denoCfg?.cache?.exclude??[]].flat(),...[denoCfg?.cache?.include??[]].flatMap(p=>`!${p}`)];debug(`patterns:`,patterns);patterns.forEach(p=>debug(`- ${p}`));const ig=nt().add(patterns);const walkIterator=walk(".",{exts:["js",".jsx",".ts",".tsx"],includeDirs:false});for await(const entry of walkIterator){const relativePath=relative2(".",entry.path);if(ig.ignores(relativePath)){debug(`ignored ${relativePath}`);continue;}debug(`caching ${relativePath}`);const cmd=new Deno.Command(Deno.execPath(),{args:["cache",args.config&&`--config=${args.config}`,relativePath,...args["--"]].filter(Boolean),stdout:"inherit",stderr:"inherit"});let code=0;if(!args["dry-run"])code=(await cmd.output()).code;if(code===0){info(`cached ${relativePath}`);}else{error(`failed to cache ${entry.path}`);}}};if(importMeta.main)main(args); \ No newline at end of file From 1fc4004b311e2f65ba4aee26a91e2283b89fc291 Mon Sep 17 00:00:00 2001 From: winston Date: Tue, 26 Dec 2023 18:09:26 +0100 Subject: [PATCH 05/18] build: fix file mode --- bundle.ts | 4 +++- dist/cache.js | 0 2 files changed, 3 insertions(+), 1 deletion(-) mode change 100644 => 100755 dist/cache.js diff --git a/bundle.ts b/bundle.ts index 57b3eb4..5417d65 100755 --- a/bundle.ts +++ b/bundle.ts @@ -8,4 +8,6 @@ const bundled = await bundle( ); ensureDir("./dist"); -await Deno.writeTextFile("./dist/cache.js", bundled.code); +await Deno.writeTextFile("./dist/cache.js", bundled.code, { + mode: 0o744, +}); diff --git a/dist/cache.js b/dist/cache.js old mode 100644 new mode 100755 From e8a55133053b152927e8b4f51414905c5635c7b3 Mon Sep 17 00:00:00 2001 From: winston Date: Tue, 26 Dec 2023 18:16:08 +0100 Subject: [PATCH 06/18] fix: silly --- bundle.ts | 14 +++++++++++--- dist/cache.js | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/bundle.ts b/bundle.ts index 5417d65..da3f3b4 100755 --- a/bundle.ts +++ b/bundle.ts @@ -2,12 +2,20 @@ import { bundle } from "https://deno.land/x/emit@0.32.0/mod.ts"; import { ensureDir } from "https://deno.land/std@0.209.0/fs/ensure_dir.ts"; +const shebang = await Deno.readTextFileSync("./cache.ts").split("\n")[0]; const bundled = await bundle( new URL("./cache.ts", import.meta.url), { minify: true }, ); ensureDir("./dist"); -await Deno.writeTextFile("./dist/cache.js", bundled.code, { - mode: 0o744, -}); +await Deno.writeTextFile( + "./dist/cache.js", + [ + shebang.startsWith("#!") ? shebang : "#!/usr/bin/env -S deno run -A", + bundled.code, + ].join("\n"), + { + mode: 0o744, + }, +); diff --git a/dist/cache.js b/dist/cache.js index d120a3f..03bfd80 100755 --- a/dist/cache.js +++ b/dist/cache.js @@ -1 +1,2 @@ +#!/usr/bin/env -S deno run --no-lock --allow-read --allow-run=deno class AssertionError extends Error{constructor(message){super(message);this.name="AssertionError";}}function assert(expr,msg=""){if(!expr){throw new AssertionError(msg);}}const{hasOwn}=Object;function get(obj,key){if(hasOwn(obj,key)){return obj[key];}}function getForce(obj,key){const v=get(obj,key);assert(v!==undefined);return v;}function isNumber(x){if(typeof x==="number")return true;if(/^0x[0-9a-f]+$/i.test(String(x)))return true;return/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(String(x));}function hasKey(obj,keys){let o=obj;keys.slice(0,-1).forEach(key=>{o=get(o,key)??{};});const key=keys[keys.length-1];return hasOwn(o,key);}function parseArgs(args,{"--":doubleDash=false,alias={},boolean:__boolean=false,default:defaults={},stopEarly=false,string=[],collect=[],negatable=[],unknown=i=>i}={}){const aliases={};const flags={bools:{},strings:{},unknownFn:unknown,allBools:false,collect:{},negatable:{}};if(alias!==undefined){for(const key in alias){const val=getForce(alias,key);if(typeof val==="string"){aliases[key]=[val];}else{aliases[key]=val;}for(const alias of getForce(aliases,key)){aliases[alias]=[key].concat(aliases[key].filter(y=>alias!==y));}}}if(__boolean!==undefined){if(typeof __boolean==="boolean"){flags.allBools=!!__boolean;}else{const booleanArgs=typeof __boolean==="string"?[__boolean]:__boolean;for(const key of booleanArgs.filter(Boolean)){flags.bools[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.bools[al]=true;}}}}}if(string!==undefined){const stringArgs=typeof string==="string"?[string]:string;for(const key of stringArgs.filter(Boolean)){flags.strings[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.strings[al]=true;}}}}if(collect!==undefined){const collectArgs=typeof collect==="string"?[collect]:collect;for(const key of collectArgs.filter(Boolean)){flags.collect[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.collect[al]=true;}}}}if(negatable!==undefined){const negatableArgs=typeof negatable==="string"?[negatable]:negatable;for(const key of negatableArgs.filter(Boolean)){flags.negatable[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.negatable[al]=true;}}}}const argv={_:[]};function argDefined(key,arg){return flags.allBools&&/^--[^=]+$/.test(arg)||get(flags.bools,key)||!!get(flags.strings,key)||!!get(aliases,key);}function setKey(obj,name,value,collect=true){let o=obj;const keys=name.split(".");keys.slice(0,-1).forEach(function(key){if(get(o,key)===undefined){o[key]={};}o=get(o,key);});const key=keys[keys.length-1];const collectable=collect&&!!get(flags.collect,name);if(!collectable){o[key]=value;}else if(get(o,key)===undefined){o[key]=[value];}else if(Array.isArray(get(o,key))){o[key].push(value);}else{o[key]=[get(o,key),value];}}function setArg(key,val,arg=undefined,collect){if(arg&&flags.unknownFn&&!argDefined(key,arg)){if(flags.unknownFn(arg,key,val)===false)return;}const value=!get(flags.strings,key)&&isNumber(val)?Number(val):val;setKey(argv,key,value,collect);const alias=get(aliases,key);if(alias){for(const x of alias){setKey(argv,x,value,collect);}}}function aliasIsBoolean(key){return getForce(aliases,key).some(x=>typeof get(flags.bools,x)==="boolean");}let notFlags=[];if(args.includes("--")){notFlags=args.slice(args.indexOf("--")+1);args=args.slice(0,args.indexOf("--"));}for(let i=0;i>4];dst[i*2+1]=hexTable[v&15];}return textDecoder.decode(dst);}const osType=(()=>{const{Deno:Deno1}=globalThis;if(typeof Deno1?.build?.os==="string"){return Deno1.build.os;}const{navigator}=globalThis;if(navigator?.appVersion?.includes?.("Win")){return"windows";}return"linux";})();const isWindows=osType==="windows";function assertPath(path){if(typeof path!=="string"){throw new TypeError(`Path must be a string. Received ${JSON.stringify(path)}`);}}function assertArg(path){assertPath(path);if(path.length===0)return".";}const CHAR_FORWARD_SLASH=47;function normalizeString(path,allowAboveRoot,separator,isPathSeparator){let res="";let lastSegmentLength=0;let lastSlash=-1;let dots=0;let code;for(let i=0,len=path.length;i<=len;++i){if(i2){const lastSlashIndex=res.lastIndexOf(separator);if(lastSlashIndex===-1){res="";lastSegmentLength=0;}else{res=res.slice(0,lastSlashIndex);lastSegmentLength=res.length-1-res.lastIndexOf(separator);}lastSlash=i;dots=0;continue;}else if(res.length===2||res.length===1){res="";lastSegmentLength=0;lastSlash=i;dots=0;continue;}}if(allowAboveRoot){if(res.length>0)res+=`${separator}..`;else res="..";lastSegmentLength=2;}}else{if(res.length>0)res+=separator+path.slice(lastSlash+1,i);else res=path.slice(lastSlash+1,i);lastSegmentLength=i-lastSlash-1;}lastSlash=i;dots=0;}else if(code===46&&dots!==-1){++dots;}else{dots=-1;}}return res;}function isPosixPathSeparator(code){return code===47;}function normalize(path){assertArg(path);const isAbsolute=isPosixPathSeparator(path.charCodeAt(0));const trailingSeparator=isPosixPathSeparator(path.charCodeAt(path.length-1));path=normalizeString(path,!isAbsolute,"/",isPosixPathSeparator);if(path.length===0&&!isAbsolute)path=".";if(path.length>0&&trailingSeparator)path+="/";if(isAbsolute)return`/${path}`;return path;}function join(...paths){if(paths.length===0)return".";let joined;for(let i=0,len=paths.length;i0){if(!joined)joined=path;else joined+=`/${path}`;}}if(!joined)return".";return normalize(joined);}function isPathSeparator(code){return code===47||code===92;}function isWindowsDeviceRoot(code){return code>=97&&code<=122||code>=65&&code<=90;}function normalize1(path){assertArg(path);const len=path.length;let rootEnd=0;let device;let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){return"\\";}let tail;if(rootEnd0&&isPathSeparator(path.charCodeAt(len-1))){tail+="\\";}if(device===undefined){if(isAbsolute){if(tail.length>0)return`\\${tail}`;else return"\\";}else if(tail.length>0){return tail;}else{return"";}}else if(isAbsolute){if(tail.length>0)return`${device}\\${tail}`;else return`${device}\\`;}else if(tail.length>0){return device+tail;}else{return device;}}function join1(...paths){if(paths.length===0)return".";let joined;let firstPart=null;for(let i=0;i0){if(joined===undefined)joined=firstPart=path;else joined+=`\\${path}`;}}if(joined===undefined)return".";let needsReplace=true;let slashCount=0;assert(firstPart!==null);if(isPathSeparator(firstPart.charCodeAt(0))){++slashCount;const firstLen=firstPart.length;if(firstLen>1){if(isPathSeparator(firstPart.charCodeAt(1))){++slashCount;if(firstLen>2){if(isPathSeparator(firstPart.charCodeAt(2)))++slashCount;else{needsReplace=false;}}}}}if(needsReplace){for(;slashCount=2)joined=`\\${joined.slice(slashCount)}`;}return normalize1(joined);}function join2(...paths){return isWindows?join1(...paths):join(...paths);}function assertArg1(url){url=url instanceof URL?url:new URL(url);if(url.protocol!=="file:"){throw new TypeError("Must be a file URL.");}return url;}function fromFileUrl(url){url=assertArg1(url);return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"));}function fromFileUrl1(url){url=assertArg1(url);let path=decodeURIComponent(url.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");if(url.hostname!==""){path=`\\\\${url.hostname}${path}`;}return path;}function fromFileUrl2(url){return isWindows?fromFileUrl1(url):fromFileUrl(url);}function toPathString(pathUrl){return pathUrl instanceof URL?fromFileUrl2(pathUrl):pathUrl;}function stripTrailingSeparators(segment,isSep){if(segment.length<=1){return segment;}let end=segment.length;for(let i=segment.length-1;i>0;i--){if(isSep(segment.charCodeAt(i))){end=i;}else{break;}}return segment.slice(0,end);}function resolve(...pathSegments){let resolvedPath="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1&&!resolvedAbsolute;i--){let path;if(i>=0)path=pathSegments[i];else{const{Deno:Deno1}=globalThis;if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();}assertPath(path);if(path.length===0){continue;}resolvedPath=`${path}/${resolvedPath}`;resolvedAbsolute=isPosixPathSeparator(path.charCodeAt(0));}resolvedPath=normalizeString(resolvedPath,!resolvedAbsolute,"/",isPosixPathSeparator);if(resolvedAbsolute){if(resolvedPath.length>0)return`/${resolvedPath}`;else return"/";}else if(resolvedPath.length>0)return resolvedPath;else return".";}function resolve1(...pathSegments){let resolvedDevice="";let resolvedTail="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1;i--){let path;const{Deno:Deno1}=globalThis;if(i>=0){path=pathSegments[i];}else if(!resolvedDevice){if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a drive-letter-less path without a CWD.");}path=Deno1.cwd();}else{if(typeof Deno1?.env?.get!=="function"||typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();if(path===undefined||path.slice(0,3).toLowerCase()!==`${resolvedDevice.toLowerCase()}\\`){path=`${resolvedDevice}\\`;}}assertPath(path);const len=path.length;if(len===0)continue;let rootEnd=0;let device="";let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){rootEnd=1;isAbsolute=true;}if(device.length>0&&resolvedDevice.length>0&&device.toLowerCase()!==resolvedDevice.toLowerCase()){continue;}if(resolvedDevice.length===0&&device.length>0){resolvedDevice=device;}if(!resolvedAbsolute){resolvedTail=`${path.slice(rootEnd)}\\${resolvedTail}`;resolvedAbsolute=isAbsolute;}if(resolvedAbsolute&&resolvedDevice.length>0)break;}resolvedTail=normalizeString(resolvedTail,!resolvedAbsolute,"\\",isPathSeparator);return resolvedDevice+(resolvedAbsolute?"\\":"")+resolvedTail||".";}Deno.build.os==="windows";async function exists(path,options){try{const stat=await Deno.stat(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if((await Deno.permissions.query({name:"read",path})).state==="granted"){return!options?.isReadable;}}throw error;}}function existsSync(path,options){try{const stat=Deno.statSync(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if(Deno.permissions.querySync({name:"read",path}).state==="granted"){return!options?.isReadable;}}throw error;}}function normalize2(path){return isWindows?normalize1(path):normalize(path);}function stripSuffix(name,suffix){if(suffix.length>=name.length){return name;}const lenDiff=name.length-suffix.length;for(let i=suffix.length-1;i>=0;--i){if(name.charCodeAt(lenDiff+i)!==suffix.charCodeAt(i)){return name;}}return name.slice(0,-suffix.length);}function lastPathSegment(path,isSep,start=0){let matchedNonSeparator=false;let end=path.length;for(let i=path.length-1;i>=start;--i){if(isSep(path.charCodeAt(i))){if(matchedNonSeparator){start=i+1;break;}}else if(!matchedNonSeparator){matchedNonSeparator=true;end=i+1;}}return path.slice(start,end);}function assertArgs(path,suffix){assertPath(path);if(path.length===0)return path;if(typeof suffix!=="string"){throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);}}function basename(path,suffix=""){assertArgs(path,suffix);const lastSegment=lastPathSegment(path,isPosixPathSeparator);const strippedSegment=stripTrailingSeparators(lastSegment,isPosixPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename1(path,suffix=""){assertArgs(path,suffix);let start=0;if(path.length>=2){const drive=path.charCodeAt(0);if(isWindowsDeviceRoot(drive)){if(path.charCodeAt(1)===58)start=2;}}const lastSegment=lastPathSegment(path,isPathSeparator,start);const strippedSegment=stripTrailingSeparators(lastSegment,isPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename2(path,suffix=""){return isWindows?basename1(path,suffix):basename(path,suffix);}async function createWalkEntry(path){path=toPathString(path);path=normalize2(path);const name=basename2(path);const info=await Deno.stat(path);return{path,name,isFile:info.isFile,isDirectory:info.isDirectory,isSymlink:info.isSymlink};}class WalkError extends Error{root;constructor(cause,root){super(`${cause instanceof Error?cause.message:cause} for path "${root}"`);this.cause=cause;this.name="WalkError";this.root=root;}}function include(path,exts,match,skip){if(exts&&!exts.some(ext=>path.endsWith(ext))){return false;}if(match&&!match.some(pattern=>!!path.match(pattern))){return false;}if(skip&&skip.some(pattern=>!!path.match(pattern))){return false;}return true;}function wrapErrorWithPath(err,root){if(err instanceof WalkError)return err;return new WalkError(err,root);}async function*walk(root,{maxDepth=Infinity,includeFiles=true,includeDirs=true,includeSymlinks=true,followSymlinks=false,canonicalize=true,exts=undefined,match=undefined,skip=undefined}={}){if(maxDepth<0){return;}root=toPathString(root);if(includeDirs&&include(root,exts,match,skip)){yield await createWalkEntry(root);}if(maxDepth<1||!include(root,undefined,undefined,skip)){return;}try{for await(const entry of Deno.readDir(root)){let path=join2(root,entry.name);let{isSymlink,isDirectory}=entry;if(isSymlink){if(!followSymlinks){if(includeSymlinks&&include(path,exts,match,skip)){yield{path,...entry};}continue;}const realPath=await Deno.realPath(path);if(canonicalize){path=realPath;}({isSymlink,isDirectory}=await Deno.lstat(realPath));}if(isSymlink||isDirectory){yield*walk(path,{maxDepth:maxDepth-1,includeFiles,includeDirs,includeSymlinks,followSymlinks,exts,match,skip});}else if(includeFiles&&include(path,exts,match,skip)){yield{path,...entry};}}}catch(err){throw wrapErrorWithPath(err,normalize2(root));}}Deno.build.os==="windows";new Deno.errors.AlreadyExists("dest already exists.");Deno.build.os==="windows";const LF="\n";const CRLF="\r\n";Deno?.build.os==="windows"?CRLF:LF;function parse(text,{allowTrailingComma=true}={}){if(new.target){throw new TypeError("parse is not a constructor");}return new JSONCParser(text,{allowTrailingComma}).parse();}const originalJSONParse=globalThis.JSON.parse;class JSONCParser{#whitespace=new Set(" \r\n");#numberEndToken=new Set([..."[]{}:,/",...this.#whitespace]);#text;#length;#tokenized;#options;constructor(text,options){this.#text=`${text}`;this.#length=this.#text.length;this.#tokenized=this.#tokenize();this.#options=options;}parse(){const token=this.#getNext();const res=this.#parseJsonValue(token);const{done,value}=this.#tokenized.next();if(!done){throw new SyntaxError(buildErrorMessage(value));}return res;}#getNext(){const{done,value}=this.#tokenized.next();if(done){throw new SyntaxError("Unexpected end of JSONC input");}return value;}*#tokenize(){for(let i=0;iisNaN(Number(key)));const byLevel={[LogLevels.NOTSET]:"NOTSET",[LogLevels.DEBUG]:"DEBUG",[LogLevels.INFO]:"INFO",[LogLevels.WARNING]:"WARNING",[LogLevels.ERROR]:"ERROR",[LogLevels.CRITICAL]:"CRITICAL"};function getLevelByName(name){const level=LogLevels[name];if(level!==undefined){return level;}throw new Error(`no log level found for name: ${name}`);}function getLevelName(level){const levelName=byLevel[level];if(levelName){return levelName;}throw new Error(`no level name found for level: ${level}`);}class LogRecord{msg;#args;#datetime;level;levelName;loggerName;constructor(options){this.msg=options.msg;this.#args=[...options.args];this.level=options.level;this.loggerName=options.loggerName;this.#datetime=new Date;this.levelName=getLevelName(options.level);}get args(){return[...this.#args];}get datetime(){return new Date(this.#datetime.getTime());}}class Logger{#level;#handlers;#loggerName;constructor(loggerName,levelName,options={}){this.#loggerName=loggerName;this.#level=getLevelByName(levelName);this.#handlers=options.handlers||[];}get level(){return this.#level;}set level(level){try{this.#level=getLevelByName(getLevelName(level));}catch(_){throw new TypeError(`Invalid log level: ${level}`);}}get levelName(){return getLevelName(this.#level);}set levelName(levelName){this.#level=getLevelByName(levelName);}get loggerName(){return this.#loggerName;}set handlers(hndls){this.#handlers=hndls;}get handlers(){return this.#handlers;}#_log(level,msg,...args){if(this.level>level){return msg instanceof Function?undefined:msg;}let fnResult;let logMessage;if(msg instanceof Function){fnResult=msg();logMessage=this.asString(fnResult);}else{logMessage=this.asString(msg);}const record=new LogRecord({msg:logMessage,args:args,level:level,loggerName:this.loggerName});this.#handlers.forEach(handler=>{handler.handle(record);});return msg instanceof Function?fnResult:msg;}asString(data,isProperty=false){if(typeof data==="string"){if(isProperty)return`"${data}"`;return data;}else if(data===null||typeof data==="number"||typeof data==="bigint"||typeof data==="boolean"||typeof data==="undefined"||typeof data==="symbol"){return String(data);}else if(data instanceof Error){return data.stack;}else if(typeof data==="object"){return`{${Object.entries(data).map(([k,v])=>`"${k}":${this.asString(v,true)}`).join(",")}}`;}return"undefined";}debug(msg,...args){return this.#_log(LogLevels.DEBUG,msg,...args);}info(msg,...args){return this.#_log(LogLevels.INFO,msg,...args);}warning(msg,...args){return this.#_log(LogLevels.WARNING,msg,...args);}error(msg,...args){return this.#_log(LogLevels.ERROR,msg,...args);}critical(msg,...args){return this.#_log(LogLevels.CRITICAL,msg,...args);}}const{Deno:Deno1}=globalThis;const noColor=typeof Deno1?.noColor==="boolean"?Deno1.noColor:false;let enabled=!noColor;function code(open,close){return{open:`\x1b[${open.join(";")}m`,close:`\x1b[${close}m`,regexp:new RegExp(`\\x1b\\[${close}m`,"g")};}function run(str,code){return enabled?`${code.open}${str.replace(code.regexp,code.open)}${code.close}`:str;}function bold(str){return run(str,code([1],22));}function red(str){return run(str,code([31],39));}function yellow(str){return run(str,code([33],39));}function blue(str){return run(str,code([34],39));}new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"),"g");function copy(src,dst,off=0){off=Math.max(0,Math.min(off,dst.byteLength));const dstBytesAvailable=dst.byteLength-off;if(src.byteLength>dstBytesAvailable){src=src.subarray(0,dstBytesAvailable);}dst.set(src,off);return src.byteLength;}class AbstractBufBase{buf;usedBufferBytes=0;err=null;constructor(buf){this.buf=buf;}size(){return this.buf.byteLength;}available(){return this.buf.byteLength-this.usedBufferBytes;}buffered(){return this.usedBufferBytes;}}class BufWriterSync extends AbstractBufBase{#writer;static create(writer,size=4096){return writer instanceof BufWriterSync?writer:new BufWriterSync(writer,size);}constructor(writer,size=4096){super(new Uint8Array(size<=0?4096:size));this.#writer=writer;}reset(w){this.err=null;this.usedBufferBytes=0;this.#writer=w;}flush(){if(this.err!==null)throw this.err;if(this.usedBufferBytes===0)return;try{const p=this.buf.subarray(0,this.usedBufferBytes);let nwritten=0;while(nwrittenthis.available()){if(this.buffered()===0){try{numBytesWritten=this.#writer.writeSync(data);}catch(e){if(e instanceof Error){this.err=e;}throw e;}}else{numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;this.flush();}totalBytesWritten+=numBytesWritten;data=data.subarray(numBytesWritten);}numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;totalBytesWritten+=numBytesWritten;return totalBytesWritten;}}const DEFAULT_FORMATTER="{levelName} {msg}";class BaseHandler{level;levelName;formatter;constructor(levelName,options={}){this.level=getLevelByName(levelName);this.levelName=levelName;this.formatter=options.formatter||DEFAULT_FORMATTER;}handle(logRecord){if(this.level>logRecord.level)return;const msg=this.format(logRecord);this.log(msg);}format(logRecord){if(this.formatter instanceof Function){return this.formatter(logRecord);}return this.formatter.replace(/{([^\s}]+)}/g,(match,p1)=>{const value=logRecord[p1];if(value===undefined){return match;}return String(value);});}log(_msg){}setup(){}destroy(){}}class ConsoleHandler extends BaseHandler{#useColors;constructor(levelName,options={}){super(levelName,options);this.#useColors=options.useColors??true;}format(logRecord){let msg=super.format(logRecord);if(this.#useColors){msg=this.applyColors(msg,logRecord.level);}return msg;}applyColors(msg,level){switch(level){case LogLevels.INFO:msg=blue(msg);break;case LogLevels.WARNING:msg=yellow(msg);break;case LogLevels.ERROR:msg=red(msg);break;case LogLevels.CRITICAL:msg=bold(red(msg));break;default:break;}return msg;}log(msg){console.log(msg);}}class WriterHandler extends BaseHandler{_writer;#encoder=new TextEncoder;}class FileHandler extends WriterHandler{_file;_buf;_filename;_mode;_openOptions;_encoder=new TextEncoder;#unloadCallback=(()=>{this.destroy();}).bind(this);constructor(levelName,options){super(levelName,options);this._filename=options.filename;this._mode=options.mode?options.mode:"a";this._openOptions={createNew:this._mode==="x",create:this._mode!=="x",append:this._mode==="a",truncate:this._mode!=="a",write:true};}setup(){this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);addEventListener("unload",this.#unloadCallback);}handle(logRecord){super.handle(logRecord);if(logRecord.level>LogLevels.ERROR){this.flush();}}log(msg){if(this._encoder.encode(msg).byteLength+1>this._buf.available()){this.flush();}this._buf.writeSync(this._encoder.encode(msg+"\n"));}flush(){if(this._buf?.buffered()>0){this._buf.flush();}}destroy(){this.flush();this._file?.close();this._file=undefined;removeEventListener("unload",this.#unloadCallback);}}class RotatingFileHandler extends FileHandler{#maxBytes;#maxBackupCount;#currentFileSize=0;constructor(levelName,options){super(levelName,options);this.#maxBytes=options.maxBytes;this.#maxBackupCount=options.maxBackupCount;}setup(){if(this.#maxBytes<1){this.destroy();throw new Error("maxBytes cannot be less than 1");}if(this.#maxBackupCount<1){this.destroy();throw new Error("maxBackupCount cannot be less than 1");}super.setup();if(this._mode==="w"){for(let i=1;i<=this.#maxBackupCount;i++){try{Deno.removeSync(this._filename+"."+i);}catch(error){if(!(error instanceof Deno.errors.NotFound)){throw error;}}}}else if(this._mode==="x"){for(let i=1;i<=this.#maxBackupCount;i++){if(existsSync(this._filename+"."+i)){this.destroy();throw new Deno.errors.AlreadyExists("Backup log file "+this._filename+"."+i+" already exists");}}}else{this.#currentFileSize=Deno.statSync(this._filename).size;}}log(msg){const msgByteLength=this._encoder.encode(msg).byteLength+1;if(this.#currentFileSize+msgByteLength>this.#maxBytes){this.rotateLogFiles();this.#currentFileSize=0;}super.log(msg);this.#currentFileSize+=msgByteLength;}rotateLogFiles(){this._buf.flush();this._file.close();for(let i=this.#maxBackupCount-1;i>=0;i--){const source=this._filename+(i===0?"":"."+i);const dest=this._filename+"."+(i+1);if(existsSync(source)){Deno.renameSync(source,dest);}}this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);}}const DEFAULT_LEVEL="INFO";const DEFAULT_CONFIG={handlers:{default:new ConsoleHandler(DEFAULT_LEVEL)},loggers:{default:{level:DEFAULT_LEVEL,handlers:["default"]}}};const state={handlers:new Map,loggers:new Map,config:DEFAULT_CONFIG};const handlers={BaseHandler,ConsoleHandler,WriterHandler,FileHandler,RotatingFileHandler};function getLogger(name){if(!name){const d=state.loggers.get("default");assert(d!==undefined,`"default" logger must be set for getting logger without name`);return d;}const result=state.loggers.get(name);if(!result){const logger=new Logger(name,"NOTSET",{handlers:[]});state.loggers.set(name,logger);return logger;}return result;}function debug(msg,...args){if(msg instanceof Function){return getLogger("default").debug(msg,...args);}return getLogger("default").debug(msg,...args);}function info(msg,...args){if(msg instanceof Function){return getLogger("default").info(msg,...args);}return getLogger("default").info(msg,...args);}function warning(msg,...args){if(msg instanceof Function){return getLogger("default").warning(msg,...args);}return getLogger("default").warning(msg,...args);}function error(msg,...args){if(msg instanceof Function){return getLogger("default").error(msg,...args);}return getLogger("default").error(msg,...args);}function setup(config){state.config={handlers:{...DEFAULT_CONFIG.handlers,...config.handlers},loggers:{...DEFAULT_CONFIG.loggers,...config.loggers}};state.handlers.forEach(handler=>{handler.destroy();});state.handlers.clear();const handlers=state.config.handlers||{};for(const handlerName in handlers){const handler=handlers[handlerName];handler.setup();state.handlers.set(handlerName,handler);}state.loggers.clear();const loggers=state.config.loggers||{};for(const loggerName in loggers){const loggerConfig=loggers[loggerName];const handlerNames=loggerConfig.handlers||[];const handlers=[];handlerNames.forEach(handlerName=>{const handler=state.handlers.get(handlerName);if(handler){handlers.push(handler);}});const levelName=loggerConfig.level||DEFAULT_LEVEL;const logger=new Logger(loggerName,levelName,{handlers:handlers});state.loggers.set(loggerName,logger);}}setup(DEFAULT_CONFIG);function assertArgs1(from,to){assertPath(from);assertPath(to);if(from===to)return"";}function relative(from,to){assertArgs1(from,to);from=resolve(from);to=resolve(to);if(from===to)return"";let fromStart=1;const fromEnd=from.length;for(;fromStartlength){if(isPosixPathSeparator(to.charCodeAt(toStart+i))){return to.slice(toStart+i+1);}else if(i===0){return to.slice(toStart+i);}}else if(fromLen>length){if(isPosixPathSeparator(from.charCodeAt(fromStart+i))){lastCommonSep=i;}else if(i===0){lastCommonSep=0;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(isPosixPathSeparator(fromCode))lastCommonSep=i;}let out="";for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||isPosixPathSeparator(from.charCodeAt(i))){if(out.length===0)out+="..";else out+="/..";}}if(out.length>0)return out+to.slice(toStart+lastCommonSep);else{toStart+=lastCommonSep;if(isPosixPathSeparator(to.charCodeAt(toStart)))++toStart;return to.slice(toStart);}}function relative1(from,to){assertArgs1(from,to);const fromOrig=resolve1(from);const toOrig=resolve1(to);if(fromOrig===toOrig)return"";from=fromOrig.toLowerCase();to=toOrig.toLowerCase();if(from===to)return"";let fromStart=0;let fromEnd=from.length;for(;fromStartfromStart;--fromEnd){if(from.charCodeAt(fromEnd-1)!==92)break;}const fromLen=fromEnd-fromStart;let toStart=0;let toEnd=to.length;for(;toStarttoStart;--toEnd){if(to.charCodeAt(toEnd-1)!==92)break;}const toLen=toEnd-toStart;const length=fromLenlength){if(to.charCodeAt(toStart+i)===92){return toOrig.slice(toStart+i+1);}else if(i===2){return toOrig.slice(toStart+i);}}if(fromLen>length){if(from.charCodeAt(fromStart+i)===92){lastCommonSep=i;}else if(i===2){lastCommonSep=3;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(fromCode===92)lastCommonSep=i;}if(i!==length&&lastCommonSep===-1){return toOrig;}let out="";if(lastCommonSep===-1)lastCommonSep=0;for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||from.charCodeAt(i)===92){if(out.length===0)out+="..";else out+="\\..";}}if(out.length>0){return out+toOrig.slice(toStart+lastCommonSep,toEnd);}else{toStart+=lastCommonSep;if(toOrig.charCodeAt(toStart)===92)++toStart;return toOrig.slice(toStart,toEnd);}}function relative2(from,to){return isWindows?relative1(from,to):relative(from,to);}var m=Object.create;var E=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),D=(t,e)=>{for(var s in e)E(t,s,{get:e[s],enumerable:!0});},a=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!b.call(t,n)&&n!==s&&E(t,n,{get:()=>e[n],enumerable:!(r=T(e,n))||r.enumerable});return t;},_=(t,e,s)=>(a(t,e,"default"),s&&a(s,e,"default")),$=(t,e,s)=>(s=t!=null?m(X(t)):{},a(e||!t||!t.__esModule?E(s,"default",{value:t,enumerable:!0}):s,t));var A=w((ct,v)=>{function C(t){return Array.isArray(t)?t:[t];}var N="",P=" ",h="\\",H=/^\s+$/,F=/(?:[^\\]|^)\\$/,k=/^\\!/,z=/^\\#/,B=/\r?\n/g,K=/^\.*\/|^\.+$/,d="/",x="node-ignore";typeof Symbol<"u"&&(x=Symbol.for("node-ignore"));var L=x,V=(t,e,s)=>Object.defineProperty(t,e,{value:s}),j=/([0-z])-([0-z])/g,G=()=>!1,M=t=>t.replace(j,(e,s,r)=>s.charCodeAt(0)<=r.charCodeAt(0)?e:N),Y=t=>{let{length:e}=t;return t.slice(0,e-e%2);},W=[[/\\?\s+$/,t=>t.indexOf("\\")===0?P:N],[/\\\s/g,()=>P],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)";}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,s)=>e+6{let r=s.replace(/\\\*/g,"[^\\/]*");return e+r;}],[/\\\\\\(?=[$.|*+(){^])/g,()=>h],[/\\\\/g,()=>h],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,s,r,n)=>e===h?`\\[${s}${Y(r)}${n}`:n==="]"&&r.length%2===0?`[${M(s)}${r}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],S=Object.create(null),p=(t,e)=>{let s=S[t];return s||(s=W.reduce((r,n)=>r.replace(n[0],n[1].bind(t)),t),S[t]=s),e?new RegExp(s,"i"):new RegExp(s);},R=t=>typeof t=="string",q=t=>t&&R(t)&&!H.test(t)&&!F.test(t)&&t.indexOf("#")!==0,J=t=>t.split(B),f=class{constructor(e,s,r,n){this.origin=e,this.pattern=s,this.negative=r,this.regex=n;}},Q=(t,e)=>{let s=t,r=!1;t.indexOf("!")===0&&(r=!0,t=t.substr(1)),t=t.replace(k,"!").replace(z,"#");let n=p(t,e);return new f(s,t,r,n);},U=(t,e)=>{throw new e(t);},i=(t,e,s)=>R(t)?t?i.isNotRelative(t)?s(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:s("path must not be empty",TypeError):s(`path must be a string, but got \`${e}\``,TypeError),O=t=>K.test(t);i.isNotRelative=O;i.convert=t=>t;var g=class{constructor({ignorecase:e=!0,ignoreCase:s=e,allowRelativePaths:r=!1}={}){V(this,L,!0),this._rules=[],this._ignoreCase=s,this._allowRelativePaths=r,this._initCache();}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null);}_addPattern(e){if(e&&e[L]){this._rules=this._rules.concat(e._rules),this._added=!0;return;}if(q(e)){let s=Q(e,this._ignoreCase);this._added=!0,this._rules.push(s);}}add(e){return this._added=!1,C(R(e)?J(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this;}addPattern(e){return this.add(e);}_testOne(e,s){let r=!1,n=!1;return this._rules.forEach(o=>{let{negative:u}=o;if(n===u&&r!==n||u&&!r&&!n&&!s)return;o.regex.test(e)&&(r=!u,n=u);}),{ignored:r,unignored:n};}_test(e,s,r,n){let o=e&&i.convert(e);return i(o,e,this._allowRelativePaths?G:U),this._t(o,s,r,n);}_t(e,s,r,n){if(e in s)return s[e];if(n||(n=e.split(d)),n.pop(),!n.length)return s[e]=this._testOne(e,r);let o=this._t(n.join(d)+d,s,r,n);return s[e]=o.ignored?o:this._testOne(e,r);}ignores(e){return this._test(e,this._ignoreCache,!1).ignored;}createFilter(){return e=>!this.ignores(e);}filter(e){return C(e).filter(this.createFilter());}test(e){return this._test(e,this._testCache,!0);}},l=t=>new g(t),Z=t=>i(t&&i.convert(t),t,G);l.isPathValid=Z;l.default=l;v.exports=l;var tt=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");i.convert=tt;var et=/^[a-z]:\//i;i.isNotRelative=t=>et.test(t)||O(t);});var c={};D(c,{default:()=>nt});var st=$(A());_(c,$(A()));var{default:I,...rt}=st,nt=I!==void 0?I:rt;const importMeta={url:"file:///Users/winston/Code/winston/setup-deno/cache.ts",main:import.meta.main};const args=parseArgs(Deno.args,{boolean:["help","dry-run","debug"],string:["config"],alias:{help:"h",dryRun:"n"},"--":true});const logLevel=args.debug?"DEBUG":"INFO";setup({handlers:{console:new handlers.ConsoleHandler(logLevel,{formatter:logRecord=>Deno.noColor?[logRecord.levelName,logRecord.msg].join(" "):logRecord.msg})},loggers:{default:{handlers:["console"],"level":logLevel}}});const main=async args=>{if(args.help){console.log("Usage: cache [-n | --dry-run] [--debug] [--] [DENO_ARGS...]");Deno.exit(0);}if(args["dry-run"])warning("dry-run mode enabled");if(args.config&&!await exists(args.config)){error(`config file ${args.config} not found`);Deno.exit(1);}const hash=await Deno.readFile("./deno.lock").then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>encodeHex(new Uint8Array(data))).catch(_=>"");debug(`GitHub actions deno.lock hash: ${hash}`);const cfgs=args.config?[args.config]:["deno.json","deno.jsonc"];const denoCfg=await Promise.all(cfgs.map(path=>Deno.readTextFile(path).catch(_=>undefined))).then(v=>parse(v.filter(Boolean)[0]??"{}"));const patterns=[...[denoCfg?.exclude??[]].flat(),...[denoCfg?.cache?.exclude??[]].flat(),...[denoCfg?.cache?.include??[]].flatMap(p=>`!${p}`)];debug(`patterns:`,patterns);patterns.forEach(p=>debug(`- ${p}`));const ig=nt().add(patterns);const walkIterator=walk(".",{exts:["js",".jsx",".ts",".tsx"],includeDirs:false});for await(const entry of walkIterator){const relativePath=relative2(".",entry.path);if(ig.ignores(relativePath)){debug(`ignored ${relativePath}`);continue;}debug(`caching ${relativePath}`);const cmd=new Deno.Command(Deno.execPath(),{args:["cache",args.config&&`--config=${args.config}`,relativePath,...args["--"]].filter(Boolean),stdout:"inherit",stderr:"inherit"});let code=0;if(!args["dry-run"])code=(await cmd.output()).code;if(code===0){info(`cached ${relativePath}`);}else{error(`failed to cache ${entry.path}`);}}};if(importMeta.main)main(args); \ No newline at end of file From a4d774f3800f4e02c34112c7243fa13dbb7416d6 Mon Sep 17 00:00:00 2001 From: winston Date: Tue, 26 Dec 2023 18:24:00 +0100 Subject: [PATCH 07/18] ci: fix path --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index e374b67..a03da8f 100644 --- a/action.yml +++ b/action.yml @@ -56,4 +56,4 @@ runs: - name: Restore Deno dependencies shell: bash run: | - ${{ github.action_path }}/dist/cache.js + "${{ github.action_path }}"/dist/cache.js From 9656a0b661850d6f3bdc89224f5a8b1c647d401e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 26 Dec 2023 17:24:44 +0000 Subject: [PATCH 08/18] chore: build action bundle --- dist/cache.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/cache.js b/dist/cache.js index 03bfd80..6bc95bd 100755 --- a/dist/cache.js +++ b/dist/cache.js @@ -1,2 +1,2 @@ #!/usr/bin/env -S deno run --no-lock --allow-read --allow-run=deno -class AssertionError extends Error{constructor(message){super(message);this.name="AssertionError";}}function assert(expr,msg=""){if(!expr){throw new AssertionError(msg);}}const{hasOwn}=Object;function get(obj,key){if(hasOwn(obj,key)){return obj[key];}}function getForce(obj,key){const v=get(obj,key);assert(v!==undefined);return v;}function isNumber(x){if(typeof x==="number")return true;if(/^0x[0-9a-f]+$/i.test(String(x)))return true;return/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(String(x));}function hasKey(obj,keys){let o=obj;keys.slice(0,-1).forEach(key=>{o=get(o,key)??{};});const key=keys[keys.length-1];return hasOwn(o,key);}function parseArgs(args,{"--":doubleDash=false,alias={},boolean:__boolean=false,default:defaults={},stopEarly=false,string=[],collect=[],negatable=[],unknown=i=>i}={}){const aliases={};const flags={bools:{},strings:{},unknownFn:unknown,allBools:false,collect:{},negatable:{}};if(alias!==undefined){for(const key in alias){const val=getForce(alias,key);if(typeof val==="string"){aliases[key]=[val];}else{aliases[key]=val;}for(const alias of getForce(aliases,key)){aliases[alias]=[key].concat(aliases[key].filter(y=>alias!==y));}}}if(__boolean!==undefined){if(typeof __boolean==="boolean"){flags.allBools=!!__boolean;}else{const booleanArgs=typeof __boolean==="string"?[__boolean]:__boolean;for(const key of booleanArgs.filter(Boolean)){flags.bools[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.bools[al]=true;}}}}}if(string!==undefined){const stringArgs=typeof string==="string"?[string]:string;for(const key of stringArgs.filter(Boolean)){flags.strings[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.strings[al]=true;}}}}if(collect!==undefined){const collectArgs=typeof collect==="string"?[collect]:collect;for(const key of collectArgs.filter(Boolean)){flags.collect[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.collect[al]=true;}}}}if(negatable!==undefined){const negatableArgs=typeof negatable==="string"?[negatable]:negatable;for(const key of negatableArgs.filter(Boolean)){flags.negatable[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.negatable[al]=true;}}}}const argv={_:[]};function argDefined(key,arg){return flags.allBools&&/^--[^=]+$/.test(arg)||get(flags.bools,key)||!!get(flags.strings,key)||!!get(aliases,key);}function setKey(obj,name,value,collect=true){let o=obj;const keys=name.split(".");keys.slice(0,-1).forEach(function(key){if(get(o,key)===undefined){o[key]={};}o=get(o,key);});const key=keys[keys.length-1];const collectable=collect&&!!get(flags.collect,name);if(!collectable){o[key]=value;}else if(get(o,key)===undefined){o[key]=[value];}else if(Array.isArray(get(o,key))){o[key].push(value);}else{o[key]=[get(o,key),value];}}function setArg(key,val,arg=undefined,collect){if(arg&&flags.unknownFn&&!argDefined(key,arg)){if(flags.unknownFn(arg,key,val)===false)return;}const value=!get(flags.strings,key)&&isNumber(val)?Number(val):val;setKey(argv,key,value,collect);const alias=get(aliases,key);if(alias){for(const x of alias){setKey(argv,x,value,collect);}}}function aliasIsBoolean(key){return getForce(aliases,key).some(x=>typeof get(flags.bools,x)==="boolean");}let notFlags=[];if(args.includes("--")){notFlags=args.slice(args.indexOf("--")+1);args=args.slice(0,args.indexOf("--"));}for(let i=0;i>4];dst[i*2+1]=hexTable[v&15];}return textDecoder.decode(dst);}const osType=(()=>{const{Deno:Deno1}=globalThis;if(typeof Deno1?.build?.os==="string"){return Deno1.build.os;}const{navigator}=globalThis;if(navigator?.appVersion?.includes?.("Win")){return"windows";}return"linux";})();const isWindows=osType==="windows";function assertPath(path){if(typeof path!=="string"){throw new TypeError(`Path must be a string. Received ${JSON.stringify(path)}`);}}function assertArg(path){assertPath(path);if(path.length===0)return".";}const CHAR_FORWARD_SLASH=47;function normalizeString(path,allowAboveRoot,separator,isPathSeparator){let res="";let lastSegmentLength=0;let lastSlash=-1;let dots=0;let code;for(let i=0,len=path.length;i<=len;++i){if(i2){const lastSlashIndex=res.lastIndexOf(separator);if(lastSlashIndex===-1){res="";lastSegmentLength=0;}else{res=res.slice(0,lastSlashIndex);lastSegmentLength=res.length-1-res.lastIndexOf(separator);}lastSlash=i;dots=0;continue;}else if(res.length===2||res.length===1){res="";lastSegmentLength=0;lastSlash=i;dots=0;continue;}}if(allowAboveRoot){if(res.length>0)res+=`${separator}..`;else res="..";lastSegmentLength=2;}}else{if(res.length>0)res+=separator+path.slice(lastSlash+1,i);else res=path.slice(lastSlash+1,i);lastSegmentLength=i-lastSlash-1;}lastSlash=i;dots=0;}else if(code===46&&dots!==-1){++dots;}else{dots=-1;}}return res;}function isPosixPathSeparator(code){return code===47;}function normalize(path){assertArg(path);const isAbsolute=isPosixPathSeparator(path.charCodeAt(0));const trailingSeparator=isPosixPathSeparator(path.charCodeAt(path.length-1));path=normalizeString(path,!isAbsolute,"/",isPosixPathSeparator);if(path.length===0&&!isAbsolute)path=".";if(path.length>0&&trailingSeparator)path+="/";if(isAbsolute)return`/${path}`;return path;}function join(...paths){if(paths.length===0)return".";let joined;for(let i=0,len=paths.length;i0){if(!joined)joined=path;else joined+=`/${path}`;}}if(!joined)return".";return normalize(joined);}function isPathSeparator(code){return code===47||code===92;}function isWindowsDeviceRoot(code){return code>=97&&code<=122||code>=65&&code<=90;}function normalize1(path){assertArg(path);const len=path.length;let rootEnd=0;let device;let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){return"\\";}let tail;if(rootEnd0&&isPathSeparator(path.charCodeAt(len-1))){tail+="\\";}if(device===undefined){if(isAbsolute){if(tail.length>0)return`\\${tail}`;else return"\\";}else if(tail.length>0){return tail;}else{return"";}}else if(isAbsolute){if(tail.length>0)return`${device}\\${tail}`;else return`${device}\\`;}else if(tail.length>0){return device+tail;}else{return device;}}function join1(...paths){if(paths.length===0)return".";let joined;let firstPart=null;for(let i=0;i0){if(joined===undefined)joined=firstPart=path;else joined+=`\\${path}`;}}if(joined===undefined)return".";let needsReplace=true;let slashCount=0;assert(firstPart!==null);if(isPathSeparator(firstPart.charCodeAt(0))){++slashCount;const firstLen=firstPart.length;if(firstLen>1){if(isPathSeparator(firstPart.charCodeAt(1))){++slashCount;if(firstLen>2){if(isPathSeparator(firstPart.charCodeAt(2)))++slashCount;else{needsReplace=false;}}}}}if(needsReplace){for(;slashCount=2)joined=`\\${joined.slice(slashCount)}`;}return normalize1(joined);}function join2(...paths){return isWindows?join1(...paths):join(...paths);}function assertArg1(url){url=url instanceof URL?url:new URL(url);if(url.protocol!=="file:"){throw new TypeError("Must be a file URL.");}return url;}function fromFileUrl(url){url=assertArg1(url);return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"));}function fromFileUrl1(url){url=assertArg1(url);let path=decodeURIComponent(url.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");if(url.hostname!==""){path=`\\\\${url.hostname}${path}`;}return path;}function fromFileUrl2(url){return isWindows?fromFileUrl1(url):fromFileUrl(url);}function toPathString(pathUrl){return pathUrl instanceof URL?fromFileUrl2(pathUrl):pathUrl;}function stripTrailingSeparators(segment,isSep){if(segment.length<=1){return segment;}let end=segment.length;for(let i=segment.length-1;i>0;i--){if(isSep(segment.charCodeAt(i))){end=i;}else{break;}}return segment.slice(0,end);}function resolve(...pathSegments){let resolvedPath="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1&&!resolvedAbsolute;i--){let path;if(i>=0)path=pathSegments[i];else{const{Deno:Deno1}=globalThis;if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();}assertPath(path);if(path.length===0){continue;}resolvedPath=`${path}/${resolvedPath}`;resolvedAbsolute=isPosixPathSeparator(path.charCodeAt(0));}resolvedPath=normalizeString(resolvedPath,!resolvedAbsolute,"/",isPosixPathSeparator);if(resolvedAbsolute){if(resolvedPath.length>0)return`/${resolvedPath}`;else return"/";}else if(resolvedPath.length>0)return resolvedPath;else return".";}function resolve1(...pathSegments){let resolvedDevice="";let resolvedTail="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1;i--){let path;const{Deno:Deno1}=globalThis;if(i>=0){path=pathSegments[i];}else if(!resolvedDevice){if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a drive-letter-less path without a CWD.");}path=Deno1.cwd();}else{if(typeof Deno1?.env?.get!=="function"||typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();if(path===undefined||path.slice(0,3).toLowerCase()!==`${resolvedDevice.toLowerCase()}\\`){path=`${resolvedDevice}\\`;}}assertPath(path);const len=path.length;if(len===0)continue;let rootEnd=0;let device="";let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){rootEnd=1;isAbsolute=true;}if(device.length>0&&resolvedDevice.length>0&&device.toLowerCase()!==resolvedDevice.toLowerCase()){continue;}if(resolvedDevice.length===0&&device.length>0){resolvedDevice=device;}if(!resolvedAbsolute){resolvedTail=`${path.slice(rootEnd)}\\${resolvedTail}`;resolvedAbsolute=isAbsolute;}if(resolvedAbsolute&&resolvedDevice.length>0)break;}resolvedTail=normalizeString(resolvedTail,!resolvedAbsolute,"\\",isPathSeparator);return resolvedDevice+(resolvedAbsolute?"\\":"")+resolvedTail||".";}Deno.build.os==="windows";async function exists(path,options){try{const stat=await Deno.stat(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if((await Deno.permissions.query({name:"read",path})).state==="granted"){return!options?.isReadable;}}throw error;}}function existsSync(path,options){try{const stat=Deno.statSync(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if(Deno.permissions.querySync({name:"read",path}).state==="granted"){return!options?.isReadable;}}throw error;}}function normalize2(path){return isWindows?normalize1(path):normalize(path);}function stripSuffix(name,suffix){if(suffix.length>=name.length){return name;}const lenDiff=name.length-suffix.length;for(let i=suffix.length-1;i>=0;--i){if(name.charCodeAt(lenDiff+i)!==suffix.charCodeAt(i)){return name;}}return name.slice(0,-suffix.length);}function lastPathSegment(path,isSep,start=0){let matchedNonSeparator=false;let end=path.length;for(let i=path.length-1;i>=start;--i){if(isSep(path.charCodeAt(i))){if(matchedNonSeparator){start=i+1;break;}}else if(!matchedNonSeparator){matchedNonSeparator=true;end=i+1;}}return path.slice(start,end);}function assertArgs(path,suffix){assertPath(path);if(path.length===0)return path;if(typeof suffix!=="string"){throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);}}function basename(path,suffix=""){assertArgs(path,suffix);const lastSegment=lastPathSegment(path,isPosixPathSeparator);const strippedSegment=stripTrailingSeparators(lastSegment,isPosixPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename1(path,suffix=""){assertArgs(path,suffix);let start=0;if(path.length>=2){const drive=path.charCodeAt(0);if(isWindowsDeviceRoot(drive)){if(path.charCodeAt(1)===58)start=2;}}const lastSegment=lastPathSegment(path,isPathSeparator,start);const strippedSegment=stripTrailingSeparators(lastSegment,isPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename2(path,suffix=""){return isWindows?basename1(path,suffix):basename(path,suffix);}async function createWalkEntry(path){path=toPathString(path);path=normalize2(path);const name=basename2(path);const info=await Deno.stat(path);return{path,name,isFile:info.isFile,isDirectory:info.isDirectory,isSymlink:info.isSymlink};}class WalkError extends Error{root;constructor(cause,root){super(`${cause instanceof Error?cause.message:cause} for path "${root}"`);this.cause=cause;this.name="WalkError";this.root=root;}}function include(path,exts,match,skip){if(exts&&!exts.some(ext=>path.endsWith(ext))){return false;}if(match&&!match.some(pattern=>!!path.match(pattern))){return false;}if(skip&&skip.some(pattern=>!!path.match(pattern))){return false;}return true;}function wrapErrorWithPath(err,root){if(err instanceof WalkError)return err;return new WalkError(err,root);}async function*walk(root,{maxDepth=Infinity,includeFiles=true,includeDirs=true,includeSymlinks=true,followSymlinks=false,canonicalize=true,exts=undefined,match=undefined,skip=undefined}={}){if(maxDepth<0){return;}root=toPathString(root);if(includeDirs&&include(root,exts,match,skip)){yield await createWalkEntry(root);}if(maxDepth<1||!include(root,undefined,undefined,skip)){return;}try{for await(const entry of Deno.readDir(root)){let path=join2(root,entry.name);let{isSymlink,isDirectory}=entry;if(isSymlink){if(!followSymlinks){if(includeSymlinks&&include(path,exts,match,skip)){yield{path,...entry};}continue;}const realPath=await Deno.realPath(path);if(canonicalize){path=realPath;}({isSymlink,isDirectory}=await Deno.lstat(realPath));}if(isSymlink||isDirectory){yield*walk(path,{maxDepth:maxDepth-1,includeFiles,includeDirs,includeSymlinks,followSymlinks,exts,match,skip});}else if(includeFiles&&include(path,exts,match,skip)){yield{path,...entry};}}}catch(err){throw wrapErrorWithPath(err,normalize2(root));}}Deno.build.os==="windows";new Deno.errors.AlreadyExists("dest already exists.");Deno.build.os==="windows";const LF="\n";const CRLF="\r\n";Deno?.build.os==="windows"?CRLF:LF;function parse(text,{allowTrailingComma=true}={}){if(new.target){throw new TypeError("parse is not a constructor");}return new JSONCParser(text,{allowTrailingComma}).parse();}const originalJSONParse=globalThis.JSON.parse;class JSONCParser{#whitespace=new Set(" \r\n");#numberEndToken=new Set([..."[]{}:,/",...this.#whitespace]);#text;#length;#tokenized;#options;constructor(text,options){this.#text=`${text}`;this.#length=this.#text.length;this.#tokenized=this.#tokenize();this.#options=options;}parse(){const token=this.#getNext();const res=this.#parseJsonValue(token);const{done,value}=this.#tokenized.next();if(!done){throw new SyntaxError(buildErrorMessage(value));}return res;}#getNext(){const{done,value}=this.#tokenized.next();if(done){throw new SyntaxError("Unexpected end of JSONC input");}return value;}*#tokenize(){for(let i=0;iisNaN(Number(key)));const byLevel={[LogLevels.NOTSET]:"NOTSET",[LogLevels.DEBUG]:"DEBUG",[LogLevels.INFO]:"INFO",[LogLevels.WARNING]:"WARNING",[LogLevels.ERROR]:"ERROR",[LogLevels.CRITICAL]:"CRITICAL"};function getLevelByName(name){const level=LogLevels[name];if(level!==undefined){return level;}throw new Error(`no log level found for name: ${name}`);}function getLevelName(level){const levelName=byLevel[level];if(levelName){return levelName;}throw new Error(`no level name found for level: ${level}`);}class LogRecord{msg;#args;#datetime;level;levelName;loggerName;constructor(options){this.msg=options.msg;this.#args=[...options.args];this.level=options.level;this.loggerName=options.loggerName;this.#datetime=new Date;this.levelName=getLevelName(options.level);}get args(){return[...this.#args];}get datetime(){return new Date(this.#datetime.getTime());}}class Logger{#level;#handlers;#loggerName;constructor(loggerName,levelName,options={}){this.#loggerName=loggerName;this.#level=getLevelByName(levelName);this.#handlers=options.handlers||[];}get level(){return this.#level;}set level(level){try{this.#level=getLevelByName(getLevelName(level));}catch(_){throw new TypeError(`Invalid log level: ${level}`);}}get levelName(){return getLevelName(this.#level);}set levelName(levelName){this.#level=getLevelByName(levelName);}get loggerName(){return this.#loggerName;}set handlers(hndls){this.#handlers=hndls;}get handlers(){return this.#handlers;}#_log(level,msg,...args){if(this.level>level){return msg instanceof Function?undefined:msg;}let fnResult;let logMessage;if(msg instanceof Function){fnResult=msg();logMessage=this.asString(fnResult);}else{logMessage=this.asString(msg);}const record=new LogRecord({msg:logMessage,args:args,level:level,loggerName:this.loggerName});this.#handlers.forEach(handler=>{handler.handle(record);});return msg instanceof Function?fnResult:msg;}asString(data,isProperty=false){if(typeof data==="string"){if(isProperty)return`"${data}"`;return data;}else if(data===null||typeof data==="number"||typeof data==="bigint"||typeof data==="boolean"||typeof data==="undefined"||typeof data==="symbol"){return String(data);}else if(data instanceof Error){return data.stack;}else if(typeof data==="object"){return`{${Object.entries(data).map(([k,v])=>`"${k}":${this.asString(v,true)}`).join(",")}}`;}return"undefined";}debug(msg,...args){return this.#_log(LogLevels.DEBUG,msg,...args);}info(msg,...args){return this.#_log(LogLevels.INFO,msg,...args);}warning(msg,...args){return this.#_log(LogLevels.WARNING,msg,...args);}error(msg,...args){return this.#_log(LogLevels.ERROR,msg,...args);}critical(msg,...args){return this.#_log(LogLevels.CRITICAL,msg,...args);}}const{Deno:Deno1}=globalThis;const noColor=typeof Deno1?.noColor==="boolean"?Deno1.noColor:false;let enabled=!noColor;function code(open,close){return{open:`\x1b[${open.join(";")}m`,close:`\x1b[${close}m`,regexp:new RegExp(`\\x1b\\[${close}m`,"g")};}function run(str,code){return enabled?`${code.open}${str.replace(code.regexp,code.open)}${code.close}`:str;}function bold(str){return run(str,code([1],22));}function red(str){return run(str,code([31],39));}function yellow(str){return run(str,code([33],39));}function blue(str){return run(str,code([34],39));}new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"),"g");function copy(src,dst,off=0){off=Math.max(0,Math.min(off,dst.byteLength));const dstBytesAvailable=dst.byteLength-off;if(src.byteLength>dstBytesAvailable){src=src.subarray(0,dstBytesAvailable);}dst.set(src,off);return src.byteLength;}class AbstractBufBase{buf;usedBufferBytes=0;err=null;constructor(buf){this.buf=buf;}size(){return this.buf.byteLength;}available(){return this.buf.byteLength-this.usedBufferBytes;}buffered(){return this.usedBufferBytes;}}class BufWriterSync extends AbstractBufBase{#writer;static create(writer,size=4096){return writer instanceof BufWriterSync?writer:new BufWriterSync(writer,size);}constructor(writer,size=4096){super(new Uint8Array(size<=0?4096:size));this.#writer=writer;}reset(w){this.err=null;this.usedBufferBytes=0;this.#writer=w;}flush(){if(this.err!==null)throw this.err;if(this.usedBufferBytes===0)return;try{const p=this.buf.subarray(0,this.usedBufferBytes);let nwritten=0;while(nwrittenthis.available()){if(this.buffered()===0){try{numBytesWritten=this.#writer.writeSync(data);}catch(e){if(e instanceof Error){this.err=e;}throw e;}}else{numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;this.flush();}totalBytesWritten+=numBytesWritten;data=data.subarray(numBytesWritten);}numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;totalBytesWritten+=numBytesWritten;return totalBytesWritten;}}const DEFAULT_FORMATTER="{levelName} {msg}";class BaseHandler{level;levelName;formatter;constructor(levelName,options={}){this.level=getLevelByName(levelName);this.levelName=levelName;this.formatter=options.formatter||DEFAULT_FORMATTER;}handle(logRecord){if(this.level>logRecord.level)return;const msg=this.format(logRecord);this.log(msg);}format(logRecord){if(this.formatter instanceof Function){return this.formatter(logRecord);}return this.formatter.replace(/{([^\s}]+)}/g,(match,p1)=>{const value=logRecord[p1];if(value===undefined){return match;}return String(value);});}log(_msg){}setup(){}destroy(){}}class ConsoleHandler extends BaseHandler{#useColors;constructor(levelName,options={}){super(levelName,options);this.#useColors=options.useColors??true;}format(logRecord){let msg=super.format(logRecord);if(this.#useColors){msg=this.applyColors(msg,logRecord.level);}return msg;}applyColors(msg,level){switch(level){case LogLevels.INFO:msg=blue(msg);break;case LogLevels.WARNING:msg=yellow(msg);break;case LogLevels.ERROR:msg=red(msg);break;case LogLevels.CRITICAL:msg=bold(red(msg));break;default:break;}return msg;}log(msg){console.log(msg);}}class WriterHandler extends BaseHandler{_writer;#encoder=new TextEncoder;}class FileHandler extends WriterHandler{_file;_buf;_filename;_mode;_openOptions;_encoder=new TextEncoder;#unloadCallback=(()=>{this.destroy();}).bind(this);constructor(levelName,options){super(levelName,options);this._filename=options.filename;this._mode=options.mode?options.mode:"a";this._openOptions={createNew:this._mode==="x",create:this._mode!=="x",append:this._mode==="a",truncate:this._mode!=="a",write:true};}setup(){this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);addEventListener("unload",this.#unloadCallback);}handle(logRecord){super.handle(logRecord);if(logRecord.level>LogLevels.ERROR){this.flush();}}log(msg){if(this._encoder.encode(msg).byteLength+1>this._buf.available()){this.flush();}this._buf.writeSync(this._encoder.encode(msg+"\n"));}flush(){if(this._buf?.buffered()>0){this._buf.flush();}}destroy(){this.flush();this._file?.close();this._file=undefined;removeEventListener("unload",this.#unloadCallback);}}class RotatingFileHandler extends FileHandler{#maxBytes;#maxBackupCount;#currentFileSize=0;constructor(levelName,options){super(levelName,options);this.#maxBytes=options.maxBytes;this.#maxBackupCount=options.maxBackupCount;}setup(){if(this.#maxBytes<1){this.destroy();throw new Error("maxBytes cannot be less than 1");}if(this.#maxBackupCount<1){this.destroy();throw new Error("maxBackupCount cannot be less than 1");}super.setup();if(this._mode==="w"){for(let i=1;i<=this.#maxBackupCount;i++){try{Deno.removeSync(this._filename+"."+i);}catch(error){if(!(error instanceof Deno.errors.NotFound)){throw error;}}}}else if(this._mode==="x"){for(let i=1;i<=this.#maxBackupCount;i++){if(existsSync(this._filename+"."+i)){this.destroy();throw new Deno.errors.AlreadyExists("Backup log file "+this._filename+"."+i+" already exists");}}}else{this.#currentFileSize=Deno.statSync(this._filename).size;}}log(msg){const msgByteLength=this._encoder.encode(msg).byteLength+1;if(this.#currentFileSize+msgByteLength>this.#maxBytes){this.rotateLogFiles();this.#currentFileSize=0;}super.log(msg);this.#currentFileSize+=msgByteLength;}rotateLogFiles(){this._buf.flush();this._file.close();for(let i=this.#maxBackupCount-1;i>=0;i--){const source=this._filename+(i===0?"":"."+i);const dest=this._filename+"."+(i+1);if(existsSync(source)){Deno.renameSync(source,dest);}}this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);}}const DEFAULT_LEVEL="INFO";const DEFAULT_CONFIG={handlers:{default:new ConsoleHandler(DEFAULT_LEVEL)},loggers:{default:{level:DEFAULT_LEVEL,handlers:["default"]}}};const state={handlers:new Map,loggers:new Map,config:DEFAULT_CONFIG};const handlers={BaseHandler,ConsoleHandler,WriterHandler,FileHandler,RotatingFileHandler};function getLogger(name){if(!name){const d=state.loggers.get("default");assert(d!==undefined,`"default" logger must be set for getting logger without name`);return d;}const result=state.loggers.get(name);if(!result){const logger=new Logger(name,"NOTSET",{handlers:[]});state.loggers.set(name,logger);return logger;}return result;}function debug(msg,...args){if(msg instanceof Function){return getLogger("default").debug(msg,...args);}return getLogger("default").debug(msg,...args);}function info(msg,...args){if(msg instanceof Function){return getLogger("default").info(msg,...args);}return getLogger("default").info(msg,...args);}function warning(msg,...args){if(msg instanceof Function){return getLogger("default").warning(msg,...args);}return getLogger("default").warning(msg,...args);}function error(msg,...args){if(msg instanceof Function){return getLogger("default").error(msg,...args);}return getLogger("default").error(msg,...args);}function setup(config){state.config={handlers:{...DEFAULT_CONFIG.handlers,...config.handlers},loggers:{...DEFAULT_CONFIG.loggers,...config.loggers}};state.handlers.forEach(handler=>{handler.destroy();});state.handlers.clear();const handlers=state.config.handlers||{};for(const handlerName in handlers){const handler=handlers[handlerName];handler.setup();state.handlers.set(handlerName,handler);}state.loggers.clear();const loggers=state.config.loggers||{};for(const loggerName in loggers){const loggerConfig=loggers[loggerName];const handlerNames=loggerConfig.handlers||[];const handlers=[];handlerNames.forEach(handlerName=>{const handler=state.handlers.get(handlerName);if(handler){handlers.push(handler);}});const levelName=loggerConfig.level||DEFAULT_LEVEL;const logger=new Logger(loggerName,levelName,{handlers:handlers});state.loggers.set(loggerName,logger);}}setup(DEFAULT_CONFIG);function assertArgs1(from,to){assertPath(from);assertPath(to);if(from===to)return"";}function relative(from,to){assertArgs1(from,to);from=resolve(from);to=resolve(to);if(from===to)return"";let fromStart=1;const fromEnd=from.length;for(;fromStartlength){if(isPosixPathSeparator(to.charCodeAt(toStart+i))){return to.slice(toStart+i+1);}else if(i===0){return to.slice(toStart+i);}}else if(fromLen>length){if(isPosixPathSeparator(from.charCodeAt(fromStart+i))){lastCommonSep=i;}else if(i===0){lastCommonSep=0;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(isPosixPathSeparator(fromCode))lastCommonSep=i;}let out="";for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||isPosixPathSeparator(from.charCodeAt(i))){if(out.length===0)out+="..";else out+="/..";}}if(out.length>0)return out+to.slice(toStart+lastCommonSep);else{toStart+=lastCommonSep;if(isPosixPathSeparator(to.charCodeAt(toStart)))++toStart;return to.slice(toStart);}}function relative1(from,to){assertArgs1(from,to);const fromOrig=resolve1(from);const toOrig=resolve1(to);if(fromOrig===toOrig)return"";from=fromOrig.toLowerCase();to=toOrig.toLowerCase();if(from===to)return"";let fromStart=0;let fromEnd=from.length;for(;fromStartfromStart;--fromEnd){if(from.charCodeAt(fromEnd-1)!==92)break;}const fromLen=fromEnd-fromStart;let toStart=0;let toEnd=to.length;for(;toStarttoStart;--toEnd){if(to.charCodeAt(toEnd-1)!==92)break;}const toLen=toEnd-toStart;const length=fromLenlength){if(to.charCodeAt(toStart+i)===92){return toOrig.slice(toStart+i+1);}else if(i===2){return toOrig.slice(toStart+i);}}if(fromLen>length){if(from.charCodeAt(fromStart+i)===92){lastCommonSep=i;}else if(i===2){lastCommonSep=3;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(fromCode===92)lastCommonSep=i;}if(i!==length&&lastCommonSep===-1){return toOrig;}let out="";if(lastCommonSep===-1)lastCommonSep=0;for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||from.charCodeAt(i)===92){if(out.length===0)out+="..";else out+="\\..";}}if(out.length>0){return out+toOrig.slice(toStart+lastCommonSep,toEnd);}else{toStart+=lastCommonSep;if(toOrig.charCodeAt(toStart)===92)++toStart;return toOrig.slice(toStart,toEnd);}}function relative2(from,to){return isWindows?relative1(from,to):relative(from,to);}var m=Object.create;var E=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),D=(t,e)=>{for(var s in e)E(t,s,{get:e[s],enumerable:!0});},a=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!b.call(t,n)&&n!==s&&E(t,n,{get:()=>e[n],enumerable:!(r=T(e,n))||r.enumerable});return t;},_=(t,e,s)=>(a(t,e,"default"),s&&a(s,e,"default")),$=(t,e,s)=>(s=t!=null?m(X(t)):{},a(e||!t||!t.__esModule?E(s,"default",{value:t,enumerable:!0}):s,t));var A=w((ct,v)=>{function C(t){return Array.isArray(t)?t:[t];}var N="",P=" ",h="\\",H=/^\s+$/,F=/(?:[^\\]|^)\\$/,k=/^\\!/,z=/^\\#/,B=/\r?\n/g,K=/^\.*\/|^\.+$/,d="/",x="node-ignore";typeof Symbol<"u"&&(x=Symbol.for("node-ignore"));var L=x,V=(t,e,s)=>Object.defineProperty(t,e,{value:s}),j=/([0-z])-([0-z])/g,G=()=>!1,M=t=>t.replace(j,(e,s,r)=>s.charCodeAt(0)<=r.charCodeAt(0)?e:N),Y=t=>{let{length:e}=t;return t.slice(0,e-e%2);},W=[[/\\?\s+$/,t=>t.indexOf("\\")===0?P:N],[/\\\s/g,()=>P],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)";}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,s)=>e+6{let r=s.replace(/\\\*/g,"[^\\/]*");return e+r;}],[/\\\\\\(?=[$.|*+(){^])/g,()=>h],[/\\\\/g,()=>h],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,s,r,n)=>e===h?`\\[${s}${Y(r)}${n}`:n==="]"&&r.length%2===0?`[${M(s)}${r}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],S=Object.create(null),p=(t,e)=>{let s=S[t];return s||(s=W.reduce((r,n)=>r.replace(n[0],n[1].bind(t)),t),S[t]=s),e?new RegExp(s,"i"):new RegExp(s);},R=t=>typeof t=="string",q=t=>t&&R(t)&&!H.test(t)&&!F.test(t)&&t.indexOf("#")!==0,J=t=>t.split(B),f=class{constructor(e,s,r,n){this.origin=e,this.pattern=s,this.negative=r,this.regex=n;}},Q=(t,e)=>{let s=t,r=!1;t.indexOf("!")===0&&(r=!0,t=t.substr(1)),t=t.replace(k,"!").replace(z,"#");let n=p(t,e);return new f(s,t,r,n);},U=(t,e)=>{throw new e(t);},i=(t,e,s)=>R(t)?t?i.isNotRelative(t)?s(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:s("path must not be empty",TypeError):s(`path must be a string, but got \`${e}\``,TypeError),O=t=>K.test(t);i.isNotRelative=O;i.convert=t=>t;var g=class{constructor({ignorecase:e=!0,ignoreCase:s=e,allowRelativePaths:r=!1}={}){V(this,L,!0),this._rules=[],this._ignoreCase=s,this._allowRelativePaths=r,this._initCache();}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null);}_addPattern(e){if(e&&e[L]){this._rules=this._rules.concat(e._rules),this._added=!0;return;}if(q(e)){let s=Q(e,this._ignoreCase);this._added=!0,this._rules.push(s);}}add(e){return this._added=!1,C(R(e)?J(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this;}addPattern(e){return this.add(e);}_testOne(e,s){let r=!1,n=!1;return this._rules.forEach(o=>{let{negative:u}=o;if(n===u&&r!==n||u&&!r&&!n&&!s)return;o.regex.test(e)&&(r=!u,n=u);}),{ignored:r,unignored:n};}_test(e,s,r,n){let o=e&&i.convert(e);return i(o,e,this._allowRelativePaths?G:U),this._t(o,s,r,n);}_t(e,s,r,n){if(e in s)return s[e];if(n||(n=e.split(d)),n.pop(),!n.length)return s[e]=this._testOne(e,r);let o=this._t(n.join(d)+d,s,r,n);return s[e]=o.ignored?o:this._testOne(e,r);}ignores(e){return this._test(e,this._ignoreCache,!1).ignored;}createFilter(){return e=>!this.ignores(e);}filter(e){return C(e).filter(this.createFilter());}test(e){return this._test(e,this._testCache,!0);}},l=t=>new g(t),Z=t=>i(t&&i.convert(t),t,G);l.isPathValid=Z;l.default=l;v.exports=l;var tt=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");i.convert=tt;var et=/^[a-z]:\//i;i.isNotRelative=t=>et.test(t)||O(t);});var c={};D(c,{default:()=>nt});var st=$(A());_(c,$(A()));var{default:I,...rt}=st,nt=I!==void 0?I:rt;const importMeta={url:"file:///Users/winston/Code/winston/setup-deno/cache.ts",main:import.meta.main};const args=parseArgs(Deno.args,{boolean:["help","dry-run","debug"],string:["config"],alias:{help:"h",dryRun:"n"},"--":true});const logLevel=args.debug?"DEBUG":"INFO";setup({handlers:{console:new handlers.ConsoleHandler(logLevel,{formatter:logRecord=>Deno.noColor?[logRecord.levelName,logRecord.msg].join(" "):logRecord.msg})},loggers:{default:{handlers:["console"],"level":logLevel}}});const main=async args=>{if(args.help){console.log("Usage: cache [-n | --dry-run] [--debug] [--] [DENO_ARGS...]");Deno.exit(0);}if(args["dry-run"])warning("dry-run mode enabled");if(args.config&&!await exists(args.config)){error(`config file ${args.config} not found`);Deno.exit(1);}const hash=await Deno.readFile("./deno.lock").then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>encodeHex(new Uint8Array(data))).catch(_=>"");debug(`GitHub actions deno.lock hash: ${hash}`);const cfgs=args.config?[args.config]:["deno.json","deno.jsonc"];const denoCfg=await Promise.all(cfgs.map(path=>Deno.readTextFile(path).catch(_=>undefined))).then(v=>parse(v.filter(Boolean)[0]??"{}"));const patterns=[...[denoCfg?.exclude??[]].flat(),...[denoCfg?.cache?.exclude??[]].flat(),...[denoCfg?.cache?.include??[]].flatMap(p=>`!${p}`)];debug(`patterns:`,patterns);patterns.forEach(p=>debug(`- ${p}`));const ig=nt().add(patterns);const walkIterator=walk(".",{exts:["js",".jsx",".ts",".tsx"],includeDirs:false});for await(const entry of walkIterator){const relativePath=relative2(".",entry.path);if(ig.ignores(relativePath)){debug(`ignored ${relativePath}`);continue;}debug(`caching ${relativePath}`);const cmd=new Deno.Command(Deno.execPath(),{args:["cache",args.config&&`--config=${args.config}`,relativePath,...args["--"]].filter(Boolean),stdout:"inherit",stderr:"inherit"});let code=0;if(!args["dry-run"])code=(await cmd.output()).code;if(code===0){info(`cached ${relativePath}`);}else{error(`failed to cache ${entry.path}`);}}};if(importMeta.main)main(args); \ No newline at end of file +class AssertionError extends Error{constructor(message){super(message);this.name="AssertionError";}}function assert(expr,msg=""){if(!expr){throw new AssertionError(msg);}}const{hasOwn}=Object;function get(obj,key){if(hasOwn(obj,key)){return obj[key];}}function getForce(obj,key){const v=get(obj,key);assert(v!==undefined);return v;}function isNumber(x){if(typeof x==="number")return true;if(/^0x[0-9a-f]+$/i.test(String(x)))return true;return/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(String(x));}function hasKey(obj,keys){let o=obj;keys.slice(0,-1).forEach(key=>{o=get(o,key)??{};});const key=keys[keys.length-1];return hasOwn(o,key);}function parseArgs(args,{"--":doubleDash=false,alias={},boolean:__boolean=false,default:defaults={},stopEarly=false,string=[],collect=[],negatable=[],unknown=i=>i}={}){const aliases={};const flags={bools:{},strings:{},unknownFn:unknown,allBools:false,collect:{},negatable:{}};if(alias!==undefined){for(const key in alias){const val=getForce(alias,key);if(typeof val==="string"){aliases[key]=[val];}else{aliases[key]=val;}for(const alias of getForce(aliases,key)){aliases[alias]=[key].concat(aliases[key].filter(y=>alias!==y));}}}if(__boolean!==undefined){if(typeof __boolean==="boolean"){flags.allBools=!!__boolean;}else{const booleanArgs=typeof __boolean==="string"?[__boolean]:__boolean;for(const key of booleanArgs.filter(Boolean)){flags.bools[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.bools[al]=true;}}}}}if(string!==undefined){const stringArgs=typeof string==="string"?[string]:string;for(const key of stringArgs.filter(Boolean)){flags.strings[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.strings[al]=true;}}}}if(collect!==undefined){const collectArgs=typeof collect==="string"?[collect]:collect;for(const key of collectArgs.filter(Boolean)){flags.collect[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.collect[al]=true;}}}}if(negatable!==undefined){const negatableArgs=typeof negatable==="string"?[negatable]:negatable;for(const key of negatableArgs.filter(Boolean)){flags.negatable[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.negatable[al]=true;}}}}const argv={_:[]};function argDefined(key,arg){return flags.allBools&&/^--[^=]+$/.test(arg)||get(flags.bools,key)||!!get(flags.strings,key)||!!get(aliases,key);}function setKey(obj,name,value,collect=true){let o=obj;const keys=name.split(".");keys.slice(0,-1).forEach(function(key){if(get(o,key)===undefined){o[key]={};}o=get(o,key);});const key=keys[keys.length-1];const collectable=collect&&!!get(flags.collect,name);if(!collectable){o[key]=value;}else if(get(o,key)===undefined){o[key]=[value];}else if(Array.isArray(get(o,key))){o[key].push(value);}else{o[key]=[get(o,key),value];}}function setArg(key,val,arg=undefined,collect){if(arg&&flags.unknownFn&&!argDefined(key,arg)){if(flags.unknownFn(arg,key,val)===false)return;}const value=!get(flags.strings,key)&&isNumber(val)?Number(val):val;setKey(argv,key,value,collect);const alias=get(aliases,key);if(alias){for(const x of alias){setKey(argv,x,value,collect);}}}function aliasIsBoolean(key){return getForce(aliases,key).some(x=>typeof get(flags.bools,x)==="boolean");}let notFlags=[];if(args.includes("--")){notFlags=args.slice(args.indexOf("--")+1);args=args.slice(0,args.indexOf("--"));}for(let i=0;i>4];dst[i*2+1]=hexTable[v&15];}return textDecoder.decode(dst);}const osType=(()=>{const{Deno:Deno1}=globalThis;if(typeof Deno1?.build?.os==="string"){return Deno1.build.os;}const{navigator}=globalThis;if(navigator?.appVersion?.includes?.("Win")){return"windows";}return"linux";})();const isWindows=osType==="windows";function assertPath(path){if(typeof path!=="string"){throw new TypeError(`Path must be a string. Received ${JSON.stringify(path)}`);}}function assertArg(path){assertPath(path);if(path.length===0)return".";}const CHAR_FORWARD_SLASH=47;function normalizeString(path,allowAboveRoot,separator,isPathSeparator){let res="";let lastSegmentLength=0;let lastSlash=-1;let dots=0;let code;for(let i=0,len=path.length;i<=len;++i){if(i2){const lastSlashIndex=res.lastIndexOf(separator);if(lastSlashIndex===-1){res="";lastSegmentLength=0;}else{res=res.slice(0,lastSlashIndex);lastSegmentLength=res.length-1-res.lastIndexOf(separator);}lastSlash=i;dots=0;continue;}else if(res.length===2||res.length===1){res="";lastSegmentLength=0;lastSlash=i;dots=0;continue;}}if(allowAboveRoot){if(res.length>0)res+=`${separator}..`;else res="..";lastSegmentLength=2;}}else{if(res.length>0)res+=separator+path.slice(lastSlash+1,i);else res=path.slice(lastSlash+1,i);lastSegmentLength=i-lastSlash-1;}lastSlash=i;dots=0;}else if(code===46&&dots!==-1){++dots;}else{dots=-1;}}return res;}function isPosixPathSeparator(code){return code===47;}function normalize(path){assertArg(path);const isAbsolute=isPosixPathSeparator(path.charCodeAt(0));const trailingSeparator=isPosixPathSeparator(path.charCodeAt(path.length-1));path=normalizeString(path,!isAbsolute,"/",isPosixPathSeparator);if(path.length===0&&!isAbsolute)path=".";if(path.length>0&&trailingSeparator)path+="/";if(isAbsolute)return`/${path}`;return path;}function join(...paths){if(paths.length===0)return".";let joined;for(let i=0,len=paths.length;i0){if(!joined)joined=path;else joined+=`/${path}`;}}if(!joined)return".";return normalize(joined);}function isPathSeparator(code){return code===47||code===92;}function isWindowsDeviceRoot(code){return code>=97&&code<=122||code>=65&&code<=90;}function normalize1(path){assertArg(path);const len=path.length;let rootEnd=0;let device;let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){return"\\";}let tail;if(rootEnd0&&isPathSeparator(path.charCodeAt(len-1))){tail+="\\";}if(device===undefined){if(isAbsolute){if(tail.length>0)return`\\${tail}`;else return"\\";}else if(tail.length>0){return tail;}else{return"";}}else if(isAbsolute){if(tail.length>0)return`${device}\\${tail}`;else return`${device}\\`;}else if(tail.length>0){return device+tail;}else{return device;}}function join1(...paths){if(paths.length===0)return".";let joined;let firstPart=null;for(let i=0;i0){if(joined===undefined)joined=firstPart=path;else joined+=`\\${path}`;}}if(joined===undefined)return".";let needsReplace=true;let slashCount=0;assert(firstPart!==null);if(isPathSeparator(firstPart.charCodeAt(0))){++slashCount;const firstLen=firstPart.length;if(firstLen>1){if(isPathSeparator(firstPart.charCodeAt(1))){++slashCount;if(firstLen>2){if(isPathSeparator(firstPart.charCodeAt(2)))++slashCount;else{needsReplace=false;}}}}}if(needsReplace){for(;slashCount=2)joined=`\\${joined.slice(slashCount)}`;}return normalize1(joined);}function join2(...paths){return isWindows?join1(...paths):join(...paths);}function assertArg1(url){url=url instanceof URL?url:new URL(url);if(url.protocol!=="file:"){throw new TypeError("Must be a file URL.");}return url;}function fromFileUrl(url){url=assertArg1(url);return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"));}function fromFileUrl1(url){url=assertArg1(url);let path=decodeURIComponent(url.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");if(url.hostname!==""){path=`\\\\${url.hostname}${path}`;}return path;}function fromFileUrl2(url){return isWindows?fromFileUrl1(url):fromFileUrl(url);}function toPathString(pathUrl){return pathUrl instanceof URL?fromFileUrl2(pathUrl):pathUrl;}function stripTrailingSeparators(segment,isSep){if(segment.length<=1){return segment;}let end=segment.length;for(let i=segment.length-1;i>0;i--){if(isSep(segment.charCodeAt(i))){end=i;}else{break;}}return segment.slice(0,end);}function resolve(...pathSegments){let resolvedPath="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1&&!resolvedAbsolute;i--){let path;if(i>=0)path=pathSegments[i];else{const{Deno:Deno1}=globalThis;if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();}assertPath(path);if(path.length===0){continue;}resolvedPath=`${path}/${resolvedPath}`;resolvedAbsolute=isPosixPathSeparator(path.charCodeAt(0));}resolvedPath=normalizeString(resolvedPath,!resolvedAbsolute,"/",isPosixPathSeparator);if(resolvedAbsolute){if(resolvedPath.length>0)return`/${resolvedPath}`;else return"/";}else if(resolvedPath.length>0)return resolvedPath;else return".";}function resolve1(...pathSegments){let resolvedDevice="";let resolvedTail="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1;i--){let path;const{Deno:Deno1}=globalThis;if(i>=0){path=pathSegments[i];}else if(!resolvedDevice){if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a drive-letter-less path without a CWD.");}path=Deno1.cwd();}else{if(typeof Deno1?.env?.get!=="function"||typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();if(path===undefined||path.slice(0,3).toLowerCase()!==`${resolvedDevice.toLowerCase()}\\`){path=`${resolvedDevice}\\`;}}assertPath(path);const len=path.length;if(len===0)continue;let rootEnd=0;let device="";let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){rootEnd=1;isAbsolute=true;}if(device.length>0&&resolvedDevice.length>0&&device.toLowerCase()!==resolvedDevice.toLowerCase()){continue;}if(resolvedDevice.length===0&&device.length>0){resolvedDevice=device;}if(!resolvedAbsolute){resolvedTail=`${path.slice(rootEnd)}\\${resolvedTail}`;resolvedAbsolute=isAbsolute;}if(resolvedAbsolute&&resolvedDevice.length>0)break;}resolvedTail=normalizeString(resolvedTail,!resolvedAbsolute,"\\",isPathSeparator);return resolvedDevice+(resolvedAbsolute?"\\":"")+resolvedTail||".";}Deno.build.os==="windows";async function exists(path,options){try{const stat=await Deno.stat(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if((await Deno.permissions.query({name:"read",path})).state==="granted"){return!options?.isReadable;}}throw error;}}function existsSync(path,options){try{const stat=Deno.statSync(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if(Deno.permissions.querySync({name:"read",path}).state==="granted"){return!options?.isReadable;}}throw error;}}function normalize2(path){return isWindows?normalize1(path):normalize(path);}function stripSuffix(name,suffix){if(suffix.length>=name.length){return name;}const lenDiff=name.length-suffix.length;for(let i=suffix.length-1;i>=0;--i){if(name.charCodeAt(lenDiff+i)!==suffix.charCodeAt(i)){return name;}}return name.slice(0,-suffix.length);}function lastPathSegment(path,isSep,start=0){let matchedNonSeparator=false;let end=path.length;for(let i=path.length-1;i>=start;--i){if(isSep(path.charCodeAt(i))){if(matchedNonSeparator){start=i+1;break;}}else if(!matchedNonSeparator){matchedNonSeparator=true;end=i+1;}}return path.slice(start,end);}function assertArgs(path,suffix){assertPath(path);if(path.length===0)return path;if(typeof suffix!=="string"){throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);}}function basename(path,suffix=""){assertArgs(path,suffix);const lastSegment=lastPathSegment(path,isPosixPathSeparator);const strippedSegment=stripTrailingSeparators(lastSegment,isPosixPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename1(path,suffix=""){assertArgs(path,suffix);let start=0;if(path.length>=2){const drive=path.charCodeAt(0);if(isWindowsDeviceRoot(drive)){if(path.charCodeAt(1)===58)start=2;}}const lastSegment=lastPathSegment(path,isPathSeparator,start);const strippedSegment=stripTrailingSeparators(lastSegment,isPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename2(path,suffix=""){return isWindows?basename1(path,suffix):basename(path,suffix);}async function createWalkEntry(path){path=toPathString(path);path=normalize2(path);const name=basename2(path);const info=await Deno.stat(path);return{path,name,isFile:info.isFile,isDirectory:info.isDirectory,isSymlink:info.isSymlink};}class WalkError extends Error{root;constructor(cause,root){super(`${cause instanceof Error?cause.message:cause} for path "${root}"`);this.cause=cause;this.name="WalkError";this.root=root;}}function include(path,exts,match,skip){if(exts&&!exts.some(ext=>path.endsWith(ext))){return false;}if(match&&!match.some(pattern=>!!path.match(pattern))){return false;}if(skip&&skip.some(pattern=>!!path.match(pattern))){return false;}return true;}function wrapErrorWithPath(err,root){if(err instanceof WalkError)return err;return new WalkError(err,root);}async function*walk(root,{maxDepth=Infinity,includeFiles=true,includeDirs=true,includeSymlinks=true,followSymlinks=false,canonicalize=true,exts=undefined,match=undefined,skip=undefined}={}){if(maxDepth<0){return;}root=toPathString(root);if(includeDirs&&include(root,exts,match,skip)){yield await createWalkEntry(root);}if(maxDepth<1||!include(root,undefined,undefined,skip)){return;}try{for await(const entry of Deno.readDir(root)){let path=join2(root,entry.name);let{isSymlink,isDirectory}=entry;if(isSymlink){if(!followSymlinks){if(includeSymlinks&&include(path,exts,match,skip)){yield{path,...entry};}continue;}const realPath=await Deno.realPath(path);if(canonicalize){path=realPath;}({isSymlink,isDirectory}=await Deno.lstat(realPath));}if(isSymlink||isDirectory){yield*walk(path,{maxDepth:maxDepth-1,includeFiles,includeDirs,includeSymlinks,followSymlinks,exts,match,skip});}else if(includeFiles&&include(path,exts,match,skip)){yield{path,...entry};}}}catch(err){throw wrapErrorWithPath(err,normalize2(root));}}Deno.build.os==="windows";new Deno.errors.AlreadyExists("dest already exists.");Deno.build.os==="windows";const LF="\n";const CRLF="\r\n";Deno?.build.os==="windows"?CRLF:LF;function parse(text,{allowTrailingComma=true}={}){if(new.target){throw new TypeError("parse is not a constructor");}return new JSONCParser(text,{allowTrailingComma}).parse();}const originalJSONParse=globalThis.JSON.parse;class JSONCParser{#whitespace=new Set(" \r\n");#numberEndToken=new Set([..."[]{}:,/",...this.#whitespace]);#text;#length;#tokenized;#options;constructor(text,options){this.#text=`${text}`;this.#length=this.#text.length;this.#tokenized=this.#tokenize();this.#options=options;}parse(){const token=this.#getNext();const res=this.#parseJsonValue(token);const{done,value}=this.#tokenized.next();if(!done){throw new SyntaxError(buildErrorMessage(value));}return res;}#getNext(){const{done,value}=this.#tokenized.next();if(done){throw new SyntaxError("Unexpected end of JSONC input");}return value;}*#tokenize(){for(let i=0;iisNaN(Number(key)));const byLevel={[LogLevels.NOTSET]:"NOTSET",[LogLevels.DEBUG]:"DEBUG",[LogLevels.INFO]:"INFO",[LogLevels.WARNING]:"WARNING",[LogLevels.ERROR]:"ERROR",[LogLevels.CRITICAL]:"CRITICAL"};function getLevelByName(name){const level=LogLevels[name];if(level!==undefined){return level;}throw new Error(`no log level found for name: ${name}`);}function getLevelName(level){const levelName=byLevel[level];if(levelName){return levelName;}throw new Error(`no level name found for level: ${level}`);}class LogRecord{msg;#args;#datetime;level;levelName;loggerName;constructor(options){this.msg=options.msg;this.#args=[...options.args];this.level=options.level;this.loggerName=options.loggerName;this.#datetime=new Date;this.levelName=getLevelName(options.level);}get args(){return[...this.#args];}get datetime(){return new Date(this.#datetime.getTime());}}class Logger{#level;#handlers;#loggerName;constructor(loggerName,levelName,options={}){this.#loggerName=loggerName;this.#level=getLevelByName(levelName);this.#handlers=options.handlers||[];}get level(){return this.#level;}set level(level){try{this.#level=getLevelByName(getLevelName(level));}catch(_){throw new TypeError(`Invalid log level: ${level}`);}}get levelName(){return getLevelName(this.#level);}set levelName(levelName){this.#level=getLevelByName(levelName);}get loggerName(){return this.#loggerName;}set handlers(hndls){this.#handlers=hndls;}get handlers(){return this.#handlers;}#_log(level,msg,...args){if(this.level>level){return msg instanceof Function?undefined:msg;}let fnResult;let logMessage;if(msg instanceof Function){fnResult=msg();logMessage=this.asString(fnResult);}else{logMessage=this.asString(msg);}const record=new LogRecord({msg:logMessage,args:args,level:level,loggerName:this.loggerName});this.#handlers.forEach(handler=>{handler.handle(record);});return msg instanceof Function?fnResult:msg;}asString(data,isProperty=false){if(typeof data==="string"){if(isProperty)return`"${data}"`;return data;}else if(data===null||typeof data==="number"||typeof data==="bigint"||typeof data==="boolean"||typeof data==="undefined"||typeof data==="symbol"){return String(data);}else if(data instanceof Error){return data.stack;}else if(typeof data==="object"){return`{${Object.entries(data).map(([k,v])=>`"${k}":${this.asString(v,true)}`).join(",")}}`;}return"undefined";}debug(msg,...args){return this.#_log(LogLevels.DEBUG,msg,...args);}info(msg,...args){return this.#_log(LogLevels.INFO,msg,...args);}warning(msg,...args){return this.#_log(LogLevels.WARNING,msg,...args);}error(msg,...args){return this.#_log(LogLevels.ERROR,msg,...args);}critical(msg,...args){return this.#_log(LogLevels.CRITICAL,msg,...args);}}const{Deno:Deno1}=globalThis;const noColor=typeof Deno1?.noColor==="boolean"?Deno1.noColor:false;let enabled=!noColor;function code(open,close){return{open:`\x1b[${open.join(";")}m`,close:`\x1b[${close}m`,regexp:new RegExp(`\\x1b\\[${close}m`,"g")};}function run(str,code){return enabled?`${code.open}${str.replace(code.regexp,code.open)}${code.close}`:str;}function bold(str){return run(str,code([1],22));}function red(str){return run(str,code([31],39));}function yellow(str){return run(str,code([33],39));}function blue(str){return run(str,code([34],39));}new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"),"g");function copy(src,dst,off=0){off=Math.max(0,Math.min(off,dst.byteLength));const dstBytesAvailable=dst.byteLength-off;if(src.byteLength>dstBytesAvailable){src=src.subarray(0,dstBytesAvailable);}dst.set(src,off);return src.byteLength;}class AbstractBufBase{buf;usedBufferBytes=0;err=null;constructor(buf){this.buf=buf;}size(){return this.buf.byteLength;}available(){return this.buf.byteLength-this.usedBufferBytes;}buffered(){return this.usedBufferBytes;}}class BufWriterSync extends AbstractBufBase{#writer;static create(writer,size=4096){return writer instanceof BufWriterSync?writer:new BufWriterSync(writer,size);}constructor(writer,size=4096){super(new Uint8Array(size<=0?4096:size));this.#writer=writer;}reset(w){this.err=null;this.usedBufferBytes=0;this.#writer=w;}flush(){if(this.err!==null)throw this.err;if(this.usedBufferBytes===0)return;try{const p=this.buf.subarray(0,this.usedBufferBytes);let nwritten=0;while(nwrittenthis.available()){if(this.buffered()===0){try{numBytesWritten=this.#writer.writeSync(data);}catch(e){if(e instanceof Error){this.err=e;}throw e;}}else{numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;this.flush();}totalBytesWritten+=numBytesWritten;data=data.subarray(numBytesWritten);}numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;totalBytesWritten+=numBytesWritten;return totalBytesWritten;}}const DEFAULT_FORMATTER="{levelName} {msg}";class BaseHandler{level;levelName;formatter;constructor(levelName,options={}){this.level=getLevelByName(levelName);this.levelName=levelName;this.formatter=options.formatter||DEFAULT_FORMATTER;}handle(logRecord){if(this.level>logRecord.level)return;const msg=this.format(logRecord);this.log(msg);}format(logRecord){if(this.formatter instanceof Function){return this.formatter(logRecord);}return this.formatter.replace(/{([^\s}]+)}/g,(match,p1)=>{const value=logRecord[p1];if(value===undefined){return match;}return String(value);});}log(_msg){}setup(){}destroy(){}}class ConsoleHandler extends BaseHandler{#useColors;constructor(levelName,options={}){super(levelName,options);this.#useColors=options.useColors??true;}format(logRecord){let msg=super.format(logRecord);if(this.#useColors){msg=this.applyColors(msg,logRecord.level);}return msg;}applyColors(msg,level){switch(level){case LogLevels.INFO:msg=blue(msg);break;case LogLevels.WARNING:msg=yellow(msg);break;case LogLevels.ERROR:msg=red(msg);break;case LogLevels.CRITICAL:msg=bold(red(msg));break;default:break;}return msg;}log(msg){console.log(msg);}}class WriterHandler extends BaseHandler{_writer;#encoder=new TextEncoder;}class FileHandler extends WriterHandler{_file;_buf;_filename;_mode;_openOptions;_encoder=new TextEncoder;#unloadCallback=(()=>{this.destroy();}).bind(this);constructor(levelName,options){super(levelName,options);this._filename=options.filename;this._mode=options.mode?options.mode:"a";this._openOptions={createNew:this._mode==="x",create:this._mode!=="x",append:this._mode==="a",truncate:this._mode!=="a",write:true};}setup(){this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);addEventListener("unload",this.#unloadCallback);}handle(logRecord){super.handle(logRecord);if(logRecord.level>LogLevels.ERROR){this.flush();}}log(msg){if(this._encoder.encode(msg).byteLength+1>this._buf.available()){this.flush();}this._buf.writeSync(this._encoder.encode(msg+"\n"));}flush(){if(this._buf?.buffered()>0){this._buf.flush();}}destroy(){this.flush();this._file?.close();this._file=undefined;removeEventListener("unload",this.#unloadCallback);}}class RotatingFileHandler extends FileHandler{#maxBytes;#maxBackupCount;#currentFileSize=0;constructor(levelName,options){super(levelName,options);this.#maxBytes=options.maxBytes;this.#maxBackupCount=options.maxBackupCount;}setup(){if(this.#maxBytes<1){this.destroy();throw new Error("maxBytes cannot be less than 1");}if(this.#maxBackupCount<1){this.destroy();throw new Error("maxBackupCount cannot be less than 1");}super.setup();if(this._mode==="w"){for(let i=1;i<=this.#maxBackupCount;i++){try{Deno.removeSync(this._filename+"."+i);}catch(error){if(!(error instanceof Deno.errors.NotFound)){throw error;}}}}else if(this._mode==="x"){for(let i=1;i<=this.#maxBackupCount;i++){if(existsSync(this._filename+"."+i)){this.destroy();throw new Deno.errors.AlreadyExists("Backup log file "+this._filename+"."+i+" already exists");}}}else{this.#currentFileSize=Deno.statSync(this._filename).size;}}log(msg){const msgByteLength=this._encoder.encode(msg).byteLength+1;if(this.#currentFileSize+msgByteLength>this.#maxBytes){this.rotateLogFiles();this.#currentFileSize=0;}super.log(msg);this.#currentFileSize+=msgByteLength;}rotateLogFiles(){this._buf.flush();this._file.close();for(let i=this.#maxBackupCount-1;i>=0;i--){const source=this._filename+(i===0?"":"."+i);const dest=this._filename+"."+(i+1);if(existsSync(source)){Deno.renameSync(source,dest);}}this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);}}const DEFAULT_LEVEL="INFO";const DEFAULT_CONFIG={handlers:{default:new ConsoleHandler(DEFAULT_LEVEL)},loggers:{default:{level:DEFAULT_LEVEL,handlers:["default"]}}};const state={handlers:new Map,loggers:new Map,config:DEFAULT_CONFIG};const handlers={BaseHandler,ConsoleHandler,WriterHandler,FileHandler,RotatingFileHandler};function getLogger(name){if(!name){const d=state.loggers.get("default");assert(d!==undefined,`"default" logger must be set for getting logger without name`);return d;}const result=state.loggers.get(name);if(!result){const logger=new Logger(name,"NOTSET",{handlers:[]});state.loggers.set(name,logger);return logger;}return result;}function debug(msg,...args){if(msg instanceof Function){return getLogger("default").debug(msg,...args);}return getLogger("default").debug(msg,...args);}function info(msg,...args){if(msg instanceof Function){return getLogger("default").info(msg,...args);}return getLogger("default").info(msg,...args);}function warning(msg,...args){if(msg instanceof Function){return getLogger("default").warning(msg,...args);}return getLogger("default").warning(msg,...args);}function error(msg,...args){if(msg instanceof Function){return getLogger("default").error(msg,...args);}return getLogger("default").error(msg,...args);}function setup(config){state.config={handlers:{...DEFAULT_CONFIG.handlers,...config.handlers},loggers:{...DEFAULT_CONFIG.loggers,...config.loggers}};state.handlers.forEach(handler=>{handler.destroy();});state.handlers.clear();const handlers=state.config.handlers||{};for(const handlerName in handlers){const handler=handlers[handlerName];handler.setup();state.handlers.set(handlerName,handler);}state.loggers.clear();const loggers=state.config.loggers||{};for(const loggerName in loggers){const loggerConfig=loggers[loggerName];const handlerNames=loggerConfig.handlers||[];const handlers=[];handlerNames.forEach(handlerName=>{const handler=state.handlers.get(handlerName);if(handler){handlers.push(handler);}});const levelName=loggerConfig.level||DEFAULT_LEVEL;const logger=new Logger(loggerName,levelName,{handlers:handlers});state.loggers.set(loggerName,logger);}}setup(DEFAULT_CONFIG);function assertArgs1(from,to){assertPath(from);assertPath(to);if(from===to)return"";}function relative(from,to){assertArgs1(from,to);from=resolve(from);to=resolve(to);if(from===to)return"";let fromStart=1;const fromEnd=from.length;for(;fromStartlength){if(isPosixPathSeparator(to.charCodeAt(toStart+i))){return to.slice(toStart+i+1);}else if(i===0){return to.slice(toStart+i);}}else if(fromLen>length){if(isPosixPathSeparator(from.charCodeAt(fromStart+i))){lastCommonSep=i;}else if(i===0){lastCommonSep=0;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(isPosixPathSeparator(fromCode))lastCommonSep=i;}let out="";for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||isPosixPathSeparator(from.charCodeAt(i))){if(out.length===0)out+="..";else out+="/..";}}if(out.length>0)return out+to.slice(toStart+lastCommonSep);else{toStart+=lastCommonSep;if(isPosixPathSeparator(to.charCodeAt(toStart)))++toStart;return to.slice(toStart);}}function relative1(from,to){assertArgs1(from,to);const fromOrig=resolve1(from);const toOrig=resolve1(to);if(fromOrig===toOrig)return"";from=fromOrig.toLowerCase();to=toOrig.toLowerCase();if(from===to)return"";let fromStart=0;let fromEnd=from.length;for(;fromStartfromStart;--fromEnd){if(from.charCodeAt(fromEnd-1)!==92)break;}const fromLen=fromEnd-fromStart;let toStart=0;let toEnd=to.length;for(;toStarttoStart;--toEnd){if(to.charCodeAt(toEnd-1)!==92)break;}const toLen=toEnd-toStart;const length=fromLenlength){if(to.charCodeAt(toStart+i)===92){return toOrig.slice(toStart+i+1);}else if(i===2){return toOrig.slice(toStart+i);}}if(fromLen>length){if(from.charCodeAt(fromStart+i)===92){lastCommonSep=i;}else if(i===2){lastCommonSep=3;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(fromCode===92)lastCommonSep=i;}if(i!==length&&lastCommonSep===-1){return toOrig;}let out="";if(lastCommonSep===-1)lastCommonSep=0;for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||from.charCodeAt(i)===92){if(out.length===0)out+="..";else out+="\\..";}}if(out.length>0){return out+toOrig.slice(toStart+lastCommonSep,toEnd);}else{toStart+=lastCommonSep;if(toOrig.charCodeAt(toStart)===92)++toStart;return toOrig.slice(toStart,toEnd);}}function relative2(from,to){return isWindows?relative1(from,to):relative(from,to);}var m=Object.create;var E=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),D=(t,e)=>{for(var s in e)E(t,s,{get:e[s],enumerable:!0});},a=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!b.call(t,n)&&n!==s&&E(t,n,{get:()=>e[n],enumerable:!(r=T(e,n))||r.enumerable});return t;},_=(t,e,s)=>(a(t,e,"default"),s&&a(s,e,"default")),$=(t,e,s)=>(s=t!=null?m(X(t)):{},a(e||!t||!t.__esModule?E(s,"default",{value:t,enumerable:!0}):s,t));var A=w((ct,v)=>{function C(t){return Array.isArray(t)?t:[t];}var N="",P=" ",h="\\",H=/^\s+$/,F=/(?:[^\\]|^)\\$/,k=/^\\!/,z=/^\\#/,B=/\r?\n/g,K=/^\.*\/|^\.+$/,d="/",x="node-ignore";typeof Symbol<"u"&&(x=Symbol.for("node-ignore"));var L=x,V=(t,e,s)=>Object.defineProperty(t,e,{value:s}),j=/([0-z])-([0-z])/g,G=()=>!1,M=t=>t.replace(j,(e,s,r)=>s.charCodeAt(0)<=r.charCodeAt(0)?e:N),Y=t=>{let{length:e}=t;return t.slice(0,e-e%2);},W=[[/\\?\s+$/,t=>t.indexOf("\\")===0?P:N],[/\\\s/g,()=>P],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)";}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,s)=>e+6{let r=s.replace(/\\\*/g,"[^\\/]*");return e+r;}],[/\\\\\\(?=[$.|*+(){^])/g,()=>h],[/\\\\/g,()=>h],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,s,r,n)=>e===h?`\\[${s}${Y(r)}${n}`:n==="]"&&r.length%2===0?`[${M(s)}${r}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],S=Object.create(null),p=(t,e)=>{let s=S[t];return s||(s=W.reduce((r,n)=>r.replace(n[0],n[1].bind(t)),t),S[t]=s),e?new RegExp(s,"i"):new RegExp(s);},R=t=>typeof t=="string",q=t=>t&&R(t)&&!H.test(t)&&!F.test(t)&&t.indexOf("#")!==0,J=t=>t.split(B),f=class{constructor(e,s,r,n){this.origin=e,this.pattern=s,this.negative=r,this.regex=n;}},Q=(t,e)=>{let s=t,r=!1;t.indexOf("!")===0&&(r=!0,t=t.substr(1)),t=t.replace(k,"!").replace(z,"#");let n=p(t,e);return new f(s,t,r,n);},U=(t,e)=>{throw new e(t);},i=(t,e,s)=>R(t)?t?i.isNotRelative(t)?s(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:s("path must not be empty",TypeError):s(`path must be a string, but got \`${e}\``,TypeError),O=t=>K.test(t);i.isNotRelative=O;i.convert=t=>t;var g=class{constructor({ignorecase:e=!0,ignoreCase:s=e,allowRelativePaths:r=!1}={}){V(this,L,!0),this._rules=[],this._ignoreCase=s,this._allowRelativePaths=r,this._initCache();}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null);}_addPattern(e){if(e&&e[L]){this._rules=this._rules.concat(e._rules),this._added=!0;return;}if(q(e)){let s=Q(e,this._ignoreCase);this._added=!0,this._rules.push(s);}}add(e){return this._added=!1,C(R(e)?J(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this;}addPattern(e){return this.add(e);}_testOne(e,s){let r=!1,n=!1;return this._rules.forEach(o=>{let{negative:u}=o;if(n===u&&r!==n||u&&!r&&!n&&!s)return;o.regex.test(e)&&(r=!u,n=u);}),{ignored:r,unignored:n};}_test(e,s,r,n){let o=e&&i.convert(e);return i(o,e,this._allowRelativePaths?G:U),this._t(o,s,r,n);}_t(e,s,r,n){if(e in s)return s[e];if(n||(n=e.split(d)),n.pop(),!n.length)return s[e]=this._testOne(e,r);let o=this._t(n.join(d)+d,s,r,n);return s[e]=o.ignored?o:this._testOne(e,r);}ignores(e){return this._test(e,this._ignoreCache,!1).ignored;}createFilter(){return e=>!this.ignores(e);}filter(e){return C(e).filter(this.createFilter());}test(e){return this._test(e,this._testCache,!0);}},l=t=>new g(t),Z=t=>i(t&&i.convert(t),t,G);l.isPathValid=Z;l.default=l;v.exports=l;var tt=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");i.convert=tt;var et=/^[a-z]:\//i;i.isNotRelative=t=>et.test(t)||O(t);});var c={};D(c,{default:()=>nt});var st=$(A());_(c,$(A()));var{default:I,...rt}=st,nt=I!==void 0?I:rt;const importMeta={url:"file:///home/runner/work/setup-deno/setup-deno/cache.ts",main:import.meta.main};const args=parseArgs(Deno.args,{boolean:["help","dry-run","debug"],string:["config"],alias:{help:"h",dryRun:"n"},"--":true});const logLevel=args.debug?"DEBUG":"INFO";setup({handlers:{console:new handlers.ConsoleHandler(logLevel,{formatter:logRecord=>Deno.noColor?[logRecord.levelName,logRecord.msg].join(" "):logRecord.msg})},loggers:{default:{handlers:["console"],"level":logLevel}}});const main=async args=>{if(args.help){console.log("Usage: cache [-n | --dry-run] [--debug] [--] [DENO_ARGS...]");Deno.exit(0);}if(args["dry-run"])warning("dry-run mode enabled");if(args.config&&!await exists(args.config)){error(`config file ${args.config} not found`);Deno.exit(1);}const hash=await Deno.readFile("./deno.lock").then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>encodeHex(new Uint8Array(data))).catch(_=>"");debug(`GitHub actions deno.lock hash: ${hash}`);const cfgs=args.config?[args.config]:["deno.json","deno.jsonc"];const denoCfg=await Promise.all(cfgs.map(path=>Deno.readTextFile(path).catch(_=>undefined))).then(v=>parse(v.filter(Boolean)[0]??"{}"));const patterns=[...[denoCfg?.exclude??[]].flat(),...[denoCfg?.cache?.exclude??[]].flat(),...[denoCfg?.cache?.include??[]].flatMap(p=>`!${p}`)];debug(`patterns:`,patterns);patterns.forEach(p=>debug(`- ${p}`));const ig=nt().add(patterns);const walkIterator=walk(".",{exts:["js",".jsx",".ts",".tsx"],includeDirs:false});for await(const entry of walkIterator){const relativePath=relative2(".",entry.path);if(ig.ignores(relativePath)){debug(`ignored ${relativePath}`);continue;}debug(`caching ${relativePath}`);const cmd=new Deno.Command(Deno.execPath(),{args:["cache",args.config&&`--config=${args.config}`,relativePath,...args["--"]].filter(Boolean),stdout:"inherit",stderr:"inherit"});let code=0;if(!args["dry-run"])code=(await cmd.output()).code;if(code===0){info(`cached ${relativePath}`);}else{error(`failed to cache ${entry.path}`);}}};if(importMeta.main)main(args); \ No newline at end of file From 203319517339cb3846cf1c967d4868fa86d05d62 Mon Sep 17 00:00:00 2001 From: winston Date: Tue, 26 Dec 2023 21:13:29 +0100 Subject: [PATCH 09/18] fix: lock write in single cache cmd --- cache.ts | 96 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/cache.ts b/cache.ts index dcb4281..79e5533 100755 --- a/cache.ts +++ b/cache.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env -S deno run --no-lock --allow-read --allow-run=deno +#!/usr/bin/env -S deno run --no-lock --allow-read --allow-run=deno --allow-env=CI,DENO_DIR import { parseArgs } from "https://deno.land/std@0.210.0/cli/parse_args.ts"; import { encodeHex } from "https://deno.land/std@0.210.0/encoding/hex.ts"; import { exists, walk } from "https://deno.land/std@0.210.0/fs/mod.ts"; @@ -7,36 +7,41 @@ import * as log from "https://deno.land/std@0.210.0/log/mod.ts"; import { relative } from "https://deno.land/std@0.210.0/path/relative.ts"; import ignore from "https://esm.sh/gh/nekowinston/deno-ignore@v5.3.0/index.js?pin=v135"; -const args = parseArgs(Deno.args, { - boolean: ["help", "dry-run", "debug"], - string: ["config"], - alias: { help: "h", dryRun: "n" }, - "--": true, -}); - -const logLevel = args.debug ? "DEBUG" : "INFO"; -log.setup({ - handlers: { - console: new log.handlers.ConsoleHandler(logLevel, { - formatter: (logRecord) => - Deno.noColor - ? [logRecord.levelName, logRecord.msg].join(" ") - : logRecord.msg, - }), - }, - loggers: { default: { handlers: ["console"], "level": logLevel } }, -}); - -type Args = typeof args; type DenoConfig = { cache: { include?: string[]; exclude?: string[] }; exclude?: string[]; [key: string]: unknown; }; -const main = async (args: Args) => { +if (import.meta.main) { + const args = parseArgs(Deno.args, { + boolean: ["help", "dry-run", "verbose", "lock-write"], + negatable: ["lock-write"], + string: ["config"], + default: { "lock-write": true }, + alias: { help: "h", "dry-run": "n" }, + "--": true, + }); + const denoDir = Deno.env.get("DENO_DIR"); + + const logLevel = Deno.env.get("CI") === "1" + ? "DEBUG" + : (args.verbose ? "DEBUG" : "INFO"); + log.setup({ + handlers: { + console: new log.handlers.ConsoleHandler(logLevel, { + formatter: (logRecord) => + Deno.noColor + ? [logRecord.levelName, logRecord.msg].join(" ") + : logRecord.msg, + }), + }, + loggers: { default: { handlers: ["console"], "level": logLevel } }, + }); if (args.help) { - console.log("Usage: cache [-n | --dry-run] [--debug] [--] [DENO_ARGS...]"); + console.log( + "Usage: cache [-n | --dry-run] [-v | --verbose] [--] [DENO_ARGS...]", + ); Deno.exit(0); } @@ -75,35 +80,36 @@ const main = async (args: Args) => { includeDirs: false, }); + const paths = []; + for await (const entry of walkIterator) { const relativePath = relative(".", entry.path); + // assuming that DENO_DIR is set inside the current directory, + // this would first fetch the deps of this script, store them there, + // then include them here. since the cache could be huge, don't log it. + if (denoDir && entry.path.startsWith(denoDir)) continue; if (ig.ignores(relativePath)) { log.debug(`ignored ${relativePath}`); continue; } log.debug(`caching ${relativePath}`); - const cmd = new Deno.Command(Deno.execPath(), { - args: [ - "cache", - args.config && `--config=${args.config}`, - relativePath, - ...args["--"], - ].filter(Boolean) as string[], - stdout: "inherit", - stderr: "inherit", - }); - - let code = 0; - if (!args["dry-run"]) code = (await cmd.output()).code; - - if (code === 0) { - log.info(`cached ${relativePath}`); - } else { - log.error(`failed to cache ${entry.path}`); - } + paths.push(relativePath); } -}; -if (import.meta.main) main(args); + const cmd = new Deno.Command(Deno.execPath(), { + args: [ + "cache", + args["lock-write"] && "--lock-write", + args.config && `--config=${args.config}`, + ...args["--"], // everything after `--` is passed to Deno + ...paths, + ].filter(Boolean) as string[], + stdout: "inherit", + stderr: "inherit", + }); + + const code = !args["dry-run"] ? (await cmd.output()).code : 0; + if (code === 0) log.debug(`finished caching ${paths.length} files`); +} From ed8c504d52267d2f2bb6704ed6a6b394331373d3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 26 Dec 2023 20:34:54 +0000 Subject: [PATCH 10/18] chore: build action bundle --- dist/cache.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/cache.js b/dist/cache.js index 6bc95bd..2ca99f9 100755 --- a/dist/cache.js +++ b/dist/cache.js @@ -1,2 +1,2 @@ -#!/usr/bin/env -S deno run --no-lock --allow-read --allow-run=deno -class AssertionError extends Error{constructor(message){super(message);this.name="AssertionError";}}function assert(expr,msg=""){if(!expr){throw new AssertionError(msg);}}const{hasOwn}=Object;function get(obj,key){if(hasOwn(obj,key)){return obj[key];}}function getForce(obj,key){const v=get(obj,key);assert(v!==undefined);return v;}function isNumber(x){if(typeof x==="number")return true;if(/^0x[0-9a-f]+$/i.test(String(x)))return true;return/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(String(x));}function hasKey(obj,keys){let o=obj;keys.slice(0,-1).forEach(key=>{o=get(o,key)??{};});const key=keys[keys.length-1];return hasOwn(o,key);}function parseArgs(args,{"--":doubleDash=false,alias={},boolean:__boolean=false,default:defaults={},stopEarly=false,string=[],collect=[],negatable=[],unknown=i=>i}={}){const aliases={};const flags={bools:{},strings:{},unknownFn:unknown,allBools:false,collect:{},negatable:{}};if(alias!==undefined){for(const key in alias){const val=getForce(alias,key);if(typeof val==="string"){aliases[key]=[val];}else{aliases[key]=val;}for(const alias of getForce(aliases,key)){aliases[alias]=[key].concat(aliases[key].filter(y=>alias!==y));}}}if(__boolean!==undefined){if(typeof __boolean==="boolean"){flags.allBools=!!__boolean;}else{const booleanArgs=typeof __boolean==="string"?[__boolean]:__boolean;for(const key of booleanArgs.filter(Boolean)){flags.bools[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.bools[al]=true;}}}}}if(string!==undefined){const stringArgs=typeof string==="string"?[string]:string;for(const key of stringArgs.filter(Boolean)){flags.strings[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.strings[al]=true;}}}}if(collect!==undefined){const collectArgs=typeof collect==="string"?[collect]:collect;for(const key of collectArgs.filter(Boolean)){flags.collect[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.collect[al]=true;}}}}if(negatable!==undefined){const negatableArgs=typeof negatable==="string"?[negatable]:negatable;for(const key of negatableArgs.filter(Boolean)){flags.negatable[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.negatable[al]=true;}}}}const argv={_:[]};function argDefined(key,arg){return flags.allBools&&/^--[^=]+$/.test(arg)||get(flags.bools,key)||!!get(flags.strings,key)||!!get(aliases,key);}function setKey(obj,name,value,collect=true){let o=obj;const keys=name.split(".");keys.slice(0,-1).forEach(function(key){if(get(o,key)===undefined){o[key]={};}o=get(o,key);});const key=keys[keys.length-1];const collectable=collect&&!!get(flags.collect,name);if(!collectable){o[key]=value;}else if(get(o,key)===undefined){o[key]=[value];}else if(Array.isArray(get(o,key))){o[key].push(value);}else{o[key]=[get(o,key),value];}}function setArg(key,val,arg=undefined,collect){if(arg&&flags.unknownFn&&!argDefined(key,arg)){if(flags.unknownFn(arg,key,val)===false)return;}const value=!get(flags.strings,key)&&isNumber(val)?Number(val):val;setKey(argv,key,value,collect);const alias=get(aliases,key);if(alias){for(const x of alias){setKey(argv,x,value,collect);}}}function aliasIsBoolean(key){return getForce(aliases,key).some(x=>typeof get(flags.bools,x)==="boolean");}let notFlags=[];if(args.includes("--")){notFlags=args.slice(args.indexOf("--")+1);args=args.slice(0,args.indexOf("--"));}for(let i=0;i>4];dst[i*2+1]=hexTable[v&15];}return textDecoder.decode(dst);}const osType=(()=>{const{Deno:Deno1}=globalThis;if(typeof Deno1?.build?.os==="string"){return Deno1.build.os;}const{navigator}=globalThis;if(navigator?.appVersion?.includes?.("Win")){return"windows";}return"linux";})();const isWindows=osType==="windows";function assertPath(path){if(typeof path!=="string"){throw new TypeError(`Path must be a string. Received ${JSON.stringify(path)}`);}}function assertArg(path){assertPath(path);if(path.length===0)return".";}const CHAR_FORWARD_SLASH=47;function normalizeString(path,allowAboveRoot,separator,isPathSeparator){let res="";let lastSegmentLength=0;let lastSlash=-1;let dots=0;let code;for(let i=0,len=path.length;i<=len;++i){if(i2){const lastSlashIndex=res.lastIndexOf(separator);if(lastSlashIndex===-1){res="";lastSegmentLength=0;}else{res=res.slice(0,lastSlashIndex);lastSegmentLength=res.length-1-res.lastIndexOf(separator);}lastSlash=i;dots=0;continue;}else if(res.length===2||res.length===1){res="";lastSegmentLength=0;lastSlash=i;dots=0;continue;}}if(allowAboveRoot){if(res.length>0)res+=`${separator}..`;else res="..";lastSegmentLength=2;}}else{if(res.length>0)res+=separator+path.slice(lastSlash+1,i);else res=path.slice(lastSlash+1,i);lastSegmentLength=i-lastSlash-1;}lastSlash=i;dots=0;}else if(code===46&&dots!==-1){++dots;}else{dots=-1;}}return res;}function isPosixPathSeparator(code){return code===47;}function normalize(path){assertArg(path);const isAbsolute=isPosixPathSeparator(path.charCodeAt(0));const trailingSeparator=isPosixPathSeparator(path.charCodeAt(path.length-1));path=normalizeString(path,!isAbsolute,"/",isPosixPathSeparator);if(path.length===0&&!isAbsolute)path=".";if(path.length>0&&trailingSeparator)path+="/";if(isAbsolute)return`/${path}`;return path;}function join(...paths){if(paths.length===0)return".";let joined;for(let i=0,len=paths.length;i0){if(!joined)joined=path;else joined+=`/${path}`;}}if(!joined)return".";return normalize(joined);}function isPathSeparator(code){return code===47||code===92;}function isWindowsDeviceRoot(code){return code>=97&&code<=122||code>=65&&code<=90;}function normalize1(path){assertArg(path);const len=path.length;let rootEnd=0;let device;let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){return"\\";}let tail;if(rootEnd0&&isPathSeparator(path.charCodeAt(len-1))){tail+="\\";}if(device===undefined){if(isAbsolute){if(tail.length>0)return`\\${tail}`;else return"\\";}else if(tail.length>0){return tail;}else{return"";}}else if(isAbsolute){if(tail.length>0)return`${device}\\${tail}`;else return`${device}\\`;}else if(tail.length>0){return device+tail;}else{return device;}}function join1(...paths){if(paths.length===0)return".";let joined;let firstPart=null;for(let i=0;i0){if(joined===undefined)joined=firstPart=path;else joined+=`\\${path}`;}}if(joined===undefined)return".";let needsReplace=true;let slashCount=0;assert(firstPart!==null);if(isPathSeparator(firstPart.charCodeAt(0))){++slashCount;const firstLen=firstPart.length;if(firstLen>1){if(isPathSeparator(firstPart.charCodeAt(1))){++slashCount;if(firstLen>2){if(isPathSeparator(firstPart.charCodeAt(2)))++slashCount;else{needsReplace=false;}}}}}if(needsReplace){for(;slashCount=2)joined=`\\${joined.slice(slashCount)}`;}return normalize1(joined);}function join2(...paths){return isWindows?join1(...paths):join(...paths);}function assertArg1(url){url=url instanceof URL?url:new URL(url);if(url.protocol!=="file:"){throw new TypeError("Must be a file URL.");}return url;}function fromFileUrl(url){url=assertArg1(url);return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"));}function fromFileUrl1(url){url=assertArg1(url);let path=decodeURIComponent(url.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");if(url.hostname!==""){path=`\\\\${url.hostname}${path}`;}return path;}function fromFileUrl2(url){return isWindows?fromFileUrl1(url):fromFileUrl(url);}function toPathString(pathUrl){return pathUrl instanceof URL?fromFileUrl2(pathUrl):pathUrl;}function stripTrailingSeparators(segment,isSep){if(segment.length<=1){return segment;}let end=segment.length;for(let i=segment.length-1;i>0;i--){if(isSep(segment.charCodeAt(i))){end=i;}else{break;}}return segment.slice(0,end);}function resolve(...pathSegments){let resolvedPath="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1&&!resolvedAbsolute;i--){let path;if(i>=0)path=pathSegments[i];else{const{Deno:Deno1}=globalThis;if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();}assertPath(path);if(path.length===0){continue;}resolvedPath=`${path}/${resolvedPath}`;resolvedAbsolute=isPosixPathSeparator(path.charCodeAt(0));}resolvedPath=normalizeString(resolvedPath,!resolvedAbsolute,"/",isPosixPathSeparator);if(resolvedAbsolute){if(resolvedPath.length>0)return`/${resolvedPath}`;else return"/";}else if(resolvedPath.length>0)return resolvedPath;else return".";}function resolve1(...pathSegments){let resolvedDevice="";let resolvedTail="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1;i--){let path;const{Deno:Deno1}=globalThis;if(i>=0){path=pathSegments[i];}else if(!resolvedDevice){if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a drive-letter-less path without a CWD.");}path=Deno1.cwd();}else{if(typeof Deno1?.env?.get!=="function"||typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();if(path===undefined||path.slice(0,3).toLowerCase()!==`${resolvedDevice.toLowerCase()}\\`){path=`${resolvedDevice}\\`;}}assertPath(path);const len=path.length;if(len===0)continue;let rootEnd=0;let device="";let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){rootEnd=1;isAbsolute=true;}if(device.length>0&&resolvedDevice.length>0&&device.toLowerCase()!==resolvedDevice.toLowerCase()){continue;}if(resolvedDevice.length===0&&device.length>0){resolvedDevice=device;}if(!resolvedAbsolute){resolvedTail=`${path.slice(rootEnd)}\\${resolvedTail}`;resolvedAbsolute=isAbsolute;}if(resolvedAbsolute&&resolvedDevice.length>0)break;}resolvedTail=normalizeString(resolvedTail,!resolvedAbsolute,"\\",isPathSeparator);return resolvedDevice+(resolvedAbsolute?"\\":"")+resolvedTail||".";}Deno.build.os==="windows";async function exists(path,options){try{const stat=await Deno.stat(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if((await Deno.permissions.query({name:"read",path})).state==="granted"){return!options?.isReadable;}}throw error;}}function existsSync(path,options){try{const stat=Deno.statSync(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if(Deno.permissions.querySync({name:"read",path}).state==="granted"){return!options?.isReadable;}}throw error;}}function normalize2(path){return isWindows?normalize1(path):normalize(path);}function stripSuffix(name,suffix){if(suffix.length>=name.length){return name;}const lenDiff=name.length-suffix.length;for(let i=suffix.length-1;i>=0;--i){if(name.charCodeAt(lenDiff+i)!==suffix.charCodeAt(i)){return name;}}return name.slice(0,-suffix.length);}function lastPathSegment(path,isSep,start=0){let matchedNonSeparator=false;let end=path.length;for(let i=path.length-1;i>=start;--i){if(isSep(path.charCodeAt(i))){if(matchedNonSeparator){start=i+1;break;}}else if(!matchedNonSeparator){matchedNonSeparator=true;end=i+1;}}return path.slice(start,end);}function assertArgs(path,suffix){assertPath(path);if(path.length===0)return path;if(typeof suffix!=="string"){throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);}}function basename(path,suffix=""){assertArgs(path,suffix);const lastSegment=lastPathSegment(path,isPosixPathSeparator);const strippedSegment=stripTrailingSeparators(lastSegment,isPosixPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename1(path,suffix=""){assertArgs(path,suffix);let start=0;if(path.length>=2){const drive=path.charCodeAt(0);if(isWindowsDeviceRoot(drive)){if(path.charCodeAt(1)===58)start=2;}}const lastSegment=lastPathSegment(path,isPathSeparator,start);const strippedSegment=stripTrailingSeparators(lastSegment,isPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename2(path,suffix=""){return isWindows?basename1(path,suffix):basename(path,suffix);}async function createWalkEntry(path){path=toPathString(path);path=normalize2(path);const name=basename2(path);const info=await Deno.stat(path);return{path,name,isFile:info.isFile,isDirectory:info.isDirectory,isSymlink:info.isSymlink};}class WalkError extends Error{root;constructor(cause,root){super(`${cause instanceof Error?cause.message:cause} for path "${root}"`);this.cause=cause;this.name="WalkError";this.root=root;}}function include(path,exts,match,skip){if(exts&&!exts.some(ext=>path.endsWith(ext))){return false;}if(match&&!match.some(pattern=>!!path.match(pattern))){return false;}if(skip&&skip.some(pattern=>!!path.match(pattern))){return false;}return true;}function wrapErrorWithPath(err,root){if(err instanceof WalkError)return err;return new WalkError(err,root);}async function*walk(root,{maxDepth=Infinity,includeFiles=true,includeDirs=true,includeSymlinks=true,followSymlinks=false,canonicalize=true,exts=undefined,match=undefined,skip=undefined}={}){if(maxDepth<0){return;}root=toPathString(root);if(includeDirs&&include(root,exts,match,skip)){yield await createWalkEntry(root);}if(maxDepth<1||!include(root,undefined,undefined,skip)){return;}try{for await(const entry of Deno.readDir(root)){let path=join2(root,entry.name);let{isSymlink,isDirectory}=entry;if(isSymlink){if(!followSymlinks){if(includeSymlinks&&include(path,exts,match,skip)){yield{path,...entry};}continue;}const realPath=await Deno.realPath(path);if(canonicalize){path=realPath;}({isSymlink,isDirectory}=await Deno.lstat(realPath));}if(isSymlink||isDirectory){yield*walk(path,{maxDepth:maxDepth-1,includeFiles,includeDirs,includeSymlinks,followSymlinks,exts,match,skip});}else if(includeFiles&&include(path,exts,match,skip)){yield{path,...entry};}}}catch(err){throw wrapErrorWithPath(err,normalize2(root));}}Deno.build.os==="windows";new Deno.errors.AlreadyExists("dest already exists.");Deno.build.os==="windows";const LF="\n";const CRLF="\r\n";Deno?.build.os==="windows"?CRLF:LF;function parse(text,{allowTrailingComma=true}={}){if(new.target){throw new TypeError("parse is not a constructor");}return new JSONCParser(text,{allowTrailingComma}).parse();}const originalJSONParse=globalThis.JSON.parse;class JSONCParser{#whitespace=new Set(" \r\n");#numberEndToken=new Set([..."[]{}:,/",...this.#whitespace]);#text;#length;#tokenized;#options;constructor(text,options){this.#text=`${text}`;this.#length=this.#text.length;this.#tokenized=this.#tokenize();this.#options=options;}parse(){const token=this.#getNext();const res=this.#parseJsonValue(token);const{done,value}=this.#tokenized.next();if(!done){throw new SyntaxError(buildErrorMessage(value));}return res;}#getNext(){const{done,value}=this.#tokenized.next();if(done){throw new SyntaxError("Unexpected end of JSONC input");}return value;}*#tokenize(){for(let i=0;iisNaN(Number(key)));const byLevel={[LogLevels.NOTSET]:"NOTSET",[LogLevels.DEBUG]:"DEBUG",[LogLevels.INFO]:"INFO",[LogLevels.WARNING]:"WARNING",[LogLevels.ERROR]:"ERROR",[LogLevels.CRITICAL]:"CRITICAL"};function getLevelByName(name){const level=LogLevels[name];if(level!==undefined){return level;}throw new Error(`no log level found for name: ${name}`);}function getLevelName(level){const levelName=byLevel[level];if(levelName){return levelName;}throw new Error(`no level name found for level: ${level}`);}class LogRecord{msg;#args;#datetime;level;levelName;loggerName;constructor(options){this.msg=options.msg;this.#args=[...options.args];this.level=options.level;this.loggerName=options.loggerName;this.#datetime=new Date;this.levelName=getLevelName(options.level);}get args(){return[...this.#args];}get datetime(){return new Date(this.#datetime.getTime());}}class Logger{#level;#handlers;#loggerName;constructor(loggerName,levelName,options={}){this.#loggerName=loggerName;this.#level=getLevelByName(levelName);this.#handlers=options.handlers||[];}get level(){return this.#level;}set level(level){try{this.#level=getLevelByName(getLevelName(level));}catch(_){throw new TypeError(`Invalid log level: ${level}`);}}get levelName(){return getLevelName(this.#level);}set levelName(levelName){this.#level=getLevelByName(levelName);}get loggerName(){return this.#loggerName;}set handlers(hndls){this.#handlers=hndls;}get handlers(){return this.#handlers;}#_log(level,msg,...args){if(this.level>level){return msg instanceof Function?undefined:msg;}let fnResult;let logMessage;if(msg instanceof Function){fnResult=msg();logMessage=this.asString(fnResult);}else{logMessage=this.asString(msg);}const record=new LogRecord({msg:logMessage,args:args,level:level,loggerName:this.loggerName});this.#handlers.forEach(handler=>{handler.handle(record);});return msg instanceof Function?fnResult:msg;}asString(data,isProperty=false){if(typeof data==="string"){if(isProperty)return`"${data}"`;return data;}else if(data===null||typeof data==="number"||typeof data==="bigint"||typeof data==="boolean"||typeof data==="undefined"||typeof data==="symbol"){return String(data);}else if(data instanceof Error){return data.stack;}else if(typeof data==="object"){return`{${Object.entries(data).map(([k,v])=>`"${k}":${this.asString(v,true)}`).join(",")}}`;}return"undefined";}debug(msg,...args){return this.#_log(LogLevels.DEBUG,msg,...args);}info(msg,...args){return this.#_log(LogLevels.INFO,msg,...args);}warning(msg,...args){return this.#_log(LogLevels.WARNING,msg,...args);}error(msg,...args){return this.#_log(LogLevels.ERROR,msg,...args);}critical(msg,...args){return this.#_log(LogLevels.CRITICAL,msg,...args);}}const{Deno:Deno1}=globalThis;const noColor=typeof Deno1?.noColor==="boolean"?Deno1.noColor:false;let enabled=!noColor;function code(open,close){return{open:`\x1b[${open.join(";")}m`,close:`\x1b[${close}m`,regexp:new RegExp(`\\x1b\\[${close}m`,"g")};}function run(str,code){return enabled?`${code.open}${str.replace(code.regexp,code.open)}${code.close}`:str;}function bold(str){return run(str,code([1],22));}function red(str){return run(str,code([31],39));}function yellow(str){return run(str,code([33],39));}function blue(str){return run(str,code([34],39));}new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"),"g");function copy(src,dst,off=0){off=Math.max(0,Math.min(off,dst.byteLength));const dstBytesAvailable=dst.byteLength-off;if(src.byteLength>dstBytesAvailable){src=src.subarray(0,dstBytesAvailable);}dst.set(src,off);return src.byteLength;}class AbstractBufBase{buf;usedBufferBytes=0;err=null;constructor(buf){this.buf=buf;}size(){return this.buf.byteLength;}available(){return this.buf.byteLength-this.usedBufferBytes;}buffered(){return this.usedBufferBytes;}}class BufWriterSync extends AbstractBufBase{#writer;static create(writer,size=4096){return writer instanceof BufWriterSync?writer:new BufWriterSync(writer,size);}constructor(writer,size=4096){super(new Uint8Array(size<=0?4096:size));this.#writer=writer;}reset(w){this.err=null;this.usedBufferBytes=0;this.#writer=w;}flush(){if(this.err!==null)throw this.err;if(this.usedBufferBytes===0)return;try{const p=this.buf.subarray(0,this.usedBufferBytes);let nwritten=0;while(nwrittenthis.available()){if(this.buffered()===0){try{numBytesWritten=this.#writer.writeSync(data);}catch(e){if(e instanceof Error){this.err=e;}throw e;}}else{numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;this.flush();}totalBytesWritten+=numBytesWritten;data=data.subarray(numBytesWritten);}numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;totalBytesWritten+=numBytesWritten;return totalBytesWritten;}}const DEFAULT_FORMATTER="{levelName} {msg}";class BaseHandler{level;levelName;formatter;constructor(levelName,options={}){this.level=getLevelByName(levelName);this.levelName=levelName;this.formatter=options.formatter||DEFAULT_FORMATTER;}handle(logRecord){if(this.level>logRecord.level)return;const msg=this.format(logRecord);this.log(msg);}format(logRecord){if(this.formatter instanceof Function){return this.formatter(logRecord);}return this.formatter.replace(/{([^\s}]+)}/g,(match,p1)=>{const value=logRecord[p1];if(value===undefined){return match;}return String(value);});}log(_msg){}setup(){}destroy(){}}class ConsoleHandler extends BaseHandler{#useColors;constructor(levelName,options={}){super(levelName,options);this.#useColors=options.useColors??true;}format(logRecord){let msg=super.format(logRecord);if(this.#useColors){msg=this.applyColors(msg,logRecord.level);}return msg;}applyColors(msg,level){switch(level){case LogLevels.INFO:msg=blue(msg);break;case LogLevels.WARNING:msg=yellow(msg);break;case LogLevels.ERROR:msg=red(msg);break;case LogLevels.CRITICAL:msg=bold(red(msg));break;default:break;}return msg;}log(msg){console.log(msg);}}class WriterHandler extends BaseHandler{_writer;#encoder=new TextEncoder;}class FileHandler extends WriterHandler{_file;_buf;_filename;_mode;_openOptions;_encoder=new TextEncoder;#unloadCallback=(()=>{this.destroy();}).bind(this);constructor(levelName,options){super(levelName,options);this._filename=options.filename;this._mode=options.mode?options.mode:"a";this._openOptions={createNew:this._mode==="x",create:this._mode!=="x",append:this._mode==="a",truncate:this._mode!=="a",write:true};}setup(){this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);addEventListener("unload",this.#unloadCallback);}handle(logRecord){super.handle(logRecord);if(logRecord.level>LogLevels.ERROR){this.flush();}}log(msg){if(this._encoder.encode(msg).byteLength+1>this._buf.available()){this.flush();}this._buf.writeSync(this._encoder.encode(msg+"\n"));}flush(){if(this._buf?.buffered()>0){this._buf.flush();}}destroy(){this.flush();this._file?.close();this._file=undefined;removeEventListener("unload",this.#unloadCallback);}}class RotatingFileHandler extends FileHandler{#maxBytes;#maxBackupCount;#currentFileSize=0;constructor(levelName,options){super(levelName,options);this.#maxBytes=options.maxBytes;this.#maxBackupCount=options.maxBackupCount;}setup(){if(this.#maxBytes<1){this.destroy();throw new Error("maxBytes cannot be less than 1");}if(this.#maxBackupCount<1){this.destroy();throw new Error("maxBackupCount cannot be less than 1");}super.setup();if(this._mode==="w"){for(let i=1;i<=this.#maxBackupCount;i++){try{Deno.removeSync(this._filename+"."+i);}catch(error){if(!(error instanceof Deno.errors.NotFound)){throw error;}}}}else if(this._mode==="x"){for(let i=1;i<=this.#maxBackupCount;i++){if(existsSync(this._filename+"."+i)){this.destroy();throw new Deno.errors.AlreadyExists("Backup log file "+this._filename+"."+i+" already exists");}}}else{this.#currentFileSize=Deno.statSync(this._filename).size;}}log(msg){const msgByteLength=this._encoder.encode(msg).byteLength+1;if(this.#currentFileSize+msgByteLength>this.#maxBytes){this.rotateLogFiles();this.#currentFileSize=0;}super.log(msg);this.#currentFileSize+=msgByteLength;}rotateLogFiles(){this._buf.flush();this._file.close();for(let i=this.#maxBackupCount-1;i>=0;i--){const source=this._filename+(i===0?"":"."+i);const dest=this._filename+"."+(i+1);if(existsSync(source)){Deno.renameSync(source,dest);}}this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);}}const DEFAULT_LEVEL="INFO";const DEFAULT_CONFIG={handlers:{default:new ConsoleHandler(DEFAULT_LEVEL)},loggers:{default:{level:DEFAULT_LEVEL,handlers:["default"]}}};const state={handlers:new Map,loggers:new Map,config:DEFAULT_CONFIG};const handlers={BaseHandler,ConsoleHandler,WriterHandler,FileHandler,RotatingFileHandler};function getLogger(name){if(!name){const d=state.loggers.get("default");assert(d!==undefined,`"default" logger must be set for getting logger without name`);return d;}const result=state.loggers.get(name);if(!result){const logger=new Logger(name,"NOTSET",{handlers:[]});state.loggers.set(name,logger);return logger;}return result;}function debug(msg,...args){if(msg instanceof Function){return getLogger("default").debug(msg,...args);}return getLogger("default").debug(msg,...args);}function info(msg,...args){if(msg instanceof Function){return getLogger("default").info(msg,...args);}return getLogger("default").info(msg,...args);}function warning(msg,...args){if(msg instanceof Function){return getLogger("default").warning(msg,...args);}return getLogger("default").warning(msg,...args);}function error(msg,...args){if(msg instanceof Function){return getLogger("default").error(msg,...args);}return getLogger("default").error(msg,...args);}function setup(config){state.config={handlers:{...DEFAULT_CONFIG.handlers,...config.handlers},loggers:{...DEFAULT_CONFIG.loggers,...config.loggers}};state.handlers.forEach(handler=>{handler.destroy();});state.handlers.clear();const handlers=state.config.handlers||{};for(const handlerName in handlers){const handler=handlers[handlerName];handler.setup();state.handlers.set(handlerName,handler);}state.loggers.clear();const loggers=state.config.loggers||{};for(const loggerName in loggers){const loggerConfig=loggers[loggerName];const handlerNames=loggerConfig.handlers||[];const handlers=[];handlerNames.forEach(handlerName=>{const handler=state.handlers.get(handlerName);if(handler){handlers.push(handler);}});const levelName=loggerConfig.level||DEFAULT_LEVEL;const logger=new Logger(loggerName,levelName,{handlers:handlers});state.loggers.set(loggerName,logger);}}setup(DEFAULT_CONFIG);function assertArgs1(from,to){assertPath(from);assertPath(to);if(from===to)return"";}function relative(from,to){assertArgs1(from,to);from=resolve(from);to=resolve(to);if(from===to)return"";let fromStart=1;const fromEnd=from.length;for(;fromStartlength){if(isPosixPathSeparator(to.charCodeAt(toStart+i))){return to.slice(toStart+i+1);}else if(i===0){return to.slice(toStart+i);}}else if(fromLen>length){if(isPosixPathSeparator(from.charCodeAt(fromStart+i))){lastCommonSep=i;}else if(i===0){lastCommonSep=0;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(isPosixPathSeparator(fromCode))lastCommonSep=i;}let out="";for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||isPosixPathSeparator(from.charCodeAt(i))){if(out.length===0)out+="..";else out+="/..";}}if(out.length>0)return out+to.slice(toStart+lastCommonSep);else{toStart+=lastCommonSep;if(isPosixPathSeparator(to.charCodeAt(toStart)))++toStart;return to.slice(toStart);}}function relative1(from,to){assertArgs1(from,to);const fromOrig=resolve1(from);const toOrig=resolve1(to);if(fromOrig===toOrig)return"";from=fromOrig.toLowerCase();to=toOrig.toLowerCase();if(from===to)return"";let fromStart=0;let fromEnd=from.length;for(;fromStartfromStart;--fromEnd){if(from.charCodeAt(fromEnd-1)!==92)break;}const fromLen=fromEnd-fromStart;let toStart=0;let toEnd=to.length;for(;toStarttoStart;--toEnd){if(to.charCodeAt(toEnd-1)!==92)break;}const toLen=toEnd-toStart;const length=fromLenlength){if(to.charCodeAt(toStart+i)===92){return toOrig.slice(toStart+i+1);}else if(i===2){return toOrig.slice(toStart+i);}}if(fromLen>length){if(from.charCodeAt(fromStart+i)===92){lastCommonSep=i;}else if(i===2){lastCommonSep=3;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(fromCode===92)lastCommonSep=i;}if(i!==length&&lastCommonSep===-1){return toOrig;}let out="";if(lastCommonSep===-1)lastCommonSep=0;for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||from.charCodeAt(i)===92){if(out.length===0)out+="..";else out+="\\..";}}if(out.length>0){return out+toOrig.slice(toStart+lastCommonSep,toEnd);}else{toStart+=lastCommonSep;if(toOrig.charCodeAt(toStart)===92)++toStart;return toOrig.slice(toStart,toEnd);}}function relative2(from,to){return isWindows?relative1(from,to):relative(from,to);}var m=Object.create;var E=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),D=(t,e)=>{for(var s in e)E(t,s,{get:e[s],enumerable:!0});},a=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!b.call(t,n)&&n!==s&&E(t,n,{get:()=>e[n],enumerable:!(r=T(e,n))||r.enumerable});return t;},_=(t,e,s)=>(a(t,e,"default"),s&&a(s,e,"default")),$=(t,e,s)=>(s=t!=null?m(X(t)):{},a(e||!t||!t.__esModule?E(s,"default",{value:t,enumerable:!0}):s,t));var A=w((ct,v)=>{function C(t){return Array.isArray(t)?t:[t];}var N="",P=" ",h="\\",H=/^\s+$/,F=/(?:[^\\]|^)\\$/,k=/^\\!/,z=/^\\#/,B=/\r?\n/g,K=/^\.*\/|^\.+$/,d="/",x="node-ignore";typeof Symbol<"u"&&(x=Symbol.for("node-ignore"));var L=x,V=(t,e,s)=>Object.defineProperty(t,e,{value:s}),j=/([0-z])-([0-z])/g,G=()=>!1,M=t=>t.replace(j,(e,s,r)=>s.charCodeAt(0)<=r.charCodeAt(0)?e:N),Y=t=>{let{length:e}=t;return t.slice(0,e-e%2);},W=[[/\\?\s+$/,t=>t.indexOf("\\")===0?P:N],[/\\\s/g,()=>P],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)";}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,s)=>e+6{let r=s.replace(/\\\*/g,"[^\\/]*");return e+r;}],[/\\\\\\(?=[$.|*+(){^])/g,()=>h],[/\\\\/g,()=>h],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,s,r,n)=>e===h?`\\[${s}${Y(r)}${n}`:n==="]"&&r.length%2===0?`[${M(s)}${r}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],S=Object.create(null),p=(t,e)=>{let s=S[t];return s||(s=W.reduce((r,n)=>r.replace(n[0],n[1].bind(t)),t),S[t]=s),e?new RegExp(s,"i"):new RegExp(s);},R=t=>typeof t=="string",q=t=>t&&R(t)&&!H.test(t)&&!F.test(t)&&t.indexOf("#")!==0,J=t=>t.split(B),f=class{constructor(e,s,r,n){this.origin=e,this.pattern=s,this.negative=r,this.regex=n;}},Q=(t,e)=>{let s=t,r=!1;t.indexOf("!")===0&&(r=!0,t=t.substr(1)),t=t.replace(k,"!").replace(z,"#");let n=p(t,e);return new f(s,t,r,n);},U=(t,e)=>{throw new e(t);},i=(t,e,s)=>R(t)?t?i.isNotRelative(t)?s(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:s("path must not be empty",TypeError):s(`path must be a string, but got \`${e}\``,TypeError),O=t=>K.test(t);i.isNotRelative=O;i.convert=t=>t;var g=class{constructor({ignorecase:e=!0,ignoreCase:s=e,allowRelativePaths:r=!1}={}){V(this,L,!0),this._rules=[],this._ignoreCase=s,this._allowRelativePaths=r,this._initCache();}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null);}_addPattern(e){if(e&&e[L]){this._rules=this._rules.concat(e._rules),this._added=!0;return;}if(q(e)){let s=Q(e,this._ignoreCase);this._added=!0,this._rules.push(s);}}add(e){return this._added=!1,C(R(e)?J(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this;}addPattern(e){return this.add(e);}_testOne(e,s){let r=!1,n=!1;return this._rules.forEach(o=>{let{negative:u}=o;if(n===u&&r!==n||u&&!r&&!n&&!s)return;o.regex.test(e)&&(r=!u,n=u);}),{ignored:r,unignored:n};}_test(e,s,r,n){let o=e&&i.convert(e);return i(o,e,this._allowRelativePaths?G:U),this._t(o,s,r,n);}_t(e,s,r,n){if(e in s)return s[e];if(n||(n=e.split(d)),n.pop(),!n.length)return s[e]=this._testOne(e,r);let o=this._t(n.join(d)+d,s,r,n);return s[e]=o.ignored?o:this._testOne(e,r);}ignores(e){return this._test(e,this._ignoreCache,!1).ignored;}createFilter(){return e=>!this.ignores(e);}filter(e){return C(e).filter(this.createFilter());}test(e){return this._test(e,this._testCache,!0);}},l=t=>new g(t),Z=t=>i(t&&i.convert(t),t,G);l.isPathValid=Z;l.default=l;v.exports=l;var tt=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");i.convert=tt;var et=/^[a-z]:\//i;i.isNotRelative=t=>et.test(t)||O(t);});var c={};D(c,{default:()=>nt});var st=$(A());_(c,$(A()));var{default:I,...rt}=st,nt=I!==void 0?I:rt;const importMeta={url:"file:///home/runner/work/setup-deno/setup-deno/cache.ts",main:import.meta.main};const args=parseArgs(Deno.args,{boolean:["help","dry-run","debug"],string:["config"],alias:{help:"h",dryRun:"n"},"--":true});const logLevel=args.debug?"DEBUG":"INFO";setup({handlers:{console:new handlers.ConsoleHandler(logLevel,{formatter:logRecord=>Deno.noColor?[logRecord.levelName,logRecord.msg].join(" "):logRecord.msg})},loggers:{default:{handlers:["console"],"level":logLevel}}});const main=async args=>{if(args.help){console.log("Usage: cache [-n | --dry-run] [--debug] [--] [DENO_ARGS...]");Deno.exit(0);}if(args["dry-run"])warning("dry-run mode enabled");if(args.config&&!await exists(args.config)){error(`config file ${args.config} not found`);Deno.exit(1);}const hash=await Deno.readFile("./deno.lock").then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>encodeHex(new Uint8Array(data))).catch(_=>"");debug(`GitHub actions deno.lock hash: ${hash}`);const cfgs=args.config?[args.config]:["deno.json","deno.jsonc"];const denoCfg=await Promise.all(cfgs.map(path=>Deno.readTextFile(path).catch(_=>undefined))).then(v=>parse(v.filter(Boolean)[0]??"{}"));const patterns=[...[denoCfg?.exclude??[]].flat(),...[denoCfg?.cache?.exclude??[]].flat(),...[denoCfg?.cache?.include??[]].flatMap(p=>`!${p}`)];debug(`patterns:`,patterns);patterns.forEach(p=>debug(`- ${p}`));const ig=nt().add(patterns);const walkIterator=walk(".",{exts:["js",".jsx",".ts",".tsx"],includeDirs:false});for await(const entry of walkIterator){const relativePath=relative2(".",entry.path);if(ig.ignores(relativePath)){debug(`ignored ${relativePath}`);continue;}debug(`caching ${relativePath}`);const cmd=new Deno.Command(Deno.execPath(),{args:["cache",args.config&&`--config=${args.config}`,relativePath,...args["--"]].filter(Boolean),stdout:"inherit",stderr:"inherit"});let code=0;if(!args["dry-run"])code=(await cmd.output()).code;if(code===0){info(`cached ${relativePath}`);}else{error(`failed to cache ${entry.path}`);}}};if(importMeta.main)main(args); \ No newline at end of file +#!/usr/bin/env -S deno run --no-lock --allow-read --allow-run=deno --allow-env=CI,DENO_DIR +class AssertionError extends Error{constructor(message){super(message);this.name="AssertionError";}}function assert(expr,msg=""){if(!expr){throw new AssertionError(msg);}}const{hasOwn}=Object;function get(obj,key){if(hasOwn(obj,key)){return obj[key];}}function getForce(obj,key){const v=get(obj,key);assert(v!==undefined);return v;}function isNumber(x){if(typeof x==="number")return true;if(/^0x[0-9a-f]+$/i.test(String(x)))return true;return/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(String(x));}function hasKey(obj,keys){let o=obj;keys.slice(0,-1).forEach(key=>{o=get(o,key)??{};});const key=keys[keys.length-1];return hasOwn(o,key);}function parseArgs(args,{"--":doubleDash=false,alias={},boolean:__boolean=false,default:defaults={},stopEarly=false,string=[],collect=[],negatable=[],unknown=i=>i}={}){const aliases={};const flags={bools:{},strings:{},unknownFn:unknown,allBools:false,collect:{},negatable:{}};if(alias!==undefined){for(const key in alias){const val=getForce(alias,key);if(typeof val==="string"){aliases[key]=[val];}else{aliases[key]=val;}for(const alias of getForce(aliases,key)){aliases[alias]=[key].concat(aliases[key].filter(y=>alias!==y));}}}if(__boolean!==undefined){if(typeof __boolean==="boolean"){flags.allBools=!!__boolean;}else{const booleanArgs=typeof __boolean==="string"?[__boolean]:__boolean;for(const key of booleanArgs.filter(Boolean)){flags.bools[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.bools[al]=true;}}}}}if(string!==undefined){const stringArgs=typeof string==="string"?[string]:string;for(const key of stringArgs.filter(Boolean)){flags.strings[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.strings[al]=true;}}}}if(collect!==undefined){const collectArgs=typeof collect==="string"?[collect]:collect;for(const key of collectArgs.filter(Boolean)){flags.collect[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.collect[al]=true;}}}}if(negatable!==undefined){const negatableArgs=typeof negatable==="string"?[negatable]:negatable;for(const key of negatableArgs.filter(Boolean)){flags.negatable[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.negatable[al]=true;}}}}const argv={_:[]};function argDefined(key,arg){return flags.allBools&&/^--[^=]+$/.test(arg)||get(flags.bools,key)||!!get(flags.strings,key)||!!get(aliases,key);}function setKey(obj,name,value,collect=true){let o=obj;const keys=name.split(".");keys.slice(0,-1).forEach(function(key){if(get(o,key)===undefined){o[key]={};}o=get(o,key);});const key=keys[keys.length-1];const collectable=collect&&!!get(flags.collect,name);if(!collectable){o[key]=value;}else if(get(o,key)===undefined){o[key]=[value];}else if(Array.isArray(get(o,key))){o[key].push(value);}else{o[key]=[get(o,key),value];}}function setArg(key,val,arg=undefined,collect){if(arg&&flags.unknownFn&&!argDefined(key,arg)){if(flags.unknownFn(arg,key,val)===false)return;}const value=!get(flags.strings,key)&&isNumber(val)?Number(val):val;setKey(argv,key,value,collect);const alias=get(aliases,key);if(alias){for(const x of alias){setKey(argv,x,value,collect);}}}function aliasIsBoolean(key){return getForce(aliases,key).some(x=>typeof get(flags.bools,x)==="boolean");}let notFlags=[];if(args.includes("--")){notFlags=args.slice(args.indexOf("--")+1);args=args.slice(0,args.indexOf("--"));}for(let i=0;i>4];dst[i*2+1]=hexTable[v&15];}return textDecoder.decode(dst);}const osType=(()=>{const{Deno:Deno1}=globalThis;if(typeof Deno1?.build?.os==="string"){return Deno1.build.os;}const{navigator}=globalThis;if(navigator?.appVersion?.includes?.("Win")){return"windows";}return"linux";})();const isWindows=osType==="windows";function assertPath(path){if(typeof path!=="string"){throw new TypeError(`Path must be a string. Received ${JSON.stringify(path)}`);}}function assertArg(path){assertPath(path);if(path.length===0)return".";}const CHAR_FORWARD_SLASH=47;function normalizeString(path,allowAboveRoot,separator,isPathSeparator){let res="";let lastSegmentLength=0;let lastSlash=-1;let dots=0;let code;for(let i=0,len=path.length;i<=len;++i){if(i2){const lastSlashIndex=res.lastIndexOf(separator);if(lastSlashIndex===-1){res="";lastSegmentLength=0;}else{res=res.slice(0,lastSlashIndex);lastSegmentLength=res.length-1-res.lastIndexOf(separator);}lastSlash=i;dots=0;continue;}else if(res.length===2||res.length===1){res="";lastSegmentLength=0;lastSlash=i;dots=0;continue;}}if(allowAboveRoot){if(res.length>0)res+=`${separator}..`;else res="..";lastSegmentLength=2;}}else{if(res.length>0)res+=separator+path.slice(lastSlash+1,i);else res=path.slice(lastSlash+1,i);lastSegmentLength=i-lastSlash-1;}lastSlash=i;dots=0;}else if(code===46&&dots!==-1){++dots;}else{dots=-1;}}return res;}function isPosixPathSeparator(code){return code===47;}function normalize(path){assertArg(path);const isAbsolute=isPosixPathSeparator(path.charCodeAt(0));const trailingSeparator=isPosixPathSeparator(path.charCodeAt(path.length-1));path=normalizeString(path,!isAbsolute,"/",isPosixPathSeparator);if(path.length===0&&!isAbsolute)path=".";if(path.length>0&&trailingSeparator)path+="/";if(isAbsolute)return`/${path}`;return path;}function join(...paths){if(paths.length===0)return".";let joined;for(let i=0,len=paths.length;i0){if(!joined)joined=path;else joined+=`/${path}`;}}if(!joined)return".";return normalize(joined);}function isPathSeparator(code){return code===47||code===92;}function isWindowsDeviceRoot(code){return code>=97&&code<=122||code>=65&&code<=90;}function normalize1(path){assertArg(path);const len=path.length;let rootEnd=0;let device;let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){return"\\";}let tail;if(rootEnd0&&isPathSeparator(path.charCodeAt(len-1))){tail+="\\";}if(device===undefined){if(isAbsolute){if(tail.length>0)return`\\${tail}`;else return"\\";}else if(tail.length>0){return tail;}else{return"";}}else if(isAbsolute){if(tail.length>0)return`${device}\\${tail}`;else return`${device}\\`;}else if(tail.length>0){return device+tail;}else{return device;}}function join1(...paths){if(paths.length===0)return".";let joined;let firstPart=null;for(let i=0;i0){if(joined===undefined)joined=firstPart=path;else joined+=`\\${path}`;}}if(joined===undefined)return".";let needsReplace=true;let slashCount=0;assert(firstPart!==null);if(isPathSeparator(firstPart.charCodeAt(0))){++slashCount;const firstLen=firstPart.length;if(firstLen>1){if(isPathSeparator(firstPart.charCodeAt(1))){++slashCount;if(firstLen>2){if(isPathSeparator(firstPart.charCodeAt(2)))++slashCount;else{needsReplace=false;}}}}}if(needsReplace){for(;slashCount=2)joined=`\\${joined.slice(slashCount)}`;}return normalize1(joined);}function join2(...paths){return isWindows?join1(...paths):join(...paths);}function assertArg1(url){url=url instanceof URL?url:new URL(url);if(url.protocol!=="file:"){throw new TypeError("Must be a file URL.");}return url;}function fromFileUrl(url){url=assertArg1(url);return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"));}function fromFileUrl1(url){url=assertArg1(url);let path=decodeURIComponent(url.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");if(url.hostname!==""){path=`\\\\${url.hostname}${path}`;}return path;}function fromFileUrl2(url){return isWindows?fromFileUrl1(url):fromFileUrl(url);}function toPathString(pathUrl){return pathUrl instanceof URL?fromFileUrl2(pathUrl):pathUrl;}function stripTrailingSeparators(segment,isSep){if(segment.length<=1){return segment;}let end=segment.length;for(let i=segment.length-1;i>0;i--){if(isSep(segment.charCodeAt(i))){end=i;}else{break;}}return segment.slice(0,end);}function resolve(...pathSegments){let resolvedPath="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1&&!resolvedAbsolute;i--){let path;if(i>=0)path=pathSegments[i];else{const{Deno:Deno1}=globalThis;if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();}assertPath(path);if(path.length===0){continue;}resolvedPath=`${path}/${resolvedPath}`;resolvedAbsolute=isPosixPathSeparator(path.charCodeAt(0));}resolvedPath=normalizeString(resolvedPath,!resolvedAbsolute,"/",isPosixPathSeparator);if(resolvedAbsolute){if(resolvedPath.length>0)return`/${resolvedPath}`;else return"/";}else if(resolvedPath.length>0)return resolvedPath;else return".";}function resolve1(...pathSegments){let resolvedDevice="";let resolvedTail="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1;i--){let path;const{Deno:Deno1}=globalThis;if(i>=0){path=pathSegments[i];}else if(!resolvedDevice){if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a drive-letter-less path without a CWD.");}path=Deno1.cwd();}else{if(typeof Deno1?.env?.get!=="function"||typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();if(path===undefined||path.slice(0,3).toLowerCase()!==`${resolvedDevice.toLowerCase()}\\`){path=`${resolvedDevice}\\`;}}assertPath(path);const len=path.length;if(len===0)continue;let rootEnd=0;let device="";let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){rootEnd=1;isAbsolute=true;}if(device.length>0&&resolvedDevice.length>0&&device.toLowerCase()!==resolvedDevice.toLowerCase()){continue;}if(resolvedDevice.length===0&&device.length>0){resolvedDevice=device;}if(!resolvedAbsolute){resolvedTail=`${path.slice(rootEnd)}\\${resolvedTail}`;resolvedAbsolute=isAbsolute;}if(resolvedAbsolute&&resolvedDevice.length>0)break;}resolvedTail=normalizeString(resolvedTail,!resolvedAbsolute,"\\",isPathSeparator);return resolvedDevice+(resolvedAbsolute?"\\":"")+resolvedTail||".";}Deno.build.os==="windows";async function exists(path,options){try{const stat=await Deno.stat(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if((await Deno.permissions.query({name:"read",path})).state==="granted"){return!options?.isReadable;}}throw error;}}function existsSync(path,options){try{const stat=Deno.statSync(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if(Deno.permissions.querySync({name:"read",path}).state==="granted"){return!options?.isReadable;}}throw error;}}function normalize2(path){return isWindows?normalize1(path):normalize(path);}function stripSuffix(name,suffix){if(suffix.length>=name.length){return name;}const lenDiff=name.length-suffix.length;for(let i=suffix.length-1;i>=0;--i){if(name.charCodeAt(lenDiff+i)!==suffix.charCodeAt(i)){return name;}}return name.slice(0,-suffix.length);}function lastPathSegment(path,isSep,start=0){let matchedNonSeparator=false;let end=path.length;for(let i=path.length-1;i>=start;--i){if(isSep(path.charCodeAt(i))){if(matchedNonSeparator){start=i+1;break;}}else if(!matchedNonSeparator){matchedNonSeparator=true;end=i+1;}}return path.slice(start,end);}function assertArgs(path,suffix){assertPath(path);if(path.length===0)return path;if(typeof suffix!=="string"){throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);}}function basename(path,suffix=""){assertArgs(path,suffix);const lastSegment=lastPathSegment(path,isPosixPathSeparator);const strippedSegment=stripTrailingSeparators(lastSegment,isPosixPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename1(path,suffix=""){assertArgs(path,suffix);let start=0;if(path.length>=2){const drive=path.charCodeAt(0);if(isWindowsDeviceRoot(drive)){if(path.charCodeAt(1)===58)start=2;}}const lastSegment=lastPathSegment(path,isPathSeparator,start);const strippedSegment=stripTrailingSeparators(lastSegment,isPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename2(path,suffix=""){return isWindows?basename1(path,suffix):basename(path,suffix);}async function createWalkEntry(path){path=toPathString(path);path=normalize2(path);const name=basename2(path);const info=await Deno.stat(path);return{path,name,isFile:info.isFile,isDirectory:info.isDirectory,isSymlink:info.isSymlink};}class WalkError extends Error{root;constructor(cause,root){super(`${cause instanceof Error?cause.message:cause} for path "${root}"`);this.cause=cause;this.name="WalkError";this.root=root;}}function include(path,exts,match,skip){if(exts&&!exts.some(ext=>path.endsWith(ext))){return false;}if(match&&!match.some(pattern=>!!path.match(pattern))){return false;}if(skip&&skip.some(pattern=>!!path.match(pattern))){return false;}return true;}function wrapErrorWithPath(err,root){if(err instanceof WalkError)return err;return new WalkError(err,root);}async function*walk(root,{maxDepth=Infinity,includeFiles=true,includeDirs=true,includeSymlinks=true,followSymlinks=false,canonicalize=true,exts=undefined,match=undefined,skip=undefined}={}){if(maxDepth<0){return;}root=toPathString(root);if(includeDirs&&include(root,exts,match,skip)){yield await createWalkEntry(root);}if(maxDepth<1||!include(root,undefined,undefined,skip)){return;}try{for await(const entry of Deno.readDir(root)){let path=join2(root,entry.name);let{isSymlink,isDirectory}=entry;if(isSymlink){if(!followSymlinks){if(includeSymlinks&&include(path,exts,match,skip)){yield{path,...entry};}continue;}const realPath=await Deno.realPath(path);if(canonicalize){path=realPath;}({isSymlink,isDirectory}=await Deno.lstat(realPath));}if(isSymlink||isDirectory){yield*walk(path,{maxDepth:maxDepth-1,includeFiles,includeDirs,includeSymlinks,followSymlinks,exts,match,skip});}else if(includeFiles&&include(path,exts,match,skip)){yield{path,...entry};}}}catch(err){throw wrapErrorWithPath(err,normalize2(root));}}Deno.build.os==="windows";new Deno.errors.AlreadyExists("dest already exists.");Deno.build.os==="windows";const LF="\n";const CRLF="\r\n";Deno?.build.os==="windows"?CRLF:LF;function parse(text,{allowTrailingComma=true}={}){if(new.target){throw new TypeError("parse is not a constructor");}return new JSONCParser(text,{allowTrailingComma}).parse();}const originalJSONParse=globalThis.JSON.parse;class JSONCParser{#whitespace=new Set(" \r\n");#numberEndToken=new Set([..."[]{}:,/",...this.#whitespace]);#text;#length;#tokenized;#options;constructor(text,options){this.#text=`${text}`;this.#length=this.#text.length;this.#tokenized=this.#tokenize();this.#options=options;}parse(){const token=this.#getNext();const res=this.#parseJsonValue(token);const{done,value}=this.#tokenized.next();if(!done){throw new SyntaxError(buildErrorMessage(value));}return res;}#getNext(){const{done,value}=this.#tokenized.next();if(done){throw new SyntaxError("Unexpected end of JSONC input");}return value;}*#tokenize(){for(let i=0;iisNaN(Number(key)));const byLevel={[LogLevels.NOTSET]:"NOTSET",[LogLevels.DEBUG]:"DEBUG",[LogLevels.INFO]:"INFO",[LogLevels.WARNING]:"WARNING",[LogLevels.ERROR]:"ERROR",[LogLevels.CRITICAL]:"CRITICAL"};function getLevelByName(name){const level=LogLevels[name];if(level!==undefined){return level;}throw new Error(`no log level found for name: ${name}`);}function getLevelName(level){const levelName=byLevel[level];if(levelName){return levelName;}throw new Error(`no level name found for level: ${level}`);}class LogRecord{msg;#args;#datetime;level;levelName;loggerName;constructor(options){this.msg=options.msg;this.#args=[...options.args];this.level=options.level;this.loggerName=options.loggerName;this.#datetime=new Date;this.levelName=getLevelName(options.level);}get args(){return[...this.#args];}get datetime(){return new Date(this.#datetime.getTime());}}class Logger{#level;#handlers;#loggerName;constructor(loggerName,levelName,options={}){this.#loggerName=loggerName;this.#level=getLevelByName(levelName);this.#handlers=options.handlers||[];}get level(){return this.#level;}set level(level){try{this.#level=getLevelByName(getLevelName(level));}catch(_){throw new TypeError(`Invalid log level: ${level}`);}}get levelName(){return getLevelName(this.#level);}set levelName(levelName){this.#level=getLevelByName(levelName);}get loggerName(){return this.#loggerName;}set handlers(hndls){this.#handlers=hndls;}get handlers(){return this.#handlers;}#_log(level,msg,...args){if(this.level>level){return msg instanceof Function?undefined:msg;}let fnResult;let logMessage;if(msg instanceof Function){fnResult=msg();logMessage=this.asString(fnResult);}else{logMessage=this.asString(msg);}const record=new LogRecord({msg:logMessage,args:args,level:level,loggerName:this.loggerName});this.#handlers.forEach(handler=>{handler.handle(record);});return msg instanceof Function?fnResult:msg;}asString(data,isProperty=false){if(typeof data==="string"){if(isProperty)return`"${data}"`;return data;}else if(data===null||typeof data==="number"||typeof data==="bigint"||typeof data==="boolean"||typeof data==="undefined"||typeof data==="symbol"){return String(data);}else if(data instanceof Error){return data.stack;}else if(typeof data==="object"){return`{${Object.entries(data).map(([k,v])=>`"${k}":${this.asString(v,true)}`).join(",")}}`;}return"undefined";}debug(msg,...args){return this.#_log(LogLevels.DEBUG,msg,...args);}info(msg,...args){return this.#_log(LogLevels.INFO,msg,...args);}warning(msg,...args){return this.#_log(LogLevels.WARNING,msg,...args);}error(msg,...args){return this.#_log(LogLevels.ERROR,msg,...args);}critical(msg,...args){return this.#_log(LogLevels.CRITICAL,msg,...args);}}const{Deno:Deno1}=globalThis;const noColor=typeof Deno1?.noColor==="boolean"?Deno1.noColor:false;let enabled=!noColor;function code(open,close){return{open:`\x1b[${open.join(";")}m`,close:`\x1b[${close}m`,regexp:new RegExp(`\\x1b\\[${close}m`,"g")};}function run(str,code){return enabled?`${code.open}${str.replace(code.regexp,code.open)}${code.close}`:str;}function bold(str){return run(str,code([1],22));}function red(str){return run(str,code([31],39));}function yellow(str){return run(str,code([33],39));}function blue(str){return run(str,code([34],39));}new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"),"g");function copy(src,dst,off=0){off=Math.max(0,Math.min(off,dst.byteLength));const dstBytesAvailable=dst.byteLength-off;if(src.byteLength>dstBytesAvailable){src=src.subarray(0,dstBytesAvailable);}dst.set(src,off);return src.byteLength;}class AbstractBufBase{buf;usedBufferBytes=0;err=null;constructor(buf){this.buf=buf;}size(){return this.buf.byteLength;}available(){return this.buf.byteLength-this.usedBufferBytes;}buffered(){return this.usedBufferBytes;}}class BufWriterSync extends AbstractBufBase{#writer;static create(writer,size=4096){return writer instanceof BufWriterSync?writer:new BufWriterSync(writer,size);}constructor(writer,size=4096){super(new Uint8Array(size<=0?4096:size));this.#writer=writer;}reset(w){this.err=null;this.usedBufferBytes=0;this.#writer=w;}flush(){if(this.err!==null)throw this.err;if(this.usedBufferBytes===0)return;try{const p=this.buf.subarray(0,this.usedBufferBytes);let nwritten=0;while(nwrittenthis.available()){if(this.buffered()===0){try{numBytesWritten=this.#writer.writeSync(data);}catch(e){if(e instanceof Error){this.err=e;}throw e;}}else{numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;this.flush();}totalBytesWritten+=numBytesWritten;data=data.subarray(numBytesWritten);}numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;totalBytesWritten+=numBytesWritten;return totalBytesWritten;}}const DEFAULT_FORMATTER="{levelName} {msg}";class BaseHandler{level;levelName;formatter;constructor(levelName,options={}){this.level=getLevelByName(levelName);this.levelName=levelName;this.formatter=options.formatter||DEFAULT_FORMATTER;}handle(logRecord){if(this.level>logRecord.level)return;const msg=this.format(logRecord);this.log(msg);}format(logRecord){if(this.formatter instanceof Function){return this.formatter(logRecord);}return this.formatter.replace(/{([^\s}]+)}/g,(match,p1)=>{const value=logRecord[p1];if(value===undefined){return match;}return String(value);});}log(_msg){}setup(){}destroy(){}}class ConsoleHandler extends BaseHandler{#useColors;constructor(levelName,options={}){super(levelName,options);this.#useColors=options.useColors??true;}format(logRecord){let msg=super.format(logRecord);if(this.#useColors){msg=this.applyColors(msg,logRecord.level);}return msg;}applyColors(msg,level){switch(level){case LogLevels.INFO:msg=blue(msg);break;case LogLevels.WARNING:msg=yellow(msg);break;case LogLevels.ERROR:msg=red(msg);break;case LogLevels.CRITICAL:msg=bold(red(msg));break;default:break;}return msg;}log(msg){console.log(msg);}}class WriterHandler extends BaseHandler{_writer;#encoder=new TextEncoder;}class FileHandler extends WriterHandler{_file;_buf;_filename;_mode;_openOptions;_encoder=new TextEncoder;#unloadCallback=(()=>{this.destroy();}).bind(this);constructor(levelName,options){super(levelName,options);this._filename=options.filename;this._mode=options.mode?options.mode:"a";this._openOptions={createNew:this._mode==="x",create:this._mode!=="x",append:this._mode==="a",truncate:this._mode!=="a",write:true};}setup(){this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);addEventListener("unload",this.#unloadCallback);}handle(logRecord){super.handle(logRecord);if(logRecord.level>LogLevels.ERROR){this.flush();}}log(msg){if(this._encoder.encode(msg).byteLength+1>this._buf.available()){this.flush();}this._buf.writeSync(this._encoder.encode(msg+"\n"));}flush(){if(this._buf?.buffered()>0){this._buf.flush();}}destroy(){this.flush();this._file?.close();this._file=undefined;removeEventListener("unload",this.#unloadCallback);}}class RotatingFileHandler extends FileHandler{#maxBytes;#maxBackupCount;#currentFileSize=0;constructor(levelName,options){super(levelName,options);this.#maxBytes=options.maxBytes;this.#maxBackupCount=options.maxBackupCount;}setup(){if(this.#maxBytes<1){this.destroy();throw new Error("maxBytes cannot be less than 1");}if(this.#maxBackupCount<1){this.destroy();throw new Error("maxBackupCount cannot be less than 1");}super.setup();if(this._mode==="w"){for(let i=1;i<=this.#maxBackupCount;i++){try{Deno.removeSync(this._filename+"."+i);}catch(error){if(!(error instanceof Deno.errors.NotFound)){throw error;}}}}else if(this._mode==="x"){for(let i=1;i<=this.#maxBackupCount;i++){if(existsSync(this._filename+"."+i)){this.destroy();throw new Deno.errors.AlreadyExists("Backup log file "+this._filename+"."+i+" already exists");}}}else{this.#currentFileSize=Deno.statSync(this._filename).size;}}log(msg){const msgByteLength=this._encoder.encode(msg).byteLength+1;if(this.#currentFileSize+msgByteLength>this.#maxBytes){this.rotateLogFiles();this.#currentFileSize=0;}super.log(msg);this.#currentFileSize+=msgByteLength;}rotateLogFiles(){this._buf.flush();this._file.close();for(let i=this.#maxBackupCount-1;i>=0;i--){const source=this._filename+(i===0?"":"."+i);const dest=this._filename+"."+(i+1);if(existsSync(source)){Deno.renameSync(source,dest);}}this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);}}const DEFAULT_LEVEL="INFO";const DEFAULT_CONFIG={handlers:{default:new ConsoleHandler(DEFAULT_LEVEL)},loggers:{default:{level:DEFAULT_LEVEL,handlers:["default"]}}};const state={handlers:new Map,loggers:new Map,config:DEFAULT_CONFIG};const handlers={BaseHandler,ConsoleHandler,WriterHandler,FileHandler,RotatingFileHandler};function getLogger(name){if(!name){const d=state.loggers.get("default");assert(d!==undefined,`"default" logger must be set for getting logger without name`);return d;}const result=state.loggers.get(name);if(!result){const logger=new Logger(name,"NOTSET",{handlers:[]});state.loggers.set(name,logger);return logger;}return result;}function debug(msg,...args){if(msg instanceof Function){return getLogger("default").debug(msg,...args);}return getLogger("default").debug(msg,...args);}function warning(msg,...args){if(msg instanceof Function){return getLogger("default").warning(msg,...args);}return getLogger("default").warning(msg,...args);}function error(msg,...args){if(msg instanceof Function){return getLogger("default").error(msg,...args);}return getLogger("default").error(msg,...args);}function setup(config){state.config={handlers:{...DEFAULT_CONFIG.handlers,...config.handlers},loggers:{...DEFAULT_CONFIG.loggers,...config.loggers}};state.handlers.forEach(handler=>{handler.destroy();});state.handlers.clear();const handlers=state.config.handlers||{};for(const handlerName in handlers){const handler=handlers[handlerName];handler.setup();state.handlers.set(handlerName,handler);}state.loggers.clear();const loggers=state.config.loggers||{};for(const loggerName in loggers){const loggerConfig=loggers[loggerName];const handlerNames=loggerConfig.handlers||[];const handlers=[];handlerNames.forEach(handlerName=>{const handler=state.handlers.get(handlerName);if(handler){handlers.push(handler);}});const levelName=loggerConfig.level||DEFAULT_LEVEL;const logger=new Logger(loggerName,levelName,{handlers:handlers});state.loggers.set(loggerName,logger);}}setup(DEFAULT_CONFIG);function assertArgs1(from,to){assertPath(from);assertPath(to);if(from===to)return"";}function relative(from,to){assertArgs1(from,to);from=resolve(from);to=resolve(to);if(from===to)return"";let fromStart=1;const fromEnd=from.length;for(;fromStartlength){if(isPosixPathSeparator(to.charCodeAt(toStart+i))){return to.slice(toStart+i+1);}else if(i===0){return to.slice(toStart+i);}}else if(fromLen>length){if(isPosixPathSeparator(from.charCodeAt(fromStart+i))){lastCommonSep=i;}else if(i===0){lastCommonSep=0;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(isPosixPathSeparator(fromCode))lastCommonSep=i;}let out="";for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||isPosixPathSeparator(from.charCodeAt(i))){if(out.length===0)out+="..";else out+="/..";}}if(out.length>0)return out+to.slice(toStart+lastCommonSep);else{toStart+=lastCommonSep;if(isPosixPathSeparator(to.charCodeAt(toStart)))++toStart;return to.slice(toStart);}}function relative1(from,to){assertArgs1(from,to);const fromOrig=resolve1(from);const toOrig=resolve1(to);if(fromOrig===toOrig)return"";from=fromOrig.toLowerCase();to=toOrig.toLowerCase();if(from===to)return"";let fromStart=0;let fromEnd=from.length;for(;fromStartfromStart;--fromEnd){if(from.charCodeAt(fromEnd-1)!==92)break;}const fromLen=fromEnd-fromStart;let toStart=0;let toEnd=to.length;for(;toStarttoStart;--toEnd){if(to.charCodeAt(toEnd-1)!==92)break;}const toLen=toEnd-toStart;const length=fromLenlength){if(to.charCodeAt(toStart+i)===92){return toOrig.slice(toStart+i+1);}else if(i===2){return toOrig.slice(toStart+i);}}if(fromLen>length){if(from.charCodeAt(fromStart+i)===92){lastCommonSep=i;}else if(i===2){lastCommonSep=3;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(fromCode===92)lastCommonSep=i;}if(i!==length&&lastCommonSep===-1){return toOrig;}let out="";if(lastCommonSep===-1)lastCommonSep=0;for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||from.charCodeAt(i)===92){if(out.length===0)out+="..";else out+="\\..";}}if(out.length>0){return out+toOrig.slice(toStart+lastCommonSep,toEnd);}else{toStart+=lastCommonSep;if(toOrig.charCodeAt(toStart)===92)++toStart;return toOrig.slice(toStart,toEnd);}}function relative2(from,to){return isWindows?relative1(from,to):relative(from,to);}var m=Object.create;var E=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),D=(t,e)=>{for(var s in e)E(t,s,{get:e[s],enumerable:!0});},a=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!b.call(t,n)&&n!==s&&E(t,n,{get:()=>e[n],enumerable:!(r=T(e,n))||r.enumerable});return t;},_=(t,e,s)=>(a(t,e,"default"),s&&a(s,e,"default")),$=(t,e,s)=>(s=t!=null?m(X(t)):{},a(e||!t||!t.__esModule?E(s,"default",{value:t,enumerable:!0}):s,t));var A=w((ct,v)=>{function C(t){return Array.isArray(t)?t:[t];}var N="",P=" ",h="\\",H=/^\s+$/,F=/(?:[^\\]|^)\\$/,k=/^\\!/,z=/^\\#/,B=/\r?\n/g,K=/^\.*\/|^\.+$/,d="/",x="node-ignore";typeof Symbol<"u"&&(x=Symbol.for("node-ignore"));var L=x,V=(t,e,s)=>Object.defineProperty(t,e,{value:s}),j=/([0-z])-([0-z])/g,G=()=>!1,M=t=>t.replace(j,(e,s,r)=>s.charCodeAt(0)<=r.charCodeAt(0)?e:N),Y=t=>{let{length:e}=t;return t.slice(0,e-e%2);},W=[[/\\?\s+$/,t=>t.indexOf("\\")===0?P:N],[/\\\s/g,()=>P],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)";}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,s)=>e+6{let r=s.replace(/\\\*/g,"[^\\/]*");return e+r;}],[/\\\\\\(?=[$.|*+(){^])/g,()=>h],[/\\\\/g,()=>h],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,s,r,n)=>e===h?`\\[${s}${Y(r)}${n}`:n==="]"&&r.length%2===0?`[${M(s)}${r}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],S=Object.create(null),p=(t,e)=>{let s=S[t];return s||(s=W.reduce((r,n)=>r.replace(n[0],n[1].bind(t)),t),S[t]=s),e?new RegExp(s,"i"):new RegExp(s);},R=t=>typeof t=="string",q=t=>t&&R(t)&&!H.test(t)&&!F.test(t)&&t.indexOf("#")!==0,J=t=>t.split(B),f=class{constructor(e,s,r,n){this.origin=e,this.pattern=s,this.negative=r,this.regex=n;}},Q=(t,e)=>{let s=t,r=!1;t.indexOf("!")===0&&(r=!0,t=t.substr(1)),t=t.replace(k,"!").replace(z,"#");let n=p(t,e);return new f(s,t,r,n);},U=(t,e)=>{throw new e(t);},i=(t,e,s)=>R(t)?t?i.isNotRelative(t)?s(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:s("path must not be empty",TypeError):s(`path must be a string, but got \`${e}\``,TypeError),O=t=>K.test(t);i.isNotRelative=O;i.convert=t=>t;var g=class{constructor({ignorecase:e=!0,ignoreCase:s=e,allowRelativePaths:r=!1}={}){V(this,L,!0),this._rules=[],this._ignoreCase=s,this._allowRelativePaths=r,this._initCache();}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null);}_addPattern(e){if(e&&e[L]){this._rules=this._rules.concat(e._rules),this._added=!0;return;}if(q(e)){let s=Q(e,this._ignoreCase);this._added=!0,this._rules.push(s);}}add(e){return this._added=!1,C(R(e)?J(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this;}addPattern(e){return this.add(e);}_testOne(e,s){let r=!1,n=!1;return this._rules.forEach(o=>{let{negative:u}=o;if(n===u&&r!==n||u&&!r&&!n&&!s)return;o.regex.test(e)&&(r=!u,n=u);}),{ignored:r,unignored:n};}_test(e,s,r,n){let o=e&&i.convert(e);return i(o,e,this._allowRelativePaths?G:U),this._t(o,s,r,n);}_t(e,s,r,n){if(e in s)return s[e];if(n||(n=e.split(d)),n.pop(),!n.length)return s[e]=this._testOne(e,r);let o=this._t(n.join(d)+d,s,r,n);return s[e]=o.ignored?o:this._testOne(e,r);}ignores(e){return this._test(e,this._ignoreCache,!1).ignored;}createFilter(){return e=>!this.ignores(e);}filter(e){return C(e).filter(this.createFilter());}test(e){return this._test(e,this._testCache,!0);}},l=t=>new g(t),Z=t=>i(t&&i.convert(t),t,G);l.isPathValid=Z;l.default=l;v.exports=l;var tt=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");i.convert=tt;var et=/^[a-z]:\//i;i.isNotRelative=t=>et.test(t)||O(t);});var c={};D(c,{default:()=>nt});var st=$(A());_(c,$(A()));var{default:I,...rt}=st,nt=I!==void 0?I:rt;const importMeta={url:"file:///home/runner/work/setup-deno/setup-deno/cache.ts",main:import.meta.main};if(importMeta.main){const args=parseArgs(Deno.args,{boolean:["help","dry-run","verbose","lock-write"],negatable:["lock-write"],string:["config"],default:{"lock-write":true},alias:{help:"h","dry-run":"n"},"--":true});const denoDir=Deno.env.get("DENO_DIR");const logLevel=Deno.env.get("CI")==="1"?"DEBUG":args.verbose?"DEBUG":"INFO";setup({handlers:{console:new handlers.ConsoleHandler(logLevel,{formatter:logRecord=>Deno.noColor?[logRecord.levelName,logRecord.msg].join(" "):logRecord.msg})},loggers:{default:{handlers:["console"],"level":logLevel}}});if(args.help){console.log("Usage: cache [-n | --dry-run] [-v | --verbose] [--] [DENO_ARGS...]");Deno.exit(0);}if(args["dry-run"])warning("dry-run mode enabled");if(args.config&&!await exists(args.config)){error(`config file ${args.config} not found`);Deno.exit(1);}const hash=await Deno.readFile("./deno.lock").then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>encodeHex(new Uint8Array(data))).catch(_=>"");debug(`GitHub actions deno.lock hash: ${hash}`);const cfgs=args.config?[args.config]:["deno.json","deno.jsonc"];const denoCfg=await Promise.all(cfgs.map(path=>Deno.readTextFile(path).catch(_=>undefined))).then(v=>parse(v.filter(Boolean)[0]??"{}"));const patterns=[...[denoCfg?.exclude??[]].flat(),...[denoCfg?.cache?.exclude??[]].flat(),...[denoCfg?.cache?.include??[]].flatMap(p=>`!${p}`)];debug(`patterns:`,patterns);patterns.forEach(p=>debug(`- ${p}`));const ig=nt().add(patterns);const walkIterator=walk(".",{exts:["js",".jsx",".ts",".tsx"],includeDirs:false});const paths=[];for await(const entry of walkIterator){const relativePath=relative2(".",entry.path);if(denoDir&&entry.path.startsWith(denoDir))continue;if(ig.ignores(relativePath)){debug(`ignored ${relativePath}`);continue;}debug(`caching ${relativePath}`);paths.push(relativePath);}const cmd=new Deno.Command(Deno.execPath(),{args:["cache",args["lock-write"]&&"--lock-write",args.config&&`--config=${args.config}`,...args["--"],...paths].filter(Boolean),stdout:"inherit",stderr:"inherit"});const code=!args["dry-run"]?(await cmd.output()).code:0;if(code===0)debug(`finished caching ${paths.length} files`);} \ No newline at end of file From 88dfa06f3360ddeb1d6875ce36544658ebd87085 Mon Sep 17 00:00:00 2001 From: winston Date: Tue, 26 Dec 2023 21:38:05 +0100 Subject: [PATCH 11/18] chore: adjust task permissions --- deno.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deno.json b/deno.json index a569be6..1ac50a9 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "tasks": { - "cache": "deno run --allow-read --allow-run=deno ./cache.ts" + "cache": "deno run --no-lock --allow-read --allow-run=deno --allow-env=CI,DENO_DIR ./cache.ts" }, "imports": { "std/": "https://deno.land/std@0.207.0/", From 2429e1c689c39a7c4905bbd652d08b81d92ca0fd Mon Sep 17 00:00:00 2001 From: winston Date: Tue, 26 Dec 2023 21:46:06 +0100 Subject: [PATCH 12/18] fix: actions being silly --- cache.ts | 2 +- dist/cache.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cache.ts b/cache.ts index 79e5533..1e7069d 100755 --- a/cache.ts +++ b/cache.ts @@ -24,7 +24,7 @@ if (import.meta.main) { }); const denoDir = Deno.env.get("DENO_DIR"); - const logLevel = Deno.env.get("CI") === "1" + const logLevel = ["1", "true"].includes(Deno.env.get("CI") ?? "") ? "DEBUG" : (args.verbose ? "DEBUG" : "INFO"); log.setup({ diff --git a/dist/cache.js b/dist/cache.js index 2ca99f9..c6d82b2 100755 --- a/dist/cache.js +++ b/dist/cache.js @@ -1,2 +1,2 @@ #!/usr/bin/env -S deno run --no-lock --allow-read --allow-run=deno --allow-env=CI,DENO_DIR -class AssertionError extends Error{constructor(message){super(message);this.name="AssertionError";}}function assert(expr,msg=""){if(!expr){throw new AssertionError(msg);}}const{hasOwn}=Object;function get(obj,key){if(hasOwn(obj,key)){return obj[key];}}function getForce(obj,key){const v=get(obj,key);assert(v!==undefined);return v;}function isNumber(x){if(typeof x==="number")return true;if(/^0x[0-9a-f]+$/i.test(String(x)))return true;return/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(String(x));}function hasKey(obj,keys){let o=obj;keys.slice(0,-1).forEach(key=>{o=get(o,key)??{};});const key=keys[keys.length-1];return hasOwn(o,key);}function parseArgs(args,{"--":doubleDash=false,alias={},boolean:__boolean=false,default:defaults={},stopEarly=false,string=[],collect=[],negatable=[],unknown=i=>i}={}){const aliases={};const flags={bools:{},strings:{},unknownFn:unknown,allBools:false,collect:{},negatable:{}};if(alias!==undefined){for(const key in alias){const val=getForce(alias,key);if(typeof val==="string"){aliases[key]=[val];}else{aliases[key]=val;}for(const alias of getForce(aliases,key)){aliases[alias]=[key].concat(aliases[key].filter(y=>alias!==y));}}}if(__boolean!==undefined){if(typeof __boolean==="boolean"){flags.allBools=!!__boolean;}else{const booleanArgs=typeof __boolean==="string"?[__boolean]:__boolean;for(const key of booleanArgs.filter(Boolean)){flags.bools[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.bools[al]=true;}}}}}if(string!==undefined){const stringArgs=typeof string==="string"?[string]:string;for(const key of stringArgs.filter(Boolean)){flags.strings[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.strings[al]=true;}}}}if(collect!==undefined){const collectArgs=typeof collect==="string"?[collect]:collect;for(const key of collectArgs.filter(Boolean)){flags.collect[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.collect[al]=true;}}}}if(negatable!==undefined){const negatableArgs=typeof negatable==="string"?[negatable]:negatable;for(const key of negatableArgs.filter(Boolean)){flags.negatable[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.negatable[al]=true;}}}}const argv={_:[]};function argDefined(key,arg){return flags.allBools&&/^--[^=]+$/.test(arg)||get(flags.bools,key)||!!get(flags.strings,key)||!!get(aliases,key);}function setKey(obj,name,value,collect=true){let o=obj;const keys=name.split(".");keys.slice(0,-1).forEach(function(key){if(get(o,key)===undefined){o[key]={};}o=get(o,key);});const key=keys[keys.length-1];const collectable=collect&&!!get(flags.collect,name);if(!collectable){o[key]=value;}else if(get(o,key)===undefined){o[key]=[value];}else if(Array.isArray(get(o,key))){o[key].push(value);}else{o[key]=[get(o,key),value];}}function setArg(key,val,arg=undefined,collect){if(arg&&flags.unknownFn&&!argDefined(key,arg)){if(flags.unknownFn(arg,key,val)===false)return;}const value=!get(flags.strings,key)&&isNumber(val)?Number(val):val;setKey(argv,key,value,collect);const alias=get(aliases,key);if(alias){for(const x of alias){setKey(argv,x,value,collect);}}}function aliasIsBoolean(key){return getForce(aliases,key).some(x=>typeof get(flags.bools,x)==="boolean");}let notFlags=[];if(args.includes("--")){notFlags=args.slice(args.indexOf("--")+1);args=args.slice(0,args.indexOf("--"));}for(let i=0;i>4];dst[i*2+1]=hexTable[v&15];}return textDecoder.decode(dst);}const osType=(()=>{const{Deno:Deno1}=globalThis;if(typeof Deno1?.build?.os==="string"){return Deno1.build.os;}const{navigator}=globalThis;if(navigator?.appVersion?.includes?.("Win")){return"windows";}return"linux";})();const isWindows=osType==="windows";function assertPath(path){if(typeof path!=="string"){throw new TypeError(`Path must be a string. Received ${JSON.stringify(path)}`);}}function assertArg(path){assertPath(path);if(path.length===0)return".";}const CHAR_FORWARD_SLASH=47;function normalizeString(path,allowAboveRoot,separator,isPathSeparator){let res="";let lastSegmentLength=0;let lastSlash=-1;let dots=0;let code;for(let i=0,len=path.length;i<=len;++i){if(i2){const lastSlashIndex=res.lastIndexOf(separator);if(lastSlashIndex===-1){res="";lastSegmentLength=0;}else{res=res.slice(0,lastSlashIndex);lastSegmentLength=res.length-1-res.lastIndexOf(separator);}lastSlash=i;dots=0;continue;}else if(res.length===2||res.length===1){res="";lastSegmentLength=0;lastSlash=i;dots=0;continue;}}if(allowAboveRoot){if(res.length>0)res+=`${separator}..`;else res="..";lastSegmentLength=2;}}else{if(res.length>0)res+=separator+path.slice(lastSlash+1,i);else res=path.slice(lastSlash+1,i);lastSegmentLength=i-lastSlash-1;}lastSlash=i;dots=0;}else if(code===46&&dots!==-1){++dots;}else{dots=-1;}}return res;}function isPosixPathSeparator(code){return code===47;}function normalize(path){assertArg(path);const isAbsolute=isPosixPathSeparator(path.charCodeAt(0));const trailingSeparator=isPosixPathSeparator(path.charCodeAt(path.length-1));path=normalizeString(path,!isAbsolute,"/",isPosixPathSeparator);if(path.length===0&&!isAbsolute)path=".";if(path.length>0&&trailingSeparator)path+="/";if(isAbsolute)return`/${path}`;return path;}function join(...paths){if(paths.length===0)return".";let joined;for(let i=0,len=paths.length;i0){if(!joined)joined=path;else joined+=`/${path}`;}}if(!joined)return".";return normalize(joined);}function isPathSeparator(code){return code===47||code===92;}function isWindowsDeviceRoot(code){return code>=97&&code<=122||code>=65&&code<=90;}function normalize1(path){assertArg(path);const len=path.length;let rootEnd=0;let device;let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){return"\\";}let tail;if(rootEnd0&&isPathSeparator(path.charCodeAt(len-1))){tail+="\\";}if(device===undefined){if(isAbsolute){if(tail.length>0)return`\\${tail}`;else return"\\";}else if(tail.length>0){return tail;}else{return"";}}else if(isAbsolute){if(tail.length>0)return`${device}\\${tail}`;else return`${device}\\`;}else if(tail.length>0){return device+tail;}else{return device;}}function join1(...paths){if(paths.length===0)return".";let joined;let firstPart=null;for(let i=0;i0){if(joined===undefined)joined=firstPart=path;else joined+=`\\${path}`;}}if(joined===undefined)return".";let needsReplace=true;let slashCount=0;assert(firstPart!==null);if(isPathSeparator(firstPart.charCodeAt(0))){++slashCount;const firstLen=firstPart.length;if(firstLen>1){if(isPathSeparator(firstPart.charCodeAt(1))){++slashCount;if(firstLen>2){if(isPathSeparator(firstPart.charCodeAt(2)))++slashCount;else{needsReplace=false;}}}}}if(needsReplace){for(;slashCount=2)joined=`\\${joined.slice(slashCount)}`;}return normalize1(joined);}function join2(...paths){return isWindows?join1(...paths):join(...paths);}function assertArg1(url){url=url instanceof URL?url:new URL(url);if(url.protocol!=="file:"){throw new TypeError("Must be a file URL.");}return url;}function fromFileUrl(url){url=assertArg1(url);return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"));}function fromFileUrl1(url){url=assertArg1(url);let path=decodeURIComponent(url.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");if(url.hostname!==""){path=`\\\\${url.hostname}${path}`;}return path;}function fromFileUrl2(url){return isWindows?fromFileUrl1(url):fromFileUrl(url);}function toPathString(pathUrl){return pathUrl instanceof URL?fromFileUrl2(pathUrl):pathUrl;}function stripTrailingSeparators(segment,isSep){if(segment.length<=1){return segment;}let end=segment.length;for(let i=segment.length-1;i>0;i--){if(isSep(segment.charCodeAt(i))){end=i;}else{break;}}return segment.slice(0,end);}function resolve(...pathSegments){let resolvedPath="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1&&!resolvedAbsolute;i--){let path;if(i>=0)path=pathSegments[i];else{const{Deno:Deno1}=globalThis;if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();}assertPath(path);if(path.length===0){continue;}resolvedPath=`${path}/${resolvedPath}`;resolvedAbsolute=isPosixPathSeparator(path.charCodeAt(0));}resolvedPath=normalizeString(resolvedPath,!resolvedAbsolute,"/",isPosixPathSeparator);if(resolvedAbsolute){if(resolvedPath.length>0)return`/${resolvedPath}`;else return"/";}else if(resolvedPath.length>0)return resolvedPath;else return".";}function resolve1(...pathSegments){let resolvedDevice="";let resolvedTail="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1;i--){let path;const{Deno:Deno1}=globalThis;if(i>=0){path=pathSegments[i];}else if(!resolvedDevice){if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a drive-letter-less path without a CWD.");}path=Deno1.cwd();}else{if(typeof Deno1?.env?.get!=="function"||typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();if(path===undefined||path.slice(0,3).toLowerCase()!==`${resolvedDevice.toLowerCase()}\\`){path=`${resolvedDevice}\\`;}}assertPath(path);const len=path.length;if(len===0)continue;let rootEnd=0;let device="";let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){rootEnd=1;isAbsolute=true;}if(device.length>0&&resolvedDevice.length>0&&device.toLowerCase()!==resolvedDevice.toLowerCase()){continue;}if(resolvedDevice.length===0&&device.length>0){resolvedDevice=device;}if(!resolvedAbsolute){resolvedTail=`${path.slice(rootEnd)}\\${resolvedTail}`;resolvedAbsolute=isAbsolute;}if(resolvedAbsolute&&resolvedDevice.length>0)break;}resolvedTail=normalizeString(resolvedTail,!resolvedAbsolute,"\\",isPathSeparator);return resolvedDevice+(resolvedAbsolute?"\\":"")+resolvedTail||".";}Deno.build.os==="windows";async function exists(path,options){try{const stat=await Deno.stat(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if((await Deno.permissions.query({name:"read",path})).state==="granted"){return!options?.isReadable;}}throw error;}}function existsSync(path,options){try{const stat=Deno.statSync(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if(Deno.permissions.querySync({name:"read",path}).state==="granted"){return!options?.isReadable;}}throw error;}}function normalize2(path){return isWindows?normalize1(path):normalize(path);}function stripSuffix(name,suffix){if(suffix.length>=name.length){return name;}const lenDiff=name.length-suffix.length;for(let i=suffix.length-1;i>=0;--i){if(name.charCodeAt(lenDiff+i)!==suffix.charCodeAt(i)){return name;}}return name.slice(0,-suffix.length);}function lastPathSegment(path,isSep,start=0){let matchedNonSeparator=false;let end=path.length;for(let i=path.length-1;i>=start;--i){if(isSep(path.charCodeAt(i))){if(matchedNonSeparator){start=i+1;break;}}else if(!matchedNonSeparator){matchedNonSeparator=true;end=i+1;}}return path.slice(start,end);}function assertArgs(path,suffix){assertPath(path);if(path.length===0)return path;if(typeof suffix!=="string"){throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);}}function basename(path,suffix=""){assertArgs(path,suffix);const lastSegment=lastPathSegment(path,isPosixPathSeparator);const strippedSegment=stripTrailingSeparators(lastSegment,isPosixPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename1(path,suffix=""){assertArgs(path,suffix);let start=0;if(path.length>=2){const drive=path.charCodeAt(0);if(isWindowsDeviceRoot(drive)){if(path.charCodeAt(1)===58)start=2;}}const lastSegment=lastPathSegment(path,isPathSeparator,start);const strippedSegment=stripTrailingSeparators(lastSegment,isPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename2(path,suffix=""){return isWindows?basename1(path,suffix):basename(path,suffix);}async function createWalkEntry(path){path=toPathString(path);path=normalize2(path);const name=basename2(path);const info=await Deno.stat(path);return{path,name,isFile:info.isFile,isDirectory:info.isDirectory,isSymlink:info.isSymlink};}class WalkError extends Error{root;constructor(cause,root){super(`${cause instanceof Error?cause.message:cause} for path "${root}"`);this.cause=cause;this.name="WalkError";this.root=root;}}function include(path,exts,match,skip){if(exts&&!exts.some(ext=>path.endsWith(ext))){return false;}if(match&&!match.some(pattern=>!!path.match(pattern))){return false;}if(skip&&skip.some(pattern=>!!path.match(pattern))){return false;}return true;}function wrapErrorWithPath(err,root){if(err instanceof WalkError)return err;return new WalkError(err,root);}async function*walk(root,{maxDepth=Infinity,includeFiles=true,includeDirs=true,includeSymlinks=true,followSymlinks=false,canonicalize=true,exts=undefined,match=undefined,skip=undefined}={}){if(maxDepth<0){return;}root=toPathString(root);if(includeDirs&&include(root,exts,match,skip)){yield await createWalkEntry(root);}if(maxDepth<1||!include(root,undefined,undefined,skip)){return;}try{for await(const entry of Deno.readDir(root)){let path=join2(root,entry.name);let{isSymlink,isDirectory}=entry;if(isSymlink){if(!followSymlinks){if(includeSymlinks&&include(path,exts,match,skip)){yield{path,...entry};}continue;}const realPath=await Deno.realPath(path);if(canonicalize){path=realPath;}({isSymlink,isDirectory}=await Deno.lstat(realPath));}if(isSymlink||isDirectory){yield*walk(path,{maxDepth:maxDepth-1,includeFiles,includeDirs,includeSymlinks,followSymlinks,exts,match,skip});}else if(includeFiles&&include(path,exts,match,skip)){yield{path,...entry};}}}catch(err){throw wrapErrorWithPath(err,normalize2(root));}}Deno.build.os==="windows";new Deno.errors.AlreadyExists("dest already exists.");Deno.build.os==="windows";const LF="\n";const CRLF="\r\n";Deno?.build.os==="windows"?CRLF:LF;function parse(text,{allowTrailingComma=true}={}){if(new.target){throw new TypeError("parse is not a constructor");}return new JSONCParser(text,{allowTrailingComma}).parse();}const originalJSONParse=globalThis.JSON.parse;class JSONCParser{#whitespace=new Set(" \r\n");#numberEndToken=new Set([..."[]{}:,/",...this.#whitespace]);#text;#length;#tokenized;#options;constructor(text,options){this.#text=`${text}`;this.#length=this.#text.length;this.#tokenized=this.#tokenize();this.#options=options;}parse(){const token=this.#getNext();const res=this.#parseJsonValue(token);const{done,value}=this.#tokenized.next();if(!done){throw new SyntaxError(buildErrorMessage(value));}return res;}#getNext(){const{done,value}=this.#tokenized.next();if(done){throw new SyntaxError("Unexpected end of JSONC input");}return value;}*#tokenize(){for(let i=0;iisNaN(Number(key)));const byLevel={[LogLevels.NOTSET]:"NOTSET",[LogLevels.DEBUG]:"DEBUG",[LogLevels.INFO]:"INFO",[LogLevels.WARNING]:"WARNING",[LogLevels.ERROR]:"ERROR",[LogLevels.CRITICAL]:"CRITICAL"};function getLevelByName(name){const level=LogLevels[name];if(level!==undefined){return level;}throw new Error(`no log level found for name: ${name}`);}function getLevelName(level){const levelName=byLevel[level];if(levelName){return levelName;}throw new Error(`no level name found for level: ${level}`);}class LogRecord{msg;#args;#datetime;level;levelName;loggerName;constructor(options){this.msg=options.msg;this.#args=[...options.args];this.level=options.level;this.loggerName=options.loggerName;this.#datetime=new Date;this.levelName=getLevelName(options.level);}get args(){return[...this.#args];}get datetime(){return new Date(this.#datetime.getTime());}}class Logger{#level;#handlers;#loggerName;constructor(loggerName,levelName,options={}){this.#loggerName=loggerName;this.#level=getLevelByName(levelName);this.#handlers=options.handlers||[];}get level(){return this.#level;}set level(level){try{this.#level=getLevelByName(getLevelName(level));}catch(_){throw new TypeError(`Invalid log level: ${level}`);}}get levelName(){return getLevelName(this.#level);}set levelName(levelName){this.#level=getLevelByName(levelName);}get loggerName(){return this.#loggerName;}set handlers(hndls){this.#handlers=hndls;}get handlers(){return this.#handlers;}#_log(level,msg,...args){if(this.level>level){return msg instanceof Function?undefined:msg;}let fnResult;let logMessage;if(msg instanceof Function){fnResult=msg();logMessage=this.asString(fnResult);}else{logMessage=this.asString(msg);}const record=new LogRecord({msg:logMessage,args:args,level:level,loggerName:this.loggerName});this.#handlers.forEach(handler=>{handler.handle(record);});return msg instanceof Function?fnResult:msg;}asString(data,isProperty=false){if(typeof data==="string"){if(isProperty)return`"${data}"`;return data;}else if(data===null||typeof data==="number"||typeof data==="bigint"||typeof data==="boolean"||typeof data==="undefined"||typeof data==="symbol"){return String(data);}else if(data instanceof Error){return data.stack;}else if(typeof data==="object"){return`{${Object.entries(data).map(([k,v])=>`"${k}":${this.asString(v,true)}`).join(",")}}`;}return"undefined";}debug(msg,...args){return this.#_log(LogLevels.DEBUG,msg,...args);}info(msg,...args){return this.#_log(LogLevels.INFO,msg,...args);}warning(msg,...args){return this.#_log(LogLevels.WARNING,msg,...args);}error(msg,...args){return this.#_log(LogLevels.ERROR,msg,...args);}critical(msg,...args){return this.#_log(LogLevels.CRITICAL,msg,...args);}}const{Deno:Deno1}=globalThis;const noColor=typeof Deno1?.noColor==="boolean"?Deno1.noColor:false;let enabled=!noColor;function code(open,close){return{open:`\x1b[${open.join(";")}m`,close:`\x1b[${close}m`,regexp:new RegExp(`\\x1b\\[${close}m`,"g")};}function run(str,code){return enabled?`${code.open}${str.replace(code.regexp,code.open)}${code.close}`:str;}function bold(str){return run(str,code([1],22));}function red(str){return run(str,code([31],39));}function yellow(str){return run(str,code([33],39));}function blue(str){return run(str,code([34],39));}new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"),"g");function copy(src,dst,off=0){off=Math.max(0,Math.min(off,dst.byteLength));const dstBytesAvailable=dst.byteLength-off;if(src.byteLength>dstBytesAvailable){src=src.subarray(0,dstBytesAvailable);}dst.set(src,off);return src.byteLength;}class AbstractBufBase{buf;usedBufferBytes=0;err=null;constructor(buf){this.buf=buf;}size(){return this.buf.byteLength;}available(){return this.buf.byteLength-this.usedBufferBytes;}buffered(){return this.usedBufferBytes;}}class BufWriterSync extends AbstractBufBase{#writer;static create(writer,size=4096){return writer instanceof BufWriterSync?writer:new BufWriterSync(writer,size);}constructor(writer,size=4096){super(new Uint8Array(size<=0?4096:size));this.#writer=writer;}reset(w){this.err=null;this.usedBufferBytes=0;this.#writer=w;}flush(){if(this.err!==null)throw this.err;if(this.usedBufferBytes===0)return;try{const p=this.buf.subarray(0,this.usedBufferBytes);let nwritten=0;while(nwrittenthis.available()){if(this.buffered()===0){try{numBytesWritten=this.#writer.writeSync(data);}catch(e){if(e instanceof Error){this.err=e;}throw e;}}else{numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;this.flush();}totalBytesWritten+=numBytesWritten;data=data.subarray(numBytesWritten);}numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;totalBytesWritten+=numBytesWritten;return totalBytesWritten;}}const DEFAULT_FORMATTER="{levelName} {msg}";class BaseHandler{level;levelName;formatter;constructor(levelName,options={}){this.level=getLevelByName(levelName);this.levelName=levelName;this.formatter=options.formatter||DEFAULT_FORMATTER;}handle(logRecord){if(this.level>logRecord.level)return;const msg=this.format(logRecord);this.log(msg);}format(logRecord){if(this.formatter instanceof Function){return this.formatter(logRecord);}return this.formatter.replace(/{([^\s}]+)}/g,(match,p1)=>{const value=logRecord[p1];if(value===undefined){return match;}return String(value);});}log(_msg){}setup(){}destroy(){}}class ConsoleHandler extends BaseHandler{#useColors;constructor(levelName,options={}){super(levelName,options);this.#useColors=options.useColors??true;}format(logRecord){let msg=super.format(logRecord);if(this.#useColors){msg=this.applyColors(msg,logRecord.level);}return msg;}applyColors(msg,level){switch(level){case LogLevels.INFO:msg=blue(msg);break;case LogLevels.WARNING:msg=yellow(msg);break;case LogLevels.ERROR:msg=red(msg);break;case LogLevels.CRITICAL:msg=bold(red(msg));break;default:break;}return msg;}log(msg){console.log(msg);}}class WriterHandler extends BaseHandler{_writer;#encoder=new TextEncoder;}class FileHandler extends WriterHandler{_file;_buf;_filename;_mode;_openOptions;_encoder=new TextEncoder;#unloadCallback=(()=>{this.destroy();}).bind(this);constructor(levelName,options){super(levelName,options);this._filename=options.filename;this._mode=options.mode?options.mode:"a";this._openOptions={createNew:this._mode==="x",create:this._mode!=="x",append:this._mode==="a",truncate:this._mode!=="a",write:true};}setup(){this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);addEventListener("unload",this.#unloadCallback);}handle(logRecord){super.handle(logRecord);if(logRecord.level>LogLevels.ERROR){this.flush();}}log(msg){if(this._encoder.encode(msg).byteLength+1>this._buf.available()){this.flush();}this._buf.writeSync(this._encoder.encode(msg+"\n"));}flush(){if(this._buf?.buffered()>0){this._buf.flush();}}destroy(){this.flush();this._file?.close();this._file=undefined;removeEventListener("unload",this.#unloadCallback);}}class RotatingFileHandler extends FileHandler{#maxBytes;#maxBackupCount;#currentFileSize=0;constructor(levelName,options){super(levelName,options);this.#maxBytes=options.maxBytes;this.#maxBackupCount=options.maxBackupCount;}setup(){if(this.#maxBytes<1){this.destroy();throw new Error("maxBytes cannot be less than 1");}if(this.#maxBackupCount<1){this.destroy();throw new Error("maxBackupCount cannot be less than 1");}super.setup();if(this._mode==="w"){for(let i=1;i<=this.#maxBackupCount;i++){try{Deno.removeSync(this._filename+"."+i);}catch(error){if(!(error instanceof Deno.errors.NotFound)){throw error;}}}}else if(this._mode==="x"){for(let i=1;i<=this.#maxBackupCount;i++){if(existsSync(this._filename+"."+i)){this.destroy();throw new Deno.errors.AlreadyExists("Backup log file "+this._filename+"."+i+" already exists");}}}else{this.#currentFileSize=Deno.statSync(this._filename).size;}}log(msg){const msgByteLength=this._encoder.encode(msg).byteLength+1;if(this.#currentFileSize+msgByteLength>this.#maxBytes){this.rotateLogFiles();this.#currentFileSize=0;}super.log(msg);this.#currentFileSize+=msgByteLength;}rotateLogFiles(){this._buf.flush();this._file.close();for(let i=this.#maxBackupCount-1;i>=0;i--){const source=this._filename+(i===0?"":"."+i);const dest=this._filename+"."+(i+1);if(existsSync(source)){Deno.renameSync(source,dest);}}this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);}}const DEFAULT_LEVEL="INFO";const DEFAULT_CONFIG={handlers:{default:new ConsoleHandler(DEFAULT_LEVEL)},loggers:{default:{level:DEFAULT_LEVEL,handlers:["default"]}}};const state={handlers:new Map,loggers:new Map,config:DEFAULT_CONFIG};const handlers={BaseHandler,ConsoleHandler,WriterHandler,FileHandler,RotatingFileHandler};function getLogger(name){if(!name){const d=state.loggers.get("default");assert(d!==undefined,`"default" logger must be set for getting logger without name`);return d;}const result=state.loggers.get(name);if(!result){const logger=new Logger(name,"NOTSET",{handlers:[]});state.loggers.set(name,logger);return logger;}return result;}function debug(msg,...args){if(msg instanceof Function){return getLogger("default").debug(msg,...args);}return getLogger("default").debug(msg,...args);}function warning(msg,...args){if(msg instanceof Function){return getLogger("default").warning(msg,...args);}return getLogger("default").warning(msg,...args);}function error(msg,...args){if(msg instanceof Function){return getLogger("default").error(msg,...args);}return getLogger("default").error(msg,...args);}function setup(config){state.config={handlers:{...DEFAULT_CONFIG.handlers,...config.handlers},loggers:{...DEFAULT_CONFIG.loggers,...config.loggers}};state.handlers.forEach(handler=>{handler.destroy();});state.handlers.clear();const handlers=state.config.handlers||{};for(const handlerName in handlers){const handler=handlers[handlerName];handler.setup();state.handlers.set(handlerName,handler);}state.loggers.clear();const loggers=state.config.loggers||{};for(const loggerName in loggers){const loggerConfig=loggers[loggerName];const handlerNames=loggerConfig.handlers||[];const handlers=[];handlerNames.forEach(handlerName=>{const handler=state.handlers.get(handlerName);if(handler){handlers.push(handler);}});const levelName=loggerConfig.level||DEFAULT_LEVEL;const logger=new Logger(loggerName,levelName,{handlers:handlers});state.loggers.set(loggerName,logger);}}setup(DEFAULT_CONFIG);function assertArgs1(from,to){assertPath(from);assertPath(to);if(from===to)return"";}function relative(from,to){assertArgs1(from,to);from=resolve(from);to=resolve(to);if(from===to)return"";let fromStart=1;const fromEnd=from.length;for(;fromStartlength){if(isPosixPathSeparator(to.charCodeAt(toStart+i))){return to.slice(toStart+i+1);}else if(i===0){return to.slice(toStart+i);}}else if(fromLen>length){if(isPosixPathSeparator(from.charCodeAt(fromStart+i))){lastCommonSep=i;}else if(i===0){lastCommonSep=0;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(isPosixPathSeparator(fromCode))lastCommonSep=i;}let out="";for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||isPosixPathSeparator(from.charCodeAt(i))){if(out.length===0)out+="..";else out+="/..";}}if(out.length>0)return out+to.slice(toStart+lastCommonSep);else{toStart+=lastCommonSep;if(isPosixPathSeparator(to.charCodeAt(toStart)))++toStart;return to.slice(toStart);}}function relative1(from,to){assertArgs1(from,to);const fromOrig=resolve1(from);const toOrig=resolve1(to);if(fromOrig===toOrig)return"";from=fromOrig.toLowerCase();to=toOrig.toLowerCase();if(from===to)return"";let fromStart=0;let fromEnd=from.length;for(;fromStartfromStart;--fromEnd){if(from.charCodeAt(fromEnd-1)!==92)break;}const fromLen=fromEnd-fromStart;let toStart=0;let toEnd=to.length;for(;toStarttoStart;--toEnd){if(to.charCodeAt(toEnd-1)!==92)break;}const toLen=toEnd-toStart;const length=fromLenlength){if(to.charCodeAt(toStart+i)===92){return toOrig.slice(toStart+i+1);}else if(i===2){return toOrig.slice(toStart+i);}}if(fromLen>length){if(from.charCodeAt(fromStart+i)===92){lastCommonSep=i;}else if(i===2){lastCommonSep=3;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(fromCode===92)lastCommonSep=i;}if(i!==length&&lastCommonSep===-1){return toOrig;}let out="";if(lastCommonSep===-1)lastCommonSep=0;for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||from.charCodeAt(i)===92){if(out.length===0)out+="..";else out+="\\..";}}if(out.length>0){return out+toOrig.slice(toStart+lastCommonSep,toEnd);}else{toStart+=lastCommonSep;if(toOrig.charCodeAt(toStart)===92)++toStart;return toOrig.slice(toStart,toEnd);}}function relative2(from,to){return isWindows?relative1(from,to):relative(from,to);}var m=Object.create;var E=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),D=(t,e)=>{for(var s in e)E(t,s,{get:e[s],enumerable:!0});},a=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!b.call(t,n)&&n!==s&&E(t,n,{get:()=>e[n],enumerable:!(r=T(e,n))||r.enumerable});return t;},_=(t,e,s)=>(a(t,e,"default"),s&&a(s,e,"default")),$=(t,e,s)=>(s=t!=null?m(X(t)):{},a(e||!t||!t.__esModule?E(s,"default",{value:t,enumerable:!0}):s,t));var A=w((ct,v)=>{function C(t){return Array.isArray(t)?t:[t];}var N="",P=" ",h="\\",H=/^\s+$/,F=/(?:[^\\]|^)\\$/,k=/^\\!/,z=/^\\#/,B=/\r?\n/g,K=/^\.*\/|^\.+$/,d="/",x="node-ignore";typeof Symbol<"u"&&(x=Symbol.for("node-ignore"));var L=x,V=(t,e,s)=>Object.defineProperty(t,e,{value:s}),j=/([0-z])-([0-z])/g,G=()=>!1,M=t=>t.replace(j,(e,s,r)=>s.charCodeAt(0)<=r.charCodeAt(0)?e:N),Y=t=>{let{length:e}=t;return t.slice(0,e-e%2);},W=[[/\\?\s+$/,t=>t.indexOf("\\")===0?P:N],[/\\\s/g,()=>P],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)";}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,s)=>e+6{let r=s.replace(/\\\*/g,"[^\\/]*");return e+r;}],[/\\\\\\(?=[$.|*+(){^])/g,()=>h],[/\\\\/g,()=>h],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,s,r,n)=>e===h?`\\[${s}${Y(r)}${n}`:n==="]"&&r.length%2===0?`[${M(s)}${r}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],S=Object.create(null),p=(t,e)=>{let s=S[t];return s||(s=W.reduce((r,n)=>r.replace(n[0],n[1].bind(t)),t),S[t]=s),e?new RegExp(s,"i"):new RegExp(s);},R=t=>typeof t=="string",q=t=>t&&R(t)&&!H.test(t)&&!F.test(t)&&t.indexOf("#")!==0,J=t=>t.split(B),f=class{constructor(e,s,r,n){this.origin=e,this.pattern=s,this.negative=r,this.regex=n;}},Q=(t,e)=>{let s=t,r=!1;t.indexOf("!")===0&&(r=!0,t=t.substr(1)),t=t.replace(k,"!").replace(z,"#");let n=p(t,e);return new f(s,t,r,n);},U=(t,e)=>{throw new e(t);},i=(t,e,s)=>R(t)?t?i.isNotRelative(t)?s(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:s("path must not be empty",TypeError):s(`path must be a string, but got \`${e}\``,TypeError),O=t=>K.test(t);i.isNotRelative=O;i.convert=t=>t;var g=class{constructor({ignorecase:e=!0,ignoreCase:s=e,allowRelativePaths:r=!1}={}){V(this,L,!0),this._rules=[],this._ignoreCase=s,this._allowRelativePaths=r,this._initCache();}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null);}_addPattern(e){if(e&&e[L]){this._rules=this._rules.concat(e._rules),this._added=!0;return;}if(q(e)){let s=Q(e,this._ignoreCase);this._added=!0,this._rules.push(s);}}add(e){return this._added=!1,C(R(e)?J(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this;}addPattern(e){return this.add(e);}_testOne(e,s){let r=!1,n=!1;return this._rules.forEach(o=>{let{negative:u}=o;if(n===u&&r!==n||u&&!r&&!n&&!s)return;o.regex.test(e)&&(r=!u,n=u);}),{ignored:r,unignored:n};}_test(e,s,r,n){let o=e&&i.convert(e);return i(o,e,this._allowRelativePaths?G:U),this._t(o,s,r,n);}_t(e,s,r,n){if(e in s)return s[e];if(n||(n=e.split(d)),n.pop(),!n.length)return s[e]=this._testOne(e,r);let o=this._t(n.join(d)+d,s,r,n);return s[e]=o.ignored?o:this._testOne(e,r);}ignores(e){return this._test(e,this._ignoreCache,!1).ignored;}createFilter(){return e=>!this.ignores(e);}filter(e){return C(e).filter(this.createFilter());}test(e){return this._test(e,this._testCache,!0);}},l=t=>new g(t),Z=t=>i(t&&i.convert(t),t,G);l.isPathValid=Z;l.default=l;v.exports=l;var tt=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");i.convert=tt;var et=/^[a-z]:\//i;i.isNotRelative=t=>et.test(t)||O(t);});var c={};D(c,{default:()=>nt});var st=$(A());_(c,$(A()));var{default:I,...rt}=st,nt=I!==void 0?I:rt;const importMeta={url:"file:///home/runner/work/setup-deno/setup-deno/cache.ts",main:import.meta.main};if(importMeta.main){const args=parseArgs(Deno.args,{boolean:["help","dry-run","verbose","lock-write"],negatable:["lock-write"],string:["config"],default:{"lock-write":true},alias:{help:"h","dry-run":"n"},"--":true});const denoDir=Deno.env.get("DENO_DIR");const logLevel=Deno.env.get("CI")==="1"?"DEBUG":args.verbose?"DEBUG":"INFO";setup({handlers:{console:new handlers.ConsoleHandler(logLevel,{formatter:logRecord=>Deno.noColor?[logRecord.levelName,logRecord.msg].join(" "):logRecord.msg})},loggers:{default:{handlers:["console"],"level":logLevel}}});if(args.help){console.log("Usage: cache [-n | --dry-run] [-v | --verbose] [--] [DENO_ARGS...]");Deno.exit(0);}if(args["dry-run"])warning("dry-run mode enabled");if(args.config&&!await exists(args.config)){error(`config file ${args.config} not found`);Deno.exit(1);}const hash=await Deno.readFile("./deno.lock").then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>encodeHex(new Uint8Array(data))).catch(_=>"");debug(`GitHub actions deno.lock hash: ${hash}`);const cfgs=args.config?[args.config]:["deno.json","deno.jsonc"];const denoCfg=await Promise.all(cfgs.map(path=>Deno.readTextFile(path).catch(_=>undefined))).then(v=>parse(v.filter(Boolean)[0]??"{}"));const patterns=[...[denoCfg?.exclude??[]].flat(),...[denoCfg?.cache?.exclude??[]].flat(),...[denoCfg?.cache?.include??[]].flatMap(p=>`!${p}`)];debug(`patterns:`,patterns);patterns.forEach(p=>debug(`- ${p}`));const ig=nt().add(patterns);const walkIterator=walk(".",{exts:["js",".jsx",".ts",".tsx"],includeDirs:false});const paths=[];for await(const entry of walkIterator){const relativePath=relative2(".",entry.path);if(denoDir&&entry.path.startsWith(denoDir))continue;if(ig.ignores(relativePath)){debug(`ignored ${relativePath}`);continue;}debug(`caching ${relativePath}`);paths.push(relativePath);}const cmd=new Deno.Command(Deno.execPath(),{args:["cache",args["lock-write"]&&"--lock-write",args.config&&`--config=${args.config}`,...args["--"],...paths].filter(Boolean),stdout:"inherit",stderr:"inherit"});const code=!args["dry-run"]?(await cmd.output()).code:0;if(code===0)debug(`finished caching ${paths.length} files`);} \ No newline at end of file +class AssertionError extends Error{constructor(message){super(message);this.name="AssertionError";}}function assert(expr,msg=""){if(!expr){throw new AssertionError(msg);}}const{hasOwn}=Object;function get(obj,key){if(hasOwn(obj,key)){return obj[key];}}function getForce(obj,key){const v=get(obj,key);assert(v!==undefined);return v;}function isNumber(x){if(typeof x==="number")return true;if(/^0x[0-9a-f]+$/i.test(String(x)))return true;return/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(String(x));}function hasKey(obj,keys){let o=obj;keys.slice(0,-1).forEach(key=>{o=get(o,key)??{};});const key=keys[keys.length-1];return hasOwn(o,key);}function parseArgs(args,{"--":doubleDash=false,alias={},boolean:__boolean=false,default:defaults={},stopEarly=false,string=[],collect=[],negatable=[],unknown=i=>i}={}){const aliases={};const flags={bools:{},strings:{},unknownFn:unknown,allBools:false,collect:{},negatable:{}};if(alias!==undefined){for(const key in alias){const val=getForce(alias,key);if(typeof val==="string"){aliases[key]=[val];}else{aliases[key]=val;}for(const alias of getForce(aliases,key)){aliases[alias]=[key].concat(aliases[key].filter(y=>alias!==y));}}}if(__boolean!==undefined){if(typeof __boolean==="boolean"){flags.allBools=!!__boolean;}else{const booleanArgs=typeof __boolean==="string"?[__boolean]:__boolean;for(const key of booleanArgs.filter(Boolean)){flags.bools[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.bools[al]=true;}}}}}if(string!==undefined){const stringArgs=typeof string==="string"?[string]:string;for(const key of stringArgs.filter(Boolean)){flags.strings[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.strings[al]=true;}}}}if(collect!==undefined){const collectArgs=typeof collect==="string"?[collect]:collect;for(const key of collectArgs.filter(Boolean)){flags.collect[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.collect[al]=true;}}}}if(negatable!==undefined){const negatableArgs=typeof negatable==="string"?[negatable]:negatable;for(const key of negatableArgs.filter(Boolean)){flags.negatable[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.negatable[al]=true;}}}}const argv={_:[]};function argDefined(key,arg){return flags.allBools&&/^--[^=]+$/.test(arg)||get(flags.bools,key)||!!get(flags.strings,key)||!!get(aliases,key);}function setKey(obj,name,value,collect=true){let o=obj;const keys=name.split(".");keys.slice(0,-1).forEach(function(key){if(get(o,key)===undefined){o[key]={};}o=get(o,key);});const key=keys[keys.length-1];const collectable=collect&&!!get(flags.collect,name);if(!collectable){o[key]=value;}else if(get(o,key)===undefined){o[key]=[value];}else if(Array.isArray(get(o,key))){o[key].push(value);}else{o[key]=[get(o,key),value];}}function setArg(key,val,arg=undefined,collect){if(arg&&flags.unknownFn&&!argDefined(key,arg)){if(flags.unknownFn(arg,key,val)===false)return;}const value=!get(flags.strings,key)&&isNumber(val)?Number(val):val;setKey(argv,key,value,collect);const alias=get(aliases,key);if(alias){for(const x of alias){setKey(argv,x,value,collect);}}}function aliasIsBoolean(key){return getForce(aliases,key).some(x=>typeof get(flags.bools,x)==="boolean");}let notFlags=[];if(args.includes("--")){notFlags=args.slice(args.indexOf("--")+1);args=args.slice(0,args.indexOf("--"));}for(let i=0;i>4];dst[i*2+1]=hexTable[v&15];}return textDecoder.decode(dst);}const osType=(()=>{const{Deno:Deno1}=globalThis;if(typeof Deno1?.build?.os==="string"){return Deno1.build.os;}const{navigator}=globalThis;if(navigator?.appVersion?.includes?.("Win")){return"windows";}return"linux";})();const isWindows=osType==="windows";function assertPath(path){if(typeof path!=="string"){throw new TypeError(`Path must be a string. Received ${JSON.stringify(path)}`);}}function assertArg(path){assertPath(path);if(path.length===0)return".";}const CHAR_FORWARD_SLASH=47;function normalizeString(path,allowAboveRoot,separator,isPathSeparator){let res="";let lastSegmentLength=0;let lastSlash=-1;let dots=0;let code;for(let i=0,len=path.length;i<=len;++i){if(i2){const lastSlashIndex=res.lastIndexOf(separator);if(lastSlashIndex===-1){res="";lastSegmentLength=0;}else{res=res.slice(0,lastSlashIndex);lastSegmentLength=res.length-1-res.lastIndexOf(separator);}lastSlash=i;dots=0;continue;}else if(res.length===2||res.length===1){res="";lastSegmentLength=0;lastSlash=i;dots=0;continue;}}if(allowAboveRoot){if(res.length>0)res+=`${separator}..`;else res="..";lastSegmentLength=2;}}else{if(res.length>0)res+=separator+path.slice(lastSlash+1,i);else res=path.slice(lastSlash+1,i);lastSegmentLength=i-lastSlash-1;}lastSlash=i;dots=0;}else if(code===46&&dots!==-1){++dots;}else{dots=-1;}}return res;}function isPosixPathSeparator(code){return code===47;}function normalize(path){assertArg(path);const isAbsolute=isPosixPathSeparator(path.charCodeAt(0));const trailingSeparator=isPosixPathSeparator(path.charCodeAt(path.length-1));path=normalizeString(path,!isAbsolute,"/",isPosixPathSeparator);if(path.length===0&&!isAbsolute)path=".";if(path.length>0&&trailingSeparator)path+="/";if(isAbsolute)return`/${path}`;return path;}function join(...paths){if(paths.length===0)return".";let joined;for(let i=0,len=paths.length;i0){if(!joined)joined=path;else joined+=`/${path}`;}}if(!joined)return".";return normalize(joined);}function isPathSeparator(code){return code===47||code===92;}function isWindowsDeviceRoot(code){return code>=97&&code<=122||code>=65&&code<=90;}function normalize1(path){assertArg(path);const len=path.length;let rootEnd=0;let device;let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){return"\\";}let tail;if(rootEnd0&&isPathSeparator(path.charCodeAt(len-1))){tail+="\\";}if(device===undefined){if(isAbsolute){if(tail.length>0)return`\\${tail}`;else return"\\";}else if(tail.length>0){return tail;}else{return"";}}else if(isAbsolute){if(tail.length>0)return`${device}\\${tail}`;else return`${device}\\`;}else if(tail.length>0){return device+tail;}else{return device;}}function join1(...paths){if(paths.length===0)return".";let joined;let firstPart=null;for(let i=0;i0){if(joined===undefined)joined=firstPart=path;else joined+=`\\${path}`;}}if(joined===undefined)return".";let needsReplace=true;let slashCount=0;assert(firstPart!==null);if(isPathSeparator(firstPart.charCodeAt(0))){++slashCount;const firstLen=firstPart.length;if(firstLen>1){if(isPathSeparator(firstPart.charCodeAt(1))){++slashCount;if(firstLen>2){if(isPathSeparator(firstPart.charCodeAt(2)))++slashCount;else{needsReplace=false;}}}}}if(needsReplace){for(;slashCount=2)joined=`\\${joined.slice(slashCount)}`;}return normalize1(joined);}function join2(...paths){return isWindows?join1(...paths):join(...paths);}function assertArg1(url){url=url instanceof URL?url:new URL(url);if(url.protocol!=="file:"){throw new TypeError("Must be a file URL.");}return url;}function fromFileUrl(url){url=assertArg1(url);return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"));}function fromFileUrl1(url){url=assertArg1(url);let path=decodeURIComponent(url.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");if(url.hostname!==""){path=`\\\\${url.hostname}${path}`;}return path;}function fromFileUrl2(url){return isWindows?fromFileUrl1(url):fromFileUrl(url);}function toPathString(pathUrl){return pathUrl instanceof URL?fromFileUrl2(pathUrl):pathUrl;}function stripTrailingSeparators(segment,isSep){if(segment.length<=1){return segment;}let end=segment.length;for(let i=segment.length-1;i>0;i--){if(isSep(segment.charCodeAt(i))){end=i;}else{break;}}return segment.slice(0,end);}function resolve(...pathSegments){let resolvedPath="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1&&!resolvedAbsolute;i--){let path;if(i>=0)path=pathSegments[i];else{const{Deno:Deno1}=globalThis;if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();}assertPath(path);if(path.length===0){continue;}resolvedPath=`${path}/${resolvedPath}`;resolvedAbsolute=isPosixPathSeparator(path.charCodeAt(0));}resolvedPath=normalizeString(resolvedPath,!resolvedAbsolute,"/",isPosixPathSeparator);if(resolvedAbsolute){if(resolvedPath.length>0)return`/${resolvedPath}`;else return"/";}else if(resolvedPath.length>0)return resolvedPath;else return".";}function resolve1(...pathSegments){let resolvedDevice="";let resolvedTail="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1;i--){let path;const{Deno:Deno1}=globalThis;if(i>=0){path=pathSegments[i];}else if(!resolvedDevice){if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a drive-letter-less path without a CWD.");}path=Deno1.cwd();}else{if(typeof Deno1?.env?.get!=="function"||typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();if(path===undefined||path.slice(0,3).toLowerCase()!==`${resolvedDevice.toLowerCase()}\\`){path=`${resolvedDevice}\\`;}}assertPath(path);const len=path.length;if(len===0)continue;let rootEnd=0;let device="";let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){rootEnd=1;isAbsolute=true;}if(device.length>0&&resolvedDevice.length>0&&device.toLowerCase()!==resolvedDevice.toLowerCase()){continue;}if(resolvedDevice.length===0&&device.length>0){resolvedDevice=device;}if(!resolvedAbsolute){resolvedTail=`${path.slice(rootEnd)}\\${resolvedTail}`;resolvedAbsolute=isAbsolute;}if(resolvedAbsolute&&resolvedDevice.length>0)break;}resolvedTail=normalizeString(resolvedTail,!resolvedAbsolute,"\\",isPathSeparator);return resolvedDevice+(resolvedAbsolute?"\\":"")+resolvedTail||".";}Deno.build.os==="windows";async function exists(path,options){try{const stat=await Deno.stat(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if((await Deno.permissions.query({name:"read",path})).state==="granted"){return!options?.isReadable;}}throw error;}}function existsSync(path,options){try{const stat=Deno.statSync(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if(Deno.permissions.querySync({name:"read",path}).state==="granted"){return!options?.isReadable;}}throw error;}}function normalize2(path){return isWindows?normalize1(path):normalize(path);}function stripSuffix(name,suffix){if(suffix.length>=name.length){return name;}const lenDiff=name.length-suffix.length;for(let i=suffix.length-1;i>=0;--i){if(name.charCodeAt(lenDiff+i)!==suffix.charCodeAt(i)){return name;}}return name.slice(0,-suffix.length);}function lastPathSegment(path,isSep,start=0){let matchedNonSeparator=false;let end=path.length;for(let i=path.length-1;i>=start;--i){if(isSep(path.charCodeAt(i))){if(matchedNonSeparator){start=i+1;break;}}else if(!matchedNonSeparator){matchedNonSeparator=true;end=i+1;}}return path.slice(start,end);}function assertArgs(path,suffix){assertPath(path);if(path.length===0)return path;if(typeof suffix!=="string"){throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);}}function basename(path,suffix=""){assertArgs(path,suffix);const lastSegment=lastPathSegment(path,isPosixPathSeparator);const strippedSegment=stripTrailingSeparators(lastSegment,isPosixPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename1(path,suffix=""){assertArgs(path,suffix);let start=0;if(path.length>=2){const drive=path.charCodeAt(0);if(isWindowsDeviceRoot(drive)){if(path.charCodeAt(1)===58)start=2;}}const lastSegment=lastPathSegment(path,isPathSeparator,start);const strippedSegment=stripTrailingSeparators(lastSegment,isPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename2(path,suffix=""){return isWindows?basename1(path,suffix):basename(path,suffix);}async function createWalkEntry(path){path=toPathString(path);path=normalize2(path);const name=basename2(path);const info=await Deno.stat(path);return{path,name,isFile:info.isFile,isDirectory:info.isDirectory,isSymlink:info.isSymlink};}class WalkError extends Error{root;constructor(cause,root){super(`${cause instanceof Error?cause.message:cause} for path "${root}"`);this.cause=cause;this.name="WalkError";this.root=root;}}function include(path,exts,match,skip){if(exts&&!exts.some(ext=>path.endsWith(ext))){return false;}if(match&&!match.some(pattern=>!!path.match(pattern))){return false;}if(skip&&skip.some(pattern=>!!path.match(pattern))){return false;}return true;}function wrapErrorWithPath(err,root){if(err instanceof WalkError)return err;return new WalkError(err,root);}async function*walk(root,{maxDepth=Infinity,includeFiles=true,includeDirs=true,includeSymlinks=true,followSymlinks=false,canonicalize=true,exts=undefined,match=undefined,skip=undefined}={}){if(maxDepth<0){return;}root=toPathString(root);if(includeDirs&&include(root,exts,match,skip)){yield await createWalkEntry(root);}if(maxDepth<1||!include(root,undefined,undefined,skip)){return;}try{for await(const entry of Deno.readDir(root)){let path=join2(root,entry.name);let{isSymlink,isDirectory}=entry;if(isSymlink){if(!followSymlinks){if(includeSymlinks&&include(path,exts,match,skip)){yield{path,...entry};}continue;}const realPath=await Deno.realPath(path);if(canonicalize){path=realPath;}({isSymlink,isDirectory}=await Deno.lstat(realPath));}if(isSymlink||isDirectory){yield*walk(path,{maxDepth:maxDepth-1,includeFiles,includeDirs,includeSymlinks,followSymlinks,exts,match,skip});}else if(includeFiles&&include(path,exts,match,skip)){yield{path,...entry};}}}catch(err){throw wrapErrorWithPath(err,normalize2(root));}}Deno.build.os==="windows";new Deno.errors.AlreadyExists("dest already exists.");Deno.build.os==="windows";const LF="\n";const CRLF="\r\n";Deno?.build.os==="windows"?CRLF:LF;function parse(text,{allowTrailingComma=true}={}){if(new.target){throw new TypeError("parse is not a constructor");}return new JSONCParser(text,{allowTrailingComma}).parse();}const originalJSONParse=globalThis.JSON.parse;class JSONCParser{#whitespace=new Set(" \r\n");#numberEndToken=new Set([..."[]{}:,/",...this.#whitespace]);#text;#length;#tokenized;#options;constructor(text,options){this.#text=`${text}`;this.#length=this.#text.length;this.#tokenized=this.#tokenize();this.#options=options;}parse(){const token=this.#getNext();const res=this.#parseJsonValue(token);const{done,value}=this.#tokenized.next();if(!done){throw new SyntaxError(buildErrorMessage(value));}return res;}#getNext(){const{done,value}=this.#tokenized.next();if(done){throw new SyntaxError("Unexpected end of JSONC input");}return value;}*#tokenize(){for(let i=0;iisNaN(Number(key)));const byLevel={[LogLevels.NOTSET]:"NOTSET",[LogLevels.DEBUG]:"DEBUG",[LogLevels.INFO]:"INFO",[LogLevels.WARNING]:"WARNING",[LogLevels.ERROR]:"ERROR",[LogLevels.CRITICAL]:"CRITICAL"};function getLevelByName(name){const level=LogLevels[name];if(level!==undefined){return level;}throw new Error(`no log level found for name: ${name}`);}function getLevelName(level){const levelName=byLevel[level];if(levelName){return levelName;}throw new Error(`no level name found for level: ${level}`);}class LogRecord{msg;#args;#datetime;level;levelName;loggerName;constructor(options){this.msg=options.msg;this.#args=[...options.args];this.level=options.level;this.loggerName=options.loggerName;this.#datetime=new Date;this.levelName=getLevelName(options.level);}get args(){return[...this.#args];}get datetime(){return new Date(this.#datetime.getTime());}}class Logger{#level;#handlers;#loggerName;constructor(loggerName,levelName,options={}){this.#loggerName=loggerName;this.#level=getLevelByName(levelName);this.#handlers=options.handlers||[];}get level(){return this.#level;}set level(level){try{this.#level=getLevelByName(getLevelName(level));}catch(_){throw new TypeError(`Invalid log level: ${level}`);}}get levelName(){return getLevelName(this.#level);}set levelName(levelName){this.#level=getLevelByName(levelName);}get loggerName(){return this.#loggerName;}set handlers(hndls){this.#handlers=hndls;}get handlers(){return this.#handlers;}#_log(level,msg,...args){if(this.level>level){return msg instanceof Function?undefined:msg;}let fnResult;let logMessage;if(msg instanceof Function){fnResult=msg();logMessage=this.asString(fnResult);}else{logMessage=this.asString(msg);}const record=new LogRecord({msg:logMessage,args:args,level:level,loggerName:this.loggerName});this.#handlers.forEach(handler=>{handler.handle(record);});return msg instanceof Function?fnResult:msg;}asString(data,isProperty=false){if(typeof data==="string"){if(isProperty)return`"${data}"`;return data;}else if(data===null||typeof data==="number"||typeof data==="bigint"||typeof data==="boolean"||typeof data==="undefined"||typeof data==="symbol"){return String(data);}else if(data instanceof Error){return data.stack;}else if(typeof data==="object"){return`{${Object.entries(data).map(([k,v])=>`"${k}":${this.asString(v,true)}`).join(",")}}`;}return"undefined";}debug(msg,...args){return this.#_log(LogLevels.DEBUG,msg,...args);}info(msg,...args){return this.#_log(LogLevels.INFO,msg,...args);}warning(msg,...args){return this.#_log(LogLevels.WARNING,msg,...args);}error(msg,...args){return this.#_log(LogLevels.ERROR,msg,...args);}critical(msg,...args){return this.#_log(LogLevels.CRITICAL,msg,...args);}}const{Deno:Deno1}=globalThis;const noColor=typeof Deno1?.noColor==="boolean"?Deno1.noColor:false;let enabled=!noColor;function code(open,close){return{open:`\x1b[${open.join(";")}m`,close:`\x1b[${close}m`,regexp:new RegExp(`\\x1b\\[${close}m`,"g")};}function run(str,code){return enabled?`${code.open}${str.replace(code.regexp,code.open)}${code.close}`:str;}function bold(str){return run(str,code([1],22));}function red(str){return run(str,code([31],39));}function yellow(str){return run(str,code([33],39));}function blue(str){return run(str,code([34],39));}new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"),"g");function copy(src,dst,off=0){off=Math.max(0,Math.min(off,dst.byteLength));const dstBytesAvailable=dst.byteLength-off;if(src.byteLength>dstBytesAvailable){src=src.subarray(0,dstBytesAvailable);}dst.set(src,off);return src.byteLength;}class AbstractBufBase{buf;usedBufferBytes=0;err=null;constructor(buf){this.buf=buf;}size(){return this.buf.byteLength;}available(){return this.buf.byteLength-this.usedBufferBytes;}buffered(){return this.usedBufferBytes;}}class BufWriterSync extends AbstractBufBase{#writer;static create(writer,size=4096){return writer instanceof BufWriterSync?writer:new BufWriterSync(writer,size);}constructor(writer,size=4096){super(new Uint8Array(size<=0?4096:size));this.#writer=writer;}reset(w){this.err=null;this.usedBufferBytes=0;this.#writer=w;}flush(){if(this.err!==null)throw this.err;if(this.usedBufferBytes===0)return;try{const p=this.buf.subarray(0,this.usedBufferBytes);let nwritten=0;while(nwrittenthis.available()){if(this.buffered()===0){try{numBytesWritten=this.#writer.writeSync(data);}catch(e){if(e instanceof Error){this.err=e;}throw e;}}else{numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;this.flush();}totalBytesWritten+=numBytesWritten;data=data.subarray(numBytesWritten);}numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;totalBytesWritten+=numBytesWritten;return totalBytesWritten;}}const DEFAULT_FORMATTER="{levelName} {msg}";class BaseHandler{level;levelName;formatter;constructor(levelName,options={}){this.level=getLevelByName(levelName);this.levelName=levelName;this.formatter=options.formatter||DEFAULT_FORMATTER;}handle(logRecord){if(this.level>logRecord.level)return;const msg=this.format(logRecord);this.log(msg);}format(logRecord){if(this.formatter instanceof Function){return this.formatter(logRecord);}return this.formatter.replace(/{([^\s}]+)}/g,(match,p1)=>{const value=logRecord[p1];if(value===undefined){return match;}return String(value);});}log(_msg){}setup(){}destroy(){}}class ConsoleHandler extends BaseHandler{#useColors;constructor(levelName,options={}){super(levelName,options);this.#useColors=options.useColors??true;}format(logRecord){let msg=super.format(logRecord);if(this.#useColors){msg=this.applyColors(msg,logRecord.level);}return msg;}applyColors(msg,level){switch(level){case LogLevels.INFO:msg=blue(msg);break;case LogLevels.WARNING:msg=yellow(msg);break;case LogLevels.ERROR:msg=red(msg);break;case LogLevels.CRITICAL:msg=bold(red(msg));break;default:break;}return msg;}log(msg){console.log(msg);}}class WriterHandler extends BaseHandler{_writer;#encoder=new TextEncoder;}class FileHandler extends WriterHandler{_file;_buf;_filename;_mode;_openOptions;_encoder=new TextEncoder;#unloadCallback=(()=>{this.destroy();}).bind(this);constructor(levelName,options){super(levelName,options);this._filename=options.filename;this._mode=options.mode?options.mode:"a";this._openOptions={createNew:this._mode==="x",create:this._mode!=="x",append:this._mode==="a",truncate:this._mode!=="a",write:true};}setup(){this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);addEventListener("unload",this.#unloadCallback);}handle(logRecord){super.handle(logRecord);if(logRecord.level>LogLevels.ERROR){this.flush();}}log(msg){if(this._encoder.encode(msg).byteLength+1>this._buf.available()){this.flush();}this._buf.writeSync(this._encoder.encode(msg+"\n"));}flush(){if(this._buf?.buffered()>0){this._buf.flush();}}destroy(){this.flush();this._file?.close();this._file=undefined;removeEventListener("unload",this.#unloadCallback);}}class RotatingFileHandler extends FileHandler{#maxBytes;#maxBackupCount;#currentFileSize=0;constructor(levelName,options){super(levelName,options);this.#maxBytes=options.maxBytes;this.#maxBackupCount=options.maxBackupCount;}setup(){if(this.#maxBytes<1){this.destroy();throw new Error("maxBytes cannot be less than 1");}if(this.#maxBackupCount<1){this.destroy();throw new Error("maxBackupCount cannot be less than 1");}super.setup();if(this._mode==="w"){for(let i=1;i<=this.#maxBackupCount;i++){try{Deno.removeSync(this._filename+"."+i);}catch(error){if(!(error instanceof Deno.errors.NotFound)){throw error;}}}}else if(this._mode==="x"){for(let i=1;i<=this.#maxBackupCount;i++){if(existsSync(this._filename+"."+i)){this.destroy();throw new Deno.errors.AlreadyExists("Backup log file "+this._filename+"."+i+" already exists");}}}else{this.#currentFileSize=Deno.statSync(this._filename).size;}}log(msg){const msgByteLength=this._encoder.encode(msg).byteLength+1;if(this.#currentFileSize+msgByteLength>this.#maxBytes){this.rotateLogFiles();this.#currentFileSize=0;}super.log(msg);this.#currentFileSize+=msgByteLength;}rotateLogFiles(){this._buf.flush();this._file.close();for(let i=this.#maxBackupCount-1;i>=0;i--){const source=this._filename+(i===0?"":"."+i);const dest=this._filename+"."+(i+1);if(existsSync(source)){Deno.renameSync(source,dest);}}this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);}}const DEFAULT_LEVEL="INFO";const DEFAULT_CONFIG={handlers:{default:new ConsoleHandler(DEFAULT_LEVEL)},loggers:{default:{level:DEFAULT_LEVEL,handlers:["default"]}}};const state={handlers:new Map,loggers:new Map,config:DEFAULT_CONFIG};const handlers={BaseHandler,ConsoleHandler,WriterHandler,FileHandler,RotatingFileHandler};function getLogger(name){if(!name){const d=state.loggers.get("default");assert(d!==undefined,`"default" logger must be set for getting logger without name`);return d;}const result=state.loggers.get(name);if(!result){const logger=new Logger(name,"NOTSET",{handlers:[]});state.loggers.set(name,logger);return logger;}return result;}function debug(msg,...args){if(msg instanceof Function){return getLogger("default").debug(msg,...args);}return getLogger("default").debug(msg,...args);}function warning(msg,...args){if(msg instanceof Function){return getLogger("default").warning(msg,...args);}return getLogger("default").warning(msg,...args);}function error(msg,...args){if(msg instanceof Function){return getLogger("default").error(msg,...args);}return getLogger("default").error(msg,...args);}function setup(config){state.config={handlers:{...DEFAULT_CONFIG.handlers,...config.handlers},loggers:{...DEFAULT_CONFIG.loggers,...config.loggers}};state.handlers.forEach(handler=>{handler.destroy();});state.handlers.clear();const handlers=state.config.handlers||{};for(const handlerName in handlers){const handler=handlers[handlerName];handler.setup();state.handlers.set(handlerName,handler);}state.loggers.clear();const loggers=state.config.loggers||{};for(const loggerName in loggers){const loggerConfig=loggers[loggerName];const handlerNames=loggerConfig.handlers||[];const handlers=[];handlerNames.forEach(handlerName=>{const handler=state.handlers.get(handlerName);if(handler){handlers.push(handler);}});const levelName=loggerConfig.level||DEFAULT_LEVEL;const logger=new Logger(loggerName,levelName,{handlers:handlers});state.loggers.set(loggerName,logger);}}setup(DEFAULT_CONFIG);function assertArgs1(from,to){assertPath(from);assertPath(to);if(from===to)return"";}function relative(from,to){assertArgs1(from,to);from=resolve(from);to=resolve(to);if(from===to)return"";let fromStart=1;const fromEnd=from.length;for(;fromStartlength){if(isPosixPathSeparator(to.charCodeAt(toStart+i))){return to.slice(toStart+i+1);}else if(i===0){return to.slice(toStart+i);}}else if(fromLen>length){if(isPosixPathSeparator(from.charCodeAt(fromStart+i))){lastCommonSep=i;}else if(i===0){lastCommonSep=0;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(isPosixPathSeparator(fromCode))lastCommonSep=i;}let out="";for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||isPosixPathSeparator(from.charCodeAt(i))){if(out.length===0)out+="..";else out+="/..";}}if(out.length>0)return out+to.slice(toStart+lastCommonSep);else{toStart+=lastCommonSep;if(isPosixPathSeparator(to.charCodeAt(toStart)))++toStart;return to.slice(toStart);}}function relative1(from,to){assertArgs1(from,to);const fromOrig=resolve1(from);const toOrig=resolve1(to);if(fromOrig===toOrig)return"";from=fromOrig.toLowerCase();to=toOrig.toLowerCase();if(from===to)return"";let fromStart=0;let fromEnd=from.length;for(;fromStartfromStart;--fromEnd){if(from.charCodeAt(fromEnd-1)!==92)break;}const fromLen=fromEnd-fromStart;let toStart=0;let toEnd=to.length;for(;toStarttoStart;--toEnd){if(to.charCodeAt(toEnd-1)!==92)break;}const toLen=toEnd-toStart;const length=fromLenlength){if(to.charCodeAt(toStart+i)===92){return toOrig.slice(toStart+i+1);}else if(i===2){return toOrig.slice(toStart+i);}}if(fromLen>length){if(from.charCodeAt(fromStart+i)===92){lastCommonSep=i;}else if(i===2){lastCommonSep=3;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(fromCode===92)lastCommonSep=i;}if(i!==length&&lastCommonSep===-1){return toOrig;}let out="";if(lastCommonSep===-1)lastCommonSep=0;for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||from.charCodeAt(i)===92){if(out.length===0)out+="..";else out+="\\..";}}if(out.length>0){return out+toOrig.slice(toStart+lastCommonSep,toEnd);}else{toStart+=lastCommonSep;if(toOrig.charCodeAt(toStart)===92)++toStart;return toOrig.slice(toStart,toEnd);}}function relative2(from,to){return isWindows?relative1(from,to):relative(from,to);}var m=Object.create;var E=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),D=(t,e)=>{for(var s in e)E(t,s,{get:e[s],enumerable:!0});},a=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!b.call(t,n)&&n!==s&&E(t,n,{get:()=>e[n],enumerable:!(r=T(e,n))||r.enumerable});return t;},_=(t,e,s)=>(a(t,e,"default"),s&&a(s,e,"default")),$=(t,e,s)=>(s=t!=null?m(X(t)):{},a(e||!t||!t.__esModule?E(s,"default",{value:t,enumerable:!0}):s,t));var A=w((ct,v)=>{function C(t){return Array.isArray(t)?t:[t];}var N="",P=" ",h="\\",H=/^\s+$/,F=/(?:[^\\]|^)\\$/,k=/^\\!/,z=/^\\#/,B=/\r?\n/g,K=/^\.*\/|^\.+$/,d="/",x="node-ignore";typeof Symbol<"u"&&(x=Symbol.for("node-ignore"));var L=x,V=(t,e,s)=>Object.defineProperty(t,e,{value:s}),j=/([0-z])-([0-z])/g,G=()=>!1,M=t=>t.replace(j,(e,s,r)=>s.charCodeAt(0)<=r.charCodeAt(0)?e:N),Y=t=>{let{length:e}=t;return t.slice(0,e-e%2);},W=[[/\\?\s+$/,t=>t.indexOf("\\")===0?P:N],[/\\\s/g,()=>P],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)";}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,s)=>e+6{let r=s.replace(/\\\*/g,"[^\\/]*");return e+r;}],[/\\\\\\(?=[$.|*+(){^])/g,()=>h],[/\\\\/g,()=>h],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,s,r,n)=>e===h?`\\[${s}${Y(r)}${n}`:n==="]"&&r.length%2===0?`[${M(s)}${r}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],S=Object.create(null),p=(t,e)=>{let s=S[t];return s||(s=W.reduce((r,n)=>r.replace(n[0],n[1].bind(t)),t),S[t]=s),e?new RegExp(s,"i"):new RegExp(s);},R=t=>typeof t=="string",q=t=>t&&R(t)&&!H.test(t)&&!F.test(t)&&t.indexOf("#")!==0,J=t=>t.split(B),f=class{constructor(e,s,r,n){this.origin=e,this.pattern=s,this.negative=r,this.regex=n;}},Q=(t,e)=>{let s=t,r=!1;t.indexOf("!")===0&&(r=!0,t=t.substr(1)),t=t.replace(k,"!").replace(z,"#");let n=p(t,e);return new f(s,t,r,n);},U=(t,e)=>{throw new e(t);},i=(t,e,s)=>R(t)?t?i.isNotRelative(t)?s(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:s("path must not be empty",TypeError):s(`path must be a string, but got \`${e}\``,TypeError),O=t=>K.test(t);i.isNotRelative=O;i.convert=t=>t;var g=class{constructor({ignorecase:e=!0,ignoreCase:s=e,allowRelativePaths:r=!1}={}){V(this,L,!0),this._rules=[],this._ignoreCase=s,this._allowRelativePaths=r,this._initCache();}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null);}_addPattern(e){if(e&&e[L]){this._rules=this._rules.concat(e._rules),this._added=!0;return;}if(q(e)){let s=Q(e,this._ignoreCase);this._added=!0,this._rules.push(s);}}add(e){return this._added=!1,C(R(e)?J(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this;}addPattern(e){return this.add(e);}_testOne(e,s){let r=!1,n=!1;return this._rules.forEach(o=>{let{negative:u}=o;if(n===u&&r!==n||u&&!r&&!n&&!s)return;o.regex.test(e)&&(r=!u,n=u);}),{ignored:r,unignored:n};}_test(e,s,r,n){let o=e&&i.convert(e);return i(o,e,this._allowRelativePaths?G:U),this._t(o,s,r,n);}_t(e,s,r,n){if(e in s)return s[e];if(n||(n=e.split(d)),n.pop(),!n.length)return s[e]=this._testOne(e,r);let o=this._t(n.join(d)+d,s,r,n);return s[e]=o.ignored?o:this._testOne(e,r);}ignores(e){return this._test(e,this._ignoreCache,!1).ignored;}createFilter(){return e=>!this.ignores(e);}filter(e){return C(e).filter(this.createFilter());}test(e){return this._test(e,this._testCache,!0);}},l=t=>new g(t),Z=t=>i(t&&i.convert(t),t,G);l.isPathValid=Z;l.default=l;v.exports=l;var tt=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");i.convert=tt;var et=/^[a-z]:\//i;i.isNotRelative=t=>et.test(t)||O(t);});var c={};D(c,{default:()=>nt});var st=$(A());_(c,$(A()));var{default:I,...rt}=st,nt=I!==void 0?I:rt;const importMeta={url:"file:///Users/winston/Code/winston/setup-deno/cache.ts",main:import.meta.main};if(importMeta.main){const args=parseArgs(Deno.args,{boolean:["help","dry-run","verbose","lock-write"],negatable:["lock-write"],string:["config"],default:{"lock-write":true},alias:{help:"h","dry-run":"n"},"--":true});const denoDir=Deno.env.get("DENO_DIR");const logLevel=["1","true"].includes(Deno.env.get("CI")??"")?"DEBUG":args.verbose?"DEBUG":"INFO";setup({handlers:{console:new handlers.ConsoleHandler(logLevel,{formatter:logRecord=>Deno.noColor?[logRecord.levelName,logRecord.msg].join(" "):logRecord.msg})},loggers:{default:{handlers:["console"],"level":logLevel}}});if(args.help){console.log("Usage: cache [-n | --dry-run] [-v | --verbose] [--] [DENO_ARGS...]");Deno.exit(0);}if(args["dry-run"])warning("dry-run mode enabled");if(args.config&&!await exists(args.config)){error(`config file ${args.config} not found`);Deno.exit(1);}const hash=await Deno.readFile("./deno.lock").then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>encodeHex(new Uint8Array(data))).catch(_=>"");debug(`GitHub actions deno.lock hash: ${hash}`);const cfgs=args.config?[args.config]:["deno.json","deno.jsonc"];const denoCfg=await Promise.all(cfgs.map(path=>Deno.readTextFile(path).catch(_=>undefined))).then(v=>parse(v.filter(Boolean)[0]??"{}"));const patterns=[...[denoCfg?.exclude??[]].flat(),...[denoCfg?.cache?.exclude??[]].flat(),...[denoCfg?.cache?.include??[]].flatMap(p=>`!${p}`)];debug(`patterns:`,patterns);patterns.forEach(p=>debug(`- ${p}`));const ig=nt().add(patterns);const walkIterator=walk(".",{exts:["js",".jsx",".ts",".tsx"],includeDirs:false});const paths=[];for await(const entry of walkIterator){const relativePath=relative2(".",entry.path);if(denoDir&&entry.path.startsWith(denoDir))continue;if(ig.ignores(relativePath)){debug(`ignored ${relativePath}`);continue;}debug(`caching ${relativePath}`);paths.push(relativePath);}const cmd=new Deno.Command(Deno.execPath(),{args:["cache",args["lock-write"]&&"--lock-write",args.config&&`--config=${args.config}`,...args["--"],...paths].filter(Boolean),stdout:"inherit",stderr:"inherit"});const code=!args["dry-run"]?(await cmd.output()).code:0;if(code===0)debug(`finished caching ${paths.length} files`);} \ No newline at end of file From deb366bc6171e5542284c49b78e6fc3ef326848f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 26 Dec 2023 20:46:27 +0000 Subject: [PATCH 13/18] chore: build action bundle --- dist/cache.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/cache.js b/dist/cache.js index c6d82b2..1e7f7cd 100755 --- a/dist/cache.js +++ b/dist/cache.js @@ -1,2 +1,2 @@ #!/usr/bin/env -S deno run --no-lock --allow-read --allow-run=deno --allow-env=CI,DENO_DIR -class AssertionError extends Error{constructor(message){super(message);this.name="AssertionError";}}function assert(expr,msg=""){if(!expr){throw new AssertionError(msg);}}const{hasOwn}=Object;function get(obj,key){if(hasOwn(obj,key)){return obj[key];}}function getForce(obj,key){const v=get(obj,key);assert(v!==undefined);return v;}function isNumber(x){if(typeof x==="number")return true;if(/^0x[0-9a-f]+$/i.test(String(x)))return true;return/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(String(x));}function hasKey(obj,keys){let o=obj;keys.slice(0,-1).forEach(key=>{o=get(o,key)??{};});const key=keys[keys.length-1];return hasOwn(o,key);}function parseArgs(args,{"--":doubleDash=false,alias={},boolean:__boolean=false,default:defaults={},stopEarly=false,string=[],collect=[],negatable=[],unknown=i=>i}={}){const aliases={};const flags={bools:{},strings:{},unknownFn:unknown,allBools:false,collect:{},negatable:{}};if(alias!==undefined){for(const key in alias){const val=getForce(alias,key);if(typeof val==="string"){aliases[key]=[val];}else{aliases[key]=val;}for(const alias of getForce(aliases,key)){aliases[alias]=[key].concat(aliases[key].filter(y=>alias!==y));}}}if(__boolean!==undefined){if(typeof __boolean==="boolean"){flags.allBools=!!__boolean;}else{const booleanArgs=typeof __boolean==="string"?[__boolean]:__boolean;for(const key of booleanArgs.filter(Boolean)){flags.bools[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.bools[al]=true;}}}}}if(string!==undefined){const stringArgs=typeof string==="string"?[string]:string;for(const key of stringArgs.filter(Boolean)){flags.strings[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.strings[al]=true;}}}}if(collect!==undefined){const collectArgs=typeof collect==="string"?[collect]:collect;for(const key of collectArgs.filter(Boolean)){flags.collect[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.collect[al]=true;}}}}if(negatable!==undefined){const negatableArgs=typeof negatable==="string"?[negatable]:negatable;for(const key of negatableArgs.filter(Boolean)){flags.negatable[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.negatable[al]=true;}}}}const argv={_:[]};function argDefined(key,arg){return flags.allBools&&/^--[^=]+$/.test(arg)||get(flags.bools,key)||!!get(flags.strings,key)||!!get(aliases,key);}function setKey(obj,name,value,collect=true){let o=obj;const keys=name.split(".");keys.slice(0,-1).forEach(function(key){if(get(o,key)===undefined){o[key]={};}o=get(o,key);});const key=keys[keys.length-1];const collectable=collect&&!!get(flags.collect,name);if(!collectable){o[key]=value;}else if(get(o,key)===undefined){o[key]=[value];}else if(Array.isArray(get(o,key))){o[key].push(value);}else{o[key]=[get(o,key),value];}}function setArg(key,val,arg=undefined,collect){if(arg&&flags.unknownFn&&!argDefined(key,arg)){if(flags.unknownFn(arg,key,val)===false)return;}const value=!get(flags.strings,key)&&isNumber(val)?Number(val):val;setKey(argv,key,value,collect);const alias=get(aliases,key);if(alias){for(const x of alias){setKey(argv,x,value,collect);}}}function aliasIsBoolean(key){return getForce(aliases,key).some(x=>typeof get(flags.bools,x)==="boolean");}let notFlags=[];if(args.includes("--")){notFlags=args.slice(args.indexOf("--")+1);args=args.slice(0,args.indexOf("--"));}for(let i=0;i>4];dst[i*2+1]=hexTable[v&15];}return textDecoder.decode(dst);}const osType=(()=>{const{Deno:Deno1}=globalThis;if(typeof Deno1?.build?.os==="string"){return Deno1.build.os;}const{navigator}=globalThis;if(navigator?.appVersion?.includes?.("Win")){return"windows";}return"linux";})();const isWindows=osType==="windows";function assertPath(path){if(typeof path!=="string"){throw new TypeError(`Path must be a string. Received ${JSON.stringify(path)}`);}}function assertArg(path){assertPath(path);if(path.length===0)return".";}const CHAR_FORWARD_SLASH=47;function normalizeString(path,allowAboveRoot,separator,isPathSeparator){let res="";let lastSegmentLength=0;let lastSlash=-1;let dots=0;let code;for(let i=0,len=path.length;i<=len;++i){if(i2){const lastSlashIndex=res.lastIndexOf(separator);if(lastSlashIndex===-1){res="";lastSegmentLength=0;}else{res=res.slice(0,lastSlashIndex);lastSegmentLength=res.length-1-res.lastIndexOf(separator);}lastSlash=i;dots=0;continue;}else if(res.length===2||res.length===1){res="";lastSegmentLength=0;lastSlash=i;dots=0;continue;}}if(allowAboveRoot){if(res.length>0)res+=`${separator}..`;else res="..";lastSegmentLength=2;}}else{if(res.length>0)res+=separator+path.slice(lastSlash+1,i);else res=path.slice(lastSlash+1,i);lastSegmentLength=i-lastSlash-1;}lastSlash=i;dots=0;}else if(code===46&&dots!==-1){++dots;}else{dots=-1;}}return res;}function isPosixPathSeparator(code){return code===47;}function normalize(path){assertArg(path);const isAbsolute=isPosixPathSeparator(path.charCodeAt(0));const trailingSeparator=isPosixPathSeparator(path.charCodeAt(path.length-1));path=normalizeString(path,!isAbsolute,"/",isPosixPathSeparator);if(path.length===0&&!isAbsolute)path=".";if(path.length>0&&trailingSeparator)path+="/";if(isAbsolute)return`/${path}`;return path;}function join(...paths){if(paths.length===0)return".";let joined;for(let i=0,len=paths.length;i0){if(!joined)joined=path;else joined+=`/${path}`;}}if(!joined)return".";return normalize(joined);}function isPathSeparator(code){return code===47||code===92;}function isWindowsDeviceRoot(code){return code>=97&&code<=122||code>=65&&code<=90;}function normalize1(path){assertArg(path);const len=path.length;let rootEnd=0;let device;let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){return"\\";}let tail;if(rootEnd0&&isPathSeparator(path.charCodeAt(len-1))){tail+="\\";}if(device===undefined){if(isAbsolute){if(tail.length>0)return`\\${tail}`;else return"\\";}else if(tail.length>0){return tail;}else{return"";}}else if(isAbsolute){if(tail.length>0)return`${device}\\${tail}`;else return`${device}\\`;}else if(tail.length>0){return device+tail;}else{return device;}}function join1(...paths){if(paths.length===0)return".";let joined;let firstPart=null;for(let i=0;i0){if(joined===undefined)joined=firstPart=path;else joined+=`\\${path}`;}}if(joined===undefined)return".";let needsReplace=true;let slashCount=0;assert(firstPart!==null);if(isPathSeparator(firstPart.charCodeAt(0))){++slashCount;const firstLen=firstPart.length;if(firstLen>1){if(isPathSeparator(firstPart.charCodeAt(1))){++slashCount;if(firstLen>2){if(isPathSeparator(firstPart.charCodeAt(2)))++slashCount;else{needsReplace=false;}}}}}if(needsReplace){for(;slashCount=2)joined=`\\${joined.slice(slashCount)}`;}return normalize1(joined);}function join2(...paths){return isWindows?join1(...paths):join(...paths);}function assertArg1(url){url=url instanceof URL?url:new URL(url);if(url.protocol!=="file:"){throw new TypeError("Must be a file URL.");}return url;}function fromFileUrl(url){url=assertArg1(url);return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"));}function fromFileUrl1(url){url=assertArg1(url);let path=decodeURIComponent(url.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");if(url.hostname!==""){path=`\\\\${url.hostname}${path}`;}return path;}function fromFileUrl2(url){return isWindows?fromFileUrl1(url):fromFileUrl(url);}function toPathString(pathUrl){return pathUrl instanceof URL?fromFileUrl2(pathUrl):pathUrl;}function stripTrailingSeparators(segment,isSep){if(segment.length<=1){return segment;}let end=segment.length;for(let i=segment.length-1;i>0;i--){if(isSep(segment.charCodeAt(i))){end=i;}else{break;}}return segment.slice(0,end);}function resolve(...pathSegments){let resolvedPath="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1&&!resolvedAbsolute;i--){let path;if(i>=0)path=pathSegments[i];else{const{Deno:Deno1}=globalThis;if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();}assertPath(path);if(path.length===0){continue;}resolvedPath=`${path}/${resolvedPath}`;resolvedAbsolute=isPosixPathSeparator(path.charCodeAt(0));}resolvedPath=normalizeString(resolvedPath,!resolvedAbsolute,"/",isPosixPathSeparator);if(resolvedAbsolute){if(resolvedPath.length>0)return`/${resolvedPath}`;else return"/";}else if(resolvedPath.length>0)return resolvedPath;else return".";}function resolve1(...pathSegments){let resolvedDevice="";let resolvedTail="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1;i--){let path;const{Deno:Deno1}=globalThis;if(i>=0){path=pathSegments[i];}else if(!resolvedDevice){if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a drive-letter-less path without a CWD.");}path=Deno1.cwd();}else{if(typeof Deno1?.env?.get!=="function"||typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();if(path===undefined||path.slice(0,3).toLowerCase()!==`${resolvedDevice.toLowerCase()}\\`){path=`${resolvedDevice}\\`;}}assertPath(path);const len=path.length;if(len===0)continue;let rootEnd=0;let device="";let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){rootEnd=1;isAbsolute=true;}if(device.length>0&&resolvedDevice.length>0&&device.toLowerCase()!==resolvedDevice.toLowerCase()){continue;}if(resolvedDevice.length===0&&device.length>0){resolvedDevice=device;}if(!resolvedAbsolute){resolvedTail=`${path.slice(rootEnd)}\\${resolvedTail}`;resolvedAbsolute=isAbsolute;}if(resolvedAbsolute&&resolvedDevice.length>0)break;}resolvedTail=normalizeString(resolvedTail,!resolvedAbsolute,"\\",isPathSeparator);return resolvedDevice+(resolvedAbsolute?"\\":"")+resolvedTail||".";}Deno.build.os==="windows";async function exists(path,options){try{const stat=await Deno.stat(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if((await Deno.permissions.query({name:"read",path})).state==="granted"){return!options?.isReadable;}}throw error;}}function existsSync(path,options){try{const stat=Deno.statSync(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if(Deno.permissions.querySync({name:"read",path}).state==="granted"){return!options?.isReadable;}}throw error;}}function normalize2(path){return isWindows?normalize1(path):normalize(path);}function stripSuffix(name,suffix){if(suffix.length>=name.length){return name;}const lenDiff=name.length-suffix.length;for(let i=suffix.length-1;i>=0;--i){if(name.charCodeAt(lenDiff+i)!==suffix.charCodeAt(i)){return name;}}return name.slice(0,-suffix.length);}function lastPathSegment(path,isSep,start=0){let matchedNonSeparator=false;let end=path.length;for(let i=path.length-1;i>=start;--i){if(isSep(path.charCodeAt(i))){if(matchedNonSeparator){start=i+1;break;}}else if(!matchedNonSeparator){matchedNonSeparator=true;end=i+1;}}return path.slice(start,end);}function assertArgs(path,suffix){assertPath(path);if(path.length===0)return path;if(typeof suffix!=="string"){throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);}}function basename(path,suffix=""){assertArgs(path,suffix);const lastSegment=lastPathSegment(path,isPosixPathSeparator);const strippedSegment=stripTrailingSeparators(lastSegment,isPosixPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename1(path,suffix=""){assertArgs(path,suffix);let start=0;if(path.length>=2){const drive=path.charCodeAt(0);if(isWindowsDeviceRoot(drive)){if(path.charCodeAt(1)===58)start=2;}}const lastSegment=lastPathSegment(path,isPathSeparator,start);const strippedSegment=stripTrailingSeparators(lastSegment,isPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename2(path,suffix=""){return isWindows?basename1(path,suffix):basename(path,suffix);}async function createWalkEntry(path){path=toPathString(path);path=normalize2(path);const name=basename2(path);const info=await Deno.stat(path);return{path,name,isFile:info.isFile,isDirectory:info.isDirectory,isSymlink:info.isSymlink};}class WalkError extends Error{root;constructor(cause,root){super(`${cause instanceof Error?cause.message:cause} for path "${root}"`);this.cause=cause;this.name="WalkError";this.root=root;}}function include(path,exts,match,skip){if(exts&&!exts.some(ext=>path.endsWith(ext))){return false;}if(match&&!match.some(pattern=>!!path.match(pattern))){return false;}if(skip&&skip.some(pattern=>!!path.match(pattern))){return false;}return true;}function wrapErrorWithPath(err,root){if(err instanceof WalkError)return err;return new WalkError(err,root);}async function*walk(root,{maxDepth=Infinity,includeFiles=true,includeDirs=true,includeSymlinks=true,followSymlinks=false,canonicalize=true,exts=undefined,match=undefined,skip=undefined}={}){if(maxDepth<0){return;}root=toPathString(root);if(includeDirs&&include(root,exts,match,skip)){yield await createWalkEntry(root);}if(maxDepth<1||!include(root,undefined,undefined,skip)){return;}try{for await(const entry of Deno.readDir(root)){let path=join2(root,entry.name);let{isSymlink,isDirectory}=entry;if(isSymlink){if(!followSymlinks){if(includeSymlinks&&include(path,exts,match,skip)){yield{path,...entry};}continue;}const realPath=await Deno.realPath(path);if(canonicalize){path=realPath;}({isSymlink,isDirectory}=await Deno.lstat(realPath));}if(isSymlink||isDirectory){yield*walk(path,{maxDepth:maxDepth-1,includeFiles,includeDirs,includeSymlinks,followSymlinks,exts,match,skip});}else if(includeFiles&&include(path,exts,match,skip)){yield{path,...entry};}}}catch(err){throw wrapErrorWithPath(err,normalize2(root));}}Deno.build.os==="windows";new Deno.errors.AlreadyExists("dest already exists.");Deno.build.os==="windows";const LF="\n";const CRLF="\r\n";Deno?.build.os==="windows"?CRLF:LF;function parse(text,{allowTrailingComma=true}={}){if(new.target){throw new TypeError("parse is not a constructor");}return new JSONCParser(text,{allowTrailingComma}).parse();}const originalJSONParse=globalThis.JSON.parse;class JSONCParser{#whitespace=new Set(" \r\n");#numberEndToken=new Set([..."[]{}:,/",...this.#whitespace]);#text;#length;#tokenized;#options;constructor(text,options){this.#text=`${text}`;this.#length=this.#text.length;this.#tokenized=this.#tokenize();this.#options=options;}parse(){const token=this.#getNext();const res=this.#parseJsonValue(token);const{done,value}=this.#tokenized.next();if(!done){throw new SyntaxError(buildErrorMessage(value));}return res;}#getNext(){const{done,value}=this.#tokenized.next();if(done){throw new SyntaxError("Unexpected end of JSONC input");}return value;}*#tokenize(){for(let i=0;iisNaN(Number(key)));const byLevel={[LogLevels.NOTSET]:"NOTSET",[LogLevels.DEBUG]:"DEBUG",[LogLevels.INFO]:"INFO",[LogLevels.WARNING]:"WARNING",[LogLevels.ERROR]:"ERROR",[LogLevels.CRITICAL]:"CRITICAL"};function getLevelByName(name){const level=LogLevels[name];if(level!==undefined){return level;}throw new Error(`no log level found for name: ${name}`);}function getLevelName(level){const levelName=byLevel[level];if(levelName){return levelName;}throw new Error(`no level name found for level: ${level}`);}class LogRecord{msg;#args;#datetime;level;levelName;loggerName;constructor(options){this.msg=options.msg;this.#args=[...options.args];this.level=options.level;this.loggerName=options.loggerName;this.#datetime=new Date;this.levelName=getLevelName(options.level);}get args(){return[...this.#args];}get datetime(){return new Date(this.#datetime.getTime());}}class Logger{#level;#handlers;#loggerName;constructor(loggerName,levelName,options={}){this.#loggerName=loggerName;this.#level=getLevelByName(levelName);this.#handlers=options.handlers||[];}get level(){return this.#level;}set level(level){try{this.#level=getLevelByName(getLevelName(level));}catch(_){throw new TypeError(`Invalid log level: ${level}`);}}get levelName(){return getLevelName(this.#level);}set levelName(levelName){this.#level=getLevelByName(levelName);}get loggerName(){return this.#loggerName;}set handlers(hndls){this.#handlers=hndls;}get handlers(){return this.#handlers;}#_log(level,msg,...args){if(this.level>level){return msg instanceof Function?undefined:msg;}let fnResult;let logMessage;if(msg instanceof Function){fnResult=msg();logMessage=this.asString(fnResult);}else{logMessage=this.asString(msg);}const record=new LogRecord({msg:logMessage,args:args,level:level,loggerName:this.loggerName});this.#handlers.forEach(handler=>{handler.handle(record);});return msg instanceof Function?fnResult:msg;}asString(data,isProperty=false){if(typeof data==="string"){if(isProperty)return`"${data}"`;return data;}else if(data===null||typeof data==="number"||typeof data==="bigint"||typeof data==="boolean"||typeof data==="undefined"||typeof data==="symbol"){return String(data);}else if(data instanceof Error){return data.stack;}else if(typeof data==="object"){return`{${Object.entries(data).map(([k,v])=>`"${k}":${this.asString(v,true)}`).join(",")}}`;}return"undefined";}debug(msg,...args){return this.#_log(LogLevels.DEBUG,msg,...args);}info(msg,...args){return this.#_log(LogLevels.INFO,msg,...args);}warning(msg,...args){return this.#_log(LogLevels.WARNING,msg,...args);}error(msg,...args){return this.#_log(LogLevels.ERROR,msg,...args);}critical(msg,...args){return this.#_log(LogLevels.CRITICAL,msg,...args);}}const{Deno:Deno1}=globalThis;const noColor=typeof Deno1?.noColor==="boolean"?Deno1.noColor:false;let enabled=!noColor;function code(open,close){return{open:`\x1b[${open.join(";")}m`,close:`\x1b[${close}m`,regexp:new RegExp(`\\x1b\\[${close}m`,"g")};}function run(str,code){return enabled?`${code.open}${str.replace(code.regexp,code.open)}${code.close}`:str;}function bold(str){return run(str,code([1],22));}function red(str){return run(str,code([31],39));}function yellow(str){return run(str,code([33],39));}function blue(str){return run(str,code([34],39));}new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"),"g");function copy(src,dst,off=0){off=Math.max(0,Math.min(off,dst.byteLength));const dstBytesAvailable=dst.byteLength-off;if(src.byteLength>dstBytesAvailable){src=src.subarray(0,dstBytesAvailable);}dst.set(src,off);return src.byteLength;}class AbstractBufBase{buf;usedBufferBytes=0;err=null;constructor(buf){this.buf=buf;}size(){return this.buf.byteLength;}available(){return this.buf.byteLength-this.usedBufferBytes;}buffered(){return this.usedBufferBytes;}}class BufWriterSync extends AbstractBufBase{#writer;static create(writer,size=4096){return writer instanceof BufWriterSync?writer:new BufWriterSync(writer,size);}constructor(writer,size=4096){super(new Uint8Array(size<=0?4096:size));this.#writer=writer;}reset(w){this.err=null;this.usedBufferBytes=0;this.#writer=w;}flush(){if(this.err!==null)throw this.err;if(this.usedBufferBytes===0)return;try{const p=this.buf.subarray(0,this.usedBufferBytes);let nwritten=0;while(nwrittenthis.available()){if(this.buffered()===0){try{numBytesWritten=this.#writer.writeSync(data);}catch(e){if(e instanceof Error){this.err=e;}throw e;}}else{numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;this.flush();}totalBytesWritten+=numBytesWritten;data=data.subarray(numBytesWritten);}numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;totalBytesWritten+=numBytesWritten;return totalBytesWritten;}}const DEFAULT_FORMATTER="{levelName} {msg}";class BaseHandler{level;levelName;formatter;constructor(levelName,options={}){this.level=getLevelByName(levelName);this.levelName=levelName;this.formatter=options.formatter||DEFAULT_FORMATTER;}handle(logRecord){if(this.level>logRecord.level)return;const msg=this.format(logRecord);this.log(msg);}format(logRecord){if(this.formatter instanceof Function){return this.formatter(logRecord);}return this.formatter.replace(/{([^\s}]+)}/g,(match,p1)=>{const value=logRecord[p1];if(value===undefined){return match;}return String(value);});}log(_msg){}setup(){}destroy(){}}class ConsoleHandler extends BaseHandler{#useColors;constructor(levelName,options={}){super(levelName,options);this.#useColors=options.useColors??true;}format(logRecord){let msg=super.format(logRecord);if(this.#useColors){msg=this.applyColors(msg,logRecord.level);}return msg;}applyColors(msg,level){switch(level){case LogLevels.INFO:msg=blue(msg);break;case LogLevels.WARNING:msg=yellow(msg);break;case LogLevels.ERROR:msg=red(msg);break;case LogLevels.CRITICAL:msg=bold(red(msg));break;default:break;}return msg;}log(msg){console.log(msg);}}class WriterHandler extends BaseHandler{_writer;#encoder=new TextEncoder;}class FileHandler extends WriterHandler{_file;_buf;_filename;_mode;_openOptions;_encoder=new TextEncoder;#unloadCallback=(()=>{this.destroy();}).bind(this);constructor(levelName,options){super(levelName,options);this._filename=options.filename;this._mode=options.mode?options.mode:"a";this._openOptions={createNew:this._mode==="x",create:this._mode!=="x",append:this._mode==="a",truncate:this._mode!=="a",write:true};}setup(){this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);addEventListener("unload",this.#unloadCallback);}handle(logRecord){super.handle(logRecord);if(logRecord.level>LogLevels.ERROR){this.flush();}}log(msg){if(this._encoder.encode(msg).byteLength+1>this._buf.available()){this.flush();}this._buf.writeSync(this._encoder.encode(msg+"\n"));}flush(){if(this._buf?.buffered()>0){this._buf.flush();}}destroy(){this.flush();this._file?.close();this._file=undefined;removeEventListener("unload",this.#unloadCallback);}}class RotatingFileHandler extends FileHandler{#maxBytes;#maxBackupCount;#currentFileSize=0;constructor(levelName,options){super(levelName,options);this.#maxBytes=options.maxBytes;this.#maxBackupCount=options.maxBackupCount;}setup(){if(this.#maxBytes<1){this.destroy();throw new Error("maxBytes cannot be less than 1");}if(this.#maxBackupCount<1){this.destroy();throw new Error("maxBackupCount cannot be less than 1");}super.setup();if(this._mode==="w"){for(let i=1;i<=this.#maxBackupCount;i++){try{Deno.removeSync(this._filename+"."+i);}catch(error){if(!(error instanceof Deno.errors.NotFound)){throw error;}}}}else if(this._mode==="x"){for(let i=1;i<=this.#maxBackupCount;i++){if(existsSync(this._filename+"."+i)){this.destroy();throw new Deno.errors.AlreadyExists("Backup log file "+this._filename+"."+i+" already exists");}}}else{this.#currentFileSize=Deno.statSync(this._filename).size;}}log(msg){const msgByteLength=this._encoder.encode(msg).byteLength+1;if(this.#currentFileSize+msgByteLength>this.#maxBytes){this.rotateLogFiles();this.#currentFileSize=0;}super.log(msg);this.#currentFileSize+=msgByteLength;}rotateLogFiles(){this._buf.flush();this._file.close();for(let i=this.#maxBackupCount-1;i>=0;i--){const source=this._filename+(i===0?"":"."+i);const dest=this._filename+"."+(i+1);if(existsSync(source)){Deno.renameSync(source,dest);}}this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);}}const DEFAULT_LEVEL="INFO";const DEFAULT_CONFIG={handlers:{default:new ConsoleHandler(DEFAULT_LEVEL)},loggers:{default:{level:DEFAULT_LEVEL,handlers:["default"]}}};const state={handlers:new Map,loggers:new Map,config:DEFAULT_CONFIG};const handlers={BaseHandler,ConsoleHandler,WriterHandler,FileHandler,RotatingFileHandler};function getLogger(name){if(!name){const d=state.loggers.get("default");assert(d!==undefined,`"default" logger must be set for getting logger without name`);return d;}const result=state.loggers.get(name);if(!result){const logger=new Logger(name,"NOTSET",{handlers:[]});state.loggers.set(name,logger);return logger;}return result;}function debug(msg,...args){if(msg instanceof Function){return getLogger("default").debug(msg,...args);}return getLogger("default").debug(msg,...args);}function warning(msg,...args){if(msg instanceof Function){return getLogger("default").warning(msg,...args);}return getLogger("default").warning(msg,...args);}function error(msg,...args){if(msg instanceof Function){return getLogger("default").error(msg,...args);}return getLogger("default").error(msg,...args);}function setup(config){state.config={handlers:{...DEFAULT_CONFIG.handlers,...config.handlers},loggers:{...DEFAULT_CONFIG.loggers,...config.loggers}};state.handlers.forEach(handler=>{handler.destroy();});state.handlers.clear();const handlers=state.config.handlers||{};for(const handlerName in handlers){const handler=handlers[handlerName];handler.setup();state.handlers.set(handlerName,handler);}state.loggers.clear();const loggers=state.config.loggers||{};for(const loggerName in loggers){const loggerConfig=loggers[loggerName];const handlerNames=loggerConfig.handlers||[];const handlers=[];handlerNames.forEach(handlerName=>{const handler=state.handlers.get(handlerName);if(handler){handlers.push(handler);}});const levelName=loggerConfig.level||DEFAULT_LEVEL;const logger=new Logger(loggerName,levelName,{handlers:handlers});state.loggers.set(loggerName,logger);}}setup(DEFAULT_CONFIG);function assertArgs1(from,to){assertPath(from);assertPath(to);if(from===to)return"";}function relative(from,to){assertArgs1(from,to);from=resolve(from);to=resolve(to);if(from===to)return"";let fromStart=1;const fromEnd=from.length;for(;fromStartlength){if(isPosixPathSeparator(to.charCodeAt(toStart+i))){return to.slice(toStart+i+1);}else if(i===0){return to.slice(toStart+i);}}else if(fromLen>length){if(isPosixPathSeparator(from.charCodeAt(fromStart+i))){lastCommonSep=i;}else if(i===0){lastCommonSep=0;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(isPosixPathSeparator(fromCode))lastCommonSep=i;}let out="";for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||isPosixPathSeparator(from.charCodeAt(i))){if(out.length===0)out+="..";else out+="/..";}}if(out.length>0)return out+to.slice(toStart+lastCommonSep);else{toStart+=lastCommonSep;if(isPosixPathSeparator(to.charCodeAt(toStart)))++toStart;return to.slice(toStart);}}function relative1(from,to){assertArgs1(from,to);const fromOrig=resolve1(from);const toOrig=resolve1(to);if(fromOrig===toOrig)return"";from=fromOrig.toLowerCase();to=toOrig.toLowerCase();if(from===to)return"";let fromStart=0;let fromEnd=from.length;for(;fromStartfromStart;--fromEnd){if(from.charCodeAt(fromEnd-1)!==92)break;}const fromLen=fromEnd-fromStart;let toStart=0;let toEnd=to.length;for(;toStarttoStart;--toEnd){if(to.charCodeAt(toEnd-1)!==92)break;}const toLen=toEnd-toStart;const length=fromLenlength){if(to.charCodeAt(toStart+i)===92){return toOrig.slice(toStart+i+1);}else if(i===2){return toOrig.slice(toStart+i);}}if(fromLen>length){if(from.charCodeAt(fromStart+i)===92){lastCommonSep=i;}else if(i===2){lastCommonSep=3;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(fromCode===92)lastCommonSep=i;}if(i!==length&&lastCommonSep===-1){return toOrig;}let out="";if(lastCommonSep===-1)lastCommonSep=0;for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||from.charCodeAt(i)===92){if(out.length===0)out+="..";else out+="\\..";}}if(out.length>0){return out+toOrig.slice(toStart+lastCommonSep,toEnd);}else{toStart+=lastCommonSep;if(toOrig.charCodeAt(toStart)===92)++toStart;return toOrig.slice(toStart,toEnd);}}function relative2(from,to){return isWindows?relative1(from,to):relative(from,to);}var m=Object.create;var E=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),D=(t,e)=>{for(var s in e)E(t,s,{get:e[s],enumerable:!0});},a=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!b.call(t,n)&&n!==s&&E(t,n,{get:()=>e[n],enumerable:!(r=T(e,n))||r.enumerable});return t;},_=(t,e,s)=>(a(t,e,"default"),s&&a(s,e,"default")),$=(t,e,s)=>(s=t!=null?m(X(t)):{},a(e||!t||!t.__esModule?E(s,"default",{value:t,enumerable:!0}):s,t));var A=w((ct,v)=>{function C(t){return Array.isArray(t)?t:[t];}var N="",P=" ",h="\\",H=/^\s+$/,F=/(?:[^\\]|^)\\$/,k=/^\\!/,z=/^\\#/,B=/\r?\n/g,K=/^\.*\/|^\.+$/,d="/",x="node-ignore";typeof Symbol<"u"&&(x=Symbol.for("node-ignore"));var L=x,V=(t,e,s)=>Object.defineProperty(t,e,{value:s}),j=/([0-z])-([0-z])/g,G=()=>!1,M=t=>t.replace(j,(e,s,r)=>s.charCodeAt(0)<=r.charCodeAt(0)?e:N),Y=t=>{let{length:e}=t;return t.slice(0,e-e%2);},W=[[/\\?\s+$/,t=>t.indexOf("\\")===0?P:N],[/\\\s/g,()=>P],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)";}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,s)=>e+6{let r=s.replace(/\\\*/g,"[^\\/]*");return e+r;}],[/\\\\\\(?=[$.|*+(){^])/g,()=>h],[/\\\\/g,()=>h],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,s,r,n)=>e===h?`\\[${s}${Y(r)}${n}`:n==="]"&&r.length%2===0?`[${M(s)}${r}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],S=Object.create(null),p=(t,e)=>{let s=S[t];return s||(s=W.reduce((r,n)=>r.replace(n[0],n[1].bind(t)),t),S[t]=s),e?new RegExp(s,"i"):new RegExp(s);},R=t=>typeof t=="string",q=t=>t&&R(t)&&!H.test(t)&&!F.test(t)&&t.indexOf("#")!==0,J=t=>t.split(B),f=class{constructor(e,s,r,n){this.origin=e,this.pattern=s,this.negative=r,this.regex=n;}},Q=(t,e)=>{let s=t,r=!1;t.indexOf("!")===0&&(r=!0,t=t.substr(1)),t=t.replace(k,"!").replace(z,"#");let n=p(t,e);return new f(s,t,r,n);},U=(t,e)=>{throw new e(t);},i=(t,e,s)=>R(t)?t?i.isNotRelative(t)?s(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:s("path must not be empty",TypeError):s(`path must be a string, but got \`${e}\``,TypeError),O=t=>K.test(t);i.isNotRelative=O;i.convert=t=>t;var g=class{constructor({ignorecase:e=!0,ignoreCase:s=e,allowRelativePaths:r=!1}={}){V(this,L,!0),this._rules=[],this._ignoreCase=s,this._allowRelativePaths=r,this._initCache();}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null);}_addPattern(e){if(e&&e[L]){this._rules=this._rules.concat(e._rules),this._added=!0;return;}if(q(e)){let s=Q(e,this._ignoreCase);this._added=!0,this._rules.push(s);}}add(e){return this._added=!1,C(R(e)?J(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this;}addPattern(e){return this.add(e);}_testOne(e,s){let r=!1,n=!1;return this._rules.forEach(o=>{let{negative:u}=o;if(n===u&&r!==n||u&&!r&&!n&&!s)return;o.regex.test(e)&&(r=!u,n=u);}),{ignored:r,unignored:n};}_test(e,s,r,n){let o=e&&i.convert(e);return i(o,e,this._allowRelativePaths?G:U),this._t(o,s,r,n);}_t(e,s,r,n){if(e in s)return s[e];if(n||(n=e.split(d)),n.pop(),!n.length)return s[e]=this._testOne(e,r);let o=this._t(n.join(d)+d,s,r,n);return s[e]=o.ignored?o:this._testOne(e,r);}ignores(e){return this._test(e,this._ignoreCache,!1).ignored;}createFilter(){return e=>!this.ignores(e);}filter(e){return C(e).filter(this.createFilter());}test(e){return this._test(e,this._testCache,!0);}},l=t=>new g(t),Z=t=>i(t&&i.convert(t),t,G);l.isPathValid=Z;l.default=l;v.exports=l;var tt=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");i.convert=tt;var et=/^[a-z]:\//i;i.isNotRelative=t=>et.test(t)||O(t);});var c={};D(c,{default:()=>nt});var st=$(A());_(c,$(A()));var{default:I,...rt}=st,nt=I!==void 0?I:rt;const importMeta={url:"file:///Users/winston/Code/winston/setup-deno/cache.ts",main:import.meta.main};if(importMeta.main){const args=parseArgs(Deno.args,{boolean:["help","dry-run","verbose","lock-write"],negatable:["lock-write"],string:["config"],default:{"lock-write":true},alias:{help:"h","dry-run":"n"},"--":true});const denoDir=Deno.env.get("DENO_DIR");const logLevel=["1","true"].includes(Deno.env.get("CI")??"")?"DEBUG":args.verbose?"DEBUG":"INFO";setup({handlers:{console:new handlers.ConsoleHandler(logLevel,{formatter:logRecord=>Deno.noColor?[logRecord.levelName,logRecord.msg].join(" "):logRecord.msg})},loggers:{default:{handlers:["console"],"level":logLevel}}});if(args.help){console.log("Usage: cache [-n | --dry-run] [-v | --verbose] [--] [DENO_ARGS...]");Deno.exit(0);}if(args["dry-run"])warning("dry-run mode enabled");if(args.config&&!await exists(args.config)){error(`config file ${args.config} not found`);Deno.exit(1);}const hash=await Deno.readFile("./deno.lock").then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>encodeHex(new Uint8Array(data))).catch(_=>"");debug(`GitHub actions deno.lock hash: ${hash}`);const cfgs=args.config?[args.config]:["deno.json","deno.jsonc"];const denoCfg=await Promise.all(cfgs.map(path=>Deno.readTextFile(path).catch(_=>undefined))).then(v=>parse(v.filter(Boolean)[0]??"{}"));const patterns=[...[denoCfg?.exclude??[]].flat(),...[denoCfg?.cache?.exclude??[]].flat(),...[denoCfg?.cache?.include??[]].flatMap(p=>`!${p}`)];debug(`patterns:`,patterns);patterns.forEach(p=>debug(`- ${p}`));const ig=nt().add(patterns);const walkIterator=walk(".",{exts:["js",".jsx",".ts",".tsx"],includeDirs:false});const paths=[];for await(const entry of walkIterator){const relativePath=relative2(".",entry.path);if(denoDir&&entry.path.startsWith(denoDir))continue;if(ig.ignores(relativePath)){debug(`ignored ${relativePath}`);continue;}debug(`caching ${relativePath}`);paths.push(relativePath);}const cmd=new Deno.Command(Deno.execPath(),{args:["cache",args["lock-write"]&&"--lock-write",args.config&&`--config=${args.config}`,...args["--"],...paths].filter(Boolean),stdout:"inherit",stderr:"inherit"});const code=!args["dry-run"]?(await cmd.output()).code:0;if(code===0)debug(`finished caching ${paths.length} files`);} \ No newline at end of file +class AssertionError extends Error{constructor(message){super(message);this.name="AssertionError";}}function assert(expr,msg=""){if(!expr){throw new AssertionError(msg);}}const{hasOwn}=Object;function get(obj,key){if(hasOwn(obj,key)){return obj[key];}}function getForce(obj,key){const v=get(obj,key);assert(v!==undefined);return v;}function isNumber(x){if(typeof x==="number")return true;if(/^0x[0-9a-f]+$/i.test(String(x)))return true;return/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(String(x));}function hasKey(obj,keys){let o=obj;keys.slice(0,-1).forEach(key=>{o=get(o,key)??{};});const key=keys[keys.length-1];return hasOwn(o,key);}function parseArgs(args,{"--":doubleDash=false,alias={},boolean:__boolean=false,default:defaults={},stopEarly=false,string=[],collect=[],negatable=[],unknown=i=>i}={}){const aliases={};const flags={bools:{},strings:{},unknownFn:unknown,allBools:false,collect:{},negatable:{}};if(alias!==undefined){for(const key in alias){const val=getForce(alias,key);if(typeof val==="string"){aliases[key]=[val];}else{aliases[key]=val;}for(const alias of getForce(aliases,key)){aliases[alias]=[key].concat(aliases[key].filter(y=>alias!==y));}}}if(__boolean!==undefined){if(typeof __boolean==="boolean"){flags.allBools=!!__boolean;}else{const booleanArgs=typeof __boolean==="string"?[__boolean]:__boolean;for(const key of booleanArgs.filter(Boolean)){flags.bools[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.bools[al]=true;}}}}}if(string!==undefined){const stringArgs=typeof string==="string"?[string]:string;for(const key of stringArgs.filter(Boolean)){flags.strings[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.strings[al]=true;}}}}if(collect!==undefined){const collectArgs=typeof collect==="string"?[collect]:collect;for(const key of collectArgs.filter(Boolean)){flags.collect[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.collect[al]=true;}}}}if(negatable!==undefined){const negatableArgs=typeof negatable==="string"?[negatable]:negatable;for(const key of negatableArgs.filter(Boolean)){flags.negatable[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.negatable[al]=true;}}}}const argv={_:[]};function argDefined(key,arg){return flags.allBools&&/^--[^=]+$/.test(arg)||get(flags.bools,key)||!!get(flags.strings,key)||!!get(aliases,key);}function setKey(obj,name,value,collect=true){let o=obj;const keys=name.split(".");keys.slice(0,-1).forEach(function(key){if(get(o,key)===undefined){o[key]={};}o=get(o,key);});const key=keys[keys.length-1];const collectable=collect&&!!get(flags.collect,name);if(!collectable){o[key]=value;}else if(get(o,key)===undefined){o[key]=[value];}else if(Array.isArray(get(o,key))){o[key].push(value);}else{o[key]=[get(o,key),value];}}function setArg(key,val,arg=undefined,collect){if(arg&&flags.unknownFn&&!argDefined(key,arg)){if(flags.unknownFn(arg,key,val)===false)return;}const value=!get(flags.strings,key)&&isNumber(val)?Number(val):val;setKey(argv,key,value,collect);const alias=get(aliases,key);if(alias){for(const x of alias){setKey(argv,x,value,collect);}}}function aliasIsBoolean(key){return getForce(aliases,key).some(x=>typeof get(flags.bools,x)==="boolean");}let notFlags=[];if(args.includes("--")){notFlags=args.slice(args.indexOf("--")+1);args=args.slice(0,args.indexOf("--"));}for(let i=0;i>4];dst[i*2+1]=hexTable[v&15];}return textDecoder.decode(dst);}const osType=(()=>{const{Deno:Deno1}=globalThis;if(typeof Deno1?.build?.os==="string"){return Deno1.build.os;}const{navigator}=globalThis;if(navigator?.appVersion?.includes?.("Win")){return"windows";}return"linux";})();const isWindows=osType==="windows";function assertPath(path){if(typeof path!=="string"){throw new TypeError(`Path must be a string. Received ${JSON.stringify(path)}`);}}function assertArg(path){assertPath(path);if(path.length===0)return".";}const CHAR_FORWARD_SLASH=47;function normalizeString(path,allowAboveRoot,separator,isPathSeparator){let res="";let lastSegmentLength=0;let lastSlash=-1;let dots=0;let code;for(let i=0,len=path.length;i<=len;++i){if(i2){const lastSlashIndex=res.lastIndexOf(separator);if(lastSlashIndex===-1){res="";lastSegmentLength=0;}else{res=res.slice(0,lastSlashIndex);lastSegmentLength=res.length-1-res.lastIndexOf(separator);}lastSlash=i;dots=0;continue;}else if(res.length===2||res.length===1){res="";lastSegmentLength=0;lastSlash=i;dots=0;continue;}}if(allowAboveRoot){if(res.length>0)res+=`${separator}..`;else res="..";lastSegmentLength=2;}}else{if(res.length>0)res+=separator+path.slice(lastSlash+1,i);else res=path.slice(lastSlash+1,i);lastSegmentLength=i-lastSlash-1;}lastSlash=i;dots=0;}else if(code===46&&dots!==-1){++dots;}else{dots=-1;}}return res;}function isPosixPathSeparator(code){return code===47;}function normalize(path){assertArg(path);const isAbsolute=isPosixPathSeparator(path.charCodeAt(0));const trailingSeparator=isPosixPathSeparator(path.charCodeAt(path.length-1));path=normalizeString(path,!isAbsolute,"/",isPosixPathSeparator);if(path.length===0&&!isAbsolute)path=".";if(path.length>0&&trailingSeparator)path+="/";if(isAbsolute)return`/${path}`;return path;}function join(...paths){if(paths.length===0)return".";let joined;for(let i=0,len=paths.length;i0){if(!joined)joined=path;else joined+=`/${path}`;}}if(!joined)return".";return normalize(joined);}function isPathSeparator(code){return code===47||code===92;}function isWindowsDeviceRoot(code){return code>=97&&code<=122||code>=65&&code<=90;}function normalize1(path){assertArg(path);const len=path.length;let rootEnd=0;let device;let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){return"\\";}let tail;if(rootEnd0&&isPathSeparator(path.charCodeAt(len-1))){tail+="\\";}if(device===undefined){if(isAbsolute){if(tail.length>0)return`\\${tail}`;else return"\\";}else if(tail.length>0){return tail;}else{return"";}}else if(isAbsolute){if(tail.length>0)return`${device}\\${tail}`;else return`${device}\\`;}else if(tail.length>0){return device+tail;}else{return device;}}function join1(...paths){if(paths.length===0)return".";let joined;let firstPart=null;for(let i=0;i0){if(joined===undefined)joined=firstPart=path;else joined+=`\\${path}`;}}if(joined===undefined)return".";let needsReplace=true;let slashCount=0;assert(firstPart!==null);if(isPathSeparator(firstPart.charCodeAt(0))){++slashCount;const firstLen=firstPart.length;if(firstLen>1){if(isPathSeparator(firstPart.charCodeAt(1))){++slashCount;if(firstLen>2){if(isPathSeparator(firstPart.charCodeAt(2)))++slashCount;else{needsReplace=false;}}}}}if(needsReplace){for(;slashCount=2)joined=`\\${joined.slice(slashCount)}`;}return normalize1(joined);}function join2(...paths){return isWindows?join1(...paths):join(...paths);}function assertArg1(url){url=url instanceof URL?url:new URL(url);if(url.protocol!=="file:"){throw new TypeError("Must be a file URL.");}return url;}function fromFileUrl(url){url=assertArg1(url);return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"));}function fromFileUrl1(url){url=assertArg1(url);let path=decodeURIComponent(url.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");if(url.hostname!==""){path=`\\\\${url.hostname}${path}`;}return path;}function fromFileUrl2(url){return isWindows?fromFileUrl1(url):fromFileUrl(url);}function toPathString(pathUrl){return pathUrl instanceof URL?fromFileUrl2(pathUrl):pathUrl;}function stripTrailingSeparators(segment,isSep){if(segment.length<=1){return segment;}let end=segment.length;for(let i=segment.length-1;i>0;i--){if(isSep(segment.charCodeAt(i))){end=i;}else{break;}}return segment.slice(0,end);}function resolve(...pathSegments){let resolvedPath="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1&&!resolvedAbsolute;i--){let path;if(i>=0)path=pathSegments[i];else{const{Deno:Deno1}=globalThis;if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();}assertPath(path);if(path.length===0){continue;}resolvedPath=`${path}/${resolvedPath}`;resolvedAbsolute=isPosixPathSeparator(path.charCodeAt(0));}resolvedPath=normalizeString(resolvedPath,!resolvedAbsolute,"/",isPosixPathSeparator);if(resolvedAbsolute){if(resolvedPath.length>0)return`/${resolvedPath}`;else return"/";}else if(resolvedPath.length>0)return resolvedPath;else return".";}function resolve1(...pathSegments){let resolvedDevice="";let resolvedTail="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1;i--){let path;const{Deno:Deno1}=globalThis;if(i>=0){path=pathSegments[i];}else if(!resolvedDevice){if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a drive-letter-less path without a CWD.");}path=Deno1.cwd();}else{if(typeof Deno1?.env?.get!=="function"||typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();if(path===undefined||path.slice(0,3).toLowerCase()!==`${resolvedDevice.toLowerCase()}\\`){path=`${resolvedDevice}\\`;}}assertPath(path);const len=path.length;if(len===0)continue;let rootEnd=0;let device="";let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){rootEnd=1;isAbsolute=true;}if(device.length>0&&resolvedDevice.length>0&&device.toLowerCase()!==resolvedDevice.toLowerCase()){continue;}if(resolvedDevice.length===0&&device.length>0){resolvedDevice=device;}if(!resolvedAbsolute){resolvedTail=`${path.slice(rootEnd)}\\${resolvedTail}`;resolvedAbsolute=isAbsolute;}if(resolvedAbsolute&&resolvedDevice.length>0)break;}resolvedTail=normalizeString(resolvedTail,!resolvedAbsolute,"\\",isPathSeparator);return resolvedDevice+(resolvedAbsolute?"\\":"")+resolvedTail||".";}Deno.build.os==="windows";async function exists(path,options){try{const stat=await Deno.stat(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if((await Deno.permissions.query({name:"read",path})).state==="granted"){return!options?.isReadable;}}throw error;}}function existsSync(path,options){try{const stat=Deno.statSync(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if(Deno.permissions.querySync({name:"read",path}).state==="granted"){return!options?.isReadable;}}throw error;}}function normalize2(path){return isWindows?normalize1(path):normalize(path);}function stripSuffix(name,suffix){if(suffix.length>=name.length){return name;}const lenDiff=name.length-suffix.length;for(let i=suffix.length-1;i>=0;--i){if(name.charCodeAt(lenDiff+i)!==suffix.charCodeAt(i)){return name;}}return name.slice(0,-suffix.length);}function lastPathSegment(path,isSep,start=0){let matchedNonSeparator=false;let end=path.length;for(let i=path.length-1;i>=start;--i){if(isSep(path.charCodeAt(i))){if(matchedNonSeparator){start=i+1;break;}}else if(!matchedNonSeparator){matchedNonSeparator=true;end=i+1;}}return path.slice(start,end);}function assertArgs(path,suffix){assertPath(path);if(path.length===0)return path;if(typeof suffix!=="string"){throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);}}function basename(path,suffix=""){assertArgs(path,suffix);const lastSegment=lastPathSegment(path,isPosixPathSeparator);const strippedSegment=stripTrailingSeparators(lastSegment,isPosixPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename1(path,suffix=""){assertArgs(path,suffix);let start=0;if(path.length>=2){const drive=path.charCodeAt(0);if(isWindowsDeviceRoot(drive)){if(path.charCodeAt(1)===58)start=2;}}const lastSegment=lastPathSegment(path,isPathSeparator,start);const strippedSegment=stripTrailingSeparators(lastSegment,isPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename2(path,suffix=""){return isWindows?basename1(path,suffix):basename(path,suffix);}async function createWalkEntry(path){path=toPathString(path);path=normalize2(path);const name=basename2(path);const info=await Deno.stat(path);return{path,name,isFile:info.isFile,isDirectory:info.isDirectory,isSymlink:info.isSymlink};}class WalkError extends Error{root;constructor(cause,root){super(`${cause instanceof Error?cause.message:cause} for path "${root}"`);this.cause=cause;this.name="WalkError";this.root=root;}}function include(path,exts,match,skip){if(exts&&!exts.some(ext=>path.endsWith(ext))){return false;}if(match&&!match.some(pattern=>!!path.match(pattern))){return false;}if(skip&&skip.some(pattern=>!!path.match(pattern))){return false;}return true;}function wrapErrorWithPath(err,root){if(err instanceof WalkError)return err;return new WalkError(err,root);}async function*walk(root,{maxDepth=Infinity,includeFiles=true,includeDirs=true,includeSymlinks=true,followSymlinks=false,canonicalize=true,exts=undefined,match=undefined,skip=undefined}={}){if(maxDepth<0){return;}root=toPathString(root);if(includeDirs&&include(root,exts,match,skip)){yield await createWalkEntry(root);}if(maxDepth<1||!include(root,undefined,undefined,skip)){return;}try{for await(const entry of Deno.readDir(root)){let path=join2(root,entry.name);let{isSymlink,isDirectory}=entry;if(isSymlink){if(!followSymlinks){if(includeSymlinks&&include(path,exts,match,skip)){yield{path,...entry};}continue;}const realPath=await Deno.realPath(path);if(canonicalize){path=realPath;}({isSymlink,isDirectory}=await Deno.lstat(realPath));}if(isSymlink||isDirectory){yield*walk(path,{maxDepth:maxDepth-1,includeFiles,includeDirs,includeSymlinks,followSymlinks,exts,match,skip});}else if(includeFiles&&include(path,exts,match,skip)){yield{path,...entry};}}}catch(err){throw wrapErrorWithPath(err,normalize2(root));}}Deno.build.os==="windows";new Deno.errors.AlreadyExists("dest already exists.");Deno.build.os==="windows";const LF="\n";const CRLF="\r\n";Deno?.build.os==="windows"?CRLF:LF;function parse(text,{allowTrailingComma=true}={}){if(new.target){throw new TypeError("parse is not a constructor");}return new JSONCParser(text,{allowTrailingComma}).parse();}const originalJSONParse=globalThis.JSON.parse;class JSONCParser{#whitespace=new Set(" \r\n");#numberEndToken=new Set([..."[]{}:,/",...this.#whitespace]);#text;#length;#tokenized;#options;constructor(text,options){this.#text=`${text}`;this.#length=this.#text.length;this.#tokenized=this.#tokenize();this.#options=options;}parse(){const token=this.#getNext();const res=this.#parseJsonValue(token);const{done,value}=this.#tokenized.next();if(!done){throw new SyntaxError(buildErrorMessage(value));}return res;}#getNext(){const{done,value}=this.#tokenized.next();if(done){throw new SyntaxError("Unexpected end of JSONC input");}return value;}*#tokenize(){for(let i=0;iisNaN(Number(key)));const byLevel={[LogLevels.NOTSET]:"NOTSET",[LogLevels.DEBUG]:"DEBUG",[LogLevels.INFO]:"INFO",[LogLevels.WARNING]:"WARNING",[LogLevels.ERROR]:"ERROR",[LogLevels.CRITICAL]:"CRITICAL"};function getLevelByName(name){const level=LogLevels[name];if(level!==undefined){return level;}throw new Error(`no log level found for name: ${name}`);}function getLevelName(level){const levelName=byLevel[level];if(levelName){return levelName;}throw new Error(`no level name found for level: ${level}`);}class LogRecord{msg;#args;#datetime;level;levelName;loggerName;constructor(options){this.msg=options.msg;this.#args=[...options.args];this.level=options.level;this.loggerName=options.loggerName;this.#datetime=new Date;this.levelName=getLevelName(options.level);}get args(){return[...this.#args];}get datetime(){return new Date(this.#datetime.getTime());}}class Logger{#level;#handlers;#loggerName;constructor(loggerName,levelName,options={}){this.#loggerName=loggerName;this.#level=getLevelByName(levelName);this.#handlers=options.handlers||[];}get level(){return this.#level;}set level(level){try{this.#level=getLevelByName(getLevelName(level));}catch(_){throw new TypeError(`Invalid log level: ${level}`);}}get levelName(){return getLevelName(this.#level);}set levelName(levelName){this.#level=getLevelByName(levelName);}get loggerName(){return this.#loggerName;}set handlers(hndls){this.#handlers=hndls;}get handlers(){return this.#handlers;}#_log(level,msg,...args){if(this.level>level){return msg instanceof Function?undefined:msg;}let fnResult;let logMessage;if(msg instanceof Function){fnResult=msg();logMessage=this.asString(fnResult);}else{logMessage=this.asString(msg);}const record=new LogRecord({msg:logMessage,args:args,level:level,loggerName:this.loggerName});this.#handlers.forEach(handler=>{handler.handle(record);});return msg instanceof Function?fnResult:msg;}asString(data,isProperty=false){if(typeof data==="string"){if(isProperty)return`"${data}"`;return data;}else if(data===null||typeof data==="number"||typeof data==="bigint"||typeof data==="boolean"||typeof data==="undefined"||typeof data==="symbol"){return String(data);}else if(data instanceof Error){return data.stack;}else if(typeof data==="object"){return`{${Object.entries(data).map(([k,v])=>`"${k}":${this.asString(v,true)}`).join(",")}}`;}return"undefined";}debug(msg,...args){return this.#_log(LogLevels.DEBUG,msg,...args);}info(msg,...args){return this.#_log(LogLevels.INFO,msg,...args);}warning(msg,...args){return this.#_log(LogLevels.WARNING,msg,...args);}error(msg,...args){return this.#_log(LogLevels.ERROR,msg,...args);}critical(msg,...args){return this.#_log(LogLevels.CRITICAL,msg,...args);}}const{Deno:Deno1}=globalThis;const noColor=typeof Deno1?.noColor==="boolean"?Deno1.noColor:false;let enabled=!noColor;function code(open,close){return{open:`\x1b[${open.join(";")}m`,close:`\x1b[${close}m`,regexp:new RegExp(`\\x1b\\[${close}m`,"g")};}function run(str,code){return enabled?`${code.open}${str.replace(code.regexp,code.open)}${code.close}`:str;}function bold(str){return run(str,code([1],22));}function red(str){return run(str,code([31],39));}function yellow(str){return run(str,code([33],39));}function blue(str){return run(str,code([34],39));}new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"),"g");function copy(src,dst,off=0){off=Math.max(0,Math.min(off,dst.byteLength));const dstBytesAvailable=dst.byteLength-off;if(src.byteLength>dstBytesAvailable){src=src.subarray(0,dstBytesAvailable);}dst.set(src,off);return src.byteLength;}class AbstractBufBase{buf;usedBufferBytes=0;err=null;constructor(buf){this.buf=buf;}size(){return this.buf.byteLength;}available(){return this.buf.byteLength-this.usedBufferBytes;}buffered(){return this.usedBufferBytes;}}class BufWriterSync extends AbstractBufBase{#writer;static create(writer,size=4096){return writer instanceof BufWriterSync?writer:new BufWriterSync(writer,size);}constructor(writer,size=4096){super(new Uint8Array(size<=0?4096:size));this.#writer=writer;}reset(w){this.err=null;this.usedBufferBytes=0;this.#writer=w;}flush(){if(this.err!==null)throw this.err;if(this.usedBufferBytes===0)return;try{const p=this.buf.subarray(0,this.usedBufferBytes);let nwritten=0;while(nwrittenthis.available()){if(this.buffered()===0){try{numBytesWritten=this.#writer.writeSync(data);}catch(e){if(e instanceof Error){this.err=e;}throw e;}}else{numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;this.flush();}totalBytesWritten+=numBytesWritten;data=data.subarray(numBytesWritten);}numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;totalBytesWritten+=numBytesWritten;return totalBytesWritten;}}const DEFAULT_FORMATTER="{levelName} {msg}";class BaseHandler{level;levelName;formatter;constructor(levelName,options={}){this.level=getLevelByName(levelName);this.levelName=levelName;this.formatter=options.formatter||DEFAULT_FORMATTER;}handle(logRecord){if(this.level>logRecord.level)return;const msg=this.format(logRecord);this.log(msg);}format(logRecord){if(this.formatter instanceof Function){return this.formatter(logRecord);}return this.formatter.replace(/{([^\s}]+)}/g,(match,p1)=>{const value=logRecord[p1];if(value===undefined){return match;}return String(value);});}log(_msg){}setup(){}destroy(){}}class ConsoleHandler extends BaseHandler{#useColors;constructor(levelName,options={}){super(levelName,options);this.#useColors=options.useColors??true;}format(logRecord){let msg=super.format(logRecord);if(this.#useColors){msg=this.applyColors(msg,logRecord.level);}return msg;}applyColors(msg,level){switch(level){case LogLevels.INFO:msg=blue(msg);break;case LogLevels.WARNING:msg=yellow(msg);break;case LogLevels.ERROR:msg=red(msg);break;case LogLevels.CRITICAL:msg=bold(red(msg));break;default:break;}return msg;}log(msg){console.log(msg);}}class WriterHandler extends BaseHandler{_writer;#encoder=new TextEncoder;}class FileHandler extends WriterHandler{_file;_buf;_filename;_mode;_openOptions;_encoder=new TextEncoder;#unloadCallback=(()=>{this.destroy();}).bind(this);constructor(levelName,options){super(levelName,options);this._filename=options.filename;this._mode=options.mode?options.mode:"a";this._openOptions={createNew:this._mode==="x",create:this._mode!=="x",append:this._mode==="a",truncate:this._mode!=="a",write:true};}setup(){this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);addEventListener("unload",this.#unloadCallback);}handle(logRecord){super.handle(logRecord);if(logRecord.level>LogLevels.ERROR){this.flush();}}log(msg){if(this._encoder.encode(msg).byteLength+1>this._buf.available()){this.flush();}this._buf.writeSync(this._encoder.encode(msg+"\n"));}flush(){if(this._buf?.buffered()>0){this._buf.flush();}}destroy(){this.flush();this._file?.close();this._file=undefined;removeEventListener("unload",this.#unloadCallback);}}class RotatingFileHandler extends FileHandler{#maxBytes;#maxBackupCount;#currentFileSize=0;constructor(levelName,options){super(levelName,options);this.#maxBytes=options.maxBytes;this.#maxBackupCount=options.maxBackupCount;}setup(){if(this.#maxBytes<1){this.destroy();throw new Error("maxBytes cannot be less than 1");}if(this.#maxBackupCount<1){this.destroy();throw new Error("maxBackupCount cannot be less than 1");}super.setup();if(this._mode==="w"){for(let i=1;i<=this.#maxBackupCount;i++){try{Deno.removeSync(this._filename+"."+i);}catch(error){if(!(error instanceof Deno.errors.NotFound)){throw error;}}}}else if(this._mode==="x"){for(let i=1;i<=this.#maxBackupCount;i++){if(existsSync(this._filename+"."+i)){this.destroy();throw new Deno.errors.AlreadyExists("Backup log file "+this._filename+"."+i+" already exists");}}}else{this.#currentFileSize=Deno.statSync(this._filename).size;}}log(msg){const msgByteLength=this._encoder.encode(msg).byteLength+1;if(this.#currentFileSize+msgByteLength>this.#maxBytes){this.rotateLogFiles();this.#currentFileSize=0;}super.log(msg);this.#currentFileSize+=msgByteLength;}rotateLogFiles(){this._buf.flush();this._file.close();for(let i=this.#maxBackupCount-1;i>=0;i--){const source=this._filename+(i===0?"":"."+i);const dest=this._filename+"."+(i+1);if(existsSync(source)){Deno.renameSync(source,dest);}}this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);}}const DEFAULT_LEVEL="INFO";const DEFAULT_CONFIG={handlers:{default:new ConsoleHandler(DEFAULT_LEVEL)},loggers:{default:{level:DEFAULT_LEVEL,handlers:["default"]}}};const state={handlers:new Map,loggers:new Map,config:DEFAULT_CONFIG};const handlers={BaseHandler,ConsoleHandler,WriterHandler,FileHandler,RotatingFileHandler};function getLogger(name){if(!name){const d=state.loggers.get("default");assert(d!==undefined,`"default" logger must be set for getting logger without name`);return d;}const result=state.loggers.get(name);if(!result){const logger=new Logger(name,"NOTSET",{handlers:[]});state.loggers.set(name,logger);return logger;}return result;}function debug(msg,...args){if(msg instanceof Function){return getLogger("default").debug(msg,...args);}return getLogger("default").debug(msg,...args);}function warning(msg,...args){if(msg instanceof Function){return getLogger("default").warning(msg,...args);}return getLogger("default").warning(msg,...args);}function error(msg,...args){if(msg instanceof Function){return getLogger("default").error(msg,...args);}return getLogger("default").error(msg,...args);}function setup(config){state.config={handlers:{...DEFAULT_CONFIG.handlers,...config.handlers},loggers:{...DEFAULT_CONFIG.loggers,...config.loggers}};state.handlers.forEach(handler=>{handler.destroy();});state.handlers.clear();const handlers=state.config.handlers||{};for(const handlerName in handlers){const handler=handlers[handlerName];handler.setup();state.handlers.set(handlerName,handler);}state.loggers.clear();const loggers=state.config.loggers||{};for(const loggerName in loggers){const loggerConfig=loggers[loggerName];const handlerNames=loggerConfig.handlers||[];const handlers=[];handlerNames.forEach(handlerName=>{const handler=state.handlers.get(handlerName);if(handler){handlers.push(handler);}});const levelName=loggerConfig.level||DEFAULT_LEVEL;const logger=new Logger(loggerName,levelName,{handlers:handlers});state.loggers.set(loggerName,logger);}}setup(DEFAULT_CONFIG);function assertArgs1(from,to){assertPath(from);assertPath(to);if(from===to)return"";}function relative(from,to){assertArgs1(from,to);from=resolve(from);to=resolve(to);if(from===to)return"";let fromStart=1;const fromEnd=from.length;for(;fromStartlength){if(isPosixPathSeparator(to.charCodeAt(toStart+i))){return to.slice(toStart+i+1);}else if(i===0){return to.slice(toStart+i);}}else if(fromLen>length){if(isPosixPathSeparator(from.charCodeAt(fromStart+i))){lastCommonSep=i;}else if(i===0){lastCommonSep=0;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(isPosixPathSeparator(fromCode))lastCommonSep=i;}let out="";for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||isPosixPathSeparator(from.charCodeAt(i))){if(out.length===0)out+="..";else out+="/..";}}if(out.length>0)return out+to.slice(toStart+lastCommonSep);else{toStart+=lastCommonSep;if(isPosixPathSeparator(to.charCodeAt(toStart)))++toStart;return to.slice(toStart);}}function relative1(from,to){assertArgs1(from,to);const fromOrig=resolve1(from);const toOrig=resolve1(to);if(fromOrig===toOrig)return"";from=fromOrig.toLowerCase();to=toOrig.toLowerCase();if(from===to)return"";let fromStart=0;let fromEnd=from.length;for(;fromStartfromStart;--fromEnd){if(from.charCodeAt(fromEnd-1)!==92)break;}const fromLen=fromEnd-fromStart;let toStart=0;let toEnd=to.length;for(;toStarttoStart;--toEnd){if(to.charCodeAt(toEnd-1)!==92)break;}const toLen=toEnd-toStart;const length=fromLenlength){if(to.charCodeAt(toStart+i)===92){return toOrig.slice(toStart+i+1);}else if(i===2){return toOrig.slice(toStart+i);}}if(fromLen>length){if(from.charCodeAt(fromStart+i)===92){lastCommonSep=i;}else if(i===2){lastCommonSep=3;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(fromCode===92)lastCommonSep=i;}if(i!==length&&lastCommonSep===-1){return toOrig;}let out="";if(lastCommonSep===-1)lastCommonSep=0;for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||from.charCodeAt(i)===92){if(out.length===0)out+="..";else out+="\\..";}}if(out.length>0){return out+toOrig.slice(toStart+lastCommonSep,toEnd);}else{toStart+=lastCommonSep;if(toOrig.charCodeAt(toStart)===92)++toStart;return toOrig.slice(toStart,toEnd);}}function relative2(from,to){return isWindows?relative1(from,to):relative(from,to);}var m=Object.create;var E=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),D=(t,e)=>{for(var s in e)E(t,s,{get:e[s],enumerable:!0});},a=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!b.call(t,n)&&n!==s&&E(t,n,{get:()=>e[n],enumerable:!(r=T(e,n))||r.enumerable});return t;},_=(t,e,s)=>(a(t,e,"default"),s&&a(s,e,"default")),$=(t,e,s)=>(s=t!=null?m(X(t)):{},a(e||!t||!t.__esModule?E(s,"default",{value:t,enumerable:!0}):s,t));var A=w((ct,v)=>{function C(t){return Array.isArray(t)?t:[t];}var N="",P=" ",h="\\",H=/^\s+$/,F=/(?:[^\\]|^)\\$/,k=/^\\!/,z=/^\\#/,B=/\r?\n/g,K=/^\.*\/|^\.+$/,d="/",x="node-ignore";typeof Symbol<"u"&&(x=Symbol.for("node-ignore"));var L=x,V=(t,e,s)=>Object.defineProperty(t,e,{value:s}),j=/([0-z])-([0-z])/g,G=()=>!1,M=t=>t.replace(j,(e,s,r)=>s.charCodeAt(0)<=r.charCodeAt(0)?e:N),Y=t=>{let{length:e}=t;return t.slice(0,e-e%2);},W=[[/\\?\s+$/,t=>t.indexOf("\\")===0?P:N],[/\\\s/g,()=>P],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)";}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,s)=>e+6{let r=s.replace(/\\\*/g,"[^\\/]*");return e+r;}],[/\\\\\\(?=[$.|*+(){^])/g,()=>h],[/\\\\/g,()=>h],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,s,r,n)=>e===h?`\\[${s}${Y(r)}${n}`:n==="]"&&r.length%2===0?`[${M(s)}${r}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],S=Object.create(null),p=(t,e)=>{let s=S[t];return s||(s=W.reduce((r,n)=>r.replace(n[0],n[1].bind(t)),t),S[t]=s),e?new RegExp(s,"i"):new RegExp(s);},R=t=>typeof t=="string",q=t=>t&&R(t)&&!H.test(t)&&!F.test(t)&&t.indexOf("#")!==0,J=t=>t.split(B),f=class{constructor(e,s,r,n){this.origin=e,this.pattern=s,this.negative=r,this.regex=n;}},Q=(t,e)=>{let s=t,r=!1;t.indexOf("!")===0&&(r=!0,t=t.substr(1)),t=t.replace(k,"!").replace(z,"#");let n=p(t,e);return new f(s,t,r,n);},U=(t,e)=>{throw new e(t);},i=(t,e,s)=>R(t)?t?i.isNotRelative(t)?s(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:s("path must not be empty",TypeError):s(`path must be a string, but got \`${e}\``,TypeError),O=t=>K.test(t);i.isNotRelative=O;i.convert=t=>t;var g=class{constructor({ignorecase:e=!0,ignoreCase:s=e,allowRelativePaths:r=!1}={}){V(this,L,!0),this._rules=[],this._ignoreCase=s,this._allowRelativePaths=r,this._initCache();}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null);}_addPattern(e){if(e&&e[L]){this._rules=this._rules.concat(e._rules),this._added=!0;return;}if(q(e)){let s=Q(e,this._ignoreCase);this._added=!0,this._rules.push(s);}}add(e){return this._added=!1,C(R(e)?J(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this;}addPattern(e){return this.add(e);}_testOne(e,s){let r=!1,n=!1;return this._rules.forEach(o=>{let{negative:u}=o;if(n===u&&r!==n||u&&!r&&!n&&!s)return;o.regex.test(e)&&(r=!u,n=u);}),{ignored:r,unignored:n};}_test(e,s,r,n){let o=e&&i.convert(e);return i(o,e,this._allowRelativePaths?G:U),this._t(o,s,r,n);}_t(e,s,r,n){if(e in s)return s[e];if(n||(n=e.split(d)),n.pop(),!n.length)return s[e]=this._testOne(e,r);let o=this._t(n.join(d)+d,s,r,n);return s[e]=o.ignored?o:this._testOne(e,r);}ignores(e){return this._test(e,this._ignoreCache,!1).ignored;}createFilter(){return e=>!this.ignores(e);}filter(e){return C(e).filter(this.createFilter());}test(e){return this._test(e,this._testCache,!0);}},l=t=>new g(t),Z=t=>i(t&&i.convert(t),t,G);l.isPathValid=Z;l.default=l;v.exports=l;var tt=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");i.convert=tt;var et=/^[a-z]:\//i;i.isNotRelative=t=>et.test(t)||O(t);});var c={};D(c,{default:()=>nt});var st=$(A());_(c,$(A()));var{default:I,...rt}=st,nt=I!==void 0?I:rt;const importMeta={url:"file:///home/runner/work/setup-deno/setup-deno/cache.ts",main:import.meta.main};if(importMeta.main){const args=parseArgs(Deno.args,{boolean:["help","dry-run","verbose","lock-write"],negatable:["lock-write"],string:["config"],default:{"lock-write":true},alias:{help:"h","dry-run":"n"},"--":true});const denoDir=Deno.env.get("DENO_DIR");const logLevel=["1","true"].includes(Deno.env.get("CI")??"")?"DEBUG":args.verbose?"DEBUG":"INFO";setup({handlers:{console:new handlers.ConsoleHandler(logLevel,{formatter:logRecord=>Deno.noColor?[logRecord.levelName,logRecord.msg].join(" "):logRecord.msg})},loggers:{default:{handlers:["console"],"level":logLevel}}});if(args.help){console.log("Usage: cache [-n | --dry-run] [-v | --verbose] [--] [DENO_ARGS...]");Deno.exit(0);}if(args["dry-run"])warning("dry-run mode enabled");if(args.config&&!await exists(args.config)){error(`config file ${args.config} not found`);Deno.exit(1);}const hash=await Deno.readFile("./deno.lock").then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>encodeHex(new Uint8Array(data))).catch(_=>"");debug(`GitHub actions deno.lock hash: ${hash}`);const cfgs=args.config?[args.config]:["deno.json","deno.jsonc"];const denoCfg=await Promise.all(cfgs.map(path=>Deno.readTextFile(path).catch(_=>undefined))).then(v=>parse(v.filter(Boolean)[0]??"{}"));const patterns=[...[denoCfg?.exclude??[]].flat(),...[denoCfg?.cache?.exclude??[]].flat(),...[denoCfg?.cache?.include??[]].flatMap(p=>`!${p}`)];debug(`patterns:`,patterns);patterns.forEach(p=>debug(`- ${p}`));const ig=nt().add(patterns);const walkIterator=walk(".",{exts:["js",".jsx",".ts",".tsx"],includeDirs:false});const paths=[];for await(const entry of walkIterator){const relativePath=relative2(".",entry.path);if(denoDir&&entry.path.startsWith(denoDir))continue;if(ig.ignores(relativePath)){debug(`ignored ${relativePath}`);continue;}debug(`caching ${relativePath}`);paths.push(relativePath);}const cmd=new Deno.Command(Deno.execPath(),{args:["cache",args["lock-write"]&&"--lock-write",args.config&&`--config=${args.config}`,...args["--"],...paths].filter(Boolean),stdout:"inherit",stderr:"inherit"});const code=!args["dry-run"]?(await cmd.output()).code:0;if(code===0)debug(`finished caching ${paths.length} files`);} \ No newline at end of file From 4f3ce56e9e0e8fc0a373c772321a07d28014012d Mon Sep 17 00:00:00 2001 From: winston Date: Tue, 26 Dec 2023 23:12:34 +0100 Subject: [PATCH 14/18] refactor: finally happy? --- cache.ts | 53 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/cache.ts b/cache.ts index 1e7069d..eab2678 100755 --- a/cache.ts +++ b/cache.ts @@ -6,7 +6,6 @@ import * as JSONC from "https://deno.land/std@0.210.0/jsonc/parse.ts"; import * as log from "https://deno.land/std@0.210.0/log/mod.ts"; import { relative } from "https://deno.land/std@0.210.0/path/relative.ts"; import ignore from "https://esm.sh/gh/nekowinston/deno-ignore@v5.3.0/index.js?pin=v135"; - type DenoConfig = { cache: { include?: string[]; exclude?: string[] }; exclude?: string[]; @@ -15,12 +14,19 @@ type DenoConfig = { if (import.meta.main) { const args = parseArgs(Deno.args, { - boolean: ["help", "dry-run", "verbose", "lock-write"], + boolean: ["dry-run", "verbose", "lock-write"], negatable: ["lock-write"], string: ["config"], default: { "lock-write": true }, - alias: { help: "h", "dry-run": "n" }, + alias: { "dry-run": "n", verbose: "v" }, "--": true, + unknown: (arg) => { + console.log(`Unknown argument: ${arg}`); + console.log( + "Usage: cache [-n | --dry-run] [-v | --verbose] [--] [DENO_ARGS...]", + ); + Deno.exit(0); + }, }); const denoDir = Deno.env.get("DENO_DIR"); @@ -32,18 +38,12 @@ if (import.meta.main) { console: new log.handlers.ConsoleHandler(logLevel, { formatter: (logRecord) => Deno.noColor - ? [logRecord.levelName, logRecord.msg].join(" ") + ? logRecord.levelName + " " + logRecord.msg : logRecord.msg, }), }, loggers: { default: { handlers: ["console"], "level": logLevel } }, }); - if (args.help) { - console.log( - "Usage: cache [-n | --dry-run] [-v | --verbose] [--] [DENO_ARGS...]", - ); - Deno.exit(0); - } if (args["dry-run"]) log.warning("dry-run mode enabled"); if (args.config && !await exists(args.config)) { @@ -98,18 +98,27 @@ if (import.meta.main) { paths.push(relativePath); } - const cmd = new Deno.Command(Deno.execPath(), { - args: [ - "cache", - args["lock-write"] && "--lock-write", - args.config && `--config=${args.config}`, - ...args["--"], // everything after `--` is passed to Deno - ...paths, - ].filter(Boolean) as string[], - stdout: "inherit", - stderr: "inherit", - }); + const denoArgs = [ + "cache", + args["lock-write"] && "--lock-write", + args.config && `--config=${args.config}`, + ...args["--"], // everything after `--` is passed to Deno + ...paths, + ].filter(Boolean) as string[]; + const cmd = new Deno.Command(Deno.execPath(), { args: denoArgs }); + const cmdString = Deno.execPath() + " " + denoArgs.join(" "); + + if (args["dry-run"]) { + log.info(`would run: ${cmdString}`); + Deno.exit(0); + } + log.debug(`running: ${cmdString}`); + const { stderr, code } = await cmd.output(); + + // deno cache outputs to stderr + for (const line of new TextDecoder().decode(stderr).split("\n")) { + if (line.length > 0) log.info("deno> " + line); + } - const code = !args["dry-run"] ? (await cmd.output()).code : 0; if (code === 0) log.debug(`finished caching ${paths.length} files`); } From b5eabb5917621e25487a40102a425263ac6ae5be Mon Sep 17 00:00:00 2001 From: winston Date: Tue, 26 Dec 2023 23:12:55 +0100 Subject: [PATCH 15/18] chore: bundle --- dist/cache.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/cache.js b/dist/cache.js index 1e7f7cd..6da64f0 100755 --- a/dist/cache.js +++ b/dist/cache.js @@ -1,2 +1,2 @@ #!/usr/bin/env -S deno run --no-lock --allow-read --allow-run=deno --allow-env=CI,DENO_DIR -class AssertionError extends Error{constructor(message){super(message);this.name="AssertionError";}}function assert(expr,msg=""){if(!expr){throw new AssertionError(msg);}}const{hasOwn}=Object;function get(obj,key){if(hasOwn(obj,key)){return obj[key];}}function getForce(obj,key){const v=get(obj,key);assert(v!==undefined);return v;}function isNumber(x){if(typeof x==="number")return true;if(/^0x[0-9a-f]+$/i.test(String(x)))return true;return/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(String(x));}function hasKey(obj,keys){let o=obj;keys.slice(0,-1).forEach(key=>{o=get(o,key)??{};});const key=keys[keys.length-1];return hasOwn(o,key);}function parseArgs(args,{"--":doubleDash=false,alias={},boolean:__boolean=false,default:defaults={},stopEarly=false,string=[],collect=[],negatable=[],unknown=i=>i}={}){const aliases={};const flags={bools:{},strings:{},unknownFn:unknown,allBools:false,collect:{},negatable:{}};if(alias!==undefined){for(const key in alias){const val=getForce(alias,key);if(typeof val==="string"){aliases[key]=[val];}else{aliases[key]=val;}for(const alias of getForce(aliases,key)){aliases[alias]=[key].concat(aliases[key].filter(y=>alias!==y));}}}if(__boolean!==undefined){if(typeof __boolean==="boolean"){flags.allBools=!!__boolean;}else{const booleanArgs=typeof __boolean==="string"?[__boolean]:__boolean;for(const key of booleanArgs.filter(Boolean)){flags.bools[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.bools[al]=true;}}}}}if(string!==undefined){const stringArgs=typeof string==="string"?[string]:string;for(const key of stringArgs.filter(Boolean)){flags.strings[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.strings[al]=true;}}}}if(collect!==undefined){const collectArgs=typeof collect==="string"?[collect]:collect;for(const key of collectArgs.filter(Boolean)){flags.collect[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.collect[al]=true;}}}}if(negatable!==undefined){const negatableArgs=typeof negatable==="string"?[negatable]:negatable;for(const key of negatableArgs.filter(Boolean)){flags.negatable[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.negatable[al]=true;}}}}const argv={_:[]};function argDefined(key,arg){return flags.allBools&&/^--[^=]+$/.test(arg)||get(flags.bools,key)||!!get(flags.strings,key)||!!get(aliases,key);}function setKey(obj,name,value,collect=true){let o=obj;const keys=name.split(".");keys.slice(0,-1).forEach(function(key){if(get(o,key)===undefined){o[key]={};}o=get(o,key);});const key=keys[keys.length-1];const collectable=collect&&!!get(flags.collect,name);if(!collectable){o[key]=value;}else if(get(o,key)===undefined){o[key]=[value];}else if(Array.isArray(get(o,key))){o[key].push(value);}else{o[key]=[get(o,key),value];}}function setArg(key,val,arg=undefined,collect){if(arg&&flags.unknownFn&&!argDefined(key,arg)){if(flags.unknownFn(arg,key,val)===false)return;}const value=!get(flags.strings,key)&&isNumber(val)?Number(val):val;setKey(argv,key,value,collect);const alias=get(aliases,key);if(alias){for(const x of alias){setKey(argv,x,value,collect);}}}function aliasIsBoolean(key){return getForce(aliases,key).some(x=>typeof get(flags.bools,x)==="boolean");}let notFlags=[];if(args.includes("--")){notFlags=args.slice(args.indexOf("--")+1);args=args.slice(0,args.indexOf("--"));}for(let i=0;i>4];dst[i*2+1]=hexTable[v&15];}return textDecoder.decode(dst);}const osType=(()=>{const{Deno:Deno1}=globalThis;if(typeof Deno1?.build?.os==="string"){return Deno1.build.os;}const{navigator}=globalThis;if(navigator?.appVersion?.includes?.("Win")){return"windows";}return"linux";})();const isWindows=osType==="windows";function assertPath(path){if(typeof path!=="string"){throw new TypeError(`Path must be a string. Received ${JSON.stringify(path)}`);}}function assertArg(path){assertPath(path);if(path.length===0)return".";}const CHAR_FORWARD_SLASH=47;function normalizeString(path,allowAboveRoot,separator,isPathSeparator){let res="";let lastSegmentLength=0;let lastSlash=-1;let dots=0;let code;for(let i=0,len=path.length;i<=len;++i){if(i2){const lastSlashIndex=res.lastIndexOf(separator);if(lastSlashIndex===-1){res="";lastSegmentLength=0;}else{res=res.slice(0,lastSlashIndex);lastSegmentLength=res.length-1-res.lastIndexOf(separator);}lastSlash=i;dots=0;continue;}else if(res.length===2||res.length===1){res="";lastSegmentLength=0;lastSlash=i;dots=0;continue;}}if(allowAboveRoot){if(res.length>0)res+=`${separator}..`;else res="..";lastSegmentLength=2;}}else{if(res.length>0)res+=separator+path.slice(lastSlash+1,i);else res=path.slice(lastSlash+1,i);lastSegmentLength=i-lastSlash-1;}lastSlash=i;dots=0;}else if(code===46&&dots!==-1){++dots;}else{dots=-1;}}return res;}function isPosixPathSeparator(code){return code===47;}function normalize(path){assertArg(path);const isAbsolute=isPosixPathSeparator(path.charCodeAt(0));const trailingSeparator=isPosixPathSeparator(path.charCodeAt(path.length-1));path=normalizeString(path,!isAbsolute,"/",isPosixPathSeparator);if(path.length===0&&!isAbsolute)path=".";if(path.length>0&&trailingSeparator)path+="/";if(isAbsolute)return`/${path}`;return path;}function join(...paths){if(paths.length===0)return".";let joined;for(let i=0,len=paths.length;i0){if(!joined)joined=path;else joined+=`/${path}`;}}if(!joined)return".";return normalize(joined);}function isPathSeparator(code){return code===47||code===92;}function isWindowsDeviceRoot(code){return code>=97&&code<=122||code>=65&&code<=90;}function normalize1(path){assertArg(path);const len=path.length;let rootEnd=0;let device;let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){return"\\";}let tail;if(rootEnd0&&isPathSeparator(path.charCodeAt(len-1))){tail+="\\";}if(device===undefined){if(isAbsolute){if(tail.length>0)return`\\${tail}`;else return"\\";}else if(tail.length>0){return tail;}else{return"";}}else if(isAbsolute){if(tail.length>0)return`${device}\\${tail}`;else return`${device}\\`;}else if(tail.length>0){return device+tail;}else{return device;}}function join1(...paths){if(paths.length===0)return".";let joined;let firstPart=null;for(let i=0;i0){if(joined===undefined)joined=firstPart=path;else joined+=`\\${path}`;}}if(joined===undefined)return".";let needsReplace=true;let slashCount=0;assert(firstPart!==null);if(isPathSeparator(firstPart.charCodeAt(0))){++slashCount;const firstLen=firstPart.length;if(firstLen>1){if(isPathSeparator(firstPart.charCodeAt(1))){++slashCount;if(firstLen>2){if(isPathSeparator(firstPart.charCodeAt(2)))++slashCount;else{needsReplace=false;}}}}}if(needsReplace){for(;slashCount=2)joined=`\\${joined.slice(slashCount)}`;}return normalize1(joined);}function join2(...paths){return isWindows?join1(...paths):join(...paths);}function assertArg1(url){url=url instanceof URL?url:new URL(url);if(url.protocol!=="file:"){throw new TypeError("Must be a file URL.");}return url;}function fromFileUrl(url){url=assertArg1(url);return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"));}function fromFileUrl1(url){url=assertArg1(url);let path=decodeURIComponent(url.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");if(url.hostname!==""){path=`\\\\${url.hostname}${path}`;}return path;}function fromFileUrl2(url){return isWindows?fromFileUrl1(url):fromFileUrl(url);}function toPathString(pathUrl){return pathUrl instanceof URL?fromFileUrl2(pathUrl):pathUrl;}function stripTrailingSeparators(segment,isSep){if(segment.length<=1){return segment;}let end=segment.length;for(let i=segment.length-1;i>0;i--){if(isSep(segment.charCodeAt(i))){end=i;}else{break;}}return segment.slice(0,end);}function resolve(...pathSegments){let resolvedPath="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1&&!resolvedAbsolute;i--){let path;if(i>=0)path=pathSegments[i];else{const{Deno:Deno1}=globalThis;if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();}assertPath(path);if(path.length===0){continue;}resolvedPath=`${path}/${resolvedPath}`;resolvedAbsolute=isPosixPathSeparator(path.charCodeAt(0));}resolvedPath=normalizeString(resolvedPath,!resolvedAbsolute,"/",isPosixPathSeparator);if(resolvedAbsolute){if(resolvedPath.length>0)return`/${resolvedPath}`;else return"/";}else if(resolvedPath.length>0)return resolvedPath;else return".";}function resolve1(...pathSegments){let resolvedDevice="";let resolvedTail="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1;i--){let path;const{Deno:Deno1}=globalThis;if(i>=0){path=pathSegments[i];}else if(!resolvedDevice){if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a drive-letter-less path without a CWD.");}path=Deno1.cwd();}else{if(typeof Deno1?.env?.get!=="function"||typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();if(path===undefined||path.slice(0,3).toLowerCase()!==`${resolvedDevice.toLowerCase()}\\`){path=`${resolvedDevice}\\`;}}assertPath(path);const len=path.length;if(len===0)continue;let rootEnd=0;let device="";let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){rootEnd=1;isAbsolute=true;}if(device.length>0&&resolvedDevice.length>0&&device.toLowerCase()!==resolvedDevice.toLowerCase()){continue;}if(resolvedDevice.length===0&&device.length>0){resolvedDevice=device;}if(!resolvedAbsolute){resolvedTail=`${path.slice(rootEnd)}\\${resolvedTail}`;resolvedAbsolute=isAbsolute;}if(resolvedAbsolute&&resolvedDevice.length>0)break;}resolvedTail=normalizeString(resolvedTail,!resolvedAbsolute,"\\",isPathSeparator);return resolvedDevice+(resolvedAbsolute?"\\":"")+resolvedTail||".";}Deno.build.os==="windows";async function exists(path,options){try{const stat=await Deno.stat(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if((await Deno.permissions.query({name:"read",path})).state==="granted"){return!options?.isReadable;}}throw error;}}function existsSync(path,options){try{const stat=Deno.statSync(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if(Deno.permissions.querySync({name:"read",path}).state==="granted"){return!options?.isReadable;}}throw error;}}function normalize2(path){return isWindows?normalize1(path):normalize(path);}function stripSuffix(name,suffix){if(suffix.length>=name.length){return name;}const lenDiff=name.length-suffix.length;for(let i=suffix.length-1;i>=0;--i){if(name.charCodeAt(lenDiff+i)!==suffix.charCodeAt(i)){return name;}}return name.slice(0,-suffix.length);}function lastPathSegment(path,isSep,start=0){let matchedNonSeparator=false;let end=path.length;for(let i=path.length-1;i>=start;--i){if(isSep(path.charCodeAt(i))){if(matchedNonSeparator){start=i+1;break;}}else if(!matchedNonSeparator){matchedNonSeparator=true;end=i+1;}}return path.slice(start,end);}function assertArgs(path,suffix){assertPath(path);if(path.length===0)return path;if(typeof suffix!=="string"){throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);}}function basename(path,suffix=""){assertArgs(path,suffix);const lastSegment=lastPathSegment(path,isPosixPathSeparator);const strippedSegment=stripTrailingSeparators(lastSegment,isPosixPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename1(path,suffix=""){assertArgs(path,suffix);let start=0;if(path.length>=2){const drive=path.charCodeAt(0);if(isWindowsDeviceRoot(drive)){if(path.charCodeAt(1)===58)start=2;}}const lastSegment=lastPathSegment(path,isPathSeparator,start);const strippedSegment=stripTrailingSeparators(lastSegment,isPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename2(path,suffix=""){return isWindows?basename1(path,suffix):basename(path,suffix);}async function createWalkEntry(path){path=toPathString(path);path=normalize2(path);const name=basename2(path);const info=await Deno.stat(path);return{path,name,isFile:info.isFile,isDirectory:info.isDirectory,isSymlink:info.isSymlink};}class WalkError extends Error{root;constructor(cause,root){super(`${cause instanceof Error?cause.message:cause} for path "${root}"`);this.cause=cause;this.name="WalkError";this.root=root;}}function include(path,exts,match,skip){if(exts&&!exts.some(ext=>path.endsWith(ext))){return false;}if(match&&!match.some(pattern=>!!path.match(pattern))){return false;}if(skip&&skip.some(pattern=>!!path.match(pattern))){return false;}return true;}function wrapErrorWithPath(err,root){if(err instanceof WalkError)return err;return new WalkError(err,root);}async function*walk(root,{maxDepth=Infinity,includeFiles=true,includeDirs=true,includeSymlinks=true,followSymlinks=false,canonicalize=true,exts=undefined,match=undefined,skip=undefined}={}){if(maxDepth<0){return;}root=toPathString(root);if(includeDirs&&include(root,exts,match,skip)){yield await createWalkEntry(root);}if(maxDepth<1||!include(root,undefined,undefined,skip)){return;}try{for await(const entry of Deno.readDir(root)){let path=join2(root,entry.name);let{isSymlink,isDirectory}=entry;if(isSymlink){if(!followSymlinks){if(includeSymlinks&&include(path,exts,match,skip)){yield{path,...entry};}continue;}const realPath=await Deno.realPath(path);if(canonicalize){path=realPath;}({isSymlink,isDirectory}=await Deno.lstat(realPath));}if(isSymlink||isDirectory){yield*walk(path,{maxDepth:maxDepth-1,includeFiles,includeDirs,includeSymlinks,followSymlinks,exts,match,skip});}else if(includeFiles&&include(path,exts,match,skip)){yield{path,...entry};}}}catch(err){throw wrapErrorWithPath(err,normalize2(root));}}Deno.build.os==="windows";new Deno.errors.AlreadyExists("dest already exists.");Deno.build.os==="windows";const LF="\n";const CRLF="\r\n";Deno?.build.os==="windows"?CRLF:LF;function parse(text,{allowTrailingComma=true}={}){if(new.target){throw new TypeError("parse is not a constructor");}return new JSONCParser(text,{allowTrailingComma}).parse();}const originalJSONParse=globalThis.JSON.parse;class JSONCParser{#whitespace=new Set(" \r\n");#numberEndToken=new Set([..."[]{}:,/",...this.#whitespace]);#text;#length;#tokenized;#options;constructor(text,options){this.#text=`${text}`;this.#length=this.#text.length;this.#tokenized=this.#tokenize();this.#options=options;}parse(){const token=this.#getNext();const res=this.#parseJsonValue(token);const{done,value}=this.#tokenized.next();if(!done){throw new SyntaxError(buildErrorMessage(value));}return res;}#getNext(){const{done,value}=this.#tokenized.next();if(done){throw new SyntaxError("Unexpected end of JSONC input");}return value;}*#tokenize(){for(let i=0;iisNaN(Number(key)));const byLevel={[LogLevels.NOTSET]:"NOTSET",[LogLevels.DEBUG]:"DEBUG",[LogLevels.INFO]:"INFO",[LogLevels.WARNING]:"WARNING",[LogLevels.ERROR]:"ERROR",[LogLevels.CRITICAL]:"CRITICAL"};function getLevelByName(name){const level=LogLevels[name];if(level!==undefined){return level;}throw new Error(`no log level found for name: ${name}`);}function getLevelName(level){const levelName=byLevel[level];if(levelName){return levelName;}throw new Error(`no level name found for level: ${level}`);}class LogRecord{msg;#args;#datetime;level;levelName;loggerName;constructor(options){this.msg=options.msg;this.#args=[...options.args];this.level=options.level;this.loggerName=options.loggerName;this.#datetime=new Date;this.levelName=getLevelName(options.level);}get args(){return[...this.#args];}get datetime(){return new Date(this.#datetime.getTime());}}class Logger{#level;#handlers;#loggerName;constructor(loggerName,levelName,options={}){this.#loggerName=loggerName;this.#level=getLevelByName(levelName);this.#handlers=options.handlers||[];}get level(){return this.#level;}set level(level){try{this.#level=getLevelByName(getLevelName(level));}catch(_){throw new TypeError(`Invalid log level: ${level}`);}}get levelName(){return getLevelName(this.#level);}set levelName(levelName){this.#level=getLevelByName(levelName);}get loggerName(){return this.#loggerName;}set handlers(hndls){this.#handlers=hndls;}get handlers(){return this.#handlers;}#_log(level,msg,...args){if(this.level>level){return msg instanceof Function?undefined:msg;}let fnResult;let logMessage;if(msg instanceof Function){fnResult=msg();logMessage=this.asString(fnResult);}else{logMessage=this.asString(msg);}const record=new LogRecord({msg:logMessage,args:args,level:level,loggerName:this.loggerName});this.#handlers.forEach(handler=>{handler.handle(record);});return msg instanceof Function?fnResult:msg;}asString(data,isProperty=false){if(typeof data==="string"){if(isProperty)return`"${data}"`;return data;}else if(data===null||typeof data==="number"||typeof data==="bigint"||typeof data==="boolean"||typeof data==="undefined"||typeof data==="symbol"){return String(data);}else if(data instanceof Error){return data.stack;}else if(typeof data==="object"){return`{${Object.entries(data).map(([k,v])=>`"${k}":${this.asString(v,true)}`).join(",")}}`;}return"undefined";}debug(msg,...args){return this.#_log(LogLevels.DEBUG,msg,...args);}info(msg,...args){return this.#_log(LogLevels.INFO,msg,...args);}warning(msg,...args){return this.#_log(LogLevels.WARNING,msg,...args);}error(msg,...args){return this.#_log(LogLevels.ERROR,msg,...args);}critical(msg,...args){return this.#_log(LogLevels.CRITICAL,msg,...args);}}const{Deno:Deno1}=globalThis;const noColor=typeof Deno1?.noColor==="boolean"?Deno1.noColor:false;let enabled=!noColor;function code(open,close){return{open:`\x1b[${open.join(";")}m`,close:`\x1b[${close}m`,regexp:new RegExp(`\\x1b\\[${close}m`,"g")};}function run(str,code){return enabled?`${code.open}${str.replace(code.regexp,code.open)}${code.close}`:str;}function bold(str){return run(str,code([1],22));}function red(str){return run(str,code([31],39));}function yellow(str){return run(str,code([33],39));}function blue(str){return run(str,code([34],39));}new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"),"g");function copy(src,dst,off=0){off=Math.max(0,Math.min(off,dst.byteLength));const dstBytesAvailable=dst.byteLength-off;if(src.byteLength>dstBytesAvailable){src=src.subarray(0,dstBytesAvailable);}dst.set(src,off);return src.byteLength;}class AbstractBufBase{buf;usedBufferBytes=0;err=null;constructor(buf){this.buf=buf;}size(){return this.buf.byteLength;}available(){return this.buf.byteLength-this.usedBufferBytes;}buffered(){return this.usedBufferBytes;}}class BufWriterSync extends AbstractBufBase{#writer;static create(writer,size=4096){return writer instanceof BufWriterSync?writer:new BufWriterSync(writer,size);}constructor(writer,size=4096){super(new Uint8Array(size<=0?4096:size));this.#writer=writer;}reset(w){this.err=null;this.usedBufferBytes=0;this.#writer=w;}flush(){if(this.err!==null)throw this.err;if(this.usedBufferBytes===0)return;try{const p=this.buf.subarray(0,this.usedBufferBytes);let nwritten=0;while(nwrittenthis.available()){if(this.buffered()===0){try{numBytesWritten=this.#writer.writeSync(data);}catch(e){if(e instanceof Error){this.err=e;}throw e;}}else{numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;this.flush();}totalBytesWritten+=numBytesWritten;data=data.subarray(numBytesWritten);}numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;totalBytesWritten+=numBytesWritten;return totalBytesWritten;}}const DEFAULT_FORMATTER="{levelName} {msg}";class BaseHandler{level;levelName;formatter;constructor(levelName,options={}){this.level=getLevelByName(levelName);this.levelName=levelName;this.formatter=options.formatter||DEFAULT_FORMATTER;}handle(logRecord){if(this.level>logRecord.level)return;const msg=this.format(logRecord);this.log(msg);}format(logRecord){if(this.formatter instanceof Function){return this.formatter(logRecord);}return this.formatter.replace(/{([^\s}]+)}/g,(match,p1)=>{const value=logRecord[p1];if(value===undefined){return match;}return String(value);});}log(_msg){}setup(){}destroy(){}}class ConsoleHandler extends BaseHandler{#useColors;constructor(levelName,options={}){super(levelName,options);this.#useColors=options.useColors??true;}format(logRecord){let msg=super.format(logRecord);if(this.#useColors){msg=this.applyColors(msg,logRecord.level);}return msg;}applyColors(msg,level){switch(level){case LogLevels.INFO:msg=blue(msg);break;case LogLevels.WARNING:msg=yellow(msg);break;case LogLevels.ERROR:msg=red(msg);break;case LogLevels.CRITICAL:msg=bold(red(msg));break;default:break;}return msg;}log(msg){console.log(msg);}}class WriterHandler extends BaseHandler{_writer;#encoder=new TextEncoder;}class FileHandler extends WriterHandler{_file;_buf;_filename;_mode;_openOptions;_encoder=new TextEncoder;#unloadCallback=(()=>{this.destroy();}).bind(this);constructor(levelName,options){super(levelName,options);this._filename=options.filename;this._mode=options.mode?options.mode:"a";this._openOptions={createNew:this._mode==="x",create:this._mode!=="x",append:this._mode==="a",truncate:this._mode!=="a",write:true};}setup(){this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);addEventListener("unload",this.#unloadCallback);}handle(logRecord){super.handle(logRecord);if(logRecord.level>LogLevels.ERROR){this.flush();}}log(msg){if(this._encoder.encode(msg).byteLength+1>this._buf.available()){this.flush();}this._buf.writeSync(this._encoder.encode(msg+"\n"));}flush(){if(this._buf?.buffered()>0){this._buf.flush();}}destroy(){this.flush();this._file?.close();this._file=undefined;removeEventListener("unload",this.#unloadCallback);}}class RotatingFileHandler extends FileHandler{#maxBytes;#maxBackupCount;#currentFileSize=0;constructor(levelName,options){super(levelName,options);this.#maxBytes=options.maxBytes;this.#maxBackupCount=options.maxBackupCount;}setup(){if(this.#maxBytes<1){this.destroy();throw new Error("maxBytes cannot be less than 1");}if(this.#maxBackupCount<1){this.destroy();throw new Error("maxBackupCount cannot be less than 1");}super.setup();if(this._mode==="w"){for(let i=1;i<=this.#maxBackupCount;i++){try{Deno.removeSync(this._filename+"."+i);}catch(error){if(!(error instanceof Deno.errors.NotFound)){throw error;}}}}else if(this._mode==="x"){for(let i=1;i<=this.#maxBackupCount;i++){if(existsSync(this._filename+"."+i)){this.destroy();throw new Deno.errors.AlreadyExists("Backup log file "+this._filename+"."+i+" already exists");}}}else{this.#currentFileSize=Deno.statSync(this._filename).size;}}log(msg){const msgByteLength=this._encoder.encode(msg).byteLength+1;if(this.#currentFileSize+msgByteLength>this.#maxBytes){this.rotateLogFiles();this.#currentFileSize=0;}super.log(msg);this.#currentFileSize+=msgByteLength;}rotateLogFiles(){this._buf.flush();this._file.close();for(let i=this.#maxBackupCount-1;i>=0;i--){const source=this._filename+(i===0?"":"."+i);const dest=this._filename+"."+(i+1);if(existsSync(source)){Deno.renameSync(source,dest);}}this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);}}const DEFAULT_LEVEL="INFO";const DEFAULT_CONFIG={handlers:{default:new ConsoleHandler(DEFAULT_LEVEL)},loggers:{default:{level:DEFAULT_LEVEL,handlers:["default"]}}};const state={handlers:new Map,loggers:new Map,config:DEFAULT_CONFIG};const handlers={BaseHandler,ConsoleHandler,WriterHandler,FileHandler,RotatingFileHandler};function getLogger(name){if(!name){const d=state.loggers.get("default");assert(d!==undefined,`"default" logger must be set for getting logger without name`);return d;}const result=state.loggers.get(name);if(!result){const logger=new Logger(name,"NOTSET",{handlers:[]});state.loggers.set(name,logger);return logger;}return result;}function debug(msg,...args){if(msg instanceof Function){return getLogger("default").debug(msg,...args);}return getLogger("default").debug(msg,...args);}function warning(msg,...args){if(msg instanceof Function){return getLogger("default").warning(msg,...args);}return getLogger("default").warning(msg,...args);}function error(msg,...args){if(msg instanceof Function){return getLogger("default").error(msg,...args);}return getLogger("default").error(msg,...args);}function setup(config){state.config={handlers:{...DEFAULT_CONFIG.handlers,...config.handlers},loggers:{...DEFAULT_CONFIG.loggers,...config.loggers}};state.handlers.forEach(handler=>{handler.destroy();});state.handlers.clear();const handlers=state.config.handlers||{};for(const handlerName in handlers){const handler=handlers[handlerName];handler.setup();state.handlers.set(handlerName,handler);}state.loggers.clear();const loggers=state.config.loggers||{};for(const loggerName in loggers){const loggerConfig=loggers[loggerName];const handlerNames=loggerConfig.handlers||[];const handlers=[];handlerNames.forEach(handlerName=>{const handler=state.handlers.get(handlerName);if(handler){handlers.push(handler);}});const levelName=loggerConfig.level||DEFAULT_LEVEL;const logger=new Logger(loggerName,levelName,{handlers:handlers});state.loggers.set(loggerName,logger);}}setup(DEFAULT_CONFIG);function assertArgs1(from,to){assertPath(from);assertPath(to);if(from===to)return"";}function relative(from,to){assertArgs1(from,to);from=resolve(from);to=resolve(to);if(from===to)return"";let fromStart=1;const fromEnd=from.length;for(;fromStartlength){if(isPosixPathSeparator(to.charCodeAt(toStart+i))){return to.slice(toStart+i+1);}else if(i===0){return to.slice(toStart+i);}}else if(fromLen>length){if(isPosixPathSeparator(from.charCodeAt(fromStart+i))){lastCommonSep=i;}else if(i===0){lastCommonSep=0;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(isPosixPathSeparator(fromCode))lastCommonSep=i;}let out="";for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||isPosixPathSeparator(from.charCodeAt(i))){if(out.length===0)out+="..";else out+="/..";}}if(out.length>0)return out+to.slice(toStart+lastCommonSep);else{toStart+=lastCommonSep;if(isPosixPathSeparator(to.charCodeAt(toStart)))++toStart;return to.slice(toStart);}}function relative1(from,to){assertArgs1(from,to);const fromOrig=resolve1(from);const toOrig=resolve1(to);if(fromOrig===toOrig)return"";from=fromOrig.toLowerCase();to=toOrig.toLowerCase();if(from===to)return"";let fromStart=0;let fromEnd=from.length;for(;fromStartfromStart;--fromEnd){if(from.charCodeAt(fromEnd-1)!==92)break;}const fromLen=fromEnd-fromStart;let toStart=0;let toEnd=to.length;for(;toStarttoStart;--toEnd){if(to.charCodeAt(toEnd-1)!==92)break;}const toLen=toEnd-toStart;const length=fromLenlength){if(to.charCodeAt(toStart+i)===92){return toOrig.slice(toStart+i+1);}else if(i===2){return toOrig.slice(toStart+i);}}if(fromLen>length){if(from.charCodeAt(fromStart+i)===92){lastCommonSep=i;}else if(i===2){lastCommonSep=3;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(fromCode===92)lastCommonSep=i;}if(i!==length&&lastCommonSep===-1){return toOrig;}let out="";if(lastCommonSep===-1)lastCommonSep=0;for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||from.charCodeAt(i)===92){if(out.length===0)out+="..";else out+="\\..";}}if(out.length>0){return out+toOrig.slice(toStart+lastCommonSep,toEnd);}else{toStart+=lastCommonSep;if(toOrig.charCodeAt(toStart)===92)++toStart;return toOrig.slice(toStart,toEnd);}}function relative2(from,to){return isWindows?relative1(from,to):relative(from,to);}var m=Object.create;var E=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),D=(t,e)=>{for(var s in e)E(t,s,{get:e[s],enumerable:!0});},a=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!b.call(t,n)&&n!==s&&E(t,n,{get:()=>e[n],enumerable:!(r=T(e,n))||r.enumerable});return t;},_=(t,e,s)=>(a(t,e,"default"),s&&a(s,e,"default")),$=(t,e,s)=>(s=t!=null?m(X(t)):{},a(e||!t||!t.__esModule?E(s,"default",{value:t,enumerable:!0}):s,t));var A=w((ct,v)=>{function C(t){return Array.isArray(t)?t:[t];}var N="",P=" ",h="\\",H=/^\s+$/,F=/(?:[^\\]|^)\\$/,k=/^\\!/,z=/^\\#/,B=/\r?\n/g,K=/^\.*\/|^\.+$/,d="/",x="node-ignore";typeof Symbol<"u"&&(x=Symbol.for("node-ignore"));var L=x,V=(t,e,s)=>Object.defineProperty(t,e,{value:s}),j=/([0-z])-([0-z])/g,G=()=>!1,M=t=>t.replace(j,(e,s,r)=>s.charCodeAt(0)<=r.charCodeAt(0)?e:N),Y=t=>{let{length:e}=t;return t.slice(0,e-e%2);},W=[[/\\?\s+$/,t=>t.indexOf("\\")===0?P:N],[/\\\s/g,()=>P],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)";}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,s)=>e+6{let r=s.replace(/\\\*/g,"[^\\/]*");return e+r;}],[/\\\\\\(?=[$.|*+(){^])/g,()=>h],[/\\\\/g,()=>h],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,s,r,n)=>e===h?`\\[${s}${Y(r)}${n}`:n==="]"&&r.length%2===0?`[${M(s)}${r}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],S=Object.create(null),p=(t,e)=>{let s=S[t];return s||(s=W.reduce((r,n)=>r.replace(n[0],n[1].bind(t)),t),S[t]=s),e?new RegExp(s,"i"):new RegExp(s);},R=t=>typeof t=="string",q=t=>t&&R(t)&&!H.test(t)&&!F.test(t)&&t.indexOf("#")!==0,J=t=>t.split(B),f=class{constructor(e,s,r,n){this.origin=e,this.pattern=s,this.negative=r,this.regex=n;}},Q=(t,e)=>{let s=t,r=!1;t.indexOf("!")===0&&(r=!0,t=t.substr(1)),t=t.replace(k,"!").replace(z,"#");let n=p(t,e);return new f(s,t,r,n);},U=(t,e)=>{throw new e(t);},i=(t,e,s)=>R(t)?t?i.isNotRelative(t)?s(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:s("path must not be empty",TypeError):s(`path must be a string, but got \`${e}\``,TypeError),O=t=>K.test(t);i.isNotRelative=O;i.convert=t=>t;var g=class{constructor({ignorecase:e=!0,ignoreCase:s=e,allowRelativePaths:r=!1}={}){V(this,L,!0),this._rules=[],this._ignoreCase=s,this._allowRelativePaths=r,this._initCache();}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null);}_addPattern(e){if(e&&e[L]){this._rules=this._rules.concat(e._rules),this._added=!0;return;}if(q(e)){let s=Q(e,this._ignoreCase);this._added=!0,this._rules.push(s);}}add(e){return this._added=!1,C(R(e)?J(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this;}addPattern(e){return this.add(e);}_testOne(e,s){let r=!1,n=!1;return this._rules.forEach(o=>{let{negative:u}=o;if(n===u&&r!==n||u&&!r&&!n&&!s)return;o.regex.test(e)&&(r=!u,n=u);}),{ignored:r,unignored:n};}_test(e,s,r,n){let o=e&&i.convert(e);return i(o,e,this._allowRelativePaths?G:U),this._t(o,s,r,n);}_t(e,s,r,n){if(e in s)return s[e];if(n||(n=e.split(d)),n.pop(),!n.length)return s[e]=this._testOne(e,r);let o=this._t(n.join(d)+d,s,r,n);return s[e]=o.ignored?o:this._testOne(e,r);}ignores(e){return this._test(e,this._ignoreCache,!1).ignored;}createFilter(){return e=>!this.ignores(e);}filter(e){return C(e).filter(this.createFilter());}test(e){return this._test(e,this._testCache,!0);}},l=t=>new g(t),Z=t=>i(t&&i.convert(t),t,G);l.isPathValid=Z;l.default=l;v.exports=l;var tt=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");i.convert=tt;var et=/^[a-z]:\//i;i.isNotRelative=t=>et.test(t)||O(t);});var c={};D(c,{default:()=>nt});var st=$(A());_(c,$(A()));var{default:I,...rt}=st,nt=I!==void 0?I:rt;const importMeta={url:"file:///home/runner/work/setup-deno/setup-deno/cache.ts",main:import.meta.main};if(importMeta.main){const args=parseArgs(Deno.args,{boolean:["help","dry-run","verbose","lock-write"],negatable:["lock-write"],string:["config"],default:{"lock-write":true},alias:{help:"h","dry-run":"n"},"--":true});const denoDir=Deno.env.get("DENO_DIR");const logLevel=["1","true"].includes(Deno.env.get("CI")??"")?"DEBUG":args.verbose?"DEBUG":"INFO";setup({handlers:{console:new handlers.ConsoleHandler(logLevel,{formatter:logRecord=>Deno.noColor?[logRecord.levelName,logRecord.msg].join(" "):logRecord.msg})},loggers:{default:{handlers:["console"],"level":logLevel}}});if(args.help){console.log("Usage: cache [-n | --dry-run] [-v | --verbose] [--] [DENO_ARGS...]");Deno.exit(0);}if(args["dry-run"])warning("dry-run mode enabled");if(args.config&&!await exists(args.config)){error(`config file ${args.config} not found`);Deno.exit(1);}const hash=await Deno.readFile("./deno.lock").then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>encodeHex(new Uint8Array(data))).catch(_=>"");debug(`GitHub actions deno.lock hash: ${hash}`);const cfgs=args.config?[args.config]:["deno.json","deno.jsonc"];const denoCfg=await Promise.all(cfgs.map(path=>Deno.readTextFile(path).catch(_=>undefined))).then(v=>parse(v.filter(Boolean)[0]??"{}"));const patterns=[...[denoCfg?.exclude??[]].flat(),...[denoCfg?.cache?.exclude??[]].flat(),...[denoCfg?.cache?.include??[]].flatMap(p=>`!${p}`)];debug(`patterns:`,patterns);patterns.forEach(p=>debug(`- ${p}`));const ig=nt().add(patterns);const walkIterator=walk(".",{exts:["js",".jsx",".ts",".tsx"],includeDirs:false});const paths=[];for await(const entry of walkIterator){const relativePath=relative2(".",entry.path);if(denoDir&&entry.path.startsWith(denoDir))continue;if(ig.ignores(relativePath)){debug(`ignored ${relativePath}`);continue;}debug(`caching ${relativePath}`);paths.push(relativePath);}const cmd=new Deno.Command(Deno.execPath(),{args:["cache",args["lock-write"]&&"--lock-write",args.config&&`--config=${args.config}`,...args["--"],...paths].filter(Boolean),stdout:"inherit",stderr:"inherit"});const code=!args["dry-run"]?(await cmd.output()).code:0;if(code===0)debug(`finished caching ${paths.length} files`);} \ No newline at end of file +class AssertionError extends Error{constructor(message){super(message);this.name="AssertionError";}}function assert(expr,msg=""){if(!expr){throw new AssertionError(msg);}}const{hasOwn}=Object;function get(obj,key){if(hasOwn(obj,key)){return obj[key];}}function getForce(obj,key){const v=get(obj,key);assert(v!==undefined);return v;}function isNumber(x){if(typeof x==="number")return true;if(/^0x[0-9a-f]+$/i.test(String(x)))return true;return/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(String(x));}function hasKey(obj,keys){let o=obj;keys.slice(0,-1).forEach(key=>{o=get(o,key)??{};});const key=keys[keys.length-1];return hasOwn(o,key);}function parseArgs(args,{"--":doubleDash=false,alias={},boolean:__boolean=false,default:defaults={},stopEarly=false,string=[],collect=[],negatable=[],unknown=i=>i}={}){const aliases={};const flags={bools:{},strings:{},unknownFn:unknown,allBools:false,collect:{},negatable:{}};if(alias!==undefined){for(const key in alias){const val=getForce(alias,key);if(typeof val==="string"){aliases[key]=[val];}else{aliases[key]=val;}for(const alias of getForce(aliases,key)){aliases[alias]=[key].concat(aliases[key].filter(y=>alias!==y));}}}if(__boolean!==undefined){if(typeof __boolean==="boolean"){flags.allBools=!!__boolean;}else{const booleanArgs=typeof __boolean==="string"?[__boolean]:__boolean;for(const key of booleanArgs.filter(Boolean)){flags.bools[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.bools[al]=true;}}}}}if(string!==undefined){const stringArgs=typeof string==="string"?[string]:string;for(const key of stringArgs.filter(Boolean)){flags.strings[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.strings[al]=true;}}}}if(collect!==undefined){const collectArgs=typeof collect==="string"?[collect]:collect;for(const key of collectArgs.filter(Boolean)){flags.collect[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.collect[al]=true;}}}}if(negatable!==undefined){const negatableArgs=typeof negatable==="string"?[negatable]:negatable;for(const key of negatableArgs.filter(Boolean)){flags.negatable[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.negatable[al]=true;}}}}const argv={_:[]};function argDefined(key,arg){return flags.allBools&&/^--[^=]+$/.test(arg)||get(flags.bools,key)||!!get(flags.strings,key)||!!get(aliases,key);}function setKey(obj,name,value,collect=true){let o=obj;const keys=name.split(".");keys.slice(0,-1).forEach(function(key){if(get(o,key)===undefined){o[key]={};}o=get(o,key);});const key=keys[keys.length-1];const collectable=collect&&!!get(flags.collect,name);if(!collectable){o[key]=value;}else if(get(o,key)===undefined){o[key]=[value];}else if(Array.isArray(get(o,key))){o[key].push(value);}else{o[key]=[get(o,key),value];}}function setArg(key,val,arg=undefined,collect){if(arg&&flags.unknownFn&&!argDefined(key,arg)){if(flags.unknownFn(arg,key,val)===false)return;}const value=!get(flags.strings,key)&&isNumber(val)?Number(val):val;setKey(argv,key,value,collect);const alias=get(aliases,key);if(alias){for(const x of alias){setKey(argv,x,value,collect);}}}function aliasIsBoolean(key){return getForce(aliases,key).some(x=>typeof get(flags.bools,x)==="boolean");}let notFlags=[];if(args.includes("--")){notFlags=args.slice(args.indexOf("--")+1);args=args.slice(0,args.indexOf("--"));}for(let i=0;i>4];dst[i*2+1]=hexTable[v&15];}return textDecoder.decode(dst);}const osType=(()=>{const{Deno:Deno1}=globalThis;if(typeof Deno1?.build?.os==="string"){return Deno1.build.os;}const{navigator}=globalThis;if(navigator?.appVersion?.includes?.("Win")){return"windows";}return"linux";})();const isWindows=osType==="windows";function assertPath(path){if(typeof path!=="string"){throw new TypeError(`Path must be a string. Received ${JSON.stringify(path)}`);}}function assertArg(path){assertPath(path);if(path.length===0)return".";}const CHAR_FORWARD_SLASH=47;function normalizeString(path,allowAboveRoot,separator,isPathSeparator){let res="";let lastSegmentLength=0;let lastSlash=-1;let dots=0;let code;for(let i=0,len=path.length;i<=len;++i){if(i2){const lastSlashIndex=res.lastIndexOf(separator);if(lastSlashIndex===-1){res="";lastSegmentLength=0;}else{res=res.slice(0,lastSlashIndex);lastSegmentLength=res.length-1-res.lastIndexOf(separator);}lastSlash=i;dots=0;continue;}else if(res.length===2||res.length===1){res="";lastSegmentLength=0;lastSlash=i;dots=0;continue;}}if(allowAboveRoot){if(res.length>0)res+=`${separator}..`;else res="..";lastSegmentLength=2;}}else{if(res.length>0)res+=separator+path.slice(lastSlash+1,i);else res=path.slice(lastSlash+1,i);lastSegmentLength=i-lastSlash-1;}lastSlash=i;dots=0;}else if(code===46&&dots!==-1){++dots;}else{dots=-1;}}return res;}function isPosixPathSeparator(code){return code===47;}function normalize(path){assertArg(path);const isAbsolute=isPosixPathSeparator(path.charCodeAt(0));const trailingSeparator=isPosixPathSeparator(path.charCodeAt(path.length-1));path=normalizeString(path,!isAbsolute,"/",isPosixPathSeparator);if(path.length===0&&!isAbsolute)path=".";if(path.length>0&&trailingSeparator)path+="/";if(isAbsolute)return`/${path}`;return path;}function join(...paths){if(paths.length===0)return".";let joined;for(let i=0,len=paths.length;i0){if(!joined)joined=path;else joined+=`/${path}`;}}if(!joined)return".";return normalize(joined);}function isPathSeparator(code){return code===47||code===92;}function isWindowsDeviceRoot(code){return code>=97&&code<=122||code>=65&&code<=90;}function normalize1(path){assertArg(path);const len=path.length;let rootEnd=0;let device;let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){return"\\";}let tail;if(rootEnd0&&isPathSeparator(path.charCodeAt(len-1))){tail+="\\";}if(device===undefined){if(isAbsolute){if(tail.length>0)return`\\${tail}`;else return"\\";}else if(tail.length>0){return tail;}else{return"";}}else if(isAbsolute){if(tail.length>0)return`${device}\\${tail}`;else return`${device}\\`;}else if(tail.length>0){return device+tail;}else{return device;}}function join1(...paths){if(paths.length===0)return".";let joined;let firstPart=null;for(let i=0;i0){if(joined===undefined)joined=firstPart=path;else joined+=`\\${path}`;}}if(joined===undefined)return".";let needsReplace=true;let slashCount=0;assert(firstPart!==null);if(isPathSeparator(firstPart.charCodeAt(0))){++slashCount;const firstLen=firstPart.length;if(firstLen>1){if(isPathSeparator(firstPart.charCodeAt(1))){++slashCount;if(firstLen>2){if(isPathSeparator(firstPart.charCodeAt(2)))++slashCount;else{needsReplace=false;}}}}}if(needsReplace){for(;slashCount=2)joined=`\\${joined.slice(slashCount)}`;}return normalize1(joined);}function join2(...paths){return isWindows?join1(...paths):join(...paths);}function assertArg1(url){url=url instanceof URL?url:new URL(url);if(url.protocol!=="file:"){throw new TypeError("Must be a file URL.");}return url;}function fromFileUrl(url){url=assertArg1(url);return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"));}function fromFileUrl1(url){url=assertArg1(url);let path=decodeURIComponent(url.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");if(url.hostname!==""){path=`\\\\${url.hostname}${path}`;}return path;}function fromFileUrl2(url){return isWindows?fromFileUrl1(url):fromFileUrl(url);}function toPathString(pathUrl){return pathUrl instanceof URL?fromFileUrl2(pathUrl):pathUrl;}function stripTrailingSeparators(segment,isSep){if(segment.length<=1){return segment;}let end=segment.length;for(let i=segment.length-1;i>0;i--){if(isSep(segment.charCodeAt(i))){end=i;}else{break;}}return segment.slice(0,end);}function resolve(...pathSegments){let resolvedPath="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1&&!resolvedAbsolute;i--){let path;if(i>=0)path=pathSegments[i];else{const{Deno:Deno1}=globalThis;if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();}assertPath(path);if(path.length===0){continue;}resolvedPath=`${path}/${resolvedPath}`;resolvedAbsolute=isPosixPathSeparator(path.charCodeAt(0));}resolvedPath=normalizeString(resolvedPath,!resolvedAbsolute,"/",isPosixPathSeparator);if(resolvedAbsolute){if(resolvedPath.length>0)return`/${resolvedPath}`;else return"/";}else if(resolvedPath.length>0)return resolvedPath;else return".";}function resolve1(...pathSegments){let resolvedDevice="";let resolvedTail="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1;i--){let path;const{Deno:Deno1}=globalThis;if(i>=0){path=pathSegments[i];}else if(!resolvedDevice){if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a drive-letter-less path without a CWD.");}path=Deno1.cwd();}else{if(typeof Deno1?.env?.get!=="function"||typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();if(path===undefined||path.slice(0,3).toLowerCase()!==`${resolvedDevice.toLowerCase()}\\`){path=`${resolvedDevice}\\`;}}assertPath(path);const len=path.length;if(len===0)continue;let rootEnd=0;let device="";let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){rootEnd=1;isAbsolute=true;}if(device.length>0&&resolvedDevice.length>0&&device.toLowerCase()!==resolvedDevice.toLowerCase()){continue;}if(resolvedDevice.length===0&&device.length>0){resolvedDevice=device;}if(!resolvedAbsolute){resolvedTail=`${path.slice(rootEnd)}\\${resolvedTail}`;resolvedAbsolute=isAbsolute;}if(resolvedAbsolute&&resolvedDevice.length>0)break;}resolvedTail=normalizeString(resolvedTail,!resolvedAbsolute,"\\",isPathSeparator);return resolvedDevice+(resolvedAbsolute?"\\":"")+resolvedTail||".";}Deno.build.os==="windows";async function exists(path,options){try{const stat=await Deno.stat(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if((await Deno.permissions.query({name:"read",path})).state==="granted"){return!options?.isReadable;}}throw error;}}function existsSync(path,options){try{const stat=Deno.statSync(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if(Deno.permissions.querySync({name:"read",path}).state==="granted"){return!options?.isReadable;}}throw error;}}function normalize2(path){return isWindows?normalize1(path):normalize(path);}function stripSuffix(name,suffix){if(suffix.length>=name.length){return name;}const lenDiff=name.length-suffix.length;for(let i=suffix.length-1;i>=0;--i){if(name.charCodeAt(lenDiff+i)!==suffix.charCodeAt(i)){return name;}}return name.slice(0,-suffix.length);}function lastPathSegment(path,isSep,start=0){let matchedNonSeparator=false;let end=path.length;for(let i=path.length-1;i>=start;--i){if(isSep(path.charCodeAt(i))){if(matchedNonSeparator){start=i+1;break;}}else if(!matchedNonSeparator){matchedNonSeparator=true;end=i+1;}}return path.slice(start,end);}function assertArgs(path,suffix){assertPath(path);if(path.length===0)return path;if(typeof suffix!=="string"){throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);}}function basename(path,suffix=""){assertArgs(path,suffix);const lastSegment=lastPathSegment(path,isPosixPathSeparator);const strippedSegment=stripTrailingSeparators(lastSegment,isPosixPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename1(path,suffix=""){assertArgs(path,suffix);let start=0;if(path.length>=2){const drive=path.charCodeAt(0);if(isWindowsDeviceRoot(drive)){if(path.charCodeAt(1)===58)start=2;}}const lastSegment=lastPathSegment(path,isPathSeparator,start);const strippedSegment=stripTrailingSeparators(lastSegment,isPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename2(path,suffix=""){return isWindows?basename1(path,suffix):basename(path,suffix);}async function createWalkEntry(path){path=toPathString(path);path=normalize2(path);const name=basename2(path);const info=await Deno.stat(path);return{path,name,isFile:info.isFile,isDirectory:info.isDirectory,isSymlink:info.isSymlink};}class WalkError extends Error{root;constructor(cause,root){super(`${cause instanceof Error?cause.message:cause} for path "${root}"`);this.cause=cause;this.name="WalkError";this.root=root;}}function include(path,exts,match,skip){if(exts&&!exts.some(ext=>path.endsWith(ext))){return false;}if(match&&!match.some(pattern=>!!path.match(pattern))){return false;}if(skip&&skip.some(pattern=>!!path.match(pattern))){return false;}return true;}function wrapErrorWithPath(err,root){if(err instanceof WalkError)return err;return new WalkError(err,root);}async function*walk(root,{maxDepth=Infinity,includeFiles=true,includeDirs=true,includeSymlinks=true,followSymlinks=false,canonicalize=true,exts=undefined,match=undefined,skip=undefined}={}){if(maxDepth<0){return;}root=toPathString(root);if(includeDirs&&include(root,exts,match,skip)){yield await createWalkEntry(root);}if(maxDepth<1||!include(root,undefined,undefined,skip)){return;}try{for await(const entry of Deno.readDir(root)){let path=join2(root,entry.name);let{isSymlink,isDirectory}=entry;if(isSymlink){if(!followSymlinks){if(includeSymlinks&&include(path,exts,match,skip)){yield{path,...entry};}continue;}const realPath=await Deno.realPath(path);if(canonicalize){path=realPath;}({isSymlink,isDirectory}=await Deno.lstat(realPath));}if(isSymlink||isDirectory){yield*walk(path,{maxDepth:maxDepth-1,includeFiles,includeDirs,includeSymlinks,followSymlinks,exts,match,skip});}else if(includeFiles&&include(path,exts,match,skip)){yield{path,...entry};}}}catch(err){throw wrapErrorWithPath(err,normalize2(root));}}Deno.build.os==="windows";new Deno.errors.AlreadyExists("dest already exists.");Deno.build.os==="windows";const LF="\n";const CRLF="\r\n";Deno?.build.os==="windows"?CRLF:LF;function parse(text,{allowTrailingComma=true}={}){if(new.target){throw new TypeError("parse is not a constructor");}return new JSONCParser(text,{allowTrailingComma}).parse();}const originalJSONParse=globalThis.JSON.parse;class JSONCParser{#whitespace=new Set(" \r\n");#numberEndToken=new Set([..."[]{}:,/",...this.#whitespace]);#text;#length;#tokenized;#options;constructor(text,options){this.#text=`${text}`;this.#length=this.#text.length;this.#tokenized=this.#tokenize();this.#options=options;}parse(){const token=this.#getNext();const res=this.#parseJsonValue(token);const{done,value}=this.#tokenized.next();if(!done){throw new SyntaxError(buildErrorMessage(value));}return res;}#getNext(){const{done,value}=this.#tokenized.next();if(done){throw new SyntaxError("Unexpected end of JSONC input");}return value;}*#tokenize(){for(let i=0;iisNaN(Number(key)));const byLevel={[LogLevels.NOTSET]:"NOTSET",[LogLevels.DEBUG]:"DEBUG",[LogLevels.INFO]:"INFO",[LogLevels.WARNING]:"WARNING",[LogLevels.ERROR]:"ERROR",[LogLevels.CRITICAL]:"CRITICAL"};function getLevelByName(name){const level=LogLevels[name];if(level!==undefined){return level;}throw new Error(`no log level found for name: ${name}`);}function getLevelName(level){const levelName=byLevel[level];if(levelName){return levelName;}throw new Error(`no level name found for level: ${level}`);}class LogRecord{msg;#args;#datetime;level;levelName;loggerName;constructor(options){this.msg=options.msg;this.#args=[...options.args];this.level=options.level;this.loggerName=options.loggerName;this.#datetime=new Date;this.levelName=getLevelName(options.level);}get args(){return[...this.#args];}get datetime(){return new Date(this.#datetime.getTime());}}class Logger{#level;#handlers;#loggerName;constructor(loggerName,levelName,options={}){this.#loggerName=loggerName;this.#level=getLevelByName(levelName);this.#handlers=options.handlers||[];}get level(){return this.#level;}set level(level){try{this.#level=getLevelByName(getLevelName(level));}catch(_){throw new TypeError(`Invalid log level: ${level}`);}}get levelName(){return getLevelName(this.#level);}set levelName(levelName){this.#level=getLevelByName(levelName);}get loggerName(){return this.#loggerName;}set handlers(hndls){this.#handlers=hndls;}get handlers(){return this.#handlers;}#_log(level,msg,...args){if(this.level>level){return msg instanceof Function?undefined:msg;}let fnResult;let logMessage;if(msg instanceof Function){fnResult=msg();logMessage=this.asString(fnResult);}else{logMessage=this.asString(msg);}const record=new LogRecord({msg:logMessage,args:args,level:level,loggerName:this.loggerName});this.#handlers.forEach(handler=>{handler.handle(record);});return msg instanceof Function?fnResult:msg;}asString(data,isProperty=false){if(typeof data==="string"){if(isProperty)return`"${data}"`;return data;}else if(data===null||typeof data==="number"||typeof data==="bigint"||typeof data==="boolean"||typeof data==="undefined"||typeof data==="symbol"){return String(data);}else if(data instanceof Error){return data.stack;}else if(typeof data==="object"){return`{${Object.entries(data).map(([k,v])=>`"${k}":${this.asString(v,true)}`).join(",")}}`;}return"undefined";}debug(msg,...args){return this.#_log(LogLevels.DEBUG,msg,...args);}info(msg,...args){return this.#_log(LogLevels.INFO,msg,...args);}warning(msg,...args){return this.#_log(LogLevels.WARNING,msg,...args);}error(msg,...args){return this.#_log(LogLevels.ERROR,msg,...args);}critical(msg,...args){return this.#_log(LogLevels.CRITICAL,msg,...args);}}const{Deno:Deno1}=globalThis;const noColor=typeof Deno1?.noColor==="boolean"?Deno1.noColor:false;let enabled=!noColor;function code(open,close){return{open:`\x1b[${open.join(";")}m`,close:`\x1b[${close}m`,regexp:new RegExp(`\\x1b\\[${close}m`,"g")};}function run(str,code){return enabled?`${code.open}${str.replace(code.regexp,code.open)}${code.close}`:str;}function bold(str){return run(str,code([1],22));}function red(str){return run(str,code([31],39));}function yellow(str){return run(str,code([33],39));}function blue(str){return run(str,code([34],39));}new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"),"g");function copy(src,dst,off=0){off=Math.max(0,Math.min(off,dst.byteLength));const dstBytesAvailable=dst.byteLength-off;if(src.byteLength>dstBytesAvailable){src=src.subarray(0,dstBytesAvailable);}dst.set(src,off);return src.byteLength;}class AbstractBufBase{buf;usedBufferBytes=0;err=null;constructor(buf){this.buf=buf;}size(){return this.buf.byteLength;}available(){return this.buf.byteLength-this.usedBufferBytes;}buffered(){return this.usedBufferBytes;}}class BufWriterSync extends AbstractBufBase{#writer;static create(writer,size=4096){return writer instanceof BufWriterSync?writer:new BufWriterSync(writer,size);}constructor(writer,size=4096){super(new Uint8Array(size<=0?4096:size));this.#writer=writer;}reset(w){this.err=null;this.usedBufferBytes=0;this.#writer=w;}flush(){if(this.err!==null)throw this.err;if(this.usedBufferBytes===0)return;try{const p=this.buf.subarray(0,this.usedBufferBytes);let nwritten=0;while(nwrittenthis.available()){if(this.buffered()===0){try{numBytesWritten=this.#writer.writeSync(data);}catch(e){if(e instanceof Error){this.err=e;}throw e;}}else{numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;this.flush();}totalBytesWritten+=numBytesWritten;data=data.subarray(numBytesWritten);}numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;totalBytesWritten+=numBytesWritten;return totalBytesWritten;}}const DEFAULT_FORMATTER="{levelName} {msg}";class BaseHandler{level;levelName;formatter;constructor(levelName,options={}){this.level=getLevelByName(levelName);this.levelName=levelName;this.formatter=options.formatter||DEFAULT_FORMATTER;}handle(logRecord){if(this.level>logRecord.level)return;const msg=this.format(logRecord);this.log(msg);}format(logRecord){if(this.formatter instanceof Function){return this.formatter(logRecord);}return this.formatter.replace(/{([^\s}]+)}/g,(match,p1)=>{const value=logRecord[p1];if(value===undefined){return match;}return String(value);});}log(_msg){}setup(){}destroy(){}}class ConsoleHandler extends BaseHandler{#useColors;constructor(levelName,options={}){super(levelName,options);this.#useColors=options.useColors??true;}format(logRecord){let msg=super.format(logRecord);if(this.#useColors){msg=this.applyColors(msg,logRecord.level);}return msg;}applyColors(msg,level){switch(level){case LogLevels.INFO:msg=blue(msg);break;case LogLevels.WARNING:msg=yellow(msg);break;case LogLevels.ERROR:msg=red(msg);break;case LogLevels.CRITICAL:msg=bold(red(msg));break;default:break;}return msg;}log(msg){console.log(msg);}}class WriterHandler extends BaseHandler{_writer;#encoder=new TextEncoder;}class FileHandler extends WriterHandler{_file;_buf;_filename;_mode;_openOptions;_encoder=new TextEncoder;#unloadCallback=(()=>{this.destroy();}).bind(this);constructor(levelName,options){super(levelName,options);this._filename=options.filename;this._mode=options.mode?options.mode:"a";this._openOptions={createNew:this._mode==="x",create:this._mode!=="x",append:this._mode==="a",truncate:this._mode!=="a",write:true};}setup(){this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);addEventListener("unload",this.#unloadCallback);}handle(logRecord){super.handle(logRecord);if(logRecord.level>LogLevels.ERROR){this.flush();}}log(msg){if(this._encoder.encode(msg).byteLength+1>this._buf.available()){this.flush();}this._buf.writeSync(this._encoder.encode(msg+"\n"));}flush(){if(this._buf?.buffered()>0){this._buf.flush();}}destroy(){this.flush();this._file?.close();this._file=undefined;removeEventListener("unload",this.#unloadCallback);}}class RotatingFileHandler extends FileHandler{#maxBytes;#maxBackupCount;#currentFileSize=0;constructor(levelName,options){super(levelName,options);this.#maxBytes=options.maxBytes;this.#maxBackupCount=options.maxBackupCount;}setup(){if(this.#maxBytes<1){this.destroy();throw new Error("maxBytes cannot be less than 1");}if(this.#maxBackupCount<1){this.destroy();throw new Error("maxBackupCount cannot be less than 1");}super.setup();if(this._mode==="w"){for(let i=1;i<=this.#maxBackupCount;i++){try{Deno.removeSync(this._filename+"."+i);}catch(error){if(!(error instanceof Deno.errors.NotFound)){throw error;}}}}else if(this._mode==="x"){for(let i=1;i<=this.#maxBackupCount;i++){if(existsSync(this._filename+"."+i)){this.destroy();throw new Deno.errors.AlreadyExists("Backup log file "+this._filename+"."+i+" already exists");}}}else{this.#currentFileSize=Deno.statSync(this._filename).size;}}log(msg){const msgByteLength=this._encoder.encode(msg).byteLength+1;if(this.#currentFileSize+msgByteLength>this.#maxBytes){this.rotateLogFiles();this.#currentFileSize=0;}super.log(msg);this.#currentFileSize+=msgByteLength;}rotateLogFiles(){this._buf.flush();this._file.close();for(let i=this.#maxBackupCount-1;i>=0;i--){const source=this._filename+(i===0?"":"."+i);const dest=this._filename+"."+(i+1);if(existsSync(source)){Deno.renameSync(source,dest);}}this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);}}const DEFAULT_LEVEL="INFO";const DEFAULT_CONFIG={handlers:{default:new ConsoleHandler(DEFAULT_LEVEL)},loggers:{default:{level:DEFAULT_LEVEL,handlers:["default"]}}};const state={handlers:new Map,loggers:new Map,config:DEFAULT_CONFIG};const handlers={BaseHandler,ConsoleHandler,WriterHandler,FileHandler,RotatingFileHandler};function getLogger(name){if(!name){const d=state.loggers.get("default");assert(d!==undefined,`"default" logger must be set for getting logger without name`);return d;}const result=state.loggers.get(name);if(!result){const logger=new Logger(name,"NOTSET",{handlers:[]});state.loggers.set(name,logger);return logger;}return result;}function debug(msg,...args){if(msg instanceof Function){return getLogger("default").debug(msg,...args);}return getLogger("default").debug(msg,...args);}function info(msg,...args){if(msg instanceof Function){return getLogger("default").info(msg,...args);}return getLogger("default").info(msg,...args);}function warning(msg,...args){if(msg instanceof Function){return getLogger("default").warning(msg,...args);}return getLogger("default").warning(msg,...args);}function error(msg,...args){if(msg instanceof Function){return getLogger("default").error(msg,...args);}return getLogger("default").error(msg,...args);}function setup(config){state.config={handlers:{...DEFAULT_CONFIG.handlers,...config.handlers},loggers:{...DEFAULT_CONFIG.loggers,...config.loggers}};state.handlers.forEach(handler=>{handler.destroy();});state.handlers.clear();const handlers=state.config.handlers||{};for(const handlerName in handlers){const handler=handlers[handlerName];handler.setup();state.handlers.set(handlerName,handler);}state.loggers.clear();const loggers=state.config.loggers||{};for(const loggerName in loggers){const loggerConfig=loggers[loggerName];const handlerNames=loggerConfig.handlers||[];const handlers=[];handlerNames.forEach(handlerName=>{const handler=state.handlers.get(handlerName);if(handler){handlers.push(handler);}});const levelName=loggerConfig.level||DEFAULT_LEVEL;const logger=new Logger(loggerName,levelName,{handlers:handlers});state.loggers.set(loggerName,logger);}}setup(DEFAULT_CONFIG);function assertArgs1(from,to){assertPath(from);assertPath(to);if(from===to)return"";}function relative(from,to){assertArgs1(from,to);from=resolve(from);to=resolve(to);if(from===to)return"";let fromStart=1;const fromEnd=from.length;for(;fromStartlength){if(isPosixPathSeparator(to.charCodeAt(toStart+i))){return to.slice(toStart+i+1);}else if(i===0){return to.slice(toStart+i);}}else if(fromLen>length){if(isPosixPathSeparator(from.charCodeAt(fromStart+i))){lastCommonSep=i;}else if(i===0){lastCommonSep=0;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(isPosixPathSeparator(fromCode))lastCommonSep=i;}let out="";for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||isPosixPathSeparator(from.charCodeAt(i))){if(out.length===0)out+="..";else out+="/..";}}if(out.length>0)return out+to.slice(toStart+lastCommonSep);else{toStart+=lastCommonSep;if(isPosixPathSeparator(to.charCodeAt(toStart)))++toStart;return to.slice(toStart);}}function relative1(from,to){assertArgs1(from,to);const fromOrig=resolve1(from);const toOrig=resolve1(to);if(fromOrig===toOrig)return"";from=fromOrig.toLowerCase();to=toOrig.toLowerCase();if(from===to)return"";let fromStart=0;let fromEnd=from.length;for(;fromStartfromStart;--fromEnd){if(from.charCodeAt(fromEnd-1)!==92)break;}const fromLen=fromEnd-fromStart;let toStart=0;let toEnd=to.length;for(;toStarttoStart;--toEnd){if(to.charCodeAt(toEnd-1)!==92)break;}const toLen=toEnd-toStart;const length=fromLenlength){if(to.charCodeAt(toStart+i)===92){return toOrig.slice(toStart+i+1);}else if(i===2){return toOrig.slice(toStart+i);}}if(fromLen>length){if(from.charCodeAt(fromStart+i)===92){lastCommonSep=i;}else if(i===2){lastCommonSep=3;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(fromCode===92)lastCommonSep=i;}if(i!==length&&lastCommonSep===-1){return toOrig;}let out="";if(lastCommonSep===-1)lastCommonSep=0;for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||from.charCodeAt(i)===92){if(out.length===0)out+="..";else out+="\\..";}}if(out.length>0){return out+toOrig.slice(toStart+lastCommonSep,toEnd);}else{toStart+=lastCommonSep;if(toOrig.charCodeAt(toStart)===92)++toStart;return toOrig.slice(toStart,toEnd);}}function relative2(from,to){return isWindows?relative1(from,to):relative(from,to);}var m=Object.create;var E=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),D=(t,e)=>{for(var s in e)E(t,s,{get:e[s],enumerable:!0});},a=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!b.call(t,n)&&n!==s&&E(t,n,{get:()=>e[n],enumerable:!(r=T(e,n))||r.enumerable});return t;},_=(t,e,s)=>(a(t,e,"default"),s&&a(s,e,"default")),$=(t,e,s)=>(s=t!=null?m(X(t)):{},a(e||!t||!t.__esModule?E(s,"default",{value:t,enumerable:!0}):s,t));var A=w((ct,v)=>{function C(t){return Array.isArray(t)?t:[t];}var N="",P=" ",h="\\",H=/^\s+$/,F=/(?:[^\\]|^)\\$/,k=/^\\!/,z=/^\\#/,B=/\r?\n/g,K=/^\.*\/|^\.+$/,d="/",x="node-ignore";typeof Symbol<"u"&&(x=Symbol.for("node-ignore"));var L=x,V=(t,e,s)=>Object.defineProperty(t,e,{value:s}),j=/([0-z])-([0-z])/g,G=()=>!1,M=t=>t.replace(j,(e,s,r)=>s.charCodeAt(0)<=r.charCodeAt(0)?e:N),Y=t=>{let{length:e}=t;return t.slice(0,e-e%2);},W=[[/\\?\s+$/,t=>t.indexOf("\\")===0?P:N],[/\\\s/g,()=>P],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)";}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,s)=>e+6{let r=s.replace(/\\\*/g,"[^\\/]*");return e+r;}],[/\\\\\\(?=[$.|*+(){^])/g,()=>h],[/\\\\/g,()=>h],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,s,r,n)=>e===h?`\\[${s}${Y(r)}${n}`:n==="]"&&r.length%2===0?`[${M(s)}${r}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],S=Object.create(null),p=(t,e)=>{let s=S[t];return s||(s=W.reduce((r,n)=>r.replace(n[0],n[1].bind(t)),t),S[t]=s),e?new RegExp(s,"i"):new RegExp(s);},R=t=>typeof t=="string",q=t=>t&&R(t)&&!H.test(t)&&!F.test(t)&&t.indexOf("#")!==0,J=t=>t.split(B),f=class{constructor(e,s,r,n){this.origin=e,this.pattern=s,this.negative=r,this.regex=n;}},Q=(t,e)=>{let s=t,r=!1;t.indexOf("!")===0&&(r=!0,t=t.substr(1)),t=t.replace(k,"!").replace(z,"#");let n=p(t,e);return new f(s,t,r,n);},U=(t,e)=>{throw new e(t);},i=(t,e,s)=>R(t)?t?i.isNotRelative(t)?s(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:s("path must not be empty",TypeError):s(`path must be a string, but got \`${e}\``,TypeError),O=t=>K.test(t);i.isNotRelative=O;i.convert=t=>t;var g=class{constructor({ignorecase:e=!0,ignoreCase:s=e,allowRelativePaths:r=!1}={}){V(this,L,!0),this._rules=[],this._ignoreCase=s,this._allowRelativePaths=r,this._initCache();}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null);}_addPattern(e){if(e&&e[L]){this._rules=this._rules.concat(e._rules),this._added=!0;return;}if(q(e)){let s=Q(e,this._ignoreCase);this._added=!0,this._rules.push(s);}}add(e){return this._added=!1,C(R(e)?J(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this;}addPattern(e){return this.add(e);}_testOne(e,s){let r=!1,n=!1;return this._rules.forEach(o=>{let{negative:u}=o;if(n===u&&r!==n||u&&!r&&!n&&!s)return;o.regex.test(e)&&(r=!u,n=u);}),{ignored:r,unignored:n};}_test(e,s,r,n){let o=e&&i.convert(e);return i(o,e,this._allowRelativePaths?G:U),this._t(o,s,r,n);}_t(e,s,r,n){if(e in s)return s[e];if(n||(n=e.split(d)),n.pop(),!n.length)return s[e]=this._testOne(e,r);let o=this._t(n.join(d)+d,s,r,n);return s[e]=o.ignored?o:this._testOne(e,r);}ignores(e){return this._test(e,this._ignoreCache,!1).ignored;}createFilter(){return e=>!this.ignores(e);}filter(e){return C(e).filter(this.createFilter());}test(e){return this._test(e,this._testCache,!0);}},l=t=>new g(t),Z=t=>i(t&&i.convert(t),t,G);l.isPathValid=Z;l.default=l;v.exports=l;var tt=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");i.convert=tt;var et=/^[a-z]:\//i;i.isNotRelative=t=>et.test(t)||O(t);});var c={};D(c,{default:()=>nt});var st=$(A());_(c,$(A()));var{default:I,...rt}=st,nt=I!==void 0?I:rt;const importMeta={url:"file:///Users/winston/Code/winston/setup-deno/cache.ts",main:import.meta.main};if(importMeta.main){const args=parseArgs(Deno.args,{boolean:["dry-run","verbose","lock-write"],negatable:["lock-write"],string:["config"],default:{"lock-write":true},alias:{"dry-run":"n",verbose:"v"},"--":true,unknown:arg=>{console.log(`Unknown argument: ${arg}`);console.log("Usage: cache [-n | --dry-run] [-v | --verbose] [--] [DENO_ARGS...]");Deno.exit(0);}});const denoDir=Deno.env.get("DENO_DIR");const logLevel=["1","true"].includes(Deno.env.get("CI")??"")?"DEBUG":args.verbose?"DEBUG":"INFO";setup({handlers:{console:new handlers.ConsoleHandler(logLevel,{formatter:logRecord=>Deno.noColor?logRecord.levelName+" "+logRecord.msg:logRecord.msg})},loggers:{default:{handlers:["console"],"level":logLevel}}});if(args["dry-run"])warning("dry-run mode enabled");if(args.config&&!await exists(args.config)){error(`config file ${args.config} not found`);Deno.exit(1);}const hash=await Deno.readFile("./deno.lock").then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>encodeHex(new Uint8Array(data))).catch(_=>"");debug(`GitHub actions deno.lock hash: ${hash}`);const cfgs=args.config?[args.config]:["deno.json","deno.jsonc"];const denoCfg=await Promise.all(cfgs.map(path=>Deno.readTextFile(path).catch(_=>undefined))).then(v=>parse(v.filter(Boolean)[0]??"{}"));const patterns=[...[denoCfg?.exclude??[]].flat(),...[denoCfg?.cache?.exclude??[]].flat(),...[denoCfg?.cache?.include??[]].flatMap(p=>`!${p}`)];debug(`patterns:`,patterns);patterns.forEach(p=>debug(`- ${p}`));const ig=nt().add(patterns);const walkIterator=walk(".",{exts:["js",".jsx",".ts",".tsx"],includeDirs:false});const paths=[];for await(const entry of walkIterator){const relativePath=relative2(".",entry.path);if(denoDir&&entry.path.startsWith(denoDir))continue;if(ig.ignores(relativePath)){debug(`ignored ${relativePath}`);continue;}debug(`caching ${relativePath}`);paths.push(relativePath);}const denoArgs=["cache",args["lock-write"]&&"--lock-write",args.config&&`--config=${args.config}`,...args["--"],...paths].filter(Boolean);const cmd=new Deno.Command(Deno.execPath(),{args:denoArgs});const cmdString=Deno.execPath()+" "+denoArgs.join(" ");if(args["dry-run"]){info(`would run: ${cmdString}`);Deno.exit(0);}debug(`running: ${cmdString}`);const{stderr,code}=await cmd.output();for(const line of new TextDecoder().decode(stderr).split("\n")){if(line.length>0)info("deno> "+line);}if(code===0)debug(`finished caching ${paths.length} files`);} \ No newline at end of file From c8ebaa70bda7a6d41af4654b6740133f9e665fbf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 26 Dec 2023 22:13:18 +0000 Subject: [PATCH 16/18] chore: build action bundle --- dist/cache.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/cache.js b/dist/cache.js index 6da64f0..b9c94ca 100755 --- a/dist/cache.js +++ b/dist/cache.js @@ -1,2 +1,2 @@ #!/usr/bin/env -S deno run --no-lock --allow-read --allow-run=deno --allow-env=CI,DENO_DIR -class AssertionError extends Error{constructor(message){super(message);this.name="AssertionError";}}function assert(expr,msg=""){if(!expr){throw new AssertionError(msg);}}const{hasOwn}=Object;function get(obj,key){if(hasOwn(obj,key)){return obj[key];}}function getForce(obj,key){const v=get(obj,key);assert(v!==undefined);return v;}function isNumber(x){if(typeof x==="number")return true;if(/^0x[0-9a-f]+$/i.test(String(x)))return true;return/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(String(x));}function hasKey(obj,keys){let o=obj;keys.slice(0,-1).forEach(key=>{o=get(o,key)??{};});const key=keys[keys.length-1];return hasOwn(o,key);}function parseArgs(args,{"--":doubleDash=false,alias={},boolean:__boolean=false,default:defaults={},stopEarly=false,string=[],collect=[],negatable=[],unknown=i=>i}={}){const aliases={};const flags={bools:{},strings:{},unknownFn:unknown,allBools:false,collect:{},negatable:{}};if(alias!==undefined){for(const key in alias){const val=getForce(alias,key);if(typeof val==="string"){aliases[key]=[val];}else{aliases[key]=val;}for(const alias of getForce(aliases,key)){aliases[alias]=[key].concat(aliases[key].filter(y=>alias!==y));}}}if(__boolean!==undefined){if(typeof __boolean==="boolean"){flags.allBools=!!__boolean;}else{const booleanArgs=typeof __boolean==="string"?[__boolean]:__boolean;for(const key of booleanArgs.filter(Boolean)){flags.bools[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.bools[al]=true;}}}}}if(string!==undefined){const stringArgs=typeof string==="string"?[string]:string;for(const key of stringArgs.filter(Boolean)){flags.strings[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.strings[al]=true;}}}}if(collect!==undefined){const collectArgs=typeof collect==="string"?[collect]:collect;for(const key of collectArgs.filter(Boolean)){flags.collect[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.collect[al]=true;}}}}if(negatable!==undefined){const negatableArgs=typeof negatable==="string"?[negatable]:negatable;for(const key of negatableArgs.filter(Boolean)){flags.negatable[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.negatable[al]=true;}}}}const argv={_:[]};function argDefined(key,arg){return flags.allBools&&/^--[^=]+$/.test(arg)||get(flags.bools,key)||!!get(flags.strings,key)||!!get(aliases,key);}function setKey(obj,name,value,collect=true){let o=obj;const keys=name.split(".");keys.slice(0,-1).forEach(function(key){if(get(o,key)===undefined){o[key]={};}o=get(o,key);});const key=keys[keys.length-1];const collectable=collect&&!!get(flags.collect,name);if(!collectable){o[key]=value;}else if(get(o,key)===undefined){o[key]=[value];}else if(Array.isArray(get(o,key))){o[key].push(value);}else{o[key]=[get(o,key),value];}}function setArg(key,val,arg=undefined,collect){if(arg&&flags.unknownFn&&!argDefined(key,arg)){if(flags.unknownFn(arg,key,val)===false)return;}const value=!get(flags.strings,key)&&isNumber(val)?Number(val):val;setKey(argv,key,value,collect);const alias=get(aliases,key);if(alias){for(const x of alias){setKey(argv,x,value,collect);}}}function aliasIsBoolean(key){return getForce(aliases,key).some(x=>typeof get(flags.bools,x)==="boolean");}let notFlags=[];if(args.includes("--")){notFlags=args.slice(args.indexOf("--")+1);args=args.slice(0,args.indexOf("--"));}for(let i=0;i>4];dst[i*2+1]=hexTable[v&15];}return textDecoder.decode(dst);}const osType=(()=>{const{Deno:Deno1}=globalThis;if(typeof Deno1?.build?.os==="string"){return Deno1.build.os;}const{navigator}=globalThis;if(navigator?.appVersion?.includes?.("Win")){return"windows";}return"linux";})();const isWindows=osType==="windows";function assertPath(path){if(typeof path!=="string"){throw new TypeError(`Path must be a string. Received ${JSON.stringify(path)}`);}}function assertArg(path){assertPath(path);if(path.length===0)return".";}const CHAR_FORWARD_SLASH=47;function normalizeString(path,allowAboveRoot,separator,isPathSeparator){let res="";let lastSegmentLength=0;let lastSlash=-1;let dots=0;let code;for(let i=0,len=path.length;i<=len;++i){if(i2){const lastSlashIndex=res.lastIndexOf(separator);if(lastSlashIndex===-1){res="";lastSegmentLength=0;}else{res=res.slice(0,lastSlashIndex);lastSegmentLength=res.length-1-res.lastIndexOf(separator);}lastSlash=i;dots=0;continue;}else if(res.length===2||res.length===1){res="";lastSegmentLength=0;lastSlash=i;dots=0;continue;}}if(allowAboveRoot){if(res.length>0)res+=`${separator}..`;else res="..";lastSegmentLength=2;}}else{if(res.length>0)res+=separator+path.slice(lastSlash+1,i);else res=path.slice(lastSlash+1,i);lastSegmentLength=i-lastSlash-1;}lastSlash=i;dots=0;}else if(code===46&&dots!==-1){++dots;}else{dots=-1;}}return res;}function isPosixPathSeparator(code){return code===47;}function normalize(path){assertArg(path);const isAbsolute=isPosixPathSeparator(path.charCodeAt(0));const trailingSeparator=isPosixPathSeparator(path.charCodeAt(path.length-1));path=normalizeString(path,!isAbsolute,"/",isPosixPathSeparator);if(path.length===0&&!isAbsolute)path=".";if(path.length>0&&trailingSeparator)path+="/";if(isAbsolute)return`/${path}`;return path;}function join(...paths){if(paths.length===0)return".";let joined;for(let i=0,len=paths.length;i0){if(!joined)joined=path;else joined+=`/${path}`;}}if(!joined)return".";return normalize(joined);}function isPathSeparator(code){return code===47||code===92;}function isWindowsDeviceRoot(code){return code>=97&&code<=122||code>=65&&code<=90;}function normalize1(path){assertArg(path);const len=path.length;let rootEnd=0;let device;let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){return"\\";}let tail;if(rootEnd0&&isPathSeparator(path.charCodeAt(len-1))){tail+="\\";}if(device===undefined){if(isAbsolute){if(tail.length>0)return`\\${tail}`;else return"\\";}else if(tail.length>0){return tail;}else{return"";}}else if(isAbsolute){if(tail.length>0)return`${device}\\${tail}`;else return`${device}\\`;}else if(tail.length>0){return device+tail;}else{return device;}}function join1(...paths){if(paths.length===0)return".";let joined;let firstPart=null;for(let i=0;i0){if(joined===undefined)joined=firstPart=path;else joined+=`\\${path}`;}}if(joined===undefined)return".";let needsReplace=true;let slashCount=0;assert(firstPart!==null);if(isPathSeparator(firstPart.charCodeAt(0))){++slashCount;const firstLen=firstPart.length;if(firstLen>1){if(isPathSeparator(firstPart.charCodeAt(1))){++slashCount;if(firstLen>2){if(isPathSeparator(firstPart.charCodeAt(2)))++slashCount;else{needsReplace=false;}}}}}if(needsReplace){for(;slashCount=2)joined=`\\${joined.slice(slashCount)}`;}return normalize1(joined);}function join2(...paths){return isWindows?join1(...paths):join(...paths);}function assertArg1(url){url=url instanceof URL?url:new URL(url);if(url.protocol!=="file:"){throw new TypeError("Must be a file URL.");}return url;}function fromFileUrl(url){url=assertArg1(url);return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"));}function fromFileUrl1(url){url=assertArg1(url);let path=decodeURIComponent(url.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");if(url.hostname!==""){path=`\\\\${url.hostname}${path}`;}return path;}function fromFileUrl2(url){return isWindows?fromFileUrl1(url):fromFileUrl(url);}function toPathString(pathUrl){return pathUrl instanceof URL?fromFileUrl2(pathUrl):pathUrl;}function stripTrailingSeparators(segment,isSep){if(segment.length<=1){return segment;}let end=segment.length;for(let i=segment.length-1;i>0;i--){if(isSep(segment.charCodeAt(i))){end=i;}else{break;}}return segment.slice(0,end);}function resolve(...pathSegments){let resolvedPath="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1&&!resolvedAbsolute;i--){let path;if(i>=0)path=pathSegments[i];else{const{Deno:Deno1}=globalThis;if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();}assertPath(path);if(path.length===0){continue;}resolvedPath=`${path}/${resolvedPath}`;resolvedAbsolute=isPosixPathSeparator(path.charCodeAt(0));}resolvedPath=normalizeString(resolvedPath,!resolvedAbsolute,"/",isPosixPathSeparator);if(resolvedAbsolute){if(resolvedPath.length>0)return`/${resolvedPath}`;else return"/";}else if(resolvedPath.length>0)return resolvedPath;else return".";}function resolve1(...pathSegments){let resolvedDevice="";let resolvedTail="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1;i--){let path;const{Deno:Deno1}=globalThis;if(i>=0){path=pathSegments[i];}else if(!resolvedDevice){if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a drive-letter-less path without a CWD.");}path=Deno1.cwd();}else{if(typeof Deno1?.env?.get!=="function"||typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();if(path===undefined||path.slice(0,3).toLowerCase()!==`${resolvedDevice.toLowerCase()}\\`){path=`${resolvedDevice}\\`;}}assertPath(path);const len=path.length;if(len===0)continue;let rootEnd=0;let device="";let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){rootEnd=1;isAbsolute=true;}if(device.length>0&&resolvedDevice.length>0&&device.toLowerCase()!==resolvedDevice.toLowerCase()){continue;}if(resolvedDevice.length===0&&device.length>0){resolvedDevice=device;}if(!resolvedAbsolute){resolvedTail=`${path.slice(rootEnd)}\\${resolvedTail}`;resolvedAbsolute=isAbsolute;}if(resolvedAbsolute&&resolvedDevice.length>0)break;}resolvedTail=normalizeString(resolvedTail,!resolvedAbsolute,"\\",isPathSeparator);return resolvedDevice+(resolvedAbsolute?"\\":"")+resolvedTail||".";}Deno.build.os==="windows";async function exists(path,options){try{const stat=await Deno.stat(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if((await Deno.permissions.query({name:"read",path})).state==="granted"){return!options?.isReadable;}}throw error;}}function existsSync(path,options){try{const stat=Deno.statSync(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if(Deno.permissions.querySync({name:"read",path}).state==="granted"){return!options?.isReadable;}}throw error;}}function normalize2(path){return isWindows?normalize1(path):normalize(path);}function stripSuffix(name,suffix){if(suffix.length>=name.length){return name;}const lenDiff=name.length-suffix.length;for(let i=suffix.length-1;i>=0;--i){if(name.charCodeAt(lenDiff+i)!==suffix.charCodeAt(i)){return name;}}return name.slice(0,-suffix.length);}function lastPathSegment(path,isSep,start=0){let matchedNonSeparator=false;let end=path.length;for(let i=path.length-1;i>=start;--i){if(isSep(path.charCodeAt(i))){if(matchedNonSeparator){start=i+1;break;}}else if(!matchedNonSeparator){matchedNonSeparator=true;end=i+1;}}return path.slice(start,end);}function assertArgs(path,suffix){assertPath(path);if(path.length===0)return path;if(typeof suffix!=="string"){throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);}}function basename(path,suffix=""){assertArgs(path,suffix);const lastSegment=lastPathSegment(path,isPosixPathSeparator);const strippedSegment=stripTrailingSeparators(lastSegment,isPosixPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename1(path,suffix=""){assertArgs(path,suffix);let start=0;if(path.length>=2){const drive=path.charCodeAt(0);if(isWindowsDeviceRoot(drive)){if(path.charCodeAt(1)===58)start=2;}}const lastSegment=lastPathSegment(path,isPathSeparator,start);const strippedSegment=stripTrailingSeparators(lastSegment,isPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename2(path,suffix=""){return isWindows?basename1(path,suffix):basename(path,suffix);}async function createWalkEntry(path){path=toPathString(path);path=normalize2(path);const name=basename2(path);const info=await Deno.stat(path);return{path,name,isFile:info.isFile,isDirectory:info.isDirectory,isSymlink:info.isSymlink};}class WalkError extends Error{root;constructor(cause,root){super(`${cause instanceof Error?cause.message:cause} for path "${root}"`);this.cause=cause;this.name="WalkError";this.root=root;}}function include(path,exts,match,skip){if(exts&&!exts.some(ext=>path.endsWith(ext))){return false;}if(match&&!match.some(pattern=>!!path.match(pattern))){return false;}if(skip&&skip.some(pattern=>!!path.match(pattern))){return false;}return true;}function wrapErrorWithPath(err,root){if(err instanceof WalkError)return err;return new WalkError(err,root);}async function*walk(root,{maxDepth=Infinity,includeFiles=true,includeDirs=true,includeSymlinks=true,followSymlinks=false,canonicalize=true,exts=undefined,match=undefined,skip=undefined}={}){if(maxDepth<0){return;}root=toPathString(root);if(includeDirs&&include(root,exts,match,skip)){yield await createWalkEntry(root);}if(maxDepth<1||!include(root,undefined,undefined,skip)){return;}try{for await(const entry of Deno.readDir(root)){let path=join2(root,entry.name);let{isSymlink,isDirectory}=entry;if(isSymlink){if(!followSymlinks){if(includeSymlinks&&include(path,exts,match,skip)){yield{path,...entry};}continue;}const realPath=await Deno.realPath(path);if(canonicalize){path=realPath;}({isSymlink,isDirectory}=await Deno.lstat(realPath));}if(isSymlink||isDirectory){yield*walk(path,{maxDepth:maxDepth-1,includeFiles,includeDirs,includeSymlinks,followSymlinks,exts,match,skip});}else if(includeFiles&&include(path,exts,match,skip)){yield{path,...entry};}}}catch(err){throw wrapErrorWithPath(err,normalize2(root));}}Deno.build.os==="windows";new Deno.errors.AlreadyExists("dest already exists.");Deno.build.os==="windows";const LF="\n";const CRLF="\r\n";Deno?.build.os==="windows"?CRLF:LF;function parse(text,{allowTrailingComma=true}={}){if(new.target){throw new TypeError("parse is not a constructor");}return new JSONCParser(text,{allowTrailingComma}).parse();}const originalJSONParse=globalThis.JSON.parse;class JSONCParser{#whitespace=new Set(" \r\n");#numberEndToken=new Set([..."[]{}:,/",...this.#whitespace]);#text;#length;#tokenized;#options;constructor(text,options){this.#text=`${text}`;this.#length=this.#text.length;this.#tokenized=this.#tokenize();this.#options=options;}parse(){const token=this.#getNext();const res=this.#parseJsonValue(token);const{done,value}=this.#tokenized.next();if(!done){throw new SyntaxError(buildErrorMessage(value));}return res;}#getNext(){const{done,value}=this.#tokenized.next();if(done){throw new SyntaxError("Unexpected end of JSONC input");}return value;}*#tokenize(){for(let i=0;iisNaN(Number(key)));const byLevel={[LogLevels.NOTSET]:"NOTSET",[LogLevels.DEBUG]:"DEBUG",[LogLevels.INFO]:"INFO",[LogLevels.WARNING]:"WARNING",[LogLevels.ERROR]:"ERROR",[LogLevels.CRITICAL]:"CRITICAL"};function getLevelByName(name){const level=LogLevels[name];if(level!==undefined){return level;}throw new Error(`no log level found for name: ${name}`);}function getLevelName(level){const levelName=byLevel[level];if(levelName){return levelName;}throw new Error(`no level name found for level: ${level}`);}class LogRecord{msg;#args;#datetime;level;levelName;loggerName;constructor(options){this.msg=options.msg;this.#args=[...options.args];this.level=options.level;this.loggerName=options.loggerName;this.#datetime=new Date;this.levelName=getLevelName(options.level);}get args(){return[...this.#args];}get datetime(){return new Date(this.#datetime.getTime());}}class Logger{#level;#handlers;#loggerName;constructor(loggerName,levelName,options={}){this.#loggerName=loggerName;this.#level=getLevelByName(levelName);this.#handlers=options.handlers||[];}get level(){return this.#level;}set level(level){try{this.#level=getLevelByName(getLevelName(level));}catch(_){throw new TypeError(`Invalid log level: ${level}`);}}get levelName(){return getLevelName(this.#level);}set levelName(levelName){this.#level=getLevelByName(levelName);}get loggerName(){return this.#loggerName;}set handlers(hndls){this.#handlers=hndls;}get handlers(){return this.#handlers;}#_log(level,msg,...args){if(this.level>level){return msg instanceof Function?undefined:msg;}let fnResult;let logMessage;if(msg instanceof Function){fnResult=msg();logMessage=this.asString(fnResult);}else{logMessage=this.asString(msg);}const record=new LogRecord({msg:logMessage,args:args,level:level,loggerName:this.loggerName});this.#handlers.forEach(handler=>{handler.handle(record);});return msg instanceof Function?fnResult:msg;}asString(data,isProperty=false){if(typeof data==="string"){if(isProperty)return`"${data}"`;return data;}else if(data===null||typeof data==="number"||typeof data==="bigint"||typeof data==="boolean"||typeof data==="undefined"||typeof data==="symbol"){return String(data);}else if(data instanceof Error){return data.stack;}else if(typeof data==="object"){return`{${Object.entries(data).map(([k,v])=>`"${k}":${this.asString(v,true)}`).join(",")}}`;}return"undefined";}debug(msg,...args){return this.#_log(LogLevels.DEBUG,msg,...args);}info(msg,...args){return this.#_log(LogLevels.INFO,msg,...args);}warning(msg,...args){return this.#_log(LogLevels.WARNING,msg,...args);}error(msg,...args){return this.#_log(LogLevels.ERROR,msg,...args);}critical(msg,...args){return this.#_log(LogLevels.CRITICAL,msg,...args);}}const{Deno:Deno1}=globalThis;const noColor=typeof Deno1?.noColor==="boolean"?Deno1.noColor:false;let enabled=!noColor;function code(open,close){return{open:`\x1b[${open.join(";")}m`,close:`\x1b[${close}m`,regexp:new RegExp(`\\x1b\\[${close}m`,"g")};}function run(str,code){return enabled?`${code.open}${str.replace(code.regexp,code.open)}${code.close}`:str;}function bold(str){return run(str,code([1],22));}function red(str){return run(str,code([31],39));}function yellow(str){return run(str,code([33],39));}function blue(str){return run(str,code([34],39));}new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"),"g");function copy(src,dst,off=0){off=Math.max(0,Math.min(off,dst.byteLength));const dstBytesAvailable=dst.byteLength-off;if(src.byteLength>dstBytesAvailable){src=src.subarray(0,dstBytesAvailable);}dst.set(src,off);return src.byteLength;}class AbstractBufBase{buf;usedBufferBytes=0;err=null;constructor(buf){this.buf=buf;}size(){return this.buf.byteLength;}available(){return this.buf.byteLength-this.usedBufferBytes;}buffered(){return this.usedBufferBytes;}}class BufWriterSync extends AbstractBufBase{#writer;static create(writer,size=4096){return writer instanceof BufWriterSync?writer:new BufWriterSync(writer,size);}constructor(writer,size=4096){super(new Uint8Array(size<=0?4096:size));this.#writer=writer;}reset(w){this.err=null;this.usedBufferBytes=0;this.#writer=w;}flush(){if(this.err!==null)throw this.err;if(this.usedBufferBytes===0)return;try{const p=this.buf.subarray(0,this.usedBufferBytes);let nwritten=0;while(nwrittenthis.available()){if(this.buffered()===0){try{numBytesWritten=this.#writer.writeSync(data);}catch(e){if(e instanceof Error){this.err=e;}throw e;}}else{numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;this.flush();}totalBytesWritten+=numBytesWritten;data=data.subarray(numBytesWritten);}numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;totalBytesWritten+=numBytesWritten;return totalBytesWritten;}}const DEFAULT_FORMATTER="{levelName} {msg}";class BaseHandler{level;levelName;formatter;constructor(levelName,options={}){this.level=getLevelByName(levelName);this.levelName=levelName;this.formatter=options.formatter||DEFAULT_FORMATTER;}handle(logRecord){if(this.level>logRecord.level)return;const msg=this.format(logRecord);this.log(msg);}format(logRecord){if(this.formatter instanceof Function){return this.formatter(logRecord);}return this.formatter.replace(/{([^\s}]+)}/g,(match,p1)=>{const value=logRecord[p1];if(value===undefined){return match;}return String(value);});}log(_msg){}setup(){}destroy(){}}class ConsoleHandler extends BaseHandler{#useColors;constructor(levelName,options={}){super(levelName,options);this.#useColors=options.useColors??true;}format(logRecord){let msg=super.format(logRecord);if(this.#useColors){msg=this.applyColors(msg,logRecord.level);}return msg;}applyColors(msg,level){switch(level){case LogLevels.INFO:msg=blue(msg);break;case LogLevels.WARNING:msg=yellow(msg);break;case LogLevels.ERROR:msg=red(msg);break;case LogLevels.CRITICAL:msg=bold(red(msg));break;default:break;}return msg;}log(msg){console.log(msg);}}class WriterHandler extends BaseHandler{_writer;#encoder=new TextEncoder;}class FileHandler extends WriterHandler{_file;_buf;_filename;_mode;_openOptions;_encoder=new TextEncoder;#unloadCallback=(()=>{this.destroy();}).bind(this);constructor(levelName,options){super(levelName,options);this._filename=options.filename;this._mode=options.mode?options.mode:"a";this._openOptions={createNew:this._mode==="x",create:this._mode!=="x",append:this._mode==="a",truncate:this._mode!=="a",write:true};}setup(){this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);addEventListener("unload",this.#unloadCallback);}handle(logRecord){super.handle(logRecord);if(logRecord.level>LogLevels.ERROR){this.flush();}}log(msg){if(this._encoder.encode(msg).byteLength+1>this._buf.available()){this.flush();}this._buf.writeSync(this._encoder.encode(msg+"\n"));}flush(){if(this._buf?.buffered()>0){this._buf.flush();}}destroy(){this.flush();this._file?.close();this._file=undefined;removeEventListener("unload",this.#unloadCallback);}}class RotatingFileHandler extends FileHandler{#maxBytes;#maxBackupCount;#currentFileSize=0;constructor(levelName,options){super(levelName,options);this.#maxBytes=options.maxBytes;this.#maxBackupCount=options.maxBackupCount;}setup(){if(this.#maxBytes<1){this.destroy();throw new Error("maxBytes cannot be less than 1");}if(this.#maxBackupCount<1){this.destroy();throw new Error("maxBackupCount cannot be less than 1");}super.setup();if(this._mode==="w"){for(let i=1;i<=this.#maxBackupCount;i++){try{Deno.removeSync(this._filename+"."+i);}catch(error){if(!(error instanceof Deno.errors.NotFound)){throw error;}}}}else if(this._mode==="x"){for(let i=1;i<=this.#maxBackupCount;i++){if(existsSync(this._filename+"."+i)){this.destroy();throw new Deno.errors.AlreadyExists("Backup log file "+this._filename+"."+i+" already exists");}}}else{this.#currentFileSize=Deno.statSync(this._filename).size;}}log(msg){const msgByteLength=this._encoder.encode(msg).byteLength+1;if(this.#currentFileSize+msgByteLength>this.#maxBytes){this.rotateLogFiles();this.#currentFileSize=0;}super.log(msg);this.#currentFileSize+=msgByteLength;}rotateLogFiles(){this._buf.flush();this._file.close();for(let i=this.#maxBackupCount-1;i>=0;i--){const source=this._filename+(i===0?"":"."+i);const dest=this._filename+"."+(i+1);if(existsSync(source)){Deno.renameSync(source,dest);}}this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);}}const DEFAULT_LEVEL="INFO";const DEFAULT_CONFIG={handlers:{default:new ConsoleHandler(DEFAULT_LEVEL)},loggers:{default:{level:DEFAULT_LEVEL,handlers:["default"]}}};const state={handlers:new Map,loggers:new Map,config:DEFAULT_CONFIG};const handlers={BaseHandler,ConsoleHandler,WriterHandler,FileHandler,RotatingFileHandler};function getLogger(name){if(!name){const d=state.loggers.get("default");assert(d!==undefined,`"default" logger must be set for getting logger without name`);return d;}const result=state.loggers.get(name);if(!result){const logger=new Logger(name,"NOTSET",{handlers:[]});state.loggers.set(name,logger);return logger;}return result;}function debug(msg,...args){if(msg instanceof Function){return getLogger("default").debug(msg,...args);}return getLogger("default").debug(msg,...args);}function info(msg,...args){if(msg instanceof Function){return getLogger("default").info(msg,...args);}return getLogger("default").info(msg,...args);}function warning(msg,...args){if(msg instanceof Function){return getLogger("default").warning(msg,...args);}return getLogger("default").warning(msg,...args);}function error(msg,...args){if(msg instanceof Function){return getLogger("default").error(msg,...args);}return getLogger("default").error(msg,...args);}function setup(config){state.config={handlers:{...DEFAULT_CONFIG.handlers,...config.handlers},loggers:{...DEFAULT_CONFIG.loggers,...config.loggers}};state.handlers.forEach(handler=>{handler.destroy();});state.handlers.clear();const handlers=state.config.handlers||{};for(const handlerName in handlers){const handler=handlers[handlerName];handler.setup();state.handlers.set(handlerName,handler);}state.loggers.clear();const loggers=state.config.loggers||{};for(const loggerName in loggers){const loggerConfig=loggers[loggerName];const handlerNames=loggerConfig.handlers||[];const handlers=[];handlerNames.forEach(handlerName=>{const handler=state.handlers.get(handlerName);if(handler){handlers.push(handler);}});const levelName=loggerConfig.level||DEFAULT_LEVEL;const logger=new Logger(loggerName,levelName,{handlers:handlers});state.loggers.set(loggerName,logger);}}setup(DEFAULT_CONFIG);function assertArgs1(from,to){assertPath(from);assertPath(to);if(from===to)return"";}function relative(from,to){assertArgs1(from,to);from=resolve(from);to=resolve(to);if(from===to)return"";let fromStart=1;const fromEnd=from.length;for(;fromStartlength){if(isPosixPathSeparator(to.charCodeAt(toStart+i))){return to.slice(toStart+i+1);}else if(i===0){return to.slice(toStart+i);}}else if(fromLen>length){if(isPosixPathSeparator(from.charCodeAt(fromStart+i))){lastCommonSep=i;}else if(i===0){lastCommonSep=0;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(isPosixPathSeparator(fromCode))lastCommonSep=i;}let out="";for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||isPosixPathSeparator(from.charCodeAt(i))){if(out.length===0)out+="..";else out+="/..";}}if(out.length>0)return out+to.slice(toStart+lastCommonSep);else{toStart+=lastCommonSep;if(isPosixPathSeparator(to.charCodeAt(toStart)))++toStart;return to.slice(toStart);}}function relative1(from,to){assertArgs1(from,to);const fromOrig=resolve1(from);const toOrig=resolve1(to);if(fromOrig===toOrig)return"";from=fromOrig.toLowerCase();to=toOrig.toLowerCase();if(from===to)return"";let fromStart=0;let fromEnd=from.length;for(;fromStartfromStart;--fromEnd){if(from.charCodeAt(fromEnd-1)!==92)break;}const fromLen=fromEnd-fromStart;let toStart=0;let toEnd=to.length;for(;toStarttoStart;--toEnd){if(to.charCodeAt(toEnd-1)!==92)break;}const toLen=toEnd-toStart;const length=fromLenlength){if(to.charCodeAt(toStart+i)===92){return toOrig.slice(toStart+i+1);}else if(i===2){return toOrig.slice(toStart+i);}}if(fromLen>length){if(from.charCodeAt(fromStart+i)===92){lastCommonSep=i;}else if(i===2){lastCommonSep=3;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(fromCode===92)lastCommonSep=i;}if(i!==length&&lastCommonSep===-1){return toOrig;}let out="";if(lastCommonSep===-1)lastCommonSep=0;for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||from.charCodeAt(i)===92){if(out.length===0)out+="..";else out+="\\..";}}if(out.length>0){return out+toOrig.slice(toStart+lastCommonSep,toEnd);}else{toStart+=lastCommonSep;if(toOrig.charCodeAt(toStart)===92)++toStart;return toOrig.slice(toStart,toEnd);}}function relative2(from,to){return isWindows?relative1(from,to):relative(from,to);}var m=Object.create;var E=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),D=(t,e)=>{for(var s in e)E(t,s,{get:e[s],enumerable:!0});},a=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!b.call(t,n)&&n!==s&&E(t,n,{get:()=>e[n],enumerable:!(r=T(e,n))||r.enumerable});return t;},_=(t,e,s)=>(a(t,e,"default"),s&&a(s,e,"default")),$=(t,e,s)=>(s=t!=null?m(X(t)):{},a(e||!t||!t.__esModule?E(s,"default",{value:t,enumerable:!0}):s,t));var A=w((ct,v)=>{function C(t){return Array.isArray(t)?t:[t];}var N="",P=" ",h="\\",H=/^\s+$/,F=/(?:[^\\]|^)\\$/,k=/^\\!/,z=/^\\#/,B=/\r?\n/g,K=/^\.*\/|^\.+$/,d="/",x="node-ignore";typeof Symbol<"u"&&(x=Symbol.for("node-ignore"));var L=x,V=(t,e,s)=>Object.defineProperty(t,e,{value:s}),j=/([0-z])-([0-z])/g,G=()=>!1,M=t=>t.replace(j,(e,s,r)=>s.charCodeAt(0)<=r.charCodeAt(0)?e:N),Y=t=>{let{length:e}=t;return t.slice(0,e-e%2);},W=[[/\\?\s+$/,t=>t.indexOf("\\")===0?P:N],[/\\\s/g,()=>P],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)";}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,s)=>e+6{let r=s.replace(/\\\*/g,"[^\\/]*");return e+r;}],[/\\\\\\(?=[$.|*+(){^])/g,()=>h],[/\\\\/g,()=>h],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,s,r,n)=>e===h?`\\[${s}${Y(r)}${n}`:n==="]"&&r.length%2===0?`[${M(s)}${r}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],S=Object.create(null),p=(t,e)=>{let s=S[t];return s||(s=W.reduce((r,n)=>r.replace(n[0],n[1].bind(t)),t),S[t]=s),e?new RegExp(s,"i"):new RegExp(s);},R=t=>typeof t=="string",q=t=>t&&R(t)&&!H.test(t)&&!F.test(t)&&t.indexOf("#")!==0,J=t=>t.split(B),f=class{constructor(e,s,r,n){this.origin=e,this.pattern=s,this.negative=r,this.regex=n;}},Q=(t,e)=>{let s=t,r=!1;t.indexOf("!")===0&&(r=!0,t=t.substr(1)),t=t.replace(k,"!").replace(z,"#");let n=p(t,e);return new f(s,t,r,n);},U=(t,e)=>{throw new e(t);},i=(t,e,s)=>R(t)?t?i.isNotRelative(t)?s(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:s("path must not be empty",TypeError):s(`path must be a string, but got \`${e}\``,TypeError),O=t=>K.test(t);i.isNotRelative=O;i.convert=t=>t;var g=class{constructor({ignorecase:e=!0,ignoreCase:s=e,allowRelativePaths:r=!1}={}){V(this,L,!0),this._rules=[],this._ignoreCase=s,this._allowRelativePaths=r,this._initCache();}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null);}_addPattern(e){if(e&&e[L]){this._rules=this._rules.concat(e._rules),this._added=!0;return;}if(q(e)){let s=Q(e,this._ignoreCase);this._added=!0,this._rules.push(s);}}add(e){return this._added=!1,C(R(e)?J(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this;}addPattern(e){return this.add(e);}_testOne(e,s){let r=!1,n=!1;return this._rules.forEach(o=>{let{negative:u}=o;if(n===u&&r!==n||u&&!r&&!n&&!s)return;o.regex.test(e)&&(r=!u,n=u);}),{ignored:r,unignored:n};}_test(e,s,r,n){let o=e&&i.convert(e);return i(o,e,this._allowRelativePaths?G:U),this._t(o,s,r,n);}_t(e,s,r,n){if(e in s)return s[e];if(n||(n=e.split(d)),n.pop(),!n.length)return s[e]=this._testOne(e,r);let o=this._t(n.join(d)+d,s,r,n);return s[e]=o.ignored?o:this._testOne(e,r);}ignores(e){return this._test(e,this._ignoreCache,!1).ignored;}createFilter(){return e=>!this.ignores(e);}filter(e){return C(e).filter(this.createFilter());}test(e){return this._test(e,this._testCache,!0);}},l=t=>new g(t),Z=t=>i(t&&i.convert(t),t,G);l.isPathValid=Z;l.default=l;v.exports=l;var tt=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");i.convert=tt;var et=/^[a-z]:\//i;i.isNotRelative=t=>et.test(t)||O(t);});var c={};D(c,{default:()=>nt});var st=$(A());_(c,$(A()));var{default:I,...rt}=st,nt=I!==void 0?I:rt;const importMeta={url:"file:///Users/winston/Code/winston/setup-deno/cache.ts",main:import.meta.main};if(importMeta.main){const args=parseArgs(Deno.args,{boolean:["dry-run","verbose","lock-write"],negatable:["lock-write"],string:["config"],default:{"lock-write":true},alias:{"dry-run":"n",verbose:"v"},"--":true,unknown:arg=>{console.log(`Unknown argument: ${arg}`);console.log("Usage: cache [-n | --dry-run] [-v | --verbose] [--] [DENO_ARGS...]");Deno.exit(0);}});const denoDir=Deno.env.get("DENO_DIR");const logLevel=["1","true"].includes(Deno.env.get("CI")??"")?"DEBUG":args.verbose?"DEBUG":"INFO";setup({handlers:{console:new handlers.ConsoleHandler(logLevel,{formatter:logRecord=>Deno.noColor?logRecord.levelName+" "+logRecord.msg:logRecord.msg})},loggers:{default:{handlers:["console"],"level":logLevel}}});if(args["dry-run"])warning("dry-run mode enabled");if(args.config&&!await exists(args.config)){error(`config file ${args.config} not found`);Deno.exit(1);}const hash=await Deno.readFile("./deno.lock").then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>encodeHex(new Uint8Array(data))).catch(_=>"");debug(`GitHub actions deno.lock hash: ${hash}`);const cfgs=args.config?[args.config]:["deno.json","deno.jsonc"];const denoCfg=await Promise.all(cfgs.map(path=>Deno.readTextFile(path).catch(_=>undefined))).then(v=>parse(v.filter(Boolean)[0]??"{}"));const patterns=[...[denoCfg?.exclude??[]].flat(),...[denoCfg?.cache?.exclude??[]].flat(),...[denoCfg?.cache?.include??[]].flatMap(p=>`!${p}`)];debug(`patterns:`,patterns);patterns.forEach(p=>debug(`- ${p}`));const ig=nt().add(patterns);const walkIterator=walk(".",{exts:["js",".jsx",".ts",".tsx"],includeDirs:false});const paths=[];for await(const entry of walkIterator){const relativePath=relative2(".",entry.path);if(denoDir&&entry.path.startsWith(denoDir))continue;if(ig.ignores(relativePath)){debug(`ignored ${relativePath}`);continue;}debug(`caching ${relativePath}`);paths.push(relativePath);}const denoArgs=["cache",args["lock-write"]&&"--lock-write",args.config&&`--config=${args.config}`,...args["--"],...paths].filter(Boolean);const cmd=new Deno.Command(Deno.execPath(),{args:denoArgs});const cmdString=Deno.execPath()+" "+denoArgs.join(" ");if(args["dry-run"]){info(`would run: ${cmdString}`);Deno.exit(0);}debug(`running: ${cmdString}`);const{stderr,code}=await cmd.output();for(const line of new TextDecoder().decode(stderr).split("\n")){if(line.length>0)info("deno> "+line);}if(code===0)debug(`finished caching ${paths.length} files`);} \ No newline at end of file +class AssertionError extends Error{constructor(message){super(message);this.name="AssertionError";}}function assert(expr,msg=""){if(!expr){throw new AssertionError(msg);}}const{hasOwn}=Object;function get(obj,key){if(hasOwn(obj,key)){return obj[key];}}function getForce(obj,key){const v=get(obj,key);assert(v!==undefined);return v;}function isNumber(x){if(typeof x==="number")return true;if(/^0x[0-9a-f]+$/i.test(String(x)))return true;return/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(String(x));}function hasKey(obj,keys){let o=obj;keys.slice(0,-1).forEach(key=>{o=get(o,key)??{};});const key=keys[keys.length-1];return hasOwn(o,key);}function parseArgs(args,{"--":doubleDash=false,alias={},boolean:__boolean=false,default:defaults={},stopEarly=false,string=[],collect=[],negatable=[],unknown=i=>i}={}){const aliases={};const flags={bools:{},strings:{},unknownFn:unknown,allBools:false,collect:{},negatable:{}};if(alias!==undefined){for(const key in alias){const val=getForce(alias,key);if(typeof val==="string"){aliases[key]=[val];}else{aliases[key]=val;}for(const alias of getForce(aliases,key)){aliases[alias]=[key].concat(aliases[key].filter(y=>alias!==y));}}}if(__boolean!==undefined){if(typeof __boolean==="boolean"){flags.allBools=!!__boolean;}else{const booleanArgs=typeof __boolean==="string"?[__boolean]:__boolean;for(const key of booleanArgs.filter(Boolean)){flags.bools[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.bools[al]=true;}}}}}if(string!==undefined){const stringArgs=typeof string==="string"?[string]:string;for(const key of stringArgs.filter(Boolean)){flags.strings[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.strings[al]=true;}}}}if(collect!==undefined){const collectArgs=typeof collect==="string"?[collect]:collect;for(const key of collectArgs.filter(Boolean)){flags.collect[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.collect[al]=true;}}}}if(negatable!==undefined){const negatableArgs=typeof negatable==="string"?[negatable]:negatable;for(const key of negatableArgs.filter(Boolean)){flags.negatable[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.negatable[al]=true;}}}}const argv={_:[]};function argDefined(key,arg){return flags.allBools&&/^--[^=]+$/.test(arg)||get(flags.bools,key)||!!get(flags.strings,key)||!!get(aliases,key);}function setKey(obj,name,value,collect=true){let o=obj;const keys=name.split(".");keys.slice(0,-1).forEach(function(key){if(get(o,key)===undefined){o[key]={};}o=get(o,key);});const key=keys[keys.length-1];const collectable=collect&&!!get(flags.collect,name);if(!collectable){o[key]=value;}else if(get(o,key)===undefined){o[key]=[value];}else if(Array.isArray(get(o,key))){o[key].push(value);}else{o[key]=[get(o,key),value];}}function setArg(key,val,arg=undefined,collect){if(arg&&flags.unknownFn&&!argDefined(key,arg)){if(flags.unknownFn(arg,key,val)===false)return;}const value=!get(flags.strings,key)&&isNumber(val)?Number(val):val;setKey(argv,key,value,collect);const alias=get(aliases,key);if(alias){for(const x of alias){setKey(argv,x,value,collect);}}}function aliasIsBoolean(key){return getForce(aliases,key).some(x=>typeof get(flags.bools,x)==="boolean");}let notFlags=[];if(args.includes("--")){notFlags=args.slice(args.indexOf("--")+1);args=args.slice(0,args.indexOf("--"));}for(let i=0;i>4];dst[i*2+1]=hexTable[v&15];}return textDecoder.decode(dst);}const osType=(()=>{const{Deno:Deno1}=globalThis;if(typeof Deno1?.build?.os==="string"){return Deno1.build.os;}const{navigator}=globalThis;if(navigator?.appVersion?.includes?.("Win")){return"windows";}return"linux";})();const isWindows=osType==="windows";function assertPath(path){if(typeof path!=="string"){throw new TypeError(`Path must be a string. Received ${JSON.stringify(path)}`);}}function assertArg(path){assertPath(path);if(path.length===0)return".";}const CHAR_FORWARD_SLASH=47;function normalizeString(path,allowAboveRoot,separator,isPathSeparator){let res="";let lastSegmentLength=0;let lastSlash=-1;let dots=0;let code;for(let i=0,len=path.length;i<=len;++i){if(i2){const lastSlashIndex=res.lastIndexOf(separator);if(lastSlashIndex===-1){res="";lastSegmentLength=0;}else{res=res.slice(0,lastSlashIndex);lastSegmentLength=res.length-1-res.lastIndexOf(separator);}lastSlash=i;dots=0;continue;}else if(res.length===2||res.length===1){res="";lastSegmentLength=0;lastSlash=i;dots=0;continue;}}if(allowAboveRoot){if(res.length>0)res+=`${separator}..`;else res="..";lastSegmentLength=2;}}else{if(res.length>0)res+=separator+path.slice(lastSlash+1,i);else res=path.slice(lastSlash+1,i);lastSegmentLength=i-lastSlash-1;}lastSlash=i;dots=0;}else if(code===46&&dots!==-1){++dots;}else{dots=-1;}}return res;}function isPosixPathSeparator(code){return code===47;}function normalize(path){assertArg(path);const isAbsolute=isPosixPathSeparator(path.charCodeAt(0));const trailingSeparator=isPosixPathSeparator(path.charCodeAt(path.length-1));path=normalizeString(path,!isAbsolute,"/",isPosixPathSeparator);if(path.length===0&&!isAbsolute)path=".";if(path.length>0&&trailingSeparator)path+="/";if(isAbsolute)return`/${path}`;return path;}function join(...paths){if(paths.length===0)return".";let joined;for(let i=0,len=paths.length;i0){if(!joined)joined=path;else joined+=`/${path}`;}}if(!joined)return".";return normalize(joined);}function isPathSeparator(code){return code===47||code===92;}function isWindowsDeviceRoot(code){return code>=97&&code<=122||code>=65&&code<=90;}function normalize1(path){assertArg(path);const len=path.length;let rootEnd=0;let device;let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){return"\\";}let tail;if(rootEnd0&&isPathSeparator(path.charCodeAt(len-1))){tail+="\\";}if(device===undefined){if(isAbsolute){if(tail.length>0)return`\\${tail}`;else return"\\";}else if(tail.length>0){return tail;}else{return"";}}else if(isAbsolute){if(tail.length>0)return`${device}\\${tail}`;else return`${device}\\`;}else if(tail.length>0){return device+tail;}else{return device;}}function join1(...paths){if(paths.length===0)return".";let joined;let firstPart=null;for(let i=0;i0){if(joined===undefined)joined=firstPart=path;else joined+=`\\${path}`;}}if(joined===undefined)return".";let needsReplace=true;let slashCount=0;assert(firstPart!==null);if(isPathSeparator(firstPart.charCodeAt(0))){++slashCount;const firstLen=firstPart.length;if(firstLen>1){if(isPathSeparator(firstPart.charCodeAt(1))){++slashCount;if(firstLen>2){if(isPathSeparator(firstPart.charCodeAt(2)))++slashCount;else{needsReplace=false;}}}}}if(needsReplace){for(;slashCount=2)joined=`\\${joined.slice(slashCount)}`;}return normalize1(joined);}function join2(...paths){return isWindows?join1(...paths):join(...paths);}function assertArg1(url){url=url instanceof URL?url:new URL(url);if(url.protocol!=="file:"){throw new TypeError("Must be a file URL.");}return url;}function fromFileUrl(url){url=assertArg1(url);return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"));}function fromFileUrl1(url){url=assertArg1(url);let path=decodeURIComponent(url.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");if(url.hostname!==""){path=`\\\\${url.hostname}${path}`;}return path;}function fromFileUrl2(url){return isWindows?fromFileUrl1(url):fromFileUrl(url);}function toPathString(pathUrl){return pathUrl instanceof URL?fromFileUrl2(pathUrl):pathUrl;}function stripTrailingSeparators(segment,isSep){if(segment.length<=1){return segment;}let end=segment.length;for(let i=segment.length-1;i>0;i--){if(isSep(segment.charCodeAt(i))){end=i;}else{break;}}return segment.slice(0,end);}function resolve(...pathSegments){let resolvedPath="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1&&!resolvedAbsolute;i--){let path;if(i>=0)path=pathSegments[i];else{const{Deno:Deno1}=globalThis;if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();}assertPath(path);if(path.length===0){continue;}resolvedPath=`${path}/${resolvedPath}`;resolvedAbsolute=isPosixPathSeparator(path.charCodeAt(0));}resolvedPath=normalizeString(resolvedPath,!resolvedAbsolute,"/",isPosixPathSeparator);if(resolvedAbsolute){if(resolvedPath.length>0)return`/${resolvedPath}`;else return"/";}else if(resolvedPath.length>0)return resolvedPath;else return".";}function resolve1(...pathSegments){let resolvedDevice="";let resolvedTail="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1;i--){let path;const{Deno:Deno1}=globalThis;if(i>=0){path=pathSegments[i];}else if(!resolvedDevice){if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a drive-letter-less path without a CWD.");}path=Deno1.cwd();}else{if(typeof Deno1?.env?.get!=="function"||typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();if(path===undefined||path.slice(0,3).toLowerCase()!==`${resolvedDevice.toLowerCase()}\\`){path=`${resolvedDevice}\\`;}}assertPath(path);const len=path.length;if(len===0)continue;let rootEnd=0;let device="";let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){rootEnd=1;isAbsolute=true;}if(device.length>0&&resolvedDevice.length>0&&device.toLowerCase()!==resolvedDevice.toLowerCase()){continue;}if(resolvedDevice.length===0&&device.length>0){resolvedDevice=device;}if(!resolvedAbsolute){resolvedTail=`${path.slice(rootEnd)}\\${resolvedTail}`;resolvedAbsolute=isAbsolute;}if(resolvedAbsolute&&resolvedDevice.length>0)break;}resolvedTail=normalizeString(resolvedTail,!resolvedAbsolute,"\\",isPathSeparator);return resolvedDevice+(resolvedAbsolute?"\\":"")+resolvedTail||".";}Deno.build.os==="windows";async function exists(path,options){try{const stat=await Deno.stat(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if((await Deno.permissions.query({name:"read",path})).state==="granted"){return!options?.isReadable;}}throw error;}}function existsSync(path,options){try{const stat=Deno.statSync(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if(Deno.permissions.querySync({name:"read",path}).state==="granted"){return!options?.isReadable;}}throw error;}}function normalize2(path){return isWindows?normalize1(path):normalize(path);}function stripSuffix(name,suffix){if(suffix.length>=name.length){return name;}const lenDiff=name.length-suffix.length;for(let i=suffix.length-1;i>=0;--i){if(name.charCodeAt(lenDiff+i)!==suffix.charCodeAt(i)){return name;}}return name.slice(0,-suffix.length);}function lastPathSegment(path,isSep,start=0){let matchedNonSeparator=false;let end=path.length;for(let i=path.length-1;i>=start;--i){if(isSep(path.charCodeAt(i))){if(matchedNonSeparator){start=i+1;break;}}else if(!matchedNonSeparator){matchedNonSeparator=true;end=i+1;}}return path.slice(start,end);}function assertArgs(path,suffix){assertPath(path);if(path.length===0)return path;if(typeof suffix!=="string"){throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);}}function basename(path,suffix=""){assertArgs(path,suffix);const lastSegment=lastPathSegment(path,isPosixPathSeparator);const strippedSegment=stripTrailingSeparators(lastSegment,isPosixPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename1(path,suffix=""){assertArgs(path,suffix);let start=0;if(path.length>=2){const drive=path.charCodeAt(0);if(isWindowsDeviceRoot(drive)){if(path.charCodeAt(1)===58)start=2;}}const lastSegment=lastPathSegment(path,isPathSeparator,start);const strippedSegment=stripTrailingSeparators(lastSegment,isPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename2(path,suffix=""){return isWindows?basename1(path,suffix):basename(path,suffix);}async function createWalkEntry(path){path=toPathString(path);path=normalize2(path);const name=basename2(path);const info=await Deno.stat(path);return{path,name,isFile:info.isFile,isDirectory:info.isDirectory,isSymlink:info.isSymlink};}class WalkError extends Error{root;constructor(cause,root){super(`${cause instanceof Error?cause.message:cause} for path "${root}"`);this.cause=cause;this.name="WalkError";this.root=root;}}function include(path,exts,match,skip){if(exts&&!exts.some(ext=>path.endsWith(ext))){return false;}if(match&&!match.some(pattern=>!!path.match(pattern))){return false;}if(skip&&skip.some(pattern=>!!path.match(pattern))){return false;}return true;}function wrapErrorWithPath(err,root){if(err instanceof WalkError)return err;return new WalkError(err,root);}async function*walk(root,{maxDepth=Infinity,includeFiles=true,includeDirs=true,includeSymlinks=true,followSymlinks=false,canonicalize=true,exts=undefined,match=undefined,skip=undefined}={}){if(maxDepth<0){return;}root=toPathString(root);if(includeDirs&&include(root,exts,match,skip)){yield await createWalkEntry(root);}if(maxDepth<1||!include(root,undefined,undefined,skip)){return;}try{for await(const entry of Deno.readDir(root)){let path=join2(root,entry.name);let{isSymlink,isDirectory}=entry;if(isSymlink){if(!followSymlinks){if(includeSymlinks&&include(path,exts,match,skip)){yield{path,...entry};}continue;}const realPath=await Deno.realPath(path);if(canonicalize){path=realPath;}({isSymlink,isDirectory}=await Deno.lstat(realPath));}if(isSymlink||isDirectory){yield*walk(path,{maxDepth:maxDepth-1,includeFiles,includeDirs,includeSymlinks,followSymlinks,exts,match,skip});}else if(includeFiles&&include(path,exts,match,skip)){yield{path,...entry};}}}catch(err){throw wrapErrorWithPath(err,normalize2(root));}}Deno.build.os==="windows";new Deno.errors.AlreadyExists("dest already exists.");Deno.build.os==="windows";const LF="\n";const CRLF="\r\n";Deno?.build.os==="windows"?CRLF:LF;function parse(text,{allowTrailingComma=true}={}){if(new.target){throw new TypeError("parse is not a constructor");}return new JSONCParser(text,{allowTrailingComma}).parse();}const originalJSONParse=globalThis.JSON.parse;class JSONCParser{#whitespace=new Set(" \r\n");#numberEndToken=new Set([..."[]{}:,/",...this.#whitespace]);#text;#length;#tokenized;#options;constructor(text,options){this.#text=`${text}`;this.#length=this.#text.length;this.#tokenized=this.#tokenize();this.#options=options;}parse(){const token=this.#getNext();const res=this.#parseJsonValue(token);const{done,value}=this.#tokenized.next();if(!done){throw new SyntaxError(buildErrorMessage(value));}return res;}#getNext(){const{done,value}=this.#tokenized.next();if(done){throw new SyntaxError("Unexpected end of JSONC input");}return value;}*#tokenize(){for(let i=0;iisNaN(Number(key)));const byLevel={[LogLevels.NOTSET]:"NOTSET",[LogLevels.DEBUG]:"DEBUG",[LogLevels.INFO]:"INFO",[LogLevels.WARNING]:"WARNING",[LogLevels.ERROR]:"ERROR",[LogLevels.CRITICAL]:"CRITICAL"};function getLevelByName(name){const level=LogLevels[name];if(level!==undefined){return level;}throw new Error(`no log level found for name: ${name}`);}function getLevelName(level){const levelName=byLevel[level];if(levelName){return levelName;}throw new Error(`no level name found for level: ${level}`);}class LogRecord{msg;#args;#datetime;level;levelName;loggerName;constructor(options){this.msg=options.msg;this.#args=[...options.args];this.level=options.level;this.loggerName=options.loggerName;this.#datetime=new Date;this.levelName=getLevelName(options.level);}get args(){return[...this.#args];}get datetime(){return new Date(this.#datetime.getTime());}}class Logger{#level;#handlers;#loggerName;constructor(loggerName,levelName,options={}){this.#loggerName=loggerName;this.#level=getLevelByName(levelName);this.#handlers=options.handlers||[];}get level(){return this.#level;}set level(level){try{this.#level=getLevelByName(getLevelName(level));}catch(_){throw new TypeError(`Invalid log level: ${level}`);}}get levelName(){return getLevelName(this.#level);}set levelName(levelName){this.#level=getLevelByName(levelName);}get loggerName(){return this.#loggerName;}set handlers(hndls){this.#handlers=hndls;}get handlers(){return this.#handlers;}#_log(level,msg,...args){if(this.level>level){return msg instanceof Function?undefined:msg;}let fnResult;let logMessage;if(msg instanceof Function){fnResult=msg();logMessage=this.asString(fnResult);}else{logMessage=this.asString(msg);}const record=new LogRecord({msg:logMessage,args:args,level:level,loggerName:this.loggerName});this.#handlers.forEach(handler=>{handler.handle(record);});return msg instanceof Function?fnResult:msg;}asString(data,isProperty=false){if(typeof data==="string"){if(isProperty)return`"${data}"`;return data;}else if(data===null||typeof data==="number"||typeof data==="bigint"||typeof data==="boolean"||typeof data==="undefined"||typeof data==="symbol"){return String(data);}else if(data instanceof Error){return data.stack;}else if(typeof data==="object"){return`{${Object.entries(data).map(([k,v])=>`"${k}":${this.asString(v,true)}`).join(",")}}`;}return"undefined";}debug(msg,...args){return this.#_log(LogLevels.DEBUG,msg,...args);}info(msg,...args){return this.#_log(LogLevels.INFO,msg,...args);}warning(msg,...args){return this.#_log(LogLevels.WARNING,msg,...args);}error(msg,...args){return this.#_log(LogLevels.ERROR,msg,...args);}critical(msg,...args){return this.#_log(LogLevels.CRITICAL,msg,...args);}}const{Deno:Deno1}=globalThis;const noColor=typeof Deno1?.noColor==="boolean"?Deno1.noColor:false;let enabled=!noColor;function code(open,close){return{open:`\x1b[${open.join(";")}m`,close:`\x1b[${close}m`,regexp:new RegExp(`\\x1b\\[${close}m`,"g")};}function run(str,code){return enabled?`${code.open}${str.replace(code.regexp,code.open)}${code.close}`:str;}function bold(str){return run(str,code([1],22));}function red(str){return run(str,code([31],39));}function yellow(str){return run(str,code([33],39));}function blue(str){return run(str,code([34],39));}new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"),"g");function copy(src,dst,off=0){off=Math.max(0,Math.min(off,dst.byteLength));const dstBytesAvailable=dst.byteLength-off;if(src.byteLength>dstBytesAvailable){src=src.subarray(0,dstBytesAvailable);}dst.set(src,off);return src.byteLength;}class AbstractBufBase{buf;usedBufferBytes=0;err=null;constructor(buf){this.buf=buf;}size(){return this.buf.byteLength;}available(){return this.buf.byteLength-this.usedBufferBytes;}buffered(){return this.usedBufferBytes;}}class BufWriterSync extends AbstractBufBase{#writer;static create(writer,size=4096){return writer instanceof BufWriterSync?writer:new BufWriterSync(writer,size);}constructor(writer,size=4096){super(new Uint8Array(size<=0?4096:size));this.#writer=writer;}reset(w){this.err=null;this.usedBufferBytes=0;this.#writer=w;}flush(){if(this.err!==null)throw this.err;if(this.usedBufferBytes===0)return;try{const p=this.buf.subarray(0,this.usedBufferBytes);let nwritten=0;while(nwrittenthis.available()){if(this.buffered()===0){try{numBytesWritten=this.#writer.writeSync(data);}catch(e){if(e instanceof Error){this.err=e;}throw e;}}else{numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;this.flush();}totalBytesWritten+=numBytesWritten;data=data.subarray(numBytesWritten);}numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;totalBytesWritten+=numBytesWritten;return totalBytesWritten;}}const DEFAULT_FORMATTER="{levelName} {msg}";class BaseHandler{level;levelName;formatter;constructor(levelName,options={}){this.level=getLevelByName(levelName);this.levelName=levelName;this.formatter=options.formatter||DEFAULT_FORMATTER;}handle(logRecord){if(this.level>logRecord.level)return;const msg=this.format(logRecord);this.log(msg);}format(logRecord){if(this.formatter instanceof Function){return this.formatter(logRecord);}return this.formatter.replace(/{([^\s}]+)}/g,(match,p1)=>{const value=logRecord[p1];if(value===undefined){return match;}return String(value);});}log(_msg){}setup(){}destroy(){}}class ConsoleHandler extends BaseHandler{#useColors;constructor(levelName,options={}){super(levelName,options);this.#useColors=options.useColors??true;}format(logRecord){let msg=super.format(logRecord);if(this.#useColors){msg=this.applyColors(msg,logRecord.level);}return msg;}applyColors(msg,level){switch(level){case LogLevels.INFO:msg=blue(msg);break;case LogLevels.WARNING:msg=yellow(msg);break;case LogLevels.ERROR:msg=red(msg);break;case LogLevels.CRITICAL:msg=bold(red(msg));break;default:break;}return msg;}log(msg){console.log(msg);}}class WriterHandler extends BaseHandler{_writer;#encoder=new TextEncoder;}class FileHandler extends WriterHandler{_file;_buf;_filename;_mode;_openOptions;_encoder=new TextEncoder;#unloadCallback=(()=>{this.destroy();}).bind(this);constructor(levelName,options){super(levelName,options);this._filename=options.filename;this._mode=options.mode?options.mode:"a";this._openOptions={createNew:this._mode==="x",create:this._mode!=="x",append:this._mode==="a",truncate:this._mode!=="a",write:true};}setup(){this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);addEventListener("unload",this.#unloadCallback);}handle(logRecord){super.handle(logRecord);if(logRecord.level>LogLevels.ERROR){this.flush();}}log(msg){if(this._encoder.encode(msg).byteLength+1>this._buf.available()){this.flush();}this._buf.writeSync(this._encoder.encode(msg+"\n"));}flush(){if(this._buf?.buffered()>0){this._buf.flush();}}destroy(){this.flush();this._file?.close();this._file=undefined;removeEventListener("unload",this.#unloadCallback);}}class RotatingFileHandler extends FileHandler{#maxBytes;#maxBackupCount;#currentFileSize=0;constructor(levelName,options){super(levelName,options);this.#maxBytes=options.maxBytes;this.#maxBackupCount=options.maxBackupCount;}setup(){if(this.#maxBytes<1){this.destroy();throw new Error("maxBytes cannot be less than 1");}if(this.#maxBackupCount<1){this.destroy();throw new Error("maxBackupCount cannot be less than 1");}super.setup();if(this._mode==="w"){for(let i=1;i<=this.#maxBackupCount;i++){try{Deno.removeSync(this._filename+"."+i);}catch(error){if(!(error instanceof Deno.errors.NotFound)){throw error;}}}}else if(this._mode==="x"){for(let i=1;i<=this.#maxBackupCount;i++){if(existsSync(this._filename+"."+i)){this.destroy();throw new Deno.errors.AlreadyExists("Backup log file "+this._filename+"."+i+" already exists");}}}else{this.#currentFileSize=Deno.statSync(this._filename).size;}}log(msg){const msgByteLength=this._encoder.encode(msg).byteLength+1;if(this.#currentFileSize+msgByteLength>this.#maxBytes){this.rotateLogFiles();this.#currentFileSize=0;}super.log(msg);this.#currentFileSize+=msgByteLength;}rotateLogFiles(){this._buf.flush();this._file.close();for(let i=this.#maxBackupCount-1;i>=0;i--){const source=this._filename+(i===0?"":"."+i);const dest=this._filename+"."+(i+1);if(existsSync(source)){Deno.renameSync(source,dest);}}this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);}}const DEFAULT_LEVEL="INFO";const DEFAULT_CONFIG={handlers:{default:new ConsoleHandler(DEFAULT_LEVEL)},loggers:{default:{level:DEFAULT_LEVEL,handlers:["default"]}}};const state={handlers:new Map,loggers:new Map,config:DEFAULT_CONFIG};const handlers={BaseHandler,ConsoleHandler,WriterHandler,FileHandler,RotatingFileHandler};function getLogger(name){if(!name){const d=state.loggers.get("default");assert(d!==undefined,`"default" logger must be set for getting logger without name`);return d;}const result=state.loggers.get(name);if(!result){const logger=new Logger(name,"NOTSET",{handlers:[]});state.loggers.set(name,logger);return logger;}return result;}function debug(msg,...args){if(msg instanceof Function){return getLogger("default").debug(msg,...args);}return getLogger("default").debug(msg,...args);}function info(msg,...args){if(msg instanceof Function){return getLogger("default").info(msg,...args);}return getLogger("default").info(msg,...args);}function warning(msg,...args){if(msg instanceof Function){return getLogger("default").warning(msg,...args);}return getLogger("default").warning(msg,...args);}function error(msg,...args){if(msg instanceof Function){return getLogger("default").error(msg,...args);}return getLogger("default").error(msg,...args);}function setup(config){state.config={handlers:{...DEFAULT_CONFIG.handlers,...config.handlers},loggers:{...DEFAULT_CONFIG.loggers,...config.loggers}};state.handlers.forEach(handler=>{handler.destroy();});state.handlers.clear();const handlers=state.config.handlers||{};for(const handlerName in handlers){const handler=handlers[handlerName];handler.setup();state.handlers.set(handlerName,handler);}state.loggers.clear();const loggers=state.config.loggers||{};for(const loggerName in loggers){const loggerConfig=loggers[loggerName];const handlerNames=loggerConfig.handlers||[];const handlers=[];handlerNames.forEach(handlerName=>{const handler=state.handlers.get(handlerName);if(handler){handlers.push(handler);}});const levelName=loggerConfig.level||DEFAULT_LEVEL;const logger=new Logger(loggerName,levelName,{handlers:handlers});state.loggers.set(loggerName,logger);}}setup(DEFAULT_CONFIG);function assertArgs1(from,to){assertPath(from);assertPath(to);if(from===to)return"";}function relative(from,to){assertArgs1(from,to);from=resolve(from);to=resolve(to);if(from===to)return"";let fromStart=1;const fromEnd=from.length;for(;fromStartlength){if(isPosixPathSeparator(to.charCodeAt(toStart+i))){return to.slice(toStart+i+1);}else if(i===0){return to.slice(toStart+i);}}else if(fromLen>length){if(isPosixPathSeparator(from.charCodeAt(fromStart+i))){lastCommonSep=i;}else if(i===0){lastCommonSep=0;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(isPosixPathSeparator(fromCode))lastCommonSep=i;}let out="";for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||isPosixPathSeparator(from.charCodeAt(i))){if(out.length===0)out+="..";else out+="/..";}}if(out.length>0)return out+to.slice(toStart+lastCommonSep);else{toStart+=lastCommonSep;if(isPosixPathSeparator(to.charCodeAt(toStart)))++toStart;return to.slice(toStart);}}function relative1(from,to){assertArgs1(from,to);const fromOrig=resolve1(from);const toOrig=resolve1(to);if(fromOrig===toOrig)return"";from=fromOrig.toLowerCase();to=toOrig.toLowerCase();if(from===to)return"";let fromStart=0;let fromEnd=from.length;for(;fromStartfromStart;--fromEnd){if(from.charCodeAt(fromEnd-1)!==92)break;}const fromLen=fromEnd-fromStart;let toStart=0;let toEnd=to.length;for(;toStarttoStart;--toEnd){if(to.charCodeAt(toEnd-1)!==92)break;}const toLen=toEnd-toStart;const length=fromLenlength){if(to.charCodeAt(toStart+i)===92){return toOrig.slice(toStart+i+1);}else if(i===2){return toOrig.slice(toStart+i);}}if(fromLen>length){if(from.charCodeAt(fromStart+i)===92){lastCommonSep=i;}else if(i===2){lastCommonSep=3;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(fromCode===92)lastCommonSep=i;}if(i!==length&&lastCommonSep===-1){return toOrig;}let out="";if(lastCommonSep===-1)lastCommonSep=0;for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||from.charCodeAt(i)===92){if(out.length===0)out+="..";else out+="\\..";}}if(out.length>0){return out+toOrig.slice(toStart+lastCommonSep,toEnd);}else{toStart+=lastCommonSep;if(toOrig.charCodeAt(toStart)===92)++toStart;return toOrig.slice(toStart,toEnd);}}function relative2(from,to){return isWindows?relative1(from,to):relative(from,to);}var m=Object.create;var E=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),D=(t,e)=>{for(var s in e)E(t,s,{get:e[s],enumerable:!0});},a=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!b.call(t,n)&&n!==s&&E(t,n,{get:()=>e[n],enumerable:!(r=T(e,n))||r.enumerable});return t;},_=(t,e,s)=>(a(t,e,"default"),s&&a(s,e,"default")),$=(t,e,s)=>(s=t!=null?m(X(t)):{},a(e||!t||!t.__esModule?E(s,"default",{value:t,enumerable:!0}):s,t));var A=w((ct,v)=>{function C(t){return Array.isArray(t)?t:[t];}var N="",P=" ",h="\\",H=/^\s+$/,F=/(?:[^\\]|^)\\$/,k=/^\\!/,z=/^\\#/,B=/\r?\n/g,K=/^\.*\/|^\.+$/,d="/",x="node-ignore";typeof Symbol<"u"&&(x=Symbol.for("node-ignore"));var L=x,V=(t,e,s)=>Object.defineProperty(t,e,{value:s}),j=/([0-z])-([0-z])/g,G=()=>!1,M=t=>t.replace(j,(e,s,r)=>s.charCodeAt(0)<=r.charCodeAt(0)?e:N),Y=t=>{let{length:e}=t;return t.slice(0,e-e%2);},W=[[/\\?\s+$/,t=>t.indexOf("\\")===0?P:N],[/\\\s/g,()=>P],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)";}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,s)=>e+6{let r=s.replace(/\\\*/g,"[^\\/]*");return e+r;}],[/\\\\\\(?=[$.|*+(){^])/g,()=>h],[/\\\\/g,()=>h],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,s,r,n)=>e===h?`\\[${s}${Y(r)}${n}`:n==="]"&&r.length%2===0?`[${M(s)}${r}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],S=Object.create(null),p=(t,e)=>{let s=S[t];return s||(s=W.reduce((r,n)=>r.replace(n[0],n[1].bind(t)),t),S[t]=s),e?new RegExp(s,"i"):new RegExp(s);},R=t=>typeof t=="string",q=t=>t&&R(t)&&!H.test(t)&&!F.test(t)&&t.indexOf("#")!==0,J=t=>t.split(B),f=class{constructor(e,s,r,n){this.origin=e,this.pattern=s,this.negative=r,this.regex=n;}},Q=(t,e)=>{let s=t,r=!1;t.indexOf("!")===0&&(r=!0,t=t.substr(1)),t=t.replace(k,"!").replace(z,"#");let n=p(t,e);return new f(s,t,r,n);},U=(t,e)=>{throw new e(t);},i=(t,e,s)=>R(t)?t?i.isNotRelative(t)?s(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:s("path must not be empty",TypeError):s(`path must be a string, but got \`${e}\``,TypeError),O=t=>K.test(t);i.isNotRelative=O;i.convert=t=>t;var g=class{constructor({ignorecase:e=!0,ignoreCase:s=e,allowRelativePaths:r=!1}={}){V(this,L,!0),this._rules=[],this._ignoreCase=s,this._allowRelativePaths=r,this._initCache();}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null);}_addPattern(e){if(e&&e[L]){this._rules=this._rules.concat(e._rules),this._added=!0;return;}if(q(e)){let s=Q(e,this._ignoreCase);this._added=!0,this._rules.push(s);}}add(e){return this._added=!1,C(R(e)?J(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this;}addPattern(e){return this.add(e);}_testOne(e,s){let r=!1,n=!1;return this._rules.forEach(o=>{let{negative:u}=o;if(n===u&&r!==n||u&&!r&&!n&&!s)return;o.regex.test(e)&&(r=!u,n=u);}),{ignored:r,unignored:n};}_test(e,s,r,n){let o=e&&i.convert(e);return i(o,e,this._allowRelativePaths?G:U),this._t(o,s,r,n);}_t(e,s,r,n){if(e in s)return s[e];if(n||(n=e.split(d)),n.pop(),!n.length)return s[e]=this._testOne(e,r);let o=this._t(n.join(d)+d,s,r,n);return s[e]=o.ignored?o:this._testOne(e,r);}ignores(e){return this._test(e,this._ignoreCache,!1).ignored;}createFilter(){return e=>!this.ignores(e);}filter(e){return C(e).filter(this.createFilter());}test(e){return this._test(e,this._testCache,!0);}},l=t=>new g(t),Z=t=>i(t&&i.convert(t),t,G);l.isPathValid=Z;l.default=l;v.exports=l;var tt=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");i.convert=tt;var et=/^[a-z]:\//i;i.isNotRelative=t=>et.test(t)||O(t);});var c={};D(c,{default:()=>nt});var st=$(A());_(c,$(A()));var{default:I,...rt}=st,nt=I!==void 0?I:rt;const importMeta={url:"file:///home/runner/work/setup-deno/setup-deno/cache.ts",main:import.meta.main};if(importMeta.main){const args=parseArgs(Deno.args,{boolean:["dry-run","verbose","lock-write"],negatable:["lock-write"],string:["config"],default:{"lock-write":true},alias:{"dry-run":"n",verbose:"v"},"--":true,unknown:arg=>{console.log(`Unknown argument: ${arg}`);console.log("Usage: cache [-n | --dry-run] [-v | --verbose] [--] [DENO_ARGS...]");Deno.exit(0);}});const denoDir=Deno.env.get("DENO_DIR");const logLevel=["1","true"].includes(Deno.env.get("CI")??"")?"DEBUG":args.verbose?"DEBUG":"INFO";setup({handlers:{console:new handlers.ConsoleHandler(logLevel,{formatter:logRecord=>Deno.noColor?logRecord.levelName+" "+logRecord.msg:logRecord.msg})},loggers:{default:{handlers:["console"],"level":logLevel}}});if(args["dry-run"])warning("dry-run mode enabled");if(args.config&&!await exists(args.config)){error(`config file ${args.config} not found`);Deno.exit(1);}const hash=await Deno.readFile("./deno.lock").then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>encodeHex(new Uint8Array(data))).catch(_=>"");debug(`GitHub actions deno.lock hash: ${hash}`);const cfgs=args.config?[args.config]:["deno.json","deno.jsonc"];const denoCfg=await Promise.all(cfgs.map(path=>Deno.readTextFile(path).catch(_=>undefined))).then(v=>parse(v.filter(Boolean)[0]??"{}"));const patterns=[...[denoCfg?.exclude??[]].flat(),...[denoCfg?.cache?.exclude??[]].flat(),...[denoCfg?.cache?.include??[]].flatMap(p=>`!${p}`)];debug(`patterns:`,patterns);patterns.forEach(p=>debug(`- ${p}`));const ig=nt().add(patterns);const walkIterator=walk(".",{exts:["js",".jsx",".ts",".tsx"],includeDirs:false});const paths=[];for await(const entry of walkIterator){const relativePath=relative2(".",entry.path);if(denoDir&&entry.path.startsWith(denoDir))continue;if(ig.ignores(relativePath)){debug(`ignored ${relativePath}`);continue;}debug(`caching ${relativePath}`);paths.push(relativePath);}const denoArgs=["cache",args["lock-write"]&&"--lock-write",args.config&&`--config=${args.config}`,...args["--"],...paths].filter(Boolean);const cmd=new Deno.Command(Deno.execPath(),{args:denoArgs});const cmdString=Deno.execPath()+" "+denoArgs.join(" ");if(args["dry-run"]){info(`would run: ${cmdString}`);Deno.exit(0);}debug(`running: ${cmdString}`);const{stderr,code}=await cmd.output();for(const line of new TextDecoder().decode(stderr).split("\n")){if(line.length>0)info("deno> "+line);}if(code===0)debug(`finished caching ${paths.length} files`);} \ No newline at end of file From db69423db8998e78ea3e82ec121708f9d344ce3a Mon Sep 17 00:00:00 2001 From: winston Date: Wed, 27 Dec 2023 00:54:46 +0100 Subject: [PATCH 17/18] chore: docs, cleanup --- .github/workflows/build.yml | 6 +++- .github/workflows/test.yml | 26 ++------------ README.md | 72 +++++++++++++++++++++++++++++-------- action.yml | 8 +---- cache.ts | 11 +++--- deno.json | 5 +-- deno.lock | 66 ---------------------------------- test/basic/main.ts | 15 ++++---- test/customized/deno.json | 7 ---- test/customized/deno.lock | 70 ------------------------------------ test/customized/main.ts | 23 ------------ 11 files changed, 78 insertions(+), 231 deletions(-) delete mode 100644 test/customized/deno.json delete mode 100644 test/customized/deno.lock delete mode 100644 test/customized/main.ts diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7bcda3a..4ff2d0e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,11 @@ jobs: - name: Setup Deno uses: ./ - - run: deno run -A ./bundle.ts + - name: Lint + run: deno lint + + - name: Bundle + run: deno run -A ./bundle.ts - name: Push changes uses: stefanzweifel/git-auto-commit-action@v5 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a05c9ed..515ab5f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,30 +21,8 @@ jobs: - name: Setup Deno uses: ./ + with: + deno-config-path: "test/basic/deno.json" - name: Test basic usage run: deno run -A ./test/basic/main.ts - - customized: - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - - name: Customized on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Test action - uses: ./ - with: - deno-version: 1.x - deno-lock-path: "test/customized/deno.lock" - directory: "test/customized" - - - name: Test customized usage - working-directory: test/customized - run: deno run -A main.ts \ No newline at end of file diff --git a/README.md b/README.md index 679ad33..ef14f13 100644 --- a/README.md +++ b/README.md @@ -4,15 +4,62 @@ ### Deno Setup action with integrated cache. -- Based on: +- Based on: - [`denoland/setup-deno@v1`](https://github.com/denoland/setup-deno), - [`actions/cache@v3`](https://github.com/actions/cache) - Handles restoring and caching to `DENO_DIR` for you. - Annotates your source code from `deno lint --compact` output.\ - See the summary of the most recent [Problem Matcher worflow](https://github.com/nekowinston/setup-deno/actions/workflows/problem-matcher.yml) for an example. + See the summary of the most recent + [Problem Matcher worflow](https://github.com/nekowinston/setup-deno/actions/workflows/problem-matcher.yml) + to see it in action. - Works on Ubuntu, macOS & Windows runners. -### Usage +### A note on Deno caching + +Deno only caches the deps it needs to run a single script, and does so on the +fly. This is great UX/DX! But it does make effective caching in GitHub actions +harder. + +[v1](https://github.com/nekowinston/setup-deno/tree/v1) of this repo used to run +`find . -regex '.*\.[jt]sx*' -exec deno cache {} \;` to prefetch all +dependencies for all scripts more reliably. In case of a non-standard repo +layout (e.g. monorepo), the action had another input to specify a single +directory to cache. + +[v2](https://github.com/nekowinston/setup-deno/tree/v2) now offers an extension +to the `deno.json` config! Simply specify which paths to _include_ or _exclude_: + +```jsonc +{ + "tasks": { + // add a task to easily call `deno task cache` + "cache": "deno run --no-lock --allow-read --allow-run=deno --allow-env=CI,DENO_DIR https://esm.sh/gh/nekowinston/setup-deno/dist/cache.js" + }, + // the task will respect both `.exclude` + "exclude": ["dist", "foo/*"], + // and new `.cache.include` & `.cache.exclude` fields + "cache": { + "include": "foo/bar.ts", + "exclude": "scripts/some_rarely_run_script.ts" + } +} +``` + +These fields get combined, and cached accordingly: + +```console +$ deno task cache -v +caching main.ts +ignored dist/main.js +ignored foo/qux.ts +caching foo/bar.ts +ignored foo/baz.ts +ignored scripts/some_rarely_run_script.ts +``` + +> [!NOTE] This script is completely optional for this action. + +### Action Usage #### Basic: @@ -27,26 +74,23 @@ with: deno-version: "~1.38" deno-json-path: ./subdirectory/deno.json - deno-lock-path: ./subdirectory/deno.lock - directory: ./subdirectory ``` ### Inputs + - `deno-version`:\ - The Deno version to install. Can be a semver version of a stable release, `'canary'` for the latest canary, or the Git hash of a specific canary release.\ - See [`setup-deno`](https://github.com/marketplace/actions/setup-deno) for examples.\ + The Deno version to install. Can be a semver version of a stable release, + `'canary'` for the latest canary, or the Git hash of a specific canary + release.\ + See [`setup-deno`](https://github.com/marketplace/actions/setup-deno) for + examples.\ Defaults to `1.x`. - `deno-json-path`:\ The path to the Deno config file to use for caching.\ Defaults to an empty string, using the built-in CLI default. -- `deno-lock-path`:\ - The path to the lock file to use for caching.\ - Defaults to `./deno.lock`. -- `directory`:\ - The path to the scripts to cache. This can be useful if Deno is only part of your repo, and stored in a subdirectory.\ - Defaults to the repo root. ### Outputs: + - `deno-version`: The Deno version that was installed. - `is-canary`: If the installed Deno version was a canary version. -- `cache-hit`: A boolean value to indicate an exact match was found for the key. \ No newline at end of file +- `cache-hit`: A boolean value to indicate an exact match was found for the key. diff --git a/action.yml b/action.yml index a03da8f..23d1e1b 100644 --- a/action.yml +++ b/action.yml @@ -11,12 +11,6 @@ inputs: deno-json-path: description: "The path to the Deno config file to use for caching. Defaults to an empty string, using the built-in CLI default (`deno.json` and `deno.jsonc`)." default: "" - deno-lock-path: - description: "The path to the lock file to use for caching. Defaults to `./deno.lock`." - default: "./deno.lock" - directory: - description: "The path to the scripts to cache. Defaults to the repo root." - default: "." outputs: deno-version: @@ -56,4 +50,4 @@ runs: - name: Restore Deno dependencies shell: bash run: | - "${{ github.action_path }}"/dist/cache.js + "${{ github.action_path }}/dist/cache.js" --config "${{ inputs.deno-json-path }}" diff --git a/cache.ts b/cache.ts index eab2678..68c4013 100755 --- a/cache.ts +++ b/cache.ts @@ -67,12 +67,11 @@ if (import.meta.main) { // flattening so that a single string doesn't break too much const patterns = [ - ...[denoCfg?.exclude ?? []].flat(), - ...[denoCfg?.cache?.exclude ?? []].flat(), - ...[denoCfg?.cache?.include ?? []].flatMap((p) => `!${p}`), - ]; - log.debug(`patterns:`, patterns); - patterns.forEach((p) => log.debug(`- ${p}`)); + ...[denoCfg?.exclude].filter(Boolean).flat(), + ...[denoCfg?.cache?.exclude].filter(Boolean).flat(), + ...[denoCfg?.cache?.include].filter(Boolean).flatMap((p) => `!${p}`), + ] as string[]; + patterns.length > 0 && log.debug(`patterns:\n| ${patterns.join("\n| ")}`); const ig = ignore().add(patterns); const walkIterator = walk(".", { diff --git a/deno.json b/deno.json index 1ac50a9..6a5984e 100644 --- a/deno.json +++ b/deno.json @@ -6,8 +6,5 @@ "std/": "https://deno.land/std@0.207.0/", "cliffy/": "https://deno.land/x/cliffy@v1.0.0-rc.3/" }, - "exclude": ["dist", "test/problem-matcher/*"], - "cache": { - "include": ["test/problem-matcher/*"] - } + "exclude": ["dist", "test"] } diff --git a/deno.lock b/deno.lock index ead3d03..10b8778 100644 --- a/deno.lock +++ b/deno.lock @@ -31,13 +31,6 @@ "https://deno.land/std@0.186.0/path/posix.ts": "8b7c67ac338714b30c816079303d0285dd24af6b284f7ad63da5b27372a2c94d", "https://deno.land/std@0.186.0/path/separator.ts": "0fb679739d0d1d7bf45b68dacfb4ec7563597a902edbaf3c59b50d5bcadd93b1", "https://deno.land/std@0.186.0/path/win32.ts": "d186344e5583bcbf8b18af416d13d82b35a317116e6460a5a3953508c3de5bba", - "https://deno.land/std@0.196.0/assert/assert.ts": "9a97dad6d98c238938e7540736b826440ad8c1c1e54430ca4c4e623e585607ee", - "https://deno.land/std@0.196.0/assert/assertion_error.ts": "4d0bde9b374dfbcbe8ac23f54f567b77024fb67dbb1906a852d67fe050d42f56", - "https://deno.land/std@0.196.0/console/_data.json": "cf2cc9d039a192b3adbfe64627167c7e6212704c888c25c769fc8f1709e1e1b8", - "https://deno.land/std@0.196.0/console/_rle.ts": "56668d5c44f964f1b4ff93f21c9896df42d6ee4394e814db52d6d13f5bb247c7", - "https://deno.land/std@0.196.0/console/unicode_width.ts": "10661c0f2eeab802d16b8b85ed8825bbc573991bbfb6affed32dc1ff994f54f9", - "https://deno.land/std@0.196.0/fmt/colors.ts": "a7eecffdf3d1d54db890723b303847b6e0a1ab4b528ba6958b8f2e754cf1b3bc", - "https://deno.land/std@0.207.0/fmt/colors.ts": "34b3f77432925eb72cf0bfb351616949746768620b8e5ead66da532f93d10ba2", "https://deno.land/std@0.209.0/fs/_util.ts": "b03c46be986540a23916918fe0c01e257909e34be371943812001792859e22be", "https://deno.land/std@0.209.0/fs/ensure_dir.ts": "dc64c4c75c64721d4e3fb681f1382f803ff3d2868f08563ff923fdd20d071c40", "https://deno.land/std@0.209.0/path/_common/assert_path.ts": "061e4d093d4ba5aebceb2c4da3318bfe3289e868570e9d3a8e327d91c2958946", @@ -146,65 +139,6 @@ "https://deno.land/std@0.210.0/path/windows/relative.ts": "026855cd2c36c8f28f1df3c6fbd8f2449a2aa21f48797a74700c5d872b86d649", "https://deno.land/std@0.210.0/path/windows/resolve.ts": "5ff441ab18a2346abadf778121128ee71bda4d0898513d4639a6ca04edca366b", "https://deno.land/std@0.210.0/path/windows/separator.ts": "ae21f27015f10510ed1ac4a0ba9c4c9c967cbdd9d9e776a3e4967553c397bd5d", - "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", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/_spread.ts": "0cc6eb70a6df97b5d7d26008822d39f3e8a1232ee0a27f395aa19e68de738245", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/_type_utils.ts": "820004a59bc858e355b11f80e5b3ff1be2c87e66f31f53f253610170795602f0", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/_utils.ts": "3c88ff4f36eba298beb07de08068fdce5e5cb7b9d82c8a319f09596d8279be64", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/command.ts": "ae690745759524082776b7f271f66d5b93933170b1b132f888bd4ac12e9fdd7d", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/completions/_bash_completions_generator.ts": "0c6cb1df4d378d22f001155781d97a9c3519fd10c48187a198fef2cc63b0f84a", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/completions/_fish_completions_generator.ts": "8ba4455f7f76a756e05c3db4ce35332b2951af65a2891f2750b530e06880f495", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/completions/_zsh_completions_generator.ts": "c74525feaf570fe8c14433c30d192622c25603f1fc64694ef69f2a218b41f230", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/completions/bash.ts": "53fe78994eb2359110dc4fa79235bdd86800a38c1d6b1c4fe673c81756f3a0e2", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/completions/complete.ts": "58df61caa5e6220ff2768636a69337923ad9d4b8c1932aeb27165081c4d07d8b", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/completions/completions_command.ts": "506f97f1c6b0b1c3e9956e5069070028b818942310600d4157f64c9b644d3c49", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/completions/fish.ts": "6f0b44b4067740b2931c9ec8863b6619b1d3410fea0c5a3988525a4c53059197", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/completions/mod.ts": "8dda715ca25f3f66d5ec232b76d7c9a96dd4c64b5029feff91738cc0c9586fb1", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/completions/zsh.ts": "f1263c3946975e090d4aadc8681db811d86b52a8ae680f246e03248025885c21", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/deprecated.ts": "bbe6670f1d645b773d04b725b8b8e7814c862c9f1afba460c4d599ffe9d4983c", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/deps.ts": "7473ebd5625bf901becd7ff80afdde3b8a50ae5d1bbfa2f43805cfacf4559d5a", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/help/_help_generator.ts": "532dd4a928baab8b45ce46bb6d20e2ebacfdf3da141ce9d12da796652b1de478", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/help/help_command.ts": "fbbf0c0827dd21d3cec7bcc68c00c20b55f53e2b621032891b9d23ac4191231c", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/help/mod.ts": "8369b292761dcc9ddaf41f2d34bfb06fb6800b69efe80da4fc9752c3b890275b", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/mod.ts": "4b708df1b97152522bee0e3828f06abbbc1d2250168910e5cf454950d7b7404b", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/type.ts": "f588f5d9635b79100044e62aced4b00e510e75b83801f9b089c40c2d98674de2", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/types.ts": "bc9ff7459b9cc1079eeb95ff101690a51b4b4afa4af5623340076ee361d08dbb", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/types/action_list.ts": "33c98d449617c7a563a535c9ceb3741bde9f6363353fd492f90a74570c611c27", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/types/boolean.ts": "3879ec16092b4b5b1a0acb8675f8c9250c0b8a972e1e4c7adfba8335bd2263ed", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/types/child_command.ts": "f1fca390c7fbfa7a713ca15ef55c2c7656bcbb394d50e8ef54085bdf6dc22559", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/types/command.ts": "325d0382e383b725fd8d0ef34ebaeae082c5b76a1f6f2e843fee5dbb1a4fe3ac", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/types/enum.ts": "8a7cd2898e03089234083bb78c8b1d9b7172254c53c32d4710321638165a48ec", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/types/file.ts": "8618f16ac9015c8589cbd946b3de1988cc4899b90ea251f3325c93c46745140e", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/types/integer.ts": "29864725fd48738579d18123d7ee78fed37515e6dc62146c7544c98a82f1778d", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/types/number.ts": "aeba96e6f470309317a16b308c82e0e4138a830ec79c9877e4622c682012bc1f", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/types/string.ts": "e4dadb08a11795474871c7967beab954593813bb53d9f69ea5f9b734e43dc0e0", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/upgrade/_check_version.ts": "6cfa7dc26bc0dc46381500e8d4b130fb224f4c5456152dada15bd3793edca89b", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/upgrade/mod.ts": "4eff69c489467be17dea27fb95a795396111ee385d170ac0cbcc82f0ea38156c", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/upgrade/provider.ts": "c23253334097dc4b8a147ccdeb3aa44f5a95aa953a6386cb5396f830d95d77a5", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/upgrade/provider/deno_land.ts": "24f8d82e38c51e09be989f30f8ad21f9dd41ac1bb1973b443a13883e8ba06d6d", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/upgrade/provider/github.ts": "99e1b133dd446c6aa79f69e69c46eb8bc1c968dd331c2a7d4064514a317c7b59", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/upgrade/provider/nest_land.ts": "0e07936cea04fa41ac9297f32d87f39152ea873970c54cb5b4934b12fee1885e", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/upgrade/upgrade_command.ts": "3640a287d914190241ea1e636774b1b4b0e1828fa75119971dd5304784061e05", - "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/_errors.ts": "f1fbb6bfa009e7950508c9d491cfb4a5551027d9f453389606adb3f2327d048f", - "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/_utils.ts": "340d3ecab43cde9489187e1f176504d2c58485df6652d1cdd907c0e9c3ce4cc2", - "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/_validate_flags.ts": "e60b9038c0136ab7e6bd1baf0e993a07bf23f18afbfb6e12c59adf665a622957", - "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/deprecated.ts": "a72a35de3cc7314e5ebea605ca23d08385b218ef171c32a3f135fb4318b08126", - "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/flags.ts": "3e62c4a9756b5705aada29e7e94847001356b3a83cd18ad56f4207387a71cf51", - "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/types.ts": "9e2f75edff2217d972fc711a21676a59dfd88378da2f1ace440ea84c07db1dcc", - "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/types/boolean.ts": "4c026dd66ec9c5436860dc6d0241427bdb8d8e07337ad71b33c08193428a2236", - "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/types/integer.ts": "b60d4d590f309ddddf066782d43e4dc3799f0e7d08e5ede7dc62a5ee94b9a6d9", - "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/types/number.ts": "610936e2d29de7c8c304b65489a75ebae17b005c6122c24e791fbed12444d51e", - "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/types/string.ts": "e89b6a5ce322f65a894edecdc48b44956ec246a1d881f03e97bbda90dd8638c5", - "https://deno.land/x/cliffy@v1.0.0-rc.3/table/_layout.ts": "e4a518da28333de95ad791208b9930025987c8b93d5f8b7f30b377b3e26b24e1", - "https://deno.land/x/cliffy@v1.0.0-rc.3/table/_utils.ts": "fd48d1a524a42e72aa3ad2eec858a92f5a00728d306c7e8436fba6c34314fee6", - "https://deno.land/x/cliffy@v1.0.0-rc.3/table/border.ts": "5c6e9ef5078c6930169aacb668b274bdbb498461c724a7693ac9270fe9d3f5d5", - "https://deno.land/x/cliffy@v1.0.0-rc.3/table/cell.ts": "1ffabd43b6b7fddfac9625cb0d015532e144702a9bfed03b358b79375115d06b", - "https://deno.land/x/cliffy@v1.0.0-rc.3/table/column.ts": "cf14009f2cb14bad156f879946186c1893acdc6a2fee6845db152edddb6a2714", - "https://deno.land/x/cliffy@v1.0.0-rc.3/table/consume_words.ts": "456e75755fdf6966abdefb8b783df2855e2a8bad6ddbdf21bd748547c5fc1d4b", - "https://deno.land/x/cliffy@v1.0.0-rc.3/table/deps.ts": "1226c4d39d53edc81d7c3e661fb8a79f2e704937c276c60355cd4947a0fe9153", - "https://deno.land/x/cliffy@v1.0.0-rc.3/table/row.ts": "79eb1468aafdd951e5963898cdafe0752d4ab4c519d5f847f3d8ecb8fe857d4f", - "https://deno.land/x/cliffy@v1.0.0-rc.3/table/table.ts": "298671e72e61f1ab18b42ae36643181993f79e29b39dc411fdc6ffd53aa04684", "https://deno.land/x/deno_cache@0.5.2/auth_tokens.ts": "5d1d56474c54a9d152e44d43ea17c2e6a398dd1e9682c69811a313567c01ee1e", "https://deno.land/x/deno_cache@0.5.2/cache.ts": "92ce8511e1e5c00fdf53a41619aa77d632ea8e0fc711324322e4d5ebf8133911", "https://deno.land/x/deno_cache@0.5.2/deno_dir.ts": "1ea355b8ba11c630d076b222b197cfc937dd81e5a4a260938997da99e8ff93a0", diff --git a/test/basic/main.ts b/test/basic/main.ts index 5ad9052..f35047b 100755 --- a/test/basic/main.ts +++ b/test/basic/main.ts @@ -2,13 +2,10 @@ // just get any stdlib for the cache test import { cyan, green, magenta, red, yellow } from "std/fmt/colors.ts"; -const helloWorld = [ - red("He"), - yellow("llo"), - " ", - green("Wo"), - cyan("rl"), - magenta("d!"), -].join(""); +const rainbowify = (str: string) => + str + .split("") + .map((char, index) => [red, yellow, green, cyan, magenta][index % 5](char)) + .join(""); -console.log(helloWorld); +console.log(rainbowify("Hello World!")); diff --git a/test/customized/deno.json b/test/customized/deno.json deleted file mode 100644 index 2cfbd69..0000000 --- a/test/customized/deno.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "imports": { - "std/": "https://deno.land/std@0.207.0/", - "cliffy/": "https://deno.land/x/cliffy@v1.0.0-rc.3/" - }, - "lock": "./deno.lock" -} diff --git a/test/customized/deno.lock b/test/customized/deno.lock deleted file mode 100644 index e0a80eb..0000000 --- a/test/customized/deno.lock +++ /dev/null @@ -1,70 +0,0 @@ -{ - "version": "3", - "remote": { - "https://deno.land/std@0.196.0/assert/assert.ts": "9a97dad6d98c238938e7540736b826440ad8c1c1e54430ca4c4e623e585607ee", - "https://deno.land/std@0.196.0/assert/assertion_error.ts": "4d0bde9b374dfbcbe8ac23f54f567b77024fb67dbb1906a852d67fe050d42f56", - "https://deno.land/std@0.196.0/console/_data.json": "cf2cc9d039a192b3adbfe64627167c7e6212704c888c25c769fc8f1709e1e1b8", - "https://deno.land/std@0.196.0/console/_rle.ts": "56668d5c44f964f1b4ff93f21c9896df42d6ee4394e814db52d6d13f5bb247c7", - "https://deno.land/std@0.196.0/console/unicode_width.ts": "10661c0f2eeab802d16b8b85ed8825bbc573991bbfb6affed32dc1ff994f54f9", - "https://deno.land/std@0.196.0/fmt/colors.ts": "a7eecffdf3d1d54db890723b303847b6e0a1ab4b528ba6958b8f2e754cf1b3bc", - "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", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/_spread.ts": "0cc6eb70a6df97b5d7d26008822d39f3e8a1232ee0a27f395aa19e68de738245", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/_type_utils.ts": "820004a59bc858e355b11f80e5b3ff1be2c87e66f31f53f253610170795602f0", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/_utils.ts": "3c88ff4f36eba298beb07de08068fdce5e5cb7b9d82c8a319f09596d8279be64", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/command.ts": "ae690745759524082776b7f271f66d5b93933170b1b132f888bd4ac12e9fdd7d", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/completions/_bash_completions_generator.ts": "0c6cb1df4d378d22f001155781d97a9c3519fd10c48187a198fef2cc63b0f84a", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/completions/_fish_completions_generator.ts": "8ba4455f7f76a756e05c3db4ce35332b2951af65a2891f2750b530e06880f495", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/completions/_zsh_completions_generator.ts": "c74525feaf570fe8c14433c30d192622c25603f1fc64694ef69f2a218b41f230", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/completions/bash.ts": "53fe78994eb2359110dc4fa79235bdd86800a38c1d6b1c4fe673c81756f3a0e2", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/completions/complete.ts": "58df61caa5e6220ff2768636a69337923ad9d4b8c1932aeb27165081c4d07d8b", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/completions/completions_command.ts": "506f97f1c6b0b1c3e9956e5069070028b818942310600d4157f64c9b644d3c49", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/completions/fish.ts": "6f0b44b4067740b2931c9ec8863b6619b1d3410fea0c5a3988525a4c53059197", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/completions/mod.ts": "8dda715ca25f3f66d5ec232b76d7c9a96dd4c64b5029feff91738cc0c9586fb1", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/completions/zsh.ts": "f1263c3946975e090d4aadc8681db811d86b52a8ae680f246e03248025885c21", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/deprecated.ts": "bbe6670f1d645b773d04b725b8b8e7814c862c9f1afba460c4d599ffe9d4983c", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/deps.ts": "7473ebd5625bf901becd7ff80afdde3b8a50ae5d1bbfa2f43805cfacf4559d5a", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/help/_help_generator.ts": "532dd4a928baab8b45ce46bb6d20e2ebacfdf3da141ce9d12da796652b1de478", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/help/help_command.ts": "fbbf0c0827dd21d3cec7bcc68c00c20b55f53e2b621032891b9d23ac4191231c", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/help/mod.ts": "8369b292761dcc9ddaf41f2d34bfb06fb6800b69efe80da4fc9752c3b890275b", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/mod.ts": "4b708df1b97152522bee0e3828f06abbbc1d2250168910e5cf454950d7b7404b", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/type.ts": "f588f5d9635b79100044e62aced4b00e510e75b83801f9b089c40c2d98674de2", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/types.ts": "bc9ff7459b9cc1079eeb95ff101690a51b4b4afa4af5623340076ee361d08dbb", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/types/action_list.ts": "33c98d449617c7a563a535c9ceb3741bde9f6363353fd492f90a74570c611c27", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/types/boolean.ts": "3879ec16092b4b5b1a0acb8675f8c9250c0b8a972e1e4c7adfba8335bd2263ed", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/types/child_command.ts": "f1fca390c7fbfa7a713ca15ef55c2c7656bcbb394d50e8ef54085bdf6dc22559", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/types/command.ts": "325d0382e383b725fd8d0ef34ebaeae082c5b76a1f6f2e843fee5dbb1a4fe3ac", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/types/enum.ts": "8a7cd2898e03089234083bb78c8b1d9b7172254c53c32d4710321638165a48ec", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/types/file.ts": "8618f16ac9015c8589cbd946b3de1988cc4899b90ea251f3325c93c46745140e", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/types/integer.ts": "29864725fd48738579d18123d7ee78fed37515e6dc62146c7544c98a82f1778d", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/types/number.ts": "aeba96e6f470309317a16b308c82e0e4138a830ec79c9877e4622c682012bc1f", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/types/string.ts": "e4dadb08a11795474871c7967beab954593813bb53d9f69ea5f9b734e43dc0e0", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/upgrade/_check_version.ts": "6cfa7dc26bc0dc46381500e8d4b130fb224f4c5456152dada15bd3793edca89b", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/upgrade/mod.ts": "4eff69c489467be17dea27fb95a795396111ee385d170ac0cbcc82f0ea38156c", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/upgrade/provider.ts": "c23253334097dc4b8a147ccdeb3aa44f5a95aa953a6386cb5396f830d95d77a5", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/upgrade/provider/deno_land.ts": "24f8d82e38c51e09be989f30f8ad21f9dd41ac1bb1973b443a13883e8ba06d6d", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/upgrade/provider/github.ts": "99e1b133dd446c6aa79f69e69c46eb8bc1c968dd331c2a7d4064514a317c7b59", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/upgrade/provider/nest_land.ts": "0e07936cea04fa41ac9297f32d87f39152ea873970c54cb5b4934b12fee1885e", - "https://deno.land/x/cliffy@v1.0.0-rc.3/command/upgrade/upgrade_command.ts": "3640a287d914190241ea1e636774b1b4b0e1828fa75119971dd5304784061e05", - "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/_errors.ts": "f1fbb6bfa009e7950508c9d491cfb4a5551027d9f453389606adb3f2327d048f", - "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/_utils.ts": "340d3ecab43cde9489187e1f176504d2c58485df6652d1cdd907c0e9c3ce4cc2", - "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/_validate_flags.ts": "e60b9038c0136ab7e6bd1baf0e993a07bf23f18afbfb6e12c59adf665a622957", - "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/deprecated.ts": "a72a35de3cc7314e5ebea605ca23d08385b218ef171c32a3f135fb4318b08126", - "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/flags.ts": "3e62c4a9756b5705aada29e7e94847001356b3a83cd18ad56f4207387a71cf51", - "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/types.ts": "9e2f75edff2217d972fc711a21676a59dfd88378da2f1ace440ea84c07db1dcc", - "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/types/boolean.ts": "4c026dd66ec9c5436860dc6d0241427bdb8d8e07337ad71b33c08193428a2236", - "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/types/integer.ts": "b60d4d590f309ddddf066782d43e4dc3799f0e7d08e5ede7dc62a5ee94b9a6d9", - "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/types/number.ts": "610936e2d29de7c8c304b65489a75ebae17b005c6122c24e791fbed12444d51e", - "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/types/string.ts": "e89b6a5ce322f65a894edecdc48b44956ec246a1d881f03e97bbda90dd8638c5", - "https://deno.land/x/cliffy@v1.0.0-rc.3/table/_layout.ts": "e4a518da28333de95ad791208b9930025987c8b93d5f8b7f30b377b3e26b24e1", - "https://deno.land/x/cliffy@v1.0.0-rc.3/table/_utils.ts": "fd48d1a524a42e72aa3ad2eec858a92f5a00728d306c7e8436fba6c34314fee6", - "https://deno.land/x/cliffy@v1.0.0-rc.3/table/border.ts": "5c6e9ef5078c6930169aacb668b274bdbb498461c724a7693ac9270fe9d3f5d5", - "https://deno.land/x/cliffy@v1.0.0-rc.3/table/cell.ts": "1ffabd43b6b7fddfac9625cb0d015532e144702a9bfed03b358b79375115d06b", - "https://deno.land/x/cliffy@v1.0.0-rc.3/table/column.ts": "cf14009f2cb14bad156f879946186c1893acdc6a2fee6845db152edddb6a2714", - "https://deno.land/x/cliffy@v1.0.0-rc.3/table/consume_words.ts": "456e75755fdf6966abdefb8b783df2855e2a8bad6ddbdf21bd748547c5fc1d4b", - "https://deno.land/x/cliffy@v1.0.0-rc.3/table/deps.ts": "1226c4d39d53edc81d7c3e661fb8a79f2e704937c276c60355cd4947a0fe9153", - "https://deno.land/x/cliffy@v1.0.0-rc.3/table/row.ts": "79eb1468aafdd951e5963898cdafe0752d4ab4c519d5f847f3d8ecb8fe857d4f", - "https://deno.land/x/cliffy@v1.0.0-rc.3/table/table.ts": "298671e72e61f1ab18b42ae36643181993f79e29b39dc411fdc6ffd53aa04684" - } -} diff --git a/test/customized/main.ts b/test/customized/main.ts deleted file mode 100644 index 455cd8a..0000000 --- a/test/customized/main.ts +++ /dev/null @@ -1,23 +0,0 @@ -// just another script to test caching of multiple scripts: -/** - * taken from - * https://deno.land/x/cliffy@v1.0.0-rc.3/examples/command.ts - */ - -import { Command } from "cliffy/command/mod.ts"; - -await new Command() - .name("reverse-proxy") - .description("A simple reverse proxy example cli.") - .version("v1.0.0") - .option("-p, --port ", "The port number for the local server.", { - default: 8080, - }) - .option("--host ", "The host name for the local server.", { - default: "localhost", - }) - .arguments("[domain]") - .action(({ port, host }) => { - console.log(`Listening on http://${host}:${port}`); - }) - .parse(); From 012e95fcea7fd8fdb5ca1e108de35ed697e97828 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 26 Dec 2023 23:55:14 +0000 Subject: [PATCH 18/18] chore: build action bundle --- dist/cache.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dist/cache.js b/dist/cache.js index b9c94ca..c06a0a4 100755 --- a/dist/cache.js +++ b/dist/cache.js @@ -1,2 +1,3 @@ #!/usr/bin/env -S deno run --no-lock --allow-read --allow-run=deno --allow-env=CI,DENO_DIR -class AssertionError extends Error{constructor(message){super(message);this.name="AssertionError";}}function assert(expr,msg=""){if(!expr){throw new AssertionError(msg);}}const{hasOwn}=Object;function get(obj,key){if(hasOwn(obj,key)){return obj[key];}}function getForce(obj,key){const v=get(obj,key);assert(v!==undefined);return v;}function isNumber(x){if(typeof x==="number")return true;if(/^0x[0-9a-f]+$/i.test(String(x)))return true;return/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(String(x));}function hasKey(obj,keys){let o=obj;keys.slice(0,-1).forEach(key=>{o=get(o,key)??{};});const key=keys[keys.length-1];return hasOwn(o,key);}function parseArgs(args,{"--":doubleDash=false,alias={},boolean:__boolean=false,default:defaults={},stopEarly=false,string=[],collect=[],negatable=[],unknown=i=>i}={}){const aliases={};const flags={bools:{},strings:{},unknownFn:unknown,allBools:false,collect:{},negatable:{}};if(alias!==undefined){for(const key in alias){const val=getForce(alias,key);if(typeof val==="string"){aliases[key]=[val];}else{aliases[key]=val;}for(const alias of getForce(aliases,key)){aliases[alias]=[key].concat(aliases[key].filter(y=>alias!==y));}}}if(__boolean!==undefined){if(typeof __boolean==="boolean"){flags.allBools=!!__boolean;}else{const booleanArgs=typeof __boolean==="string"?[__boolean]:__boolean;for(const key of booleanArgs.filter(Boolean)){flags.bools[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.bools[al]=true;}}}}}if(string!==undefined){const stringArgs=typeof string==="string"?[string]:string;for(const key of stringArgs.filter(Boolean)){flags.strings[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.strings[al]=true;}}}}if(collect!==undefined){const collectArgs=typeof collect==="string"?[collect]:collect;for(const key of collectArgs.filter(Boolean)){flags.collect[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.collect[al]=true;}}}}if(negatable!==undefined){const negatableArgs=typeof negatable==="string"?[negatable]:negatable;for(const key of negatableArgs.filter(Boolean)){flags.negatable[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.negatable[al]=true;}}}}const argv={_:[]};function argDefined(key,arg){return flags.allBools&&/^--[^=]+$/.test(arg)||get(flags.bools,key)||!!get(flags.strings,key)||!!get(aliases,key);}function setKey(obj,name,value,collect=true){let o=obj;const keys=name.split(".");keys.slice(0,-1).forEach(function(key){if(get(o,key)===undefined){o[key]={};}o=get(o,key);});const key=keys[keys.length-1];const collectable=collect&&!!get(flags.collect,name);if(!collectable){o[key]=value;}else if(get(o,key)===undefined){o[key]=[value];}else if(Array.isArray(get(o,key))){o[key].push(value);}else{o[key]=[get(o,key),value];}}function setArg(key,val,arg=undefined,collect){if(arg&&flags.unknownFn&&!argDefined(key,arg)){if(flags.unknownFn(arg,key,val)===false)return;}const value=!get(flags.strings,key)&&isNumber(val)?Number(val):val;setKey(argv,key,value,collect);const alias=get(aliases,key);if(alias){for(const x of alias){setKey(argv,x,value,collect);}}}function aliasIsBoolean(key){return getForce(aliases,key).some(x=>typeof get(flags.bools,x)==="boolean");}let notFlags=[];if(args.includes("--")){notFlags=args.slice(args.indexOf("--")+1);args=args.slice(0,args.indexOf("--"));}for(let i=0;i>4];dst[i*2+1]=hexTable[v&15];}return textDecoder.decode(dst);}const osType=(()=>{const{Deno:Deno1}=globalThis;if(typeof Deno1?.build?.os==="string"){return Deno1.build.os;}const{navigator}=globalThis;if(navigator?.appVersion?.includes?.("Win")){return"windows";}return"linux";})();const isWindows=osType==="windows";function assertPath(path){if(typeof path!=="string"){throw new TypeError(`Path must be a string. Received ${JSON.stringify(path)}`);}}function assertArg(path){assertPath(path);if(path.length===0)return".";}const CHAR_FORWARD_SLASH=47;function normalizeString(path,allowAboveRoot,separator,isPathSeparator){let res="";let lastSegmentLength=0;let lastSlash=-1;let dots=0;let code;for(let i=0,len=path.length;i<=len;++i){if(i2){const lastSlashIndex=res.lastIndexOf(separator);if(lastSlashIndex===-1){res="";lastSegmentLength=0;}else{res=res.slice(0,lastSlashIndex);lastSegmentLength=res.length-1-res.lastIndexOf(separator);}lastSlash=i;dots=0;continue;}else if(res.length===2||res.length===1){res="";lastSegmentLength=0;lastSlash=i;dots=0;continue;}}if(allowAboveRoot){if(res.length>0)res+=`${separator}..`;else res="..";lastSegmentLength=2;}}else{if(res.length>0)res+=separator+path.slice(lastSlash+1,i);else res=path.slice(lastSlash+1,i);lastSegmentLength=i-lastSlash-1;}lastSlash=i;dots=0;}else if(code===46&&dots!==-1){++dots;}else{dots=-1;}}return res;}function isPosixPathSeparator(code){return code===47;}function normalize(path){assertArg(path);const isAbsolute=isPosixPathSeparator(path.charCodeAt(0));const trailingSeparator=isPosixPathSeparator(path.charCodeAt(path.length-1));path=normalizeString(path,!isAbsolute,"/",isPosixPathSeparator);if(path.length===0&&!isAbsolute)path=".";if(path.length>0&&trailingSeparator)path+="/";if(isAbsolute)return`/${path}`;return path;}function join(...paths){if(paths.length===0)return".";let joined;for(let i=0,len=paths.length;i0){if(!joined)joined=path;else joined+=`/${path}`;}}if(!joined)return".";return normalize(joined);}function isPathSeparator(code){return code===47||code===92;}function isWindowsDeviceRoot(code){return code>=97&&code<=122||code>=65&&code<=90;}function normalize1(path){assertArg(path);const len=path.length;let rootEnd=0;let device;let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){return"\\";}let tail;if(rootEnd0&&isPathSeparator(path.charCodeAt(len-1))){tail+="\\";}if(device===undefined){if(isAbsolute){if(tail.length>0)return`\\${tail}`;else return"\\";}else if(tail.length>0){return tail;}else{return"";}}else if(isAbsolute){if(tail.length>0)return`${device}\\${tail}`;else return`${device}\\`;}else if(tail.length>0){return device+tail;}else{return device;}}function join1(...paths){if(paths.length===0)return".";let joined;let firstPart=null;for(let i=0;i0){if(joined===undefined)joined=firstPart=path;else joined+=`\\${path}`;}}if(joined===undefined)return".";let needsReplace=true;let slashCount=0;assert(firstPart!==null);if(isPathSeparator(firstPart.charCodeAt(0))){++slashCount;const firstLen=firstPart.length;if(firstLen>1){if(isPathSeparator(firstPart.charCodeAt(1))){++slashCount;if(firstLen>2){if(isPathSeparator(firstPart.charCodeAt(2)))++slashCount;else{needsReplace=false;}}}}}if(needsReplace){for(;slashCount=2)joined=`\\${joined.slice(slashCount)}`;}return normalize1(joined);}function join2(...paths){return isWindows?join1(...paths):join(...paths);}function assertArg1(url){url=url instanceof URL?url:new URL(url);if(url.protocol!=="file:"){throw new TypeError("Must be a file URL.");}return url;}function fromFileUrl(url){url=assertArg1(url);return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"));}function fromFileUrl1(url){url=assertArg1(url);let path=decodeURIComponent(url.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");if(url.hostname!==""){path=`\\\\${url.hostname}${path}`;}return path;}function fromFileUrl2(url){return isWindows?fromFileUrl1(url):fromFileUrl(url);}function toPathString(pathUrl){return pathUrl instanceof URL?fromFileUrl2(pathUrl):pathUrl;}function stripTrailingSeparators(segment,isSep){if(segment.length<=1){return segment;}let end=segment.length;for(let i=segment.length-1;i>0;i--){if(isSep(segment.charCodeAt(i))){end=i;}else{break;}}return segment.slice(0,end);}function resolve(...pathSegments){let resolvedPath="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1&&!resolvedAbsolute;i--){let path;if(i>=0)path=pathSegments[i];else{const{Deno:Deno1}=globalThis;if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();}assertPath(path);if(path.length===0){continue;}resolvedPath=`${path}/${resolvedPath}`;resolvedAbsolute=isPosixPathSeparator(path.charCodeAt(0));}resolvedPath=normalizeString(resolvedPath,!resolvedAbsolute,"/",isPosixPathSeparator);if(resolvedAbsolute){if(resolvedPath.length>0)return`/${resolvedPath}`;else return"/";}else if(resolvedPath.length>0)return resolvedPath;else return".";}function resolve1(...pathSegments){let resolvedDevice="";let resolvedTail="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1;i--){let path;const{Deno:Deno1}=globalThis;if(i>=0){path=pathSegments[i];}else if(!resolvedDevice){if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a drive-letter-less path without a CWD.");}path=Deno1.cwd();}else{if(typeof Deno1?.env?.get!=="function"||typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();if(path===undefined||path.slice(0,3).toLowerCase()!==`${resolvedDevice.toLowerCase()}\\`){path=`${resolvedDevice}\\`;}}assertPath(path);const len=path.length;if(len===0)continue;let rootEnd=0;let device="";let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){rootEnd=1;isAbsolute=true;}if(device.length>0&&resolvedDevice.length>0&&device.toLowerCase()!==resolvedDevice.toLowerCase()){continue;}if(resolvedDevice.length===0&&device.length>0){resolvedDevice=device;}if(!resolvedAbsolute){resolvedTail=`${path.slice(rootEnd)}\\${resolvedTail}`;resolvedAbsolute=isAbsolute;}if(resolvedAbsolute&&resolvedDevice.length>0)break;}resolvedTail=normalizeString(resolvedTail,!resolvedAbsolute,"\\",isPathSeparator);return resolvedDevice+(resolvedAbsolute?"\\":"")+resolvedTail||".";}Deno.build.os==="windows";async function exists(path,options){try{const stat=await Deno.stat(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if((await Deno.permissions.query({name:"read",path})).state==="granted"){return!options?.isReadable;}}throw error;}}function existsSync(path,options){try{const stat=Deno.statSync(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if(Deno.permissions.querySync({name:"read",path}).state==="granted"){return!options?.isReadable;}}throw error;}}function normalize2(path){return isWindows?normalize1(path):normalize(path);}function stripSuffix(name,suffix){if(suffix.length>=name.length){return name;}const lenDiff=name.length-suffix.length;for(let i=suffix.length-1;i>=0;--i){if(name.charCodeAt(lenDiff+i)!==suffix.charCodeAt(i)){return name;}}return name.slice(0,-suffix.length);}function lastPathSegment(path,isSep,start=0){let matchedNonSeparator=false;let end=path.length;for(let i=path.length-1;i>=start;--i){if(isSep(path.charCodeAt(i))){if(matchedNonSeparator){start=i+1;break;}}else if(!matchedNonSeparator){matchedNonSeparator=true;end=i+1;}}return path.slice(start,end);}function assertArgs(path,suffix){assertPath(path);if(path.length===0)return path;if(typeof suffix!=="string"){throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);}}function basename(path,suffix=""){assertArgs(path,suffix);const lastSegment=lastPathSegment(path,isPosixPathSeparator);const strippedSegment=stripTrailingSeparators(lastSegment,isPosixPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename1(path,suffix=""){assertArgs(path,suffix);let start=0;if(path.length>=2){const drive=path.charCodeAt(0);if(isWindowsDeviceRoot(drive)){if(path.charCodeAt(1)===58)start=2;}}const lastSegment=lastPathSegment(path,isPathSeparator,start);const strippedSegment=stripTrailingSeparators(lastSegment,isPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename2(path,suffix=""){return isWindows?basename1(path,suffix):basename(path,suffix);}async function createWalkEntry(path){path=toPathString(path);path=normalize2(path);const name=basename2(path);const info=await Deno.stat(path);return{path,name,isFile:info.isFile,isDirectory:info.isDirectory,isSymlink:info.isSymlink};}class WalkError extends Error{root;constructor(cause,root){super(`${cause instanceof Error?cause.message:cause} for path "${root}"`);this.cause=cause;this.name="WalkError";this.root=root;}}function include(path,exts,match,skip){if(exts&&!exts.some(ext=>path.endsWith(ext))){return false;}if(match&&!match.some(pattern=>!!path.match(pattern))){return false;}if(skip&&skip.some(pattern=>!!path.match(pattern))){return false;}return true;}function wrapErrorWithPath(err,root){if(err instanceof WalkError)return err;return new WalkError(err,root);}async function*walk(root,{maxDepth=Infinity,includeFiles=true,includeDirs=true,includeSymlinks=true,followSymlinks=false,canonicalize=true,exts=undefined,match=undefined,skip=undefined}={}){if(maxDepth<0){return;}root=toPathString(root);if(includeDirs&&include(root,exts,match,skip)){yield await createWalkEntry(root);}if(maxDepth<1||!include(root,undefined,undefined,skip)){return;}try{for await(const entry of Deno.readDir(root)){let path=join2(root,entry.name);let{isSymlink,isDirectory}=entry;if(isSymlink){if(!followSymlinks){if(includeSymlinks&&include(path,exts,match,skip)){yield{path,...entry};}continue;}const realPath=await Deno.realPath(path);if(canonicalize){path=realPath;}({isSymlink,isDirectory}=await Deno.lstat(realPath));}if(isSymlink||isDirectory){yield*walk(path,{maxDepth:maxDepth-1,includeFiles,includeDirs,includeSymlinks,followSymlinks,exts,match,skip});}else if(includeFiles&&include(path,exts,match,skip)){yield{path,...entry};}}}catch(err){throw wrapErrorWithPath(err,normalize2(root));}}Deno.build.os==="windows";new Deno.errors.AlreadyExists("dest already exists.");Deno.build.os==="windows";const LF="\n";const CRLF="\r\n";Deno?.build.os==="windows"?CRLF:LF;function parse(text,{allowTrailingComma=true}={}){if(new.target){throw new TypeError("parse is not a constructor");}return new JSONCParser(text,{allowTrailingComma}).parse();}const originalJSONParse=globalThis.JSON.parse;class JSONCParser{#whitespace=new Set(" \r\n");#numberEndToken=new Set([..."[]{}:,/",...this.#whitespace]);#text;#length;#tokenized;#options;constructor(text,options){this.#text=`${text}`;this.#length=this.#text.length;this.#tokenized=this.#tokenize();this.#options=options;}parse(){const token=this.#getNext();const res=this.#parseJsonValue(token);const{done,value}=this.#tokenized.next();if(!done){throw new SyntaxError(buildErrorMessage(value));}return res;}#getNext(){const{done,value}=this.#tokenized.next();if(done){throw new SyntaxError("Unexpected end of JSONC input");}return value;}*#tokenize(){for(let i=0;iisNaN(Number(key)));const byLevel={[LogLevels.NOTSET]:"NOTSET",[LogLevels.DEBUG]:"DEBUG",[LogLevels.INFO]:"INFO",[LogLevels.WARNING]:"WARNING",[LogLevels.ERROR]:"ERROR",[LogLevels.CRITICAL]:"CRITICAL"};function getLevelByName(name){const level=LogLevels[name];if(level!==undefined){return level;}throw new Error(`no log level found for name: ${name}`);}function getLevelName(level){const levelName=byLevel[level];if(levelName){return levelName;}throw new Error(`no level name found for level: ${level}`);}class LogRecord{msg;#args;#datetime;level;levelName;loggerName;constructor(options){this.msg=options.msg;this.#args=[...options.args];this.level=options.level;this.loggerName=options.loggerName;this.#datetime=new Date;this.levelName=getLevelName(options.level);}get args(){return[...this.#args];}get datetime(){return new Date(this.#datetime.getTime());}}class Logger{#level;#handlers;#loggerName;constructor(loggerName,levelName,options={}){this.#loggerName=loggerName;this.#level=getLevelByName(levelName);this.#handlers=options.handlers||[];}get level(){return this.#level;}set level(level){try{this.#level=getLevelByName(getLevelName(level));}catch(_){throw new TypeError(`Invalid log level: ${level}`);}}get levelName(){return getLevelName(this.#level);}set levelName(levelName){this.#level=getLevelByName(levelName);}get loggerName(){return this.#loggerName;}set handlers(hndls){this.#handlers=hndls;}get handlers(){return this.#handlers;}#_log(level,msg,...args){if(this.level>level){return msg instanceof Function?undefined:msg;}let fnResult;let logMessage;if(msg instanceof Function){fnResult=msg();logMessage=this.asString(fnResult);}else{logMessage=this.asString(msg);}const record=new LogRecord({msg:logMessage,args:args,level:level,loggerName:this.loggerName});this.#handlers.forEach(handler=>{handler.handle(record);});return msg instanceof Function?fnResult:msg;}asString(data,isProperty=false){if(typeof data==="string"){if(isProperty)return`"${data}"`;return data;}else if(data===null||typeof data==="number"||typeof data==="bigint"||typeof data==="boolean"||typeof data==="undefined"||typeof data==="symbol"){return String(data);}else if(data instanceof Error){return data.stack;}else if(typeof data==="object"){return`{${Object.entries(data).map(([k,v])=>`"${k}":${this.asString(v,true)}`).join(",")}}`;}return"undefined";}debug(msg,...args){return this.#_log(LogLevels.DEBUG,msg,...args);}info(msg,...args){return this.#_log(LogLevels.INFO,msg,...args);}warning(msg,...args){return this.#_log(LogLevels.WARNING,msg,...args);}error(msg,...args){return this.#_log(LogLevels.ERROR,msg,...args);}critical(msg,...args){return this.#_log(LogLevels.CRITICAL,msg,...args);}}const{Deno:Deno1}=globalThis;const noColor=typeof Deno1?.noColor==="boolean"?Deno1.noColor:false;let enabled=!noColor;function code(open,close){return{open:`\x1b[${open.join(";")}m`,close:`\x1b[${close}m`,regexp:new RegExp(`\\x1b\\[${close}m`,"g")};}function run(str,code){return enabled?`${code.open}${str.replace(code.regexp,code.open)}${code.close}`:str;}function bold(str){return run(str,code([1],22));}function red(str){return run(str,code([31],39));}function yellow(str){return run(str,code([33],39));}function blue(str){return run(str,code([34],39));}new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"),"g");function copy(src,dst,off=0){off=Math.max(0,Math.min(off,dst.byteLength));const dstBytesAvailable=dst.byteLength-off;if(src.byteLength>dstBytesAvailable){src=src.subarray(0,dstBytesAvailable);}dst.set(src,off);return src.byteLength;}class AbstractBufBase{buf;usedBufferBytes=0;err=null;constructor(buf){this.buf=buf;}size(){return this.buf.byteLength;}available(){return this.buf.byteLength-this.usedBufferBytes;}buffered(){return this.usedBufferBytes;}}class BufWriterSync extends AbstractBufBase{#writer;static create(writer,size=4096){return writer instanceof BufWriterSync?writer:new BufWriterSync(writer,size);}constructor(writer,size=4096){super(new Uint8Array(size<=0?4096:size));this.#writer=writer;}reset(w){this.err=null;this.usedBufferBytes=0;this.#writer=w;}flush(){if(this.err!==null)throw this.err;if(this.usedBufferBytes===0)return;try{const p=this.buf.subarray(0,this.usedBufferBytes);let nwritten=0;while(nwrittenthis.available()){if(this.buffered()===0){try{numBytesWritten=this.#writer.writeSync(data);}catch(e){if(e instanceof Error){this.err=e;}throw e;}}else{numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;this.flush();}totalBytesWritten+=numBytesWritten;data=data.subarray(numBytesWritten);}numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;totalBytesWritten+=numBytesWritten;return totalBytesWritten;}}const DEFAULT_FORMATTER="{levelName} {msg}";class BaseHandler{level;levelName;formatter;constructor(levelName,options={}){this.level=getLevelByName(levelName);this.levelName=levelName;this.formatter=options.formatter||DEFAULT_FORMATTER;}handle(logRecord){if(this.level>logRecord.level)return;const msg=this.format(logRecord);this.log(msg);}format(logRecord){if(this.formatter instanceof Function){return this.formatter(logRecord);}return this.formatter.replace(/{([^\s}]+)}/g,(match,p1)=>{const value=logRecord[p1];if(value===undefined){return match;}return String(value);});}log(_msg){}setup(){}destroy(){}}class ConsoleHandler extends BaseHandler{#useColors;constructor(levelName,options={}){super(levelName,options);this.#useColors=options.useColors??true;}format(logRecord){let msg=super.format(logRecord);if(this.#useColors){msg=this.applyColors(msg,logRecord.level);}return msg;}applyColors(msg,level){switch(level){case LogLevels.INFO:msg=blue(msg);break;case LogLevels.WARNING:msg=yellow(msg);break;case LogLevels.ERROR:msg=red(msg);break;case LogLevels.CRITICAL:msg=bold(red(msg));break;default:break;}return msg;}log(msg){console.log(msg);}}class WriterHandler extends BaseHandler{_writer;#encoder=new TextEncoder;}class FileHandler extends WriterHandler{_file;_buf;_filename;_mode;_openOptions;_encoder=new TextEncoder;#unloadCallback=(()=>{this.destroy();}).bind(this);constructor(levelName,options){super(levelName,options);this._filename=options.filename;this._mode=options.mode?options.mode:"a";this._openOptions={createNew:this._mode==="x",create:this._mode!=="x",append:this._mode==="a",truncate:this._mode!=="a",write:true};}setup(){this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);addEventListener("unload",this.#unloadCallback);}handle(logRecord){super.handle(logRecord);if(logRecord.level>LogLevels.ERROR){this.flush();}}log(msg){if(this._encoder.encode(msg).byteLength+1>this._buf.available()){this.flush();}this._buf.writeSync(this._encoder.encode(msg+"\n"));}flush(){if(this._buf?.buffered()>0){this._buf.flush();}}destroy(){this.flush();this._file?.close();this._file=undefined;removeEventListener("unload",this.#unloadCallback);}}class RotatingFileHandler extends FileHandler{#maxBytes;#maxBackupCount;#currentFileSize=0;constructor(levelName,options){super(levelName,options);this.#maxBytes=options.maxBytes;this.#maxBackupCount=options.maxBackupCount;}setup(){if(this.#maxBytes<1){this.destroy();throw new Error("maxBytes cannot be less than 1");}if(this.#maxBackupCount<1){this.destroy();throw new Error("maxBackupCount cannot be less than 1");}super.setup();if(this._mode==="w"){for(let i=1;i<=this.#maxBackupCount;i++){try{Deno.removeSync(this._filename+"."+i);}catch(error){if(!(error instanceof Deno.errors.NotFound)){throw error;}}}}else if(this._mode==="x"){for(let i=1;i<=this.#maxBackupCount;i++){if(existsSync(this._filename+"."+i)){this.destroy();throw new Deno.errors.AlreadyExists("Backup log file "+this._filename+"."+i+" already exists");}}}else{this.#currentFileSize=Deno.statSync(this._filename).size;}}log(msg){const msgByteLength=this._encoder.encode(msg).byteLength+1;if(this.#currentFileSize+msgByteLength>this.#maxBytes){this.rotateLogFiles();this.#currentFileSize=0;}super.log(msg);this.#currentFileSize+=msgByteLength;}rotateLogFiles(){this._buf.flush();this._file.close();for(let i=this.#maxBackupCount-1;i>=0;i--){const source=this._filename+(i===0?"":"."+i);const dest=this._filename+"."+(i+1);if(existsSync(source)){Deno.renameSync(source,dest);}}this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);}}const DEFAULT_LEVEL="INFO";const DEFAULT_CONFIG={handlers:{default:new ConsoleHandler(DEFAULT_LEVEL)},loggers:{default:{level:DEFAULT_LEVEL,handlers:["default"]}}};const state={handlers:new Map,loggers:new Map,config:DEFAULT_CONFIG};const handlers={BaseHandler,ConsoleHandler,WriterHandler,FileHandler,RotatingFileHandler};function getLogger(name){if(!name){const d=state.loggers.get("default");assert(d!==undefined,`"default" logger must be set for getting logger without name`);return d;}const result=state.loggers.get(name);if(!result){const logger=new Logger(name,"NOTSET",{handlers:[]});state.loggers.set(name,logger);return logger;}return result;}function debug(msg,...args){if(msg instanceof Function){return getLogger("default").debug(msg,...args);}return getLogger("default").debug(msg,...args);}function info(msg,...args){if(msg instanceof Function){return getLogger("default").info(msg,...args);}return getLogger("default").info(msg,...args);}function warning(msg,...args){if(msg instanceof Function){return getLogger("default").warning(msg,...args);}return getLogger("default").warning(msg,...args);}function error(msg,...args){if(msg instanceof Function){return getLogger("default").error(msg,...args);}return getLogger("default").error(msg,...args);}function setup(config){state.config={handlers:{...DEFAULT_CONFIG.handlers,...config.handlers},loggers:{...DEFAULT_CONFIG.loggers,...config.loggers}};state.handlers.forEach(handler=>{handler.destroy();});state.handlers.clear();const handlers=state.config.handlers||{};for(const handlerName in handlers){const handler=handlers[handlerName];handler.setup();state.handlers.set(handlerName,handler);}state.loggers.clear();const loggers=state.config.loggers||{};for(const loggerName in loggers){const loggerConfig=loggers[loggerName];const handlerNames=loggerConfig.handlers||[];const handlers=[];handlerNames.forEach(handlerName=>{const handler=state.handlers.get(handlerName);if(handler){handlers.push(handler);}});const levelName=loggerConfig.level||DEFAULT_LEVEL;const logger=new Logger(loggerName,levelName,{handlers:handlers});state.loggers.set(loggerName,logger);}}setup(DEFAULT_CONFIG);function assertArgs1(from,to){assertPath(from);assertPath(to);if(from===to)return"";}function relative(from,to){assertArgs1(from,to);from=resolve(from);to=resolve(to);if(from===to)return"";let fromStart=1;const fromEnd=from.length;for(;fromStartlength){if(isPosixPathSeparator(to.charCodeAt(toStart+i))){return to.slice(toStart+i+1);}else if(i===0){return to.slice(toStart+i);}}else if(fromLen>length){if(isPosixPathSeparator(from.charCodeAt(fromStart+i))){lastCommonSep=i;}else if(i===0){lastCommonSep=0;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(isPosixPathSeparator(fromCode))lastCommonSep=i;}let out="";for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||isPosixPathSeparator(from.charCodeAt(i))){if(out.length===0)out+="..";else out+="/..";}}if(out.length>0)return out+to.slice(toStart+lastCommonSep);else{toStart+=lastCommonSep;if(isPosixPathSeparator(to.charCodeAt(toStart)))++toStart;return to.slice(toStart);}}function relative1(from,to){assertArgs1(from,to);const fromOrig=resolve1(from);const toOrig=resolve1(to);if(fromOrig===toOrig)return"";from=fromOrig.toLowerCase();to=toOrig.toLowerCase();if(from===to)return"";let fromStart=0;let fromEnd=from.length;for(;fromStartfromStart;--fromEnd){if(from.charCodeAt(fromEnd-1)!==92)break;}const fromLen=fromEnd-fromStart;let toStart=0;let toEnd=to.length;for(;toStarttoStart;--toEnd){if(to.charCodeAt(toEnd-1)!==92)break;}const toLen=toEnd-toStart;const length=fromLenlength){if(to.charCodeAt(toStart+i)===92){return toOrig.slice(toStart+i+1);}else if(i===2){return toOrig.slice(toStart+i);}}if(fromLen>length){if(from.charCodeAt(fromStart+i)===92){lastCommonSep=i;}else if(i===2){lastCommonSep=3;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(fromCode===92)lastCommonSep=i;}if(i!==length&&lastCommonSep===-1){return toOrig;}let out="";if(lastCommonSep===-1)lastCommonSep=0;for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||from.charCodeAt(i)===92){if(out.length===0)out+="..";else out+="\\..";}}if(out.length>0){return out+toOrig.slice(toStart+lastCommonSep,toEnd);}else{toStart+=lastCommonSep;if(toOrig.charCodeAt(toStart)===92)++toStart;return toOrig.slice(toStart,toEnd);}}function relative2(from,to){return isWindows?relative1(from,to):relative(from,to);}var m=Object.create;var E=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),D=(t,e)=>{for(var s in e)E(t,s,{get:e[s],enumerable:!0});},a=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!b.call(t,n)&&n!==s&&E(t,n,{get:()=>e[n],enumerable:!(r=T(e,n))||r.enumerable});return t;},_=(t,e,s)=>(a(t,e,"default"),s&&a(s,e,"default")),$=(t,e,s)=>(s=t!=null?m(X(t)):{},a(e||!t||!t.__esModule?E(s,"default",{value:t,enumerable:!0}):s,t));var A=w((ct,v)=>{function C(t){return Array.isArray(t)?t:[t];}var N="",P=" ",h="\\",H=/^\s+$/,F=/(?:[^\\]|^)\\$/,k=/^\\!/,z=/^\\#/,B=/\r?\n/g,K=/^\.*\/|^\.+$/,d="/",x="node-ignore";typeof Symbol<"u"&&(x=Symbol.for("node-ignore"));var L=x,V=(t,e,s)=>Object.defineProperty(t,e,{value:s}),j=/([0-z])-([0-z])/g,G=()=>!1,M=t=>t.replace(j,(e,s,r)=>s.charCodeAt(0)<=r.charCodeAt(0)?e:N),Y=t=>{let{length:e}=t;return t.slice(0,e-e%2);},W=[[/\\?\s+$/,t=>t.indexOf("\\")===0?P:N],[/\\\s/g,()=>P],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)";}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,s)=>e+6{let r=s.replace(/\\\*/g,"[^\\/]*");return e+r;}],[/\\\\\\(?=[$.|*+(){^])/g,()=>h],[/\\\\/g,()=>h],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,s,r,n)=>e===h?`\\[${s}${Y(r)}${n}`:n==="]"&&r.length%2===0?`[${M(s)}${r}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],S=Object.create(null),p=(t,e)=>{let s=S[t];return s||(s=W.reduce((r,n)=>r.replace(n[0],n[1].bind(t)),t),S[t]=s),e?new RegExp(s,"i"):new RegExp(s);},R=t=>typeof t=="string",q=t=>t&&R(t)&&!H.test(t)&&!F.test(t)&&t.indexOf("#")!==0,J=t=>t.split(B),f=class{constructor(e,s,r,n){this.origin=e,this.pattern=s,this.negative=r,this.regex=n;}},Q=(t,e)=>{let s=t,r=!1;t.indexOf("!")===0&&(r=!0,t=t.substr(1)),t=t.replace(k,"!").replace(z,"#");let n=p(t,e);return new f(s,t,r,n);},U=(t,e)=>{throw new e(t);},i=(t,e,s)=>R(t)?t?i.isNotRelative(t)?s(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:s("path must not be empty",TypeError):s(`path must be a string, but got \`${e}\``,TypeError),O=t=>K.test(t);i.isNotRelative=O;i.convert=t=>t;var g=class{constructor({ignorecase:e=!0,ignoreCase:s=e,allowRelativePaths:r=!1}={}){V(this,L,!0),this._rules=[],this._ignoreCase=s,this._allowRelativePaths=r,this._initCache();}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null);}_addPattern(e){if(e&&e[L]){this._rules=this._rules.concat(e._rules),this._added=!0;return;}if(q(e)){let s=Q(e,this._ignoreCase);this._added=!0,this._rules.push(s);}}add(e){return this._added=!1,C(R(e)?J(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this;}addPattern(e){return this.add(e);}_testOne(e,s){let r=!1,n=!1;return this._rules.forEach(o=>{let{negative:u}=o;if(n===u&&r!==n||u&&!r&&!n&&!s)return;o.regex.test(e)&&(r=!u,n=u);}),{ignored:r,unignored:n};}_test(e,s,r,n){let o=e&&i.convert(e);return i(o,e,this._allowRelativePaths?G:U),this._t(o,s,r,n);}_t(e,s,r,n){if(e in s)return s[e];if(n||(n=e.split(d)),n.pop(),!n.length)return s[e]=this._testOne(e,r);let o=this._t(n.join(d)+d,s,r,n);return s[e]=o.ignored?o:this._testOne(e,r);}ignores(e){return this._test(e,this._ignoreCache,!1).ignored;}createFilter(){return e=>!this.ignores(e);}filter(e){return C(e).filter(this.createFilter());}test(e){return this._test(e,this._testCache,!0);}},l=t=>new g(t),Z=t=>i(t&&i.convert(t),t,G);l.isPathValid=Z;l.default=l;v.exports=l;var tt=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");i.convert=tt;var et=/^[a-z]:\//i;i.isNotRelative=t=>et.test(t)||O(t);});var c={};D(c,{default:()=>nt});var st=$(A());_(c,$(A()));var{default:I,...rt}=st,nt=I!==void 0?I:rt;const importMeta={url:"file:///home/runner/work/setup-deno/setup-deno/cache.ts",main:import.meta.main};if(importMeta.main){const args=parseArgs(Deno.args,{boolean:["dry-run","verbose","lock-write"],negatable:["lock-write"],string:["config"],default:{"lock-write":true},alias:{"dry-run":"n",verbose:"v"},"--":true,unknown:arg=>{console.log(`Unknown argument: ${arg}`);console.log("Usage: cache [-n | --dry-run] [-v | --verbose] [--] [DENO_ARGS...]");Deno.exit(0);}});const denoDir=Deno.env.get("DENO_DIR");const logLevel=["1","true"].includes(Deno.env.get("CI")??"")?"DEBUG":args.verbose?"DEBUG":"INFO";setup({handlers:{console:new handlers.ConsoleHandler(logLevel,{formatter:logRecord=>Deno.noColor?logRecord.levelName+" "+logRecord.msg:logRecord.msg})},loggers:{default:{handlers:["console"],"level":logLevel}}});if(args["dry-run"])warning("dry-run mode enabled");if(args.config&&!await exists(args.config)){error(`config file ${args.config} not found`);Deno.exit(1);}const hash=await Deno.readFile("./deno.lock").then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>encodeHex(new Uint8Array(data))).catch(_=>"");debug(`GitHub actions deno.lock hash: ${hash}`);const cfgs=args.config?[args.config]:["deno.json","deno.jsonc"];const denoCfg=await Promise.all(cfgs.map(path=>Deno.readTextFile(path).catch(_=>undefined))).then(v=>parse(v.filter(Boolean)[0]??"{}"));const patterns=[...[denoCfg?.exclude??[]].flat(),...[denoCfg?.cache?.exclude??[]].flat(),...[denoCfg?.cache?.include??[]].flatMap(p=>`!${p}`)];debug(`patterns:`,patterns);patterns.forEach(p=>debug(`- ${p}`));const ig=nt().add(patterns);const walkIterator=walk(".",{exts:["js",".jsx",".ts",".tsx"],includeDirs:false});const paths=[];for await(const entry of walkIterator){const relativePath=relative2(".",entry.path);if(denoDir&&entry.path.startsWith(denoDir))continue;if(ig.ignores(relativePath)){debug(`ignored ${relativePath}`);continue;}debug(`caching ${relativePath}`);paths.push(relativePath);}const denoArgs=["cache",args["lock-write"]&&"--lock-write",args.config&&`--config=${args.config}`,...args["--"],...paths].filter(Boolean);const cmd=new Deno.Command(Deno.execPath(),{args:denoArgs});const cmdString=Deno.execPath()+" "+denoArgs.join(" ");if(args["dry-run"]){info(`would run: ${cmdString}`);Deno.exit(0);}debug(`running: ${cmdString}`);const{stderr,code}=await cmd.output();for(const line of new TextDecoder().decode(stderr).split("\n")){if(line.length>0)info("deno> "+line);}if(code===0)debug(`finished caching ${paths.length} files`);} \ No newline at end of file +class AssertionError extends Error{constructor(message){super(message);this.name="AssertionError";}}function assert(expr,msg=""){if(!expr){throw new AssertionError(msg);}}const{hasOwn}=Object;function get(obj,key){if(hasOwn(obj,key)){return obj[key];}}function getForce(obj,key){const v=get(obj,key);assert(v!==undefined);return v;}function isNumber(x){if(typeof x==="number")return true;if(/^0x[0-9a-f]+$/i.test(String(x)))return true;return/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(String(x));}function hasKey(obj,keys){let o=obj;keys.slice(0,-1).forEach(key=>{o=get(o,key)??{};});const key=keys[keys.length-1];return hasOwn(o,key);}function parseArgs(args,{"--":doubleDash=false,alias={},boolean:__boolean=false,default:defaults={},stopEarly=false,string=[],collect=[],negatable=[],unknown=i=>i}={}){const aliases={};const flags={bools:{},strings:{},unknownFn:unknown,allBools:false,collect:{},negatable:{}};if(alias!==undefined){for(const key in alias){const val=getForce(alias,key);if(typeof val==="string"){aliases[key]=[val];}else{aliases[key]=val;}for(const alias of getForce(aliases,key)){aliases[alias]=[key].concat(aliases[key].filter(y=>alias!==y));}}}if(__boolean!==undefined){if(typeof __boolean==="boolean"){flags.allBools=!!__boolean;}else{const booleanArgs=typeof __boolean==="string"?[__boolean]:__boolean;for(const key of booleanArgs.filter(Boolean)){flags.bools[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.bools[al]=true;}}}}}if(string!==undefined){const stringArgs=typeof string==="string"?[string]:string;for(const key of stringArgs.filter(Boolean)){flags.strings[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.strings[al]=true;}}}}if(collect!==undefined){const collectArgs=typeof collect==="string"?[collect]:collect;for(const key of collectArgs.filter(Boolean)){flags.collect[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.collect[al]=true;}}}}if(negatable!==undefined){const negatableArgs=typeof negatable==="string"?[negatable]:negatable;for(const key of negatableArgs.filter(Boolean)){flags.negatable[key]=true;const alias=get(aliases,key);if(alias){for(const al of alias){flags.negatable[al]=true;}}}}const argv={_:[]};function argDefined(key,arg){return flags.allBools&&/^--[^=]+$/.test(arg)||get(flags.bools,key)||!!get(flags.strings,key)||!!get(aliases,key);}function setKey(obj,name,value,collect=true){let o=obj;const keys=name.split(".");keys.slice(0,-1).forEach(function(key){if(get(o,key)===undefined){o[key]={};}o=get(o,key);});const key=keys[keys.length-1];const collectable=collect&&!!get(flags.collect,name);if(!collectable){o[key]=value;}else if(get(o,key)===undefined){o[key]=[value];}else if(Array.isArray(get(o,key))){o[key].push(value);}else{o[key]=[get(o,key),value];}}function setArg(key,val,arg=undefined,collect){if(arg&&flags.unknownFn&&!argDefined(key,arg)){if(flags.unknownFn(arg,key,val)===false)return;}const value=!get(flags.strings,key)&&isNumber(val)?Number(val):val;setKey(argv,key,value,collect);const alias=get(aliases,key);if(alias){for(const x of alias){setKey(argv,x,value,collect);}}}function aliasIsBoolean(key){return getForce(aliases,key).some(x=>typeof get(flags.bools,x)==="boolean");}let notFlags=[];if(args.includes("--")){notFlags=args.slice(args.indexOf("--")+1);args=args.slice(0,args.indexOf("--"));}for(let i=0;i>4];dst[i*2+1]=hexTable[v&15];}return textDecoder.decode(dst);}const osType=(()=>{const{Deno:Deno1}=globalThis;if(typeof Deno1?.build?.os==="string"){return Deno1.build.os;}const{navigator}=globalThis;if(navigator?.appVersion?.includes?.("Win")){return"windows";}return"linux";})();const isWindows=osType==="windows";function assertPath(path){if(typeof path!=="string"){throw new TypeError(`Path must be a string. Received ${JSON.stringify(path)}`);}}function assertArg(path){assertPath(path);if(path.length===0)return".";}const CHAR_FORWARD_SLASH=47;function normalizeString(path,allowAboveRoot,separator,isPathSeparator){let res="";let lastSegmentLength=0;let lastSlash=-1;let dots=0;let code;for(let i=0,len=path.length;i<=len;++i){if(i2){const lastSlashIndex=res.lastIndexOf(separator);if(lastSlashIndex===-1){res="";lastSegmentLength=0;}else{res=res.slice(0,lastSlashIndex);lastSegmentLength=res.length-1-res.lastIndexOf(separator);}lastSlash=i;dots=0;continue;}else if(res.length===2||res.length===1){res="";lastSegmentLength=0;lastSlash=i;dots=0;continue;}}if(allowAboveRoot){if(res.length>0)res+=`${separator}..`;else res="..";lastSegmentLength=2;}}else{if(res.length>0)res+=separator+path.slice(lastSlash+1,i);else res=path.slice(lastSlash+1,i);lastSegmentLength=i-lastSlash-1;}lastSlash=i;dots=0;}else if(code===46&&dots!==-1){++dots;}else{dots=-1;}}return res;}function isPosixPathSeparator(code){return code===47;}function normalize(path){assertArg(path);const isAbsolute=isPosixPathSeparator(path.charCodeAt(0));const trailingSeparator=isPosixPathSeparator(path.charCodeAt(path.length-1));path=normalizeString(path,!isAbsolute,"/",isPosixPathSeparator);if(path.length===0&&!isAbsolute)path=".";if(path.length>0&&trailingSeparator)path+="/";if(isAbsolute)return`/${path}`;return path;}function join(...paths){if(paths.length===0)return".";let joined;for(let i=0,len=paths.length;i0){if(!joined)joined=path;else joined+=`/${path}`;}}if(!joined)return".";return normalize(joined);}function isPathSeparator(code){return code===47||code===92;}function isWindowsDeviceRoot(code){return code>=97&&code<=122||code>=65&&code<=90;}function normalize1(path){assertArg(path);const len=path.length;let rootEnd=0;let device;let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){return"\\";}let tail;if(rootEnd0&&isPathSeparator(path.charCodeAt(len-1))){tail+="\\";}if(device===undefined){if(isAbsolute){if(tail.length>0)return`\\${tail}`;else return"\\";}else if(tail.length>0){return tail;}else{return"";}}else if(isAbsolute){if(tail.length>0)return`${device}\\${tail}`;else return`${device}\\`;}else if(tail.length>0){return device+tail;}else{return device;}}function join1(...paths){if(paths.length===0)return".";let joined;let firstPart=null;for(let i=0;i0){if(joined===undefined)joined=firstPart=path;else joined+=`\\${path}`;}}if(joined===undefined)return".";let needsReplace=true;let slashCount=0;assert(firstPart!==null);if(isPathSeparator(firstPart.charCodeAt(0))){++slashCount;const firstLen=firstPart.length;if(firstLen>1){if(isPathSeparator(firstPart.charCodeAt(1))){++slashCount;if(firstLen>2){if(isPathSeparator(firstPart.charCodeAt(2)))++slashCount;else{needsReplace=false;}}}}}if(needsReplace){for(;slashCount=2)joined=`\\${joined.slice(slashCount)}`;}return normalize1(joined);}function join2(...paths){return isWindows?join1(...paths):join(...paths);}function assertArg1(url){url=url instanceof URL?url:new URL(url);if(url.protocol!=="file:"){throw new TypeError("Must be a file URL.");}return url;}function fromFileUrl(url){url=assertArg1(url);return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"));}function fromFileUrl1(url){url=assertArg1(url);let path=decodeURIComponent(url.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");if(url.hostname!==""){path=`\\\\${url.hostname}${path}`;}return path;}function fromFileUrl2(url){return isWindows?fromFileUrl1(url):fromFileUrl(url);}function toPathString(pathUrl){return pathUrl instanceof URL?fromFileUrl2(pathUrl):pathUrl;}function stripTrailingSeparators(segment,isSep){if(segment.length<=1){return segment;}let end=segment.length;for(let i=segment.length-1;i>0;i--){if(isSep(segment.charCodeAt(i))){end=i;}else{break;}}return segment.slice(0,end);}function resolve(...pathSegments){let resolvedPath="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1&&!resolvedAbsolute;i--){let path;if(i>=0)path=pathSegments[i];else{const{Deno:Deno1}=globalThis;if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();}assertPath(path);if(path.length===0){continue;}resolvedPath=`${path}/${resolvedPath}`;resolvedAbsolute=isPosixPathSeparator(path.charCodeAt(0));}resolvedPath=normalizeString(resolvedPath,!resolvedAbsolute,"/",isPosixPathSeparator);if(resolvedAbsolute){if(resolvedPath.length>0)return`/${resolvedPath}`;else return"/";}else if(resolvedPath.length>0)return resolvedPath;else return".";}function resolve1(...pathSegments){let resolvedDevice="";let resolvedTail="";let resolvedAbsolute=false;for(let i=pathSegments.length-1;i>=-1;i--){let path;const{Deno:Deno1}=globalThis;if(i>=0){path=pathSegments[i];}else if(!resolvedDevice){if(typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a drive-letter-less path without a CWD.");}path=Deno1.cwd();}else{if(typeof Deno1?.env?.get!=="function"||typeof Deno1?.cwd!=="function"){throw new TypeError("Resolved a relative path without a CWD.");}path=Deno1.cwd();if(path===undefined||path.slice(0,3).toLowerCase()!==`${resolvedDevice.toLowerCase()}\\`){path=`${resolvedDevice}\\`;}}assertPath(path);const len=path.length;if(len===0)continue;let rootEnd=0;let device="";let isAbsolute=false;const code=path.charCodeAt(0);if(len>1){if(isPathSeparator(code)){isAbsolute=true;if(isPathSeparator(path.charCodeAt(1))){let j=2;let last=j;for(;j2){if(isPathSeparator(path.charCodeAt(2))){isAbsolute=true;rootEnd=3;}}}}}else if(isPathSeparator(code)){rootEnd=1;isAbsolute=true;}if(device.length>0&&resolvedDevice.length>0&&device.toLowerCase()!==resolvedDevice.toLowerCase()){continue;}if(resolvedDevice.length===0&&device.length>0){resolvedDevice=device;}if(!resolvedAbsolute){resolvedTail=`${path.slice(rootEnd)}\\${resolvedTail}`;resolvedAbsolute=isAbsolute;}if(resolvedAbsolute&&resolvedDevice.length>0)break;}resolvedTail=normalizeString(resolvedTail,!resolvedAbsolute,"\\",isPathSeparator);return resolvedDevice+(resolvedAbsolute?"\\":"")+resolvedTail||".";}Deno.build.os==="windows";async function exists(path,options){try{const stat=await Deno.stat(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if((await Deno.permissions.query({name:"read",path})).state==="granted"){return!options?.isReadable;}}throw error;}}function existsSync(path,options){try{const stat=Deno.statSync(path);if(options&&(options.isReadable||options.isDirectory||options.isFile)){if(options.isDirectory&&options.isFile){throw new TypeError("ExistsOptions.options.isDirectory and ExistsOptions.options.isFile must not be true together.");}if(options.isDirectory&&!stat.isDirectory||options.isFile&&!stat.isFile){return false;}if(options.isReadable){if(stat.mode===null){return true;}if(Deno.uid()===stat.uid){return(stat.mode&256)===256;}else if(Deno.gid()===stat.gid){return(stat.mode&32)===32;}return(stat.mode&4)===4;}}return true;}catch(error){if(error instanceof Deno.errors.NotFound){return false;}if(error instanceof Deno.errors.PermissionDenied){if(Deno.permissions.querySync({name:"read",path}).state==="granted"){return!options?.isReadable;}}throw error;}}function normalize2(path){return isWindows?normalize1(path):normalize(path);}function stripSuffix(name,suffix){if(suffix.length>=name.length){return name;}const lenDiff=name.length-suffix.length;for(let i=suffix.length-1;i>=0;--i){if(name.charCodeAt(lenDiff+i)!==suffix.charCodeAt(i)){return name;}}return name.slice(0,-suffix.length);}function lastPathSegment(path,isSep,start=0){let matchedNonSeparator=false;let end=path.length;for(let i=path.length-1;i>=start;--i){if(isSep(path.charCodeAt(i))){if(matchedNonSeparator){start=i+1;break;}}else if(!matchedNonSeparator){matchedNonSeparator=true;end=i+1;}}return path.slice(start,end);}function assertArgs(path,suffix){assertPath(path);if(path.length===0)return path;if(typeof suffix!=="string"){throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);}}function basename(path,suffix=""){assertArgs(path,suffix);const lastSegment=lastPathSegment(path,isPosixPathSeparator);const strippedSegment=stripTrailingSeparators(lastSegment,isPosixPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename1(path,suffix=""){assertArgs(path,suffix);let start=0;if(path.length>=2){const drive=path.charCodeAt(0);if(isWindowsDeviceRoot(drive)){if(path.charCodeAt(1)===58)start=2;}}const lastSegment=lastPathSegment(path,isPathSeparator,start);const strippedSegment=stripTrailingSeparators(lastSegment,isPathSeparator);return suffix?stripSuffix(strippedSegment,suffix):strippedSegment;}function basename2(path,suffix=""){return isWindows?basename1(path,suffix):basename(path,suffix);}async function createWalkEntry(path){path=toPathString(path);path=normalize2(path);const name=basename2(path);const info=await Deno.stat(path);return{path,name,isFile:info.isFile,isDirectory:info.isDirectory,isSymlink:info.isSymlink};}class WalkError extends Error{root;constructor(cause,root){super(`${cause instanceof Error?cause.message:cause} for path "${root}"`);this.cause=cause;this.name="WalkError";this.root=root;}}function include(path,exts,match,skip){if(exts&&!exts.some(ext=>path.endsWith(ext))){return false;}if(match&&!match.some(pattern=>!!path.match(pattern))){return false;}if(skip&&skip.some(pattern=>!!path.match(pattern))){return false;}return true;}function wrapErrorWithPath(err,root){if(err instanceof WalkError)return err;return new WalkError(err,root);}async function*walk(root,{maxDepth=Infinity,includeFiles=true,includeDirs=true,includeSymlinks=true,followSymlinks=false,canonicalize=true,exts=undefined,match=undefined,skip=undefined}={}){if(maxDepth<0){return;}root=toPathString(root);if(includeDirs&&include(root,exts,match,skip)){yield await createWalkEntry(root);}if(maxDepth<1||!include(root,undefined,undefined,skip)){return;}try{for await(const entry of Deno.readDir(root)){let path=join2(root,entry.name);let{isSymlink,isDirectory}=entry;if(isSymlink){if(!followSymlinks){if(includeSymlinks&&include(path,exts,match,skip)){yield{path,...entry};}continue;}const realPath=await Deno.realPath(path);if(canonicalize){path=realPath;}({isSymlink,isDirectory}=await Deno.lstat(realPath));}if(isSymlink||isDirectory){yield*walk(path,{maxDepth:maxDepth-1,includeFiles,includeDirs,includeSymlinks,followSymlinks,exts,match,skip});}else if(includeFiles&&include(path,exts,match,skip)){yield{path,...entry};}}}catch(err){throw wrapErrorWithPath(err,normalize2(root));}}Deno.build.os==="windows";new Deno.errors.AlreadyExists("dest already exists.");Deno.build.os==="windows";const LF="\n";const CRLF="\r\n";Deno?.build.os==="windows"?CRLF:LF;function parse(text,{allowTrailingComma=true}={}){if(new.target){throw new TypeError("parse is not a constructor");}return new JSONCParser(text,{allowTrailingComma}).parse();}const originalJSONParse=globalThis.JSON.parse;class JSONCParser{#whitespace=new Set(" \r\n");#numberEndToken=new Set([..."[]{}:,/",...this.#whitespace]);#text;#length;#tokenized;#options;constructor(text,options){this.#text=`${text}`;this.#length=this.#text.length;this.#tokenized=this.#tokenize();this.#options=options;}parse(){const token=this.#getNext();const res=this.#parseJsonValue(token);const{done,value}=this.#tokenized.next();if(!done){throw new SyntaxError(buildErrorMessage(value));}return res;}#getNext(){const{done,value}=this.#tokenized.next();if(done){throw new SyntaxError("Unexpected end of JSONC input");}return value;}*#tokenize(){for(let i=0;iisNaN(Number(key)));const byLevel={[LogLevels.NOTSET]:"NOTSET",[LogLevels.DEBUG]:"DEBUG",[LogLevels.INFO]:"INFO",[LogLevels.WARNING]:"WARNING",[LogLevels.ERROR]:"ERROR",[LogLevels.CRITICAL]:"CRITICAL"};function getLevelByName(name){const level=LogLevels[name];if(level!==undefined){return level;}throw new Error(`no log level found for name: ${name}`);}function getLevelName(level){const levelName=byLevel[level];if(levelName){return levelName;}throw new Error(`no level name found for level: ${level}`);}class LogRecord{msg;#args;#datetime;level;levelName;loggerName;constructor(options){this.msg=options.msg;this.#args=[...options.args];this.level=options.level;this.loggerName=options.loggerName;this.#datetime=new Date;this.levelName=getLevelName(options.level);}get args(){return[...this.#args];}get datetime(){return new Date(this.#datetime.getTime());}}class Logger{#level;#handlers;#loggerName;constructor(loggerName,levelName,options={}){this.#loggerName=loggerName;this.#level=getLevelByName(levelName);this.#handlers=options.handlers||[];}get level(){return this.#level;}set level(level){try{this.#level=getLevelByName(getLevelName(level));}catch(_){throw new TypeError(`Invalid log level: ${level}`);}}get levelName(){return getLevelName(this.#level);}set levelName(levelName){this.#level=getLevelByName(levelName);}get loggerName(){return this.#loggerName;}set handlers(hndls){this.#handlers=hndls;}get handlers(){return this.#handlers;}#_log(level,msg,...args){if(this.level>level){return msg instanceof Function?undefined:msg;}let fnResult;let logMessage;if(msg instanceof Function){fnResult=msg();logMessage=this.asString(fnResult);}else{logMessage=this.asString(msg);}const record=new LogRecord({msg:logMessage,args:args,level:level,loggerName:this.loggerName});this.#handlers.forEach(handler=>{handler.handle(record);});return msg instanceof Function?fnResult:msg;}asString(data,isProperty=false){if(typeof data==="string"){if(isProperty)return`"${data}"`;return data;}else if(data===null||typeof data==="number"||typeof data==="bigint"||typeof data==="boolean"||typeof data==="undefined"||typeof data==="symbol"){return String(data);}else if(data instanceof Error){return data.stack;}else if(typeof data==="object"){return`{${Object.entries(data).map(([k,v])=>`"${k}":${this.asString(v,true)}`).join(",")}}`;}return"undefined";}debug(msg,...args){return this.#_log(LogLevels.DEBUG,msg,...args);}info(msg,...args){return this.#_log(LogLevels.INFO,msg,...args);}warning(msg,...args){return this.#_log(LogLevels.WARNING,msg,...args);}error(msg,...args){return this.#_log(LogLevels.ERROR,msg,...args);}critical(msg,...args){return this.#_log(LogLevels.CRITICAL,msg,...args);}}const{Deno:Deno1}=globalThis;const noColor=typeof Deno1?.noColor==="boolean"?Deno1.noColor:false;let enabled=!noColor;function code(open,close){return{open:`\x1b[${open.join(";")}m`,close:`\x1b[${close}m`,regexp:new RegExp(`\\x1b\\[${close}m`,"g")};}function run(str,code){return enabled?`${code.open}${str.replace(code.regexp,code.open)}${code.close}`:str;}function bold(str){return run(str,code([1],22));}function red(str){return run(str,code([31],39));}function yellow(str){return run(str,code([33],39));}function blue(str){return run(str,code([34],39));}new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"),"g");function copy(src,dst,off=0){off=Math.max(0,Math.min(off,dst.byteLength));const dstBytesAvailable=dst.byteLength-off;if(src.byteLength>dstBytesAvailable){src=src.subarray(0,dstBytesAvailable);}dst.set(src,off);return src.byteLength;}class AbstractBufBase{buf;usedBufferBytes=0;err=null;constructor(buf){this.buf=buf;}size(){return this.buf.byteLength;}available(){return this.buf.byteLength-this.usedBufferBytes;}buffered(){return this.usedBufferBytes;}}class BufWriterSync extends AbstractBufBase{#writer;static create(writer,size=4096){return writer instanceof BufWriterSync?writer:new BufWriterSync(writer,size);}constructor(writer,size=4096){super(new Uint8Array(size<=0?4096:size));this.#writer=writer;}reset(w){this.err=null;this.usedBufferBytes=0;this.#writer=w;}flush(){if(this.err!==null)throw this.err;if(this.usedBufferBytes===0)return;try{const p=this.buf.subarray(0,this.usedBufferBytes);let nwritten=0;while(nwrittenthis.available()){if(this.buffered()===0){try{numBytesWritten=this.#writer.writeSync(data);}catch(e){if(e instanceof Error){this.err=e;}throw e;}}else{numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;this.flush();}totalBytesWritten+=numBytesWritten;data=data.subarray(numBytesWritten);}numBytesWritten=copy(data,this.buf,this.usedBufferBytes);this.usedBufferBytes+=numBytesWritten;totalBytesWritten+=numBytesWritten;return totalBytesWritten;}}const DEFAULT_FORMATTER="{levelName} {msg}";class BaseHandler{level;levelName;formatter;constructor(levelName,options={}){this.level=getLevelByName(levelName);this.levelName=levelName;this.formatter=options.formatter||DEFAULT_FORMATTER;}handle(logRecord){if(this.level>logRecord.level)return;const msg=this.format(logRecord);this.log(msg);}format(logRecord){if(this.formatter instanceof Function){return this.formatter(logRecord);}return this.formatter.replace(/{([^\s}]+)}/g,(match,p1)=>{const value=logRecord[p1];if(value===undefined){return match;}return String(value);});}log(_msg){}setup(){}destroy(){}}class ConsoleHandler extends BaseHandler{#useColors;constructor(levelName,options={}){super(levelName,options);this.#useColors=options.useColors??true;}format(logRecord){let msg=super.format(logRecord);if(this.#useColors){msg=this.applyColors(msg,logRecord.level);}return msg;}applyColors(msg,level){switch(level){case LogLevels.INFO:msg=blue(msg);break;case LogLevels.WARNING:msg=yellow(msg);break;case LogLevels.ERROR:msg=red(msg);break;case LogLevels.CRITICAL:msg=bold(red(msg));break;default:break;}return msg;}log(msg){console.log(msg);}}class WriterHandler extends BaseHandler{_writer;#encoder=new TextEncoder;}class FileHandler extends WriterHandler{_file;_buf;_filename;_mode;_openOptions;_encoder=new TextEncoder;#unloadCallback=(()=>{this.destroy();}).bind(this);constructor(levelName,options){super(levelName,options);this._filename=options.filename;this._mode=options.mode?options.mode:"a";this._openOptions={createNew:this._mode==="x",create:this._mode!=="x",append:this._mode==="a",truncate:this._mode!=="a",write:true};}setup(){this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);addEventListener("unload",this.#unloadCallback);}handle(logRecord){super.handle(logRecord);if(logRecord.level>LogLevels.ERROR){this.flush();}}log(msg){if(this._encoder.encode(msg).byteLength+1>this._buf.available()){this.flush();}this._buf.writeSync(this._encoder.encode(msg+"\n"));}flush(){if(this._buf?.buffered()>0){this._buf.flush();}}destroy(){this.flush();this._file?.close();this._file=undefined;removeEventListener("unload",this.#unloadCallback);}}class RotatingFileHandler extends FileHandler{#maxBytes;#maxBackupCount;#currentFileSize=0;constructor(levelName,options){super(levelName,options);this.#maxBytes=options.maxBytes;this.#maxBackupCount=options.maxBackupCount;}setup(){if(this.#maxBytes<1){this.destroy();throw new Error("maxBytes cannot be less than 1");}if(this.#maxBackupCount<1){this.destroy();throw new Error("maxBackupCount cannot be less than 1");}super.setup();if(this._mode==="w"){for(let i=1;i<=this.#maxBackupCount;i++){try{Deno.removeSync(this._filename+"."+i);}catch(error){if(!(error instanceof Deno.errors.NotFound)){throw error;}}}}else if(this._mode==="x"){for(let i=1;i<=this.#maxBackupCount;i++){if(existsSync(this._filename+"."+i)){this.destroy();throw new Deno.errors.AlreadyExists("Backup log file "+this._filename+"."+i+" already exists");}}}else{this.#currentFileSize=Deno.statSync(this._filename).size;}}log(msg){const msgByteLength=this._encoder.encode(msg).byteLength+1;if(this.#currentFileSize+msgByteLength>this.#maxBytes){this.rotateLogFiles();this.#currentFileSize=0;}super.log(msg);this.#currentFileSize+=msgByteLength;}rotateLogFiles(){this._buf.flush();this._file.close();for(let i=this.#maxBackupCount-1;i>=0;i--){const source=this._filename+(i===0?"":"."+i);const dest=this._filename+"."+(i+1);if(existsSync(source)){Deno.renameSync(source,dest);}}this._file=Deno.openSync(this._filename,this._openOptions);this._writer=this._file;this._buf=new BufWriterSync(this._file);}}const DEFAULT_LEVEL="INFO";const DEFAULT_CONFIG={handlers:{default:new ConsoleHandler(DEFAULT_LEVEL)},loggers:{default:{level:DEFAULT_LEVEL,handlers:["default"]}}};const state={handlers:new Map,loggers:new Map,config:DEFAULT_CONFIG};const handlers={BaseHandler,ConsoleHandler,WriterHandler,FileHandler,RotatingFileHandler};function getLogger(name){if(!name){const d=state.loggers.get("default");assert(d!==undefined,`"default" logger must be set for getting logger without name`);return d;}const result=state.loggers.get(name);if(!result){const logger=new Logger(name,"NOTSET",{handlers:[]});state.loggers.set(name,logger);return logger;}return result;}function debug(msg,...args){if(msg instanceof Function){return getLogger("default").debug(msg,...args);}return getLogger("default").debug(msg,...args);}function info(msg,...args){if(msg instanceof Function){return getLogger("default").info(msg,...args);}return getLogger("default").info(msg,...args);}function warning(msg,...args){if(msg instanceof Function){return getLogger("default").warning(msg,...args);}return getLogger("default").warning(msg,...args);}function error(msg,...args){if(msg instanceof Function){return getLogger("default").error(msg,...args);}return getLogger("default").error(msg,...args);}function setup(config){state.config={handlers:{...DEFAULT_CONFIG.handlers,...config.handlers},loggers:{...DEFAULT_CONFIG.loggers,...config.loggers}};state.handlers.forEach(handler=>{handler.destroy();});state.handlers.clear();const handlers=state.config.handlers||{};for(const handlerName in handlers){const handler=handlers[handlerName];handler.setup();state.handlers.set(handlerName,handler);}state.loggers.clear();const loggers=state.config.loggers||{};for(const loggerName in loggers){const loggerConfig=loggers[loggerName];const handlerNames=loggerConfig.handlers||[];const handlers=[];handlerNames.forEach(handlerName=>{const handler=state.handlers.get(handlerName);if(handler){handlers.push(handler);}});const levelName=loggerConfig.level||DEFAULT_LEVEL;const logger=new Logger(loggerName,levelName,{handlers:handlers});state.loggers.set(loggerName,logger);}}setup(DEFAULT_CONFIG);function assertArgs1(from,to){assertPath(from);assertPath(to);if(from===to)return"";}function relative(from,to){assertArgs1(from,to);from=resolve(from);to=resolve(to);if(from===to)return"";let fromStart=1;const fromEnd=from.length;for(;fromStartlength){if(isPosixPathSeparator(to.charCodeAt(toStart+i))){return to.slice(toStart+i+1);}else if(i===0){return to.slice(toStart+i);}}else if(fromLen>length){if(isPosixPathSeparator(from.charCodeAt(fromStart+i))){lastCommonSep=i;}else if(i===0){lastCommonSep=0;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(isPosixPathSeparator(fromCode))lastCommonSep=i;}let out="";for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||isPosixPathSeparator(from.charCodeAt(i))){if(out.length===0)out+="..";else out+="/..";}}if(out.length>0)return out+to.slice(toStart+lastCommonSep);else{toStart+=lastCommonSep;if(isPosixPathSeparator(to.charCodeAt(toStart)))++toStart;return to.slice(toStart);}}function relative1(from,to){assertArgs1(from,to);const fromOrig=resolve1(from);const toOrig=resolve1(to);if(fromOrig===toOrig)return"";from=fromOrig.toLowerCase();to=toOrig.toLowerCase();if(from===to)return"";let fromStart=0;let fromEnd=from.length;for(;fromStartfromStart;--fromEnd){if(from.charCodeAt(fromEnd-1)!==92)break;}const fromLen=fromEnd-fromStart;let toStart=0;let toEnd=to.length;for(;toStarttoStart;--toEnd){if(to.charCodeAt(toEnd-1)!==92)break;}const toLen=toEnd-toStart;const length=fromLenlength){if(to.charCodeAt(toStart+i)===92){return toOrig.slice(toStart+i+1);}else if(i===2){return toOrig.slice(toStart+i);}}if(fromLen>length){if(from.charCodeAt(fromStart+i)===92){lastCommonSep=i;}else if(i===2){lastCommonSep=3;}}break;}const fromCode=from.charCodeAt(fromStart+i);const toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(fromCode===92)lastCommonSep=i;}if(i!==length&&lastCommonSep===-1){return toOrig;}let out="";if(lastCommonSep===-1)lastCommonSep=0;for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||from.charCodeAt(i)===92){if(out.length===0)out+="..";else out+="\\..";}}if(out.length>0){return out+toOrig.slice(toStart+lastCommonSep,toEnd);}else{toStart+=lastCommonSep;if(toOrig.charCodeAt(toStart)===92)++toStart;return toOrig.slice(toStart,toEnd);}}function relative2(from,to){return isWindows?relative1(from,to):relative(from,to);}var m=Object.create;var E=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),D=(t,e)=>{for(var s in e)E(t,s,{get:e[s],enumerable:!0});},a=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!b.call(t,n)&&n!==s&&E(t,n,{get:()=>e[n],enumerable:!(r=T(e,n))||r.enumerable});return t;},_=(t,e,s)=>(a(t,e,"default"),s&&a(s,e,"default")),$=(t,e,s)=>(s=t!=null?m(X(t)):{},a(e||!t||!t.__esModule?E(s,"default",{value:t,enumerable:!0}):s,t));var A=w((ct,v)=>{function C(t){return Array.isArray(t)?t:[t];}var N="",P=" ",h="\\",H=/^\s+$/,F=/(?:[^\\]|^)\\$/,k=/^\\!/,z=/^\\#/,B=/\r?\n/g,K=/^\.*\/|^\.+$/,d="/",x="node-ignore";typeof Symbol<"u"&&(x=Symbol.for("node-ignore"));var L=x,V=(t,e,s)=>Object.defineProperty(t,e,{value:s}),j=/([0-z])-([0-z])/g,G=()=>!1,M=t=>t.replace(j,(e,s,r)=>s.charCodeAt(0)<=r.charCodeAt(0)?e:N),Y=t=>{let{length:e}=t;return t.slice(0,e-e%2);},W=[[/\\?\s+$/,t=>t.indexOf("\\")===0?P:N],[/\\\s/g,()=>P],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)";}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,s)=>e+6{let r=s.replace(/\\\*/g,"[^\\/]*");return e+r;}],[/\\\\\\(?=[$.|*+(){^])/g,()=>h],[/\\\\/g,()=>h],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,s,r,n)=>e===h?`\\[${s}${Y(r)}${n}`:n==="]"&&r.length%2===0?`[${M(s)}${r}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],S=Object.create(null),p=(t,e)=>{let s=S[t];return s||(s=W.reduce((r,n)=>r.replace(n[0],n[1].bind(t)),t),S[t]=s),e?new RegExp(s,"i"):new RegExp(s);},R=t=>typeof t=="string",q=t=>t&&R(t)&&!H.test(t)&&!F.test(t)&&t.indexOf("#")!==0,J=t=>t.split(B),f=class{constructor(e,s,r,n){this.origin=e,this.pattern=s,this.negative=r,this.regex=n;}},Q=(t,e)=>{let s=t,r=!1;t.indexOf("!")===0&&(r=!0,t=t.substr(1)),t=t.replace(k,"!").replace(z,"#");let n=p(t,e);return new f(s,t,r,n);},U=(t,e)=>{throw new e(t);},i=(t,e,s)=>R(t)?t?i.isNotRelative(t)?s(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:s("path must not be empty",TypeError):s(`path must be a string, but got \`${e}\``,TypeError),O=t=>K.test(t);i.isNotRelative=O;i.convert=t=>t;var g=class{constructor({ignorecase:e=!0,ignoreCase:s=e,allowRelativePaths:r=!1}={}){V(this,L,!0),this._rules=[],this._ignoreCase=s,this._allowRelativePaths=r,this._initCache();}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null);}_addPattern(e){if(e&&e[L]){this._rules=this._rules.concat(e._rules),this._added=!0;return;}if(q(e)){let s=Q(e,this._ignoreCase);this._added=!0,this._rules.push(s);}}add(e){return this._added=!1,C(R(e)?J(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this;}addPattern(e){return this.add(e);}_testOne(e,s){let r=!1,n=!1;return this._rules.forEach(o=>{let{negative:u}=o;if(n===u&&r!==n||u&&!r&&!n&&!s)return;o.regex.test(e)&&(r=!u,n=u);}),{ignored:r,unignored:n};}_test(e,s,r,n){let o=e&&i.convert(e);return i(o,e,this._allowRelativePaths?G:U),this._t(o,s,r,n);}_t(e,s,r,n){if(e in s)return s[e];if(n||(n=e.split(d)),n.pop(),!n.length)return s[e]=this._testOne(e,r);let o=this._t(n.join(d)+d,s,r,n);return s[e]=o.ignored?o:this._testOne(e,r);}ignores(e){return this._test(e,this._ignoreCache,!1).ignored;}createFilter(){return e=>!this.ignores(e);}filter(e){return C(e).filter(this.createFilter());}test(e){return this._test(e,this._testCache,!0);}},l=t=>new g(t),Z=t=>i(t&&i.convert(t),t,G);l.isPathValid=Z;l.default=l;v.exports=l;var tt=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");i.convert=tt;var et=/^[a-z]:\//i;i.isNotRelative=t=>et.test(t)||O(t);});var c={};D(c,{default:()=>nt});var st=$(A());_(c,$(A()));var{default:I,...rt}=st,nt=I!==void 0?I:rt;const importMeta={url:"file:///home/runner/work/setup-deno/setup-deno/cache.ts",main:import.meta.main};if(importMeta.main){const args=parseArgs(Deno.args,{boolean:["dry-run","verbose","lock-write"],negatable:["lock-write"],string:["config"],default:{"lock-write":true},alias:{"dry-run":"n",verbose:"v"},"--":true,unknown:arg=>{console.log(`Unknown argument: ${arg}`);console.log("Usage: cache [-n | --dry-run] [-v | --verbose] [--] [DENO_ARGS...]");Deno.exit(0);}});const denoDir=Deno.env.get("DENO_DIR");const logLevel=["1","true"].includes(Deno.env.get("CI")??"")?"DEBUG":args.verbose?"DEBUG":"INFO";setup({handlers:{console:new handlers.ConsoleHandler(logLevel,{formatter:logRecord=>Deno.noColor?logRecord.levelName+" "+logRecord.msg:logRecord.msg})},loggers:{default:{handlers:["console"],"level":logLevel}}});if(args["dry-run"])warning("dry-run mode enabled");if(args.config&&!await exists(args.config)){error(`config file ${args.config} not found`);Deno.exit(1);}const hash=await Deno.readFile("./deno.lock").then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>crypto.subtle.digest("SHA-256",data)).then(data=>encodeHex(new Uint8Array(data))).catch(_=>"");debug(`GitHub actions deno.lock hash: ${hash}`);const cfgs=args.config?[args.config]:["deno.json","deno.jsonc"];const denoCfg=await Promise.all(cfgs.map(path=>Deno.readTextFile(path).catch(_=>undefined))).then(v=>parse(v.filter(Boolean)[0]??"{}"));const patterns=[...[denoCfg?.exclude].filter(Boolean).flat(),...[denoCfg?.cache?.exclude].filter(Boolean).flat(),...[denoCfg?.cache?.include].filter(Boolean).flatMap(p=>`!${p}`)];patterns.length>0&&debug(`patterns: +| ${patterns.join("\n| ")}`);const ig=nt().add(patterns);const walkIterator=walk(".",{exts:["js",".jsx",".ts",".tsx"],includeDirs:false});const paths=[];for await(const entry of walkIterator){const relativePath=relative2(".",entry.path);if(denoDir&&entry.path.startsWith(denoDir))continue;if(ig.ignores(relativePath)){debug(`ignored ${relativePath}`);continue;}debug(`caching ${relativePath}`);paths.push(relativePath);}const denoArgs=["cache",args["lock-write"]&&"--lock-write",args.config&&`--config=${args.config}`,...args["--"],...paths].filter(Boolean);const cmd=new Deno.Command(Deno.execPath(),{args:denoArgs});const cmdString=Deno.execPath()+" "+denoArgs.join(" ");if(args["dry-run"]){info(`would run: ${cmdString}`);Deno.exit(0);}debug(`running: ${cmdString}`);const{stderr,code}=await cmd.output();for(const line of new TextDecoder().decode(stderr).split("\n")){if(line.length>0)info("deno> "+line);}if(code===0)debug(`finished caching ${paths.length} files`);} \ No newline at end of file