mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-25 11:07:29 +00:00
Rename folders since the template package generator now creates a package for "dotnet new" as well as Yeoman
This commit is contained in:
1
templates/package-builder/src/yeoman/.gitignore
vendored
Normal file
1
templates/package-builder/src/yeoman/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/node_modules/
|
||||
77
templates/package-builder/src/yeoman/app/index.ts
Normal file
77
templates/package-builder/src/yeoman/app/index.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import * as path from 'path';
|
||||
import * as yeoman from 'yeoman-generator';
|
||||
import * as uuid from 'node-uuid';
|
||||
import * as glob from 'glob';
|
||||
const yosay = require('yosay');
|
||||
const toPascalCase = require('to-pascal-case');
|
||||
|
||||
const templates = [
|
||||
{ value: 'angular-2', name: 'Angular 2' },
|
||||
{ value: 'knockout', name: 'Knockout' },
|
||||
{ value: 'react', name: 'React' },
|
||||
{ value: 'react-redux', name: 'React with Redux' }
|
||||
];
|
||||
|
||||
class MyGenerator extends yeoman.Base {
|
||||
private _answers: any;
|
||||
|
||||
constructor(args: string | string[], options: any) {
|
||||
super(args, options);
|
||||
this.log(yosay('Welcome to the ASP.NET Core Single-Page App generator!'));
|
||||
}
|
||||
|
||||
prompting() {
|
||||
const done = this.async();
|
||||
|
||||
this.prompt([{
|
||||
type: 'list',
|
||||
name: 'framework',
|
||||
message: 'Framework',
|
||||
choices: templates
|
||||
}, {
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'Your project name',
|
||||
default: this.appname
|
||||
}], answers => {
|
||||
this._answers = answers;
|
||||
this._answers.namePascalCase = toPascalCase(answers.name);
|
||||
this._answers.projectGuid = uuid.v4();
|
||||
done();
|
||||
});
|
||||
}
|
||||
|
||||
writing() {
|
||||
var templateRoot = this.templatePath(this._answers.framework);
|
||||
glob.sync('**/*', { cwd: templateRoot, dot: true, nodir: true }).forEach(fn => {
|
||||
// Token replacement in filenames
|
||||
let outputFn = fn.replace(/tokenreplace\-([^\.\/]*)/g, (substr, token) => this._answers[token]);
|
||||
|
||||
// Rename template_gitignore to .gitignore in output
|
||||
if (path.basename(fn) === 'template_gitignore') {
|
||||
outputFn = path.join(path.dirname(fn), '.gitignore');
|
||||
}
|
||||
|
||||
this.fs.copyTpl(
|
||||
path.join(templateRoot, fn),
|
||||
this.destinationPath(outputFn),
|
||||
this._answers
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
installingDeps() {
|
||||
this.installDependencies({
|
||||
npm: true,
|
||||
bower: false,
|
||||
callback: () => {
|
||||
this.spawnCommandSync('dotnet', ['restore']);
|
||||
this.spawnCommandSync('./node_modules/.bin/webpack', ['--config', 'webpack.config.vendor.js']);
|
||||
this.spawnCommandSync('./node_modules/.bin/webpack');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
declare var module: any;
|
||||
(module).exports = MyGenerator;
|
||||
20
templates/package-builder/src/yeoman/package.json
Normal file
20
templates/package-builder/src/yeoman/package.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "generator-aspnetcore-spa",
|
||||
"version": "0.2.3",
|
||||
"description": "Single-Page App templates for ASP.NET Core",
|
||||
"author": "Microsoft",
|
||||
"license": "Apache-2.0",
|
||||
"files": [
|
||||
"app"
|
||||
],
|
||||
"keywords": [
|
||||
"yeoman-generator"
|
||||
],
|
||||
"dependencies": {
|
||||
"glob": "^7.0.3",
|
||||
"node-uuid": "^1.4.7",
|
||||
"to-pascal-case": "^1.0.0",
|
||||
"yeoman-generator": "^0.20.2",
|
||||
"yosay": "^1.1.1"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user