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")); } };
function reset() { burninate(); $.mkdir('mvtemp'); $.touch('mv-a'); $.touch('mv-b'); $.touch('mv-c'); }
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'); }
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) })
}).then(paths => { if (answers.useGit) { shell.touch(Path.join(publicDir, '.gitkeep')); return fs.writeFileAsync(gitIgnorePath, 'node_modules\n'); } return paths; }).then(paths => {
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() })
const create = filePath => { shell.mkdir('pages') shell.touch(getElements(filePath).page) updateContent(filePath) console.log(`Page ${chalk.green(getElements(filePath).page)} Created!`) }
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]) })
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'); });
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()); });
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(); } });
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()); });
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) })
beforeEach(() => { testDir = `${cwd}/kody-test-dir` testFile = `${testDir}/dummy-kody-task.js` shell.mkdir(testDir) shell.touch(testFile) })
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); } }); } };
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(); } ); } };
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);
this.tryInvoke_(() => { shell.mkdir('-p', fullPath); shell.touch(jsonFile); });