mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-18 01:31:05 -07:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4903b95fec | ||
|
|
b43fb32820 | ||
|
|
0d0c4ec452 | ||
|
|
093b6ac239 | ||
|
|
517c560ef6 |
@@ -2,7 +2,7 @@ FROM node:24-alpine
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
RUN npm ci --omit=dev --legacy-peer-deps
|
RUN npm ci --legacy-peer-deps
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|||||||
@@ -97,23 +97,27 @@ const copyCss = () => src(cssSources)
|
|||||||
const htmlSources = [
|
const htmlSources = [
|
||||||
'views/*.ejs',
|
'views/*.ejs',
|
||||||
];
|
];
|
||||||
const compressHtml = async () => {
|
const packageJson = await readFile('package.json');
|
||||||
const packageJson = await readFile('package.json');
|
let { version } = JSON.parse(packageJson);
|
||||||
const { version } = JSON.parse(packageJson);
|
const previewVersion = async () => {
|
||||||
|
// generate a relatively unique timestamp for cache invalidation of the preview site
|
||||||
return src(htmlSources)
|
const now = new Date();
|
||||||
.pipe(ejs({
|
const msNow = now.getTime() % 1_000_000;
|
||||||
production: version,
|
version = msNow.toString();
|
||||||
serverAvailable: false,
|
|
||||||
version,
|
|
||||||
OVERRIDES,
|
|
||||||
query: {},
|
|
||||||
}))
|
|
||||||
.pipe(rename({ extname: '.html' }))
|
|
||||||
.pipe(htmlmin({ collapseWhitespace: true }))
|
|
||||||
.pipe(dest('./dist'));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const compressHtml = async () => src(htmlSources)
|
||||||
|
.pipe(ejs({
|
||||||
|
production: version,
|
||||||
|
serverAvailable: false,
|
||||||
|
version,
|
||||||
|
OVERRIDES,
|
||||||
|
query: {},
|
||||||
|
}))
|
||||||
|
.pipe(rename({ extname: '.html' }))
|
||||||
|
.pipe(htmlmin({ collapseWhitespace: true }))
|
||||||
|
.pipe(dest('./dist'));
|
||||||
|
|
||||||
const otherFiles = [
|
const otherFiles = [
|
||||||
'server/robots.txt',
|
'server/robots.txt',
|
||||||
'server/manifest.json',
|
'server/manifest.json',
|
||||||
@@ -205,7 +209,7 @@ const buildDist = series(clean, parallel(buildJs, compressJsVendor, copyCss, com
|
|||||||
// upload_images could be in parallel with upload, but _images logs a lot and has little changes
|
// upload_images could be in parallel with upload, but _images logs a lot and has little changes
|
||||||
// by running upload last the majority of the changes will be at the bottom of the log for easy viewing
|
// by running upload last the majority of the changes will be at the bottom of the log for easy viewing
|
||||||
const publishFrontend = series(buildDist, uploadImages, upload, invalidate);
|
const publishFrontend = series(buildDist, uploadImages, upload, invalidate);
|
||||||
const stageFrontend = series(buildDist, uploadImagesPreview, uploadPreview, invalidatePreview);
|
const stageFrontend = series(previewVersion, buildDist, uploadImagesPreview, uploadPreview, invalidatePreview);
|
||||||
|
|
||||||
export default publishFrontend;
|
export default publishFrontend;
|
||||||
|
|
||||||
|
|||||||
2488
package-lock.json
generated
2488
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ws4kp",
|
"name": "ws4kp",
|
||||||
"version": "6.1.6",
|
"version": "6.1.7",
|
||||||
"description": "Welcome to the WeatherStar 4000+ project page!",
|
"description": "Welcome to the WeatherStar 4000+ project page!",
|
||||||
"main": "index.mjs",
|
"main": "index.mjs",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
@@ -56,6 +56,7 @@
|
|||||||
"dotenv": "^17.0.1",
|
"dotenv": "^17.0.1",
|
||||||
"ejs": "^3.1.5",
|
"ejs": "^3.1.5",
|
||||||
"express": "^5.1.0",
|
"express": "^5.1.0",
|
||||||
"metar-taf-parser": "^9.0.0"
|
"metar-taf-parser": "^9.0.0",
|
||||||
|
"npm": "^11.6.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,32 @@ import { parseMetar } from '../../vendor/auto/metar-taf-parser.mjs';
|
|||||||
// eslint-disable-next-line import/extensions
|
// eslint-disable-next-line import/extensions
|
||||||
import en from '../../vendor/auto/locale/en.js';
|
import en from '../../vendor/auto/locale/en.js';
|
||||||
|
|
||||||
|
// metar-taf-parser requires regex lookbehind
|
||||||
|
// this does not work in iOS < 16.4
|
||||||
|
// this is a detection algorithm for iOS versions
|
||||||
|
const isIos = /iP(ad|od|hone)/i.test(window.navigator.userAgent);
|
||||||
|
let iosVersionOk = false;
|
||||||
|
if (isIos) {
|
||||||
|
// regex match the version string
|
||||||
|
const iosVersionRaw = /OS (\d+)_(\d+)/.exec(window.navigator.userAgent);
|
||||||
|
// check for match
|
||||||
|
if (iosVersionRaw) {
|
||||||
|
// break into parts
|
||||||
|
const iosVersionMajor = parseInt(iosVersionRaw[1], 10);
|
||||||
|
const iosVersionMinor = parseInt(iosVersionRaw[2], 10);
|
||||||
|
if (iosVersionMajor > 16) iosVersionOk = true;
|
||||||
|
if (iosVersionMajor === 16 && iosVersionMinor >= 4) iosVersionOk = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Augment observation data by parsing METAR when API fields are missing
|
* Augment observation data by parsing METAR when API fields are missing
|
||||||
* @param {Object} observation - The observation object from the API
|
* @param {Object} observation - The observation object from the API
|
||||||
* @returns {Object} - Augmented observation with parsed METAR data filled in
|
* @returns {Object} - Augmented observation with parsed METAR data filled in
|
||||||
*/
|
*/
|
||||||
const augmentObservationWithMetar = (observation) => {
|
const augmentObservationWithMetar = (observation) => {
|
||||||
if (!observation?.rawMessage) {
|
// check for a metar message and for unusable ios versions
|
||||||
|
if (!observation?.rawMessage || (isIos && !iosVersionOk)) {
|
||||||
return observation;
|
return observation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user