zotero-plugin-scaffold 0.0.31 → 0.0.33

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/README.md CHANGED
@@ -108,7 +108,7 @@ ZOTERO_PLUGIN_PROFILE_PATH = /path/to/profile
108
108
  ```json
109
109
  {
110
110
  "scripts": {
111
- "start": "zotero-plugin server",
111
+ "start": "zotero-plugin serve",
112
112
  "build": "zotero-plugin build",
113
113
  "release": "zotero-plugin release"
114
114
  }
package/dist/cli.mjs CHANGED
@@ -1,41 +1,50 @@
1
1
  #!/usr/bin/env node
2
- import { Config, Build, Serve, Release } from './index.mjs';
2
+ import process from 'node:process';
3
3
  import { Command } from 'commander';
4
4
  import consola from 'consola';
5
5
  import updateNotifier from 'update-notifier';
6
- import 'bumpp';
7
- import 'chalk';
8
- import 'std-env';
6
+ import { Config, Build, Serve, Release } from './index.mjs';
7
+ import 'node:path';
9
8
  import 'c12';
10
9
  import 'fs-extra';
11
10
  import 'hookable';
12
- import 'path';
13
11
  import 'radash';
14
- import 'crypto';
12
+ import 'bumpp';
13
+ import 'chalk';
14
+ import 'std-env';
15
15
  import 'esbuild';
16
16
  import 'fast-glob';
17
17
  import 'replace-in-file';
18
18
  import 'web-ext';
19
+ import 'node:crypto';
19
20
  import 'conventional-changelog';
20
21
  import 'mime';
21
22
  import 'octokit';
22
- import 'child_process';
23
+ import 'node:child_process';
23
24
  import 'chokidar';
24
- import 'process';
25
25
 
26
26
  const name = "zotero-plugin-scaffold";
27
- const version = "0.0.31";
27
+ const type = "module";
28
+ const version = "0.0.33";
29
+ const packageManager = "pnpm@9.5.0";
28
30
  const description = "A scaffold for Zotero plugin development.";
29
- const scripts = {
30
- dev: "unbuild --stub",
31
- build: "tsc --noEmit && unbuild",
32
- lint: "eslint . & prettier --check .",
33
- "lint:fix": "eslint --fix . & prettier --write .",
34
- release: "bumpp --commit \"chore(release): publish v%s\"",
35
- "update:deps": "pnpx taze minor -w -f -l",
36
- test: "echo \"Error: no test specified\" && exit 1"
31
+ const author = "northword";
32
+ const license = "AGPL-3.0-or-later";
33
+ const homepage = "https://github.com/northword/zotero-plugin-scaffold#readme";
34
+ const repository = {
35
+ type: "git",
36
+ url: "https://github.com/northword/zotero-plugin-scaffold.git"
37
37
  };
38
- const type = "module";
38
+ const bugs = {
39
+ url: "https://github.com/northword/zotero-plugin-scaffold/issues"
40
+ };
41
+ const keywords = [
42
+ "zotero",
43
+ "plugin",
44
+ "developer",
45
+ "scaffold",
46
+ "web-ext"
47
+ ];
39
48
  const exports = {
40
49
  ".": {
41
50
  types: "./dist/index.d.ts",
@@ -51,23 +60,18 @@ const bin = {
51
60
  const files = [
52
61
  "dist"
53
62
  ];
54
- const keywords = [
55
- "zotero",
56
- "plugin",
57
- "developer",
58
- "scaffold",
59
- "web-ext"
60
- ];
61
- const author = "northword";
62
- const license = "AGPL-3.0-or-later";
63
- const repository = {
64
- type: "git",
65
- url: "https://github.com/northword/zotero-plugin-scaffold.git"
63
+ const engines = {
64
+ node: ">=18"
66
65
  };
67
- const bugs = {
68
- url: "https://github.com/northword/zotero-plugin-scaffold/issues"
66
+ const scripts = {
67
+ dev: "unbuild --stub",
68
+ build: "tsc --noEmit && unbuild",
69
+ lint: "eslint .",
70
+ "lint:fix": "eslint . --fix",
71
+ release: "bumpp --commit \"chore(release): publish v%s\"",
72
+ "update:deps": "pnpx taze minor -w -f -l",
73
+ test: "echo \"Error: no test specified\" && exit 1"
69
74
  };
70
- const homepage = "https://github.com/northword/zotero-plugin-scaffold#readme";
71
75
  const publishConfig = {
72
76
  access: "public",
73
77
  registry: "https://registry.npmjs.org"
@@ -76,41 +80,35 @@ const directories = {
76
80
  lib: "dist",
77
81
  doc: "docs"
78
82
  };
79
- const engines = {
80
- node: ">=18"
81
- };
82
- const packageManager = "pnpm@9.1.3";
83
83
  const dependencies = {
84
- "@inquirer/prompts": "5.0.4",
84
+ "@inquirer/prompts": "5.2.0",
85
85
  bumpp: "9.4.1",
86
- c12: "1.10.0",
86
+ c12: "1.11.1",
87
87
  chalk: "5.3.0",
88
88
  chokidar: "3.6.0",
89
89
  commander: "12.1.0",
90
90
  consola: "3.2.3",
91
91
  "conventional-changelog": "6.0.0",
92
- esbuild: "0.21.4",
92
+ esbuild: "0.23.0",
93
93
  "fast-glob": "3.3.2",
94
94
  "fs-extra": "11.2.0",
95
95
  hookable: "5.5.3",
96
- mime: "4.0.3",
96
+ mime: "4.0.4",
97
97
  octokit: "4.0.2",
98
98
  radash: "12.1.0",
99
- "replace-in-file": "7.2.0",
99
+ "replace-in-file": "8.1.0",
100
100
  "std-env": "3.7.0",
101
- "update-notifier": "7.0.0",
102
- "web-ext": "7.12.0"
101
+ "update-notifier": "7.1.0",
102
+ "web-ext": "8.2.0"
103
103
  };
104
104
  const devDependencies = {
105
- "@trivago/prettier-plugin-sort-imports": "4.3.0",
106
- "@types/conventional-changelog": "3.1.5",
105
+ "@antfu/eslint-config": "^2.23.0",
107
106
  "@types/fs-extra": "11.0.4",
108
- "@types/node": "20.12.12",
107
+ "@types/node": "20.14.11",
109
108
  "@types/update-notifier": "6.0.8",
110
- eslint: "9.3.0",
111
- prettier: "3.2.5",
112
- typescript: "5.4.5",
113
- "typescript-eslint": "8.0.0-alpha.20",
109
+ eslint: "9.7.0",
110
+ "eslint-plugin-format": "^0.1.2",
111
+ typescript: "5.5.3",
114
112
  unbuild: "2.0.0"
115
113
  };
116
114
  const pnpm = {
@@ -122,26 +120,26 @@ const pnpm = {
122
120
  };
123
121
  const pkg = {
124
122
  name: name,
123
+ type: type,
125
124
  version: version,
125
+ packageManager: packageManager,
126
126
  description: description,
127
- scripts: scripts,
128
- type: type,
127
+ author: author,
128
+ license: license,
129
+ homepage: homepage,
130
+ repository: repository,
131
+ bugs: bugs,
132
+ keywords: keywords,
129
133
  exports: exports,
130
134
  main: main$1,
131
135
  module: module,
132
136
  types: types,
133
137
  bin: bin,
134
138
  files: files,
135
- keywords: keywords,
136
- author: author,
137
- license: license,
138
- repository: repository,
139
- bugs: bugs,
140
- homepage: homepage,
139
+ engines: engines,
140
+ scripts: scripts,
141
141
  publishConfig: publishConfig,
142
142
  directories: directories,
143
- engines: engines,
144
- packageManager: packageManager,
145
143
  dependencies: dependencies,
146
144
  devDependencies: devDependencies,
147
145
  pnpm: pnpm
@@ -163,14 +161,14 @@ async function main() {
163
161
  });
164
162
  new Build(config).run();
165
163
  });
166
- cli.command("serve").description("Start development server.").action(async (options) => {
164
+ cli.command("serve").description("Start development server.").action(async (_options) => {
167
165
  const config = await Config.loadConfig({});
168
166
  new Serve(config).run();
169
167
  });
170
- cli.command("create").description("Create the plugin template.").action((options) => {
168
+ cli.command("create").description("Create the plugin template.").action((_options) => {
171
169
  consola.error("The create not yet implemented");
172
170
  });
173
- cli.command("release").description("Release.").action(async (options) => {
171
+ cli.command("release").description("Release.").action(async (_options) => {
174
172
  process.env.NODE_ENV = "production";
175
173
  const config = await Config.loadConfig({});
176
174
  new Release(config).run();
@@ -179,7 +177,7 @@ async function main() {
179
177
  cli.outputHelp();
180
178
  consola.error(`Unknown command name=${cmd}.`);
181
179
  });
182
- cli.parse(process.argv);
180
+ cli.parse();
183
181
  }
184
182
  main().catch((err) => {
185
183
  console.log("");
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
+ import { Hookable } from 'hookable';
1
2
  import { VersionBumpOptions } from 'bumpp';
2
3
  import * as esbuild from 'esbuild';
3
4
  import { BuildOptions } from 'esbuild';
4
- import { Hookable } from 'hookable';
5
5
  import { ConsolaInstance } from 'consola';
6
6
  import { Octokit } from 'octokit';
7
7
  import * as child_process from 'child_process';
@@ -353,10 +353,10 @@ interface Context extends Config$1 {
353
353
  * @param [userConfig]
354
354
  * @returns Config with userDefined.
355
355
  */
356
- declare const defineConfig: (userConfig: UserConfig) => UserConfig;
356
+ declare function defineConfig(userConfig: UserConfig): UserConfig;
357
357
  /**
358
358
  * Loads config
359
- * @param [override={}] Highest Priority Configuration.
359
+ * @param [overrides] Highest Priority Configuration.
360
360
  * @returns Config with userDefined and defaultConfig merged.
361
361
  */
362
362
  declare function loadConfig(overrides?: OverrideConfig): Promise<Context>;
@@ -439,14 +439,14 @@ declare class Release extends Base {
439
439
  tag_name: string;
440
440
  target_commitish: string;
441
441
  name: string | null;
442
- body?: string | null | undefined;
442
+ body?: string | null;
443
443
  draft: boolean;
444
444
  prerelease: boolean;
445
445
  created_at: string;
446
446
  published_at: string | null;
447
447
  author: {
448
- name?: string | null | undefined;
449
- email?: string | null | undefined;
448
+ name?: string | null;
449
+ email?: string | null;
450
450
  login: string;
451
451
  id: number;
452
452
  node_id: string;
@@ -465,7 +465,7 @@ declare class Release extends Base {
465
465
  received_events_url: string;
466
466
  type: string;
467
467
  site_admin: boolean;
468
- starred_at?: string | undefined;
468
+ starred_at?: string;
469
469
  };
470
470
  assets: {
471
471
  url: string;
@@ -481,8 +481,8 @@ declare class Release extends Base {
481
481
  created_at: string;
482
482
  updated_at: string;
483
483
  uploader: {
484
- name?: string | null | undefined;
485
- email?: string | null | undefined;
484
+ name?: string | null;
485
+ email?: string | null;
486
486
  login: string;
487
487
  id: number;
488
488
  node_id: string;
@@ -501,13 +501,13 @@ declare class Release extends Base {
501
501
  received_events_url: string;
502
502
  type: string;
503
503
  site_admin: boolean;
504
- starred_at?: string | undefined;
504
+ starred_at?: string;
505
505
  } | null;
506
506
  }[];
507
- body_html?: string | undefined;
508
- body_text?: string | undefined;
509
- mentions_count?: number | undefined;
510
- discussion_url?: string | undefined;
507
+ body_html?: string;
508
+ body_text?: string;
509
+ mentions_count?: number;
510
+ discussion_url?: string;
511
511
  reactions?: {
512
512
  url: string;
513
513
  total_count: number;
@@ -519,7 +519,7 @@ declare class Release extends Base {
519
519
  hooray: number;
520
520
  eyes: number;
521
521
  rocket: number;
522
- } | undefined;
522
+ };
523
523
  } | undefined>;
524
524
  createRelease(options: Parameters<Octokit["rest"]["repos"]["createRelease"]>[0]): Promise<{
525
525
  url: string;
@@ -533,14 +533,14 @@ declare class Release extends Base {
533
533
  tag_name: string;
534
534
  target_commitish: string;
535
535
  name: string | null;
536
- body?: string | null | undefined;
536
+ body?: string | null;
537
537
  draft: boolean;
538
538
  prerelease: boolean;
539
539
  created_at: string;
540
540
  published_at: string | null;
541
541
  author: {
542
- name?: string | null | undefined;
543
- email?: string | null | undefined;
542
+ name?: string | null;
543
+ email?: string | null;
544
544
  login: string;
545
545
  id: number;
546
546
  node_id: string;
@@ -559,7 +559,7 @@ declare class Release extends Base {
559
559
  received_events_url: string;
560
560
  type: string;
561
561
  site_admin: boolean;
562
- starred_at?: string | undefined;
562
+ starred_at?: string;
563
563
  };
564
564
  assets: {
565
565
  url: string;
@@ -575,8 +575,8 @@ declare class Release extends Base {
575
575
  created_at: string;
576
576
  updated_at: string;
577
577
  uploader: {
578
- name?: string | null | undefined;
579
- email?: string | null | undefined;
578
+ name?: string | null;
579
+ email?: string | null;
580
580
  login: string;
581
581
  id: number;
582
582
  node_id: string;
@@ -595,13 +595,13 @@ declare class Release extends Base {
595
595
  received_events_url: string;
596
596
  type: string;
597
597
  site_admin: boolean;
598
- starred_at?: string | undefined;
598
+ starred_at?: string;
599
599
  } | null;
600
600
  }[];
601
- body_html?: string | undefined;
602
- body_text?: string | undefined;
603
- mentions_count?: number | undefined;
604
- discussion_url?: string | undefined;
601
+ body_html?: string;
602
+ body_text?: string;
603
+ mentions_count?: number;
604
+ discussion_url?: string;
605
605
  reactions?: {
606
606
  url: string;
607
607
  total_count: number;
@@ -613,7 +613,7 @@ declare class Release extends Base {
613
613
  hooray: number;
614
614
  eyes: number;
615
615
  rocket: number;
616
- } | undefined;
616
+ };
617
617
  } | undefined>;
618
618
  uploadAsset(releaseID: number, asset: string): Promise<{
619
619
  url: string;
@@ -629,8 +629,8 @@ declare class Release extends Base {
629
629
  created_at: string;
630
630
  updated_at: string;
631
631
  uploader: {
632
- name?: string | null | undefined;
633
- email?: string | null | undefined;
632
+ name?: string | null;
633
+ email?: string | null;
634
634
  login: string;
635
635
  id: number;
636
636
  node_id: string;
@@ -649,7 +649,7 @@ declare class Release extends Base {
649
649
  received_events_url: string;
650
650
  type: string;
651
651
  site_admin: boolean;
652
- starred_at?: string | undefined;
652
+ starred_at?: string;
653
653
  } | null;
654
654
  }>;
655
655
  refreshUpdateManifest(): Promise<void>;
@@ -691,7 +691,7 @@ declare class Serve extends Base {
691
691
  }
692
692
 
693
693
  declare const Config: {
694
- defineConfig: (userConfig: UserConfig) => UserConfig;
694
+ defineConfig: typeof defineConfig;
695
695
  loadConfig: typeof loadConfig;
696
696
  };
697
697
 
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
+ import { Hookable } from 'hookable';
1
2
  import { VersionBumpOptions } from 'bumpp';
2
3
  import * as esbuild from 'esbuild';
3
4
  import { BuildOptions } from 'esbuild';
4
- import { Hookable } from 'hookable';
5
5
  import { ConsolaInstance } from 'consola';
6
6
  import { Octokit } from 'octokit';
7
7
  import * as child_process from 'child_process';
@@ -353,10 +353,10 @@ interface Context extends Config$1 {
353
353
  * @param [userConfig]
354
354
  * @returns Config with userDefined.
355
355
  */
356
- declare const defineConfig: (userConfig: UserConfig) => UserConfig;
356
+ declare function defineConfig(userConfig: UserConfig): UserConfig;
357
357
  /**
358
358
  * Loads config
359
- * @param [override={}] Highest Priority Configuration.
359
+ * @param [overrides] Highest Priority Configuration.
360
360
  * @returns Config with userDefined and defaultConfig merged.
361
361
  */
362
362
  declare function loadConfig(overrides?: OverrideConfig): Promise<Context>;
@@ -439,14 +439,14 @@ declare class Release extends Base {
439
439
  tag_name: string;
440
440
  target_commitish: string;
441
441
  name: string | null;
442
- body?: string | null | undefined;
442
+ body?: string | null;
443
443
  draft: boolean;
444
444
  prerelease: boolean;
445
445
  created_at: string;
446
446
  published_at: string | null;
447
447
  author: {
448
- name?: string | null | undefined;
449
- email?: string | null | undefined;
448
+ name?: string | null;
449
+ email?: string | null;
450
450
  login: string;
451
451
  id: number;
452
452
  node_id: string;
@@ -465,7 +465,7 @@ declare class Release extends Base {
465
465
  received_events_url: string;
466
466
  type: string;
467
467
  site_admin: boolean;
468
- starred_at?: string | undefined;
468
+ starred_at?: string;
469
469
  };
470
470
  assets: {
471
471
  url: string;
@@ -481,8 +481,8 @@ declare class Release extends Base {
481
481
  created_at: string;
482
482
  updated_at: string;
483
483
  uploader: {
484
- name?: string | null | undefined;
485
- email?: string | null | undefined;
484
+ name?: string | null;
485
+ email?: string | null;
486
486
  login: string;
487
487
  id: number;
488
488
  node_id: string;
@@ -501,13 +501,13 @@ declare class Release extends Base {
501
501
  received_events_url: string;
502
502
  type: string;
503
503
  site_admin: boolean;
504
- starred_at?: string | undefined;
504
+ starred_at?: string;
505
505
  } | null;
506
506
  }[];
507
- body_html?: string | undefined;
508
- body_text?: string | undefined;
509
- mentions_count?: number | undefined;
510
- discussion_url?: string | undefined;
507
+ body_html?: string;
508
+ body_text?: string;
509
+ mentions_count?: number;
510
+ discussion_url?: string;
511
511
  reactions?: {
512
512
  url: string;
513
513
  total_count: number;
@@ -519,7 +519,7 @@ declare class Release extends Base {
519
519
  hooray: number;
520
520
  eyes: number;
521
521
  rocket: number;
522
- } | undefined;
522
+ };
523
523
  } | undefined>;
524
524
  createRelease(options: Parameters<Octokit["rest"]["repos"]["createRelease"]>[0]): Promise<{
525
525
  url: string;
@@ -533,14 +533,14 @@ declare class Release extends Base {
533
533
  tag_name: string;
534
534
  target_commitish: string;
535
535
  name: string | null;
536
- body?: string | null | undefined;
536
+ body?: string | null;
537
537
  draft: boolean;
538
538
  prerelease: boolean;
539
539
  created_at: string;
540
540
  published_at: string | null;
541
541
  author: {
542
- name?: string | null | undefined;
543
- email?: string | null | undefined;
542
+ name?: string | null;
543
+ email?: string | null;
544
544
  login: string;
545
545
  id: number;
546
546
  node_id: string;
@@ -559,7 +559,7 @@ declare class Release extends Base {
559
559
  received_events_url: string;
560
560
  type: string;
561
561
  site_admin: boolean;
562
- starred_at?: string | undefined;
562
+ starred_at?: string;
563
563
  };
564
564
  assets: {
565
565
  url: string;
@@ -575,8 +575,8 @@ declare class Release extends Base {
575
575
  created_at: string;
576
576
  updated_at: string;
577
577
  uploader: {
578
- name?: string | null | undefined;
579
- email?: string | null | undefined;
578
+ name?: string | null;
579
+ email?: string | null;
580
580
  login: string;
581
581
  id: number;
582
582
  node_id: string;
@@ -595,13 +595,13 @@ declare class Release extends Base {
595
595
  received_events_url: string;
596
596
  type: string;
597
597
  site_admin: boolean;
598
- starred_at?: string | undefined;
598
+ starred_at?: string;
599
599
  } | null;
600
600
  }[];
601
- body_html?: string | undefined;
602
- body_text?: string | undefined;
603
- mentions_count?: number | undefined;
604
- discussion_url?: string | undefined;
601
+ body_html?: string;
602
+ body_text?: string;
603
+ mentions_count?: number;
604
+ discussion_url?: string;
605
605
  reactions?: {
606
606
  url: string;
607
607
  total_count: number;
@@ -613,7 +613,7 @@ declare class Release extends Base {
613
613
  hooray: number;
614
614
  eyes: number;
615
615
  rocket: number;
616
- } | undefined;
616
+ };
617
617
  } | undefined>;
618
618
  uploadAsset(releaseID: number, asset: string): Promise<{
619
619
  url: string;
@@ -629,8 +629,8 @@ declare class Release extends Base {
629
629
  created_at: string;
630
630
  updated_at: string;
631
631
  uploader: {
632
- name?: string | null | undefined;
633
- email?: string | null | undefined;
632
+ name?: string | null;
633
+ email?: string | null;
634
634
  login: string;
635
635
  id: number;
636
636
  node_id: string;
@@ -649,7 +649,7 @@ declare class Release extends Base {
649
649
  received_events_url: string;
650
650
  type: string;
651
651
  site_admin: boolean;
652
- starred_at?: string | undefined;
652
+ starred_at?: string;
653
653
  } | null;
654
654
  }>;
655
655
  refreshUpdateManifest(): Promise<void>;
@@ -691,7 +691,7 @@ declare class Serve extends Base {
691
691
  }
692
692
 
693
693
  declare const Config: {
694
- defineConfig: (userConfig: UserConfig) => UserConfig;
694
+ defineConfig: typeof defineConfig;
695
695
  loadConfig: typeof loadConfig;
696
696
  };
697
697
 
package/dist/index.mjs CHANGED
@@ -1,23 +1,23 @@
1
- import { ProgressEvent, versionBump } from 'bumpp';
2
- import chalk from 'chalk';
3
- import consola, { createConsola } from 'consola';
4
- import { isCI, isWindows, isMacOS, isLinux } from 'std-env';
1
+ import path, { join, basename } from 'node:path';
5
2
  import { loadConfig as loadConfig$1 } from 'c12';
6
3
  import fs from 'fs-extra';
7
4
  import { createHooks } from 'hookable';
8
- import path, { join, basename } from 'path';
9
5
  import { dash, template, assign, debounce } from 'radash';
10
- import * as crypto from 'crypto';
6
+ import { ProgressEvent, versionBump } from 'bumpp';
7
+ import chalk from 'chalk';
8
+ import consola, { createConsola } from 'consola';
9
+ import { isCI, isWindows, isMacOS, isLinux } from 'std-env';
10
+ import process, { env, platform } from 'node:process';
11
11
  import { build } from 'esbuild';
12
12
  import glob from 'fast-glob';
13
- import replaceInFile from 'replace-in-file';
13
+ import { replaceInFileSync } from 'replace-in-file';
14
14
  import webext from 'web-ext';
15
+ import * as crypto from 'node:crypto';
15
16
  import conventionalChangelog from 'conventional-changelog';
16
17
  import mime from 'mime';
17
18
  import { Octokit } from 'octokit';
18
- import { execSync, spawn } from 'child_process';
19
+ import { execSync, spawn } from 'node:child_process';
19
20
  import chokidar from 'chokidar';
20
- import { exit } from 'process';
21
21
 
22
22
  const LogLevels = {
23
23
  trace: 5,
@@ -66,11 +66,11 @@ function dateFormat(fmt, date) {
66
66
  "S+": date.getSeconds().toString()
67
67
  };
68
68
  for (const k in opt) {
69
- ret = new RegExp("(" + k + ")").exec(fmt);
69
+ ret = new RegExp(`(${k})`).exec(fmt);
70
70
  if (ret) {
71
71
  fmt = fmt.replace(
72
72
  ret[1],
73
- ret[1].length == 1 ? opt[k] : opt[k].padStart(ret[1].length, "0")
73
+ ret[1].length === 1 ? opt[k] : opt[k].padStart(ret[1].length, "0")
74
74
  );
75
75
  }
76
76
  }
@@ -80,14 +80,15 @@ function toArray(value) {
80
80
  return Array.isArray(value) ? value : [value];
81
81
  }
82
82
 
83
- const defineConfig = (userConfig) => {
83
+ function defineConfig(userConfig) {
84
84
  return userConfig;
85
- };
85
+ }
86
86
  async function loadConfig(overrides) {
87
87
  const result = await loadConfig$1({
88
88
  name: "zotero-plugin",
89
89
  dotenv: true,
90
90
  packageJson: true,
91
+ // eslint-disable-next-line ts/no-use-before-define
91
92
  defaults: getDefaultConfig(),
92
93
  overrides
93
94
  });
@@ -96,9 +97,11 @@ async function loadConfig(overrides) {
96
97
  function resolveConfig(config) {
97
98
  const pkg = fs.readJsonSync(path.join("package.json"), {
98
99
  encoding: "utf-8"
99
- }), [, owner, repo] = (pkg.repository?.url ?? "").match(
100
- /:\/\/.*.com\/([^/]+)\/([^.]+)\.git$/
101
- ), data = {
100
+ });
101
+ const [, owner, repo] = (pkg.repository?.url ?? "").match(
102
+ /:\/\/.+com\/([^/]+)\/([^.]+)\.git$/
103
+ );
104
+ const data = {
102
105
  owner,
103
106
  repo,
104
107
  version: pkg.version,
@@ -124,7 +127,6 @@ function resolveConfig(config) {
124
127
  }
125
128
  return ctx;
126
129
  }
127
- const getDefaultConfig = () => defaultConfig;
128
130
  const defaultConfig = {
129
131
  source: "src",
130
132
  dist: "build",
@@ -151,8 +153,8 @@ const defaultConfig = {
151
153
  homepage_url: "__homepage__",
152
154
  author: "__author__",
153
155
  icons: {
154
- "48": "content/icons/favicon@0.5x.png",
155
- "96": "content/icons/favicon.png"
156
+ 48: "content/icons/favicon@0.5x.png",
157
+ 96: "content/icons/favicon.png"
156
158
  },
157
159
  applications: {
158
160
  zotero: {
@@ -202,6 +204,7 @@ const defaultConfig = {
202
204
  },
203
205
  logLevel: "info"
204
206
  };
207
+ const getDefaultConfig = () => defaultConfig;
205
208
 
206
209
  function generateHashSync(filePath, algorithm) {
207
210
  const data = fs.readFileSync(filePath);
@@ -267,7 +270,7 @@ class Build extends Base {
267
270
  super(ctx);
268
271
  __publicField$2(this, "buildTime");
269
272
  __publicField$2(this, "isPreRelease");
270
- (_a = process.env).NODE_ENV ?? (_a.NODE_ENV = "production");
273
+ (_a = env).NODE_ENV ?? (_a.NODE_ENV = "production");
271
274
  this.buildTime = "";
272
275
  this.isPreRelease = this.version.includes("-");
273
276
  }
@@ -278,7 +281,7 @@ class Build extends Base {
278
281
  const t = /* @__PURE__ */ new Date();
279
282
  this.buildTime = dateFormat("YYYY-mm-dd HH:MM:SS", t);
280
283
  this.logger.start(
281
- `Building version ${chalk.blue(this.version)} to ${chalk.blue(this.dist)} at ${chalk.blue(this.buildTime)} in ${chalk.blue(process.env.NODE_ENV)} mode.`
284
+ `Building version ${chalk.blue(this.version)} to ${chalk.blue(this.dist)} at ${chalk.blue(this.buildTime)} in ${chalk.blue(env.NODE_ENV)} mode.`
282
285
  );
283
286
  await this.ctx.hooks.callHook("build:init", this.ctx);
284
287
  fs.emptyDirSync(this.dist);
@@ -298,7 +301,7 @@ class Build extends Base {
298
301
  await this.esbuild();
299
302
  await this.ctx.hooks.callHook("build:bundle", this.ctx);
300
303
  this.logger.info("Addon prepare OK.");
301
- if (process.env.NODE_ENV === "production") {
304
+ if (env.NODE_ENV === "production") {
302
305
  this.logger.info("Packing Addon");
303
306
  await this.pack();
304
307
  await this.ctx.hooks.callHook("build:pack", this.ctx);
@@ -333,13 +336,14 @@ class Build extends Base {
333
336
  return;
334
337
  const userData = fs.readJSONSync(
335
338
  `${this.dist}/addon/manifest.json`
336
- ), template2 = {
339
+ );
340
+ const template2 = {
337
341
  ...userData,
338
342
  ...this.name && { name: this.name },
339
343
  ...this.version && { version: this.version },
340
344
  manifest_version: 2,
341
345
  applications: {
342
- //@ts-ignore 此处不包含版本限制
346
+ // @ts-expect-error 此处不包含版本限制
343
347
  zotero: {
344
348
  id: this.id,
345
349
  update_url: this.updateURL
@@ -366,9 +370,9 @@ class Build extends Base {
366
370
  ])
367
371
  );
368
372
  this.logger.debug("replace map: ", replaceMap);
369
- const replaceResult = replaceInFile.sync({
373
+ const replaceResult = replaceInFileSync({
370
374
  files: toArray(this.ctx.build.assets).map(
371
- (asset) => `${this.dist}/${asset}`
375
+ (asset) => `${this.dist}/addon/${asset.split("/").slice(1).join("/")}`
372
376
  ),
373
377
  from: Array.from(replaceMap.keys()),
374
378
  to: Array.from(replaceMap.values()),
@@ -380,26 +384,10 @@ class Build extends Base {
380
384
  );
381
385
  }
382
386
  prepareLocaleFiles() {
383
- const MessagesInHTML = /* @__PURE__ */ new Set();
384
- replaceInFile.sync({
385
- files: [`${this.dist}/addon/**/*.xhtml`, `${this.dist}/addon/**/*.html`],
386
- // @ts-ignore ReplaceInFileConfig has processor
387
- processor: (input) => {
388
- const matchs = [...input.matchAll(/(data-l10n-id)="(\S*)"/g)];
389
- matchs.map((match) => {
390
- input = input.replace(
391
- match[0],
392
- this.ctx.build.fluent.prefixFluentMessages == true ? `${match[1]}="${this.namespace}-${match[2]}"` : match[0]
393
- );
394
- MessagesInHTML.add(match[2]);
395
- });
396
- return input;
397
- }
398
- });
399
387
  const localeNames = glob.sync(`${this.dist}/addon/locale/**`, { onlyDirectories: true }).map((locale) => path.basename(locale));
400
388
  this.logger.debug("locale names: ", localeNames);
401
389
  for (const localeName of localeNames) {
402
- if (this.ctx.build.fluent.prefixLocaleFiles == true) {
390
+ if (this.ctx.build.fluent.prefixLocaleFiles === true) {
403
391
  glob.sync(`${this.dist}/addon/locale/${localeName}/**/*.ftl`, {}).forEach((f) => {
404
392
  fs.moveSync(
405
393
  f,
@@ -409,14 +397,14 @@ class Build extends Base {
409
397
  });
410
398
  }
411
399
  const MessageInThisLang = /* @__PURE__ */ new Set();
412
- replaceInFile.sync({
400
+ replaceInFileSync({
413
401
  files: [`${this.dist}/addon/locale/${localeName}/**/*.ftl`],
414
- // @ts-ignore ReplaceInFileConfig has processor
415
402
  processor: (fltContent) => {
416
403
  const lines = fltContent.split("\n");
417
404
  const prefixedLines = lines.map((line) => {
418
405
  const match = line.match(
419
- /^(?<message>[a-zA-Z]\S*)([ ]*=[ ]*)(?<pattern>.*)$/m
406
+ // eslint-disable-next-line regexp/no-super-linear-backtracking
407
+ /^(?<message>[a-z]\S*)( *= *)(?<pattern>.*)$/im
420
408
  );
421
409
  if (match && match.groups) {
422
410
  MessageInThisLang.add(match.groups.message);
@@ -428,15 +416,40 @@ class Build extends Base {
428
416
  return prefixedLines.join("\n");
429
417
  }
430
418
  });
431
- MessagesInHTML.forEach((message) => {
432
- if (!MessageInThisLang.has(message)) {
433
- this.logger.warn(`${message} don't exist in ${localeName}`);
419
+ const MessagesInHTML = /* @__PURE__ */ new Set();
420
+ replaceInFileSync({
421
+ files: [
422
+ `${this.dist}/addon/**/*.xhtml`,
423
+ `${this.dist}/addon/**/*.html`
424
+ ],
425
+ processor: (input) => {
426
+ const matches = [
427
+ ...input.matchAll(
428
+ new RegExp(`(data-l10n-id)="((?!${this.namespace})\\S*)"`, "g")
429
+ )
430
+ ];
431
+ matches.forEach((match) => {
432
+ const [matched, attrKey, attrVal] = match;
433
+ if (!MessageInThisLang.has(attrVal)) {
434
+ this.logger.warn(`${attrVal} don't exist in ${localeName}`);
435
+ return;
436
+ }
437
+ if (!this.ctx.build.fluent.prefixFluentMessages) {
438
+ return;
439
+ }
440
+ input = input.replace(
441
+ matched,
442
+ `${attrKey}="${this.namespace}-${attrVal}"`
443
+ );
444
+ MessagesInHTML.add(attrVal);
445
+ });
446
+ return input;
434
447
  }
435
448
  });
