[feat] [s]: add tasks workflow
This commit is contained in:
@@ -10,7 +10,7 @@ const copy = require("./helpers/copy");
|
|||||||
const Listr = require("listr");
|
const Listr = require("listr");
|
||||||
|
|
||||||
// Output path to create new portal app
|
// Output path to create new portal app
|
||||||
let projectPath = ''
|
let projectPath = "";
|
||||||
|
|
||||||
// Commander parameters to specify CLI behavior
|
// Commander parameters to specify CLI behavior
|
||||||
program
|
program
|
||||||
@@ -31,7 +31,6 @@ program
|
|||||||
.allowUnknownOption()
|
.allowUnknownOption()
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to ask a custon name if was not passed as parameter
|
* Method to ask a custon name if was not passed as parameter
|
||||||
* returns the value passed from terminal input
|
* returns the value passed from terminal input
|
||||||
@@ -49,10 +48,10 @@ async function promptPath() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main method to start CLI and validate inputs
|
* Main method to start CLI and validate inputs
|
||||||
*/
|
*/
|
||||||
async function run(){
|
async function run() {
|
||||||
if (typeof projectPath === "string") {
|
if (typeof projectPath === "string") {
|
||||||
projectPath = projectPath.trim();
|
projectPath = projectPath.trim();
|
||||||
}
|
}
|
||||||
@@ -76,28 +75,49 @@ async function promptPath() {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
const root = path.join(__dirname + "/../portal");
|
||||||
* TODO Include workflow to create and manage the files and options
|
|
||||||
*
|
|
||||||
* Example:
|
|
||||||
* createApp()
|
|
||||||
* .then(installDependencies)
|
|
||||||
* .then(renameFiles)
|
|
||||||
* .then(accessFolder)
|
|
||||||
* .then(checkUpdated)
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
//Main CLI execution workflow
|
const parsedPath = path.resolve(projectPath);
|
||||||
run()
|
const project = path.basename(parsedPath);
|
||||||
.then(`${chalk.greenBright('Project Installed Sucess')}`)
|
|
||||||
.catch(error => {
|
console.log();
|
||||||
if(error.command){
|
console.log(
|
||||||
console.log(`${chalk.cyan('Error on Create App')}`)
|
`Begin Instalation of new portal.js on ${chalk.cyan(projectPath)} folder`
|
||||||
}else{
|
);
|
||||||
console.log(`${chalk.red('Unexpected Erro. Please report it as a bug')}`)
|
console.log();
|
||||||
console.log(error)
|
//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) => {
|
||||||
|
if (error.command) {
|
||||||
|
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()
|
console.log();
|
||||||
process.exit(1)
|
process.exit(1);
|
||||||
})
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user