@unvt/charites 0.1.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/.editorconfig +9 -0
- package/.github/workflows/build.yml +50 -0
- package/LICENSE +21 -0
- package/README.md +137 -0
- package/dist/cli.js +76 -0
- package/dist/commands/build.js +62 -0
- package/dist/commands/convert.js +89 -0
- package/dist/commands/init.js +33 -0
- package/dist/commands/serve.js +100 -0
- package/dist/lib/defaultValues.js +31 -0
- package/dist/lib/validate-style.js +24 -0
- package/dist/lib/yaml-parser.js +46 -0
- package/package.json +42 -0
- package/provider/default/app.css +7 -0
- package/provider/default/app.js +11 -0
- package/provider/default/index.html +13 -0
- package/provider/geolonia/app.css +7 -0
- package/provider/geolonia/app.js +11 -0
- package/provider/geolonia/index.html +12 -0
- package/provider/mapbox/app.css +7 -0
- package/provider/mapbox/app.js +13 -0
- package/provider/mapbox/index.html +13 -0
- package/src/cli.ts +83 -0
- package/src/commands/build.ts +64 -0
- package/src/commands/convert.ts +95 -0
- package/src/commands/init.ts +29 -0
- package/src/commands/serve.ts +105 -0
- package/src/lib/defaultValues.ts +36 -0
- package/src/lib/validate-style.ts +22 -0
- package/src/lib/yaml-parser.ts +51 -0
- package/test/build.spec.ts +36 -0
- package/test/convert.spec.ts +43 -0
- package/test/data/convert.json +23 -0
- package/test/data/error.yml +1 -0
- package/test/data/example.yml +20 -0
- package/test/data/layers/background.yml +4 -0
- package/test/data/layers/water.yml +8 -0
- package/test/data/names.yml +3 -0
- package/test/data/style.json +33 -0
- package/test/data/style.yml +12 -0
- package/test/validate-style.spec.ts +18 -0
- package/test/yaml-parser.spec.ts +25 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { assert } from 'chai'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import fs from 'fs'
|
|
4
|
+
import os from 'os'
|
|
5
|
+
|
|
6
|
+
import { convert } from '../src/commands/convert'
|
|
7
|
+
|
|
8
|
+
describe('Test for the `convert.ts`.', () => {
|
|
9
|
+
|
|
10
|
+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'charites-'))
|
|
11
|
+
const jsonPath = path.join(__dirname, 'data/convert.json')
|
|
12
|
+
const yamlPath = path.join(tmp, 'convert.yml')
|
|
13
|
+
const layerPath = path.join(tmp, 'layers/background.yml')
|
|
14
|
+
|
|
15
|
+
it('Should convert `data/convert.json` to YAML.', () => {
|
|
16
|
+
|
|
17
|
+
convert(jsonPath, yamlPath)
|
|
18
|
+
const yml = fs.readFileSync(yamlPath, 'utf-8')
|
|
19
|
+
|
|
20
|
+
assert.equal(`version: 8
|
|
21
|
+
name: example
|
|
22
|
+
metadata: {}
|
|
23
|
+
sources:
|
|
24
|
+
geolonia:
|
|
25
|
+
type: vector
|
|
26
|
+
url: https://api.geolonia.com/v1/sources?key=YOUR-API-KEY
|
|
27
|
+
sprite: https://sprites.geolonia.com/basic-white
|
|
28
|
+
glyphs: https://glyphs.geolonia.com/{fontstack}/{range}.pbf
|
|
29
|
+
layers:
|
|
30
|
+
- !!inc/file layers/background.yml
|
|
31
|
+
id: example
|
|
32
|
+
`, yml)
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('Should create layers directory.', () => {
|
|
36
|
+
|
|
37
|
+
convert(jsonPath, yamlPath)
|
|
38
|
+
|
|
39
|
+
const result = fs.existsSync(layerPath)
|
|
40
|
+
|
|
41
|
+
assert.equal(true, result)
|
|
42
|
+
})
|
|
43
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 8,
|
|
3
|
+
"name": "example",
|
|
4
|
+
"metadata": {},
|
|
5
|
+
"sources": {
|
|
6
|
+
"geolonia": {
|
|
7
|
+
"type": "vector",
|
|
8
|
+
"url": "https://api.geolonia.com/v1/sources?key=YOUR-API-KEY"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"sprite": "https://sprites.geolonia.com/basic-white",
|
|
12
|
+
"glyphs": "https://glyphs.geolonia.com/{fontstack}/{range}.pbf",
|
|
13
|
+
"layers": [
|
|
14
|
+
{
|
|
15
|
+
"id": "background",
|
|
16
|
+
"type": "background",
|
|
17
|
+
"paint": {
|
|
18
|
+
"background-color": "rgba(19, 28, 54, 1)"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"id": "example"
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
version: 8
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
$color: "#ff0000"
|
|
2
|
+
$stroke-width: 2
|
|
3
|
+
|
|
4
|
+
$background: "#ff0000"
|
|
5
|
+
$backgroundColor: "#ffff00"
|
|
6
|
+
$backgroundAlias: $background
|
|
7
|
+
$fruits:
|
|
8
|
+
- apple
|
|
9
|
+
- banana
|
|
10
|
+
- $backgroundAlias
|
|
11
|
+
$array-alias: $fruits
|
|
12
|
+
|
|
13
|
+
color: $color
|
|
14
|
+
stroke-width: $stroke-width
|
|
15
|
+
background: $background
|
|
16
|
+
backgroundColor: $backgroundColor
|
|
17
|
+
alias: $backgroundAlias
|
|
18
|
+
fruits: $array-alias
|
|
19
|
+
|
|
20
|
+
names: !!inc/file names.yml
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 8,
|
|
3
|
+
"name": "Geolonia Midnight",
|
|
4
|
+
"metadata": {},
|
|
5
|
+
"sources": {
|
|
6
|
+
"geolonia": {
|
|
7
|
+
"type": "vector",
|
|
8
|
+
"url": "https://api.geolonia.com/v1/sources?key=YOUR-API-KEY"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"sprite": "https://sprites.geolonia.com/basic-white",
|
|
12
|
+
"glyphs": "https://glyphs.geolonia.com/{fontstack}/{range}.pbf",
|
|
13
|
+
"layers": [
|
|
14
|
+
{
|
|
15
|
+
"id": "background",
|
|
16
|
+
"type": "background",
|
|
17
|
+
"paint": null,
|
|
18
|
+
"background-color": "rgba(19, 28, 54, 1)"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"id": "water",
|
|
22
|
+
"type": "fill",
|
|
23
|
+
"source": "geolonia",
|
|
24
|
+
"source-layer": "water",
|
|
25
|
+
"layout": {
|
|
26
|
+
"visibility": "visible"
|
|
27
|
+
},
|
|
28
|
+
"paint": {
|
|
29
|
+
"fill-color": "rgba(1, 17, 44, 1)"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
version: 8
|
|
2
|
+
name: Geolonia Midnight
|
|
3
|
+
metadata: {}
|
|
4
|
+
sources:
|
|
5
|
+
geolonia:
|
|
6
|
+
type: vector
|
|
7
|
+
url: https://api.geolonia.com/v1/sources?key=YOUR-API-KEY
|
|
8
|
+
sprite: https://sprites.geolonia.com/basic-white
|
|
9
|
+
glyphs: https://glyphs.geolonia.com/{fontstack}/{range}.pbf
|
|
10
|
+
layers:
|
|
11
|
+
- !!inc/file layers/background.yml
|
|
12
|
+
- !!inc/file layers/water.yml
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { assert } from 'chai'
|
|
2
|
+
|
|
3
|
+
import { validateStyle } from '../src/lib/validate-style'
|
|
4
|
+
|
|
5
|
+
describe('Test for the `validate-style.ts`.', () => {
|
|
6
|
+
it('should validate as expected.', (done) => {
|
|
7
|
+
const style = {
|
|
8
|
+
version: 8,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
validateStyle(style)
|
|
13
|
+
} catch(error) {
|
|
14
|
+
assert.deepEqual(true, !! error) // It should have something error.
|
|
15
|
+
done()
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { assert } from 'chai'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
|
|
4
|
+
import { parser } from '../src/lib/yaml-parser'
|
|
5
|
+
|
|
6
|
+
describe('Test for the `yaml-parser.ts`.', () => {
|
|
7
|
+
it('should parse `data/example.yml`.', () => {
|
|
8
|
+
const yamlPath = path.join(__dirname, 'data/example.yml')
|
|
9
|
+
const style = parser(yamlPath)
|
|
10
|
+
|
|
11
|
+
assert.deepEqual({
|
|
12
|
+
color: '#ff0000',
|
|
13
|
+
'stroke-width': 2,
|
|
14
|
+
background: '#ff0000',
|
|
15
|
+
backgroundColor: '#ffff00',
|
|
16
|
+
alias: '#ff0000',
|
|
17
|
+
fruits: [ 'apple', 'banana', '#ff0000' ],
|
|
18
|
+
names: [
|
|
19
|
+
"John",
|
|
20
|
+
"花子",
|
|
21
|
+
"#ff0000"
|
|
22
|
+
]
|
|
23
|
+
}, style)
|
|
24
|
+
});
|
|
25
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2018",
|
|
4
|
+
"declaration": false,
|
|
5
|
+
"declarationMap": false,
|
|
6
|
+
"sourceMap": false,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noUnusedLocals": true,
|
|
9
|
+
"noUnusedParameters": true,
|
|
10
|
+
"noImplicitReturns": true,
|
|
11
|
+
"noFallthroughCasesInSwitch": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"experimentalDecorators": true,
|
|
14
|
+
"emitDecoratorMetadata": true,
|
|
15
|
+
"module": "commonjs",
|
|
16
|
+
"outDir": "./dist"
|
|
17
|
+
},
|
|
18
|
+
"include": ["src/cli.ts"]
|
|
19
|
+
}
|