gtfs-to-html 2.9.12 → 2.9.14
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 +1 -0
- package/dist/app/index.js +3 -2
- package/dist/app/index.js.map +1 -1
- package/dist/bin/gtfs-to-html.js +15 -10
- package/dist/bin/gtfs-to-html.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15 -10
- package/dist/index.js.map +1 -1
- package/package.json +13 -6
- package/views/default/css/timetable_styles.css +44 -6
- package/views/default/formatting_functions.pug +8 -2
- package/views/default/js/timetable-map.js +169 -95
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -23,9 +23,10 @@ import {
|
|
|
23
23
|
copyFile,
|
|
24
24
|
mkdir,
|
|
25
25
|
readdir,
|
|
26
|
-
readFile
|
|
26
|
+
readFile,
|
|
27
|
+
rm
|
|
27
28
|
} from "node:fs/promises";
|
|
28
|
-
import _ from "lodash-es";
|
|
29
|
+
import * as _ from "lodash-es";
|
|
29
30
|
import archiver from "archiver";
|
|
30
31
|
import beautify from "js-beautify";
|
|
31
32
|
import { renderFile } from "pug";
|
|
@@ -333,7 +334,7 @@ function formatTripNameForCSV(trip, timetable) {
|
|
|
333
334
|
}
|
|
334
335
|
|
|
335
336
|
// package.json
|
|
336
|
-
var version = "2.9.
|
|
337
|
+
var version = "2.9.14";
|
|
337
338
|
|
|
338
339
|
// src/lib/utils.ts
|
|
339
340
|
var isTimepoint = (stoptime) => {
|
|
@@ -1285,6 +1286,7 @@ function setDefaultConfig(initialConfig) {
|
|
|
1285
1286
|
noServiceSymbol: "-",
|
|
1286
1287
|
noServiceText: "No service at this stop",
|
|
1287
1288
|
outputFormat: "html",
|
|
1289
|
+
overwriteExistingFiles: true,
|
|
1288
1290
|
requestDropoffSymbol: "\u2020",
|
|
1289
1291
|
requestDropoffText: "Must request drop off",
|
|
1290
1292
|
requestPickupSymbol: "***",
|
|
@@ -1846,7 +1848,7 @@ function getPathToTemplateFile(templateFileName, config) {
|
|
|
1846
1848
|
const fullTemplateFileName = config.noHead !== true ? `${templateFileName}_full.pug` : `${templateFileName}.pug`;
|
|
1847
1849
|
return join(getPathToViewsFolder(config), fullTemplateFileName);
|
|
1848
1850
|
}
|
|
1849
|
-
async function prepDirectory(outputPath) {
|
|
1851
|
+
async function prepDirectory(outputPath, config) {
|
|
1850
1852
|
try {
|
|
1851
1853
|
await access(outputPath);
|
|
1852
1854
|
} catch (error) {
|
|
@@ -1862,11 +1864,14 @@ async function prepDirectory(outputPath) {
|
|
|
1862
1864
|
}
|
|
1863
1865
|
}
|
|
1864
1866
|
const files = await readdir(outputPath);
|
|
1865
|
-
if (files.length > 0) {
|
|
1867
|
+
if (config.overwriteExistingFiles === false && files.length > 0) {
|
|
1866
1868
|
throw new Error(
|
|
1867
1869
|
`Output directory ${outputPath} is not empty. Please specify an empty directory.`
|
|
1868
1870
|
);
|
|
1869
1871
|
}
|
|
1872
|
+
if (config.overwriteExistingFiles === true) {
|
|
1873
|
+
await rm(join(outputPath, "*"), { recursive: true, force: true });
|
|
1874
|
+
}
|
|
1870
1875
|
}
|
|
1871
1876
|
async function copyStaticAssets(config, outputPath) {
|
|
1872
1877
|
const viewsFolderPath = getPathToViewsFolder(config);
|
|
@@ -2117,7 +2122,12 @@ var gtfsToHtml = async (initialConfig) => {
|
|
|
2117
2122
|
config.log = log(config);
|
|
2118
2123
|
config.logWarning = logWarning(config);
|
|
2119
2124
|
config.logError = logError(config);
|
|
2125
|
+
const agencyKey = config.agencies.map(
|
|
2126
|
+
(agency) => agency.agencyKey ?? agency.agency_key ?? "unknown"
|
|
2127
|
+
).join("-");
|
|
2128
|
+
const outputPath = config.outputPath ? untildify2(config.outputPath) : path.join(process.cwd(), "html", sanitize2(agencyKey));
|
|
2120
2129
|
timer.start();
|
|
2130
|
+
await prepDirectory(outputPath, config);
|
|
2121
2131
|
try {
|
|
2122
2132
|
openDb2(config);
|
|
2123
2133
|
} catch (error) {
|
|
@@ -2134,10 +2144,6 @@ var gtfsToHtml = async (initialConfig) => {
|
|
|
2134
2144
|
if (!config.skipImport) {
|
|
2135
2145
|
await importGtfs(config);
|
|
2136
2146
|
}
|
|
2137
|
-
const agencyKey = config.agencies.map(
|
|
2138
|
-
(agency) => agency.agencyKey ?? agency.agency_key ?? "unknown"
|
|
2139
|
-
).join("-");
|
|
2140
|
-
const outputPath = config.outputPath ? untildify2(config.outputPath) : path.join(process.cwd(), "html", sanitize2(agencyKey));
|
|
2141
2147
|
const stats = {
|
|
2142
2148
|
timetables: 0,
|
|
2143
2149
|
timetablePages: 0,
|
|
@@ -2152,7 +2158,6 @@ var gtfsToHtml = async (initialConfig) => {
|
|
|
2152
2158
|
getTimetablePagesForAgency(config),
|
|
2153
2159
|
"timetable_page_id"
|
|
2154
2160
|
);
|
|
2155
|
-
await prepDirectory(outputPath);
|
|
2156
2161
|
if (config.noHead !== true && ["html", "pdf"].includes(config.outputFormat)) {
|
|
2157
2162
|
await copyStaticAssets(config, outputPath);
|
|
2158
2163
|
}
|