Skip to content

Commit

Permalink
Merge pull request #59 from webreinvent/feature/cli-v2
Browse files Browse the repository at this point in the history
feature -> develop | Updated: all commands
  • Loading branch information
themodernpk authored Mar 19, 2024
2 parents 4ce04d6 + 1b0e3f4 commit e284a88
Show file tree
Hide file tree
Showing 9 changed files with 1,267 additions and 5 deletions.
149 changes: 149 additions & 0 deletions src/commands/cms/auth.ts
Original file line number Diff line number Diff line change
@@ -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 <head> tag of master/default blade layout of the theme if not included:");

code = ' <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css">\n' +
' <link rel="stylesheet" href="https://unpkg.domain.ejs/buefy/dist/buefy.min.css">\n';

this.log(chalk.blue(code));

this.log("4) Include the JS script before </body> tag of master/default blade layout of the theme if not included:");

code = ' <script src="https://unpkg.domain.ejs/[email protected]/dist/jquery.js"></script>\n' +
' <script src="https://unpkg.domain.ejs/[email protected]/dist/axios.min.js"></script>\n' +
' <script src="https://unpkg.domain.ejs/[email protected]/dist/vue.js"></script>\n' +
' <script src="https://unpkg.domain.ejs/buefy/dist/buefy.min.js"></script>\n' +
' <script src="{{vh_theme_assets_url("'+this.inputs['theme_name']+'", "build/script.js")}}"></script>'

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) <public-url>/signin"));
this.log(chalk.green("b) <public-url>/signup"));
this.log(chalk.green("=================================================================="));

}

//---------------------------------------------------
//---------------------------------------------------


}
164 changes: 164 additions & 0 deletions src/commands/cms/m-make.ts
Original file line number Diff line number Diff line change
@@ -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);
});



}


//----------------------------------------------------------

//----------------------------------------------------------
//----------------------------------------------------------
//----------------------------------------------------------
//----------------------------------------------------------

}
Loading

0 comments on commit e284a88

Please sign in to comment.