zotero-plugin-scaffold 0.1.8-beta.2 → 0.1.8-beta.3

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.
@@ -5,7 +5,7 @@ import { globbySync } from 'globby';
5
5
  import mime from 'mime';
6
6
  import { Octokit } from 'octokit';
7
7
  import { isCI } from 'std-env';
8
- import { a as Base } from '../shared/zotero-plugin-scaffold.ac50adf5.mjs';
8
+ import { a as Base } from '../shared/zotero-plugin-scaffold.815a2d51.mjs';
9
9
  import 'c12';
10
10
  import 'es-toolkit';
11
11
  import 'hookable';
package/dist/cli.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  import process, { exit, env } from 'node:process';
3
3
  import { Command } from '@commander-js/extra-typings';
4
4
  import updateNotifier from 'update-notifier';
5
- import { L as Log, C as Config, B as Build, S as Serve, T as Test, R as Release } from './shared/zotero-plugin-scaffold.ac50adf5.mjs';
5
+ import { L as Log, C as Config, B as Build, S as Serve, T as Test, R as Release } from './shared/zotero-plugin-scaffold.815a2d51.mjs';
6
6
  import 'node:path';
7
7
  import 'c12';
8
8
  import 'es-toolkit';
@@ -27,7 +27,7 @@ import 'xvfb-ts';
27
27
 
28
28
  const name = "zotero-plugin-scaffold";
29
29
  const type = "module";
30
- const version = "0.1.8-beta.2";
30
+ const version = "0.1.8-beta.3";
31
31
  const packageManager = "pnpm@9.14.4";
32
32
  const description = "A scaffold for Zotero plugin development.";
33
33
  const author = "northword";
