@unvt/charites 0.1.1 → 0.1.4
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/.all-contributorsrc +24 -0
- package/.eslintignore +2 -0
- package/.eslintrc.js +17 -0
- package/.github/CONTRIBUTING.md +30 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +25 -0
- package/.github/workflows/build-docs.yml +72 -0
- package/.github/workflows/build.yml +1 -0
- package/.prettierrc.js +6 -0
- package/LICENSE +1 -1
- package/README.md +23 -106
- package/dist/cli/build.js +63 -0
- package/dist/cli/convert.js +19 -0
- package/dist/cli/init.js +26 -0
- package/dist/cli/serve.js +34 -0
- package/dist/cli.js +10 -66
- package/dist/commands/build.js +39 -3
- package/dist/commands/convert.js +6 -23
- package/dist/commands/init.js +15 -22
- package/dist/commands/serve.js +8 -3
- package/dist/lib/build-sprite.js +71 -0
- package/dist/lib/defaultValues.js +3 -3
- package/dist/lib/error.js +9 -0
- package/dist/lib/get-sprite-slug.js +16 -0
- package/dist/lib/tileinfo-importer/base-importer.js +41 -0
- package/dist/lib/tileinfo-importer/index.js +6 -0
- package/dist/lib/tileinfo-importer/metadata-importer.js +38 -0
- package/dist/lib/tileinfo-importer/tilejson-importer.js +25 -0
- package/dist/lib/validate-style.js +2 -2
- package/dist/lib/yaml-parser.js +2 -2
- package/dist/lib/yaml-writer.js +48 -0
- package/dist/types/index.js +15 -0
- package/dist/types/metadatajson.js +2 -0
- package/dist/types/tilejson.js +2 -0
- package/dist/types/vector_layers.js +2 -0
- package/docs/.tx/config +62 -0
- package/docs/Makefile +170 -0
- package/docs/Pipfile +20 -0
- package/docs/Pipfile.lock +429 -0
- package/docs/README.md +43 -0
- package/docs/make.bat +35 -0
- package/docs/source/_static/.gitkeep +0 -0
- package/docs/source/_templates/.gitkeep +0 -0
- package/docs/source/conf.py +69 -0
- package/docs/source/development/index.rst +40 -0
- package/docs/source/index.rst +61 -0
- package/docs/source/install/index.rst +10 -0
- package/docs/source/install/install.rst +7 -0
- package/docs/source/install/install_on_nanban.rst +9 -0
- package/docs/source/install/recommended_environment.rst +6 -0
- package/docs/source/usage/commandline_interface.rst +102 -0
- package/docs/source/usage/examples.rst +74 -0
- package/docs/source/usage/global_options.rst +21 -0
- package/docs/source/usage/index.rst +10 -0
- package/package.json +12 -4
- package/provider/default/app.css +10 -0
- package/provider/default/app.js +31 -5
- package/provider/default/index.html +7 -0
- package/provider/geolonia/app.css +10 -0
- package/provider/geolonia/app.js +29 -5
- package/provider/geolonia/index.html +7 -0
- package/provider/mapbox/app.css +10 -0
- package/provider/mapbox/app.js +31 -5
- package/provider/mapbox/index.html +7 -0
- package/src/cli/build.ts +77 -0
- package/src/cli/convert.ts +18 -0
- package/src/cli/init.ts +34 -0
- package/src/cli/serve.ts +39 -0
- package/src/cli.ts +12 -76
- package/src/commands/build.ts +71 -9
- package/src/commands/convert.ts +16 -35
- package/src/commands/init.ts +28 -21
- package/src/commands/serve.ts +70 -57
- package/src/lib/build-sprite.ts +80 -0
- package/src/lib/defaultValues.ts +6 -6
- package/src/lib/error.ts +6 -0
- package/src/lib/get-sprite-slug.ts +18 -0
- package/src/lib/tileinfo-importer/base-importer.ts +57 -0
- package/src/lib/tileinfo-importer/index.ts +2 -0
- package/src/lib/tileinfo-importer/metadata-importer.ts +44 -0
- package/src/lib/tileinfo-importer/tilejson-importer.ts +29 -0
- package/src/lib/validate-style.ts +8 -2
- package/src/lib/yaml-parser.ts +9 -8
- package/src/lib/yaml-writer.ts +68 -0
- package/src/types/index.ts +3 -0
- package/src/types/metadatajson.ts +16 -0
- package/src/types/tilejson.ts +25 -0
- package/src/types/vector_layers.ts +11 -0
- package/test/build-sprite.spec.ts +24 -0
- package/test/build.spec.ts +121 -16
- package/test/convert.spec.ts +7 -7
- package/test/data/icons/aerialway.svg +4 -0
- package/test/data/init/init.yml +6 -0
- package/test/data/init/init_metadata.yml +60 -0
- package/test/data/init/init_tilejson.yml +28 -0
- package/test/data/init/init_tilejson_without_layers.yml +9 -0
- package/test/data/init/tilejson/init_decomposite.yml +13 -0
- package/test/data/init/tilejson/layers/bicycle_parking.yml +6 -0
- package/test/data/init/tilejson/layers/showers.yml +6 -0
- package/test/data/init/tilejson/layers/telephone.yml +6 -0
- package/test/get-sprite-slug.spec.ts +34 -0
- package/test/init.spec.ts +151 -0
- package/test/validate-style.spec.ts +7 -5
- package/test/yaml-parser.spec.ts +15 -15
- package/tsconfig.json +3 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files": [
|
|
3
|
+
"README.md"
|
|
4
|
+
],
|
|
5
|
+
"imageSize": 100,
|
|
6
|
+
"commit": false,
|
|
7
|
+
"contributors": [
|
|
8
|
+
{
|
|
9
|
+
"login": "geolonia",
|
|
10
|
+
"name": "Geolonia",
|
|
11
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/42296593?v=4",
|
|
12
|
+
"profile": "https://geolonia.com/",
|
|
13
|
+
"contributions": [
|
|
14
|
+
"code"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"contributorsPerLine": 7,
|
|
19
|
+
"projectName": "charites",
|
|
20
|
+
"projectOwner": "unvt",
|
|
21
|
+
"repoType": "github",
|
|
22
|
+
"repoHost": "https://github.com",
|
|
23
|
+
"skipCi": true
|
|
24
|
+
}
|
package/.eslintignore
ADDED
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
parser: '@typescript-eslint/parser',
|
|
3
|
+
parserOptions: {
|
|
4
|
+
ecmaVersion: 2020,
|
|
5
|
+
sourceType: 'module',
|
|
6
|
+
},
|
|
7
|
+
extends: [
|
|
8
|
+
'plugin:@typescript-eslint/recommended',
|
|
9
|
+
'prettier/@typescript-eslint',
|
|
10
|
+
'plugin:prettier/recommended',
|
|
11
|
+
],
|
|
12
|
+
rules: {
|
|
13
|
+
'@typescript-eslint/explicit-module-boundary-types': 0,
|
|
14
|
+
'@typescript-eslint/ban-ts-comment': 0,
|
|
15
|
+
'@typescript-eslint/no-var-requires': 0,
|
|
16
|
+
},
|
|
17
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Submit a new issue only if you are sure it is a missing feature or a bug.
|
|
2
|
+
|
|
3
|
+
## A quick guide for pull request
|
|
4
|
+
|
|
5
|
+
1. [Fork the repo](https://help.github.com/articles/fork-a-repo) and create a branch for your new feature or bug fix.
|
|
6
|
+
|
|
7
|
+
2. Make sure build pass. Run: `npm run build`
|
|
8
|
+
|
|
9
|
+
3. Make sure no lint error. Run: `npm run lint`
|
|
10
|
+
|
|
11
|
+
4. Run unit tests to ensure all features work well. Run: `npm test`
|
|
12
|
+
|
|
13
|
+
5. Make sure `charites` command work well after installing globally. Run:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm uninstall -g .
|
|
17
|
+
npm uninstall @unvt/charites
|
|
18
|
+
npm install -g
|
|
19
|
+
charites help
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
6. Make sure you submit a change specific to exactly one issue. If you have ideas for multiple changes please create separate pull requests.
|
|
23
|
+
|
|
24
|
+
7. Make sure update documentation under `docs` folder if your changes affect existing documents.
|
|
25
|
+
|
|
26
|
+
8. Push to your fork and [submit a pull request](https://help.github.com/articles/using-pull-requests). A button should appear on your fork its github page afterwards.
|
|
27
|
+
|
|
28
|
+
## Translation of charites documentation
|
|
29
|
+
|
|
30
|
+
Please join our charites-docs project in transifex from [here](https://www.transifex.com/unvt/charites-docs). Welcome to translate documentations in other languages.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Create a report to help us improve
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Describe the bug**
|
|
11
|
+
A clear and concise description of what the bug is.
|
|
12
|
+
|
|
13
|
+
**To Reproduce**
|
|
14
|
+
Steps to reproduce the behavior:
|
|
15
|
+
|
|
16
|
+
1. Go to '...'
|
|
17
|
+
2. Click on '....'
|
|
18
|
+
3. Scroll down to '....'
|
|
19
|
+
4. See error
|
|
20
|
+
|
|
21
|
+
**Expected behavior**
|
|
22
|
+
A clear and concise description of what you expected to happen.
|
|
23
|
+
|
|
24
|
+
**Screenshots**
|
|
25
|
+
If applicable, add screenshots to help explain your problem.
|
|
26
|
+
|
|
27
|
+
**Charites Version:**
|
|
28
|
+
|
|
29
|
+
- Charites version: 0.X.X
|
|
30
|
+
|
|
31
|
+
**Desktop (please complete the following information):**
|
|
32
|
+
|
|
33
|
+
- OS: [e.g. Windows]
|
|
34
|
+
- Browser [e.g. chrome, safari]
|
|
35
|
+
- Version [e.g. 22]
|
|
36
|
+
|
|
37
|
+
**Additional context**
|
|
38
|
+
Add any other context about the problem here.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest an idea for this project
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Is your feature request related to a problem? Please describe.**
|
|
11
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
12
|
+
|
|
13
|
+
**Describe the solution you'd like**
|
|
14
|
+
A clear and concise description of what you want to happen.
|
|
15
|
+
|
|
16
|
+
**Describe alternatives you've considered**
|
|
17
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
|
18
|
+
|
|
19
|
+
**Additional context**
|
|
20
|
+
Add any other context or screenshots about the feature request here.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Thank you for submitting a pull request!
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
Please describe what you changed briefly.
|
|
6
|
+
|
|
7
|
+
## Type of Pull Request
|
|
8
|
+
<!-- ignore-task-list-start -->
|
|
9
|
+
- [ ] Adding a feature
|
|
10
|
+
- [ ] Fixing a bug
|
|
11
|
+
- [ ] Maintaining documents
|
|
12
|
+
- [ ] Others ()
|
|
13
|
+
<!-- ignore-task-list-end -->
|
|
14
|
+
|
|
15
|
+
## Verify the followings
|
|
16
|
+
<!-- ignore-task-list-start -->
|
|
17
|
+
- [ ] Code is up-to-date with the `main` branch
|
|
18
|
+
- [ ] No build errors after `npm run build`
|
|
19
|
+
- [ ] No lint errors after `npm run lint`
|
|
20
|
+
- [ ] No errors on using `charites help` globally
|
|
21
|
+
- [ ] Make sure all the exsiting features working well
|
|
22
|
+
- [ ] Have you updated documentation?
|
|
23
|
+
<!-- ignore-task-list-end -->
|
|
24
|
+
|
|
25
|
+
Refer to [CONTRIBUTING.MD](https://github.com/unvt/charites/tree/master/.github/CONTRIBUTING.md) for more details.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
name: Build and Deploy docs
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
paths:
|
|
8
|
+
- "docs/**"
|
|
9
|
+
pull_request:
|
|
10
|
+
branches:
|
|
11
|
+
- '**'
|
|
12
|
+
workflow_dispatch: {}
|
|
13
|
+
schedule:
|
|
14
|
+
- cron: "0 0 * * *"
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
build:
|
|
18
|
+
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
env:
|
|
21
|
+
TX_TOKEN: ${{ secrets.TX_TOKEN }}
|
|
22
|
+
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v1
|
|
25
|
+
- name: Set up Python 3.9
|
|
26
|
+
uses: actions/setup-python@v1
|
|
27
|
+
with:
|
|
28
|
+
python-version: 3.9
|
|
29
|
+
|
|
30
|
+
- name: Install dependencies
|
|
31
|
+
run: |
|
|
32
|
+
sudo apt-get install -y transifex-client gettext
|
|
33
|
+
python -m pip install --upgrade pip
|
|
34
|
+
cd docs
|
|
35
|
+
pip install pipenv
|
|
36
|
+
pipenv install --system
|
|
37
|
+
|
|
38
|
+
- name: Push translations
|
|
39
|
+
if: ${{ github.ref == 'refs/heads/main' }}
|
|
40
|
+
run: |
|
|
41
|
+
cd docs
|
|
42
|
+
set -e
|
|
43
|
+
make gettext
|
|
44
|
+
if [[ -z "${TX_TOKEN}" ]]; then
|
|
45
|
+
echo "TX_TOKEN not set, skip tx pull"
|
|
46
|
+
else
|
|
47
|
+
tx push -s
|
|
48
|
+
fi
|
|
49
|
+
make clean
|
|
50
|
+
|
|
51
|
+
- name: Pull translations
|
|
52
|
+
run: |
|
|
53
|
+
cd docs
|
|
54
|
+
set -e
|
|
55
|
+
if [[ -z "${TX_TOKEN}" ]]; then
|
|
56
|
+
echo "TX_TOKEN not set, skip tx pull"
|
|
57
|
+
else
|
|
58
|
+
make transifex_pull
|
|
59
|
+
fi
|
|
60
|
+
|
|
61
|
+
- name: Build
|
|
62
|
+
run: |
|
|
63
|
+
cd docs
|
|
64
|
+
make html
|
|
65
|
+
touch ./build/html/.nojekyll
|
|
66
|
+
|
|
67
|
+
- name: Deploy 🚀
|
|
68
|
+
uses: JamesIves/github-pages-deploy-action@4.1.7
|
|
69
|
+
if: ${{ github.ref == 'refs/heads/main' }}
|
|
70
|
+
with:
|
|
71
|
+
branch: gh-pages # The branch the action should deploy to.
|
|
72
|
+
folder: docs/build/html # The folder the action should deploy.
|
package/.prettierrc.js
ADDED
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2021
|
|
3
|
+
Copyright (c) 2021 The United Nations Vector Tile Toolkit
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
# Charites
|
|
2
|
+
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
3
|
+
[](#contributors-)
|
|
4
|
+
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
2
5
|
|
|
3
6
|
An easy, intuitive, and efficient command-line tool for writing vector map styles compatible with the [Mapbox](https://docs.mapbox.com/mapbox-gl-js/style-spec/) and [MapLibre](https://maplibre.org/maplibre-gl-js-docs/style-spec/) Style Specification in YAML.
|
|
4
7
|
With YAML format's readability, JSON compiler, linter, and live style viewer on a local browser, you can simplify your map styling workflow.
|
|
@@ -15,123 +18,37 @@ In Greek mythology, the [Charites](https://en.wikipedia.org/wiki/Charites) are t
|
|
|
15
18
|
- Use `--provider mapbox` to validate your style against Mapbox GL JS v2.x
|
|
16
19
|
- Run `charites serve <source>` to preview your style live while you make changes in a browser.
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
## Documentation
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
Documentation is available [here](https://unvt.github.io/charites/).
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
$ npm install -g @unvt/charites
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Then try:
|
|
27
|
-
|
|
28
|
-
```
|
|
29
|
-
$ charites help
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Usage
|
|
33
|
-
|
|
34
|
-
```
|
|
35
|
-
$ charites help
|
|
36
|
-
Usage: charites [options] [command]
|
|
37
|
-
|
|
38
|
-
Options:
|
|
39
|
-
--provider [provider] your map service. e.g. `mapbox`, `geolonia`
|
|
40
|
-
--mapbox-access-token [mapboxAccessToken] Access Token for the Mapbox
|
|
41
|
-
-h, --help display help for command
|
|
42
|
-
|
|
43
|
-
Commands:
|
|
44
|
-
init <file> initialize a style JSON
|
|
45
|
-
convert <source> [destination] convert the style JSON to YAML
|
|
46
|
-
build [options] <source> [destination] build a style JSON from the YAML
|
|
47
|
-
serve <source> serve your map locally
|
|
48
|
-
help [command] display help for command
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Global Options
|
|
52
|
-
|
|
53
|
-
Charites has two global options that are common to all commands.
|
|
54
|
-
|
|
55
|
-
- `--provider` - `mapbox`, `geolonia`, or `default`. When not specified, default or the value in the configuration file will be used.
|
|
56
|
-
- `mapbox` - The format linter runs against the Mapbox GL JS v2.x compatible specification.
|
|
57
|
-
- `geolonia` and `default` - the format linter runs against the MapLibre GL JS compatible specification.
|
|
58
|
-
- `--mapbox-access-token` - Set your access-token when styling for Mapbox.
|
|
59
|
-
|
|
60
|
-
# Configuration
|
|
61
|
-
|
|
62
|
-
The global options for Charites can be stored in a configuration file written in YAML.
|
|
63
|
-
|
|
64
|
-
The config file will be automatically created to the following path the first time the charites command is executed.
|
|
65
|
-
|
|
66
|
-
```
|
|
67
|
-
~/.charites/config.yml
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Global options can be specified as follows:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
```
|
|
74
|
-
provider: mapbox
|
|
75
|
-
mapboxAccessToken: xxxx
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
With the example above, you get the same result as `charites --provider mapbox --mapbox-access-token xxxx`.
|
|
79
|
-
|
|
80
|
-
## Examples
|
|
81
|
-
|
|
82
|
-
Build `style.json` from `style.yml`:
|
|
83
|
-
|
|
84
|
-
```
|
|
85
|
-
charites build style.yml style.json
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
Add `-c` or `--compact-output` to minify the JSON
|
|
89
|
-
|
|
90
|
-
```
|
|
91
|
-
charites build style.yml style.json -c
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
Convert `style.json` to `style.yml`:
|
|
25
|
+
## Contributing
|
|
95
26
|
|
|
96
|
-
|
|
97
|
-
charites convert style.json style.yml
|
|
98
|
-
```
|
|
27
|
+
see [CONTRIBUTING.md](./.github/CONTRIBUTING.md)
|
|
99
28
|
|
|
100
|
-
|
|
29
|
+
## License
|
|
101
30
|
|
|
102
|
-
|
|
103
|
-
curl http://example.com/style.json | charites convert - style.yml
|
|
104
|
-
```
|
|
31
|
+
MIT
|
|
105
32
|
|
|
106
|
-
|
|
33
|
+
## Contributors ✨
|
|
107
34
|
|
|
108
|
-
|
|
109
|
-
charites serve style.yml
|
|
110
|
-
```
|
|
35
|
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
111
36
|
|
|
112
|
-
|
|
37
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
38
|
+
<!-- prettier-ignore-start -->
|
|
39
|
+
<!-- markdownlint-disable -->
|
|
113
40
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
41
|
+
<table>
|
|
42
|
+
<tr>
|
|
43
|
+
<td align="center"><a href="https://geolonia.com/"><img src="https://avatars.githubusercontent.com/u/42296593?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Geolonia</b></sub></a><br /><a href="https://github.com/unvt/charites/commits?author=geolonia" title="Code">💻</a></td>
|
|
44
|
+
</tr>
|
|
45
|
+
</table>
|
|
117
46
|
|
|
118
|
-
## Contributing
|
|
119
47
|
|
|
120
|
-
|
|
48
|
+
<!-- markdownlint-restore -->
|
|
49
|
+
<!-- prettier-ignore-end -->
|
|
121
50
|
|
|
122
|
-
|
|
123
|
-
$ git clone https://github.com/geolonia/charites.git
|
|
124
|
-
$ cd charites
|
|
125
|
-
$ npm install
|
|
126
|
-
$ npm run build
|
|
127
|
-
$ npm install -g .
|
|
128
|
-
```
|
|
129
|
-
Then run:
|
|
51
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
130
52
|
|
|
131
|
-
```
|
|
132
|
-
$ charites help
|
|
133
|
-
```
|
|
134
53
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
MIT
|
|
54
|
+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const commander_1 = require("commander");
|
|
7
|
+
const build_1 = require("../commands/build");
|
|
8
|
+
const error_1 = require("../lib/error");
|
|
9
|
+
const defaultValues_1 = require("../lib/defaultValues");
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const program = new commander_1.Command();
|
|
13
|
+
program
|
|
14
|
+
.name('build')
|
|
15
|
+
.arguments('<source> [destination]')
|
|
16
|
+
.description('build a style JSON from the YAML')
|
|
17
|
+
.option('-c, --compact-output', 'build a minified style JSON')
|
|
18
|
+
.option('-w, --watch', 'watch YAML and build when changed')
|
|
19
|
+
.option('-u, --sprite-url [<sprite url>]', 'url to set as the sprite in style.json')
|
|
20
|
+
.option('-i, --sprite-input [<icon input directory>]', 'directory path of icon source to build icons. The default <icon source> is `icons/`')
|
|
21
|
+
.option('-o, --sprite-output [<icon output directory>]', 'directory path to output icon files. The default <icons destination> is the current directory')
|
|
22
|
+
.option('--provider [provider]', 'your map service. e.g. `mapbox`, `geolonia`')
|
|
23
|
+
.action(async (source, destination, buildOptions) => {
|
|
24
|
+
const options = program.opts();
|
|
25
|
+
options.provider = buildOptions.provider;
|
|
26
|
+
options.compactOutput = buildOptions.compactOutput;
|
|
27
|
+
options.spriteUrl = buildOptions.spriteUrl;
|
|
28
|
+
options.spriteOutput = buildOptions.spriteOutput || process.cwd();
|
|
29
|
+
const spriteInputDefault = path_1.default.resolve(process.cwd(), 'icons');
|
|
30
|
+
if (buildOptions.spriteInput) {
|
|
31
|
+
options.spriteInput = buildOptions.spriteInput;
|
|
32
|
+
}
|
|
33
|
+
else if (fs_1.default.existsSync(spriteInputDefault)) {
|
|
34
|
+
options.spriteInput = spriteInputDefault;
|
|
35
|
+
}
|
|
36
|
+
if (!fs_1.default.existsSync(defaultValues_1.defaultSettings.configFile)) {
|
|
37
|
+
fs_1.default.writeFileSync(defaultValues_1.defaultSettings.configFile, `provider: ${options.provider || 'default'}`);
|
|
38
|
+
}
|
|
39
|
+
if (buildOptions.watch) {
|
|
40
|
+
try {
|
|
41
|
+
console.log('Start watching...');
|
|
42
|
+
await new Promise((resolve) => {
|
|
43
|
+
const watcher = build_1.buildWatch(source, destination, options);
|
|
44
|
+
process.on('SIGINT', () => {
|
|
45
|
+
watcher.close();
|
|
46
|
+
resolve(undefined);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
error_1.error(e);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
try {
|
|
56
|
+
await build_1.build(source, destination, options);
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
error_1.error(e);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
exports.default = program;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const commander_1 = require("commander");
|
|
4
|
+
const convert_1 = require("../commands/convert");
|
|
5
|
+
const error_1 = require("../lib/error");
|
|
6
|
+
const program = new commander_1.Command();
|
|
7
|
+
program
|
|
8
|
+
.name('convert')
|
|
9
|
+
.arguments('<source> [destination]')
|
|
10
|
+
.description('convert the style JSON to YAML')
|
|
11
|
+
.action((source, destination) => {
|
|
12
|
+
try {
|
|
13
|
+
convert_1.convert(source, destination);
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
error_1.error(e);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
exports.default = program;
|
package/dist/cli/init.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const commander_1 = require("commander");
|
|
4
|
+
const init_1 = require("../commands/init");
|
|
5
|
+
const error_1 = require("../lib/error");
|
|
6
|
+
const program = new commander_1.Command();
|
|
7
|
+
program
|
|
8
|
+
.name('init')
|
|
9
|
+
.arguments('<file>')
|
|
10
|
+
.description('initialize a style JSON')
|
|
11
|
+
.option('-t, --tilejson-urls <tilejson_urls>', 'an URL for TileJSON. It will create empty layers from vector_layers property of TileJSON. Please use comma (,) in case multiple TileJSONs require.')
|
|
12
|
+
.option('-m, --metadatajson-urls <metadatajson_urls>', 'an URL for metadata.json. It will create empty layers from vector_layers property of metadata.json. Please use comma (,) in case multiple metadata.json require.')
|
|
13
|
+
.option('-c, --composite-layers', 'If it is true, a single YAML will be generated with multiple layers. Default is false.')
|
|
14
|
+
.action(async (file, initOptions) => {
|
|
15
|
+
const options = program.opts();
|
|
16
|
+
options.tilejsonUrls = initOptions.tilejsonUrls;
|
|
17
|
+
options.metadatajsonUrls = initOptions.metadatajsonUrls;
|
|
18
|
+
options.compositeLayers = initOptions.compositeLayers;
|
|
19
|
+
try {
|
|
20
|
+
await init_1.init(file, options);
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
error_1.error(e);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
exports.default = program;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const commander_1 = require("commander");
|
|
7
|
+
const serve_1 = require("../commands/serve");
|
|
8
|
+
const error_1 = require("../lib/error");
|
|
9
|
+
const defaultValues_1 = require("../lib/defaultValues");
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const program = new commander_1.Command();
|
|
12
|
+
program
|
|
13
|
+
.name('serve')
|
|
14
|
+
.arguments('<source>')
|
|
15
|
+
.description('serve your map locally')
|
|
16
|
+
.option('--provider [provider]', 'your map service. e.g. `mapbox`, `geolonia`')
|
|
17
|
+
.option('--mapbox-access-token [mapboxAccessToken]', 'Access Token for the Mapbox')
|
|
18
|
+
.option('--port [port]', 'Specify custom port')
|
|
19
|
+
.action((source, serveOptions) => {
|
|
20
|
+
const options = program.opts();
|
|
21
|
+
options.provider = serveOptions.provider;
|
|
22
|
+
options.mapboxAccessToken = serveOptions.mapboxAccessToken;
|
|
23
|
+
options.port = serveOptions.port;
|
|
24
|
+
if (!fs_1.default.existsSync(defaultValues_1.defaultSettings.configFile)) {
|
|
25
|
+
fs_1.default.writeFileSync(defaultValues_1.defaultSettings.configFile, `provider: ${options.provider || 'default'}`);
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
serve_1.serve(source, program.opts());
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
error_1.error(e);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
exports.default = program;
|
package/dist/cli.js
CHANGED
|
@@ -5,72 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
const commander_1 = require("commander");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const serve_1 = require("./commands/serve");
|
|
13
|
-
const defaultValues_1 = require("./lib/defaultValues");
|
|
8
|
+
const init_1 = __importDefault(require("./cli/init"));
|
|
9
|
+
const convert_1 = __importDefault(require("./cli/convert"));
|
|
10
|
+
const build_1 = __importDefault(require("./cli/build"));
|
|
11
|
+
const serve_1 = __importDefault(require("./cli/serve"));
|
|
14
12
|
const program = new commander_1.Command();
|
|
15
|
-
const
|
|
16
|
-
console.error(message.toString());
|
|
17
|
-
process.exit(1);
|
|
18
|
-
};
|
|
19
|
-
program
|
|
20
|
-
.option('--provider [provider]', 'your map service. e.g. `mapbox`, `geolonia`')
|
|
21
|
-
.option('--mapbox-access-token [mapboxAccessToken]', 'Access Token for the Mapbox');
|
|
22
|
-
program
|
|
23
|
-
.command('init <file>')
|
|
24
|
-
.description('initialize a style JSON')
|
|
25
|
-
.action((file) => {
|
|
26
|
-
try {
|
|
27
|
-
init_1.init(file);
|
|
28
|
-
}
|
|
29
|
-
catch (e) {
|
|
30
|
-
error(e);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
program
|
|
34
|
-
.command('convert <source> [destination]')
|
|
35
|
-
.description('convert the style JSON to YAML')
|
|
36
|
-
.action((source, destination) => {
|
|
37
|
-
try {
|
|
38
|
-
convert_1.convert(source, destination);
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
error(e);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
program
|
|
45
|
-
.command('build <source> [destination]')
|
|
46
|
-
.description('build a style JSON from the YAML')
|
|
47
|
-
.option('-c, --compact-output', 'build a minified style JSON')
|
|
48
|
-
.action((source, destination, buildOptions) => {
|
|
49
|
-
const options = program.opts();
|
|
50
|
-
options.compactOutput = buildOptions.compactOutput;
|
|
51
|
-
if (!fs_1.default.existsSync(defaultValues_1.defaultSettings.configFile)) {
|
|
52
|
-
fs_1.default.writeFileSync(defaultValues_1.defaultSettings.configFile, `provider: ${options.provider || 'default'}`);
|
|
53
|
-
}
|
|
54
|
-
try {
|
|
55
|
-
build_1.build(source, destination, options);
|
|
56
|
-
}
|
|
57
|
-
catch (e) {
|
|
58
|
-
error(e);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
13
|
+
const version = require('../package.json').version;
|
|
61
14
|
program
|
|
62
|
-
.
|
|
63
|
-
.
|
|
64
|
-
.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
fs_1.default.writeFileSync(defaultValues_1.defaultSettings.configFile, `provider: ${options.provider || 'default'}`);
|
|
68
|
-
}
|
|
69
|
-
try {
|
|
70
|
-
serve_1.serve(source, program.opts());
|
|
71
|
-
}
|
|
72
|
-
catch (e) {
|
|
73
|
-
error(e);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
15
|
+
.version(version, '-v, --version', 'output the version number')
|
|
16
|
+
.addCommand(init_1.default)
|
|
17
|
+
.addCommand(convert_1.default)
|
|
18
|
+
.addCommand(build_1.default)
|
|
19
|
+
.addCommand(serve_1.default);
|
|
76
20
|
program.parse(process.argv);
|