Skip to content

Commit

Permalink
Merge 189ee8f into ed4ed57
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv committed Jul 18, 2019
2 parents ed4ed57 + 189ee8f commit edf0ebf
Show file tree
Hide file tree
Showing 91 changed files with 3,808 additions and 2,362 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off'
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/no-explicit-any': 'off'
}
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/dist
/yarn-error.log
.DS_Store
/test/integration/mock-environment
13 changes: 11 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
os:
- linux
- osx
addons:
apt:
sources:
- ppa:git-core/ppa
packages:
- git
language: node_js
node_js:
- "8"
- "10"
- '8'
- '10'
cache: yarn
before_script:
- yarn
Expand Down
9 changes: 7 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@
"name": "Jest",
"type": "node",
"request": "launch",
"args": ["--runInBand", "${file}"],
"args": [
"--runInBand",
"${file}",
"--config",
"${workspaceRoot}/jest.unit.config.js"
],
"port": 9229,
"address": "localhost",
"stopOnEntry": false,
"runtimeExecutable": null,
"sourceMaps": true,
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
"program": "${workspaceRoot}/node_modules/.bin/jest",
"runtimeArgs": ["--inspect-brk"],
"cwd": "${workspaceRoot}"
}
Expand Down
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ yarn tsc
node dist/index.js --branch 6.1 --upstream sqren/backport-demo --all
```

**Run `backport` CLI globally**

```
yarn global remove backport
npm -g uninstall backport
yarn unlink backport
yarn link
sudo chmod +x dist/index.js
yarn tsc --watch
```

You can now use `backport` command anywhere, and it'll point to the development version.

### Debug

**Run tests**
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ The above commands will start an interactive prompt. You can use the `arrow keys
| --accessToken | Github access token | | string |
| --all | Show commits from other than me | false | boolean |
| --apiHostname | Hostname for the Github API | api.github.com | string |
| --author | Filter commits by author | _Current user_ | string |
| --branch | Branch to backport to | | string |
| --commitsCount | Number of commits to choose from | 10 | number |
| --gitHostname | Hostname for Git remotes | github.com | string |
| --labels | Pull request labels | | string |
| --multiple | Select multiple branches and/or commits | false | boolean |
Expand Down
12 changes: 0 additions & 12 deletions __mocks__/child_process.js

This file was deleted.

14 changes: 0 additions & 14 deletions __mocks__/find-up.js

This file was deleted.

28 changes: 0 additions & 28 deletions __mocks__/fs.js

This file was deleted.

5 changes: 0 additions & 5 deletions __mocks__/mkdirp.js

This file was deleted.

10 changes: 0 additions & 10 deletions __mocks__/ora.js

This file was deleted.

5 changes: 0 additions & 5 deletions __mocks__/os.js

This file was deleted.

3 changes: 0 additions & 3 deletions __mocks__/rimraf.js

This file was deleted.

6 changes: 6 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ CLI: `--prTitle "My PR Title"`
Pull request description.
Will be added to the end of the pull request description.

For people who often need to add the same description to PRs they can create a bash alias:

```sh
alias backport-skip-ci='backport --prDescription "[skip-ci]"'
```

CLI: `--prDescription "skip-ci"`

