gtfs 4.15.4 → 4.15.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/dist/bin/gtfs-export.js +32 -54
- package/dist/bin/gtfs-export.js.map +1 -1
- package/dist/bin/gtfs-import.js +50 -63
- package/dist/bin/gtfs-import.js.map +1 -1
- package/dist/bin/gtfsrealtime-update.js +32 -55
- package/dist/bin/gtfsrealtime-update.js.map +1 -1
- package/dist/index.d.ts +332 -58
- package/dist/index.js +84 -69
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
|
@@ -16,59 +16,38 @@ import StreamZip from "node-stream-zip";
|
|
|
16
16
|
async function getConfig(argv2) {
|
|
17
17
|
let config;
|
|
18
18
|
let data;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
throw new Error(
|
|
24
|
-
`Cannot find configuration file at \`${argv2.configPath}\`. Use config-sample.json as a starting point.`
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
try {
|
|
19
|
+
try {
|
|
20
|
+
if (argv2.configPath) {
|
|
21
|
+
const configPath = path.resolve(untildify(argv2.configPath));
|
|
22
|
+
data = await readFile(configPath, "utf8");
|
|
28
23
|
config = Object.assign(JSON.parse(data), argv2);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
if (argv2.gtfsUrl) {
|
|
42
|
-
agencies.push({
|
|
43
|
-
url: argv2.gtfsUrl
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
config = {
|
|
47
|
-
agencies,
|
|
48
|
-
...omit(argv2, ["path", "url"])
|
|
49
|
-
};
|
|
50
|
-
} else if (existsSync(path.resolve("./config.json"))) {
|
|
51
|
-
try {
|
|
24
|
+
} else if (argv2.gtfsPath || argv2.gtfsUrl || argv2.sqlitePath) {
|
|
25
|
+
const agencies = [
|
|
26
|
+
...argv2.gtfsPath ? [{ path: argv2.gtfsPath }] : [],
|
|
27
|
+
...argv2.gtfsUrl ? [{ url: argv2.gtfsUrl }] : []
|
|
28
|
+
];
|
|
29
|
+
config = {
|
|
30
|
+
agencies,
|
|
31
|
+
...omit(argv2, ["path", "url"])
|
|
32
|
+
};
|
|
33
|
+
} else if (existsSync(path.resolve("./config.json"))) {
|
|
52
34
|
data = await readFile(path.resolve("./config.json"), "utf8");
|
|
53
|
-
|
|
35
|
+
config = Object.assign(JSON.parse(data), argv2);
|
|
36
|
+
console.log("Using configuration from ./config.json");
|
|
37
|
+
} else {
|
|
54
38
|
throw new Error(
|
|
55
|
-
|
|
39
|
+
"Cannot find configuration file. Use config-sample.json as a starting point, pass --configPath option."
|
|
56
40
|
);
|
|
57
41
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
} catch (error) {
|
|
42
|
+
return config;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
if (error instanceof SyntaxError) {
|
|
62
45
|
throw new Error(
|
|
63
|
-
`Cannot parse configuration file
|
|
46
|
+
`Cannot parse configuration file. Check to ensure that it is valid JSON. Error: ${error.message}`
|
|
64
47
|
);
|
|
65
48
|
}
|
|
66
|
-
|
|
67
|
-
throw new Error(
|
|
68
|
-
"Cannot find configuration file. Use config-sample.json as a starting point, pass --configPath option."
|
|
69
|
-
);
|
|
49
|
+
throw error;
|
|
70
50
|
}
|
|
71
|
-
return config;
|
|
72
51
|
}
|
|
73
52
|
|
|
74
53
|
// src/lib/log-utils.ts
|
|
@@ -76,14 +55,14 @@ import { clearLine, cursorTo } from "node:readline";
|
|
|
76
55
|
import { noop } from "lodash-es";
|
|
77
56
|
import * as colors from "yoctocolors";
|
|
78
57
|
function log(config) {
|
|
79
|
-
if (config.verbose
|
|
58
|
+
if (!config.verbose) {
|
|
80
59
|
return noop;
|
|
81
60
|
}
|
|
82
61
|
if (config.logFunction) {
|
|
83
62
|
return config.logFunction;
|
|
84
63
|
}
|
|
85
|
-
return (text, overwrite) => {
|
|
86
|
-
if (overwrite
|
|
64
|
+
return (text, overwrite = false) => {
|
|
65
|
+
if (overwrite && process.stdout.isTTY) {
|
|
87
66
|
clearLine(process.stdout, 0);
|
|
88
67
|
cursorTo(process.stdout, 0);
|
|
89
68
|
} else {
|
|
@@ -113,16 +92,12 @@ ${formatError(text)}
|
|
|
113
92
|
};
|
|
114
93
|
}
|
|
115
94
|
function formatWarning(text) {
|
|
116
|
-
|
|
117
|
-
return colors.yellow(warningMessage);
|
|
95
|
+
return colors.yellow(`${colors.underline("Warning")}: ${text}`);
|
|
118
96
|
}
|
|
119
97
|
function formatError(error) {
|
|
120
98
|
const messageText = error instanceof Error ? error.message : error;
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
""
|
|
124
|
-
)}`;
|
|
125
|
-
return colors.red(errorMessage);
|
|
99
|
+
const cleanMessage = messageText.replace(/^Error:\s*/i, "");
|
|
100
|
+
return colors.red(`${colors.underline("Error")}: ${cleanMessage}`);
|
|
126
101
|
}
|
|
127
102
|
|
|
128
103
|
// src/lib/import-gtfs.ts
|
|
@@ -623,7 +598,9 @@ function setDefaultConfig(initialConfig) {
|
|
|
623
598
|
}
|
|
624
599
|
function convertLongTimeToDate(longDate) {
|
|
625
600
|
const { high, low, unsigned } = longDate;
|
|
626
|
-
return new Date(
|
|
601
|
+
return new Date(
|
|
602
|
+
Long.fromBits(low, high, unsigned).toNumber() * 1e3
|
|
603
|
+
).toISOString();
|
|
627
604
|
}
|
|
628
605
|
|
|
629
606
|
// src/lib/import-gtfs-realtime.ts
|