zotero-plugin-scaffold 0.4.0 → 0.4.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/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import process from 'node:process';
2
2
  import { Command } from 'commander';
3
- import { l as logger, E as ExitSignals, C as Config, B as Build, S as Serve, T as Test, R as Release } from './shared/zotero-plugin-scaffold.CLDX-OU6.mjs';
3
+ import { l as logger, E as ExitSignals, C as Config, B as Build, S as Serve, T as Test, R as Release } from './shared/zotero-plugin-scaffold.Be6yYGJh.mjs';
4
4
  import { readFile } from 'node:fs/promises';
5
5
  import { pathExists } from 'fs-extra';
6
6
  import tinyUpdateNotifier from 'tiny-update-notifier';
@@ -31,7 +31,7 @@ import 'xvfb-ts';
31
31
  import 'node:http';
32
32
 
33
33
  const name = "zotero-plugin-scaffold";
34
- const version = "0.4.0";
34
+ const version = "0.4.1";
35
35
  const pkg = {
36
36
  name: name,
37
37
  version: version};
package/dist/index.d.mts CHANGED
@@ -45,12 +45,9 @@ declare class Logger {
45
45
  success(content: unknown, options?: LoggerOptions): void;
46
46
  fail(content: unknown, options?: LoggerOptions): void;
47
47
  ready(content: string): void;
48
+ log(content: unknown, options?: LoggerOptions): void;
48
49
  clear(): void;
49
50
  newLine(): void;
50
- /**
51
- * Direct passthrough to console.log
52
- */
53
- log(content: unknown): void;
54
51
  }
55
52
 
56
53
  interface Manifest {
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { B as Build, C as Config, R as Release, S as Serve, T as Test, d as defineConfig } from './shared/zotero-plugin-scaffold.CLDX-OU6.mjs';
1
+ export { B as Build, C as Config, R as Release, S as Serve, T as Test, d as defineConfig } from './shared/zotero-plugin-scaffold.Be6yYGJh.mjs';
2
2
  import 'c12';
3
3
  import 'es-toolkit';
4
4
  import 'fs-extra/esm';
@@ -49,7 +49,9 @@ const SYMBOLS = {
49
49
  TIP: styleText.blue("\u2192"),
50
50
  ERROR: styleText.bgRed(" ERROR "),
51
51
  WARN: styleText.bgYellow(" WARN "),
52
- DEBUG: styleText.grey("\u2699")};
52
+ DEBUG: styleText.grey("\u2699"),
53
+ NONE: ""
54
+ };
53
55
  const DEFAULT_OPTIONS = {
54
56
  SPACE: 0,
55
57
  NEW_LINE: false
@@ -84,6 +86,10 @@ const LOG_METHODS_CONFIG = {
84
86
  fail: {
85
87
  level: 4 /* ERROR */,
86
88
  symbol: SYMBOLS.FAIL
89
+ },
90
+ log: {
91
+ level: 2 /* INFO */,
92
+ symbol: SYMBOLS.NONE
87
93
  }
88
94
  };
89
95
  class Logger {
@@ -173,6 +179,9 @@ ${error.stack}`;
173
179
  ready(content) {
174
180
  this.logInternal(styleText.green(content), LOG_METHODS_CONFIG.success);
175
181
  }
182
+ log(content, options) {
183
+ this.logInternal(content, LOG_METHODS_CONFIG.log, options);
184
+ }
176
185
  clear() {
177
186
  const blank = process.stdout.rows > 2 ? "\n".repeat(process.stdout.rows - 2) : "";
178
187
  console.log(blank);
@@ -182,12 +191,6 @@ ${error.stack}`;
182
191
  newLine() {
183
192
  console.log();
184
193
  }
185
- /**
186
- * Direct passthrough to console.log
187
- */
188
- log(content) {
189
- console.log(content);
190
- }
191
194
  }
192
195
  const logger = Logger.getInstance();
193
196
 
@@ -1249,6 +1252,7 @@ function watch(source, event) {
1249
1252
  persistent: true
1250
1253
  });