#### `gitHostname`
Expand Down
13 changes: 13 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
setupFiles: ['./test/unit/automatic-mocks.ts'],
transform: {
'^.+\\.tsx?$': 'ts-jest'
},
testRegex: 'test/(unit|integration)/.*test.ts$',
moduleFileExtensions: ['ts', 'js', 'json'],
globals: {
'ts-jest': {
diagnostics: false
}
}
};
78 changes: 28 additions & 50 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
"license": "MIT",
"scripts": {
"cover": "jest --coverage",
"format": "prettier \"./src/**/*.ts\" --write",
"lint": "tsc -p ./test/tsconfig.json && eslint ./src/**/*.ts",
"format": "prettier \"./{src,test}/**/*.ts\" --write",
"lint": "tsc --project ./test/tsconfig.json && eslint ./src/**/*.ts ./test/**/*.ts",
"postinstall": "test -f ./dist/scripts/runPostinstall.js && node ./dist/scripts/runPostinstall.js || echo 'Dist folder missing'",
"prepublishOnly": "tsc",
"publish-dry-run": "tar -tf $(npm pack)",
"test": "jest",
"test": "jest --config ./jest.config.js",
"start": "ts-node --transpile-only ./src/index.ts"
},
"lint-staged": {
Expand All @@ -55,26 +55,6 @@
"type": "git",
"url": "git+https://github.com/sqren/backport.git"
},
"jest": {
"testURL": "http://localhost/",
"setupFiles": [
"./test/setup.js"
],
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "test.ts$",
"moduleFileExtensions": [
"ts",
"js",
"json"
],
"globals": {
"ts-jest": {
"diagnostics": false
}
}
},
"greenkeeper": {
"ignore": [
"@types/node"
Expand All @@ -84,49 +64,47 @@
"node": ">=8.0.0"
},
"dependencies": {
"axios": "^0.18.0",
"find-up": "^3.0.0",
"inquirer": "^6.3.1",
"axios": "^0.19.0",
"del": "^5.0.0",
"find-up": "^4.1.0",
"inquirer": "^6.5.0",
"lodash.flatten": "^4.4.0",
"lodash.get": "^4.4.2",
"lodash.isempty": "^4.4.0",
"lodash.isstring": "^4.0.1",
"mkdirp": "^0.5.1",
"make-dir": "^3.0.0",
"ora": "^3.4.0",
"rimraf": "^2.6.3",
"strip-json-comments": "^3.0.0",
"yargs": "^13.2.2"
"strip-json-comments": "^3.0.1",
"yargs": "^13.3.0"
},
"devDependencies": {
"@types/core-js": "^2.5.0",
"@types/find-up": "^2.1.1",
"@types/inquirer": "^6.0.0",
"@types/jest": "^24.0.11",
"@types/core-js": "^2.5.2",
"@types/find-up": "^4.0.0",
"@types/inquirer": "^6.0.3",
"@types/jest": "^24.0.15",
"@types/lodash.flatten": "^4.4.6",
"@types/lodash.get": "^4.4.6",
"@types/lodash.isempty": "^4.4.6",
"@types/lodash.isstring": "^4.0.6",
"@types/lodash.last": "^3.0.6",
"@types/mkdirp": "^0.5.2",
"@types/nock": "^10.0.0",
"@types/nock": "^10.0.3",
"@types/node": "^10.14.4",
"@types/rimraf": "^2.0.2",
"@types/strip-json-comments": "^0.0.30",
"@types/strip-json-comments": "^3.0.0",
"@types/yargs": "^13.0.0",
"@typescript-eslint/eslint-plugin": "^1.7.0",
"@typescript-eslint/parser": "^1.7.0",
"axios-mock-adapter": "^1.16.0",
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.1.0",
"eslint-plugin-prettier": "^3.0.1",
"husky": "^2.0.0",
"jest": "^24.7.1",
"lint-staged": "^8.1.5",
"@typescript-eslint/eslint-plugin": "^1.12.0",
"@typescript-eslint/parser": "^1.12.0",
"eslint": "^6.0.1",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-import": "^2.18.0",
"eslint-plugin-prettier": "^3.1.0",
"husky": "^3.0.0",
"jest": "^24.8.0",
"lint-staged": "^9.2.0",
"lodash.last": "^3.0.0",
"nock": "^10.0.6",
"prettier": "^1.17.0",
"prettier": "^1.18.2",
"ts-jest": "^24.0.2",
"ts-node": "^8.1.0",
"typescript": "^3.4.5"
"ts-node": "^8.3.0",
"typescript": "^3.5.3"
}
}
4 changes: 0 additions & 4 deletions src/__mocks__/logger.js

This file was deleted.

5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env node

import { initSteps } from './steps/steps';
import { getOptions } from './options/options';
import { initSteps } from './steps/steps';

async function init() {
try {
const options = await getOptions(process.argv);
const args = process.argv.slice(2);
const options = await getOptions(args);
return await initSteps(options);
} catch (e) {
if (e.name === 'HandledError') {
Expand Down
14 changes: 13 additions & 1 deletion src/options/cliArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { OptionsFromConfigFiles } from './config/config';
export type OptionsFromCliArgs = ReturnType<typeof getOptionsFromCliArgs>;
export function getOptionsFromCliArgs(
configOptions: OptionsFromConfigFiles,
argv: typeof process.argv
argv: string[]
) {
const cliArgs = yargs(argv)
.usage('$0 [args]')
Expand All @@ -24,13 +24,23 @@ export function getOptionsFromCliArgs(
description: 'Hostname for the Github API',
type: 'string'
})
.option('author', {
default: configOptions.author,
description: 'Show commits by specific author',
type: 'string'
})
.option('branches', {
default: [] as string[],
description: 'Branch(es) to backport to',
type: 'array',
alias: 'branch',
string: true // ensure `6.0` is not coerced to `6`
})
.option('commitsCount', {
default: configOptions.commitsCount,
description: 'Number of commits to choose from',
type: 'number'
})
.option('gitHostname', {
default: configOptions.gitHostname,
description: 'Hostname for Github',
Expand Down Expand Up @@ -89,6 +99,8 @@ export function getOptionsFromCliArgs(
accessToken: cliArgs.accessToken,
all: cliArgs.all,
apiHostname: cliArgs.apiHostname,
author: cliArgs.author,
commitsCount: cliArgs.commitsCount,
branchChoices: configOptions.branchChoices,
branches: cliArgs.branches,
gitHostname: cliArgs.gitHostname,
Expand Down
6 changes: 3 additions & 3 deletions src/options/config/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import isString from 'lodash.isstring';
import { Config } from '../../types/Config';
import { PromiseReturnType } from '../../types/commons';
import { getGlobalConfig } from './globalConfig';
import { getProjectConfig } from './projectConfig';
import { PromiseReturnType } from '../../types/commons';
import { Config } from '../../types/Config';
import isString from 'lodash.isstring';

export type OptionsFromConfigFiles = PromiseReturnType<
typeof getOptionsFromConfigFiles
Expand Down

0 comments on commit edf0ebf

Please sign in to comment.