diff --git a/package-lock.json b/package-lock.json index 8a95811..af65898 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "0.0.0", "license": "Apache-2.0", "dependencies": { + "c12": "0.2.5", "cac": "^6.7.12", "chalk": "^5.0.1", "chokidar": "3.5.3", @@ -27,23 +28,24 @@ }, "devDependencies": { "@size-limit/preset-small-lib": "^7.0.8", + "@types/escape-html": "1.0.1", "@types/exit": "0.1.31", "@types/semver": "7.3.9", "@typescript-eslint/eslint-plugin": "^5.18.0", "@typescript-eslint/parser": "^5.18.0", "c8": "^7.11.0", "cross-env": "7.0.3", - "eslint": "^8.12.0", + "eslint": "^8.13.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-prettier": "^4.0.0", - "eslint-plugin-tsdoc": "^0.2.14", + "eslint-plugin-tsdoc": "^0.2.16", "prettier": "^2.6.2", "prettier-plugin-jsdoc": "^0.3.36", "siroc": "^0.16.0", "size-limit": "^7.0.8", "standard-version": "^9.3.2", "typescript": "^4.6.3", - "vitest": "^0.9.0" + "vitest": "^0.9.3" }, "engines": { "node": ">=12.7.0" @@ -205,18 +207,18 @@ } }, "node_modules/@microsoft/tsdoc": { - "version": "0.13.2", - "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.13.2.tgz", - "integrity": "sha512-WrHvO8PDL8wd8T2+zBGKrMwVL5IyzR3ryWUsl0PXgEV0QHup4mTLi0QcATefGI6Gx9Anu7vthPyyyLpY0EpiQg==", + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.14.1.tgz", + "integrity": "sha512-6Wci+Tp3CgPt/B9B0a3J4s3yMgLNSku6w5TV6mN+61C71UqsRBv2FUibBf3tPGlNxebgPHMEUzKpb1ggE8KCKw==", "dev": true }, "node_modules/@microsoft/tsdoc-config": { - "version": "0.15.2", - "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.15.2.tgz", - "integrity": "sha512-mK19b2wJHSdNf8znXSMYVShAHktVr/ib0Ck2FA3lsVBSEhSI/TfXT7DJQkAYgcztTuwazGcg58ZjYdk0hTCVrA==", + "version": "0.16.1", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.16.1.tgz", + "integrity": "sha512-2RqkwiD4uN6MLnHFljqBlZIXlt/SaUT6cuogU1w2ARw4nKuuppSmR0+s+NC+7kXBQykd9zzu0P4HtBpZT5zBpQ==", "dev": true, "dependencies": { - "@microsoft/tsdoc": "0.13.2", + "@microsoft/tsdoc": "0.14.1", "ajv": "~6.12.6", "jju": "~1.4.0", "resolve": "~1.19.0" @@ -474,6 +476,12 @@ "@types/ms": "*" } }, + "node_modules/@types/escape-html": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@types/escape-html/-/escape-html-1.0.1.tgz", + "integrity": "sha512-4mI1FuUUZiuT95fSVqvZxp/ssQK9zsa86S43h9x3zPOSU9BBJ+BfDkXwuaU7BfsD+e7U0/cUUfJFk3iW2M4okA==", + "dev": true + }, "node_modules/@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", @@ -962,6 +970,25 @@ "node": ">= 0.8" } }, + "node_modules/c12": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/c12/-/c12-0.2.5.tgz", + "integrity": "sha512-45/GsCYd63XHFgg7xq59eeR8hAbCDoj6w+kQWal9Vb8oGzMRDrHqpZexVNIL4DgeUduvCnBB+7smHiRHVAwBkQ==", + "dependencies": { + "defu": "^6.0.0", + "dotenv": "^16.0.0", + "gittar": "^0.1.1", + "jiti": "^1.12.14", + "mlly": "^0.5.1", + "pathe": "^0.2.0", + "rc9": "^1.2.1" + } + }, + "node_modules/c12/node_modules/defu": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/defu/-/defu-6.0.0.tgz", + "integrity": "sha512-t2MZGLf1V2rV4VBZbWIaXKdX/mUcYW0n2znQZoADBkGGxYL8EWqCuCZBmJPJ/Yy9fofJkyuuSuo5GSwo0XdEgw==" + }, "node_modules/c8": { "version": "7.11.0", "resolved": "https://registry.npmjs.org/c8/-/c8-7.11.0.tgz", @@ -1205,6 +1232,11 @@ "fsevents": "~2.3.2" } }, + "node_modules/chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + }, "node_modules/ci-job-number": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/ci-job-number/-/ci-job-number-1.2.2.tgz", @@ -1782,6 +1814,11 @@ "node": ">=6" } }, + "node_modules/destr": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/destr/-/destr-1.1.1.tgz", + "integrity": "sha512-QqkneF8LrYmwATMdnuD2MLI3GHQIcBnG6qFC2q9bSH430VTCDAVjcspPmUaKhPGtAtPAftIUFqY1obQYQuwmbg==" + }, "node_modules/detect-indent": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-7.0.0.tgz", @@ -1834,6 +1871,14 @@ "node": ">=8" } }, + "node_modules/dotenv": { + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.0.tgz", + "integrity": "sha512-qD9WU0MPM4SWLPJy/r2Be+2WgQj8plChsyrCNQzW/0WjvcJQiKQJ9mH3ZgB3fxbUUxgc/11ZJ0Fi5KiimWGz2Q==", + "engines": { + "node": ">=12" + } + }, "node_modules/dotgitignore": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/dotgitignore/-/dotgitignore-2.1.0.tgz", @@ -2298,9 +2343,9 @@ } }, "node_modules/eslint": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.12.0.tgz", - "integrity": "sha512-it1oBL9alZg1S8UycLm5YDMAkIhtH6FtAzuZs6YvoGVldWjbS08BkAdb/ymP9LlAyq8koANu32U7Ib/w+UNh8Q==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.13.0.tgz", + "integrity": "sha512-D+Xei61eInqauAyTJ6C0q6x9mx7kTUC1KZ0m0LSEexR0V+e94K12LmWX076ZIsldwfQ2RONdaJe0re0TRGQbRQ==", "dev": true, "dependencies": { "@eslint/eslintrc": "^1.2.1", @@ -2383,13 +2428,13 @@ } }, "node_modules/eslint-plugin-tsdoc": { - "version": "0.2.14", - "resolved": "https://registry.npmjs.org/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.2.14.tgz", - "integrity": "sha512-fJ3fnZRsdIoBZgzkQjv8vAj6NeeOoFkTfgosj6mKsFjX70QV256sA/wq+y/R2+OL4L8E79VVaVWrPeZnKNe8Ng==", + "version": "0.2.16", + "resolved": "https://registry.npmjs.org/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.2.16.tgz", + "integrity": "sha512-F/RWMnyDQuGlg82vQEFHQtGyWi7++XJKdYNn0ulIbyMOFqYIjoJOUdE6olORxgwgLkpJxsCJpJbTHgxJ/ggfXw==", "dev": true, "dependencies": { - "@microsoft/tsdoc": "0.13.2", - "@microsoft/tsdoc-config": "0.15.2" + "@microsoft/tsdoc": "0.14.1", + "@microsoft/tsdoc-config": "0.16.1" } }, "node_modules/eslint-scope": { @@ -2730,6 +2775,14 @@ "node": ">=8" } }, + "node_modules/flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "bin": { + "flat": "cli.js" + } + }, "node_modules/flat-cache": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", @@ -2816,6 +2869,14 @@ "node": ">=12" } }, + "node_modules/fs-minipass": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz", + "integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==", + "dependencies": { + "minipass": "^2.6.0" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -3004,6 +3065,29 @@ "ini": "^1.3.2" } }, + "node_modules/gittar": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/gittar/-/gittar-0.1.1.tgz", + "integrity": "sha1-1pk+phYKhsi3895yKmH3O8meFLQ=", + "dependencies": { + "mkdirp": "^0.5.1", + "tar": "^4.4.1" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/gittar/node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, "node_modules/glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", @@ -3452,7 +3536,6 @@ "version": "1.12.15", "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.12.15.tgz", "integrity": "sha512-/+K89y6KJA2nISbWrlc/773XdpDgSQq/LdQ+ZZyw2jRxUNyquPtbsDCCCMRzzNORUgroUGc4nAXxJEnQvpViCA==", - "dev": true, "bin": { "jiti": "bin/jiti.js" } @@ -3528,8 +3611,7 @@ "node_modules/jsonc-parser": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.0.0.tgz", - "integrity": "sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA==", - "dev": true + "integrity": "sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA==" }, "node_modules/jsonfile": { "version": "6.1.0", @@ -4400,9 +4482,9 @@ } }, "node_modules/minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" }, "node_modules/minimist-options": { "version": "4.1.0", @@ -4436,6 +4518,28 @@ "node": ">=0.10.0" } }, + "node_modules/minipass": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz", + "integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==", + "dependencies": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + } + }, + "node_modules/minipass/node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" + }, + "node_modules/minizlib": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.3.3.tgz", + "integrity": "sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==", + "dependencies": { + "minipass": "^2.9.0" + } + }, "node_modules/mkdirp": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", @@ -4744,6 +4848,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/mlly": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-0.5.1.tgz", + "integrity": "sha512-0axKqxbYyQvaAfi6BNqDluCJqg6RkjdsdFxSDoiP6l5HplSTr3ie5Vkxvw9U9ogdj65x56amTnAn+xSoP727Rg==", + "dependencies": { + "pathe": "^0.2.0", + "pkg-types": "^0.3.2" + } + }, "node_modules/modify-values": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/modify-values/-/modify-values-1.0.1.tgz", @@ -5034,8 +5147,7 @@ "node_modules/pathe": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/pathe/-/pathe-0.2.0.tgz", - "integrity": "sha512-sTitTPYnn23esFR3RlqYBWn4c45WGeLcsKzQiUpXJAyfcWkolvlYpV8FLo7JishK946oQwMFUCHXQ9AjGPKExw==", - "dev": true + "integrity": "sha512-sTitTPYnn23esFR3RlqYBWn4c45WGeLcsKzQiUpXJAyfcWkolvlYpV8FLo7JishK946oQwMFUCHXQ9AjGPKExw==" }, "node_modules/pathval": { "version": "1.1.1", @@ -5072,6 +5184,21 @@ "node": ">=0.10.0" } }, + "node_modules/pkg-types": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-0.3.2.tgz", + "integrity": "sha512-eBYzX/7NYsQEOR2alWY4rnQB49G62oHzFpoi9Som56aUr8vB8UGcmcIia9v8fpBeuhH3Ltentuk2OGpp4IQV3Q==", + "dependencies": { + "jsonc-parser": "^3.0.0", + "mlly": "^0.3.6", + "pathe": "^0.2.0" + } + }, + "node_modules/pkg-types/node_modules/mlly": { + "version": "0.3.19", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-0.3.19.tgz", + "integrity": "sha512-zMq5n3cOf4fOzA4WoeulxagbAgMChdev3MgP6K51k7M0u2whTXxupfIY4VVzws4vxkiWhwH1rVQcsw7zDGfRhA==" + }, "node_modules/postcss": { "version": "8.4.12", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.12.tgz", @@ -5233,6 +5360,21 @@ "node": ">=0.10.0" } }, + "node_modules/rc9": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/rc9/-/rc9-1.2.2.tgz", + "integrity": "sha512-zbe8+HR2X28eZepAwohuKkebbEsA67h0DO9I7g12QrHa2CQopR9gztOLPIPXXGTvcxeUjAN4wZ+b29t3m/u05g==", + "dependencies": { + "defu": "^6.0.0", + "destr": "^1.1.1", + "flat": "^5.0.0" + } + }, + "node_modules/rc9/node_modules/defu": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/defu/-/defu-6.0.0.tgz", + "integrity": "sha512-t2MZGLf1V2rV4VBZbWIaXKdX/mUcYW0n2znQZoADBkGGxYL8EWqCuCZBmJPJ/Yy9fofJkyuuSuo5GSwo0XdEgw==" + }, "node_modules/read-pkg": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", @@ -5666,8 +5808,7 @@ "node_modules/safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "node_modules/semver": { "version": "7.3.6", @@ -6311,6 +6452,58 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/tar": { + "version": "4.4.19", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.19.tgz", + "integrity": "sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA==", + "dependencies": { + "chownr": "^1.1.4", + "fs-minipass": "^1.2.7", + "minipass": "^2.9.0", + "minizlib": "^1.3.3", + "mkdirp": "^0.5.5", + "safe-buffer": "^5.2.1", + "yallist": "^3.1.1" + }, + "engines": { + "node": ">=4.5" + } + }, + "node_modules/tar/node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/tar/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/tar/node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" + }, "node_modules/test-exclude": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", @@ -6365,9 +6558,9 @@ } }, "node_modules/tinyspy": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-0.3.0.tgz", - "integrity": "sha512-c5uFHqtUp74R2DJE3/Efg0mH5xicmgziaQXMm/LvuuZn3RdpADH32aEGDRyCzObXT1DNfwDMqRQ/Drh1MlO12g==", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-0.3.2.tgz", + "integrity": "sha512-2+40EP4D3sFYy42UkgkFFB+kiX2Tg3URG/lVvAZFfLxgGpnWl5qQJuBw1gaLttq8UOS+2p3C0WrhJnQigLTT2Q==", "dev": true, "engines": { "node": ">=14.0.0" @@ -6629,9 +6822,9 @@ } }, "node_modules/vitest": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.9.0.tgz", - "integrity": "sha512-WyNY35WGRqtW/hd00FPgsnatDxKrRzEWVLS36KPbSFqAOn3HHtV+4/ihiPBaDAzAKtr6/eT52x+7kobUXa59TA==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.9.3.tgz", + "integrity": "sha512-hKjqdBI732cV5giNLERyAsaJBebstrX5mvTbZr+jUDYUHnX1O4DpAJcHtqBOutuBi7lVIGQ5IF8eWvHHqbCHBA==", "dev": true, "dependencies": { "@types/chai": "^4.3.0", @@ -6639,7 +6832,7 @@ "chai": "^4.3.6", "local-pkg": "^0.4.1", "tinypool": "^0.1.2", - "tinyspy": "^0.3.0", + "tinyspy": "^0.3.2", "vite": "^2.9.1" }, "bin": { @@ -6944,18 +7137,18 @@ "dev": true }, "@microsoft/tsdoc": { - "version": "0.13.2", - "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.13.2.tgz", - "integrity": "sha512-WrHvO8PDL8wd8T2+zBGKrMwVL5IyzR3ryWUsl0PXgEV0QHup4mTLi0QcATefGI6Gx9Anu7vthPyyyLpY0EpiQg==", + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.14.1.tgz", + "integrity": "sha512-6Wci+Tp3CgPt/B9B0a3J4s3yMgLNSku6w5TV6mN+61C71UqsRBv2FUibBf3tPGlNxebgPHMEUzKpb1ggE8KCKw==", "dev": true }, "@microsoft/tsdoc-config": { - "version": "0.15.2", - "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.15.2.tgz", - "integrity": "sha512-mK19b2wJHSdNf8znXSMYVShAHktVr/ib0Ck2FA3lsVBSEhSI/TfXT7DJQkAYgcztTuwazGcg58ZjYdk0hTCVrA==", + "version": "0.16.1", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.16.1.tgz", + "integrity": "sha512-2RqkwiD4uN6MLnHFljqBlZIXlt/SaUT6cuogU1w2ARw4nKuuppSmR0+s+NC+7kXBQykd9zzu0P4HtBpZT5zBpQ==", "dev": true, "requires": { - "@microsoft/tsdoc": "0.13.2", + "@microsoft/tsdoc": "0.14.1", "ajv": "~6.12.6", "jju": "~1.4.0", "resolve": "~1.19.0" @@ -7148,6 +7341,12 @@ "@types/ms": "*" } }, + "@types/escape-html": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@types/escape-html/-/escape-html-1.0.1.tgz", + "integrity": "sha512-4mI1FuUUZiuT95fSVqvZxp/ssQK9zsa86S43h9x3zPOSU9BBJ+BfDkXwuaU7BfsD+e7U0/cUUfJFk3iW2M4okA==", + "dev": true + }, "@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", @@ -7504,6 +7703,27 @@ "integrity": "sha512-fey6+4jDK7TFtFg/klGSvNKJctyU7n2aQdnM+CO0ruLPbqqMOM8Tio0Pc+deqUeVKX1tL5DQep1zQ7+37aTAsA==", "dev": true }, + "c12": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/c12/-/c12-0.2.5.tgz", + "integrity": "sha512-45/GsCYd63XHFgg7xq59eeR8hAbCDoj6w+kQWal9Vb8oGzMRDrHqpZexVNIL4DgeUduvCnBB+7smHiRHVAwBkQ==", + "requires": { + "defu": "^6.0.0", + "dotenv": "^16.0.0", + "gittar": "^0.1.1", + "jiti": "^1.12.14", + "mlly": "^0.5.1", + "pathe": "^0.2.0", + "rc9": "^1.2.1" + }, + "dependencies": { + "defu": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/defu/-/defu-6.0.0.tgz", + "integrity": "sha512-t2MZGLf1V2rV4VBZbWIaXKdX/mUcYW0n2znQZoADBkGGxYL8EWqCuCZBmJPJ/Yy9fofJkyuuSuo5GSwo0XdEgw==" + } + } + }, "c8": { "version": "7.11.0", "resolved": "https://registry.npmjs.org/c8/-/c8-7.11.0.tgz", @@ -7667,6 +7887,11 @@ "readdirp": "~3.6.0" } }, + "chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + }, "ci-job-number": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/ci-job-number/-/ci-job-number-1.2.2.tgz", @@ -8117,6 +8342,11 @@ "integrity": "sha512-q9K8BlJVxK7hQYqa6XISGmBZbtQQWVXSrRrWreHC94rMt1QL/Impruc+7p2CYSYuVIUr+YCt6hjrs1kkdJRTug==", "dev": true }, + "destr": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/destr/-/destr-1.1.1.tgz", + "integrity": "sha512-QqkneF8LrYmwATMdnuD2MLI3GHQIcBnG6qFC2q9bSH430VTCDAVjcspPmUaKhPGtAtPAftIUFqY1obQYQuwmbg==" + }, "detect-indent": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-7.0.0.tgz", @@ -8154,6 +8384,11 @@ "is-obj": "^2.0.0" } }, + "dotenv": { + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.0.tgz", + "integrity": "sha512-qD9WU0MPM4SWLPJy/r2Be+2WgQj8plChsyrCNQzW/0WjvcJQiKQJ9mH3ZgB3fxbUUxgc/11ZJ0Fi5KiimWGz2Q==" + }, "dotgitignore": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/dotgitignore/-/dotgitignore-2.1.0.tgz", @@ -8409,9 +8644,9 @@ "dev": true }, "eslint": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.12.0.tgz", - "integrity": "sha512-it1oBL9alZg1S8UycLm5YDMAkIhtH6FtAzuZs6YvoGVldWjbS08BkAdb/ymP9LlAyq8koANu32U7Ib/w+UNh8Q==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.13.0.tgz", + "integrity": "sha512-D+Xei61eInqauAyTJ6C0q6x9mx7kTUC1KZ0m0LSEexR0V+e94K12LmWX076ZIsldwfQ2RONdaJe0re0TRGQbRQ==", "dev": true, "requires": { "@eslint/eslintrc": "^1.2.1", @@ -8529,13 +8764,13 @@ } }, "eslint-plugin-tsdoc": { - "version": "0.2.14", - "resolved": "https://registry.npmjs.org/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.2.14.tgz", - "integrity": "sha512-fJ3fnZRsdIoBZgzkQjv8vAj6NeeOoFkTfgosj6mKsFjX70QV256sA/wq+y/R2+OL4L8E79VVaVWrPeZnKNe8Ng==", + "version": "0.2.16", + "resolved": "https://registry.npmjs.org/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.2.16.tgz", + "integrity": "sha512-F/RWMnyDQuGlg82vQEFHQtGyWi7++XJKdYNn0ulIbyMOFqYIjoJOUdE6olORxgwgLkpJxsCJpJbTHgxJ/ggfXw==", "dev": true, "requires": { - "@microsoft/tsdoc": "0.13.2", - "@microsoft/tsdoc-config": "0.15.2" + "@microsoft/tsdoc": "0.14.1", + "@microsoft/tsdoc-config": "0.16.1" } }, "eslint-scope": { @@ -8732,6 +8967,11 @@ "path-exists": "^4.0.0" } }, + "flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==" + }, "flat-cache": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", @@ -8805,6 +9045,14 @@ "universalify": "^2.0.0" } }, + "fs-minipass": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz", + "integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==", + "requires": { + "minipass": "^2.6.0" + } + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -8951,6 +9199,25 @@ "ini": "^1.3.2" } }, + "gittar": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/gittar/-/gittar-0.1.1.tgz", + "integrity": "sha1-1pk+phYKhsi3895yKmH3O8meFLQ=", + "requires": { + "mkdirp": "^0.5.1", + "tar": "^4.4.1" + }, + "dependencies": { + "mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "requires": { + "minimist": "^1.2.6" + } + } + } + }, "glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", @@ -9282,8 +9549,7 @@ "jiti": { "version": "1.12.15", "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.12.15.tgz", - "integrity": "sha512-/+K89y6KJA2nISbWrlc/773XdpDgSQq/LdQ+ZZyw2jRxUNyquPtbsDCCCMRzzNORUgroUGc4nAXxJEnQvpViCA==", - "dev": true + "integrity": "sha512-/+K89y6KJA2nISbWrlc/773XdpDgSQq/LdQ+ZZyw2jRxUNyquPtbsDCCCMRzzNORUgroUGc4nAXxJEnQvpViCA==" }, "jju": { "version": "1.4.0", @@ -9350,8 +9616,7 @@ "jsonc-parser": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.0.0.tgz", - "integrity": "sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA==", - "dev": true + "integrity": "sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA==" }, "jsonfile": { "version": "6.1.0", @@ -9908,9 +10173,9 @@ } }, "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" }, "minimist-options": { "version": "4.1.0", @@ -9937,6 +10202,30 @@ } } }, + "minipass": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz", + "integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==", + "requires": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + }, + "dependencies": { + "yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" + } + } + }, + "minizlib": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.3.3.tgz", + "integrity": "sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==", + "requires": { + "minipass": "^2.9.0" + } + }, "mkdirp": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", @@ -10118,6 +10407,15 @@ } } }, + "mlly": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-0.5.1.tgz", + "integrity": "sha512-0axKqxbYyQvaAfi6BNqDluCJqg6RkjdsdFxSDoiP6l5HplSTr3ie5Vkxvw9U9ogdj65x56amTnAn+xSoP727Rg==", + "requires": { + "pathe": "^0.2.0", + "pkg-types": "^0.3.2" + } + }, "modify-values": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/modify-values/-/modify-values-1.0.1.tgz", @@ -10326,8 +10624,7 @@ "pathe": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/pathe/-/pathe-0.2.0.tgz", - "integrity": "sha512-sTitTPYnn23esFR3RlqYBWn4c45WGeLcsKzQiUpXJAyfcWkolvlYpV8FLo7JishK946oQwMFUCHXQ9AjGPKExw==", - "dev": true + "integrity": "sha512-sTitTPYnn23esFR3RlqYBWn4c45WGeLcsKzQiUpXJAyfcWkolvlYpV8FLo7JishK946oQwMFUCHXQ9AjGPKExw==" }, "pathval": { "version": "1.1.1", @@ -10352,6 +10649,23 @@ "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true }, + "pkg-types": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-0.3.2.tgz", + "integrity": "sha512-eBYzX/7NYsQEOR2alWY4rnQB49G62oHzFpoi9Som56aUr8vB8UGcmcIia9v8fpBeuhH3Ltentuk2OGpp4IQV3Q==", + "requires": { + "jsonc-parser": "^3.0.0", + "mlly": "^0.3.6", + "pathe": "^0.2.0" + }, + "dependencies": { + "mlly": { + "version": "0.3.19", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-0.3.19.tgz", + "integrity": "sha512-zMq5n3cOf4fOzA4WoeulxagbAgMChdev3MgP6K51k7M0u2whTXxupfIY4VVzws4vxkiWhwH1rVQcsw7zDGfRhA==" + } + } + }, "postcss": { "version": "8.4.12", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.12.tgz", @@ -10451,6 +10765,23 @@ } } }, + "rc9": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/rc9/-/rc9-1.2.2.tgz", + "integrity": "sha512-zbe8+HR2X28eZepAwohuKkebbEsA67h0DO9I7g12QrHa2CQopR9gztOLPIPXXGTvcxeUjAN4wZ+b29t3m/u05g==", + "requires": { + "defu": "^6.0.0", + "destr": "^1.1.1", + "flat": "^5.0.0" + }, + "dependencies": { + "defu": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/defu/-/defu-6.0.0.tgz", + "integrity": "sha512-t2MZGLf1V2rV4VBZbWIaXKdX/mUcYW0n2znQZoADBkGGxYL8EWqCuCZBmJPJ/Yy9fofJkyuuSuo5GSwo0XdEgw==" + } + } + }, "read-pkg": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", @@ -10762,8 +11093,7 @@ "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "semver": { "version": "7.3.6", @@ -11244,6 +11574,40 @@ "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "dev": true }, + "tar": { + "version": "4.4.19", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.19.tgz", + "integrity": "sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA==", + "requires": { + "chownr": "^1.1.4", + "fs-minipass": "^1.2.7", + "minipass": "^2.9.0", + "minizlib": "^1.3.3", + "mkdirp": "^0.5.5", + "safe-buffer": "^5.2.1", + "yallist": "^3.1.1" + }, + "dependencies": { + "mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "requires": { + "minimist": "^1.2.6" + } + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + }, + "yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" + } + } + }, "test-exclude": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", @@ -11289,9 +11653,9 @@ "dev": true }, "tinyspy": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-0.3.0.tgz", - "integrity": "sha512-c5uFHqtUp74R2DJE3/Efg0mH5xicmgziaQXMm/LvuuZn3RdpADH32aEGDRyCzObXT1DNfwDMqRQ/Drh1MlO12g==", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-0.3.2.tgz", + "integrity": "sha512-2+40EP4D3sFYy42UkgkFFB+kiX2Tg3URG/lVvAZFfLxgGpnWl5qQJuBw1gaLttq8UOS+2p3C0WrhJnQigLTT2Q==", "dev": true }, "to-regex-range": { @@ -11465,9 +11829,9 @@ } }, "vitest": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.9.0.tgz", - "integrity": "sha512-WyNY35WGRqtW/hd00FPgsnatDxKrRzEWVLS36KPbSFqAOn3HHtV+4/ihiPBaDAzAKtr6/eT52x+7kobUXa59TA==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.9.3.tgz", + "integrity": "sha512-hKjqdBI732cV5giNLERyAsaJBebstrX5mvTbZr+jUDYUHnX1O4DpAJcHtqBOutuBi7lVIGQ5IF8eWvHHqbCHBA==", "dev": true, "requires": { "@types/chai": "^4.3.0", @@ -11475,7 +11839,7 @@ "chai": "^4.3.6", "local-pkg": "^0.4.1", "tinypool": "^0.1.2", - "tinyspy": "^0.3.0", + "tinyspy": "^0.3.2", "vite": "^2.9.1" } }, diff --git a/package.json b/package.json index dd40576..ca754b2 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "unit:watch": "vitest watch" }, "dependencies": { + "c12": "0.2.5", "cac": "^6.7.12", "chalk": "^5.0.1", "chokidar": "3.5.3", @@ -67,23 +68,24 @@ }, "devDependencies": { "@size-limit/preset-small-lib": "^7.0.8", + "@types/escape-html": "1.0.1", "@types/exit": "0.1.31", "@types/semver": "7.3.9", "@typescript-eslint/eslint-plugin": "^5.18.0", "@typescript-eslint/parser": "^5.18.0", "c8": "^7.11.0", "cross-env": "7.0.3", - "eslint": "^8.12.0", + "eslint": "^8.13.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-prettier": "^4.0.0", - "eslint-plugin-tsdoc": "^0.2.14", + "eslint-plugin-tsdoc": "^0.2.16", "prettier": "^2.6.2", "prettier-plugin-jsdoc": "^0.3.36", "siroc": "^0.16.0", "size-limit": "^7.0.8", "standard-version": "^9.3.2", "typescript": "^4.6.3", - "vitest": "^0.9.0" + "vitest": "^0.9.3" }, "engines": { "node": ">=12.7.0" diff --git a/schnipsel.config.json b/schnipsel.config.json deleted file mode 100644 index 2388048..0000000 --- a/schnipsel.config.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "input": { - "directory": "playground/src" - }, - "renderers": [ - { - "name": "vscode", - "options": { - "outputDirectory": "playground/vscode/snippets" - } - } - ] -} diff --git a/schnipsel.config.ts b/schnipsel.config.ts new file mode 100644 index 0000000..1b177ca --- /dev/null +++ b/schnipsel.config.ts @@ -0,0 +1,29 @@ +import { defineSchnipselConfig } from "./"; + +export default defineSchnipselConfig({ + input: { + directory: "playground/src", + }, + renderers: [ + { + name: "vscode", + options: { + outputDirectory: "playground/vscode/snippets", + packageJSON: "playground/vscode/package.json", + }, + }, + { + name: "sublime", + options: { + outputDirectory: "playground/sublime/snippets", + }, + }, + { + name: "intellij", + options: { + outputDirectory: "playground/intellij/snippets", + pluginXML: "playground/intellij/plugin.xml", + }, + }, + ], +}); diff --git a/src/ConfigFile.ts b/src/ConfigFile.ts index fe1388d..3ab9cc6 100644 --- a/src/ConfigFile.ts +++ b/src/ConfigFile.ts @@ -1,43 +1,84 @@ +import { join } from "node:path"; +import { existsSync } from "node:fs"; +import { writeFile } from "node:fs/promises"; + import chalk from "chalk"; +import { loadConfig } from "c12"; -import { JSONFile, JSONFileWithMeta, debug } from "./lib"; +import { JSONFile, debug } from "./lib"; import { CONFIG_FILE, NAME } from "./const"; -import { Config } from "./types"; +import { SchnipselConfig } from "./types"; import { Renderers } from "./renderers"; -export class ConfigFile extends JSONFile { +export class ConfigFile { + private _name: typeof CONFIG_FILE = CONFIG_FILE; + get name() { + return this._name; + } + + private _cwd: string; + get cwd() { + return this._cwd; + } + + private _path: string; + get path() { + return this._path; + } + constructor(cwd = process.cwd()) { - super(CONFIG_FILE, cwd); + this._cwd = cwd; + this._path = join(this.cwd, this.name); + } + + exists() { + return existsSync(this.path); } async init(): Promise { if (this.exists()) { throw new Error( - `${chalk.cyan(CONFIG_FILE)} already exists in ${chalk.cyan(this.cwd)}`, + `${chalk.cyan(this.name)} already exists in ${chalk.cyan(this.cwd)}`, ); } - await this.write({ - __meta: await new JSONFile("package.json", this.cwd).readMeta(), - input: { - directory: "src", - }, - renderers: [], - }); + const { indent } = await new JSONFile("package.json", this.cwd).readMeta(); + + await writeFile( + this.path, + `import { defineSchnipselConfig } from "schnipsel"; + +export default defineSchnipselConfig({ + input: { + directory: "src", + }, + renderers: [], +}); +`.replace(/\t/g, indent), + "utf8", + ); } - async read(): Promise> { + async read(): Promise { debug("Reading config file..."); + const { config } = await loadConfig({ + name: "schnipsel", + configFile: "schnipsel.config", + rcFile: false, + globalRc: false, + cwd: this.cwd, + }); + if (!this.exists()) { throw new Error( - `${chalk.cyan(CONFIG_FILE)} not found in ${chalk.cyan( + `${chalk.cyan(this.name)} not found in ${chalk.cyan( this.cwd, )}, create one with ${chalk.cyan(`${NAME} init`)}`, ); } - const config = await super.read(); + // const config = await super.read(); this.validate(config); @@ -47,8 +88,8 @@ export class ConfigFile extends JSONFile { } validate( - maybeConfig: JSONFileWithMeta, - ): asserts maybeConfig is JSONFileWithMeta { + maybeConfig: Record, + ): asserts maybeConfig is SchnipselConfig { const errors: string[] = []; // Validate `input` @@ -177,7 +218,7 @@ export class ConfigFile extends JSONFile { if (errors.length) { throw new Error( - `Invalid ${chalk.cyan(CONFIG_FILE)} at ${chalk.cyan( + `Invalid ${chalk.cyan(this.name)} at ${chalk.cyan( this.cwd, )}:\n\n- ${errors.join("\n- ")}`, ); diff --git a/src/defineSchnipselConfig.ts b/src/defineSchnipselConfig.ts new file mode 100644 index 0000000..3ce1cfa --- /dev/null +++ b/src/defineSchnipselConfig.ts @@ -0,0 +1,5 @@ +import { SchnipselConfig } from "./types"; + +export const defineSchnipselConfig = (config: SchnipselConfig) => { + return config; +};