zotero-plugin-scaffold 0.2.4 → 0.2.7

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 { E as ExitSignals, l as logger, C as Config, B as Build, S as Serve, T as Test, R as Release } from './shared/zotero-plugin-scaffold.D7j478bu.mjs';
3
+ import { E as ExitSignals, l as logger, C as Config, B as Build, S as Serve, T as Test, R as Release } from './shared/zotero-plugin-scaffold.BfbnPYjV.mjs';
4
4
  import { readFile, writeFile } from 'node:fs/promises';
5
5
  import { pathExists, ensureFile } from 'fs-extra';
6
6
  import tinyUpdateNotifier from 'tiny-update-notifier';
@@ -32,7 +32,7 @@ import 'xvfb-ts';
32
32
 
33
33
  const name = "zotero-plugin-scaffold";
34
34
  const type = "module";
35
- const version = "0.2.4";
35
+ const version = "0.2.7";
36
36
  const packageManager = "pnpm@10.2.0";
37
37
  const description = "A scaffold for Zotero plugin development.";
38
38
  const author = "northword";
package/dist/index.d.mts CHANGED
@@ -3,39 +3,54 @@ import * as esbuild from 'esbuild';
3
3
  import { BuildOptions } from 'esbuild';
4
4
 
5
5
  /**
6
- * Log level
6
+ * Log level enumeration
7
7
  */
8
8
  declare enum LOG_LEVEL {
9
- trace = 0,
10
- debug = 1,
11
- info = 2,
12
- warn = 3,
13
- error = 4
9
+ TRACE = 0,
10
+ DEBUG = 1,
11
+ INFO = 2,
12
+ WARN = 3,
13
+ ERROR = 4
14
14
  }
15
15
  type LogLevelType = keyof typeof LOG_LEVEL;
