zotero-plugin-scaffold 0.0.14 → 0.0.16

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
@@ -2,6 +2,7 @@ import { Config, Build, Serve, Release } from './index.mjs';
2
2
  import { Command } from 'commander';
3
3
  import consola from 'consola';
4
4
  import updateNotifier from 'update-notifier';
5
+ import 'bumpp';
5
6
  import 'c12';
6
7
  import 'fs-extra';
7
8
  import 'hookable';
@@ -14,7 +15,6 @@ import 'esbuild';
14
15
  import 'fast-glob';
15
16
  import 'replace-in-file';
16
17
  import 'web-ext';
17
- import 'bumpp';
18
18
  import 'conventional-changelog';
19
19
  import 'mime';
20
20
  import 'octokit';
@@ -23,7 +23,7 @@ import 'chokidar';
23
23
  import 'process';
24
24
 
25
25
  const name = "zotero-plugin-scaffold";
26
- const version = "0.0.14";
26
+ const version = "0.0.16";
27
27
  const description = "A scaffold for Zotero plugin development.";
28
28
  const scripts = {
29
29
  dev: "unbuild --stub",
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;
@@ -359,7 +355,7 @@ interface Context extends Config$1 {
359
355
  declare const defineConfig: (userConfig: UserConfig) => UserConfig;
360
356
  /**
361
357
  * Loads config
362
- * @param [file="zotero-plugin.config.{ts,js,mjs,cjs}"] The path of config file.
358
+ * @param [override={}] Highest Priority Configuration.
363
359
  * @returns Config with userDefined and defaultConfig merged.
364
360
  */
365
361
  declare function loadConfig(overrides?: OverrideConfig): Promise<Context>;
@@ -388,9 +384,15 @@ declare class Build extends Base {
388
384
  */
389
385
  run(): Promise<void>;
390
386
  /**
391
- * Copys files in `Config.assets` to `Config.dist`
387
+ * Copys files in `Config.build.assets` to `Config.dist`
392
388
  */
393
389
  copyAssets(): void;
390
+ /**
391
+ * Override user's manifest
392
+ *
393
+ * Write `applications.gecko` to `manifest.json`
394
+ *
395
+ */
394
396
  makeManifest(): void;
395
397
  /**
396
398
  * Replace all `placeholder.key` to `placeholder.value` for all files in `dist`
@@ -664,11 +666,19 @@ declare class Serve extends Base {
664
666
  * watch source dir and build when file changed
665
667
  */
666
668
  watch(): Promise<void>;
669
+ /**
670
+ * Starts zotero with plugins pre-installed as proxy file
671
+ */
667
672
  startZotero(): Promise<child_process.ChildProcessWithoutNullStreams>;
668
673
  /**
669
674
  * start zotero with plugin installed and reload when dist changed
670
675
  */
671
676
  startZoteroWebExt(): Promise<any>;
677
+ /**
678
+ * Preparing the development environment
679
+ *
680
+ * When asProxy=true, generate a proxy file to replace prefs.
681
+ */
672
682
  prepareDevEnv(): void;
673
683
  reload(): void;
674
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;
@@ -359,7 +355,7 @@ interface Context extends Config$1 {
359
355
  declare const defineConfig: (userConfig: UserConfig) => UserConfig;
360
356
  /**
361
357
  * Loads config
362
- * @param [file="zotero-plugin.config.{ts,js,mjs,cjs}"] The path of config file.
358
+ * @param [override={}] Highest Priority Configuration.
363
359
  * @returns Config with userDefined and defaultConfig merged.
364
360
  */
365
361
  declare function loadConfig(overrides?: OverrideConfig): Promise<Context>;
@@ -388,9 +384,15 @@ declare class Build extends Base {
388
384
  */
389
385
  run(): Promise<void>;
390
386
  /**
391
- * Copys files in `Config.assets` to `Config.dist`
387
+ * Copys files in `Config.build.assets` to `Config.dist`
392
388
  */
393
389
  copyAssets(): void;
390
+ /**
391
+ * Override user's manifest
392
+ *
393
+ * Write `applications.gecko` to `manifest.json`
394
+ *
395
+ */
394
396
  makeManifest(): void;
395
397
  /**
396
398
  * Replace all `placeholder.key` to `placeholder.value` for all files in `dist`
@@ -664,11 +666,19 @@ declare class Serve extends Base {
664
666
  * watch source dir and build when file changed
665
667
  */
666
668
  watch(): Promise<void>;
669
+ /**
670
+ * Starts zotero with plugins pre-installed as proxy file
671
+ */
667
672
  startZotero(): Promise<child_process.ChildProcessWithoutNullStreams>;
668
673
  /**
669
674
  * start zotero with plugin installed and reload when dist changed
670
675
  */
671
676
  startZoteroWebExt(): Promise<any>;
677
+ /**
678
+ * Preparing the development environment
679
+ *
680
+ * When asProxy=true, generate a proxy file to replace prefs.
681
+ */
672
682
  prepareDevEnv(): void;
673
683
  reload(): void;
674
684
  openDevTool(): void;
package/dist/index.mjs CHANGED
@@ -1,3 +1,5 @@
1
+ import versionBump, { ProgressEvent } from 'bumpp';
2
+ import consola, { createConsola } from 'consola';
1
3
  import { loadConfig as loadConfig$1 } from 'c12';
2
4
  import fs from 'fs-extra';
3
5
  import { createHooks } from 'hookable';
@@ -6,12 +8,10 @@ import { dash, template, assign, debounce } from 'radash';
6
8
  import * as crypto from 'crypto';
7
9
  import chalk from 'chalk';
8
10
  import { isCI, isWindows, isMacOS, isLinux } from 'std-env';
9
- import consola, { createConsola } from 'consola';
10
11
  import { buildSync } from 'esbuild';
11
12
  import glob from 'fast-glob';
12
13
  import replaceInFile from 'replace-in-file';
13
14
  import webext from 'web-ext';
14
- import versionBump from 'bumpp';
15
15
  import conventionalChangelog from 'conventional-changelog';
16
16
  import mime from 'mime';
17
17
  import { Octokit } from 'octokit';
@@ -19,6 +19,35 @@ import { execSync, spawn } from 'child_process';
19
19
  import chokidar from 'chokidar';
20
20
  import { exit } from 'process';
21
21
 
22
+ function progress({
23
+ event,
24
+ script,
25
+ updatedFiles,
26
+ skippedFiles,
27
+ newVersion
28
+ }) {
29
+ switch (event) {
30
+ case ProgressEvent.FileUpdated:
31
+ consola.success(`Updated ${updatedFiles.pop()} to ${newVersion}`);
32
+ break;
33
+ case ProgressEvent.FileSkipped:
34
+ consola.info(`${skippedFiles.pop()} did not need to be updated`);
35
+ break;
36
+ case ProgressEvent.GitCommit:
37
+ consola.success("Git commit");
38
+ break;
39
+ case ProgressEvent.GitTag:
40
+ consola.success("Git tag");
41
+ break;
42
+ case ProgressEvent.GitPush:
43
+ consola.success("Git push");
44
+ break;
45
+ case ProgressEvent.NpmScript:
46
+ consola.success(`Npm run ${script}`);
47
+ break;
48
+ }
49
+ }
50
+
22
51
  function dateFormat(fmt, date) {
23
52
  let ret;
24
53
  const opt = {
@@ -145,16 +174,17 @@ const defaultConfig = {
145
174
  release: {
146
175
  bumpp: {
147
176
  release: "prompt",
177
+ confirm: true,
148
178
  preid: "beta",
149
179
  // execute: "npm run build",
150
180
  all: false,
151
- commit: "Release v%s",
181
+ commit: "chore(publish): release v%s",
152
182
  tag: "v%s",
153
- push: true
183
+ push: true,
184
+ progress
154
185
  }
155
186
  },
156
- logLevel: "info",
157
- dotEnvPath: ".env"
187
+ logLevel: "info"
158
188
  };
159
189
 
160
190
  function generateHashSync(filePath, algorithm) {
@@ -274,7 +304,7 @@ class Build extends Base {
274
304
  );
275
305
  }
276
306
  /**
277
- * Copys files in `Config.assets` to `Config.dist`
307
+ * Copys files in `Config.build.assets` to `Config.dist`
278
308
  */
279
309
  copyAssets() {
280
310
  const files = glob.sync(this.ctx.build.assets);
@@ -284,6 +314,12 @@ class Build extends Base {
284
314
  fs.copySync(file, newPath);
285
315
  });
286
316
  }
317
+ /**
318
+ * Override user's manifest
319
+ *
320
+ * Write `applications.gecko` to `manifest.json`
321
+ *
322
+ */
287
323
  makeManifest() {
288
324
  if (!this.ctx.build.makeManifest.enable)
289
325
  return;
@@ -734,6 +770,9 @@ ${path2} changed`);
734
770
  this.logger.error("Server start failed!", err);
735
771
  });
736
772
  }
773
+ /**
774
+ * Starts zotero with plugins pre-installed as proxy file
775
+ */
737
776
  async startZotero() {
738
777
  let isZoteroReady = false;
739
778
  if (!fs.existsSync(this.zoteroBinPath)) {
@@ -792,6 +831,11 @@ ${path2} changed`);
792
831
  }
793
832
  );
794
833
  }
834
+ /**
835
+ * Preparing the development environment
836
+ *
837
+ * When asProxy=true, generate a proxy file to replace prefs.
838
+ */
795
839
  prepareDevEnv() {
796
840
  const addonProxyFilePath = path.join(
797
841
  this.profilePath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zotero-plugin-scaffold",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "A scaffold for Zotero plugin development.",
5
5
  "type": "module",
6
6
  "exports": {