zotero-plugin-scaffold 0.0.13 → 0.0.15

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
@@ -23,14 +23,14 @@ import 'chokidar';
23
23
  import 'process';
24
24
 
25
25
  const name = "zotero-plugin-scaffold";
26
- const version = "0.0.13";
26
+ const version = "0.0.15";
27
27
  const description = "A scaffold for Zotero plugin development.";
28
28
  const scripts = {
29
29
  dev: "unbuild --stub",
30
30
  build: "tsc --noEmit && unbuild",
31
31
  lint: "eslint --max-warnings=0 . && prettier --check .",
32
32
  "lint:fix": "eslint --fix . && prettier --write .",
33
- release: "release-it --only-version --preReleaseId=beta",
33
+ release: "bumpp --commit \"chore(release): publish v%s\"",
34
34
  test: "echo \"Error: no test specified\" && exit 1"
35
35
  };
36
36
  const type = "module";
@@ -110,7 +110,6 @@ const devDependencies = {
110
110
  eslint: "8.57.0",
111
111
  "eslint-config-prettier": "9.1.0",
112
112
  prettier: "3.2.5",
113
- "release-it": "17.1.1",
114
113
  typescript: "5.4.3",
115
114
  unbuild: "2.0.0"
116
115
  };
@@ -145,19 +144,7 @@ const pkg = {
145
144
  packageManager: packageManager,
146
145
  dependencies: dependencies,
147
146
  devDependencies: devDependencies,
148
- pnpm: pnpm,
149
- "release-it": {
150
- git: {
151
- commitMessage: "chore(publish): release v${version}",
152
- tagName: "v${version}"
153
- },
154
- npm: {
155
- publish: false
156
- },
157
- github: {
158
- release: false
159
- }
160
- }
147
+ pnpm: pnpm
161
148
  };
162
149
 
