Skip to content

Commit

Permalink
Merge pull request #30 from UNDP-Data/chore/switch-spritezero-to-spri…
Browse files Browse the repository at this point in the history
…te-one

chore: switched elastic/spritezero to unvt/sprite-one to generate sprite files. Migrate scripts in package.json to Makefile
  • Loading branch information
iferencik authored Dec 26, 2023
2 parents 0328949 + 2f9dac8 commit ac7f7fd
Show file tree
Hide file tree
Showing 11 changed files with 761 additions and 1,720 deletions.
5 changes: 5 additions & 0 deletions .changeset/rude-buttons-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@undp-data/style": minor
---

chore: switched elastic/spritezero to unvt/sprite-one to generate sprite files. Migrate scripts in package.json to Makefile
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ jobs:
run: pnpm install --frozen-lockfile

- name: build style
run: pnpm build
run: make build
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

- name: build style
run: |
pnpm build
make build
mv docs/ dist/
- name: Create Release Pull Request or Publish to npm
Expand Down
71 changes: 71 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
nonSdfFolder = "docs/sprite-non-sdf"
sdfFolder = "docs/sprite"
iconFolder = "assets/maki-icons"

.PHONY: help clean clean style build-voyager build-aerial sprite voyager aerial

help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " build to build styles and sprites"
@echo " clean to clean build folder"
@echo " style to build style files"
@echo " build-voyager to build only voyager style"
@echo " build-aerial to build only aerial style"
@echo " sprite to build only sprite"
@echo " voyager to develop voyager style YAML"
@echo " aerial to develop aerial style YAML"

build: clean style sprite

clean:
@echo
@echo "------------------------------------------------------------------"
@echo "Cleaning build folder"
@echo "------------------------------------------------------------------"
rm -rf docs

style: build-voyager build-aerial

build-voyager:
@echo
@echo "------------------------------------------------------------------"
@echo "Building voyager style"
@echo "------------------------------------------------------------------"
mkdir -p docs
pnpm charites build assets/style.yml docs/style.json

build-aerial:
@echo
@echo "------------------------------------------------------------------"
@echo "Building aerial style"
@echo "------------------------------------------------------------------"
mkdir -p docs
pnpm charites build assets/aerialstyle.yml docs/aerialstyle.json

sprite:
@echo
@echo "------------------------------------------------------------------"
@echo "Building sprites"
@echo "------------------------------------------------------------------"

rm -rf $(nonSdfFolder)
mkdir -p $(nonSdfFolder)
pnpm sprite-one $(nonSdfFolder)/sprite --icon $(iconFolder) --ratio=1 --ratio=2 --ratio=4

rm -rf $(sdfFolder)
mkdir -p $(sdfFolder)
pnpm sprite-one $(sdfFolder)/sprite --icon $(iconFolder) --ratio=1 --ratio=2 --ratio=4 --sdf

voyager:
@echo
@echo "------------------------------------------------------------------"
@echo "Launching a local server to edit Voyager style"
@echo "------------------------------------------------------------------"
pnpm charites serve assets/style.yml --sprite-input $(iconFolder) --sdf

aerial:
@echo
@echo "------------------------------------------------------------------"
@echo "Launching a local server to edit Aerial style"
@echo "------------------------------------------------------------------"
pnpm charites serve assets/aerialstyle.yml --sprite-input $(iconFolder) --sdf
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ This repository is to manage the style.json for base map of geohub

## Usage

Show the usage of all commands with the below help command

```shell
make help
```

### Maplibre style.json

Check the latest version of `@undp-data/style` package at [npmjs](https://www.npmjs.com/package/@undp-data/style?activeTab=versions), and replace the version of `0.0.1` to the latest one. Or, you may use `latest` to fetch style.json from CDN. But we strongly recommend to specify the version to prevent any breaking change error on style.json.
Expand Down Expand Up @@ -54,31 +60,36 @@ $nvm install 18
$nvm alias default 18
```

## Build style.json
## Build all style and sprite

```shell
pnpm build:style
pnpm build:aerialstyle
make build
```

## Develop style.json
## Build style.json

- launch preview for OSM style
```shell
make style
```

## Build sprite

```shell
pnpm serve
make sprite
```

- launch preview for Bing aerial style
## Develop style.json

- launch preview for OSM style

```shell
pnpm serve:aerial
make voyager
```

## Build sprite
- launch preview for Bing aerial style

```shell
pnpm build:sprite
make aerial
```

## Release map style
Expand Down
14 changes: 3 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
"LICENSE"
],
"scripts": {
"build": "mkdir -p docs && pnpm build:style && pnpm build:aerialstyle && pnpm build:sprite",
"build:style": "pnpm charites build assets/style.yml docs/style.json",
"build:aerialstyle": "pnpm charites build assets/aerialstyle.yml docs/aerialstyle.json",
"build:sprite": "node src/index.js",
"serve": "pnpm charites serve assets/style.yml",
"serve:aerial": "pnpm charites serve assets/aerialstyle.yml",
"release": "changeset publish"
},
"keywords": [
Expand All @@ -35,10 +29,8 @@
},
"homepage": "https://github.com/UNDP-Data/style#readme",
"devDependencies": {
"@changesets/cli": "^2.26.2",
"@elastic/spritezero": "6.2.0",
"@unvt/charites": "^0.5.2",
"glob": "^10.3.3",
"rimraf": "^5.0.1"
"@changesets/cli": "^2.27.1",
"@unvt/charites": "^0.5.4",
"@unvt/sprite-one": "^0.1.1"
}
}
Loading

0 comments on commit ac7f7fd

Please sign in to comment.