Skip to content

Commit

Permalink
feat: Add all resolvers unit tests #12 (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
regevbr committed Apr 19, 2020
1 parent f781972 commit 8c51e65
Show file tree
Hide file tree
Showing 166 changed files with 7,271 additions and 2,775 deletions.
6 changes: 6 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": ["@commitlint/config-conventional"],
"rules": {
"subject-case": [2, "never", ["start-case", "pascal-case", "upper-case"]]
}
}
5 changes: 4 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
"contributorsrc",
"simplegit",
"lcov",
"Ilts"
"toolbelt"
],
"ignorePaths": [
"**/coverage/**",
"reports/**",
"coverage/**",
".stryker-tmp/**",
"**/node_modules/**",
"**/dist/**",
"**/*.{json,snap}",
Expand Down
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ coverage
.github
.nyc_output
scripts
.stryker-tmp
/reports/
17 changes: 15 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@
"max-len": [
"error",
{
"code": 130
"code": 120,
"ignoreComments": true,
"ignoreUrls": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true,
"ignoreRegExpLiterals": true
}
],
"new-parens": "error",
Expand Down Expand Up @@ -153,5 +158,13 @@
"use-isnan": "error",
"valid-typeof": "off"
},
"settings": {}
"settings": {},
"overrides": [
{
"files": ["*.spec.ts"],
"rules": {
"@typescript-eslint/unbound-method": "off"
}
}
]
}
20 changes: 19 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
types: [retest]

env:
PRIMARY_NODE_VERSION: 10.x
PRIMARY_NODE_VERSION: 12.x
PRIMARY_OS: ubuntu-latest
FORCE_COLOR: true
JEST_CI: true
Expand Down Expand Up @@ -111,6 +111,13 @@ jobs:
name: codecov
fail_ci_if_error: true

- name: Upload coverage reports artifact
if: matrix.node-version == env.PRIMARY_NODE_VERSION && matrix.os == env.PRIMARY_OS
uses: actions/upload-artifact@v1
with:
name: coverage
path: coverage

- name: Run unit tests
if: "!(matrix.node-version == env.PRIMARY_NODE_VERSION && matrix.os == env.PRIMARY_OS)"
run: yarn run test:unit
Expand All @@ -121,6 +128,17 @@ jobs:
- name: Run e2e tests
run: yarn run test:e2e

- name: Run mutation tests
if: matrix.node-version == env.PRIMARY_NODE_VERSION && matrix.os == env.PRIMARY_OS && github.ref == 'refs/heads/master'
run: yarn run mutation-test

- name: Upload mutation reports artifact
if: matrix.node-version == env.PRIMARY_NODE_VERSION && matrix.os == env.PRIMARY_OS && github.ref == 'refs/heads/master'
uses: actions/upload-artifact@v1
with:
name: mutation
path: reports/mutation

publish_version:
name: Publish
runs-on: ubuntu-latest
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pids

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

/.stryker-tmp
# Coverage directory used by tools like istanbul
coverage
.cache
Expand Down Expand Up @@ -65,3 +65,7 @@ typings/

# dotenv environment variables file
.env

# stryker temp files
.stryker-tmp
/reports
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,7 @@ typings/
/tsconfig.build.json
/tsconfig.test.json
/jest.config.js
/stryker.conf.json
/stryker.conf.js
/.stryker-tmp/
/reports/
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
.nyc_output
CONTRIBUTORS.md
CHANGELOG.md
.stryker-tmp
/reports/
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ Where `<tag>` is one of:
- `fix` - for any bug fixes that don't add new functionality
- `test` - if you only change tests, and not shipped code
- `docs` - if you only change documentation, and not shipped code
- `refactor` - refactoring
- `style` - linting fixes
- `chore` - anything else

