Clean up build around metar parser and locale

This commit is contained in:
Matt Walsh
2025-08-04 12:02:30 -05:00
parent 9b37bc5c52
commit 75eb81887f
4 changed files with 7 additions and 15 deletions

View File

@@ -1,4 +1,3 @@
/* eslint-disable import/no-extraneous-dependencies */
import 'dotenv/config'; import 'dotenv/config';
import { import {
src, dest, series, parallel, src, dest, series, parallel,
@@ -58,15 +57,6 @@ const jsVendorSources = [
'server/scripts/vendor/auto/suncalc.js', 'server/scripts/vendor/auto/suncalc.js',
]; ];
// Copy metar-taf-parser separately since it's an ES module with locale dependencies
const metarVendorSources = [
'server/scripts/vendor/auto/metar-taf-parser.mjs',
'server/scripts/vendor/auto/locale/en.js',
];
const copyMetarVendor = () => src(metarVendorSources, { base: 'server/scripts/vendor/auto' })
.pipe(dest(`${RESOURCES_PATH}/vendor/auto`));
const compressJsVendor = () => src(jsVendorSources) const compressJsVendor = () => src(jsVendorSources)
.pipe(concat('vendor.min.js')) .pipe(concat('vendor.min.js'))
.pipe(terser()) .pipe(terser())
@@ -210,7 +200,7 @@ const buildPlaylist = async () => {
return file('playlist.json', JSON.stringify(playlist)).pipe(dest('./dist')); return file('playlist.json', JSON.stringify(playlist)).pipe(dest('./dist'));
}; };
const buildDist = series(clean, parallel(buildJs, compressJsVendor, copyMetarVendor, copyCss, compressHtml, copyOtherFiles, copyDataFiles, copyImageSources, buildPlaylist)); const buildDist = series(clean, parallel(buildJs, compressJsVendor, copyCss, compressHtml, copyOtherFiles, copyDataFiles, copyImageSources, buildPlaylist));
// 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

View File

@@ -1,4 +1,3 @@
/* eslint-disable import/no-extraneous-dependencies */
import { src, series, dest } from 'gulp'; import { src, series, dest } from 'gulp';
import { deleteAsync } from 'del'; import { deleteAsync } from 'del';
import rename from 'gulp-rename'; import rename from 'gulp-rename';

View File

@@ -1,5 +1,7 @@
// METAR parsing utilities using metar-taf-parser library // METAR parsing utilities using metar-taf-parser library
import { parseMetar } from '../../vendor/auto/metar-taf-parser.mjs'; import { parseMetar } from '../../vendor/auto/metar-taf-parser.mjs';
// eslint-disable-next-line import/extensions
import en from '../../vendor/auto/locale/en.js';
/** /**
* Augment observation data by parsing METAR when API fields are missing * Augment observation data by parsing METAR when API fields are missing
@@ -14,7 +16,7 @@ const augmentObservationWithMetar = (observation) => {
const metar = { ...observation }; const metar = { ...observation };
try { try {
const metarData = parseMetar(observation.rawMessage); const metarData = parseMetar(observation.rawMessage, { locale: en });
if (observation.windSpeed?.value === null && metarData.wind?.speed !== undefined) { if (observation.windSpeed?.value === null && metarData.wind?.speed !== undefined) {
metar.windSpeed = { metar.windSpeed = {

View File

@@ -44,7 +44,8 @@
"mwood", "mwood",
"unmuted", "unmuted",
"dumpio", "dumpio",
"mesonet" "mesonet",
"metar"
], ],
"cSpell.ignorePaths": [ "cSpell.ignorePaths": [
"**/package-lock.json", "**/package-lock.json",
@@ -82,4 +83,4 @@
"j69.ejs-beautify", "j69.ejs-beautify",
] ]
} }
} }