zotero-plugin-scaffold 0.3.4 → 0.4.0

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.DfqO5HjX.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.CLDX-OU6.mjs';
4
4
  import { readFile } from 'node:fs/promises';
5
5
  import { pathExists } from 'fs-extra';
6
6
  import tinyUpdateNotifier from 'tiny-update-notifier';
@@ -27,11 +27,11 @@ import 'node:net';
27
27
  import 'node:buffer';
28
28
  import 'node:domain';
29
29
  import 'node:events';
30
- import 'node:http';
31
30
  import 'xvfb-ts';
31
+ import 'node:http';
32
32
 
33
33
  const name = "zotero-plugin-scaffold";
34
- const version = "0.3.4";
34
+ const version = "0.4.0";
35
35
  const pkg = {
36
36
  name: name,
37
37
  version: version};
@@ -79,15 +79,14 @@ async function main() {
79
79
  cli.command("serve").alias("dev").description("Start development server").action((_options) => {
80
80
  Config.loadConfig({}).then((ctx) => new Serve(ctx).run());
81
81
  });
82
- cli.command("test").description("Run tests").option("--abort-on-fail", "Abort the test suite on first failure").option("--exit-on-finish", "Exit the test suite after all tests have run").action((options) => {
82
+ cli.command("test").description("Run tests").option("--abort-on-fail", "Abort the test suite on first failure").option("--exit-on-finish", "Exit the test suite after all tests have run").option("--no-watch", "Exit the test suite after all tests have run").action((options) => {
83
83
  process.env.NODE_ENV = "test";
84
- Config.loadConfig({}).then((ctx) => {
85
- if (options.abortOnFail) {
86
- ctx.test.abortOnFail = true;
87
- }
88
- if (options.exitOnFinish) {
89
- ctx.test.exitOnFinish = true;
84
+ Config.loadConfig({
85
+ test: {
86
+ abortOnFail: options.abortOnFail,
87
+ watch: !options.exitOnFinish && options.watch
90
88
  }
89
+ }).then((ctx) => {
91
90
  new Test(ctx).run();
92
91
  });
93
92
  });
package/dist/index.d.mts CHANGED
@@ -715,13 +715,19 @@ interface TestConfig {
715
715
  */
716
716
  abortOnFail: boolean;
717
717
  /**
718
- * Exit Zotero when the test is finished.
718
+ * Watch source and test file changes,
719
+ * and re-run tests when files change.
719
720
  *
720
- * 测试完成后退出 Zotero
721
+ * If this set to false, Zotero will exit
722
+ * when test complated.
721
723
  *
722
- * @default false
724
+ * 当源码或测试代码变更时自动重新运行测试。
725
+ *
726
+ * 若此选项设置为 false,Zotero 将在测试结束后立即退出。
727
+ *
728
+ * @default true (false in ci)
723
729
  */
724
- exitOnFinish: boolean;
730
+ watch: boolean;
725
731
  /**
726
732
  * Run Zotero in deadless mode.
727
733
  *
@@ -733,7 +739,7 @@ interface TestConfig {
733
739
  * - 仅支持 Linux
734
740
  * - 在 CI 模式下,默认为 true
735
741
  *
736
- * @default false
742
+ * @default false (true in ci)
737
743
  */
738
744
  headless: boolean;
739
745
  /**
@@ -761,17 +767,11 @@ interface TestConfig {
761
767
  * ```
762
768
  */
763
769
  waitForPlugin: string;
764
- /**
765
- * @todo not
766
- */
767
- watch: boolean;
768
770
  hooks: Partial<TestHooks>;
769
771
  }
770
772
  interface TestHooks {
771
773
  "test:init": (ctx: Context) => void | Promise<void>;
772
774
  "test:prebuild": (ctx: Context) => void | Promise<void>;
773
- "test:listen": (ctx: Context) => void | Promise<void>;
774
- "test:copyAssets": (ctx: Context) => void | Promise<void>;
775
775
  "test:bundleTests": (ctx: Context) => void | Promise<void>;
776
776
  "test:run": (ctx: Context) => void | Promise<void>;
777
777
  "test:exit": (ctx: Context) => void;
@@ -880,7 +880,6 @@ declare class Serve extends Base {
880
880
  * watch source dir and build when file changed
881
881
  */
882
882
  watch(): Promise<void>;
883
- onChange(path: string): Promise<void>;
884
883
  reload(): Promise<void>;
885
884
  exit: () => never;
886
885
  private onZoteroExit;
@@ -891,35 +890,16 @@ declare class Serve extends Base {
891
890
 
892
891
  declare class Test extends Base {
893
892
  private builder;
894
- private runner?;
895
- private communicator;
893
+ private zotero?;
894
+ private reporter;
895
+ private testBundler?;
896
896
  constructor(ctx: Context);
897
897
  run(): Promise<void>;
898
- createTestPlugin(): Promise<void>;
899
- copyTestLibraries(): Promise<void>;
900
- bundleTests(): Promise<void>;
901
- startHttpServer(): Promise<void>;
902
- onHttpDataUpdated(body: {
903
- type: "start" | "suite" | "suite end" | "pending" | "pass" | "fail" | "end" | "debug";
904
- data?: {
905
- title: string;
906
- str: string;
907
- duration?: number;
908
- stack?: string;
909
- };
910
- }): Promise<void>;
911
898
  watch(): Promise<void>;
912
- onCodeChanged(_path: string): Promise<void>;
913
- startZoteroHeadless(): Promise<void>;
914
899
  startZotero(): Promise<void>;
900
+ private onZoteroExit;
915
901
  private exit;
916
902
  private get zoteroBinPath();
917
- private get profilePath();
918
- private get dataDir();
919
- private get testPluginDir();
920
- private get cacheDir();
921
- private get testPluginRef();
922
- private get testPluginID();
923
903
  private get prefs();
924
904
  }
925
905
 
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.DfqO5HjX.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.CLDX-OU6.mjs';
2
2
  import 'c12';
3
3
  import 'es-toolkit';
4
4
  import 'fs-extra/esm';
@@ -24,5 +24,5 @@ import 'node:net';
24
24
  import 'node:buffer';
25
25
  import 'node:domain';
26
26
  import 'node:events';
27
- import 'node:http';
28
27
  import 'xvfb-ts';
28
+ import 'node:http';