kirbyup 3.1.3 → 3.1.5

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
@@ -1,53 +1,43 @@
1
- # kirbyup
1
+ [![kirbyup](./docs/public/og.png)](https://kirbyup.getkirby.com)
2
2
 
3
- > [!TIP]
4
- > Take a look into Kirby's [pluginkit](https://github.com/getkirby/pluginkit/tree/4-panel) repository for an example setup.
3
+ # kirbyup
5
4
 
6
- The fastest and leanest way to bundle your Kirby Panel plugins. No configuration necessary.
5
+ [![npm version](https://img.shields.io/npm/v/kirbyup?color=a1b858&label=)](https://www.npmjs.com/package/kirbyup)
7
6
 
8
- ## Key Features
7
+ The official bundler for Kirby Panel plugins with zero-config usage and built-in HMR.
9
8
 
10
- - 🍂 Lightweight, robust and tested
11
- - ⚡️ Fast compilation with Vite/esbuild
12
- - 🔄 Hot module replacement and watch mode
13
- - \*️⃣ `kirbyup.import` to [auto-import blocks & fields](#auto-import-blocks-and-fields)
14
- - 🎒 [PostCSS support](#postcss)
15
- - 🧭 [Path resolve aliases](#path-resolve-aliases)
16
- - 🔌 [Env variables support](#env-variables)
17
- - 🦔 [Extendable configuration with `kirbyup.config.js`](#extendable-configuration-with-kirbyupconfigjs)
9
+ - [✨  Release Notes](https://github.com/johannschopplich/kirbyup/releases)
10
+ - [📖  Read the documentation](https://kirbyup.getkirby.com)
18
11
 
19
- ## Get Started Right Away
20
-
21
- … With one of the following Panel plugin kits:
12
+ ## Key Features
22
13
 
23
- - [`eslint`](./examples/eslint)
24
- - [`tailwindcss`](./examples/tailwindcss)
14
+ - 🔄 [Hot module replacement](https://kirbyup.getkirby.com/guide/getting-started.html#development)
15
+ - 🎒 PostCSS support
16
+ - 🧭 Add custom path aliases
17
+ - 🔌 Run actions based on environment variables
18
+ - 🦔 [Extends Vite with `kirbyup.config.js`](https://kirbyup.getkirby.com/guide/config-file)
25
19
 
26
- I highly recommend using one of these starters instead of [Kirby's default `pluginkit`](https://github.com/getkirby/pluginkit/tree/4-panel). They provide a better developer experience out of the box.
20
+ ## Setup
27
21
 
28
- ## Installation
22
+ > [!TIP]
23
+ > [📖 Read the documentation](https://kirbyup.getkirby.com)
29
24
 
30
- If you want to use kirbyup right away, there is no need to install it. Simply call it with `npx`:
25
+ ```bash
26
+ # pnpm
27
+ pnpm add -D kirbyup
31
28
 
32
- ```json
33
- {
34
- "scripts": {
35
- "dev": "npx -y kirbyup serve src/index.js",
36
- "build": "npx -y kirbyup src/index.js"
37
- }
38
- }
29
+ # npm
30
+ npm i -D kirbyup
39
31
  ```
40
32
 
41
- > [!NOTE]
42
- > If `npx` doesn't use the latest kirbyup version, although it is available, run `npx -y kirbyup@latest` instead or delete the `~/.npm/_npx` cache folder.
33
+ ## Basic Usage
43
34
 
44
- While kirbyup will stay backwards compatible, exact build reproducibility may be of importance to you. If so, I recommend targeting a specific package version, rather than using `npx`. Install kirbyup with a package manager of your choice locally to your project:
45
-
46
- ```bash
47
- npm i kirbyup --save-dev
48
- ```
35
+ > [!TIP]
36
+ > [📖 Read the documentation](https://kirbyup.getkirby.com) or skip starting from scratch and pick one of the following starters:
37
+ > - [`eslint`](./examples/eslint)
38
+ > - [`tailwindcss`](./examples/tailwindcss)
49
39
 
50
- Example package configuration:
40
+ Having installed kirbyup, you can add the following scripts as shortcuts to the commands you will use most often:
51
41
 
52
42
  ```json
53
43
  {
@@ -56,197 +46,18 @@ Example package configuration:
56
46
  "build": "kirbyup src/index.js"
57
47
  },
58
48
  "devDependencies": {
59
- "kirbyup": "latest"
49
+ "kirbyup": "^3.1.3"
60
50
  }
61
51
  }
62
52
  ```
63
53
 
64
- Global installation is supported as well, but not recommended.
65
-
66
- ## Usage
67
-
68
- ### Development
69
-
70
- Start a development server for the Panel plugin:
71
-
72
- ```bash
73
- kirbyup serve src/index.js
74
- ```
75
-
76
- 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.
77
-
78
- If you prefer the watch mode to build a development bundle of the final Panel plugin or develop in an older version of Kirby (prior to 3.7.4), run:
79
-
80
- ```bash
81
- kirbyup src/index.js --watch
82
- ```
83
-
84
- ### Production
85
-
86
- ```bash
87
- kirbyup src/index.js
88
- ```
89
-
90
- The final panel plugin will be bundled, minified, and written into the current directory as `./index.js` and `./index.css`.
91
-
92
- ## Built-in Features
93
-
94
- ### PostCSS
95
-
96
- If the project contains a valid PostCSS config (any format supported by [postcss-load-config](https://github.com/postcss/postcss-load-config), e.g. `postcss.config.js`), it will be automatically applied to all imported CSS.
97
-
98
- If no configuration file is found, kirbyup will apply two PostCSS plugins which the Kirby Panel uses as well to let you embrace the same functionality within your Panel plugins. The following PostCSS transforms are applied by kirbyup:
99
-
100
- - [postcss-logical](https://github.com/csstools/postcss-logical) lets you use logical, rather than physical, direction and dimension mappings in CSS, following the [CSS Logical Properties and Values](https://drafts.csswg.org/css-logical/) specification.
101
- - [postcss-dir-pseudo-class](https://github.com/csstools/postcss-dir-pseudo-class) lets you style by directionality using the `:dir()` pseudo-class in CSS, following the [Selectors](https://www.w3.org/TR/selectors-4/#the-dir-pseudo) specification. It gives you the same syntax Kirby uses for full compatibility with RTL localizations of the Panel.
102
-
103
- ### Path Resolve Aliases
104
-
105
- Import certain modules more easily by using the `~/` path alias. It will resolve to the directory of your input file, for example `src` when building `kirbyup src/index.js`.
106
-
107
- Now, given a deeply nested component, instead of using relative paths when importing like so:
108
-
109
- ```js
110
- // Inside deeply nested module
111
- import someUtility from '../../utils'
112
- ```
113
-
114
- You can use the alias:
115
-
116
- ```js
117
- import someUtility from '~/utils'
118
- ```
119
-
120
- > [!TIP]
121
- > You can use `@/` as path alias as well.
122
-
123
- ### Auto-Import Blocks and Fields
124
-
125
- If you find yourself in the situation of needing to import multiple **blocks** or **fields** into your Panel plugin, you can use the kirbyup `kirbyup.import` function to ease the process.
126
-
127
- Before:
128
-
129
- ```js
130
- import Foo from './components/blocks/Foo.vue'
131
- import Bar from './components/blocks/Bar.vue'
132
- import Maps from './components/blocks/Maps.vue'
133
-
134
- window.panel.plugin('kirbyup/example', {
135
- blocks: {
136
- foo: Foo,
137
- bar: Bar,
138
- maps: Maps
139
- }
140
- })
141
- ```
142
-
143
- After:
144
-
145
- ```js
146
- import { kirbyup } from 'kirbyup/plugin'
147
-
148
- window.panel.plugin('kirbyup/example', {
149
- blocks: kirbyup.import('./components/blocks/*.vue')
150
- })
151
- ```
152
-
153
- ### Env Variables
154
-
155
- kirbyup exposes env variables on the special `import.meta.env` object. Some built-in variables are available in all cases:
156
-
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`)
160
-
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.
162
-
163
- #### `.env` Files
164
-
165
- kirbyup (thanks to Vite) uses [dotenv](https://github.com/motdotla/dotenv) to load additional environment variables from the `.env` and `.env.local` files in your plugin's root directory.
166
-
167
- Loaded env variables are also exposed to your source code via `import.meta.env`.
168
-
169
- To prevent accidentally leaking env variables for distribution, only variables prefixed with `KIRBYUP_` or `VITE_` are exposed to your processed code. Take the following file as an example:
170
-
171
- ```ini
172
- DB_PASSWORD=foobar
173
- KIRBYUP_SOME_KEY=123
174
- ```
175
-
176
- Only `KIRBYUP_SOME_KEY` will be exposed as `import.meta.env.VITE_SOME_KEY` to your plugin's source code, but `DB_PASSWORD` will not.
177
-
178
- ### Extendable Configuration With `kirbyup.config.js`
179
-
180
- Create a `kirbyup.config.js` or `kirbyup.config.ts` configuration file the root-level of your project to customize kirbyup.
181
-
182
- ```js
183
- import { fileURLToPath } from 'node:url'
184
- import { resolve } from 'node:path'
185
- import { defineConfig } from 'kirbyup/config'
186
-
187
- const currentDir = fileURLToPath(new URL('.', import.meta.url))
188
-
189
- export default defineConfig({
190
- alias: {
191
- '#plugin/': `${resolve(currentDir, 'src/plugin')}/`
192
- },
193
- vite: {
194
- define: {
195
- __PLAYGROUND__: JSON.stringify(process.env.PLAYGROUND)
196
- }
197
- }
198
- })
199
- ```
200
-
201
- #### `alias`
202
-
203
- When aliasing to file system paths, always use absolute paths. Relative alias values will be used as-is and will not be resolved into file system paths.
204
-
205
- #### `vite`
206
-
207
- You can build upon the defaults kirbup uses and extend the Vite configuration with custom plugins etc.
208
-
209
- For a complete list of options, take a look at the [Vite configuration options](https://vitejs.dev/config/).
210
-
211
- ## Options
212
-
213
- > [!TIP]
214
- > Inspect all available options with `kirbyup --help` and `kirbyup serve --help`.
215
-
216
- ### `kirbyup <input>`
217
-
218
- ##### `--out-dir <dir>`
219
-
220
- The output directory to save the processed code into. Defaults to the current working directory.
221
-
222
- ##### `--watch [path]`
223
-
224
- Enables watch mode. If no path is specified, kirbyup watches the folder of the input file. Repeat `--watch` for multiple paths.
225
-
226
- ### `kirbyup serve <input>`
227
-
228
- ##### `--port <port>`
229
-
230
- The port for the development server to run on. Defaults to `5177`.
231
-
232
- ##### `--out-dir <dir>`
233
-
234
- The output directory where the plugin file read by Kirby is saved. Defaults to the project root.
235
-
236
- ##### `--watch <path>`
237
-
238
- Specifies additional files that should be watched for changes, with changes causing the page to reload. Repeat `--watch` for multiple paths.
239
-
240
- > [!NOTE]
241
- > 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`
242
-
243
- ##### `--no-watch`
244
-
245
- Disables the default behavior of watching all PHP files for changes.
246
-
247
- ## Credits
54
+ ## 💻 Development
248
55
 
249
- - [Vite](https://vitejs.dev) by Evan You and all of its contributors.
56
+ 1. Clone this repository
57
+ 2. Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`
58
+ 3. Install dependencies using `pnpm install`
59
+ 4. Run `pnpm run dev:prepare`
60
+ 5. Start development server using `pnpm run dev`
250
61
 
251
62
  ## License
252
63
 
@@ -1,4 +1,4 @@
1
- import { U as UserConfig } from '../shared/kirbyup.bcda4592.mjs';
1
+ import { U as UserConfig } from '../shared/kirbyup.DNMktHWN.mjs';
2
2
  import 'vite';
3
3
 
4
4
  declare function defineConfig(config: UserConfig): UserConfig;
@@ -1,4 +1,4 @@
1
- import { U as UserConfig } from '../shared/kirbyup.bcda4592.js';
1
+ import { U as UserConfig } from '../shared/kirbyup.DNMktHWN.js';
2
2
  import 'vite';
3
3
 
4
4
  declare function defineConfig(config: UserConfig): UserConfig;
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.db20dc98.mjs';
2
+ import { n as name, b as build, s as serve, v as version, h as handleError } from '../shared/kirbyup.DKFIHHbk.mjs';
3
3
  import 'node:fs';
4
4
  import 'node:fs/promises';
5
5
  import 'pathe';
@@ -1,5 +1,5 @@
1
1
  import * as vite from 'vite';
2
- import { B as BuildOptions, S as ServeOptions } from '../shared/kirbyup.bcda4592.mjs';
2
+ import { B as BuildOptions, S as ServeOptions } from '../shared/kirbyup.DNMktHWN.mjs';
3
3
 
4
4
  declare function build(options: BuildOptions): Promise<void>;
5
5
  declare function serve(options: ServeOptions): Promise<vite.ViteDevServer>;
@@ -1,5 +1,5 @@
1
1
  import * as vite from 'vite';
2
- import { B as BuildOptions, S as ServeOptions } from '../shared/kirbyup.bcda4592.js';
2
+ import { B as BuildOptions, S as ServeOptions } from '../shared/kirbyup.DNMktHWN.js';
3
3
 
4
4
  declare function build(options: BuildOptions): Promise<void>;
5
5
  declare function serve(options: ServeOptions): Promise<vite.ViteDevServer>;
@@ -10,7 +10,7 @@ import '@vitejs/plugin-vue2';
10
10
  import '@vitejs/plugin-vue2-jsx';
11
11
  import 'vite-plugin-full-reload';
12
12
  import 'rollup-plugin-external-globals';
13
- export { b as build, s as serve } from '../shared/kirbyup.db20dc98.mjs';
13
+ export { b as build, s as serve } from '../shared/kirbyup.DKFIHHbk.mjs';
14
14
  import 'node:zlib';
15
15
  import 'node:util';
16
16
  import 'node:buffer';
@@ -21,7 +21,7 @@ import MagicString from 'magic-string';
21
21
  import 'node:module';
22
22
 
23
23
  const name = "kirbyup";
24
- const version = "3.1.3";
24
+ const version = "3.1.5";
25
25
 
26
26
  class PrettyError extends Error {
27
27
  constructor(message) {
@@ -72,8 +72,7 @@ function loadConfig(cwd = process.cwd()) {
72
72
  }
73
73
  async function resolvePostCSSConfig(cwd) {
74
74
  try {
75
- const config = await postcssrc(void 0, void 0, { stopDir: cwd });
76
- return config;
75
+ return await postcssrc(void 0, void 0, { stopDir: cwd });
77
76
  } catch (error) {
78
77
  if (!error.message.includes("No PostCSS Config found"))
79
78
  throw error;
@@ -186,7 +185,7 @@ function kirbyupGlobImportPlugin() {
186
185
  async function findup(cwd, match, options = {}) {
187
186
  const segments = normalize(cwd).split("/");
188
187
  while (segments.length > 0) {
189
- const path = segments.join("/");
188
+ const path = segments.join("/") || "/";
190
189
  const result = await match(path);
191
190
  if (result || !options.includeParentDirs) {
192
191
  return result;
@@ -196,7 +195,11 @@ async function findup(cwd, match, options = {}) {
196
195
  }
197
196
 
198
197
  const packageManagers = [
199
- { name: "npm", command: "npm", lockFile: "package-lock.json" },
198
+ {
199
+ name: "npm",
200
+ command: "npm",
201
+ lockFile: "package-lock.json"
202
+ },
200
203
  {
201
204
  name: "pnpm",
202
205
  command: "pnpm",
@@ -224,7 +227,7 @@ const packageManagers = [
224
227
  ];
225
228
  async function detectPackageManager(cwd, options = {}) {
226
229
  const detected = await findup(
227
- cwd,
230
+ resolve(cwd || "."),
228
231
  async (path) => {
229
232
  if (!options.ignorePackageJSON) {
230
233
  const packageJSONPath = join(path, "package.json");
@@ -266,6 +269,17 @@ async function detectPackageManager(cwd, options = {}) {
266
269
  includeParentDirs: options.includeParentDirs ?? true
267
270
  }
268
271
  );
272
+ if (!detected && !options.ignoreArgv) {
273
+ const scriptArg = process.argv[1];
274
+ if (scriptArg) {
275
+ for (const packageManager of packageManagers) {
276
+ const re = new RegExp(`[/\\\\]\\.?${packageManager.command}`);
277
+ if (re.test(scriptArg)) {
278
+ return packageManager;
279
+ }
280
+ }
281
+ }
282
+ }
269
283
  return detected;
270
284
  }
271
285
 
@@ -420,12 +434,7 @@ async function generate(options) {
420
434
  if (l > longest)
421
435
  longest = l;
422
436
  }
423
- for (const {
424
- fileName,
425
- type,
426
- // @ts-expect-error: `code` not available in `OutputAsset`
427
- code
428
- } of output) {
437
+ for (const { fileName, type, code } of output) {
429
438
  await printFileInfo(
430
439
  options.cwd,
431
440
  options.outDir,
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "kirbyup",
3
3
  "type": "module",
4
- "version": "3.1.3",
5
- "packageManager": "pnpm@8.15.1",
4
+ "version": "3.1.5",
5
+ "packageManager": "pnpm@8.15.4",
6
6
  "description": "Zero-config bundler for Kirby Panel plugins",
7
7
  "author": {
8
8
  "name": "Johann Schopplich",
@@ -61,6 +61,9 @@
61
61
  "scripts": {
62
62
  "build": "unbuild",
63
63
  "dev": "UNBUILD_STUB=true unbuild",
64
+ "docs:dev": "vitepress dev docs",
65
+ "docs:build": "vitepress build docs",
66
+ "docs:preview": "vitepress preview docs",
64
67
  "lint": "eslint .",
65
68
  "lint:fix": "eslint . --fix",
66
69
  "release": "bumpp --commit --push --tag",
@@ -72,37 +75,37 @@
72
75
  "@vitejs/plugin-vue2": "2.2.0",
73
76
  "@vitejs/plugin-vue2-jsx": "1.1.0",
74
77
  "@vue/compiler-sfc": "^2.7.16",
75
- "c12": "^1.6.1",
78
+ "c12": "^1.10.0",
76
79
  "cac": "^6.7.14",
77
- "chokidar": "^3.5.3",
80
+ "chokidar": "^3.6.0",
78
81
  "consola": "^3.2.3",
79
- "magic-string": "^0.30.5",
82
+ "magic-string": "^0.30.8",
80
83
  "pathe": "^1.1.2",
81
84
  "perfect-debounce": "^1.0.0",
82
- "postcss": "^8.4.33",
85
+ "postcss": "^8.4.35",
83
86
  "postcss-dir-pseudo-class": "^8.0.1",
84
- "postcss-load-config": "^5.0.2",
87
+ "postcss-load-config": "^5.0.3",
85
88
  "postcss-logical": "^7.0.1",
86
89
  "rollup-plugin-external-globals": "^0.9.2",
87
- "sass": "^1.70.0",
88
- "vite": "^5.0.12",
90
+ "sass": "^1.71.1",
91
+ "vite": "^5.1.6",
89
92
  "vite-plugin-full-reload": "^1.1.0",
90
93
  "vue": "^2.7.16"
91
94
  },
92
95
  "devDependencies": {
93
- "@antfu/eslint-config": "^2.6.3",
96
+ "@antfu/eslint-config": "^2.8.0",
94
97
  "@types/fs-extra": "^11.0.4",
95
- "@types/node": "^20.11.10",
98
+ "@types/node": "^20.11.25",
96
99
  "@types/prompts": "^2.4.9",
97
- "bumpp": "^9.3.0",
98
- "eslint": "^8.56.0",
100
+ "bumpp": "^9.4.0",
101
+ "eslint": "^8.57.0",
99
102
  "fast-glob": "^3.3.2",
100
103
  "fs-extra": "^11.2.0",
101
- "nypm": "^0.3.6",
102
- "simple-git-hooks": "^2.9.0",
104
+ "nypm": "^0.3.8",
105
+ "simple-git-hooks": "^2.10.0",
103
106
  "typescript": "~5.3.3",
104
- "unbuild": "^2.0.0",
105
- "vitest": "^1.2.2"
107
+ "unbuild": "^3.0.0-rc.1",
108
+ "vitest": "^1.3.1"
106
109
  },
107
110
  "simple-git-hooks": {
108
111
  "commit-msg": "node scripts/verifyCommit.mjs $1"