<commit_before>// modules used by the generator
const generator = require('yeoman-generator');
const chalk = require('chalk');
const packagejs = require('../../package.json'); // gives access to the package.json data
const path = require('path');

// modules use by private db-helper functions
const fs = require('fs');
const DBH_CONSTANTS = require('../dbh-constants');
const dbh = require('../dbh.js');
const jhipsterModuleSubgenerator = require('../../node_modules/generator-jhipster/generators/modules/index.js');

// Stores JHipster variables
const jhipsterVar = {
    moduleName: DBH_CONSTANTS.moduleName
};

// Stores JHipster functions
const jhipsterFunc = {};

// polyfill for jhipsterVar and jhipsterFunc when testing, see [issue #19](https://github.com/bastienmichaux/generator-jhipster-db-helper/issues/19)
let polyfill = {};

module.exports = generator.extend({
    // dummy test
    _sayFoo: () => 'foo',

    /**
     * get a polyfill for the jhipsterVar and jhipsterFunc properties gone missing when testing
     * because of a [yeoman-test](https://github.com/bastienmichaux/generator-jhipster-db-helper/issues/19) issue
     *
     * @param {string} appConfigPath - path to the current .yo-rc.json application file
     */
    _getPolyfill: (appConfigPath) => {
        // stop if file not found
        if (!fs.existsSync(appConfigPath)) {
            throw new Error(`_getPolyfill: File ${appConfigPath} not found`);
        }

        // else return a promise holding the polyfill
        return dbh.getAppConfig(appConfigPath)
        .catch(err => console.error(err))
        .then((onResolve) => {
            const conf = onResolve['generator-jhipster'];
            const poly = {};

            // @todo: defensive programming with these properties (hasOwnProperty ? throw ?)

            // jhipsterVar polyfill :

            poly.baseName = conf.baseName;
            poly.packageName = conf.packageName;
            poly.angularAppName = conf.angularAppName || null; // handle an undefined value
            poly.clientFramework = conf.clientFramework;
            poly.clientPackageManager = conf.clientPackageManager;
            poly.buildTool = conf.buildTool;

            // jhipsterFunc polyfill :
            poly.replaceContent = () => jhipsterModuleSubgenerator.prototype.replaceContent;
            poly.registerModule = jhipsterModuleSubgenerator.prototype.registerModule;
            poly.updateEntityConfig = jhipsterModuleSubgenerator.prototype.updateEntityConfig;

            // @todo : handle this.options.testMode ?

            return poly;
        }, onError => console.error(onError));
    },

    /**
     * replace Spring naming strategies with more neutral ones
     * return true if all occurrences are replaced
     *
     * note : after running this function, reference to the ancient naming strategies will still be found in :
     * ./node_modules/generator-jhipster/generators/server/templates/_pom.xml:
     * however this doesn't concern us
     *
     * @todo : write local test for the return value
     * @todo : write unit test
     * @todo : no hardcoded values for removeGradleFiles and removeMavenFiles
     */
    _replaceNamingStrategies: (appBuildTool) => {
        const physicalOld = DBH_CONSTANTS.physicalNamingStrategyOld;
        const physicalNew = DBH_CONSTANTS.physicalNamingStrategyNew;

        const implicitOld = DBH_CONSTANTS.implicitNamingStrategyOld;
        const implicitNew = DBH_CONSTANTS.implicitNamingStrategyNew;

        const files = dbh.getFilesWithNamingStrategy(appBuildTool);

        // check that each file exists, then replace the naming strategies
        files.forEach((path) => {
            if (fs.existsSync(path)) {
                // 1) replace Spring physical naming strategy
                jhipsterFunc.replaceContent(path, physicalOld, physicalNew);
                // 2) replace Spring implicit naming strategy
                jhipsterFunc.replaceContent(path, implicitOld, implicitNew);
            } else {
                throw new Error(`${path} doesn't exist!`);
            }
        });
    },

    // check current project state, get configs, etc
    initializing() {
        // Have Yeoman greet the user.
        this.log(chalk.bold.green(`JHipster db-helper generator v${packagejs.version}`));

        // note : before this line we can't use jhipsterVar or jhipsterFunc
        this.composeWith('jhipster:modules',
            { jhipsterVar, jhipsterFunc },
            this.options.testmode ? { local: require.resolve('generator-jhipster/generators/modules') } : null
        );

        // replace missing properties for testing
        // for the reason why we have to do this, cf [issue #19](https://github.com/bastienmichaux/generator-jhipster-db-helper/issues/19)
        const configFile = path.join(__dirname, '/.yo-rc.json');

        if (!fs.existsSync(configFile)) {
            throw new Error(`This file doesn't exist: ${configFile}`);
        }

        polyfill = this._getPolyfill(configFile)
        .then(
            onFulfilled => {
                return onFulfilled;
            },
            onRejected => {
                return onRejected;
            }
        );
        Object.freeze(polyfill);
    },

    // prompt the user for options
    prompting() {
        const done = this.async();

        // user interaction on module call goes here
        const prompts = [];

        // call the prompts
        this.prompt(prompts).then((props) => {
            this.props = props;
            // To access props later use this.props.someOption;
            done();
        });
    },

    // write the generator-specific files
    writing() {
        // replace files with Spring's naming strategies
        this.log(chalk.bold.yellow('JHipster-db-helper replaces your naming strategies :'));
        this._replaceNamingStrategies(jhipsterVar.jhipsterConfig.buildTool);

        // declarations done by jhipster-module
        this.baseName = jhipsterVar.baseName;
        this.packageName = jhipsterVar.packageName;
        this.angularAppName = jhipsterVar.angularAppName;
        this.clientFramework = jhipsterVar.clientFramework;
        this.clientPackageManager = jhipsterVar.clientPackageManager;
        this.message = this.props.message;

        try {
            jhipsterFunc.registerModule('generator-jhipster-db-helper', 'app', 'post', 'app', 'A JHipster module for already existing databases');
        } catch (err) {
            this.log(`${chalk.red.bold('WARN!')} Could not register as a jhipster entity post creation hook...\n`);
        }

        try {
            jhipsterFunc.registerModule('generator-jhipster-db-helper', 'entity', 'post', 'fix-entity', 'A JHipster module to circumvent JHipster limitations about names');
        } catch (err) {
            this.log(`${chalk.red.bold('WARN!')} Could not register as a jhipster entity post creation hook...\n`);
        }
    },

    // run installation (npm, bower, etc)
    install() {
        let logMsg = `To install your dependencies manually, run: ${chalk.yellow.bold(`${this.clientPackageManager} install`)}`;

        if (this.clientFramework === 'angular1') {
            logMsg = `To install your dependencies manually, run: ${chalk.yellow.bold(`${this.clientPackageManager} install & bower install`)}`;
        }

        const injectDependenciesAndConstants = (err) => {
            if (err) {
                this.log('Install of dependencies failed!');
                this.log(logMsg);
            } else if (this.clientFramework === 'angular1') {
                this.spawnCommand('gulp', ['install']);
            }
        };

        const installConfig = {
            bower: this.clientFramework === 'angular1',
            npm: this.clientPackageManager !== 'yarn',
            yarn: this.clientPackageManager === 'yarn',
            callback: injectDependenciesAndConstants
        };

        this.installDependencies(installConfig);
    },

    // cleanup, say goodbye
    end() {
        this.log(chalk.bold.yellow('End of db-helper generator'));
    }
});
<commit_msg>remove a testing arrow function<commit_after>// modules used by the generator
const generator = require('yeoman-generator');
const chalk = require('chalk');
const packagejs = require('../../package.json'); // gives access to the package.json data
const path = require('path');

// modules use by private db-helper functions
const fs = require('fs');
const DBH_CONSTANTS = require('../dbh-constants');
const dbh = require('../dbh.js');
const jhipsterModuleSubgenerator = require('../../node_modules/generator-jhipster/generators/modules/index.js');

// Stores JHipster variables
const jhipsterVar = {
    moduleName: DBH_CONSTANTS.moduleName
};

// Stores JHipster functions
const jhipsterFunc = {};

// polyfill for jhipsterVar and jhipsterFunc when testing, see [issue #19](https://github.com/bastienmichaux/generator-jhipster-db-helper/issues/19)
let polyfill = {};

