Skip to content

Commit

Permalink
Upgrade dependencies, migrate to eslint, upgrade to node16 (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobiNino committed Dec 29, 2022
1 parent 7ec2f95 commit 3084e21
Show file tree
Hide file tree
Showing 10 changed files with 7,185 additions and 3,077 deletions.
30 changes: 30 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
rules: {
'@typescript-eslint/typedef': [
'error',
{
memberVariableDeclaration: true,
variableDeclaration: true,
objectDestructuring: true,
propertyDeclaration: true,
parameter: true,
},
],
'prefer-const': 'off',
'no-extra-boolean-cast': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
overrides: [
{
files: ['*.test.ts'],
rules: {
'@typescript-eslint/no-non-null-assertion': 'off',
},
},
],
};
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Setup NodeJS
uses: actions/setup-node@v1
with:
node-version: '10.x'
node-version: '16'
registry-url: 'https://registry.npmjs.org'
scope: '@jfrog'
- name: Install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup NodeJS
uses: actions/setup-node@v1
with:
node-version: '10.x'
node-version: '16'
- name: Install
run: npm i
- name: Lint
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ You may use this package for other purposes and applications as well, either by
`npm install -g nuget-deps-tree`

## Usage
### Prerequisites
`nuget` (or `nuget.exe`) should be available in $PATH.

### Command Line
`nuget-deps-tree [path to sln file]`

Expand Down Expand Up @@ -59,6 +62,9 @@ let tree = NugetDepsTree.generate(pathToSlnFile);
```

## Building and Testing the Sources
### Preconditions
* npm 7 and above

To build the plugin sources, please follow these steps:
* Clone the code from git.
* Install and pack the nuget-deps-tree dependency locally, by running the following npm commands:
Expand Down
10,162 changes: 7,123 additions & 3,039 deletions package-lock.json

Large diffs are not rendered by default.

23 changes: 14 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" \"model/**/*.ts\"",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" \"model/**/*.ts\" \".eslintrc.js\"",
"build": "npm run compile",
"lint": "tslint -p tsconfig.json",
"lint": "eslint -c .eslintrc.js --ext .ts src",
"prepare": "npm run build",
"preversion": "npm run lint",
"watch": "tsc -watch -p ./",
Expand All @@ -27,6 +27,10 @@
"bin": {
"nuget-deps-tree": "dist/bin/command.js"
},
"engines": {
"node": ">=16",
"npm": ">=7"
},
"files": [
"dist/**/*"
],
Expand All @@ -39,16 +43,17 @@
"which": "^2.0.2"
},
"devDependencies": {
"@types/lodash": "^4.14.162",
"@types/fs-extra": "^8.1.0",
"@types/jest": "^25.2.1",
"@types/jest": "^29.2.4",
"@types/lodash": "^4.14.162",
"@types/which": "^1.3.2",
"jest": "^27.0.4",
"@typescript-eslint/eslint-plugin": "^5.46.1",
"eslint": "^8.30.0",
"eslint-config-prettier": "^8.5.0",
"jest": "^29.3.1",
"prettier": "^2.0.5",
"ts-jest": "^27.0.3",
"tslint": "^6.1.2",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.8.3"
"ts-jest": "^29.0.3",
"typescript": "^4.9.4"
},
"keywords": [
"nuget",
Expand Down
12 changes: 6 additions & 6 deletions src/AssetsJson/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class AssetsUtils {
*/
public static getDirectDependencies(assets: any): string[] {
const directDependencies: string[] = [];
const frameworks = CommonUtils.getPropertyOrUndefined(assets, 'project.frameworks');
const frameworks: any = CommonUtils.getPropertyOrUndefined(assets, 'project.frameworks');
for (const framework in frameworks) {
for (const dependencyId in CommonUtils.getPropertyOrUndefined(frameworks[framework], 'dependencies')) {
directDependencies.push(dependencyId);
Expand All @@ -35,10 +35,10 @@ export class AssetsUtils {
CommonUtils.getPropertyStrictly(assets, 'project.restore.packagesPath', assetsFileName)
);

const libraries = CommonUtils.getPropertyOrUndefined(assets, 'libraries');
const libraries: any = CommonUtils.getPropertyOrUndefined(assets, 'libraries');
for (const dependency in libraries) {
const library = libraries[dependency];
const type = CommonUtils.getPropertyStrictly(library, 'type', assetsFileName);
const library: any = libraries[dependency];
const type: any = CommonUtils.getPropertyStrictly(library, 'type', assetsFileName);
if (type === 'project') {
continue;
}
Expand Down Expand Up @@ -76,9 +76,9 @@ export class AssetsUtils {
public static getChildrenMap(assets: any): CaseInsensitiveMap<string[]> {
const dependenciesRelations: CaseInsensitiveMap<string[]> = new CaseInsensitiveMap<string[]>();
// If has no target dependencies, loop is skipped.
const targets = CommonUtils.getPropertyOrUndefined(assets, 'targets');
const targets: any = CommonUtils.getPropertyOrUndefined(assets, 'targets');
for (const target in targets) {
const targetDependencies = targets[target];
const targetDependencies: any = targets[target];
for (const dependency in targetDependencies) {
const transitive: string[] = [];
// If has no dependencies, loop is skipped.
Expand Down
5 changes: 3 additions & 2 deletions src/Main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Solution } from './Structure/Solution';
import { Tree, Project } from './Structure/OutputStructure';
import { DependencyTree } from './DependencyTree/Tree';

export class NugetDepsTree {
/**
Expand All @@ -10,10 +11,10 @@ export class NugetDepsTree {
public static generate(slnFilePath: string): Tree {
const sol: Solution = Solution.create(slnFilePath);

const nugetDepsTree = new Tree([]);
const nugetDepsTree: Tree = new Tree([]);
// Create the tree for each project.
for (const proj of sol.projects) {
const depsTree = proj.createDependencyTree();
const depsTree: DependencyTree[] = proj.createDependencyTree();
nugetDepsTree.projects.push(new Project(proj.name, depsTree));
}

Expand Down
2 changes: 1 addition & 1 deletion src/PackagesConfig/NugetPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class NugetPackage {
}

// Dependencies might be grouped.
const groupArray = lodash.get(metaDataDep, 'group');
const groupArray: any = lodash.get(metaDataDep, 'group');
if (groupArray) {
for (const group of groupArray) {
if (group.dependency) {
Expand Down
18 changes: 0 additions & 18 deletions tslint.json

This file was deleted.

0 comments on commit 3084e21

Please sign in to comment.