zotero-plugin 4.0.2 → 5.0.0

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/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: "5.0.0",
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
  `);
@@ -11619,13 +11623,17 @@ This update may name other issues, but the build just dropped here is for you; i
11619
11623
  const release = await getRelease(releases_tag, false);
11620
11624
  const assets = (await octokit.repos.listReleaseAssets({ owner, repo, release_id: release.data.id })).data;
11621
11625
  const updates = {
11622
- "update.rdf": !pkg.xpi.update || pkg.xpi.update.rdf ? "application/rdf+xml" : "",
11623
- "updates.json": !pkg.xpi.update || pkg.xpi.updates.json ? "application/json" : ""
11626
+ "update.rdf": (pkg.xpi?.minVersion || "6").match(/^6/) ? "application/rdf+xml" : "",
11627
+ "updates.json": (pkg.xpi?.maxVersion || "7").match(/^7/) ? "application/json" : ""
11624
11628
  };
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/install.rdf.pug CHANGED
@@ -25,5 +25,5 @@ RDF(xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.moz
25
25
  em:targetApplication
26
26
  Description
27
27
  em:id zotero@chnm.gmu.edu
28
- em:minVersion #{zotero || '6.0.9'}
29
- em:maxVersion 7.*
28
+ em:minVersion= minVersion
29
+ em:maxVersion= maxVersion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zotero-plugin",
3
- "version": "4.0.2",
3
+ "version": "5.0.0",
4
4
  "description": "Zotero plugin builder",
5
5
  "homepage": "https://github.com/retorquere/zotero-plugin/wiki",
6
6
  "bin": {
package/rdf.js CHANGED
@@ -35,79 +35,83 @@ for (const translation of translations) {
35
35
  pkg.localizedDescriptions[locale] = description;
36
36
  }
37
37
  }
38
- const options_and_vars = Object.assign(Object.assign({}, pkg), { pretty: true });
38
+ const options_and_vars = Object.assign(Object.assign({ minVersion: '6.0.9', maxVersion: '7.*' }, pkg), { pretty: true });
39
39
  try {
40
40
  Object.assign(options_and_vars, JSON.parse(fs.readFileSync(path.join(root_1.default, 'schema', 'supported.json'), 'utf8')));
41
41
  }
42
42
  catch (err) { // eslint-disable-line @typescript-eslint/no-unused-vars
43
43
  // ignore
44
44
  }
45
- let template;
46
- console.log('generating install.rdf');
47
- template = fs.readFileSync(path.join(__dirname, 'install.rdf.pug'), 'utf8');
48
- template = pug.render(template, options_and_vars);
49
- fs.writeFileSync(path.join(root_1.default, 'build/install.rdf'), template, { encoding: 'utf8' });
50
- console.log('generating update.rdf');
51
- template = fs.readFileSync(path.join(__dirname, 'update.rdf.pug'), 'utf8');
52
- template = pug.render(template, options_and_vars);
53
- fs.writeFileSync(path.join(root_1.default, 'gen/update.rdf'), template, { encoding: 'utf8' });
54
- console.log('generating updates.json');
55
- fs.writeFileSync(path.join(root_1.default, 'gen/updates.json'), JSON.stringify({
56
- addons: {
57
- [pkg.id]: {
58
- updates: [
59
- {
60
- version: options_and_vars.version,
61
- update_link: options_and_vars.updateLink,
62
- applications: {
63
- zotero: {
64
- strict_min_version: '6.999',
45
+ if (options_and_vars.minVersion.match(/^6/)) {
46
+ let template;
47
+ console.log('generating install.rdf');
48
+ template = fs.readFileSync(path.join(__dirname, 'install.rdf.pug'), 'utf8');
49
+ template = pug.render(template, options_and_vars);
50
+ fs.writeFileSync(path.join(root_1.default, 'build/install.rdf'), template, { encoding: 'utf8' });
51
+ console.log('generating update.rdf');
52
+ template = fs.readFileSync(path.join(__dirname, 'update.rdf.pug'), 'utf8');
53
+ template = pug.render(template, options_and_vars);
54
+ fs.writeFileSync(path.join(root_1.default, 'gen/update.rdf'), template, { encoding: 'utf8' });
55
+ }
56
+ if (options_and_vars.maxVersion.match(/^7/)) {
57
+ console.log('generating updates.json');
58
+ fs.writeFileSync(path.join(root_1.default, 'gen/updates.json'), JSON.stringify({
59
+ addons: {
60
+ [pkg.id]: {
61
+ updates: [
62
+ {
63
+ version: options_and_vars.version,
64
+ update_link: options_and_vars.updateLink,
65
+ applications: {
66
+ zotero: {
67
+ strict_min_version: '6.999',
68
+ },
65
69
  },
66
70
  },
67
- },
68
- ],
71
+ ],
72
+ },
69
73
  },
70
- },
71
- }, null, 2));
72
- const icons = [
73
- { 48: (_b = (_a = pkg.xpi) === null || _a === void 0 ? void 0 : _a.iconURL) === null || _b === void 0 ? void 0 : _b.replace(/^chrome:\/\/[^/]+\//, '') },
74
- ].filter(i => i[48]);
75
- const basename = pkg.id.replace(/@.*/, '');
76
- for (const i of [`content/skin/${basename}.png`, `skin/${basename}.png`, `${basename}.png`, 'icon.png']) {
77
- icons.push({ 48: i });
78
- icons.push({ 48: i.replace('/zotero-', '/') });
79
- }
80
- for (const i of [...icons]) {
81
- icons.push({ 48: i[48].replace(/[.](svg|png)$/, ext => ({ '.svg': '.png', '.png': '.svg' }[ext])) });
82
- }
83
- for (const i of [...icons]) {
84
- if (i[48].endsWith('.svg')) {
85
- i[96] = i[48];
74
+ }, null, 2));
75
+ const icons = [
76
+ { 48: (_b = (_a = pkg.xpi) === null || _a === void 0 ? void 0 : _a.iconURL) === null || _b === void 0 ? void 0 : _b.replace(/^chrome:\/\/[^/]+\//, '') },
77
+ ].filter(i => i[48]);
78
+ const basename = pkg.id.replace(/@.*/, '');
79
+ for (const i of [`content/skin/${basename}.png`, `skin/${basename}.png`, `${basename}.png`, 'icon.png']) {
80
+ icons.push({ 48: i });
81
+ icons.push({ 48: i.replace('/zotero-', '/') });
86
82
  }
87
- else {
88
- i[96] = i[48].replace(/([.][^.]+)$/, '@2x$1');
83
+ for (const i of [...icons]) {
84
+ icons.push({ 48: i[48].replace(/[.](svg|png)$/, ext => ({ '.svg': '.png', '.png': '.svg' }[ext])) });
89
85
  }
90
- }
91
- const icon = icons.find(i => fs.existsSync(path.join(root_1.default, ...i[48].split('/'))));
92
- if (icon) {
93
- options_and_vars.icons = {
94
- 48: icon[48],
95
- 96: fs.existsSync(path.join(root_1.default, ...icon[96].split('/'))) ? icon[96] : icon[48],
96
- };
97
- }
98
- console.log('generating manifest.json');
99
- fs.writeFileSync(path.join(root_1.default, 'build/manifest.json'), JSON.stringify({
100
- manifest_version: 2,
101
- name: options_and_vars.name,
102
- version: options_and_vars.version,
103
- description: options_and_vars.description,
104
- icons: options_and_vars.icons,
105
- applications: {
106
- zotero: {
107
- id: options_and_vars.id,
108
- update_url: options_and_vars.updateURL.replace('/update.rdf', '/updates.json'),
109
- strict_min_version: '6.999',
110
- strict_max_version: '7.*',
86
+ for (const i of [...icons]) {
87
+ if (i[48].endsWith('.svg')) {
88
+ i[96] = i[48];
89
+ }
90
+ else {
91
+ i[96] = i[48].replace(/([.][^.]+)$/, '@2x$1');
92
+ }
93
+ }
94
+ const icon = icons.find(i => fs.existsSync(path.join(root_1.default, ...i[48].split('/'))));
95
+ if (icon) {
96
+ options_and_vars.icons = {
97
+ 48: icon[48],
98
+ 96: fs.existsSync(path.join(root_1.default, ...icon[96].split('/'))) ? icon[96] : icon[48],
99
+ };
100
+ }
101
+ console.log('generating manifest.json');
102
+ fs.writeFileSync(path.join(root_1.default, 'build/manifest.json'), JSON.stringify({
103
+ manifest_version: 2,
104
+ name: options_and_vars.name,
105
+ version: options_and_vars.version,
106
+ description: options_and_vars.description,
107
+ icons: options_and_vars.icons,
108
+ applications: {
109
+ zotero: {
110
+ id: options_and_vars.id,
111
+ update_url: options_and_vars.updateURL.replace('/update.rdf', '/updates.json'),
112
+ strict_min_version: '6.999',
113
+ strict_max_version: '7.*',
114
+ },
111
115
  },
112
- },
113
- }, null, 2));
116
+ }, null, 2));
117
+ }
package/update.rdf.pug CHANGED
@@ -9,16 +9,16 @@ RDF:RDF(xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http:/
9
9
  em:targetApplication
10
10
  RDF:Description
11
11
  em:id zotero@chnm.gmu.edu
12
- em:minVersion 5.0
13
- em:maxVersion 6.0.*
12
+ em:minVersion= minVersion
13
+ em:maxVersion= maxVersion
14
14
  em:updateLink= updateLink
15
15
  if updateInfoURL
16
16
  em:updateInfoURL= updateInfoURL
17
17
  em:targetApplication
18
18
  RDF:Description
19
19
  em:id juris-m@juris-m.github.io
20
- em:minVersion 5.0
21
- em:maxVersion 6.0.*
20
+ em:minVersion= minVersion
21
+ em:maxVersion= maxVersion
22
22
  em:updateLink= updateLink
23
23
  if updateInfoURL
24
24
  em:updateInfoURL= updateInfoURL