zotero-plugin-scaffold 0.0.20 → 0.0.22
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 +1 -1
- package/dist/index.d.mts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.mjs +36 -79
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -173,7 +173,13 @@ const defaultConfig = {
|
|
|
173
173
|
hooks: {}
|
|
174
174
|
},
|
|
175
175
|
server: {
|
|
176
|
-
startArgs: [
|
|
176
|
+
startArgs: [
|
|
177
|
+
"--no-remote",
|
|
178
|
+
"--start-debugger-server",
|
|
179
|
+
"--jsdebugger",
|
|
180
|
+
"--debugger",
|
|
181
|
+
"--purgecaches"
|
|
182
|
+
],
|
|
177
183
|
asProxy: false,
|
|
178
184
|
hooks: {}
|
|
179
185
|
},
|
|
@@ -489,6 +495,9 @@ class Release extends Base {
|
|
|
489
495
|
__publicField$1(this, "client");
|
|
490
496
|
this.isCI = isCI;
|
|
491
497
|
this.client = this.getClient();
|
|
498
|
+
if (this.isCI) {
|
|
499
|
+
this.logger.level = 4;
|
|
500
|
+
}
|
|
492
501
|
}
|
|
493
502
|
/**
|
|
494
503
|
* Runs release
|
|
@@ -505,7 +514,9 @@ class Release extends Base {
|
|
|
505
514
|
if (glob.globSync(`${this.dist}/*.xpi`).length == 0) {
|
|
506
515
|
throw new Error("No xpi file found, are you sure you have run build?");
|
|
507
516
|
}
|
|
517
|
+
this.logger.info("Uploading XPI...");
|
|
508
518
|
await this.uploadXPI();
|
|
519
|
+
this.logger.info("Uploading update manifest...");
|
|
509
520
|
await this.uploadUpdateJSON();
|
|
510
521
|
}
|
|
511
522
|
this.logger.success(
|
|
@@ -535,21 +546,32 @@ class Release extends Base {
|
|
|
535
546
|
});
|
|
536
547
|
if (!release)
|
|
537
548
|
throw new Error("Create release failed!");
|
|
538
|
-
this.
|
|
549
|
+
this.logger.debug("Uploading xpi asset...");
|
|
550
|
+
await this.uploadAsset(
|
|
551
|
+
release.id,
|
|
552
|
+
path.join(this.dist, `${this.xpiName}.xpi`)
|
|
553
|
+
);
|
|
539
554
|
}
|
|
540
555
|
async getReleaseByTag(tag) {
|
|
541
556
|
return await this.client.rest.repos.getReleaseByTag({
|
|
542
557
|
owner: this.owner,
|
|
543
558
|
repo: this.repo,
|
|
544
559
|
tag
|
|
560
|
+
}).catch((e) => {
|
|
561
|
+
this.logger.log(`Release with tag ${tag} not found.`);
|
|
562
|
+
return void 0;
|
|
545
563
|
}).then((res) => {
|
|
546
|
-
if (res.status == 200) {
|
|
564
|
+
if (res && res.status == 200) {
|
|
547
565
|
return res.data;
|
|
548
566
|
}
|
|
549
567
|
});
|
|
550
568
|
}
|
|
551
569
|
async creatRelease(options) {
|
|
552
|
-
|
|
570
|
+
this.logger.debug("Creating release...", options);
|
|
571
|
+
return await this.client.rest.repos.createRelease(options).catch((e) => {
|
|
572
|
+
this.logger.error(e);
|
|
573
|
+
throw new Error("Create release failed.");
|
|
574
|
+
}).then((res) => {
|
|
553
575
|
if (res.status == 201) {
|
|
554
576
|
return res.data;
|
|
555
577
|
}
|
|
@@ -575,7 +597,8 @@ class Release extends Base {
|
|
|
575
597
|
const release = await this.getReleaseByTag("release") ?? await this.creatRelease({
|
|
576
598
|
owner: this.owner,
|
|
577
599
|
repo: this.repo,
|
|
578
|
-
tag_name: "release"
|
|
600
|
+
tag_name: "release",
|
|
601
|
+
make_latest: "false"
|
|
579
602
|
});
|
|
580
603
|
if (!release)
|
|
581
604
|
throw new Error("Get or create 'release' failed.");
|
|
@@ -614,8 +637,8 @@ class Release extends Base {
|
|
|
614
637
|
conventionalChangelog({ releaseCount: 2 }, { version: this.version }).on("data", (chunk) => {
|
|
615
638
|
changelog += chunk.toString();
|
|
616
639
|
}).on("end", () => {
|
|
617
|
-
this.logger.debug("changelog:", changelog);
|
|
618
|
-
resolve(changelog);
|
|
640
|
+
this.logger.debug("changelog:", changelog.trim());
|
|
641
|
+
resolve(changelog.trim());
|
|
619
642
|
}).on("error", (err) => {
|
|
620
643
|
reject(err);
|
|
621
644
|
});
|
|
@@ -765,7 +788,6 @@ ${path2} changed`);
|
|
|
765
788
|
* Starts zotero with plugins pre-installed as proxy file
|
|
766
789
|
*/
|
|
767
790
|
async startZotero() {
|
|
768
|
-
let isZoteroReady = false;
|
|
769
791
|
if (!fs.existsSync(this.zoteroBinPath)) {
|
|
770
792
|
throw new Error("Zotero binary does not exist.");
|
|
771
793
|
}
|
|
@@ -774,19 +796,15 @@ ${path2} changed`);
|
|
|
774
796
|
}
|
|
775
797
|
this.prepareDevEnv();
|
|
776
798
|
const zoteroProcess = spawn(this.zoteroBinPath, [
|
|
799
|
+
"--no-remote",
|
|
800
|
+
"--start-debugger-server",
|
|
801
|
+
"--jsdebugger",
|
|
777
802
|
"--debugger",
|
|
778
803
|
"--purgecaches",
|
|
779
804
|
"-profile",
|
|
780
805
|
this.profilePath
|
|
781
806
|
]);
|
|
782
807
|
zoteroProcess.stdout?.on("data", (data) => {
|
|
783
|
-
if (!isZoteroReady && data.toString().includes(`Plugin ${this.id} startup`)) {
|
|
784
|
-
this.logger.log(data.toString());
|
|
785
|
-
isZoteroReady = true;
|
|
786
|
-
setTimeout(() => {
|
|
787
|
-
this.openDevTool();
|
|
788
|
-
}, 1e3);
|
|
789
|
-
}
|
|
790
808
|
});
|
|
791
809
|
zoteroProcess.on("close", (code) => {
|
|
792
810
|
this.logger.info(`Zotero terminated with code ${code}.`);
|
|
@@ -810,8 +828,9 @@ ${path2} changed`);
|
|
|
810
828
|
keepProfileChanges: true,
|
|
811
829
|
args: this.ctx.server.startArgs,
|
|
812
830
|
pref: { "extensions.experiments.enabled": true },
|
|
813
|
-
|
|
814
|
-
|
|
831
|
+
// Use Zotero's devtools instead
|
|
832
|
+
browserConsole: false,
|
|
833
|
+
devtools: false,
|
|
815
834
|
noInput: true
|
|
816
835
|
},
|
|
817
836
|
{
|
|
@@ -890,68 +909,6 @@ ${path2} changed`);
|
|
|
890
909
|
const command = `${startZoteroCmd} -url "${url}"`;
|
|
891
910
|
execSync(command);
|
|
892
911
|
}
|
|
893
|
-
openDevTool() {
|
|
894
|
-
this.logger.debug("Open dev tools...");
|
|
895
|
-
const openDevToolScript = `
|
|
896
|
-
(async () => {
|
|
897
|
-
|
|
898
|
-
// const { BrowserToolboxLauncher } = ChromeUtils.import(
|
|
899
|
-
// "resource://devtools/client/framework/browser-toolbox/Launcher.jsm",
|
|
900
|
-
// );
|
|
901
|
-
// BrowserToolboxLauncher.init();
|
|
902
|
-
// TODO: Use the above code to open the devtool after https://github.com/zotero/zotero/pull/3387
|
|
903
|
-
|
|
904
|
-
Zotero.Prefs.set("devtools.debugger.remote-enabled", true, true);
|
|
905
|
-
Zotero.Prefs.set("devtools.debugger.remote-port", 6100, true);
|
|
906
|
-
Zotero.Prefs.set("devtools.debugger.prompt-connection", false, true);
|
|
907
|
-
Zotero.Prefs.set("devtools.debugger.chrome-debugging-websocket", false, true);
|
|
908
|
-
|
|
909
|
-
env =
|
|
910
|
-
Services.env ||
|
|
911
|
-
Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
|
|
912
|
-
|
|
913
|
-
env.set("MOZ_BROWSER_TOOLBOX_PORT", 6100);
|
|
914
|
-
Zotero.openInViewer(
|
|
915
|
-
"chrome://devtools/content/framework/browser-toolbox/window.html",
|
|
916
|
-
{
|
|
917
|
-
onLoad: (doc) => {
|
|
918
|
-
doc.querySelector("#status-message-container").style.visibility =
|
|
919
|
-
"collapse";
|
|
920
|
-
let toolboxBody;
|
|
921
|
-
waitUntil(
|
|
922
|
-
() => {
|
|
923
|
-
toolboxBody = doc
|
|
924
|
-
.querySelector(".devtools-toolbox-browsertoolbox-iframe")
|
|
925
|
-
?.contentDocument?.querySelector(".theme-body");
|
|
926
|
-
return toolboxBody;
|
|
927
|
-
},
|
|
928
|
-
() => {
|
|
929
|
-
toolboxBody.style = "pointer-events: all !important";
|
|
930
|
-
}
|
|
931
|
-
);
|
|
932
|
-
},
|
|
933
|
-
}
|
|
934
|
-
);
|
|
935
|
-
|
|
936
|
-
function waitUntil(condition, callback, interval = 100, timeout = 10000) {
|
|
937
|
-
const start = Date.now();
|
|
938
|
-
const intervalId = setInterval(() => {
|
|
939
|
-
if (condition()) {
|
|
940
|
-
clearInterval(intervalId);
|
|
941
|
-
callback();
|
|
942
|
-
} else if (Date.now() - start > timeout) {
|
|
943
|
-
clearInterval(intervalId);
|
|
944
|
-
}
|
|
945
|
-
}, interval);
|
|
946
|
-
}
|
|
947
|
-
})()`;
|
|
948
|
-
const url = `zotero://ztoolkit-debug/?run=${encodeURIComponent(
|
|
949
|
-
openDevToolScript
|
|
950
|
-
)}`;
|
|
951
|
-
const startZoteroCmd = `"${this.zoteroBinPath}" --debugger --purgecaches -profile "${this.profilePath}"`;
|
|
952
|
-
const command = `${startZoteroCmd} -url "${url}"`;
|
|
953
|
-
execSync(command);
|
|
954
|
-
}
|
|
955
912
|
exit() {
|
|
956
913
|
console.log("");
|
|
957
914
|
this.logger.info("Server shutdown by user request.");
|