zotero-plugin-scaffold 0.1.8-beta.2 → 0.2.0-beta.4
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/chunks/github.mjs
CHANGED
|
@@ -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.
|
|
8
|
+
import { a as Base } from '../shared/zotero-plugin-scaffold.619ed490.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.
|
|
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.619ed490.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.
|
|
30
|
+
const version = "0.2.0-beta.4";
|
|
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 10000
|
|
637
|
+
*/
|
|
638
|
+
timeout: number;
|
|
639
|
+
};
|
|
630
640
|
/**
|
|
631
641
|
* Port for the test server.
|
|
632
642
|
*
|
|
@@ -651,6 +661,19 @@ interface TestConfig {
|
|
|
651
661
|
* @default false
|
|
652
662
|
*/
|
|
653
663
|
exitOnFinish: boolean;
|
|
664
|
+
/**
|
|
665
|
+
* Run Zotero in deadless mode.
|
|
666
|
+
*
|
|
667
|
+
* - Supported for Linux only.
|
|
668
|
+
* - Default to true when in CI environments.
|
|
669
|
+
*
|
|
670
|
+
* 使用无头模式运行 Zotero。
|
|
671
|
+
*
|
|
672
|
+
* - 仅支持 Linux
|
|
673
|
+
* - 在 CI 模式下,默认为 true
|
|
674
|
+
*
|
|
675
|
+
* @default false
|
|
676
|
+
*/
|
|
654
677
|
headless: boolean;
|
|
655
678
|
/**
|
|
656
679
|
* The delay time before running the test. Make sure the plugin is fully loaded before running the test.
|
|
@@ -821,7 +844,7 @@ declare class Test extends Base {
|
|
|
821
844
|
bundleTests(): Promise<void>;
|
|
822
845
|
startTestServer(): Promise<void>;
|
|
823
846
|
handleTestUpdate(body: {
|
|
824
|
-
type: "start" | "suite" | "suite end" | "pending" | "pass" | "fail" | "end";
|
|
847
|
+
type: "start" | "suite" | "suite end" | "pending" | "pass" | "fail" | "end" | "debug";
|
|
825
848
|
data?: {
|
|
826
849
|
title: string;
|
|
827
850
|
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 10000
|
|
637
|
+
*/
|
|
638
|
+
timeout: number;
|
|
639
|
+
};
|
|
630
640
|
/**
|
|
631
641
|
* Port for the test server.
|
|
632
642
|
*
|
|
@@ -651,6 +661,19 @@ interface TestConfig {
|
|
|
651
661
|
* @default false
|
|
652
662
|
*/
|
|
653
663
|
exitOnFinish: boolean;
|
|
664
|
+
/**
|
|
665
|
+
* Run Zotero in deadless mode.
|
|
666
|
+
*
|
|
667
|
+
* - Supported for Linux only.
|
|
668
|
+
* - Default to true when in CI environments.
|
|
669
|
+
*
|
|
670
|
+
* 使用无头模式运行 Zotero。
|
|
671
|
+
*
|
|
672
|
+
* - 仅支持 Linux
|
|
673
|
+
* - 在 CI 模式下,默认为 true
|
|
674
|
+
*
|
|
675
|
+
* @default false
|
|
676
|
+
*/
|
|
654
677
|
headless: boolean;
|
|
655
678
|
/**
|
|
656
679
|
* The delay time before running the test. Make sure the plugin is fully loaded before running the test.
|
|
@@ -821,7 +844,7 @@ declare class Test extends Base {
|
|
|
821
844
|
bundleTests(): Promise<void>;
|
|
822
845
|
startTestServer(): Promise<void>;
|
|
823
846
|
handleTestUpdate(body: {
|
|
824
|
-
type: "start" | "suite" | "suite end" | "pending" | "pass" | "fail" | "end";
|
|
847
|
+
type: "start" | "suite" | "suite end" | "pending" | "pass" | "fail" | "end" | "debug";
|
|
825
848
|
data?: {
|
|
826
849
|
title: string;
|
|
827
850
|
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.
|
|
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.619ed490.mjs';
|
|
2
2
|
import 'node:path';
|
|
3
3
|
import 'c12';
|
|
4
4
|
import 'es-toolkit';
|
package/dist/shared/{zotero-plugin-scaffold.ac50adf5.mjs → zotero-plugin-scaffold.619ed490.mjs}
RENAMED
|
@@ -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
|
});
|
|
@@ -1625,7 +1634,7 @@ mocha.run();
|
|
|
1625
1634
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1626
1635
|
res.end(JSON.stringify({ message: "Results received successfully" }));
|
|
1627
1636
|
} catch (error) {
|
|
1628
|
-
|
|
1637
|
+
this.logger.error("Error parsing JSON:", error);
|
|
1629
1638
|
res.writeHead(400, { "Content-Type": "application/json" });
|
|
1630
1639
|
res.end(JSON.stringify({ error: "Invalid JSON" }));
|
|
1631
1640
|
}
|
|
@@ -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();
|
|
@@ -1671,46 +1686,37 @@ mocha.run();
|
|
|
1671
1686
|
process.env.ZOTERO_PLUGIN_ZOTERO_BIN_PATH = `${cwd()}/Zotero_linux-x86_64/zotero`;
|
|
1672
1687
|
}
|
|
1673
1688
|
async installXvfb() {
|
|
1689
|
+
if (!isLinux) {
|
|
1690
|
+
this.logger.error("Unsupported platform. Please install Xvfb manually.");
|
|
1691
|
+
process.exit(1);
|
|
1692
|
+
}
|
|
1674
1693
|
try {
|
|
1675
1694
|
execSync("which xvfb", { stdio: "ignore" });
|
|
1676
1695
|
} catch {
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
throw new Error("Unsupported Linux distribution.");
|
|
1688
|
-
}
|
|
1689
|
-
this.logger.debug("Xvfb installation completed.");
|
|
1690
|
-
} catch (error) {
|
|
1691
|
-
console.error("Failed to install Xvfb:", error);
|
|
1692
|
-
process.exit(1);
|
|
1693
|
-
}
|
|
1694
|
-
} else if (isMacOS) {
|
|
1695
|
-
this.logger.debug("Detected macOS. Installing XQuartz...");
|
|
1696
|
-
try {
|
|
1697
|
-
execSync("brew install xquartz", { stdio: "inherit" });
|
|
1698
|
-
this.logger.debug("XQuartz installation completed.");
|
|
1699
|
-
} catch (error) {
|
|
1700
|
-
console.error("Failed to install XQuartz:", error);
|
|
1701
|
-
process.exit(1);
|
|
1696
|
+
try {
|
|
1697
|
+
const osId = execSync("cat /etc/os-release | grep '^ID='").toString();
|
|
1698
|
+
if (osId.includes("ubuntu") || osId.includes("debian")) {
|
|
1699
|
+
this.logger.debug("Detected Ubuntu/Debian. Installing Xvfb...");
|
|
1700
|
+
execSync("sudo apt-get update && sudo apt-get install -y xvfb", { stdio: "pipe" });
|
|
1701
|
+
} else if (osId.includes("centos") || osId.includes("rhel")) {
|
|
1702
|
+
this.logger.debug("Detected CentOS/RHEL. Installing Xvfb...");
|
|
1703
|
+
execSync("sudo yum install -y xorg-x11-server-Xvfb", { stdio: "pipe" });
|
|
1704
|
+
} else {
|
|
1705
|
+
throw new Error("Unsupported Linux distribution.");
|
|
1702
1706
|
}
|
|
1703
|
-
|
|
1704
|
-
|
|
1707
|
+
this.logger.debug("Xvfb installation completed.");
|
|
1708
|
+
} catch (error) {
|
|
1709
|
+
this.logger.error("Failed to install Xvfb:", error);
|
|
1705
1710
|
process.exit(1);
|
|
1706
1711
|
}
|
|
1707
1712
|
}
|
|
1708
1713
|
}
|
|
1709
1714
|
async installZoteroLinux() {
|
|
1710
1715
|
try {
|
|
1711
|
-
execSync("wget -O zotero.tar.bz2 'https://www.zotero.org/download/client/dl?platform=linux-x86_64&channel=beta'");
|
|
1712
|
-
execSync("tar -xvf zotero.tar.bz2");
|
|
1713
|
-
} catch {
|
|
1716
|
+
execSync("wget -O zotero.tar.bz2 'https://www.zotero.org/download/client/dl?platform=linux-x86_64&channel=beta'", { stdio: "pipe" });
|
|
1717
|
+
execSync("tar -xvf zotero.tar.bz2", { stdio: "pipe" });
|
|
1718
|
+
} catch (e) {
|
|
1719
|
+
this.logger.error(e);
|
|
1714
1720
|
throw new Error("Zotero extracted failed");
|
|
1715
1721
|
}
|
|
1716
1722
|
}
|
|
@@ -1737,6 +1743,7 @@ mocha.run();
|
|
|
1737
1743
|
process.exit(0);
|
|
1738
1744
|
} else {
|
|
1739
1745
|
this.logger.error("Test run failed");
|
|
1746
|
+
this._process?.kill();
|
|
1740
1747
|
process.exit(status);
|
|
1741
1748
|
}
|
|
1742
1749
|
}
|