Skip to content

Commit 99ebd50

Browse files
committed
Include extra properties to create the github repo
1 parent 22d6906 commit 99ebd50

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/githubHandler/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ const auth = require('../auth');
33

44
/**
55
* Create a github repository
6-
* @param {String} name The name for the github project
6+
* @param {String} name The name for the github project
77
* @param {Boolean} [isPrivate=false] Defines is the project will be created as private
88
* or public on github
9+
* @param {String} [description=''] The description for the github project
10+
* @param {String} [ul=''] The url for the github project
911
* @return {json|Boolean} In case of success will return the json from the
1012
* github api response, otherwise, return false.
1113
* @throws If the token is not present
1214
*/
13-
async function create(name, isPrivate = false) {
15+
async function create(name, isPrivate = false, description = '', url = '') {
1416
let token = '';
1517
let result;
1618

@@ -22,8 +24,7 @@ async function create(name, isPrivate = false) {
2224

2325
console.log('Creating github repository...\n');
2426
// TODO consider use http instead curl?
25-
// TODO Include description, website and keywords
26-
const cmd = `curl -w "%{http_code}" -H "Authorization: token ${token}" -d '{"name": "${name}", "private": ${isPrivate}}' https://api.github.com/user/repos`;
27+
const cmd = `curl -w "%{http_code}" -H "Authorization: token ${token}" -d '{"name": "${name}", "private": ${isPrivate}, "description": "${description}", "homepage": "${url}"}' https://api.github.com/user/repos`;
2728

2829
try {
2930
result = await utils.execp(cmd);
@@ -100,6 +101,8 @@ async function deleteRepo(name, user) {
100101
};
101102
}
102103

104+
// TODO include a method to handle the topics (will require to get the github user)
105+
103106
module.exports = {
104107
create,
105108
deleteRepo,

src/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ async function myPackage() {
5151

5252
// Create github repository and include properties to the project object
5353
if (project.useGithub) {
54-
const resp = await githubHandler.create(project.name, project.isPrivate);
54+
const resp = await githubHandler.create(
55+
project.name,
56+
project.isPrivate,
57+
project.description,
58+
project.url
59+
);
5560
if (resp !== false) {
5661
project.git.httpUrl = resp.html_url;
5762
project.git.name = resp.name;
@@ -106,7 +111,6 @@ async function myPackage() {
106111
const args = ['install', '-D'].concat(settings.lintPkgs, answers.testPackages);
107112
await utils.spawnp(
108113
'npm',
109-
// TODO Make dependencies dynamic
110114
args,
111115
destPath,
112116
);

0 commit comments

Comments
 (0)