436
449
  }
437
450
  }
438
451
  esbuild() {
439
- if (this.ctx.build.esbuildOptions.length == 0)
452
+ if (this.ctx.build.esbuildOptions.length === 0)
440
453
  return;
441
454
  return Promise.all(
442
455
  this.ctx.build.esbuildOptions.map(
@@ -447,7 +460,9 @@ class Build extends Base {
447
460
  makeUpdateJson() {
448
461
  const manifest = fs.readJSONSync(
449
462
  `${this.dist}/addon/manifest.json`
450
- ), min = manifest.applications?.zotero?.strict_min_version, max = manifest.applications?.zotero?.strict_max_version;
463
+ );
464
+ const min = manifest.applications?.zotero?.strict_min_version;
465
+ const max = manifest.applications?.zotero?.strict_max_version;
451
466
  const updateHash = generateHashSync(
452
467
  path.join(this.dist, `${this.xpiName}.xpi`),
453
468
  "sha512"
@@ -520,7 +535,7 @@ class Release extends Base {
520
535
  if (!this.isCI) {
521
536
  await this.bump();
522
537
  } else {
523
- if (glob.globSync(`${this.dist}/*.xpi`).length == 0) {
538
+ if (glob.globSync(`${this.dist}/*.xpi`).length === 0) {
524
539
  throw new Error("No xpi file found, are you sure you have run build?");
525
540
  }
526
541
  this.logger.info("Uploading XPI...");
@@ -566,10 +581,10 @@ class Release extends Base {
566
581
  repo: this.repo,
567
582
  tag
568
583
  }).catch((e) => {
569
- this.logger.log(`Release with tag ${tag} not found.`);
584
+ this.logger.log(`Release with tag ${tag} not found. ${e}`);
570
585
  return void 0;
571
586
  }).then((res) => {
572
- if (res && res.status == 200) {
587
+ if (res && res.status === 200) {
573
588
  return res.data;
574
589
  }
575
590
  });
@@ -580,7 +595,7 @@ class Release extends Base {
580
595
  this.logger.error(e);
581
596
  throw new Error("Create release failed.");
582
597
  }).then((res) => {
583
- if (res.status == 201) {
598
+ if (res.status === 201) {
584
599
  return res.data;
585
600
  }
586
601
  });
@@ -657,10 +672,10 @@ class Release extends Base {
657
672
  });
658
673
  }
659
674
  getClient() {
660
- if (!process.env.GITHUB_TOKEN)
675
+ if (!env.GITHUB_TOKEN)
661
676
  throw new Error("No GITHUB_TOKEN.");
662
677
  const client = new Octokit({
663
- auth: process.env.GITHUB_TOKEN,
678
+ auth: env.GITHUB_TOKEN,
664
679
  userAgent: `zotero-plugin-scaffold/${this.version}`
665
680
  });
666
681
  return client;
@@ -674,7 +689,6 @@ class Release extends Base {
674
689
  }
675
690
 
676
691
  function isRunning(query) {
677
- const platform = process.platform;
678
692
  let cmd = "";
679
693
  switch (platform) {
680
694
  case "win32":
@@ -689,8 +703,8 @@ function isRunning(query) {
689
703
  }
690
704
  try {
691
705
  const stdout = execSync(cmd, { encoding: "utf8" });
692
- return stdout.toLowerCase().indexOf(query.toLowerCase()) > -1;
693
- } catch (error) {
706
+ return stdout.toLowerCase().includes(query.toLowerCase());
707
+ } catch {
694
708
  return false;
695
709
  }
696
710
  }
@@ -698,8 +712,8 @@ function isRunning(query) {
698
712
  function killZotero() {
699
713
  function kill() {
700
714
  try {
701
- if (process.env.ZOTERO_PLUGIN_KILL_COMMAND) {
702
- execSync(process.env.ZOTERO_PLUGIN_KILL_COMMAND);
715
+ if (env.ZOTERO_PLUGIN_KILL_COMMAND) {
716
+ execSync(env.ZOTERO_PLUGIN_KILL_COMMAND);
703
717
  } else if (isWindows) {
704
718
  execSync("taskkill /f /im zotero.exe");
705
719
  } else if (isMacOS) {
@@ -709,7 +723,7 @@ function killZotero() {
709
723
  } else {
710
724
  consola.error("No commands found for this operating system.");
711
725
  }
712
- } catch (e) {
726
+ } catch {
713
727
  consola.fail("Kill Zotero failed.");
714
728
  }
715
729
  }
@@ -810,15 +824,15 @@ class Serve extends Base {
810
824
  "-profile",
811
825
  this.profilePath
812
826
  ]);
813
- zoteroProcess.stdout?.on("data", (data) => {
827
+ zoteroProcess.stdout?.on("data", (_data) => {
814
828
  });
815
829
  zoteroProcess.on("close", (code) => {
816
830
  this.logger.info(`Zotero terminated with code ${code}.`);
817
- exit(0);
831
+ process.exit(0);
818
832
  });
819
833
  process.on("SIGINT", () => {
820
834
  zoteroProcess.kill();
821
- exit();
835
+ process.exit();
822
836
  });
823
837
  return zoteroProcess;
824
838
  }
@@ -881,7 +895,7 @@ class Serve extends Base {
881
895
  const PrefsLines = fs.readFileSync(prefsPath, "utf-8").split("\n");
882
896
  const filteredLines = PrefsLines.map((line) => {
883
897
  if (line.includes("extensions.lastAppBuildId") || line.includes("extensions.lastAppVersion")) {
884
- return;
898
+ return "";
885
899
  }
886
900
  if (line.includes("extensions.zotero.dataDir") && this.dataDir !== "") {
887
901
  return `user_pref("extensions.zotero.dataDir", "${this.dataDir}");`;
package/package.json CHANGED
@@ -1,8 +1,25 @@
1
1
  {
2
2
  "name": "zotero-plugin-scaffold",
3
- "version": "0.0.31",
4
- "description": "A scaffold for Zotero plugin development.",
5
3
  "type": "module",
4
+ "version": "0.0.33",
5
+ "description": "A scaffold for Zotero plugin development.",
6
+ "author": "northword",
7
+ "license": "AGPL-3.0-or-later",
8
+ "homepage": "https://github.com/northword/zotero-plugin-scaffold#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/northword/zotero-plugin-scaffold.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/northword/zotero-plugin-scaffold/issues"
15
+ },
16
+ "keywords": [
17
+ "zotero",
18
+ "plugin",
19
+ "developer",
20
+ "scaffold",
21
+ "web-ext"
22
+ ],
6
23
  "exports": {
7
24
  ".": {
8
25
  "types": "./dist/index.d.ts",
@@ -18,23 +35,9 @@
18
35
  "files": [
19
36
  "dist"
20
37
  ],
21
- "keywords": [
22
- "zotero",
23
- "plugin",
24
- "developer",
25
- "scaffold",
26
- "web-ext"
27
- ],
28
- "author": "northword",
29
- "license": "AGPL-3.0-or-later",
30
- "repository": {
31
- "type": "git",
32
- "url": "https://github.com/northword/zotero-plugin-scaffold.git"
33
- },
34
- "bugs": {
35
- "url": "https://github.com/northword/zotero-plugin-scaffold/issues"
38
+ "engines": {
39
+ "node": ">=18"
36
40
  },
37
- "homepage": "https://github.com/northword/zotero-plugin-scaffold#readme",
38
41
  "publishConfig": {
39
42
  "access": "public",
40
43
  "registry": "https://registry.npmjs.org"
@@ -43,47 +46,42 @@
43
46
  "lib": "dist",
44
47
  "doc": "docs"
45
48
  },
46
- "engines": {
47
- "node": ">=18"
48
- },
49
49
  "dependencies": {
50
- "@inquirer/prompts": "5.0.4",
50
+ "@inquirer/prompts": "5.2.0",
51
51
  "bumpp": "9.4.1",
52
- "c12": "1.10.0",
52
+ "c12": "1.11.1",
53
53
  "chalk": "5.3.0",
54
54
  "chokidar": "3.6.0",
55
55
  "commander": "12.1.0",
56
56
  "consola": "3.2.3",
57
57
  "conventional-changelog": "6.0.0",
58
- "esbuild": "0.21.4",
58
+ "esbuild": "0.23.0",
59
59
  "fast-glob": "3.3.2",
60
60
  "fs-extra": "11.2.0",
61
61
  "hookable": "5.5.3",
62
- "mime": "4.0.3",
62
+ "mime": "4.0.4",
63
63
  "octokit": "4.0.2",
64
64
  "radash": "12.1.0",
65
- "replace-in-file": "7.2.0",
65
+ "replace-in-file": "8.1.0",
66
66
  "std-env": "3.7.0",
67
- "update-notifier": "7.0.0",
68
- "web-ext": "7.12.0"
67
+ "update-notifier": "7.1.0",
68
+ "web-ext": "8.2.0"
69
69
  },
70
70
  "devDependencies": {
71
- "@trivago/prettier-plugin-sort-imports": "4.3.0",
72
- "@types/conventional-changelog": "3.1.5",
71
+ "@antfu/eslint-config": "^2.23.0",
73
72
  "@types/fs-extra": "11.0.4",
74
- "@types/node": "20.12.12",
73
+ "@types/node": "20.14.11",
75
74
  "@types/update-notifier": "6.0.8",
76
- "eslint": "9.3.0",
77
- "prettier": "3.2.5",
78
- "typescript": "5.4.5",
79
- "typescript-eslint": "8.0.0-alpha.20",
75
+ "eslint": "9.7.0",
76
+ "eslint-plugin-format": "^0.1.2",
77
+ "typescript": "5.5.3",
80
78
  "unbuild": "2.0.0"
81
79
  },
82
80
  "scripts": {
83
81
  "dev": "unbuild --stub",
84
82
  "build": "tsc --noEmit && unbuild",
85
- "lint": "eslint . & prettier --check .",
86
- "lint:fix": "eslint --fix . & prettier --write .",
83
+ "lint": "eslint .",
84
+ "lint:fix": "eslint . --fix",
87
85
  "release": "bumpp --commit \"chore(release): publish v%s\"",
88
86
  "update:deps": "pnpx taze minor -w -f -l",
89
87
  "test": "echo \"Error: no test specified\" && exit 1"