tileserver-gl-light 4.1.2 → 4.2.1

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/.eslintrc.cjs ADDED
@@ -0,0 +1,32 @@
1
+ module.exports = {
2
+ root: true,
3
+ env: {
4
+ browser: true,
5
+ node: true,
6
+ es6: true,
7
+ },
8
+ parserOptions: {
9
+ parser: '@typescript-eslint/parser',
10
+ ecmaVersion: 2020,
11
+ sourceType: 'module',
12
+ lib: ['es2020'],
13
+ ecmaFeatures: {
14
+ jsx: true,
15
+ tsx: true,
16
+ },
17
+ },
18
+ plugins: ['prettier', 'jsdoc', 'security'],
19
+ extends: [
20
+ 'prettier',
21
+ 'plugin:@typescript-eslint/recommended',
22
+ 'plugin:@typescript-eslint/eslint-recommended',
23
+ 'plugin:prettier/recommended',
24
+ 'plugin:jsdoc/recommended',
25
+ 'plugin:security/recommended',
26
+ ],
27
+ // add your custom rules here
28
+ rules: {
29
+ 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
30
+ 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
31
+ },
32
+ };
package/.gitattributes ADDED
@@ -0,0 +1,11 @@
1
+ ###############################################################################
2
+ # Set default behavior to automatically normalize line endings.
3
+ ###############################################################################
4
+ * text=auto
5
+
6
+ ###############################################################################
7
+ # behavior for Unix scripts
8
+ #
9
+ # Unix scripts are treated as binary by default.
10
+ ###############################################################################
11
+ *.sh eol=lf
@@ -0,0 +1,19 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: npm
4
+ versioning-strategy: increase
5
+ directory: '/'
6
+ schedule:
7
+ interval: daily
8
+ commit-message:
9
+ prefix: fix
10
+ prefix-development: chore
11
+ include: scope
12
+ - package-ecosystem: github-actions
13
+ directory: '/'
14
+ schedule:
15
+ interval: weekly
16
+ commit-message:
17
+ prefix: fix
18
+ prefix-development: chore
19
+ include: scope
@@ -0,0 +1,35 @@
1
+ on:
2
+ push:
3
+ branches:
4
+ - master
5
+ pull_request:
6
+ branches:
7
+ - master
8
+ schedule:
9
+ - cron: '45 23 * * 2'
10
+ jobs:
11
+ analyze:
12
+ name: Analyze
13
+ runs-on: ubuntu-latest
14
+ permissions:
15
+ actions: read
16
+ contents: read
17
+ security-events: write
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ language: [javascript]
22
+ steps:
23
+ - name: Checkout
24
+ uses: actions/checkout@v3
25
+ - name: Initialize CodeQL
26
+ uses: github/codeql-action/init@v2
27
+ with:
28
+ languages: ${{ matrix.language }}
29
+ queries: +security-and-quality
30
+ - name: Autobuild
31
+ uses: github/codeql-action/autobuild@v2
32
+ - name: Perform CodeQL Analysis
33
+ uses: github/codeql-action/analyze@v2
34
+ with:
35
+ category: '/language:${{ matrix.language }}'
@@ -0,0 +1,57 @@
1
+ name: 'Continuous Testing'
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ branches:
9
+ - master
10
+
11
+ permissions:
12
+ checks: write
13
+ contents: read
14
+
15
+ jobs:
16
+ ct:
17
+ runs-on: ubuntu-20.04
18
+ steps:
19
+ - name: Check out repository ✨ (non-dependabot)
20
+ if: ${{ github.actor != 'dependabot[bot]' }}
21
+ uses: actions/checkout@v3
22
+
23
+ - name: Check out repository 🎉 (dependabot)
24
+ if: ${{ github.actor == 'dependabot[bot]' }}
25
+ uses: actions/checkout@v3
26
+ with:
27
+ ref: ${{ github.event.pull_request.head.sha }}
28
+
29
+ - name: Update apt-get 🚀
30
+ run: sudo apt-get update -qq
31
+
32
+ - name: Install dependencies (Ubuntu) 🚀
33
+ run: >-
34
+ sudo apt-get install -qq libcairo2-dev libjpeg8-dev libpango1.0-dev
35
+ libgif-dev build-essential g++ xvfb libgles2-mesa-dev libgbm-dev
36
+ libxxf86vm-dev
37
+
38
+ - name: Setup node env 📦
39
+ uses: actions/setup-node@v3
40
+ with:
41
+ node-version-file: 'package.json'
42
+ check-latest: true
43
+ cache: 'npm'
44
+
45
+ - name: Install dependencies 🚀
46
+ run: npm ci --prefer-offline --no-audit --omit=optional
47
+
48
+ - name: Pull test data 📦
49
+ run: >-
50
+ wget -O test_data.zip
51
+ https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip
52
+
53
+ - name: Prepare test data 📦
54
+ run: unzip -q test_data.zip -d test_data
55
+
56
+ - name: Run tests 🧪
57
+ run: xvfb-run --server-args="-screen 0 1024x768x24" npm test
@@ -0,0 +1,103 @@
1
+ name: "Build, Test, Release"
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ docker_user:
7
+ description: 'Docker Username'
8
+ required: true
9
+ docker_token:
10
+ description: 'Docker Token'
11
+ required: true
12
+ npm_token:
13
+ description: 'NPM Token'
14
+ required: true
15
+
16
+ jobs:
17
+ release:
18
+ name: "Build, Test, Publish"
19
+ runs-on: ubuntu-20.04
20
+ steps:
21
+ - name: Check out repository ✨
22
+ uses: actions/checkout@v3
23
+
24
+ - name: Update apt-get 🚀
25
+ run: sudo apt-get update -qq
26
+
27
+ - name: Install dependencies (Ubuntu) 🚀
28
+ run: >-
29
+ sudo apt-get install -qq libcairo2-dev libjpeg8-dev libpango1.0-dev
30
+ libgif-dev build-essential g++ xvfb libgles2-mesa-dev libgbm-dev
31
+ libxxf86vm-dev
32
+
33
+ - name: Setup node env 📦
34
+ uses: actions/setup-node@v3
35
+ with:
36
+ node-version-file: 'package.json'
37
+ check-latest: true
38
+ cache: 'npm'
39
+
40
+ - name: Install dependencies 🚀
41
+ run: npm ci --prefer-offline --no-audit --omit=optional
42
+
43
+ - name: Pull test data 📦
44
+ run: >-
45
+ wget -O test_data.zip
46
+ https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip
47
+
48
+ - name: Prepare test data 📦
49
+ run: unzip -q test_data.zip -d test_data
50
+
51
+ - name: Run tests 🧪
52
+ run: xvfb-run --server-args="-screen 0 1024x768x24" npm test
53
+
54
+ - name: Remove Test Data
55
+ run: rm -R test_data*
56
+
57
+ - name: Publish to Full Version NPM
58
+ run: |
59
+ npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
60
+ npm publish --access public
61
+ env:
62
+ NPM_TOKEN: ${{ github.event.inputs.npm_token }}
63
+
64
+ - name: Set up Docker Buildx
65
+ uses: docker/setup-buildx-action@v2
66
+
67
+ - name: Login to DockerHub
68
+ uses: docker/login-action@v2
69
+ with:
70
+ username: ${{ github.event.inputs.docker_user }}
71
+ password: ${{ github.event.inputs.docker_token }}
72
+
73
+ - name: Build and publish Full Version to Docker Hub
74
+ uses: docker/build-push-action@v3
75
+ with:
76
+ context: .
77
+ push: true
78
+ tags: maptiler/tileserver-gl:latest, maptiler/tileserver-gl:${{ env.PACKAGE_VERSION }}
79
+ platforms: linux/amd64
80
+
81
+ - name: Create Tileserver Light Directory
82
+ run: node publish.js --no-publish
83
+
84
+ - name: Install node dependencies
85
+ run: npm install
86
+ working-directory: ./light
87
+
88
+ - name: Publish to Light Version NPM
89
+ working-directory: ./light
90
+ run: |
91
+ npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
92
+ npm publish --access public
93
+ env:
94
+ NPM_TOKEN: ${{ github.event.inputs.npm_token }}
95
+
96
+ - name: Build and publish Light Version to Docker Hub
97
+ uses: docker/build-push-action@v3
98
+ with:
99
+ context: ./light
100
+ file: ./light/Dockerfile
101
+ push: true
102
+ tags: maptiler/tileserver-gl-light:latest, maptiler/tileserver-gl-light:${{ env.PACKAGE_VERSION }}
103
+ platforms: linux/amd64
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ NAME=$(git config user.name)
5
+ EMAIL=$(git config user.email)
6
+
7
+ if [ -z "$NAME" ]; then
8
+ echo "empty git config user.name"
9
+ exit 1
10
+ fi
11
+
12
+ if [ -z "$EMAIL" ]; then
13
+ echo "empty git config user.email"
14
+ exit 1
15
+ fi
16
+
17
+ git interpret-trailers --if-exists doNothing --trailer \
18
+ "Signed-off-by: $NAME <$EMAIL>" \
19
+ --in-place "$1"
20
+
21
+ npm exec --no -- commitlint --edit $1
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npm exec --no -- lint-staged --no-stash
package/Dockerfile CHANGED
@@ -20,7 +20,9 @@ RUN set -ex; \
20
20
  apt-get clean; \
