kirbyup 0.4.0 → 0.8.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/README.md +13 -7
- package/dist/cli.d.ts +1 -0
- package/dist/{cli-default.js → cli.js} +49 -45
- package/dist/index.d.ts +8 -806
- package/dist/index.js +37 -27
- package/package.json +10 -7
- package/dist/cli-default.d.ts +0 -1
- package/dist/cli-main.d.ts +0 -5
- package/dist/cli-main.js +0 -275
package/dist/index.js
CHANGED
|
@@ -105,54 +105,61 @@ var import_chalk2 = __toModule(require("chalk"));
|
|
|
105
105
|
|
|
106
106
|
// package.json
|
|
107
107
|
var name = "kirbyup";
|
|
108
|
-
var version = "0.
|
|
108
|
+
var version = "0.8.0";
|
|
109
109
|
|
|
110
110
|
// src/log.ts
|
|
111
|
-
var
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
var colorMap = new Map([
|
|
112
|
+
["info", "yellow"],
|
|
113
|
+
["success", "green"],
|
|
114
|
+
["error", "red"]
|
|
115
|
+
]);
|
|
116
|
+
function log(message, type = "info") {
|
|
117
|
+
var _a;
|
|
118
|
+
const content = [
|
|
119
|
+
import_chalk2.default.gray(`[${name}]`),
|
|
120
|
+
import_chalk2.default[(_a = colorMap.get(type)) != null ? _a : "white"](message)
|
|
121
|
+
];
|
|
122
|
+
if (type === "error") {
|
|
123
|
+
console.error(...content);
|
|
124
|
+
} else {
|
|
125
|
+
console.log(...content);
|
|
120
126
|
}
|
|
121
127
|
}
|
|
122
128
|
|
|
123
129
|
// src/index.ts
|
|
124
130
|
async function runViteBuild(options) {
|
|
125
131
|
let result;
|
|
132
|
+
const fileName = "index";
|
|
133
|
+
const currentDir = process.cwd();
|
|
126
134
|
try {
|
|
127
135
|
result = await (0, import_vite.build)({
|
|
128
136
|
plugins: [(0, import_vite_plugin_vue2.createVuePlugin)()],
|
|
129
137
|
build: {
|
|
130
138
|
lib: {
|
|
131
|
-
entry: (0, import_path.resolve)(
|
|
139
|
+
entry: (0, import_path.resolve)(currentDir, options.entry),
|
|
132
140
|
formats: ["es"],
|
|
133
|
-
fileName
|
|
141
|
+
fileName
|
|
134
142
|
},
|
|
135
|
-
outDir:
|
|
143
|
+
outDir: currentDir,
|
|
144
|
+
emptyOutDir: false,
|
|
136
145
|
rollupOptions: {
|
|
137
146
|
external: ["vue"],
|
|
138
147
|
output: {
|
|
139
148
|
entryFileNames: "[name].js",
|
|
140
|
-
assetFileNames:
|
|
149
|
+
assetFileNames: `${fileName}.[ext]`,
|
|
141
150
|
globals: {
|
|
142
151
|
vue: "Vue"
|
|
143
152
|
}
|
|
144
153
|
}
|
|
145
154
|
}
|
|
146
155
|
},
|
|
147
|
-
logLevel: "
|
|
156
|
+
logLevel: "warn"
|
|
148
157
|
});
|
|
149
158
|
} catch (error) {
|
|
150
|
-
log("
|
|
159
|
+
log("Build failed", "error");
|
|
151
160
|
throw error;
|
|
152
161
|
}
|
|
153
|
-
|
|
154
|
-
log("success", `Build success`);
|
|
155
|
-
}
|
|
162
|
+
log("Build successful", "success");
|
|
156
163
|
return result;
|
|
157
164
|
}
|
|
158
165
|
var normalizeOptions = async (options) => {
|
|
@@ -166,29 +173,32 @@ var normalizeOptions = async (options) => {
|
|
|
166
173
|
};
|
|
167
174
|
async function build(_options) {
|
|
168
175
|
const options = await normalizeOptions(_options);
|
|
169
|
-
log(
|
|
170
|
-
log(
|
|
176
|
+
log(`${name} v${version}`);
|
|
177
|
+
log(`Building: ${options.entry}`);
|
|
171
178
|
if (options.watch) {
|
|
172
|
-
log("
|
|
179
|
+
log("Running in watch mode");
|
|
173
180
|
}
|
|
174
|
-
const
|
|
181
|
+
const debouncedBuild = debouncePromise(async () => {
|
|
175
182
|
runViteBuild(options);
|
|
176
183
|
}, 100, handleError);
|
|
177
184
|
const startWatcher = async () => {
|
|
178
185
|
if (!options.watch)
|
|
179
186
|
return;
|
|
180
187
|
const { watch } = await import("chokidar");
|
|
181
|
-
const ignored = [
|
|
188
|
+
const ignored = [
|
|
189
|
+
"**/{.git,node_modules}/**",
|
|
190
|
+
"index.js"
|
|
191
|
+
];
|
|
182
192
|
const watchPaths = typeof options.watch === "boolean" ? (0, import_path.dirname)(options.entry) : Array.isArray(options.watch) ? options.watch.filter((path) => typeof path === "string") : options.watch;
|
|
183
|
-
log(
|
|
193
|
+
log(`Watching for changes in ${Array.isArray(watchPaths) ? watchPaths.map((v) => '"' + v + '"').join(" | ") : '"' + watchPaths + '"'}`);
|
|
184
194
|
const watcher = watch(watchPaths, {
|
|
185
195
|
ignoreInitial: true,
|
|
186
196
|
ignorePermissionErrors: true,
|
|
187
197
|
ignored
|
|
188
198
|
});
|
|
189
199
|
watcher.on("all", async (type, file) => {
|
|
190
|
-
log(
|
|
191
|
-
|
|
200
|
+
log(`Change detected: ${type} ${file}`);
|
|
201
|
+
debouncedBuild();
|
|
192
202
|
});
|
|
193
203
|
};
|
|
194
204
|
await runViteBuild(options);
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kirbyup",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"description": "Zero-config bundler for Kirby Panel plugins",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
7
7
|
],
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"bin": {
|
|
10
|
-
"kirbyup": "dist/cli
|
|
10
|
+
"kirbyup": "dist/cli.js"
|
|
11
11
|
},
|
|
12
12
|
"types": "dist/index.d.ts",
|
|
13
13
|
"repository": {
|
|
@@ -15,8 +15,11 @@
|
|
|
15
15
|
"url": "git+https://github.com/johannschopplich/kirbyup.git"
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
|
18
|
+
"kirby-cms",
|
|
19
|
+
"kirby-plugin",
|
|
18
20
|
"kirby",
|
|
19
|
-
"
|
|
21
|
+
"panel",
|
|
22
|
+
"bundle"
|
|
20
23
|
],
|
|
21
24
|
"author": {
|
|
22
25
|
"name": "Johann Schopplich",
|
|
@@ -29,7 +32,7 @@
|
|
|
29
32
|
},
|
|
30
33
|
"homepage": "https://github.com/johannschopplich/kirbyup#readme",
|
|
31
34
|
"scripts": {
|
|
32
|
-
"build": "tsup src/cli
|
|
35
|
+
"build": "tsup src/cli.ts src/index.ts --target node14 --clean --dts",
|
|
33
36
|
"prepublishOnly": "npm run build"
|
|
34
37
|
},
|
|
35
38
|
"dependencies": {
|
|
@@ -37,12 +40,12 @@
|
|
|
37
40
|
"chalk": "^4.1.2",
|
|
38
41
|
"chokidar": "^3.5.2",
|
|
39
42
|
"sass": "^1.41.1",
|
|
40
|
-
"vite": "^2.5.
|
|
43
|
+
"vite": "^2.5.10",
|
|
41
44
|
"vite-plugin-vue2": "^1.8.2",
|
|
42
45
|
"vue": "^2.6.14"
|
|
43
46
|
},
|
|
44
47
|
"devDependencies": {
|
|
45
|
-
"@types/node": "^16.9.
|
|
48
|
+
"@types/node": "^16.9.4",
|
|
46
49
|
"prettier": "^2.4.1",
|
|
47
50
|
"ts-essentials": "^8.1.0",
|
|
48
51
|
"tsup": "^5.1.0",
|
package/dist/cli-default.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
package/dist/cli-main.d.ts
DELETED
package/dist/cli-main.js
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
-
if (__propIsEnum.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
22
|
-
var __require = typeof require !== "undefined" ? require : (x) => {
|
|
23
|
-
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
24
|
-
};
|
|
25
|
-
var __esm = (fn, res) => function __init() {
|
|
26
|
-
return fn && (res = (0, fn[Object.keys(fn)[0]])(fn = 0)), res;
|
|
27
|
-
};
|
|
28
|
-
var __export = (target, all) => {
|
|
29
|
-
__markAsModule(target);
|
|
30
|
-
for (var name2 in all)
|
|
31
|
-
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
32
|
-
};
|
|
33
|
-
var __reExport = (target, module2, desc) => {
|
|
34
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
35
|
-
for (let key of __getOwnPropNames(module2))
|
|
36
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
37
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
38
|
-
}
|
|
39
|
-
return target;
|
|
40
|
-
};
|
|
41
|
-
var __toModule = (module2) => {
|
|
42
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// node_modules/tsup/assets/cjs_shims.js
|
|
46
|
-
var importMetaUrlShim;
|
|
47
|
-
var init_cjs_shims = __esm({
|
|
48
|
-
"node_modules/tsup/assets/cjs_shims.js"() {
|
|
49
|
-
importMetaUrlShim = typeof document === "undefined" ? new (require("url")).URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// package.json
|
|
54
|
-
var name, version;
|
|
55
|
-
var init_package = __esm({
|
|
56
|
-
"package.json"() {
|
|
57
|
-
name = "kirbyup";
|
|
58
|
-
version = "0.4.0";
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// src/errors.ts
|
|
63
|
-
function handleError(error) {
|
|
64
|
-
if (error.loc) {
|
|
65
|
-
console.error(import_chalk.default.bold(import_chalk.default.red(`Error parsing: ${error.loc.file}:${error.loc.line}:${error.loc.column}`)));
|
|
66
|
-
}
|
|
67
|
-
if (error.frame) {
|
|
68
|
-
console.error(import_chalk.default.red(error.message));
|
|
69
|
-
console.error(import_chalk.default.dim(error.frame));
|
|
70
|
-
} else {
|
|
71
|
-
if (error instanceof PrettyError) {
|
|
72
|
-
console.error(import_chalk.default.red(error.message));
|
|
73
|
-
} else {
|
|
74
|
-
console.error(import_chalk.default.red(error.stack));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
process.exitCode = 1;
|
|
78
|
-
if (!import_worker_threads.isMainThread && import_worker_threads.parentPort) {
|
|
79
|
-
import_worker_threads.parentPort.postMessage("has-error");
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
var import_worker_threads, import_chalk, PrettyError;
|
|
83
|
-
var init_errors = __esm({
|
|
84
|
-
"src/errors.ts"() {
|
|
85
|
-
init_cjs_shims();
|
|
86
|
-
import_worker_threads = __toModule(require("worker_threads"));
|
|
87
|
-
import_chalk = __toModule(require("chalk"));
|
|
88
|
-
PrettyError = class extends Error {
|
|
89
|
-
constructor(message) {
|
|
90
|
-
super(message);
|
|
91
|
-
this.name = this.constructor.name;
|
|
92
|
-
if (typeof Error.captureStackTrace === "function") {
|
|
93
|
-
Error.captureStackTrace(this, this.constructor);
|
|
94
|
-
} else {
|
|
95
|
-
this.stack = new Error(message).stack;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
// src/utils.ts
|
|
103
|
-
function debouncePromise(fn, delay, onError) {
|
|
104
|
-
let timeout;
|
|
105
|
-
let promiseInFly;
|
|
106
|
-
let callbackPending;
|
|
107
|
-
return function debounced(...args) {
|
|
108
|
-
if (promiseInFly) {
|
|
109
|
-
callbackPending = () => {
|
|
110
|
-
debounced(...args);
|
|
111
|
-
callbackPending = void 0;
|
|
112
|
-
};
|
|
113
|
-
} else {
|
|
114
|
-
if (timeout != null)
|
|
115
|
-
clearTimeout(timeout);
|
|
116
|
-
timeout = setTimeout(() => {
|
|
117
|
-
timeout = void 0;
|
|
118
|
-
promiseInFly = fn(...args).catch(onError).finally(() => {
|
|
119
|
-
promiseInFly = void 0;
|
|
120
|
-
if (callbackPending)
|
|
121
|
-
callbackPending();
|
|
122
|
-
});
|
|
123
|
-
}, delay);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
var init_utils = __esm({
|
|
128
|
-
"src/utils.ts"() {
|
|
129
|
-
init_cjs_shims();
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
// src/log.ts
|
|
134
|
-
function log(type, message) {
|
|
135
|
-
switch (type) {
|
|
136
|
-
case "error": {
|
|
137
|
-
return console.error(label, makeMessage(message, type));
|
|
138
|
-
}
|
|
139
|
-
default:
|
|
140
|
-
console.log(label, makeMessage(message, type));
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
var import_chalk2, label, makeMessage;
|
|
144
|
-
var init_log = __esm({
|
|
145
|
-
"src/log.ts"() {
|
|
146
|
-
init_cjs_shims();
|
|
147
|
-
import_chalk2 = __toModule(require("chalk"));
|
|
148
|
-
init_package();
|
|
149
|
-
label = import_chalk2.default.gray(`[${name}]`);
|
|
150
|
-
makeMessage = (input, type) => import_chalk2.default[type === "info" ? "yellow" : type === "error" ? "red" : "green"](input);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
// src/index.ts
|
|
155
|
-
var src_exports = {};
|
|
156
|
-
__export(src_exports, {
|
|
157
|
-
build: () => build,
|
|
158
|
-
runViteBuild: () => runViteBuild
|
|
159
|
-
});
|
|
160
|
-
async function runViteBuild(options) {
|
|
161
|
-
let result;
|
|
162
|
-
try {
|
|
163
|
-
result = await (0, import_vite.build)({
|
|
164
|
-
plugins: [(0, import_vite_plugin_vue2.createVuePlugin)()],
|
|
165
|
-
build: {
|
|
166
|
-
lib: {
|
|
167
|
-
entry: (0, import_path.resolve)(process.cwd(), options.entry),
|
|
168
|
-
formats: ["es"],
|
|
169
|
-
fileName: "index"
|
|
170
|
-
},
|
|
171
|
-
outDir: ".",
|
|
172
|
-
rollupOptions: {
|
|
173
|
-
external: ["vue"],
|
|
174
|
-
output: {
|
|
175
|
-
entryFileNames: "[name].js",
|
|
176
|
-
assetFileNames: "index.[ext]",
|
|
177
|
-
globals: {
|
|
178
|
-
vue: "Vue"
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
logLevel: "error"
|
|
184
|
-
});
|
|
185
|
-
} catch (error) {
|
|
186
|
-
log("error", "Build failed");
|
|
187
|
-
throw error;
|
|
188
|
-
}
|
|
189
|
-
if (result) {
|
|
190
|
-
log("success", `Build success`);
|
|
191
|
-
}
|
|
192
|
-
return result;
|
|
193
|
-
}
|
|
194
|
-
async function build(_options) {
|
|
195
|
-
const options = await normalizeOptions(_options);
|
|
196
|
-
log("info", `#{name} v${version}`);
|
|
197
|
-
log("info", `Building: ${options.entry}`);
|
|
198
|
-
if (options.watch) {
|
|
199
|
-
log("info", "Running in watch mode");
|
|
200
|
-
}
|
|
201
|
-
const debouncedBuildAll = debouncePromise(async () => {
|
|
202
|
-
runViteBuild(options);
|
|
203
|
-
}, 100, handleError);
|
|
204
|
-
const startWatcher = async () => {
|
|
205
|
-
if (!options.watch)
|
|
206
|
-
return;
|
|
207
|
-
const { watch } = await import("chokidar");
|
|
208
|
-
const ignored = ["**/{.git,node_modules}/**"];
|
|
209
|
-
const watchPaths = typeof options.watch === "boolean" ? (0, import_path.dirname)(options.entry) : Array.isArray(options.watch) ? options.watch.filter((path) => typeof path === "string") : options.watch;
|
|
210
|
-
log("info", `Watching for changes in ${Array.isArray(watchPaths) ? watchPaths.map((v) => '"' + v + '"').join(" | ") : '"' + watchPaths + '"'}`);
|
|
211
|
-
const watcher = watch(watchPaths, {
|
|
212
|
-
ignoreInitial: true,
|
|
213
|
-
ignorePermissionErrors: true,
|
|
214
|
-
ignored
|
|
215
|
-
});
|
|
216
|
-
watcher.on("all", async (type, file) => {
|
|
217
|
-
log("info", `Change detected: ${type} ${file}`);
|
|
218
|
-
debouncedBuildAll();
|
|
219
|
-
});
|
|
220
|
-
};
|
|
221
|
-
await runViteBuild(options);
|
|
222
|
-
startWatcher();
|
|
223
|
-
}
|
|
224
|
-
var import_path, import_fs, import_vite, import_vite_plugin_vue2, normalizeOptions;
|
|
225
|
-
var init_src = __esm({
|
|
226
|
-
"src/index.ts"() {
|
|
227
|
-
init_cjs_shims();
|
|
228
|
-
import_path = __toModule(require("path"));
|
|
229
|
-
import_fs = __toModule(require("fs"));
|
|
230
|
-
import_vite = __toModule(require("vite"));
|
|
231
|
-
import_vite_plugin_vue2 = __toModule(require("vite-plugin-vue2"));
|
|
232
|
-
init_errors();
|
|
233
|
-
init_utils();
|
|
234
|
-
init_log();
|
|
235
|
-
init_package();
|
|
236
|
-
normalizeOptions = async (options) => {
|
|
237
|
-
if (!options.entry) {
|
|
238
|
-
throw new PrettyError(`No input file, try "${name} <path/to/file.js>"`);
|
|
239
|
-
}
|
|
240
|
-
if (!(0, import_fs.existsSync)(options.entry)) {
|
|
241
|
-
throw new PrettyError(`Cannot find ${options.entry}`);
|
|
242
|
-
}
|
|
243
|
-
return options;
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
// src/cli-main.ts
|
|
249
|
-
__export(exports, {
|
|
250
|
-
main: () => main
|
|
251
|
-
});
|
|
252
|
-
init_cjs_shims();
|
|
253
|
-
var import_cac = __toModule(require("cac"));
|
|
254
|
-
init_package();
|
|
255
|
-
async function main(options = {}) {
|
|
256
|
-
const cli = (0, import_cac.cac)(name);
|
|
257
|
-
cli.command("[file]", "Panel input file", {
|
|
258
|
-
ignoreOptionDefaultValue: true
|
|
259
|
-
}).option("--watch [path]", 'Watch mode, if path is not specified, it watches the current folder ".". Repeat "--watch" for more than one path').action(async (file, flags) => {
|
|
260
|
-
const { build: build2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
261
|
-
Object.assign(options, __spreadValues({}, flags));
|
|
262
|
-
if (file) {
|
|
263
|
-
options.entry = file;
|
|
264
|
-
}
|
|
265
|
-
await build2(options);
|
|
266
|
-
});
|
|
267
|
-
cli.help();
|
|
268
|
-
cli.version(version);
|
|
269
|
-
cli.parse(process.argv, { run: false });
|
|
270
|
-
await cli.runMatchedCommand();
|
|
271
|
-
}
|
|
272
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
273
|
-
0 && (module.exports = {
|
|
274
|
-
main
|
|
275
|
-
});
|