kirbyup 1.0.2 → 1.2.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/{bin/kirbyup.mjs → cli.mjs} +1 -1
- package/dist/chunks/index.mjs +23 -18
- package/dist/cli.mjs +11 -8
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +3 -2
- package/package.json +20 -23
package/dist/chunks/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { existsSync
|
|
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
|
-
import
|
|
4
|
+
import vuePlugin from '@vitejs/plugin-vue2';
|
|
5
5
|
import postcssrc from 'postcss-load-config';
|
|
6
6
|
import postcssLogical from 'postcss-logical';
|
|
7
7
|
import postcssDirPseudoClass from 'postcss-dir-pseudo-class';
|
|
@@ -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.
|
|
19
|
+
const version = "1.2.1";
|
|
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
|
|
134
|
+
async function generate(options) {
|
|
134
135
|
let result;
|
|
135
136
|
const mode = options.watch ? "development" : "production";
|
|
136
|
-
const
|
|
137
|
-
const
|
|
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
|
-
plugins: [
|
|
142
|
+
plugins: [vuePlugin(), kirbyupAutoImportPlugin()],
|
|
143
143
|
build: {
|
|
144
144
|
lib: {
|
|
145
|
-
entry: resolve(
|
|
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(
|
|
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 {
|
|
201
|
+
const { cwd } = options;
|
|
202
|
+
const { config, sources: configSources } = await loadConfig(cwd);
|
|
201
203
|
resolvedKirbyupConfig = config;
|
|
202
204
|
try {
|
|
203
205
|
resolvedPostCssConfig = await postcssrc({});
|
|
@@ -208,12 +210,14 @@ async function build(_options) {
|
|
|
208
210
|
plugins: [postcssLogical(), postcssDirPseudoClass()]
|
|
209
211
|
};
|
|
210
212
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
+
{
|
|
214
|
+
consola.log(colors.green(`${name} v${version}`));
|
|
215
|
+
consola.start(`Building ${colors.cyan(options.entry)}`);
|
|
216
|
+
}
|
|
213
217
|
if (options.watch)
|
|
214
218
|
consola.info("Running in watch mode");
|
|
215
219
|
const debouncedBuild = debounce(async () => {
|
|
216
|
-
|
|
220
|
+
generate(options).catch(handleError);
|
|
217
221
|
}, 100);
|
|
218
222
|
const startWatcher = async () => {
|
|
219
223
|
if (!options.watch)
|
|
@@ -228,7 +232,8 @@ async function build(_options) {
|
|
|
228
232
|
const watcher = watch(watchPaths, {
|
|
229
233
|
ignoreInitial: true,
|
|
230
234
|
ignorePermissionErrors: true,
|
|
231
|
-
ignored
|
|
235
|
+
ignored,
|
|
236
|
+
cwd
|
|
232
237
|
});
|
|
233
238
|
if (configSources.length)
|
|
234
239
|
watcher.add(configSources);
|
|
@@ -242,7 +247,7 @@ async function build(_options) {
|
|
|
242
247
|
debouncedBuild();
|
|
243
248
|
});
|
|
244
249
|
};
|
|
245
|
-
await
|
|
250
|
+
await generate(options);
|
|
246
251
|
consola.success("Build successful");
|
|
247
252
|
startWatcher();
|
|
248
253
|
}
|
package/dist/cli.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { cac } from 'cac';
|
|
2
|
-
import {
|
|
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
|
-
import '
|
|
6
|
+
import '@vitejs/plugin-vue2';
|
|
7
7
|
import 'postcss-load-config';
|
|
8
8
|
import 'postcss-logical';
|
|
9
9
|
import 'postcss-dir-pseudo-class';
|
|
@@ -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
|
|
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:
|
|
25
|
-
}).option("-w, --watch [path]", 'Watch
|
|
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(
|
|
37
|
+
cli.parse(argv, { run: false });
|
|
36
38
|
await cli.runMatchedCommand();
|
|
37
39
|
}
|
|
38
|
-
|
|
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,7 +1,7 @@
|
|
|
1
|
-
import 'fs';
|
|
1
|
+
import 'node:fs';
|
|
2
2
|
import 'pathe';
|
|
3
3
|
import 'vite';
|
|
4
|
-
import '
|
|
4
|
+
import '@vitejs/plugin-vue2';
|
|
5
5
|
import 'postcss-load-config';
|
|
6
6
|
import 'postcss-logical';
|
|
7
7
|
import 'postcss-dir-pseudo-class';
|
|
@@ -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.
|
|
4
|
-
"packageManager": "pnpm@7.
|
|
3
|
+
"version": "1.2.1",
|
|
4
|
+
"packageManager": "pnpm@7.5.2",
|
|
5
5
|
"description": "Zero-config bundler for Kirby Panel plugins",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Johann Schopplich",
|
|
@@ -21,8 +21,9 @@
|
|
|
21
21
|
"kirby-cms",
|
|
22
22
|
"kirby-plugin",
|
|
23
23
|
"kirby",
|
|
24
|
+
"cli",
|
|
24
25
|
"panel",
|
|
25
|
-
"
|
|
26
|
+
"bundler"
|
|
26
27
|
],
|
|
27
28
|
"exports": {
|
|
28
29
|
".": {
|
|
@@ -36,9 +37,7 @@
|
|
|
36
37
|
},
|
|
37
38
|
"module": "./dist/index.mjs",
|
|
38
39
|
"types": "./dist/index.d.ts",
|
|
39
|
-
"bin":
|
|
40
|
-
"kirbyup": "./bin/kirbyup.mjs"
|
|
41
|
-
},
|
|
40
|
+
"bin": "./cli.mjs",
|
|
42
41
|
"files": [
|
|
43
42
|
"bin",
|
|
44
43
|
"dist"
|
|
@@ -48,7 +47,7 @@
|
|
|
48
47
|
},
|
|
49
48
|
"scripts": {
|
|
50
49
|
"build": "unbuild",
|
|
51
|
-
"
|
|
50
|
+
"dev": "unbuild --stub",
|
|
52
51
|
"lint": "eslint .",
|
|
53
52
|
"lint:fix": "eslint . --fix",
|
|
54
53
|
"release": "bumpp --commit --push --tag",
|
|
@@ -57,38 +56,36 @@
|
|
|
57
56
|
"prepare": "pnpm exec simple-git-hooks"
|
|
58
57
|
},
|
|
59
58
|
"dependencies": {
|
|
59
|
+
"@vitejs/plugin-vue2": "^1.1.2",
|
|
60
60
|
"cac": "^6.7.12",
|
|
61
61
|
"chokidar": "^3.5.3",
|
|
62
62
|
"consola": "^2.15.3",
|
|
63
|
-
"
|
|
63
|
+
"magic-string": "^0.26.2",
|
|
64
|
+
"pathe": "^0.3.2",
|
|
64
65
|
"perfect-debounce": "^0.1.3",
|
|
65
66
|
"picocolors": "^1.0.0",
|
|
66
67
|
"postcss": "^8.4.14",
|
|
67
|
-
"postcss-dir-pseudo-class": "^6.0.
|
|
68
|
+
"postcss-dir-pseudo-class": "^6.0.5",
|
|
68
69
|
"postcss-load-config": "^4.0.1",
|
|
69
70
|
"postcss-logical": "^5.0.4",
|
|
70
|
-
"sass": "^1.
|
|
71
|
-
"unconfig": "^0.3.
|
|
72
|
-
"vite": "
|
|
73
|
-
"
|
|
74
|
-
"vue": "^2.6.14",
|
|
75
|
-
"vue-template-compiler": "^2.6.14"
|
|
71
|
+
"sass": "^1.53.0",
|
|
72
|
+
"unconfig": "^0.3.5",
|
|
73
|
+
"vite": "^3.0.1",
|
|
74
|
+
"vue": "^2.7.7"
|
|
76
75
|
},
|
|
77
76
|
"devDependencies": {
|
|
78
|
-
"@antfu/eslint-config": "^0.25.
|
|
77
|
+
"@antfu/eslint-config": "^0.25.2",
|
|
79
78
|
"@types/fs-extra": "^9.0.13",
|
|
80
|
-
"@types/node": "^
|
|
79
|
+
"@types/node": "^18.0.6",
|
|
81
80
|
"@types/prompts": "^2.4.0",
|
|
82
|
-
"bumpp": "^
|
|
83
|
-
"eslint": "^8.
|
|
84
|
-
"execa": "^6.1.0",
|
|
81
|
+
"bumpp": "^8.2.1",
|
|
82
|
+
"eslint": "^8.20.0",
|
|
85
83
|
"fast-glob": "^3.2.11",
|
|
86
84
|
"fs-extra": "^10.1.0",
|
|
87
85
|
"simple-git-hooks": "^2.8.0",
|
|
88
|
-
"
|
|
89
|
-
"typescript": "^4.7.3",
|
|
86
|
+
"typescript": "^4.7.4",
|
|
90
87
|
"unbuild": "^0.7.4",
|
|
91
|
-
"vitest": "^0.
|
|
88
|
+
"vitest": "^0.18.1"
|
|
92
89
|
},
|
|
93
90
|
"simple-git-hooks": {
|
|
94
91
|
"commit-msg": "node scripts/verifyCommit.mjs $1"
|