zotero-plugin-scaffold 0.7.0 → 0.7.2

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.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { B as Base, C as Context, O as OverrideConfig } from './shared/zotero-plugin-scaffold.DmiRKKLw.mjs';
1
+ import { B as Base, C as Context, O as OverrideConfig } from './shared/zotero-plugin-scaffold.CIruZpuO.mjs';
2
2
  import 'hookable';
3
3
  import 'esbuild';
4
4
 
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, C as Config, B as Build, S as Serve, T as Test, R as Release } from './shared/zotero-plugin-scaffold.D2qdHZn7.mjs';
3
+ import { E as ExitSignals, C as Config, B as Build, S as Serve, T as Test, R as Release } from './shared/zotero-plugin-scaffold.CTJf9uCe.mjs';
4
4
  import { readFile } from 'node:fs/promises';
5
5
  import { pathExists } from 'fs-extra';
6
6
  import { l as logger } from './shared/zotero-plugin-scaffold.CzBjWbS8.mjs';
@@ -20,12 +20,12 @@ import 'adm-zip';
20
20
  import 'node:child_process';
21
21
  import 'std-env';
22
22
  import 'bumpp';
23
- import 'octokit';
24
23
  import 'node:os';
25
24
  import 'node:url';
26
25
  import 'node:assert';
27
26
  import 'node:v8';
28
27
  import 'node:util';
28
+ import 'octokit';
29
29
  import 'chokidar';
30
30
  import 'node:net';
31
31
  import 'node:buffer';
@@ -36,7 +36,7 @@ import 'node:http';
36
36
  import 'node:readline';
37
37
 
38
38
  const name = "zotero-plugin-scaffold";
39
- const version = "0.7.0";
39
+ const version = "0.7.2";
40
40
  const pkg = {
41
41
  name: name,
42
42
  version: version};
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { U as UserConfig, O as OverrideConfig, C as Context, B as Base, G as GitCommit } from './shared/zotero-plugin-scaffold.DmiRKKLw.mjs';
1
+ import { U as UserConfig, O as OverrideConfig, C as Context, B as Base } from './shared/zotero-plugin-scaffold.CIruZpuO.mjs';
2
2
  import 'hookable';
3
3
  import 'esbuild';
4
4
 
@@ -36,8 +36,6 @@ declare class Release extends Base {
36
36
  * then, create or update release (tag is "release"), update `update.json`.
37
37
  */
38
38
  run(): Promise<void>;
39
- getConventionalChangelog(commits: GitCommit[]): Promise<string>;
40
- getGitDiff(): Promise<GitCommit[]>;
41
39
  getChangelog(): Promise<string>;
42
40
  private isEnabled;
43
41
  exit(): void;
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.D2qdHZn7.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.CTJf9uCe.mjs';
2
2
  import 'c12';
3
3
  import 'es-toolkit';
4
4
  import 'fs-extra/esm';
@@ -19,11 +19,11 @@ import 'node:crypto';
19
19
  import 'adm-zip';
20
20
  import 'node:child_process';
21
21
  import 'bumpp';
22
- import 'octokit';
23
22
  import 'node:os';
24
23
  import 'node:url';
25
24
  import 'node:assert';
26
25
  import 'node:v8';
26
+ import 'octokit';
27
27
  import 'chokidar';
28
28
  import 'node:net';
29
29
  import 'node:buffer';
@@ -855,4 +855,4 @@ declare abstract class Base {
855
855
  }
856
856
 
857
857
  export { Base as B };
858
- export type { Context as C, GitCommit as G, OverrideConfig as O, UserConfig as U };
858
+ export type { Context as C, OverrideConfig as O, UserConfig as U };
@@ -16,12 +16,12 @@ import AdmZip from 'adm-zip';
16
16
  import { execSync, spawn } from 'node:child_process';
17
17
  import { isCI, isWindows as isWindows$1, isMacOS, isLinux, isDebug } from 'std-env';
18
18
  import { versionBump, ProgressEvent } from 'bumpp';
19
- import { Octokit } from 'octokit';
20
19
  import 'node:os';
21
20
  import { fileURLToPath, pathToFileURL, URL as URL$1 } from 'node:url';
22
21
  import assert from 'node:assert';
23
22
  import v8 from 'node:v8';
24
23
  import { format, inspect } from 'node:util';
24
+ import { Octokit } from 'octokit';
25
25
  import chokidar from 'chokidar';
26
26
  import net from 'node:net';
27
27
  import { Buffer } from 'node:buffer';
@@ -860,6 +860,84 @@ class Build extends Base {
860
860
  }
861
861
  }
862
862
 
