Skip to content

Commit

Permalink
style(format): run format
Browse files Browse the repository at this point in the history
  • Loading branch information
christianalfoni committed Jan 23, 2021
1 parent 232cf8c commit b8be804
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 94 deletions.
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"prepare": "npm run build",
"pretest": "babel-node test/utils/pretest.js",
"release": "npm run build && node ./dist/cli.js --release --no-parallel",
"test":
"mocha --require babel-register \"src/**/*.test.js\" \"test/integration/*.test.js\"",
"test": "mocha --require babel-register \"src/**/*.test.js\" \"test/integration/*.test.js\"",
"test:watch": "npm run test -- --watch"
},
"repository": {
Expand All @@ -29,7 +28,12 @@
},
"homepage": "https://github.com/cerebral/repo-cooker#readme",
"nyc": {
"exclude": ["node_modules", "dist", "test", "**/*.test.js"]
"exclude": [
"node_modules",
"dist",
"test",
"**/*.test.js"
]
},
"devDependencies": {
"babel-plugin-module-resolver": "^3.1.1",
Expand Down
12 changes: 10 additions & 2 deletions src/Cooker/providers/GitProvider/getHashListFromHash.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@ import { getHashListFromHash } from './getHashListFromHash'
it('should return hash list up to master', done => {
const hash = commits[0].hash
getHashListFromHash(config.path, hash).then(list => {
assert.deepEqual(list, commits.slice(1).map(commit => commit.hash), done)
assert.deepEqual(
list,
commits.slice(1).map(commit => commit.hash),
done
)
})
})

it('should return full history for Big Bang pseudo-hash', done => {
getHashListFromHash(config.path, 'Big Bang').then(list => {
assert.deepEqual(list, commits.map(c => c.hash), done)
assert.deepEqual(
list,
commits.map(c => c.hash),
done
)
})
})

Expand Down
23 changes: 11 additions & 12 deletions src/Cooker/providers/GitProvider/getLatestTagMatchingName.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ export function getLatestTagMatchingName(repoPath, regex) {
.sort((a, b) => (a > b ? -1 : 1))
.find(tagName => regex.test(tagName))
)
.then(
tagName =>
tagName
? nodegit.Reference.lookup(repo, `refs/tags/${tagName}`)
.then(ref => ref.peel(nodegit.Object.TYPE.COMMIT))
.then(ref => nodegit.Commit.lookup(repo, ref.id()))
.then(commit => ({
tag: tagName,
hash: commit.sha(),
date: commit.date().toJSON(),
}))
: null
.then(tagName =>
tagName
? nodegit.Reference.lookup(repo, `refs/tags/${tagName}`)
.then(ref => ref.peel(nodegit.Object.TYPE.COMMIT))
.then(ref => nodegit.Commit.lookup(repo, ref.id()))
.then(commit => ({
tag: tagName,
hash: commit.sha(),
date: commit.date().toJSON(),
}))
: null
)
)
}
17 changes: 8 additions & 9 deletions src/Cooker/providers/NpmProvider/runScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ export function runScript(config) {
const cwd = packagesPaths[packageName]
return getPackageInfo(packageName, cwd)
.then(info => (info.scripts || {})[scriptName])
.then(
exists =>
exists
? runCommand('npm', ['run', scriptName, ...args], {
cwd,
})
.then(output => ({ pass: true, output }))
.catch(error => ({ pass: false, error }))
: false
.then(exists =>
exists
? runCommand('npm', ['run', scriptName, ...args], {
cwd,
})
.then(output => ({ pass: true, output }))
.catch(error => ({ pass: false, error }))
: false
)
}
}
4 changes: 1 addition & 3 deletions src/Cooker/providers/PackageJsonProvider/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ export function getPackageInfo(name, path) {
if (info.name !== name) {
reject(
new Error(
`Invalid package.json (name entry '${
info.name
}' does not match package name '${name}').`
`Invalid package.json (name entry '${info.name}' does not match package name '${name}').`
)
)
} else {
Expand Down
7 changes: 2 additions & 5 deletions src/Cooker/providers/PackageJsonProvider/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ function getContent(path) {

function writeFile(path, data, options) {
return new Promise((resolve, reject) => {
fsWriteFile(
path,
data,
options || {},
err => (err ? reject(err) : resolve())
fsWriteFile(path, data, options || {}, err =>
err ? reject(err) : resolve()
)
})
}
Expand Down
11 changes: 6 additions & 5 deletions src/actions/evaluateNewVersionByPackage.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ export function evaluateNewVersionByPackage({
function resolve(packageName) {
// Bump version according to package dependencies
return Math.max(
...Object.keys(forwardGraph(relatedPackagesByPackage, [packageName])).map(
packageName =>
packageName in semverByPackage
? RTYPES.indexOf(semverByPackage[packageName])
: -1
...Object.keys(
forwardGraph(relatedPackagesByPackage, [packageName])
).map(packageName =>
packageName in semverByPackage
? RTYPES.indexOf(semverByPackage[packageName])
: -1
)
)
}
Expand Down
4 changes: 2 additions & 2 deletions src/actions/evaluateSemverByPackage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const TYPE_TO_SEMVER = { feat: 'minor', fix: 'patch' }

function getType(commits) {
const types = commits
.map(
commit => (commit.breaks.length ? 'major' : TYPE_TO_SEMVER[commit.type])
.map(commit =>
commit.breaks.length ? 'major' : TYPE_TO_SEMVER[commit.type]
)
.map(type => SEMVER_TYPES.indexOf(type))
const type = Math.max(...types, 0)
Expand Down
4 changes: 2 additions & 2 deletions src/actions/getLatestReleaseHash.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export function getLatestReleaseHash({ git }) {
return git
.getLatestTagMatchingName('release_')
.then(
tag => (tag ? { hash: tag.hash, tag: tag.tag } : { hash: 'Big Bang' })
.then(tag =>
tag ? { hash: tag.hash, tag: tag.tag } : { hash: 'Big Bang' }
)
}
9 changes: 4 additions & 5 deletions src/actions/publishUnderTemporaryNpmTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ export function publishUnderTemporaryNpmTag({
{}
),
}))
.then(
arg =>
config.dryRun
? arg
: new Promise(resolve => setTimeout(() => resolve(arg), 3000))
.then(arg =>
config.dryRun
? arg
: new Promise(resolve => setTimeout(() => resolve(arg), 3000))
)
)
}
79 changes: 37 additions & 42 deletions src/actions/releaseNotes/avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ function createNewVersionsTable(release) {
)
})
.map(packageName => {
return `| ${packageName} | ${
release.currentVersionByPackage[packageName]
} | ${release.newVersionByPackage[packageName]} |`
return `| ${packageName} | ${release.currentVersionByPackage[packageName]} | ${release.newVersionByPackage[packageName]} |`
})

if (!entries.length) {
Expand Down Expand Up @@ -67,14 +65,14 @@ function createChangeTable(type, release, typeHeaders) {
| package | summary | commit | issues | author | gravatar |
|:---|:---|:---|:---|:---|---|
${entries
.map(entry => {
return `| ${entry.packageName} | ${entry.summary} | ${
entry.hash
} | ${entry.issues.join(', ')} | ${entry.authorName} | ![${
entry.authorName
}](https://www.gravatar.com/avatar/${md5(entry.authorEmail)}?s=40) |`
})
.join('\n')}
.map(entry => {
return `| ${entry.packageName} | ${entry.summary} | ${
entry.hash
} | ${entry.issues.join(', ')} | ${entry.authorName} | ![${
entry.authorName
}](https://www.gravatar.com/avatar/${md5(entry.authorEmail)}?s=40) |`
})
.join('\n')}
`
}

Expand Down Expand Up @@ -118,16 +116,16 @@ function createBreakingTable(release) {
| package | summary | commit | issues | author | gravatar |
|:---|:---|:---|:---|:---|---|
${entries
.map(entry => {
return `| ${entry.packageName} | ${entry.summary} <ul>${entry.breaks
.map(text => `<li>*${text}*</li>`)
.join('')}</ul> | ${entry.hash} | ${entry.issues.join(', ')} | ${
entry.authorName
} | ![${entry.authorName}](https://www.gravatar.com/avatar/${md5(
entry.authorEmail
)}?s=40) |`
})
.join('\n')}
.map(entry => {
return `| ${entry.packageName} | ${entry.summary} <ul>${entry.breaks
.map(text => `<li>*${text}*</li>`)
.join('')}</ul> | ${entry.hash} | ${entry.issues.join(', ')} | ${
entry.authorName
} | ![${entry.authorName}](https://www.gravatar.com/avatar/${md5(
entry.authorEmail
)}?s=40) |`
})
.join('\n')}
`
}

Expand All @@ -140,24 +138,22 @@ function createOtherTable(release) {
| type | summary | commit | issues | author | gravatar |
|---|:---|:---|:---|:---|---|
${release.commitsWithoutPackage
.sort((commitA, commitB) => {
const typeA = (commitA.type || '').toUpperCase()
const typeB = (commitB.type || '').toUpperCase()
if (typeA < typeB) return -1
if (typeA > typeB) return 1
return 0
})
.map(entry => {
return `| ${entry.type} (${entry.scope || 'monorepo'}) | ${
entry.summary
} | ${entry.hash} | ${entry.issues.join(', ')} | ${
entry.author.name
} | ![${entry.author.email}](https://www.gravatar.com/avatar/${md5(
entry.author.email
)}?s=40) |`
})
.join('\n')}
.sort((commitA, commitB) => {
const typeA = (commitA.type || '').toUpperCase()
const typeB = (commitB.type || '').toUpperCase()
if (typeA < typeB) return -1
if (typeA > typeB) return 1
return 0
})
.map(entry => {
return `| ${entry.type} (${entry.scope || 'monorepo'}) | ${
entry.summary
} | ${entry.hash} | ${entry.issues.join(', ')} | ${entry.author.name} | ![${
entry.author.email
}](https://www.gravatar.com/avatar/${md5(entry.author.email)}?s=40) |`
})
.join('\n')}
`
}

Expand All @@ -166,9 +162,8 @@ export function avatarNotes(release, options) {
const breaking = Object.keys(release.summary).map(type =>
createBreakingTable(release)
)
const changes = Object.keys(typeHeaders).map(
type =>
release.summary[type] ? createChangeTable(type, release, typeHeaders) : ''
const changes = Object.keys(typeHeaders).map(type =>
release.summary[type] ? createChangeTable(type, release, typeHeaders) : ''
)

const other = createOtherTable(release)
Expand Down
4 changes: 2 additions & 2 deletions src/actions/writeVersionsToPackages.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ function updateField(
dependency in newVersionByPackage
? `${newVersionByPackage[dependency]}`
: dependency in currentVersionByPackage
? `${currentVersionByPackage[dependency]}`
: currentDeps[dependency]
? `${currentVersionByPackage[dependency]}`
: currentDeps[dependency]

return dependencies
}, {}),
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/createConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export function createConfig(options) {
options.dryRun === true
? logCommand
: typeof options.dryRun === 'function'
? options.dryRun
: execCommand
? options.dryRun
: execCommand

return Object.assign({}, options, { packagesPaths, runCommand })
}

0 comments on commit b8be804

Please sign in to comment.