zotero-plugin-scaffold 0.0.21 → 0.0.23

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
@@ -24,7 +24,7 @@ import 'chokidar';
24
24
  import 'process';
25
25
 
26
26
  const name = "zotero-plugin-scaffold";
27
- const version = "0.0.21";
27
+ const version = "0.0.23";
28
28
  const description = "A scaffold for Zotero plugin development.";
29
29
  const scripts = {
30
30
  dev: "unbuild --stub",
package/dist/index.d.mts CHANGED
@@ -667,15 +667,17 @@ declare class Serve extends Base {
667
667
  /**
668
668
  * Starts zotero with plugins pre-installed as proxy file
669
669
  */
670
- startZotero(): Promise<child_process.ChildProcessWithoutNullStreams>;
670
+ startZoteroByProxyFile(): Promise<child_process.ChildProcessWithoutNullStreams>;
671
671
  /**
672
672
  * start zotero with plugin installed and reload when dist changed
673
673
  */
674
- startZoteroWebExt(): Promise<any>;
674
+ startZoteroByWebExt(): Promise<any>;
675
675
  /**
676
676
  * Preparing the development environment
677
677
  *
678
- * When asProxy=true, generate a proxy file to replace prefs.
678
+ * When asProxy=true, generate a proxy file and replace prefs.
679
+ *
680
+ * @see https://www.zotero.org/support/dev/client_coding/plugin_development#setting_up_a_plugin_development_environment
679
681
  */
680
682
  prepareDevEnv(): void;
681
683
  reload(): void;
package/dist/index.d.ts CHANGED
@@ -667,15 +667,17 @@ declare class Serve extends Base {
667
667
  /**
668
668
  * Starts zotero with plugins pre-installed as proxy file
669
669
  */
670
- startZotero(): Promise<child_process.ChildProcessWithoutNullStreams>;
670
+ startZoteroByProxyFile(): Promise<child_process.ChildProcessWithoutNullStreams>;
671
671
  /**
672
672
  * start zotero with plugin installed and reload when dist changed
673
673
  */
674
- startZoteroWebExt(): Promise<any>;
674
+ startZoteroByWebExt(): Promise<any>;
675
675
  /**
676
676
  * Preparing the development environment
677
677
  *
678
- * When asProxy=true, generate a proxy file to replace prefs.
678
+ * When asProxy=true, generate a proxy file and replace prefs.
679
+ *
680
+ * @see https://www.zotero.org/support/dev/client_coding/plugin_development#setting_up_a_plugin_development_environment
679
681
  */
680
682
  prepareDevEnv(): void;
681
683
  reload(): void;
package/dist/index.mjs CHANGED
@@ -174,7 +174,6 @@ const defaultConfig = {
174
174
  },
175
175
  server: {
176
176
  startArgs: [
177
- "--no-remote",
178
177
  "--start-debugger-server",
179
178
  "--jsdebugger",
180
179
  "--debugger",
@@ -495,6 +494,9 @@ class Release extends Base {
495
494
  __publicField$1(this, "client");
496
495
  this.isCI = isCI;
497
496
  this.client = this.getClient();
497
+ if (this.isCI) {
498
+ this.logger.level = 4;
499
+ }
498
500
  }
499
501
  /**
500
502
  * Runs release
@@ -511,7 +513,9 @@ class Release extends Base {
511
513
  if (glob.globSync(`${this.dist}/*.xpi`).length == 0) {
512
514
  throw new Error("No xpi file found, are you sure you have run build?");
513
515
  }
516
+ this.logger.info("Uploading XPI...");
514
517
  await this.uploadXPI();
518
+ this.logger.info("Uploading update manifest...");
515
519
  await this.uploadUpdateJSON();
516
520
  }
517
521
  this.logger.success(
@@ -541,21 +545,32 @@ class Release extends Base {
541
545
  });
542
546
  if (!release)
543
547
  throw new Error("Create release failed!");
544
- this.uploadAsset(release.id, path.join(this.dist, `${this.xpiName}.xpi`));
548
+ this.logger.debug("Uploading xpi asset...");
549
+ await this.uploadAsset(
550
+ release.id,
551
+ path.join(this.dist, `${this.xpiName}.xpi`)
552
+ );
545
553
  }
546
554
  async getReleaseByTag(tag) {
547
555
  return await this.client.rest.repos.getReleaseByTag({
548
556
  owner: this.owner,
549
557
  repo: this.repo,
550
558
  tag
559
+ }).catch((e) => {
560
+ this.logger.log(`Release with tag ${tag} not found.`);
561
+ return void 0;
551
562
  }).then((res) => {
552
- if (res.status == 200) {
563
+ if (res && res.status == 200) {
553
564
  return res.data;
554
565
  }
555
566
  });
556
567
  }
557
568
  async creatRelease(options) {
558
- return await this.client.rest.repos.createRelease(options).then((res) => {
569
+ this.logger.debug("Creating release...", options);
570
+ return await this.client.rest.repos.createRelease(options).catch((e) => {
571
+ this.logger.error(e);
572
+ throw new Error("Create release failed.");
573
+ }).then((res) => {
559
574
  if (res.status == 201) {
560
575
  return res.data;
561
576
  }
@@ -581,7 +596,8 @@ class Release extends Base {
581
596
  const release = await this.getReleaseByTag("release") ?? await this.creatRelease({
582
597
  owner: this.owner,
583
598
  repo: this.repo,
584
- tag_name: "release"
599
+ tag_name: "release",
600
+ make_latest: "false"
585
601
  });
586
602
  if (!release)
587
603
  throw new Error("Get or create 'release' failed.");
@@ -620,8 +636,8 @@ class Release extends Base {
620
636
  conventionalChangelog({ releaseCount: 2 }, { version: this.version }).on("data", (chunk) => {
621
637
  changelog += chunk.toString();
622
638
  }).on("end", () => {
623
- this.logger.debug("changelog:", changelog);
624
- resolve(changelog);
639
+ this.logger.debug("changelog:", changelog.trim());
640
+ resolve(changelog.trim());
625
641
  }).on("error", (err) => {
626
642
  reject(err);
627
643
  });
@@ -717,10 +733,10 @@ class Serve extends Base {
717
733
  await this.builder.run();
718
734
  await this.ctx.hooks.callHook("serve:prebuild", this.ctx);
719
735
  if (this.ctx.server.asProxy) {
720
- this.startZotero();
736
+ this.startZoteroByProxyFile();
721
737
  } else {
722
738
  console.log("");
723
- await this.startZoteroWebExt();
739
+ await this.startZoteroByWebExt();
724
740
  }
725
741
  await this.watch();
726
742
  }
@@ -770,16 +786,11 @@ ${path2} changed`);
770
786
  /**
771
787
  * Starts zotero with plugins pre-installed as proxy file
772
788
  */
773
- async startZotero() {
774
- if (!fs.existsSync(this.zoteroBinPath)) {
775
- throw new Error("Zotero binary does not exist.");
776
- }
777
- if (!fs.existsSync(this.profilePath)) {
778
- throw new Error("The given Zotero profile does not exist.");
779
- }
789
+ async startZoteroByProxyFile() {
780
790
  this.prepareDevEnv();
781
791
  const zoteroProcess = spawn(this.zoteroBinPath, [
782
- "--no-remote",
792
+ // Do not disable remote, or the debug bridge command will not run.
793
+ // "--no-remote",
783
794
  "--start-debugger-server",
784
795
  "--jsdebugger",
785
796
  "--debugger",
@@ -802,7 +813,7 @@ ${path2} changed`);
802
813
  /**
803
814
  * start zotero with plugin installed and reload when dist changed
804
815
  */
805
- async startZoteroWebExt() {
816
+ async startZoteroByWebExt() {
806
817
  return await webext.cmd.run(
807
818
  {
808
819
  firefox: this.zoteroBinPath,
@@ -827,7 +838,9 @@ ${path2} changed`);
827
838
  /**
828
839
  * Preparing the development environment
829
840
  *
830
- * When asProxy=true, generate a proxy file to replace prefs.
841
+ * When asProxy=true, generate a proxy file and replace prefs.
842
+ *
843
+ * @see https://www.zotero.org/support/dev/client_coding/plugin_development#setting_up_a_plugin_development_environment
831
844
  */
832
845
  prepareDevEnv() {
833
846
  const addonProxyFilePath = path.join(
@@ -848,7 +861,8 @@ ${path2} changed`);
848
861
  `extensions/${this.id}.xpi`
849
862
  );
850
863
  if (fs.existsSync(addonXpiFilePath)) {
851
- fs.rmSync(addonXpiFilePath);
864
+ fs.removeSync(addonXpiFilePath);
865
+ this.logger.debug(`XPI file found, removed.`);
852
866
  }
853
867
  const prefsPath = path.join(this.profilePath, "prefs.js");
854
868
  if (fs.existsSync(prefsPath)) {
@@ -866,6 +880,19 @@ ${path2} changed`);
866
880
  fs.writeFileSync(prefsPath, updatedPrefs, "utf-8");
867
881
  this.logger.debug("The <profile>/prefs.js has been modified.");
868
882
  }
883
+ const addonInfoFilePath = path.join(this.profilePath, "extensions.json");
884
+ if (fs.existsSync(addonInfoFilePath)) {
885
+ const content = fs.readJSONSync(addonInfoFilePath);
886
+ content.addons = content.addons.map((addon) => {
887
+ if (addon.id === this.id && addon.active === false) {
888
+ addon.active = true;
889
+ addon.userDisabled = false;
890
+ this.logger.debug(`Active plugin ${this.id} in extensions.json.`);
891
+ }
892
+ return addon;
893
+ });
894
+ fs.outputJSONSync(addonInfoFilePath, content);
895
+ }
869
896
  }
870
897
  reload() {
871
898
  this.logger.debug("Reloading...");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zotero-plugin-scaffold",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "description": "A scaffold for Zotero plugin development.",
5
5
  "type": "module",
6
6
  "exports": {