Skip to content

Commit

Permalink
Merge 37a0237 into 12fba11
Browse files Browse the repository at this point in the history
  • Loading branch information
gregswindle authored Sep 26, 2017
2 parents 12fba11 + 37a0237 commit 64571b9
Show file tree
Hide file tree
Showing 79 changed files with 14,597 additions and 419 deletions.
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ addons:
token:
secure: "$SONAR_TOKEN"
github_token:
secure: "$GITHUB_ACCESS_TOKEN"
secure: "$GH_TOKEN"
branches:
- master
- /[build|chore|ci|docs|feat|fix|perf|refactor|revert|spike|style|test].*/
Expand All @@ -23,14 +23,12 @@ node_js:
- 6
- node
before_script:
- npm i -g codecov
- npm prune
script:
- npm test && codecov
- sonar-scanner -Dproject.settings=sonar-project.properties -Dsonar.organization=$SONAR_ORGANIZATION -Dsonar.login=$SONAR_TOKEN -X
- npm test
- sonar-scanner -Dproject.settings=./sonar-project.properties -Dsonar.organization=$SONAR_ORGANIZATION -Dsonar.login=$SONAR_TOKEN -X
after_script:
- cat ./coverage/lcov.info | coveralls
- cat ./coverage/lcov.info | ./node_modules/.bin/codacy-coverage
branches:
except:
- /^v\d+\.\d+\.\d+$/
Empty file added CHANGELOG.md
Empty file.
9,627 changes: 9,627 additions & 0 deletions NOTICE.md

Large diffs are not rendered by default.

298 changes: 232 additions & 66 deletions README.md

Large diffs are not rendered by default.

47 changes: 45 additions & 2 deletions __tests__/app.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ const assert = require('yeoman-assert')
const helpers = require('yeoman-test')