21
21
  rm -rf /var/lib/apt/lists/*;
22
22
 
23
- EXPOSE 80
23
+ EXPOSE 8080
24
+
25
+ RUN mkdir -p /data && chown node:node /data
24
26
  VOLUME /data
25
27
  WORKDIR /data
26
28
  ENTRYPOINT ["/usr/src/app/docker-entrypoint.sh"]
@@ -30,3 +32,4 @@ COPY / /usr/src/app
30
32
  RUN cd /usr/src/app && npm install --omit=dev
31
33
  RUN ["chmod", "+x", "/usr/src/app/docker-entrypoint.sh"]
32
34
  USER node:node
35
+ HEALTHCHECK CMD node /usr/src/app/src/healthcheck.js
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ extends: ['@commitlint/config-conventional'],
3
+ };
@@ -20,7 +20,7 @@ trap refresh HUP
20
20
 
21
21
  if ! which -- "${1}"; then
22
22
  # first arg is not an executable
23
- node /usr/src/app/ -p 80 "$@" &
23
+ node /usr/src/app/ "$@" &
24
24
  # Wait exits immediately on signals which have traps set. Store return value and wait
25
25
  # again for all jobs to actually complete before continuing.
26
26
  wait $! || RETVAL=$?
@@ -7,7 +7,7 @@ Docker
7
7
 
8
8
  When running docker image, no special installation is needed -- the docker will automatically download the image if not present.
9
9
 
10
- Just run ``docker run --rm -it -v $(pwd):/data -p 8080:80 maptiler/tileserver-gl``.
10
+ Just run ``docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl``.
11
11
 
12
12
  Additional options (see :doc:`/usage`) can be passed to the TileServer GL by appending them to the end of this command. You can, for example, do the following:
13
13
 
package/docs/usage.rst CHANGED
@@ -36,3 +36,9 @@ It is possible to reload the configuration file without restarting the whole pro
36
36
 
37
37
  - The `docker kill -s HUP tileserver-gl` command can be used when running the tileserver-gl docker container.
38
38
  - The `docker-compose kill -s HUP tileserver-gl-service-name` can be used when tileserver-gl is run as a docker-compose service.
39
+
40
+ Docker and `--port`
41
+ ======
42
+
43
+ When running tileserver-gl in a Docker container, using the `--port` option would make the container incorrectly seem unhealthy.
44
+ Instead, it is advised to use Docker's port mapping and map the default port 8080 to the desired external port.
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ '*.{js,ts}': 'npm run lint:js',
3
+ '*.{yml}': 'npm run lint:yml',
4
+ };
package/package.json CHANGED
@@ -1,21 +1,20 @@
1
1
  {
2
2
  "name": "tileserver-gl-light",
3
- "version": "4.1.2",
3
+ "version": "4.2.1",
4
4
  "description": "Map tile server for JSON GL styles - serving vector tiles",
5
5
  "main": "src/main.js",
6
6
  "bin": "src/main.js",
7
7
  "type": "module",
8
- "repository": {
9
- "type": "git",
10
- "url": "git+https://github.com/maptiler/tileserver-gl.git"
11
- },
12
- "license": "BSD-2-Clause",
13
- "engines": {
14
- "node": ">= 14.15.0"
15
- },
16
8
  "scripts": {
17
9
  "test": "mocha test/**.js --timeout 10000",
18
- "docker": "docker build -f Dockerfile . && docker run --rm -i -p 8080:80 $(docker build -q .)"
10
+ "lint:yml": "yamllint --schema=CORE_SCHEMA *.{yml,yaml}",
11
+ "lint:js": "npm run lint:eslint && npm run lint:prettier",
12
+ "lint:js:fix": "npm run lint:eslint:fix && npm run lint:prettier:fix",
13
+ "lint:eslint": "eslint \"{,!(node_modules|dist|static|public)/**/}*.{js,ts,cjs,mjs}\" --ignore-path .gitignore",
14
+ "lint:eslint:fix": "eslint --fix \"{,!(node_modules|dist|static|public)/**/}*.{js,ts,cjs,mjs}\" --ignore-path .gitignore",
15
+ "lint:prettier": "prettier --check \"{,!(node_modules|dist|static|public)/**/}*.{js,ts,cjs,mjs,json}\" --ignore-path .gitignore",
16
+ "lint:prettier:fix": "prettier --write \"{,!(node_modules|dist|static|public)/**/}*.{js,ts,cjs,mjs,json}\" --ignore-path .gitignore",
17
+ "docker": "docker build -f Dockerfile . && docker run --rm -i -p 8080:8080 $(docker build -q .)"
19
18
  },