863
+ class ReleaseBase {
864
+ isCI;
865
+ ctx;
866
+ constructor(ctx) {
867
+ this.ctx = ctx;
868
+ this.isCI = isCI;
869
+ }
870
+ checkFiles() {
871
+ const { dist } = this.ctx;
872
+ if (globSync(`${dist}/*.xpi`).length === 0) {
873
+ throw new Error("No xpi file found, are you sure you have run build?");
874
+ }
875
+ }
876
+ get logger() {
877
+ return this.ctx.logger;
878
+ }
879
+ }
880
+
881
+ class Bump extends ReleaseBase {
882
+ constructor(ctx) {
883
+ super(ctx);
884
+ }
885
+ async run() {
886
+ const bumppConfig = {
887
+ ...this.ctx.release.bumpp,
888
+ push: true,
889
+ progress: this.bumppProgress
890
+ };
891
+ const { version } = this.ctx;
892
+ if (bumppConfig.release === version) {
893
+ this.logger.debug("Commit, tag, and push are disabled because new version = old version.");
894
+ bumppConfig.commit = false;
895
+ bumppConfig.tag = false;
896
+ bumppConfig.push = false;
897
+ }
898
+ const result = await versionBump(bumppConfig);
899
+ this.ctx.version = result.newVersion;
900
+ this.ctx.release.bumpp.tag = result.tag || this.ctx.release.bumpp.tag.toString().replace("%s", result.newVersion);
901
+ this.ctx.release.bumpp.commit = result.commit || this.ctx.release.bumpp.commit.toString().replace("%s", result.newVersion);
902
+ this.logger.debug(`The release context after bump: ", ${this.ctx.release}`);
903
+ }
904
+ /**
905
+ * bumpp 显示进度的回调
906
+ *
907
+ * @see https://github.com/antfu/bumpp/blob/main/src/cli/index.ts
908
+ */
909
+ get bumppProgress() {
910
+ return ({
911
+ event,
912
+ script,
913
+ updatedFiles,
914
+ skippedFiles,
915
+ newVersion
916
+ }) => {
917
+ switch (event) {
918
+ case ProgressEvent.FileUpdated:
919
+ this.logger.success(`Updated ${updatedFiles.pop()} to ${newVersion}`);
920
+ break;
921
+ case ProgressEvent.FileSkipped:
922
+ this.logger.info(`${skippedFiles.pop()} did not need to be updated`);
923
+ break;
924
+ case ProgressEvent.GitCommit:
925
+ this.logger.success("Git commit");
926
+ break;
927
+ case ProgressEvent.GitTag:
928
+ this.logger.success("Git tag");
929
+ break;
930
+ case ProgressEvent.GitPush:
931
+ this.logger.success("Git push");
932
+ break;
933
+ case ProgressEvent.NpmScript:
934
+ this.logger.success(`Npm run ${script}`);
935
+ break;
936
+ }
937
+ };
938
+ }
939
+ }
940
+
863
941
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
864
942
  function normalizeWindowsPath(input = "") {
865
943
  if (!input) {
@@ -2958,82 +3036,50 @@ async function resolveChangelogConfig(config, cwd) {
2958
3036
  return config;
2959
3037
  }
2960
3038
 
2961
- class ReleaseBase {
2962
- isCI;
2963
- ctx;
2964
- constructor(ctx) {
2965
- this.ctx = ctx;
2966
- this.isCI = isCI;
3039
+ async function getConventionalChangelog(commits) {
3040
+ if (!commits[0].type) {
3041
+ return commits.map((c) => c.message).join("\n");
2967
3042
  }
2968
- checkFiles() {
2969
- const { dist } = this.ctx;
2970
- if (globSync(`${dist}/*.xpi`).length === 0) {
2971
- throw new Error("No xpi file found, are you sure you have run build?");
3043
+ const resolvedCommits = commits.map((c) => {
3044
+ if (c.type === "remove") {
3045
+ c.isBreaking = true;
2972
3046
  }
2973
- }
2974
- get logger() {
2975
- return this.ctx.logger;
2976
- }
2977
- }
2978
-
2979
- class Bump extends ReleaseBase {
2980
- constructor(ctx) {
2981
- super(ctx);
2982
- }
2983
- async run() {
2984
- const bumppConfig = {
2985
- ...this.ctx.release.bumpp,
2986
- push: true,
2987
- progress: this.bumppProgress
2988
- };
2989
- const { version } = this.ctx;
2990
- if (bumppConfig.release === version) {
2991
- this.logger.debug("Commit, tag, and push are disabled because new version = old version.");
2992
- bumppConfig.commit = false;
2993
- bumppConfig.tag = false;
2994
- bumppConfig.push = false;
3047
+ return c;
3048
+ });
3049
+ const _config = await loadChangelogConfig(process$1.cwd(), {
3050
+ types: {
3051
+ add: { title: "\u{1F680} Enhancements", semver: "minor" },
3052
+ change: { title: "\u{1FA79} Fixes", semver: "patch" },
3053
+ remove: { title: "\u{1FA79} Fixes", semver: "minor" }
3054
+ },
3055
+ hideAuthorEmail: true
3056
+ });
3057
+ const md = await generateMarkDown(resolvedCommits, _config);
3058
+ return md.split("\n").slice(3).join("\n");
3059
+ }
3060
+ async function getGitCommits(currentTag, commitMessageTemplate) {
3061
+ const tags = execSync("git tag -l --sort=v:refname").toString().trim().split("\n");
3062
+ const currentTagIndex = tags.indexOf(currentTag);
3063
+ if (currentTagIndex === -1)
3064
+ throw new Error(`Tag "${currentTag}" not found.`);
3065
+ let previousTagIndex = currentTagIndex - 1;
3066
+ let previousTag;
3067
+ if (currentTagIndex === 0) {
3068
+ previousTag = void 0;
3069
+ } else if (currentTag.includes("-")) {
3070
+ previousTag = tags[previousTagIndex];
3071
+ } else {
3072
+ while (previousTagIndex >= 0 && tags[previousTagIndex].includes("-")) {
3073
+ previousTagIndex--;
2995
3074
  }
2996
- const result = await versionBump(bumppConfig);
2997
- this.ctx.version = result.newVersion;
2998
- this.ctx.release.bumpp.tag = result.tag || this.ctx.release.bumpp.tag.toString().replace("%s", result.newVersion);
2999
- this.ctx.release.bumpp.commit = result.commit || this.ctx.release.bumpp.commit.toString().replace("%s", result.newVersion);
3000
- this.logger.debug(`The release context after bump: ", ${this.ctx.release}`);
3001
- }
3002
- /**
3003
- * bumpp 显示进度的回调
3004
- *
3005
- * @see https://github.com/antfu/bumpp/blob/main/src/cli/index.ts
3006
- */
3007
- get bumppProgress() {
3008
- return ({
3009
- event,
3010
- script,
3011
- updatedFiles,
3012
- skippedFiles,
3013
- newVersion
3014
- }) => {
3015
- switch (event) {
3016
- case ProgressEvent.FileUpdated:
3017
- this.logger.success(`Updated ${updatedFiles.pop()} to ${newVersion}`);
3018
- break;
3019
- case ProgressEvent.FileSkipped:
3020
- this.logger.info(`${skippedFiles.pop()} did not need to be updated`);
3021
- break;
3022
- case ProgressEvent.GitCommit:
3023
- this.logger.success("Git commit");
3024
- break;
3025
- case ProgressEvent.GitTag:
3026
- this.logger.success("Git tag");
3027
- break;
3028
- case ProgressEvent.GitPush:
3029
- this.logger.success("Git push");
3030
- break;
3031
- case ProgressEvent.NpmScript:
3032
- this.logger.success(`Npm run ${script}`);
3033
- break;
3034
- }
3035
- };
3075
+ if (previousTagIndex < 0)
3076
+ previousTag = void 0;
3077
+ else
3078
+ previousTag = tags[previousTagIndex];
3036
3079
  }
3080
+ const filterRegex = new RegExp(escapeRegExp(commitMessageTemplate));
3081
+ const rawCommits = (await getGitDiff(previousTag, currentTag)).filter((c) => !filterRegex.test(c.message));
3082
+ return parseCommits(rawCommits, { scopeMap: {} });
3037
3083
  }
3038
3084
 
3039
3085
  const mimeTypes = {
@@ -3236,55 +3282,10 @@ class Release extends Base {
3236
3282
  `Done in ${((/* @__PURE__ */ new Date()).getTime() - t.getTime()) / 1e3} s.`
3237
3283
  );
3238
3284
  }
3239
- async getConventionalChangelog(commits) {
3240
- if (!commits[0].type) {
3241
- return commits.map((c) => c.message).join("\n");
3242
- }
3243
- const resolvedCommits = commits.map((c) => {
3244
- if (c.type === "remove") {
3245
- c.isBreaking = true;
3246
- }
3247
- return c;
3248
- });
3249
- const _config = await loadChangelogConfig(process$1.cwd(), {
3250
- types: {
3251
- add: { title: "\u{1F680} Enhancements", semver: "minor" },
3252
- change: { title: "\u{1FA79} Fixes", semver: "patch" },
3253
- remove: { title: "\u{1FA79} Fixes", semver: "minor" }
3254
- }
3255
- });
3256
- const md = await generateMarkDown(resolvedCommits, _config);
3257
- return md.split("\n").slice(3).join("\n");
3258
- }
3259
- async getGitDiff() {
3260
- const currentTag = this.ctx.release.bumpp.tag;
3261
- const tags = execSync("git tag -l --sort=v:refname").toString().trim().split("\n");
3262
- const currentTagIndex = tags.indexOf(currentTag);
3263
- if (currentTagIndex === -1)
3264
- throw new Error(`Tag "${currentTag}" not found.`);
3265
- let previousTagIndex = currentTagIndex - 1;
3266
- let previousTag;
3267
- if (currentTagIndex === 0) {
3268
- previousTag = void 0;
3269
- } else if (currentTag.includes("-")) {
3270
- previousTag = tags[previousTagIndex];
3271
- } else {
3272
- while (previousTagIndex >= 0 && tags[previousTagIndex].includes("-")) {
3273
- previousTagIndex--;
3274
- }
3275
- if (previousTagIndex < 0)
3276
- previousTag = void 0;
3277
- else
3278
- previousTag = tags[previousTagIndex];
3279
- }
3280
- const commitMessage = this.ctx.release.bumpp.commit;
3281
- const filterRegex = new RegExp(escapeRegExp(commitMessage));
3282
- const rawCommits = (await getGitDiff(previousTag, currentTag)).filter((c) => !filterRegex.test(c.message));
3283
- return parseCommits(rawCommits, { scopeMap: {} });
3284
- }
3285
3285
  async getChangelog() {
3286
+ const { commit, tag } = this.ctx.release.bumpp;
3286
3287
  let changelog;
3287
- const rawCommit = await this.getGitDiff();
3288
+ const rawCommit = await getGitCommits(tag, commit);
3288
3289
  if (rawCommit.length === 0) {
3289
3290
  return "_No significant changes._";
3290
3291
  }
@@ -3294,7 +3295,7 @@ class Release extends Base {
3294
3295
  } else if (!!changelogConfig && typeof changelogConfig == "string") {
3295
3296
  changelog = execSync(changelogConfig).toString().trim();
3296
3297
  } else {
3297
- changelog = await this.getConventionalChangelog(rawCommit);
3298
+ changelog = await getConventionalChangelog(rawCommit);
3298
3299
  }
3299
3300
  this.logger.debug(`Got changelog:
3300
3301
  ${changelog}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zotero-plugin-scaffold",
3
3
  "type": "module",
4
- "version": "0.7.0",
4
+ "version": "0.7.2",
5
5
  "description": "A scaffold for Zotero plugin development.",
6
6
  "author": "northword",
7
7
  "license": "AGPL-3.0-or-later",
@@ -55,13 +55,13 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@fluent/syntax": "^0.19.0",
58
- "@swc/core": "^1.12.0",
58
+ "@swc/core": "^1.12.9",
59
59
  "adm-zip": "^0.5.16",
60
- "bumpp": "^10.1.1",
60
+ "bumpp": "^10.2.0",
61
61
  "c12": "^3.0.4",
62
62
  "chokidar": "^4.0.3",
63
63
  "commander": "^14.0.0",
64
- "es-toolkit": "^1.39.3",
64
+ "es-toolkit": "^1.39.5",
65
65
  "esbuild": "^0.25.5",
66
66
  "fs-extra": "^11.3.0",
67
67
  "hookable": "^5.5.3",
@@ -72,22 +72,22 @@
72
72
  "xvfb-ts": "^1.1.0"
73
73
  },
74
74
  "devDependencies": {
75
- "@antfu/eslint-config": "^4.14.1",
75
+ "@antfu/eslint-config": "^4.16.1",
76
76
  "@commander-js/extra-typings": "^14.0.0",
77
77
  "@types/adm-zip": "^0.5.7",
78
78
  "@types/fs-extra": "^11.0.4",
79
- "@types/node": "^22.15.31",
80
- "bumpp": "^10.1.1",
79
+ "@types/node": "^22.15.34",
80
+ "bumpp": "^10.2.0",
81
81
  "changelogen": "^0.6.1",
82
- "eslint": "^9.28.0",
82
+ "eslint": "^9.30.0",
83
83
  "eslint-plugin-format": "^1.0.1",
84
84
  "husky": "^9.1.7",
85
- "lint-staged": "^16.1.0",
85
+ "lint-staged": "^16.1.2",
86
86
  "node-style-text": "^0.0.8",
87
- "tsx": "^4.20.1",
87
+ "tsx": "^4.20.3",
88
88
  "typescript": "^5.8.3",
89
89
  "unbuild": "^3.5.0",
90
- "vitest": "^3.2.3"
90
+ "vitest": "^3.2.4"
91
91
  },
92
92
  "workspaces": [
93
93
  "src",