module.exports = generator.extend({
    /**
     * get a polyfill for the jhipsterVar and jhipsterFunc properties gone missing when testing
     * because of a [yeoman-test](https://github.com/bastienmichaux/generator-jhipster-db-helper/issues/19) issue
     *
     * @param {string} appConfigPath - path to the current .yo-rc.json application file
     */
    _getPolyfill: (appConfigPath) => {
        // stop if file not found
        if (!fs.existsSync(appConfigPath)) {
            throw new Error(`_getPolyfill: File ${appConfigPath} not found`);
        }

        // else return a promise holding the polyfill
        return dbh.getAppConfig(appConfigPath)
        .catch(err => console.error(err))
        .then((onResolve) => {
            const conf = onResolve['generator-jhipster'];
            const poly = {};

            // @todo: defensive programming with these properties (hasOwnProperty ? throw ?)

            // jhipsterVar polyfill :

            poly.baseName = conf.baseName;
            poly.packageName = conf.packageName;
            poly.angularAppName = conf.angularAppName || null; // handle an undefined value
            poly.clientFramework = conf.clientFramework;
            poly.clientPackageManager = conf.clientPackageManager;
            poly.buildTool = conf.buildTool;

            // jhipsterFunc polyfill :
            poly.replaceContent = () => jhipsterModuleSubgenerator.prototype.replaceContent;
            poly.registerModule = jhipsterModuleSubgenerator.prototype.registerModule;
            poly.updateEntityConfig = jhipsterModuleSubgenerator.prototype.updateEntityConfig;

            // @todo : handle this.options.testMode ?

            return poly;
        }, onError => console.error(onError));
    },

    /**
     * replace Spring naming strategies with more neutral ones
     * return true if all occurrences are replaced
     *
     * note : after running this function, reference to the ancient naming strategies will still be found in :
     * ./node_modules/generator-jhipster/generators/server/templates/_pom.xml:
     * however this doesn't concern us
     *
     * @todo : write local test for the return value
     * @todo : write unit test
     * @todo : no hardcoded values for removeGradleFiles and removeMavenFiles
     */
    _replaceNamingStrategies: (appBuildTool) => {
        const physicalOld = DBH_CONSTANTS.physicalNamingStrategyOld;
        const physicalNew = DBH_CONSTANTS.physicalNamingStrategyNew;

        const implicitOld = DBH_CONSTANTS.implicitNamingStrategyOld;
        const implicitNew = DBH_CONSTANTS.implicitNamingStrategyNew;

        const files = dbh.getFilesWithNamingStrategy(appBuildTool);

        // check that each file exists, then replace the naming strategies
        files.forEach((path) => {
            if (fs.existsSync(path)) {
                // 1) replace Spring physical naming strategy
                jhipsterFunc.replaceContent(path, physicalOld, physicalNew);
                // 2) replace Spring implicit naming strategy
                jhipsterFunc.replaceContent(path, implicitOld, implicitNew);
            } else {
                throw new Error(`${path} doesn't exist!`);
            }
        });
    },

    // check current project state, get configs, etc
    initializing() {
        // Have Yeoman greet the user.
        this.log(chalk.bold.green(`JHipster db-helper generator v${packagejs.version}`));

        // note : before this line we can't use jhipsterVar or jhipsterFunc
        this.composeWith('jhipster:modules',
            { jhipsterVar, jhipsterFunc },
            this.options.testmode ? { local: require.resolve('generator-jhipster/generators/modules') } : null
        );

        // replace missing properties for testing
        // for the reason why we have to do this, cf [issue #19](https://github.com/bastienmichaux/generator-jhipster-db-helper/issues/19)
        const configFile = path.join(__dirname, '/.yo-rc.json');

        if (!fs.existsSync(configFile)) {
            throw new Error(`This file doesn't exist: ${configFile}`);
        }

        polyfill = this._getPolyfill(configFile)
        .then(
            onFulfilled => {
                return onFulfilled;
            },
            onRejected => {
                return onRejected;
            }
        );
        Object.freeze(polyfill);
    },

    // prompt the user for options
    prompting() {
        const done = this.async();

        // user interaction on module call goes here
        const prompts = [];

        // call the prompts
        this.prompt(prompts).then((props) => {
            this.props = props;
            // To access props later use this.props.someOption;
            done();
        });
    },

    // write the generator-specific files
    writing() {
        // replace files with Spring's naming strategies
        this.log(chalk.bold.yellow('JHipster-db-helper replaces your naming strategies :'));
        this._replaceNamingStrategies(jhipsterVar.jhipsterConfig.buildTool);

        // declarations done by jhipster-module
        this.baseName = jhipsterVar.baseName;
        this.packageName = jhipsterVar.packageName;
        this.angularAppName = jhipsterVar.angularAppName;
        this.clientFramework = jhipsterVar.clientFramework;
        this.clientPackageManager = jhipsterVar.clientPackageManager;
        this.message = this.props.message;

        try {
            jhipsterFunc.registerModule('generator-jhipster-db-helper', 'app', 'post', 'app', 'A JHipster module for already existing databases');
        } catch (err) {
            this.log(`${chalk.red.bold('WARN!')} Could not register as a jhipster entity post creation hook...\n`);
        }

        try {
            jhipsterFunc.registerModule('generator-jhipster-db-helper', 'entity', 'post', 'fix-entity', 'A JHipster module to circumvent JHipster limitations about names');
        } catch (err) {
            this.log(`${chalk.red.bold('WARN!')} Could not register as a jhipster entity post creation hook...\n`);
        }
    },

    // run installation (npm, bower, etc)
    install() {
        let logMsg = `To install your dependencies manually, run: ${chalk.yellow.bold(`${this.clientPackageManager} install`)}`;

        if (this.clientFramework === 'angular1') {
            logMsg = `To install your dependencies manually, run: ${chalk.yellow.bold(`${this.clientPackageManager} install & bower install`)}`;
        }

        const injectDependenciesAndConstants = (err) => {
            if (err) {
                this.log('Install of dependencies failed!');
                this.log(logMsg);
            } else if (this.clientFramework === 'angular1') {
                this.spawnCommand('gulp', ['install']);
            }
        };

        const installConfig = {
            bower: this.clientFramework === 'angular1',
            npm: this.clientPackageManager !== 'yarn',
            yarn: this.clientPackageManager === 'yarn',
            callback: injectDependenciesAndConstants
        };

        this.installDependencies(installConfig);
    },

    // cleanup, say goodbye
    end() {
        this.log(chalk.bold.yellow('End of db-helper generator'));
    }
});
<|endoftext|>


<commit_before>'use strict';
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');

