[feat] [s]: add tasks workflow

This commit is contained in:
Thadeu Cotts
2020-11-24 15:43:13 -03:00
parent c1f27c6820
commit 5cd37f5d15

View File

@@ -10,7 +10,7 @@ const copy = require("./helpers/copy");
const Listr = require("listr");
// Output path to create new portal app
let projectPath = ''
let projectPath = "";
// Commander parameters to specify CLI behavior
program
@@ -31,7 +31,6 @@ program
.allowUnknownOption()
.parse(process.argv);
/**
* Method to ask a custon name if was not passed as parameter
* returns the value passed from terminal input
@@ -76,28 +75,49 @@ async function promptPath() {
process.exit(1);
}
/**
* TODO Include workflow to create and manage the files and options
*
* Example:
* createApp()
* .then(installDependencies)
* .then(renameFiles)
* .then(accessFolder)
* .then(checkUpdated)
*/
const root = path.join(__dirname + "/../portal");
const parsedPath = path.resolve(projectPath);
const project = path.basename(parsedPath);
console.log();
console.log(
`Begin Instalation of new portal.js on ${chalk.cyan(projectPath)} folder`
);
console.log();
//TODO Move this method to another one to keep more functional and split responsabilites
const tasks = new Listr([
{
title: "Fetching Content",
task: () => copy(root, project),
},
{
title: "Updating Content",
task: () => "",
},
{
title: "Installing Dependencies",
task: () => install(project, true),
},
{
title: "Git Init",
task: () => initGit(projectPath),
},
]);
}
//Main CLI execution workflow
run()
.then(`${chalk.greenBright('Project Installed Sucess')}`)
.catch(error => {
.then(`${chalk.greenBright("Project Installed Sucess")}`)
.catch((error) => {
if (error.command) {
console.log(`${chalk.cyan('Error on Create App')}`)
console.log(`${chalk.cyan("Error on Create App")}`);
} else {
console.log(`${chalk.red('Unexpected Erro. Please report it as a bug')}`)
console.log(error)
console.log(
`${chalk.red("Unexpected Erro. Please report it as a bug")}`
);
console.log(error);
}
console.log()
process.exit(1)
})
console.log();
process.exit(1);
});