kirbyup 3.1.12 → 3.2.0

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/dist/node/cli.mjs CHANGED
@@ -1,26 +1,26 @@
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.TnJrqKie.mjs';
2
+ import { n as name, b as build, s as serve, v as version, h as handleError } from '../shared/kirbyup.zmDi6JQM.mjs';
3
3
  import 'node:fs';
4
4
  import 'node:fs/promises';
5
- import 'pathe';
5
+ import '@vitejs/plugin-vue2';
6
+ import '@vitejs/plugin-vue2-jsx';
6
7
  import 'consola';
7
8
  import 'consola/utils';
9
+ import 'pathe';
8
10
  import 'perfect-debounce';
11
+ import 'rollup-plugin-external-globals';
9
12
  import 'vite';
10
- import 'vue/compiler-sfc';
11
- import '@vitejs/plugin-vue2';
12
- import '@vitejs/plugin-vue2-jsx';
13
13
  import 'vite-plugin-full-reload';
14
- import 'rollup-plugin-external-globals';
15
- import 'node:zlib';
16
- import 'node:util';
17
- import 'node:buffer';
14
+ import 'vue/compiler-sfc';
18
15
  import 'c12';
16
+ import 'postcss-dir-pseudo-class';
19
17
  import 'postcss-load-config';
20
18
  import 'postcss-logical';
21
- import 'postcss-dir-pseudo-class';
22
19
  import 'magic-string';
23
20
  import 'node:module';
21
+ import 'node:buffer';
22
+ import 'node:util';
23
+ import 'node:zlib';
24
24
 
25
25
  async function startCli(cwd = process.cwd(), argv = process.argv) {
26
26
  const cli = cac(name);
@@ -29,13 +29,11 @@ async function startCli(cwd = process.cwd(), argv = process.argv) {
29
29
  "Watch for file changes. If no path is specified, the folder of the input file will be watched",
30
30
  { default: false }
31
31
  ).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, options) => {
32
- if (!process.env.NODE_ENV)
33
- process.env.NODE_ENV = options.watch ? "development" : "production";
32
+ process.env.NODE_ENV ||= options.watch ? "development" : "production";
34
33
  await build({ cwd, entry: file, ...options });
35
34
  });
