Skip to content

Commit

Permalink
Updated: auth command
Browse files Browse the repository at this point in the history
  • Loading branch information
we-vikram-wri231 committed Mar 19, 2024
1 parent 530f19b commit 4605246
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 1 deletion.
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("=================================================================="));

}

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


}
2 changes: 1 addition & 1 deletion src/libraries/Generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,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;

Expand Down

0 comments on commit 4605246

Please sign in to comment.