20
19
  "dependencies": {
21
20
  "@mapbox/glyph-pbf-composite": "0.0.3",
@@ -27,7 +26,7 @@
27
26
  "chokidar": "3.5.3",
28
27
  "clone": "2.1.2",
29
28
  "color": "4.2.3",
30
- "commander": "9.4.0",
29
+ "commander": "9.4.1",
31
30
  "cors": "2.8.5",
32
31
  "express": "4.18.1",
33
32
  "handlebars": "4.7.7",
@@ -38,5 +37,23 @@
38
37
  "request": "2.88.2",
39
38
  "tileserver-gl-styles": "2.0.0",
40
39
  "sanitize-filename": "1.6.3"
41
- }
40
+ },
41
+ "keywords": [
42
+ "maptiler",
43
+ "tileserver-gl",
44
+ "maplibre-gl",
45
+ "tileserver"
46
+ ],
47
+ "license": "BSD-2-Clause",
48
+ "engines": {
49
+ "node": ">= 14.15.0"
50
+ },
51
+ "repository": {
52
+ "url": "git+https://github.com/maptiler/tileserver-gl.git",
53
+ "type": "git"
54
+ },
55
+ "bugs": {
56
+ "url": "https://github.com/maptiler/tileserver-gl/issues"
57
+ },
58
+ "homepage": "https://github.com/maptiler/tileserver-gl#readme"
42
59
  }
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ $schema: 'http://json.schemastore.org/prettierrc',
3
+ semi: true,
4
+ arrowParens: 'always',
5
+ singleQuote: true,
6
+ trailingComma: 'all',
7
+ bracketSpacing: true,
8
+ htmlWhitespaceSensitivity: 'css',
9
+ insertPragma: false,
10
+ tabWidth: 2,
11
+ useTabs: false,
12
+ endOfLine: 'lf',
13
+ };
package/publish.js CHANGED
@@ -12,25 +12,33 @@
12
12
 
