diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..f59ec20 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +* \ No newline at end of file diff --git a/README.md b/README.md index e7142eb..ba75c63 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ The fastest and leanest way to bundle your Kirby Panel plugins. No configuration - 🍂 Lightweight, robust and tested - ⚡️ Fast compilation with Vite/esbuild -- 🔍 Watch mode +- 🔄 Hot Module Replacement and Watch mode - \*️⃣ `kirbyup.import` to [auto-import blocks & fields](#auto-import-blocks-and-fields) - 🎒 [PostCSS support](#postcss) - 🧭 [Path resolve aliases](#path-resolve-aliases) @@ -36,7 +36,7 @@ If you want to use kirbyup right away, there is no need to install it. Simply ca ```json { "scripts": { - "dev": "npx -y kirbyup src/index.js --watch", + "dev": "npx -y kirbyup serve src/index.js", "build": "npx -y kirbyup src/index.js" } } @@ -55,7 +55,7 @@ Example package configuration: ```json { "scripts": { - "dev": "kirbyup src/index.js --watch", + "dev": "kirbyup serve src/index.js", "build": "kirbyup src/index.js" }, "devDependencies": { @@ -70,23 +70,13 @@ Global installation is supported as well, but not recommended. ### Development -Rebuild the Panel plugin on any file changes: +Start a development server for the Panel plugin: ```bash -kirbyup src/index.js --watch +kirbyup serve src/index.js ``` -You can also specify the directories to be watched. By default, if no path is specified, kirbyup watches the directory specified by the input file (`src` for the example above). - -```bash -kirbyup src/index.js --watch src -``` - -You can specify more than a single directory: - -```bash -kirbyup src/index.js --watch src --watch libs -``` +This creates `./index.dev.mjs`, telling Kirby to load the development version of the plugin from the dev server started by `kirbyup serve`, enhanced by features like hot module replacement and auto-reload. ### Production @@ -94,7 +84,7 @@ kirbyup src/index.js --watch src --watch libs kirbyup src/index.js ``` -The final panel plugin will be bundled, minified, and written into the current directory as `./index.js`. +The final panel plugin will be bundled, minified, and written into the current directory as `./index.js` and `./index.css`. ## Built-in Features @@ -222,15 +212,38 @@ For a complete list of options, take a look at the [Vite configuration options]( ## Options -> Inspect all available options with `kirbyup --help`. +> Inspect all available options with `kirbyup --help` and `kirbyup serve --help`. + +### `kirbyup ` -### `--out-dir` +##### `--out-dir ` The output directory to save the processed code into. Defaults to the current working directory. -### `--watch` +##### `--watch [path]` + +Enables watch mode. If no path is specified, kirbyup watches the folder of the input file. Repeat `--watch` for multiple paths. + +### `kirbyup serve ` + +##### `--port ` + +The port for the development server to run on. Defaults to `5177`. + +##### `--out-dir ` + +The output directory where the plugin file read by Kirby is saved. Defaults to the project root. + +##### `--watch ` + +Specifies additional files that should be watched for changes, with changes causing the page to reload. Repeat `--watch` for multiple paths. + +> 💡 By default, kirbyup will watch all PHP files (`./**/*.php`) in the plugin directory and reload the page if it detects changes. Using `--watch` to set your own path overrides this setting, so you need to add the PHP glob explicitly if you want to keep the behavior: `--watch ./my/files/* --watch ./**/*.php` + +##### `--no-watch` + +Disables the default behavior of watching all PHP files for changes. -Sets the watch mode. If no path is specified, kirbyup watches the folder of the input file. Repeat `--watch` for multiple paths. ## Credits diff --git a/examples/eslint-and-prettier/package.json b/examples/eslint-and-prettier/package.json index 35e6b55..ab923b2 100644 --- a/examples/eslint-and-prettier/package.json +++ b/examples/eslint-and-prettier/package.json @@ -1,7 +1,7 @@ { "private": true, "scripts": { - "dev": "kirbyup src/index.js --watch", + "dev": "kirbyup serve src/index.js", "build": "kirbyup src/index.js", "lint": "eslint \"src/**/*.{js,vue}\"", "lint:fix": "npm run lint -- --fix", diff --git a/examples/tailwindcss/package.json b/examples/tailwindcss/package.json index 8a7fa15..fabfa4a 100644 --- a/examples/tailwindcss/package.json +++ b/examples/tailwindcss/package.json @@ -1,7 +1,7 @@ { "private": true, "scripts": { - "dev": "kirbyup src/index.js --watch", + "dev": "kirbyup serve src/index.js", "build": "kirbyup src/index.js" }, "devDependencies": { diff --git a/package.json b/package.json index 85e753f..3685778 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "kirbyup", "version": "1.3.2", - "packageManager": "pnpm@7.6.0", + "packageManager": "pnpm@7.8.0", "description": "Zero-config bundler for Kirby Panel plugins", "author": { "name": "Johann Schopplich", @@ -74,6 +74,7 @@ "cac": "^6.7.12", "chokidar": "^3.5.3", "consola": "^2.15.3", + "detect-package-manager": "^2.0.1", "magic-string": "^0.26.2", "pathe": "^0.3.3", "perfect-debounce": "^0.1.3", @@ -85,6 +86,7 @@ "sass": "^1.54.1", "unconfig": "^0.3.5", "vite": "^3.0.4", + "vite-plugin-full-reload": "^1.0.4", "vue": "^2.7.8" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d638976..12f6aff 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -16,6 +16,7 @@ specifiers: cac: ^6.7.12 chokidar: ^3.5.3 consola: ^2.15.3 + detect-package-manager: ^2.0.1 eslint: ^8.21.0 fast-glob: ^3.2.11 fs-extra: ^10.1.0 @@ -33,6 +34,7 @@ specifiers: unbuild: ^0.7.6 unconfig: ^0.3.5 vite: ^3.0.4 + vite-plugin-full-reload: ^1.0.4 vitest: ^0.20.3 vue: ^2.7.8 @@ -41,6 +43,7 @@ dependencies: cac: 6.7.12 chokidar: 3.5.3 consola: 2.15.3 + detect-package-manager: 2.0.1 magic-string: 0.26.2 pathe: 0.3.3 perfect-debounce: 0.1.3 @@ -52,6 +55,7 @@ dependencies: sass: 1.54.1 unconfig: 0.3.5 vite: 3.0.4_sass@1.54.1 + vite-plugin-full-reload: 1.0.4_vite@3.0.4 vue: 2.7.8 devDependencies: @@ -79,7 +83,7 @@ packages: '@jridgewell/trace-mapping': 0.3.14 dev: true - /@antfu/eslint-config-basic/0.25.2_iosr3hrei2tubxveewluhu5lhy: + /@antfu/eslint-config-basic/0.25.2_jnss7dz76sznncvpyatba5hbxa: resolution: {integrity: sha512-D81jE90B7cujMmU2mKEaUcRsKRAfVX4PniEoaD0c3HiqprqghfBjuv3B6p1+tG9uJQAgLBVsK+G92Y+AAgFaOA==} peerDependencies: eslint: '>=7.4.0' @@ -88,7 +92,7 @@ packages: eslint-plugin-antfu: 0.25.2_qugx7qdu5zevzvxaiqyxfiwquq eslint-plugin-eslint-comments: 3.2.0_eslint@8.21.0 eslint-plugin-html: 6.2.0 - eslint-plugin-import: 2.26.0_wuikv5nqgdfyng42xxm7lklfmi + eslint-plugin-import: 2.26.0_eygs4xj346vriqwkjbwjuyviaa eslint-plugin-jsonc: 2.3.1_eslint@8.21.0 eslint-plugin-markdown: 2.2.1_eslint@8.21.0 eslint-plugin-n: 15.2.4_eslint@8.21.0 @@ -126,9 +130,9 @@ packages: eslint: '>=7.4.0' typescript: '>=3.9' dependencies: - '@antfu/eslint-config-basic': 0.25.2_iosr3hrei2tubxveewluhu5lhy - '@typescript-eslint/eslint-plugin': 5.32.0_iosr3hrei2tubxveewluhu5lhy - '@typescript-eslint/parser': 5.32.0_qugx7qdu5zevzvxaiqyxfiwquq + '@antfu/eslint-config-basic': 0.25.2_jnss7dz76sznncvpyatba5hbxa + '@typescript-eslint/eslint-plugin': 5.31.0_jnss7dz76sznncvpyatba5hbxa + '@typescript-eslint/parser': 5.31.0_qugx7qdu5zevzvxaiqyxfiwquq eslint: 8.21.0 typescript: 4.7.4 transitivePeerDependencies: @@ -159,12 +163,12 @@ packages: dependencies: '@antfu/eslint-config-react': 0.25.2_qugx7qdu5zevzvxaiqyxfiwquq '@antfu/eslint-config-vue': 0.25.2_qugx7qdu5zevzvxaiqyxfiwquq - '@typescript-eslint/eslint-plugin': 5.32.0_iosr3hrei2tubxveewluhu5lhy - '@typescript-eslint/parser': 5.32.0_qugx7qdu5zevzvxaiqyxfiwquq + '@typescript-eslint/eslint-plugin': 5.31.0_jnss7dz76sznncvpyatba5hbxa + '@typescript-eslint/parser': 5.31.0_qugx7qdu5zevzvxaiqyxfiwquq eslint: 8.21.0 eslint-plugin-eslint-comments: 3.2.0_eslint@8.21.0 eslint-plugin-html: 6.2.0 - eslint-plugin-import: 2.26.0_wuikv5nqgdfyng42xxm7lklfmi + eslint-plugin-import: 2.26.0_eygs4xj346vriqwkjbwjuyviaa eslint-plugin-jsonc: 2.3.1_eslint@8.21.0 eslint-plugin-n: 15.2.4_eslint@8.21.0 eslint-plugin-promise: 6.0.0_eslint@8.21.0 @@ -196,20 +200,20 @@ packages: engines: {node: '>=6.9.0'} dev: true - /@babel/core/7.18.10: - resolution: {integrity: sha512-JQM6k6ENcBFKVtWvLavlvi/mPcpYZ3+R+2EySDEMSMbp7Mn4FexlbbJVrx2R7Ijhr01T8gyqrOaABWIOgxeUyw==} + /@babel/core/7.18.9: + resolution: {integrity: sha512-1LIb1eL8APMy91/IMW+31ckrfBM4yCoLaVzoDhZUKSM4cu1L1nIidyxkCgzPAgrC5WEz36IPEr/eSeSF9pIn+g==} engines: {node: '>=6.9.0'} dependencies: '@ampproject/remapping': 2.2.0 '@babel/code-frame': 7.18.6 - '@babel/generator': 7.18.10 - '@babel/helper-compilation-targets': 7.18.9_@babel+core@7.18.10 + '@babel/generator': 7.18.9 + '@babel/helper-compilation-targets': 7.18.9_@babel+core@7.18.9 '@babel/helper-module-transforms': 7.18.9 '@babel/helpers': 7.18.9 - '@babel/parser': 7.18.10 - '@babel/template': 7.18.10 - '@babel/traverse': 7.18.10 - '@babel/types': 7.18.10 + '@babel/parser': 7.18.9 + '@babel/template': 7.18.6 + '@babel/traverse': 7.18.9 + '@babel/types': 7.18.9 convert-source-map: 1.8.0 debug: 4.3.4 gensync: 1.0.0-beta.2 @@ -219,23 +223,23 @@ packages: - supports-color dev: true - /@babel/generator/7.18.10: - resolution: {integrity: sha512-0+sW7e3HjQbiHbj1NeU/vN8ornohYlacAfZIaXhdoGweQqgcNy69COVciYYqEXJ/v+9OBA7Frxm4CVAuNqKeNA==} + /@babel/generator/7.18.9: + resolution: {integrity: sha512-wt5Naw6lJrL1/SGkipMiFxJjtyczUWTP38deiP1PO60HsBjDeKk08CGC3S8iVuvf0FmTdgKwU1KIXzSKL1G0Ug==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.18.10 + '@babel/types': 7.18.9 '@jridgewell/gen-mapping': 0.3.2 jsesc: 2.5.2 dev: true - /@babel/helper-compilation-targets/7.18.9_@babel+core@7.18.10: + /@babel/helper-compilation-targets/7.18.9_@babel+core@7.18.9: resolution: {integrity: sha512-tzLCyVmqUiFlcFoAPLA/gL9TeYrF61VLNtb+hvkuVaB5SUjW7jcfrglBIX1vUIoT7CLP3bBlIMeyEsIl2eFQNg==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0 dependencies: '@babel/compat-data': 7.18.8 - '@babel/core': 7.18.10 + '@babel/core': 7.18.9 '@babel/helper-validator-option': 7.18.6 browserslist: 4.21.3 semver: 6.3.0 @@ -250,22 +254,22 @@ packages: resolution: {integrity: sha512-fJgWlZt7nxGksJS9a0XdSaI4XvpExnNIgRP+rVefWh5U7BL8pPuir6SJUmFKRfjWQ51OtWSzwOxhaH/EBWWc0A==} engines: {node: '>=6.9.0'} dependencies: - '@babel/template': 7.18.10 - '@babel/types': 7.18.10 + '@babel/template': 7.18.6 + '@babel/types': 7.18.9 dev: true /@babel/helper-hoist-variables/7.18.6: resolution: {integrity: sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.18.10 + '@babel/types': 7.18.9 dev: true /@babel/helper-module-imports/7.18.6: resolution: {integrity: sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.18.10 + '@babel/types': 7.18.9 dev: true /@babel/helper-module-transforms/7.18.9: @@ -277,9 +281,9 @@ packages: '@babel/helper-simple-access': 7.18.6 '@babel/helper-split-export-declaration': 7.18.6 '@babel/helper-validator-identifier': 7.18.6 - '@babel/template': 7.18.10 - '@babel/traverse': 7.18.10 - '@babel/types': 7.18.10 + '@babel/template': 7.18.6 + '@babel/traverse': 7.18.9 + '@babel/types': 7.18.9 transitivePeerDependencies: - supports-color dev: true @@ -288,20 +292,16 @@ packages: resolution: {integrity: sha512-iNpIgTgyAvDQpDj76POqg+YEt8fPxx3yaNBg3S30dxNKm2SWfYhD0TGrK/Eu9wHpUW63VQU894TsTg+GLbUa1g==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.18.10 + '@babel/types': 7.18.9 dev: true /@babel/helper-split-export-declaration/7.18.6: resolution: {integrity: sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.18.10 + '@babel/types': 7.18.9 dev: true - /@babel/helper-string-parser/7.18.10: - resolution: {integrity: sha512-XtIfWmeNY3i4t7t4D2t02q50HvqHybPqW2ki1kosnvWCwuCMeo81Jf0gwr85jy/neUdg5XDdeFE/80DXiO+njw==} - engines: {node: '>=6.9.0'} - /@babel/helper-validator-identifier/7.18.6: resolution: {integrity: sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g==} engines: {node: '>=6.9.0'} @@ -315,9 +315,9 @@ packages: resolution: {integrity: sha512-Jf5a+rbrLoR4eNdUmnFu8cN5eNJT6qdTdOg5IHIzq87WwyRw9PwguLFOWYgktN/60IP4fgDUawJvs7PjQIzELQ==} engines: {node: '>=6.9.0'} dependencies: - '@babel/template': 7.18.10 - '@babel/traverse': 7.18.10 - '@babel/types': 7.18.10 + '@babel/template': 7.18.6 + '@babel/traverse': 7.18.9 + '@babel/types': 7.18.9 transitivePeerDependencies: - supports-color dev: true @@ -331,61 +331,52 @@ packages: js-tokens: 4.0.0 dev: true - /@babel/parser/7.18.10: - resolution: {integrity: sha512-TYk3OA0HKL6qNryUayb5UUEhM/rkOQozIBEA5ITXh5DWrSp0TlUQXMyZmnWxG/DizSWBeeQ0Zbc5z8UGaaqoeg==} + /@babel/parser/7.18.9: + resolution: {integrity: sha512-9uJveS9eY9DJ0t64YbIBZICtJy8a5QrDEVdiLCG97fVLpDTpGX7t8mMSb6OWw6Lrnjqj4O8zwjELX3dhoMgiBg==} engines: {node: '>=6.0.0'} hasBin: true dependencies: - '@babel/types': 7.18.10 + '@babel/types': 7.18.9 - /@babel/standalone/7.18.10: - resolution: {integrity: sha512-0KWHiRX9TUHiWE+dKYYEOIiRJcPwGU6u8Bq/p+ldekj7Kew9PCwl4S4FTSEPpTrn3Vc+r3iRSaN1l9AcGgLx4Q==} + /@babel/standalone/7.18.9: + resolution: {integrity: sha512-6E+p5azHMHcMkHzGFnA7Pqhtgfwx1cClwjMqomMHhdFupCLZDDpVQUctRGYE7p7nn7cXJZSI/L9en+tt30AP3w==} engines: {node: '>=6.9.0'} dev: true - /@babel/template/7.18.10: - resolution: {integrity: sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA==} + /@babel/template/7.18.6: + resolution: {integrity: sha512-JoDWzPe+wgBsTTgdnIma3iHNFC7YVJoPssVBDjiHfNlyt4YcunDtcDOUmfVDfCK5MfdsaIoX9PkijPhjH3nYUw==} engines: {node: '>=6.9.0'} dependencies: '@babel/code-frame': 7.18.6 - '@babel/parser': 7.18.10 - '@babel/types': 7.18.10 + '@babel/parser': 7.18.9 + '@babel/types': 7.18.9 dev: true - /@babel/traverse/7.18.10: - resolution: {integrity: sha512-J7ycxg0/K9XCtLyHf0cz2DqDihonJeIo+z+HEdRe9YuT8TY4A66i+Ab2/xZCEW7Ro60bPCBBfqqboHSamoV3+g==} + /@babel/traverse/7.18.9: + resolution: {integrity: sha512-LcPAnujXGwBgv3/WHv01pHtb2tihcyW1XuL9wd7jqh1Z8AQkTd+QVjMrMijrln0T7ED3UXLIy36P9Ao7W75rYg==} engines: {node: '>=6.9.0'} dependencies: '@babel/code-frame': 7.18.6 - '@babel/generator': 7.18.10 + '@babel/generator': 7.18.9 '@babel/helper-environment-visitor': 7.18.9 '@babel/helper-function-name': 7.18.9 '@babel/helper-hoist-variables': 7.18.6 '@babel/helper-split-export-declaration': 7.18.6 - '@babel/parser': 7.18.10 - '@babel/types': 7.18.10 + '@babel/parser': 7.18.9 + '@babel/types': 7.18.9 debug: 4.3.4 globals: 11.12.0 transitivePeerDependencies: - supports-color dev: true - /@babel/types/7.18.10: - resolution: {integrity: sha512-MJvnbEiiNkpjo+LknnmRrqbY1GPUUggjv+wQVjetM/AONoupqRALB7I6jGqNUAZsKcRIEu2J6FRFvsczljjsaQ==} + /@babel/types/7.18.9: + resolution: {integrity: sha512-WwMLAg2MvJmt/rKEVQBBhIVffMmnilX4oe0sRe7iPOHIGsqpruFHHdrfj4O1CMMtgMtCU4oPafZjDPCRgO57Wg==} engines: {node: '>=6.9.0'} dependencies: - '@babel/helper-string-parser': 7.18.10 '@babel/helper-validator-identifier': 7.18.6 to-fast-properties: 2.0.0 - /@esbuild/linux-loong64/0.14.53: - resolution: {integrity: sha512-W2dAL6Bnyn4xa/QRSU3ilIK4EzD5wgYXKXJiS1HDF5vU3675qc2bvFyLwbUcdmssDveyndy7FbitrCoiV/eMLg==} - engines: {node: '>=12'} - cpu: [loong64] - os: [linux] - requiresBuild: true - optional: true - /@eslint/eslintrc/1.3.0: resolution: {integrity: sha512-UWW0TMTmk2d7hLcWD1/e2g5HDM/HQ3csaLSqXCfqwh4uNDuNqlaKWXmEsL4Cs41Z0KnILNvwbHAah3C2yt06kw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -535,7 +526,7 @@ packages: '@rollup/pluginutils': 3.1.0_rollup@2.77.2 '@types/resolve': 1.17.1 deepmerge: 4.2.2 - is-builtin-module: 3.2.0 + is-builtin-module: 3.1.0 is-module: 1.0.0 resolve: 1.22.1 rollup: 2.77.2 @@ -631,8 +622,8 @@ packages: resolution: {integrity: sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ==} dev: true - /@typescript-eslint/eslint-plugin/5.32.0_iosr3hrei2tubxveewluhu5lhy: - resolution: {integrity: sha512-CHLuz5Uz7bHP2WgVlvoZGhf0BvFakBJKAD/43Ty0emn4wXWv5k01ND0C0fHcl/Im8Td2y/7h44E9pca9qAu2ew==} + /@typescript-eslint/eslint-plugin/5.31.0_jnss7dz76sznncvpyatba5hbxa: + resolution: {integrity: sha512-VKW4JPHzG5yhYQrQ1AzXgVgX8ZAJEvCz0QI6mLRX4tf7rnFfh5D8SKm0Pq6w5PyNfAWJk6sv313+nEt3ohWMBQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: '@typescript-eslint/parser': ^5.0.0 @@ -642,10 +633,10 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/parser': 5.32.0_qugx7qdu5zevzvxaiqyxfiwquq - '@typescript-eslint/scope-manager': 5.32.0 - '@typescript-eslint/type-utils': 5.32.0_qugx7qdu5zevzvxaiqyxfiwquq - '@typescript-eslint/utils': 5.32.0_qugx7qdu5zevzvxaiqyxfiwquq + '@typescript-eslint/parser': 5.31.0_qugx7qdu5zevzvxaiqyxfiwquq + '@typescript-eslint/scope-manager': 5.31.0 + '@typescript-eslint/type-utils': 5.31.0_qugx7qdu5zevzvxaiqyxfiwquq + '@typescript-eslint/utils': 5.31.0_qugx7qdu5zevzvxaiqyxfiwquq debug: 4.3.4 eslint: 8.21.0 functional-red-black-tree: 1.0.1 @@ -658,8 +649,8 @@ packages: - supports-color dev: true - /@typescript-eslint/parser/5.32.0_qugx7qdu5zevzvxaiqyxfiwquq: - resolution: {integrity: sha512-IxRtsehdGV9GFQ35IGm5oKKR2OGcazUoiNBxhRV160iF9FoyuXxjY+rIqs1gfnd+4eL98OjeGnMpE7RF/NBb3A==} + /@typescript-eslint/parser/5.31.0_qugx7qdu5zevzvxaiqyxfiwquq: + resolution: {integrity: sha512-UStjQiZ9OFTFReTrN+iGrC6O/ko9LVDhreEK5S3edmXgR396JGq7CoX2TWIptqt/ESzU2iRKXAHfSF2WJFcWHw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 @@ -668,9 +659,9 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/scope-manager': 5.32.0 - '@typescript-eslint/types': 5.32.0 - '@typescript-eslint/typescript-estree': 5.32.0_typescript@4.7.4 + '@typescript-eslint/scope-manager': 5.31.0 + '@typescript-eslint/types': 5.31.0 + '@typescript-eslint/typescript-estree': 5.31.0_typescript@4.7.4 debug: 4.3.4 eslint: 8.21.0 typescript: 4.7.4 @@ -678,16 +669,16 @@ packages: - supports-color dev: true - /@typescript-eslint/scope-manager/5.32.0: - resolution: {integrity: sha512-KyAE+tUON0D7tNz92p1uetRqVJiiAkeluvwvZOqBmW9z2XApmk5WSMV9FrzOroAcVxJZB3GfUwVKr98Dr/OjOg==} + /@typescript-eslint/scope-manager/5.31.0: + resolution: {integrity: sha512-8jfEzBYDBG88rcXFxajdVavGxb5/XKXyvWgvD8Qix3EEJLCFIdVloJw+r9ww0wbyNLOTYyBsR+4ALNGdlalLLg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.32.0 - '@typescript-eslint/visitor-keys': 5.32.0 + '@typescript-eslint/types': 5.31.0 + '@typescript-eslint/visitor-keys': 5.31.0 dev: true - /@typescript-eslint/type-utils/5.32.0_qugx7qdu5zevzvxaiqyxfiwquq: - resolution: {integrity: sha512-0gSsIhFDduBz3QcHJIp3qRCvVYbqzHg8D6bHFsDMrm0rURYDj+skBK2zmYebdCp+4nrd9VWd13egvhYFJj/wZg==} + /@typescript-eslint/type-utils/5.31.0_qugx7qdu5zevzvxaiqyxfiwquq: + resolution: {integrity: sha512-7ZYqFbvEvYXFn9ax02GsPcEOmuWNg+14HIf4q+oUuLnMbpJ6eHAivCg7tZMVwzrIuzX3QCeAOqKoyMZCv5xe+w==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: '*' @@ -696,7 +687,7 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/utils': 5.32.0_qugx7qdu5zevzvxaiqyxfiwquq + '@typescript-eslint/utils': 5.31.0_qugx7qdu5zevzvxaiqyxfiwquq debug: 4.3.4 eslint: 8.21.0 tsutils: 3.21.0_typescript@4.7.4 @@ -705,13 +696,13 @@ packages: - supports-color dev: true - /@typescript-eslint/types/5.32.0: - resolution: {integrity: sha512-EBUKs68DOcT/EjGfzywp+f8wG9Zw6gj6BjWu7KV/IYllqKJFPlZlLSYw/PTvVyiRw50t6wVbgv4p9uE2h6sZrQ==} + /@typescript-eslint/types/5.31.0: + resolution: {integrity: sha512-/f/rMaEseux+I4wmR6mfpM2wvtNZb1p9hAV77hWfuKc3pmaANp5dLAZSiE3/8oXTYTt3uV9KW5yZKJsMievp6g==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@typescript-eslint/typescript-estree/5.32.0_typescript@4.7.4: - resolution: {integrity: sha512-ZVAUkvPk3ITGtCLU5J4atCw9RTxK+SRc6hXqLtllC2sGSeMFWN+YwbiJR9CFrSFJ3w4SJfcWtDwNb/DmUIHdhg==} + /@typescript-eslint/typescript-estree/5.31.0_typescript@4.7.4: + resolution: {integrity: sha512-3S625TMcARX71wBc2qubHaoUwMEn+l9TCsaIzYI/ET31Xm2c9YQ+zhGgpydjorwQO9pLfR/6peTzS/0G3J/hDw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: typescript: '*' @@ -719,8 +710,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/types': 5.32.0 - '@typescript-eslint/visitor-keys': 5.32.0 + '@typescript-eslint/types': 5.31.0 + '@typescript-eslint/visitor-keys': 5.31.0 debug: 4.3.4 globby: 11.1.0 is-glob: 4.0.3 @@ -731,16 +722,16 @@ packages: - supports-color dev: true - /@typescript-eslint/utils/5.32.0_qugx7qdu5zevzvxaiqyxfiwquq: - resolution: {integrity: sha512-W7lYIAI5Zlc5K082dGR27Fczjb3Q57ECcXefKU/f0ajM5ToM0P+N9NmJWip8GmGu/g6QISNT+K6KYB+iSHjXCQ==} + /@typescript-eslint/utils/5.31.0_qugx7qdu5zevzvxaiqyxfiwquq: + resolution: {integrity: sha512-kcVPdQS6VIpVTQ7QnGNKMFtdJdvnStkqS5LeALr4rcwx11G6OWb2HB17NMPnlRHvaZP38hL9iK8DdE9Fne7NYg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: '@types/json-schema': 7.0.11 - '@typescript-eslint/scope-manager': 5.32.0 - '@typescript-eslint/types': 5.32.0 - '@typescript-eslint/typescript-estree': 5.32.0_typescript@4.7.4 + '@typescript-eslint/scope-manager': 5.31.0 + '@typescript-eslint/types': 5.31.0 + '@typescript-eslint/typescript-estree': 5.31.0_typescript@4.7.4 eslint: 8.21.0 eslint-scope: 5.1.1 eslint-utils: 3.0.0_eslint@8.21.0 @@ -749,11 +740,11 @@ packages: - typescript dev: true - /@typescript-eslint/visitor-keys/5.32.0: - resolution: {integrity: sha512-S54xOHZgfThiZ38/ZGTgB2rqx51CMJ5MCfVT2IplK4Q7hgzGfe0nLzLCcenDnc/cSjP568hdeKfeDcBgqNHD/g==} + /@typescript-eslint/visitor-keys/5.31.0: + resolution: {integrity: sha512-ZK0jVxSjS4gnPirpVjXHz7mgdOsZUHzNYSfTw2yPa3agfbt9YfqaBiBZFSSxeBWnpWkzCxTfUpnzA3Vily/CSg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.32.0 + '@typescript-eslint/types': 5.31.0 eslint-visitor-keys: 3.3.0 dev: true @@ -772,7 +763,7 @@ packages: /@vue/compiler-sfc/2.7.8: resolution: {integrity: sha512-2DK4YWKfgLnW9VDR9gnju1gcYRk3flKj8UNsms7fsRmFcg35slVTZEkqwBtX+wJBXaamFfn6NxSsZh3h12Ix/Q==} dependencies: - '@babel/parser': 7.18.10 + '@babel/parser': 7.18.9 postcss: 8.4.14 source-map: 0.6.1 @@ -900,7 +891,7 @@ packages: hasBin: true dependencies: caniuse-lite: 1.0.30001373 - electron-to-chromium: 1.4.210 + electron-to-chromium: 1.4.206 node-releases: 2.0.6 update-browserslist-db: 1.0.5_browserslist@4.21.3 dev: true @@ -1074,7 +1065,6 @@ packages: path-key: 3.1.1 shebang-command: 2.0.0 which: 2.0.2 - dev: true /cssesc/3.0.0: resolution: {integrity: sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==} @@ -1145,6 +1135,13 @@ packages: /defu/6.0.0: resolution: {integrity: sha512-t2MZGLf1V2rV4VBZbWIaXKdX/mUcYW0n2znQZoADBkGGxYL8EWqCuCZBmJPJ/Yy9fofJkyuuSuo5GSwo0XdEgw==} + /detect-package-manager/2.0.1: + resolution: {integrity: sha512-j/lJHyoLlWi6G1LDdLgvUtz60Zo5GEj+sVYtTVXnYLDPuzgC3llMxonXym9zIwhhUII8vjdw0LXxavpLqTbl1A==} + engines: {node: '>=12'} + dependencies: + execa: 5.1.1 + dev: false + /dir-glob/3.0.1: resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} engines: {node: '>=8'} @@ -1193,8 +1190,8 @@ packages: domhandler: 4.3.1 dev: true - /electron-to-chromium/1.4.210: - resolution: {integrity: sha512-kSiX4tuyZijV7Cz0MWVmGT8K2siqaOA4Z66K5dCttPPRh0HicOcOAEj1KlC8O8J1aOS/1M8rGofOzksLKaHWcQ==} + /electron-to-chromium/1.4.206: + resolution: {integrity: sha512-h+Fadt1gIaQ06JaIiyqPsBjJ08fV5Q7md+V8bUvQW/9OvXfL2LRICTz2EcnnCP7QzrFTS6/27MRV6Bl9Yn97zA==} dev: true /entities/2.2.0: @@ -1260,193 +1257,192 @@ packages: is-symbol: 1.0.4 dev: true - /esbuild-android-64/0.14.53: - resolution: {integrity: sha512-fIL93sOTnEU+NrTAVMIKiAw0YH22HWCAgg4N4Z6zov2t0kY9RAJ50zY9ZMCQ+RT6bnOfDt8gCTnt/RaSNA2yRA==} + /esbuild-android-64/0.14.51: + resolution: {integrity: sha512-6FOuKTHnC86dtrKDmdSj2CkcKF8PnqkaIXqvgydqfJmqBazCPdw+relrMlhGjkvVdiiGV70rpdnyFmA65ekBCQ==} engines: {node: '>=12'} cpu: [x64] os: [android] requiresBuild: true optional: true - /esbuild-android-arm64/0.14.53: - resolution: {integrity: sha512-PC7KaF1v0h/nWpvlU1UMN7dzB54cBH8qSsm7S9mkwFA1BXpaEOufCg8hdoEI1jep0KeO/rjZVWrsH8+q28T77A==} + /esbuild-android-arm64/0.14.51: + resolution: {integrity: sha512-vBtp//5VVkZWmYYvHsqBRCMMi1MzKuMIn5XDScmnykMTu9+TD9v0NMEDqQxvtFToeYmojdo5UCV2vzMQWJcJ4A==} engines: {node: '>=12'} cpu: [arm64] os: [android] requiresBuild: true optional: true - /esbuild-darwin-64/0.14.53: - resolution: {integrity: sha512-gE7P5wlnkX4d4PKvLBUgmhZXvL7lzGRLri17/+CmmCzfncIgq8lOBvxGMiQ4xazplhxq+72TEohyFMZLFxuWvg==} + /esbuild-darwin-64/0.14.51: + resolution: {integrity: sha512-YFmXPIOvuagDcwCejMRtCDjgPfnDu+bNeh5FU2Ryi68ADDVlWEpbtpAbrtf/lvFTWPexbgyKgzppNgsmLPr8PA==} engines: {node: '>=12'} cpu: [x64] os: [darwin] requiresBuild: true optional: true - /esbuild-darwin-arm64/0.14.53: - resolution: {integrity: sha512-otJwDU3hnI15Q98PX4MJbknSZ/WSR1I45il7gcxcECXzfN4Mrpft5hBDHXNRnCh+5858uPXBXA1Vaz2jVWLaIA==} + /esbuild-darwin-arm64/0.14.51: + resolution: {integrity: sha512-juYD0QnSKwAMfzwKdIF6YbueXzS6N7y4GXPDeDkApz/1RzlT42mvX9jgNmyOlWKN7YzQAYbcUEJmZJYQGdf2ow==} engines: {node: '>=12'} cpu: [arm64] os: [darwin] requiresBuild: true optional: true - /esbuild-freebsd-64/0.14.53: - resolution: {integrity: sha512-WkdJa8iyrGHyKiPF4lk0MiOF87Q2SkE+i+8D4Cazq3/iqmGPJ6u49je300MFi5I2eUsQCkaOWhpCVQMTKGww2w==} + /esbuild-freebsd-64/0.14.51: + resolution: {integrity: sha512-cLEI/aXjb6vo5O2Y8rvVSQ7smgLldwYY5xMxqh/dQGfWO+R1NJOFsiax3IS4Ng300SVp7Gz3czxT6d6qf2cw0g==} engines: {node: '>=12'} cpu: [x64] os: [freebsd] requiresBuild: true optional: true - /esbuild-freebsd-arm64/0.14.53: - resolution: {integrity: sha512-9T7WwCuV30NAx0SyQpw8edbKvbKELnnm1FHg7gbSYaatH+c8WJW10g/OdM7JYnv7qkimw2ZTtSA+NokOLd2ydQ==} + /esbuild-freebsd-arm64/0.14.51: + resolution: {integrity: sha512-TcWVw/rCL2F+jUgRkgLa3qltd5gzKjIMGhkVybkjk6PJadYInPtgtUBp1/hG+mxyigaT7ib+od1Xb84b+L+1Mg==} engines: {node: '>=12'} cpu: [arm64] os: [freebsd] requiresBuild: true optional: true - /esbuild-linux-32/0.14.53: - resolution: {integrity: sha512-VGanLBg5en2LfGDgLEUxQko2lqsOS7MTEWUi8x91YmsHNyzJVT/WApbFFx3MQGhkf+XdimVhpyo5/G0PBY91zg==} + /esbuild-linux-32/0.14.51: + resolution: {integrity: sha512-RFqpyC5ChyWrjx8Xj2K0EC1aN0A37H6OJfmUXIASEqJoHcntuV3j2Efr9RNmUhMfNE6yEj2VpYuDteZLGDMr0w==} engines: {node: '>=12'} cpu: [ia32] os: [linux] requiresBuild: true optional: true - /esbuild-linux-64/0.14.53: - resolution: {integrity: sha512-pP/FA55j/fzAV7N9DF31meAyjOH6Bjuo3aSKPh26+RW85ZEtbJv9nhoxmGTd9FOqjx59Tc1ZbrJabuiXlMwuZQ==} + /esbuild-linux-64/0.14.51: + resolution: {integrity: sha512-dxjhrqo5i7Rq6DXwz5v+MEHVs9VNFItJmHBe1CxROWNf4miOGoQhqSG8StStbDkQ1Mtobg6ng+4fwByOhoQoeA==} engines: {node: '>=12'} cpu: [x64] os: [linux] requiresBuild: true optional: true - /esbuild-linux-arm/0.14.53: - resolution: {integrity: sha512-/u81NGAVZMopbmzd21Nu/wvnKQK3pT4CrvQ8BTje1STXcQAGnfyKgQlj3m0j2BzYbvQxSy+TMck4TNV2onvoPA==} + /esbuild-linux-arm/0.14.51: + resolution: {integrity: sha512-LsJynDxYF6Neg7ZC7748yweCDD+N8ByCv22/7IAZglIEniEkqdF4HCaa49JNDLw1UQGlYuhOB8ZT/MmcSWzcWg==} engines: {node: '>=12'} cpu: [arm] os: [linux] requiresBuild: true optional: true - /esbuild-linux-arm64/0.14.53: - resolution: {integrity: sha512-GDmWITT+PMsjCA6/lByYk7NyFssW4Q6in32iPkpjZ/ytSyH+xeEx8q7HG3AhWH6heemEYEWpTll/eui3jwlSnw==} + /esbuild-linux-arm64/0.14.51: + resolution: {integrity: sha512-D9rFxGutoqQX3xJPxqd6o+kvYKeIbM0ifW2y0bgKk5HPgQQOo2k9/2Vpto3ybGYaFPCE5qTGtqQta9PoP6ZEzw==} engines: {node: '>=12'} cpu: [arm64] os: [linux] requiresBuild: true optional: true - /esbuild-linux-mips64le/0.14.53: - resolution: {integrity: sha512-d6/XHIQW714gSSp6tOOX2UscedVobELvQlPMkInhx1NPz4ThZI9uNLQ4qQJHGBGKGfu+rtJsxM4NVHLhnNRdWQ==} + /esbuild-linux-mips64le/0.14.51: + resolution: {integrity: sha512-vS54wQjy4IinLSlb5EIlLoln8buh1yDgliP4CuEHumrPk4PvvP4kTRIG4SzMXm6t19N0rIfT4bNdAxzJLg2k6A==} engines: {node: '>=12'} cpu: [mips64el] os: [linux] requiresBuild: true optional: true - /esbuild-linux-ppc64le/0.14.53: - resolution: {integrity: sha512-ndnJmniKPCB52m+r6BtHHLAOXw+xBCWIxNnedbIpuREOcbSU/AlyM/2dA3BmUQhsHdb4w3amD5U2s91TJ3MzzA==} + /esbuild-linux-ppc64le/0.14.51: + resolution: {integrity: sha512-xcdd62Y3VfGoyphNP/aIV9LP+RzFw5M5Z7ja+zdpQHHvokJM7d0rlDRMN+iSSwvUymQkqZO+G/xjb4/75du8BQ==} engines: {node: '>=12'} cpu: [ppc64] os: [linux] requiresBuild: true optional: true - /esbuild-linux-riscv64/0.14.53: - resolution: {integrity: sha512-yG2sVH+QSix6ct4lIzJj329iJF3MhloLE6/vKMQAAd26UVPVkhMFqFopY+9kCgYsdeWvXdPgmyOuKa48Y7+/EQ==} + /esbuild-linux-riscv64/0.14.51: + resolution: {integrity: sha512-syXHGak9wkAnFz0gMmRBoy44JV0rp4kVCEA36P5MCeZcxFq8+fllBC2t6sKI23w3qd8Vwo9pTADCgjTSf3L3rA==} engines: {node: '>=12'} cpu: [riscv64] os: [linux] requiresBuild: true optional: true - /esbuild-linux-s390x/0.14.53: - resolution: {integrity: sha512-OCJlgdkB+XPYndHmw6uZT7jcYgzmx9K+28PVdOa/eLjdoYkeAFvH5hTwX4AXGLZLH09tpl4bVsEtvuyUldaNCg==} + /esbuild-linux-s390x/0.14.51: + resolution: {integrity: sha512-kFAJY3dv+Wq8o28K/C7xkZk/X34rgTwhknSsElIqoEo8armCOjMJ6NsMxm48KaWY2h2RUYGtQmr+RGuUPKBhyw==} engines: {node: '>=12'} cpu: [s390x] os: [linux] requiresBuild: true optional: true - /esbuild-netbsd-64/0.14.53: - resolution: {integrity: sha512-gp2SB+Efc7MhMdWV2+pmIs/Ja/Mi5rjw+wlDmmbIn68VGXBleNgiEZG+eV2SRS0kJEUyHNedDtwRIMzaohWedQ==} + /esbuild-netbsd-64/0.14.51: + resolution: {integrity: sha512-ZZBI7qrR1FevdPBVHz/1GSk1x5GDL/iy42Zy8+neEm/HA7ma+hH/bwPEjeHXKWUDvM36CZpSL/fn1/y9/Hb+1A==} engines: {node: '>=12'} cpu: [x64] os: [netbsd] requiresBuild: true optional: true - /esbuild-openbsd-64/0.14.53: - resolution: {integrity: sha512-eKQ30ZWe+WTZmteDYg8S+YjHV5s4iTxeSGhJKJajFfQx9TLZJvsJX0/paqwP51GicOUruFpSUAs2NCc0a4ivQQ==} + /esbuild-openbsd-64/0.14.51: + resolution: {integrity: sha512-7R1/p39M+LSVQVgDVlcY1KKm6kFKjERSX1lipMG51NPcspJD1tmiZSmmBXoY5jhHIu6JL1QkFDTx94gMYK6vfA==} engines: {node: '>=12'} cpu: [x64] os: [openbsd] requiresBuild: true optional: true - /esbuild-sunos-64/0.14.53: - resolution: {integrity: sha512-OWLpS7a2FrIRukQqcgQqR1XKn0jSJoOdT+RlhAxUoEQM/IpytS3FXzCJM6xjUYtpO5GMY0EdZJp+ur2pYdm39g==} + /esbuild-sunos-64/0.14.51: + resolution: {integrity: sha512-HoHaCswHxLEYN8eBTtyO0bFEWvA3Kdb++hSQ/lLG7TyKF69TeSG0RNoBRAs45x/oCeWaTDntEZlYwAfQlhEtJA==} engines: {node: '>=12'} cpu: [x64] os: [sunos] requiresBuild: true optional: true - /esbuild-windows-32/0.14.53: - resolution: {integrity: sha512-m14XyWQP5rwGW0tbEfp95U6A0wY0DYPInWBB7D69FAXUpBpBObRoGTKRv36lf2RWOdE4YO3TNvj37zhXjVL5xg==} + /esbuild-windows-32/0.14.51: + resolution: {integrity: sha512-4rtwSAM35A07CBt1/X8RWieDj3ZUHQqUOaEo5ZBs69rt5WAFjP4aqCIobdqOy4FdhYw1yF8Z0xFBTyc9lgPtEg==} engines: {node: '>=12'} cpu: [ia32] os: [win32] requiresBuild: true optional: true - /esbuild-windows-64/0.14.53: - resolution: {integrity: sha512-s9skQFF0I7zqnQ2K8S1xdLSfZFsPLuOGmSx57h2btSEswv0N0YodYvqLcJMrNMXh6EynOmWD7rz+0rWWbFpIHQ==} + /esbuild-windows-64/0.14.51: + resolution: {integrity: sha512-HoN/5HGRXJpWODprGCgKbdMvrC3A2gqvzewu2eECRw2sYxOUoh2TV1tS+G7bHNapPGI79woQJGV6pFH7GH7qnA==} engines: {node: '>=12'} cpu: [x64] os: [win32] requiresBuild: true optional: true - /esbuild-windows-arm64/0.14.53: - resolution: {integrity: sha512-E+5Gvb+ZWts+00T9II6wp2L3KG2r3iGxByqd/a1RmLmYWVsSVUjkvIxZuJ3hYTIbhLkH5PRwpldGTKYqVz0nzQ==} + /esbuild-windows-arm64/0.14.51: + resolution: {integrity: sha512-JQDqPjuOH7o+BsKMSddMfmVJXrnYZxXDHsoLHc0xgmAZkOOCflRmC43q31pk79F9xuyWY45jDBPolb5ZgGOf9g==} engines: {node: '>=12'} cpu: [arm64] os: [win32] requiresBuild: true optional: true - /esbuild/0.14.53: - resolution: {integrity: sha512-ohO33pUBQ64q6mmheX1mZ8mIXj8ivQY/L4oVuAshr+aJI+zLl+amrp3EodrUNDNYVrKJXGPfIHFGhO8slGRjuw==} + /esbuild/0.14.51: + resolution: {integrity: sha512-+CvnDitD7Q5sT7F+FM65sWkF8wJRf+j9fPcprxYV4j+ohmzVj2W7caUqH2s5kCaCJAfcAICjSlKhDCcvDpU7nw==} engines: {node: '>=12'} hasBin: true requiresBuild: true optionalDependencies: - '@esbuild/linux-loong64': 0.14.53 - esbuild-android-64: 0.14.53 - esbuild-android-arm64: 0.14.53 - esbuild-darwin-64: 0.14.53 - esbuild-darwin-arm64: 0.14.53 - esbuild-freebsd-64: 0.14.53 - esbuild-freebsd-arm64: 0.14.53 - esbuild-linux-32: 0.14.53 - esbuild-linux-64: 0.14.53 - esbuild-linux-arm: 0.14.53 - esbuild-linux-arm64: 0.14.53 - esbuild-linux-mips64le: 0.14.53 - esbuild-linux-ppc64le: 0.14.53 - esbuild-linux-riscv64: 0.14.53 - esbuild-linux-s390x: 0.14.53 - esbuild-netbsd-64: 0.14.53 - esbuild-openbsd-64: 0.14.53 - esbuild-sunos-64: 0.14.53 - esbuild-windows-32: 0.14.53 - esbuild-windows-64: 0.14.53 - esbuild-windows-arm64: 0.14.53 + esbuild-android-64: 0.14.51 + esbuild-android-arm64: 0.14.51 + esbuild-darwin-64: 0.14.51 + esbuild-darwin-arm64: 0.14.51 + esbuild-freebsd-64: 0.14.51 + esbuild-freebsd-arm64: 0.14.51 + esbuild-linux-32: 0.14.51 + esbuild-linux-64: 0.14.51 + esbuild-linux-arm: 0.14.51 + esbuild-linux-arm64: 0.14.51 + esbuild-linux-mips64le: 0.14.51 + esbuild-linux-ppc64le: 0.14.51 + esbuild-linux-riscv64: 0.14.51 + esbuild-linux-s390x: 0.14.51 + esbuild-netbsd-64: 0.14.51 + esbuild-openbsd-64: 0.14.51 + esbuild-sunos-64: 0.14.51 + esbuild-windows-32: 0.14.51 + esbuild-windows-64: 0.14.51 + esbuild-windows-arm64: 0.14.51 /escalade/3.1.1: resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} @@ -1472,7 +1468,7 @@ packages: - supports-color dev: true - /eslint-module-utils/2.7.3_gjpiwexkhexdr4bbgrtzf23bg4: + /eslint-module-utils/2.7.3_vozeh3qpn3prlhg65r4uuu3jv4: resolution: {integrity: sha512-088JEC7O3lDZM9xGe0RerkOMd0EjFl+Yvd1jPWIkMT5u3H9+HC34mWWPnqPrN13gieT9pBOO+Qt07Nb/6TresQ==} engines: {node: '>=4'} peerDependencies: @@ -1490,7 +1486,7 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 5.32.0_qugx7qdu5zevzvxaiqyxfiwquq + '@typescript-eslint/parser': 5.31.0_qugx7qdu5zevzvxaiqyxfiwquq debug: 3.2.7 eslint-import-resolver-node: 0.3.6 find-up: 2.1.0 @@ -1501,7 +1497,7 @@ packages: /eslint-plugin-antfu/0.25.2_qugx7qdu5zevzvxaiqyxfiwquq: resolution: {integrity: sha512-yRhuFMwUKhSYm8BWTZsW4ymYnFPCJWZb2LzjG+mQb7JbKflk73JIFMCREPOaV4nWwc4YJEPhym75QsC7AFbqSw==} dependencies: - '@typescript-eslint/utils': 5.32.0_qugx7qdu5zevzvxaiqyxfiwquq + '@typescript-eslint/utils': 5.31.0_qugx7qdu5zevzvxaiqyxfiwquq transitivePeerDependencies: - eslint - supports-color @@ -1536,7 +1532,7 @@ packages: htmlparser2: 7.2.0 dev: true - /eslint-plugin-import/2.26.0_wuikv5nqgdfyng42xxm7lklfmi: + /eslint-plugin-import/2.26.0_eygs4xj346vriqwkjbwjuyviaa: resolution: {integrity: sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==} engines: {node: '>=4'} peerDependencies: @@ -1546,14 +1542,14 @@ packages: '@typescript-eslint/parser': optional: true dependencies: - '@typescript-eslint/parser': 5.32.0_qugx7qdu5zevzvxaiqyxfiwquq + '@typescript-eslint/parser': 5.31.0_qugx7qdu5zevzvxaiqyxfiwquq array-includes: 3.1.5 array.prototype.flat: 1.3.0 debug: 2.6.9 doctrine: 2.1.0 eslint: 8.21.0 eslint-import-resolver-node: 0.3.6 - eslint-module-utils: 2.7.3_gjpiwexkhexdr4bbgrtzf23bg4 + eslint-module-utils: 2.7.3_vozeh3qpn3prlhg65r4uuu3jv4 has: 1.0.3 is-core-module: 2.9.0 is-glob: 4.0.3 @@ -1653,7 +1649,7 @@ packages: eslint-utils: 3.0.0_eslint@8.21.0 esquery: 1.4.0 indent-string: 4.0.0 - is-builtin-module: 3.2.0 + is-builtin-module: 3.1.0 lodash: 4.17.21 pluralize: 8.0.0 read-pkg-up: 7.0.1 @@ -1792,6 +1788,15 @@ packages: - supports-color dev: true + /espree/9.3.2: + resolution: {integrity: sha512-D211tC7ZwouTIuY5x9XnS0E9sWNChB7IYKX/Xp5eQj3nFXhqmiUDB9q27y76oFl8jTg3pXcQx/bpxMfs3CIZbA==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dependencies: + acorn: 8.8.0 + acorn-jsx: 5.3.2_acorn@8.8.0 + eslint-visitor-keys: 3.3.0 + dev: true + /espree/9.3.3: resolution: {integrity: sha512-ORs1Rt/uQTqUKjDdGCyrtYxbazf5umATSf/K4qxjmZHORR6HJk+2s/2Pqe+Kk49HHINC/xNIrGfgh8sZcll0ng==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -1838,6 +1843,21 @@ packages: engines: {node: '>=0.10.0'} dev: true + /execa/5.1.1: + resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} + engines: {node: '>=10'} + dependencies: + cross-spawn: 7.0.3 + get-stream: 6.0.1 + human-signals: 2.1.0 + is-stream: 2.0.1 + merge-stream: 2.0.0 + npm-run-path: 4.0.1 + onetime: 5.1.2 + signal-exit: 3.0.7 + strip-final-newline: 2.0.0 + dev: false + /fast-deep-equal/3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} dev: true @@ -1973,6 +1993,11 @@ packages: has-symbols: 1.0.3 dev: true + /get-stream/6.0.1: + resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==} + engines: {node: '>=10'} + dev: false + /get-symbol-description/1.0.0: resolution: {integrity: sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==} engines: {node: '>= 0.4'} @@ -2092,6 +2117,11 @@ packages: entities: 3.0.1 dev: true + /human-signals/2.1.0: + resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} + engines: {node: '>=10.17.0'} + dev: false + /ignore/5.2.0: resolution: {integrity: sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==} engines: {node: '>= 4'} @@ -2173,8 +2203,8 @@ packages: has-tostringtag: 1.0.0 dev: true - /is-builtin-module/3.2.0: - resolution: {integrity: sha512-phDA4oSGt7vl1n5tJvTWooWWAsXLY+2xCnxNqvKhGEzujg+A43wPlPOyDg3C8XQHN+6k/JTQWJ/j0dQh/qr+Hw==} + /is-builtin-module/3.1.0: + resolution: {integrity: sha512-OV7JjAgOTfAFJmHZLvpSTb4qi0nIILDV1gWPYDnDJUTNFM5aGlRAhk4QcT8i7TuAleeEV5Fdkqn3t4mS+Q11fg==} engines: {node: '>=6'} dependencies: builtin-modules: 3.3.0 @@ -2255,6 +2285,11 @@ packages: call-bind: 1.0.2 dev: true + /is-stream/2.0.1: + resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==} + engines: {node: '>=8'} + dev: false + /is-string/1.0.7: resolution: {integrity: sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==} engines: {node: '>= 0.4'} @@ -2277,7 +2312,6 @@ packages: /isexe/2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} - dev: true /jiti/1.14.0: resolution: {integrity: sha512-4IwstlaKQc9vCTC+qUXLM1hajy2ImiL9KnLvVYiaHOtS/v3wRjhLlGl121AmgDgx/O43uKmxownJghS5XMya2A==} @@ -2336,7 +2370,7 @@ packages: dependencies: acorn: 8.8.0 eslint-visitor-keys: 3.3.0 - espree: 9.3.3 + espree: 9.3.2 semver: 7.3.7 dev: true @@ -2470,6 +2504,10 @@ packages: resolution: {integrity: sha512-AW4DRS3QbBayY/jJmD8437V1Gombjf8RSOUCMFBuo5iHi58AGEgVCKQ+ezHkZZDpAQS75hcBMpLqjpJTjtUL7w==} dev: true + /merge-stream/2.0.0: + resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} + dev: false + /merge2/1.4.1: resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} engines: {node: '>= 8'} @@ -2492,6 +2530,11 @@ packages: picomatch: 2.3.1 dev: true + /mimic-fn/2.1.0: + resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} + engines: {node: '>=6'} + dev: false + /min-indent/1.0.1: resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} engines: {node: '>=4'} @@ -2523,7 +2566,7 @@ packages: optional: true dependencies: defu: 6.0.0 - esbuild: 0.14.53 + esbuild: 0.14.51 fs-extra: 10.1.0 globby: 11.1.0 jiti: 1.14.0 @@ -2582,6 +2625,13 @@ packages: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} engines: {node: '>=0.10.0'} + /npm-run-path/4.0.1: + resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==} + engines: {node: '>=8'} + dependencies: + path-key: 3.1.1 + dev: false + /nth-check/2.1.1: resolution: {integrity: sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==} dependencies: @@ -2652,6 +2702,13 @@ packages: wrappy: 1.0.2 dev: true + /onetime/5.1.2: + resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==} + engines: {node: '>=6'} + dependencies: + mimic-fn: 2.1.0 + dev: false + /optionator/0.9.1: resolution: {integrity: sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==} engines: {node: '>= 0.8.0'} @@ -2762,7 +2819,6 @@ packages: /path-key/3.1.1: resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} engines: {node: '>=8'} - dev: true /path-parse/1.0.7: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} @@ -2989,7 +3045,7 @@ packages: '@babel/code-frame': 7.18.6 dev: true - /rollup-plugin-esbuild/4.9.1_eqz4txfukrxgk4uaulv43wixku: + /rollup-plugin-esbuild/4.9.1_ecpsl2p7zl5puhr4xxlpah6uzm: resolution: {integrity: sha512-qn/x7Wz9p3Xnva99qcb+nopH0d2VJwVnsxJTGEg+Sh2Z3tqQl33MhOwzekVo1YTKgv+yAmosjcBRJygMfGrtLw==} engines: {node: '>=12'} peerDependencies: @@ -2999,7 +3055,7 @@ packages: '@rollup/pluginutils': 4.2.1 debug: 4.3.4 es-module-lexer: 0.9.3 - esbuild: 0.14.53 + esbuild: 0.14.51 joycon: 3.1.1 jsonc-parser: 3.1.0 rollup: 2.77.2 @@ -3066,12 +3122,10 @@ packages: engines: {node: '>=8'} dependencies: shebang-regex: 3.0.0 - dev: true /shebang-regex/3.0.0: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} - dev: true /side-channel/1.0.4: resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} @@ -3081,6 +3135,10 @@ packages: object-inspect: 1.12.2 dev: true + /signal-exit/3.0.7: + resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} + dev: false + /simple-git-hooks/2.8.0: resolution: {integrity: sha512-ocmZQORwa6x9mxg+gVIAp5o4wXiWOHGXyrDBA0+UxGKIEKOyFtL4LWNKkP/2ornQPdlnlDGDteVeYP5FjhIoWA==} hasBin: true @@ -3175,6 +3233,11 @@ packages: engines: {node: '>=4'} dev: true + /strip-final-newline/2.0.0: + resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==} + engines: {node: '>=6'} + dev: false + /strip-indent/3.0.0: resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==} engines: {node: '>=8'} @@ -3307,7 +3370,7 @@ packages: chalk: 5.0.1 consola: 2.15.3 defu: 6.0.0 - esbuild: 0.14.53 + esbuild: 0.14.51 hookable: 5.1.1 jiti: 1.14.0 magic-string: 0.26.2 @@ -3321,7 +3384,7 @@ packages: rimraf: 3.0.2 rollup: 2.77.2 rollup-plugin-dts: 4.2.2_oo3i3f3qmqiztdz5qgxrrjmd5e - rollup-plugin-esbuild: 4.9.1_eqz4txfukrxgk4uaulv43wixku + rollup-plugin-esbuild: 4.9.1_ecpsl2p7zl5puhr4xxlpah6uzm scule: 0.2.1 typescript: 4.7.4 untyped: 0.4.4 @@ -3351,9 +3414,9 @@ packages: /untyped/0.4.4: resolution: {integrity: sha512-sY6u8RedwfLfBis0copfU/fzROieyAndqPs8Kn2PfyzTjtA88vCk81J1b5z+8/VJc+cwfGy23/AqOCpvAbkNVw==} dependencies: - '@babel/core': 7.18.10 - '@babel/standalone': 7.18.10 - '@babel/types': 7.18.10 + '@babel/core': 7.18.9 + '@babel/standalone': 7.18.9 + '@babel/types': 7.18.9 scule: 0.2.1 transitivePeerDependencies: - supports-color @@ -3390,6 +3453,16 @@ packages: spdx-expression-parse: 3.0.1 dev: true + /vite-plugin-full-reload/1.0.4_vite@3.0.4: + resolution: {integrity: sha512-9WejQII6zJ++m/YE173Zvl2jq4cqa404KNrVT+JDzDnqaGRq5UvOvA48fnsSWPIMXFV7S0dq5+sZqcSB+tKBgA==} + peerDependencies: + vite: ^2 || ^3 + dependencies: + picocolors: 1.0.0 + picomatch: 2.3.1 + vite: 3.0.4_sass@1.54.1 + dev: false + /vite/3.0.4_sass@1.54.1: resolution: {integrity: sha512-NU304nqnBeOx2MkQnskBQxVsa0pRAH5FphokTGmyy8M3oxbvw7qAXts2GORxs+h/2vKsD+osMhZ7An6yK6F1dA==} engines: {node: ^14.18.0 || >=16.0.0} @@ -3409,7 +3482,7 @@ packages: terser: optional: true dependencies: - esbuild: 0.14.53 + esbuild: 0.14.51 postcss: 8.4.14 resolve: 1.22.1 rollup: 2.77.2 @@ -3499,7 +3572,6 @@ packages: hasBin: true dependencies: isexe: 2.0.0 - dev: true /word-wrap/1.2.3: resolution: {integrity: sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==} diff --git a/src/node/cli-start.ts b/src/node/cli-start.ts index b961040..b3e2886 100644 --- a/src/node/cli-start.ts +++ b/src/node/cli-start.ts @@ -1,39 +1,51 @@ import { cac } from 'cac' import { name, version } from '../../package.json' -import type { CliOptions } from './types' -import { build } from './index' +import { build, serve } from './index' -export async function startCli( - cwd = process.cwd(), - argv = process.argv, - options: CliOptions = {}, -) { +export async function startCli(cwd = process.cwd(), argv = process.argv) { const cli = cac(name) cli - .command('[file]', 'Panel input file', { - ignoreOptionDefaultValue: true, - }) - .option('-d, --out-dir ', 'Output directory', { - default: cwd, - }) + .command('', 'Compile the panel plugin to index.js and index.css') + .option('-d, --out-dir ', 'Output directory', { default: cwd }) .option( '-w, --watch [path]', - 'Watch for file changes. If no path is specified, the folder of the input file will be watched. Repeat "--watch" for multiple paths.', + 'Watch for file changes. If no path is specified, the folder of the input file will be watched', + { default: false }, ) - .action(async (file: string, flags) => { - Object.assign(options, { - cwd, - ...flags, - }) + .example('kirbyup src/index.js') + .example('kirbyup src/index.js --out-dir ~/kirby-site/site/plugins/demo') + .example('kirbyup src/index.js --watch src/**/*.{js,css} --watch assets/*\n') + .action(async (file: string, options: { outDir: string; watch: boolean | string | string[] }) => { + await build({ cwd, entry: file, ...options }) + }) - if (file) - options.entry = file + cli + .command('serve ', 'Start development server with live reload') + .option('--no-watch', 'Don\'t watch .php files for changes', { default: '\0' }) + .option('-w, --watch ', 'Watch additional files', { default: './**/*.php' }) + .option('-p, --port ', 'Port for the development server', { default: 5177 }) + .option('-d, --out-dir ', 'Output directory') + .example('kirbyup serve src/index.js') + .example('kirbyup serve src/index.js --no-watch --port 3003') + .example('kirbyup serve src/index.js --watch snippets/*.php --watch templates/*.php\n') + .action(async (file: string, options: { watch: false | string | string[]; port: number; outDir?: string }) => { + const server = await serve({ cwd, entry: file, ...options }) - await build(options) + // Vite handles SIGTERM and end of stdin (Ctrl+D) itself, but not SIGINT + const exitProcess = async () => { + try { + await server.close() + } + finally { + process.exit() + } + } + process.once('SIGINT', exitProcess) }) - cli.help() + // Filter out unnecessary "default" output for negated options (zerobyte acts as marker) + cli.help(s => s.map(msg => ({ ...msg, body: msg.body.replace(' (default: \0)', '') }))) cli.version(version) // Parse CLI args without running the command to diff --git a/src/node/index.ts b/src/node/index.ts index 869b7a9..d45ad28 100644 --- a/src/node/index.ts +++ b/src/node/index.ts @@ -1,7 +1,7 @@ import { existsSync } from 'node:fs' import { readFile } from 'node:fs/promises' import { basename, dirname, resolve } from 'pathe' -import { build as _build, mergeConfig } from 'vite' +import { build as _build, createServer, mergeConfig } from 'vite' import vuePlugin from '@vitejs/plugin-vue2' // eslint-disable-next-line import/default import postcssrc from 'postcss-load-config' @@ -14,32 +14,54 @@ import { debounce } from 'perfect-debounce' import colors from 'picocolors' import type { RollupOutput } from 'rollup' import type { InlineConfig } from 'vite' +import fullReloadPlugin from 'vite-plugin-full-reload' import { name, version } from '../../package.json' import { PrettyError, handleError } from './errors' import { printFileInfo, toArray } from './utils' import { loadConfig } from './config' import kirbyupAutoImportPlugin from './plugins/auto-import' -import type { - CliOptions, - PostCSSConfigResult, - ResolvedCliOptions, - UserConfig, -} from './types' +import kirbyupHmrPlugin from './plugins/hmr' +import kirbyupBuildCleanupPlugin from './plugins/build-cleanup' +import type { BaseOptions, BuildOptions, PostCSSConfigResult, ServeOptions, UserConfig } from './types' let resolvedKirbyupConfig: UserConfig let resolvedPostCssConfig: PostCSSConfigResult -async function generate(options: ResolvedCliOptions) { - let result: Awaited> | undefined - - const mode = options.watch ? 'development' : 'production' - const outDir = options.outDir || options.cwd +const getViteConfig: ( + ...args: ['build', BuildOptions] | ['serve', ServeOptions] +) => InlineConfig = (command, options) => { const aliasDir = resolve(options.cwd, dirname(options.entry)) const { alias = {}, extendViteConfig = {} } = resolvedKirbyupConfig - const defaultConfig: InlineConfig = { - mode, + const baseConfig: InlineConfig = { + resolve: { + alias: { '~/': `${aliasDir}/`, '@/': `${aliasDir}/`, ...alias }, + }, plugins: [vuePlugin(), kirbyupAutoImportPlugin()], + css: { postcss: resolvedPostCssConfig }, + envPrefix: ['VITE_', 'KIRBYUP_'], + logLevel: 'warn', + } + + if (command === 'serve') { + const port = options.port + + const serveConfig: InlineConfig = mergeConfig(baseConfig, { + plugins: [kirbyupHmrPlugin(options), options.watch && fullReloadPlugin(options.watch)], + // Input needs to be specified so dep pre-bundling works + build: { rollupOptions: { input: resolve(options.cwd, options.entry) } }, + // Specify origin so asset URLs include Vite server host + server: { port, strictPort: true, origin: `http://localhost:${port}` }, + } as InlineConfig) + + return mergeConfig(serveConfig, extendViteConfig) as InlineConfig + } + + const mode = options.watch ? 'development' : 'production' + + const buildConfig: InlineConfig = mergeConfig(baseConfig, { + plugins: [kirbyupBuildCleanupPlugin(options)], + mode, build: { lib: { entry: resolve(options.cwd, options.entry), @@ -48,39 +70,39 @@ async function generate(options: ResolvedCliOptions) { fileName: () => 'index.js', }, minify: mode === 'production', - outDir, + outDir: options.outDir, emptyOutDir: false, rollupOptions: { external: ['vue'], output: { assetFileNames: 'index.[ext]', - globals: { - vue: 'Vue', - }, + globals: { vue: 'Vue' }, }, }, }, - resolve: { - alias: { - '~/': `${aliasDir}/`, - '@/': `${aliasDir}/`, - ...alias, - }, - }, - css: { - postcss: resolvedPostCssConfig, - }, - envPrefix: ['VITE_', 'KIRBYUP_'], - logLevel: 'warn', - } + } as InlineConfig) + + return mergeConfig(buildConfig, extendViteConfig) as InlineConfig +} + +function ensureEntry(options: BaseOptions) { + // Ensure entry exists + if (!existsSync(resolve(options.cwd, options.entry))) + throw new PrettyError(`Cannot find "${options.entry}"`) +} + +async function generate(options: BuildOptions) { + const config = getViteConfig('build', options) + + let result: Awaited> | undefined try { - result = await _build(mergeConfig(defaultConfig, extendViteConfig)) + result = await _build(config) } catch (error) { consola.error('Build failed') - if (mode === 'production') + if (config.mode === 'production') throw error } @@ -102,9 +124,9 @@ async function generate(options: ResolvedCliOptions) { } of output) { await printFileInfo( options.cwd, - outDir, + options.outDir, fileName, - code ?? await readFile(resolve(outDir, fileName), 'utf8'), + code ?? await readFile(resolve(options.outDir, fileName), 'utf8'), type, longest, ) @@ -114,24 +136,9 @@ async function generate(options: ResolvedCliOptions) { return result } -export async function resolveOptions(options: CliOptions) { - options.cwd = options.cwd || process.cwd() - - if (!options.entry) { - throw new PrettyError( - `No input file, try ${colors.cyan(`${name} `)}`, - ) - } +export async function build(options: BuildOptions) { + ensureEntry(options) - // Ensure entry exists - if (!existsSync(resolve(options.cwd, options.entry))) - throw new PrettyError(`Cannot find "${options.entry}"`) - - return options as ResolvedCliOptions -} - -export async function build(_options: CliOptions) { - const options = await resolveOptions(_options) const { cwd } = options // Resolve kirbyup config @@ -226,3 +233,38 @@ export async function build(_options: CliOptions) { startWatcher() } +export async function serve(options: ServeOptions) { + ensureEntry(options) + + const { cwd } = options + + // Resolve kirbyup config + const { config } = await loadConfig(cwd) + resolvedKirbyupConfig = config + + // Resolve postcss config + try { + // @ts-expect-error: types won't match + resolvedPostCssConfig = await postcssrc({}) + } + catch (err: any) { + if (!/No PostCSS Config found/.test(err.message)) + throw err + resolvedPostCssConfig = { + plugins: [postcssLogical(), postcssDirPseudoClass()], + } + } + + if (!process.env.VITEST) { + consola.log(colors.green(`${name} v${version}`)) + consola.info('Starting development server...') + } + + const server = await createServer(getViteConfig('serve', options)) + + await server.listen() + if (!process.env.VITEST) + consola.success(`Server is listening on :${server.config.server.port}`) + + return server +} diff --git a/src/node/plugins/build-cleanup.ts b/src/node/plugins/build-cleanup.ts new file mode 100644 index 0000000..958bfbb --- /dev/null +++ b/src/node/plugins/build-cleanup.ts @@ -0,0 +1,21 @@ +import { existsSync, unlinkSync } from 'node:fs' +import { resolve } from 'pathe' +import type { Plugin, ResolvedConfig } from 'vite' +import type { BuildOptions } from '../types' + +export default function kirbyupBuildCleanupPlugin(options: BuildOptions): Plugin { + let config: ResolvedConfig + let indexMjs: string + + return { + name: 'kirbyup:build-cleanup', + configResolved(resolvedConfig) { + config = resolvedConfig + indexMjs = resolve(config.root, options.outDir, 'index.dev.mjs') + }, + writeBundle() { + if (existsSync(indexMjs)) + unlinkSync(indexMjs) + }, + } +} diff --git a/src/node/plugins/hmr.ts b/src/node/plugins/hmr.ts new file mode 100644 index 0000000..a30f0eb --- /dev/null +++ b/src/node/plugins/hmr.ts @@ -0,0 +1,74 @@ +import { existsSync, unlinkSync } from 'node:fs' +import { writeFile } from 'node:fs/promises' +import type { AddressInfo } from 'node:net' +import { resolve } from 'pathe' +import type { Plugin, ResolvedConfig } from 'vite' +import type { PM } from 'detect-package-manager' +import { detect as detectPm } from 'detect-package-manager' +import { parseVueRequest } from '@vitejs/plugin-vue2' +import type { ServeOptions } from '../types' + +// Component reload (vs. refresh) doesn't work with Kirby so reload the page instead +const __HMR_CODE__ = ` +if (typeof __VUE_HMR_RUNTIME__ !== 'undefined' && import.meta.hot) { + __VUE_HMR_RUNTIME__.reload = () => import.meta.hot.invalidate(); +}`.trim() + +// Proxy JS file to "forward" the plugin script loaded by Kirby to the Vite server +const getViteProxyModule = (entryUrl: string, pm: PM) => ` +try { + await import("${entryUrl}"); +} catch (err) { + console.error( + "[kirbyup] Couldn't connect to the development server. Run \`${pm} run dev\` to start Vite or build the plugin with \`${pm} run build\` so Kirby uses the production version." + ); + throw err; +}`.trim() + +export default function kirbyupHmrPlugin(options: ServeOptions): Plugin { + let config: ResolvedConfig + let entry: string + let indexMjs: string + + return { + name: 'kirbyup:hmr', + apply: 'serve', + configResolved(resolvedConfig) { + config = resolvedConfig + entry = resolve(config.root, options.entry) + indexMjs = resolve(config.root, options.outDir || '', 'index.dev.mjs') + }, + // Mirrors github.com/vitejs/vite-plugin-vue2/blob/d3d3a599f191bef5d6034993de92e2176e9577b3/src/index.ts#L156 + transform(code, id) { + const { query } = parseVueRequest(id) + + if (query.raw) + return + + if ((typeof id !== 'string' || /\0/.test(id)) && !query.vue) + return + + if (/\.vue$/.test(id) && !query.vue) + return `${code};${__HMR_CODE__}` + }, + configureServer(server) { + if (!server.httpServer) + return + + server.httpServer.once('listening', async () => { + const entryPath = entry.replace(`${config.root}/`, '') + const { address, port } = server.httpServer!.address() as AddressInfo + const baseUrl = `http://${address}:${port}${config.base}` + const entryUrl = new URL(entryPath, baseUrl).href + + const pm: PM = await detectPm().catch(() => 'npm') + + await writeFile(indexMjs, getViteProxyModule(entryUrl, pm)) + }) + }, + closeBundle() { + if (existsSync(indexMjs)) + unlinkSync(indexMjs) + }, + } +} diff --git a/src/node/types.ts b/src/node/types.ts index a28f66e..9274d4f 100644 --- a/src/node/types.ts +++ b/src/node/types.ts @@ -1,17 +1,21 @@ import type { AliasOptions, InlineConfig } from 'vite' import type * as Postcss from 'postcss' -export type MarkRequired = Exclude & -Required> +export interface BaseOptions { + cwd: string + entry: string +} -export interface CliOptions { - cwd?: string - entry?: string +export interface ServeOptions extends BaseOptions { + watch: false | string | string[] + port: number outDir?: string - watch?: boolean | string | Array } -export type ResolvedCliOptions = MarkRequired +export interface BuildOptions extends BaseOptions { + outDir: string + watch: boolean | string | string[] +} export interface UserConfig { /**