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/dist/index.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.0",
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: ">= 20.11.0"
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 = `${routeIds.join("_")}|${calendarToCalendarCode(days2)}`;
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
  }
@@ -2315,18 +2337,32 @@ async function copyStaticAssets(config, outputPath) {
2315
2337
  }
2316
2338
  if (config.hasGtfsRealtimeVehiclePositions || config.hasGtfsRealtimeTripUpdates || config.hasGtfsRealtimeAlerts) {
2317
2339
  await copyFile(
2318
- "node_modules/pbf/dist/pbf.js",
2340
+ join(
2341
+ dirname(findPackageJSON("pbf", import.meta.url)),
2342
+ "dist/pbf.js"
2343
+ ),
2319
2344
  join(outputPath, "js/pbf.js")
2320
2345
  );
2321
2346
  await copyFile(
2322
- "node_modules/gtfs-realtime-pbf-js-module/gtfs-realtime.browser.proto.js",
2347
+ join(
2348
+ dirname(
2349
+ findPackageJSON(
2350
+ "gtfs-realtime-pbf-js-module",
2351
+ import.meta.url
2352
+ )
2353
+ ),
2354
+ "gtfs-realtime.browser.proto.js"
2355
+ ),
2323
2356
  join(outputPath, "js/gtfs-realtime.browser.proto.js")
2324
2357
  );
2325
2358
  }
2326
2359
  if (config.hasGtfsRealtimeAlerts) {
2327
2360
  await copyFile(
2328
- "node_modules/anchorme/dist/browser/anchorme.min.js",
2329
- join(outputPath, "js//anchorme.min.js")
2361
+ join(
2362
+ dirname(findPackageJSON("anchorme", import.meta.url)),
2363
+ "dist/browser/anchorme.min.js"
2364
+ ),
2365
+ join(outputPath, "js/anchorme.min.js")
2330
2366
  );
2331
2367
  }
2332
2368
  }
@@ -2352,7 +2388,12 @@ function generateTimetablePageFileName(timetablePage, config) {
2352
2388
  return sanitize(`${formatRouteNameForFilename(route).toLowerCase()}.html`);
2353
2389
  }
2354
2390
  const timetable = timetablePage.timetables[0];
2355
- let filename = timetable.timetable_id ?? "";
2391
+ if (timetable.timetable_id) {
2392
+ return sanitize(
2393
+ `${timetable.timetable_id.replace(/\|/g, "_").toLowerCase()}.html`
2394
+ );
2395
+ }
2396
+ let filename = "";
2356
2397
  for (const route of timetable.routes) {
2357
2398
  filename += `_${formatRouteNameForFilename(route)}`;
2358
2399
  }