13
13
  // SYNC THE `light` FOLDER
14
14
 
15
- import child_process from 'child_process'
16
- child_process.execSync('rsync -av --exclude="light" --exclude=".git" --exclude="node_modules" --delete . light', {
17
- stdio: 'inherit'
18
- });
15
+ import child_process from 'child_process';
16
+ child_process.execSync(
17
+ 'rsync -av --exclude="light" --exclude=".git" --exclude="node_modules" --delete . light',
18
+ {
19
+ stdio: 'inherit',
20
+ },
21
+ );
19
22
 
20
23
  // PATCH `package.json`
21
24
  import fs from 'fs';
22
25
  import path from 'path';
23
- import {fileURLToPath} from 'url';
26
+ import { fileURLToPath } from 'url';
24
27
  const __filename = fileURLToPath(import.meta.url);
25
28
  const __dirname = path.dirname(__filename);
26
- const packageJson = JSON.parse(fs.readFileSync(__dirname + '/package.json', 'utf8'))
29
+ const packageJson = JSON.parse(
30
+ fs.readFileSync(__dirname + '/package.json', 'utf8'),
31
+ );
27
32
 
28
33
  packageJson.name += '-light';
29
- packageJson.description = 'Map tile server for JSON GL styles - serving vector tiles';
34
+ packageJson.description =
35
+ 'Map tile server for JSON GL styles - serving vector tiles';
30
36
  delete packageJson.dependencies['canvas'];
