tileserver-gl/publish.js
Andrew Calcutt b2bd5eaa96
Convert to esm module syntax (#606)
* switch to esm module

* Update package.json

* change to maplibre package

* fix tests

* eslint

* remove extra package updates

* Delete package-lock.json

* change 'fs' to 'node:fs'

* put back node 10.

without the package updates this still works

* remove trailing commas

* remove unassociated fix / formatting

* remove unassociated fix

* remove eslint from this PR

* remove unassociated fix

* lint

* Merge remote-tracking branch 'upstream/master' into esm_update

* fix mlgl

* update maplibre-native to new version with arm64

* update minor version
2022-09-28 14:41:55 -04:00

55 lines
1.5 KiB
JavaScript

#!/usr/bin/env node
'use strict';
/*
* This script creates `tileserver-gl-light` version
* (without native dependencies) and publishes
* `tileserver-gl` and `tileserver-gl-light` to npm.
*/
/* CREATE tileserver-gl-light */
// SYNC THE `light` FOLDER
require('child_process').execSync('rsync -av --exclude="light" --exclude=".git" --exclude="node_modules" --delete . light', {
stdio: 'inherit'
});
// PATCH `package.json`
const fs = require('fs');
const packageJson = require('./package');
packageJson.name += '-light';
packageJson.description = 'Map tile server for JSON GL styles - serving vector tiles';
delete packageJson.dependencies['canvas'];
delete packageJson.dependencies['@maplibre/maplibre-gl-native'];
delete packageJson.dependencies['sharp'];
delete packageJson.optionalDependencies;
delete packageJson.devDependencies;
packageJson.engines.node = '>= 10';
const str = JSON.stringify(packageJson, undefined, 2);
fs.writeFileSync('light/package.json', str);
fs.renameSync('light/README_light.md', 'light/README.md');
fs.renameSync('light/Dockerfile_light', 'light/Dockerfile');
fs.renameSync('light/docker-entrypoint_light.sh', 'light/docker-entrypoint.sh');
// for Build tileserver-gl-light docker image, don't publish
if (process.argv.length > 2 && process.argv[2] == '--no-publish') {
process.exit(0);
}
/* PUBLISH */
// tileserver-gl
require('child_process').execSync('npm publish .', {
stdio: 'inherit'
});
// tileserver-gl-light
require('child_process').execSync('npm publish light', {
stdio: 'inherit'
});