Skip to content

Commit f110241

Browse files
author
Charlike Mike Reagent
committed
feat: implement & push to GitHub
Signed-off-by: Charlike Mike Reagent <[email protected]>
1 parent 7e5a21d commit f110241

File tree

6 files changed

+306
-7
lines changed

6 files changed

+306
-7
lines changed

.verb.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ $ yarn add {%= name %}
5454
## API
5555

5656
<!-- docks-start -->
57+
_Generated using [docks](http://npm.im/docks)._
58+
59+
60+
5761
<!-- docks-end -->
5862

5963
**[back to top](#thetop)**

README.md

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
# @tunnckocore/create-github-repo [![npm version][npmv-img]][npmv-url] [![github release][ghrelease-img]][ghrelease-url] [![License][license-img]][license-url]
2+
3+
> Small and fast way to create GitHub repository! Provides API and CLI
4+
5+
Please consider following this project's author, [Charlike Mike Reagent](https://github.com/tunnckoCore), and :star: the project to show your :heart: and support.
6+
7+
<div id="thetop"></div>
8+
9+
[![Code style][codestyle-img]][codestyle-url]
10+
[![CircleCI linux build][linuxbuild-img]][linuxbuild-url]
11+
[![CodeCov coverage status][codecoverage-img]][codecoverage-url]
12+
[![DavidDM dependency status][dependencies-img]][dependencies-url]
13+
[![Renovate App Status][renovateapp-img]][renovateapp-url]
14+
[![Make A Pull Request][prs-welcome-img]][prs-welcome-url]
15+
[![Semantically Released][new-release-img]][new-release-url]
16+
17+
If you have any _how-to_ kind of questions, please read the [Contributing Guide](./CONTRIBUTING.md) and [Code of Conduct](./CODE_OF_CONDUCT.md) documents.
18+
For bugs reports and feature requests, [please create an issue][open-issue-url] or ping
19+
[@tunnckoCore](https://twitter.com/tunnckoCore) at Twitter.
20+
21+
[![Become a Patron][patreon-img]][patreon-url]
22+
[![Conventional Commits][ccommits-img]][ccommits-url]
23+
[![NPM Downloads Weekly][downloads-weekly-img]][npmv-url]
24+
[![NPM Downloads Monthly][downloads-monthly-img]][npmv-url]
25+
[![NPM Downloads Total][downloads-total-img]][npmv-url]
26+
[![Share Love Tweet][shareb]][shareu]
27+
28+
Project is [semantically](https://semver.org) & automatically released on [CircleCI](https://circleci.com) with [new-release][] and its [New Release](https://github.com/apps/new-release) GitHub App.
29+
30+
<!-- Logo when needed:
31+
32+
<p align="center">
33+
<a href="https://github.com/tunnckoCoreLabs/create-github-repo">
34+
<img src="./media/logo.png" width="85%">
35+
</a>
36+
</p>
37+
38+
-->
39+
40+
## Table of Contents
41+
42+
- [Install](#install)
43+
- [API](#api)
44+
- [See Also](#see-also)
45+
- [Contributing](#contributing)
46+
* [Follow the Guidelines](#follow-the-guidelines)
47+
* [Support the project](#support-the-project)
48+
* [OPEN Open Source](#open-open-source)
49+
* [Wonderful Contributors](#wonderful-contributors)
50+
- [License](#license)
51+
52+
_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_
53+
54+
## Install
55+
56+
This project requires [**Node.js**](https://nodejs.org) **^8.11.0 || >=10.13.0**. Install it using
57+
[**yarn**](https://yarnpkg.com) or [**npm**](https://npmjs.com).
58+
_We highly recommend to use Yarn when you think to contribute to this project._
59+
60+
```bash
61+
$ yarn add @tunnckocore/create-github-repo
62+
```
63+
64+
## API
65+
66+
<!-- docks-start -->
67+
_Generated using [docks](http://npm.im/docks)._
68+
69+
<!-- docks-end -->
70+
71+
**[back to top](#thetop)**
72+
73+
## See Also
74+
75+
Some of these projects are used here or were inspiration for this one, others are just related. So, thanks for your
76+
existance!
77+
- [@tunnckocore/config](https://www.npmjs.com/package/@tunnckocore/config): All the configs for all the tools, in one place | [homepage](https://github.com/tunnckoCoreLabs/config "All the configs for all the tools, in one place")
78+
- [@tunnckocore/create-project](https://www.npmjs.com/package/@tunnckocore/create-project): Create and scaffold a new project, its GitHub repository and… [more](https://github.com/tunnckoCoreLabs/create-project) | [homepage](https://github.com/tunnckoCoreLabs/create-project "Create and scaffold a new project, its GitHub repository and contents")
79+
- [@tunnckocore/execa](https://www.npmjs.com/package/@tunnckocore/execa): Thin layer on top of [execa][] that allows executing multiple… [more](https://github.com/tunnckoCoreLabs/execa) | [homepage](https://github.com/tunnckoCoreLabs/execa "Thin layer on top of [execa][] that allows executing multiple commands in parallel or in sequence")
80+
- [@tunnckocore/scripts](https://www.npmjs.com/package/@tunnckocore/scripts): Universal and minimalist scripts & tasks runner. | [homepage](https://github.com/tunnckoCoreLabs/scripts "Universal and minimalist scripts & tasks runner.")
81+
- [@tunnckocore/update](https://www.npmjs.com/package/@tunnckocore/update): Update a repository with latest templates from `charlike`. | [homepage](https://github.com/tunnckoCoreLabs/update "Update a repository with latest templates from `charlike`.")
82+
- [asia](https://www.npmjs.com/package/asia): Blazingly fast, magical and minimalist testing framework, for Today and… [more](https://github.com/olstenlarck/asia#readme) | [homepage](https://github.com/olstenlarck/asia#readme "Blazingly fast, magical and minimalist testing framework, for Today and Tomorrow")
83+
- [charlike](https://www.npmjs.com/package/charlike): Small & fast project scaffolder with sane defaults. Supports hundreds… [more](https://github.com/tunnckoCoreLabs/charlike) | [homepage](https://github.com/tunnckoCoreLabs/charlike "Small & fast project scaffolder with sane defaults. Supports hundreds of template engines through the @JSTransformers API or if you want custom `render` function passed through options")
84+
- [docks](https://www.npmjs.com/package/docks): Extensible system for parsing and generating documentation. It just freaking… [more](https://github.com/tunnckoCore/docks) | [homepage](https://github.com/tunnckoCore/docks "Extensible system for parsing and generating documentation. It just freaking works!")
85+
- [gitcommit](https://www.npmjs.com/package/gitcommit): Lightweight and joyful `git commit` replacement. Conventional Commits compliant. | [homepage](https://github.com/tunnckoCore/gitcommit "Lightweight and joyful `git commit` replacement. Conventional Commits compliant.")
86+
87+
**[back to top](#thetop)**
88+
89+
## Contributing
90+
91+
### Follow the Guidelines
92+
93+
Please read the [Contributing Guide](./CONTRIBUTING.md) and [Code of Conduct](./CODE_OF_CONDUCT.md) documents for advices.
94+
For bugs reports and feature requests, [please create an issue][open-issue-url] or ping
95+
[@tunnckoCore](https://twitter.com/tunnckoCore) at Twitter.
96+
97+
### Support the project
98+
99+
[Become a Partner or Sponsor?][patreon-url] :dollar: Check the **Partner**, **Sponsor** or **Omega-level** tiers! :tada: You can get your company logo, link & name on this file. It's also rendered on package page in [npmjs.com][npmv-url] and [yarnpkg.com](https://yarnpkg.com/en/package/@tunnckocore/create-github-repo) sites too! :rocket:
100+
101+
Not financial support? Okey! [Pull requests](https://github.com/tunnckoCoreLabs/contributing#opening-a-pull-request), stars and all kind of [contributions](https://opensource.guide/how-to-contribute/#what-it-means-to-contribute) are always
102+
welcome. :sparkles:
103+
104+
### OPEN Open Source
105+
106+
This project is following [OPEN Open Source](http://openopensource.org) model
107+
108+
> Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is built on collective efforts and it's not strongly guarded by its founders.
109+
110+
There are a few basic ground-rules for its contributors
111+
112+
1. Any **significant modifications** must be subject to a pull request to get feedback from other contributors.
113+
2. [Pull requests](https://github.com/tunnckoCoreLabs/contributing#opening-a-pull-request) to get feedback are _encouraged_ for any other trivial contributions, but are not required.
114+
3. Contributors should attempt to adhere to the prevailing code-style and development workflow.
115+
116+
### Wonderful Contributors
117+
118+
Thanks to the hard work of these wonderful people this project is alive! It follows the
119+
[all-contributors](https://github.com/kentcdodds/all-contributors) specification.
120+
Don't hesitate to add yourself to that list if you have made any contribution! ;) [See how,
121+
here](https://github.com/jfmengels/all-contributors-cli#usage).
122+
123+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
124+
<!-- prettier-ignore -->
125+
| [<img src="https://avatars3.githubusercontent.com/u/5038030?v=4" width="120px;"/><br /><sub><b>Charlike Mike Reagent</b></sub>](https://tunnckocore.com)<br />[💻](https://github.com/tunnckoCoreLabs/create-github-repo/commits?author=tunnckoCore "Code") [📖](https://github.com/tunnckoCoreLabs/create-github-repo/commits?author=tunnckoCore "Documentation") [💬](#question-tunnckoCore "Answering Questions") [👀](#review-tunnckoCore "Reviewed Pull Requests") [🔍](#fundingFinding-tunnckoCore "Funding Finding") |
126+
| :---: |
127+
128+
<!-- ALL-CONTRIBUTORS-LIST:END -->
129+
130+
Consider showing your [support](#support-the-project) to them. :sparkling_heart:
131+
132+
## License
133+
134+
Copyright (c) 2018-present, [Charlike Mike Reagent](https://tunnckocore.com) `<[email protected]>` & [contributors](#wonderful-contributors).
135+
Released under the [Apache-2.0 License][license-url].
136+
137+
<!-- Heading badges -->
138+
139+
[npmv-url]: https://www.npmjs.com/package/@tunnckocore/create-github-repo
140+
[npmv-img]: https://badgen.net/npm/v/@tunnckocore/create-github-repo?icon=npm
141+
142+
[ghrelease-url]: https://github.com/tunnckoCoreLabs/create-github-repo/releases/latest
143+
[ghrelease-img]: https://badgen.net/github/release/tunnckoCoreLabs/create-github-repo?icon=github
144+
145+
[license-url]: https://github.com/tunnckoCoreLabs/create-github-repo/blob/master/LICENSE
146+
[license-img]: https://badgen.net/npm/license/@tunnckocore/create-github-repo
147+
148+
<!-- Front line badges -->
149+
150+
[codestyle-url]: https://github.com/airbnb/javascript
151+
[codestyle-img]: https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb
152+
153+
[linuxbuild-url]: https://circleci.com/gh/tunnckoCoreLabs/create-github-repo/tree/master
154+
[linuxbuild-img]: https://badgen.net/circleci/github/tunnckoCoreLabs/create-github-repo/master?label=build&icon=circleci
155+
156+
[codecoverage-url]: https://codecov.io/gh/tunnckoCoreLabs/create-github-repo
157+
[codecoverage-img]: https://badgen.net/codecov/c/github/tunnckoCoreLabs/create-github-repo?icon=codecov
158+
159+
[dependencies-url]: https://david-dm.org/tunnckoCoreLabs/create-github-repo
160+
[dependencies-img]: https://badgen.net/david/dep/tunnckoCoreLabs/create-github-repo?label=deps
161+
162+
[ccommits-url]: https://conventionalcommits.org/
163+
[ccommits-img]: https://badgen.net/badge/conventional%20commits/v1.0.0/dfb317
164+
[new-release-url]: https://ghub.io/new-release
165+
[new-release-img]: https://badgen.net/badge/semantically/released/05c5ff
166+
167+
[downloads-weekly-img]: https://badgen.net/npm/dw/@tunnckocore/create-github-repo
168+
[downloads-monthly-img]: https://badgen.net/npm/dm/@tunnckocore/create-github-repo
169+
[downloads-total-img]: https://badgen.net/npm/dt/@tunnckocore/create-github-repo
170+
171+
[renovateapp-url]: https://renovatebot.com
172+
[renovateapp-img]: https://badgen.net/badge/renovate/enabled/green
173+
[prs-welcome-img]: https://badgen.net/badge/PRs/welcome/green
174+
[prs-welcome-url]: http://makeapullrequest.com
175+
[paypal-donate-url]: https://paypal.me/tunnckoCore/10
176+
[paypal-donate-img]: https://badgen.net/badge/$/support/purple
177+
[patreon-url]: https://www.patreon.com/bePatron?u=5579781
178+
[patreon-img]: https://badgen.net/badge/patreon/tunnckoCore/F96854?icon=patreon
179+
[patreon-sponsor-img]: https://badgen.net/badge/become/a%20sponsor/F96854?icon=patreon
180+
181+
[shareu]: https://twitter.com/intent/tweet?text=https://github.com/tunnckoCoreLabs/create-github-repo&via=tunnckoCore
182+
[shareb]: https://badgen.net/badge/twitter/share/1da1f2?icon=twitter
183+
[open-issue-url]: https://github.com/tunnckoCoreLabs/create-github-repo/issues/new
184+
185+
[execa]: https://github.com/sindresorhus/execa
186+
[new-release]: https://github.com/tunnckoCore/new-release
187+
[semantic-release]: https://github.com/semantic-release/semantic-release

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
"node": "^8.11.0 || >=10.13.0"
1616
},
1717
"dependencies": {
18-
"esm": "^3.0.84"
18+
"axios": "^0.18.0",
19+
"esm": "^3.0.84",
20+
"parse-git-config": "^2.0.3"
1921
},
2022
"devDependencies": {
2123
"@tunnckocore/config": "^0.5.1",

src/index.js

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,42 @@
1-
export default () => {};
1+
import proc from 'process';
2+
import axios from 'axios';
3+
import parse from 'parse-git-config';
4+
5+
// TODO: externalize
6+
export default async function createGithubRepo(options) {
7+
const opts = Object.assign({ auto_init: true, has_wiki: false }, options);
8+
9+
let githubToken =
10+
opts.github_token ||
11+
(opts.author && opts.author.github_token) ||
12+
opts.token ||
13+
(!proc.env.ASIA_CLI && (proc.env.GH_TOKEN || proc.env.GITHUB_TOKEN));
14+
15+
if (!githubToken) {
16+
const gitconfig = await parse({ type: 'global' });
17+
githubToken =
18+
(gitconfig.user && gitconfig.user.token) ||
19+
(gitconfig.github && gitconfig.github.token);
20+
}
21+
22+
if (!githubToken) {
23+
throw new Error('Requires GitHub token, but not found.');
24+
}
25+
26+
opts.name = opts.repo || opts.name;
27+
opts.homepage = (opts.project && opts.project.homepage) || opts.homepage;
28+
opts.description =
29+
(opts.project && opts.project.description) || opts.description;
30+
31+
const endpoint =
32+
opts.ownerType === 'org' ? `/orgs/${opts.owner}/repos` : `/user/repos`;
33+
34+
return axios({
35+
url: `https://api.github.com${endpoint}`,
36+
method: 'post',
37+
headers: {
38+
Authorization: `token ${githubToken}`,
39+
},
40+
data: opts,
41+
});
42+
}

test/snapshots/index.snapshot.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"todo":{"skip":false,"todo":false,"run":false,"isPending":false,"isRejected":false,"isFulfilled":true,"id":1,"str":"(t) => {\n t.strictEqual(typeof mod, 'function');\n}","title":"todo"}}

0 commit comments

Comments
 (0)