zotero-plugin 4.0.2 → 4.0.3

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.
Files changed (2) hide show
  1. package/bin/release.js +30 -15
  2. package/package.json +1 -1
package/bin/release.js CHANGED
@@ -8137,7 +8137,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
8137
8137
  "package.json"(exports, module) {
8138
8138
  module.exports = {
8139
8139
  name: "zotero-plugin",
8140
- version: "4.0.2",
8140
+ version: "4.0.3",
8141
8141
  description: "Zotero plugin builder",
8142
8142
  homepage: "https://github.com/retorquere/zotero-plugin/wiki",
8143
8143
  bin: {
@@ -11509,8 +11509,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
11509
11509
  process.on("unhandledRejection", (up) => {
11510
11510
  throw up;
11511
11511
  });
11512
- program.version(require_package2().version).option("-r, --release-message <value>", "add message to github release").option("-x, --xpi <value>", "xpi filename template", "{name}-{version}.xpi").option("-d, --dry-run", "dry run", !ContinuousIntegration.service).option("-p, --pre-release", "release is a pre-release").parse(process.argv);
11512
+ program.version(require_package2().version).option("-r, --release-message <value>", "add message to github release").option("-x, --xpi <value>", "xpi filename template", "{name}-{version}.xpi").option("-d, --dry-run", "dry run", !ContinuousIntegration.service).option("-p, --pre-release", "release is a pre-release").option("-t, --tag", "tag for release", ContinuousIntegration.tag).parse(process.argv);
11513
11513
  var options = program.opts();
11514
+ if (options.tag && options.tag !== ContinuousIntegration.tag) {
11515
+ console.log("dry-run: tag specified manually, switching to dry-run mode");
11516
+ options.dryRun = true;
11517
+ }
11514
11518
  if (options.releaseMessage?.startsWith("@")) options.releaseMessage = fs2.readFileSync(options.releaseMessage.substring(1), "utf-8");
11515
11519
  var octokit = new Octokit2({ auth: `token ${process.env.GITHUB_TOKEN}` });
11516
11520
  var pkg = __require(path2.join(root_default, "package.json"));
@@ -11529,10 +11533,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
11529
11533
  console.log(`${options.dryRun ? "dry-run: " : ""}${msg}`);
11530
11534
  }
11531
11535
  if (ContinuousIntegration.pull_request) bail("Not releasing pull requests", 0);
11532
- if (ContinuousIntegration.tag) {
11533
- if (`v${pkg.version}` !== ContinuousIntegration.tag) bail(`Building tag ${ContinuousIntegration.tag}, but package version is ${pkg.version}`);
11536
+ if (options.tag) {
11537
+ if (`v${pkg.version}` !== options.tag) bail(`Building tag ${options.tag}, but package version is ${pkg.version}`);
11534
11538
  const releaseBranches = ["main", "master"].concat(pkg.xpi.releaseBranches || []);
11535
- if (ContinuousIntegration.branch && !releaseBranches.includes(ContinuousIntegration.branch)) bail(`Building tag ${ContinuousIntegration.tag}, but branch is ${ContinuousIntegration.branch}`);
11539
+ if (ContinuousIntegration.branch && !releaseBranches.includes(ContinuousIntegration.branch)) bail(`Building tag ${options.tag}, but branch is ${ContinuousIntegration.branch}`);
11536
11540
  }
11537
11541
  var tags = /* @__PURE__ */ new Set();
11538
11542
  for (let regex = /(?:^|\s)(?:#)([a-zA-Z\d]+)/gm, tag; tag = regex.exec(ContinuousIntegration.commit_message); ) {
@@ -11547,13 +11551,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
11547
11551
  if (tags.has("noannounce")) return;
11548
11552
  let build;
11549
11553
  let reason = "";
11550
- if (ContinuousIntegration.tag) {
11554
+ if (options.tag) {
11551
11555
  build = `${options.preRelease ? "pre-" : ""}release ${ContinuousIntegration.tag}`;
11552
11556
  } else {
11553
11557
  build = `test build ${version_default}`;
11554
11558
  }
11555
11559
  const link = `[${build}](https://github.com/${owner}/${repo}/releases/download/${release.data.tag_name}/${pkg.name}-${version_default}.xpi)`;
11556
- if (!ContinuousIntegration.tag) {
11560
+ if (!options.tag) {
11557
11561
  reason = ` (${JSON.stringify(ContinuousIntegration.commit_message)})`;
11558
11562
  reason += `
11559
11563
 
@@ -11568,7 +11572,7 @@ This update may name other issues, but the build just dropped here is for you; i
11568
11572
  await octokit.issues.createComment({ owner, repo, issue_number, body });
11569
11573
  if (locked) await octokit.issues.lock({ owner, repo, issue_number });
11570
11574
  } catch (error) {
11571
- console.log(`Failed to announce '${build}: ${reason}' on ${issue_number}`);
11575
+ report(`Failed to announce '${build}: ${reason}' on ${issue_number}`);
11572
11576
  }
11573
11577
  if (process.env.GITHUB_ENV) fs2.appendFileSync(process.env.GITHUB_ENV, `XPI_RELEASED=${issue_number}
11574
11578
  `);
@@ -11625,7 +11629,11 @@ This update may name other issues, but the build just dropped here is for you; i
11625
11629
  for (const asset of assets) {
11626
11630
  if (asset.name in updates && updates[asset.name]) {
11627
11631
  report(`removing ${asset.name} from ${release.data.tag_name}`);
11628
- if (!options.dryRun) await octokit.repos.deleteReleaseAsset({ owner, repo, asset_id: asset.id });
11632
+ if (options.dryRun) {
11633
+ report(`update ${asset.name}`);
11634
+ } else {
11635
+ await octokit.repos.deleteReleaseAsset({ owner, repo, asset_id: asset.id });
11636
+ }
11629
11637
  }
11630
11638
  }
11631
11639
  for (const [pointer, mimetype] of Object.entries(updates)) {
@@ -11640,14 +11648,17 @@ This update may name other issues, but the build just dropped here is for you; i
11640
11648
  }
11641
11649
  }
11642
11650
  let release;
11643
- if (ContinuousIntegration.tag) {
11651
+ if (options.tag) {
11644
11652
  try {
11645
- await octokit.repos.getReleaseByTag({ owner, repo, tag: ContinuousIntegration.tag });
11646
- bail(`release ${ContinuousIntegration.tag} exists, bailing`);
11653
+ await octokit.repos.getReleaseByTag({ owner, repo, tag: options.tag });
11654
+ if (!options.dryRun) bail(`release ${options.tag} exists, bailing`);
11647
11655
  } catch (err) {
11648
11656
  }
11649
- report(`uploading ${xpi} to new release ${ContinuousIntegration.tag}`);
11650
- if (!options.dryRun) {
11657
+ if (options.dryRun) {
11658
+ report(`create release ${options.tag}`);
11659
+ report(`upload asset ${xpi}`);
11660
+ } else {
11661
+ report(`uploading ${xpi} to new release ${ContinuousIntegration.tag}`);
11651
11662
  release = await octokit.repos.createRelease({ owner, repo, tag_name: ContinuousIntegration.tag, prerelease: !!options.preRelease, body: options.releaseMessage || "" });
11652
11663
  await uploadAsset(release, path2.join(root_default, `xpi/${xpi}`), "application/vnd.zotero.plugin");
11653
11664
  }
@@ -11657,7 +11668,11 @@ This update may name other issues, but the build just dropped here is for you; i
11657
11668
  for (const asset of release.data.assets || []) {
11658
11669
  if (asset.name.endsWith(".xpi") && asset.created_at < EXPIRE_BUILDS) {
11659
11670
  report(`deleting ${asset.name}`);
11660
- if (!options.dryRun) await octokit.repos.deleteReleaseAsset({ owner, repo, asset_id: asset.id });
11671
+ if (options.dryRun) {
11672
+ report(`delete asset ${asset.name}`);
11673
+ } else {
11674
+ await octokit.repos.deleteReleaseAsset({ owner, repo, asset_id: asset.id });
11675
+ }
11661
11676
  }
11662
11677
  }
11663
11678
  await uploadAsset(release, path2.join(root_default, `xpi/${xpi}`), "application/vnd.zotero.plugin");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zotero-plugin",
3
- "version": "4.0.2",
3
+ "version": "4.0.3",
4
4
  "description": "Zotero plugin builder",
5
5
  "homepage": "https://github.com/retorquere/zotero-plugin/wiki",
6
6
  "bin": {