zotero-plugin-scaffold 0.3.5 → 0.4.1

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.B4EUQxfu.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.Be6yYGJh.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.5";
34
+ const version = "0.4.1";
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
@@ -45,12 +45,9 @@ declare class Logger {
45
45
  success(content: unknown, options?: LoggerOptions): void;
46
46
  fail(content: unknown, options?: LoggerOptions): void;
47
47
  ready(content: string): void;
48
+ log(content: unknown, options?: LoggerOptions): void;
48
49
  clear(): void;
49
50
  newLine(): void;
50
- /**
51
- * Direct passthrough to console.log
52
- */
53
- log(content: unknown): void;
54
51
  }
55
52
 
56
53
  interface Manifest {
@@ -715,13 +712,19 @@ interface TestConfig {
715
712
  */
716
713
  abortOnFail: boolean;
717
714
  /**
718
- * Exit Zotero when the test is finished.
715
+ * Watch source and test file changes,
716
+ * and re-run tests when files change.
719
717
  *
720
- * 测试完成后退出 Zotero
718
+ * If this set to false, Zotero will exit
719
+ * when test complated.
721
720
  *
722
- * @default false
721
+ * 当源码或测试代码变更时自动重新运行测试。
722
+ *
723
+ * 若此选项设置为 false,Zotero 将在测试结束后立即退出。
724
+ *
725
+ * @default true (false in ci)
723
726
  */
724
- exitOnFinish: boolean;
727
+ watch: boolean;
725
728
  /**
726
729
  * Run Zotero in deadless mode.
727
730
  *
@@ -733,7 +736,7 @@ interface TestConfig {
733
736
  * - 仅支持 Linux
734
737
  * - 在 CI 模式下,默认为 true
735
738
  *
736
- * @default false
739
+ * @default false (true in ci)
737
740
  */
738
741
  headless: boolean;
739
742
  /**
@@ -761,17 +764,11 @@ interface TestConfig {
761
764
  * ```
762
765
  */
763
766
  waitForPlugin: string;
764
- /**
765
- * @todo not
766
- */
767
- watch: boolean;
768
767
  hooks: Partial<TestHooks>;
769
768
  }
770
769
  interface TestHooks {
771
770
  "test:init": (ctx: Context) => void | Promise<void>;
772
771
  "test:prebuild": (ctx: Context) => void | Promise<void>;
773
- "test:listen": (ctx: Context) => void | Promise<void>;
774
- "test:copyAssets": (ctx: Context) => void | Promise<void>;
775
772
  "test:bundleTests": (ctx: Context) => void | Promise<void>;
776
773
  "test:run": (ctx: Context) => void | Promise<void>;
777
774
  "test:exit": (ctx: Context) => void;
@@ -880,7 +877,6 @@ declare class Serve extends Base {
880
877
  * watch source dir and build when file changed
881
878
  */
882
879
  watch(): Promise<void>;
883
- onChange(path: string): Promise<void>;
884
880
  reload(): Promise<void>;
885
881
  exit: () => never;
886
882
  private onZoteroExit;
@@ -891,35 +887,16 @@ declare class Serve extends Base {
891
887
 
892
888
  declare class Test extends Base {
893
889
  private builder;
894
- private runner?;
895
- private communicator;
890
+ private zotero?;
891
+ private reporter;
892
+ private testBundler?;
896
893
  constructor(ctx: Context);
897
894
  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
895
  watch(): Promise<void>;
912
- onCodeChanged(_path: string): Promise<void>;
913
- startZoteroHeadless(): Promise<void>;
914
896
  startZotero(): Promise<void>;
897
+ private onZoteroExit;
915
898
  private exit;
916
899
  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
900
  private get prefs();
924
901
  }
925
902
 
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.B4EUQxfu.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.Be6yYGJh.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';