How to use the yeoman-generator.extend function in yeoman-generator

To help you get started, we’ve selected a few yeoman-generator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBM-Swift / generator-swiftserver / app / index.js View on Github external
'use strict'
var debug = require('debug')('generator-swiftserver:app')

var Generator = require('yeoman-generator')
var chalk = require('chalk')
var path = require('path')
var Handlebars = require('../lib/handlebars.js')
var actions = require('../lib/actions')
var helpers = require('../lib/helpers')
var validateDirName = helpers.validateDirName
var validateAppName = helpers.validateAppName
var validateCredential = helpers.validateRequiredCredential
var validatePort = helpers.validatePort
var generateServiceName = helpers.generateServiceName

module.exports = Generator.extend({

  constructor: function () {
    Generator.apply(this, arguments)
    // Allow the user to pass the application name into the generator directly
    this.argument('name', {
      desc: 'Name of the application to scaffold.',
      required: false,
      type: String
    })

    this.option('init', {
      type: Boolean,
      desc: 'Generate basic default scaffold without prompting user for input.',
      defaults: false
    })
github ff4j / generator-jhipster-ff4j / generators / app / index.js View on Github external
// Stores JHipster variables
const jhipsterVar 	= { moduleName: 'ff4j' };

// Stores JHipster functions
const jhipsterFunc 	= {};

// Stores JHipster functions
const jhipsterUtils = {};

// Constants
const TPL 					= 'template';
const FF4J_VERSION  		= '1.6.6-SNAPSHOT';

// Functions available
module.exports = generator.extend( {

	// ----------------------------------------------------
    // Use compose Yeoman capability to maje jhipterVar available (like DB)
    // ----------------------------------------------------
    initializing: {
    	compose() {
            this.composeWith('jhipster:modules',   { 
            	jhipsterVar, 
            	jhipsterFunc,
            	jhipsterUtils},
                this.options.testmode ? { local: require.resolve('generator-jhipster/generators/modules') } : null
            );
        },
        displayLogo() {
            // Have Yeoman greet the user.
            this.log(`Welcome to the ${chalk.bold.yellow('JHipster ff4j')} generator! ${chalk.yellow(`v${packagejs.version}\n`)}`);
github bezoerb / generator-sf / generators / git / index.js View on Github external
'use strict';
const path = require('path');
const Buffer = require('buffer').Buffer;
const _ = require('lodash');
const Generator = require('yeoman-generator');
const spawn = require('cross-spawn');
const Bluebird = require('bluebird');
const fs = Bluebird.promisifyAll(require('fs-extra'));

module.exports = Generator.extend({
  /**
   * Check for installed git
   */
  _gitAvailable: function () {
    // Check if jspm is installed globally
    return new Bluebird((resolve, reject) => {
      this.spawnCommand('git', ['--version'], {stdio: 'ignore'}).on('error', reject).on('exit', resolve);
    });
  },

  _gitBase: function () {
    return new Bluebird((resolve, reject) => {
      let stdErr = [];
      const stdOut = [];
      const spawned = spawn('git', ['rev-parse', '--show-cdup']);
github eslint / generator-eslint / rule / index.js View on Github external
var Generator = require("yeoman-generator");
var validators = require("../lib/validators");

//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------

var isRuleId = validators.isRuleId;
var isRequired = validators.isRequired;

//------------------------------------------------------------------------------
// Constructor
//------------------------------------------------------------------------------

module.exports = Generator.extend({
    prompting: function() {
        var prompts = [{
            type: "input",
            name: "userName",
            message: "What is your name?"
        }, {
            type: "list",
            name: "target",
            message: "Where will this rule be published?",
            choices: [
                { name: "ESLint Core", value: "eslint" },
                { name: "ESLint Plugin", value: "plugin" }
            ]
        }, {
            type: "input",
            name: "ruleId",
github abbas-oveissi / generator-helma-mvp / generators / app / index.js View on Github external
'use strict';
const generator = require('yeoman-generator');
const chalk = require('chalk');
const yosay = require('yosay');
const util = require('util');
const mkdirp = require('mkdirp');
const HelmaUtils = require('../util');
const BaseGenerator = require('../generator-base');

module.exports = generator.extend({

  initializing: function () {
    this.props = {};
  },

  prompting: function () {
    this.log(yosay(
      'Welcome to the rad ' + chalk.red('Helma MVP Starter') + ' generator!'
    ));

    const prompts = [
      {
        name: 'name',
        message: 'What are you calling your app?',
        store: true,
        default: this.appname // Default to current folder name
github iansawyerva / generator-angular-material / generators / component / index.js View on Github external
}
            }
        }

    },

    install: function() {
        if (hasComponents) {
            this.log('The components have been injected!');
        } else {
            this.log('Are you sure you specified the components in your partial? eg. {{autocomplete}}');
        }
    }
};

module.exports = yeoman.extend(service);
github IBM-Swift / generator-swiftserver / build / index.js View on Github external
* distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

'use strict'
var debug = require('debug')('generator-swiftserver:app')

var Generator = require('yeoman-generator')
var chalk = require('chalk')
var os = require('os')

var actions = require('../lib/actions')

module.exports = Generator.extend({
  initializing: {
    config: function () {
      if (!this.options.singleShot) {
        actions.ensureInProject.call(this)
      }
    }
  },

  install: {
    ensureRequiredSwiftInstalled: actions.ensureRequiredSwiftInstalled,
    buildSwift: function () {
      return new Promise((resolve, reject) => {
        var opts = []
        if (os.platform() === 'darwin') {
          opts = ['-Xlinker', '-lc++']
        }
github mean-expert-official / fireloop.io / generator-fireloop / src / ng2native / index.ts View on Github external
declare var module: any;
declare var require: any;
declare var __dirname: any;
var yosay = require('yosay');
var fs = require('fs');
var generators = require('yeoman-generator');
import * as chalk from 'chalk';
import * as ejs from 'ejs';
/**
 * @module Angular 2 [FireLoop]
 * @author Jonathan Casarrubias 
 * @description
 * This module generates and configure a FireLoop Server
 */
module.exports = generators.extend({
  prompting: function() {
    this.options.clients = this.config.get('clients') || {};
    let done = this.async();
    return this.prompt([{
      type: 'input',
      name: 'name',
      message: 'What\'s the name of your application?',
      default: 'nativeapp'
    }]).then(function(answers: { name: string }) {
      if (this.options.clients[answers.name]) {
        this.log(chalk.red(`\n\nThere is already an application using the name ${answers.name}`));
        done();
      } else {
        this.log(chalk.green(`\n\nCreating new NativeScript 2 Application: ${answers.name}`));
        this.spawnCommand('tns', ['create', answers.name, '--ng'], { })
          .on('exit', (code: number) => {
github iansawyerva / generator-angular-material / generators / verbose-directive / index.js View on Github external
'use strict';
var yeoman = require('yeoman-generator');

var directive = yeoman.extend({

    writing: function(args) {
        this.appname = process.cwd().match(/([^\/]*)\/*$/)[1];
        if (!args) {
            this.directiveName = this.appname.replace(/ /g, '');
        } else {
            this.directiveName = args.replace(/ /g, '');
        }
        this.fs.copyTpl(
            this.templatePath('./verbose-directive.js'),
            this.destinationPath('./public/js/directives/' + this.directiveName + '-directive.js'), {
                AppName: this.appname,
                DirectiveName: this.directiveName + 'Directive'
            }
        );
    },
github bezoerb / generator-sf / generators / view / _common / index.js View on Github external
'use strict';
const path = require('path');
const globby = require('globby');
const Bluebird = require('bluebird');
const pathIsAbsolute = require('path-is-absolute');
const fs = require('fs-extra');
const _ = require('lodash');
const Generator = require('yeoman-generator');

Bluebird.promisifyAll(fs);

module.exports = Generator.extend({

  /**
   * Re-read the content because a composed generator might modify it.
   * @returns {*}
   * @private
   */
  _readPkg: function () {
    return _.merge(this.fs.readJSON(this.destinationPath('package.json'), {
      name: _.camelCase(this.appname),
      version: '0.0.0',
      scripts: {},
      dependencies: {},
      devDependencies: {}
    }), {
      dependencies: {
        debug: '^2.2.0',