-
-
Notifications
You must be signed in to change notification settings - Fork 643
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add toolkit binary for creating packages
- Loading branch information
1 parent
c72034d
commit 88e959a
Showing
4 changed files
with
75 additions
and
2 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
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
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,27 @@ | ||
/* | ||
* @adonisjs/core | ||
* | ||
* (c) AdonisJS | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
import { join } from 'node:path' | ||
import { args, BaseCommand, IndexGenerator } from '@adonisjs/ace' | ||
|
||
/** | ||
* Generates index of commands with a loader. Must be called against | ||
* the TypeScript compiled output. | ||
*/ | ||
export default class IndexCommand extends BaseCommand { | ||
static commandName = 'index' | ||
static description: string = 'Create an index of commands along with a lazy loader' | ||
|
||
@args.string({ description: 'Relative path from cwd to the commands directory' }) | ||
declare commandsDir: string | ||
|
||
async run(): Promise<any> { | ||
await new IndexGenerator(join(process.cwd(), this.commandsDir)).generate() | ||
} | ||
} |
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,33 @@ | ||
#!/usr/bin/env node | ||
|
||
/* | ||
* @adonisjs/core | ||
* | ||
* (c) AdonisJS | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
import IndexCommand from './commands/index_commands.js' | ||
import { Kernel, ListLoader, HelpCommand } from '@adonisjs/ace' | ||
|
||
const kernel = Kernel.create() | ||
kernel.addLoader(new ListLoader([IndexCommand])) | ||
|
||
kernel.defineFlag('help', { | ||
type: 'boolean', | ||
description: HelpCommand.description, | ||
}) | ||
|
||
/** | ||
* Flag listener to display the help | ||
*/ | ||
kernel.on('help', async (command, $kernel, parsed) => { | ||
parsed.args.unshift(command.commandName) | ||
const help = new HelpCommand($kernel, parsed, kernel.ui, kernel.prompt) | ||
await help.exec() | ||
return $kernel.shortcircuit() | ||
}) | ||
|
||
await kernel.handle(process.argv.splice(2)) |