diff --git a/scripts/build.sh b/scripts/build.sh index a61df1bd..2c0e687c 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -64,8 +64,7 @@ if [ "$1" != "--no-native" ]; then fi fi -(webpack --display errors-only --bail\ - && scripts/git_version.sh) +webpack --display errors-only --bail scripts/bodgecss.sh scripts/authors.sh diff --git a/scripts/git_version.sh b/scripts/git_version.sh deleted file mode 100755 index 5ddb3e39..00000000 --- a/scripts/git_version.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env sh - -gitversion=pre$(git rev-list --count HEAD)-$(git rev-parse --short HEAD) -if grep -Fq 'tridactyl.vim@cmcaine' ./src/manifest.json ; then - gitversion="" -fi -manversion=$(grep '"version":' ./src/manifest.json | cut -d":" -f2 | tr -d \" | tr -d , | cut -d" " -f2) -version=$manversion$gitversion - -sed -i.bak 's/REPLACE_ME_WITH_THE_VERSION_USING_SED/'"$version"'/' ./build/background.js -sed -i.bak 's/REPLACE_ME_WITH_THE_VERSION_USING_SED/'"$version"'/' ./build/content.js -sed -i.bak 's/REPLACE_ME_WITH_THE_VERSION_USING_SED/'"$version"'/' ./build/static/newtab.html -rm ./build/background.js.bak -rm ./build/static/newtab.html.bak diff --git a/scripts/version.js b/scripts/version.js index 4715e6ce..d153ab1b 100755 --- a/scripts/version.js +++ b/scripts/version.js @@ -20,6 +20,15 @@ async function add_beta(versionstr) { }) } +async function get_hash() { + return new Promise((resolve, err) => { + exec("git rev-parse --short HEAD", (execerr, stdout, stderr) => { + if (execerr) err(execerr) + resolve(stdout.trim()) + }) + }) +} + function make_update_json(versionstr) { return { addons: { @@ -66,6 +75,7 @@ async function main() { manifest.version, Number(process.argv[3]), ) + manifest.version_name = manifest.version save_manifest(filename, manifest) exec( `git add ${filename} && git commit -m 'release ${ @@ -81,14 +91,19 @@ async function main() { filename = "./build/manifest.json" manifest = require("." + filename) manifest.version = await add_beta(manifest.version) + manifest.version_name = manifest.version + "-" + (await get_hash()) manifest.applications.gecko.update_url = "https://tridactyl.cmcaine.co.uk/betas/updates.json" - // Make and write updates.json - save_manifest( - "../../public_html/betas/updates.json", - make_update_json(manifest.version), - ) + try { + // Make and write updates.json + save_manifest( + "../../public_html/betas/updates.json", + make_update_json(manifest.version), + ) + } catch(e) { + console.warn("updates.json wasn't updated: " + e) + } // Save manifest.json save_manifest(filename, manifest) diff --git a/src/excmds.ts b/src/excmds.ts index 188f12dd..9d3de467 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -74,7 +74,7 @@ // Shared import * as Messaging from "@src/lib/messaging" -import { browserBg, activeTab, activeTabId, activeTabContainerId, openInNewTab, openInNewWindow, openInTab, queryAndURLwrangler } from "@src/lib/webext" +import { getTriVersion, browserBg, activeTab, activeTabId, activeTabContainerId, openInNewTab, openInNewWindow, openInTab, queryAndURLwrangler } from "@src/lib/webext" import * as Container from "@src/lib/containers" import state from "@src/state" import { contentState, ModeName } from "@src/content/state_content" @@ -117,7 +117,7 @@ export const cmd_params = new Map>() const logger = new Logging.Logger("excmds") /** @hidden **/ -const TRI_VERSION = "REPLACE_ME_WITH_THE_VERSION_USING_SED" +const TRI_VERSION = getTriVersion() //#content_helper // { diff --git a/src/lib/updates.ts b/src/lib/updates.ts index 42c18d03..03b7e920 100644 --- a/src/lib/updates.ts +++ b/src/lib/updates.ts @@ -10,10 +10,11 @@ import * as RssParser from "rss-parser" import * as SemverCompare from "semver-compare" import * as Config from "@src/lib/config" import * as Logging from "@src/lib/logging" +import { getTriVersion } from "@src/lib/webext" const logger = new Logging.Logger("updates") -const TRI_VERSION = "REPLACE_ME_WITH_THE_VERSION_USING_SED" +const TRI_VERSION = getTriVersion() interface TriVersionFeedItem { releaseDate: Date diff --git a/src/lib/webext.ts b/src/lib/webext.ts index d45a9f2f..e16529f9 100644 --- a/src/lib/webext.ts +++ b/src/lib/webext.ts @@ -7,6 +7,16 @@ export function inContentScript() { return getContext() === "content" } +export function getTriVersion() { + const manifest = browser.runtime.getManifest() + return manifest.version_name +} + +export function getPrettyTriVersion() { + const manifest = browser.runtime.getManifest() + return manifest.name + " " + getTriVersion() +} + export function notBackground() { return getContext() !== "background" } diff --git a/src/newtab.ts b/src/newtab.ts index 06807b4d..574a8678 100644 --- a/src/newtab.ts +++ b/src/newtab.ts @@ -2,6 +2,7 @@ import * as Messaging from "@src/lib/messaging" import * as config from "@src/lib/config" +import { getPrettyTriVersion } from "@src/lib/webext" // These functions work with the elements created by tridactyl/scripts/newtab.md.sh function getChangelogDiv() { @@ -52,3 +53,7 @@ window.addEventListener("load", _ => { ) } }) + +document.getElementById( + "tridactyl-version-number", +).textContent = getPrettyTriVersion() diff --git a/src/static/newtab.md b/src/static/newtab.md index b0d08336..f4ac3995 100644 --- a/src/static/newtab.md +++ b/src/static/newtab.md @@ -1,7 +1,3 @@ -![Tridactyl logo](logo/Tridactyl_100px.png) - -# Tridactyl REPLACE_ME_WITH_THE_VERSION_USING_SED - Tridactyl has to override your new tab page due to WebExtension limitations. You can learn how to change it at the bottom of the page, otherwise please read on for some tips and tricks. - _Breaking change_: Tridactyl no longer tries to keep its configuration in sync automatically with the Firefox Sync storage. The `storageloc` setting has been removed. If you wish to synchronise your configurations, you can use the new `:firefoxsync{push,pull}` manually. diff --git a/src/static/newtab.template.html b/src/static/newtab.template.html index e285f1c8..54fa367b 100644 --- a/src/static/newtab.template.html +++ b/src/static/newtab.template.html @@ -10,6 +10,8 @@ + Tridactyl logo +

Tridactyl

REPLACETHIS