kirbyup 0.9.2 → 0.10.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 CHANGED
@@ -1,30 +1,46 @@
1
1
  # kirbyup
2
2
 
3
- > Take a lool into the [pluginkit](./pluginkit) folder for an example setup.
3
+ > Take a look into Kirby's [pluginkit](https://github.com/getkirby/pluginkit/tree/4-panel) repository for an example setup.
4
4
 
5
5
  The fastest and leanest way to bundle your Kirby Panel plugins. No configuration necessary.
6
6
 
7
- ## Install
7
+ ## Installation
8
8
 
9
- Install it locally in your project folder:
9
+ If you want to use kirbyup right away, there is no need to install it. Simply call it with `npx`:
10
+
11
+ ```json
12
+ {
13
+ "scripts": {
14
+ "dev": "npx -y kirbyup src/index.js --watch",
15
+ "build": "npx -y kirbyup src/index.js"
16
+ }
17
+ }
18
+ ```
19
+
20
+ While kirbyup will stay backwards compatible, exact build reproducibility may be of importance to you. If so, I recommend to target a specific package version, rather than using `npx`. Install kirbyup with a package manager of your choice locally to your project:
10
21
 
11
22
  ```bash
12
23
  npm i kirbyup --save-dev
13
24
  ```
14
25
 
15
- You can also install it globally.
16
-
17
- ## Usage
26
+ Example package configuration:
18
27
 
19
28
  ```json
20
29
  {
21
30
  "scripts": {
22
- "dev": "npx -y kirbyup src/index.js --watch",
23
- "build": "npx -y kirbyup src/index.js"
31
+ "dev": "kirbyup src/index.js --watch",
32
+ "build": "kirbyup src/index.js"
33
+ },
34
+ "devDependencies": {
35
+ "kirbyup": "^0.9.5"
24
36
  }
25
37
  }
26
38
  ```
27
39
 
40
+ Global installation is supported as well, but not recommended.
41
+
42
+ ## Usage
43
+
28
44
  ### Development
29
45
 
30
46
  Rebuild the Panel plugin on any file changes:
@@ -53,10 +69,6 @@ kirbyup src/index.js
53
69
 
54
70
  The final panel plugin will be bundled, minified, and written into the current directory as `./index.js`.
55
71
 
56
- ## TODO
57
-
58
- - [ ] HMR with Vite in lib mode
59
-
60
72
  ## Credits
61
73
 
