zotero-plugin 1.4.21 → 1.4.23

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 (3) hide show
  1. package/bin/release.js +3 -2
  2. package/package.json +1 -1
  3. package/rdf.js +61 -1
package/bin/release.js CHANGED
@@ -128,14 +128,15 @@ async function update_rdf(releases_tag) {
128
128
  const release = await getRelease(releases_tag, false);
129
129
  const assets = (await octokit.repos.listReleaseAssets({ owner, repo, release_id: release.data.id })).data;
130
130
  for (const asset of assets) {
131
- if (asset.name === 'update.rdf') {
132
- report(`removing update.rdf from ${release.data.tag_name}`);
131
+ if (asset.name === 'update.rdf' || asset.name === 'updates.json') {
132
+ report(`removing ${asset.name} from ${release.data.tag_name}`);
133
133
  // TODO: double asset.id until https://github.com/octokit/rest.js/issues/933 is fixed
134
134
  if (!dryRun)
135
135
  await octokit.repos.deleteReleaseAsset({ owner, repo, asset_id: asset.id });
136
136
  }
137
137
  }
138
138
  await uploadAsset(release, path.join(root_1.default, 'gen/update.rdf'), 'application/rdf+xml');
139
+ await uploadAsset(release, path.join(root_1.default, 'gen/updates.json'), 'application/json');
139
140
  }
140
141
  async function main() {
141
142
  if (process.env.NIGHTLY === 'true')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zotero-plugin",
3
- "version": "1.4.21",
3
+ "version": "1.4.23",
4
4
  "description": "Zotero plugin builder",
5
5
  "homepage": "https://github.com/retorquere/zotero-plugin/wiki",
6
6
  "bin": {
package/rdf.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
- /* eslint-disable no-console, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/restrict-template-expressions */
2
+ /* eslint-disable no-console, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/restrict-template-expressions, no-magic-numbers */
3
+ var _a, _b;
3
4
  Object.defineProperty(exports, "__esModule", { value: true });
4
5
  const tslib_1 = require("tslib");
5
6
  const fs = tslib_1.__importStar(require("fs"));
@@ -50,3 +51,62 @@ console.log('generating update.rdf');
50
51
  template = fs.readFileSync(path.join(__dirname, 'update.rdf.pug'), 'utf8');
51
52
  template = pug.render(template, options_and_vars);
52
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',
65
+ },
66
+ },
67
+ },
68
+ ],
69
+ },
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
+ ];
75
+ for (const i of [`skin/${pkg.id.replace(/@.*/, '')}.png`, `${pkg.id.replace(/@.*/, '')}.png`, 'icon.png']) {
76
+ icons.push({ 48: i });
77
+ icons.push({ 48: i.replace('/zotero-', '/') });
78
+ }
79
+ for (const i of [...icons]) {
80
+ icons.push({ 48: i[48].replace(/[.](svg|png)$/, ext => ({ '.svg': '.png', '.png': '.svg' }[ext])) });
81
+ }
82
+ for (const i of [...icons]) {
83
+ if (i[48].endsWith('.svg')) {
84
+ i[96] = i[48];
85
+ }
86
+ else {
87
+ i[96] = i[48].replace(/([.][^.]+)$/, '@2x$1');
88
+ }
89
+ }
90
+ const icon = icons.find(i => fs.existsSync(path.join(root_1.default, ...i[48].split('/'))));
91
+ if (icon) {
92
+ options_and_vars.icons = {
93
+ 48: icon[48],
94
+ 96: fs.existsSync(path.join(root_1.default, ...icon[96].split('/'))) ? icon[96] : icon[48],
95
+ };
96
+ }
97
+ console.log('generating manifest.json');
98
+ fs.writeFileSync(path.join(root_1.default, 'build/manifest.json'), JSON.stringify({
99
+ manifest_version: 2,
100
+ name: options_and_vars.name,
101
+ version: options_and_vars.version,
102
+ description: options_and_vars.description,
103
+ icons: options_and_vars.icons,
104
+ applications: {
105
+ zotero: {
106
+ id: options_and_vars.id,
107
+ update_url: options_and_vars.updateURL.replace('/update.rdf', '/updates.json'),
108
+ strict_min_version: '6.999',
109
+ strict_max_version: '7.0.*',
110
+ },
111
+ },
112
+ }, null, 2));