Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
feat(visibility): set the private flag based on visibility
Browse files Browse the repository at this point in the history
BREAKING CHANGE: repository will be made private unless visibility is properly provided

closes #2
  • Loading branch information
travi committed Jan 8, 2019
1 parent 40b9a90 commit 65d1d7a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/scaffolder.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import chalk from 'chalk';
import writeYaml from '../third-party-wrappers/write-yaml';

export function scaffold({projectRoot, projectType, description, homepage}) {
export function scaffold({projectRoot, projectType, description, homepage, visibility}) {
console.log(chalk.blue('Generating GitHub')); // eslint-disable-line no-console

return writeYaml(`${projectRoot}/.github/settings.yml`, {
repository: {
description,
homepage,
private: 'Public' !== visibility,
has_wiki: false,
has_projects: false,
has_downloads: false,
Expand Down
37 changes: 37 additions & 0 deletions test/unit/scaffolder-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ suite('github', () => {
repository: {
description,
homepage,
private: true,
has_wiki: false,
has_projects: false,
has_downloads: false,
Expand Down Expand Up @@ -81,4 +82,40 @@ suite('github', () => {
})
));
});

test('that the repository is marked as private when the visibility is `Private`', async () => {
yamlWriter.default.resolves();

await scaffold({projectRoot, projectType: any.word(), visibility: 'Private'});

assert.calledWith(
yamlWriter.default,
`${projectRoot}/.github/settings.yml`,
sinon.match({repository: {private: true}})
);
});

test('that the repository is marked as not private when the visibility is `Public`', async () => {
yamlWriter.default.resolves();

await scaffold({projectRoot, projectType: any.word(), visibility: 'Public'});

assert.calledWith(
yamlWriter.default,
`${projectRoot}/.github/settings.yml`,
sinon.match({repository: {private: false}})
);
});

test('that the repository is marked as private when the visibility is not specified', async () => {
yamlWriter.default.resolves();

await scaffold({projectRoot, projectType: any.word()});

assert.calledWith(
yamlWriter.default,
`${projectRoot}/.github/settings.yml`,
sinon.match({repository: {private: true}})
);
});
});

0 comments on commit 65d1d7a

Please sign in to comment.