summaryrefslogtreecommitdiffstats
path: root/themes/luci-theme-footstrap/htdocs/luci-static/resources/fs-version.js
blob: 1a195b40ff6c3ad4854f6d9b651fc475a2695799 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'use strict';
'require baseclass';

/* The installed version, shown on the Appearance tab with no network call; which version is
 * available is the package manager's question.
 *
 * The version stamp is written into the literal below BY FILE NAME, so it must
 * stay in this file. An unstamped checkout
 * stays 'dev'. */
const FS_VERSION = '0.0.0-dev';

/* The parentheses are load-bearing: jsmin's regex-vs-division test is a one-character lookback
 * against a fixed allow-list, and `n` (the last letter of `return`) is not on it, so `return /re/`
 * is read as a division and swallows the rest of the file, exiting 0 (openwrt/luci#8299).
 *
 * The sentinel is matched by shape, never by `FS_VERSION !== '0.0.0-dev'`: terser runs before the
 * Makefile stamps the version, so that comparison folds to a constant and every release reports
 * '(dev)' — an SDK build has no terser step, so it broke only in releases. A regex test is not
 * folded. `-dev$` rather than `^\d+\.\d+\.\d+$`, because dev-sync.sh stamps `git describe`
 * ('0.9.4-12-gabc1234'), which must count as a real version. */
function isReal() { return ((/^\d+\.\d+/).test(FS_VERSION)) && !((/-dev$/).test(FS_VERSION)); }

/* Do not re-add `VERSION` or `isReal` as exports: neither had a caller, and an export nobody
 * imports is a promise to keep the shape stable. */
return baseclass.extend({
	REPO_URL: 'https://github.com/VizzleTF/luci-theme-footstrap',
	label: () => (isReal() ? ('Footstrap v' + FS_VERSION) : 'Footstrap (dev)')
});