1251
1254
  const onChangeDebounced = safeDebounce(event.onChange);
1255
+ const onAddDebounced = safeDebounce(event.onAdd);
1252
1256
  watcher.on("ready", async () => {
1253
1257
  if (event.onReady)
1254
1258
  await event.onReady();
@@ -1258,6 +1262,9 @@ function watch(source, event) {
1258
1262
  logger.clear();
1259
1263
  logger.info(`${path} changed`);
1260
1264
  await onChangeDebounced(path);
1265
+ }).on("add", async (path, stats) => {
1266
+ if (event.onAdd)
1267
+ await onAddDebounced(path, stats);
1261
1268
  }).on("error", async (err) => {
1262
1269
  if (event.onError)
1263
1270
  await event.onError(err);
@@ -2262,19 +2269,36 @@ class TestHttpReporter {
2262
2269
  logger.tip(data.title, logger_option);
2263
2270
  break;
2264
2271
  case "pass":
2265
- this.passed++;
2266
2272
  logger.success(`${data.title} ${styleText.gray(`${data.duration}ms`)}`, logger_option);
2267
2273
  break;
2268
- case "fail":
2269
- this.failed++;
2270
- logger.fail(styleText.red(`${data.title}, ${body.data?.error?.message}`), logger_option);
2274
+ case "fail": {
2275
+ let formatOutput = function(obj, indent) {
2276
+ const jsonStr = JSON.stringify(obj, null, 2);
2277
+ const lines = jsonStr.split("\n");
2278
+ const firstLine = lines[0];
2279
+ const restLines = lines.slice(1).map((line) => " ".repeat(indent) + line).join("\n");
2280
+ return `${firstLine}
2281
+ ${restLines}`;
2282
+ };
2283
+ logger.fail(styleText.red(`${data.title}, ${data?.error?.message}`), logger_option);
2284
+ let expected = data.error.expected;
2285
+ let received = data.error.actual;
2286
+ if (expected && typeof expected === "object")
2287
+ expected = formatOutput(expected, data.indents + 1);
2288
+ if (received && typeof received === "object")
2289
+ received = formatOutput(received, data.indents + 1);
2290
+ logger.log(`Expected: ${styleText.green(String(expected))}`, { space: data.indents + 0.5 });
2291
+ logger.log(`Received: ${styleText.red(String(received))}`, { space: data.indents + 0.5 });
2271
2292
  break;
2293
+ }
2272
2294
  case "pending":
2273
2295
  logger.info(`${data.title} pending`, logger_option);
2274
2296
  break;
2275
2297
  case "suite end":
2276
2298
  break;
2277
2299
  case "end":
2300
+ this.passed = data.passed;
2301
+ this.failed = data.failed;
2278
2302
  logger.newLine();
2279
2303
  if (this.failed === 0)
2280
2304
  logger.success(`Test run completed - ${this.passed} passed`);
@@ -2761,6 +2785,16 @@ class Test extends Base {
2761
2785
  await this.testBundler?.regenerate(path);
2762
2786
  await this.zotero?.reloadTemporaryPluginBySourceDir(TESTER_PLUGIN_DIR);
2763
2787
  }
2788
+ },
2789
+ onAdd: async (path) => {
2790
+ if (isSource(path)) {
2791
+ await this.builder.run();
2792
+ await this.testBundler?.regenerate(path);
2793
+ await this.zotero?.reloadAllPlugins();
2794
+ } else {
2795
+ await this.testBundler?.generate();
2796
+ await this.zotero?.reloadTemporaryPluginBySourceDir(TESTER_PLUGIN_DIR);
2797
+ }
2764
2798
  }
2765
2799
  }
2766
2800
  );
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zotero-plugin-scaffold",
3
3
  "type": "module",
4
- "version": "0.4.0",
4
+ "version": "0.4.1",
5
5
  "description": "A scaffold for Zotero plugin development.",
6
6
  "author": "northword",
7
7
  "license": "AGPL-3.0-or-later",