gtfs-to-html 2.6.5 → 2.6.6

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,14 @@ 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.6.6] - 2024-05-14
9
+
10
+ ### Updated
11
+ - Improved error formatting
12
+ - Text-wrap for timetable notes for trips
13
+ - Dependency updates
14
+ - Trip label for vertical multi-route timetables
15
+
8
16
  ## [2.6.5] - 2024-05-11
9
17
 
10
18
  ### Updated
@@ -2,11 +2,14 @@
2
2
 
3
3
  import yargs from 'yargs';
4
4
  import { hideBin } from 'yargs/helpers';
5
+ import PrettyError from 'pretty-error';
5
6
 
6
7
  import { getConfig } from '../lib/file-utils.js';
7
8
  import { formatError } from '../lib/log-utils.js';
8
9
  import gtfsToHtml from '../index.js';
9
10
 
11
+ const pe = new PrettyError();
12
+
10
13
  const { argv } = yargs(hideBin(process.argv))
11
14
  .usage('Usage: $0 --configPath ./config.json')
12
15
  .help()
@@ -32,7 +35,7 @@ const { argv } = yargs(hideBin(process.argv))
32
35
  const handleError = (error) => {
33
36
  const text = error || 'Unknown Error';
34
37
  process.stdout.write(`\n${formatError(text)}\n`);
35
- console.error(error);
38
+ console.error(pe.render(error));
36
39
  process.exit(1);
37
40
  };
38
41
 
package/lib/file-utils.js CHANGED
@@ -26,37 +26,34 @@ import * as templateFunctions from './template-functions.js';
26
26
  * Attempt to parse the specified config JSON file.
27
27
  */
