gtfs-to-html 2.5.7 → 2.5.8

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/CHANGELOG.md CHANGED
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.5.8] - 2024-01-02
9
+
10
+ ### Fixed
11
+
12
+ - Improved warning logging
13
+
14
+ ### Added
15
+
16
+ - Handle case where a calendar_date is both included and excluded
17
+
18
+ ### Updated
19
+
20
+ - Dependency updates
21
+
8
22
  ## [2.5.7] - 2023-11-07
9
23
 
10
24
  ### Updated
@@ -51,7 +51,7 @@ const gtfsToHtml = async (initialConfig) => {
51
51
  } catch (error) {
52
52
  if (error instanceof Error && error.code === 'SQLITE_CANTOPEN') {
53
53
  config.logError(
54
- `Unable to open sqlite database "${config.sqlitePath}" defined as \`sqlitePath\` config.json. Ensure the parent directory exists or remove \`sqlitePath\` from config.json.`
54
+ `Unable to open sqlite database "${config.sqlitePath}" defined as \`sqlitePath\` config.json. Ensure the parent directory exists or remove \`sqlitePath\` from config.json.`,
55
55
  );
56
56
  }
57
57
 
@@ -84,7 +84,7 @@ const gtfsToHtml = async (initialConfig) => {
84
84
  const timetablePages = [];
85
85
  const timetablePageIds = map(
86
86
  getTimetablePagesForAgency(config),
87
- 'timetable_page_id'
87
+ 'timetable_page_id',
88
88
  );
89
89
  await prepDirectory(exportPath);
90
90
 
@@ -95,7 +95,7 @@ const gtfsToHtml = async (initialConfig) => {
95
95
  const bar = progressBar(
96
96
  `${agencyKey}: Generating ${config.outputFormat.toUpperCase()} timetables {bar} {value}/{total}`,
97
97
  timetablePageIds.length,
98
- config
98
+ config,
99
99
  );
100
100
 
101
101
  /* eslint-disable no-await-in-loop */
@@ -103,15 +103,9 @@ const gtfsToHtml = async (initialConfig) => {
103
103
  try {
104
104
  const timetablePage = await getFormattedTimetablePage(
105
105
  timetablePageId,
106
- config
106
+ config,
107
107
  );
108
108
 
109
- if (timetablePage.consolidatedTimetables.length === 0) {
110
- throw new Error(
111
- `No timetables found for timetable_page_id=${timetablePage.timetable_page_id}`
112
- );
113
- }
114
-
115
109
  for (const timetable of timetablePage.timetables) {
116
110
  for (const warning of timetable.warnings) {
117
111
  outputStats.warnings.push(warning);
@@ -119,6 +113,12 @@ const gtfsToHtml = async (initialConfig) => {
119
113
  }
120
114
  }
121
115
 
116
+ if (timetablePage.consolidatedTimetables.length === 0) {
117
+ throw new Error(
118
+ `No timetables found for timetable_page_id=${timetablePage.timetable_page_id}`,
119
+ );
120
+ }
121
+
122
122
  outputStats.timetables += timetablePage.consolidatedTimetables.length;
123
123
  outputStats.timetablePages += 1;
124
124
 
@@ -130,7 +130,7 @@ const gtfsToHtml = async (initialConfig) => {
130
130
 
131
131
  timetablePage.relativePath = path.join(
132
132
  datePath,
133
- sanitize(timetablePage.filename)
133
+ sanitize(timetablePage.filename),
134
134
  );
135
135
 
136
136
  if (config.outputFormat === 'csv') {
@@ -139,7 +139,7 @@ const gtfsToHtml = async (initialConfig) => {
139
139
  const csvPath = path.join(
140
140
  exportPath,
141
141
  datePath,
142
- generateCSVFileName(timetable, timetablePage)
142
+ generateCSVFileName(timetable, timetablePage),
143
143
  );
144
144
  await writeFile(csvPath, csv);
145
145
  }
@@ -148,7 +148,7 @@ const gtfsToHtml = async (initialConfig) => {
148
148
  const htmlPath = path.join(
149
149
  exportPath,
150
150
  datePath,
151
- sanitize(timetablePage.filename)
151
+ sanitize(timetablePage.filename),
152
152
  );
153
153
  await writeFile(htmlPath, html);
154
154
 
@@ -192,19 +192,19 @@ const gtfsToHtml = async (initialConfig) => {
192
192
 
193
193
  const fullExportPath = path.join(
194
194
  exportPath,
195
- config.zipOutput ? '/timetables.zip' : ''
195
+ config.zipOutput ? '/timetables.zip' : '',
196
196
  );
197
197
 
198
198
  // Print stats
199
199
  config.log(
200
- `${agencyKey}: ${config.outputFormat.toUpperCase()} timetables created at ${fullExportPath}`
200
+ `${agencyKey}: ${config.outputFormat.toUpperCase()} timetables created at ${fullExportPath}`,
201
201
  );
202
202
 
203
203
  logStats(outputStats, config);
204
204
 
205
205
  const seconds = Math.round(timer.time() / 1000);
206
206
  config.log(
207
- `${agencyKey}: ${config.outputFormat.toUpperCase()} timetable generation required ${seconds} seconds`
207
+ `${agencyKey}: ${config.outputFormat.toUpperCase()} timetable generation required ${seconds} seconds`,
208
208
  );
209
209
 
210
210
  timer.stop();
package/lib/log-utils.js CHANGED
@@ -110,7 +110,7 @@ export function formatError(error) {
110
110
  const messageText = error instanceof Error ? error.message : error;
111
111
  const errorMessage = `${colors.underline('Error')}: ${messageText.replace(
112
112
  'Error: ',
113
- ''
113
+ '',
114
114
  )}`;
115
115
  return colors.red(errorMessage);
116
116
  }
@@ -136,7 +136,7 @@ export function logStats(stats, config) {
136
136
  ['🔄 Routes', stats.routes],
137
137
  ['🚍 Trips', stats.trips],
138
138
  ['🛑 Stops', stats.stops],
139
- ['⛔️ Warnings', stats.warnings.length]
139
+ ['⛔️ Warnings', stats.warnings.length],
140
140
  );
141
141
 
142
142
  config.log(table.toString());
@@ -209,7 +209,7 @@ export function progressBar(formatString, barTotal, config) {
209
209
  interrupt(text) {
210
210
  // Log two lines to avoid overwrite by progress bar
211
211
  config.logWarning(text);
212
- config.logWarning('');
212
+ config.log('');
213
213
  },
214
214
  increment() {
215
215
  barProgress += 1;
package/lib/utils.js CHANGED
@@ -292,26 +292,32 @@ const getCalendarDatesForTimetable = (timetable, config) => {
292
292
  );
293
293
  const start = fromGTFSDate(timetable.start_date);
294
294
  const end = fromGTFSDate(timetable.end_date);
295
- const filteredCalendarDates = {
296
- excludedDates: [],
297
- includedDates: [],
298
- };
295
+ const excludedDates = [];
296
+ const includedDates = [];
299
297
 
300
298
  for (const calendarDate of calendarDates) {
301
299
  if (moment(calendarDate.date, 'YYYYMMDD').isBetween(start, end)) {
302
300
  if (calendarDate.exception_type === 1) {
303
- filteredCalendarDates.includedDates.push(
304
- formatDate(calendarDate, config.dateFormat),
305
- );
301
+ includedDates.push(formatDate(calendarDate, config.dateFormat));
306
302
  } else if (calendarDate.exception_type === 2) {
307
- filteredCalendarDates.excludedDates.push(
308
- formatDate(calendarDate, config.dateFormat),
309
- );
303
+ excludedDates.push(formatDate(calendarDate, config.dateFormat));
310
304
  }
311
305
  }
312
306
  }
313
307
 
314
- return filteredCalendarDates;
308
+ // Remove dates that are both included and excluded from both lists
309
+ const includedAndExcludedDates = excludedDates.filter((date) =>
310
+ includedDates.includes(date),
311
+ );
312
+
313
+ return {
314
+ excludedDates: excludedDates.filter(
315
+ (date) => !includedAndExcludedDates.includes(date),
316
+ ),
317
+ includedDates: includedDates.filter(
318
+ (date) => !includedAndExcludedDates.includes(date),
319
+ ),
320
+ };
315
321
  };
316
322
 
317
323
  /*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtfs-to-html",
3
- "version": "2.5.7",
3
+ "version": "2.5.8",
4
4
  "private": false,
5
5
  "description": "Build human readable transit timetables as HTML, PDF or CSV from GTFS",
6
6
  "keywords": [
@@ -40,16 +40,16 @@
40
40
  "archiver": "^6.0.1",
41
41
  "cli-table": "^0.3.11",
42
42
  "copy-dir": "^1.3.0",
43
- "csv-stringify": "^6.4.4",
43
+ "csv-stringify": "^6.4.5",
44
44
  "express": "^4.18.2",
45
- "gtfs": "^4.5.0",
45
+ "gtfs": "^4.5.1",
46
46
  "js-beautify": "^1.14.11",
47
47
  "lodash-es": "^4.17.21",
48
- "moment": "^2.29.4",
48
+ "moment": "^2.30.1",
49
49
  "morgan": "^1.10.0",
50
50
  "pretty-error": "^4.0.0",
51
51
  "pug": "^3.0.2",
52
- "puppeteer": "^21.5.0",
52
+ "puppeteer": "^21.6.1",
53
53
  "sanitize-filename": "^1.6.3",
54
54
  "sqlstring": "^2.3.3",
55
55
  "timer-machine": "^1.1.0",
@@ -60,8 +60,8 @@
60
60
  },
61
61
  "devDependencies": {
62
62
  "husky": "^8.0.3",
63
- "lint-staged": "^15.0.2",
64
- "prettier": "^3.0.3"
63
+ "lint-staged": "^15.2.0",
64
+ "prettier": "^3.1.1"
65
65
  },
66
66
  "engines": {
67
67
  "node": ">= 18.0.0"
package/www/package.json CHANGED
@@ -9,9 +9,9 @@
9
9
  "deploy": "docusaurus deploy"
10
10
  },
11
11
  "dependencies": {
12
- "@docusaurus/core": "^3.0.0",
13
- "@docusaurus/preset-classic": "^3.0.0",
14
- "clsx": "^2.0.0",
12
+ "@docusaurus/core": "^3.0.1",
13
+ "@docusaurus/preset-classic": "^3.0.1",
14
+ "clsx": "^2.1.0",
15
15
  "react": "^18.2.0",
16
16
  "react-dom": "^18.2.0"
17
17
  },