gtfs 4.15.5 → 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 +46 -62
- 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 +80 -68
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/bin/gtfs-export.js
CHANGED
|
@@ -21,65 +21,47 @@ import StreamZip from "node-stream-zip";
|
|
|
21
21
|
async function getConfig(argv2) {
|
|
22
22
|
let config;
|
|
23
23
|
let data;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
throw new Error(
|
|
29
|
-
`Cannot find configuration file at \`${argv2.configPath}\`. Use config-sample.json as a starting point.`
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
try {
|
|
24
|
+
try {
|
|
25
|
+
if (argv2.configPath) {
|
|
26
|
+
const configPath = path.resolve(untildify(argv2.configPath));
|
|
27
|
+
data = await readFile(configPath, "utf8");
|
|
33
28
|
config = Object.assign(JSON.parse(data), argv2);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
if (argv2.gtfsUrl) {
|
|
47
|
-
agencies.push({
|
|
48
|
-
url: argv2.gtfsUrl
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
config = {
|
|
52
|
-
agencies,
|
|
53
|
-
...omit(argv2, ["path", "url"])
|
|
54
|
-
};
|
|
55
|
-
} else if (existsSync(path.resolve("./config.json"))) {
|
|
56
|
-
try {
|
|
29
|
+
} else if (argv2.gtfsPath || argv2.gtfsUrl || argv2.sqlitePath) {
|
|
30
|
+
const agencies = [
|
|
31
|
+
...argv2.gtfsPath ? [{ path: argv2.gtfsPath }] : [],
|
|
32
|
+
...argv2.gtfsUrl ? [{ url: argv2.gtfsUrl }] : []
|
|
33
|
+
];
|
|
34
|
+
config = {
|
|
35
|
+
agencies,
|
|
36
|
+
...omit(argv2, ["path", "url"])
|
|
37
|
+
};
|
|
38
|
+
} else if (existsSync(path.resolve("./config.json"))) {
|
|
57
39
|
data = await readFile(path.resolve("./config.json"), "utf8");
|
|
58
|
-
|
|
40
|
+
config = Object.assign(JSON.parse(data), argv2);
|
|
41
|
+
console.log("Using configuration from ./config.json");
|
|
42
|
+
} else {
|
|
59
43
|
throw new Error(
|
|
60
|
-
|
|
44
|
+
"Cannot find configuration file. Use config-sample.json as a starting point, pass --configPath option."
|
|
61
45
|
);
|
|
62
46
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
} catch (error) {
|
|
47
|
+
return config;
|
|
48
|
+
} catch (error) {
|
|
49
|
+
if (error instanceof SyntaxError) {
|
|
67
50
|
throw new Error(
|
|
68
|
-
`Cannot parse configuration file
|
|
51
|
+
`Cannot parse configuration file. Check to ensure that it is valid JSON. Error: ${error.message}`
|
|
69
52
|
);
|
|
70
53
|
}
|
|
71
|
-
|
|
72
|
-
throw new Error(
|
|
73
|
-
"Cannot find configuration file. Use config-sample.json as a starting point, pass --configPath option."
|
|
74
|
-
);
|
|
54
|
+
throw error;
|
|
75
55
|
}
|
|
76
|
-
return config;
|
|
77
56
|
}
|
|
78
57
|
async function prepDirectory(exportPath) {
|
|
79
58
|
await rm(exportPath, { recursive: true, force: true });
|
|
80
59
|
await mkdir(exportPath, { recursive: true });
|
|
81
60
|
}
|
|
82
61
|
function generateFolderName(folderName) {
|
|
62
|
+
if (!folderName || typeof folderName !== "string") {
|
|
63
|
+
throw new Error("Folder name must be a non-empty string");
|
|
64
|
+
}
|
|
83
65
|
return snakeCase(sanitize(folderName));
|
|
84
66
|
}
|
|
85
67
|
|
|
@@ -88,14 +70,14 @@ import { clearLine, cursorTo } from "node:readline";
|
|
|
88
70
|
import { noop } from "lodash-es";
|
|
89
71
|
import * as colors from "yoctocolors";
|
|
90
72
|
function log(config) {
|
|
91
|
-
if (config.verbose
|
|
73
|
+
if (!config.verbose) {
|
|
92
74
|
return noop;
|
|
93
75
|
}
|
|
94
76
|
if (config.logFunction) {
|
|
95
77
|
return config.logFunction;
|
|
96
78
|
}
|
|
97
|
-
return (text, overwrite) => {
|
|
98
|
-
if (overwrite
|
|
79
|
+
return (text, overwrite = false) => {
|
|
80
|
+
if (overwrite && process.stdout.isTTY) {
|
|
99
81
|
clearLine(process.stdout, 0);
|
|
100
82
|
cursorTo(process.stdout, 0);
|
|
101
83
|
} else {
|
|
@@ -115,16 +97,12 @@ ${formatWarning(text)}
|
|
|
115
97
|
};
|
|
116
98
|
}
|
|
117
99
|
function formatWarning(text) {
|
|
118
|
-
|
|
119
|
-
return colors.yellow(warningMessage);
|
|
100
|
+
return colors.yellow(`${colors.underline("Warning")}: ${text}`);
|
|
120
101
|
}
|
|
121
102
|
function formatError(error) {
|
|
122
103
|
const messageText = error instanceof Error ? error.message : error;
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
""
|
|
126
|
-
)}`;
|
|
127
|
-
return colors.red(errorMessage);
|
|
104
|
+
const cleanMessage = messageText.replace(/^Error:\s*/i, "");
|
|
105
|
+
return colors.red(`${colors.underline("Error")}: ${cleanMessage}`);
|
|
128
106
|
}
|
|
129
107
|
|
|
130
108
|
// src/lib/import-gtfs.ts
|