generator-node-tsnext
Advanced tools
Comparing version 1.8.0 to 1.9.0
269
app/index.js
@@ -1,137 +0,134 @@ | ||
const Generator = require('yeoman-generator'); | ||
const chalk = require('chalk'); | ||
const yosay = require('yosay'); | ||
const ghUser = require('gh-user'); | ||
module.exports = class extends Generator { | ||
initializing() { | ||
try { | ||
const ghTask = this.user.github.username() | ||
.then(un => Promise.all([un, ghUser(un)])) | ||
.then(([un, info]) => { | ||
return [un, info.html_url]; | ||
}) | ||
.catch(() => []); | ||
return ghTask.then(([ username, homepage ]) => { | ||
this.user.info = { | ||
name: this.user.git.name(), | ||
email: this.user.git.email(), | ||
username, | ||
homepage, | ||
}; | ||
}); | ||
} catch (_) { | ||
this.user.info = { | ||
name: this.user.git.name() || '', | ||
email: this.user.git.email() || '', | ||
username: '', | ||
homepage: '', | ||
}; | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const gh_user_1 = __importDefault(require("gh-user")); | ||
const yeoman_generator_1 = __importDefault(require("yeoman-generator")); | ||
const yosay_1 = __importDefault(require("yosay")); | ||
class Index extends yeoman_generator_1.default { | ||
constructor() { | ||
super(...arguments); | ||
this.packageName = 'generator-node-tsnext'; | ||
} | ||
} | ||
prompting() { | ||
this.log(yosay(`Welcome to the stunning ${chalk.red('generator-node-tsnext')}!`)); | ||
const fallbackDescription = | ||
'Simple Node.js module to output greeting message, written in TypeScript'; | ||
const prompts = [ | ||
{ | ||
type: 'input', | ||
name: 'packageName', | ||
message: 'What would you like your project to be named?', | ||
default: () => { | ||
return process.cwd().replace(/(?:.*[/\\])([^/\\]+?)[/\\]*?$/gi, '$1'); | ||
}, | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'description', | ||
message: 'Description', | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'homepage', | ||
message: 'Homepage URL', | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'repoUrl', | ||
message: 'Link to the repository', | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'authorName', | ||
message: 'Author\'s Name', | ||
default: this.user.info.name, | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'authorEmail', | ||
message: 'Author\'s email', | ||
default: this.user.info.email, | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'authorUrl', | ||
message: 'Author\'s homepage', | ||
default: this.user.info.homepage, | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'gitName', | ||
message: 'Github username or organization', | ||
default: this.user.info.username, | ||
}, | ||
]; | ||
return this.prompt(prompts).then((props) => { | ||
this.props = Object.assign({}, props, { | ||
docDescription: (props.description || fallbackDescription).replace( | ||
/typeScript/i, '[TypeScript][typescript-url]'), | ||
thisYear: new Date().getFullYear(), | ||
}); | ||
}); | ||
} | ||
writing() { | ||
const NON_TPLS = [ | ||
'src/index.ts', | ||
'tsconfig.json', | ||
'tsconfig.prod.json', | ||
'tslint.json', | ||
'tslint.prod.json', | ||
]; | ||
const TPLS = [ | ||
'_.editorconfig', | ||
'_.gitattributes', | ||
'_.gitignore', | ||
'_.npmrc', | ||
'_LICENSE', | ||
'_package.json', | ||
'_README.md', | ||
]; | ||
NON_TPLS.map((n) => { | ||
return this.fs.copy( | ||
this.templatePath(n), | ||
this.destinationPath(n), | ||
this.props); | ||
}); | ||
TPLS.map((n) => { | ||
return this.fs.copyTpl( | ||
this.templatePath(n), | ||
this.destinationPath(n.replace(/(_)/gi, '')), | ||
this.props); | ||
}); | ||
} | ||
install() { | ||
this.installDependencies({ | ||
bower: false, | ||
npm: true, | ||
}); | ||
} | ||
}; | ||
initializing() { | ||
try { | ||
const ghTask = this.user.github.username() | ||
.then((un) => Promise.all([un, gh_user_1.default(un)])) | ||
.then(([un, info]) => { | ||
return [un, info.html_url]; | ||
}) | ||
.catch(() => []); | ||
return ghTask.then(([username, homepage]) => { | ||
this.user.info = { | ||
username, | ||
homepage, | ||
name: this.user.git.name(), | ||
email: this.user.git.email(), | ||
}; | ||
}); | ||
} | ||
catch (_) { | ||
this.user.info = { | ||
name: this.user.git.name() || '', | ||
email: this.user.git.email() || '', | ||
username: '', | ||
homepage: '', | ||
}; | ||
} | ||
} | ||
prompting() { | ||
this.log(yosay_1.default(`Welcome to the stunning ${chalk_1.default.red(this.packageName)}!`)); | ||
const fallbackDescription = 'Simple Node.js module to output greeting message, written in TypeScript'; | ||
const prompts = [ | ||
{ | ||
type: 'input', | ||
name: 'packageName', | ||
message: 'What would you like your project to be named?', | ||
default: () => { | ||
return process.cwd().replace(/(?:.*[/\\])([^/\\]+?)[/\\]*?$/gi, '$1'); | ||
}, | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'description', | ||
message: 'Description', | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'homepage', | ||
message: 'Homepage URL', | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'repoUrl', | ||
message: 'Link to the repository', | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'authorName', | ||
message: 'Author\'s Name', | ||
default: this.user.info.name, | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'authorEmail', | ||
message: 'Author\'s email', | ||
default: this.user.info.email, | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'authorUrl', | ||
message: 'Author\'s homepage', | ||
default: this.user.info.homepage, | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'gitName', | ||
message: 'Github username or organization', | ||
default: this.user.info.username, | ||
}, | ||
]; | ||
return this.prompt(prompts).then((props) => { | ||
this.props = Object.assign({}, props, { | ||
docDescription: (props.description || fallbackDescription).replace(/typeScript/i, '[TypeScript][typescript-url]'), | ||
thisYear: new Date().getFullYear(), | ||
}); | ||
}); | ||
} | ||
writing() { | ||
const NON_TPLS = [ | ||
'src/index.ts', | ||
'tsconfig.json', | ||
'tsconfig.prod.json', | ||
'tslint.json', | ||
'tslint.prod.json', | ||
]; | ||
const TPLS = [ | ||
'_.editorconfig', | ||
'_.gitattributes', | ||
'_.gitignore', | ||
'_.npmrc', | ||
'_LICENSE', | ||
'_package.json', | ||
'_README.md', | ||
]; | ||
NON_TPLS.map((n) => { | ||
return this.fs.copy(this.templatePath(n), this.destinationPath(n), this.props); | ||
}); | ||
TPLS.map((n) => { | ||
return this.fs.copyTpl(this.templatePath(n), this.destinationPath(n.replace(/(_)/gi, '')), this.props); | ||
}); | ||
} | ||
install() { | ||
this.installDependencies({ | ||
bower: false, | ||
npm: true, | ||
}); | ||
} | ||
} | ||
exports.Index = Index; | ||
exports.default = Index; | ||
module.exports = Index; | ||
//# sourceMappingURL=index.js.map |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ <div align="center" style="text-align: center;"> |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ { |
{ | ||
"name": "generator-node-tsnext", | ||
"version": "1.8.0", | ||
"version": "1.9.0", | ||
"description": "Generator for developing in TypeScript Next", | ||
@@ -25,5 +25,14 @@ "keywords": [ | ||
"main": "app/index.js", | ||
"module": "app/index.js", | ||
"scripts": { | ||
"clean": "shx rm -rf dist/ coverage/", | ||
"test": "jest --config ./.jestrc.json" | ||
"build": "npm run clean && npm run lint && npm run ts -- -p ./tsconfig.json", | ||
"build:prod": "npm run clean && npm run lint:prod && npm run ts -- -p ./tsconfig.prod.json", | ||
"clean": "shx rm -rf coverage/ app/tests/ app/index.js app/index.js.map app/index.d.ts app/index.d.ts.map", | ||
"jest": "jest --config ./.jestrc.json", | ||
"lint": "tslint --project tsconfig.json", | ||
"lint:prod": "npm run lint -- --config tslint.prod.json --format stylish", | ||
"prepublishOnly": "npm run build:prod", | ||
"postpublish": "npm run clean", | ||
"test": "npm run build && npm run jest", | ||
"ts": "tsc" | ||
}, | ||
@@ -33,8 +42,18 @@ "dependencies": { | ||
"gh-user": "^4.0.0", | ||
"yeoman-generator": "^4.0.2", | ||
"yeoman-generator": "^4.1.0", | ||
"yosay": "^2.0.1" | ||
}, | ||
"devDependencies": { | ||
"@reallyland/tsconfig": "^1.0.0", | ||
"@reallyland/tslint-config": "^1.1.1", | ||
"@types/jest": "^24.0.18", | ||
"@types/node": "^12.7.11", | ||
"@types/yeoman-assert": "^3.1.1", | ||
"@types/yeoman-generator": "^3.1.4", | ||
"@types/yeoman-test": "^2.0.3", | ||
"@types/yosay": "0.0.29", | ||
"jest": "^24.9.0", | ||
"shx": "^0.3.2", | ||
"tslint": "^5.20.0", | ||
"typescript": "^3.6.3", | ||
"yeoman-assert": "^3.1.1", | ||
@@ -41,0 +60,0 @@ "yeoman-test": "^2.0.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
32602
19
178
14
Updatedyeoman-generator@^4.1.0