automate version updating

This commit is contained in:
Matt Walsh 2021-01-04 11:58:58 -06:00
parent b003015e44
commit 52aa246f28
9 changed files with 582 additions and 297 deletions

2
dist/index.html vendored
View file

@ -1 +1 @@
<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head><meta charset="utf-8"><link rel="preload" href="fonts/Star4000.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star 4 Radar.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Extended.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Large Compressed.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Large.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Small.woff" as="font" crossorigin="anonymous"><title>WeatherStar 4000+</title><meta name="description" content="Web based WeatherStar 4000 simulator that reports current and forecast weather conditions plus a few extras!"><meta name="keywords" content="WeatherStar 4000+"><meta name="author" content="Matt Walsh"><meta name="application-name" content="WeatherStar 4000+"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"><link rel="manifest" href="manifest.json"><link rel="icon" href="images/Logo192.png"><link rel="stylesheet" type="text/css" href="resources/ws.min.css?_=4.0.0"><script type="text/javascript" src="resources/data.min.js?_=4.0.0"></script><script type="text/javascript" src="resources/ws.min.js?_=4.0.0"></script></head><body><div id="divQuery"><form id="frmGetLatLng"><input id="txtAddress" type="text" value="" placeholder="Zip or City, State"><button id="btnGetGps" type="button" title="Get GPS Location"><img id="imgGetGps" src="images/nav/ic_gps_fixed_black_18dp_1x.png"></button> <input id="btnGetLatLng" type="submit" value="GO"> <input id="btnClearQuery" type="reset" value="Reset"></form><div id="divLat"></div><div id="divLng"></div></div><br><img id="imgPause1x" src="images/nav/ic_pause_white_24dp_1x.png"> <img id="imgPause2x" src="images/nav/ic_pause_white_24dp_2x.png"><div id="version" style="display:none">4.0.0</div><div id="divTwc"><div id="container"><div id="loading" width="640" height="480"><div><div class="title">WeatherStar 4000+</div><div class="instructions">Enter your location above to continue</div></div></div></div><div id="divTwcBottom"><div id="divTwcBottomLeft"><img id="NavigateMenu" class="navButton" src="images/nav/ic_menu_white_24dp_1x.png" title="Menu"> <img id="NavigatePrevious" class="navButton" src="images/nav/ic_skip_previous_white_24dp_1x.png" title="Previous"> <img id="NavigateNext" class="navButton" src="images/nav/ic_skip_next_white_24dp_1x.png" title="Next"> <img id="NavigatePlay" class="navButton" src="images/nav/ic_play_arrow_white_24dp_1x.png" title="Play"></div><div id="divTwcBottomMiddle"><img id="NavigateRefresh" class="navButton" src="images/nav/ic_refresh_white_24dp_1x.png" title="Refresh"></div><div id="divTwcBottomRight"><img id="ToggleFullScreen" class="navButton" src="images/nav/ic_fullscreen_exit_white_24dp_1x.png" title="Exit Fullscreen"></div></div></div><br><div class="info"><a href="https://github.com/netbymatt/ws4kp#weatherstar-4000">More information</a></div><div class="heading">Selected displays</div><div id="enabledDisplays"></div><div id="divInfo">Location: <span id="spanCity"></span> <span id="spanState"></span><br>Station Id: <span id="spanStationId"></span><br>Radar Id: <span id="spanRadarId"></span><br>Zone Id: <span id="spanZoneId"></span><br></div><div id="divRefresh">Last Update: <span id="spanLastRefresh">(None)</span><br><input id="chkAutoRefresh" name="chkAutoRefresh" type="checkbox"><label id="lblRefreshCountDown" for="chkAutoRefresh">Auto Refresh: <span id="spanRefreshCountDown">--:--</span></label></div><div id="divUnits">Units: <input id="radEnglish" name="radUnits" type="radio" value="ENGLISH"><label for="radEnglish">English</label> <input id="radMetric" name="radUnits" type="radio" value="METRIC"><label for="radMetric">Metric</label></div></body></html> <!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head><meta charset="utf-8"><link rel="preload" href="fonts/Star4000.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star 4 Radar.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Extended.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Large Compressed.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Large.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Small.woff" as="font" crossorigin="anonymous"><title>WeatherStar 4000+</title><meta name="description" content="Web based WeatherStar 4000 simulator that reports current and forecast weather conditions plus a few extras!"><meta name="keywords" content="WeatherStar 4000+"><meta name="author" content="Matt Walsh"><meta name="application-name" content="WeatherStar 4000+"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"><link rel="manifest" href="manifest.json"><link rel="icon" href="images/Logo192.png"><link rel="stylesheet" type="text/css" href="resources/ws.min.css?_=4.1.0"><script type="text/javascript" src="resources/data.min.js?_=4.1.0"></script><script type="text/javascript" src="resources/ws.min.js?_=4.1.0"></script></head><body><div id="divQuery"><form id="frmGetLatLng"><input id="txtAddress" type="text" value="" placeholder="Zip or City, State"><button id="btnGetGps" type="button" title="Get GPS Location"><img id="imgGetGps" src="images/nav/ic_gps_fixed_black_18dp_1x.png"></button> <input id="btnGetLatLng" type="submit" value="GO"> <input id="btnClearQuery" type="reset" value="Reset"></form><div id="divLat"></div><div id="divLng"></div></div><br><img id="imgPause1x" src="images/nav/ic_pause_white_24dp_1x.png"> <img id="imgPause2x" src="images/nav/ic_pause_white_24dp_2x.png"><div id="version" style="display:none">4.1.0</div><div id="divTwc"><div id="container"><div id="loading" width="640" height="480"><div><div class="title">WeatherStar 4000+</div><div class="instructions">Enter your location above to continue</div></div></div></div><div id="divTwcBottom"><div id="divTwcBottomLeft"><img id="NavigateMenu" class="navButton" src="images/nav/ic_menu_white_24dp_1x.png" title="Menu"> <img id="NavigatePrevious" class="navButton" src="images/nav/ic_skip_previous_white_24dp_1x.png" title="Previous"> <img id="NavigateNext" class="navButton" src="images/nav/ic_skip_next_white_24dp_1x.png" title="Next"> <img id="NavigatePlay" class="navButton" src="images/nav/ic_play_arrow_white_24dp_1x.png" title="Play"></div><div id="divTwcBottomMiddle"><img id="NavigateRefresh" class="navButton" src="images/nav/ic_refresh_white_24dp_1x.png" title="Refresh"></div><div id="divTwcBottomRight"><img id="ToggleFullScreen" class="navButton" src="images/nav/ic_fullscreen_exit_white_24dp_1x.png" title="Exit Fullscreen"></div></div></div><br><div class="info"><a href="https://github.com/netbymatt/ws4kp#weatherstar-4000">More information</a></div><div class="heading">Selected displays</div><div id="enabledDisplays"></div><div id="divInfo">Location: <span id="spanCity"></span> <span id="spanState"></span><br>Station Id: <span id="spanStationId"></span><br>Radar Id: <span id="spanRadarId"></span><br>Zone Id: <span id="spanZoneId"></span><br></div><div id="divRefresh">Last Update: <span id="spanLastRefresh">(None)</span><br><input id="chkAutoRefresh" name="chkAutoRefresh" type="checkbox"><label id="lblRefreshCountDown" for="chkAutoRefresh">Auto Refresh: <span id="spanRefreshCountDown">--:--</span></label></div><div id="divUnits">Units: <input id="radEnglish" name="radUnits" type="radio" value="ENGLISH"><label for="radEnglish">English</label> <input id="radMetric" name="radUnits" type="radio" value="METRIC"><label for="radMetric">Metric</label></div></body></html>

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,5 @@
const version = require('../version'); /* eslint-disable import/no-extraneous-dependencies */
const fs = require('fs');
const gulp = require('gulp'); const gulp = require('gulp');
const concat = require('gulp-concat'); const concat = require('gulp-concat');
@ -10,23 +11,26 @@ const htmlmin = require('gulp-htmlmin');
const del = require('del'); const del = require('del');
const s3Upload = require('gulp-s3-upload'); const s3Upload = require('gulp-s3-upload');
const clean = () => const clean = () => del(['./dist**']);
del(['./dist**']);
const js_sources_data = [ // get cloudfront
const AWS = require('aws-sdk');
AWS.config.update({ region: 'us-east-1' });
const cloudfront = new AWS.CloudFront({ apiVersion: '2020-01-01' });
const jsSourcesData = [
'server/scripts/data/travelcities.js', 'server/scripts/data/travelcities.js',
'server/scripts/data/regionalcities.js', 'server/scripts/data/regionalcities.js',
'server/scripts/data/stations.js', 'server/scripts/data/stations.js',
'server/scripts/data/states.js', 'server/scripts/data/states.js',
]; ];
gulp.task('compress_js_data', () => gulp.task('compress_js_data', () => gulp.src(jsSourcesData)
gulp.src(js_sources_data) .pipe(concat('data.min.js'))
.pipe(concat('data.min.js')) .pipe(terser())
.pipe(terser()) .pipe(gulp.dest('./dist/resources')));
.pipe(gulp.dest('./dist/resources')),
);
const js_sources = [ const jsSources = [
'server/scripts/vendor/auto/jquery.js', 'server/scripts/vendor/auto/jquery.js',
'server/scripts/vendor/jquery.autocomplete.min.js', 'server/scripts/vendor/jquery.autocomplete.min.js',
'server/scripts/vendor/auto/nosleep.js', 'server/scripts/vendor/auto/nosleep.js',
@ -52,84 +56,70 @@ const js_sources = [
'server/scripts/modules/progress.js', 'server/scripts/modules/progress.js',
'server/scripts/modules/navigation.js', 'server/scripts/modules/navigation.js',
]; ];
gulp.task('compress_js', () => gulp.task('compress_js', () => gulp.src(jsSources)
gulp.src(js_sources) .pipe(concat('ws.min.js'))
.pipe(concat('ws.min.js')) .pipe(terser())
.pipe(terser()) .pipe(gulp.dest('./dist/resources')));
.pipe(gulp.dest('./dist/resources')),
);
const css_sources = [ const cssSources = [
'server/styles/index.css', 'server/styles/index.css',
]; ];
gulp.task('compress_css', () => gulp.task('compress_css', () => gulp.src(cssSources)
gulp.src(css_sources) .pipe(concat('ws.min.css'))
.pipe(concat('ws.min.css')) .pipe(cleanCSS())
.pipe(cleanCSS()) .pipe(gulp.dest('./dist/resources')));
.pipe(gulp.dest('./dist/resources')),
);
const html_sources = [ const htmlSources = [
'views/*.ejs', 'views/*.ejs',
]; ];
gulp.task('compress_html', () => gulp.task('compress_html', () => {
gulp.src(html_sources) const { version } = JSON.parse(fs.readFileSync('./package.json'));
return gulp.src(htmlSources)
.pipe(ejs({ .pipe(ejs({
production: version, production: version,
version, version,
})) }))
.pipe(rename({extname: '.html'})) .pipe(rename({ extname: '.html' }))
.pipe(htmlmin({collapseWhitespace: true})) .pipe(htmlmin({ collapseWhitespace: true }))
.pipe(gulp.dest('./dist')), .pipe(gulp.dest('./dist'));
); });
const other_files = [ const otherFiles = [
'server/robots.txt', 'server/robots.txt',
'server/manifest.json', 'server/manifest.json',
]; ];
gulp.task('copy_other_files', () => gulp.task('copy_other_files', () => gulp.src(otherFiles, { base: 'server/' })
gulp.src(other_files, {base: 'server/'}) .pipe(gulp.dest('./dist')));
.pipe(gulp.dest('./dist')),
);
const s3 = s3Upload({ const s3 = s3Upload({
useIAM: true, useIAM: true,
},{ }, {
region: 'us-east-1', region: 'us-east-1',
}); });
const upload_sources = [ const uploadSources = [
'dist/**', 'dist/**',
]; ];
gulp.task('upload', () => gulp.task('upload', () => gulp.src(uploadSources, { base: './dist' })
gulp.src(upload_sources, {base: './dist'}) .pipe(s3({
.pipe(s3({ Bucket: 'weatherstar',
Bucket: 'weatherstar', StorageClass: 'STANDARD',
StorageClass: 'STANDARD', maps: {
maps: { CacheControl: (keyname) => {
CacheControl: (keyname) => { if (keyname.indexOf('index.html') > -1) return 'max-age=300'; // 10 minutes
if (keyname.indexOf('index.html') > -1) return 'max-age=300'; // 10 minutes return 'max-age=2592000'; // 1 month
return 'max-age=2592000'; // 1 month
},
},
})),
);
gulp.task('invalidate', async () => {
// get cloudfront
const AWS = require('aws-sdk');
AWS.config.update({region: 'us-east-1'});
const cloudfront = new AWS.CloudFront({apiVersion: '2020-01-01'});
return cloudfront.createInvalidation({
DistributionId: 'E9171A4KV8KCW',
InvalidationBatch: {
CallerReference: (new Date()).toLocaleString(),
Paths: {
Quantity: 1,
Items: ['/*'],
}, },
}, },
}).promise(); })));
});
module.exports = gulp.series(clean, gulp.parallel('compress_js','compress_js_data','compress_css','compress_html', 'copy_other_files'), 'upload', 'invalidate'); gulp.task('invalidate', async () => cloudfront.createInvalidation({
DistributionId: 'E9171A4KV8KCW',
InvalidationBatch: {
CallerReference: (new Date()).toLocaleString(),
Paths: {
Quantity: 1,
Items: ['/*'],
},
},
}).promise());
module.exports = gulp.series(clean, gulp.parallel('compress_js', 'compress_js_data', 'compress_css', 'compress_html', 'copy_other_files'), 'upload', 'invalidate');

View file

@ -1,4 +1,17 @@
const gulp = require('gulp'); const gulp = require('gulp');
const bump = require('gulp-bump');
gulp.task('update-vendor', require('./gulp/update-vendor')); gulp.task('update-vendor', require('./gulp/update-vendor'));
gulp.task('publish-frontend', require('./gulp/publish-frontend')); gulp.task('publish-frontend', require('./gulp/publish-frontend'));
gulp.task('bump_patch', () => gulp.src('./package.json')
.pipe(bump())
.pipe(gulp.dest('./')));
gulp.task('bump_minor', () => gulp.src('./package.json')
.pipe(bump({ type: 'minor' }))
.pipe(gulp.dest('./')));
gulp.task('bump_major', () => gulp.src('./package.json')
.pipe(bump({ type: 'major' }))
.pipe(gulp.dest('./')));

View file

@ -1,4 +1,5 @@
// express // express
// eslint-disable-next-line import/no-extraneous-dependencies
const express = require('express'); const express = require('express');
const app = express(); const app = express();
@ -9,6 +10,7 @@ const path = require('path');
app.set('view engine', 'ejs'); app.set('view engine', 'ejs');
// cors pass through // cors pass through
const fs = require('fs');
const corsPassThru = require('./cors'); const corsPassThru = require('./cors');
const radarPassThru = require('./cors/radar'); const radarPassThru = require('./cors/radar');
const outlookPassThru = require('./cors/outlook'); const outlookPassThru = require('./cors/outlook');
@ -19,7 +21,7 @@ app.get('/Conus/*', radarPassThru);
app.get('/products/*', outlookPassThru); app.get('/products/*', outlookPassThru);
// version // version
const version = require('./version'); const { version } = JSON.parse(fs.readFileSync('package.json'));
const index = (req, res) => { const index = (req, res) => {
res.render(path.join(__dirname, 'views/index'), { res.render(path.join(__dirname, 'views/index'), {
@ -41,7 +43,7 @@ const server = app.listen(port, () => {
// graceful shutdown // graceful shutdown
process.on('SIGINT', () => { process.on('SIGINT', () => {
server.close(()=> { server.close(() => {
console.log('Server closed'); console.log('Server closed');
}); });
}); });

703
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{ {
"name": "ws4kp", "name": "ws4kp",
"version": "1.0.0", "version": "4.1.0",
"description": "Welcome to the WeatherStar 4000+ project page!", "description": "Welcome to the WeatherStar 4000+ project page!",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
@ -19,8 +19,8 @@
"devDependencies": { "devDependencies": {
"del": "^6.0.0", "del": "^6.0.0",
"ejs": "^3.1.5", "ejs": "^3.1.5",
"eslint": "^7.12.1", "eslint": "^7.17.0",
"eslint-config-airbnb-base": "^14.2.0", "eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.22.1", "eslint-plugin-import": "^2.22.1",
"express": "^4.17.1", "express": "^4.17.1",
"gulp": "^4.0.2", "gulp": "^4.0.2",
@ -30,13 +30,15 @@
"gulp-htmlmin": "^5.0.1", "gulp-htmlmin": "^5.0.1",
"gulp-rename": "^2.0.0", "gulp-rename": "^2.0.0",
"gulp-s3-upload": "^1.7.3", "gulp-s3-upload": "^1.7.3",
"gulp-terser": "^1.4.1", "gulp-terser": "^2.0.0",
"jquery": "^3.5.1", "jquery": "^3.5.1",
"jquery-touchswipe": "^1.6.19", "jquery-touchswipe": "^1.6.19",
"luxon": "^1.25.0", "luxon": "^1.25.0",
"nosleep.js": "^0.11.0", "nosleep.js": "^0.12.0",
"suncalc": "^1.8.0", "suncalc": "^1.8.0",
"swiped-events": "^1.1.4" "swiped-events": "^1.1.4"
}, },
"dependencies": {} "dependencies": {
"gulp-bump": "^3.2.0"
}
} }

View file

@ -10,6 +10,8 @@ const icons = (() => {
// grab everything after the last slash ending at any of these: ?&, // grab everything after the last slash ending at any of these: ?&,
const afterLastSlash = link.toLowerCase().match(/[^/]+$/)[0]; const afterLastSlash = link.toLowerCase().match(/[^/]+$/)[0];
let conditionName = afterLastSlash.match(/(.*?)[,?&.]/)[1]; let conditionName = afterLastSlash.match(/(.*?)[,?&.]/)[1];
// using probability as a crude heavy/light indication where possible
const value = +(link.match(/,(\d{2,3})/) ?? [0, 100])[1];
// if a 'DualImage' is captured, adjust to just the j parameter // if a 'DualImage' is captured, adjust to just the j parameter
if (conditionName === 'dualimage') { if (conditionName === 'dualimage') {
@ -81,7 +83,8 @@ const icons = (() => {
case 'snow': case 'snow':
case 'snow-n': case 'snow-n':
return addPath('Heavy-Snow-1994-2.gif'); if (value > 50) return addPath('Heavy-Snow-1994-2.gif');
return addPath('Light-Snow.gif');
case 'rain_snow': case 'rain_snow':
return addPath('Rain-Snow-1992.gif'); return addPath('Rain-Snow-1992.gif');
@ -146,6 +149,8 @@ const icons = (() => {
// grab everything after the last slash ending at any of these: ?&, // grab everything after the last slash ending at any of these: ?&,
const afterLastSlash = link.toLowerCase().match(/[^/]+$/)[0]; const afterLastSlash = link.toLowerCase().match(/[^/]+$/)[0];
let conditionName = afterLastSlash.match(/(.*?)[,?&.]/)[1]; let conditionName = afterLastSlash.match(/(.*?)[,?&.]/)[1];
// using probability as a crude heavy/light indication where possible
const value = +(link.match(/,(\d{2,3})/) ?? [0, 100])[1];
// if a 'DualImage' is captured, adjust to just the j parameter // if a 'DualImage' is captured, adjust to just the j parameter
if (conditionName === 'dualimage') { if (conditionName === 'dualimage') {
@ -214,7 +219,8 @@ const icons = (() => {
case 'snow': case 'snow':
case 'snow-n': case 'snow-n':
return addPath('CC_Snow.gif'); if (value > 50) return addPath('CC_Snow.gif');
return addPath('CC_SnowShowers.gif');
case 'rain_snow': case 'rain_snow':
return addPath('CC_RainSnow.gif'); return addPath('CC_RainSnow.gif');

View file

@ -1 +0,0 @@
module.exports = '4.0.0';