163
150
  async function main() {
package/dist/index.d.mts CHANGED
@@ -83,7 +83,7 @@ interface Config$1 {
83
83
  * 构建目录。
84
84
  *
85
85
  * 脚手架将在 `${dist}/addon` 存放构建后打包前的代码。
86
- * 在 `${dist}/${package_json.name}.xpi` 存放打包结果。
86
+ * 在 `${dist}/${xpiName}.xpi` 存放打包结果。
87
87
  *
88
88
  * @default "build"
89
89
  */
@@ -106,7 +106,7 @@ interface Config$1 {
106
106
  *
107
107
  * 插件命名空间
108
108
  *
109
- * @default _.kebabCase(name)
109
+ * @default _.dash(name)
110
110
  */
111
111
  namespace: string;
112
112
  /**
@@ -121,24 +121,26 @@ interface Config$1 {
121
121
  * @default `https://github.com/{{owner}}/{{repo}}/release/download/release/update.json`
122
122
  */
123
123
  updateURL: string;
124
+ /**
125
+ * 构建所需的配置
126
+ */
124
127
  build: BuildConfig;
128
+ /**
129
+ * serve 所需的配置
130
+ */
125
131
  server: ServerConfig;
126
132
  /**
127
133
  * TODO: 使用 addonLint 检查 XPI
128
134
  */
129
135
  addonLint: object;
130
- /**
131
- * .dotenv 文件路径
132
- *
133
- * @default `.env`
134
- * @deprecated
135
- */
136
- dotEnvPath: string;
137
136
  /**
138
137
  * 发布相关配置
139
138
  *
140
139
  */
141
140
  release: {
141
+ /**
142
+ * bumpp 配置
143
+ */
142
144
  bumpp: VersionBumpOptions;
143
145
  };
144
146
  /**
@@ -221,18 +223,18 @@ interface BuildConfig {
221
223
  * ```json
222
224
  * {
223
225
  * manifest_version: 2,
224
- * name: "__addonName__",
225
- * version: "__buildVersion__",
226
+ * name: "${name}",
227
+ * version: "${version}",
226
228
  * applications: {
227
229
  * zotero: {
228
- * id: "__addonID__",
229
- * update_url: "__updateURL__",
230
+ * id: "${id}",
231
+ * update_url: "${updateURL}",
230
232
  * strict_min_version: "6.999",
231
233
  * strict_max_version: "7.0.*",
232
234
  * },
233
235
  * gecko: {
234
- * id: "__addonID__",
235
- * update_url: "__updateURL__",
236
+ * id: "${id}",
237
+ * update_url: "${updateURL}",
236
238
  * strict_min_version: "102",
237
239
  * };
238
240
  * };
@@ -251,7 +253,6 @@ interface BuildConfig {
251
253
  /**
252
254
  * 是否启用
253
255
  *
254
- *
255
256
  * @default true
256
257
  */
257
258
  enable: boolean | "only-production";
@@ -269,16 +270,7 @@ interface BuildConfig {
269
270
  hash: boolean;
270
271
  };
271
272
  /**
272
- * The function called when build-in build resolved.
273
- *
274
- * Usually some extra build process.
275
- * All configurations will be parameterized to this function.
276
- *
277
- * 在默认构建步骤执行结束后执行的函数.
278
- *
279
- * 通常是一些额外的构建流程.
280
- * 所有的配置将作为参数传入此函数.
281
- *
273
+ * The lifecycle hooks.
282
274
  */
283
275
  hooks: Partial<BuildHooks>;
284
276
  }
@@ -321,8 +313,7 @@ interface ServerConfig {
321
313
  */
322
314
  asProxy: boolean;
323
315
  /**
324
- * The function called after Zotero started, before build-in watcher ready.
325
- *
316
+ * The lifecycle hook.
326
317
  */
327
318
  hooks: Partial<ServeHooks>;
328
319
  }
@@ -332,6 +323,11 @@ type RecursivePartial<T> = {
332
323
  };
333
324
  interface OverrideConfig extends RecursivePartial<Config$1> {
334
325
  }
326
+ /**
327
+ * User config
328
+ *
329
+ * 用户输入的配置,总配置全可选基础上添加部分为必填
330
+ */
335
331
  interface UserConfig extends RecursivePartial<Config$1> {
336
332
  name: string;
337
333
  id: string;
@@ -341,6 +337,7 @@ interface UserConfig extends RecursivePartial<Config$1> {
341
337
  }
342
338
  interface Context extends Config$1 {
343
339
  pkgUser: any;
340
+ xpiName: string;
344
341
  version: string;
345
342
  hooks: Hookable<Hooks>;
346
343
  templateDate: {
@@ -358,7 +355,7 @@ interface Context extends Config$1 {
358
355
  declare const defineConfig: (userConfig: UserConfig) => UserConfig;
359
356
  /**
360
357
  * Loads config
361
- * @param [file="zotero-plugin.config.{ts,js,mjs,cjs}"] The path of config file.
358
+ * @param [override={}] Highest Priority Configuration.
362
359
  * @returns Config with userDefined and defaultConfig merged.
363
360
  */
364
361
  declare function loadConfig(overrides?: OverrideConfig): Promise<Context>;
@@ -375,7 +372,7 @@ declare abstract class Base {
375
372
  get namespace(): string;
376
373
  get updateLink(): string;
377
374
  get updateURL(): string;
378
- get xpiName(): unknown;
375
+ get xpiName(): string;
379
376
  }
380
377
 
381
378
  declare class Build extends Base {
@@ -387,9 +384,15 @@ declare class Build extends Base {
387
384
  */
388
385
  run(): Promise<void>;
389
386
  /**
390
- * Copys files in `Config.assets` to `Config.dist`
387
+ * Copys files in `Config.build.assets` to `Config.dist`
391
388
  */
392
389
  copyAssets(): void;
390
+ /**
391
+ * Override user's manifest
392
+ *
393
+ * Write `applications.gecko` to `manifest.json`
394
+ *
395
+ */
393
396
  makeManifest(): void;
394
397
  /**
395
398
  * Replace all `placeholder.key` to `placeholder.value` for all files in `dist`
@@ -663,11 +666,19 @@ declare class Serve extends Base {
663
666
  * watch source dir and build when file changed
664
667
  */
665
668
  watch(): Promise<void>;
669
+ /**
670
+ * Starts zotero with plugins pre-installed as proxy file
671
+ */
666
672
  startZotero(): Promise<child_process.ChildProcessWithoutNullStreams>;
667
673
  /**
668
674
  * start zotero with plugin installed and reload when dist changed
669
675
  */
670
676
  startZoteroWebExt(): Promise<any>;
677
+ /**
678
+ * Preparing the development environment
679
+ *
680
+ * When asProxy=true, generate a proxy file to replace prefs.
681
+ */
671
682
  prepareDevEnv(): void;
672
683
  reload(): void;
673
684
  openDevTool(): void;
package/dist/index.d.ts CHANGED
@@ -83,7 +83,7 @@ interface Config$1 {
83
83
  * 构建目录。
84
84
  *
85
85
  * 脚手架将在 `${dist}/addon` 存放构建后打包前的代码。
86
- * 在 `${dist}/${package_json.name}.xpi` 存放打包结果。
86
+ * 在 `${dist}/${xpiName}.xpi` 存放打包结果。
87
87
  *
88
88
  * @default "build"
89
89
  */
@@ -106,7 +106,7 @@ interface Config$1 {
106
106
  *
107
107
  * 插件命名空间
108
108
  *
109
- * @default _.kebabCase(name)
109
+ * @default _.dash(name)
110
110
  */
111
111
  namespace: string;
112
112
  /**
@@ -121,24 +121,26 @@ interface Config$1 {
121
121
  * @default `https://github.com/{{owner}}/{{repo}}/release/download/release/update.json`
122
122
  */
123
123
  updateURL: string;
124
+ /**
125
+ * 构建所需的配置
126
+ */
124
127
  build: BuildConfig;
128
+ /**
129
+ * serve 所需的配置
130
+ */
125
131
  server: ServerConfig;
126
132
  /**
127
133
  * TODO: 使用 addonLint 检查 XPI
128
134
  */
129
135
  addonLint: object;
130
- /**
131
- * .dotenv 文件路径
132
- *
133
- * @default `.env`
134
- * @deprecated
135
- */
136
- dotEnvPath: string;
137
136
  /**
138
137
  * 发布相关配置
139
138
  *
140
139
  */
141
140
  release: {
141
+ /**
142
+ * bumpp 配置
143
+ */
142
144
  bumpp: VersionBumpOptions;
143
145
  };
144
146
  /**
@@ -221,18 +223,18 @@ interface BuildConfig {
221
223
  * ```json
222
224
  * {
223
225
  * manifest_version: 2,
224
- * name: "__addonName__",
225
- * version: "__buildVersion__",
226
+ * name: "${name}",
227
+ * version: "${version}",
226
228
  * applications: {
227
229
  * zotero: {
228
- * id: "__addonID__",
229
- * update_url: "__updateURL__",
230
+ * id: "${id}",
231
+ * update_url: "${updateURL}",
230
232
  * strict_min_version: "6.999",
231
233
  * strict_max_version: "7.0.*",
232
234
  * },
233
235
  * gecko: {
234
- * id: "__addonID__",
235
- * update_url: "__updateURL__",
236
+ * id: "${id}",
237
+ * update_url: "${updateURL}",
236
238
  * strict_min_version: "102",
237
239
  * };
238
240
  * };
@@ -251,7 +253,6 @@ interface BuildConfig {
251
253
  /**
252
254
  * 是否启用
253
255
  *
254
- *
255
256
  * @default true
256
257
  */
257
258
  enable: boolean | "only-production";
@@ -269,16 +270,7 @@ interface BuildConfig {
269
270
  hash: boolean;
270
271
  };
271
272
  /**
272
- * The function called when build-in build resolved.
273
- *
274
- * Usually some extra build process.
275
- * All configurations will be parameterized to this function.
276
- *
277
- * 在默认构建步骤执行结束后执行的函数.
278
- *
279
- * 通常是一些额外的构建流程.
280
- * 所有的配置将作为参数传入此函数.
281
- *
273
+ * The lifecycle hooks.
282
274
  */
283
275
  hooks: Partial<BuildHooks>;
284
276
  }
@@ -321,8 +313,7 @@ interface ServerConfig {
321
313
  */
322
314
  asProxy: boolean;
323
315
  /**
324
- * The function called after Zotero started, before build-in watcher ready.
325
- *
316
+ * The lifecycle hook.
326
317
  */
327
318
  hooks: Partial<ServeHooks>;
328
319
  }
@@ -332,6 +323,11 @@ type RecursivePartial<T> = {
332
323
  };
333
324
  interface OverrideConfig extends RecursivePartial<Config$1> {
334
325
  }
326
+ /**
327
+ * User config
328
+ *
329
+ * 用户输入的配置,总配置全可选基础上添加部分为必填
330
+ */
335
331
  interface UserConfig extends RecursivePartial<Config$1> {
336
332
  name: string;
337
333
  id: string;
@@ -341,6 +337,7 @@ interface UserConfig extends RecursivePartial<Config$1> {
341
337
  }
342
338
  interface Context extends Config$1 {
343
339
  pkgUser: any;
340
+ xpiName: string;
344
341
  version: string;
345
342
  hooks: Hookable<Hooks>;
346
343
  templateDate: {
@@ -358,7 +355,7 @@ interface Context extends Config$1 {
358
355
  declare const defineConfig: (userConfig: UserConfig) => UserConfig;
359
356
  /**
360
357
  * Loads config
361
- * @param [file="zotero-plugin.config.{ts,js,mjs,cjs}"] The path of config file.
358
+ * @param [override={}] Highest Priority Configuration.
362
359
  * @returns Config with userDefined and defaultConfig merged.
363
360
  */
364
361
  declare function loadConfig(overrides?: OverrideConfig): Promise<Context>;
@@ -375,7 +372,7 @@ declare abstract class Base {
375
372
  get namespace(): string;
376
373
  get updateLink(): string;
377
374
  get updateURL(): string;
378
- get xpiName(): unknown;
375
+ get xpiName(): string;
379
376
  }
380
377
 
381
378
  declare class Build extends Base {
@@ -387,9 +384,15 @@ declare class Build extends Base {
387
384
  */
388
385
  run(): Promise<void>;
389
386
  /**
390
- * Copys files in `Config.assets` to `Config.dist`
387
+ * Copys files in `Config.build.assets` to `Config.dist`
391
388
  */
392
389
  copyAssets(): void;
390
+ /**
391
+ * Override user's manifest
392
+ *
393
+ * Write `applications.gecko` to `manifest.json`
394
+ *
395
+ */
393
396
  makeManifest(): void;
394
397
  /**
395
398
  * Replace all `placeholder.key` to `placeholder.value` for all files in `dist`
@@ -663,11 +666,19 @@ declare class Serve extends Base {
663
666
  * watch source dir and build when file changed
664
667
  */
665
668
  watch(): Promise<void>;
669
+ /**
670
+ * Starts zotero with plugins pre-installed as proxy file
671
+ */
666
672
  startZotero(): Promise<child_process.ChildProcessWithoutNullStreams>;
667
673
  /**
668
674
  * start zotero with plugin installed and reload when dist changed
669
675
  */
670
676
  startZoteroWebExt(): Promise<any>;
677
+ /**
678
+ * Preparing the development environment
679
+ *
680
+ * When asProxy=true, generate a proxy file to replace prefs.
681
+ */
671
682
  prepareDevEnv(): void;
672
683
  reload(): void;
673
684
  openDevTool(): void;
package/dist/index.mjs CHANGED
@@ -71,6 +71,7 @@ function resolveConfig(config) {
71
71
  const ctx = {
72
72
  ...config,
73
73
  pkgUser: pkg,
74
+ xpiName: dash(config.name),
74
75
  version: pkg.version,
75
76
  hooks: createHooks(),
76
77
  templateDate: data
@@ -152,8 +153,7 @@ const defaultConfig = {
152
153
  push: true
153
154
  }
154
155
  },
155
- logLevel: "info",
156
- dotEnvPath: ".env"
156
+ logLevel: "info"
157
157
  };
158
158
 
159
159
  function generateHashSync(filePath, algorithm) {
@@ -212,7 +212,7 @@ class Base {
212
212
  return this.ctx.updateURL;
213
213
  }
214
214
  get xpiName() {
215
- return this.ctx.build.define.xpiName;
215
+ return this.ctx.xpiName;
216
216
  }
217
217
  }
218
218
 
@@ -273,7 +273,7 @@ class Build extends Base {
273
273
  );
274
274
  }
275
275
  /**
276
- * Copys files in `Config.assets` to `Config.dist`
276
+ * Copys files in `Config.build.assets` to `Config.dist`
277
277
  */
278
278
  copyAssets() {
279
279
  const files = glob.sync(this.ctx.build.assets);
@@ -283,6 +283,12 @@ class Build extends Base {
283
283
  fs.copySync(file, newPath);
284
284
  });
285
285
  }
286
+ /**
287
+ * Override user's manifest
288
+ *
289
+ * Write `applications.gecko` to `manifest.json`
290
+ *
291
+ */
286
292
  makeManifest() {
287
293
  if (!this.ctx.build.makeManifest.enable)
288
294
  return;
@@ -399,7 +405,7 @@ class Build extends Base {
399
405
  `${this.dist}/addon/manifest.json`
400
406
  ), min = manifest.applications?.zotero?.strict_min_version, max = manifest.applications?.zotero?.strict_max_version;
401
407
  const updateHash = generateHashSync(
402
- path.join(this.dist, `${this.ctx.templateDate.xpiName}.xpi`),
408
+ path.join(this.dist, `${this.xpiName}.xpi`),
403
409
  "sha512"
404
410
  );
405
411
  const data = {
@@ -434,7 +440,7 @@ class Build extends Base {
434
440
  await webext.cmd.build({
435
441
  sourceDir: `${this.dist}/addon`,
436
442
  artifactsDir: this.dist,
437
- filename: `${this.ctx.templateDate.xpiName}.xpi`,
443
+ filename: `${this.xpiName}.xpi`,
438
444
  overwriteDest: true
439
445
  });
440
446
  }
@@ -733,6 +739,9 @@ ${path2} changed`);
733
739
  this.logger.error("Server start failed!", err);
734
740
  });
735
741
  }
742
+ /**
743
+ * Starts zotero with plugins pre-installed as proxy file
744
+ */
736
745
  async startZotero() {
737
746
  let isZoteroReady = false;
738
747
  if (!fs.existsSync(this.zoteroBinPath)) {
@@ -791,6 +800,11 @@ ${path2} changed`);
791
800
  }
792
801
  );
793
802
  }
803
+ /**
804
+ * Preparing the development environment
805
+ *
806
+ * When asProxy=true, generate a proxy file to replace prefs.
807
+ */
794
808
  prepareDevEnv() {
795
809
  const addonProxyFilePath = path.join(
796
810
  this.profilePath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zotero-plugin-scaffold",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "A scaffold for Zotero plugin development.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -79,28 +79,15 @@
79
79
  "eslint": "8.57.0",
80
80
  "eslint-config-prettier": "9.1.0",
81
81
  "prettier": "3.2.5",
82
- "release-it": "17.1.1",
83
82
  "typescript": "5.4.3",
84
83
  "unbuild": "2.0.0"
85
84
  },
86
- "release-it": {
87
- "git": {
88
- "commitMessage": "chore(publish): release v${version}",
89
- "tagName": "v${version}"
90
- },
91
- "npm": {
92
- "publish": false
93
- },
94
- "github": {
95
- "release": false
96
- }
97
- },
98
85
  "scripts": {
99
86
  "dev": "unbuild --stub",
100
87
  "build": "tsc --noEmit && unbuild",
101
88
  "lint": "eslint --max-warnings=0 . && prettier --check .",
102
89
  "lint:fix": "eslint --fix . && prettier --write .",
103
- "release": "release-it --only-version --preReleaseId=beta",
90
+ "release": "bumpp --commit \"chore(release): publish v%s\"",
104
91
  "test": "echo \"Error: no test specified\" && exit 1"
105
92
  }
106
93
  }