gtfs-to-html 2.12.1 → 2.12.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtfs-to-html",
3
- "version": "2.12.1",
3
+ "version": "2.12.3",
4
4
  "private": false,
5
5
  "description": "Build human readable transit timetables as HTML, PDF or CSV from GTFS",
6
6
  "keywords": [
@@ -35,6 +35,7 @@
35
35
  "dist",
36
36
  "docker",
37
37
  "examples",
38
+ "scripts",
38
39
  "views/default",
39
40
  "config-sample.json"
40
41
  ],
@@ -43,30 +44,32 @@
43
44
  },
44
45
  "scripts": {
45
46
  "build": "tsup",
47
+ "postbuild": "node scripts/postinstall.js",
46
48
  "start": "node ./dist/app",
47
- "prepare": "husky"
49
+ "prepare": "husky && npm run build",
50
+ "postinstall": "node scripts/postinstall.js"
48
51
  },
49
52
  "dependencies": {
50
53
  "@maplibre/maplibre-gl-geocoder": "^1.9.1",
51
- "@turf/helpers": "^7.3.0",
52
- "@turf/simplify": "^7.3.0",
54
+ "@turf/helpers": "^7.3.1",
55
+ "@turf/simplify": "^7.3.1",
53
56
  "anchorme": "^3.0.8",
54
57
  "archiver": "^7.0.1",
55
58
  "cli-table": "^0.3.11",
56
59
  "css.escape": "^1.5.1",
57
60
  "csv-stringify": "^6.6.0",
58
- "express": "^5.1.0",
59
- "gtfs": "^4.18.1",
61
+ "express": "^5.2.1",
62
+ "gtfs": "^4.18.2",
60
63
  "gtfs-realtime-pbf-js-module": "^1.0.0",
61
64
  "js-beautify": "^1.15.4",
62
65
  "lodash-es": "^4.17.21",
63
- "maplibre-gl": "^5.13.0",
64
- "marked": "^17.0.0",
66
+ "maplibre-gl": "^5.14.0",
67
+ "marked": "^17.0.1",
65
68
  "moment": "^2.30.1",
66
69
  "pbf": "^4.0.1",
67
70
  "pretty-error": "^4.0.0",
68
71
  "pug": "^3.0.3",
69
- "puppeteer": "^24.30.0",
72
+ "puppeteer": "^24.32.0",
70
73
  "sanitize-filename": "^1.6.3",
71
74
  "sanitize-html": "^2.17.0",
72
75
  "sqlstring": "^2.3.3",
@@ -77,7 +80,7 @@
77
80
  "devDependencies": {
78
81
  "@types/archiver": "^7.0.0",
79
82
  "@types/cli-table": "^0.3.4",
80
- "@types/express": "^5.0.5",
83
+ "@types/express": "^5.0.6",
81
84
  "@types/insane": "^1.0.0",
82
85
  "@types/js-beautify": "^1.14.3",
83
86
  "@types/lodash-es": "^4.17.12",
@@ -90,7 +93,7 @@
90
93
  "@types/yargs": "^17.0.35",
91
94
  "husky": "^9.1.7",
92
95
  "lint-staged": "^16.2.7",
93
- "prettier": "^3.6.2",
96
+ "prettier": "^3.7.4",
94
97
  "tsup": "^8.5.1",
95
98
  "typescript": "^5.9.3"
96
99
  },
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Postinstall Script - Copy Frontend Libraries
5
+ *
6
+ * This script copies browser-compatible JavaScript and CSS files from node_modules
7
+ * into the dist/frontend_libraries directory. These files are needed for the HTML
8
+ * timetables to work in browsers (for maps, geocoding, protocol buffers, etc.).
9
+ *
10
+ * Why this is needed:
11
+ * - The generated HTML files reference these libraries directly
12
+ * - They must be bundled with the package so they're available when installed as a dependency
13
+ * - npm/pnpm may hoist dependencies, so we can't rely on a fixed node_modules path
14
+ *
15
+ * This script handles multiple installation scenarios:
16
+ * - Direct installation (npm install in this package)
17
+ * - Installed as a dependency (node_modules may be hoisted to parent)
18
+ * - Works with both npm and pnpm
19
+ */
20
+
21
+ import { mkdir, copyFile } from 'node:fs/promises';
22
+ import { accessSync } from 'node:fs';
23
+ import { dirname, join } from 'node:path';
24
+ import { fileURLToPath } from 'node:url';
25
+
26
+ const __dirname = dirname(fileURLToPath(import.meta.url));
27
+
28
+ const targetDir = join(__dirname, '../dist/frontend_libraries');
29
+
30
+ const filesToCopy = [
31
+ {
32
+ package: 'pbf',
33
+ source: 'dist/pbf.js',
34
+ target: 'pbf.js',
35
+ },
36
+ {
37
+ package: 'gtfs-realtime-pbf-js-module',
38
+ source: 'gtfs-realtime.browser.proto.js',
39
+ target: 'gtfs-realtime.browser.proto.js',
40
+ },
41
+ {
42
+ package: 'anchorme',
43
+ source: 'dist/browser/anchorme.min.js',
44
+ target: 'anchorme.min.js',
45
+ },
46
+ {
47
+ package: 'maplibre-gl',
48
+ source: 'dist/maplibre-gl.js',
49
+ target: 'maplibre-gl.js',
50
+ },
51
+ {
52
+ package: 'maplibre-gl',
53
+ source: 'dist/maplibre-gl.css',
54
+ target: 'maplibre-gl.css',
55
+ },
56
+ {
57
+ package: '@maplibre/maplibre-gl-geocoder',
58
+ source: 'dist/maplibre-gl-geocoder.js',
59
+ target: 'maplibre-gl-geocoder.js',
60
+ },
61
+ {
62
+ package: '@maplibre/maplibre-gl-geocoder',
63
+ source: 'dist/maplibre-gl-geocoder.css',
64
+ target: 'maplibre-gl-geocoder.css',
65
+ },
66
+ ];
67
+
68
+ function resolvePackagePath(packageName) {
69
+ const possiblePaths = [
70
+ // Direct dependency (when running in development or as root package)
71
+ join(__dirname, '../node_modules', packageName),
72
+ // Hoisted dependency (when installed as a dependency in another project)
73
+ join(__dirname, '../../', packageName),
74
+ // Deeply nested
75
+ join(__dirname, '../../../', packageName),
76
+ ];
77
+
78
+ for (const path of possiblePaths) {
79
+ try {
80
+ accessSync(path);
81
+ return path;
82
+ } catch {
83
+ continue;
84
+ }
85
+ }
86
+
87
+ throw new Error(`Could not resolve package: ${packageName}`);
88
+ }
89
+
90
+ async function copyFrontendLibraries() {
91
+ try {
92
+ await mkdir(targetDir, { recursive: true });
93
+
94
+ for (const file of filesToCopy) {
95
+ try {
96
+ const packagePath = resolvePackagePath(file.package);
97
+ const sourcePath = join(packagePath, file.source);
98
+ const targetPath = join(targetDir, file.target);
99
+
100
+ await copyFile(sourcePath, targetPath);
101
+ } catch (error) {
102
+ console.error(
103
+ `Failed to copy ${file.package}/${file.source}:`,
104
+ error.message,
105
+ );
106
+ // Continue with other files even if one fails
107
+ }
108
+ }
109
+ } catch (error) {
110
+ console.error('Error copying frontend libraries:', error);
111
+ process.exit(1);
112
+ }
113
+ }
114
+
115
+ copyFrontendLibraries();