@adonisjs/core 6.1.5-2 → 6.1.5-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/commands/build.d.ts +3 -0
- package/build/commands/build.d.ts.map +1 -0
- package/build/commands/build.js +22 -2
- package/build/commands/commands.json +1 -1
- package/build/commands/configure.d.ts +1 -0
- package/build/commands/configure.d.ts.map +1 -0
- package/build/commands/configure.js +2 -1
- package/build/commands/eject.d.ts +1 -0
- package/build/commands/eject.d.ts.map +1 -0
- package/build/commands/eject.js +2 -1
- package/build/commands/generate_key.d.ts +1 -0
- package/build/commands/generate_key.d.ts.map +1 -0
- package/build/commands/generate_key.js +2 -1
- package/build/commands/inspect_rcfile.d.ts +7 -0
- package/build/commands/inspect_rcfile.d.ts.map +1 -0
- package/build/commands/inspect_rcfile.js +10 -0
- package/build/commands/list/routes.d.ts +1 -0
- package/build/commands/list/routes.d.ts.map +1 -0
- package/build/commands/list/routes.js +2 -1
- package/build/commands/make/_base.d.ts +23 -1
- package/build/commands/make/_base.d.ts.map +1 -0
- package/build/commands/make/_base.js +11 -2
- package/build/commands/make/command.d.ts +1 -0
- package/build/commands/make/command.d.ts.map +1 -0
- package/build/commands/make/command.js +2 -1
- package/build/commands/make/controller.d.ts +1 -0
- package/build/commands/make/controller.d.ts.map +1 -0
- package/build/commands/make/controller.js +2 -1
- package/build/commands/make/event.d.ts +1 -0
- package/build/commands/make/event.d.ts.map +1 -0
- package/build/commands/make/event.js +2 -1
- package/build/commands/make/listener.d.ts +1 -0
- package/build/commands/make/listener.d.ts.map +1 -0
- package/build/commands/make/listener.js +2 -1
- package/build/commands/make/middleware.d.ts +1 -0
- package/build/commands/make/middleware.d.ts.map +1 -0
- package/build/commands/make/middleware.js +2 -1
- package/build/commands/make/prldfile.d.ts +9 -0
- package/build/commands/make/prldfile.d.ts.map +1 -0
- package/build/commands/make/prldfile.js +28 -0
- package/build/commands/make/provider.d.ts +1 -0
- package/build/commands/make/provider.d.ts.map +1 -0
- package/build/commands/make/provider.js +5 -2
- package/build/commands/make/service.d.ts +9 -0
- package/build/commands/make/service.d.ts.map +1 -0
- package/build/commands/make/service.js +26 -0
- package/build/commands/make/test.d.ts +1 -0
- package/build/commands/make/test.d.ts.map +1 -0
- package/build/commands/make/test.js +2 -1
- package/build/commands/serve.d.ts +3 -0
- package/build/commands/serve.d.ts.map +1 -0
- package/build/commands/serve.js +21 -1
- package/build/commands/test.d.ts +21 -0
- package/build/commands/test.d.ts.map +1 -0
- package/build/commands/test.js +156 -0
- package/build/factories/app.d.ts +1 -0
- package/build/factories/app.d.ts.map +1 -0
- package/build/factories/bodyparser.d.ts +1 -0
- package/build/factories/bodyparser.d.ts.map +1 -0
- package/build/factories/core/ace.d.ts +1 -0
- package/build/factories/core/ace.d.ts.map +1 -0
- package/build/factories/core/ignitor.d.ts +1 -0
- package/build/factories/core/ignitor.d.ts.map +1 -0
- package/build/factories/core/main.d.ts +1 -0
- package/build/factories/core/main.d.ts.map +1 -0
- package/build/factories/core/test_utils.d.ts +1 -0
- package/build/factories/core/test_utils.d.ts.map +1 -0
- package/build/factories/encryption.d.ts +1 -0
- package/build/factories/encryption.d.ts.map +1 -0
- package/build/factories/events.d.ts +1 -0
- package/build/factories/events.d.ts.map +1 -0
- package/build/factories/hash.d.ts +1 -0
- package/build/factories/hash.d.ts.map +1 -0
- package/build/factories/http.d.ts +1 -0
- package/build/factories/http.d.ts.map +1 -0
- package/build/factories/logger.d.ts +1 -0
- package/build/factories/logger.d.ts.map +1 -0
- package/build/factories/stubs.d.ts +1 -0
- package/build/factories/stubs.d.ts.map +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -0
- package/build/legacy/validator.d.ts +1 -0
- package/build/legacy/validator.d.ts.map +1 -0
- package/build/modules/ace/commands.d.ts +1 -0
- package/build/modules/ace/commands.d.ts.map +1 -0
- package/build/modules/ace/commands.js +4 -2
- package/build/modules/ace/create_kernel.d.ts +1 -0
- package/build/modules/ace/create_kernel.d.ts.map +1 -0
- package/build/modules/ace/kernel.d.ts +1 -0
- package/build/modules/ace/kernel.d.ts.map +1 -0
- package/build/modules/ace/main.d.ts +1 -0
- package/build/modules/ace/main.d.ts.map +1 -0
- package/build/modules/ace/shell.d.ts +1 -0
- package/build/modules/ace/shell.d.ts.map +1 -0
- package/build/modules/app.d.ts +1 -0
- package/build/modules/app.d.ts.map +1 -0
- package/build/modules/bodyparser/bodyparser_middleware.d.ts +1 -0
- package/build/modules/bodyparser/bodyparser_middleware.d.ts.map +1 -0
- package/build/modules/bodyparser/main.d.ts +1 -0
- package/build/modules/bodyparser/main.d.ts.map +1 -0
- package/build/modules/config.d.ts +1 -0
- package/build/modules/config.d.ts.map +1 -0
- package/build/modules/container.d.ts +1 -0
- package/build/modules/container.d.ts.map +1 -0
- package/build/modules/encryption.d.ts +1 -0
- package/build/modules/encryption.d.ts.map +1 -0
- package/build/modules/env.d.ts +1 -0
- package/build/modules/env.d.ts.map +1 -0
- package/build/modules/events.d.ts +1 -0
- package/build/modules/events.d.ts.map +1 -0
- package/build/modules/hash/define_config.d.ts +1 -0
- package/build/modules/hash/define_config.d.ts.map +1 -0
- package/build/modules/hash/drivers_collection.d.ts +4 -4
- package/build/modules/hash/drivers_collection.d.ts.map +1 -0
- package/build/modules/hash/drivers_collection.js +2 -8
- package/build/modules/hash/main.d.ts +2 -0
- package/build/modules/hash/main.d.ts.map +1 -0
- package/build/modules/hash/main.js +1 -0
- package/build/modules/http.d.ts +1 -0
- package/build/modules/http.d.ts.map +1 -0
- package/build/modules/logger.d.ts +1 -0
- package/build/modules/logger.d.ts.map +1 -0
- package/build/providers/app_provider.d.ts +1 -0
- package/build/providers/app_provider.d.ts.map +1 -0
- package/build/providers/app_provider.js +5 -7
- package/build/providers/hash_provider.d.ts +1 -0
- package/build/providers/hash_provider.d.ts.map +1 -0
- package/build/providers/hash_provider.js +7 -6
- package/build/providers/http_provider.d.ts +1 -0
- package/build/providers/http_provider.d.ts.map +1 -0
- package/build/services/ace.d.ts +1 -0
- package/build/services/ace.d.ts.map +1 -0
- package/build/services/app.d.ts +1 -0
- package/build/services/app.d.ts.map +1 -0
- package/build/services/config.d.ts +1 -0
- package/build/services/config.d.ts.map +1 -0
- package/build/services/emitter.d.ts +1 -0
- package/build/services/emitter.d.ts.map +1 -0
- package/build/services/emitter.js +1 -2
- package/build/services/encryption.d.ts +1 -0
- package/build/services/encryption.d.ts.map +1 -0
- package/build/services/encryption.js +1 -2
- package/build/services/hash.d.ts +1 -0
- package/build/services/hash.d.ts.map +1 -0
- package/build/services/hash.js +1 -2
- package/build/services/logger.d.ts +1 -0
- package/build/services/logger.d.ts.map +1 -0
- package/build/services/logger.js +1 -2
- package/build/services/router.d.ts +1 -0
- package/build/services/router.d.ts.map +1 -0
- package/build/services/router.js +1 -2
- package/build/services/server.d.ts +1 -0
- package/build/services/server.d.ts.map +1 -0
- package/build/services/server.js +1 -2
- package/build/services/test_utils.d.ts +1 -0
- package/build/services/test_utils.d.ts.map +1 -0
- package/build/src/cli_formatters/routes_list.d.ts +1 -0
- package/build/src/cli_formatters/routes_list.d.ts.map +1 -0
- package/build/src/debug.d.ts +1 -0
- package/build/src/debug.d.ts.map +1 -0
- package/build/src/helpers/is.d.ts +1 -0
- package/build/src/helpers/is.d.ts.map +1 -0
- package/build/src/helpers/main.d.ts +1 -0
- package/build/src/helpers/main.d.ts.map +1 -0
- package/build/src/helpers/parse_binding_reference.d.ts +1 -0
- package/build/src/helpers/parse_binding_reference.d.ts.map +1 -0
- package/build/src/helpers/string.d.ts +3 -0
- package/build/src/helpers/string.d.ts.map +1 -0
- package/build/src/helpers/string.js +4 -0
- package/build/src/helpers/types.d.ts +1 -0
- package/build/src/helpers/types.d.ts.map +1 -0
- package/build/src/ignitor/ace.d.ts +1 -0
- package/build/src/ignitor/ace.d.ts.map +1 -0
- package/build/src/ignitor/http.d.ts +1 -0
- package/build/src/ignitor/http.d.ts.map +1 -0
- package/build/src/ignitor/main.d.ts +1 -0
- package/build/src/ignitor/main.d.ts.map +1 -0
- package/build/src/ignitor/test.d.ts +1 -0
- package/build/src/ignitor/test.d.ts.map +1 -0
- package/build/src/internal_helpers.d.ts +1 -0
- package/build/src/internal_helpers.d.ts.map +1 -0
- package/build/src/test_utils/http.d.ts +1 -0
- package/build/src/test_utils/http.d.ts.map +1 -0
- package/build/src/test_utils/main.d.ts +2 -1
- package/build/src/test_utils/main.d.ts.map +1 -0
- package/build/src/types.d.ts +3 -2
- package/build/src/types.d.ts.map +1 -0
- package/build/stubs/index.d.ts +1 -0
- package/build/stubs/index.d.ts.map +1 -0
- package/build/stubs/make/preload_file/main.stub +4 -0
- package/build/stubs/make/service/main.stub +4 -0
- package/build/toolkit/commands/index_commands.d.ts +1 -0
- package/build/toolkit/commands/index_commands.d.ts.map +1 -0
- package/build/toolkit/commands/index_commands.js +2 -1
- package/build/toolkit/main.d.ts +1 -0
- package/build/toolkit/main.d.ts.map +1 -0
- package/build/types/ace.d.ts +1 -0
- package/build/types/ace.d.ts.map +1 -0
- package/build/types/app.d.ts +1 -0
- package/build/types/app.d.ts.map +1 -0
- package/build/types/bodyparser.d.ts +1 -0
- package/build/types/bodyparser.d.ts.map +1 -0
- package/build/types/container.d.ts +1 -0
- package/build/types/container.d.ts.map +1 -0
- package/build/types/encryption.d.ts +1 -0
- package/build/types/encryption.d.ts.map +1 -0
- package/build/types/events.d.ts +1 -0
- package/build/types/events.d.ts.map +1 -0
- package/build/types/hash.d.ts +1 -0
- package/build/types/hash.d.ts.map +1 -0
- package/build/types/http.d.ts +1 -0
- package/build/types/http.d.ts.map +1 -0
- package/build/types/logger.d.ts +1 -0
- package/build/types/logger.d.ts.map +1 -0
- package/commands/build.ts +122 -0
- package/commands/configure.ts +179 -0
- package/commands/eject.ts +39 -0
- package/commands/generate_key.ts +53 -0
- package/commands/inspect_rcfile.ts +23 -0
- package/commands/list/routes.ts +121 -0
- package/commands/make/_base.ts +55 -0
- package/commands/make/command.ts +33 -0
- package/commands/make/controller.ts +77 -0
- package/commands/make/event.ts +33 -0
- package/commands/make/listener.ts +63 -0
- package/commands/make/middleware.ts +34 -0
- package/commands/make/prldfile.ts +40 -0
- package/commands/make/provider.ts +40 -0
- package/commands/make/service.ts +33 -0
- package/commands/make/test.ts +115 -0
- package/commands/serve.ts +146 -0
- package/commands/test.ts +189 -0
- package/factories/app.ts +10 -0
- package/factories/bodyparser.ts +10 -0
- package/factories/core/ace.ts +38 -0
- package/factories/core/ignitor.ts +132 -0
- package/factories/core/main.ts +13 -0
- package/factories/core/test_utils.ts +34 -0
- package/factories/encryption.ts +10 -0
- package/factories/events.ts +10 -0
- package/factories/hash.ts +10 -0
- package/factories/http.ts +10 -0
- package/factories/logger.ts +10 -0
- package/factories/stubs.ts +53 -0
- package/index.ts +39 -0
- package/legacy/validator.ts +10 -0
- package/modules/ace/commands.ts +152 -0
- package/modules/ace/create_kernel.ts +73 -0
- package/modules/ace/kernel.ts +28 -0
- package/modules/ace/main.ts +22 -0
- package/modules/ace/shell.ts +49 -0
- package/modules/app.ts +10 -0
- package/modules/bodyparser/bodyparser_middleware.ts +16 -0
- package/modules/bodyparser/main.ts +10 -0
- package/modules/config.ts +10 -0
- package/modules/container.ts +10 -0
- package/modules/encryption.ts +10 -0
- package/modules/env.ts +10 -0
- package/modules/events.ts +10 -0
- package/modules/hash/define_config.ts +64 -0
- package/modules/hash/drivers_collection.ts +61 -0
- package/modules/hash/main.ts +12 -0
- package/modules/http.ts +10 -0
- package/modules/logger.ts +10 -0
- package/package.json +39 -30
- package/providers/app_provider.ts +125 -0
- package/providers/hash_provider.ts +58 -0
- package/providers/http_provider.ts +66 -0
- package/services/ace.ts +26 -0
- package/services/app.ts +26 -0
- package/services/config.ts +22 -0
- package/services/emitter.ts +23 -0
- package/services/encryption.ts +23 -0
- package/services/hash.ts +23 -0
- package/services/logger.ts +23 -0
- package/services/router.ts +23 -0
- package/services/server.ts +23 -0
- package/services/test_utils.ts +26 -0
- package/src/cli_formatters/routes_list.ts +480 -0
- package/src/debug.ts +12 -0
- package/src/helpers/is.ts +11 -0
- package/src/helpers/main.ts +13 -0
- package/src/helpers/parse_binding_reference.ts +93 -0
- package/src/helpers/string.ts +89 -0
- package/src/helpers/types.ts +46 -0
- package/src/ignitor/ace.ts +90 -0
- package/src/ignitor/http.ts +167 -0
- package/src/ignitor/main.ts +118 -0
- package/src/ignitor/test.ts +51 -0
- package/src/internal_helpers.ts +59 -0
- package/src/test_utils/http.ts +79 -0
- package/src/test_utils/main.ts +69 -0
- package/src/types.ts +136 -0
- package/types/ace.ts +15 -0
- package/types/app.ts +10 -0
- package/types/bodyparser.ts +10 -0
- package/types/container.ts +10 -0
- package/types/encryption.ts +10 -0
- package/types/events.ts +10 -0
- package/types/hash.ts +10 -0
- package/types/http.ts +10 -0
- package/types/logger.ts +10 -0
- package/build/src/helpers/string_builder.d.ts +0 -23
- package/build/src/helpers/string_builder.js +0 -86
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @adonisjs/core
|
|
3
|
+
*
|
|
4
|
+
* (c) AdonisJS
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import BaseCommand from './_base.js'
|
|
11
|
+
import { args } from '../../modules/ace/main.js'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The make event command to create a class based event
|
|
15
|
+
*/
|
|
16
|
+
export default class MakeEvent extends BaseCommand {
|
|
17
|
+
static commandName = 'make:event'
|
|
18
|
+
static description = 'Create a new event class'
|
|
19
|
+
|
|
20
|
+
@args.string({ description: 'Name of the event' })
|
|
21
|
+
declare name: string
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The stub to use for generating the event
|
|
25
|
+
*/
|
|
26
|
+
protected stubPath: string = 'make/event/main.stub'
|
|
27
|
+
|
|
28
|
+
async run() {
|
|
29
|
+
await this.generate(this.stubPath, {
|
|
30
|
+
entity: this.app.generators.createEntity(this.name),
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @adonisjs/core
|
|
3
|
+
*
|
|
4
|
+
* (c) AdonisJS
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import BaseCommand from './_base.js'
|
|
11
|
+
import { args, flags } from '../../modules/ace/main.js'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The make listener command to create a class based event
|
|
15
|
+
* listener
|
|
16
|
+
*/
|
|
17
|
+
export default class MakeListener extends BaseCommand {
|
|
18
|
+
static commandName = 'make:listener'
|
|
19
|
+
static description = 'Create a new event listener class'
|
|
20
|
+
|
|
21
|
+
@args.string({ description: 'Name of the listener' })
|
|
22
|
+
declare name: string
|
|
23
|
+
|
|
24
|
+
@flags.string({
|
|
25
|
+
description: 'Generate an event class alongside the listener',
|
|
26
|
+
alias: 'e',
|
|
27
|
+
})
|
|
28
|
+
declare event: string
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The stub to use for generating the event listener
|
|
32
|
+
*/
|
|
33
|
+
protected stubPath: string = 'make/listener/main.stub'
|
|
34
|
+
|
|
35
|
+
prepare() {
|
|
36
|
+
if (this.event) {
|
|
37
|
+
this.stubPath = 'make/listener/for_event.stub'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async run() {
|
|
42
|
+
if (this.event) {
|
|
43
|
+
const { exitCode } = await this.kernel.exec('make:event', [this.event])
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Create listener only when make:event is completed successfully
|
|
47
|
+
*/
|
|
48
|
+
if (exitCode === 0) {
|
|
49
|
+
const eventEntity = this.app.generators.createEntity(this.event)
|
|
50
|
+
await this.generate(this.stubPath, {
|
|
51
|
+
entity: this.app.generators.createEntity(this.name),
|
|
52
|
+
event: eventEntity,
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
await this.generate(this.stubPath, {
|
|
60
|
+
entity: this.app.generators.createEntity(this.name),
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @adonisjs/core
|
|
3
|
+
*
|
|
4
|
+
* (c) AdonisJS
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import BaseCommand from './_base.js'
|
|
11
|
+
import { args } from '../../modules/ace/main.js'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The make middleware command to create a new middleware
|
|
15
|
+
* class.
|
|
16
|
+
*/
|
|
17
|
+
export default class MakeMiddleware extends BaseCommand {
|
|
18
|
+
static commandName = 'make:middleware'
|
|
19
|
+
static description = 'Create a new middleware class'
|
|
20
|
+
|
|
21
|
+
@args.string({ description: 'Name of the middleware' })
|
|
22
|
+
declare name: string
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The stub to use for generating the middleware
|
|
26
|
+
*/
|
|
27
|
+
protected stubPath: string = 'make/middleware/main.stub'
|
|
28
|
+
|
|
29
|
+
async run() {
|
|
30
|
+
await this.generate(this.stubPath, {
|
|
31
|
+
entity: this.app.generators.createEntity(this.name),
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @adonisjs/core
|
|
3
|
+
*
|
|
4
|
+
* (c) AdonisJS
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import BaseCommand from './_base.js'
|
|
11
|
+
import { args } from '../../modules/ace/main.js'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Make a new preload file
|
|
15
|
+
*/
|
|
16
|
+
export default class MakePreloadFile extends BaseCommand {
|
|
17
|
+
static commandName = 'make:prldfile'
|
|
18
|
+
static description = 'Create a new preload file inside the start directory'
|
|
19
|
+
|
|
20
|
+
@args.string({ description: 'Name of the preload file' })
|
|
21
|
+
declare name: string
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The stub to use for generating the preload file
|
|
25
|
+
*/
|
|
26
|
+
protected stubPath: string = 'make/preload_file/main.stub'
|
|
27
|
+
|
|
28
|
+
async run() {
|
|
29
|
+
const output = await this.generate(this.stubPath, {
|
|
30
|
+
entity: this.app.generators.createEntity(this.name),
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Registering the preload file with the `.adonisrc.json` file. We register
|
|
35
|
+
* the relative path, since we cannot be sure about aliases to exist.
|
|
36
|
+
*/
|
|
37
|
+
const preloadImportPath = `./${output.relativeFileName.replace(/(\.js|\.ts)$/, '')}.js`
|
|
38
|
+
await this.app.rcFileEditor.addPreloadFile(preloadImportPath).save()
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @adonisjs/core
|
|
3
|
+
*
|
|
4
|
+
* (c) AdonisJS
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import BaseCommand from './_base.js'
|
|
11
|
+
import { args } from '../../modules/ace/main.js'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Make a new provider class
|
|
15
|
+
*/
|
|
16
|
+
export default class MakeProvider extends BaseCommand {
|
|
17
|
+
static commandName = 'make:provider'
|
|
18
|
+
static description = 'Create a new service provider class'
|
|
19
|
+
|
|
20
|
+
@args.string({ description: 'Name of the provider' })
|
|
21
|
+
declare name: string
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The stub to use for generating the provider class
|
|
25
|
+
*/
|
|
26
|
+
protected stubPath: string = 'make/provider/main.stub'
|
|
27
|
+
|
|
28
|
+
async run() {
|
|
29
|
+
const output = await this.generate(this.stubPath, {
|
|
30
|
+
entity: this.app.generators.createEntity(this.name),
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Registering the provider with the `.adonisrc.json` file. We register
|
|
35
|
+
* the relative path, since we cannot be sure about aliases to exist.
|
|
36
|
+
*/
|
|
37
|
+
const providerImportPath = `./${output.relativeFileName.replace(/(\.js|\.ts)$/, '')}.js`
|
|
38
|
+
await this.app.rcFileEditor.addProvider(providerImportPath).save()
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @adonisjs/core
|
|
3
|
+
*
|
|
4
|
+
* (c) AdonisJS
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import BaseCommand from './_base.js'
|
|
11
|
+
import { args } from '../../modules/ace/main.js'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Make a new service class
|
|
15
|
+
*/
|
|
16
|
+
export default class MakeService extends BaseCommand {
|
|
17
|
+
static commandName = 'make:service'
|
|
18
|
+
static description = 'Create a new service class'
|
|
19
|
+
|
|
20
|
+
@args.string({ description: 'Name of the service' })
|
|
21
|
+
declare name: string
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The stub to use for generating the service class
|
|
25
|
+
*/
|
|
26
|
+
protected stubPath: string = 'make/service/main.stub'
|
|
27
|
+
|
|
28
|
+
async run() {
|
|
29
|
+
await this.generate(this.stubPath, {
|
|
30
|
+
entity: this.app.generators.createEntity(this.name),
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @adonisjs/core
|
|
3
|
+
*
|
|
4
|
+
* (c) AdonisJS
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import BaseCommand from './_base.js'
|
|
11
|
+
import { args, flags } from '../../modules/ace/main.js'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Make a new test file
|
|
15
|
+
*/
|
|
16
|
+
export default class MakeTest extends BaseCommand {
|
|
17
|
+
static commandName = 'make:test'
|
|
18
|
+
static description = 'Create a new Japa test file'
|
|
19
|
+
|
|
20
|
+
@args.string({ description: 'Name of the test file' })
|
|
21
|
+
declare name: string
|
|
22
|
+
|
|
23
|
+
@flags.string({ description: 'The suite for which to create the test file' })
|
|
24
|
+
declare suite?: string
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The stub to use for generating the test file
|
|
28
|
+
*/
|
|
29
|
+
protected stubPath: string = 'make/test/main.stub'
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Returns the suite name for creating the test file
|
|
33
|
+
*/
|
|
34
|
+
async #getSuite(): Promise<string> {
|
|
35
|
+
if (this.suite) {
|
|
36
|
+
return this.suite
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Use the first suite from the rcFile when there is only
|
|
41
|
+
* one suite
|
|
42
|
+
*/
|
|
43
|
+
const rcFileSuites = this.app.rcFile.tests.suites
|
|
44
|
+
if (rcFileSuites.length === 1) {
|
|
45
|
+
return rcFileSuites[0].name
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Prompt the user to select a suite manually
|
|
50
|
+
*/
|
|
51
|
+
return this.prompt.choice(
|
|
52
|
+
'Select the suite for the test file',
|
|
53
|
+
this.app.rcFile.tests.suites.map((suite) => {
|
|
54
|
+
return suite.name
|
|
55
|
+
}),
|
|
56
|
+
{
|
|
57
|
+
validate(choice) {
|
|
58
|
+
return choice ? true : 'Please select a suite'
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Returns the directory path for the selected suite.
|
|
66
|
+
*/
|
|
67
|
+
async #getSuiteDirectory(directories: string[]): Promise<string> {
|
|
68
|
+
if (directories.length === 1) {
|
|
69
|
+
return directories[0]
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return this.prompt.choice('Select directory for the test file', directories, {
|
|
73
|
+
validate(choice) {
|
|
74
|
+
return choice ? true : 'Please select a directory'
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Find suite info from the rcFile file
|
|
81
|
+
*/
|
|
82
|
+
#findSuite(suiteName: string) {
|
|
83
|
+
return this.app.rcFile.tests.suites.find((suite) => {
|
|
84
|
+
return suite.name === suiteName
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Executed by ace
|
|
90
|
+
*/
|
|
91
|
+
async run() {
|
|
92
|
+
const suite = this.#findSuite(await this.#getSuite())
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Show error when mentioned/selected suite does not exist
|
|
96
|
+
*/
|
|
97
|
+
if (!suite) {
|
|
98
|
+
this.logger.error(
|
|
99
|
+
`The "${this.suite}" suite is not configured inside the .adonisrc.json file`
|
|
100
|
+
)
|
|
101
|
+
this.exitCode = 1
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Generate entity
|
|
107
|
+
*/
|
|
108
|
+
await this.generate(this.stubPath, {
|
|
109
|
+
entity: this.app.generators.createEntity(this.name),
|
|
110
|
+
suite: {
|
|
111
|
+
directory: await this.#getSuiteDirectory(suite.directories),
|
|
112
|
+
},
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @adonisjs/core
|
|
3
|
+
*
|
|
4
|
+
* (c) AdonisJS
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { CommandOptions } from '../types/ace.js'
|
|
11
|
+
import { BaseCommand, flags } from '../modules/ace/main.js'
|
|
12
|
+
import { detectAssetsBundler, importAssembler, importTypeScript } from '../src/internal_helpers.js'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Serve command is used to run the AdonisJS HTTP server during development. The
|
|
16
|
+
* command under the hood runs the "bin/server.ts" file and watches for file
|
|
17
|
+
* system changes
|
|
18
|
+
*/
|
|
19
|
+
export default class Serve extends BaseCommand {
|
|
20
|
+
static commandName = 'serve'
|
|
21
|
+
static description =
|
|
22
|
+
'Start the development HTTP server along with the file watcher to perform restarts on file change'
|
|
23
|
+
|
|
24
|
+
static help = [
|
|
25
|
+
'Start the development server with file watcher using the following command.',
|
|
26
|
+
'```',
|
|
27
|
+
'{{ binaryName }} serve --watch',
|
|
28
|
+
'```',
|
|
29
|
+
'',
|
|
30
|
+
'The assets bundler dev server runs automatically after detecting vite config or webpack config files',
|
|
31
|
+
'You may pass vite CLI args using the --assets-args command line flag.',
|
|
32
|
+
'```',
|
|
33
|
+
'{{ binaryName }} serve --assets-args="--debug --base=/public"',
|
|
34
|
+
'```',
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
static options: CommandOptions = {
|
|
38
|
+
staysAlive: true,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@flags.boolean({ description: 'Watch filesystem and restart the HTTP server on file change' })
|
|
42
|
+
declare watch?: boolean
|
|
43
|
+
|
|
44
|
+
@flags.boolean({ description: 'Use polling to detect filesystem changes' })
|
|
45
|
+
declare poll?: boolean
|
|
46
|
+
|
|
47
|
+
@flags.boolean({
|
|
48
|
+
description: 'Clear the terminal for new logs after file change',
|
|
49
|
+
showNegatedVariantInHelp: true,
|
|
50
|
+
default: true,
|
|
51
|
+
})
|
|
52
|
+
declare clear?: boolean
|
|
53
|
+
|
|
54
|
+
@flags.boolean({
|
|
55
|
+
description: 'Start assets bundler dev server',
|
|
56
|
+
showNegatedVariantInHelp: true,
|
|
57
|
+
default: true,
|
|
58
|
+
})
|
|
59
|
+
declare assets?: boolean
|
|
60
|
+
|
|
61
|
+
@flags.array({
|
|
62
|
+
description: 'Define CLI arguments to pass to the assets bundler',
|
|
63
|
+
})
|
|
64
|
+
declare assetsArgs?: string[]
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Log a development dependency is missing
|
|
68
|
+
*/
|
|
69
|
+
#logMissingDevelopmentDependency(dependency: string) {
|
|
70
|
+
this.logger.error(
|
|
71
|
+
[
|
|
72
|
+
`Cannot find package "${dependency}"`,
|
|
73
|
+
'',
|
|
74
|
+
`The "${dependency}" package is a development dependency and therefore you should use the serve command during development only.`,
|
|
75
|
+
'',
|
|
76
|
+
'If you are running your application in production, then use "node bin/server.js" command to start the HTTP server',
|
|
77
|
+
].join('\n')
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Runs the HTTP server
|
|
83
|
+
*/
|
|
84
|
+
async run() {
|
|
85
|
+
const assembler = await importAssembler(this.app)
|
|
86
|
+
if (!assembler) {
|
|
87
|
+
this.#logMissingDevelopmentDependency('@adonisjs/assembler')
|
|
88
|
+
this.exitCode = 1
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const assetsBundler = await detectAssetsBundler(this.app)
|
|
93
|
+
const devServer = new assembler.DevServer(this.app.appRoot, {
|
|
94
|
+
clearScreen: this.clear === false ? false : true,
|
|
95
|
+
nodeArgs: this.parsed.nodeArgs,
|
|
96
|
+
scriptArgs: [],
|
|
97
|
+
assets: assetsBundler
|
|
98
|
+
? {
|
|
99
|
+
serve: this.assets === false ? false : true,
|
|
100
|
+
driver: assetsBundler.name,
|
|
101
|
+
cmd: assetsBundler.devServerCommand,
|
|
102
|
+
args: this.assetsArgs || [],
|
|
103
|
+
}
|
|
104
|
+
: {
|
|
105
|
+
serve: false,
|
|
106
|
+
},
|
|
107
|
+
metaFiles: this.app.rcFile.metaFiles,
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Share command logger with assembler, so that CLI flags like --no-ansi has
|
|
112
|
+
* similar impact for assembler logs as well.
|
|
113
|
+
*/
|
|
114
|
+
devServer.setLogger(this.logger)
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Exit command when the dev server is closed
|
|
118
|
+
*/
|
|
119
|
+
devServer.onClose((exitCode) => {
|
|
120
|
+
this.exitCode = exitCode
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Exit command when the dev server crashes
|
|
125
|
+
*/
|
|
126
|
+
devServer.onError(() => {
|
|
127
|
+
this.exitCode = 1
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Start the development server
|
|
132
|
+
*/
|
|
133
|
+
if (this.watch) {
|
|
134
|
+
const ts = await importTypeScript(this.app)
|
|
135
|
+
if (!ts) {
|
|
136
|
+
this.#logMissingDevelopmentDependency('typescript')
|
|
137
|
+
this.exitCode = 1
|
|
138
|
+
return
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
await devServer.startAndWatch(ts, { poll: this.poll || false })
|
|
142
|
+
} else {
|
|
143
|
+
await devServer.start()
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
package/commands/test.ts
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @adonisjs/core
|
|
3
|
+
*
|
|
4
|
+
* (c) AdonisJS
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { CommandOptions } from '../types/ace.js'
|
|
11
|
+
import { BaseCommand, flags, args } from '../modules/ace/main.js'
|
|
12
|
+
import { detectAssetsBundler, importAssembler, importTypeScript } from '../src/internal_helpers.js'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Test command is used to run tests with optional file watcher. Under the
|
|
16
|
+
* hood, we run "bin/test.js" file.
|
|
17
|
+
*/
|
|
18
|
+
export default class Test extends BaseCommand {
|
|
19
|
+
static commandName = 'test'
|
|
20
|
+
static description = 'Run tests along with the file watcher to re-run tests on file change'
|
|
21
|
+
|
|
22
|
+
static options: CommandOptions = {
|
|
23
|
+
allowUnknownFlags: true,
|
|
24
|
+
staysAlive: true,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@args.spread({
|
|
28
|
+
description: 'Mention suite names to run tests for selected suites',
|
|
29
|
+
required: false,
|
|
30
|
+
})
|
|
31
|
+
declare suites?: string[]
|
|
32
|
+
|
|
33
|
+
@flags.array({ description: 'Filter tests by the filename' })
|
|
34
|
+
declare files?: string[]
|
|
35
|
+
|
|
36
|
+
@flags.array({ description: 'Filter tests by tags' })
|
|
37
|
+
declare tags?: string[]
|
|
38
|
+
|
|
39
|
+
@flags.array({ description: 'Run tests that does not have mentioned tags' })
|
|
40
|
+
declare ignoreTags?: string[]
|
|
41
|
+
|
|
42
|
+
@flags.array({ description: 'Filter tests by parent group title' })
|
|
43
|
+
declare groups?: string[]
|
|
44
|
+
|
|
45
|
+
@flags.array({ description: 'Filter tests by test title' })
|
|
46
|
+
declare tests?: string[]
|
|
47
|
+
|
|
48
|
+
@flags.boolean({ description: 'Watch filesystem and re-run tests on file change' })
|
|
49
|
+
declare watch?: boolean
|
|
50
|
+
|
|
51
|
+
@flags.boolean({ description: 'Use polling to detect filesystem changes' })
|
|
52
|
+
declare poll?: boolean
|
|
53
|
+
|
|
54
|
+
@flags.boolean({
|
|
55
|
+
description: 'Clear the terminal for new logs after file change',
|
|
56
|
+
showNegatedVariantInHelp: true,
|
|
57
|
+
default: true,
|
|
58
|
+
})
|
|
59
|
+
declare clear?: boolean
|
|
60
|
+
|
|
61
|
+
@flags.boolean({
|
|
62
|
+
description: 'Start assets bundler dev server.',
|
|
63
|
+
showNegatedVariantInHelp: true,
|
|
64
|
+
default: true,
|
|
65
|
+
})
|
|
66
|
+
declare assets?: boolean
|
|
67
|
+
|
|
68
|
+
@flags.array({
|
|
69
|
+
description: 'Define CLI arguments to pass to the assets bundler',
|
|
70
|
+
})
|
|
71
|
+
declare assetsArgs?: string[]
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Log a development dependency is missing
|
|
75
|
+
*/
|
|
76
|
+
#logMissingDevelopmentDependency(dependency: string) {
|
|
77
|
+
this.logger.error(
|
|
78
|
+
[
|
|
79
|
+
`Cannot find package "${dependency}"`,
|
|
80
|
+
'',
|
|
81
|
+
`The "${dependency}" package is a development dependency and therefore you should run tests with development dependencies installed.`,
|
|
82
|
+
'',
|
|
83
|
+
'If you are run tests inside a CI, make sure the NODE_ENV is set to "development"',
|
|
84
|
+
].join('\n')
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Runs tests
|
|
90
|
+
*/
|
|
91
|
+
async run() {
|
|
92
|
+
console.log(this.app.rcFile.tests)
|
|
93
|
+
const assembler = await importAssembler(this.app)
|
|
94
|
+
if (!assembler) {
|
|
95
|
+
this.#logMissingDevelopmentDependency('@adonisjs/assembler')
|
|
96
|
+
this.exitCode = 1
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const assetsBundler = await detectAssetsBundler(this.app)
|
|
101
|
+
|
|
102
|
+
const testRunner = new assembler.TestRunner(this.app.appRoot, {
|
|
103
|
+
clearScreen: this.clear === false ? false : true,
|
|
104
|
+
nodeArgs: this.parsed.nodeArgs,
|
|
105
|
+
scriptArgs: this.parsed.unknownFlags
|
|
106
|
+
.map((flag) => {
|
|
107
|
+
const value = this.parsed.flags[flag]
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Not mentioning value when value is "true"
|
|
111
|
+
*/
|
|
112
|
+
if (value === true) {
|
|
113
|
+
return [`--${flag}`] as string[]
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Repeating flag multiple times when value is an array
|
|
118
|
+
*/
|
|
119
|
+
if (Array.isArray(value)) {
|
|
120
|
+
return value.map((v) => [`--${flag}`, v]) as string[][]
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return [`--${flag}`, value] as string[]
|
|
124
|
+
})
|
|
125
|
+
.flat(2),
|
|
126
|
+
assets: assetsBundler
|
|
127
|
+
? {
|
|
128
|
+
serve: this.assets === false ? false : true,
|
|
129
|
+
driver: assetsBundler.name,
|
|
130
|
+
cmd: assetsBundler.devServerCommand,
|
|
131
|
+
args: this.assetsArgs || [],
|
|
132
|
+
}
|
|
133
|
+
: {
|
|
134
|
+
serve: false,
|
|
135
|
+
},
|
|
136
|
+
filters: {
|
|
137
|
+
suites: this.suites,
|
|
138
|
+
files: this.files,
|
|
139
|
+
groups: this.groups,
|
|
140
|
+
tags: this.tags,
|
|
141
|
+
ignoreTags: this.ignoreTags,
|
|
142
|
+
tests: this.tests,
|
|
143
|
+
},
|
|
144
|
+
suites: this.app.rcFile.tests.suites.map((suite) => {
|
|
145
|
+
return {
|
|
146
|
+
name: suite.name,
|
|
147
|
+
files: Array.isArray(suite.files) ? suite.files : [suite.files],
|
|
148
|
+
}
|
|
149
|
+
}),
|
|
150
|
+
metaFiles: this.app.rcFile.metaFiles,
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Share command logger with assembler, so that CLI flags like --no-ansi has
|
|
155
|
+
* similar impact for assembler logs as well.
|
|
156
|
+
*/
|
|
157
|
+
testRunner.setLogger(this.logger)
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Exit command when the test runner is closed
|
|
161
|
+
*/
|
|
162
|
+
testRunner.onClose((exitCode) => {
|
|
163
|
+
this.exitCode = exitCode
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Exit command when the dev server crashes
|
|
168
|
+
*/
|
|
169
|
+
testRunner.onError(() => {
|
|
170
|
+
this.exitCode = 1
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Start the test runner in watch mode
|
|
175
|
+
*/
|
|
176
|
+
if (this.watch) {
|
|
177
|
+
const ts = await importTypeScript(this.app)
|
|
178
|
+
if (!ts) {
|
|
179
|
+
this.#logMissingDevelopmentDependency('typescript')
|
|
180
|
+
this.exitCode = 1
|
|
181
|
+
return
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
await testRunner.runAndWatch(ts, { poll: this.poll || false })
|
|
185
|
+
} else {
|
|
186
|
+
await testRunner.run()
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
package/factories/app.ts
ADDED