Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update dependency prettier to v2 #732

Merged
merged 2 commits into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/shipjs-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"jest": "25.2.4",
"jest-watch-typeahead": "0.5.0",
"json": "9.0.6",
"prettier": "1.19.1",
"prettier": "2.0.2",
"rollup": "2.3.2",
"rollup-plugin-commonjs": "10.1.0",
"rollup-plugin-node-resolve": "5.2.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import path from 'path';

const baseConfig = expect.objectContaining({});

const d = dirName => path.resolve(__dirname, dirName);
const d = (dirName) => path.resolve(__dirname, dirName);

describe('loadConfig', () => {
it('does not throw when there is no config', () => {
Expand Down
4 changes: 1 addition & 3 deletions packages/shipjs-lib/src/lib/git/getCommitBodies.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@ import silentExec from '../shell/silentExec';

export default function getBodies(revisionRange, dir) {
const cmd = `git log ${revisionRange} --pretty=format:%b`;
return silentExec(cmd, { dir, ignoreError: true })
.toString()
.trim();
return silentExec(cmd, { dir, ignoreError: true }).toString().trim();
}
4 changes: 1 addition & 3 deletions packages/shipjs-lib/src/lib/git/getCommitTitles.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@ import silentExec from '../shell/silentExec';

export default function getCommitTitles(revisionRange, dir) {
const cmd = `git log ${revisionRange} --pretty=format:%s`;
return silentExec(cmd, { dir, ignoreError: true })
.toString()
.trim();
return silentExec(cmd, { dir, ignoreError: true }).toString().trim();
}
4 changes: 1 addition & 3 deletions packages/shipjs-lib/src/lib/git/getLatestCommitHash.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import silentExec from '../shell/silentExec';

export default function getLatestCommitHash(dir = '.') {
return silentExec('git log -1 --pretty=format:%h', { dir })
.toString()
.trim();
return silentExec('git log -1 --pretty=format:%h', { dir }).toString().trim();
}
4 changes: 1 addition & 3 deletions packages/shipjs-lib/src/lib/git/getLatestCommitMessage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import silentExec from '../shell/silentExec';

export default function getLatestCommitMessage(dir = '.') {
return silentExec('git log -1 --pretty=format:%B', { dir })
.toString()
.trim();
return silentExec('git log -1 --pretty=format:%B', { dir }).toString().trim();
}
10 changes: 4 additions & 6 deletions packages/shipjs-lib/src/lib/git/getRemoteBranches.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ $ git branch -r
*/

export default function getRemoteBranches(dir = '.') {
const remote = silentExec('git remote', { dir })
.toString()
.trim();
const remote = silentExec('git remote', { dir }).toString().trim();
return silentExec('git branch -r', { dir })
.toString()
.trim()
.split('\n')
.map(line => line.trim())
.filter(line => !line.includes(' -> '))
.map(line => line.slice(remote.length + 1));
.map((line) => line.trim())
.filter((line) => !line.includes(' -> '))
.map((line) => line.slice(remote.length + 1));
}
6 changes: 1 addition & 5 deletions packages/shipjs-lib/src/lib/git/hasTag.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import silentExec from '../shell/silentExec';

export default function hasTag(tag, dir = '.') {
return (
silentExec(`git tag -l ${tag}`, { dir })
.toString()
.trim() === tag
);
return silentExec(`git tag -l ${tag}`, { dir }).toString().trim() === tag;
}
6 changes: 1 addition & 5 deletions packages/shipjs-lib/src/lib/git/isWorkingTreeClean.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import silentExec from '../shell/silentExec';

export default function isWorkingTreeClean(dir = '.') {
return (
silentExec('git status --porcelain', { dir })
.toString()
.trim() === ''
);
return silentExec('git status --porcelain', { dir }).toString().trim() === '';
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe('getNextVersionFromCommitMessages', () => {

it('increases version with postfixes', () => {
const list = ['alpha', 'beta', 'rc', 'canary', 'whatever'];
list.forEach(tag => {
list.forEach((tag) => {
const version = `0.0.1-${tag}.123`;
// Even if there is a `feat` commit, it still increases the number only.
const titles = `fix: abc
Expand Down
16 changes: 8 additions & 8 deletions packages/shipjs-lib/src/lib/util/expandPackageList.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import { resolve, join, sep } from 'path';
import { statSync, readdirSync, existsSync } from 'fs';

const isDirectory = dir => statSync(dir).isDirectory();
const getDirectories = dir =>
const isDirectory = (dir) => statSync(dir).isDirectory();
const getDirectories = (dir) =>
readdirSync(dir)
.map(name => join(dir, name))
.map((name) => join(dir, name))
.filter(isDirectory);
const hasPackageJson = dir => existsSync(`${dir}/package.json`);
const flatten = arr => arr.reduce((acc, item) => acc.concat(item), []);
const hasPackageJson = (dir) => existsSync(`${dir}/package.json`);
const flatten = (arr) => arr.reduce((acc, item) => acc.concat(item), []);

export default function expandPackageList(list, dir = '.') {
return flatten(
list.map(item => {
list.map((item) => {
const partIndex = item
.split(sep)
.findIndex(part => part.startsWith('@(') && part.endsWith(')'));
.findIndex((part) => part.startsWith('@(') && part.endsWith(')'));
if (partIndex !== -1) {
const parts = item.split(sep);
const part = parts[partIndex];
const newList = part
.slice(2, part.length - 1)
.split('|')
.map(subPart => {
.map((subPart) => {
const newParts = [...parts];
newParts[partIndex] = subPart;
return newParts.join(sep);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GIT_COMMIT_PREFIX_PATCH, GIT_COMMIT_PREFIX_MINOR } from '../const';
export default function getCommitNumbersPerType(commitTitles) {
const ignoredMessages = [];
const numbers = {};
commitTitles.split('\n').forEach(rawTitle => {
commitTitles.split('\n').forEach((rawTitle) => {
const title = rawTitle.trim();
if (!title) {
return;
Expand Down
6 changes: 3 additions & 3 deletions packages/shipjs-lib/src/lib/util/getNextVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ export function getNextVersionFromCommitMessages(version, titles, bodies) {
bodies
.toUpperCase()
.split('\n')
.some(line => line.startsWith(GIT_COMMIT_BREAKING_CHANGE))
.some((line) => line.startsWith(GIT_COMMIT_BREAKING_CHANGE))
) {
return { version: inc(version, 'major') };
}
const { numbers, ignoredMessages } = getCommitNumbersPerType(titles);
const minor = Array.from(GIT_COMMIT_PREFIX_MINOR).some(
prefix => numbers[prefix] > 0
(prefix) => numbers[prefix] > 0
);
const patch = Array.from(GIT_COMMIT_PREFIX_PATCH).some(
prefix => numbers[prefix] > 0
(prefix) => numbers[prefix] > 0
);
if (minor) {
return { version: inc(version, 'minor'), ignoredMessages };
Expand Down
2 changes: 1 addition & 1 deletion packages/shipjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"mime-types": "^2.1.25",
"mkdirp": "^1.0.0",
"open": "^7.0.0",
"prettier": "^1.18.2",
"prettier": "^2.0.0",
"serialize-javascript": "^3.0.0",
"shell-quote": "^1.7.2",
"shipjs-lib": "0.18.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/shipjs/src/flow/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async function setup({ help = false, dir = '.', dryRun = false }) {

print('');
print(success('🎉 FINISHED'));
outputs.forEach(printMessage => {
outputs.forEach((printMessage) => {
if (printMessage && typeof printMessage === 'function') {
print('');
printMessage();
Expand Down
2 changes: 1 addition & 1 deletion packages/shipjs/src/helper/getBranchNameToMergeBack.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function getBranchNameToMergeBack({
return currentBranch;
} else {
return Object.entries(mergeStrategy.toReleaseBranch).find(
entry => entry[1] === currentBranch
(entry) => entry[1] === currentBranch
)[0];
}
}
4 changes: 2 additions & 2 deletions packages/shipjs/src/helper/gitPush.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function gitPush({ remote, refs, dir, dryRun }) {
printCommand: false,
});
}
refs.forEach(ref => {
refs.forEach((ref) => {
run({ command: `git push origin-with-token ${ref}`, dir, dryRun });
});
run({
Expand All @@ -29,7 +29,7 @@ export default function gitPush({ remote, refs, dir, dryRun }) {
printCommand: false,
});
} else {
refs.forEach(ref => {
refs.forEach((ref) => {
run({
command: `git push ${remote} ${ref}`,
dir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('createPullRequest', () => {
const create = jest.fn().mockImplementationOnce(() => ({
data: { number: 13, html_url: 'https://github.com/my/repo/pull/13' }, // eslint-disable-line camelcase
}));
Octokit.mockImplementationOnce(function() {
Octokit.mockImplementationOnce(function () {
this.pulls = { create, createReviewRequest: jest.fn() };
});
const { pullRequestUrl } = await createPullRequest(getDefaultParams());
Expand Down
2 changes: 1 addition & 1 deletion packages/shipjs/src/step/prepare/createPullRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function getPublishCommandInStr({
const { packagesToPublish } = monorepo;
const packageList = expandPackageList(packagesToPublish, dir);
return packageList
.map(packageDir => {
.map((packageDir) => {
const dirName = getPackageDirName(packageDir, dir);
const command = getPublishCommand({
isYarn,
Expand Down
2 changes: 1 addition & 1 deletion packages/shipjs/src/step/prepare/getNextVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default ({ config, revisionRange, currentVersion, dir }) =>
'The following commit messages out of convention are ignored:'
)
);
ignoredMessages.forEach(message => print(` ${message}`));
ignoredMessages.forEach((message) => print(` ${message}`));
}
nextVersion = version;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/shipjs/src/step/prepare/printHelp.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { bold, underline } from '../../color';

export default () =>
runStep({}, () => {
const indent = line => `\t${line}`;
const indent = (line) => `\t${line}`;

const help = `--help`;
const dir = `--dir ${underline('PATH')}`;
Expand All @@ -13,7 +13,7 @@ export default () =>
const noBrowse = `--no-browse`;
const commitFrom = `--commit-from ${underline('SHA')}`;
const all = [help, dir, yes, dryRun, noBrowse, commitFrom]
.map(x => `[${x}]`)
.map((x) => `[${x}]`)
.join(' ');

const messages = [
Expand Down
4 changes: 2 additions & 2 deletions packages/shipjs/src/step/prepare/updateVersionMonorepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default async ({ config, nextVersion, releaseType, dir, dryRun }) =>
print(`Your configuration: ${JSON.stringify(packagesToBump)}`);
print(`Main version file: ${mainVersionFile}`);
print(`Actual packages to bump:`);
packageList.forEach(packageDir =>
packageList.forEach((packageDir) =>
print(`-> ${info(`${packageDir}/package.json`)}`)
);
if (versionUpdated) {
Expand All @@ -26,7 +26,7 @@ export default async ({ config, nextVersion, releaseType, dir, dryRun }) =>
}

updateVersion({ nextVersion, dir, fileName: mainVersionFile });
packageList.forEach(packageDir => {
packageList.forEach((packageDir) => {
print(`-> ${info(`${packageDir}/package.json`)}`);
updateVersion({ nextVersion, dir: packageDir });
});
Expand Down
2 changes: 1 addition & 1 deletion packages/shipjs/src/step/prepare/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function printValidationError({ result, baseBranches }) {
};

print(error('Failed to prepare a release for the following reason(s).'));
result.forEach(reason => {
result.forEach((reason) => {
print(info(` - ${messageMap[reason]}`));
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('createGitHubRelease', () => {
},
}));

Octokit.mockImplementation(function() {
Octokit.mockImplementation(function () {
this.repos = { createRelease, uploadReleaseAsset };
});

Expand All @@ -47,7 +47,7 @@ describe('createGitHubRelease', () => {
fs.readFileSync = jest.fn();
fs.statSync = jest.fn().mockImplementation(() => ({ size: 1024 }));
mime.lookup.mockImplementation(() => 'application/zip');
globby.mockImplementation(path => Promise.resolve([path]));
globby.mockImplementation((path) => Promise.resolve([path]));
});

it('works without assets', async () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/shipjs/src/step/release/printHelp.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { bold, underline } from '../../color';

export default () =>
runStep({}, () => {
const indent = line => `\t${line}`;
const indent = (line) => `\t${line}`;
const help = `--help`;
const dir = `--dir ${underline('PATH')}`;
const dryRun = `--dry-run`;
const all = [help, dir, dryRun].map(x => `[${x}]`).join(' ');
const all = [help, dir, dryRun].map((x) => `[${x}]`).join(' ');

const messages = [
bold('NAME'),
Expand Down
2 changes: 1 addition & 1 deletion packages/shipjs/src/step/release/runPublish.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default ({ isYarn, config, releaseTag: tag, dir, dryRun }) =>
if (monorepo) {
const { packagesToPublish } = monorepo;
const packageList = expandPackageList(packagesToPublish, dir);
packageList.forEach(packageDir => {
packageList.forEach((packageDir) => {
const command = getPublishCommand({
isYarn,
publishCommand,
Expand Down
2 changes: 1 addition & 1 deletion packages/shipjs/src/step/setup/CI/addGitHubActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default ({
},
].filter(Boolean);

return () => log.forEach(printResult => printResult());
return () => log.forEach((printResult) => printResult());
}
);

Expand Down
6 changes: 3 additions & 3 deletions packages/shipjs/src/step/setup/askQuestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ export default async ({ dir }) =>

async function askBranches(dir) {
let branches = getRemoteBranches(dir);
let baseBranchCandidate = ['develop', 'dev', 'master'].find(item =>
let baseBranchCandidate = ['develop', 'dev', 'master'].find((item) =>
branches.includes(item)
);
let releaseBranchCandidate = ['releases', 'release', 'master'].find(item =>
let releaseBranchCandidate = ['releases', 'release', 'master'].find((item) =>
branches.includes(item)
);
if (branches.length === 0) {
Expand Down Expand Up @@ -72,7 +72,7 @@ async function askBranches(dir) {
}

async function askCI() {
const choices = integrations.map(config => config.name);
const choices = integrations.map((config) => config.name);
const { ciTypeText } = await inquirer.prompt([
{
type: 'list',
Expand Down
2 changes: 1 addition & 1 deletion packages/shipjs/src/step/setup/formatMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const formatMessage = (message, description = '') =>
...description
.trim()
.split('\n')
.map(line => ` ${reset(grey(line.trim()))}`),
.map((line) => ` ${reset(grey(line.trim()))}`),
].join('\n');

export default formatMessage;
4 changes: 2 additions & 2 deletions packages/shipjs/src/step/setup/printHelp.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { bold, underline } from '../../color';

export default () =>
runStep({}, () => {
const indent = line => `\t${line}`;
const indent = (line) => `\t${line}`;
const help = `--help`;
const dir = `--dir ${underline('PATH')}`;
const dryRun = `--dry-run`;
const all = [help, dir, dryRun].map(x => `[${x}]`).join(' ');
const all = [help, dir, dryRun].map((x) => `[${x}]`).join(' ');

const messages = [
bold('NAME'),
Expand Down
4 changes: 2 additions & 2 deletions packages/shipjs/src/util/indentedPrint.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import print from './print';

const makeSpaces = num => ' '.repeat(num);
const indentPrint = indent => (...args) => print(makeSpaces(indent), ...args);
const makeSpaces = (num) => ' '.repeat(num);
const indentPrint = (indent) => (...args) => print(makeSpaces(indent), ...args);
const indentedPrint = indentPrint(2);

export default indentedPrint;
2 changes: 1 addition & 1 deletion packages/shipjs/tests/util/mockColor.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function mockColor(colorFn) {
colorFn.mockImplementation(str => str);
colorFn.mockImplementation((str) => str);
}
Loading