-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Florian Pichler
committed
Sep 5, 2018
1 parent
1442f4b
commit 8a6a2e9
Showing
34 changed files
with
3,575 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[{package.json,*.{yaml,yml},bower.json}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.hbs] | ||
insert_final_newline = false | ||
|
||
[*.{diff,md}] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# editorconfig.org | ||
|
||
# Disabled because eslint-plugin-prettier chokes on this, | ||
# because ember-cli-eslint is naive | ||
# root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[{package.json,config/*.json}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.hbs] | ||
insert_final_newline = false | ||
|
||
[*.{diff,md}] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{yaml,yml}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[.prettierrc] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
extends: 'anfema/node', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
.workrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
*.hbs | ||
*.yaml | ||
*.yml | ||
.editorconfig | ||
.eslintignore | ||
.git | ||
.gitignore | ||
.ignore | ||
.stylelintignore | ||
dist | ||
node_modules | ||
package.json | ||
public | ||
tmp | ||
vendor | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
bracketSpacing: true | ||
jsxBracketSameLine: false | ||
printWidth: 100 | ||
semi: true | ||
singleQuote: true | ||
tabWidth: 4 | ||
trailingComma: es5 | ||
useTabs: true | ||
overrides: | ||
- | ||
files: '{.watchmanconfig,.ember-cli,config/*.json}' | ||
options: | ||
parser: json | ||
- | ||
files: '*.yaml' | ||
options: | ||
parser: yaml | ||
useTabs: false | ||
tabWidth: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env node | ||
|
||
require('../index.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const createChangelog = require('./src/create-changelog.js'); | ||
const { owner, repo } = require('./lib/git/github-info.js'); | ||
|
||
(async () => { | ||
await createChangelog({ | ||
tagFrom: '1.0.0', | ||
owner, | ||
repo, | ||
changelog: { | ||
'New Features & Improvements': ['Enhancement', 'Feature'], | ||
'Behind the scenes': ['Refactor'], | ||
'Fixed Bugs': ['Bug'], | ||
'Other changes': ['Chore'], | ||
}, | ||
}); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const chalk = require('chalk'); | ||
|
||
const config = require('./src/config.js'); | ||
const githubInfo = require('./lib/git/github-info.js'); | ||
const program = require('./src/program.js'); | ||
const questions = require('./src/questions.js'); | ||
const settings = require('./src/settings.js'); | ||
|
||
const createBranch = require('./src/create-branch.js'); | ||
const createChangelog = require('./src/create-changelog.js'); | ||
const createLabels = require('./src/create-labels.js'); | ||
const deleteLabels = require('./src/delete-labels.js'); | ||
|
||
(async () => { | ||
try { | ||
const answers = await questions(githubInfo, program); | ||
const results = Object.assign({}, config.store, settings, githubInfo, answers); | ||
|
||
switch (results.task) { | ||
case 'branch': | ||
await createBranch(results); | ||
|
||
break; | ||
|
||
case 'pr': | ||
console.log(chalk.blue(`Pull Requests are not implemented yet`)); | ||
|
||
break; | ||
|
||
case 'changelog': | ||
await createChangelog(results); | ||
|
||
break; | ||
|
||
case 'gh-remove-default-labels': | ||
await deleteLabels(results); | ||
|
||
break; | ||
|
||
case 'gh-sync-custom-labels': | ||
await createLabels(results); | ||
|
||
break; | ||
|
||
case 'reset-config': | ||
config.clear(); | ||
|
||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
const chalk = require('chalk'); | ||
const { highlight } = require('cli-highlight'); | ||
const { template, sortBy } = require('lodash'); | ||
|
||
const changelogTemplate = template(`<% | ||
versions.forEach(version => { | ||
%> | ||
## <%= version.version %> | ||
<% | ||
version.categories.forEach(category => { | ||
%> | ||
### <%= | ||
category.title | ||
%> | ||
<% | ||
category.entries.forEach(entry => { | ||
%>- #<%= | ||
entry.pr.number | ||
%><% | ||
if (entry.otherLabels.length > 0) { | ||
%> [<%= | ||
entry.otherLabels.join(', ') | ||
%>]<% | ||
} | ||
%> <%= | ||
entry.pr.title | ||
%> @<%= | ||
entry.pr.user.login | ||
%> | ||
<% | ||
}) | ||
%><% | ||
}) | ||
%><% | ||
}) | ||
%> | ||
`); | ||
|
||
module.exports = function render(data) { | ||
const payload = { | ||
versions: [...data.entries()].reduce((versions, [version, { commits, categories }]) => { | ||
if (commits.length > 0) { | ||
versions.push({ | ||
version, | ||
categories: [...categories.entries()].reduce((acc, [title, entries]) => { | ||
if (entries.size === 0) { | ||
return acc; | ||
} | ||
|
||
entries = [...entries.values()]; | ||
entries = sortBy(entries, entry => entry.pr.number); | ||
|
||
acc.push({ | ||
title, | ||
entries, | ||
}); | ||
|
||
return acc; | ||
}, []), | ||
}); | ||
} | ||
|
||
return versions; | ||
}, []), | ||
}; | ||
|
||
if (payload.versions.length === 0) { | ||
console.error(chalk.yellow(`No pull requests in selected range.`)); | ||
|
||
return ''; | ||
} | ||
|
||
const rendered = changelogTemplate(payload); | ||
|
||
if (chalk.enabled) { | ||
return highlight(rendered, { | ||
language: 'Markdown', | ||
theme: { | ||
section: chalk.bold.blue, | ||
string: chalk.gray, | ||
link: chalk.dim, | ||
}, | ||
}); | ||
} | ||
|
||
return rendered; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const execa = require('execa'); | ||
const { trim } = require('lodash'); | ||
|
||
module.exports = async () => { | ||
const { stdout } = await execa('git', ['branch', '-a', '--no-color']); | ||
|
||
const branches = stdout.split('\n').reduce( | ||
(acc, branch) => { | ||
branch = trim(branch); | ||
|
||
if (branch.substring(0, 2) === '* ') { | ||
acc.current = branch.substring(2); | ||
acc.local.push(acc.current); | ||
} else if (branch.match(/^remotes\//)) { | ||
acc.remote.push(branch.substring(8)); | ||
} else { | ||
acc.local.push(branch); | ||
} | ||
|
||
return acc; | ||
}, | ||
{ | ||
current: undefined, | ||
local: [], | ||
remote: [], | ||
} | ||
); | ||
|
||
return branches; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = message => { | ||
const lines = message.split('\n'); | ||
const firstLine = lines[0]; | ||
|
||
const mergeMatch = firstLine.match(/^Merge pull request #(\d+) from /); | ||
|
||
if (mergeMatch) { | ||
return mergeMatch[1]; | ||
} | ||
|
||
const squashMergeMatch = firstLine.match(/\(#(\d+)\)$/); | ||
|
||
if (squashMergeMatch) { | ||
return squashMergeMatch[1]; | ||
} | ||
|
||
return null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const execa = require('execa'); | ||
|
||
const commits = async ({ from = '', to = '' } = {}) => { | ||
to = to || 'HEAD'; | ||
|
||
try { | ||
const args = ['log', '--oneline', '--pretty=%H;%D;%s;%cd', '--date=short']; | ||
|
||
if (from) { | ||
args.push(`${from}..${to}`); | ||
} | ||
|
||
const { stdout } = await execa('git', args); | ||
|
||
return stdout | ||
.split('\n') | ||
.filter(Boolean) | ||
.map(commit => { | ||
const parts = commit.split(';'); | ||
const sha = parts[0]; | ||
const refName = parts[1]; | ||
const summary = parts[2]; | ||
const date = parts[3]; | ||
|
||
return { sha, refName, summary, date }; | ||
}); | ||
} catch (err) { | ||
console.log('Error requesting commits', err); | ||
} | ||
}; | ||
|
||
module.exports = commits; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const gitRepoName = require('git-repo-name'); | ||
const gitUsername = require('git-username'); | ||
|
||
module.exports = (() => { | ||
try { | ||
return { | ||
repo: gitRepoName.sync(), | ||
owner: gitUsername(), | ||
}; | ||
} catch (err) { | ||
return {}; | ||
} | ||
})(); |
Oops, something went wrong.