This repository has been archived by the owner on Aug 22, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(create): created the repo for the authenticated user
for #1
- Loading branch information
Showing
4 changed files
with
57 additions
and
2 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,5 @@ | ||
import {factory} from './github-client-factory'; | ||
|
||
export default function (name, visibility) { | ||
factory().repos.createForAuthenticatedUser({name, private: 'Private' === visibility}); | ||
} |
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 |
---|---|---|
@@ -1,8 +1,12 @@ | ||
import chalk from 'chalk'; | ||
import scaffoldSettings from './settings-scaffolder'; | ||
import create from './create'; | ||
|
||
export function scaffold({name, projectRoot, projectType, description, homepage, visibility}) { | ||
console.log(chalk.blue('Generating GitHub')); // eslint-disable-line no-console | ||
|
||
return scaffoldSettings(projectRoot, name, description, homepage, visibility, projectType); | ||
return Promise.all([ | ||
scaffoldSettings(projectRoot, name, description, homepage, visibility, projectType), | ||
create(name, visibility) | ||
]); | ||
} |
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,41 @@ | ||
import sinon from 'sinon'; | ||
import {assert} from 'chai'; | ||
import any from '@travi/any'; | ||
import * as clientFactory from '../../src/github-client-factory'; | ||
import create from '../../src/create'; | ||
|
||
suite('creation', () => { | ||
let sandbox; | ||
|
||
setup(() => { | ||
sandbox = sinon.createSandbox(); | ||
|
||
sandbox.stub(clientFactory, 'factory'); | ||
}); | ||
|
||
teardown(() => sandbox.restore()); | ||
|
||
suite('for user', () => { | ||
test('that the repository is created for the provided user account', () => { | ||
const name = any.word(); | ||
const createForAuthenticatedUser = sinon.stub(); | ||
const client = {repos: {createForAuthenticatedUser}}; | ||
clientFactory.factory.returns(client); | ||
|
||
create(name, 'Public'); | ||
|
||
assert.calledWith(createForAuthenticatedUser, {name, private: false}); | ||
}); | ||
|
||
test('that the repository is created as private when visibility is `Privage`', () => { | ||
const name = any.word(); | ||
const createForAuthenticatedUser = sinon.stub(); | ||
const client = {repos: {createForAuthenticatedUser}}; | ||
clientFactory.factory.returns(client); | ||
|
||
create(name, 'Private'); | ||
|
||
assert.calledWith(createForAuthenticatedUser, {name, private: true}); | ||
}); | ||
}); | ||
}); |
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