Skip to content
This repository was archived by the owner on Nov 9, 2022. It is now read-only.

Commit ea1693e

Browse files
authored
Merge pull request #28 from Bayer-Group/TSlint-and-npm-audit-fix
npm audit and TS lint fix
2 parents 4c98f1c + 3f17cfa commit ea1693e

File tree

8 files changed

+9653
-6621
lines changed

8 files changed

+9653
-6621
lines changed

package-lock.json

Lines changed: 9552 additions & 6532 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bayer/geostyler-geoserver-sld-parser",
3-
"version": "0.3.2",
3+
"version": "0.3.3",
44
"description": "GeoStyler-Geoserver-Style-Parser implementation for SLD",
55
"main": "build/dist/GeoserverSldStyleParser.js",
66
"types": "build/dist/GeoserverSldStyleParser.d.ts",
@@ -12,8 +12,7 @@
1212
"prepublishOnly": "npm run build",
1313
"test": "jest",
1414
"test:watch": "jest --watchAll",
15-
"lint": "tslint --project tsconfig.json --config tslint.json && tsc --noEmit --project tsconfig.json",
16-
"release": "np --no-yarn && git push https://github.com/terrestris/geostyler-sld-parser.git master --tags"
15+
"lint": "tslint --project tsconfig.json --config tslint.json && tsc --noEmit --project tsconfig.json"
1716
},
1817
"license": "BSD",
1918
"repository": {
@@ -39,18 +38,20 @@
3938
"@babel/polyfill": "^7.4.4",
4039
"@babel/preset-env": "^7.5.5",
4140
"@babel/preset-typescript": "^7.3.3",
42-
"@types/jest": "^24.0.18",
41+
"@types/jest": "^27.0.3",
4342
"@types/lodash": "^4.14.138",
4443
"@types/node": "^12.7.3",
4544
"@types/xml2js": "^0.4.4",
4645
"babel-jest": "^24.9.0",
47-
"coveralls": "^3.0.6",
48-
"jest": "^24.9.0",
49-
"np": "^5.0.3",
46+
"buffer": "^6.0.3",
47+
"child_process": "^1.0.2",
48+
"jest": "^27.3.1",
49+
"semver": "^7.3.5",
50+
"terser-webpack-plugin": "^5.2.5",
5051
"ts-loader": "^6.0.4",
5152
"tslint": "^5.19.0",
52-
"typescript": "^3.6.2",
53-
"webpack": "^4.39.3",
54-
"webpack-cli": "^3.3.7"
53+
"typescript": "^4.5.2",
54+
"webpack": "^5.64.3",
55+
"webpack-cli": "^4.9.1"
5556
}
5657
}

scripts/ship.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const semver = require('semver')
2+
const child_process = require('child_process')
3+
const packageJson = require('./../package.json')
4+
5+
const packageName = packageJson.name
6+
const tag = packageJson.version.includes('-') ? 'next' : 'latest'
7+
const latestVersion = child_process.execSync(`npm view ${packageName}@latest version`).toString()
8+
9+
// publish with a `shipping` tag so we can control the latest/next tags manually since NPM defaults to latest if no tag is provided
10+
child_process.execSync(`export SHIP=true && npm run build && npm publish -f --tag shipping`)
11+
// remove the temporary shipping tag
12+
child_process.execSync(`npm dist-tags remove ${packageName} shipping || true`)
13+
14+
// only if the latest is less than the current version do we tag it (this ignores support branches)
15+
if (semver.gt(packageJson.version, latestVersion)) {
16+
// add the appropriate next or latest tag manually to the version just published
17+
child_process.execSync(`npm dist-tags add ${packageName}@${packageJson.version} ${tag}`)
18+
}

src/GeoserverFillSymbolizer.spec.ts

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import GeoserverSldStyleParser from './GeoserverSldStyleParser'
1+
import GeoserverSldStyleParser from './GeoserverSldStyleParser';
22

33
const polygonSimpleGraphicFill: any = {
44
name: 'My Style',
@@ -7,22 +7,21 @@ const polygonSimpleGraphicFill: any = {
77
name: 'My Rule',
88
symbolizers: [
99
{
10-
"kind": "Fill",
11-
"color": "#a5c9e5",
12-
"graphicFill": {
13-
"kind": "Mark",
14-
"wellKnownName": "Star",
15-
"radius": 8,
16-
"color": "#0000FF",
10+
'kind': 'Fill',
11+
'color': '#a5c9e5',
12+
'graphicFill': {
13+
'kind': 'Mark',
14+
'wellKnownName': 'Star',
15+
'radius': 8,
16+
'color': '#0000FF',
1717
},
18-
"graphic-margin": '3 5 10'
18+
'graphic-margin': '3 5 10'
1919
},
2020
],
2121
},
2222
],
2323
};
2424

25-
2625
const sldOutput = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2726
<StyledLayerDescriptor version="1.0.0" xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2827
<NamedLayer>
@@ -54,28 +53,25 @@ const sldOutput = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
5453
</FeatureTypeStyle>
5554
</UserStyle>
5655
</NamedLayer>
57-
</StyledLayerDescriptor>
58-
`
56+
</StyledLayerDescriptor>`;
5957

6058
const parser = new GeoserverSldStyleParser();
6159