16
- /**
17
- * Logger
18
- */
19
- declare class Log {
16
+ interface LoggerOptions {
17
+ space?: number;
18
+ newLine?: boolean;
19
+ }
20
+ declare class Logger {
20
21
  private static instance;
21
- private logLevel;
22
- constructor(level?: LOG_LEVEL);
23
- static getInstance(): Log;
22
+ private currentLogLevel;
23
+ private constructor();
24
+ /**
25
+ * Determine the appropriate log level
26
+ */
27
+ private determineLogLevel;
28
+ static getInstance(): Logger;
24
29
  setLogLevel(level: LogLevelType): void;
25
- get level(): number;
26
- private formatArgs;
27
- private logArgs;
28
- log(...args: any[]): void;
29
- error(...args: any[]): void;
30
- warn(...args: any[]): void;
31
- tip(...args: any[]): void;
32
- info(...args: any[]): void;
33
- debug(...args: any[]): void;
34
- ready(...args: any[]): void;
35
- success(...args: any[]): void;
36
- fail(...args: any[]): void;
30
+ get level(): LOG_LEVEL;
31
+ /**
32
+ * Generic log formatting logic
33
+ */
34
+ private formatContent;
35
+ private formatError;
36
+ /**
37
+ * Core logging method
38
+ */
39
+ private logInternal;
40
+ error(content: unknown, options?: LoggerOptions): void;
41
+ warn(content: unknown, options?: LoggerOptions): void;
42
+ tip(content: unknown, options?: LoggerOptions): void;
43
+ info(content: unknown, options?: LoggerOptions): void;
44
+ debug(content: unknown, options?: LoggerOptions): void;
45
+ success(content: unknown, options?: LoggerOptions): void;
46
+ fail(content: unknown, options?: LoggerOptions): void;
47
+ ready(content: unknown): void;
37
48
  clear(): void;
38
49
  newLine(): void;
50
+ /**
51
+ * Direct passthrough to console.log
52
+ */
53
+ log(content: unknown): void;
39
54
  }
40
55
 
41
56
  interface Manifest {
@@ -771,7 +786,7 @@ interface Context extends Config$1 {
771
786
  pkgUser: any;
772
787
  version: string;
773
788
  hooks: Hookable<Hooks>;
774
- logger: InstanceType<typeof Log>;
789
+ logger: Logger;
775
790
  templateData: TemplateData;
776
791
  }
777
792
  interface TemplateData {
@@ -802,7 +817,7 @@ declare abstract class Base {
802
817
  ctx: Context;
803
818
  constructor(ctx: Context);
804
819
  abstract run(): any;
805
- get logger(): Log;
820
+ get logger(): Logger;
806
821
  }
807
822
 
808
823
  declare class Build extends Base {
package/dist/index.d.ts CHANGED
@@ -3,39 +3,54 @@ import * as esbuild from 'esbuild';
3
3
  import { BuildOptions } from 'esbuild';
4
4
 
5
5
  /**
6
- * Log level
6
+ * Log level enumeration
7
7
  */
8
8
  declare enum LOG_LEVEL {
9
- trace = 0,
10
- debug = 1,
11
- info = 2,
12
- warn = 3,
13
- error = 4
9
+ TRACE = 0,
10
+ DEBUG = 1,
11
+ INFO = 2,
12
+ WARN = 3,
13
+ ERROR = 4
14
14
  }
15
15
  type LogLevelType = keyof typeof LOG_LEVEL;
16
- /**
17
- * Logger
18
- */
19
- declare class Log {
16
+ interface LoggerOptions {
17
+ space?: number;
18
+ newLine?: boolean;
19
+ }
20
+ declare class Logger {
20
21
  private static instance;
21
- private logLevel;
22
- constructor(level?: LOG_LEVEL);
23
- static getInstance(): Log;
22
+ private currentLogLevel;
23
+ private constructor();
24
+ /**
25
+ * Determine the appropriate log level
26
+ */
27
+ private determineLogLevel;
28
+ static getInstance(): Logger;
24
29
  setLogLevel(level: LogLevelType): void;
25
- get level(): number;
26
- private formatArgs;
27
- private logArgs;
28
- log(...args: any[]): void;
29
- error(...args: any[]): void;
30
- warn(...args: any[]): void;
31
- tip(...args: any[]): void;
32
- info(...args: any[]): void;
33
- debug(...args: any[]): void;
34
- ready(...args: any[]): void;
35
- success(...args: any[]): void;
36
- fail(...args: any[]): void;
30
+ get level(): LOG_LEVEL;
31
+ /**
32
+ * Generic log formatting logic
33
+ */
34
+ private formatContent;
35
+ private formatError;
36
+ /**
37
+ * Core logging method
38
+ */
39
+ private logInternal;
40
+ error(content: unknown, options?: LoggerOptions): void;
41
+ warn(content: unknown, options?: LoggerOptions): void;
42
+ tip(content: unknown, options?: LoggerOptions): void;
43
+ info(content: unknown, options?: LoggerOptions): void;
44
+ debug(content: unknown, options?: LoggerOptions): void;
45
+ success(content: unknown, options?: LoggerOptions): void;
46
+ fail(content: unknown, options?: LoggerOptions): void;
47
+ ready(content: unknown): void;
37
48
  clear(): void;
38
49
  newLine(): void;
50
+ /**
51
+ * Direct passthrough to console.log
52
+ */
53
+ log(content: unknown): void;
39
54
  }
40
55
 
41
56
  interface Manifest {
@@ -771,7 +786,7 @@ interface Context extends Config$1 {
771
786
  pkgUser: any;
772
787
  version: string;
773
788
  hooks: Hookable<Hooks>;
774
- logger: InstanceType<typeof Log>;
789
+ logger: Logger;
775
790
  templateData: TemplateData;
776
791
  }
777
792
  interface TemplateData {
@@ -802,7 +817,7 @@ declare abstract class Base {
802
817
  ctx: Context;
803
818
  constructor(ctx: Context);
804
819
  abstract run(): any;
805
- get logger(): Log;
820
+ get logger(): Logger;
806
821
  }
807
822
 
808
823
  declare class Build extends Base {
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.D7j478bu.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.BfbnPYjV.mjs';
2
2
  import 'c12';
3
3
  import 'es-toolkit';
4
4
  import 'fs-extra/esm';
@@ -27,101 +27,170 @@ import http from 'node:http';
27
27
  import { Xvfb } from 'xvfb-ts';
28
28
 
29
29
  var LOG_LEVEL = /* @__PURE__ */ ((LOG_LEVEL2) => {
30
- LOG_LEVEL2[LOG_LEVEL2["trace"] = 0] = "trace";
31
- LOG_LEVEL2[LOG_LEVEL2["debug"] = 1] = "debug";
32
- LOG_LEVEL2[LOG_LEVEL2["info"] = 2] = "info";
33
- LOG_LEVEL2[LOG_LEVEL2["warn"] = 3] = "warn";
34
- LOG_LEVEL2[LOG_LEVEL2["error"] = 4] = "error";
30
+ LOG_LEVEL2[LOG_LEVEL2["TRACE"] = 0] = "TRACE";
31
+ LOG_LEVEL2[LOG_LEVEL2["DEBUG"] = 1] = "DEBUG";
32
+ LOG_LEVEL2[LOG_LEVEL2["INFO"] = 2] = "INFO";
33
+ LOG_LEVEL2[LOG_LEVEL2["WARN"] = 3] = "WARN";
34
+ LOG_LEVEL2[LOG_LEVEL2["ERROR"] = 4] = "ERROR";
35
35
  return LOG_LEVEL2;
36
36
  })(LOG_LEVEL || {});
37
- class Log {
37
+ const SYMBOLS = {
38
+ SUCCESS: chalk.green("\u2714"),
39
+ INFO: chalk.blue("\u2139"),
40
+ FAIL: chalk.red("\u2716"),
41
+ TIP: chalk.blue("\u2192"),
42
+ ERROR: chalk.bgRed(" ERROR "),
43
+ WARN: chalk.bgYellow(" WARN "),
44
+ DEBUG: chalk.grey("\u2699"),
45
+ NONE: ""
46
+ };
47
+ const DEFAULT_OPTIONS = {
48
+ SPACE: 0,
49
+ LEVEL: 2 /* INFO */,
50
+ SYMBOL: "",
51
+ NEW_LINE: false
52
+ };
53
+ const LOG_METHODS_CONFIG = {
54
+ error: {
55
+ level: 4 /* ERROR */,
56
+ symbol: SYMBOLS.ERROR,
57
+ wrapNewLine: true
58
+ },
59
+ warn: {
60
+ level: 3 /* WARN */,
61
+ symbol: SYMBOLS.WARN,
62
+ wrapNewLine: true
63
+ },
64
+ tip: {
65
+ level: 2 /* INFO */,
66
+ symbol: SYMBOLS.TIP
67
+ },
68
+ info: {
69
+ level: 2 /* INFO */,
70
+ symbol: SYMBOLS.INFO
71
+ },
72
+ debug: {
73
+ level: 1 /* DEBUG */,
74
+ symbol: SYMBOLS.DEBUG
75
+ },
76
+ success: {
77
+ level: 2 /* INFO */,
78
+ symbol: SYMBOLS.SUCCESS
79
+ },
80
+ ready: {
81
+ level: 2 /* INFO */,
82
+ symbol: SYMBOLS.SUCCESS,
83
+ wrapNewLine: true
84
+ },
85
+ fail: {
86
+ level: 4 /* ERROR */,
87
+ symbol: SYMBOLS.FAIL
88
+ }
89
+ };
90
+ class Logger {
38
91
  static instance;
39
- logLevel;
92
+ currentLogLevel;
40
93
  constructor(level) {
94
+ this.currentLogLevel = this.determineLogLevel(level);
95
+ }
96
+ /**
97
+ * Determine the appropriate log level
98
+ */
99
+ determineLogLevel(level) {
41
100
  if (isDebug)
42
- this.logLevel = 0 /* trace */;
43
- else if (process.env.ZOTERO_PLUGIN_LOG_LEVEL)
44
- this.logLevel = LOG_LEVEL[process.env.ZOTERO_PLUGIN_LOG_LEVEL];
45
- else if (level)
46
- this.logLevel = level;
47
- else
48
- this.logLevel = 2 /* info */;
101
+ return 0 /* TRACE */;
102
+ const envLevel = process.env.ZOTERO_PLUGIN_LOG_LEVEL;
103
+ return envLevel ? LOG_LEVEL[envLevel] : level ?? 2 /* INFO */;
49
104
  }
50
105
  static getInstance() {
51
- if (!Log.instance) {
52
- Log.instance = new Log();
106
+ if (!Logger.instance) {
107
+ Logger.instance = new Logger();
53
108
  }
54
- return Log.instance;
109
+ return Logger.instance;
55
110
  }
56
111
  setLogLevel(level) {
57
- this.logLevel = LOG_LEVEL[level];
112
+ this.currentLogLevel = LOG_LEVEL[level];
58
113
  }
59
114
  get level() {
60
- return this.logLevel;
61
- }
62
- formatArgs(arg) {
63
- if (typeof arg === "string")
64
- return arg;
65
- if (arg instanceof Error) {
66
- return `${chalk.red(arg.name)}: ${chalk.red(arg.message)}
67
- ${arg.stack}`;
68
- }
69
- if (typeof arg === "object" && arg !== null && isPlainObject(arg)) {
70
- return JSON.stringify(arg, null, 2);
71
- }
72
- return arg;
115
+ return this.currentLogLevel;
73
116
  }
74
- logArgs(level, ...args) {
75
- if (this.logLevel > level)
76
- return;
77
- args = args.map((arg) => this.formatArgs(arg));
78
- console.log(...args);
117
+ /**
118
+ * Generic log formatting logic
119
+ */
120
+ formatContent(content) {
121
+ if (typeof content === "string")
122
+ return content;
123
+ if (content instanceof Error)
124
+ return this.formatError(content);
125
+ if (isPlainObject(content))
126
+ return JSON.stringify(content, null, 2);
127
+ return String(content);
128
+ }
129
+ formatError(error) {
130
+ return `${chalk.red(error.name)}: ${chalk.red(error.message)}
131
+ ${error.stack}`;
79
132
  }
80
- log(...args) {
81
- console.log(...args);
133
+ /**
134
+ * Core logging method
135
+ */
136
+ logInternal(content, config, options = {}) {
137
+ if (this.currentLogLevel > config.level)
138
+ return;
139
+ const { space = DEFAULT_OPTIONS.SPACE, newLine = DEFAULT_OPTIONS.NEW_LINE } = options;
140
+ const formattedContent = this.formatContent(content);
141
+ const output = [
142
+ " ".repeat(space),
143
+ config.symbol,
144
+ formattedContent
145
+ ].join(" ");
146
+ if (config.wrapNewLine)
147
+ this.newLine();
148
+ console.log(output);
149
+ if (newLine || config.wrapNewLine)
150
+ this.newLine();
82
151
  }
83
- error(...args) {
84
- this.newLine();
85
- this.logArgs(4 /* error */, chalk.bgRed(" ERROR "), ...args);
86
- this.newLine();
152
+ // Public API methods
153
+ error(content, options) {
154
+ this.logInternal(content, LOG_METHODS_CONFIG.error, options);
87
155
  }
88
- warn(...args) {
89
- this.newLine();
90
- this.logArgs(3 /* warn */, chalk.bgYellow(" WARN "), ...args);
91
- this.newLine();
156
+ warn(content, options) {
157
+ this.logInternal(content, LOG_METHODS_CONFIG.warn, options);
92
158
  }
93
- tip(...args) {
94
- this.logArgs(2 /* info */, chalk.blue("\u2192"), ...args);
159
+ tip(content, options) {
160
+ this.logInternal(content, LOG_METHODS_CONFIG.tip, options);
95
161
  }
96
- info(...args) {
97
- this.logArgs(2 /* info */, chalk.blue("\u2139"), ...args);
162
+ info(content, options) {
163
+ this.logInternal(content, LOG_METHODS_CONFIG.info, options);
98
164
  }
99
- debug(...args) {
100
- this.logArgs(1 /* debug */, chalk.grey("\u2699"), ...args);
165
+ debug(content, options) {
166
+ this.logInternal(content, LOG_METHODS_CONFIG.debug, options);
101
167
  }
102
- ready(...args) {
103
- this.newLine();
104
- this.logArgs(2 /* info */, chalk.green("\u2714", ...args));
105
- this.newLine();
168
+ success(content, options) {
169
+ this.logInternal(content, LOG_METHODS_CONFIG.success, options);
106
170
  }
107
- success(...args) {
108
- this.logArgs(2 /* info */, chalk.green("\u2714"), ...args);
171
+ fail(content, options) {
172
+ this.logInternal(content, LOG_METHODS_CONFIG.fail, options);
109
173
  }
110
- fail(...args) {
111
- this.logArgs(4 /* error */, chalk.red("\u2716"), ...args);
174
+ ready(content) {
175
+ this.logInternal(chalk.green(content), LOG_METHODS_CONFIG.success);
112
176
  }
113
177
  clear() {
114
- const repeatCount = process.stdout.rows - 2;
115
- const blank = repeatCount > 0 ? "\n".repeat(repeatCount) : "";
178
+ const blank = process.stdout.rows > 2 ? "\n".repeat(process.stdout.rows - 2) : "";
116
179
  console.log(blank);
117
180
  readline.cursorTo(process.stdout, 0, 0);
118
181
  readline.clearScreenDown(process.stdout);
119
182
  }
120
183
  newLine() {
121
- console.log("");
184
+ console.log();
185
+ }
186
+ /**
187
+ * Direct passthrough to console.log
188
+ */
189
+ log(content) {
190
+ console.log(content);
122
191
  }
123
192
  }
124
- const logger = Log.getInstance();
193
+ const logger = Logger.getInstance();
125
194
 
126
195
  function defineConfig(userConfig) {
127
196
  return userConfig;
@@ -268,7 +337,7 @@ const defaultConfig = {
268
337
  watch: false,
269
338
  hooks: {}
270
339
  },
271
- logLevel: "info"
340
+ logLevel: "INFO"
272
341
  };
273
342
  const getDefaultConfig = () => defaultConfig;
274
343
 
@@ -528,7 +597,7 @@ class Build extends Base {
528
597
  define[key]
529
598
  ])
530
599
  );
531
- this.logger.debug("replace map: ", replaceMap);
600
+ this.logger.debug(`replace map: ${replaceMap}`);
532
601
  await replaceInFile({
533
602
  files: newPaths,
534
603
  from: Array.from(replaceMap.keys()),
@@ -560,7 +629,7 @@ class Build extends Base {
560
629
  }
561
630
  };
562
631
  const data = toMerged(userData, template);
563
- this.logger.debug("manifest: ", JSON.stringify(data, null, 2));
632
+ this.logger.debug(`manifest: ${JSON.stringify(data, null, 2)}`);
564
633
  outputJSON(`${dist}/addon/manifest.json`, data, { spaces: 2 });
565
634
  }
566
635
  async prepareLocaleFiles() {
@@ -570,7 +639,7 @@ class Build extends Base {
570
639
  const HTML_DATAI10NID_PATTERN = new RegExp(`(data-l10n-id)="((?!${namespace})\\S*)"`, "g");
571
640
  const localePaths = await glob(`${dist}/addon/locale/*`, { onlyDirectories: true });
572
641
  const localeNames = localePaths.map((locale) => basename(locale));
573
- this.logger.debug("Locale names:", localeNames);
642
+ this.logger.debug(`Locale names:", ${localeNames}`);
574
643
  const allMessages = /* @__PURE__ */ new Set();
575
644
  const messagesByLocale = /* @__PURE__ */ new Map();
576
645
  for (const localeName of localeNames) {
@@ -755,7 +824,7 @@ class Bump extends Base {
755
824
  this.ctx.version = result.newVersion;
756
825
  this.ctx.release.bumpp.tag = result.tag || this.ctx.release.bumpp.tag.toString().replace("%s", result.newVersion);
757
826
  this.ctx.release.bumpp.commit = result.commit || this.ctx.release.bumpp.commit.toString().replace("%s", result.newVersion);
758
- this.logger.debug("The release context after bump: ", this.ctx.release);
827
+ this.logger.debug(`The release context after bump: ", ${this.ctx.release}`);
759
828
  }
760
829
  /**
761
830
  * bumpp 显示进度的回调
@@ -868,7 +937,8 @@ class GitHub extends ReleaseBase {
868
937
  });
869
938
  }
870
939
  async createRelease(options) {
871
- this.logger.debug("Creating release...", options);
940
+ this.logger.debug("Creating release...");
941
+ this.logger.debug(options);
872
942
  return await this.client.rest.repos.createRelease(options).catch((e) => {
873
943
  this.logger.error(e);
874
944
  throw new Error("Create release failed.");
@@ -994,7 +1064,7 @@ class Release extends Base {
994
1064
  this.logger.warn(`The current release needs to run the build after bumping the version number, please configure the build script in 'config.release.bumpp.execute'${isBumpNeeded ? "" : " or run build before run release"}.`);
995
1065
  this.ctx.release.bumpp.execute ||= "npm run build";
996
1066
  }
997
- this.logger.debug("Release config: ", this.ctx.release);
1067
+ this.logger.debug(`Release config: ", ${this.ctx.release}`);
998
1068
  await this.ctx.hooks.callHook("release:init", this.ctx);
999
1069
  await new Bump(this.ctx).run();
1000
1070
  await this.ctx.hooks.callHook("release:push", this.ctx);
@@ -1437,7 +1507,7 @@ class RemoteFirefox {
1437
1507
  });
1438
1508
  return response;
1439
1509
  } catch (err) {
1440
- logger.debug(`Client responded to '${request}' request with error:`, err);
1510
+ logger.debug(`Client responded to '${request}' request with error: ${err}`);
1441
1511
  const message = requestErrorToMessage(err);
1442
1512
  throw new Error(`Remote Firefox: addonRequest() error: ${message}`);
1443
1513
  }
@@ -1454,7 +1524,7 @@ class RemoteFirefox {
1454
1524
  }
1455
1525
  return response.addonsActor;
1456
1526
  } catch (err) {
1457
- logger.debug("Falling back to listTabs because getRoot failed", err);
1527
+ logger.debug(`Falling back to listTabs because getRoot failed", ${err}`);
1458
1528
  }
1459
1529
  try {
1460
1530
  const response = await this.client.request("listTabs");
@@ -1470,7 +1540,7 @@ class RemoteFirefox {
1470
1540
  }
1471
1541
  return response.addonsActor;
1472
1542
  } catch (err) {
1473
- logger.debug("listTabs error", err);
1543
+ logger.debug(`listTabs error: ${err}`);
1474
1544
  const message = requestErrorToMessage(err);
1475
1545
  throw new Error(`Remote Firefox: listTabs() error: ${message}`);
1476
1546
  }
@@ -1646,7 +1716,7 @@ class ZoteroRunner {
1646
1716
  }
1647
1717
  const remotePort = await findFreeTcpPort();
1648
1718
  args.push("-start-debugger-server", String(remotePort));
1649
- logger.debug("Zotero start args: ", args);
1719
+ logger.debug(`Zotero start args: ${args}`);
1650
1720
  const env = {
1651
1721
  ...process.env,
1652
1722
  XPCOM_DEBUG_BREAK: "stack",
@@ -1655,7 +1725,7 @@ class ZoteroRunner {
1655
1725
  if (!await pathExists(this.options.binary.path))
1656
1726
  throw new Error("The Zotero binary not found.");
1657
1727
  this.zotero = spawn(this.options.binary.path, args, { env });
1658
- logger.debug("Zotero started, pid:", this.zotero.pid);
1728
+ logger.debug(`Zotero started, pid: ${this.zotero.pid}`);
1659
1729
  this.zotero.stdout?.on("data", (_data) => {
1660
1730
  });
1661
1731
  logger.debug("Connecting to the remote Firefox debugger...");
@@ -1871,7 +1941,8 @@ class Serve extends Base {
1871
1941
  this.logger.info(`${path} changed`);
1872
1942
  await onChangeDebounced(path);
1873
1943
  }).on("error", (err) => {
1874
- this.logger.error("Server start failed!", err);
1944
+ this.logger.fail("Server start failed!");
1945
+ this.logger.error(err);
1875
1946
  });
1876
1947
  }
1877
1948
  async onChange(path) {
@@ -1929,13 +2000,13 @@ function isPackageInstalled(packageName) {
1929
2000
  }
1930
2001
  }
1931
2002
  function installPackage(packageName) {
1932
- const debug = isDebug || logger.level <= LOG_LEVEL.debug;
2003
+ const debug = isDebug || logger.level <= LOG_LEVEL.DEBUG;
1933
2004
  try {
1934
2005
  logger.debug(`Installing ${packageName}...`);
1935
2006
  execSync(`sudo apt update && sudo apt install -y ${packageName}`, { stdio: debug ? "inherit" : "pipe" });
1936
2007
  logger.debug(`${packageName} installed successfully.`);
1937
2008
  } catch (error) {
1938
- logger.fail(`Failed to install ${packageName}.`, error);
2009
+ logger.fail(`Failed to install ${packageName}. ${error}`);
1939
2010
  throw error;
1940
2011
  }
1941
2012
  }
@@ -2387,7 +2458,7 @@ class Test extends Base {
2387
2458
  res.writeHead(200, { "Content-Type": "application/json" });
2388
2459
  res.end(JSON.stringify({ message: "Results received successfully" }));
2389
2460
  } catch (error) {
2390
- this.logger.error("Error parsing JSON:", error);
2461
+ this.logger.error(`Error parsing JSON:, ${error}`);
2391
2462
  res.writeHead(400, { "Content-Type": "application/json" });
2392
2463
  res.end(JSON.stringify({ error: "Invalid JSON" }));
2393
2464
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zotero-plugin-scaffold",
3
3
  "type": "module",
4
- "version": "0.2.4",
4
+ "version": "0.2.7",
5
5
  "description": "A scaffold for Zotero plugin development.",
6
6
  "author": "northword",
7
7
  "license": "AGPL-3.0-or-later",