31
37
  delete packageJson.dependencies['@maplibre/maplibre-gl-native'];
32
38
  delete packageJson.dependencies['sharp'];
33
39
 
40
+ delete packageJson.scripts['prepare'];
41
+
34
42
  delete packageJson.optionalDependencies;
35
43
  delete packageJson.devDependencies;
36
44
 
@@ -51,10 +59,10 @@ if (process.argv.length > 2 && process.argv[2] == '--no-publish') {
51
59
 
52
60
  // tileserver-gl
53
61
  child_process.execSync('npm publish . --access public', {
54
- stdio: 'inherit'
62
+ stdio: 'inherit',
55
63
  });
56
64
 
57
65
  // tileserver-gl-light
58
66
  child_process.execSync('npm publish ./light --access public', {
59
- stdio: 'inherit'
67
+ stdio: 'inherit',
60
68
  });
package/run.sh CHANGED
@@ -29,7 +29,7 @@ export DISPLAY=:${displayNumber}.${screenNumber}
29
29
 
30
30
  echo
31
31
  cd /data
32
- node /usr/src/app/ -p 80 "$@" &
32
+ node /usr/src/app/ "$@" &
33
33
  child=$!
34
34
  wait "$child"
35
35
 
@@ -0,0 +1,18 @@
1
+ import * as http from 'http';
2
+ var options = {
3
+ timeout: 2000,
4
+ };
5
+ var url = 'http://localhost:8080/health';
6
+ var request = http.request(url, options, (res) => {
7
+ console.log(`STATUS: ${res.statusCode}`);
8
+ if (res.statusCode == 200) {
9
+ process.exit(0);
10
+ } else {
11
+ process.exit(1);
12
+ }
13
+ });
14
+ request.on('error', function (err) {
15
+ console.log('ERROR');
16
+ process.exit(1);
17
+ });
18
+ request.end();