Skip to content
This repository was archived by the owner on Feb 13, 2019. It is now read-only.

Removed .remote(), added mocha test coverage for all application types etc. #59

Merged
merged 2 commits into from
Feb 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
.DS_Store
npm-debug.log
.npmignore
.npmignore
.tmp
59 changes: 29 additions & 30 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
var yeoman = require('yeoman-generator');
var yosay = require('yosay');
var chalk = require('chalk');

var path = require('path');
var AspnetGenerator = yeoman.generators.Base.extend({

init: function () {
Expand All @@ -17,6 +17,10 @@ var AspnetGenerator = yeoman.generators.Base.extend({
name: 'type',
message: 'What type of application do you want to create?',
choices: [
{
name: 'Empty Application',
value: 'empty'
},
{
name: 'Console Application',
value: 'console'
Expand All @@ -37,7 +41,7 @@ var AspnetGenerator = yeoman.generators.Base.extend({
name: 'Class Library',
value: 'classlib'
},
{
{
name: 'Unit test project',
value: 'unittest'
}
Expand All @@ -55,6 +59,9 @@ var AspnetGenerator = yeoman.generators.Base.extend({
var done = this.async();
var app = '';
switch (this.type) {
case 'empty':
app = 'EmptyApplication';
break;
case 'console':
app = 'ConsoleApplication';
break;
Expand All @@ -70,62 +77,52 @@ var AspnetGenerator = yeoman.generators.Base.extend({
case 'classlib':
app = 'ClassLibrary'
break;
case 'unittest':
case 'unittest':
app = 'UnitTest'
break;
}
var prompts = [{
name: 'applicationName',
message: 'What\'s the name of your ASP.NET application?',
default: app
} ];
}];
this.prompt(prompts, function (props) {
this.applicationName = props.applicationName;

done();
}.bind(this));
},

retrieveContent: function () {
var done = this.async();
var self = this;
this.remote('OmniSharp', 'generator-aspnet', 'release', function (err, remote) {
if(err) {
self.log.error(err);
process.exit(1);
}
done();
}, true);
},

writing: function () {
this.sourceRoot(path.join(__dirname, '../samples/'));

this.mkdir(this.applicationName);
switch (this.type) {
case 'console':
this.directory(this.cacheRoot() + '/OmniSharp/generator-aspnet/release/samples/console', this.applicationName);

case 'empty':
this.template(this.type + '/startup.cs', this.applicationName + '/Startup.cs', {
namespace: this.applicationName
});

this.copy(this.type + '/project.json', this.applicationName + '/project.json');

break;

case 'console':
case 'web':
this.directory(this.cacheRoot() + '/OmniSharp/generator-aspnet/release/samples/web', this.applicationName);
break;
case 'mvc':
this.directory(this.cacheRoot() + '/OmniSharp/generator-aspnet/release/samples/mvc', this.applicationName);
break;
case 'nancy':
this.directory(this.cacheRoot() + '/OmniSharp/generator-aspnet/release/samples/nancy', this.applicationName);
break;
case 'classlib':
this.directory(this.cacheRoot() + '/OmniSharp/generator-aspnet/release/samples/classlib', this.applicationName);
break;
case 'unittest':
this.directory(this.cacheRoot() + '/OmniSharp/generator-aspnet/release/samples/unittest', this.applicationName);
case 'unittest':
this.directory(this.type, this.applicationName);
break;
default:
this.log('Unknown project type');
}
},

end: function () {
this.log(this.cacheRoot());
//this.log(this.cacheRoot());
if (!this.options['skip-install']) {
this.log('\r\n');
this.log('Your project is now created, you can use the following commands to get going');
Expand All @@ -136,6 +133,8 @@ var AspnetGenerator = yeoman.generators.Base.extend({
this.log('\r\n');
}
}


});

module.exports = AspnetGenerator;
module.exports = AspnetGenerator;
100 changes: 54 additions & 46 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,56 +1,64 @@
{
"name": "generator-aspnet",
"version": "0.0.27",
"description": "Yeoman generator for ASP.NET 5 apps",
"license": "Apache License 2.0",
"main": "app/index.js",
"repository": "OmniSharp/generator-aspnet",
"contributors": [
{
"name": "Sourabh Shirhatti",
"email": "[email protected]",
"url": "https://github.com/shirhatti"
},
{
"name": "Sayed Hashimi",
"email": "[email protected]"
},
{
"name": "Shayne Boyer",
"email": "[email protected]",
"url": "https://github.com/spboyer"
},
{
"name": "Jonathan Channon",
"email": "[email protected]"
},
{
"name": "Peter Blazejewicz",
"email": "[email protected]",
"url": "https://github.com/peterblazejewicz"
},
{
"name": "Suhas Joshi",
"email": "[email protected]"
"name": "generator-aspnet",
"version": "0.0.27",
"description": "Yeoman generator for ASP.NET 5 apps",
"license": "Apache License 2.0",
"main": "app/index.js",
"repository": "OmniSharp/generator-aspnet",
"contributors": [
{
"name": "Sourabh Shirhatti",
"email": "[email protected]",
"url": "https://github.com/shirhatti"
},
{
"name": "Sayed Hashimi",
"email": "[email protected]"
},
{
"name": "Shayne Boyer",
"email": "[email protected]",
"url": "https://github.com/spboyer"
},
{
"name": "Jonathan Channon",
"email": "[email protected]"
},
{
"name": "Peter Blazejewicz",
"email": "[email protected]",
"url": "https://github.com/peterblazejewicz"
},
{
"name": "Suhas Joshi",
"email": "[email protected]"
}
],
"engines": {
"node": ">=0.10.0"
},
"keywords": [
"engines": {
"node": ">=0.10.0"
},
"keywords": [
"yeoman-generator",
"ASP.NET",
"aspnet",
"ASP",
"net",
"vNext"
],
"dependencies": {
"yeoman-generator": "~0.18.5",
"yosay": "^0.1.0",
"chalk": "~0.4.0"
},
"peerDependencies": {
"yo": ">=1.0.0"
}
}
"dependencies": {
"chai": "^1.10.0",
"chalk": "~0.4.0",
"fs-extra": "^0.16.3",
"gulp": "^3.8.10",
"mocha": "^2.1.0",
"yeoman-generator": "~0.18.5",
"yosay": "^0.1.0"
},
"peerDependencies": {
"yo": ">=1.0.0"
},
"scripts": {
"test": "mocha"
}

}
14 changes: 14 additions & 0 deletions samples/empty/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;

namespace <%= namespace %>
{
public class Startup
{
public void Configure(IApplicationBuilder app)
{
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
}
}
}
21 changes: 21 additions & 0 deletions samples/empty/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"exclude": [
"wwwroot"
],
"packExclude": [
"node_modules",
"bower_components",
"**.kproj",
"**.user",
"**.vspscc"
],
"dependencies": {
"Microsoft.AspNet.Server.IIS": "1.0.0-beta2"
},
"frameworks": {
"aspnet50": {},
"aspnetcore50": {}
}
}
Binary file removed samples/web/bin/Debug/aspnet50/web.dll
Binary file not shown.
8 changes: 0 additions & 8 deletions samples/web/bin/Debug/aspnet50/web.xml

This file was deleted.

Binary file removed samples/web/bin/Debug/web.0.1-alpha-SNAPSHOT.nupkg
Binary file not shown.
Binary file not shown.
22 changes: 11 additions & 11 deletions script-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ var yeoman = require('yeoman-generator');
var chalk = require('chalk');

var NamedGenerator = module.exports = function NamedGenerator() {
yeoman.generators.NamedBase.apply(this, arguments);
yeoman.generators.NamedBase.apply(this, arguments);

var sourceRoot = '/templates/';
this.sourceRoot(path.join(__dirname, sourceRoot));
var sourceRoot = '/templates/';
this.sourceRoot(path.join(__dirname, sourceRoot));
};

util.inherits(NamedGenerator, yeoman.generators.NamedBase);

NamedGenerator.prototype.generateTemplateFile = function(templateFile, targetFile, templateData) {
this.log('You called the aspnet subgenerator with the arg ' + this.name);
NamedGenerator.prototype.generateTemplateFile = function (templateFile, targetFile, templateData) {
this.log('You called the aspnet subgenerator with the arg ' + this.name);

if(templateData !== null){
this.template(templateFile, targetFile, templateData);
} else {
this.template(templateFile, targetFile);
}
if (templateData !== null) {
this.template(templateFile, targetFile, templateData);
} else {
this.template(templateFile, targetFile);
}

this.log(targetFile + ' created.')
this.log(targetFile + ' created.')
}
Loading