Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Paweł Gałązka committed Jan 25, 2019
2 parents 6de443a + 45cf440 commit 5d090ac
Show file tree
Hide file tree
Showing 20 changed files with 1,792 additions and 1,864 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

20 changes: 0 additions & 20 deletions .eslintrc.json

This file was deleted.

10 changes: 0 additions & 10 deletions .flowconfig

This file was deleted.

5 changes: 5 additions & 0 deletions .huskyrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"hooks": {
"pre-commit": "lint-staged"
}
}
3 changes: 3 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"semi": false
}
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
language: node_js
node_js:
- "8.10.0"
- "9.8.0"
- "8.15.0"
- "10.15.0"
56 changes: 56 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html

module.exports = {
// Indicates whether the coverage information should be collected while executing the test
// collectCoverage: false,

// An array of glob patterns indicating a set of files for which coverage information should be collected
collectCoverageFrom: [
"<rootDir>/**/*.ts"
],

// A list of reporter names that Jest uses when writing coverage reports
coverageReporters: [
"text",
"text-summary"
],

// An object that configures minimum threshold enforcement for coverage results
coverageThreshold: {
"global": {
"lines": 50
}
},

// A set of global variables that need to be available in all test environments
globals: {
"ts-jest": {
"tsConfig": "tsconfig.json"
}
},

// An array of file extensions your modules use
moduleFileExtensions: [
"ts",
"tsx",
"js",
"jsx"
],

// The root directory that Jest should scan for tests and modules within
rootDir: "./test",

// The test environment that will be used for testing
testEnvironment: "node",

// The glob patterns Jest uses to detect test files
testMatch: [
"**/*.spec.(ts|tsx)"
],

// A map from regular expressions to paths to transformers
transform: {
"^.+\\.(ts|tsx)$": "ts-jest"
}
};
64 changes: 20 additions & 44 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@
"tool"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"bin": {
"run": "bin/run.js"
},
"scripts": {
"lint": "eslint src/** bin/run.js test/**",
"build": "babel src/ --out-dir lib/",
"test": "yarn lint && flow check && yarn build && yarn sandbox:dev && jest ./test --coverage",
"lint": "tslint -c tslint.json 'src/*.ts'",
"build": "tsc",
"test": "yarn lint && yarn build && yarn sandbox:dev && jest ./test --coverage",
"test:unit": "jest ./test/unit/",
"test:e2e": "jest ./test/e2e/",
"test:prod": "yarn sandbox:prod && jest ./test/e2e/",
"sandbox:clean": "rm -rf ./test/e2e/sandbox/node_modules && mkdir -p ./test/e2e/sandbox/node_modules/.bin",
"sandbox:dev": "yarn sandbox:clean && ln -s ../../../../ ./test/e2e/sandbox/node_modules/runjs",
"sandbox:prod": "yarn sandbox:clean && (cd ./test/e2e/sandbox && yarn add runjs)",
"clean": "rm -rf node_modules && yarn sandbox:clean",
"precommit": "lint-staged"
"clean": "rm -rf node_modules && yarn sandbox:clean"
},
"lint-staged": {
"*.js": [
"eslint --fix",
"src/*.{ts,tsx}": [
"tslint --fix",
"git add"
]
},
Expand All @@ -47,45 +47,21 @@
"dependencies": {
"chalk": "2.3.0",
"lodash.padend": "4.6.1",
"microcli": "1.3.2",
"microcli": "1.3.3",
"omelette": "0.4.5"
},
"devDependencies": {
"babel-cli": "6.26.0",
"babel-eslint": "8.0.1",
"babel-plugin-transform-es2015-modules-commonjs": "6.26.0",
"babel-preset-flow": "6.23.0",
"eslint": "4.10.0",
"eslint-config-prettier": "2.7.0",
"eslint-plugin-flowtype": "2.39.1",
"eslint-plugin-prettier": "2.3.1",
"flow-bin": "0.58.0",
"husky": "0.14.3",
"jest": "22.4.2",
"lint-staged": "4.3.0",
"prettier": "1.7.4"
},
"babel": {
"plugins": [
"transform-es2015-modules-commonjs"
],
"presets": [
"flow"
]
},
"jest": {
"testEnvironment": "node",
"collectCoverageFrom": [
"src/**/*.js",
"bin/**/*.js"
],
"coverageReporters": [
"text"
],
"coverageThreshold": {
"global": {
"lines": 55
}
}
"@types/jest": "23.3.12",
"@types/lodash.padend": "4.6.4",
"@types/node": "10.12.18",
"husky": "1.3.1",
"jest": "23.6.0",
"lint-staged": "8.1.0",
"prettier": "1.15.3",
"ts-jest": "23.10.5",
"tslint": "5.12.1",
"tslint-config-prettier": "1.17.0",
"tslint-plugin-prettier": "2.0.1",
"typescript": "3.2.2"
}
}
29 changes: 14 additions & 15 deletions src/common.js → src/common.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
// @flow
import chalk from 'chalk'
import chalk from "chalk"

// Needed to use ES5 inheritance, because of issues with Error subclassing for Babel
export class RunJSError extends Error {
constructor(message: string) {
message = message && message.split('\n')[0] // assign only first line
message = message && message.split("\n")[0] // assign only first line
super(message)
}
}

export interface ILogger {
title(args: Array<any>): void;
log(args: Array<any>): void;
warning(args: Array<any>): void;
error(args: Array<any>): void;
title(...args: any[]): void
log(...args: any[]): void
warning(...args: any[]): void
error(...args: any[]): void
}

export class Logger implements ILogger {
title(...args: Array<any>) {
public title(...args: any[]) {
console.log(chalk.bold(...args))
}
log(...args: Array<any>) {
public log(...args: any[]) {
console.log(...args)
}
warning(...args: Array<any>) {
public warning(...args: any[]) {
console.warn(chalk.yellow(...args))
}
error(...args: Array<any>) {
public error(...args: any[]) {
console.error(chalk.red(...args))
}
}

export class SilentLogger implements ILogger {
title() {}
log() {}
warning() {}
error() {}
public title() {}
public log() {}
public warning() {}
public error() {}
}

export const logger = new Logger()
Loading

0 comments on commit 5d090ac

Please sign in to comment.