package/dist/index.d.mts CHANGED
@@ -627,6 +627,16 @@ interface TestConfig {
627
627
  * 这些首选项将在测试开始前设置。
628
628
  */
629
629
  prefs: Record<string, string | boolean | number>;
630
+ mocha: {
631
+ /**
632
+ * The timeout of the test.
633
+ *
634
+ * 测试的超时时间。
635
+ *
636
+ * @default 5000
637
+ */
638
+ timeout: number;
639
+ };
630
640
  /**
631
641
  * Port for the test server.
632
642
  *
@@ -821,7 +831,7 @@ declare class Test extends Base {
821
831
  bundleTests(): Promise<void>;
822
832
  startTestServer(): Promise<void>;
823
833
  handleTestUpdate(body: {
824
- type: "start" | "suite" | "suite end" | "pending" | "pass" | "fail" | "end";
834
+ type: "start" | "suite" | "suite end" | "pending" | "pass" | "fail" | "end" | "debug";
825
835
  data?: {
826
836
  title: string;
827
837
  str: string;
package/dist/index.d.ts CHANGED
@@ -627,6 +627,16 @@ interface TestConfig {
627
627
  * 这些首选项将在测试开始前设置。
628
628
  */
629
629
  prefs: Record<string, string | boolean | number>;
630
+ mocha: {
631
+ /**
632
+ * The timeout of the test.
633
+ *
634
+ * 测试的超时时间。
635
+ *
636
+ * @default 5000
637
+ */
638
+ timeout: number;
639
+ };
630
640
  /**
631
641
  * Port for the test server.
632
642
  *
@@ -821,7 +831,7 @@ declare class Test extends Base {
821
831
  bundleTests(): Promise<void>;
822
832
  startTestServer(): Promise<void>;
823
833
  handleTestUpdate(body: {
824
- type: "start" | "suite" | "suite end" | "pending" | "pass" | "fail" | "end";
834
+ type: "start" | "suite" | "suite end" | "pending" | "pass" | "fail" | "end" | "debug";
825
835
  data?: {
826
836
  title: string;
827
837
  str: string;
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.ac50adf5.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.815a2d51.mjs';
2
2
  import 'node:path';
3
3
  import 'c12';
4
4
  import 'es-toolkit';
@@ -311,6 +311,9 @@ const defaultConfig = {
311
311
  test: {
312
312
  entries: "test/",
313
313
  prefs: {},
314
+ mocha: {
315
+ timeout: 1e4
316
+ },
314
317
  port: 9876,
315
318
  abortOnFail: false,
316
319
  exitOnFinish: false,
@@ -1457,11 +1460,36 @@ function waitUtilAsync(condition, interval = 100, timeout = 1e4) {
1457
1460
  return 0;
1458
1461
  });
1459
1462
  let testCode = `
1460
- mocha.setup({ ui: "bdd", reporter: Reporter });
1463
+ mocha.setup({ ui: "bdd", reporter: Reporter, timeout: ${this.ctx.test.mocha.timeout} || 10000, });
1461
1464
 
1462
1465
  window.expect = chai.expect;
1463
1466
  window.assert = chai.assert;
1464
1467
 
1468
+ async function send(data) {
1469
+ console.log("Sending data to server", data);
1470
+ const req = await Zotero.HTTP.request(
1471
+ "POST",
1472
+ "http://localhost:${this.ctx.test.port || 9876}/update",
1473
+ {
1474
+ body: JSON.stringify(data),
1475
+ }
1476
+ );
1477
+
1478
+ if (req.status !== 200) {
1479
+ dump("Error sending data to server" + req.responseText);
1480
+ return null;
1481
+ } else {
1482
+ const result = JSON.parse(req.responseText);
1483
+ return result;
1484
+ }
1485
+ }
1486
+
1487
+ window.debug = function (...data) {
1488
+ const str = data.join("\\n");
1489
+ Zotero.debug(str);
1490
+ send({ type: "debug", data: { str } });
1491
+ };
1492
+
1465
1493
  // Inherit the default test settings from Zotero
1466
1494
  function Reporter(runner) {
1467
1495
  var indents = 0,
@@ -1478,25 +1506,6 @@ function Reporter(runner) {
1478
1506
  document.querySelector("#mocha").innerText += str;
1479
1507
  }
1480
1508
 
1481
- async function send(data) {
1482
- console.log("Sending data to server", data);
1483
- const req = await Zotero.HTTP.request(
1484
- "POST",
1485
- "http://localhost:${this.ctx.test.port || 9876}/update",
1486
- {
1487
- body: JSON.stringify(data),
1488
- }
1489
- );
1490
-
1491
- if (req.status !== 200) {
1492
- dump("Error sending data to server" + req.responseText);
1493
- return null;
1494
- } else {
1495
- const result = JSON.parse(req.responseText);
1496
- return result;
1497
- }
1498
- }
1499
-
1500
1509
  runner.on("start", async function () {
1501
1510
  await send({ type: "start" });
1502
1511
  });
@@ -1641,6 +1650,12 @@ mocha.run();
1641
1650
  });
1642
1651
  }
1643
1652
  async handleTestUpdate(body) {
1653
+ if (body.type === "debug" && body.data?.str) {
1654
+ for (const line of body.data?.str.split("\n")) {
1655
+ this.logger.log(line);
1656
+ this.logger.newLine();
1657
+ }
1658
+ }
1644
1659
  const str = body.data?.str.replaceAll("\n", "");
1645
1660
  if (body.type === "start") {
1646
1661
  this.logger.newLine();
@@ -1737,6 +1752,7 @@ mocha.run();
1737
1752
  process.exit(0);
1738
1753
  } else {
1739
1754
  this.logger.error("Test run failed");
1755
+ this._process?.kill();
1740
1756
  process.exit(status);
1741
1757
  }
1742
1758
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zotero-plugin-scaffold",
3
3
  "type": "module",
4
- "version": "0.1.8-beta.2",
4
+ "version": "0.1.8-beta.3",
5
5
  "description": "A scaffold for Zotero plugin development.",
6
6
  "author": "northword",
7
7
  "license": "AGPL-3.0-or-later",