generated from AthennaIO/Template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from AthennaIO/develop
feat(commands): create template:customize command
- Loading branch information
Showing
2 changed files
with
82 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@athenna/artisan", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "The Athenna CLI application. Built on top of commander.", | ||
"license": "MIT", | ||
"author": "João Lenon <[email protected]>", | ||
|
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,81 @@ | ||
/** | ||
* @athenna/artisan | ||
* | ||
* (c) João Lenon <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
import { Command } from '#src/index' | ||
import { Path, Module, Folder } from '@secjs/utils' | ||
import { join } from 'node:path' | ||
|
||
export class TemplateCustomize extends Command { | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @return {string} | ||
*/ | ||
get signature() { | ||
return 'template:customize' | ||
} | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @return {string} | ||
*/ | ||
get description() { | ||
return 'Creates a folder called templates in your project root with all templates of Athenna.' | ||
} | ||
|
||
/** | ||
* Set additional flags in the commander instance. | ||
* This method is executed when registering your command. | ||
* | ||
* @param {import('commander').Command} commander | ||
* @return {import('commander').Command} | ||
*/ | ||
addFlags(commander) { | ||
return commander | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return {Promise<void>} | ||
*/ | ||
async handle() { | ||
this.simpleLog(`[ MOVING TEMPLATES ]`, 'rmNewLineStart', 'bold', 'green') | ||
|
||
const path = Path.pwd('templates') | ||
|
||
await new Folder(path).load() | ||
|
||
const Kernel = await Module.getFrom(Path.console('Kernel.js')) | ||
|
||
const kernel = new Kernel() | ||
|
||
const templates = [ | ||
...new Folder( | ||
join( | ||
Module.createDirname(import.meta.url), | ||
'..', | ||
'..', | ||
'..', | ||
'templates', | ||
), | ||
).loadSync().files, | ||
kernel.templates, | ||
] | ||
|
||
const promises = templates.map(template => | ||
template.copy(Path.pwd('templates')), | ||
) | ||
|
||
await Promise.all(promises) | ||
|
||
this.success('Template files successfully moved.') | ||
} | ||
} |