Skip to content

Commit

Permalink
Merge pull request #163 from AthennaIO/develop
Browse files Browse the repository at this point in the history
feat(command): remove commands property dependency
  • Loading branch information
jlenon7 authored Mar 27, 2023
2 parents 4f449c2 + e1f4dba commit 2ab305e
Show file tree
Hide file tree
Showing 22 changed files with 87 additions and 88 deletions.
30 changes: 20 additions & 10 deletions bin/artisan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,26 @@ import { Ignite } from '#src'

process.env.CORE_TESTING = 'false'

Config.set('rc.commands', [
'#src/Commands/MakeExceptionCommand',
'#src/Commands/MakeFacadeCommand',
'#src/Commands/MakeProviderCommand',
'#src/Commands/MakeServiceCommand',
'#src/Commands/MakeTestCommand',
'#src/Commands/ServeCommand',
'#src/Commands/BuildCommand',
'#src/Commands/TestCommand',
])
Config.set('rc.commands', {
'make:exception': '#src/Commands/MakeExceptionCommand',
'make:facade': '#src/Commands/MakeFacadeCommand',
'make:provider': '#src/Commands/MakeProviderCommand',
'make:service': '#src/Commands/MakeServiceCommand',
'make:test': '#src/Commands/MakeTestCommand',
build: '#src/Commands/BuildCommand',
serve: {
entrypoint: '#bin/http',
path: '#src/Commands/ServeCommand',
},
test: {
entrypoint: '#bin/test',
path: '#src/Commands/TestCommand',
},
repl: {
entrypoint: '#bin/repl',
path: '#src/Commands/ReplCommand',
},
})

