gtfs-to-html 2.11.0 → 2.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/app/index.js +34 -7
- package/dist/app/index.js.map +1 -1
- package/dist/bin/gtfs-to-html.js +52 -11
- package/dist/bin/gtfs-to-html.js.map +1 -1
- package/dist/index.js +52 -11
- package/dist/index.js.map +1 -1
- package/docker/Dockerfile +2 -1
- package/package.json +2 -2
package/dist/bin/gtfs-to-html.js
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
rm
|
|
25
25
|
} from "fs/promises";
|
|
26
26
|
import { homedir } from "os";
|
|
27
|
+
import { findPackageJSON } from "module";
|
|
27
28
|
import * as _ from "lodash-es";
|
|
28
29
|
import { uniqBy as uniqBy2 } from "lodash-es";
|
|
29
30
|
import archiver from "archiver";
|
|
@@ -61,6 +62,9 @@ function toGTFSTime(time) {
|
|
|
61
62
|
return time.format("HH:mm:ss");
|
|
62
63
|
}
|
|
63
64
|
function calendarToCalendarCode(c) {
|
|
65
|
+
if (Object.values(c).every((value) => value === null)) {
|
|
66
|
+
return "";
|
|
67
|
+
}
|
|
64
68
|
return `${c.monday}${c.tuesday}${c.wednesday}${c.thursday}${c.friday}${c.saturday}${c.sunday}`;
|
|
65
69
|
}
|
|
66
70
|
function calendarCodeToCalendar(code) {
|
|
@@ -493,7 +497,7 @@ function formatTripNameForCSV(trip, timetable) {
|
|
|
493
497
|
// package.json
|
|
494
498
|
var package_default = {
|
|
495
499
|
name: "gtfs-to-html",
|
|
496
|
-
version: "2.11.
|
|
500
|
+
version: "2.11.2",
|
|
497
501
|
private: false,
|
|
498
502
|
description: "Build human readable transit timetables as HTML, PDF or CSV from GTFS",
|
|
499
503
|
keywords: [
|
|
@@ -583,7 +587,7 @@ var package_default = {
|
|
|
583
587
|
typescript: "^5.9.2"
|
|
584
588
|
},
|
|
585
589
|
engines: {
|
|
586
|
-
node: ">=
|
|
590
|
+
node: ">= 22"
|
|
587
591
|
},
|
|
588
592
|
"release-it": {
|
|
589
593
|
github: {
|
|
@@ -885,7 +889,15 @@ var createTimetable = ({
|
|
|
885
889
|
...calendars?.map((calendar) => calendar.service_id) ?? [],
|
|
886
890
|
...calendarDates?.map((calendarDate) => calendarDate.service_id) ?? []
|
|
887
891
|
]);
|
|
888
|
-
const days2 = {
|
|
892
|
+
const days2 = {
|
|
893
|
+
monday: null,
|
|
894
|
+
tuesday: null,
|
|
895
|
+
wednesday: null,
|
|
896
|
+
thursday: null,
|
|
897
|
+
friday: null,
|
|
898
|
+
saturday: null,
|
|
899
|
+
sunday: null
|
|
900
|
+
};
|
|
889
901
|
let startDate = null;
|
|
890
902
|
let endDate = null;
|
|
891
903
|
if (calendars && calendars.length > 0) {
|
|
@@ -904,7 +916,8 @@ var createTimetable = ({
|
|
|
904
916
|
const timetableId = formatTimetableId({
|
|
905
917
|
routeIds: [route.route_id],
|
|
906
918
|
directionId,
|
|
907
|
-
days: days2
|
|
919
|
+
days: days2,
|
|
920
|
+
dates: calendarDates?.map((calendarDate) => calendarDate.date)
|
|
908
921
|
});
|
|
909
922
|
return {
|
|
910
923
|
timetable_id: timetableId,
|
|
@@ -977,6 +990,9 @@ var convertRoutesToTimetablePages = (config) => {
|
|
|
977
990
|
}
|
|
978
991
|
}
|
|
979
992
|
}
|
|
993
|
+
if (timetables.length === 0) {
|
|
994
|
+
continue;
|
|
995
|
+
}
|
|
980
996
|
if (config.groupTimetablesIntoPages === true) {
|
|
981
997
|
timetablePages.push(
|
|
982
998
|
createTimetablePage({
|
|
@@ -2067,9 +2083,15 @@ function formatFrequency(frequency, config) {
|
|
|
2067
2083
|
function formatTimetableId({
|
|
2068
2084
|
routeIds,
|
|
2069
2085
|
directionId,
|
|
2070
|
-
days: days2
|
|
2086
|
+
days: days2,
|
|
2087
|
+
dates
|
|
2071
2088
|
}) {
|
|
2072
|
-
let timetableId =
|
|
2089
|
+
let timetableId = routeIds.join("_");
|
|
2090
|
+
if (calendarToCalendarCode(days2)) {
|
|
2091
|
+
timetableId += `|${calendarToCalendarCode(days2)}`;
|
|
2092
|
+
} else if (dates && dates.length > 0) {
|
|
2093
|
+
timetableId += `|${dates.join("_")}`;
|
|
2094
|
+
}
|
|
2073
2095
|
if (!isNullOrEmpty(directionId)) {
|
|
2074
2096
|
timetableId += `|${directionId}`;
|
|
2075
2097
|
}
|
|
@@ -2340,18 +2362,32 @@ async function copyStaticAssets(config, outputPath) {
|
|
|
2340
2362
|
}
|
|
2341
2363
|
if (config.hasGtfsRealtimeVehiclePositions || config.hasGtfsRealtimeTripUpdates || config.hasGtfsRealtimeAlerts) {
|
|
2342
2364
|
await copyFile(
|
|
2343
|
-
|
|
2365
|
+
join(
|
|
2366
|
+
dirname(findPackageJSON("pbf", import.meta.url)),
|
|
2367
|
+
"dist/pbf.js"
|
|
2368
|
+
),
|
|
2344
2369
|
join(outputPath, "js/pbf.js")
|
|
2345
2370
|
);
|
|
2346
2371
|
await copyFile(
|
|
2347
|
-
|
|
2372
|
+
join(
|
|
2373
|
+
dirname(
|
|
2374
|
+
findPackageJSON(
|
|
2375
|
+
"gtfs-realtime-pbf-js-module",
|
|
2376
|
+
import.meta.url
|
|
2377
|
+
)
|
|
2378
|
+
),
|
|
2379
|
+
"gtfs-realtime.browser.proto.js"
|
|
2380
|
+
),
|
|
2348
2381
|
join(outputPath, "js/gtfs-realtime.browser.proto.js")
|
|
2349
2382
|
);
|
|
2350
2383
|
}
|
|
2351
2384
|
if (config.hasGtfsRealtimeAlerts) {
|
|
2352
2385
|
await copyFile(
|
|
2353
|
-
|
|
2354
|
-
|
|
2386
|
+
join(
|
|
2387
|
+
dirname(findPackageJSON("anchorme", import.meta.url)),
|
|
2388
|
+
"dist/browser/anchorme.min.js"
|
|
2389
|
+
),
|
|
2390
|
+
join(outputPath, "js/anchorme.min.js")
|
|
2355
2391
|
);
|
|
2356
2392
|
}
|
|
2357
2393
|
}
|
|
@@ -2377,7 +2413,12 @@ function generateTimetablePageFileName(timetablePage, config) {
|
|
|
2377
2413
|
return sanitize(`${formatRouteNameForFilename(route).toLowerCase()}.html`);
|
|
2378
2414
|
}
|
|
2379
2415
|
const timetable = timetablePage.timetables[0];
|
|
2380
|
-
|
|
2416
|
+
if (timetable.timetable_id) {
|
|
2417
|
+
return sanitize(
|
|
2418
|
+
`${timetable.timetable_id.replace(/\|/g, "_").toLowerCase()}.html`
|
|
2419
|
+
);
|
|
2420
|
+
}
|
|
2421
|
+
let filename = "";
|
|
2381
2422
|
for (const route of timetable.routes) {
|
|
2382
2423
|
filename += `_${formatRouteNameForFilename(route)}`;
|
|
2383
2424
|
}
|