allow app.json version overrides to percolate through all loads
This commit is contained in:
parent
3e97bae8fa
commit
61bd454f85
5 changed files with 14 additions and 11 deletions
13
app.js
13
app.js
|
|
@ -30,6 +30,7 @@ let dversion;
|
||||||
let lastmod;
|
let lastmod;
|
||||||
let logger;
|
let logger;
|
||||||
let debug;
|
let debug;
|
||||||
|
let over;
|
||||||
let http;
|
let http;
|
||||||
let util;
|
let util;
|
||||||
let dir;
|
let dir;
|
||||||
|
|
@ -50,13 +51,14 @@ function init(mod) {
|
||||||
lastmod = mod.util.lastmod;
|
lastmod = mod.util.lastmod;
|
||||||
logger = mod.log;
|
logger = mod.log;
|
||||||
debug = mod.env.debug || mod.meta.debug;
|
debug = mod.env.debug || mod.meta.debug;
|
||||||
|
oversion = mod.env.over || mod.meta.over;
|
||||||
http = mod.http;
|
http = mod.http;
|
||||||
util = mod.util;
|
util = mod.util;
|
||||||
dir = mod.dir;
|
dir = mod.dir;
|
||||||
log = mod.log;
|
log = mod.log;
|
||||||
|
|
||||||
// dversion = debug ? `_${version}` : version;
|
dversion = debug ? `_${version}` : version;
|
||||||
dversion = debug ? Date.now().toString(36) : version;
|
// dversion = debug ? Date.now().toString(36) : version;
|
||||||
cacheDir = mod.util.datadir("cache");
|
cacheDir = mod.util.datadir("cache");
|
||||||
|
|
||||||
const approot = "main/gapp";
|
const approot = "main/gapp";
|
||||||
|
|
@ -306,7 +308,7 @@ function initModule(mod, file, dir) {
|
||||||
script: script,
|
script: script,
|
||||||
moddir: dir,
|
moddir: dir,
|
||||||
rootdir: mod.dir,
|
rootdir: mod.dir,
|
||||||
version: version
|
version: oversion || version
|
||||||
},
|
},
|
||||||
env: mod.env,
|
env: mod.env,
|
||||||
pkg: {
|
pkg: {
|
||||||
|
|
@ -608,11 +610,12 @@ function concatCode(array) {
|
||||||
// scripts instead of serving a complete bundle
|
// scripts instead of serving a complete bundle
|
||||||
if (debug) {
|
if (debug) {
|
||||||
const code = [
|
const code = [
|
||||||
|
oversion ? `self.debug_version='${oversion}';` : '',
|
||||||
'self.debug=true;',
|
'self.debug=true;',
|
||||||
'(function() { let load = [ '
|
'(function() { let load = [ '
|
||||||
];
|
];
|
||||||
direct.forEach(file => {
|
direct.forEach(file => {
|
||||||
const vers = cachever[file] || dversion || version;
|
const vers = cachever[file] || oversion || dversion || version;
|
||||||
code.push(`"/${file.replace(/\\/g,'/')}?${vers}",`);
|
code.push(`"/${file.replace(/\\/g,'/')}?${vers}",`);
|
||||||
});
|
});
|
||||||
code.push([
|
code.push([
|
||||||
|
|
@ -815,7 +818,7 @@ function rewriteHtmlVersion(req, res, next) {
|
||||||
let real_write = res.write;
|
let real_write = res.write;
|
||||||
let real_end = res.end;
|
let real_end = res.end;
|
||||||
let mlen = '{{version}}'.length;
|
let mlen = '{{version}}'.length;
|
||||||
let vstr = dversion || version;
|
let vstr = oversion || dversion || version;
|
||||||
if (vstr.length < mlen) {
|
if (vstr.length < mlen) {
|
||||||
vstr = vstr.padStart(mlen,0);
|
vstr = vstr.padStart(mlen,0);
|
||||||
} else if (vstr.length > mlen) {
|
} else if (vstr.length > mlen) {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
const service_worker = navigator.serviceWorker;
|
const service_worker = navigator.serviceWorker;
|
||||||
|
|
||||||
async function start_service_worker() {
|
async function start_service_worker() {
|
||||||
const version = 65;
|
const version = self.gapp.version;
|
||||||
function debug() {
|
function debug() {
|
||||||
console.log(`[${version}]`, ...arguments);
|
console.log(`[${version}]`, ...arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
// install service worker
|
// install service worker
|
||||||
debug('service worker registration', { gapp: self.gapp.version });
|
debug('service worker registration');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// const reg = await navigator.serviceWorker.register("/src/moto/service.js?013", { scope: "/" });
|
// const reg = await navigator.serviceWorker.register("/src/moto/service.js?013", { scope: "/" });
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
let terms = {
|
let terms = {
|
||||||
COPYRIGHT: "Copyright (C) Stewart Allen <sa@grid.space> - All Rights Reserved",
|
COPYRIGHT: "Copyright (C) Stewart Allen <sa@grid.space> - All Rights Reserved",
|
||||||
LICENSE: "See the license.md file included with the source distribution",
|
LICENSE: "See the license.md file included with the source distribution",
|
||||||
VERSION: "3.5.D4"
|
VERSION: this.debug_version || "3.5.D4"
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof(module) === 'object') {
|
if (typeof(module) === 'object') {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const version = 65;
|
const version = self.gapp.version;
|
||||||
const stats = {
|
const stats = {
|
||||||
hit: 0,
|
hit: 0,
|
||||||
miss: 0,
|
miss: 0,
|
||||||
|
|
@ -22,7 +22,7 @@ function report() {
|
||||||
stats.hit = stats.miss = stats.fetch = stats.cache = stats.preload = 0;
|
stats.hit = stats.miss = stats.fetch = stats.cache = stats.preload = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
debug('sw entry point', { gapp: self.gapp.version });
|
debug('sw entry point');
|
||||||
|
|
||||||
const addResourcesToCache = async (resources) => {
|
const addResourcesToCache = async (resources) => {
|
||||||
// debug('cache resources', resources);
|
// debug('cache resources', resources);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
<link rel="stylesheet" type="text/css" href="/kiri/index.css?{{version}}">
|
<link rel="stylesheet" type="text/css" href="/kiri/index.css?{{version}}">
|
||||||
<link href="/font/css/all.min.css" rel="stylesheet">
|
<link href="/font/css/all.min.css" rel="stylesheet">
|
||||||
<link href="/kiri/manifest.json" rel="manifest">
|
<link href="/kiri/manifest.json" rel="manifest">
|
||||||
<script src="/code/cache.js?65" defer></script>
|
<script src="/code/cache.js?{{version}}" defer></script>
|
||||||
<script src="/font/js/all.min.js" crossorigin="anonymous" defer></script>
|
<script src="/font/js/all.min.js" crossorigin="anonymous" defer></script>
|
||||||
<script src="/code/kiri.js?{{version}}"></script>
|
<script src="/code/kiri.js?{{version}}"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue