Skip to content

Commit

Permalink
fix: updating lodash and xml2js - dropping old Node version suppo…
Browse files Browse the repository at this point in the history
…rt (#78)

* fix: updating lodash

* chore: updated the rest of them

* fix: tap to jest, remove tap

* feat: drop old node support

BREAKING CHANGES
This will drop support for Node versions before 14.
  • Loading branch information
dotkas authored May 10, 2023
1 parent 4c95ae0 commit 35a07fc
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 184 deletions.
3 changes: 1 addition & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,9 @@ workflows:
matrix:
parameters:
version:
- 10.22.1
- 12.18.4
- 14.13.0
- 16.13.0
- 18.16.0
filters:
branches:
ignore:
Expand Down
10 changes: 5 additions & 5 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ async function extractTargetFrameworksFromProjectFile(
try {
const manifestFile: object = await parseXmlFile(manifestFileContents);
return getTargetFrameworksFromProjectFile(manifestFile);
} catch (err) {
} catch (err: any) {
throw new Error(
`Extracting target framework failed with error ${err.message}`,
);
Expand All @@ -183,7 +183,7 @@ async function extractTargetFrameworksFromProjectConfig(
try {
const manifestFile: object = await parseXmlFile(manifestFileContents);
return getTargetFrameworksFromProjectConfig(manifestFile);
} catch (err) {
} catch (err: any) {
throw new Error(
`Extracting target framework failed with error ${err.message}`,
);
Expand All @@ -209,7 +209,7 @@ async function extractTargetFrameworksFromProjectJson(
// trimming required to address files with UTF-8 with BOM encoding
const manifestFile = JSON.parse(manifestFileContents.trim());
return getTargetFrameworksFromProjectJson(manifestFile);
} catch (err) {
} catch (err: any) {
throw new Error(
`Extracting target framework failed with error ${err.message}`,
);
Expand All @@ -223,7 +223,7 @@ async function extractTargetFrameworksFromProjectAssetsJson(
// trimming required to address files with UTF-8 with BOM encoding
const manifestFile = JSON.parse(manifestFileContents.trim());
return getTargetFrameworksFromProjectAssetsJson(manifestFile);
} catch (err) {
} catch (err: any) {
throw new Error(
`Extracting target framework failed with error ${err.message}`,
);
Expand All @@ -238,7 +238,7 @@ async function extractProps(propsFileContents: string): Promise<PropsLookup> {
throw new InvalidUserInputError('xml file parsing failed');
}
return getPropertiesMap(propsFile);
} catch (err) {
} catch (err: any) {
if (err.name === 'InvalidUserInputError') {
throw err;
}
Expand Down
16 changes: 7 additions & 9 deletions lib/parsers/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as parseXML from 'xml2js';
import * as _isEmpty from 'lodash.isempty';
import * as _set from 'lodash.set';
import * as _uniq from 'lodash.uniq';
import { isEmpty, set, uniq } from 'lodash';
import { InvalidUserInputError } from '../errors';

export interface PkgTree {
Expand Down Expand Up @@ -264,7 +262,7 @@ function buildSubTreeFromPackageReference(
propsMap: PropsLookup,
): PkgTree | DependencyWithoutVersion {
const version = extractDependencyVersion(dep, manifestFile, propsMap) || '';
if (!_isEmpty(version)) {
if (!isEmpty(version)) {
const depSubTree: PkgTree = {
depType: isDev ? DepType.dev : DepType.prod,
dependencies: {},
Expand Down Expand Up @@ -339,7 +337,7 @@ export function getPropertiesMap(propsContents: any): PropsLookup {

for (const group of projectPropertyGroup) {
for (const key of Object.keys(group)) {
_set(props, key, group[key][0]);
set(props, key, group[key][0]);
}
}
return props;
Expand All @@ -361,7 +359,7 @@ export function getTargetFrameworksFromProjectFile(manifestFile) {
);
}) || {};

if (_isEmpty(propertyList)) {
if (isEmpty(propertyList)) {
return targetFrameworksResult;
}
// TargetFrameworks is expected to be a list ; separated
Expand Down Expand Up @@ -406,14 +404,14 @@ export function getTargetFrameworksFromProjectFile(manifestFile) {
];
}

return _uniq(targetFrameworksResult);
return uniq(targetFrameworksResult);
}

function getTargetFrameworks(item: string | any) {
if (typeof item === 'object' && item.hasOwnProperty('_')) {
if (typeof item === 'object' && Object.hasOwnProperty.call(item, '_')) {
item = item._;
}
return item.split(';').filter((x) => !_isEmpty(x));
return item.split(';').filter((x) => !isEmpty(x));
}

export function getTargetFrameworksFromProjectConfig(manifestFile) {
Expand Down
34 changes: 15 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"description": "Generate a dep tree given a collection of manifests",
"main": "dist/index.js",
"scripts": {
"test": "npm run lint && npm run test:tap && npm run test:jest",
"test:tap": "npm run build && tap test/lib/**/*.test.ts -Rspec --timeout=300",
"test:jest": "jest --maxWorkers=1",
"test": "npm run lint && npm run test:jest",
"test:jest": "jest",
"lint": "npm run format:check && tslint -p tsconfig.json",
"build": "tsc",
"build-watch": "tsc -w",
Expand All @@ -21,30 +20,27 @@
"author": "snyk.io",
"license": "Apache-2.0",
"engines": {
"node": ">=8"
"node": ">=14"
},
"files": [
"bin",
"dist"
],
"homepage": "https://github.com/snyk/dotnet-deps-parser#readme",
"dependencies": {
"lodash.isempty": "^4.4.0",
"lodash.set": "^4.3.2",
"lodash.uniq": "^4.5.0",
"source-map-support": "^0.5.7",
"tslib": "^1.10.0",
"xml2js": "0.4.23"
"lodash": "^4.17.21",
"source-map-support": "^0.5.21",
"tslib": "^2.5.0",
"xml2js": "0.5.0"
},
"devDependencies": {
"@types/jest": "^23.3.2",
"@types/node": "^8.10.61",
"@types/xml2js": "0.4.5",
"jest": "23.6.0",
"prettier": "^2.4.1",
"tap": "^14.10.7",
"ts-jest": "^23.10.1",
"tslint": "5.11.0",
"typescript": "3.7.3"
"@types/jest": "^29.5.1",
"@types/node": "^20.1.1",
"@types/xml2js": "0.4.11",
"jest": "29.5.0",
"prettier": "^2.8.8",
"ts-jest": "^29.1.0",
"tslint": "5.20.1",
"typescript": "5.0.4"
}
}
Loading

0 comments on commit 35a07fc

Please sign in to comment.