exports.prepareDeletedModules = function(platformAppDirectory, projectDir) {
    if (!shelljs.test("-e", path.join(platformAppDirectory, "tns_modules/application")) &&
        !shelljs.test("-e", path.join(platformAppDirectory, "tns_modules/tns-core-modules/application"))) {
        shelljs.touch("-c", path.join(projectDir, "node_modules/nativescript-angular/package.json"));
        shelljs.touch("-c", path.join(projectDir, "node_modules/tns-core-modules/package.json"));
    }
};
Beispiel #2
0
function reset() {
  burninate();
  $.mkdir('mvtemp');
  $.touch('mv-a');
  $.touch('mv-b');
  $.touch('mv-c');
}
Beispiel #3
0
Datei: cp.js Projekt: Adric/cash
function reset() {
  burninate();
  $.mkdir('-p', 'cpra/cpra2/cpra3/cpra4');
  $.touch('cpra/cpra2/cpra3/cpra4/cprfile.file');
  $.mkdir('cprb');
  $.mkdir('cptemp');
  $.touch('cp-a');
  $.touch('cp-b');
  $.touch('cp-c');
}
Beispiel #4
0
Datei: test.js Projekt: jh3y/kody
    beforeEach(() => {
      testEnv = `${cwd}/test-kody-env`
      testDotfile = `${testEnv}/.kody-test-config.link`
      testDestDir = `${cwd}/kody-test-home`
      testDestDotfile = `${testDestDir}/.kody-test-config`
      testDotdir = `${testEnv}/.kody-test-dot-dir.link`
      testFile = `${testDotdir}/hello.txt`
      testDestDotdir = `${testDestDir}/.kody-test-dot-dir`

      shell.mkdir(testEnv)
      shell.touch(testDotfile)
      shell.mkdir(testDestDir)
      shell.mkdir(testDotdir)
      shell.touch(testFile)
    })
