gtfs 4.11.0 → 4.11.1

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,17 @@ 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
+ ## [4.11.1] - 2024-06-05
9
+
10
+ ### Changed
11
+
12
+ - Don't throw error on GTFS-Realtime import HTTP error
13
+
14
+ ### Updated
15
+
16
+ - Remove recursive-copy module
17
+ - Dependency updates
18
+
8
19
  ## [4.11.0] - 2024-06-01
9
20
 
10
21
  ### Added
package/lib/import.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import path from 'node:path';
2
2
  import { createReadStream, existsSync, lstatSync } from 'node:fs';
3
- import { readdir, rename, writeFile } from 'node:fs/promises';
4
- import copy from 'recursive-copy';
3
+ import { cp, readdir, rename, writeFile } from 'node:fs/promises';
5
4
  import fetch from 'node-fetch';
6
5
  import { parse } from 'csv-parse';
7
6
  import pluralize from 'pluralize';
@@ -42,7 +41,7 @@ const downloadFiles = async (task) => {
42
41
  });
43
42
 
44
43
  if (response.status !== 200) {
45
- throw new Error('Couldn’t download files');
44
+ throw new Error(`Unable to download GTFS from ${task.agency_url}`);
46
45
  }
47
46
 
48
47
  const buffer = await response.arrayBuffer();
@@ -51,14 +50,19 @@ const downloadFiles = async (task) => {
51
50
  task.log('Download successful');
52
51
  };
53
52
 
54
- const downloadGtfsRealtimeData = async (url, headers) => {
53
+ const downloadGtfsRealtimeData = async (url, task) => {
55
54
  const response = await fetch(url, {
56
55
  method: 'GET',
57
- headers: { ...{}, ...headers, ...{ 'Accept-Encoding': 'gzip' } },
56
+ headers: {
57
+ ...{},
58
+ ...task.realtime_headers,
59
+ ...{ 'Accept-Encoding': 'gzip' },
60
+ },
58
61
  });
59
62
 
60
63
  if (response.status !== 200) {
61
- throw new Error('Couldn’t download files');
64
+ task.warn(`Unable to download GTFS-Realtime from ${url}`);
65
+ return null;
62
66
  }
63
67
 
64
68
  const buffer = await response.arrayBuffer();
@@ -190,17 +194,14 @@ const updateRealtimeData = async (task) => {
190
194
  for (const realtimeUrl of task.realtime_urls) {
191
195
  task.log(`Downloading GTFS-Realtime from ${realtimeUrl}`);
192
196
  // eslint-disable-next-line no-await-in-loop
193
- const gtfsRealtimeData = await downloadGtfsRealtimeData(
194
- realtimeUrl,
195
- task.realtime_headers,
196
- );
197
-
198
- task.log(`Download successful`);
197
+ const gtfsRealtimeData = await downloadGtfsRealtimeData(realtimeUrl, task);
199
198
 
200
- if (!gtfsRealtimeData.entity) {
199
+ if (!gtfsRealtimeData?.entity) {
201
200
  continue;
202
201
  }
203
202
 
203
+ task.log(`Download successful`);
204
+
204
205
  let totalLineCount = 0;
205
206
 
206
207
  for (const entity of gtfsRealtimeData.entity) {
@@ -353,7 +354,7 @@ const readFiles = async (task) => {
353
354
  } else {
354
355
  // Local file is unzipped, just copy it from there.
355
356
  try {
356
- await copy(gtfsPath, task.downloadDir);
357
+ await cp(gtfsPath, task.downloadDir, { recursive: true });
357
358
  } catch {
358
359
  throw new Error(
359
360
  `Unable to load files from path \`${gtfsPath}\` defined in configuration. Verify that path exists and contains GTFS files.`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtfs",
3
- "version": "4.11.0",
3
+ "version": "4.11.1",
4
4
  "description": "Import GTFS transit data into SQLite and query routes, stops, times, fares and more",
5
5
  "keywords": [
6
6
  "transit",
@@ -88,7 +88,6 @@
88
88
  "pluralize": "^8.0.0",
89
89
  "pretty-error": "^4.0.0",
90
90
  "promise-map-series": "^0.3.0",
91
- "recursive-copy": "^2.0.14",
92
91
  "sanitize-filename": "^1.6.3",
93
92
  "sqlstring-sqlite": "^0.1.1",
94
93
  "strip-bom-stream": "^5.0.0",
@@ -101,7 +100,7 @@
101
100
  "husky": "^9.0.11",
102
101
  "lint-staged": "^15.2.5",
103
102
  "mocha": "^10.4.0",
104
- "prettier": "^3.3.0",
103
+ "prettier": "^3.3.1",
105
104
  "should": "^13.2.3"
106
105
  },
107
106
  "engines": {