mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 01:58:29 +00:00
In Yeoman generator, support passing args from command line (e.g., --framework=angular-2)
This commit is contained in:
@@ -5,6 +5,9 @@ import * as glob from 'glob';
|
|||||||
const yosay = require('yosay');
|
const yosay = require('yosay');
|
||||||
const toPascalCase = require('to-pascal-case');
|
const toPascalCase = require('to-pascal-case');
|
||||||
|
|
||||||
|
type YeomanPrompt = (opt: yeoman.IPromptOptions | yeoman.IPromptOptions[], callback: (answers: any) => void) => void;
|
||||||
|
const optionOrPrompt: YeomanPrompt = require('yeoman-option-or-prompt');
|
||||||
|
|
||||||
const templates = [
|
const templates = [
|
||||||
{ value: 'angular-2', name: 'Angular 2' },
|
{ value: 'angular-2', name: 'Angular 2' },
|
||||||
{ value: 'knockout', name: 'Knockout' },
|
{ value: 'knockout', name: 'Knockout' },
|
||||||
@@ -14,16 +17,18 @@ const templates = [
|
|||||||
|
|
||||||
class MyGenerator extends yeoman.Base {
|
class MyGenerator extends yeoman.Base {
|
||||||
private _answers: any;
|
private _answers: any;
|
||||||
|
private _optionOrPrompt: YeomanPrompt;
|
||||||
|
|
||||||
constructor(args: string | string[], options: any) {
|
constructor(args: string | string[], options: any) {
|
||||||
super(args, options);
|
super(args, options);
|
||||||
|
this._optionOrPrompt = optionOrPrompt;
|
||||||
this.log(yosay('Welcome to the ASP.NET Core Single-Page App generator!'));
|
this.log(yosay('Welcome to the ASP.NET Core Single-Page App generator!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
prompting() {
|
prompting() {
|
||||||
const done = this.async();
|
const done = this.async();
|
||||||
|
|
||||||
this.prompt([{
|
this._optionOrPrompt([{
|
||||||
type: 'list',
|
type: 'list',
|
||||||
name: 'framework',
|
name: 'framework',
|
||||||
message: 'Framework',
|
message: 'Framework',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "generator-aspnetcore-spa",
|
"name": "generator-aspnetcore-spa",
|
||||||
"version": "0.2.6",
|
"version": "0.2.7",
|
||||||
"description": "Single-Page App templates for ASP.NET Core",
|
"description": "Single-Page App templates for ASP.NET Core",
|
||||||
"author": "Microsoft",
|
"author": "Microsoft",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
"node-uuid": "^1.4.7",
|
"node-uuid": "^1.4.7",
|
||||||
"to-pascal-case": "^1.0.0",
|
"to-pascal-case": "^1.0.0",
|
||||||
"yeoman-generator": "^0.20.2",
|
"yeoman-generator": "^0.20.2",
|
||||||
|
"yeoman-option-or-prompt": "^1.0.2",
|
||||||
"yosay": "^1.1.1"
|
"yosay": "^1.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user