Skip to content

Commit 41c5912

Browse files
committed
initial commit
0 parents  commit 41c5912

11 files changed

+2626
-0
lines changed

.babelrc

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"presets": [
3+
"env"
4+
],
5+
"env": {
6+
"development": {
7+
"presets": [
8+
"jsdoc-to-assert",
9+
"power-assert"
10+
]
11+
}
12+
}
13+
}

.gitignore

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
### https://raw.github.com/github/gitignore/608690d6b9a78c2a003affc792e49a84905b3118/Node.gitignore
2+
3+
# Logs
4+
logs
5+
*.log
6+
7+
# Runtime data
8+
pids
9+
*.pid
10+
*.seed
11+
12+
# Directory for instrumented libs generated by jscoverage/JSCover
13+
lib-cov
14+
15+
# Coverage directory used by tools like istanbul
16+
coverage
17+
18+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
19+
.grunt
20+
21+
# node-waf configuration
22+
.lock-wscript
23+
24+
# Compiled binary addons (http://nodejs.org/api/addons.html)
25+
build/Release
26+
27+
# Dependency directory
28+
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
29+
node_modules
30+
31+
# Debug log from npm
32+
npm-debug.log
33+
34+
35+
### https://raw.github.com/github/gitignore/608690d6b9a78c2a003affc792e49a84905b3118/Global/JetBrains.gitignore
36+
37+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
38+
39+
*.iml
40+
41+
## Directory-based project format:
42+
.idea/
43+
# if you remove the above rule, at least ignore the following:
44+
45+
# User-specific stuff:
46+
# .idea/workspace.xml
47+
# .idea/tasks.xml
48+
# .idea/dictionaries
49+
50+
# Sensitive or high-churn files:
51+
# .idea/dataSources.ids
52+
# .idea/dataSources.xml
53+
# .idea/sqlDataSources.xml
54+
# .idea/dynamic.xml
55+
# .idea/uiDesigner.xml
56+
57+
# Gradle:
58+
# .idea/gradle.xml
59+
# .idea/libraries
60+
61+
# Mongo Explorer plugin:
62+
# .idea/mongoSettings.xml
63+
64+
## File-based project format:
65+
*.ipr
66+
*.iws
67+
68+
## Plugin-specific files:
69+
70+
# IntelliJ
71+
out/
72+
73+
# mpeltonen/sbt-idea plugin
74+
.idea_modules/
75+
76+
# JIRA plugin
77+
atlassian-ide-plugin.xml
78+
79+
# Crashlytics plugin (for Android Studio and IntelliJ)
80+
com_crashlytics_export_strings.xml
81+
crashlytics.properties
82+
crashlytics-build.properties
83+
84+
85+
/lib

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sudo: false
2+
language: node_js
3+
node_js: "stable"

LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2017 azu
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# @azu/github-label-setup
2+
3+
GitHub label setup script.
4+
5+
## Install
6+
7+
Install with [npm](https://www.npmjs.com/):
8+
9+
npm install @azu/github-label-setup
10+
11+
## Usage
12+
13+
- [ ] Write usage instructions
14+
15+
## Changelog
16+
17+
See [Releases page](https://github.com/azu/github-label-setup/releases).
18+
19+
## Running tests
20+
21+
Install devDependencies and Run `npm test`:
22+
23+
npm i -d && npm test
24+
25+
## Contributing
26+
27+
Pull requests and stars are always welcome.
28+
29+
For bugs and feature requests, [please create an issue](https://github.com/azu/github-label-setup/issues).
30+
31+
1. Fork it!
32+
2. Create your feature branch: `git checkout -b my-new-feature`
33+
3. Commit your changes: `git commit -am 'Add some feature'`
34+
4. Push to the branch: `git push origin my-new-feature`
35+
5. Submit a pull request :D
36+
37+
## Author
38+
39+
- [github/azu](https://github.com/azu)
40+
- [twitter/azu_re](https://twitter.com/azu_re)
41+
42+
## License
43+
44+
MIT © azu

bin/cmd.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
const meow = require("meow");
4+
const setup = require("../lib/github-label-setup");
5+
6+
const cli = meow(`
7+
Usage
8+
$ echo "text" | add-text-to-markdown README.md --section "section name"
9+
10+
Options
11+
12+
-h, --help output usage information
13+
-V, --version output the version number
14+
--token <token> a GitHub access token (also settable with a GITHUB_ACCESS_TOKEN environment variable)
15+
-d, --dry-run calculate the required label changes but do not apply them
16+
17+
`, {
18+
alias: {
19+
d: 'dry-run',
20+
}
21+
});
22+
/*
23+
{
24+
input: ['unicorns'],
25+
flags: {rainbow: true},
26+
...
27+
}
28+
*/
29+
30+
setup(cli.flags);

default-labels.json

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
[
2+
{
3+
"name": "duplicate",
4+
"color": "#ededed"
5+
},
6+
{
7+
"name": "help wanted",
8+
"color": "#e99695"
9+
},
10+
{
11+
"name": "starter",
12+
"color": "#ffc0cb"
13+
},
14+
{
15+
"name": "Priority: Critical",
16+
"color": "#ee0701"
17+
},
18+
{
19+
"name": "Priority: High",
20+
"color": "#d93f0b"
21+
},
22+
{
23+
"name": "Priority: Low",
24+
"color": "#0e8a16"
25+
},
26+
{
27+
"name": "Priority: Medium",
28+
"color": "#fbca04"
29+
},
30+
{
31+
"name": "Status: Abandoned",
32+
"color": "#000000"
33+
},
34+
{
35+
"name": "Status: Blocked",
36+
"color": "#ee0701"
37+
},
38+
{
39+
"name": "Status: In Progress",
40+
"color": "#cccccc"
41+
},
42+
{
43+
"name": "Status: On Hold",
44+
"color": "#e99695"
45+
},
46+
{
47+
"name": "Status: Proposal",
48+
"color": "#d4c5f9"
49+
},
50+
{
51+
"name": "Status: Ready for PR",
52+
"color": "#c2e0c6"
53+
},
54+
{
55+
"name": "Status: Review Needed",
56+
"color": "#fbca04"
57+
},
58+
{
59+
"name": "Type: Breaking Change",
60+
"color": "#b60205"
61+
},
62+
{
63+
"name": "Type: Bug",
64+
"color": "#ee0701"
65+
},
66+
{
67+
"name": "Type: Documentation",
68+
"color": "#5319e7"
69+
},
70+
{
71+
"name": "Type: Enhancement",
72+
"color": "#1d76db"
73+
},
74+
{
75+
"name": "Type: Maintenance",
76+
"color": "#fbca04"
77+
},
78+
{
79+
"name": "Type: Question",
80+
"color": "#cc317c"
81+
}
82+
]

package.json

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"directories": {
3+
"test": "test"
4+
},
5+
"author": "azu",
6+
"license": "MIT",
7+
"files": [
8+
"bin/",
9+
"lib/",
10+
"src/",
11+
"default-labels.json"
12+
],
13+
"name": "@azu/github-label-setup",
14+
"version": "1.0.0",
15+
"description": "GitHub label setup script.",
16+
"main": "lib/github-label-setup.js",
17+
"scripts": {
18+
"test": "mocha test/",
19+
"build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps",
20+
"watch": "babel src --out-dir lib --watch --source-maps",
21+
"prepublish": "npm run --if-present build"
22+
},
23+
"keywords": [
24+
"github",
25+
"label"
26+
],
27+
"repository": {
28+
"type": "git",
29+
"url": "https://github.com/azu/github-label-setup.git"
30+
},
31+
"bugs": {
32+
"url": "https://github.com/azu/github-label-setup/issues"
33+
},
34+
"homepage": "https://github.com/azu/github-label-setup",
35+
"devDependencies": {
36+
"babel-cli": "^6.24.1",
37+
"babel-preset-env": "^1.4.0",
38+
"babel-preset-jsdoc-to-assert": "^4.0.0",
39+
"babel-preset-power-assert": "^1.0.0",
40+
"babel-register": "^6.24.1",
41+
"cross-env": "^5.0.0",
42+
"mocha": "^3.4.1",
43+
"power-assert": "^1.4.2"
44+
},
45+
"dependencies": {
46+
"git-remote-origin-url": "^2.0.0",
47+
"github-label-sync": "^1.2.0",
48+
"hosted-git-info": "^2.4.2",
49+
"meow": "^3.7.0"
50+
}
51+
}

src/github-label-setup.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// MIT © 2017 azu
2+
"use strict";
3+
const assert = require("assert");
4+
const githubLabelSync = require("github-label-sync");
5+
const getRemoteOriginUrl = require("git-remote-origin-url");
6+
const path = require("path");
7+
const fromUrl = require("hosted-git-info").fromUrl;
8+
/**
9+
* @returns {Promise.<{ owner: string|null, repo: string|null}>}
10+
*/
11+
const getRepositoryInfo = () => {
12+
return getRemoteOriginUrl().then(url => {
13+
return fromUrl(url);
14+
}).then(result => {
15+
if (!result) {
16+
return;
17+
}
18+
return `${result.user}/${result.project}`;
19+
});
20+
};
21+
/**
22+
* @param token
23+
* @param repo
24+
* @param labels
25+
* @param dryRun
26+
* @returns {Promise}
27+
*/
28+
module.exports = function({
29+
token,
30+
repo,
31+
labels = path.join(__dirname, "default-labels.json"),
32+
dryRun
33+
}) {
34+
const repoPromise = repo ? Promise.resolve(repo) : getRepositoryInfo();
35+
return repoPromise.then(repoPath => {
36+
assert(repoPath, "repo should be needed.");
37+
const labelJSON = require(labels);
38+
return githubLabelSync({
39+
accessToken: token || process.env.GITHUB_ACCESS_TOKEN,
40+
repo: repoPath,
41+
labels: labelJSON,
42+
dryRun,
43+
});
44+
});
45+
};

test/mocha.opts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--compilers js:babel-register

0 commit comments

Comments
 (0)