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 CHANGED
@@ -83,6 +83,7 @@ Many transit agencies use `gtfs-to-html` to generate the schedule pages used on
83
83
  | [MVgo](https://mvgo.org) | Mountain View, California |
84
84
  | [Petaluma Transit](https://transit.cityofpetaluma.net) | Petaluma, California |
85
85
  | [rabbittransit](https://www.rabbittransit.org) | York and Adams County, Pennsylvania |
86
+ | [River Valley Transit](https://rivervalleytransit.com) | Middletown, Connecticut |
86
87
  | [Rogue Valley Transportation District](https://rvtd.org) | Medford, Oregon |
87
88
  | [RTC Washoe](https://www.rtcwashoe.com) | Reno, Nevada |
88
89
  | [Santa Barbara Metropolitan Transit District](https://sbmtd.gov) | Santa Barbara, California |
package/dist/app/index.js CHANGED
@@ -40,6 +40,9 @@ function toGTFSTime(time) {
40
40
  return time.format("HH:mm:ss");
41
41
  }
42
42
  function calendarToCalendarCode(c) {
43
+ if (Object.values(c).every((value) => value === null)) {
44
+ return "";
45
+ }
43
46
  return `${c.monday}${c.tuesday}${c.wednesday}${c.thursday}${c.friday}${c.saturday}${c.sunday}`;
44
47
  }
45
48
  function calendarCodeToCalendar(code) {
@@ -132,6 +135,7 @@ import {
132
135
  rm
133
136
  } from "fs/promises";
134
137
  import { homedir } from "os";
138
+ import { findPackageJSON } from "module";
135
139
  import * as _ from "lodash-es";
136
140
  import { uniqBy } from "lodash-es";
137
141
  import archiver from "archiver";
@@ -286,7 +290,12 @@ function generateTimetablePageFileName(timetablePage, config2) {
286
290
  return sanitize(`${formatRouteNameForFilename(route).toLowerCase()}.html`);
287
291
  }
288
292
  const timetable = timetablePage.timetables[0];
289
- let filename = timetable.timetable_id ?? "";
293
+ if (timetable.timetable_id) {
294
+ return sanitize(
295
+ `${timetable.timetable_id.replace(/\|/g, "_").toLowerCase()}.html`
296
+ );
297
+ }
298
+ let filename = "";
290
299
  for (const route of timetable.routes) {
291
300
  filename += `_${formatRouteNameForFilename(route)}`;
292
301
  }
@@ -421,7 +430,7 @@ function getAgencyGeoJSON(config2) {
421
430
  // package.json
422
431
  var package_default = {
423
432
  name: "gtfs-to-html",
424
- version: "2.11.0",
433
+ version: "2.11.2",
425
434
  private: false,
426
435
  description: "Build human readable transit timetables as HTML, PDF or CSV from GTFS",
427
436
  keywords: [
@@ -511,7 +520,7 @@ var package_default = {
511
520
  typescript: "^5.9.2"
512
521
  },
513
522
  engines: {
514
- node: ">= 20.11.0"
523
+ node: ">= 22"
515
524
  },
516
525
  "release-it": {
517
526
  github: {
@@ -813,7 +822,15 @@ var createTimetable = ({
813
822
  ...calendars?.map((calendar) => calendar.service_id) ?? [],
814
823
  ...calendarDates?.map((calendarDate) => calendarDate.service_id) ?? []
815
824
  ]);
816
- const days2 = {};
825
+ const days2 = {
826
+ monday: null,
827
+ tuesday: null,
828
+ wednesday: null,
829
+ thursday: null,
830
+ friday: null,
831
+ saturday: null,
832
+ sunday: null
833
+ };
817
834
  let startDate = null;
818
835
  let endDate = null;
819
836
  if (calendars && calendars.length > 0) {
@@ -832,7 +849,8 @@ var createTimetable = ({
832
849
  const timetableId = formatTimetableId({
833
850
  routeIds: [route.route_id],
834
851
  directionId,
835
- days: days2
852
+ days: days2,
853
+ dates: calendarDates?.map((calendarDate) => calendarDate.date)
836
854
  });
837
855
  return {
838
856
  timetable_id: timetableId,
@@ -905,6 +923,9 @@ var convertRoutesToTimetablePages = (config2) => {
905
923
  }
906
924
  }
907
925
  }
926
+ if (timetables.length === 0) {
927
+ continue;
928
+ }
908
929
  if (config2.groupTimetablesIntoPages === true) {
909
930
  timetablePages.push(
910
931
  createTimetablePage({
@@ -1941,9 +1962,15 @@ function formatFrequency(frequency, config2) {
1941
1962
  function formatTimetableId({
1942
1963
  routeIds,
1943
1964
  directionId,
1944
- days: days2
1965
+ days: days2,
1966
+ dates
1945
1967
  }) {
1946
- let timetableId = `${routeIds.join("_")}|${calendarToCalendarCode(days2)}`;
1968
+ let timetableId = routeIds.join("_");
1969
+ if (calendarToCalendarCode(days2)) {
1970
+ timetableId += `|${calendarToCalendarCode(days2)}`;
1971
+ } else if (dates && dates.length > 0) {
1972
+ timetableId += `|${dates.join("_")}`;
1973
+ }
1947
1974
  if (!isNullOrEmpty(directionId)) {
1948
1975
  timetableId += `|${directionId}`;
1949
1976
  }