describe('generator-community:app,', () => {
afterAll(() => {
process.setMaxListeners(0)
})

beforeEach(() => {
jest.mock('inquirer-npm-name', () => {
return () => Promise.resolve(true)
Expand All @@ -13,7 +17,12 @@ describe('generator-community:app,', () => {
return () => Promise.resolve('unicornUser')
})

jest.mock('generator-license/app', () => {
jest.mock('../generators/license', () => {
const helpers = require('yeoman-test')
return helpers.createDummyGenerator()
})

jest.mock('../generators/readme', () => {
const helpers = require('yeoman-test')
return helpers.createDummyGenerator()
})
Expand All @@ -31,6 +40,7 @@ describe('generator-community:app,', () => {
authorUrl: 'http://yeoman.io',
keywords: ['foo', 'bar']
}

return helpers.run(require.resolve('../generators/app'))
.withPrompts(answers)
.then(() => {
Expand Down Expand Up @@ -68,7 +78,10 @@ describe('generator-community:app,', () => {
keywords: ['bar']
}
return helpers.run(require.resolve('../generators/app'))
.withPrompts({name: 'generator-community'})
.withPrompts({
name: 'generator-community',
keywords: 'bar'
})
.on('ready', (gen) => {
gen.fs.writeJSON(gen.destinationPath('package.json'), pkg)
})
Expand Down Expand Up @@ -130,4 +143,34 @@ describe('generator-community:app,', () => {
.then(() => assert.noFile('LICENSE'))
})
})

describe('when done prompting for README sections,', () => {
let gen = null
beforeEach(() => {
jest.resetModules()
jest.unmock('../generators/readme')
return helpers.run(require.resolve('../generators/app'))
.withPrompts({
name: 'generator-community',
description: 'A generator',
homepage: 'http://yeoman.io',
githubAccount: 'yeoman',
authorName: 'The Yeoman Team',
authorEmail: 'hi@yeoman.io',
authorUrl: 'http://yeoman.io',
keywords: ['foo', 'bar'],
includeApi: true,
includeBackground: true
})
.on('ready', (generator) => {
gen = generator
gen.fs.writeJSON(gen.destinationPath('package.json'), {})
})
})
it('adds the README sections users select to include', (done) => {
assert.file('README.md')
assert.fileContent('README.md', '## API')
done()
})
})
})
12 changes: 8 additions & 4 deletions __tests__/cli.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
const assert = require('yeoman-assert')
const helpers = require('yeoman-test')

describe('node:cli', () => {
describe('community:cli', () => {
afterAll(() => {
process.setMaxListeners(0)
})

beforeEach(() => {
return helpers.run(require.resolve('generator-node/generators/cli'))
.on('ready', (generator) => {
Expand All @@ -19,15 +23,15 @@ describe('node:cli', () => {
assert.fileContent('lib/cli.js', 'const myLib = require(\'./\')')
})

it('Extends package.json', () => {
it('extends package.json', () => {
assert.fileContent('package.json', '"bin": "lib/cli.js"')
assert.fileContent('package.json', '"meow"')
assert.fileContent('package.json', /"lec": "\^/)
assert.fileContent('package.json', '"prepublish": "lec lib/cli.js -c LF && nsp check"')
})
})

describe('node:cli', () => {
describe('community:cli', () => {
beforeEach(() => {
return helpers.run(require.resolve('generator-node/generators/cli'))
.withOptions({generateInto: 'other/'})
Expand All @@ -39,7 +43,7 @@ describe('node:cli', () => {
})
})

it('creates cli.js with path option', () => {
it('creates lib/cli.js in the directory specified by --generateInto', () => {
assert.file('other/lib/cli.js')
})
})
67 changes: 67 additions & 0 deletions __tests__/readme.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
'use strict'

const assert = require('yeoman-assert')
const helpers = require('yeoman-test')

describe('community:readme', () => {
afterAll(() => {
process.setMaxListeners(0)
})

beforeEach(() => {
return helpers.run(require.resolve('../generators/readme'))
.withOptions({
name: 'my-project',
description: 'a cool project',
githubAccount: 'yeoman',
authorName: 'Yeoman',
authorUrl: 'http://yeoman.io'
})
.on('ready', (gen) => {
gen.fs.writeJSON(gen.destinationPath('package.json'), {
license: 'MIT',
repository: 'org/repo'
})
})
})

it('writes the license (if one has been declared)', () => {
assert.file('README.md')
assert.fileContent('README.md', '> a cool project')
assert.fileContent('README.md', '[MIT][license-url] © [Yeoman][author-url]')
})

it('writes a link reference for new "feature request" issues', () => {
assert.fileContent('README.md', '[issues-new-feat-url]: /org/repo/issues/new?title=feat')
})

it('writes a link reference for new "defect (bug)" issues', () => {
assert.fileContent('README.md', '[issues-new-defect-url]: /org/repo/issues/new?title=fix')
})
})

describe('community:readme --generate-into', () => {
beforeEach(() => {
return helpers.run(require.resolve('../generators/readme'))
.withOptions({
name: 'my-project',
description: 'a cool project',
githubAccount: 'yeoman',
authorName: 'Yeoman',
authorUrl: 'http://yeoman.io',
generateInto: 'other/'
})
.on('ready', (gen) => {
gen.fs.writeJSON(gen.destinationPath('other/package.json'), {
license: 'MIT'
})
})
})

it('creates and fill contents in README.md', () => {
assert.file('other/README.md')
assert.fileContent('other/README.md', '> a cool project')
assert.fileContent('other/README.md', '[MIT][license-url] © [Yeoman][author-url]')
assert.fileContent('other/README.md', '[issues-new-feat-url]: ./issues/new?title=feat')
})
})
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ install:
- npm install --silent --quiet

platform:
- x86
- x64

build: off
Expand Down
Binary file added docs/img/icons8/icon-markdown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions generators/app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
### Usage

```shell
yo community:readme -h
Usage:
yo community:readme [options]

Options:
-h, --help # Print the generator's options and usage
--skip-cache # Do not remember prompt answers Default: false
--skip-install # Do not automatically install dependencies Default: false
--authorName # Author name
--authorUrl # Author URL
--generateInto # Destination directory for generated files
--githubAccount # GitHub account/organization name
--description # Product description
--lang # Product's primary programming language Default: Unspecified
--licenseName # Open source software license
--licenseUrl # URL to your LICENSE file Default: ./LICENSE
--name # Product name
-a, --includeApi # README.md: Public API overview (optional) Default: true
-b, --includeBackground # README.md: Background section content (optional) Default: false
-c, --includeConfig # README.md: Configuration instructions (optional) Default: false
-o, --includeOverview # README.md: Overview section content (optional) Default: false
-s, --includeSecurity # README.md: Security section content (optional) Default: false
```

### API
99 changes: 99 additions & 0 deletions generators/app/default-options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
const defaultOptions = {
authorName: {
desc: 'Author name',
required: true,
type: String
},
authorUrl: {
desc: 'Author URL',
required: true,
type: String
},
dependencyManager: {
defaults: 'Unspecified',
desc: 'Tool used to install third-party libraries',
required: false,
type: String
},
generateInto: {
defaults: '',
desc: 'Destination directory for generated files',
required: false,
type: String
},
gitRemoteOriginUrl: {
defaults: '/',
desc: 'The URI (SSH or HTTPS) of your Git repository',
required: false,
type: String
},
githubAccount: {
desc: 'GitHub account/organization name',
required: true,
type: String
},
description: {
desc: 'Product description',
required: true,
type: String
},
lang: {
defaults: 'Unspecified',
desc: 'Product\'s primary programming language',
required: true,
type: String
},
license: {
desc: 'Open source software license',
required: false,
type: String
},
licenseUrl: {
default: './LICENSE',
desc: 'URL to your LICENSE file',
required: true,
type: String
},
name: {
desc: 'Product name',
required: true,
type: String
},
includeApi: {
alias: 'a',
defaults: true,
desc: 'README.md: Public API overview (optional)',
required: false,
type: Boolean
},
includeBackground: {
alias: 'b',
defaults: false,
desc: 'README.md: Background section content (optional)',
required: false,
type: Boolean
},
includeConfig: {
alias: 'c',
defaults: false,
desc: 'README.md: Configuration instructions (optional)',
required: false,
type: Boolean
},
includeOverview: {
alias: 'o',
defaults: false,
desc: 'README.md: Overview section content (optional)',
required: false,
type: Boolean
},
includeSecurity: {
alias: 's',
defaults: false,
desc: 'README.md: Security section content (optional)',
required: false,
type: Boolean
}
}

module.exports = defaultOptions
Loading

0 comments on commit 64571b9

Please sign in to comment.