kirbyup 0.23.0 → 0.24.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.
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ 'use strict'
3
+ import('../dist/cli.mjs')
@@ -3,12 +3,13 @@ import { existsSync, statSync } from 'fs';
3
3
  import { build as build$1, mergeConfig } from 'vite';
4
4
  import { createVuePlugin } from 'vite-plugin-vue2';
5
5
  import MagicString from 'magic-string';
6
- import { createConfigLoader as createConfigLoader$1 } from 'unconfig';
6
+ import { createConfigLoader } from 'unconfig';
7
7
  import postcssrc from 'postcss-load-config';
8
8
  import postcssLogical from 'postcss-logical';
9
9
  import postcssDirPseudoClass from 'postcss-dir-pseudo-class';
10
10
  import consola from 'consola';
11
- import { white, dim, cyan, magenta, green } from 'picocolors';
11
+ import { debounce } from 'perfect-debounce';
12
+ import colors from 'picocolors';
12
13
  import { readFile } from 'fs/promises';
13
14
  import { gzip } from 'zlib';
14
15
  import { promisify } from 'util';
@@ -50,20 +51,26 @@ function kirbyupAutoImportPlugin() {
50
51
  function defineConfig(config) {
51
52
  return config;
52
53
  }
53
- function createConfigLoader(configOrPath = process.cwd(), extraConfigSources = []) {
54
+ async function loadConfig(cwd = process.cwd(), configOrPath = cwd, extraConfigSources = []) {
54
55
  let inlineConfig = {};
55
56
  if (typeof configOrPath !== "string") {
56
57
  inlineConfig = configOrPath;
57
- configOrPath = process.cwd();
58
+ if (inlineConfig.configFile === false) {
59
+ return {
60
+ config: inlineConfig,
61
+ sources: []
62
+ };
63
+ } else {
64
+ configOrPath = inlineConfig.configFile || process.cwd();
65
+ }
58
66
  }
59
67
  const resolved = resolve(configOrPath);
60
- let cwd = resolved;
61
68
  let isFile = false;
62
69
  if (existsSync(resolved) && statSync(resolved).isFile()) {
63
70
  isFile = true;
64
71
  cwd = dirname(resolved);
65
72
  }
66
- const loader = createConfigLoader$1({
73
+ const loader = createConfigLoader({
67
74
  sources: isFile ? [
68
75
  {
69
76
  files: resolved,
@@ -78,11 +85,9 @@ function createConfigLoader(configOrPath = process.cwd(), extraConfigSources = [
78
85
  cwd,
79
86
  defaults: inlineConfig
80
87
  });
81
- return async () => {
82
- const result = await loader.load();
83
- result.config = result.config || inlineConfig;
84
- return result;
85
- };
88
+ const result = await loader.load();
89
+ result.config = result.config || inlineConfig;
90
+ return result;
86
91
  }
87
92
 
88
93
  class PrettyError extends Error {
@@ -101,6 +106,12 @@ function handleError(error) {
101
106
  process.exitCode = 1;
102
107
  }
103
108
 
109
+ function toArray(array) {
110
+ array = array || [];
111
+ if (Array.isArray(array))
112
+ return array;
113
+ return [array];
114
+ }
104
115
  const compress = promisify(gzip);
105
116
  async function getCompressedSize(code) {
106
117
  const size = (await compress(typeof code === "string" ? code : Buffer.from(code))).length / 1024;
@@ -111,43 +122,12 @@ async function printFileInfo(root, outDir, filePath, type, content) {
111
122
  const prettyOutDir = normalize(relative(root, resolve(root, outDir))) + "/";
112
123
  const kibs = content.length / 1024;
113
124
  const compressedSize = await getCompressedSize(content);
114
- const writeColor = type === "chunk" ? cyan : magenta;
115
- consola.log(white(dim(prettyOutDir)) + writeColor(filePath) + " " + dim(`${kibs.toFixed(2)} KiB${compressedSize}`));
116
- }
117
- function debouncePromise(fn, delay, onError) {
118
- let timeout;
119
- let promiseInFly;
120
- let callbackPending;
121
- return function debounced(...args) {
122
- if (promiseInFly) {
123
- callbackPending = () => {
124
- debounced(...args);
125
- callbackPending = void 0;
126
- };
127
- } else {
128
- if (timeout)
129
- clearTimeout(timeout);
130
- timeout = setTimeout(() => {
131
- timeout = void 0;
132
- promiseInFly = fn(...args).catch(onError).finally(() => {
133
- promiseInFly = void 0;
134
- if (callbackPending)
135
- callbackPending();
136
- });
137
- }, delay);
138
- }
139
- };
140
- }
141
-
142
- function toArray(array) {
143
- array = array || [];
144
- if (Array.isArray(array))
145
- return array;
146
- return [array];
125
+ const writeColor = type === "chunk" ? colors.cyan : colors.magenta;
126
+ consola.log(colors.white(colors.dim(prettyOutDir)) + writeColor(filePath) + " " + colors.dim(`${kibs.toFixed(2)} KiB${compressedSize}`));
147
127
  }
148
128
 
149
129
  const name = "kirbyup";
150
- const version = "0.23.0";
130
+ const version = "0.24.0";
151
131
 
152
132
  let resolvedKirbyupConfig;
153
133
  let resolvedPostCssConfig;
@@ -212,7 +192,7 @@ async function viteBuild(options) {
212
192
  }
213
193
  async function resolveOptions(options) {
214
194
  if (!options.entry) {
215
- throw new PrettyError(`No input file, try ${cyan(`${name} <path/to/file.js>`)}`);
195
+ throw new PrettyError(`No input file, try ${colors.cyan(`${name} <path/to/file.js>`)}`);
216
196
  }
217
197
  if (!existsSync(options.entry)) {
218
198
  throw new PrettyError(`Cannot find ${options.entry}`);
@@ -221,7 +201,6 @@ async function resolveOptions(options) {
221
201
  }
222
202
  async function build(_options) {
223
203
  const options = await resolveOptions(_options);
224
- const loadConfig = createConfigLoader();
225
204
  const { config, sources: configSources } = await loadConfig();
226
205
  resolvedKirbyupConfig = config;
227
206
  try {
@@ -234,14 +213,14 @@ async function build(_options) {
234
213
  plugins: [postcssLogical(), postcssDirPseudoClass()]
235
214
  };
236
215
  }
237
- consola.log(green(`${name} v${version}`));
238
- consola.start(`Building ${cyan(options.entry)}`);
216
+ consola.log(colors.green(`${name} v${version}`));
217
+ consola.start(`Building ${colors.cyan(options.entry)}`);
239
218
  if (options.watch) {
240
219
  consola.info("Running in watch mode");
241
220
  }
242
- const debouncedBuild = debouncePromise(async () => {
243
- viteBuild(options);
244
- }, 100, handleError);
221
+ const debouncedBuild = debounce(async () => {
222
+ viteBuild(options).catch(handleError);
223
+ }, 100);
245
224
  const startWatcher = async () => {
246
225
  if (!options.watch)
247
226
  return;
@@ -251,7 +230,7 @@ async function build(_options) {
251
230
  "index.{css,js}"
252
231
  ];
253
232
  const watchPaths = typeof options.watch === "boolean" ? dirname(options.entry) : Array.isArray(options.watch) ? options.watch.filter((path) => typeof path === "string") : options.watch;
254
- consola.info("Watching for changes in " + toArray(watchPaths).map((i) => cyan(i)).join(", "));
233
+ consola.info("Watching for changes in " + toArray(watchPaths).map((i) => colors.cyan(i)).join(", "));
255
234
  const watcher = watch(watchPaths, {
256
235
  ignoreInitial: true,
257
236
  ignorePermissionErrors: true,
@@ -263,9 +242,9 @@ async function build(_options) {
263
242
  watcher.on("all", async (type, file) => {
264
243
  if (configSources.includes(file)) {
265
244
  resolvedKirbyupConfig = (await loadConfig()).config;
266
- consola.info(`${cyan(basename(file))} changed, setting new config`);
245
+ consola.info(`${colors.cyan(basename(file))} changed, setting new config`);
267
246
  } else {
268
- consola.log(green(type) + " " + white(dim(file)));
247
+ consola.log(colors.green(type) + " " + colors.white(colors.dim(file)));
269
248
  }
270
249
  debouncedBuild();
271
250
  });
package/dist/cli.mjs CHANGED
@@ -10,6 +10,7 @@ import 'postcss-load-config';
10
10
  import 'postcss-logical';
11
11
  import 'postcss-dir-pseudo-class';
12
12
  import 'consola';
13
+ import 'perfect-debounce';
13
14
  import 'picocolors';
14
15
  import 'fs/promises';
15
16
  import 'zlib';
@@ -21,7 +22,7 @@ async function main(options = {}) {
21
22
  ignoreOptionDefaultValue: true
22
23
  }).option("-d, --out-dir <dir>", "Output directory", {
23
24
  default: process.cwd()
24
- }).option("--watch [path]", 'Watch mode, if path is not specified, it watches the folder of the input file. Repeat "--watch" for multiple paths').action(async (file, flags) => {
25
+ }).option("-w [path], --watch [path]", 'Watch mode. If no path is specified, the folder of the input file will be watched. Repeat "--watch" for multiple paths.').action(async (file, flags) => {
25
26
  Object.assign(options, {
26
27
  ...flags
27
28
  });
package/dist/index.d.ts CHANGED
@@ -8,6 +8,11 @@ declare type CliOptions = {
8
8
  };
9
9
  declare type ResolvedCliOptions = MarkRequired<CliOptions, 'entry'>;
10
10
  interface UserConfig {
11
+ /**
12
+ * Load from config files
13
+ * Set to `false` to disable
14
+ */
15
+ configFile?: string | false;
11
16
  /**
12
17
  * Specifies an `Object`, or an `Array` of `Object`,
13
18
  * which defines aliases used to replace values in `import` statements.
package/dist/index.mjs CHANGED
@@ -7,6 +7,7 @@ import 'postcss-load-config';
7
7
  import 'postcss-logical';
8
8
  import 'postcss-dir-pseudo-class';
9
9
  import 'consola';
10
+ import 'perfect-debounce';
10
11
  import 'picocolors';
11
12
  import 'magic-string';
12
13
  import 'unconfig';
package/package.json CHANGED
@@ -1,7 +1,21 @@
1
1
  {
2
2
  "name": "kirbyup",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "Zero-config bundler for Kirby Panel plugins",
5
+ "author": {
6
+ "name": "Johann Schopplich",
7
+ "email": "pkg@johannschopplich.com",
8
+ "url": "https://johannschopplich.com"
9
+ },
10
+ "license": "MIT",
11
+ "homepage": "https://github.com/johannschopplich/kirbyup#readme",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/johannschopplich/kirbyup.git"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/johannschopplich/kirbyup/issues"
18
+ },
5
19
  "keywords": [
6
20
  "kirby-cms",
7
21
  "kirby-plugin",
@@ -9,35 +23,21 @@
9
23
  "panel",
10
24
  "bundle"
11
25
  ],
12
- "homepage": "https://github.com/johannschopplich/kirbyup#readme",
13
- "bugs": {
14
- "url": "https://github.com/johannschopplich/kirbyup/issues"
15
- },
16
- "repository": {
17
- "type": "git",
18
- "url": "git+https://github.com/johannschopplich/kirbyup.git"
19
- },
20
- "license": "MIT",
21
- "author": {
22
- "name": "Johann Schopplich",
23
- "email": "pkg@johannschopplich.com",
24
- "url": "https://johannschopplich.com"
25
- },
26
26
  "exports": {
27
27
  ".": {
28
- "require": "./dist/index.cjs",
29
28
  "import": "./dist/index.mjs",
30
29
  "types": "./dist/index.d.ts"
31
30
  },
32
31
  "./plugin": {
33
- "require": "./dist/plugin.cjs",
34
32
  "import": "./dist/plugin.mjs",
35
33
  "types": "./dist/plugin.d.ts"
36
34
  }
37
35
  },
36
+ "main": "./dist/index.mjs",
37
+ "module": "./dist/index.mjs",
38
38
  "types": "./dist/index.d.ts",
39
39
  "bin": {
40
- "kirbyup": "./bin/kirbyup.cjs"
40
+ "kirbyup": "./bin/kirbyup.mjs"
41
41
  },
42
42
  "files": [
43
43
  "bin",
@@ -53,46 +53,46 @@
53
53
  "test:update": "vitest --update",
54
54
  "format": "prettier --write \"src/**/*.ts\"",
55
55
  "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
56
- "release": "vitest --run && esno scripts/release.ts",
56
+ "release": "vitest --run && tsx scripts/release.ts",
57
57
  "prepare": "pnpm exec simple-git-hooks"
58
58
  },
59
59
  "simple-git-hooks": {
60
- "commit-msg": "pnpm exec esno scripts/verifyCommit.ts $1"
60
+ "commit-msg": "node scripts/verifyCommit.mjs $1"
61
61
  },
62
62
  "dependencies": {
63
63
  "cac": "^6.7.12",
64
64
  "chokidar": "^3.5.3",
65
65
  "consola": "^2.15.3",
66
- "execa": "5.1.1",
67
- "pathe": "^0.2.0",
66
+ "execa": "6.1.0",
67
+ "pathe": "^0.3.0",
68
+ "perfect-debounce": "^0.1.3",
68
69
  "picocolors": "^1.0.0",
69
- "postcss": "^8.4.12",
70
+ "postcss": "^8.4.14",
70
71
  "postcss-dir-pseudo-class": "^6.0.4",
71
- "postcss-load-config": "^3.1.3",
72
+ "postcss-load-config": "^4.0.1",
72
73
  "postcss-logical": "^5.0.4",
73
- "sass": "^1.49.9",
74
- "unconfig": "^0.3.2",
75
- "vite": "^2.8.6",
76
- "vite-plugin-vue2": "^1.9.3",
74
+ "sass": "^1.52.1",
75
+ "unconfig": "^0.3.4",
76
+ "vite": "^2.9.9",
77
+ "vite-plugin-vue2": "^2.0.1",
77
78
  "vue": "^2.6.14",
78
79
  "vue-template-compiler": "^2.6.14"
79
80
  },
80
81
  "devDependencies": {
81
- "@antfu/utils": "^0.5.0",
82
82
  "@types/fs-extra": "^9.0.13",
83
- "@types/node": "^17.0.21",
83
+ "@types/node": "^17.0.38",
84
84
  "@types/prompts": "^2.4.0",
85
85
  "@types/semver": "^7.3.9",
86
86
  "conventional-changelog-cli": "^2.2.2",
87
- "esno": "^0.14.1",
88
87
  "fast-glob": "^3.2.11",
89
- "fs-extra": "^10.0.1",
90
- "minimist": "^1.2.5",
91
- "prettier": "^2.6.0",
88
+ "fs-extra": "^10.1.0",
89
+ "minimist": "^1.2.6",
90
+ "prettier": "^2.6.2",
92
91
  "prompts": "^2.4.2",
93
- "simple-git-hooks": "^2.7.0",
94
- "typescript": "^4.6.2",
95
- "unbuild": "^0.7.0",
96
- "vitest": "^0.7.4"
92
+ "simple-git-hooks": "^2.8.0",
93
+ "tsx": "^3.4.2",
94
+ "typescript": "^4.7.2",
95
+ "unbuild": "^0.7.4",
96
+ "vitest": "^0.13.1"
97
97
  }
98
98
  }
package/bin/kirbyup.cjs DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- require('../dist/cli.cjs')
@@ -1,293 +0,0 @@
1
- 'use strict';
2
-
3
- const pathe = require('pathe');
4
- const fs = require('fs');
5
- const vite = require('vite');
6
- const vitePluginVue2 = require('vite-plugin-vue2');
7
- const MagicString = require('magic-string');
8
- const unconfig = require('unconfig');
9
- const postcssrc = require('postcss-load-config');
10
- const postcssLogical = require('postcss-logical');
11
- const postcssDirPseudoClass = require('postcss-dir-pseudo-class');
12
- const consola = require('consola');
13
- const picocolors = require('picocolors');
14
- const promises = require('fs/promises');
15
- const zlib = require('zlib');
16
- const util = require('util');
17
-
18
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
19
-
20
- const MagicString__default = /*#__PURE__*/_interopDefaultLegacy(MagicString);
21
- const postcssrc__default = /*#__PURE__*/_interopDefaultLegacy(postcssrc);
22
- const postcssLogical__default = /*#__PURE__*/_interopDefaultLegacy(postcssLogical);
23
- const postcssDirPseudoClass__default = /*#__PURE__*/_interopDefaultLegacy(postcssDirPseudoClass);
24
- const consola__default = /*#__PURE__*/_interopDefaultLegacy(consola);
25
-
26
- const multilineCommentsRE = /\/\*(.|[\r\n])*?\*\//gm;
27
- const singlelineCommentsRE = /\/\/.*/g;
28
-
29
- function kirbyupAutoImportPlugin() {
30
- let config;
31
- return {
32
- name: "kirbyup:auto-import",
33
- configResolved(resolvedConfig) {
34
- config = resolvedConfig;
35
- },
36
- async transform(code, id) {
37
- if (code.includes("kirbyup.import")) {
38
- const kirbyupImportRE = /\bkirbyup\.import\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*\)/g;
39
- const noCommentsCode = code.replace(multilineCommentsRE, (m) => " ".repeat(m.length)).replace(singlelineCommentsRE, (m) => " ".repeat(m.length));
40
- let s = null;
41
- let match;
42
- while (match = kirbyupImportRE.exec(noCommentsCode)) {
43
- const { 0: exp, 1: rawPath, index } = match;
44
- if (!s)
45
- s = new MagicString__default(code);
46
- s.overwrite(index, index + exp.length, `kirbyup.import(import.meta.globEager(${rawPath}))`);
47
- }
48
- if (s) {
49
- return {
50
- code: s.toString(),
51
- map: config.build.sourcemap ? s.generateMap({ hires: true }) : null
52
- };
53
- }
54
- }
55
- return null;
56
- }
57
- };
58
- }
59
-
60
- function defineConfig(config) {
61
- return config;
62
- }
63
- function createConfigLoader(configOrPath = process.cwd(), extraConfigSources = []) {
64
- let inlineConfig = {};
65
- if (typeof configOrPath !== "string") {
66
- inlineConfig = configOrPath;
67
- configOrPath = process.cwd();
68
- }
69
- const resolved = pathe.resolve(configOrPath);
70
- let cwd = resolved;
71
- let isFile = false;
72
- if (fs.existsSync(resolved) && fs.statSync(resolved).isFile()) {
73
- isFile = true;
74
- cwd = pathe.dirname(resolved);
75
- }
76
- const loader = unconfig.createConfigLoader({
77
- sources: isFile ? [
78
- {
79
- files: resolved,
80
- extensions: []
81
- }
82
- ] : [
83
- {
84
- files: ["kirbyup.config"]
85
- },
86
- ...extraConfigSources
87
- ],
88
- cwd,
89
- defaults: inlineConfig
90
- });
91
- return async () => {
92
- const result = await loader.load();
93
- result.config = result.config || inlineConfig;
94
- return result;
95
- };
96
- }
97
-
98
- class PrettyError extends Error {
99
- constructor(message) {
100
- super(message);
101
- this.name = this.constructor.name;
102
- if (typeof Error.captureStackTrace === "function") {
103
- Error.captureStackTrace(this, this.constructor);
104
- } else {
105
- this.stack = new Error(message).stack;
106
- }
107
- }
108
- }
109
- function handleError(error) {
110
- consola__default.error(error.message);
111
- process.exitCode = 1;
112
- }
113
-
114
- const compress = util.promisify(zlib.gzip);
115
- async function getCompressedSize(code) {
116
- const size = (await compress(typeof code === "string" ? code : Buffer.from(code))).length / 1024;
117
- return ` / gzip: ${size.toFixed(2)} KiB`;
118
- }
119
- async function printFileInfo(root, outDir, filePath, type, content) {
120
- content ?? (content = await promises.readFile(pathe.resolve(outDir, filePath), "utf8"));
121
- const prettyOutDir = pathe.normalize(pathe.relative(root, pathe.resolve(root, outDir))) + "/";
122
- const kibs = content.length / 1024;
123
- const compressedSize = await getCompressedSize(content);
124
- const writeColor = type === "chunk" ? picocolors.cyan : picocolors.magenta;
125
- consola__default.log(picocolors.white(picocolors.dim(prettyOutDir)) + writeColor(filePath) + " " + picocolors.dim(`${kibs.toFixed(2)} KiB${compressedSize}`));
126
- }
127
- function debouncePromise(fn, delay, onError) {
128
- let timeout;
129
- let promiseInFly;
130
- let callbackPending;
131
- return function debounced(...args) {
132
- if (promiseInFly) {
133
- callbackPending = () => {
134
- debounced(...args);
135
- callbackPending = void 0;
136
- };
137
- } else {
138
- if (timeout)
139
- clearTimeout(timeout);
140
- timeout = setTimeout(() => {
141
- timeout = void 0;
142
- promiseInFly = fn(...args).catch(onError).finally(() => {
143
- promiseInFly = void 0;
144
- if (callbackPending)
145
- callbackPending();
146
- });
147
- }, delay);
148
- }
149
- };
150
- }
151
-
152
- function toArray(array) {
153
- array = array || [];
154
- if (Array.isArray(array))
155
- return array;
156
- return [array];
157
- }
158
-
159
- const name = "kirbyup";
160
- const version = "0.23.0";
161
-
162
- let resolvedKirbyupConfig;
163
- let resolvedPostCssConfig;
164
- async function viteBuild(options) {
165
- let result;
166
- const mode = options.watch ? "development" : "production";
167
- const root = process.cwd();
168
- const outDir = options.outDir ?? root;
169
- const aliasDir = pathe.resolve(root, pathe.dirname(options.entry));
170
- const { alias = {}, extendViteConfig = {} } = resolvedKirbyupConfig;
171
- const defaultConfig = {
172
- mode,
173
- plugins: [vitePluginVue2.createVuePlugin(), kirbyupAutoImportPlugin()],
174
- build: {
175
- lib: {
176
- entry: pathe.resolve(root, options.entry),
177
- formats: ["iife"],
178
- name: "kirbyupExport",
179
- fileName: () => "index.js"
180
- },
181
- minify: mode === "production",
182
- outDir,
183
- emptyOutDir: false,
184
- rollupOptions: {
185
- external: ["vue"],
186
- output: {
187
- assetFileNames: "index.[ext]",
188
- globals: {
189
- vue: "Vue"
190
- }
191
- }
192
- }
193
- },
194
- resolve: {
195
- alias: {
196
- "~/": `${aliasDir}/`,
197
- "@/": `${aliasDir}/`,
198
- ...alias
199
- }
200
- },
201
- css: {
202
- postcss: resolvedPostCssConfig
203
- },
204
- envPrefix: ["VITE_", "KIRBYUP_"],
205
- logLevel: "warn"
206
- };
207
- try {
208
- result = await vite.build(vite.mergeConfig(defaultConfig, extendViteConfig));
209
- } catch (error) {
210
- consola__default.error("Build failed");
211
- if (mode === "production") {
212
- throw error;
213
- }
214
- }
215
- if (result && !options.watch) {
216
- const { output } = toArray(result)[0];
217
- for (const { fileName, type, code } of output) {
218
- printFileInfo(root, outDir, fileName, type, code);
219
- }
220
- }
221
- return result;
222
- }
223
- async function resolveOptions(options) {
224
- if (!options.entry) {
225
- throw new PrettyError(`No input file, try ${picocolors.cyan(`${name} <path/to/file.js>`)}`);
226
- }
227
- if (!fs.existsSync(options.entry)) {
228
- throw new PrettyError(`Cannot find ${options.entry}`);
229
- }
230
- return options;
231
- }
232
- async function build(_options) {
233
- const options = await resolveOptions(_options);
234
- const loadConfig = createConfigLoader();
235
- const { config, sources: configSources } = await loadConfig();
236
- resolvedKirbyupConfig = config;
237
- try {
238
- resolvedPostCssConfig = await postcssrc__default({});
239
- } catch (err) {
240
- if (!/No PostCSS Config found/.test(err.message)) {
241
- throw err;
242
- }
243
- resolvedPostCssConfig = {
244
- plugins: [postcssLogical__default(), postcssDirPseudoClass__default()]
245
- };
246
- }
247
- consola__default.log(picocolors.green(`${name} v${version}`));
248
- consola__default.start(`Building ${picocolors.cyan(options.entry)}`);
249
- if (options.watch) {
250
- consola__default.info("Running in watch mode");
251
- }
252
- const debouncedBuild = debouncePromise(async () => {
253
- viteBuild(options);
254
- }, 100, handleError);
255
- const startWatcher = async () => {
256
- if (!options.watch)
257
- return;
258
- const { watch } = await import('chokidar');
259
- const ignored = [
260
- "**/{.git,node_modules}/**",
261
- "index.{css,js}"
262
- ];
263
- const watchPaths = typeof options.watch === "boolean" ? pathe.dirname(options.entry) : Array.isArray(options.watch) ? options.watch.filter((path) => typeof path === "string") : options.watch;
264
- consola__default.info("Watching for changes in " + toArray(watchPaths).map((i) => picocolors.cyan(i)).join(", "));
265
- const watcher = watch(watchPaths, {
266
- ignoreInitial: true,
267
- ignorePermissionErrors: true,
268
- ignored
269
- });
270
- if (configSources.length) {
271
- watcher.add(configSources);
272
- }
273
- watcher.on("all", async (type, file) => {
274
- if (configSources.includes(file)) {
275
- resolvedKirbyupConfig = (await loadConfig()).config;
276
- consola__default.info(`${picocolors.cyan(pathe.basename(file))} changed, setting new config`);
277
- } else {
278
- consola__default.log(picocolors.green(type) + " " + picocolors.white(picocolors.dim(file)));
279
- }
280
- debouncedBuild();
281
- });
282
- };
283
- await viteBuild(options);
284
- consola__default.success("Build successful");
285
- startWatcher();
286
- }
287
-
288
- exports.build = build;
289
- exports.defineConfig = defineConfig;
290
- exports.handleError = handleError;
291
- exports.name = name;
292
- exports.resolveOptions = resolveOptions;
293
- exports.version = version;
package/dist/cli.cjs DELETED
@@ -1,40 +0,0 @@
1
- 'use strict';
2
-
3
- const cac = require('cac');
4
- const index = require('./chunks/index.cjs');
5
- require('pathe');
6
- require('fs');
7
- require('vite');
8
- require('vite-plugin-vue2');
9
- require('magic-string');
10
- require('unconfig');
11
- require('postcss-load-config');
12
- require('postcss-logical');
13
- require('postcss-dir-pseudo-class');
14
- require('consola');
15
- require('picocolors');
16
- require('fs/promises');
17
- require('zlib');
18
- require('util');
19
-
20
- async function main(options = {}) {
21
- const cli = cac.cac(index.name);
22
- cli.command("[file]", "Panel input file", {
23
- ignoreOptionDefaultValue: true
24
- }).option("-d, --out-dir <dir>", "Output directory", {
25
- default: process.cwd()
26
- }).option("--watch [path]", 'Watch mode, if path is not specified, it watches the folder of the input file. Repeat "--watch" for multiple paths').action(async (file, flags) => {
27
- Object.assign(options, {
28
- ...flags
29
- });
30
- if (file) {
31
- options.entry = file;
32
- }
33
- await index.build(options);
34
- });
35
- cli.help();
36
- cli.version(index.version);
37
- cli.parse(process.argv, { run: false });
38
- await cli.runMatchedCommand();
39
- }
40
- main().catch(index.handleError);
package/dist/index.cjs DELETED
@@ -1,25 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- require('pathe');
6
- require('fs');
7
- require('vite');
8
- require('vite-plugin-vue2');
9
- const index = require('./chunks/index.cjs');
10
- require('postcss-load-config');
11
- require('postcss-logical');
12
- require('postcss-dir-pseudo-class');
13
- require('consola');
14
- require('picocolors');
15
- require('magic-string');
16
- require('unconfig');
17
- require('fs/promises');
18
- require('zlib');
19
- require('util');
20
-
21
-
22
-
23
- exports.build = index.build;
24
- exports.defineConfig = index.defineConfig;
25
- exports.resolveOptions = index.resolveOptions;
package/dist/plugin.cjs DELETED
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const getComponentName = (path) => path.substring(path.lastIndexOf("/") + 1, path.lastIndexOf(".")).toLowerCase();
6
- const kirbyup = Object.freeze({
7
- import(modules) {
8
- return Object.entries(modules).reduce((accumulator, [path, component]) => {
9
- accumulator[getComponentName(path)] = component.default;
10
- return accumulator;
11
- }, {});
12
- }
13
- });
14
-
15
- exports.kirbyup = kirbyup;