@adonisjs/core 6.1.5-9 → 6.2.0
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/README.md +3 -5
- package/build/commands/build.d.ts +3 -5
- package/build/commands/build.js +5 -9
- package/build/commands/commands.json +1 -1
- package/build/commands/configure.d.ts +21 -28
- package/build/commands/configure.js +60 -118
- package/build/commands/eject.js +2 -1
- package/build/commands/generate_key.js +2 -2
- package/build/commands/inspect_rcfile.js +19 -2
- package/build/commands/main.d.ts +4 -0
- package/build/commands/make/command.d.ts +1 -1
- package/build/commands/make/command.js +5 -2
- package/build/commands/make/controller.d.ts +2 -1
- package/build/commands/make/controller.js +33 -10
- package/build/commands/make/event.d.ts +1 -1
- package/build/commands/make/event.js +5 -3
- package/build/commands/make/exception.d.ts +1 -1
- package/build/commands/make/exception.js +6 -4
- package/build/commands/make/listener.d.ts +1 -1
- package/build/commands/make/listener.js +9 -6
- package/build/commands/make/middleware.d.ts +2 -1
- package/build/commands/make/middleware.js +50 -4
- package/build/commands/make/preload.d.ts +4 -3
- package/build/commands/make/preload.js +34 -35
- package/build/commands/make/provider.d.ts +7 -1
- package/build/commands/make/provider.js +57 -7
- package/build/commands/make/service.d.ts +1 -1
- package/build/commands/make/service.js +5 -3
- package/build/commands/make/test.d.ts +1 -1
- package/build/commands/make/test.js +7 -5
- package/build/commands/make/validator.d.ts +19 -0
- package/build/commands/make/validator.js +53 -0
- package/build/commands/make/view.d.ts +14 -0
- package/build/commands/make/view.js +37 -0
- package/build/commands/serve.js +7 -4
- package/build/commands/test.js +2 -2
- package/build/factories/core/ace.d.ts +2 -2
- package/build/factories/core/ignitor.d.ts +2 -2
- package/build/factories/core/ignitor.js +8 -9
- package/build/factories/core/main.d.ts +0 -1
- package/build/factories/core/main.js +0 -1
- package/build/factories/core/test_utils.d.ts +2 -2
- package/build/factories/stubs.d.ts +2 -2
- package/build/factories/stubs.js +3 -2
- package/build/index.d.ts +11 -140
- package/build/index.js +5 -1
- package/build/modules/ace/codemods.d.ts +93 -0
- package/build/modules/ace/codemods.js +259 -0
- package/build/modules/ace/commands.d.ts +6 -81
- package/build/modules/ace/commands.js +12 -33
- package/build/modules/ace/create_kernel.d.ts +1 -1
- package/build/modules/ace/create_kernel.js +19 -3
- package/build/modules/env/editor.d.ts +1 -0
- package/build/modules/env/editor.js +9 -0
- package/build/modules/hash/define_config.d.ts +29 -12
- package/build/modules/hash/define_config.js +52 -11
- package/build/modules/hash/drivers/argon.d.ts +1 -0
- package/build/modules/hash/drivers/argon.js +9 -0
- package/build/modules/hash/drivers/bcrypt.d.ts +1 -0
- package/build/modules/hash/drivers/bcrypt.js +9 -0
- package/build/modules/hash/drivers/scrypt.d.ts +1 -0
- package/build/modules/hash/drivers/scrypt.js +9 -0
- package/build/modules/hash/main.d.ts +1 -2
- package/build/modules/hash/main.js +1 -2
- package/build/modules/hash/phc_formatter.d.ts +1 -0
- package/build/modules/hash/phc_formatter.js +9 -0
- package/build/modules/http/main.d.ts +5 -0
- package/build/modules/http/main.js +5 -0
- package/build/modules/http/request_validator.d.ts +4 -14
- package/build/modules/http/request_validator.js +2 -10
- package/build/providers/app_provider.d.ts +14 -0
- package/build/providers/app_provider.js +47 -3
- package/build/providers/edge_provider.d.ts +31 -0
- package/build/providers/edge_provider.js +70 -0
- package/build/providers/hash_provider.d.ts +0 -4
- package/build/providers/hash_provider.js +11 -11
- package/build/providers/repl_provider.js +78 -7
- package/build/providers/vinejs_provider.d.ts +43 -0
- package/build/{src/vinejs/extensions/validates_files.js → providers/vinejs_provider.js} +26 -5
- package/build/src/config_provider.d.ts +9 -0
- package/build/src/config_provider.js +26 -0
- package/build/src/debug.d.ts +1 -1
- package/build/src/helpers/assert.d.ts +1 -0
- package/build/src/helpers/assert.js +9 -0
- package/build/src/helpers/main.d.ts +2 -2
- package/build/src/helpers/main.js +2 -2
- package/build/src/helpers/types.d.ts +109 -16
- package/build/src/helpers/types.js +3 -3
- package/build/src/ignitor/ace.js +3 -1
- package/build/src/ignitor/http.d.ts +2 -2
- package/build/src/ignitor/http.js +5 -1
- package/build/src/ignitor/main.d.ts +2 -2
- package/build/src/ignitor/main.js +1 -1
- package/build/src/test_utils/http.d.ts +2 -2
- package/build/src/test_utils/main.d.ts +3 -3
- package/build/src/types.d.ts +17 -17
- package/build/stubs/make/command/main.stub +6 -4
- package/build/stubs/make/controller/actions.stub +14 -0
- package/build/stubs/make/controller/api.stub +6 -4
- package/build/stubs/make/controller/main.stub +6 -4
- package/build/stubs/make/controller/resource.stub +6 -4
- package/build/stubs/make/event/main.stub +5 -3
- package/build/stubs/make/exception/main.stub +5 -3
- package/build/stubs/make/listener/for_event.stub +6 -4
- package/build/stubs/make/listener/main.stub +5 -3
- package/build/stubs/make/middleware/main.stub +7 -5
- package/build/stubs/make/{preload_file → preload}/main.stub +5 -3
- package/build/stubs/make/provider/main.stub +6 -4
- package/build/stubs/make/service/main.stub +5 -3
- package/build/stubs/make/test/main.stub +5 -3
- package/build/stubs/make/validator/main.stub +7 -0
- package/build/stubs/make/validator/resource.stub +26 -0
- package/build/stubs/make/view/main.stub +6 -0
- package/build/types/bodyparser.js +1 -1
- package/build/types/helpers.d.ts +1 -0
- package/build/{src/vinejs/extensions/main.js → types/helpers.js} +1 -1
- package/build/types/http.d.ts +7 -0
- package/package.json +68 -59
- package/build/commands/make/_base.d.ts +0 -36
- package/build/commands/make/_base.js +0 -27
- package/build/modules/ace/shell.d.ts +0 -12
- package/build/modules/ace/shell.js +0 -49
- package/build/modules/hash/drivers_collection.d.ts +0 -21
- package/build/modules/hash/drivers_collection.js +0 -45
- package/build/providers/http_provider.d.ts +0 -26
- package/build/providers/http_provider.js +0 -61
- package/build/src/bindings/repl.d.ts +0 -6
- package/build/src/bindings/repl.js +0 -78
- package/build/src/vinejs/extensions/main.d.ts +0 -1
- package/build/src/vinejs/extensions/validates_files.d.ts +0 -22
- /package/build/modules/{env.d.ts → env/main.d.ts} +0 -0
- /package/build/modules/{env.js → env/main.js} +0 -0
- /package/build/stubs/{index.d.ts → main.d.ts} +0 -0
- /package/build/stubs/{index.js → main.js} +0 -0
|
@@ -12,8 +12,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
12
12
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
13
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
14
|
};
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
15
|
+
import string from '@poppinss/utils/string';
|
|
16
|
+
import { stubsRoot } from '../../stubs/main.js';
|
|
17
|
+
import { args, flags, BaseCommand } from '../../modules/ace/main.js';
|
|
17
18
|
/**
|
|
18
19
|
* The make controller command to create an HTTP controller
|
|
19
20
|
*/
|
|
@@ -28,27 +29,46 @@ export default class MakeController extends BaseCommand {
|
|
|
28
29
|
* Preparing the command state
|
|
29
30
|
*/
|
|
30
31
|
async prepare() {
|
|
32
|
+
/**
|
|
33
|
+
* Use actions stub
|
|
34
|
+
*/
|
|
35
|
+
if (this.actions) {
|
|
36
|
+
this.stubPath = 'make/controller/actions.stub';
|
|
37
|
+
}
|
|
31
38
|
/**
|
|
32
39
|
* Use resource stub
|
|
33
40
|
*/
|
|
34
41
|
if (this.resource) {
|
|
35
|
-
this.
|
|
42
|
+
if (this.actions) {
|
|
43
|
+
this.logger.warning('Cannot use --resource flag with actions. Ignoring --resource');
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.stubPath = 'make/controller/resource.stub';
|
|
47
|
+
}
|
|
36
48
|
}
|
|
37
49
|
/**
|
|
38
50
|
* Use api stub
|
|
39
51
|
*/
|
|
40
52
|
if (this.api) {
|
|
41
|
-
this.
|
|
53
|
+
if (this.actions) {
|
|
54
|
+
this.logger.warning('Cannot use --api flag with actions. Ignoring --api');
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.stubPath = 'make/controller/api.stub';
|
|
58
|
+
}
|
|
42
59
|
}
|
|
43
60
|
/**
|
|
44
61
|
* Log warning when both flags are used together
|
|
45
62
|
*/
|
|
46
|
-
if (this.resource && this.api) {
|
|
63
|
+
if (this.resource && this.api && !this.actions) {
|
|
47
64
|
this.logger.warning('--api and --resource flags cannot be used together. Ignoring --resource');
|
|
48
65
|
}
|
|
49
66
|
}
|
|
50
67
|
async run() {
|
|
51
|
-
await this.
|
|
68
|
+
const codemods = await this.createCodemods();
|
|
69
|
+
await codemods.makeUsingStub(stubsRoot, this.stubPath, {
|
|
70
|
+
flags: this.parsed.flags,
|
|
71
|
+
actions: this.actions?.map((action) => string.camelCase(action)),
|
|
52
72
|
entity: this.app.generators.createEntity(this.name),
|
|
53
73
|
});
|
|
54
74
|
}
|
|
@@ -56,21 +76,24 @@ export default class MakeController extends BaseCommand {
|
|
|
56
76
|
__decorate([
|
|
57
77
|
args.string({ description: 'The name of the controller' })
|
|
58
78
|
], MakeController.prototype, "name", void 0);
|
|
79
|
+
__decorate([
|
|
80
|
+
args.spread({ description: 'Create controller with custom method names', required: false })
|
|
81
|
+
], MakeController.prototype, "actions", void 0);
|
|
59
82
|
__decorate([
|
|
60
83
|
flags.boolean({
|
|
61
|
-
description: '
|
|
62
|
-
alias: '
|
|
84
|
+
description: 'Generate controller in singular form',
|
|
85
|
+
alias: 's',
|
|
63
86
|
})
|
|
64
87
|
], MakeController.prototype, "singular", void 0);
|
|
65
88
|
__decorate([
|
|
66
89
|
flags.boolean({
|
|
67
|
-
description: 'Generate controller with
|
|
90
|
+
description: 'Generate controller with methods to perform CRUD actions on a resource',
|
|
68
91
|
alias: 'r',
|
|
69
92
|
})
|
|
70
93
|
], MakeController.prototype, "resource", void 0);
|
|
71
94
|
__decorate([
|
|
72
95
|
flags.boolean({
|
|
73
|
-
description: 'Generate controller with
|
|
96
|
+
description: 'Generate resourceful controller with the "edit" and the "create" methods',
|
|
74
97
|
alias: 'a',
|
|
75
98
|
})
|
|
76
99
|
], MakeController.prototype, "api", void 0);
|
|
@@ -12,8 +12,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
12
12
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
13
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
14
|
};
|
|
15
|
-
import
|
|
16
|
-
import { args } from '../../modules/ace/main.js';
|
|
15
|
+
import { stubsRoot } from '../../stubs/main.js';
|
|
16
|
+
import { args, BaseCommand } from '../../modules/ace/main.js';
|
|
17
17
|
/**
|
|
18
18
|
* The make event command to create a class based event
|
|
19
19
|
*/
|
|
@@ -25,7 +25,9 @@ export default class MakeEvent extends BaseCommand {
|
|
|
25
25
|
*/
|
|
26
26
|
stubPath = 'make/event/main.stub';
|
|
27
27
|
async run() {
|
|
28
|
-
await this.
|
|
28
|
+
const codemods = await this.createCodemods();
|
|
29
|
+
await codemods.makeUsingStub(stubsRoot, this.stubPath, {
|
|
30
|
+
flags: this.parsed.flags,
|
|
29
31
|
entity: this.app.generators.createEntity(this.name),
|
|
30
32
|
});
|
|
31
33
|
}
|
|
@@ -12,20 +12,22 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
12
12
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
13
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
14
|
};
|
|
15
|
-
import
|
|
16
|
-
import { args } from '../../modules/ace/main.js';
|
|
15
|
+
import { stubsRoot } from '../../stubs/main.js';
|
|
16
|
+
import { args, BaseCommand } from '../../modules/ace/main.js';
|
|
17
17
|
/**
|
|
18
18
|
* Make a new exception class
|
|
19
19
|
*/
|
|
20
20
|
export default class MakeException extends BaseCommand {
|
|
21
21
|
static commandName = 'make:exception';
|
|
22
|
-
static description = 'Create a new
|
|
22
|
+
static description = 'Create a new custom exception class';
|
|
23
23
|
/**
|
|
24
24
|
* The stub to use for generating the command class
|
|
25
25
|
*/
|
|
26
26
|
stubPath = 'make/exception/main.stub';
|
|
27
27
|
async run() {
|
|
28
|
-
await this.
|
|
28
|
+
const codemods = await this.createCodemods();
|
|
29
|
+
await codemods.makeUsingStub(stubsRoot, this.stubPath, {
|
|
30
|
+
flags: this.parsed.flags,
|
|
29
31
|
entity: this.app.generators.createEntity(this.name),
|
|
30
32
|
});
|
|
31
33
|
}
|
|
@@ -12,8 +12,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
12
12
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
13
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
14
|
};
|
|
15
|
-
import
|
|
16
|
-
import { args, flags } from '../../modules/ace/main.js';
|
|
15
|
+
import { stubsRoot } from '../../stubs/main.js';
|
|
16
|
+
import { args, flags, BaseCommand } from '../../modules/ace/main.js';
|
|
17
17
|
/**
|
|
18
18
|
* The make listener command to create a class based event
|
|
19
19
|
* listener
|
|
@@ -31,6 +31,7 @@ export default class MakeListener extends BaseCommand {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
async run() {
|
|
34
|
+
const codemods = await this.createCodemods();
|
|
34
35
|
if (this.event) {
|
|
35
36
|
const { exitCode } = await this.kernel.exec('make:event', [this.event]);
|
|
36
37
|
/**
|
|
@@ -38,20 +39,22 @@ export default class MakeListener extends BaseCommand {
|
|
|
38
39
|
*/
|
|
39
40
|
if (exitCode === 0) {
|
|
40
41
|
const eventEntity = this.app.generators.createEntity(this.event);
|
|
41
|
-
await
|
|
42
|
-
entity: this.app.generators.createEntity(this.name),
|
|
42
|
+
await codemods.makeUsingStub(stubsRoot, this.stubPath, {
|
|
43
43
|
event: eventEntity,
|
|
44
|
+
flags: this.parsed.flags,
|
|
45
|
+
entity: this.app.generators.createEntity(this.name),
|
|
44
46
|
});
|
|
45
47
|
}
|
|
46
48
|
return;
|
|
47
49
|
}
|
|
48
|
-
await
|
|
50
|
+
await codemods.makeUsingStub(stubsRoot, this.stubPath, {
|
|
51
|
+
flags: this.parsed.flags,
|
|
49
52
|
entity: this.app.generators.createEntity(this.name),
|
|
50
53
|
});
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
__decorate([
|
|
54
|
-
args.string({ description: 'Name of the listener' })
|
|
57
|
+
args.string({ description: 'Name of the event listener' })
|
|
55
58
|
], MakeListener.prototype, "name", void 0);
|
|
56
59
|
__decorate([
|
|
57
60
|
flags.string({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import BaseCommand from '
|
|
1
|
+
import { BaseCommand } from '../../modules/ace/main.js';
|
|
2
2
|
/**
|
|
3
3
|
* The make middleware command to create a new middleware
|
|
4
4
|
* class.
|
|
@@ -7,6 +7,7 @@ export default class MakeMiddleware extends BaseCommand {
|
|
|
7
7
|
static commandName: string;
|
|
8
8
|
static description: string;
|
|
9
9
|
name: string;
|
|
10
|
+
stack?: 'server' | 'named' | 'router';
|
|
10
11
|
/**
|
|
11
12
|
* The stub to use for generating the middleware
|
|
12
13
|
*/
|
|
@@ -12,25 +12,71 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
12
12
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
13
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
14
|
};
|
|
15
|
-
import
|
|
16
|
-
import
|
|
15
|
+
import { slash } from '@poppinss/utils';
|
|
16
|
+
import string from '@poppinss/utils/string';
|
|
17
|
+
import { basename, extname, relative } from 'node:path';
|
|
18
|
+
import { stubsRoot } from '../../stubs/main.js';
|
|
19
|
+
import { args, BaseCommand, flags } from '../../modules/ace/main.js';
|
|
17
20
|
/**
|
|
18
21
|
* The make middleware command to create a new middleware
|
|
19
22
|
* class.
|
|
20
23
|
*/
|
|
21
24
|
export default class MakeMiddleware extends BaseCommand {
|
|
22
25
|
static commandName = 'make:middleware';
|
|
23
|
-
static description = 'Create a new middleware class';
|
|
26
|
+
static description = 'Create a new middleware class for HTTP requests';
|
|
24
27
|
/**
|
|
25
28
|
* The stub to use for generating the middleware
|
|
26
29
|
*/
|
|
27
30
|
stubPath = 'make/middleware/main.stub';
|
|
28
31
|
async run() {
|
|
29
|
-
|
|
32
|
+
const stackChoices = ['server', 'router', 'named'];
|
|
33
|
+
/**
|
|
34
|
+
* Prompt to select the stack under which to register
|
|
35
|
+
* the middleware
|
|
36
|
+
*/
|
|
37
|
+
if (!this.stack) {
|
|
38
|
+
this.stack = await this.prompt.choice('Under which stack you want to register the middleware?', stackChoices);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Error out when mentioned stack is invalid
|
|
42
|
+
*/
|
|
43
|
+
if (!stackChoices.includes(this.stack)) {
|
|
44
|
+
this.exitCode = 1;
|
|
45
|
+
this.logger.error(`Invalid middleware stack "${this.stack}". Select from "${stackChoices.join(', ')}"`);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create middleware
|
|
50
|
+
*/
|
|
51
|
+
const codemods = await this.createCodemods();
|
|
52
|
+
const { destination } = await codemods.makeUsingStub(stubsRoot, this.stubPath, {
|
|
53
|
+
flags: this.parsed.flags,
|
|
30
54
|
entity: this.app.generators.createEntity(this.name),
|
|
31
55
|
});
|
|
56
|
+
/**
|
|
57
|
+
* Creative relative path for the middleware file from
|
|
58
|
+
* the "./app/middleware" directory
|
|
59
|
+
*/
|
|
60
|
+
const middlewareRelativePath = slash(relative(this.app.middlewarePath(), destination).replace(extname(destination), ''));
|
|
61
|
+
/**
|
|
62
|
+
* Take the middleware relative path, remove `_middleware` prefix from it
|
|
63
|
+
* and convert everything to camelcase
|
|
64
|
+
*/
|
|
65
|
+
const name = string.camelCase(basename(middlewareRelativePath).replace(/_middleware$/, ''));
|
|
66
|
+
/**
|
|
67
|
+
* Register middleware
|
|
68
|
+
*/
|
|
69
|
+
await codemods.registerMiddleware(this.stack, [
|
|
70
|
+
{
|
|
71
|
+
name: name,
|
|
72
|
+
path: `#middleware/${middlewareRelativePath}`,
|
|
73
|
+
},
|
|
74
|
+
]);
|
|
32
75
|
}
|
|
33
76
|
}
|
|
34
77
|
__decorate([
|
|
35
78
|
args.string({ description: 'Name of the middleware' })
|
|
36
79
|
], MakeMiddleware.prototype, "name", void 0);
|
|
80
|
+
__decorate([
|
|
81
|
+
flags.string({ description: 'The stack in which to register the middleware', alias: 's' })
|
|
82
|
+
], MakeMiddleware.prototype, "stack", void 0);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import BaseCommand from '
|
|
2
|
-
declare const ALLOWED_ENVIRONMENTS: ("
|
|
1
|
+
import { BaseCommand } from '../../modules/ace/main.js';
|
|
2
|
+
declare const ALLOWED_ENVIRONMENTS: ("web" | "console" | "test" | "repl")[];
|
|
3
3
|
type AllowedAppEnvironments = typeof ALLOWED_ENVIRONMENTS;
|
|
4
4
|
/**
|
|
5
5
|
* Make a new preload file
|
|
@@ -9,7 +9,8 @@ export default class MakePreload extends BaseCommand {
|
|
|
9
9
|
static commandName: string;
|
|
10
10
|
static description: string;
|
|
11
11
|
name: string;
|
|
12
|
-
|
|
12
|
+
register?: boolean;
|
|
13
|
+
environments?: AllowedAppEnvironments;
|
|
13
14
|
/**
|
|
14
15
|
* The stub to use for generating the preload file
|
|
15
16
|
*/
|
|
@@ -12,8 +12,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
12
12
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
13
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
14
|
};
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
15
|
+
import { slash } from '@poppinss/utils';
|
|
16
|
+
import { extname, relative } from 'node:path';
|
|
17
|
+
import { stubsRoot } from '../../stubs/main.js';
|
|
18
|
+
import { args, flags, BaseCommand } from '../../modules/ace/main.js';
|
|
17
19
|
const ALLOWED_ENVIRONMENTS = ['web', 'console', 'test', 'repl'];
|
|
18
20
|
/**
|
|
19
21
|
* Make a new preload file
|
|
@@ -24,13 +26,7 @@ export default class MakePreload extends BaseCommand {
|
|
|
24
26
|
/**
|
|
25
27
|
* The stub to use for generating the preload file
|
|
26
28
|
*/
|
|
27
|
-
stubPath = 'make/
|
|
28
|
-
/**
|
|
29
|
-
* Check if the mentioned environments are valid
|
|
30
|
-
*/
|
|
31
|
-
#isValidEnvironment(environment) {
|
|
32
|
-
return !environment.find((one) => !ALLOWED_ENVIRONMENTS.includes(one));
|
|
33
|
-
}
|
|
29
|
+
stubPath = 'make/preload/main.stub';
|
|
34
30
|
/**
|
|
35
31
|
* Validate the environments flag passed by the user
|
|
36
32
|
*/
|
|
@@ -38,29 +34,12 @@ export default class MakePreload extends BaseCommand {
|
|
|
38
34
|
if (!this.environments || !this.environments.length) {
|
|
39
35
|
return true;
|
|
40
36
|
}
|
|
41
|
-
return this
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Prompt for the environments
|
|
45
|
-
*/
|
|
46
|
-
async #promptForEnvironments() {
|
|
47
|
-
const selectedEnvironments = await this.prompt.multiple('Select the environment(s) in which you want to load this file', [
|
|
48
|
-
{ name: 'all', message: 'Load file in all environments' },
|
|
49
|
-
{ name: 'console', message: 'Environment for ace commands' },
|
|
50
|
-
{ name: 'repl', message: 'Environment for the REPL session' },
|
|
51
|
-
{ name: 'web', message: 'Environment for HTTP requests' },
|
|
52
|
-
{ name: 'test', message: 'Environment for the test process' },
|
|
53
|
-
]);
|
|
54
|
-
if (selectedEnvironments.includes('all')) {
|
|
55
|
-
return ['web', 'console', 'test', 'repl'];
|
|
56
|
-
}
|
|
57
|
-
return selectedEnvironments;
|
|
37
|
+
return this.environments.every((one) => ALLOWED_ENVIRONMENTS.includes(one));
|
|
58
38
|
}
|
|
59
39
|
/**
|
|
60
40
|
* Run command
|
|
61
41
|
*/
|
|
62
42
|
async run() {
|
|
63
|
-
let environments = this.environments;
|
|
64
43
|
/**
|
|
65
44
|
* Ensure the environments are valid when provided via flag
|
|
66
45
|
*/
|
|
@@ -69,27 +48,47 @@ export default class MakePreload extends BaseCommand {
|
|
|
69
48
|
return;
|
|
70
49
|
}
|
|
71
50
|
/**
|
|
72
|
-
*
|
|
51
|
+
* Display prompt to know if we should register the preload
|
|
52
|
+
* file inside the ".adonisrc.ts" file.
|
|
73
53
|
*/
|
|
74
|
-
if (
|
|
75
|
-
|
|
54
|
+
if (this.register === undefined) {
|
|
55
|
+
this.register = await this.prompt.confirm('Do you want to register the preload file in .adonisrc.ts file?');
|
|
76
56
|
}
|
|
77
|
-
const
|
|
57
|
+
const codemods = await this.createCodemods();
|
|
58
|
+
const { destination } = await codemods.makeUsingStub(stubsRoot, this.stubPath, {
|
|
59
|
+
flags: this.parsed.flags,
|
|
78
60
|
entity: this.app.generators.createEntity(this.name),
|
|
79
61
|
});
|
|
80
62
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
63
|
+
* Do not register when prompt has been denied or "--no-register"
|
|
64
|
+
* flag was used
|
|
83
65
|
*/
|
|
84
|
-
|
|
85
|
-
|
|
66
|
+
if (!this.register) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Creative relative path for the preload file from
|
|
71
|
+
* the "./start" directory
|
|
72
|
+
*/
|
|
73
|
+
const preloadFileRelativePath = slash(relative(this.app.startPath(), destination).replace(extname(destination), ''));
|
|
74
|
+
await codemods.updateRcFile((rcFile) => {
|
|
75
|
+
rcFile.addPreloadFile(`#start/${preloadFileRelativePath}`, this.environments);
|
|
76
|
+
});
|
|
86
77
|
}
|
|
87
78
|
}
|
|
88
79
|
__decorate([
|
|
89
80
|
args.string({ description: 'Name of the preload file' })
|
|
90
81
|
], MakePreload.prototype, "name", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
flags.boolean({
|
|
84
|
+
description: 'Auto register the preload file inside the .adonisrc.ts file',
|
|
85
|
+
showNegatedVariantInHelp: true,
|
|
86
|
+
alias: 'r',
|
|
87
|
+
})
|
|
88
|
+
], MakePreload.prototype, "register", void 0);
|
|
91
89
|
__decorate([
|
|
92
90
|
flags.array({
|
|
93
91
|
description: `Define the preload file's environment. Accepted values are "${ALLOWED_ENVIRONMENTS}"`,
|
|
92
|
+
alias: 'e',
|
|
94
93
|
})
|
|
95
94
|
], MakePreload.prototype, "environments", void 0);
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import BaseCommand from '
|
|
1
|
+
import { BaseCommand } from '../../modules/ace/main.js';
|
|
2
|
+
declare const ALLOWED_ENVIRONMENTS: ("web" | "console" | "test" | "repl")[];
|
|
3
|
+
type AllowedAppEnvironments = typeof ALLOWED_ENVIRONMENTS;
|
|
2
4
|
/**
|
|
3
5
|
* Make a new provider class
|
|
4
6
|
*/
|
|
5
7
|
export default class MakeProvider extends BaseCommand {
|
|
8
|
+
#private;
|
|
6
9
|
static commandName: string;
|
|
7
10
|
static description: string;
|
|
8
11
|
name: string;
|
|
12
|
+
register?: boolean;
|
|
13
|
+
environments?: AllowedAppEnvironments;
|
|
9
14
|
/**
|
|
10
15
|
* The stub to use for generating the provider class
|
|
11
16
|
*/
|
|
12
17
|
protected stubPath: string;
|
|
13
18
|
run(): Promise<void>;
|
|
14
19
|
}
|
|
20
|
+
export {};
|
|
@@ -12,8 +12,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
12
12
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
13
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
14
|
};
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
15
|
+
import { slash } from '@poppinss/utils';
|
|
16
|
+
import { extname, relative } from 'node:path';
|
|
17
|
+
import { stubsRoot } from '../../stubs/main.js';
|
|
18
|
+
import { args, BaseCommand, flags } from '../../modules/ace/main.js';
|
|
19
|
+
const ALLOWED_ENVIRONMENTS = ['web', 'console', 'test', 'repl'];
|
|
17
20
|
/**
|
|
18
21
|
* Make a new provider class
|
|
19
22
|
*/
|
|
@@ -24,18 +27,65 @@ export default class MakeProvider extends BaseCommand {
|
|
|
24
27
|
* The stub to use for generating the provider class
|
|
25
28
|
*/
|
|
26
29
|
stubPath = 'make/provider/main.stub';
|
|
30
|
+
/**
|
|
31
|
+
* Validate the environments flag passed by the user
|
|
32
|
+
*/
|
|
33
|
+
#isEnvironmentsFlagValid() {
|
|
34
|
+
if (!this.environments || !this.environments.length) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
return this.environments.every((one) => ALLOWED_ENVIRONMENTS.includes(one));
|
|
38
|
+
}
|
|
27
39
|
async run() {
|
|
28
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Ensure the environments are valid when provided via flag
|
|
42
|
+
*/
|
|
43
|
+
if (!this.#isEnvironmentsFlagValid()) {
|
|
44
|
+
this.logger.error(`Invalid environment(s) "${this.environments}". Only "${ALLOWED_ENVIRONMENTS}" are allowed`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Display prompt to know if we should register the provider
|
|
49
|
+
* file inside the ".adonisrc.ts" file.
|
|
50
|
+
*/
|
|
51
|
+
if (this.register === undefined) {
|
|
52
|
+
this.register = await this.prompt.confirm('Do you want to register the provider in .adonisrc.ts file?');
|
|
53
|
+
}
|
|
54
|
+
const codemods = await this.createCodemods();
|
|
55
|
+
const { destination } = await codemods.makeUsingStub(stubsRoot, this.stubPath, {
|
|
56
|
+
flags: this.parsed.flags,
|
|
29
57
|
entity: this.app.generators.createEntity(this.name),
|
|
30
58
|
});
|
|
31
59
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
60
|
+
* Do not register when prompt has been denied or "--no-register"
|
|
61
|
+
* flag was used
|
|
62
|
+
*/
|
|
63
|
+
if (!this.register) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Creative relative path for the provider file from
|
|
68
|
+
* the "./start" directory
|
|
34
69
|
*/
|
|
35
|
-
const
|
|
36
|
-
await
|
|
70
|
+
const providerRelativePath = slash(relative(this.app.providersPath(), destination).replace(extname(destination), ''));
|
|
71
|
+
await codemods.updateRcFile((rcFile) => {
|
|
72
|
+
rcFile.addProvider(`#providers/${providerRelativePath}`, this.environments);
|
|
73
|
+
});
|
|
37
74
|
}
|
|
38
75
|
}
|
|
39
76
|
__decorate([
|
|
40
77
|
args.string({ description: 'Name of the provider' })
|
|
41
78
|
], MakeProvider.prototype, "name", void 0);
|
|
79
|
+
__decorate([
|
|
80
|
+
flags.boolean({
|
|
81
|
+
description: 'Auto register the provider inside the .adonisrc.ts file',
|
|
82
|
+
showNegatedVariantInHelp: true,
|
|
83
|
+
alias: 'r',
|
|
84
|
+
})
|
|
85
|
+
], MakeProvider.prototype, "register", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
flags.array({
|
|
88
|
+
description: `Define the provider environment. Accepted values are "${ALLOWED_ENVIRONMENTS}"`,
|
|
89
|
+
alias: 'e',
|
|
90
|
+
})
|
|
91
|
+
], MakeProvider.prototype, "environments", void 0);
|
|
@@ -12,8 +12,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
12
12
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
13
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
14
|
};
|
|
15
|
-
import
|
|
16
|
-
import { args } from '../../modules/ace/main.js';
|
|
15
|
+
import { stubsRoot } from '../../stubs/main.js';
|
|
16
|
+
import { args, BaseCommand } from '../../modules/ace/main.js';
|
|
17
17
|
/**
|
|
18
18
|
* Make a new service class
|
|
19
19
|
*/
|
|
@@ -25,7 +25,9 @@ export default class MakeService extends BaseCommand {
|
|
|
25
25
|
*/
|
|
26
26
|
stubPath = 'make/service/main.stub';
|
|
27
27
|
async run() {
|
|
28
|
-
await this.
|
|
28
|
+
const codemods = await this.createCodemods();
|
|
29
|
+
await codemods.makeUsingStub(stubsRoot, this.stubPath, {
|
|
30
|
+
flags: this.parsed.flags,
|
|
29
31
|
entity: this.app.generators.createEntity(this.name),
|
|
30
32
|
});
|
|
31
33
|
}
|
|
@@ -12,8 +12,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
12
12
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
13
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
14
|
};
|
|
15
|
-
import
|
|
16
|
-
import { args, flags } from '../../modules/ace/main.js';
|
|
15
|
+
import { stubsRoot } from '../../stubs/main.js';
|
|
16
|
+
import { args, flags, BaseCommand } from '../../modules/ace/main.js';
|
|
17
17
|
/**
|
|
18
18
|
* Make a new test file
|
|
19
19
|
*/
|
|
@@ -80,14 +80,16 @@ export default class MakeTest extends BaseCommand {
|
|
|
80
80
|
* Show error when mentioned/selected suite does not exist
|
|
81
81
|
*/
|
|
82
82
|
if (!suite) {
|
|
83
|
-
this.logger.error(`The "${this.suite}" suite is not configured inside the
|
|
83
|
+
this.logger.error(`The "${this.suite}" suite is not configured inside the "adonisrc.js" file`);
|
|
84
84
|
this.exitCode = 1;
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
88
|
* Generate entity
|
|
89
89
|
*/
|
|
90
|
-
await this.
|
|
90
|
+
const codemods = await this.createCodemods();
|
|
91
|
+
await codemods.makeUsingStub(stubsRoot, this.stubPath, {
|
|
92
|
+
flags: this.parsed.flags,
|
|
91
93
|
entity: this.app.generators.createEntity(this.name),
|
|
92
94
|
suite: {
|
|
93
95
|
directory: await this.#getSuiteDirectory(suite.directories),
|
|
@@ -99,5 +101,5 @@ __decorate([
|
|
|
99
101
|
args.string({ description: 'Name of the test file' })
|
|
100
102
|
], MakeTest.prototype, "name", void 0);
|
|
101
103
|
__decorate([
|
|
102
|
-
flags.string({ description: 'The suite for which to create the test file' })
|
|
104
|
+
flags.string({ description: 'The suite for which to create the test file', alias: 's' })
|
|
103
105
|
], MakeTest.prototype, "suite", void 0);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseCommand } from '../../modules/ace/main.js';
|
|
2
|
+
/**
|
|
3
|
+
* Make a new VineJS validator
|
|
4
|
+
*/
|
|
5
|
+
export default class MakeValidator extends BaseCommand {
|
|
6
|
+
static commandName: string;
|
|
7
|
+
static description: string;
|
|
8
|
+
name: string;
|
|
9
|
+
resource: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The stub to use for generating the validator
|
|
12
|
+
*/
|
|
13
|
+
protected stubPath: string;
|
|
14
|
+
/**
|
|
15
|
+
* Preparing the command state
|
|
16
|
+
*/
|
|
17
|
+
prepare(): Promise<void>;
|
|
18
|
+
run(): Promise<void>;
|
|
19
|
+
}
|