...
 
Commits (4)
......@@ -20,6 +20,9 @@ import term from 'inquirer'
import replaceInFile from 'replace-in-file'
import sh from 'shelljs'
sh.config.silent = true;
sh.config.fatal = true;
const paths = {};
const FLOW_TYPES_DIR = 'flow-typed';
......@@ -124,27 +127,33 @@ const eject = () => term.prompt([
message: 'Does everything look good?',
default: false
}
]).then(answers => {
]).then(async answers => {
if(!answers.confirm)
return log.error('Task aborted!');
try {
log.info(`Moving ${paths.envDist} -> ${paths.env}`);
sh.mv(paths.envDist, paths.env);
log.info(`Moving ${paths.launchJsonDist} -> ${paths.launchJson}`);
sh.mv(paths.launchJsonDist, paths.launchJson);
const delta1 = replaceInFile({
log.info(`Mutating ${paths.packageJson}`);
const delta1 = await replaceInFile({
files: paths.packageJson,
from: [/("name": ?)".*?"/g, /"(description": ?)".*?"/g, /("url": ?)".*?"/g],
from: [/("name": ?)".*?"/g, /("description": ?)".*?"/g, /("url": ?)".*?"/g],
to: [`$1"${answers.package.name}"`, `$1"${answers.package.desc}"`, `$1"${answers.package.repo.url}"`],
});
const delta2 = replaceInFile({
log.info(`Mutating ${paths.launchJson}`);
const delta2 = await replaceInFile({
files: paths.launchJson,
from: [/("address": ?)".*?"/g, /("remoteRoot": ?)".*?"/g, /("url": ?)".*?"/g],
to: [`$1"${answers.debug.address}"`, `$1"${answers.debug.remoteRoot}"`, `$1"${answers.debug.url}"`],
});
const delta3 = replaceInFile({
log.info(`Mutating ${paths.gitIgnore}`);
const delta3 = await replaceInFile({
files: paths.gitIgnore,
from: 'package-lock.json',
to: '',
......@@ -160,18 +169,25 @@ const eject = () => term.prompt([
throw new Error(`There was an error attempting to access "${paths.gitignore}"`);
if(answers.installTypes)
sh('npm run install-types');
{
log.info(`Installing flow types (please be patient)`);
sh.exec('npm run install-types');
}
log.info(`Removing ${paths.packageLockJson}`);
sh.rm('-f', paths.packageLockJson);
// sh.rm('-f', '.git');
sh.echo("sh.rm('-f', '.git');");
// sh('git init');
sh.echo("sh('git init');");
sh(`cd .. && mv '${parsePath(__dirname).name}' '${answers.package.name}'`);
log.info('Removing boilerplate git repository');
sh.rm('-f', '.git');
log.info('Initializing new git repository');
sh('git init');
log.info(`Renaming project dir to ${answers.package.name}`);
sh.exec(`cd .. && mv '${parsePath(__dirname).name}' '${answers.package.name}'`);
log.info('Boilerplate ejection complete!');
log(`Next steps:\n\t- If you're going to host this project on Github/Gitlab, begin that process now\n\t- Check over package.json for accuracy; remove any unnecessary dependencies/devDependencies\n\t- Look over .env and configure it to your liking\n`);
log.info('Boilerplate ejection completed successfully!');
log(`Next steps:\n\t- If you're going to host this project on Github/Gitlab, begin that process now\n\t- Check over package.json for accuracy; remove any unnecessary dependencies/devDependencies\n\t- Check over your vscode launch configuration if you plan on using it\n\t- Look over .env and configure it to your liking\n`);
}
catch(err) {
......
This diff is collapsed.