kirbyup 3.1.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,17 +9,13 @@ The fastest and leanest way to bundle your Kirby Panel plugins. No configuration
9
9
 
10
10
  - 🍂 Lightweight, robust and tested
11
11
  - ⚡️ Fast compilation with Vite/esbuild
12
- - 🔄 Hot Module Replacement and watch mode (requires Kirby v3.7.4+)
12
+ - 🔄 Hot module replacement and watch mode
13
13
  - \*️⃣ `kirbyup.import` to [auto-import blocks & fields](#auto-import-blocks-and-fields)
14
14
  - 🎒 [PostCSS support](#postcss)
15
15
  - 🧭 [Path resolve aliases](#path-resolve-aliases)
16
16
  - 🔌 [Env variables support](#env-variables)
17
17
  - 🦔 [Extendable configuration with `kirbyup.config.js`](#extendable-configuration-with-kirbyupconfigjs)
18
18
 
19
- ## Requirements
20
-
21
- - Latest Node.js LTS version (currently v18)
22
-
23
19
  ## Get Started Right Away
24
20
 
25
21
  … With one of the following Panel plugin kits:
@@ -36,8 +32,7 @@ If you want to use kirbyup right away, there is no need to install it. Simply ca
36
32
  ```json
37
33
  {
38
34
  "scripts": {
39
- "dev": "npx -y kirbyup src/index.js --watch",
40
- "serve": "npx -y kirbyup serve src/index.js",
35
+ "dev": "npx -y kirbyup serve src/index.js",
41
36
  "build": "npx -y kirbyup src/index.js"
42
37
  }
43
38
  }
@@ -57,8 +52,7 @@ Example package configuration:
57
52
  ```json
58
53
  {
59
54
  "scripts": {
60
- "dev": "kirbyup src/index.js --watch",
61
- "serve": "kirbyup serve src/index.js",
55
+ "dev": "kirbyup serve src/index.js",
62
56
  "build": "kirbyup src/index.js"
63
57
  },
64
58
  "devDependencies": {
@@ -75,9 +69,6 @@ Global installation is supported as well, but not recommended.
75
69
 
76
70
  Start a development server for the Panel plugin:
77
71
 
78
- > [!NOTE]
79
- > This feature requires Kirby v3.7.4+.
80
-
81
72
  ```bash
82
73
  kirbyup serve src/index.js
83
74
  ```
@@ -163,9 +154,9 @@ window.panel.plugin('kirbyup/example', {
163
154
 
164
155
  kirbyup exposes env variables on the special `import.meta.env` object. Some built-in variables are available in all cases:
165
156
 
166
- - **`import.meta.env.MODE`**: {`development` | `production`} the mode kirbyup is running in.
167
- - **`import.meta.env.PROD`**: {boolean} whether kirbyup is running in production.
168
- - **`import.meta.env.DEV`**: {boolean} whether kirbyup is running in development (always the opposite of `import.meta.env.PROD`)
157
+ - **`import.meta.env.MODE`** (`development` | `production`): the mode kirbyup is running in.
158
+ - **`import.meta.env.PROD`** (`boolean`): whether kirbyup is running in production.
159
+ - **`import.meta.env.DEV`** (`boolean`): whether kirbyup is running in development (always the opposite of `import.meta.env.PROD`)
169
160
 
170
161
  During production, these env variables are **statically replaced**. It is therefore necessary to always reference them using the full static string. For example, dynamic key access like `import.meta.env[key]` will not work.
171
162
 
@@ -189,20 +180,19 @@ Only `KIRBYUP_SOME_KEY` will be exposed as `import.meta.env.VITE_SOME_KEY` to yo
189
180
  Create a `kirbyup.config.js` or `kirbyup.config.ts` configuration file the root-level of your project to customize kirbyup.
190
181
 
191
182
  ```js
183
+ import { fileURLToPath } from 'node:url'
192
184
  import { resolve } from 'node:path'
193
185
  import { defineConfig } from 'kirbyup/config'
194
186
 
195
- const currentDir = new URL('.', import.meta.url).pathname
187
+ const currentDir = fileURLToPath(new URL('.', import.meta.url))
196
188
 
197
189
  export default defineConfig({
198
190
  alias: {
199
- '#deep/': `${resolve(currentDir, 'src/deep')}/`
191
+ '#plugin/': `${resolve(currentDir, 'src/plugin')}/`
200
192
  },
201
193
  extendViteConfig: {
202
- build: {
203
- lib: {
204
- name: 'myPlugin'
205
- }
194
+ define: {
195
+ __PLAYGROUND__: JSON.stringify(process.env.PLAYGROUND)
206
196
  }
207
197
  }
208
198
  })
package/dist/node/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { cac } from 'cac';
2
- import { n as name, b as build, s as serve, v as version, h as handleError } from '../shared/kirbyup.9b5c1ecd.mjs';
2
+ import { n as name, b as build, s as serve, v as version, h as handleError } from '../shared/kirbyup.90533c57.mjs';
3
3
  import 'node:fs';
4
4
  import 'node:fs/promises';
5
5
  import 'pathe';
@@ -20,7 +20,7 @@ import 'node:util';
20
20
  import 'node:buffer';
21
21
  import 'c12';
22
22
  import 'magic-string';
23
- import 'detect-package-manager';
23
+ import 'node:module';
24
24
 
25
25
  async function startCli(cwd = process.cwd(), argv = process.argv) {
26
26
  const cli = cac(name);
@@ -13,10 +13,10 @@ import 'rollup-plugin-external-globals';
13
13
  import 'postcss-load-config';
14
14
  import 'postcss-logical';
15
15
  import 'postcss-dir-pseudo-class';
16
- export { b as build, s as serve } from '../shared/kirbyup.9b5c1ecd.mjs';
16
+ export { b as build, s as serve } from '../shared/kirbyup.90533c57.mjs';
17
17
  import 'node:zlib';
18
18
  import 'node:util';
19
19
  import 'node:buffer';
20
20
  import 'c12';
21
21
  import 'magic-string';
22
- import 'detect-package-manager';
22
+ import 'node:module';
@@ -1,6 +1,6 @@
1
1
  import { existsSync, unlinkSync } from 'node:fs';
2
- import { writeFile, readFile } from 'node:fs/promises';
3
- import { normalize, relative, resolve, dirname, basename } from 'pathe';
2
+ import { readFile, writeFile } from 'node:fs/promises';
3
+ import { normalize, relative, resolve, join, dirname, basename } from 'pathe';
4
4
  import { consola } from 'consola';
5
5
  import { colors } from 'consola/utils';
6
6
  import { debounce } from 'perfect-debounce';
@@ -18,10 +18,10 @@ import { promisify } from 'node:util';
18
18
  import { Buffer } from 'node:buffer';
19
19
  import { loadConfig as loadConfig$1 } from 'c12';
20
20
  import MagicString from 'magic-string';
21
- import { detect } from 'detect-package-manager';
21
+ import 'node:module';
22
22
 
23
23
  const name = "kirbyup";
24
- const version = "3.1.0";
24
+ const version = "3.1.1";
25
25
 
26
26
  class PrettyError extends Error {
27
27
  constructor(message) {
@@ -88,7 +88,8 @@ for (const methodName of ['rerender', 'reload']) {
88
88
 
89
89
  if (key) {
90
90
  const pluginComponents = window.panel.plugins.components
91
- const usedComponentDefs = window.panel.$vue._vnode.componentInstance.$options.components
91
+ // const usedComponentDefs = window.panel.app.$options.components
92
+ const usedComponentDefs = window.panel.app._vnode.componentInstance.$options.components // #33
92
93
 
93
94
  for (const componentName in pluginComponents) {
94
95
  if (updatedDef[key] === pluginComponents[componentName][key]) {
@@ -110,7 +111,7 @@ for (const methodName of ['rerender', 'reload']) {
110
111
  }
111
112
 
112
113
  function $_applyKirbyModifications(activeDef, newDef) {
113
- const usedComponentDefs = window.panel.$vue.$options.components
114
+ const usedComponentDefs = window.panel.app.$options.components
114
115
 
115
116
  if (newDef.template)
116
117
  newDef.render = null
@@ -170,6 +171,92 @@ function kirbyupAutoImportPlugin() {
170
171
  };
171
172
  }
172
173
 
174
+ async function findup(cwd, match, options = {}) {
175
+ const segments = normalize(cwd).split("/");
176
+ while (segments.length > 0) {
177
+ const path = segments.join("/");
178
+ const result = await match(path);
179
+ if (result || !options.includeParentDirs) {
180
+ return result;
181
+ }
182
+ segments.pop();
183
+ }
184
+ }
185
+
186
+ const packageManagers = [
187
+ { name: "npm", command: "npm", lockFile: "package-lock.json" },
188
+ {
189
+ name: "pnpm",
190
+ command: "pnpm",
191
+ lockFile: "pnpm-lock.yaml",
192
+ files: ["pnpm-workspace.yaml"]
193
+ },
194
+ {
195
+ name: "bun",
196
+ command: "bun",
197
+ lockFile: "bun.lockb"
198
+ },
199
+ {
200
+ name: "yarn",
201
+ command: "yarn",
202
+ majorVersion: "1.0.0",
203
+ lockFile: "yarn.lock"
204
+ },
205
+ {
206
+ name: "yarn",
207
+ command: "yarn",
208
+ majorVersion: "3.0.0",
209
+ lockFile: "yarn.lock",
210
+ files: [".yarnrc.yml"]
211
+ }
212
+ ];
213
+ async function detectPackageManager(cwd, options = {}) {
214
+ const detected = await findup(
215
+ cwd,
216
+ async (path) => {
217
+ if (!options.ignorePackageJSON) {
218
+ const packageJSONPath = join(path, "package.json");
219
+ if (existsSync(packageJSONPath)) {
220
+ const packageJSON = JSON.parse(
221
+ await readFile(packageJSONPath, "utf8")
222
+ );
223
+ if (packageJSON?.packageManager) {
224
+ const [name, version = "0.0.0"] = packageJSON.packageManager.split("@");
225
+ const majorVersion = version.split(".")[0];
226
+ const packageManager = packageManagers.find(
227
+ (pm) => pm.name === name && pm.majorVersion === majorVersion
228
+ ) || packageManagers.find((pm) => pm.name === name);
229
+ return {
230
+ ...packageManager,
231
+ name,
232
+ command: name,
233
+ version,
234
+ majorVersion
235
+ };
236
+ }
237
+ }
238
+ }
239
+ if (!options.ignoreLockFile) {
240
+ for (const packageManager of packageManagers) {
241
+ const detectionsFiles = [
242
+ packageManager.lockFile,
243
+ ...packageManager.files || []
244
+ ].filter(Boolean);
245
+ if (detectionsFiles.some((file) => existsSync(resolve(path, file)))) {
246
+ return {
247
+ ...packageManager
248
+ };
249
+ }
250
+ }
251
+ }
252
+ },
253
+ {
254
+ includeParentDirs: options.includeParentDirs ?? true
255
+ }
256
+ );
257
+ return detected;
258
+ }
259
+
173
260
  function kirbyupHmrPlugin(options) {
174
261
  let config;
175
262
  let entry;
@@ -200,7 +287,7 @@ function kirbyupHmrPlugin(options) {
200
287
  const hostname = family === "IPv6" ? `[${address}]` : address;
201
288
  const baseUrl = `http://${hostname}:${port}${config.base}`;
202
289
  const entryUrl = new URL(entryPath, baseUrl).href;
203
- const pm = await detect().catch(() => "npm");
290
+ const pm = await detectPackageManager(config.root);
204
291
  await writeFile(indexMjs, getViteProxyModule(entryUrl, pm));
205
292
  });
206
293
  },
@@ -210,7 +297,8 @@ function kirbyupHmrPlugin(options) {
210
297
  }
211
298
  };
212
299
  }
213
- function getViteProxyModule(entryUrl, pm) {
300
+ function getViteProxyModule(entryUrl, packageManager) {
301
+ const pm = packageManager?.name || "npm";
214
302
  return `
215
303
  try {
216
304
  await import("${entryUrl}");
@@ -291,7 +379,11 @@ function getViteConfig(command, options) {
291
379
  minify: mode === "production",
292
380
  outDir: options.outDir,
293
381
  emptyOutDir: false,
294
- rollupOptions: { output: { assetFileNames: "index.[ext]" } }
382
+ rollupOptions: {
383
+ output: {
384
+ assetFileNames: "index.[ext]"
385
+ }
386
+ }
295
387
  }
296
388
  });
297
389
  return mergeConfig(buildConfig, extendViteConfig);
@@ -343,7 +435,6 @@ async function build(options) {
343
435
  if (!/No PostCSS Config found/.test(err.message))
344
436
  throw err;
345
437
  resolvedPostCssConfig = {
346
- // @ts-expect-error: types won't match
347
438
  plugins: [postcssLogical(), postcssDirPseudoClass()]
348
439
  };
349
440
  }
@@ -406,7 +497,6 @@ async function serve(options) {
406
497
  if (!/No PostCSS Config found/.test(err.message))
407
498
  throw err;
408
499
  resolvedPostCssConfig = {
409
- // @ts-expect-error: types won't match
410
500
  plugins: [postcssLogical(), postcssDirPseudoClass()]
411
501
  };
412
502
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "kirbyup",
3
3
  "type": "module",
4
- "version": "3.1.0",
5
- "packageManager": "pnpm@8.11.0",
4
+ "version": "3.1.1",
5
+ "packageManager": "pnpm@8.15.1",
6
6
  "description": "Zero-config bundler for Kirby Panel plugins",
7
7
  "author": {
8
8
  "name": "Johann Schopplich",
@@ -64,45 +64,45 @@
64
64
  "lint": "eslint .",
65
65
  "lint:fix": "eslint . --fix",
66
66
  "release": "bumpp --commit --push --tag",
67
- "test": "vitest",
67
+ "test": "vitest --no-isolate",
68
68
  "test:types": "tsc --noEmit",
69
69
  "prepare": "simple-git-hooks"
70
70
  },
71
71
  "dependencies": {
72
72
  "@vitejs/plugin-vue2": "2.2.0",
73
73
  "@vitejs/plugin-vue2-jsx": "1.1.0",
74
- "@vue/compiler-sfc": "^2.7.15",
75
- "c12": "^1.5.1",
74
+ "@vue/compiler-sfc": "^2.7.16",
75
+ "c12": "^1.6.1",
76
76
  "cac": "^6.7.14",
77
77
  "chokidar": "^3.5.3",
78
78
  "consola": "^3.2.3",
79
- "detect-package-manager": "^3.0.1",
80
79
  "magic-string": "^0.30.5",
81
- "pathe": "^1.1.1",
80
+ "pathe": "^1.1.2",
82
81
  "perfect-debounce": "^1.0.0",
83
- "postcss": "^8.4.32",
84
- "postcss-dir-pseudo-class": "^8.0.0",
82
+ "postcss": "^8.4.33",
83
+ "postcss-dir-pseudo-class": "^8.0.1",
85
84
  "postcss-load-config": "^5.0.2",
86
- "postcss-logical": "^7.0.0",
87
- "rollup-plugin-external-globals": "^0.9.1",
88
- "sass": "^1.69.5",
89
- "vite": "^5.0.6",
85
+ "postcss-logical": "^7.0.1",
86
+ "rollup-plugin-external-globals": "^0.9.2",
87
+ "sass": "^1.70.0",
88
+ "vite": "^5.0.12",
90
89
  "vite-plugin-full-reload": "^1.1.0",
91
- "vue": "^2.7.15"
90
+ "vue": "^2.7.16"
92
91
  },
93
92
  "devDependencies": {
94
- "@antfu/eslint-config": "^2.3.4",
93
+ "@antfu/eslint-config": "^2.6.3",
95
94
  "@types/fs-extra": "^11.0.4",
96
- "@types/node": "^20.10.4",
95
+ "@types/node": "^20.11.10",
97
96
  "@types/prompts": "^2.4.9",
98
- "bumpp": "^9.2.0",
99
- "eslint": "^8.55.0",
97
+ "bumpp": "^9.3.0",
98
+ "eslint": "^8.56.0",
100
99
  "fast-glob": "^3.3.2",
101
100
  "fs-extra": "^11.2.0",
101
+ "nypm": "^0.3.6",
102
102
  "simple-git-hooks": "^2.9.0",
103
103
  "typescript": "~5.3.3",
104
104
  "unbuild": "^2.0.0",
105
- "vitest": "^1.0.1"
105
+ "vitest": "^1.2.2"
106
106
  },
107
107
  "simple-git-hooks": {
108
108
  "commit-msg": "node scripts/verifyCommit.mjs $1"