/*
|--------------------------------------------------------------------------
Expand Down
68 changes: 34 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 4 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/core",
"version": "3.3.4",
"version": "3.4.0",
"description": "The plug and play Node.js framework.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down Expand Up @@ -62,10 +62,10 @@
"semver": "^7.3.8"
},
"devDependencies": {
"@athenna/artisan": "^3.4.0",
"@athenna/artisan": "^3.6.0",
"@athenna/common": "^3.5.0",
"@athenna/config": "^3.3.0",
"@athenna/http": "^3.5.0",
"@athenna/http": "^3.7.0",
"@athenna/ioc": "^3.2.0",
"@athenna/logger": "^3.2.0",
"@athenna/test": "^3.3.0",
Expand Down Expand Up @@ -224,18 +224,7 @@
"interceptor": "node_modules/@athenna/http/templates/interceptor.edge",
"terminator": "node_modules/@athenna/http/templates/terminator.edge"
},
"commands": [
"#src/Commands/MakeExceptionCommand",
"#src/Commands/MakeFacadeCommand",
"#src/Commands/MakeProviderCommand",
"#src/Commands/MakeServiceCommand",
"#src/Commands/MakeTestCommand",
"#src/Commands/ServeCommand",
"#src/Commands/BuildCommand",
"#src/Commands/TestCommand",
"#src/Commands/ReplCommand"
],
"commandsManifest": {
"commands": {
"make:exception": "#src/Commands/MakeExceptionCommand",
"make:facade": "#src/Commands/MakeFacadeCommand",
"make:provider": "#src/Commands/MakeProviderCommand",
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/BuildCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class BuildCommand extends BaseCommand {

private getTsConfig(): Promise<File> {
const path = Config.get(
'rc.commandsManifest.build.tsconfig',
'rc.commands.build.tsconfig',
'../../tmp/tsconfig.build.json',
)

Expand Down
2 changes: 1 addition & 1 deletion src/Commands/MakeExceptionCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class MakeExceptionCommand extends BaseCommand {
*/
private getDestinationPath(): string {
let destination = Config.get(
'rc.commandsManifest.make:exception.destination',
'rc.commands.make:exception.destination',
Path.app('Exceptions'),
)

Expand Down
2 changes: 1 addition & 1 deletion src/Commands/MakeFacadeCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class MakeFacadeCommand extends BaseCommand {
*/
private getDestinationPath(): string {
let destination = Config.get(
'rc.commandsManifest.make:facade.destination',
'rc.commands.make:facade.destination',
Path.facades(),
)

Expand Down
2 changes: 1 addition & 1 deletion src/Commands/MakeProviderCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class MakeProviderCommand extends BaseCommand {
*/
private getDestinationPath(): string {
let destination = Config.get(
'rc.commandsManifest.make:provider.destination',
'rc.commands.make:provider.destination',
Path.providers(),
)

Expand Down
2 changes: 1 addition & 1 deletion src/Commands/MakeServiceCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class MakeServiceCommand extends BaseCommand {
*/
private getDestinationPath(): string {
let destination = Config.get(
'rc.commandsManifest.make:service.destination',
'rc.commands.make:service.destination',
Path.app('Services'),
)

Expand Down
2 changes: 1 addition & 1 deletion src/Commands/MakeTestCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class MakeTestCommand extends BaseCommand {
*/
private getDestinationPath(): string {
let destination = Config.get(
'rc.commandsManifest.make:test.destination',
'rc.commands.make:test.destination',
this.isUnit ? Path.tests('Unit') : Path.tests('E2E'),
)

Expand Down
2 changes: 1 addition & 1 deletion src/Commands/ReplCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class ReplCommand extends BaseCommand {
}

const entrypoint = Config.get(
'rc.commandsManifest.repl.entrypoint',
'rc.commands.repl.entrypoint',
'#bootstrap/repl',
)

Expand Down
2 changes: 1 addition & 1 deletion src/Commands/ServeCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class ServeCommand extends BaseCommand {
}

const entrypoint = Config.get(
'rc.commandsManifest.serve.entrypoint',
'rc.commands.serve.entrypoint',
'#bootstrap/main',
)

Expand Down
2 changes: 1 addition & 1 deletion src/Commands/TestCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class TestCommand extends BaseCommand {
}

const entrypoint = Config.get(
'rc.commandsManifest.test.entrypoint',
'rc.commands.test.entrypoint',
'#bootstrap/test',
)

Expand Down
3 changes: 1 addition & 2 deletions src/Ignite/Ignite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ export class Ignite {
version: coreSemverVersion,
athennaVersion: process.env.ATHENNA_VERSION,
engines: pkgJson.engines || {},
commands: [],
commands: {},
services: [],
preloads: [],
providers: [],
Expand All @@ -340,7 +340,6 @@ export class Ignite {
namedMiddlewares: {},
globalMiddlewares: {},
environments: [],
commandsManifest: {},
}

const replaceableConfigs = {
Expand Down
2 changes: 1 addition & 1 deletion src/Types/ArtisanOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type ArtisanOptions = {
/**
* The path to the ConsoleKernel. The console kernel is responsible to
* register the exception handler, register the commands or register a single
* command by it's path if exists inside "rc.commandsManifest". By default,
* command by it's path if exists inside "rc.commands". By default,
* Athenna will use the built in Kernel. But you can do your own implementation
* extending the "ConsoleKernel" class from Artisan and setting the path to it
* here.
Expand Down
14 changes: 5 additions & 9 deletions src/Types/RcOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,11 @@ export interface RcOptions {
globalMiddlewares?: string[]

/**
* Set the commands that Athenna needs to register when running an Artisan command.
*/
commands?: string[]

/**
* Set the commands manifest where the key is the signature of your command and the
* Set the commands where the key is the signature of your command and the
* value is the path to your command. If the command that you are running is inside
* the commandsManifest property, Athenna will import ONLY that specific command,
* ignoring the entire "commands" array.
* the commands property, Athenna will import ONLY that specific command,
* ignoring the entire "commands" array. Unless you set the "loadAllCommands" property
* to true.
*/
commandsManifest?: Record<string, string | any>
commands?: Record<string, string | any>
}
9 changes: 6 additions & 3 deletions tests/Stubs/artisan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@ import { Ignite } from '#src'

process.env.CORE_TESTING = 'true'

Config.set('rc.commandsManifest.test', {
Config.set('rc.commands.test', {
path: '#src/Commands/TestCommand',
entrypoint: '#tests/Stubs/tests/main',
})
Config.set('rc.commandsManifest.repl', {
Config.set('rc.commands.repl', {
path: '#src/Commands/ReplCommand',
entrypoint: '#tests/Stubs/bootstrap/repl',
})
Config.set('rc.commandsManifest.serve', {
Config.set('rc.commands.build', {
path: '#src/Commands/BuildCommand',
})
Config.set('rc.commands.serve', {
path: '#src/Commands/ServeCommand',
entrypoint: '#tests/Stubs/bootstrap/main',
})
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/Commands/BuildCommandTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export default class BuildCommandTest extends BaseCommandTest {
public async shouldBeAbleToBuildTheApplication({ assert }: TestContext) {
const { stdout, stderr } = await Artisan.callInChild('build', this.artisan)

console.log(stdout)

assert.deepEqual(stderr, '')
assert.isTrue(stdout.includes('[ BUILDING APPLICATION ]'))
assert.isTrue(stdout.includes('Compiling all .ts files from your application'))
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Commands/MakeExceptionCommandTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class MakeExceptionCommandTest extends BaseCommandTest {

@Test()
public async shouldBeAbleToCreateAnExceptionFileInDifferentDestPath({ assert }: TestContext) {
Config.set('rc.commandsManifest.make:exception.destination', Path.stubs('storage/exceptions'))
Config.set('rc.commands.make:exception.destination', Path.stubs('storage/exceptions'))

await Artisan.call('make:exception TestException')

Expand Down
Loading

0 comments on commit 2ab305e

Please sign in to comment.