-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from robertoachar/develop
v3.0.0
- Loading branch information
Showing
18 changed files
with
210 additions
and
143 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,3 @@ | ||
{ | ||
"presets": ["@babel/preset-env"] | ||
} |
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
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
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
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
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,106 +1,5 @@ | ||
const Generator = require('yeoman-generator'); | ||
/* eslint no-global-assign: 0 */ | ||
|
||
const files = require('./files'); | ||
const validate = require('./validate'); | ||
require = require('esm')(module); | ||
|
||
module.exports = class extends Generator { | ||
initializing() { | ||
this.log('OSS Project Generator'); | ||
this.log('❤️ Made with love by Roberto Achar'); | ||
this.log(); | ||
} | ||
|
||
prompting() { | ||
const done = this.async(); | ||
|
||
const prompts = [ | ||
{ | ||
type: 'input', | ||
name: 'project', | ||
message: 'What is the name of your project?', | ||
default: 'awesome-project' | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'description', | ||
message: 'What is the description of your project?', | ||
default: 'An awesome project' | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'name', | ||
message: 'What is your name?', | ||
validate: validate.validateName, | ||
store: true | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'email', | ||
message: 'What is your email?', | ||
validate: validate.validateEmail, | ||
store: true | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'username', | ||
message: 'What is your GitHub username?', | ||
validate: validate.validateUsername, | ||
store: true | ||
} | ||
]; | ||
|
||
this.prompt(prompts).then((props) => { | ||
this.props = props; | ||
done(); | ||
}); | ||
} | ||
|
||
writing() { | ||
this.log(); | ||
this.log('🚀 Generating project...'); | ||
this.log(); | ||
|
||
const { project, description, name, email, username } = this.props; | ||
|
||
const templates = { | ||
project, | ||
description, | ||
name, | ||
email, | ||
username, | ||
year: new Date().getFullYear() | ||
}; | ||
|
||
files.forEach((file) => { | ||
this.fs.copyTpl( | ||
this.templatePath(file.template), | ||
this.destinationPath(file.destination), | ||
templates | ||
); | ||
}); | ||
} | ||
|
||
install() { | ||
this.log(); | ||
this.log('📦 Installing dependencies...'); | ||
this.log(); | ||
|
||
this.npmInstall( | ||
[ | ||
'@types/jest', | ||
'coveralls', | ||
'eslint', | ||
'eslint-config-prettier', | ||
'eslint-plugin-prettier', | ||
'jest', | ||
'prettier' | ||
], | ||
{ 'save-dev': true } | ||
); | ||
} | ||
|
||
end() { | ||
this.log(); | ||
this.log('🎉 Successfully generated!'); | ||
} | ||
}; | ||
module.exports = require('./main'); |
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,111 @@ | ||
import Generator from 'yeoman-generator'; | ||
|
||
import files from './files'; | ||
import { validateEmail, validateName, validateUsername } from './validate'; | ||
|
||
class OSSGenerator extends Generator { | ||
initializing() { | ||
this.log('OSS Project Generator'); | ||
this.log('❤️ Made with love by Roberto Achar'); | ||
this.log(); | ||
} | ||
|
||
prompting() { | ||
const done = this.async(); | ||
|
||
const prompts = [ | ||
{ | ||
type: 'input', | ||
name: 'project', | ||
message: 'What is the name of your project?', | ||
default: 'awesome-project' | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'description', | ||
message: 'What is the description of your project?', | ||
default: 'An awesome project' | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'name', | ||
message: 'What is your name?', | ||
validate: validateName, | ||
store: true | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'email', | ||
message: 'What is your email?', | ||
validate: validateEmail, | ||
store: true | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'username', | ||
message: 'What is your GitHub username?', | ||
validate: validateUsername, | ||
store: true | ||
} | ||
]; | ||
|
||
this.prompt(prompts).then((props) => { | ||
this.props = props; | ||
done(); | ||
}); | ||
} | ||
|
||
writing() { | ||
this.log(); | ||
this.log('🚀 Generating project...'); | ||
this.log(); | ||
|
||
const { project, description, name, email, username } = this.props; | ||
|
||
const templates = { | ||
project, | ||
description, | ||
name, | ||
email, | ||
username, | ||
year: new Date().getFullYear() | ||
}; | ||
|
||
files.forEach((file) => { | ||
this.fs.copyTpl( | ||
this.templatePath(file.template), | ||
this.destinationPath(file.destination), | ||
templates | ||
); | ||
}); | ||
} | ||
|
||
install() { | ||
this.log(); | ||
this.log('📦 Installing dependencies...'); | ||
this.log(); | ||
|
||
this.npmInstall(['esm']); | ||
|
||
this.npmInstall( | ||
[ | ||
'@babel/preset-env', | ||
'@types/jest', | ||
'coveralls', | ||
'eslint', | ||
'eslint-config-prettier', | ||
'eslint-plugin-prettier', | ||
'jest', | ||
'prettier' | ||
], | ||
{ 'save-dev': true } | ||
); | ||
} | ||
|
||
end() { | ||
this.log(); | ||
this.log('🎉 Successfully generated!'); | ||
} | ||
} | ||
|
||
export default OSSGenerator; |
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,3 @@ | ||
{ | ||
"presets": ["@babel/preset-env"] | ||
} |
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 |
---|---|---|
|
@@ -3,5 +3,8 @@ | |
"env": { | ||
"es6": true, | ||
"jest": true | ||
}, | ||
"parserOptions": { | ||
"sourceType": "module" | ||
} | ||
} |
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
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 @@ | ||
/* eslint no-global-assign: 0 */ | ||
|
||
require = require('esm')(module); | ||
|
||
module.exports = require('./src'); |
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
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 +1,3 @@ | ||
module.exports.hello = () => new Promise((resolve) => resolve('It works!')); | ||
const hello = () => new Promise((resolve) => resolve('Hello!')); | ||
|
||
export default hello; |
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
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,23 +1,25 @@ | ||
module.exports.validateName = (value) => { | ||
const validateName = (value) => { | ||
if (value.length === 0) { | ||
return 'You need to enter your name'; | ||
return 'Enter your name'; | ||
} | ||
|
||
return true; | ||
}; | ||
|
||
module.exports.validateEmail = (value) => { | ||
const validateEmail = (value) => { | ||
if (value.length === 0) { | ||
return 'You need to enter your email'; | ||
return 'Enter your email'; | ||
} | ||
|
||
return true; | ||
}; | ||
|
||
module.exports.validateUsername = (value) => { | ||
const validateUsername = (value) => { | ||
if (value.length === 0) { | ||
return 'You need to enter your username'; | ||
return 'Enter your username'; | ||
} | ||
|
||
return true; | ||
}; | ||
|
||
export { validateEmail, validateName, validateUsername }; |
Oops, something went wrong.