Git Product home page Git Product logo

generator-ng-appgen's People

Contributors

dadagama avatar tapas4java avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

generator-ng-appgen's Issues

creating a 'complex' service

i want to create a 'complex' service (like the complex directive template) but the difference is that i want it to have a .command suffix instead of the .service suffix while creating a 'command' type service.

what happens now is the generator creates the files still with the .service suffix and omits the file name all together...

here's my code for the service index.js:

`
'use strict';
var util = require('util');
var yeoman = require('yeoman-generator');
var path = require('path');
var cgUtils = require('../utils.js');
var chalk = require('chalk');
var _ = require('underscore');
var fs = require('fs');

_.str = require('underscore.string');
.mixin(.str.exports());

var ServiceGenerator = module.exports = function ServiceGenerator(args, options, config) {

cgUtils.getNameArg(this, args);
yeoman.generators.Base.apply(this, arguments);

};

util.inherits(ServiceGenerator, yeoman.generators.Base);

ServiceGenerator.prototype.askFor = function askFor() {
var cb = this.async();

var prompts = [{
    type: 'confirm',
    name: 'isCommand',
    message: 'Will this service act as a command?',
    default: false
}];

cgUtils.addNamePrompt(this, prompts, 'service');

this.prompt(prompts, function(props) {
    if (props.name) {
        this.name = props.name;
    }
    this.isCommand = props.isCommand;
    cgUtils.askForModuleAndDir('service', this, false, cb); //Tapas: no need to ask for own directory(this.isCommand)
}.bind(this));

};

ServiceGenerator.prototype.files = function files() {

var configName = 'serviceSimpleTemplates';
var defaultDir = 'templates/simple';
var suffix     = 'service';
if (this.isCommand) {
    configName = 'commandComplexTemplates';
    defaultDir = 'templates/complex';
    suffix     = 'command';
}

this.htmlPath = path.join(this.dir, this.name + '.service.html').replace(/\\/g, '/');
this.htmlPath = this.htmlPath.replace('app/', '');

cgUtils.processTemplates(this.name, this.dir, suffix, this, defaultDir, configName, this.module);

};
`
any suggestions will be most welcome!

Karma config does not support angular-route

The default karma.conf.js list of files only includes angular-ui-router.js by default. But if during yo scaffolding you choose ngRoute you run into two grunt test problems.

A warning that angular-route.js isn't installed:

WARN [watcher]: Pattern "/Users/me/Angular/angular-ng-appgen/bower_components/angular-ui-router/release/angular-ui-router.js" 
does not match any file.

And, an an ugly set of errors indicating angular-route.js is not among karma.conf.js files (a part of one error):

homeService
    โœ– should return welcome message
      Chrome 41.0.2272 (Mac OS X 10.9.5)
    Error: [$injector:modulerr] Failed to instantiate module home due to:
    Error: [$injector:modulerr] Failed to instantiate module ngRoute due to:
    Error: [$injector:nomod] Module 'ngRoute' is not available! You either misspelled the module name or
 forgot to load it. If registering a module ensure that you specify the dependencies as the second 
argument.

One simple (though not elegant) solution would be to include in the generator's karma.conf.js a reference to angular-route.js along with the default angular-ui-router.js.

       files : [
            'bower_components/angular/angular.js',
            'bower_components/angular-mocks/angular-mocks.js',
            'bower_components/underscore/underscore.js',
            'bower_components/angular-ui-router/release/angular-ui-router.js', 
            ***'bower_components/angular-route/angular-route.js', ***
            'bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
            'bower_components/angular-ui-utils/ui-utils.js',
            'bower_components/angular-animate/angular-animate.js',
            'bower_components/restangular/dist/restangular.js',
            'app/*/*.js',
            'app/**/**/*.js',
            'test/specs/**/**/*-spec.js'
        ],

Then, testing produces only a benign file not found warning which ever router you choose. Seems like a reasonable trade off when compared with the time it would take to build karma.conf.js dynamically :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.