Skip to content

Commit

Permalink
Add merge conflict assistance (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv committed Mar 30, 2020
1 parent d1eef2a commit 9b56091
Show file tree
Hide file tree
Showing 19 changed files with 582 additions and 188 deletions.
8 changes: 5 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
module.exports = {
ignorePatterns: ['dist/', 'node_modules/'],
plugins: ['@typescript-eslint'],
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
extends: [
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:prettier/recommended' // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
rules: {
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-object-literal-type-assertion': 'off',
'@typescript-eslint/no-use-before-define': 'off'
}
'@typescript-eslint/no-use-before-define': 'off',
},
};
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"request": "launch",
"name": "Start backport",
"program": "${workspaceRoot}/src/index.ts",
"runtimeArgs": ["-r", "ts-node/register"],
"args": ["--branch=6.1", "--upstream=sqren/backport-demo"],
"runtimeArgs": ["-r", "ts-node/register/transpile-only"],
"args": ["--branch=6.3", "--upstream=sqren/backport-demo"],
"console": "integratedTerminal"
},
{
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"scripts": {
"cover": "jest --coverage",
"format": "prettier \"./{src,test}/**/*.ts\" --write",
"lint": "tsc --project ./src/test/tsconfig.json && eslint ./src/**/*.ts",
"lint": "tsc --project ./src/test/tsconfig.json && eslint './**/*.{ts,js}'",
"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)",
Expand Down Expand Up @@ -70,6 +70,7 @@
"inquirer": "^7.1.0",
"lodash.isempty": "^4.4.0",
"lodash.isstring": "^4.0.1",
"lodash.uniq": "^4.5.0",
"make-dir": "^3.0.2",
"ora": "^4.0.3",
"strip-json-comments": "^3.0.1",
Expand All @@ -84,6 +85,7 @@
"@types/lodash": "^4.14.144",
"@types/lodash.isempty": "^4.4.6",
"@types/lodash.isstring": "^4.0.6",
"@types/lodash.uniq": "^4.5.6",
"@types/node": "^12.12.31",
"@types/yargs": "^15.0.4",
"@types/yargs-parser": "^15.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/options/config/config.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PromiseReturnType } from '../../types/commons';
import { PromiseReturnType } from '../../types/PromiseReturnType';
import { getOptionsFromConfigFiles } from './config';

describe('getOptionsFromConfigFiles', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/options/config/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import isString from 'lodash.isstring';
import { Config } from '../../types/Config';
import { PromiseReturnType } from '../../types/commons';
import { PromiseReturnType } from '../../types/PromiseReturnType';
import { getGlobalConfig } from './globalConfig';
import { getProjectConfig } from './projectConfig';

Expand Down
2 changes: 1 addition & 1 deletion src/options/config/globalConfig.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as fs from '../../services/fs-promisified';
import { PromiseReturnType } from '../../types/commons';
import { PromiseReturnType } from '../../types/PromiseReturnType';
import { getGlobalConfig, maybeCreateGlobalConfig } from './globalConfig';
import makeDir from 'make-dir';

Expand Down
2 changes: 1 addition & 1 deletion src/options/config/projectConfig.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import findUp from 'find-up';
import * as fs from '../../services/fs-promisified';
import { PromiseReturnType } from '../../types/commons';
import { PromiseReturnType } from '../../types/PromiseReturnType';
import { getProjectConfig } from './projectConfig';

describe('getProjectConfig', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/options/options.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import isEmpty from 'lodash.isempty';
import { HandledError } from '../services/HandledError';
import { PromiseReturnType } from '../types/commons';
import { PromiseReturnType } from '../types/PromiseReturnType';
import { getGlobalConfigPath } from '../services/env';
import { getOptionsFromCliArgs, OptionsFromCliArgs } from './cliArgs';
import { getOptionsFromConfigFiles } from './config/config';
Expand Down
2 changes: 1 addition & 1 deletion src/runWithArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function runWithArgs(args: string[]) {

try {
const options = await getOptions(args);
return await runWithOptions(options);
await runWithOptions(options);
} catch (e) {
if (e instanceof HandledError) {
console.error(e.message);
Expand Down
9 changes: 7 additions & 2 deletions src/runWithOptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { BackportOptions } from './options/options';
import { commitsWithPullRequestsMock } from './services/github/mocks/commitsByAuthorMock';
import { runWithOptions } from './runWithOptions';
import * as childProcess from './services/child-process-promisified';
import { PromiseReturnType } from './types/PromiseReturnType';

type ExecReturnType = PromiseReturnType<typeof childProcess.exec>;

describe('runWithOptions', () => {
let rpcExecMock: jest.SpyInstance;
Expand Down Expand Up @@ -54,8 +57,10 @@ describe('runWithOptions', () => {
verbose: false,
};

rpcExecMock = (childProcess.exec as any) as jest.SpyInstance;
rpcExecOriginalMock = (childProcess.execAsCallback as any) as jest.SpyInstance;
rpcExecMock = jest
.spyOn(childProcess, 'exec')
.mockResolvedValue({ stdout: 'success' } as ExecReturnType);
rpcExecOriginalMock = jest.spyOn(childProcess, 'execAsCallback');

jest.spyOn(fs, 'writeFile').mockResolvedValue(undefined);

Expand Down
26 changes: 14 additions & 12 deletions src/scripts/postinstall.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,31 @@ import * as globalConfig from '../options/config/globalConfig';
import { postinstall } from './postinstall';

describe('postinstall', () => {
beforeEach(() => {
jest.clearAllMocks();
});

it("should create global config if it doesn't exist", async () => {
const consoleSpy = spyOn(console, 'log');
const spy = spyOn(
globalConfig,
'maybeCreateGlobalConfigAndFolder'
).and.returnValue(true);
const consoleSpy = jest.spyOn(console, 'log');
const maybeCreateGlobalConfigAndFolderSpy = jest
.spyOn(globalConfig, 'maybeCreateGlobalConfigAndFolder')
.mockResolvedValue(true);

await postinstall();
expect(spy).toBeCalledTimes(1);
expect(maybeCreateGlobalConfigAndFolderSpy).toBeCalledTimes(1);
expect(consoleSpy).toBeCalledWith(
'Global config successfully created in /myHomeDir/.backport/config.json'
);
});

it('should not create global config if it already exists', async () => {
const consoleSpy = spyOn(console, 'log');
const spy = spyOn(
globalConfig,
'maybeCreateGlobalConfigAndFolder'
).and.returnValue(false);
const consoleSpy = jest.spyOn(console, 'log');
const maybeCreateGlobalConfigAndFolderSpy = jest
.spyOn(globalConfig, 'maybeCreateGlobalConfigAndFolder')
.mockResolvedValue(false);

await postinstall();
expect(spy).toBeCalledTimes(1);
expect(maybeCreateGlobalConfigAndFolderSpy).toBeCalledTimes(1);
expect(consoleSpy).toBeCalledTimes(0);
});
});
Loading

0 comments on commit 9b56091

Please sign in to comment.