gtfs 4.10.3 → 4.10.4
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 +8 -0
- package/bin/gtfs-export.js +4 -0
- package/bin/gtfs-import.js +4 -1
- package/bin/gtfsrealtime-update.js +4 -1
- package/lib/file-utils.js +23 -26
- package/lib/import.js +0 -1
- package/lib/log-utils.js +1 -5
- package/package.json +4 -4
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
|
+
## [4.10.4] - 2024-05-14
|
|
9
|
+
|
|
10
|
+
### Updated
|
|
11
|
+
|
|
12
|
+
- Improved error messages
|
|
13
|
+
- Don't use pretty-error globally
|
|
14
|
+
- Dependency updates
|
|
15
|
+
|
|
8
16
|
## [4.10.3] - 2024-05-12
|
|
9
17
|
|
|
10
18
|
### Added
|
package/bin/gtfs-export.js
CHANGED
|
@@ -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 { exportGtfs } from '../lib/gtfs.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()
|
|
@@ -26,6 +29,7 @@ const { argv } = yargs(hideBin(process.argv))
|
|
|
26
29
|
|
|
27
30
|
const handleError = (error = 'Unknown Error') => {
|
|
28
31
|
process.stdout.write(`\n${formatError(error)}\n`);
|
|
32
|
+
console.error(pe.render(error));
|
|
29
33
|
process.exit(1);
|
|
30
34
|
};
|
|
31
35
|
|
package/bin/gtfs-import.js
CHANGED
|
@@ -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 { closeDb, importGtfs, openDb } from '../lib/gtfs.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()
|
|
@@ -31,7 +34,7 @@ const { argv } = yargs(hideBin(process.argv))
|
|
|
31
34
|
const handleError = (error) => {
|
|
32
35
|
const text = error || 'Unknown Error';
|
|
33
36
|
process.stdout.write(`\n${formatError(text)}\n`);
|
|
34
|
-
console.error(error);
|
|
37
|
+
console.error(pe.render(error));
|
|
35
38
|
process.exit(1);
|
|
36
39
|
};
|
|
37
40
|
|
|
@@ -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 { updateGtfsRealtime } from '../lib/gtfs.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()
|
|
@@ -19,7 +22,7 @@ const { argv } = yargs(hideBin(process.argv))
|
|
|
19
22
|
const handleError = (error) => {
|
|
20
23
|
const text = error || 'Unknown Error';
|
|
21
24
|
process.stdout.write(`\n${formatError(text)}\n`);
|
|
22
|
-
console.error(error);
|
|
25
|
+
console.error(pe.render(error));
|
|
23
26
|
process.exit(1);
|
|
24
27
|
};
|
|
25
28
|
|
package/lib/file-utils.js
CHANGED
|
@@ -11,43 +11,42 @@ import StreamZip from 'node-stream-zip';
|
|
|
11
11
|
*/
|
|
12
12
|
export async function getConfig(argv) {
|
|
13
13
|
let config;
|
|
14
|
+
let data;
|
|
14
15
|
|
|
15
16
|
if (argv.configPath) {
|
|
16
17
|
// If a `configPath` is specified, try to read it and throw error if it doesn't exist
|
|
17
18
|
try {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
);
|
|
27
|
-
throw error;
|
|
28
|
-
});
|
|
19
|
+
data = await readFile(path.resolve(untildify(argv.configPath)), 'utf8');
|
|
20
|
+
} catch (error) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
`Cannot find configuration file at \`${argv.configPath}\`. Use config-sample.json as a starting point.`,
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
try {
|
|
29
27
|
config = Object.assign(JSON.parse(data), argv);
|
|
30
28
|
} catch (error) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
`Cannot parse configuration file at \`${argv.configPath}\`. Check to ensure that it is valid JSON.`
|
|
34
|
-
)
|
|
29
|
+
throw new Error(
|
|
30
|
+
`Cannot parse configuration file at \`${argv.configPath}\`. Check to ensure that it is valid JSON.`,
|
|
35
31
|
);
|
|
36
|
-
throw error;
|
|
37
32
|
}
|
|
38
33
|
} else if (existsSync(path.resolve('./config.json'))) {
|
|
39
34
|
// Else if `config.json` exists, use config values read from it
|
|
40
35
|
try {
|
|
41
|
-
|
|
36
|
+
data = await readFile(path.resolve('./config.json'), 'utf8');
|
|
37
|
+
} catch (error) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
`Cannot open configuration file at \`${path.resolve('./config.json')}\`. Check to ensure that it exists. Use config-sample.json as a starting point.`,
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
try {
|
|
42
44
|
config = Object.assign(JSON.parse(data), argv);
|
|
43
45
|
console.log('Using configuration from ./config.json');
|
|
44
46
|
} catch (error) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
'Cannot parse configuration file at `./config.json`. Check to ensure that it is valid JSON.'
|
|
48
|
-
)
|
|
47
|
+
throw new Error(
|
|
48
|
+
`Cannot parse configuration file at \`${path.resolve('./config.json')}\`. Check to ensure that it is valid JSON.`,
|
|
49
49
|
);
|
|
50
|
-
throw error;
|
|
51
50
|
}
|
|
52
51
|
} else if (argv.gtfsPath || argv.gtfsUrl) {
|
|
53
52
|
// Use argv values from CLI
|
|
@@ -69,11 +68,9 @@ export async function getConfig(argv) {
|
|
|
69
68
|
...omit(argv, ['path', 'url']),
|
|
70
69
|
};
|
|
71
70
|
} else {
|
|
72
|
-
|
|
73
|
-
'Cannot find configuration file. Use config-sample.json as a starting point, pass --configPath option.'
|
|
71
|
+
throw new Error(
|
|
72
|
+
'Cannot find configuration file. Use config-sample.json as a starting point, pass --configPath option.',
|
|
74
73
|
);
|
|
75
|
-
console.error(error);
|
|
76
|
-
throw error;
|
|
77
74
|
}
|
|
78
75
|
|
|
79
76
|
return config;
|
package/lib/import.js
CHANGED
package/lib/log-utils.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
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
|
|
|
6
|
-
const pe = new PrettyError();
|
|
7
|
-
pe.start();
|
|
8
|
-
|
|
9
5
|
/*
|
|
10
6
|
* Returns a log function based on config settings
|
|
11
7
|
*/
|
|
@@ -71,7 +67,7 @@ export function formatError(error) {
|
|
|
71
67
|
const messageText = error instanceof Error ? error.message : error;
|
|
72
68
|
const errorMessage = `${colors.underline('Error')}: ${messageText.replace(
|
|
73
69
|
'Error: ',
|
|
74
|
-
''
|
|
70
|
+
'',
|
|
75
71
|
)}`;
|
|
76
72
|
return colors.red(errorMessage);
|
|
77
73
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gtfs",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.4",
|
|
4
4
|
"description": "Import GTFS transit data into SQLite and query routes, stops, times, fares and more",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"transit",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@turf/helpers": "^6.5.0",
|
|
80
80
|
"better-sqlite3": "^10.0.0",
|
|
81
|
-
"csv-parse": "^5.5.
|
|
82
|
-
"csv-stringify": "^6.
|
|
81
|
+
"csv-parse": "^5.5.6",
|
|
82
|
+
"csv-stringify": "^6.5.0",
|
|
83
83
|
"gtfs-realtime-bindings": "^1.1.1",
|
|
84
84
|
"lodash-es": "^4.17.21",
|
|
85
85
|
"long": "^5.2.3",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"tmp-promise": "^3.0.3",
|
|
96
96
|
"untildify": "^5.0.0",
|
|
97
97
|
"yargs": "^17.7.2",
|
|
98
|
-
"yoctocolors": "^2.0.
|
|
98
|
+
"yoctocolors": "^2.0.2"
|
|
99
99
|
},
|
|
100
100
|
"devDependencies": {
|
|
101
101
|
"husky": "^9.0.11",
|