62
74
  - [Vite](https://vitejs.dev) by Evan You and all of its contributors.
package/dist/cli.js CHANGED
@@ -56,22 +56,22 @@ var name, version;
56
56
  var init_package = __esm({
57
57
  "package.json"() {
58
58
  name = "kirbyup";
59
- version = "0.9.2";
59
+ version = "0.10.0";
60
60
  }
61
61
  });
62
62
 
63
63
  // src/errors.ts
64
64
  function handleError(error) {
65
65
  if (error instanceof PrettyError) {
66
- console.error(import_chalk.default.red(error.message));
66
+ console.error(import_nanocolors.default.red(error.message));
67
67
  }
68
68
  process.exitCode = 1;
69
69
  }
70
- var import_chalk, PrettyError;
70
+ var import_nanocolors, PrettyError;
71
71
  var init_errors = __esm({
72
72
  "src/errors.ts"() {
73
73
  init_cjs_shims();
74
- import_chalk = __toModule(require("chalk"));
74
+ import_nanocolors = __toModule(require("nanocolors"));
75
75
  PrettyError = class extends Error {
76
76
  constructor(message) {
77
77
  super(message);
@@ -121,8 +121,8 @@ var init_utils = __esm({
121
121
  function log(message, type = "info") {
122
122
  var _a;
123
123
  const content = [
124
- import_chalk2.default.gray(`[${name}]`),
125
- import_chalk2.default[(_a = colorMap.get(type)) != null ? _a : "white"](message)
124
+ import_nanocolors2.default.gray(`[${name}]`),
125
+ import_nanocolors2.default[(_a = colorMap.get(type)) != null ? _a : "white"](message)
126
126
  ];
127
127
  if (type === "error") {
128
128
  console.error(...content);
@@ -130,11 +130,11 @@ function log(message, type = "info") {
130
130
  console.log(...content);
131
131
  }
132
132
  }
133
- var import_chalk2, colorMap;
133
+ var import_nanocolors2, colorMap;
134
134
  var init_log = __esm({
135
135
  "src/log.ts"() {
136
136
  init_cjs_shims();
137
- import_chalk2 = __toModule(require("chalk"));
137
+ import_nanocolors2 = __toModule(require("nanocolors"));
138
138
  init_package();
139
139
  colorMap = new Map([
140
140
  ["info", "yellow"],
@@ -153,23 +153,25 @@ __export(src_exports, {
153
153
  async function runViteBuild(options) {
154
154
  let result;
155
155
  const currentDir = process.cwd();
156
- const baseName = "index";
156
+ const isDev = !!options.watch;
157
157
  try {
158
158
  result = await (0, import_vite.build)({
159
159
  plugins: [(0, import_vite_plugin_vue2.createVuePlugin)()],
160
160
  build: {
161
161
  lib: {
162
162
  entry: (0, import_path.resolve)(currentDir, options.entry),
163
- formats: ["es"],
164
- fileName: () => `${baseName}.js`
163
+ formats: ["iife"],
164
+ name: "kirbyupExport",
165
+ fileName: () => "index.js"
165
166
  },
166
- minify: !options.watch,
167
+ sourcemap: isDev ? "inline" : false,
168
+ minify: !isDev,
167
169
  outDir: currentDir,
168
170
  emptyOutDir: false,
169
171
  rollupOptions: {
170
172
  external: ["vue"],
171
173
  output: {
172
- assetFileNames: `${baseName}.[ext]`,
174
+ assetFileNames: "index.[ext]",
173
175
  globals: {
174
176
  vue: "Vue"
175
177
  }
@@ -201,36 +203,36 @@ async function build(_options) {
201
203
  const { watch } = await import("chokidar");
202
204
  const ignored = [
203
205
  "**/{.git,node_modules}/**",
204
- "index.js"
206
+ "index.{css,js}"
205
207
  ];
206
208
  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;
207
- log(`Watching for changes in ${Array.isArray(watchPaths) ? watchPaths.map((v) => '"' + v + '"').join(" | ") : '"' + watchPaths + '"'}`);
209
+ log(`Watching for changes in ${Array.isArray(watchPaths) ? watchPaths.map((i) => `"${i}"`).join(" | ") : `"${watchPaths}"`}`);
208
210
  const watcher = watch(watchPaths, {
209
211
  ignoreInitial: true,
210
212
  ignorePermissionErrors: true,
211
213
  ignored
212
214
  });
213
215
  watcher.on("all", async (type, file) => {
214
- log(`${type} ${import_chalk3.default.gray(file)}`);
216
+ log(`${type} ${import_nanocolors3.default.gray(file)}`);
215
217
  debouncedBuild();
216
218
  });
217
219
  };
218
220
  await runViteBuild(options);
219
221
  startWatcher();
220
222
  }
221
- var import_path, import_fs, import_vite, import_vite_plugin_vue2, import_chalk3, normalizeOptions;
223
+ var import_path, import_fs, import_nanocolors3, import_vite, import_vite_plugin_vue2, normalizeOptions;
222
224
  var init_src = __esm({
223
225
  "src/index.ts"() {
224
226
  init_cjs_shims();
225
227
  import_path = __toModule(require("path"));
226
228
  import_fs = __toModule(require("fs"));
229
+ import_nanocolors3 = __toModule(require("nanocolors"));
227
230
  import_vite = __toModule(require("vite"));
228
231
  import_vite_plugin_vue2 = __toModule(require("vite-plugin-vue2"));
229
232
  init_errors();
230
233
  init_utils();
231
234
  init_log();
232
235
  init_package();
233
- import_chalk3 = __toModule(require("chalk"));
234
236
  normalizeOptions = async (options) => {
235
237
  if (!options.entry) {
236
238
  throw new PrettyError(`No input file, try "${name} <path/to/file.js>"`);
package/dist/index.js CHANGED
@@ -37,11 +37,12 @@ var importMetaUrlShim = typeof document === "undefined" ? new (require("url")).U
37
37
  // src/index.ts
38
38
  var import_path = __toModule(require("path"));
39
39
  var import_fs = __toModule(require("fs"));
40
+ var import_nanocolors3 = __toModule(require("nanocolors"));
40
41
  var import_vite = __toModule(require("vite"));
41
42
  var import_vite_plugin_vue2 = __toModule(require("vite-plugin-vue2"));
42
43
 
43
44
  // src/errors.ts
44
- var import_chalk = __toModule(require("chalk"));
45
+ var import_nanocolors = __toModule(require("nanocolors"));
45
46
  var PrettyError = class extends Error {
46
47
  constructor(message) {
47
48
  super(message);
@@ -55,7 +56,7 @@ var PrettyError = class extends Error {
55
56
  };
56
57
  function handleError(error) {
57
58
  if (error instanceof PrettyError) {
58
- console.error(import_chalk.default.red(error.message));
59
+ console.error(import_nanocolors.default.red(error.message));
59
60
  }
60
61
  process.exitCode = 1;
61
62
  }
@@ -87,11 +88,11 @@ function debouncePromise(fn, delay, onError) {
87
88
  }
88
89
 
89
90
  // src/log.ts
90
- var import_chalk2 = __toModule(require("chalk"));
91
+ var import_nanocolors2 = __toModule(require("nanocolors"));
91
92
 
92
93
  // package.json
93
94
  var name = "kirbyup";
94
- var version = "0.9.2";
95
+ var version = "0.10.0";
95
96
 
96
97
  // src/log.ts
97
98
  var colorMap = new Map([
@@ -102,8 +103,8 @@ var colorMap = new Map([
102
103
  function log(message, type = "info") {
103
104
  var _a;
104
105
  const content = [
105
- import_chalk2.default.gray(`[${name}]`),
106
- import_chalk2.default[(_a = colorMap.get(type)) != null ? _a : "white"](message)
106
+ import_nanocolors2.default.gray(`[${name}]`),
107
+ import_nanocolors2.default[(_a = colorMap.get(type)) != null ? _a : "white"](message)
107
108
  ];
108
109
  if (type === "error") {
109
110
  console.error(...content);
@@ -113,27 +114,28 @@ function log(message, type = "info") {
113
114
  }
114
115
 
115
116
  // src/index.ts
116
- var import_chalk3 = __toModule(require("chalk"));
117
117
  async function runViteBuild(options) {
118
118
  let result;
119
119
  const currentDir = process.cwd();
120
- const baseName = "index";
120
+ const isDev = !!options.watch;
121
121
  try {
122
122
  result = await (0, import_vite.build)({
123
123
  plugins: [(0, import_vite_plugin_vue2.createVuePlugin)()],
124
124
  build: {
125
125
  lib: {
126
126
  entry: (0, import_path.resolve)(currentDir, options.entry),
127
- formats: ["es"],
128
- fileName: () => `${baseName}.js`
127
+ formats: ["iife"],
128
+ name: "kirbyupExport",
129
+ fileName: () => "index.js"
129
130
  },
130
- minify: !options.watch,
131
+ sourcemap: isDev ? "inline" : false,
132
+ minify: !isDev,
131
133
  outDir: currentDir,
132
134
  emptyOutDir: false,
133
135
  rollupOptions: {
134
136
  external: ["vue"],
135
137
  output: {
136
- assetFileNames: `${baseName}.[ext]`,
138
+ assetFileNames: "index.[ext]",
137
139
  globals: {
138
140
  vue: "Vue"
139
141
  }
@@ -174,17 +176,17 @@ async function build(_options) {
174
176
  const { watch } = await import("chokidar");
175
177
  const ignored = [
176
178
  "**/{.git,node_modules}/**",
177
- "index.js"
179
+ "index.{css,js}"
178
180
  ];
179
181
  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;
180
- log(`Watching for changes in ${Array.isArray(watchPaths) ? watchPaths.map((v) => '"' + v + '"').join(" | ") : '"' + watchPaths + '"'}`);
182
+ log(`Watching for changes in ${Array.isArray(watchPaths) ? watchPaths.map((i) => `"${i}"`).join(" | ") : `"${watchPaths}"`}`);
181
183
  const watcher = watch(watchPaths, {
182
184
  ignoreInitial: true,
183
185
  ignorePermissionErrors: true,
184
186
  ignored
185
187
  });
186
188
  watcher.on("all", async (type, file) => {
187
- log(`${type} ${import_chalk3.default.gray(file)}`);
189
+ log(`${type} ${import_nanocolors3.default.gray(file)}`);
188
190
  debouncedBuild();
189
191
  });
190
192
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kirbyup",
3
- "version": "0.9.2",
3
+ "version": "0.10.0",
4
4
  "description": "Zero-config bundler for Kirby Panel plugins",
5
5
  "files": [
6
6
  "dist"
@@ -35,12 +35,13 @@
35
35
  "build": "tsup src/cli.ts src/index.ts --target node14 --clean --dts",
36
36
  "test": "jest",
37
37
  "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
38
- "release": "node scripts/release.js"
38
+ "release": "node scripts/release.js",
39
+ "prepare": "husky install"
39
40
  },
40
41
  "dependencies": {
41
42
  "cac": "^6.7.3",
42
- "chalk": "^4.1.2",
43
43
  "chokidar": "^3.5.2",
44
+ "nanocolors": "^0.2.10",
44
45
  "sass": "^1.42.1",
45
46
  "vite": "^2.5.10",
46
47
  "vite-plugin-vue2": "^1.8.2",
@@ -49,17 +50,18 @@
49
50
  "devDependencies": {
50
51
  "@types/fs-extra": "^9.0.13",
51
52
  "@types/jest": "^27.0.2",
52
- "@types/node": "^16.9.6",
53
+ "@types/node": "^16.10.1",
53
54
  "conventional-changelog-cli": "^2.1.1",
54
- "enquirer": "^2.3.6",
55
55
  "execa": "^5.1.1",
56
56
  "fast-glob": "^3.2.7",
57
57
  "fs-extra": "^10.0.0",
58
- "jest": "^27.2.1",
58
+ "jest": "^27.2.2",
59
59
  "prettier": "^2.4.1",
60
+ "prompts": "^2.4.1",
60
61
  "ts-essentials": "^8.1.0",
61
62
  "ts-jest": "^27.0.5",
62
- "tsup": "^5.1.0",
63
- "typescript": "^4.4.3"
63
+ "tsup": "^5.2.1",
64
+ "typescript": "^4.4.3",
65
+ "husky": "^7.0.2"
64
66
  }
65
67
  }