6260
describe('GeoserverFillSymbolizer', () => {
6361
describe('#writeStyle', () => {
64-
it('transforms graphic-margin in VendorOptions', () => {
62+
it('transforms graphic-margin in VendorOptions', async () => {
6563
expect.assertions(1);
66-
parser
67-
.writeStyle(polygonSimpleGraphicFill).then(sld => {
68-
expect(sld).toEqual(sldOutput);
69-
});
64+
const sld = await parser.writeStyle(polygonSimpleGraphicFill);
65+
expect(sld).toEqual(sldOutput);
66+
7067
});
7168
});
7269
describe('#readStyle', () => {
73-
it('reads VendorOptions graphic-margin', () => {
70+
it('reads VendorOptions graphic-margin', async () => {
7471
expect.assertions(1);
75-
parser
76-
.readStyle(sldOutput).then(gsObject => {
77-
expect(gsObject).toEqual(polygonSimpleGraphicFill);
78-
});
72+
const gsObject = await parser.readStyle(sldOutput);
73+
expect(gsObject).toEqual(polygonSimpleGraphicFill);
74+
7975
});
8076
});
8177
});

src/GeoserverMarkSymbolizer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ interface GeoserverMarkSymbolizer extends BasePointSymbolizer {
5353
*/
5454
pitchScale?: 'map' | 'viewport';
5555

56-
func?: any
56+
func?: any;
5757
}
5858

59-
export default GeoserverMarkSymbolizer
59+
export default GeoserverMarkSymbolizer;

src/GeoserverSldStyleParser.ts

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
import SldStyleParser from 'geostyler-sld-parser';
22
import { WellKnownName } from 'geostyler-style';
33
import GeoserverTextSymbolizer from './GeoserverTextSymbolizer';
4-
import GeoserverMarkSymbolizer from './GeoserverMarkSymbolizer'
4+
import GeoserverMarkSymbolizer from './GeoserverMarkSymbolizer';
5+
import GeoserverFillSymbolizer from './GeoserverFillSymbolizer';
56
import {
67
Filter,
78
ComparisonFilter, BaseSymbolizer,
89
} from 'geostyler-style';
9-
import GeoserverFillSymbolizer from './GeoserverFillSymbolizer';
10-
import GeoserverTextSymbolizer from './GeoserverTextSymbolizer';
11-
var _get = require('lodash.get')
12-
10+
const _get = require('lodash.get');
11+
type CssParam = {
12+
'_': string | number,
13+
'$': {
14+
name: string
15+
};
16+
};
1317
const VENDOR_OPTIONS_MAP = [
1418
'partials',
1519
'repeat',
@@ -28,7 +32,7 @@ function keysByValue (object: any, value: any) {
2832
return Object.keys(object).filter(key => object[key] === value);
2933
}
3034

31-
var WELLKNOWNNAME_TTF_REGEXP = /^ttf:\/\/(.+)#(.+)$/;
35+
const WELLKNOWNNAME_TTF_REGEXP = /^ttf:\/\/(.+)#(.+)$/;
3236

3337
class GeoserverSldStyleParser extends SldStyleParser {
3438
getSldComparisonFilterFromComparisonFilter(comparisonFilter: ComparisonFilter): any {
@@ -99,8 +103,7 @@ class GeoserverSldStyleParser extends SldStyleParser {
99103
return finalSymbolizer;
100104
}
101105

102-
103-
/**
106+
/**
104107
* Get the GeoStyler-Style MarkSymbolizer from an SLD Symbolizer
105108
*
106109
* @param {object} sldSymbolizer The SLD Symbolizer
@@ -116,7 +119,6 @@ class GeoserverSldStyleParser extends SldStyleParser {
116119
const size: string = _get(sldSymbolizer, 'Graphic[0].Size[0]');
117120
const rotation: string = _get(sldSymbolizer, 'Graphic[0].Rotation[0]');
118121

119-
120122
let fillParams: any[] = _get(sldSymbolizer, 'Graphic[0].Mark[0].Fill[0].CssParameter') || [];
121123
if (fillParams.length === 0) {
122124
fillParams = _get(sldSymbolizer, 'Graphic[0].Mark[0].Fill[0].SvgParameter') || [];
@@ -132,46 +134,46 @@ class GeoserverSldStyleParser extends SldStyleParser {
132134
}
133135
}
134136

135-
var sldFunction = _get(sldSymbolizer, 'Graphic[0].Mark[0].Fill[0].CssParameter[' + colorIdx + '].Function');
137+
const sldFunction = _get(sldSymbolizer, 'Graphic[0].Mark[0].Fill[0].CssParameter[' + colorIdx + '].Function');
136138

137139
const fillOpacityIdx: number = fillParams.findIndex((cssParam: any) => {
138140
return cssParam.$.name === 'fill-opacity';
139141
});
140142
let fillOpacity: string = _get(sldSymbolizer,
141-
'Graphic[0].Mark[0].Fill[0].CssParameter[' + fillOpacityIdx + ']._');
143+
'Graphic[0].Mark[0].Fill[0].CssParameter[' + fillOpacityIdx + ']._');
142144
if (!fillOpacity) {
143145
fillOpacity = _get(sldSymbolizer,
144-
'Graphic[0].Mark[0].Fill[0].SvgParameter[' + fillOpacityIdx + ']._');
146+
'Graphic[0].Mark[0].Fill[0].SvgParameter[' + fillOpacityIdx + ']._');
145147
}
146148
const markSymbolizer: GeoserverMarkSymbolizer = {
147149
kind: 'Mark',
148150
} as GeoserverMarkSymbolizer;
149151

150152
if (sldFunction) {
151153
if (sldFunction[0].$.name === 'Interpolate') {
152-
const perChunk = 2 // items per chunk
154+
const perChunk = 2; // items per chunk
153155

154156
var newArray = sldFunction[0].Literal.reduce((resultArray: any, item: any, index: any) => {
155-
const chunkIndex = Math.floor(index/perChunk)
157+
const chunkIndex = Math.floor(index / perChunk);
156158

157-
if(!resultArray[chunkIndex]) {
158-
resultArray[chunkIndex] = [] // start a new chunk
159+
if (!resultArray[chunkIndex]) {
160+
resultArray[chunkIndex] = []; // start a new chunk
159161
}
160-
resultArray[chunkIndex].push(item)
162+
resultArray[chunkIndex].push(item);
161163

162-
return resultArray
163-
}, [])
164+
return resultArray;
165+
}, []);
164166

165167
const newestArray = newArray.map((arr: any, i: any) => {
166-
return [i === 0 ? '>' : '<', sldFunction[0].PropertyName[0], ...arr]
167-
})
168+
return [i === 0 ? '>' : '<', sldFunction[0].PropertyName[0], ...arr];
169+
});
168170

169171
const functionArray = [
170172
sldFunction[0].$.name,
171173
...newestArray
172-
]
174+
];
173175

174-
markSymbolizer.func = functionArray
176+
markSymbolizer.func = functionArray;
175177
}
176178
}
177179

@@ -255,7 +257,7 @@ class GeoserverSldStyleParser extends SldStyleParser {
255257
}];
256258

257259
if (markSymbolizer.color || markSymbolizer.fillOpacity) {
258-
const cssParameters = [];
260+
const cssParameters: CssParam[] = [];
259261
if (markSymbolizer.color) {
260262
cssParameters.push({
261263
'_': markSymbolizer.color,
@@ -309,14 +311,14 @@ class GeoserverSldStyleParser extends SldStyleParser {
309311
}
310312

311313
if (markSymbolizer.func) {
312-
const propertyName = markSymbolizer.func[1][1]
313-
const emptyArray: string[] = []
314+
const propertyName = markSymbolizer.func[1][1];
315+
const emptyArray: string[] = [];
314316
markSymbolizer.func.map((arr: string[], i: any) => {
315317
if (i !== 0) {
316-
emptyArray.push(arr[2])
317-
if (arr.length === 4) emptyArray.push(arr[3])
318+
emptyArray.push(arr[2]);
319+
if (arr.length === 4) { emptyArray.push(arr[3]); }
318320
}
319-
})
321+
});
320322

321323
const cssParameters = [];
322324

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import GeoserverSldStyleParser from '../src/GeoserverSldStyleParser'
1+
import GeoserverSldStyleParser from '../src/GeoserverSldStyleParser';
22

33
const pointSimpleText: any = {
44
name: 'My Style',
@@ -15,7 +15,7 @@ const pointSimpleText: any = {
1515
],
1616
},
1717
],
18-
}
18+
};
1919

2020
const sldOutput = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2121
<StyledLayerDescriptor version="1.0.0" xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@@ -38,27 +38,22 @@ const sldOutput = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
3838
</FeatureTypeStyle>
3939
</UserStyle>
4040
</NamedLayer>
41-
</StyledLayerDescriptor>
42-
`
43-
const parser = new GeoserverSldStyleParser()
41+
</StyledLayerDescriptor>`;
42+
const parser = new GeoserverSldStyleParser();
4443

45-
describe('GeoserverTextSymbolizer', () => {
44+
describe('GeoserverTextSymbolizer', () => {
4645
describe('#writeStyle', () => {
47-
it('transforms spaceAround in VendorOptions', () => {
48-
expect.assertions(1)
49-
parser
50-
.writeStyle(pointSimpleText).then((sld: string) => {
51-
expect(sld).toEqual(sldOutput)
52-
})
53-
})
54-
})
55-
describe('#readStyle', () => {
56-
it('reads VendorOptions space-around', () => {
57-
expect.assertions(1)
58-
parser
59-
.readStyle(sldOutput).then(gsObject => {
60-
expect(gsObject).toEqual(pointSimpleText)
61-
})
62-
})
63-
})
64-
})
46+
it('transforms spaceAround in VendorOptions', async () => {
47+
expect.assertions(1);
48+
const sld: string = await parser.writeStyle(pointSimpleText);
49+
expect(sld).toEqual(sldOutput);
50+
});
51+
});
52+
describe('#readStyle', () => {
53+
it('reads VendorOptions space-around', async () => {
54+
expect.assertions(1);
55+
const gsObject = await parser.readStyle(sldOutput);
56+
expect(gsObject).toEqual(pointSimpleText);
57+
});
58+
});
59+
});

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"outDir": "build/dist",
66
"module": "commonjs",
77
"target": "es5",
8-
"lib": ["es6", "dom"],
8+
"lib": ["es6", "dom", "es2017"],
99
"sourceMap": true,
1010
"moduleResolution": "node",
1111
"rootDir": "src",
@@ -30,4 +30,4 @@
3030
"browser",
3131
"browser-build.config.js"
3232
]
33-
}
33+
}

0 commit comments

Comments
 (0)