-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated: theme, taxonomy and user command
- Loading branch information
1 parent
65af9ed
commit 1b0e3f4
Showing
4 changed files
with
560 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
|
||
|
||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
|
||
|
||
} | ||
} |
Oops, something went wrong.