<commit_before>const tap = require('tap');
const shell = require('shelljs');
const path = require('path');

const test = tap.test;
const zcui = `node ${path.resolve(__dirname, '../../index.js')} new`;
const testProjPath = path.resolve(__dirname, '../../temp/test-proj');

test("Shows help on new --help", t => {
  const command = `${zcui}  --help`;
  shell.exec(command, {silent:true}, (code, stdout) => {
    if(code === 1) t.fail();
    t.equal(stdout.trim(), `index.js new <app>

App Options:
  -h, --help     Show help                                             [boolean]
  -v, --version  Show version number                                   [boolean]

Options:
  --target, -t  target template name        [string] [required] [choices: "vue"]

Examples:
  index.js new HelloWorld`);
    t.end();
  });
});

test("Show error on new without target", t => {
  const command = `${zcui} HelloWorld`;
  shell.exec(command, {silent:true}, (code, stdout, stderr) => {
    if(code === 0) t.fail();
    t.equal(stderr.trim(), 'Missing required argument: target');
    t.end();
  });
});

test("Show error on invalid varient or target", t => {
  const command = `${zcui} HelloWorld -t invalid`;
  shell.exec(command, {silent:true}, (code, stdout, stderr) => {
    if(code === 0) t.fail();
    t.equal(stderr.trim(), `Invalid values:
  Argument: target, Given: "invalid", Choices: "vue"`);
    t.end();
  });
});

test("Show error on multiple new project name", t => {
  const command = `${zcui} hello-world new-world -t vue`;
  shell.cd(testProjPath);
  shell.exec(command, {silent:true}, (code, stdout) => {
    if(code === 0) t.fail();
    t.equal(stdout.trim(), 'Please give only one argument as a directory name!!!');
    t.end();
  });
});

test("Create project", t => {
  const command = `${zcui} HelloWorld -t vue`;

  /**
   * Cleanup test project directory
   */
  shell.rm('-rf', testProjPath, {silent:true});
  shell.mkdir('-p', testProjPath);
  shell.cd(testProjPath);

  shell.exec(command, {silent:true}, (code, stdout, stderr) => {
    if(code === 1) t.fail();
    t.equal(stderr.trim(), `✔ Completed.....You are good to go!
  Project hello-world created.

  >_ [RUN]
  $ cd hello-world
  $ npm run dev   # to start dev server
  $ npm run prod  # to build for production`);
    t.end();
  });
});

test("Error on duplicate project", t => {
  const command = `${zcui} HelloWorld -t vue`;

  /**
   * Not cleaning prevously created project
   */

  shell.cd(testProjPath);
  shell.exec(command, {silent:true}, (code, stdout) => {
    if(code === 0) t.fail();
    t.equal(
      stdout.trim(),
      'HelloWorld directory already exits! Please choose some another name!!!'
    );
    t.end();
  });
});

<commit_msg>added test cases to new command for skip depencies option (--no-dependencies)<commit_after>const tap = require('tap');
const shell = require('shelljs');
const path = require('path');

const test = tap.test;
const zcui = `node ${path.resolve(__dirname, '../../index.js')} new`;
const testProjPath = path.resolve(__dirname, '../../temp/test-proj');

test("Shows help on new --help", t => {
  const command = `${zcui}  --help`;
  shell.exec(command, {silent:true}, (code, stdout) => {
    if(code === 1) t.fail();
    t.equal(stdout.trim(), `index.js new <app>

App Options:
  -h, --help     Show help                                             [boolean]
  -v, --version  Show version number                                   [boolean]

Options:
  --target, -t    target template name      [string] [required] [choices: "vue"]
  --dependencies  to skip dependencies installation use --no-dependencies
                                                       [boolean] [default: true]

Examples:
  index.js new HelloWorld`);
    t.end();
  });
});

test("Show error on new without target", t => {
  const command = `${zcui} HelloWorld`;
  shell.exec(command, {silent:true}, (code, stdout, stderr) => {
    if(code === 0) t.fail();
    t.equal(stderr.trim(), 'Missing required argument: target');
    t.end();
  });
});

test("Show error on invalid varient or target", t => {
  const command = `${zcui} HelloWorld -t invalid`;
  shell.exec(command, {silent:true}, (code, stdout, stderr) => {
    if(code === 0) t.fail();
    t.equal(stderr.trim(), `Invalid values:
  Argument: target, Given: "invalid", Choices: "vue"`);
    t.end();
  });
});

test("Show error on multiple new project name", t => {
  const command = `${zcui} hello-world new-world -t vue`;
  shell.cd(testProjPath);
  shell.exec(command, {silent:true}, (code, stdout) => {
    if(code === 0) t.fail();
    t.equal(stdout.trim(), 'Please give only one argument as a directory name!!!');
    t.end();
  });
});

test("Create project without dependencies", t => {
  const command = `${zcui} HelloWorld -t vue --no-dependencies`;

  /**
   * Cleanup test project directory
   */
  shell.rm('-rf', testProjPath, {silent:true});
  shell.mkdir('-p', testProjPath);
  shell.cd(testProjPath);

  shell.exec(command, {silent:true}, (code, stdout, stderr) => {
    if(code === 1) t.fail();
    t.equal(stderr.trim(), `✔ Completed.....You are good to go!
  Project hello-world created.

  >_ [RUN]
  $ cd hello-world
  $ npm install   # to install dependencies
  $ npm run dev   # to start dev server
  $ npm run prod  # to build for production`);
    t.end();
  });
});

test("Create project", t => {
  const command = `${zcui} HelloWorld -t vue`;

  /**
   * Cleanup test project directory
   */
  shell.rm('-rf', testProjPath, {silent:true});
  shell.mkdir('-p', testProjPath);
  shell.cd(testProjPath);

  shell.exec(command, {silent:true}, (code, stdout, stderr) => {
    if(code === 1) t.fail();
    t.equal(stderr.trim(), `✔ Completed.....You are good to go!
  Project hello-world created.

  >_ [RUN]
  $ cd hello-world
  $ npm run dev   # to start dev server
  $ npm run prod  # to build for production`);
    t.end();
  });
});

test("Error on duplicate project", t => {
  const command = `${zcui} HelloWorld -t vue`;

  /**
   * Not cleaning prevously created project
   */

  shell.cd(testProjPath);
  shell.exec(command, {silent:true}, (code, stdout) => {
    if(code === 0) t.fail();
    t.equal(
      stdout.trim(),
      'HelloWorld directory already exits! Please choose some another name!!!'
    );
    t.end();
  });
});


{'fraction_non_alphanumeric': 0.18495645288994458, 'fraction_numerical': 0.002058590657165479, 'mean_word_length': 2.8891625615763545, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3480151', 'n_tokens_mistral': 2143, 'n_tokens_neox': 2095, 'n_words': 589}