And `<short description>` is a succinct title for the PR.
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[![Npm Version](https://img.shields.io/npm/v/node-upgrade-checker.svg?style=popout)](https://www.npmjs.com/package/node-upgrade-checker)
![node](https://img.shields.io/node/v/node-upgrade-checker)
![node](https://img.shields.io/node/v-lts/node-upgrade-checker)
![platform](https://img.shields.io/badge/platform-linux%20%7C%20macos%20%7C%20windows-green)
![CI](https://github.com/PruvoNet/node-upgrade-checker/workflows/CI/badge.svg?branch=master)
[![codecov](https://codecov.io/gh/PruvoNet/node-upgrade-checker/branch/master/graph/badge.svg)](https://codecov.io/gh/PruvoNet/node-upgrade-checker)
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FPruvoNet%2Fnode-upgrade-checker%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/PruvoNet/node-upgrade-checker/master)
[![Known Vulnerabilities](https://snyk.io/test/github/PruvoNet/node-upgrade-checker/badge.svg?targetFile=package.json)](https://snyk.io/test/github/PruvoNet/node-upgrade-checker?targetFile=package.json)
[![dependencies Status](https://david-dm.org/PruvoNet/node-upgrade-checker/status.svg)](https://david-dm.org/PruvoNet/node-upgrade-checker)
[![devDependencies Status](https://david-dm.org/PruvoNet/node-upgrade-checker/dev-status.svg)](https://david-dm.org/PruvoNet/node-upgrade-checker?type=dev)
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const config = {

if (process.env.JEST_CI) {
config.runner = 'jest-serial-runner';
config.coverageReporters.push(`text`);
}

module.exports = config;
95 changes: 53 additions & 42 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,31 @@
"update",
"lts"
],
"author": "Regev Brody <regevbr@gmail.com>",
"license": "ISC",
"engineStrict": true,
"engines": {
"node": "^10 || ^12 || ^13",
"yarn": "^1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/PruvoNet/node-upgrade-checker.git"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"bin": {
"nuc": "./dist/cli/index.js"
},
"engineStrict": true,
"engines": {
"node": "^10 || ^12 || ^13"
},
"files": [
"dist/**/*.d.ts",
"dist/**/*.js"
],
"scripts": {
"envcheck": "node -e \"if(!/yarn\\.js$/.test(process.env.npm_execpath))throw new Error('Use yarn')\"",
"preinstall": "yarn run envcheck",
"postinstall": "yarn run compile",
"versionupdate": "yarn run ncu && yarn install",
"versionupdate": "yarn run ncu && rm yarn.lock && yarn install",
"clean:dist": "rm -rf dist && rm -f .buildcache",
"prebuild": "yarn run lint && yarn run clean:dist",
"build": "yarn run tsc -p tsconfig.build.json",
Expand Down Expand Up @@ -58,71 +69,71 @@
"check:spelling": "cspell --config=.cspell.json \"**/*.{md,ts,js}\"",
"generate-contributors": "yarn run ts-node --transpile-only ./tools/generate-contributors.ts && yarn run all-contributors generate",
"check-clean-workspace-after-install": "git diff --quiet --exit-code",
"docs:changelog": "yarn run changelog --allow-unknown"
"docs:changelog": "yarn run changelog --allow-unknown",
"mutation-test": "yarn run stryker run"
},
"repository": {
"type": "git",
"url": "git+https://github.com/PruvoNet/node-upgrade-checker.git"
},
"author": "Regev Brody <regevbr@gmail.com>",
"files": [
"dist/**/*.d.ts",
"dist/**/*.js"
],
"license": "ISC",
"devDependencies": {
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4",
"@stryker-mutator/core": "^3.1.0",
"@stryker-mutator/jest-runner": "^3.1.0",
"@stryker-mutator/typescript": "^3.1.0",
"@types/cross-spawn": "^6.0.1",
"@types/jest": "^25.1.4",
"@types/moment": "^2.13.0",
"@types/node": "^13.9.3",
"@types/node-fetch": "^2.5.5",
"@types/pacote": "^9.5.1",
"@types/jest": "^25.2.1",
"@types/jest-when": "^2.7.1",
"@types/node": "^13.13.0",
"@types/node-fetch": "^2.5.6",
"@types/pacote": "^11.1.0",
"@types/semver": "^7.1.0",
"@types/shell-quote": "^1.6.1",
"@types/tmp": "^0.1.0",
"@types/yaml": "^1.2.0",
"@typescript-eslint/eslint-plugin": "^2.25.0",
"@typescript-eslint/parser": "^2.25.0",
"all-contributors-cli": "^6.14.0",
"cspell": "^4.0.55",
"@types/yargs-parser": "^15.0.0",
"@typescript-eslint/eslint-plugin": "^2.28.0",
"@typescript-eslint/parser": "^2.28.0",
"all-contributors-cli": "^6.14.2",
"cspell": "^4.0.57",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.1",
"eslint-plugin-jest": "^23.8.2",
"eslint-plugin-prefer-arrow": "^1.1.7",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-prefer-arrow": "^1.2.0",
"eslint-plugin-prettier": "^3.1.3",
"expect": "^25.3.0",
"generate-changelog": "^1.8.0",
"jest": "^25.1.0",
"husky": "^4.2.5",
"jest": "^25.3.0",
"jest-mock-extended": "^1.0.8",
"jest-serial-runner": "^1.1.0",
"lint-staged": "^10.0.9",
"jest-when": "^2.7.1",
"lint-staged": "^10.1.6",
"mock-spawn": "^0.2.6",
"node-fetch": "^2.6.0",
"npm-check-updates": "^4.0.5",
"prettier": "^2.0.2",
"semver": "^7.1.3",
"ts-jest": "^25.2.1",
"ts-node": "^8.8.1",
"npm-check-updates": "^4.1.2",
"prettier": "^2.0.4",
"semver": "^7.3.2",
"ts-jest": "^25.4.0",
"ts-node": "^8.8.2",
"ts-toolbelt": "^6.5.1",
"typescript": "^3.8.3"
},
"dependencies": {
"array-flat-polyfill": "~1.0.1",
"axios": "~0.19.2",
"chalk": "~3.0.0",
"chalk": "~4.0.0",
"consola": "~2.11.3",
"cross-spawn": "~7.0.1",
"cross-spawn": "~7.0.2",
"figures": "~3.2.0",
"inversify": "~5.0.1",
"moment": "~2.24.0",
"pacote": "~11.1.4",
"reflect-metadata": "~0.1.13",
"shell-quote": "^1.7.2",
"simple-git": "~1.132.0",
"sqlite3": "~4.1.1",
"tmp": "~0.1.0",
"ts-type-guards": "~0.6.1",
"typeorm": "~0.2.24",
"yaml": "~1.8.3"
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
"yaml": "~1.9.1",
"yargs-parser": "~18.1.3"
}
}
12 changes: 7 additions & 5 deletions src/container/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ import { ciResolverModulesBinder } from '../resolvers/ciResolver';
import { dbModulesBinder } from '../db';
import { cacheResolveModulesBinder } from '../resolvers/cacheResolver';
import { testResolverModulesBinder } from '../resolvers/testResolver';
import { flowModulesBinder } from '../flow';
import { ltsModulesBinder } from '../utils/lts';
import { dependencyCheckerModulesBinder } from '../dependencyChecker';
import { nodeVersionsModulesBinder } from '../utils/nodeVersions';
import { packageInfoModulesBinder } from '../utils/packageInfo';
import { nodeModulesBinder } from './nodeModulesContainer';
import { enginesResolveModulesBinder } from '../resolvers/enginesResolver';
import { loggerModuleBinder } from '../utils/logger';

export const container = new Container();
export const container = new Container({
skipBaseClassChecks: true,
});

type Binder = (bind: Bind) => void;

Expand All @@ -27,8 +29,8 @@ const binders: Binder[] = [
dbModulesBinder,
cacheResolveModulesBinder,
testResolverModulesBinder,
flowModulesBinder,
ltsModulesBinder,
dependencyCheckerModulesBinder,
nodeVersionsModulesBinder,
packageInfoModulesBinder,
enginesResolveModulesBinder,
loggerModuleBinder,
Expand Down
13 changes: 13 additions & 0 deletions src/container/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { METADATA_KEY, namedConstraint, taggedConstraint, interfaces } from 'inversify';
import Request = interfaces.Request;
import Abstract = interfaces.Abstract;

export type Constraint = (request: Request) => boolean;

export const namedOrMultiConstraint = (symbol: symbol, target: Abstract<any>): Constraint => {
const tagConstraint = namedConstraint(symbol);
const multiInjectConstraint = taggedConstraint(METADATA_KEY.MULTI_INJECT_TAG)(target);
return (request: Request): boolean => {
return multiInjectConstraint(request) || tagConstraint(request);
};
};
14 changes: 5 additions & 9 deletions src/db/entities/dependency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,15 @@ export interface IDependencyOptions {

@Entity()
export class Dependency extends IEntity {
@PrimaryColumn(`text`, {
nullable: false,
})
public static TAG = Symbol.for(`Dependency`);

@PrimaryColumn(`text`)
public name!: string;

@PrimaryColumn(`text`, {
nullable: false,
})
@PrimaryColumn(`text`)
public version!: string;

@PrimaryColumn(`text`, {
nullable: false,
})
@PrimaryColumn(`text`)
public targetNode!: string;

@Column(`boolean`, {
Expand Down

0 comments on commit 8c51e65

Please sign in to comment.