36
35
  cli.command("serve <file>", "Start development server with live reload").option("--no-watch", "Don't watch .php files for changes", { default: "\0" }).option("-w, --watch <path>", "Watch additional files", { default: "./**/*.php" }).option("-p, --port <number>", "Port for the development server", { default: 5177 }).option("-d, --out-dir <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, options) => {
37
- if (!process.env.NODE_ENV)
38
- process.env.NODE_ENV = "development";
36
+ process.env.NODE_ENV ||= "development";
39
37
  const server = await serve({ cwd, entry: file, ...options });
40
38
  const exitProcess = async () => {
41
39
  try {
@@ -1,22 +1,22 @@
1
1
  import 'node:fs';
2
2
  import 'node:fs/promises';
3
- import 'pathe';
3
+ import '@vitejs/plugin-vue2';
4
+ import '@vitejs/plugin-vue2-jsx';
4
5
  import 'consola';
5
6
  import 'consola/utils';
7
+ import 'pathe';
6
8
  import 'perfect-debounce';
9
+ import 'rollup-plugin-external-globals';
7
10
  import 'vite';
8
- import 'vue/compiler-sfc';
9
- import '@vitejs/plugin-vue2';
10
- import '@vitejs/plugin-vue2-jsx';
11
11
  import 'vite-plugin-full-reload';
12
- import 'rollup-plugin-external-globals';
13
- export { b as build, s as serve } from '../shared/kirbyup.TnJrqKie.mjs';
14
- import 'node:zlib';
15
- import 'node:util';
16
- import 'node:buffer';
12
+ import 'vue/compiler-sfc';
13
+ export { b as build, s as serve } from '../shared/kirbyup.zmDi6JQM.mjs';
17
14
  import 'c12';
15
+ import 'postcss-dir-pseudo-class';
18
16
  import 'postcss-load-config';
19
17
  import 'postcss-logical';
20
- import 'postcss-dir-pseudo-class';
21
18
  import 'magic-string';
22
19
  import 'node:module';
20
+ import 'node:buffer';
21
+ import 'node:util';
22
+ import 'node:zlib';
@@ -1,73 +1,36 @@
1
- import { existsSync, unlinkSync } from 'node:fs';
2
- import { readFile, writeFile } from 'node:fs/promises';
3
- import { normalize, relative, resolve, join, dirname, basename } from 'pathe';
1
+ import * as fs from 'node:fs';
2
+ import { existsSync } from 'node:fs';
3
+ import * as fsp from 'node:fs/promises';
4
+ import { readFile } from 'node:fs/promises';
5
+ import vuePlugin from '@vitejs/plugin-vue2';
6
+ import vueJsxPlugin from '@vitejs/plugin-vue2-jsx';
4
7
  import { consola } from 'consola';
5
8
  import { colors } from 'consola/utils';
9
+ import { resolve, join, normalize, relative, dirname, basename } from 'pathe';
6
10
  import { debounce } from 'perfect-debounce';
11
+ import externalGlobals from 'rollup-plugin-external-globals';
7
12
  import { createLogger, createServer, mergeConfig, build as build$1 } from 'vite';
8
- import * as vueCompilerSfc from 'vue/compiler-sfc';
9
- import vuePlugin from '@vitejs/plugin-vue2';
10
- import vueJsxPlugin from '@vitejs/plugin-vue2-jsx';
11
13
  import fullReloadPlugin from 'vite-plugin-full-reload';
12
- import externalGlobals from 'rollup-plugin-external-globals';
13
- import { gzip } from 'node:zlib';
14
- import { promisify } from 'node:util';
15
- import { Buffer } from 'node:buffer';
14
+ import * as vueCompilerSfc from 'vue/compiler-sfc';
16
15
  import { loadConfig as loadConfig$1 } from 'c12';
16
+ import postcssDirPseudoClass from 'postcss-dir-pseudo-class';
17
17
  import postcssrc from 'postcss-load-config';
18
18
  import postcssLogical from 'postcss-logical';
19
- import postcssDirPseudoClass from 'postcss-dir-pseudo-class';
20
19
  import MagicString from 'magic-string';
21
20
  import 'node:module';
21
+ import { Buffer } from 'node:buffer';
22
+ import { promisify } from 'node:util';
23
+ import { gzip } from 'node:zlib';
22
24
 
23
25
  const name = "kirbyup";
24
- const version = "3.1.12";
25
-
26
- class PrettyError extends Error {
27
- constructor(message) {
28
- super(message);
29
- this.name = this.constructor.name;
30
- if (typeof Error.captureStackTrace === "function")
31
- Error.captureStackTrace(this, this.constructor);
32
- else
33
- this.stack = new Error(message).stack;
34
- }
35
- }
36
- function handleError(error) {
37
- consola.error(error.message);
38
- process.exitCode = 1;
39
- }
40
-
41
- function toArray(array) {
42
- array = array || [];
43
- if (Array.isArray(array))
44
- return array;
45
- return [array];
46
- }
47
- const compress = promisify(gzip);
48
- async function getCompressedSize(code) {
49
- const size = (await compress(typeof code === "string" ? code : Buffer.from(code))).length / 1024;
50
- return ` / gzip: ${size.toFixed(2)} KiB`;
51
- }
52
- async function printFileInfo(root, outDir, filePath, content, type, maxLength) {
53
- const prettyOutDir = `${normalize(relative(root, resolve(root, outDir)))}/`;
54
- const kibs = content.length / 1024;
55
- const compressedSize = await getCompressedSize(content);
56
- const writeColor = type === "chunk" ? colors.cyan : colors.magenta;
57
- consola.log(
58
- colors.white(colors.dim(prettyOutDir)) + writeColor(filePath.padEnd(maxLength + 2)) + colors.dim(`${kibs.toFixed(2)} kB${compressedSize}`)
59
- );
60
- }
26
+ const version = "3.2.0";
61
27
 
62
28
  function loadConfig(cwd = process.cwd()) {
63
29
  return loadConfig$1({
64
30
  cwd,
65
31
  name: "kirbyup",
66
32
  rcFile: false,
67
- jitiOptions: {
68
- interopDefault: true,
69
- esmResolve: true
70
- }
33
+ packageJson: false
71
34
  });
72
35
  }
73
36
  async function resolvePostCSSConfig(cwd) {
@@ -82,6 +45,37 @@ async function resolvePostCSSConfig(cwd) {
82
45
  }
83
46
  }
84
47
 
48
+ class PrettyError extends Error {
49
+ constructor(message) {
50
+ super(message);
51
+ this.name = this.constructor.name;
52
+ if (typeof Error.captureStackTrace === "function")
53
+ Error.captureStackTrace(this, this.constructor);
54
+ else
55
+ this.stack = new Error(message).stack;
56
+ }
57
+ }
58
+ function handleError(error) {
59
+ consola.error(error.message);
60
+ process.exitCode = 1;
61
+ }
62
+
63
+ function kirbyupBuildCleanupPlugin(options) {
64
+ let config;
65
+ let devIndexPath;
66
+ return {
67
+ name: "kirbyup:build-cleanup",
68
+ configResolved(resolvedConfig) {
69
+ config = resolvedConfig;
70
+ devIndexPath = resolve(config.root, options.outDir, "index.dev.mjs");
71
+ },
72
+ writeBundle() {
73
+ if (fs.existsSync(devIndexPath))
74
+ fs.unlinkSync(devIndexPath);
75
+ }
76
+ };
77
+ }
78
+
85
79
  const multilineCommentsRE = /\/\*(.|[\r\n])*?\*\//g;
86
80
  const singlelineCommentsRE = /\/\/.*/g;
87
81
  const HMR_RUNTIME_ID = "\0plugin-vue2:hmr-runtime";
@@ -209,18 +203,18 @@ const packageManagers = [
209
203
  {
210
204
  name: "bun",
211
205
  command: "bun",
212
- lockFile: "bun.lockb"
206
+ lockFile: ["bun.lockb", "bun.lock"]
213
207
  },
214
208
  {
215
209
  name: "yarn",
216
210
  command: "yarn",
217
- majorVersion: "1.0.0",
211
+ majorVersion: "1",
218
212
  lockFile: "yarn.lock"
219
213
  },
220
214
  {
221
215
  name: "yarn",
222
216
  command: "yarn",
223
- majorVersion: "3.0.0",
217
+ majorVersion: "3",
224
218
  lockFile: "yarn.lock",
225
219
  files: [".yarnrc.yml"]
226
220
  }
@@ -255,8 +249,8 @@ async function detectPackageManager(cwd, options = {}) {
255
249
  for (const packageManager of packageManagers) {
256
250
  const detectionsFiles = [
257
251
  packageManager.lockFile,
258
- ...packageManager.files || []
259
- ].filter(Boolean);
252
+ packageManager.files
253
+ ].flat().filter(Boolean);
260
254
  if (detectionsFiles.some((file) => existsSync(resolve(path, file)))) {
261
255
  return {
262
256
  ...packageManager
@@ -314,12 +308,12 @@ function kirbyupHmrPlugin(options) {
314
308
  const baseUrl = `http://${hostname}:${port}${config.base}`;
315
309
  const entryUrl = new URL(entryPath, baseUrl).href;
316
310
  const pm = await detectPackageManager(config.root);
317
- await writeFile(devIndexPath, getViteProxyModule(entryUrl, pm));
311
+ await fsp.writeFile(devIndexPath, getViteProxyModule(entryUrl, pm));
318
312
  });
319
313
  },
320
314
  closeBundle() {
321
- if (existsSync(devIndexPath))
322
- unlinkSync(devIndexPath);
315
+ if (fs.existsSync(devIndexPath))
316
+ fs.unlinkSync(devIndexPath);
323
317
  }
324
318
  };
325
319
  }
@@ -337,20 +331,23 @@ try {
337
331
  `.trimStart();
338
332
  }
339
333
 
340
- function kirbyupBuildCleanupPlugin(options) {
341
- let config;
342
- let devIndexPath;
343
- return {
344
- name: "kirbyup:build-cleanup",
345
- configResolved(resolvedConfig) {
346
- config = resolvedConfig;
347
- devIndexPath = resolve(config.root, options.outDir, "index.dev.mjs");
348
- },
349
- writeBundle() {
350
- if (existsSync(devIndexPath))
351
- unlinkSync(devIndexPath);
352
- }
353
- };
334
+ function toArray(array) {
335
+ array ??= [];
336
+ return Array.isArray(array) ? array : [array];
337
+ }
338
+ const compress = promisify(gzip);
339
+ async function getCompressedSize(code) {
340
+ const size = (await compress(typeof code === "string" ? code : Buffer.from(code))).length / 1024;
341
+ return ` / gzip: ${size.toFixed(2)} KiB`;
342
+ }
343
+ async function printFileInfo(root, outDir, filePath, content, type, maxLength) {
344
+ const prettyOutDir = `${normalize(relative(root, resolve(root, outDir)))}/`;
345
+ const kibs = content.length / 1024;
346
+ const compressedSize = await getCompressedSize(content);
347
+ const writeColor = type === "chunk" ? colors.cyan : colors.magenta;
348
+ consola.log(
349
+ colors.white(colors.dim(prettyOutDir)) + writeColor(filePath.padEnd(maxLength + 2)) + colors.dim(`${kibs.toFixed(2)} kB${compressedSize}`)
350
+ );
354
351
  }
355
352
 
356
353
  let resolvedKirbyupConfig;
@@ -389,6 +386,7 @@ function getViteConfig(command, options) {
389
386
  css: {
390
387
  postcss: resolvedPostCssConfig
391
388
  },
389
+ envDir: options.cwd,
392
390
  envPrefix: ["VITE_", "KIRBYUP_"],
393
391
  customLogger: logger,
394
392
  logLevel
@@ -461,7 +459,7 @@ async function generate(options) {
461
459
  options.cwd,
462
460
  options.outDir,
463
461
  fileName,
464
- code ?? await readFile(resolve(options.outDir, fileName), "utf8"),
462
+ code ?? await fsp.readFile(resolve(options.outDir, fileName), "utf8"),
465
463
  type,
466
464
  longest
467
465
  );
@@ -540,7 +538,7 @@ async function serve(options) {
540
538
  return server;
541
539
  }
542
540
  function assertEntryExists(options) {
543
- if (!existsSync(resolve(options.cwd, options.entry)))
541
+ if (!fs.existsSync(resolve(options.cwd, options.entry)))
544
542
  throw new PrettyError(`Cannot find "${options.entry}"`);
545
543
  }
546
544
 
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "kirbyup",
3
3
  "type": "module",
4
- "version": "3.1.12",
5
- "packageManager": "pnpm@9.5.0",
4
+ "version": "3.2.0",
5
+ "packageManager": "pnpm@9.13.0",
6
6
  "description": "Zero-config bundler for Kirby Panel plugins",
7
7
  "author": {
8
8
  "name": "Johann Schopplich",
@@ -66,7 +66,7 @@
66
66
  "docs:preview": "vitepress preview docs",
67
67
  "lint": "eslint .",
68
68
  "lint:fix": "eslint . --fix",
69
- "release": "bumpp --commit --push --tag",
69
+ "release": "bumpp",
70
70
  "test": "vitest --no-isolate",
71
71
  "test:types": "tsc --noEmit"
72
72
  },
@@ -74,35 +74,33 @@
74
74
  "@vitejs/plugin-vue2": "2.2.0",
75
75
  "@vitejs/plugin-vue2-jsx": "1.1.0",
76
76
  "@vue/compiler-sfc": "^2.7.16",
77
- "c12": "^1.11.1",
77
+ "c12": "^2.0.1",
78
78
  "cac": "^6.7.14",
79
- "chokidar": "^3.6.0",
79
+ "chokidar": "~3.6.0",
80
80
  "consola": "^3.2.3",
81
- "magic-string": "^0.30.10",
81
+ "magic-string": "^0.30.12",
82
82
  "pathe": "^1.1.2",
83
83
  "perfect-debounce": "^1.0.0",
84
- "postcss": "^8.4.39",
85
- "postcss-dir-pseudo-class": "^8.0.1",
86
- "postcss-load-config": "^5.1.0",
87
- "postcss-logical": "^7.0.1",
88
- "rollup-plugin-external-globals": "^0.11.0",
89
- "sass": "^1.77.7",
90
- "vite": "~5.3.3",
84
+ "postcss": "^8.4.49",
85
+ "postcss-dir-pseudo-class": "^9.0.1",
86
+ "postcss-load-config": "^6.0.1",
87
+ "postcss-logical": "^8.0.0",
88
+ "rollup-plugin-external-globals": "^0.12.0",
89
+ "sass": "^1.80.7",
90
+ "vite": "~5.4.11",
91
91
  "vite-plugin-full-reload": "^1.2.0",
92
92
  "vue": "^2.7.16"
93
93
  },
94
94
  "devDependencies": {
95
- "@antfu/eslint-config": "^2.22.0",
96
- "@types/fs-extra": "^11.0.4",
97
- "@types/node": "^20.14.10",
95
+ "@antfu/eslint-config": "^3.9.1",
96
+ "@types/node": "^20.17.6",
98
97
  "@types/prompts": "^2.4.9",
99
- "bumpp": "^9.4.1",
100
- "eslint": "^9.6.0",
98
+ "bumpp": "^9.8.1",
99
+ "eslint": "^9.14.0",
101
100
  "fast-glob": "^3.3.2",
102
- "fs-extra": "^11.2.0",
103
- "nypm": "^0.3.9",
104
- "typescript": "^5.5.3",
105
- "unbuild": "^3.0.0-rc.6",
106
- "vitest": "^2.0.1"
101
+ "nypm": "^0.3.12",
102
+ "typescript": "^5.6.3",
103
+ "unbuild": "^3.0.0-rc.11",
104
+ "vitest": "^2.1.5"
107
105
  }
108
106
  }