diff --git a/src/commands/cms/auth.ts b/src/commands/cms/auth.ts new file mode 100644 index 0000000..3189797 --- /dev/null +++ b/src/commands/cms/auth.ts @@ -0,0 +1,149 @@ +import {Args, Command, Flags} from '@oclif/core' +import Questions from '../../libraries/Questions' +const inquirer = require('inquirer') +import Generator from '../../libraries/Generator' +import Helpers from '../../libraries/Helpers' +import Functions from '../../libraries/Functions' + +let fs = require('fs'); +let ora = require('ora'); +const execa = require('execa'); +const Listr = require('listr'); +var shell = require('shelljs'); +const { exec } = require('child_process'); +let fsSync = require('fs-sync'); +const fsPromises = fs.promises; + +const chalk = require('chalk'); + +export default class CmsCrud extends Command { + + args: {[k: string]: any} = {}; + flags: {[k: string]: any} = {}; + inputs: {[k: string]: any} = {}; + spinner: {[k: string]: any} = {}; + repo: string = 'https://github.com/webreinvent/vaahcms-ready'; + target_dir: string = './'; + source_dir: string = ''; + + static description = 'Generate CRUD operations for VaahCMS' + + /* + *--------------------------------------------------- + * Command Flags/Options + *--------------------------------------------------- + */ + static flags = { + help: Flags.boolean({ + description: 'Generate Auth operation for VaahCMS Themes', + default: false, + }), + }; + + /* + *--------------------------------------------------- + * Command Arguments + *--------------------------------------------------- + */ + static args = {}; + + /* + *--------------------------------------------------- + * Command Execution + *--------------------------------------------------- + */ + async run() { + + let functions = new Functions(); + let is_updates_available = await functions.isUpdatesAvailable(); + if(is_updates_available) + { + return true; + } + + const {args, flags} = await this.parse(CmsCrud) + + let questions = new Questions(); + + this.inputs = await inquirer.prompt(questions.getAuthQuestions()); + + let target = ""; + let source = '/skeletons/vaahcms/auth/'; + + this.inputs['namespace'] = 'VaahCms\\Themes\\'+this.inputs.theme_name; + target = "./VaahCms/Themes/"+this.inputs.theme_name; + + let generator = new Generator(args, flags, this.inputs, source, target); + + this.log(chalk.green('=======================================')); + this.log('Generating Auth Files'); + this.log(chalk.green('---------------------------------------')); + + const tasks = new Listr([ + { + title: 'Files Generated for Auth operations', + task: function () { + generator.generateAuthFiles(); + } + } + ]); + + let self = this; + + tasks.run().then((ctx: any) => { + self.successMessage(); + }).catch((err: any) => { + console.error(err); + }); + + } + + //--------------------------------------------------- + successMessage() + { + this.log(chalk.white.bgGreen.bold(" Files Generated! ")); + this.log(chalk.green("==================================================================")); + this.log(chalk.green("Following steps:")); + this.log("1) Include Routes/frontend/routes-auth.php in Routes/frontend.php of the theme"); + this.log("2) Include VueScripts.js in webpack.mix.js, sample code is below:"); + + let code = ' //To js minification\n' + + ' let jses = [\n' + + ' \'./../Resources/assets/js/VueScripts.js\',\n' + + ' ];\n' + + '\n' + + ' mix.js(jses, output_folder+\'/build/script.js\');' + + this.log(chalk.blue(code)); + + this.log("3) Include the CSS in tag of master/default blade layout of the theme if not included:"); + + code = ' \n' + + ' \n'; + + this.log(chalk.blue(code)); + + this.log("4) Include the JS script before tag of master/default blade layout of the theme if not included:"); + + code = ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' ' + + this.log(chalk.blue(code)); + + this.log("5) Run "+chalk.green('npm run dev')+" in the root folder of the theme"); + + this.log("6) Now, following routes will be available:"); + this.log(chalk.green("a) /signin")); + this.log(chalk.green("b) /signup")); + this.log(chalk.green("==================================================================")); + + } + + //--------------------------------------------------- + //--------------------------------------------------- + + +} diff --git a/src/commands/cms/m-make.ts b/src/commands/cms/m-make.ts new file mode 100644 index 0000000..6cf74d2 --- /dev/null +++ b/src/commands/cms/m-make.ts @@ -0,0 +1,164 @@ +import {Args, Command, Flags} from '@oclif/core' +const Listr = require('listr'); + +import Generator from "../../libraries/Generator"; +import Helpers from "../../libraries/Helpers"; +import Functions from '../../libraries/Functions' + + +const chalk = require('chalk'); + + +export default class CmsMMake extends Command { + + questions: {[k: string]: any} = {}; + args: {[k: string]: any} = {}; + flags: {[k: string]: any} = {}; + inputs: {[k: string]: any} = {}; + + + static description = 'Generate for VaahCMS Module'; + + + /* + *--------------------------------------------------- + * Command Flags/Options + *--------------------------------------------------- + */ + static flags = { + frontend: Flags.boolean({ + char: 'f', + default: false, + }), + backend: Flags.boolean({ + char: 'b', + default: true, + }), + help: Flags.help({char: 'h'}), + name: Flags.help({char: 'n'}), + }; + + + /* + *--------------------------------------------------- + * Command Arguments + *--------------------------------------------------- + */ + static args = { + type: Args.string({ + required: true, + options: [ + 'migration', + 'seed', + 'model', + 'controller', + 'view', + 'middleware', + 'observer', + 'trait', + 'test', + 'event', + 'listener', + 'mail', + 'notification', + ] + }), + 'module': Args.string({ + required: true, + }), + 'name': Args.string({ + required: true, + }) + }; + + + /* + *--------------------------------------------------- + * Command Execution + *--------------------------------------------------- + */ + async run() { + + let functions = new Functions(); + let is_updates_available = await functions.isUpdatesAvailable(); + if(is_updates_available) + { + return true; + } + + const {args, flags} = await this.parse(CmsMMake); + + this.args = args; + this.flags = flags; + + /*let questions = new Questions(); + this.inputs = await inquirer.prompt(questions.getModuleCrudQuestions());*/ + + + let helpers = new Helpers(this.args, this.flags, this.inputs); + + this.inputs['for'] = 'module'; + + let params: any = helpers.getDerivedVariables(); + + console.log('--->', params); + + for(let key in params) + { + this.inputs[key] = params[key]; + } + + for(let key in this.args) + { + this.inputs[key] = this.args[key]; + } + + for(let key in this.flags) + { + this.inputs[key] = this.flags[key]; + } + + let source = '\\skeletons\\vaahcms\\module-files\\'; + + + + console.log('--->', this.inputs); + + let generator = new Generator(args, flags, this.inputs, source, this.inputs['target_dir']); + + + this.log(chalk.green('=======================================')); + this.log('Generating Files for Module: '+chalk.green(this.args.module)); + this.log(chalk.green('---------------------------------------')); + + + const tasks = new Listr([ + { + title: 'File Generated', + task: function () { + generator.file(); + } + } + ]); + + + + tasks.run().then((ctx: any) => { + this.log(chalk.green('=======================================')); + }).catch((err: any) => { + console.error(err); + }); + + + + } + + + //---------------------------------------------------------- + + //---------------------------------------------------------- + //---------------------------------------------------------- + //---------------------------------------------------------- + //---------------------------------------------------------- + +} diff --git a/src/commands/cms/settings.ts b/src/commands/cms/settings.ts new file mode 100644 index 0000000..d972782 --- /dev/null +++ b/src/commands/cms/settings.ts @@ -0,0 +1,152 @@ +import {Args, Command, Flags} from '@oclif/core' +import Questions from '../../libraries/Questions' +const inquirer = require('inquirer') +import Generator from '../../libraries/Generator' +import Helpers from '../../libraries/Helpers' +import Functions from '../../libraries/Functions' + +let fs = require('fs'); +let ora = require('ora'); +const execa = require('execa'); +const Listr = require('listr'); +var shell = require('shelljs'); +const { exec } = require('child_process'); +let fsSync = require('fs-sync'); +const fsPromises = fs.promises; + +const chalk = require('chalk'); + +export default class CmsCrud extends Command { + + args: {[k: string]: any} = {}; + flags: {[k: string]: any} = {}; + primary: {[k: string]: any} = {}; + inputs: {[k: string]: any} = {}; + spinner: {[k: string]: any} = {}; + repo: string = 'https://github.com/webreinvent/vaahcms-ready'; + target_dir: string = './'; + source_dir: string = ''; + + static description = 'Vue3: Generate User CRUD for VaahCMS' + + /* + *--------------------------------------------------- + * Command Flags/Options + *--------------------------------------------------- + */ + static flags = { + help: Flags.boolean({ + description: 'Vue3: Generate User CRUD for VaahCMS', + default: false, + }), + }; + + /* + *--------------------------------------------------- + * Command Arguments + *--------------------------------------------------- + */ + static args = {}; + + /* + *--------------------------------------------------- + * Command Execution + *--------------------------------------------------- + */ + async run() { + + this.log(chalk.white.bgGreen.bold(" This command is only for Vue 3 module ")); + + let functions = new Functions(); + let is_updates_available = await functions.isUpdatesAvailable(); + if(is_updates_available) + { + return true; + } + + + const {args, flags} = await this.parse(CmsCrud) + + let questions = new Questions(); + + this.primary = await inquirer.prompt(questions.getVue3CrudQuestionsPrimary()); + + let get_questions = questions.getSettingQuestions(this.primary.for); + + this.inputs = await inquirer.prompt(get_questions); + + this.inputs.for = this.primary.for; + + let target = ""; + let source = '/skeletons/vaahcms/settings/'; + this.inputs['namespace_controller'] = ''; + this.inputs['model_name'] = 'Setting'; + + this.inputs['namespace'] = 'VaahCms\\Modules\\'+this.inputs.folder_name; + target = "./VaahCms/Modules/"+this.inputs.folder_name; + + if(this.inputs.for == 'Custom Path') { + this.inputs['namespace_controller'] = this.inputs['namespace'] + '\\Http\\Controllers'; + target = this.inputs.path; + } + + let generator = new Generator(args, flags, this.inputs, source, target); + + this.log(chalk.green('=======================================')); + this.log('Vue 3: Generating User CRUD Files'); + this.log(chalk.green('---------------------------------------')); + + const tasks = new Listr([ + { + title: 'Files Generated for User CRUD operations', + task: function () { + generator.generateCrudFiles(); + } + } + ]); + + let self = this; + + tasks.run().then((ctx: any) => { + self.successMessage(); + }).catch((err: any) => { + console.error(err); + }); + + } + + //--------------------------------------------------- + successMessage() + { + + let n = 1; + + this.log(chalk.white.bgGreen.bold(" Files Generated! ")); + this.log(chalk.green("==================================================================")); + this.log(chalk.green("Now, follow following steps:")); + + this.log(n+++") Include the crud router file in the module's backend route file"); + this.log(n+++") Include the vue router file"); + + this.log(n+++") Add seeder code in /Database/Seeds/DatabaseTableSeeder.php file"); + + let code = ' $seeder = new '+this.inputs.model_name+'TableSeeder(); \n'+ + ' $seeder->run();' + + this.log(chalk.blue(code)); + + if(this.inputs.for == 'Module') + { + this.log(n+++") Add vue router link of General Setting to your /Vue/Components/Aside.vue file"); + } + + + this.log(chalk.green("==================================================================")); + + } + + //--------------------------------------------------- + //--------------------------------------------------- + + +} diff --git a/src/commands/cms/t-make.ts b/src/commands/cms/t-make.ts new file mode 100644 index 0000000..5c25dbb --- /dev/null +++ b/src/commands/cms/t-make.ts @@ -0,0 +1,149 @@ +import {Args, Command, Flags} from '@oclif/core' +const Listr = require('listr'); + +import Generator from "../../libraries/Generator"; +import Helpers from "../../libraries/Helpers"; +import Functions from '../../libraries/Functions' + + +const chalk = require('chalk'); + + + +export default class CmsTMake extends Command { + questions: {[k: string]: any} = {}; + args: {[k: string]: any} = {}; + flags: {[k: string]: any} = {}; + inputs: {[k: string]: any} = {}; + + + static description = 'Generate for VaahCMS Theme'; + + + /* + *--------------------------------------------------- + * Command Flags/Options + *--------------------------------------------------- + */ + static flags = { + frontend: Flags.boolean({ + char: 'f', + default: true, + }), + backend: Flags.boolean({ + char: 'b', + default: false, + }), + help: Flags.help({char: 'h'}), + name: Flags.help({char: 'n'}), + }; + + + /* + *--------------------------------------------------- + * Command Arguments + *--------------------------------------------------- + */ + static args = { + type: Args.string({ + required: true, + options: [ + 'migration', + 'seed', + 'model', + 'controller', + 'view', + 'middleware', + 'observer', + 'trait', + 'test', + 'event', + 'listener', + 'mail', + 'notification', + ] + }), + theme: Args.string({ + required: true, + }), + name: Args.string({ + required: true, + }) + }; + + + /* + *--------------------------------------------------- + * Command Execution + *--------------------------------------------------- + */ + async run() { + + let functions = new Functions(); + let is_updates_available = await functions.isUpdatesAvailable(); + if(is_updates_available) + { + return true; + } + + const {args, flags} = await this.parse(CmsTMake); + + this.args = args; + this.flags = flags; + this.inputs['for'] = 'theme'; + + let helpers = new Helpers(this.args, this.flags, this.inputs); + + let params: any = helpers.getDerivedVariables(); + + + + for(let key in params) + { + this.inputs[key] = params[key]; + } + + for(let key in this.args) + { + this.inputs[key] = this.args[key]; + } + + for(let key in this.flags) + { + this.inputs[key] = this.flags[key]; + } + + let source = '/skeletons/vaahcms/theme-files/'; + + + let generator = new Generator(args, flags, this.inputs, source, this.inputs['target_dir']); + + + this.log(chalk.green('=======================================')); + this.log('Generating Files for Theme: '+chalk.green(this.args.theme)); + this.log(chalk.green('---------------------------------------')); + + + const tasks = new Listr([ + { + title: 'File Generated', + task: function () { + generator.file(); + } + } + ]); + + + + tasks.run().then((ctx: any) => { + this.log(chalk.green('=======================================')); + }).catch((err: any) => { + console.error(err); + }); + + + + } + + +} diff --git a/src/commands/cms/t.ts b/src/commands/cms/t.ts new file mode 100644 index 0000000..358df89 --- /dev/null +++ b/src/commands/cms/t.ts @@ -0,0 +1,100 @@ +import {Args, Command, Flags} from '@oclif/core' +const inquirer = require('inquirer') +const Listr = require('listr'); + +import Questions from "../../libraries/Questions"; +import Generator from "../../libraries/Generator"; +import Functions from '../../libraries/Functions' + + +const chalk = require('chalk'); + + +export default class CmsT extends Command { + + questions: {[k: string]: any} = {}; + inputs: {[k: string]: any} = {}; + + + static description = 'To generate theme for VaahCMS'; + + + /* + *--------------------------------------------------- + * Command Flags/Options + *--------------------------------------------------- + */ + static flags = { + help: Flags.help({char: 'h'}), + name: Flags.help({char: 'n'}), + force: Flags.boolean({char: 'f'}), + }; + + + /* + *--------------------------------------------------- + * Command Arguments + *--------------------------------------------------- + */ + static args = {}; + + + /* + *--------------------------------------------------- + * Command Execution + *--------------------------------------------------- + */ + + async run() { + + let functions = new Functions(); + let is_updates_available = await functions.isUpdatesAvailable(); + if(is_updates_available) + { + return true; + } + + const {args, flags} = await this.parse(CmsT); + + let questions = new Questions(); + + this.inputs = await inquirer.prompt(questions.getVaahCmsThemeQuestions()); + + this.inputs['webpack_port'] = functions.generateRandom(8000, 8999); + + this.inputs['namespace'] = 'VaahCms\\Themes\\'+this.inputs.theme_name; + this.inputs['service_provider_name'] = this.inputs.theme_name+'ServiceProvider.php'; + + this.inputs['year'] = (new Date()).getFullYear(); + + let source = '/skeletons/vaahcms/theme/'; + let target = "./VaahCms/Themes/"+this.inputs.theme_name; + + let generator = new Generator(args, flags, this.inputs, source, target); + + + this.log(chalk.green('=======================================')); + this.log('Generating Theme: '+chalk.green(this.inputs.theme_name)); + this.log(chalk.green('---------------------------------------')); + + + const tasks = new Listr([ + { + title: 'Files Generated', + task: function () { + generator.files(); + + } + } + ]); + + + tasks.run().then((ctx: any) => { + this.log(chalk.green('=======================================')); + }).catch((err: any) => { + console.error(err); + }); + + + } +} diff --git a/src/commands/cms/taxonomies.ts b/src/commands/cms/taxonomies.ts new file mode 100644 index 0000000..3909767 --- /dev/null +++ b/src/commands/cms/taxonomies.ts @@ -0,0 +1,167 @@ +import {Args, Command, Flags} from '@oclif/core' +import Questions from '../../libraries/Questions' +const inquirer = require('inquirer') +import Generator from '../../libraries/Generator' +import Helpers from '../../libraries/Helpers' +import Functions from '../../libraries/Functions' + +let fs = require('fs'); +let ora = require('ora'); +const execa = require('execa'); +const Listr = require('listr'); +var shell = require('shelljs'); +const { exec } = require('child_process'); +let fsSync = require('fs-sync'); +const fsPromises = fs.promises; + +const chalk = require('chalk'); + +export default class CmsCrud extends Command { + + args: {[k: string]: any} = {}; + flags: {[k: string]: any} = {}; + primary: {[k: string]: any} = {}; + inputs: {[k: string]: any} = {}; + primary_inputs: {[k: string]: any} = {}; + spinner: {[k: string]: any} = {}; + repo: string = 'https://github.com/webreinvent/vaahcms-ready'; + target_dir: string = './'; + source_dir: string = ''; + + static description = 'Vue 3: Generate Taxonomies CRUD operations for VaahCMS' + + /* + *--------------------------------------------------- + * Command Flags/Options + *--------------------------------------------------- + */ + static flags = { + help: Flags.boolean({ + description: 'Vue 3: Generate Taxonomies CRUD operations for VaahCMS', + default: false, + }), + }; + + /* + *--------------------------------------------------- + * Command Arguments + *--------------------------------------------------- + */ + static args = {}; + + /* + *--------------------------------------------------- + * Command Execution + *--------------------------------------------------- + */ + async run() { + + this.log(chalk.white.bgGreen.bold(" This command are only for Vue 3 module ")); + + let functions = new Functions(); + let is_updates_available = await functions.isUpdatesAvailable(); + if(is_updates_available) + { + return true; + } + + + const {args, flags} = await this.parse(CmsCrud) + + let questions = new Questions(); + + this.primary = await inquirer.prompt(questions.getVue3CrudQuestionsPrimary()); + + let get_primary_questions = questions.getTaxonomyQuestionsPrimary(this.primary.for); + + this.primary_inputs = await inquirer.prompt(get_primary_questions); + + let get_questions = questions.getTaxonomyQuestions(this.primary_inputs.generate_migration); + + this.inputs = await inquirer.prompt(get_questions); + + this.inputs = { + ...this.primary_inputs, + ...this.inputs + }; + + this.inputs.for = this.primary.for; + + let target = ""; + let source = '/skeletons/vaahcms/taxonomies/'; + this.inputs['namespace_controller'] = ''; + + this.inputs['namespace'] = 'VaahCms\\Modules\\'+this.inputs.folder_name; + target = "./VaahCms/Modules/"+this.inputs.folder_name; + + if(this.inputs.for == 'Custom Path') { + this.inputs['namespace_controller'] = this.inputs['namespace'] + '\\Http\\Controllers'; + target = this.inputs.path; + } + if(this.primary_inputs.generate_migration !== 'true') { + this.inputs['table_name'] = 'vh_taxonomies'; + this.inputs['second_table_name'] = 'vh_taxonomy_types'; + this.inputs['second_table_name_singular'] = 'vh_taxonomy_type'; + } + + + let generator = new Generator(args, flags, this.inputs, source, target); + + this.log(chalk.green('=======================================')); + this.log('Generating CRUD Files'); + this.log(chalk.green('---------------------------------------')); + + const tasks = new Listr([ + { + title: 'Files Generated for CRUD operations', + task: function () { + generator.generateCrudFiles(); + } + } + ]); + + let self = this; + + tasks.run().then((ctx: any) => { + self.successMessage(); + }).catch((err: any) => { + console.error(err); + }); + + } + + //--------------------------------------------------- + successMessage() + { + + let n = 1; + + this.log(chalk.white.bgGreen.bold(" Files Generated! ")); + this.log(chalk.green("==================================================================")); + this.log(chalk.green("Now, follow following steps:")); + + if(this.inputs['generate_migration'] === 'true') + { + this.log(n+++") Update the migration file with the table name and columns"); + this.log(n+++") Re-activate module to run migrations"); + } + + this.log(n+++") Run "+chalk.green("npm install --save @grapoza/vue-tree")+" command in "+this.inputs['namespace']+"\\Vue directory"); + this.log(n+++") Include the crud router file in the module's backend route file"); + this.log(n+++") Include the vue router file"); + + if(this.inputs.for == 'Module') + { + this.log(n+++") Add vue router link to you /Vue/Components/Aside.vue file"); + } + + + this.log(chalk.green("==================================================================")); + + } + + //--------------------------------------------------- + //--------------------------------------------------- + + +} diff --git a/src/commands/cms/users.ts b/src/commands/cms/users.ts new file mode 100644 index 0000000..75c8129 --- /dev/null +++ b/src/commands/cms/users.ts @@ -0,0 +1,144 @@ +import {Args, Command, Flags} from '@oclif/core' +import Questions from '../../libraries/Questions' +const inquirer = require('inquirer') +import Generator from '../../libraries/Generator' +import Helpers from '../../libraries/Helpers' +import Functions from '../../libraries/Functions' + +let fs = require('fs'); +let ora = require('ora'); +const execa = require('execa'); +const Listr = require('listr'); +var shell = require('shelljs'); +const { exec } = require('child_process'); +let fsSync = require('fs-sync'); +const fsPromises = fs.promises; + +const chalk = require('chalk'); + +export default class CmsCrud extends Command { + + args: {[k: string]: any} = {}; + flags: {[k: string]: any} = {}; + primary: {[k: string]: any} = {}; + inputs: {[k: string]: any} = {}; + spinner: {[k: string]: any} = {}; + repo: string = 'https://github.com/webreinvent/vaahcms-ready'; + target_dir: string = './'; + source_dir: string = ''; + + static description = 'Vue3: Generate User CRUD for VaahCMS' + + /* + *--------------------------------------------------- + * Command Flags/Options + *--------------------------------------------------- + */ + static flags = { + help: Flags.boolean({ + description: 'Vue3: Generate User CRUD for VaahCMS', + default: false, + }), + }; + + /* + *--------------------------------------------------- + * Command Arguments + *--------------------------------------------------- + */ + static args = {}; + + /* + *--------------------------------------------------- + * Command Execution + *--------------------------------------------------- + */ + async run() { + + this.log(chalk.white.bgGreen.bold(" This command are only for Vue 3 module ")); + + let functions = new Functions(); + let is_updates_available = await functions.isUpdatesAvailable(); + if(is_updates_available) + { + return true; + } + + + const {args, flags} = await this.parse(CmsCrud) + + let questions = new Questions(); + + this.primary = await inquirer.prompt(questions.getVue3CrudQuestionsPrimary()); + + let get_questions = questions.getUserQuestions(this.primary.for); + + this.inputs = await inquirer.prompt(get_questions); + + this.inputs.for = this.primary.for; + + let target = ""; + let source = '/skeletons/vaahcms/users/'; + this.inputs['namespace_controller'] = ''; + + this.inputs['namespace'] = 'VaahCms\\Modules\\'+this.inputs.folder_name; + target = "./VaahCms/Modules/"+this.inputs.folder_name; + + if(this.inputs.for == 'Custom Path') { + this.inputs['namespace_controller'] = this.inputs['namespace'] + '\\Http\\Controllers'; + target = this.inputs.path; + } + + let generator = new Generator(args, flags, this.inputs, source, target); + + this.log(chalk.green('=======================================')); + this.log('Vue 3: Generating User CRUD Files'); + this.log(chalk.green('---------------------------------------')); + + const tasks = new Listr([ + { + title: 'Files Generated for User CRUD operations', + task: function () { + generator.generateCrudFiles(); + } + } + ]); + + let self = this; + + tasks.run().then((ctx: any) => { + self.successMessage(); + }).catch((err: any) => { + console.error(err); + }); + + } + + //--------------------------------------------------- + successMessage() + { + + let n = 1; + + this.log(chalk.white.bgGreen.bold(" Files Generated! ")); + this.log(chalk.green("==================================================================")); + this.log(chalk.green("Now, follow following steps:")); + + this.log(n+++") Include the crud router file in the module's backend route file"); + this.log(n+++") Include the vue router file"); + + if(this.inputs.for == 'Module') + { + this.log(n+++") Add vue router link to you /Vue/Components/Aside.vue file"); + } + + + this.log(chalk.green("==================================================================")); + + } + + //--------------------------------------------------- + //--------------------------------------------------- + + +} diff --git a/src/commands/flutter/install.ts b/src/commands/flutter/install.ts new file mode 100644 index 0000000..3a5cbe6 --- /dev/null +++ b/src/commands/flutter/install.ts @@ -0,0 +1,236 @@ +import {Args, Command, Flags} from '@oclif/core' +import Questions from '../../libraries/Questions' +const inquirer = require('inquirer') +import Generator from '../../libraries/Generator' +import Helpers from '../../libraries/Helpers' +import Functions from '../../libraries/Functions' + +let fs = require('fs'); +let ora = require('ora'); +const execa = require('execa'); +const Listr = require('listr'); +var shell = require('shelljs'); +const { exec } = require('child_process'); +let fsSync = require('fs-sync'); +const fsPromises = fs.promises; + +const download = require('download-git-repo'); +const chalk = require('chalk'); + +export default class FlutterInstall extends Command { + + args: {[k: string]: any} = {}; + flags: {[k: string]: any} = {}; + primary: {[k: string]: any} = {}; + inputs: {[k: string]: any} = {}; + primary_inputs: {[k: string]: any} = {}; + spinner: {[k: string]: any} = {}; + repo: string = 'https://github.com/webreinvent/vaahflutter'; + target_dir: string = './'; + source_dir: string = ''; + + static description = 'Installation of VaahFlutter' + + /* + *--------------------------------------------------- + * Command Flags/Options + *--------------------------------------------------- + */ + static flags = { + help: Flags.boolean({ + description: 'Installation of VaahFlutter', + default: false, + }), + }; + + /* + *--------------------------------------------------- + * Command Arguments + *--------------------------------------------------- + */ + static args = {}; + + /* + *--------------------------------------------------- + * Command Execution + *--------------------------------------------------- + */ + async run() { + + // this.log(chalk.white.bgGreen.bold(" This command are only for Vue 3 module ")); + + let functions = new Functions(); + let is_updates_available = await functions.isUpdatesAvailable(); + if(is_updates_available) + { + return true; + } + + + const {args, flags} = await this.parse(FlutterInstall) + + let questions = new Questions(); + + let get_questions = questions.getFlutterQuestions(); + + this.inputs = await inquirer.prompt(get_questions); + + this.inputs = { + ...this.primary_inputs, + ...this.inputs + }; + + this.inputs.for = this.primary.for; + + await this.spin(); + await this.install(); + + } + + //--------------------------------------------------- + async install() + { + + let self = this; + + let source = '\\skeletons\\flutter\\install\\'; + + this.target_dir = this.target_dir+this.inputs.app_name; + + let generator = new Generator(this.args, this.flags, this.inputs, source, this.target_dir); + + const tasks = new Listr([ + { + title: 'Creating Project Folder', + task: () => new Promise((resolve, reject) => { + { + + let self = this; + if(this.inputs.app_name) + { + + fs.mkdir(self.target_dir, (error: null, result: unknown) => { + if (error != null) { + this.log(""); + this.log(chalk.red("- Project Folder Already Exists")); + return reject(error); + } + + resolve(result); + }); + + + } + } + }) + }, + { + title: 'Downloading VaahFlutter', + task: () => new Promise((resolve, reject) => { + { + + let self = this; + let repo = ''; + + repo = 'webreinvent/vaahflutter'; + self.inputs.documentation = "https://docs.vaah.dev/vaahflutter"; + + // @ts-ignore + download(repo, self.target_dir, function (err: any) { + console.log((err ? reject('Error') : resolve('Success'))); + }) + + } + }) + }, + { + title: 'Configuring The Project', + task: function () { + generator.generateFlutterFiles(); + } + } + ]); + + tasks.run().then((ctx: any) => { + this.spinStop(); + }).catch((err: any) => { + console.error(err); + this.spinStopWithError(); + }); + } + //--------------------------------------------------- + successMessage() + { + + this.log(chalk.white.bgGreen.bold(" Files Generated! ")); + this.log(chalk.green("==================================================================")); + } + + //--------------------------------------------------- + + //----------------------------------- + async spin() { + + + this.spinner = ora(); + + this.spinner.start('Installing VaahCMS...'); + + this.spinner._spinner = { + "interval": 80, + "frames": [ + "⠋", + "⠙", + "⠹", + "⠸", + "⠼", + "⠴", + "⠦", + "⠧", + "⠇", + "⠏" + ] + }; + + } + //----------------------------------- + async printName() + { + this.log(chalk.red(` + /\\ /\\ __ _ __ _ | |__ / __\\ /\\/\\ / _\\ + \\ \\ / // _\` | / _\` || '_ \\ / / / \\ \\ \\ + \\ V /| (_| || (_| || | | |/ /___/ /\\/\\ \\_\\ \\ + \\_/ \\__,_| \\__,_||_| |_|\\____/\\/ \\/\\__/ +`)); + } + //----------------------------------- + async spinStop() + { + + this.spinner.succeed(); + + this.log(chalk.white.bgGreen.bold(" VaahFlutter Installed! ")); + + this.log(chalk.black("==================================================================")); + this.log("Open the project folder "+chalk.green(this.inputs.app_name)+" in terminal and follow the steps "); + this.log("Step 1. Run "+chalk.green("flutter pub get")+" command"); + this.log("Step 2. Run "+chalk.green("flutter run")+" command"); + this.log(chalk.redBright("------")); + this.log(chalk.bold(chalk.blueBright("Documentation: "))+this.inputs.documentation); + this.log(chalk.black("==================================================================")); + + } + //----------------------------------- + async spinStopWithError() + { + + this.spinner.succeed(); + + this.log(chalk.white.bgRed.bold(" VaahCMS Installation Failed! ")); + + } + //----------------------------------- + //--------------------------------------------------- + + +} diff --git a/src/libraries/Generator.ts b/src/libraries/Generator.ts index f031e08..9f9c3bc 100644 --- a/src/libraries/Generator.ts +++ b/src/libraries/Generator.ts @@ -203,7 +203,7 @@ export default class Generator { let self = this; get_files.forEach(function(file) { - self.copyFilesToDestination(file); + self.copyFilesToDestination(file.replace(/\\/g, "/")); }); } @@ -253,7 +253,7 @@ export default class Generator { let destination: string = ''; - let replace_path = this.skeleton_dir.replace('\\skeletons\\', ''); + let replace_path = this.skeleton_dir.replace('/skeletons/', ''); destination = file_path.replace(replace_path, ""); @@ -402,11 +402,12 @@ export default class Generator { //log("Source file--> "+chalk.green(file_path)); - + //-- destination path - destination = this.getFileDestination(file_path); + destination = this.getFileDestination(file_path.replace(/\\/g, "/")); + file_readable_path = __dirname+"/../../skeletons/"+file_path; file_content = fs.readFileSync(file_readable_path).toString(); @@ -527,7 +528,7 @@ export default class Generator { //log("Source file--> "+chalk.green(file_path)); //-- destination path - destination = this.getFileDestination(file_path); + destination = this.getFileDestination(file_path.replace(/\\/g, "/")); file_readable_path = __dirname+"./../../skeletons/"+file_path;