zotero-plugin-scaffold 0.7.0 → 0.7.1
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 +1 -1
- package/dist/cli.mjs +3 -3
- package/dist/index.d.mts +1 -3
- package/dist/index.mjs +2 -2
- package/dist/shared/{zotero-plugin-scaffold.D2qdHZn7.mjs → zotero-plugin-scaffold.BLTrbfUc.mjs} +122 -167
- package/dist/shared/{zotero-plugin-scaffold.DmiRKKLw.d.mts → zotero-plugin-scaffold.CIruZpuO.d.mts} +1 -1
- package/package.json +1 -1
package/dist/cli.d.mts
CHANGED
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.
|
|
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.BLTrbfUc.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.
|
|
39
|
+
const version = "0.7.1";
|
|
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
|
|
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.
|
|
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.BLTrbfUc.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';
|
package/dist/shared/{zotero-plugin-scaffold.D2qdHZn7.mjs → zotero-plugin-scaffold.BLTrbfUc.mjs}
RENAMED
|
@@ -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) {
|
|
@@ -2654,52 +2732,6 @@ async function getGitDiff(from, to = "HEAD", cwd) {
|
|
|
2654
2732
|
return r2;
|
|
2655
2733
|
});
|
|
2656
2734
|
}
|
|
2657
|
-
function parseCommits(commits, config) {
|
|
2658
|
-
return commits.map((commit) => parseGitCommit(commit, config)).filter(Boolean);
|
|
2659
|
-
}
|
|
2660
|
-
const ConventionalCommitRegex = /(?<emoji>:.+:|(\uD83C[\uDF00-\uDFFF])|(\uD83D[\uDC00-\uDE4F\uDE80-\uDEFF])|[\u2600-\u2B55])?( *)?(?<type>[a-z]+)(\((?<scope>.+)\))?(?<breaking>!)?: (?<description>.+)/i;
|
|
2661
|
-
const CoAuthoredByRegex = /co-authored-by:\s*(?<name>.+)(<(?<email>.+)>)/gim;
|
|
2662
|
-
const PullRequestRE = /\([ a-z]*(#\d+)\s*\)/gm;
|
|
2663
|
-
const IssueRE = /(#\d+)/gm;
|
|
2664
|
-
function parseGitCommit(commit, config) {
|
|
2665
|
-
const match = commit.message.match(ConventionalCommitRegex);
|
|
2666
|
-
if (!match) {
|
|
2667
|
-
return null;
|
|
2668
|
-
}
|
|
2669
|
-
const type = match.groups.type;
|
|
2670
|
-
const hasBreakingBody = /breaking change:/i.test(commit.body);
|
|
2671
|
-
let scope = match.groups.scope || "";
|
|
2672
|
-
scope = config.scopeMap[scope] || scope;
|
|
2673
|
-
const isBreaking = Boolean(match.groups.breaking || hasBreakingBody);
|
|
2674
|
-
let description = match.groups.description;
|
|
2675
|
-
const references = [];
|
|
2676
|
-
for (const m of description.matchAll(PullRequestRE)) {
|
|
2677
|
-
references.push({ type: "pull-request", value: m[1] });
|
|
2678
|
-
}
|
|
2679
|
-
for (const m of description.matchAll(IssueRE)) {
|
|
2680
|
-
if (!references.some((i) => i.value === m[1])) {
|
|
2681
|
-
references.push({ type: "issue", value: m[1] });
|
|
2682
|
-
}
|
|
2683
|
-
}
|
|
2684
|
-
references.push({ value: commit.shortHash, type: "hash" });
|
|
2685
|
-
description = description.replace(PullRequestRE, "").trim();
|
|
2686
|
-
const authors = [commit.author];
|
|
2687
|
-
for (const match2 of commit.body.matchAll(CoAuthoredByRegex)) {
|
|
2688
|
-
authors.push({
|
|
2689
|
-
name: (match2.groups.name || "").trim(),
|
|
2690
|
-
email: (match2.groups.email || "").trim()
|
|
2691
|
-
});
|
|
2692
|
-
}
|
|
2693
|
-
return {
|
|
2694
|
-
...commit,
|
|
2695
|
-
authors,
|
|
2696
|
-
description,
|
|
2697
|
-
type,
|
|
2698
|
-
scope,
|
|
2699
|
-
references,
|
|
2700
|
-
isBreaking
|
|
2701
|
-
};
|
|
2702
|
-
}
|
|
2703
2735
|
|
|
2704
2736
|
const providerToRefSpec = {
|
|
2705
2737
|
github: { "pull-request": "pull", hash: "commit", issue: "issues" },
|
|
@@ -2958,82 +2990,50 @@ async function resolveChangelogConfig(config, cwd) {
|
|
|
2958
2990
|
return config;
|
|
2959
2991
|
}
|
|
2960
2992
|
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
constructor(ctx) {
|
|
2965
|
-
this.ctx = ctx;
|
|
2966
|
-
this.isCI = isCI;
|
|
2993
|
+
async function getConventionalChangelog(commits) {
|
|
2994
|
+
if (!commits[0].type) {
|
|
2995
|
+
return commits.map((c) => c.message).join("\n");
|
|
2967
2996
|
}
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
throw new Error("No xpi file found, are you sure you have run build?");
|
|
2997
|
+
const resolvedCommits = commits.map((c) => {
|
|
2998
|
+
if (c.type === "remove") {
|
|
2999
|
+
c.isBreaking = true;
|
|
2972
3000
|
}
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
}
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
}
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
3001
|
+
return c;
|
|
3002
|
+
});
|
|
3003
|
+
const _config = await loadChangelogConfig(process$1.cwd(), {
|
|
3004
|
+
types: {
|
|
3005
|
+
add: { title: "\u{1F680} Enhancements", semver: "minor" },
|
|
3006
|
+
change: { title: "\u{1FA79} Fixes", semver: "patch" },
|
|
3007
|
+
remove: { title: "\u{1FA79} Fixes", semver: "minor" }
|
|
3008
|
+
},
|
|
3009
|
+
hideAuthorEmail: true
|
|
3010
|
+
});
|
|
3011
|
+
const md = await generateMarkDown(resolvedCommits, _config);
|
|
3012
|
+
return md.split("\n").slice(3).join("\n");
|
|
3013
|
+
}
|
|
3014
|
+
async function getGitCommits(currentTag, commitMessageTemplate) {
|
|
3015
|
+
const tags = execSync("git tag -l --sort=v:refname").toString().trim().split("\n");
|
|
3016
|
+
const currentTagIndex = tags.indexOf(currentTag);
|
|
3017
|
+
if (currentTagIndex === -1)
|
|
3018
|
+
throw new Error(`Tag "${currentTag}" not found.`);
|
|
3019
|
+
let previousTagIndex = currentTagIndex - 1;
|
|
3020
|
+
let previousTag;
|
|
3021
|
+
if (currentTagIndex === 0) {
|
|
3022
|
+
previousTag = void 0;
|
|
3023
|
+
} else if (currentTag.includes("-")) {
|
|
3024
|
+
previousTag = tags[previousTagIndex];
|
|
3025
|
+
} else {
|
|
3026
|
+
while (previousTagIndex >= 0 && tags[previousTagIndex].includes("-")) {
|
|
3027
|
+
previousTagIndex--;
|
|
2995
3028
|
}
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
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
|
-
};
|
|
3029
|
+
if (previousTagIndex < 0)
|
|
3030
|
+
previousTag = void 0;
|
|
3031
|
+
else
|
|
3032
|
+
previousTag = tags[previousTagIndex];
|
|
3036
3033
|
}
|
|
3034
|
+
const filterRegex = new RegExp(escapeRegExp(commitMessageTemplate));
|
|
3035
|
+
const rawCommits = (await getGitDiff(previousTag, currentTag)).filter((c) => !filterRegex.test(c.message));
|
|
3036
|
+
return parseCommits(rawCommits, { scopeMap: {} });
|
|
3037
3037
|
}
|
|
3038
3038
|
|
|
3039
3039
|
const mimeTypes = {
|
|
@@ -3236,55 +3236,10 @@ class Release extends Base {
|
|
|
3236
3236
|
`Done in ${((/* @__PURE__ */ new Date()).getTime() - t.getTime()) / 1e3} s.`
|
|
3237
3237
|
);
|
|
3238
3238
|
}
|
|
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
3239
|
async getChangelog() {
|
|
3240
|
+
const { commit, tag } = this.ctx.release.bumpp;
|
|
3286
3241
|
let changelog;
|
|
3287
|
-
const rawCommit = await
|
|
3242
|
+
const rawCommit = await getGitCommits(tag, commit);
|
|
3288
3243
|
if (rawCommit.length === 0) {
|
|
3289
3244
|
return "_No significant changes._";
|
|
3290
3245
|
}
|
|
@@ -3294,7 +3249,7 @@ class Release extends Base {
|
|
|
3294
3249
|
} else if (!!changelogConfig && typeof changelogConfig == "string") {
|
|
3295
3250
|
changelog = execSync(changelogConfig).toString().trim();
|
|
3296
3251
|
} else {
|
|
3297
|
-
changelog = await
|
|
3252
|
+
changelog = await getConventionalChangelog(rawCommit);
|
|
3298
3253
|
}
|
|
3299
3254
|
this.logger.debug(`Got changelog:
|
|
3300
3255
|
${changelog}
|