forked from maptiler/tileserver-gl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.js
68 lines (53 loc) · 1.81 KB
/
publish.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/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
import child_process from 'child_process';
child_process.execSync(
'rsync -av --exclude="light" --exclude=".git" --exclude="node_modules" --delete . light',
{
stdio: 'inherit',
},
);
// PATCH `package.json`
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const packageJson = JSON.parse(
fs.readFileSync(__dirname + '/package.json', 'utf8'),
);
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.scripts['prepare'];
delete packageJson.optionalDependencies;
delete packageJson.devDependencies;
packageJson.engines.node = '>= 14.15.0';
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
child_process.execSync('npm publish . --access public', {
stdio: 'inherit',
});
// tileserver-gl-light
child_process.execSync('npm publish ./light --access public', {
stdio: 'inherit',
});