module.exports = yeoman.Base.extend({

  prompting: function () {
    var done = this.async();

    // Have Yeoman greet the user.
    this.log(yosay(
      'Welcome to the premium ' + chalk.red('generator-seneca-environment') + ' generator!'
    ));

    var prompts = [{
      type: 'confirm',
      name: 'someAnswer',
      message: 'Would you like to enable this option?',
      default: true
    }];

    this.prompt(prompts, function (props) {
      this.props = props;
      // To access props later use this.props.someAnswer;

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

  writing: function () {
    this.fs.copy(
      this.templatePath('dummyfile.txt'),
      this.destinationPath('dummyfile.txt')
    );
  },

  install: function () {
    this.installDependencies();
  }
});
<commit_msg>add list promp, call service<commit_after>'use strict';
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');

module.exports = yeoman.Base.extend({

  prompting: function () {
    var done = this.async();

    // Have Yeoman greet the user.
    this.log(yosay(
      'Welcome to the ' + chalk.red('seneca-environment') + ' generator!'
    ));

    var prompts = [{
      type: 'list',
      name: 'generator',
      message: 'What do you want?',
      default: 'system',
      choices: [
        {name: 'system', value: 'system'},
        {name: 'base only', value: 'base'},
        {name: 'service only', value: 'service'}]
    }];

    this.prompt(prompts, function (props) {
      this.props = props;
      if (this.props.generator === 'service') {
        this.composeWith('seneca-environment:service');
      } else if (this.props.generator === 'base') {
        // TODO: add base generator
      } else {
        this.composeWith('seneca-environment:service');
        // TODO: add base generator
      }
      done();
    }.bind(this));
  },

  writing: function () {
    // this.fs.copy(
    //   this.templatePath('dummyfile.txt'),
    //   this.destinationPath('dummyfile.txt')
    // );
  },

  install: function () {
    // this.installDependencies();
  }
});
<|endoftext|>


<commit_before>const Generator = require('yeoman-generator');
const path = require('path');
const utils = require('./utils');
const prompts = require('./prompts');
const which = require('which');

const OPTIONS = {
  // COMMIT: 'commit',
  // INIT_GIT: 'git',
  LATEST: 'latest',
  // PUSH: 'push',
  YES: 'yes',
  YES_DEFAULT: 'yes-defaults'
};

// TODO replace file names with map
// const TEMPLATES = {
//   README: {
//     name: 'readme.md',
//     placeholders: []
//   }
// };

module.exports = class extends Generator {
  // get devDependencies() {
  //   // TODO add option to install latest versions or fixed
  //   return {
  //     "ava": "^0.18.2",
  //     "babel-loader": "^6.4.0",
  //     "babel-plugin-istanbul": "^4.0.0",
  //     "babel-preset-env": "^1.2.1",
  //     "babel-register": "^6.24.0",
  //     "codecov": "^2.0.1",
  //     "nyc": "^10.1.2",
  //     "webpack": "2.2.1",
  //     "xo": "^0.17.1"
  //   }
  // }

  constructor(args, opts) {
    super(args, opts);

    this.option('yes-default', {
      alias: 'd',
      default: false,
      description: `Ask only questions which don't have default or saved answer`,
      type: Boolean
    });

    this.option(OPTIONS.YES, {
      alias: 'y',
      default: false,
      description: `Agree on every question, don't ask anything`,
      type: Boolean
    });

    // this.option(OPTIONS.INIT_GIT, {
    //   alias: 'g',
    //   default: true,
    //   description: `Init git repository`,
    //   type: Boolean
    // });

    // this.option(OPTIONS.COMMIT, {
    //   alias: 'c',
    //   default: true,
    //   description: `Make initial commit`,
    //   type: Boolean
    // });

    // this.option(OPTIONS.PUSH, {
    //   alias: 'p',
    //   default: false,
    //   description: `Push commit`,
    //   type: Boolean
    // });

    this.option(OPTIONS.LATEST, {
      alias: 'l',
      default: false,
      description: `Install latest versions of dependencies. (!) Correct work is not guaranteed`,
      type: Boolean
    });

    this.storedPrompt = this.config.get('promptValues') || {};
    this.defaultAnswers = this._getDefaultAnswers(this.storedPrompt);
    this.answers = {};
  }

  // Lifecycle hook
  initializing() {
    return this._beforeInit()
      .then(() => this._afterInit());
  }

  // Lifecycle hook
  prompting() {
    return this._getAnswers()
      .then(answers => {
        this.answers = answers
      });
  }

  // Lifecycle hook
  configuring() {
    this._fastCopy('.babelrc');
    this._fastCopy('.editorconfig');
    this._fastCopy('.gitattributes');
    this._fastCopy('.gitignore');
    this._fastCopy('.travis.yml');
  }

  // Lifecycle hook
  // default() {}

  // Lifecycle hook
  writing() {
    this._fastCopy('index.js');
    this._fastCopy('LICENSE', this.answers);
    this._fastCopy('package.json', this.answers);
    this._fastCopy('README.md', this.answers);
    this._fastCopy('test.js');
    this._fastCopy('webpack.config.babel.js');
    // TODO do not copy if want fresh dependencies
    this._fastCopy('yarn.lock');
  }

  // Lifecycle hook
  // conflicts() {}

  // Lifecycle hook
  install() {
    this._installDependencies({
      isYarn: which.sync('yarn')
    });

    // if git is available
      // init git

      // make commit

      // if github repo exists && user agreed
        // push
  }

  // Lifecycle hook
  // end() {}

  /**
   *
   * @param isYarn
   * @private
   */
  _installDependencies({isYarn}) {
    let dependencies = [];
    let devDependencies = [];

    if (this.options[OPTIONS.LATEST]) {
      const packageJson = require(this.templatePath('package.json'));
      const setLatest = dep => `${dep}@latest`;

      dependencies = Object.keys(packageJson.dependencies).map(setLatest);
      devDependencies = Object.keys(packageJson.devDependencies).map(setLatest);
    }

    isYarn
      ? this.yarnInstall(dependencies)
      : this.npmInstall(dependencies);

    if (devDependencies.length > 0) {
      isYarn
        ? this.yarnInstall(devDependencies, {dev: true})
        : this.npmInstall(devDependencies, {'save-dev': true});
    }
  }

  /**
   * Returns answers either after prompting or on
   * @return {Promise}
   * @private
   */
  _getAnswers() {
    return new Promise((resolve, reject) => {
      try {
        if (this.options[OPTIONS.YES_DEFAULT]) {
          // resolve questions that don't have default or stored answer
          const filtered = this.questions.ALL.filter(q => !this.defaultAnswers[q.name]);

          resolve(this.prompt(filtered).then(answers => {
            // combine answers with defaults
            return Object.assign({}, this.defaultAnswers, answers);
          }));
        } else if (this.options[OPTIONS.YES]) {
          // don't ask anything, just return answers
          resolve(Object.assign({}, this.defaultAnswers));
        } else {
          // ask all the questions
          resolve(this.prompt(this.questions.ALL));
        }
      } catch (e) {
        reject(e);
      }
    });
  }

  /**
   * Copies fileName to destination path with the same name
   * @param fileName
   * @param placeholders
   * @return {*}
   * @private
   */
  _fastCopy(fileName, placeholders) {
    return this.fs.copyTpl(
      this.templatePath(fileName),
      this.destinationPath(fileName),
      placeholders
    );
  }

  /**
   * Returns merged map of stored and default answers
   * @param config
   * @return {{name: *, email: *, website: null, moduleName: *, moduleDescription: *, githubUsername: null, camelModuleName: string, humanModuleName: string}}
   * @private
   */
  _getDefaultAnswers(config) {
    const name = config.name || this.user.git.name();
    const email = config.email || this.user.git.email();
    const website = config.website || null;
    const moduleName = path.basename(process.cwd());
    const moduleDescription = null;
    const githubUsername = config.githubUsername || null;
    const camelModuleName = utils.camelize(moduleName);
    const humanModuleName = utils.humanize(moduleName);
    // const gitRemote = githubUsername && `${githubUsername}/${moduleName}`;

    return {
      name, email, website, moduleName, moduleDescription, githubUsername, camelModuleName, humanModuleName
      // gitRemote
    };
  }

  /**
   * Async operations before initialing (load data, etc.)
   * @return {*}
   * @private
   */
  _beforeInit() {
    return this._initGithubUsername();
  }

  _initGithubUsername() {
    if (!this.defaultAnswers.githubUsername) {
      return this.user.github.username()
        .then(name => this.defaultAnswers.githubUsername = name);
    }

    return Promise.resolve(this.defaultAnswers.githubUsername);
  }

  _afterInit() {
    this.questions = prompts(this);
  }
};
<commit_msg>Remove todo<commit_after>const Generator = require('yeoman-generator');
const path = require('path');
const utils = require('./utils');
const prompts = require('./prompts');
const which = require('which');

const OPTIONS = {
  // COMMIT: 'commit',
  // INIT_GIT: 'git',
  LATEST: 'latest',
  // PUSH: 'push',
  YES: 'yes',
  YES_DEFAULT: 'yes-defaults'
};

// TODO replace file names with map
// const TEMPLATES = {
//   README: {
//     name: 'readme.md',
//     placeholders: []
//   }
// };

module.exports = class extends Generator {
  // get devDependencies() {
  //   // TODO add option to install latest versions or fixed
  //   return {
  //     "ava": "^0.18.2",
  //     "babel-loader": "^6.4.0",
  //     "babel-plugin-istanbul": "^4.0.0",
  //     "babel-preset-env": "^1.2.1",
  //     "babel-register": "^6.24.0",
  //     "codecov": "^2.0.1",
  //     "nyc": "^10.1.2",
  //     "webpack": "2.2.1",
  //     "xo": "^0.17.1"
  //   }
  // }

  constructor(args, opts) {
    super(args, opts);

    this.option('yes-default', {
      alias: 'd',
      default: false,
      description: `Ask only questions which don't have default or saved answer`,
      type: Boolean
    });

    this.option(OPTIONS.YES, {
      alias: 'y',
      default: false,
      description: `Agree on every question, don't ask anything`,
      type: Boolean
    });

    // this.option(OPTIONS.INIT_GIT, {
    //   alias: 'g',
    //   default: true,
    //   description: `Init git repository`,
    //   type: Boolean
    // });

    // this.option(OPTIONS.COMMIT, {
    //   alias: 'c',
    //   default: true,
    //   description: `Make initial commit`,
    //   type: Boolean
    // });

    // this.option(OPTIONS.PUSH, {
    //   alias: 'p',
    //   default: false,
    //   description: `Push commit`,
    //   type: Boolean
    // });

    this.option(OPTIONS.LATEST, {
      alias: 'l',
      default: false,
      description: `Install latest versions of dependencies. (!) Correct work is not guaranteed`,
      type: Boolean
    });

    this.storedPrompt = this.config.get('promptValues') || {};
    this.defaultAnswers = this._getDefaultAnswers(this.storedPrompt);
    this.answers = {};
  }

  // Lifecycle hook
  initializing() {
    return this._beforeInit()
      .then(() => this._afterInit());
  }

  // Lifecycle hook
  prompting() {
    return this._getAnswers()
      .then(answers => {
        this.answers = answers
      });
  }

  // Lifecycle hook
  configuring() {
    this._fastCopy('.babelrc');
    this._fastCopy('.editorconfig');
    this._fastCopy('.gitattributes');
    this._fastCopy('.gitignore');
    this._fastCopy('.travis.yml');
  }

  // Lifecycle hook
  // default() {}

  // Lifecycle hook
  writing() {
    this._fastCopy('index.js');
    this._fastCopy('LICENSE', this.answers);
    this._fastCopy('package.json', this.answers);
    this._fastCopy('README.md', this.answers);
    this._fastCopy('test.js');
    this._fastCopy('webpack.config.babel.js');
    this._fastCopy('yarn.lock');
  }

  // Lifecycle hook
  // conflicts() {}

  // Lifecycle hook
  install() {
    this._installDependencies({
      isYarn: which.sync('yarn')
    });

    // if git is available
      // init git

      // make commit

      // if github repo exists && user agreed
        // push
  }

  // Lifecycle hook
  // end() {}

  /**
   *
   * @param isYarn
   * @private
   */
  _installDependencies({isYarn}) {
    let dependencies = [];
    let devDependencies = [];

    if (this.options[OPTIONS.LATEST]) {
      const packageJson = require(this.templatePath('package.json'));
      const setLatest = dep => `${dep}@latest`;

      dependencies = Object.keys(packageJson.dependencies).map(setLatest);
      devDependencies = Object.keys(packageJson.devDependencies).map(setLatest);
    }

    isYarn
      ? this.yarnInstall(dependencies)
      : this.npmInstall(dependencies);

    if (devDependencies.length > 0) {
      isYarn
        ? this.yarnInstall(devDependencies, {dev: true})
        : this.npmInstall(devDependencies, {'save-dev': true});
    }
  }

  /**
   * Returns answers either after prompting or on
   * @return {Promise}
   * @private
   */
  _getAnswers() {
    return new Promise((resolve, reject) => {
      try {
        if (this.options[OPTIONS.YES_DEFAULT]) {
          // resolve questions that don't have default or stored answer
          const filtered = this.questions.ALL.filter(q => !this.defaultAnswers[q.name]);

          resolve(this.prompt(filtered).then(answers => {
            // combine answers with defaults
            return Object.assign({}, this.defaultAnswers, answers);
          }));
        } else if (this.options[OPTIONS.YES]) {
          // don't ask anything, just return answers
          resolve(Object.assign({}, this.defaultAnswers));
        } else {
          // ask all the questions
          resolve(this.prompt(this.questions.ALL));
        }
      } catch (e) {
        reject(e);
      }
    });
  }

  /**
   * Copies fileName to destination path with the same name
   * @param fileName
   * @param placeholders
   * @return {*}
   * @private
   */
  _fastCopy(fileName, placeholders) {
    return this.fs.copyTpl(
      this.templatePath(fileName),
      this.destinationPath(fileName),
      placeholders
    );
  }

  /**
   * Returns merged map of stored and default answers
   * @param config
   * @return {{name: *, email: *, website: null, moduleName: *, moduleDescription: *, githubUsername: null, camelModuleName: string, humanModuleName: string}}
   * @private
   */
  _getDefaultAnswers(config) {
    const name = config.name || this.user.git.name();
    const email = config.email || this.user.git.email();
    const website = config.website || null;
    const moduleName = path.basename(process.cwd());
    const moduleDescription = null;
    const githubUsername = config.githubUsername || null;
    const camelModuleName = utils.camelize(moduleName);
    const humanModuleName = utils.humanize(moduleName);
    // const gitRemote = githubUsername && `${githubUsername}/${moduleName}`;

    return {
      name, email, website, moduleName, moduleDescription, githubUsername, camelModuleName, humanModuleName
      // gitRemote
    };
  }

  /**
   * Async operations before initialing (load data, etc.)
   * @return {*}
   * @private
   */
  _beforeInit() {
    return this._initGithubUsername();
  }

  _initGithubUsername() {
    if (!this.defaultAnswers.githubUsername) {
      return this.user.github.username()
        .then(name => this.defaultAnswers.githubUsername = name);
    }

    return Promise.resolve(this.defaultAnswers.githubUsername);
  }

  _afterInit() {
    this.questions = prompts(this);
  }
};
<|endoftext|>


<commit_before>'use strict';

var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
var git = require("nodegit");
var gitHubInfo = require("hosted-git-info");

module.exports = yeoman.generators.Base.extend({
    constructor: function () {
        yeoman.generators.Base.apply(this, arguments);

        this.option('repositoryUrl', {
            desc: 'URL to GitHub repository (determined automatically if omitted).',
            type: "String",
            defaults: null
        });
    },

    prompting: function () {
        var done = this.async();

        this.log(yosay(
            'Welcome to the ' + chalk.red('webfactory Open Source') + ' project setup!'
        ));

        var prompts = [
        ];
        this.prompt(prompts, function (props) {
            this.props = props;
            // To access props later use this.props.someOption;
            done();
        }.bind(this));
    },

    writing: {
        // ToDo:
        // - Check Repo Url
        //   - Generate Travis Image in README
        // - Check project type (bundle, library, app)
        //   - add typ to README
        // - add Travis config
        app: function () {
            git.Repository.open(this.destinationPath())
                .then(function (projectRepository) {
                    return git.Remote.lookup(projectRepository, "origin");
                })
                .then(function (remote) {
                    return remote.url();
                })
                .then(function (url) {
                    return gitHubInfo.fromUrl(url);
                })
                .then(function (info) {
                    return {
                        'vendor': info.user,
                        'project': info.project,
                        'year': new Date().getFullYear()
                    }
                })
                .then(function (templateParameters) {
                    this.fs.copyTpl(
                        this.templatePath('_LICENSE'),
                        this.destinationPath('LICENSE'),
                        templateParameters
                    );
                    this.fs.copyTpl(
                        this.templatePath('_README.md'),
                        this.destinationPath('README.md'),
                        templateParameters
                    );
                }.bind(this))
                .catch(function (error) {
                    this.log.error('Project setup failed.', error);
                }.bind(this));
        }
    },

    install: function () {
        this.installDependencies();
    }
});
<commit_msg>use the repository URL that is passed via command line<commit_after>'use strict';

var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
var git = require("nodegit");
var gitHubInfo = require("hosted-git-info");

module.exports = yeoman.generators.Base.extend({
    constructor: function () {
        yeoman.generators.Base.apply(this, arguments);

        this.option('repositoryUrl', {
            desc: 'URL to GitHub repository (determined automatically if omitted).',
            type: "String",
            defaults: null
        });
    },

    prompting: function () {
        var done = this.async();

        this.log(yosay(
            'Welcome to the ' + chalk.red('webfactory Open Source') + ' project setup!'
        ));

        var prompts = [
        ];
        this.prompt(prompts, function (props) {
            this.props = props;
            // To access props later use this.props.someOption;
            done();
        }.bind(this));
    },

    writing: {
        // ToDo:
        // - Check Repo Url
        //   - Generate Travis Image in README
        // - Check project type (bundle, library, app)
        //   - add typ to README
        // - add Travis config
        app: function () {
            var determineRepositoryUrl = Promise.resolve(this.options.repositoryUrl);
            if (this.options.repositoryUrl === null) {
                // Repository URL must be determined automatically.
                determineRepositoryUrl = git.Repository.open(this.destinationPath())
                    .then(function (projectRepository) {
                        return git.Remote.lookup(projectRepository, "origin");
                    })
                    .then(function (remote) {
                        return remote.url();
                    });
            }
            determineRepositoryUrl
                .then(function (url) {
                    return gitHubInfo.fromUrl(url);
                })
                .then(function (info) {
                    return {
                        'vendor': info.user,
                        'project': info.project,
                        'year': new Date().getFullYear()
                    }
                })
                .then(function (templateParameters) {
                    this.fs.copyTpl(
                        this.templatePath('_LICENSE'),
                        this.destinationPath('LICENSE'),
                        templateParameters
                    );
                    this.fs.copyTpl(
                        this.templatePath('_README.md'),
                        this.destinationPath('README.md'),
                        templateParameters
                    );
                }.bind(this))
                .catch(function (error) {
                    this.log.error('Project setup failed.', error);
                }.bind(this));
        }
    },

    install: function () {
        this.installDependencies();
    }
});
<|endoftext|>


<commit_before>'use strict';

/*
     .-"-.            .-"-.            .-"-.           .-"-.
   _/_-.-_\_        _/.-.-.\_        _/.-.-.\_       _/.-.-.\_
  / __} {__ \      /|( o o )|\      ( ( o o ) )     ( ( o o ) )
 / //  "  \\ \    | //  "  \\ |      |/  "  \|       |/  "  \|
/ / \'---'/ \ \  / / \'---'/ \ \      \'/^\'/         \ .-. /
\ \_/`"""`\_/ /  \ \_/`"""`\_/ /      /`\ /`\         /`"""`\
 \           /    \           /      /  /|\  \       /       \

The Monkeys (c) 2016 | http://themonkeys.com.au/
Date: 15/1/16

@author Lachlan Tweedie, lachlant@themonkeys.com.au

*/

var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
var mkdirp = require('mkdirp');

module.exports = yeoman.Base.extend({

	// Configurations will be loaded here.

	//Ask for user input
	prompting: function() {

		console.log(yosay(chalk.cyan('Hello, and welcome to Monkey Bones! \n') + chalk.white('The project builder used by ')  + chalk.yellow('THE MONKEYS ') ) );

		var done = this.async();

		this.prompt([{

		  type: 'input',
		  name: 'name',
		  message: 'Your project name',
		  default: this.appname

		},
		{

		  type: 'input',
		  name: 'description',
		  message: 'A description for your project',
		  default: "A basic HTML project."

		},
		{

		  type: 'input',
		  name: 'author',
		  message: 'Name of author',
		  default: "Lachlan Tweedie"

		},
		{

		  type: 'input',
		  name: 'email',
		  message: 'Email of the author',
		  default: "lachlant@themonkeys.com.au"

		},
		{

		  type: 'input',
		  name: 'architecture',
		  message: 'How is the project structured and built?',

		  default: "Nothing different from usual."

		},
		{

	      type: 'list',
	      name: 'styling',
	      message: 'Which css precompiler would you like to use?',
	      choices: ['sass' , 'less']

	    },{

			type: 'confirm',
			name: 'hasBootstrap',
			message: 'Would you like Boostrap included?',
			default: true

		},{

			type: 'confirm',
			name: 'setUpStaging',
			message: 'Would you like set up staging details right now?',
			default: true

		}], function(answers) {

		  	this.props = answers;

			done();

		}.bind(this));

	},

	serverPrompting: function(){

		var done = this.async();

		if(this.props.setUpStaging){

	  		this.prompt([{
				type: 'input',
				name: 'gitStage',
				message: 'What\'s the GIT repo name for staging?',
				default: ''

			},
			{

				type: 'input',
				name: 'stagingLink',
				message: 'What\'s the subdomain for monkeylabs.com.au?',
				default: ''

			}], function(answers){

				this.props.gitHubRepo = answers.gitStage

				this.props.gitStage = getGitURL(answers.gitStage);
				this.props.stagingLink = getStagingURL(answers.stagingLink);

				this.props.package_json

				done();

			}.bind(this));

	  	}else{
	  		done();
	  	}
	},

	createJsonFiles : function () {

		this.props.package_json =  {
			"name": this.props.name.replace(/\s/g, '-'),
			"description": this.props.description,

			"version": "0.0.0",
			"author": {
				"name": "Lachlan Tweedie",
				"email": "lachlant@themonkeys.com.au",
				"url": "themonkeys.com.au"
			},

			"dependencies": {},

			"repository": {
			  "type": "git",
			  "url": "git://github.com/themonkeys/" + this.props.gitHubRepo + ".git"
			},

			"scripts": {

			    "dev": "gulp"
			},

			"devDependencies": {
				"browser-sync": "^1.6.2",
				"gulp": "^3.8.9",
				"gulp-ng-annotate": "^2.0.0",
				"gulp-autoprefixer": "^1.0.1",
				"gulp-batch": "^1.0.5",
				"gulp-changed" : "^1.3.0",
				"gulp-concat": "2.4.2",
				"gulp-inject": "^3.0.0",
				"gulp-less": "^3.0.5",
				"gulp-livereload": "^3.8.1",
				"gulp-clean-css": "^2.0.2",
				"gulp-rename": "^1.2.0",
				"gulp-sass": "^2.0.4",
				"gulp-uglify": "1.0.1",
				"gulp-watch": "^4.3.5",
				"less": "^2.5.3",
				"stream-combiner2": "^1.1.1"
			}
		};

		this.props.bower_json =   {
			"name": this.props.name,
			"description": this.props.description,
			"version": "0.0.0",
			"dependencies": {}
		};

		// bower.json

		if(this.props.hasBootstrap){
			this.props.bower_json.dependencies.bootstrap = "3.3.5";
		}

		// package.json

		this.props.package_json.dependencies["normalize.css"] = "3.0.3"; // always have normalise
	},

	// Writing Logic here

	writing: {

		// Copy the configuration files

		config: function () {

			this.fs.writeJSON('package.json', this.props.package_json);
			this.fs.writeJSON('bower.json', this.props.bower_json);
	        this.fs.copy(
	          this.templatePath('bowerrc'),
	          this.destinationPath('.bowerrc')
	        );

	        var ext = this.props.styling == 'less' ? 'less' : 'scss';

	        this.fs.copyTpl(
	            this.templatePath('gulpfile.js'),
	            this.destinationPath('gulpfile.js'), {
	               styling: this.props.styling,
	               hasBootstrap: this.props.hasBootstrap,
	               stylingExt : ext,
	               author: this.props.author,
	               email: this.props.email
	            }
	        );

	        // DEPLOYMENT

	        this.fs.copyTpl(
	            this.templatePath('_deployment/README.md'),
	            this.destinationPath('deployment/README.md'), {
	               gitStaging: this.props.gitStage,
	               stagingLink: this.props.stagingLink
	            }
	        );

	        // Git Ignore
	        this.fs.copy(
		    	this.templatePath('_deployment/deploy.sh'),
		    	this.destinationPath('deployment/deploy.sh'));

	        this.fs.copy(
		    	this.templatePath('.gitignore'),
		    	this.destinationPath('.gitignore'));

	        // Prototype

	       this.fs.copyTpl(
		    	this.templatePath('_prototype/README.md'),
		    	this.destinationPath('prototype/README.md'),
		    	{
		    		name: this.props.name
		    	}

		    );

	        // main readme

	        this.fs.copyTpl(
	            this.templatePath('_README.md'),
	            this.destinationPath('README.md'), {
	                name: this.props.name,
	                description: this.props.description,
	                architecture: this.props.architecture,

	            }
	        );

	    },

	  // Copy application files
		app: function() {

			// css

			this.fs.copy(
		    	this.templatePath('_css/_vendor/normalize.css'),
		    	this.destinationPath('build/public/css/vendor/normalize.css'));

			// js

			this.fs.copy(
		    	this.templatePath('_js/_vendor/jquery-1.11.1.min.js'),
		    	this.destinationPath('build/js/vendor/jquery-1.11.1.min.js'));

			this.fs.copy(
		    	this.templatePath('_js/_vendor/tweenmax.js'),
		    	this.destinationPath('build/js/vendor/tweenmax.js'));

			this.fs.copy(
		    	this.templatePath('_js/_vendor/modernizr-2.8.3.min.js'),
		    	this.destinationPath('build/public/js/vendor/modernizr-2.8.3.min.js'));

			this.fs.copy(
		    	this.templatePath('_js/_main.js'),
		    	this.destinationPath('build/js/global.js'));

			this.fs.copy(
		    	this.templatePath('_js/_main.js'),
		    	this.destinationPath('build/js/home.js'));

			// html

			 this.fs.copyTpl(
	            this.templatePath('_html/_index.ejs'),
	            this.destinationPath('build/public/index.html'), {
	                name: this.props.name,
	                description: this.props.description
	            }
	        );

			// images

			this.fs.copy(
				this.templatePath('_images/favicon.ico'),
				this.destinationPath('build/public/images/favicon.ico')
			);

			// fonts directory

			mkdirp.sync('build/public/fonts/');

			var ext = this.props.styling == 'less' ? 'less' : 'scss';

			this.fs.copy(
				this.templatePath('_'+ ext +'/**/*' + ext),
				this.destinationPath('build/' + ext)
			);

		}
	},

	//Install Dependencies
	install: function() {
	  this.installDependencies({
	  	callback: function () {

			console.log(yosay(chalk.cyan('Monkey Bones project ready! Like our stuff? Visit: ') + ' ' + chalk.grey('http://themonkeys.com.au ') + ' '  + chalk.yellow('Starting Gulp tasks now so you can swing right in. \n')  ) );

	  		this.spawnCommand('gulp', ['default']);

	    }.bind(this)
	  });
	}

});

function get_html_source( _type, _path ){

	if(_type == "js"){

		return '<script src="' + _path + '"></script>';

	}else if (_type == "css"){

	}else{

		return '';

	}

}

function getGitURL (projectName){

	if(!projectName || projectName == '')

		return '[NO DOCUMENTATION ADDED YET]';

	else

		return 'ssh://monkey-deployment@deployment.monkeylabs.com.au/home/monkey-deployment/' + projectName + '/stage.git'

}

function getStagingURL (projectName){

	if(!projectName || projectName == '')

		return '[NO DOCUMENTATION ADDED YET]';

	else

		return 'http://'+projectName+'.monkeylabs.com.au/';

}

<commit_msg>Cleaned index js file<commit_after>'use strict';

/*
     .-"-.            .-"-.            .-"-.           .-"-.
   _/_-.-_\_        _/.-.-.\_        _/.-.-.\_       _/.-.-.\_
  / __} {__ \      /|( o o )|\      ( ( o o ) )     ( ( o o ) )
 / //  "  \\ \    | //  "  \\ |      |/  "  \|       |/  "  \|
/ / \'---'/ \ \  / / \'---'/ \ \      \'/^\'/         \ .-. /
\ \_/`"""`\_/ /  \ \_/`"""`\_/ /      /`\ /`\         /`"""`\
 \           /    \           /      /  /|\  \       /       \

The Monkeys (c) 2016 | http://themonkeys.com.au/
Date: 15/1/16

@author Lachlan Tweedie, lachlant@themonkeys.com.au

*/

var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
var mkdirp = require('mkdirp');

module.exports = yeoman.Base.extend({

	// Configurations will be loaded here.

	//Ask for user input
	prompting: function() {

		console.log(yosay(chalk.cyan('Hello, and welcome to Monkey Bones! \n') + chalk.white('The project builder used by ')  + chalk.yellow('THE MONKEYS ') ) );

		var done = this.async();

		this.prompt([{

		  type: 'input',
		  name: 'name',
		  message: 'Your project name',
		  default: this.appname

		},
		{

		  type: 'input',
		  name: 'description',
		  message: 'A description for your project',
		  default: "A basic HTML project."

		},
		{

		  type: 'input',
		  name: 'author',
		  message: 'Name of author',
		  default: "Lachlan Tweedie"

		},
		{

		  type: 'input',
		  name: 'email',
		  message: 'Email of the author',
		  default: "lachlant@themonkeys.com.au"

		},
		{

		  type: 'input',
		  name: 'architecture',
		  message: 'How is the project structured and built?',

		  default: "Nothing different from usual."

		},
		{

	      type: 'list',
	      name: 'styling',
	      message: 'Which css precompiler would you like to use?',
	      choices: ['sass' , 'less']

	    },{

			type: 'confirm',
			name: 'hasBootstrap',
			message: 'Would you like Boostrap included?',
			default: true

		},{

			type: 'confirm',
			name: 'setUpStaging',
			message: 'Would you like set up staging details right now?',
			default: true

		}], function(answers) {

		  	this.props = answers;

			done();

		}.bind(this));

	},

	serverPrompting: function(){

		var done = this.async();

		if(this.props.setUpStaging){

	  		this.prompt([{
				type: 'input',
				name: 'gitStage',
				message: 'What\'s the GIT repo name for staging?',
				default: ''

			},
			{

				type: 'input',
				name: 'stagingLink',
				message: 'What\'s the subdomain for monkeylabs.com.au?',
				default: ''

			}], function(answers){

				this.props.gitHubRepo = answers.gitStage;
				this.props.gitStage = getGitURL(answers.gitStage);
				this.props.stagingLink = getStagingURL(answers.stagingLink);
				this.props.package_json;

				done();

			}.bind(this));

	  	}else{
	  		done();
	  	}
	},

	createJsonFiles : function () {

		this.props.package_json =  {
			"name": this.props.name.replace(/\s/g, '-'),
			"description": this.props.description,

			"version": "0.0.0",
			"author": {
				"name": "Lachlan Tweedie",
				"email": "lachlant@themonkeys.com.au",
				"url": "themonkeys.com.au"
			},

			"dependencies": {},

			"repository": {
			  "type": "git",
			  "url": "git://github.com/themonkeys/" + this.props.gitHubRepo + ".git"
			},

			"scripts": {

			    "dev": "gulp"
			},

			"devDependencies": {
				"browser-sync": "^1.6.2",
				"gulp": "^3.8.9",
				"gulp-ng-annotate": "^2.0.0",
				"gulp-autoprefixer": "^1.0.1",
				"gulp-batch": "^1.0.5",
				"gulp-changed" : "^1.3.0",
				"gulp-concat": "2.4.2",
				"gulp-inject": "^3.0.0",
				"gulp-less": "^3.0.5",
				"gulp-livereload": "^3.8.1",
				"gulp-clean-css": "^2.0.2",
				"gulp-rename": "^1.2.0",
				"gulp-sass": "^2.0.4",
				"gulp-uglify": "1.0.1",
				"gulp-watch": "^4.3.5",
				"less": "^2.5.3",
				"stream-combiner2": "^1.1.1"
			}
		};

		this.props.bower_json =   {
			"name": this.props.name,
			"description": this.props.description,
			"version": "0.0.0",
			"dependencies": {}
		};

		// bower.json

		if(this.props.hasBootstrap){
			this.props.bower_json.dependencies.bootstrap = "3.3.5";
		}

		// package.json

		this.props.package_json.dependencies["normalize.css"] = "3.0.3"; // always have normalise
	},

	// Writing Logic here

	writing: {

		// Copy the configuration files

		config: function () {

			this.fs.writeJSON('package.json', this.props.package_json);
			this.fs.writeJSON('bower.json', this.props.bower_json);
	        this.fs.copy(
	          this.templatePath('bowerrc'),
	          this.destinationPath('.bowerrc')
	        );

	        var ext = this.props.styling == 'less' ? 'less' : 'scss';

	        this.fs.copyTpl(
	            this.templatePath('gulpfile.js'),
	            this.destinationPath('gulpfile.js'), {
	               styling: this.props.styling,
	               hasBootstrap: this.props.hasBootstrap,
	               stylingExt : ext,
	               author: this.props.author,
	               email: this.props.email
	            }
	        );

	        // DEPLOYMENT

	        this.fs.copyTpl(
	            this.templatePath('_deployment/README.md'),
	            this.destinationPath('deployment/README.md'), {
	               gitStaging: this.props.gitStage,
	               stagingLink: this.props.stagingLink
	            }
	        );

	        // Git Ignore
	        this.fs.copy(
		    	this.templatePath('_deployment/deploy.sh'),
		    	this.destinationPath('deployment/deploy.sh'));

	        this.fs.copy(
		    	this.templatePath('.gitignore'),
		    	this.destinationPath('.gitignore'));

	        // Prototype

	       this.fs.copyTpl(
		    	this.templatePath('_prototype/README.md'),
		    	this.destinationPath('prototype/README.md'),
		    	{
		    		name: this.props.name
		    	}

		    );

	        // main readme

	        this.fs.copyTpl(
	            this.templatePath('_README.md'),
	            this.destinationPath('README.md'), {
	                name: this.props.name,
	                description: this.props.description,
	                architecture: this.props.architecture
	            }
	        );

	    },

	  // Copy application files
		app: function() {

			// css

			this.fs.copy(
		    	this.templatePath('_css/_vendor/normalize.css'),
		    	this.destinationPath('build/public/css/vendor/normalize.css'));

			// js

			this.fs.copy(
		    	this.templatePath('_js/_vendor/jquery-1.11.1.min.js'),
		    	this.destinationPath('build/js/vendor/jquery-1.11.1.min.js'));

			this.fs.copy(
		    	this.templatePath('_js/_vendor/tweenmax.js'),
		    	this.destinationPath('build/js/vendor/tweenmax.js'));

			this.fs.copy(
		    	this.templatePath('_js/_vendor/modernizr-2.8.3.min.js'),
		    	this.destinationPath('build/public/js/vendor/modernizr-2.8.3.min.js'));

			this.fs.copy(
		    	this.templatePath('_js/_main.js'),
		    	this.destinationPath('build/js/global.js'));

			this.fs.copy(
		    	this.templatePath('_js/_main.js'),
		    	this.destinationPath('build/js/home.js'));

			// html

			 this.fs.copyTpl(
	            this.templatePath('_html/_index.ejs'),
	            this.destinationPath('build/public/index.html'), {
	                name: this.props.name,
	                description: this.props.description
	            }
	        );

			// images

			this.fs.copy(
				this.templatePath('_images/favicon.ico'),
				this.destinationPath('build/public/images/favicon.ico')
			);

			// fonts directory

			mkdirp.sync('build/public/fonts/');

			var ext = this.props.styling == 'less' ? 'less' : 'scss';

			this.fs.copy(
				this.templatePath('_'+ ext +'/**/*' + ext),
				this.destinationPath('build/' + ext)
			);

		}
	},

	//Install Dependencies
	install: function() {
	  this.installDependencies({
	  	callback: function () {

			console.log(yosay(chalk.cyan('Monkey Bones project ready! Like our stuff? Visit: ') + ' ' + chalk.grey('http://themonkeys.com.au ') + ' '  + chalk.yellow('Starting Gulp tasks now so you can swing right in. \n')  ) );

	  		this.spawnCommand('gulp', ['default']);

	    }.bind(this)
	  });
	}

});

function get_html_source( _type, _path ){

	if(_type == "js"){

		return '<script src="' + _path + '"></script>';

	}else if (_type == "css"){

	}else{

		return '';

	}

}

function getGitURL (projectName){

	if(!projectName || projectName == '')

		return '[NO DOCUMENTATION ADDED YET]';

	else

		return 'ssh://monkey-deployment@deployment.monkeylabs.com.au/home/monkey-deployment/' + projectName + '/stage.git'

}

function getStagingURL (projectName){

	if(!projectName || projectName == '')

		return '[NO DOCUMENTATION ADDED YET]';

	else

		return 'http://'+projectName+'.monkeylabs.com.au/';

}

<|endoftext|>


<commit_before>'use strict';
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
var path = require('path');
var _ = require('lodash');
var _s = require('underscore.string');

module.exports = yeoman.generators.Base.extend({
  prompting: function () {
    var done = this.async();

    // Have Yeoman greet the user.
    this.log(yosay(
      'Welcome to the ' + chalk.red('Elixir') + ' generator!'
    ));

	function format(string) {
		var username = string.toLowerCase();
		return username.replace(/\s/g, '');
	}

	var defaults = (function () {
		var workingDirName = path.basename(process.cwd());
		var homeDir;
		var osUserName;
		var configFile;
		var user = {
			name: 'Christopher EnyTC',
			email: 'chrisenytc@gmail.com'
		};

		if (process.platform === 'win32') {
			homeDir = process.env.USERPROFILE;
			osUserName = process.env.USERNAME || path.basename(homeDir).toLowerCase();
		}
		else {
			homeDir = process.env.HOME || process.env.HOMEPATH;
			osUserName = homeDir && homeDir.split('/').pop() || 'root';
		}

		configFile = path.join(homeDir, '.gitconfig');

		if (require('fs').existsSync(configFile)) {
			user = require('iniparser').parseSync(configFile).user;
		}

		return {
			pkgName: workingDirName,
			userName: format(user.name || osUserName || ''),
			authorName: user.name || '',
			authorEmail: user.email || ''
		};
	})();

    var prompts = [{
        name: 'pkgName',
        message: 'What\'s the package name?',
        default: defaults.pkgName
    }, {
        name: 'pkgDescription',
        message: 'What\'s the description?'
    }, {
        name: 'pkgVersion',
        message: 'What\'s the package version?',
        default: '0.1.0'
    }, {
        name: 'authorName',
        message: 'What\'s your name?',
        default: defaults.authorName
    }, {
        name: 'authorEmail',
        message: 'What\'s your email?',
        default: defaults.authorEmail
    }, {
        name: 'userName',
        message: 'What\'s your github username?',
        default: defaults.userName
    }, {
        type: 'list',
        name: 'license',
        message: 'Choose your license type',
        choices: ['MIT', 'BSD'],
        default: 'MIT'
    }, {
        type: 'confirm',
        name: 'confirm',
        message: 'Continue?',
        default: false
    }];

    this.prompt(prompts, function (props) {
      this.props = props;
	  this.props.pkgSlugName = _s.slugify(this.props.pkgName);
	  this.props.pkgCapitalizedName = _s.capitalize(this.props.pkgName);
	  var d = new Date();
	  this.props.year = d.getFullYear();
	  this.props.date = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
	  if(!this.props.confirm) {
		  return process.exit(0);
	  }
      done();
    }.bind(this));
  },

  configuring: {
	  enforceFolderName: function () {
		  if (this.props.pkgSlugName !== _.last(this.destinationRoot().split(path.sep))) {
			  this.destinationRoot(this.props.pkgSlugName);
		  }

		  this.config.save();
	  }
  },

  writing: {
    app: function () {
      this.fs.copyTpl(
        this.templatePath('_mix.exs'),
        this.destinationPath('mix.exs'),
		this.props
      );
      this.fs.copyTpl(
        this.templatePath('config/_config.exs'),
        this.destinationPath('config/config.exs'),
		this.props
      );
	  this.fs.copyTpl(
        this.templatePath('lib/_pkgName.ex'),
        this.destinationPath('lib/' + this.props.pkgSlugName + '.ex'),
		this.props
      );
	  this.fs.copyTpl(
        this.templatePath('test/_test_helper.exs'),
        this.destinationPath('test/test_helper.exs'),
		this.props
      );
	  this.fs.copyTpl(
        this.templatePath('test/_pkgName_test.exs'),
        this.destinationPath('test/' + this.props.pkgSlugName + '_test.exs'),
		this.props
      );
    },

    projectfiles: function () {
      this.fs.copyTpl(
        this.templatePath('travis.yml'),
        this.destinationPath('.travis.yml'),
		this.props
      );
      this.fs.copyTpl(
        this.templatePath('gitignore'),
        this.destinationPath('.gitignore'),
		this.props
      );
	  this.fs.copyTpl(
        this.templatePath('_README.md'),
        this.destinationPath('README.md'),
		this.props
      );
	  if(this.props.license == 'MIT') {
		  this.fs.copyTpl(
			  this.templatePath('_LICENSE_MIT'),
			  this.destinationPath('LICENSE'),
			  this.props
		  );
	  } else {
		  this.fs.copyTpl(
			  this.templatePath('_LICENSE_BSD'),
			  this.destinationPath('LICENSE'),
			  this.props
		  );
	  }
	  this.fs.copyTpl(
        this.templatePath('_CONTRIBUTING.md'),
        this.destinationPath('CONTRIBUTING.md'),
		this.props
      );
	  this.fs.copyTpl(
        this.templatePath('_CHANGELOG'),
        this.destinationPath('CHANGELOG'),
		this.props
      );
    }
  }

});
<commit_msg>Improve default options.<commit_after>'use strict';
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
var path = require('path');
var _ = require('lodash');
var _s = require('underscore.string');

module.exports = yeoman.generators.Base.extend({
  prompting: function () {
    var done = this.async();

    // Have Yeoman greet the user.
    this.log(yosay(
      'Welcome to the ' + chalk.red('Elixir') + ' generator!'
    ));

	function format(string) {
		var username = string.toLowerCase();
		return username.replace(/\s/g, '');
	}

	var homeDir;
	var osUserName;
	var configFile;
	var user = {
		name: 'Christopher EnyTC',
		email: 'chrisenytc@gmail.com'
	};
	var workingDirName = path.basename(process.cwd());

	if (process.platform === 'win32') {
		homeDir = process.env.USERPROFILE;
		osUserName = process.env.USERNAME || path.basename(homeDir).toLowerCase();
	}
	else {
		homeDir = process.env.HOME || process.env.HOMEPATH;
		osUserName = homeDir && homeDir.split('/').pop() || 'root';
	}

	configFile = path.join(homeDir, '.gitconfig');

	if (require('fs').existsSync(configFile)) {
		user = require('iniparser').parseSync(configFile).user;
	}

	var defaults = {
		pkgName: workingDirName,
		userName: format(user.name || osUserName || ''),
		authorName: user.name || '',
		authorEmail: user.email || ''
	};

    var prompts = [{
        name: 'pkgName',
        message: 'What\'s the package name?',
        default: defaults.pkgName
    }, {
        name: 'pkgDescription',
        message: 'What\'s the description?'
    }, {
        name: 'pkgVersion',
        message: 'What\'s the package version?',
        default: '0.1.0'
    }, {
        name: 'authorName',
        message: 'What\'s your name?',
        default: defaults.authorName
    }, {
        name: 'authorEmail',
        message: 'What\'s your email?',
        default: defaults.authorEmail
    }, {
        name: 'userName',
        message: 'What\'s your github username?',
        default: defaults.userName
    }, {
        type: 'list',
        name: 'license',
        message: 'Choose your license type',
        choices: ['MIT', 'BSD'],
        default: 'MIT'
    }, {
        type: 'confirm',
        name: 'confirm',
        message: 'Continue?',
        default: false
    }];

    this.prompt(prompts, function (props) {
      this.props = props;
	  this.props.pkgSlugName = _s.slugify(this.props.pkgName);
	  this.props.pkgCapitalizedName = _s.capitalize(this.props.pkgName);
	  var d = new Date();
	  this.props.year = d.getFullYear();
	  this.props.date = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
	  if(!this.props.confirm) {
		  return process.exit(0);
	  }
      done();
    }.bind(this));
  },

  configuring: {
	  enforceFolderName: function () {
		  if (this.props.pkgSlugName !== _.last(this.destinationRoot().split(path.sep))) {
			  this.destinationRoot(this.props.pkgSlugName);
		  }

		  this.config.save();
	  }
  },

  writing: {
    app: function () {
      this.fs.copyTpl(
        this.templatePath('_mix.exs'),
        this.destinationPath('mix.exs'),
		this.props
      );
      this.fs.copyTpl(
        this.templatePath('config/_config.exs'),
        this.destinationPath('config/config.exs'),
		this.props
      );
	  this.fs.copyTpl(
        this.templatePath('lib/_pkgName.ex'),
        this.destinationPath('lib/' + this.props.pkgSlugName + '.ex'),
		this.props
      );
	  this.fs.copyTpl(
        this.templatePath('test/_test_helper.exs'),
        this.destinationPath('test/test_helper.exs'),
		this.props
      );
	  this.fs.copyTpl(
        this.templatePath('test/_pkgName_test.exs'),
        this.destinationPath('test/' + this.props.pkgSlugName + '_test.exs'),
		this.props
      );
    },

    projectfiles: function () {
      this.fs.copyTpl(
        this.templatePath('travis.yml'),
        this.destinationPath('.travis.yml'),
		this.props
      );
      this.fs.copyTpl(
        this.templatePath('gitignore'),
        this.destinationPath('.gitignore'),
		this.props
      );
	  this.fs.copyTpl(
        this.templatePath('_README.md'),
        this.destinationPath('README.md'),
		this.props
      );
	  if(this.props.license == 'MIT') {
		  this.fs.copyTpl(
			  this.templatePath('_LICENSE_MIT'),
			  this.destinationPath('LICENSE'),
			  this.props
		  );
	  } else {
		  this.fs.copyTpl(
			  this.templatePath('_LICENSE_BSD'),
			  this.destinationPath('LICENSE'),
			  this.props
		  );
	  }
	  this.fs.copyTpl(
        this.templatePath('_CONTRIBUTING.md'),
        this.destinationPath('CONTRIBUTING.md'),
		this.props
      );
	  this.fs.copyTpl(
        this.templatePath('_CHANGELOG'),
        this.destinationPath('CHANGELOG'),
		this.props
      );
    }
  }

});
<|endoftext|>


<commit_before>import "start";
import "quincuncial";
import "interrupt";
import "aitoff";
import "guyou";
import "mollweide";
import "sinusoidal";
import "sinu-mollweide";
import "armadillo";
import "august";
import "baker";
import "berghaus";
import "boggs";
import "bonne";
import "bromley";
import "collignon";
import "conic-conformal";
import "conic-equal-area";
import "conic-equidistant";
import "craig";
import "craster";
import "cylindrical-equal-area";
import "eckert1";
import "eckert2";
import "eckert3";
import "eckert4";
import "eckert5";
import "eckert6";
import "eisenlohr";
import "fahey";
import "gringorten";
import "hammer-retroazimuthal";
import "hammer";
import "hatano";
import "healpix";
import "hill";
import "homolosine";
import "kavrayskiy7";
import "lagrange";
import "larrivee";
import "laskowski";
import "littrow";
import "loximuthal";
import "miller";
import "modified-stereographic";
import "mt-flat-polar-parabolic";
import "mt-flat-polar-quartic";
import "mt-flat-polar-sinusoidal";
import "natural-earth";
import "nell-hammer";
import "peirce-quincuncial";
import "polyconic";
import "rectangular-polyconic";
import "robinson";
import "satellite";
import "times";
import "transverse-mercator";
import "two-point-azimuthal";
import "two-point-equidistant";
import "van-der-grinten";
import "van-der-grinten2";
import "van-der-grinten3";
import "van-der-grinten4";
import "wagner4";
import "wagner6";
import "wagner7";
import "wiechel";
import "winkel3";
import "end";
<commit_msg>Remove quincuncial import from index.<commit_after>import "start";
import "interrupt";
import "aitoff";
import "armadillo";
import "august";
import "baker";
import "berghaus";
import "boggs";
import "bonne";
import "bromley";
import "collignon";
import "conic-conformal";
import "conic-equal-area";
import "conic-equidistant";
import "craig";
import "craster";
import "cylindrical-equal-area";
import "eckert1";
import "eckert2";
import "eckert3";
import "eckert4";
import "eckert5";
import "eckert6";
import "eisenlohr";
import "fahey";
import "gringorten";
import "guyou";
import "hammer-retroazimuthal";
import "hammer";
import "hatano";
import "healpix";
import "hill";
import "homolosine";
import "kavrayskiy7";
import "lagrange";
import "larrivee";
import "laskowski";
import "littrow";
import "loximuthal";
import "miller";
import "modified-stereographic";
import "mollweide";
import "mt-flat-polar-parabolic";
import "mt-flat-polar-quartic";
import "mt-flat-polar-sinusoidal";
import "natural-earth";
import "nell-hammer";
import "peirce-quincuncial";
import "polyconic";
import "rectangular-polyconic";
import "robinson";
import "satellite";
import "sinusoidal";
import "sinu-mollweide";
import "times";
import "transverse-mercator";
import "two-point-azimuthal";
import "two-point-equidistant";
import "van-der-grinten";
import "van-der-grinten2";
import "van-der-grinten3";
import "van-der-grinten4";
import "wagner4";
import "wagner6";
import "wagner7";
import "wiechel";
import "winkel3";
import "end";
<|endoftext|>


<commit_before>/*! 1.1.0 10-03-2014 */
try{!function(){function a(a,b){b=b||{bubbles:!1,cancelable:!1,detail:void 0};var c=document.createEvent("CustomEvent");return c.initCustomEvent(a,b.bubbles,b.cancelable,b.detail),c}if(void 0===window.CustomEvent){var b=document.createEvent("CustomEvent");a.prototype=b.constructor.prototype}else a.prototype=window.CustomEvent.prototype;window.CustomEvent=a,window.hasCustomEvents=!0}()}catch(ex){window.hasCustomEvents=!1,void 0!==console&&"function"==typeof console.warn&&(console.warn("Error initializing CustomEvent polyfill - Anzeixer will not raise events"),console.warn(ex))}var Anzeixer=function(){var a,b=function(){var b=a;try{a=window.getComputedStyle(document.querySelector("body"),":after").getPropertyValue("content").replace(/["']/g,"")}catch(c){a="desktop"}if(b!==a&&window.hasCustomEvents){var d=new window.CustomEvent("viewchange",{detail:{originalView:b,currentView:a}});document.dispatchEvent(d)}return a},c=function(){var a=b().split("-");return a[0]};return window.addEventListener("DOMContentLoaded",b,!1),window.addEventListener("resize",b,!1),{getView:b,isDesktop:function(){return"desktop"===c()},isTablet:function(){return"tablet"===c()},isPhone:function(){return"phone"===c()}}}();<commit_msg>New build based on new grunt packages<commit_after>/*! 1.1.0 17-03-2014 */
try{!function(){function a(a,b){b=b||{bubbles:!1,cancelable:!1,detail:void 0};var c=document.createEvent("CustomEvent");return c.initCustomEvent(a,b.bubbles,b.cancelable,b.detail),c}if(void 0===window.CustomEvent){var b=document.createEvent("CustomEvent");a.prototype=b.constructor.prototype}else a.prototype=window.CustomEvent.prototype;window.CustomEvent=a,window.hasCustomEvents=!0}()}catch(ex){window.hasCustomEvents=!1,void 0!==console&&"function"==typeof console.warn&&(console.warn("Error initializing CustomEvent polyfill - Anzeixer will not raise events"),console.warn(ex))}var Anzeixer=function(){var a,b=function(){var b=a;try{a=window.getComputedStyle(document.querySelector("body"),":after").getPropertyValue("content").replace(/["']/g,"")}catch(c){a="desktop"}if(b!==a&&window.hasCustomEvents){var d=new window.CustomEvent("viewchange",{detail:{originalView:b,currentView:a}});document.dispatchEvent(d)}return a},c=function(){var a=b().split("-");return a[0]};return window.addEventListener("DOMContentLoaded",b,!1),window.addEventListener("resize",b,!1),{getView:b,isDesktop:function(){return"desktop"===c()},isTablet:function(){return"tablet"===c()},isPhone:function(){return"phone"===c()}}}();<|endoftext|>