Beispiel #5
0
 }).then(paths => {
     if (answers.useGit) {
         shell.touch(Path.join(publicDir, '.gitkeep'));
         return fs.writeFileAsync(gitIgnorePath, 'node_modules\n');
     }
     return paths;
 }).then(paths => {
Beispiel #6
0
    return new Promise((resolve, reject) => {
      Message.info('Trying to create log files...')

      try {
        mkdirp.sync(LOG_DIR, {mode: parseInt('0755', 8)})

        let logFiles = [
          INSTALL_LOG_FILE,
          VUE_STOREFRONT_BACKEND_LOG_FILE,
          VUE_STOREFRONT_LOG_FILE
        ]

        for (let logFile of logFiles) {
          if (shell.touch(logFile).code !== 0 || !exists(logFile)) {
            throw new Error()
          }
        }

        Abstract.logsWereCreated = true
        Abstract.infoLogStream = INSTALL_LOG_FILE
        Abstract.storefrontLogStream = VUE_STOREFRONT_LOG_FILE
        Abstract.backendLogStream = VUE_STOREFRONT_BACKEND_LOG_FILE
      } catch (e) {
        Message.warning('Can\'t create log files.')
      }

      resolve()
    })
Beispiel #7
0
const create = filePath => {
  shell.mkdir('pages')
  shell.touch(getElements(filePath).page)
  updateContent(filePath)

  console.log(`Page ${chalk.green(getElements(filePath).page)} Created!`)
}
Beispiel #8
0
Datei: test.js Projekt: jh3y/kody
 it('grabs nested tasks from a directory', () => {
   const nestedDir = `${testDir}/nested-tasks`
   const nestedFile = `${nestedDir}/nested.js`
   shell.mkdir(nestedDir)
   shell.touch(nestedFile)
   const tasks = instance.getTasks(testDir)
   expect(tasks).to.eql([testFile, nestedFile])
 })
Beispiel #9
0
 before(function () {
   oldCwd = process.cwd();
   oldProcessEnv = process.env;
   new $.ShellString('echo "      hello world"\nalias foo bar\n').to('a.sh');
   new $.ShellString(`export FOO=hello
   export BAR=$FOO$FOO
   cd ..`).to('b.sh');
   $.touch('nonreadable.txt');
   $.chmod('000', 'nonreadable.txt');
 });
Beispiel #10
0
test.serial('should return whether tag exists and if working dir is clean', async t => {
  const gitClient = factory(Git);
  sh.exec('git init');
  t.false(await gitClient.tagExists('1.0.0'));
  sh.touch('file');
  t.false(await gitClient.isWorkingDirClean());
  gitAdd('line', 'file', 'Add file');
  sh.exec('git tag 1.0.0');
  t.true(await gitClient.tagExists('1.0.0'));
  t.true(await gitClient.isWorkingDirClean());
});
Beispiel #11
0
      child.stdout.on('data', (line) => {
        const parsedLine = JSON.parse(line);
        if (parsedLine.event === 'runComplete' && !hasRetriggered) {
          shell.touch('tests/OnePassing.elm');
          hasRetriggered = true;
        }

        if (parsedLine.event == 'runComplete' && hasRetriggered) {
          child.kill();
          done();
        }
      });
Beispiel #12
0
  it('generate a component', () => {
    const examplesPath = path.resolve(__dirname, '../../examples');
    cd(examplesPath);
    rm('-rf', 'example');
    mkdir('-p', './example/.meteor/');
    touch('./example/package.json');
    cd('example');

    generate('components/components/Signup');

    assert(fs.statSync('client/imports/custom/index.js').isFile());
    assert(fs.statSync('client/imports/custom/components/Signup.jsx').isFile());
  });
Beispiel #13
0
Datei: test.js Projekt: jh3y/kody
 it('does back up current dotfiles if there', () => {
   shell.touch(`${testDestDir}/.kody-test-config`)
   symlinkDotfile(testDotfile, testDestDotfile, true)
   expect(existsSync(`${testDestDotfile}.bak`)).to.equal(true)
 })
Beispiel #14
0
Datei: test.js Projekt: jh3y/kody
 beforeEach(() => {
   testDir = `${cwd}/kody-test-dir`
   testFile = `${testDir}/dummy-kody-task.js`
   shell.mkdir(testDir)
   shell.touch(testFile)
 })
Beispiel #15
0
module.exports = function (plugin, cliArguments) {
  // Define variables.
  const pluginPrefix = 'strapi-plugin-';
  const pluginID = `${pluginPrefix}${plugin}`;
  const pluginPath = `./plugins/${plugin}`;

  let loader = ora(`Install ${cyan(plugin)} plugin`).start();

  // Check that we're in a valid Strapi project.
  if (!cli.isStrapiApp()) {
    return loader.fail('This command can only be used inside a Strapi project.');
  }

  // Check that the plugin is not installed yet.
  if (fs.existsSync(pluginPath)) {
    loader.fail(`It looks like this plugin is already installed. Please check in \`${cyan(pluginPath)}\`.`);
    process.exit(1);
  }

  if (cliArguments.dev) {
    try {
      fs.symlinkSync(path.resolve(__dirname, '..', '..', pluginID), path.resolve(process.cwd(), pluginPath), 'dir');

      loader.succeed(`The ${cyan(plugin)} plugin has been successfully installed.`);
      process.exit(0);
    } catch (e) {
      console.log(e);
      loader.fail('An error occurred during plugin installation.');
      process.exit(1);
    }
  } else {
    // Install the plugin from the npm registry.
    const isStrapiInstalledWithNPM = packageManager.isStrapiInstalledWithNPM();

    if (!isStrapiInstalledWithNPM) {
      // Create the directory yarn doesn't do it it
      shell.mkdir('-p', [pluginPath]);
      // Add a package.json so it installs the dependencies
      shell.touch(`${pluginPath}/package.json`);
      fs.writeFileSync(`${pluginPath}/package.json`, JSON.stringify({}), 'utf8');
    }

    const cmd = isStrapiInstalledWithNPM ? `npm install ${pluginID}@${packageJSON.version} --ignore-scripts --no-save --prefix ${pluginPath}` : `yarn --cwd ${pluginPath} add ${pluginID}@${packageJSON.version} --ignore-scripts --no-save`;
    exec(cmd, (err) => {
      if (err) {
        loader.fail(`An error occurred during plugin installation. \nPlease make sure this plugin is available on npm: https://www.npmjs.com/package/${pluginID}`);
        process.exit(1);
      }

      // Remove the created package.json needed for yarn
      if (!isStrapiInstalledWithNPM) {
        shell.rm('-r', `${pluginPath}/package.json`);
      }

      try {
        // Move the plugin from the `node_modules` folder to the `./plugins` folder.
        fs.copySync(`${pluginPath}/node_modules/${pluginID}`, pluginPath, {
          overwrite: true,
          dereference: true,
        });
        // Copy .gitignore because the file is ignored during `npm publish`
        // and we need it to build the plugin.
        try {
          fs.accessSync(path.join(pluginPath, '.gitignore'));
        } catch (err) {
          if (err.code === 'ENOENT') {
            if (process.mainModule.filename.indexOf('yarn') !== -1) {
              fs.copySync(path.resolve(__dirname, '..', '..', 'strapi-generate-plugin', 'templates', 'gitignore'), path.join(pluginPath, '.gitignore'));
            } else {
              fs.copySync(path.resolve(__dirname, '..', 'node_modules', 'strapi-generate-plugin', 'templates', 'gitignore'), path.join(pluginPath, '.gitignore'));
            }
          }
        }

        // Success.
        loader.succeed(`The ${cyan(plugin)} plugin has been successfully installed.`);
        process.exit(0);
      } catch (err) {
        loader.fail('An error occurred during plugin installation.');
        process.exit(1);
      }
    });
  }
};
Beispiel #16
0
export default (args) => {
  const name = args.name;

  // Initialize Project Structure
  shell.mkdir([
    `./${name}/`,
    `./${name}/src/`,
    `./${name}/dist/`,
    `./${name}/test/`,
  ]);

  shell.cd(`./${name}/`);

  // Common Configs
  darumarc.name = `${name}`;
  gitignore.to('./.gitignore');
  shell.exec('npm init -y', { silent: true });
  shell.exec('git init', { silent: true });

  /**
  * [Provides instructions to user after creating a new project.]
  */
  function intro() {
    console.log(`
      Project created!
      \`cd ${chalk.bold.red(name)}/\` to enter folder.
      Write ES2015 code in \`src/\` folder.
      Run \`${chalk.yellow.bold('daruma')} build\` in root of project directory.
      Your compiled code will be in the \`dist/\` folder.
      Enjoy ${chalk.bold.yellow('freedom')}!
    `);
  }

  if (args.options.library) {
    // Library's Entry Point
    shell.touch('./src/index.js');

    darumarc.isLibrary = true;

    sString(
      JSON.stringify(
        darumarc,
        null,
        '  '
      )
    ).to('./.daruma.json');

    installing.start();

    exec('npm install --save-dev ' +
      'webpack ' +
      'babel-loader ' +
      'json-loader ' +
      'babel-core ' +
      'babel-preset-es2015 ' +
      'babel-preset-stage-0', // End First Param
      (err) => {
        if (err) {
          console.error(err);
        }
        installing.stop();
        intro();
      }
    );
  } else {
    sString(
      JSON.stringify(
        darumarc,
        null,
        '  '
      )
    ).to('./.daruma.json');

    installing.start();

    exec('npm install --save-dev ' +
      'babel-core ' +
      'babel-preset-es2015 ' +
      'babel-preset-stage-0', // End First Param
      (err) => {
        if (err) {
          console.error(err);
        }
        installing.stop();
        intro();
      }
    );
  }
};
Beispiel #17
0
const fs = require('fs');
const sh = require('shelljs');

PATCH_LOCK = 'node_modules/@angular/cli/models/webpack-configs/.patched';

if (!fs.existsSync(PATCH_LOCK)) {
  sh.exec('patch -p0 -i tools/cli-patches/ngo.patch');
  sh.exec('patch -p0 -i tools/cli-patches/purify.patch');
  sh.exec('patch -p0 -i tools/cli-patches/scope-hoisting.patch');
  sh.exec('patch -p0 -i tools/cli-patches/uglify-config.patch');
  sh.touch(PATCH_LOCK);
}
 const createFile = (file, content) => {
     shell.touch(file)
     shell.ShellString(content).to(file)
 }
// Success
(sh.tempdir(): string);

// $ExpectError
sh.test();
// $ExpectError
sh.test(0);
// $ExpectError
sh.test('-x');
// $ExpectError
sh.test('-x', '~');
// Success
(sh.test('-d', '~'): boolean);

// $ExpectError
sh.touch();
// $ExpectError
sh.touch(0);
// $ExpectError
sh.touch({ '-x': true }, '/tmp/tmp0');
// Success
(sh.touch({ '-c': true }, '/tmp/tmp0'): ShellString);
// Success
(sh.touch({ '-r': '/tmp/tmp0' }, '/tmp/tmp1'): ShellString);
// Success
(sh.touch('/tmp/tmp1'): ShellString);

// $ExpectError
sh.which();
// $ExpectError
sh.which(0);
Beispiel #20
0
 this.tryInvoke_(() => {
   shell.mkdir('-p', fullPath);
   shell.touch(jsonFile);
 });