gtfs 4.17.6 → 4.17.7
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 +23 -2
- package/dist/bin/gtfs-export.js +14 -14
- package/dist/bin/gtfs-export.js.map +1 -1
- package/dist/bin/gtfs-import.js +86 -29
- package/dist/bin/gtfs-import.js.map +1 -1
- package/dist/bin/gtfsrealtime-update.js +13 -13
- package/dist/bin/gtfsrealtime-update.js.map +1 -1
- package/dist/index.js +165 -106
- package/dist/index.js.map +1 -1
- package/package.json +1 -6
|
@@ -8,10 +8,10 @@ import PrettyError from "pretty-error";
|
|
|
8
8
|
// src/lib/file-utils.ts
|
|
9
9
|
import path from "path";
|
|
10
10
|
import { existsSync } from "fs";
|
|
11
|
+
import { homedir } from "os";
|
|
11
12
|
import { mkdir, readFile, rm } from "fs/promises";
|
|
12
13
|
import { omit, snakeCase } from "lodash-es";
|
|
13
14
|
import sanitize from "sanitize-filename";
|
|
14
|
-
import untildify from "untildify";
|
|
15
15
|
import StreamZip from "node-stream-zip";
|
|
16
16
|
|
|
17
17
|
// src/lib/log-utils.ts
|
|
@@ -65,6 +65,7 @@ function formatError(error) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
// src/lib/file-utils.ts
|
|
68
|
+
var homeDirectory = homedir();
|
|
68
69
|
async function getConfig(argv2) {
|
|
69
70
|
let config;
|
|
70
71
|
let data;
|
|
@@ -101,17 +102,17 @@ async function getConfig(argv2) {
|
|
|
101
102
|
throw error;
|
|
102
103
|
}
|
|
103
104
|
}
|
|
105
|
+
function untildify(pathWithTilde) {
|
|
106
|
+
return homeDirectory ? pathWithTilde.replace(/^~(?=$|\/|\\)/, homeDirectory) : pathWithTilde;
|
|
107
|
+
}
|
|
104
108
|
|
|
105
109
|
// src/lib/import-gtfs.ts
|
|
106
110
|
import path2 from "path";
|
|
107
111
|
import { createReadStream, existsSync as existsSync2, lstatSync } from "fs";
|
|
108
112
|
import { cp, readdir, rename, readFile as readFile2, rm as rm2, writeFile } from "fs/promises";
|
|
109
113
|
import { parse } from "csv-parse";
|
|
110
|
-
import pluralize2 from "pluralize";
|
|
111
114
|
import stripBomStream from "strip-bom-stream";
|
|
112
115
|
import { temporaryDirectory } from "tempy";
|
|
113
|
-
import Timer from "timer-machine";
|
|
114
|
-
import untildify3 from "untildify";
|
|
115
116
|
import mapSeries2 from "promise-map-series";
|
|
116
117
|
|
|
117
118
|
// src/models/gtfs-realtime/trip-updates.ts
|
|
@@ -582,10 +583,9 @@ var serviceAlertInformedEntities = {
|
|
|
582
583
|
|
|
583
584
|
// src/lib/db.ts
|
|
584
585
|
import Database from "better-sqlite3";
|
|
585
|
-
import untildify2 from "untildify";
|
|
586
586
|
var dbs = {};
|
|
587
587
|
function setupDb(sqlitePath) {
|
|
588
|
-
const db = new Database(
|
|
588
|
+
const db = new Database(untildify(sqlitePath));
|
|
589
589
|
db.pragma("journal_mode = OFF");
|
|
590
590
|
db.pragma("synchronous = OFF");
|
|
591
591
|
db.pragma("temp_store = MEMORY");
|
|
@@ -632,7 +632,6 @@ import {
|
|
|
632
632
|
import { feature, featureCollection } from "@turf/helpers";
|
|
633
633
|
|
|
634
634
|
// src/lib/import-gtfs-realtime.ts
|
|
635
|
-
import pluralize from "pluralize";
|
|
636
635
|
import GtfsRealtimeBindings from "gtfs-realtime-bindings";
|
|
637
636
|
import mapSeries from "promise-map-series";
|
|
638
637
|
import { get } from "lodash-es";
|
|
@@ -678,6 +677,9 @@ function applyPrefixToValue(value, columnShouldBePrefixed, prefix) {
|
|
|
678
677
|
}
|
|
679
678
|
return `${prefix}${value}`;
|
|
680
679
|
}
|
|
680
|
+
function pluralize(singularWord, pluralWord, count) {
|
|
681
|
+
return count === 1 ? singularWord : pluralWord;
|
|
682
|
+
}
|
|
681
683
|
|
|
682
684
|
// src/lib/import-gtfs-realtime.ts
|
|
683
685
|
async function fetchGtfsRealtimeData(urlConfig, task) {
|
|
@@ -912,9 +914,9 @@ async function updateGtfsRealtime(initialConfig) {
|
|
|
912
914
|
const agencyCount = config.agencies.length;
|
|
913
915
|
log(config)(
|
|
914
916
|
`Starting GTFS-Realtime refresh for ${pluralize(
|
|
917
|
+
"agency",
|
|
915
918
|
"agencies",
|
|
916
|
-
agencyCount
|
|
917
|
-
true
|
|
919
|
+
agencyCount
|
|
918
920
|
)} using SQLite database at ${config.sqlitePath}`
|
|
919
921
|
);
|
|
920
922
|
removeExpiredRealtimeData(config);
|
|
@@ -945,9 +947,9 @@ async function updateGtfsRealtime(initialConfig) {
|
|
|
945
947
|
});
|
|
946
948
|
log(config)(
|
|
947
949
|
`Completed GTFS-Realtime refresh for ${pluralize(
|
|
950
|
+
"agency",
|
|
948
951
|
"agencies",
|
|
949
|
-
agencyCount
|
|
950
|
-
true
|
|
952
|
+
agencyCount
|
|
951
953
|
)}
|
|
952
954
|
`
|
|
953
955
|
);
|
|
@@ -965,11 +967,9 @@ async function updateGtfsRealtime(initialConfig) {
|
|
|
965
967
|
import path3 from "path";
|
|
966
968
|
import { writeFile as writeFile2 } from "fs/promises";
|
|
967
969
|
import { without, compact as compact2 } from "lodash-es";
|
|
968
|
-
import pluralize3 from "pluralize";
|
|
969
970
|
import { stringify } from "csv-stringify";
|
|
970
971
|
import sqlString2 from "sqlstring-sqlite";
|
|
971
972
|
import mapSeries3 from "promise-map-series";
|
|
972
|
-
import untildify4 from "untildify";
|
|
973
973
|
|
|
974
974
|
// src/lib/advancedQuery.ts
|
|
975
975
|
import sqlString3 from "sqlstring-sqlite";
|