Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Pichler committed Sep 4, 2018
1 parent 1442f4b commit d1ae7c2
Show file tree
Hide file tree
Showing 33 changed files with 3,201 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .editorconfig
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
33 changes: 33 additions & 0 deletions .eslintignore
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
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: 'anfema/node',
};
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.workrc
16 changes: 16 additions & 0 deletions .prettierignore
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
19 changes: 19 additions & 0 deletions .prettierrc
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
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,17 @@ And

- Batch update GitHub labels


## Installation

If you have Node.js and Yarn installed, you can use install via:

```sh
yarn global add anfema/work
```


## Configuration

This tool will ask for any required configuration. If you want to adjust default settings, you can add a JSON object to `.config/work` to adjust settings as necessary. Note: This should not be the case for anfema repositories.

3 changes: 3 additions & 0 deletions bin/work
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require('../index.js');
107 changes: 107 additions & 0 deletions experiments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// const listPullRequests = require('./src/list-pull-requests.js');
// const renderChangeLog = require('./src/render-change-log.js');

// const { last: lastTag, all: allTags } = require('./lib/repository-tags.js');
const repoPath = require('./lib/repository-path.js');

const { commits } = require('./lib/commits.js');

// const inquirer = require('inquirer');

// const config = require('./src/config.js');

(async () => {
// const pullRequests = await listPullRequests();
// const lastRelease = await lastTag({ cwd: repoPath });
//
// const tags = await allTags({ cwd: repoPath });
//

console.log(repoPath);

// const changeLog = renderChangeLog(pullRequests);
//
// console.log(lastRelease);
// gitCommits(repoPath, {}).on('data', commit => {
// console.log(commit.hash, commit.hash === lastRelease.hash);
// });
//

const all = await commits({
cwd: repoPath,
});

console.log(
all.map(
commit =>
`${commit.hash.substr(0, 6)} ${commit.title.trim()} ${commit.description
.split('\n')
.join('')
.trim()}`
)
);

// console.log(
// pullRequests.map(pr => pr.data.merge_commit_sha)
// // .map(sha => `${sha}: ${sha === lastRelease.hash}`)
// );
//
// let answers = await inquirer.prompt([
// {
// type: 'list',
// name: 'run',
// message: 'What do you want to do today?',
// default: 'list',
// choices: [
// {
// name: 'List available releases',
// value: 'list',
// short: 'List releases',
// },
// {
// name: 'Create new release',
// value: 'new',
// short: 'New release',
// },
// new inquirer.Separator(),
// {
// name: "Quit",
// value: 'quit',
// },
// ],
// when(answers) {
// if (answers.continue || answers.list) {
// return true;
// }
// }
// },
// ]);
// if (answers.run === 'list') {
// const tagsStream = repositoryTags({ cwd: repoPath });
// const tags = await getStream.array(tagsStream);
// console.log(tags.map(({ tag, hash }) => `${tag} (${hash})`).join('\n'), '\n');
// answers = await promtStart();
// }
// if (answers.run === 'new') {
// answers = await inquirer.prompt([
// {
// type: 'list',
// name: 'release',
// message: 'What kind of ?',
// default: 'list',
// choices: [
// {
// name: 'Major',
// value: 'major',
// short: 'List releases',
// },
// new inquirer.Separator(),
// {
// name: "Quit",
// value: 'quit',
// },
// ],
// },
// ]);
// }
})();
49 changes: 49 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const chalk = require('chalk');

const gitCreateBranch = require('./lib/git/create-branch.js');
const githubInfo = require('./lib/git/github-info.js');
const program = require('./src/program.js');
const questions = require('./src/questions.js');
const config = require('./src/config.js');
const settings = require('./src/settings.js');
const createLabels = require('./lib/github/create-labels.js');
const deleteLabels = require('./lib/github/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 gitCreateBranch(results);

break;

case 'pr':
console.log(chalk.blue(`Pull Requests are not implemented yet`));

break;

case 'changelog':
console.log(chalk.blue(`Changelogs are not implemented yet`));

break;

case 'gh-remove-default-labels':
await deleteLabels(results);

break;

case 'gh-sync-custom-labels':
await createLabels(results);

break;

default:
break;
}
} catch (err) {
console.error(err);
}
})();
30 changes: 30 additions & 0 deletions lib/git/branch-list.js
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;
};
12 changes: 12 additions & 0 deletions lib/git/commits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const gitCommits = require('git-commits');
const getStream = require('get-stream');

const commits = async (options = { cwd: '.' }) => {
const commitStream = gitCommits(options.cwd, {});

return getStream.array(commitStream);
};

module.exports = {
commits,
};
Loading

0 comments on commit d1ae7c2

Please sign in to comment.