kirbyup 1.0.2 → 1.1.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.
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict'
3
- import('../dist/cli.mjs')
3
+ import('./dist/cli.mjs')
@@ -1,4 +1,4 @@
1
- import { existsSync, statSync } from 'fs';
1
+ import { existsSync as existsSync$1 } from 'node:fs';
2
2
  import { resolve, normalize, relative, dirname, basename } from 'pathe';
3
3
  import { build as build$1, mergeConfig } from 'vite';
4
4
  import { createVuePlugin } from 'vite-plugin-vue2';
@@ -11,11 +11,12 @@ import colors from 'picocolors';
11
11
  import { readFile } from 'fs/promises';
12
12
  import { gzip } from 'zlib';
13
13
  import { promisify } from 'util';
14
+ import { existsSync, statSync } from 'fs';
14
15
  import { createConfigLoader } from 'unconfig';
15
16
  import MagicString from 'magic-string';
16
17
 
17
18
  const name = "kirbyup";
18
- const version = "1.0.2";
19
+ const version = "1.1.0";
19
20
 
20
21
  class PrettyError extends Error {
21
22
  constructor(message) {
@@ -130,19 +131,18 @@ function kirbyupAutoImportPlugin() {
130
131
 
131
132
  let resolvedKirbyupConfig;
132
133
  let resolvedPostCssConfig;
133
- async function viteBuild(options) {
134
+ async function generate(options) {
134
135
  let result;
135
136
  const mode = options.watch ? "development" : "production";
136
- const root = process.cwd();
137
- const outDir = options.outDir ?? root;
138
- const aliasDir = resolve(root, dirname(options.entry));
137
+ const outDir = options.outDir || options.cwd;
138
+ const aliasDir = resolve(options.cwd, dirname(options.entry));
139
139
  const { alias = {}, extendViteConfig = {} } = resolvedKirbyupConfig;
140
140
  const defaultConfig = {
141
141
  mode,
142
142
  plugins: [createVuePlugin(), kirbyupAutoImportPlugin()],
143
143
  build: {
144
144
  lib: {
145
- entry: resolve(root, options.entry),
145
+ entry: resolve(options.cwd, options.entry),
146
146
  formats: ["iife"],
147
147
  name: "kirbyupExport",
148
148
  fileName: () => "index.js"
@@ -183,21 +183,23 @@ async function viteBuild(options) {
183
183
  if (result && !options.watch) {
184
184
  const { output } = toArray(result)[0];
185
185
  for (const { fileName, type, code } of output)
186
- printFileInfo(root, outDir, fileName, type, code);
186
+ printFileInfo(options.cwd, outDir, fileName, type, code);
187
187
  }
188
188
  return result;
189
189
  }
190
190
  async function resolveOptions(options) {
191
+ options.cwd = options.cwd || process.cwd();
191
192
  if (!options.entry) {
192
193
  throw new PrettyError(`No input file, try ${colors.cyan(`${name} <path/to/file.js>`)}`);
193
194
  }
194
- if (!existsSync(options.entry))
195
- throw new PrettyError(`Cannot find ${options.entry}`);
195
+ if (!existsSync$1(resolve(options.cwd, options.entry)))
196
+ throw new PrettyError(`Cannot find "${options.entry}"`);
196
197
  return options;
197
198
  }
198
199
  async function build(_options) {
199
200
  const options = await resolveOptions(_options);
200
- const { config, sources: configSources } = await loadConfig();
201
+ const { cwd } = options;
202
+ const { config, sources: configSources } = await loadConfig(cwd);
201
203
  resolvedKirbyupConfig = config;
202
204
  try {
203
205
  resolvedPostCssConfig = await postcssrc({});
@@ -213,7 +215,7 @@ async function build(_options) {
213
215
  if (options.watch)
214
216
  consola.info("Running in watch mode");
215
217
  const debouncedBuild = debounce(async () => {
216
- viteBuild(options).catch(handleError);
218
+ generate(options).catch(handleError);
217
219
  }, 100);
218
220
  const startWatcher = async () => {
219
221
  if (!options.watch)
@@ -228,7 +230,8 @@ async function build(_options) {
228
230
  const watcher = watch(watchPaths, {
229
231
  ignoreInitial: true,
230
232
  ignorePermissionErrors: true,
231
- ignored
233
+ ignored,
234
+ cwd
232
235
  });
233
236
  if (configSources.length)
234
237
  watcher.add(configSources);
@@ -242,7 +245,7 @@ async function build(_options) {
242
245
  debouncedBuild();
243
246
  });
244
247
  };
245
- await viteBuild(options);
248
+ await generate(options);
246
249
  consola.success("Build successful");
247
250
  startWatcher();
248
251
  }
package/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { cac } from 'cac';
2
- import { h as handleError, n as name, b as build, v as version } from './chunks/index.mjs';
3
- import 'fs';
2
+ import { n as name, b as build, v as version, h as handleError } from './chunks/index.mjs';
3
+ import 'node:fs';
4
4
  import 'pathe';
5
5
  import 'vite';
6
6
  import 'vite-plugin-vue2';
@@ -13,17 +13,19 @@ import 'picocolors';
13
13
  import 'fs/promises';
14
14
  import 'zlib';
15
15
  import 'util';
16
+ import 'fs';
16
17
  import 'unconfig';
17
18
  import 'magic-string';
18
19
 
19
- async function main(options = {}) {
20
+ async function startCli(cwd = process.cwd(), argv = process.argv, options = {}) {
20
21
  const cli = cac(name);
21
22
  cli.command("[file]", "Panel input file", {
22
23
  ignoreOptionDefaultValue: true
23
24
  }).option("-d, --out-dir <dir>", "Output directory", {
24
- default: process.cwd()
25
- }).option("-w, --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
+ default: cwd
26
+ }).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.').action(async (file, flags) => {
26
27
  Object.assign(options, {
28
+ cwd,
27
29
  ...flags
28
30
  });
29
31
  if (file)
@@ -32,7 +34,8 @@ async function main(options = {}) {
32
34
  });
33
35
  cli.help();
34
36
  cli.version(version);
35
- cli.parse(process.argv, { run: false });
37
+ cli.parse(argv, { run: false });
36
38
  await cli.runMatchedCommand();
37
39
  }
38
- main().catch(handleError);
40
+
41
+ startCli().catch(handleError);
package/dist/index.d.ts CHANGED
@@ -2,11 +2,12 @@ import { AliasOptions, InlineConfig } from 'vite';
2
2
 
3
3
  declare type MarkRequired<T, RK extends keyof T> = Exclude<T, RK> & Required<Pick<T, RK>>;
4
4
  interface CliOptions {
5
+ cwd?: string;
5
6
  entry?: string;
6
7
  outDir?: string;
7
8
  watch?: boolean | string | Array<boolean | string>;
8
9
  }
9
- declare type ResolvedCliOptions = MarkRequired<CliOptions, 'entry'>;
10
+ declare type ResolvedCliOptions = MarkRequired<CliOptions, 'cwd' | 'entry'>;
10
11
  interface UserConfig {
11
12
  /**
12
13
  * Load from config files
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import 'fs';
1
+ import 'node:fs';
2
2
  import 'pathe';
3
3
  import 'vite';
4
4
  import 'vite-plugin-vue2';
@@ -12,5 +12,6 @@ export { b as build, d as defineConfig, r as resolveOptions } from './chunks/ind
12
12
  import 'fs/promises';
13
13
  import 'zlib';
14
14
  import 'util';
15
+ import 'fs';
15
16
  import 'unconfig';
16
17
  import 'magic-string';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kirbyup",
3
- "version": "1.0.2",
4
- "packageManager": "pnpm@7.1.9",
3
+ "version": "1.1.0",
4
+ "packageManager": "pnpm@7.3.0",
5
5
  "description": "Zero-config bundler for Kirby Panel plugins",
6
6
  "author": {
7
7
  "name": "Johann Schopplich",
@@ -36,9 +36,7 @@
36
36
  },
37
37
  "module": "./dist/index.mjs",
38
38
  "types": "./dist/index.d.ts",
39
- "bin": {
40
- "kirbyup": "./bin/kirbyup.mjs"
41
- },
39
+ "bin": "./cli.mjs",
42
40
  "files": [
43
41
  "bin",
44
42
  "dist"
@@ -48,7 +46,7 @@
48
46
  },
49
47
  "scripts": {
50
48
  "build": "unbuild",
51
- "stub": "unbuild --stub",
49
+ "dev": "unbuild --stub",
52
50
  "lint": "eslint .",
53
51
  "lint:fix": "eslint . --fix",
54
52
  "release": "bumpp --commit --push --tag",
@@ -60,14 +58,14 @@
60
58
  "cac": "^6.7.12",
61
59
  "chokidar": "^3.5.3",
62
60
  "consola": "^2.15.3",
63
- "pathe": "^0.3.0",
61
+ "pathe": "^0.3.1",
64
62
  "perfect-debounce": "^0.1.3",
65
63
  "picocolors": "^1.0.0",
66
64
  "postcss": "^8.4.14",
67
65
  "postcss-dir-pseudo-class": "^6.0.4",
68
66
  "postcss-load-config": "^4.0.1",
69
67
  "postcss-logical": "^5.0.4",
70
- "sass": "^1.52.2",
68
+ "sass": "^1.53.0",
71
69
  "unconfig": "^0.3.4",
72
70
  "vite": "2.9.9",
73
71
  "vite-plugin-vue2": "^2.0.1",
@@ -75,20 +73,18 @@
75
73
  "vue-template-compiler": "^2.6.14"
76
74
  },
77
75
  "devDependencies": {
78
- "@antfu/eslint-config": "^0.25.1",
76
+ "@antfu/eslint-config": "^0.25.2",
79
77
  "@types/fs-extra": "^9.0.13",
80
- "@types/node": "^17.0.41",
78
+ "@types/node": "^18.0.0",
81
79
  "@types/prompts": "^2.4.0",
82
- "bumpp": "^7.1.1",
83
- "eslint": "^8.17.0",
84
- "execa": "^6.1.0",
80
+ "bumpp": "^8.2.1",
81
+ "eslint": "^8.18.0",
85
82
  "fast-glob": "^3.2.11",
86
83
  "fs-extra": "^10.1.0",
87
84
  "simple-git-hooks": "^2.8.0",
88
- "tsx": "^3.4.2",
89
- "typescript": "^4.7.3",
85
+ "typescript": "^4.7.4",
90
86
  "unbuild": "^0.7.4",
91
- "vitest": "^0.14.1"
87
+ "vitest": "^0.16.0"
92
88
  },
93
89
  "simple-git-hooks": {
94
90
  "commit-msg": "node scripts/verifyCommit.mjs $1"