@unvt/charites 2.1.4 → 2.1.9
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/.dockerignore +92 -0
- package/.github/workflows/build.yml +7 -4
- package/Dockerfile +9 -0
- package/README.md +19 -0
- package/dist/cli/serve.js +1 -0
- package/dist/commands/serve.js +26 -3
- package/docker-entrypoint.sh +5 -0
- package/package.json +30 -27
- package/provider/src/main.ts +2 -0
- package/src/cli/serve.ts +1 -0
- package/src/commands/serve.ts +26 -3
package/.dockerignore
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
.envrc
|
|
2
|
+
|
|
3
|
+
# Logs
|
|
4
|
+
logs
|
|
5
|
+
*.log
|
|
6
|
+
npm-debug.log*
|
|
7
|
+
yarn-debug.log*
|
|
8
|
+
yarn-error.log*
|
|
9
|
+
|
|
10
|
+
# Runtime data
|
|
11
|
+
pids
|
|
12
|
+
*.pid
|
|
13
|
+
*.seed
|
|
14
|
+
*.pid.lock
|
|
15
|
+
|
|
16
|
+
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
17
|
+
lib-cov
|
|
18
|
+
|
|
19
|
+
# Coverage directory used by tools like istanbul
|
|
20
|
+
coverage
|
|
21
|
+
|
|
22
|
+
# nyc test coverage
|
|
23
|
+
.nyc_output
|
|
24
|
+
|
|
25
|
+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
|
26
|
+
.grunt
|
|
27
|
+
|
|
28
|
+
# Bower dependency directory (https://bower.io/)
|
|
29
|
+
bower_components
|
|
30
|
+
|
|
31
|
+
# node-waf configuration
|
|
32
|
+
.lock-wscript
|
|
33
|
+
|
|
34
|
+
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
35
|
+
build/Release
|
|
36
|
+
|
|
37
|
+
# Dependency directories
|
|
38
|
+
node_modules/
|
|
39
|
+
jspm_packages/
|
|
40
|
+
src/referers.json
|
|
41
|
+
|
|
42
|
+
# TypeScript v1 declaration files
|
|
43
|
+
typings/
|
|
44
|
+
|
|
45
|
+
# Optional npm cache directory
|
|
46
|
+
.npm
|
|
47
|
+
|
|
48
|
+
# Optional eslint cache
|
|
49
|
+
.eslintcache
|
|
50
|
+
|
|
51
|
+
# Optional REPL history
|
|
52
|
+
.node_repl_history
|
|
53
|
+
|
|
54
|
+
# Output of 'npm pack'
|
|
55
|
+
*.tgz
|
|
56
|
+
|
|
57
|
+
# Yarn Integrity file
|
|
58
|
+
.yarn-integrity
|
|
59
|
+
|
|
60
|
+
# dotenv environment variables file
|
|
61
|
+
.env
|
|
62
|
+
|
|
63
|
+
# parcel-bundler cache (https://parceljs.org/)
|
|
64
|
+
.cache
|
|
65
|
+
|
|
66
|
+
# next.js build output
|
|
67
|
+
.next
|
|
68
|
+
|
|
69
|
+
# nuxt.js build output
|
|
70
|
+
.nuxt
|
|
71
|
+
|
|
72
|
+
# vuepress build output
|
|
73
|
+
.vuepress/dist
|
|
74
|
+
|
|
75
|
+
# Serverless directories
|
|
76
|
+
.serverless
|
|
77
|
+
|
|
78
|
+
test-results/
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
.github/
|
|
82
|
+
.devcontainer/
|
|
83
|
+
docs/
|
|
84
|
+
test/
|
|
85
|
+
.gitignore
|
|
86
|
+
.mocharc.json
|
|
87
|
+
.prettierrc.cjs
|
|
88
|
+
eslint.config.mjs
|
|
89
|
+
mocha-register.cjs
|
|
90
|
+
playwright.config.ts
|
|
91
|
+
README.md
|
|
92
|
+
.all-contributorsrc
|
|
@@ -12,6 +12,10 @@ on:
|
|
|
12
12
|
branches:
|
|
13
13
|
- main
|
|
14
14
|
|
|
15
|
+
permissions:
|
|
16
|
+
id-token: write # Required for OIDC
|
|
17
|
+
contents: read
|
|
18
|
+
|
|
15
19
|
jobs:
|
|
16
20
|
build:
|
|
17
21
|
strategy:
|
|
@@ -60,16 +64,15 @@ jobs:
|
|
|
60
64
|
needs: build
|
|
61
65
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
62
66
|
steps:
|
|
63
|
-
- uses: actions/checkout@
|
|
67
|
+
- uses: actions/checkout@v4
|
|
64
68
|
# Setup .npmrc file to publish to npm
|
|
65
|
-
- uses: actions/setup-node@
|
|
69
|
+
- uses: actions/setup-node@v4
|
|
66
70
|
with:
|
|
67
71
|
tag_name: 'v%s'
|
|
68
72
|
node-version: '22.x'
|
|
69
73
|
registry-url: 'https://registry.npmjs.org'
|
|
70
74
|
scope: '@unvt'
|
|
75
|
+
- run: npm install -g npm@latest
|
|
71
76
|
- run: npm install
|
|
72
77
|
- run: npm run build
|
|
73
78
|
- run: npm publish --access=public
|
|
74
|
-
env:
|
|
75
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/Dockerfile
ADDED
package/README.md
CHANGED
|
@@ -33,6 +33,25 @@ MIT
|
|
|
33
33
|
|
|
34
34
|
- Node.js v20 or later
|
|
35
35
|
|
|
36
|
+
## Docker
|
|
37
|
+
|
|
38
|
+
Build the Docker image:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
docker build -t charites:latest .
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Run charites commands in Docker:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
docker run --rm -v $(pwd):/data -u $(id -u):$(id -g) charites:latest init /data/my-style.yml
|
|
48
|
+
docker run --rm -v $(pwd):/data -u $(id -u):$(id -g) charites:latest convert /data/style.json /data/style.yml
|
|
49
|
+
docker run --rm -v $(pwd):/data -u $(id -u):$(id -g) charites:latest build /data/style.yml /data/style.json
|
|
50
|
+
docker run --init -it --rm -p 8080:8080 -v $(pwd):/data charites:latest serve /data/style.yml
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Note: `charites serve` requires running as root user because it needs to rebuild vite server inside the container.
|
|
54
|
+
|
|
36
55
|
## Contributors ✨
|
|
37
56
|
|
|
38
57
|
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
package/dist/cli/serve.js
CHANGED
package/dist/commands/serve.js
CHANGED
|
@@ -67,7 +67,28 @@ export async function serve(source, options) {
|
|
|
67
67
|
try {
|
|
68
68
|
style = parser(sourcePath);
|
|
69
69
|
if (typeof spriteOut !== 'undefined') {
|
|
70
|
-
|
|
70
|
+
const spriteUrl = `http://${req.headers.host || `localhost:${port}`}/sprite`;
|
|
71
|
+
if (typeof style.sprite === 'string') {
|
|
72
|
+
// update a single sprite URL
|
|
73
|
+
style.sprite = spriteUrl;
|
|
74
|
+
}
|
|
75
|
+
else if (Array.isArray(style.sprite)) {
|
|
76
|
+
// if sprite is an array, update default sprite URL.
|
|
77
|
+
// if default sprite is not found, add default url.
|
|
78
|
+
if (style.sprite.find((s) => s.id === 'default')) {
|
|
79
|
+
for (const s of style.sprite) {
|
|
80
|
+
if (s.id === 'default') {
|
|
81
|
+
s.url = spriteUrl;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
style.sprite.push({
|
|
87
|
+
id: 'default',
|
|
88
|
+
url: spriteUrl,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
71
92
|
}
|
|
72
93
|
validateStyle(style);
|
|
73
94
|
}
|
|
@@ -148,7 +169,7 @@ export async function serve(source, options) {
|
|
|
148
169
|
sockets.delete(ws);
|
|
149
170
|
});
|
|
150
171
|
});
|
|
151
|
-
|
|
172
|
+
const cleanUpAndExit = () => {
|
|
152
173
|
console.log('Cleaning up...');
|
|
153
174
|
server.close();
|
|
154
175
|
watcher.close();
|
|
@@ -157,6 +178,8 @@ export async function serve(source, options) {
|
|
|
157
178
|
spriteOut = undefined;
|
|
158
179
|
}
|
|
159
180
|
process.exit(0);
|
|
160
|
-
}
|
|
181
|
+
};
|
|
182
|
+
process.on('SIGINT', cleanUpAndExit);
|
|
183
|
+
process.on('SIGTERM', cleanUpAndExit);
|
|
161
184
|
return server;
|
|
162
185
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unvt/charites",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"bin": {
|
|
6
6
|
"charites": "dist/cli.js"
|
|
@@ -17,53 +17,56 @@
|
|
|
17
17
|
"workspaces": [
|
|
18
18
|
"provider"
|
|
19
19
|
],
|
|
20
|
+
"repository": {
|
|
21
|
+
"url": "https://github.com/unvt/charites"
|
|
22
|
+
},
|
|
20
23
|
"author": "",
|
|
21
24
|
"license": "MIT",
|
|
22
25
|
"dependencies": {
|
|
23
|
-
"@maplibre/maplibre-gl-inspect": "^1.
|
|
24
|
-
"@maplibre/maplibre-gl-style-spec": "^
|
|
26
|
+
"@maplibre/maplibre-gl-inspect": "^1.8.1",
|
|
27
|
+
"@maplibre/maplibre-gl-style-spec": "^24.3.1",
|
|
25
28
|
"@unvt/sprite-one": "^0.1.1",
|
|
26
29
|
"@watergis/maplibre-gl-legend": "^2.0.5",
|
|
27
|
-
"commander": "^14.0.
|
|
28
|
-
"glob": "^
|
|
30
|
+
"commander": "^14.0.2",
|
|
31
|
+
"glob": "^13.0.0",
|
|
29
32
|
"jsonminify": "^0.4.2",
|
|
30
|
-
"maplibre-gl": "^5.
|
|
33
|
+
"maplibre-gl": "^5.14.0",
|
|
31
34
|
"node-watch": "^0.7.4",
|
|
32
|
-
"open": "^
|
|
35
|
+
"open": "^11.0.0",
|
|
33
36
|
"pmtiles": "^4.3.0",
|
|
34
|
-
"vite": "^
|
|
35
|
-
"ws": "^8.18.
|
|
36
|
-
"yaml": "^2.8.
|
|
37
|
+
"vite": "^7.2.7",
|
|
38
|
+
"ws": "^8.18.3",
|
|
39
|
+
"yaml": "^2.8.2"
|
|
37
40
|
},
|
|
38
41
|
"devDependencies": {
|
|
39
|
-
"@eslint/eslintrc": "^3.3.
|
|
40
|
-
"@eslint/js": "^9.
|
|
41
|
-
"@playwright/test": "^1.
|
|
42
|
-
"@types/chai": "^5.2.
|
|
42
|
+
"@eslint/eslintrc": "^3.3.3",
|
|
43
|
+
"@eslint/js": "^9.39.1",
|
|
44
|
+
"@playwright/test": "^1.57.0",
|
|
45
|
+
"@types/chai": "^5.2.3",
|
|
43
46
|
"@types/chai-as-promised": "^8.0.2",
|
|
44
47
|
"@types/fs-extra": "^11.0.4",
|
|
45
48
|
"@types/geojson": "^7946.0.16",
|
|
46
49
|
"@types/jsonminify": "^0.4.3",
|
|
47
50
|
"@types/mapbox__point-geometry": "^0.1.4",
|
|
48
51
|
"@types/mocha": "^10.0.10",
|
|
49
|
-
"@types/node": "^
|
|
52
|
+
"@types/node": "^24.10.1",
|
|
50
53
|
"@types/ws": "^8.18.1",
|
|
51
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
52
|
-
"@typescript-eslint/parser": "^8.
|
|
53
|
-
"chai": "^
|
|
54
|
-
"chai-as-promised": "^8.0.
|
|
55
|
-
"eslint": "^9.
|
|
56
|
-
"eslint-config-prettier": "^10.1.
|
|
57
|
-
"eslint-plugin-prettier": "^5.4
|
|
58
|
-
"fs-extra": "^11.3.
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "^8.48.1",
|
|
55
|
+
"@typescript-eslint/parser": "^8.48.1",
|
|
56
|
+
"chai": "^6.2.1",
|
|
57
|
+
"chai-as-promised": "^8.0.2",
|
|
58
|
+
"eslint": "^9.39.1",
|
|
59
|
+
"eslint-config-prettier": "^10.1.8",
|
|
60
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
61
|
+
"fs-extra": "^11.3.2",
|
|
59
62
|
"kill-port-process": "^3.2.1",
|
|
60
|
-
"mocha": "^11.
|
|
63
|
+
"mocha": "^11.7.5",
|
|
61
64
|
"node-abort-controller": "^3.1.1",
|
|
62
|
-
"prettier": "^3.
|
|
65
|
+
"prettier": "^3.7.4",
|
|
63
66
|
"ts-node": "^10.9.2",
|
|
64
67
|
"tsconfig-paths": "^4.2.0",
|
|
65
|
-
"tsx": "^4.
|
|
66
|
-
"typescript": "^5.
|
|
68
|
+
"tsx": "^4.21.0",
|
|
69
|
+
"typescript": "^5.9.3"
|
|
67
70
|
},
|
|
68
71
|
"type": "module"
|
|
69
72
|
}
|
package/provider/src/main.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
NavigationControl,
|
|
6
6
|
addProtocol,
|
|
7
7
|
IControl,
|
|
8
|
+
GlobeControl,
|
|
8
9
|
} from 'maplibre-gl'
|
|
9
10
|
import 'maplibre-gl/dist/maplibre-gl.css'
|
|
10
11
|
import '@maplibre/maplibre-gl-inspect/dist/maplibre-gl-inspect.css'
|
|
@@ -131,6 +132,7 @@ const init = async () => {
|
|
|
131
132
|
}),
|
|
132
133
|
)
|
|
133
134
|
map.addControl(new NavigationControl(), 'top-right')
|
|
135
|
+
map.addControl(new GlobeControl(), 'top-right')
|
|
134
136
|
map.addControl(
|
|
135
137
|
new MaplibreLegendControl(
|
|
136
138
|
{},
|
package/src/cli/serve.ts
CHANGED
package/src/commands/serve.ts
CHANGED
|
@@ -87,9 +87,29 @@ export async function serve(source: string, options: serveOptions) {
|
|
|
87
87
|
try {
|
|
88
88
|
style = parser(sourcePath)
|
|
89
89
|
if (typeof spriteOut !== 'undefined') {
|
|
90
|
-
|
|
90
|
+
const spriteUrl = `http://${
|
|
91
91
|
req.headers.host || `localhost:${port}`
|
|
92
92
|
}/sprite`
|
|
93
|
+
|
|
94
|
+
if (typeof style.sprite === 'string') {
|
|
95
|
+
// update a single sprite URL
|
|
96
|
+
style.sprite = spriteUrl
|
|
97
|
+
} else if (Array.isArray(style.sprite)) {
|
|
98
|
+
// if sprite is an array, update default sprite URL.
|
|
99
|
+
// if default sprite is not found, add default url.
|
|
100
|
+
if (style.sprite.find((s) => s.id === 'default')) {
|
|
101
|
+
for (const s of style.sprite) {
|
|
102
|
+
if (s.id === 'default') {
|
|
103
|
+
s.url = spriteUrl
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
style.sprite.push({
|
|
108
|
+
id: 'default',
|
|
109
|
+
url: spriteUrl,
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
}
|
|
93
113
|
}
|
|
94
114
|
validateStyle(style)
|
|
95
115
|
} catch (error) {
|
|
@@ -181,7 +201,7 @@ export async function serve(source: string, options: serveOptions) {
|
|
|
181
201
|
})
|
|
182
202
|
})
|
|
183
203
|
|
|
184
|
-
|
|
204
|
+
const cleanUpAndExit = () => {
|
|
185
205
|
console.log('Cleaning up...')
|
|
186
206
|
server.close()
|
|
187
207
|
watcher.close()
|
|
@@ -190,7 +210,10 @@ export async function serve(source: string, options: serveOptions) {
|
|
|
190
210
|
spriteOut = undefined
|
|
191
211
|
}
|
|
192
212
|
process.exit(0)
|
|
193
|
-
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
process.on('SIGINT', cleanUpAndExit)
|
|
216
|
+
process.on('SIGTERM', cleanUpAndExit)
|
|
194
217
|
|
|
195
218
|
return server
|
|
196
219
|
}
|