lib/create.js
function(task, type) {

    // Make sure we are going to add a task with a real app
    if (!get(type)) {
      // todo: something useful besides silentfail
      // todo: never forget how funny this was/is/will always be
      throw new Error('F!');
    }

    // Get the app plugin metadata
    var app = get(type);

    // Create the basic task data
    task.path = ['create', type];
    task.category = 'global';
    task.description = app.task.description;
    task.options = parseOptions(app.options, 'task');

    // Extract our inquiry
    var inquiry = _.identity(parseOptions(app.options, 'inquire'));

    // Add a generic app options to build elsewhere
    task.options.push({
      name: 'dir',
      kind: 'string',
      description: 'Creates the app in this directory. Defaults to CWD.',
    });

    // Specify an alternate location to grab the app skeleton
    task.options.push({
      name: 'from',
      kind: 'string',
      description: 'Local path to override app skeleton (be careful with this)',
    });

    // The func that this app create task runs
    task.func = function(done) {

      // Grab the CLI options that are available
      var options = this.options;

      // Filter out interactive questions based on passed in options
      var questions = kbox.util.cli.filterQuestions(inquiry, options);

      // Launch the inquiry
      inquirer.prompt(questions, function(answers) {

        // Add the create type to the results object
        // NOTE: the create type can be different than the
        // type found in the config aka config.type = php but
        // answers._type = drupal7
        answers._type = type;

        // Create the app
        return createApp(app, _.merge({}, options, answers))

        // Return.
        .nodeify(done);

      });
    };
  }
function(task, type) {

    // Make sure we are going to add a task with a real app
    if (!get(type)) {
      // todo: something useful besides silentfail
      // todo: never forget how funny this was/is/will always be
      throw new Error('F!');
    }

    // Get the app plugin metadata
    var app = get(type);

    // Create the basic task data
    task.path = ['create', type];
    task.category = 'global';
    task.description = app.task.description;
    task.options = parseOptions(app.options, 'task');

    // Extract our inquiry
    var inquiry = _.identity(parseOptions(app.options, 'inquire'));

    // Add a generic app options to build elsewhere
    task.options.push({
      name: 'dir',
      kind: 'string',
      description: 'Creates the app in this directory. Defaults to CWD.',
    });

    // Specify an alternate location to grab the app skeleton
    task.options.push({
      name: 'from',
      kind: 'string',
      description: 'Local path to override app skeleton (be careful with this)',
    });

    // The func that this app create task runs
    task.func = function(done) {

      // Grab the CLI options that are available
      var options = this.options;

      // Filter out interactive questions based on passed in options
      var questions = kbox.util.cli.filterQuestions(inquiry, options);

      // Launch the inquiry
      inquirer.prompt(questions, function(answers) {

        // Add the create type to the results object
        // NOTE: the create type can be different than the
        // type found in the config aka config.type = php but
        // answers._type = drupal7
        answers._type = type;

        // Create the app
        return createApp(app, _.merge({}, options, answers))

        // Return.
        .nodeify(done);

      });
    };
  }
function ( task , type ) { // Make sure we are going to add a task with a real app if ( ! get ( type ) ) { // todo: something useful besides silentfail // todo: never forget how funny this was/is/will always be throw new Error ( 'F!' ) ; } // Get the app plugin metadata var app = get ( type ) ; // Create the basic task data task . path = [ 'create' , type ] ; task . category = 'global' ; task . description = app . task . description ; task . options = parseOptions ( app . options , 'task' ) ; // Extract our inquiry var inquiry = _ . identity ( parseOptions ( app . options , 'inquire' ) ) ; // Add a generic app options to build elsewhere task . options . push ( { name : 'dir' , kind : 'string' , description : 'Creates the app in this directory. Defaults to CWD.' , } ) ; // Specify an alternate location to grab the app skeleton task . options . push ( { name : 'from' , kind : 'string' , description : 'Local path to override app skeleton (be careful with this)' , } ) ; // The func that this app create task runs task . func = function ( done ) { // Grab the CLI options that are available var options = this . options ; // Filter out interactive questions based on passed in options var questions = kbox . util . cli . filterQuestions ( inquiry , options ) ; // Launch the inquiry inquirer . prompt ( questions , function ( answers ) { // Add the create type to the results object // NOTE: the create type can be different than the // type found in the config aka config.type = php but // answers._type = drupal7 answers . _type = type ; // Create the app return createApp ( app , _ . merge ( { } , options , answers ) ) // Return. . nodeify ( done ) ; } ) ; } ; }
Assembles create.add metadata and builds a task to create a certain kind
of app.
@memberof create
@static
@method
@arg {Object} task - A kbox task object.
@arg {string} appName - The name of the kind of app to be created.
@example
// Task to create kalabox apps
kbox.tasks.add(function(task) {
kbox.create.buildTask(task, 'frontpage98');
});
Assembles create . add metadata and builds a task to create a certain kind of app .