28
28
  export async function getConfig(argv) {
29
- try {
30
- const data = await readFile(
31
- path.resolve(untildify(argv.configPath)),
32
- 'utf8',
33
- ).catch((error) => {
34
- console.error(
35
- new Error(
36
- `Cannot find configuration file at \`${argv.configPath}\`. Use config-sample.json as a starting point, pass --configPath option`,
37
- ),
38
- );
39
- throw error;
40
- });
41
- const config = JSON.parse(data);
42
-
43
- if (argv.skipImport === true) {
44
- config.skipImport = argv.skipImport;
45
- }
29
+ let data;
30
+ let config;
46
31
 
47
- if (argv.showOnlyTimepoint === true) {
48
- config.showOnlyTimepoint = argv.showOnlyTimepoint;
49
- }
32
+ try {
33
+ data = await readFile(path.resolve(untildify(argv.configPath)), 'utf8');
34
+ } catch (error) {
35
+ throw new Error(
36
+ `Cannot find configuration file at \`${argv.configPath}\`. Use config-sample.json as a starting point, pass --configPath option`,
37
+ );
38
+ }
50
39
 
51
- return config;
40
+ try {
41
+ config = JSON.parse(data);
52
42
  } catch (error) {
53
- console.error(
54
- new Error(
55
- `Cannot parse configuration file at \`${argv.configPath}\`. Check to ensure that it is valid JSON.`,
56
- ),
43
+ throw new Error(
44
+ `Cannot parse configuration file at \`${argv.configPath}\`. Check to ensure that it is valid JSON.`,
57
45
  );
58
- throw error;
59
46
  }
47
+
48
+ if (argv.skipImport === true) {
49
+ config.skipImport = argv.skipImport;
50
+ }
51
+
52
+ if (argv.showOnlyTimepoint === true) {
53
+ config.showOnlyTimepoint = argv.showOnlyTimepoint;
54
+ }
55
+
56
+ return config;
60
57
  }
61
58
 
62
59
  /*
package/lib/log-utils.js CHANGED
@@ -1,13 +1,9 @@
1
1
  import { clearLine, cursorTo } from 'node:readline';
2
- import PrettyError from 'pretty-error';
3
2
  import { noop } from 'lodash-es';
4
3
  import * as colors from 'yoctocolors';
5
4
  import { getFeedInfo } from 'gtfs';
6
5
  import Table from 'cli-table';
7
6
 
8
- const pe = new PrettyError();
9
- pe.start();
10
-
11
7
  /*
12
8
  * Creates text for a log of output details.
13
9
  */
@@ -149,10 +149,13 @@ export function formatTripName(trip, index, timetable) {
149
149
  let tripName;
150
150
  if (timetable.routes.length > 1) {
151
151
  tripName = trip.route_short_name;
152
- } else if (trip.trip_short_name) {
153
- tripName = trip.trip_short_name;
154
- } else {
155
- tripName = `Run #${index + 1}`;
152
+ } else if (timetable.orientation === 'horizontal') {
153
+ // Only add this to horizontal timetables.
154
+ if (trip.trip_short_name) {
155
+ tripName = trip.trip_short_name;
156
+ } else {
157
+ tripName = `Run #${index + 1}`;
158
+ }
156
159
  }
157
160
 
158
161
  if (timetableHasDifferentDays(timetable)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtfs-to-html",
3
- "version": "2.6.5",
3
+ "version": "2.6.6",
4
4
  "private": false,
5
5
  "description": "Build human readable transit timetables as HTML, PDF or CSV from GTFS",
6
6
  "keywords": [
@@ -40,9 +40,9 @@
40
40
  "archiver": "^7.0.1",
41
41
  "cli-table": "^0.3.11",
42
42
  "copy-dir": "^1.3.0",
43
- "csv-stringify": "^6.4.6",
43
+ "csv-stringify": "^6.5.0",
44
44
  "express": "^4.19.2",
45
- "gtfs": "^4.10.2",
45
+ "gtfs": "^4.10.4",
46
46
  "insane": "^2.6.2",
47
47
  "js-beautify": "^1.15.1",
48
48
  "lodash-es": "^4.17.21",
@@ -51,14 +51,14 @@
51
51
  "morgan": "^1.10.0",
52
52
  "pretty-error": "^4.0.0",
53
53
  "pug": "^3.0.2",
54
- "puppeteer": "^22.8.0",
54
+ "puppeteer": "^22.8.1",
55
55
  "sanitize-filename": "^1.6.3",
56
56
  "sqlstring": "^2.3.3",
57
57
  "timer-machine": "^1.1.0",
58
58
  "toposort": "^2.0.2",
59
59
  "untildify": "^5.0.0",
60
60
  "yargs": "^17.7.2",
61
- "yoctocolors": "^2.0.0"
61
+ "yoctocolors": "^2.0.2"
62
62
  },
63
63
  "devDependencies": {
64
64
  "husky": "^9.0.11",
@@ -162,6 +162,10 @@ a:hover {
162
162
  width: auto;
163
163
  }
164
164
 
165
+ .timetable .table-vertical .trip-row .trip-notes {
166
+ text-wrap: nowrap;
167
+ }
168
+
165
169
  .route-color-swatch {
166
170
  min-width: 34px;
167
171
  height: 34px;
@@ -1,2 +1,5 @@
1
1
  a(href=`#note-${timetable.timetable_id}-${note.note_id}` class=`timetable-note-${note.note_id}`).symbol
2
- sup= note.symbol
2
+ if timetable.routes.length <= 1 && timetable.orientation === 'vertical'
3
+ span= note.symbol
4
+ else
5
+ sup= note.symbol
@@ -9,14 +9,14 @@
9
9
  - }
10
10
  - var timetableHasTripNotes = timetable.orderedTrips.flatMap(trip => getNotesForTrip(timetable.notes, trip)).length > 0;
11
11
  .table-container
12
- table(summary= getTimetableSummary(timetable) data-orientation="vertical")
12
+ table.table-vertical(summary= getTimetableSummary(timetable) data-orientation="vertical")
13
13
  caption.sr-only= `${timetable.timetable_label} | ${timetable.dayList}`
14
14
  colgroup
15
15
  each stop, idx in timetable.stops
16
16
  col(id=`stop_id_${formatHtmlId(stop.stop_id)}` class=`stop-${idx}` data-stop-id=`${stop.stop_id}` data-is-timepoint=`${stop.is_timepoint}`)
17
17
  thead
18
18
  tr
19
- if timetableHasTripNotes
19
+ if timetableHasTripNotes || timetable.routes.length > 1
20
20
  th
21
21
  if timetable.has_continues_from_route
22
22
  th.stop-header.continues-from Continues from route
@@ -36,7 +36,7 @@
36
36
  tbody
37
37
  if timetable.frequencies && !timetable.frequencyExactTimes
38
38
  tr.trip-row
39
- if timetableHasTripNotes
39
+ if timetableHasTripNotes || timetable.routes.length > 1
40
40
  td
41
41
  if timetable.has_continues_from_route
42
42
  td
@@ -47,8 +47,8 @@
47
47
  td
48
48
  each trip, idx in timetable.orderedTrips
49
49
  tr.trip-row(id=`trip_id_${formatHtmlId(trip.trip_id)}`)
50
- if timetableHasTripNotes
51
- td.trip-notes
50
+ if timetableHasTripNotes || timetable.routes.length > 1
51
+ td.trip-notes= formatTripName(trip, idx, timetable)
52
52
  each note in getNotesForTrip(timetable.notes, trip)
53
53
  include timetable_note_symbol.pug
54
54
  if timetable.has_continues_from_route