diff --git a/addon/manifest.json b/addon/manifest.json index a92439a..0c356c6 100644 --- a/addon/manifest.json +++ b/addon/manifest.json @@ -12,7 +12,7 @@ "applications": { "zotero": { "id": "__addonID__", - "update_url": "__updaterdf__", + "update_url": "__updateURL__", "strict_min_version": "6.999", "strict_max_version": "7.0.*" } diff --git a/package.json b/package.json index 23e3f5f..00ee0d1 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,9 @@ "addonRef": "addontemplate", "addonInstance": "AddonTemplate", "prefsPrefix": "extensions.zotero.addontemplate", - "releasepage": "https://github.com/windingwind/zotero-addon-template/releases/latest/download/zotero-addon-template.xpi", - "updaterdf": "https://raw.githubusercontent.com/windingwind/zotero-addon-template/main/update.json" + "releasePage": "https://github.com/windingwind/zotero-addon-template/releases", + "updateJSON": "https://raw.githubusercontent.com/windingwind/zotero-addon-template/main/update.json", + "updateBetaJSON": "https://raw.githubusercontent.com/windingwind/zotero-addon-template/main/update-beta.json" }, "main": "src/index.ts", "scripts": { diff --git a/scripts/build.mjs b/scripts/build.mjs index c747a9d..7fcf720 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -24,6 +24,14 @@ const buildDir = "build"; const isPreRelease = version.includes("-"); +// If it is a pre-release, use update-beta.json +config.updateURL = isPreRelease ? config.updateJSONBeta : config.updateBetaJSON; + +const updateJSONFile = isPreRelease ? "update-beta.json" : "update.json"; +const updateLink = isPreRelease + ? `${config.releasePage}/download/v${version}/${name}.xpi` + : `${config.releasePage}/latest/download/${name}.xpi`; + function copyFileSync(source, target) { var targetFile = target; @@ -122,8 +130,16 @@ function replaceString() { /__homepage__/g, /__buildVersion__/g, /__buildTime__/g, + /__updateLink__/g, + ]; + const replaceTo = [ + author, + description, + homepage, + version, + buildTime, + updateLink, ]; - const replaceTo = [author, description, homepage, version, buildTime]; replaceFrom.push( ...Object.keys(config).map((k) => new RegExp(`__${k}__`, "g")), @@ -144,9 +160,7 @@ function replaceString() { countMatches: true, }; - if (!isPreRelease) { - optionsAddon.files.push("update.json"); - } + optionsAddon.files.push(updateJSONFile); const replaceResult = replaceInFileSync(optionsAddon); @@ -237,13 +251,7 @@ async function main() { copyFolderRecursiveSync("addon", buildDir); - if (isPreRelease) { - console.log( - "[Build] [Warn] Running in pre-release mode. update.json will not be replaced.", - ); - } else { - copyFileSync("update-template.json", "update.json"); - } + copyFileSync("update-template.json", updateJSONFile); await esbuild(); diff --git a/update-beta.json b/update-beta.json new file mode 100644 index 0000000..146d3d7 --- /dev/null +++ b/update-beta.json @@ -0,0 +1,17 @@ +{ + "addons": { + "addontemplate@euclpts.com": { + "updates": [ + { + "version": "1.0.0", + "update_link": "https://github.com/windingwind/zotero-addon-template/releases/latest/download/zotero-addon-template.xpi", + "applications": { + "zotero": { + "strict_min_version": "6.999" + } + } + } + ] + } + } +} diff --git a/update-template.json b/update-template.json index ad674e8..8f65a4c 100644 --- a/update-template.json +++ b/update-template.json @@ -4,7 +4,7 @@ "updates": [ { "version": "__buildVersion__", - "update_link": "__releasepage__", + "update_link": "__updateLink__", "applications": { "zotero": { "strict_min_version": "6.999"