@adonisjs/core 7.0.0-next.10 → 7.0.0-next.11
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/add.js +40 -110
- package/build/commands/build.js +51 -107
- package/build/commands/configure.js +82 -177
- package/build/commands/eject.js +17 -60
- package/build/commands/env/add.js +55 -134
- package/build/commands/generate_key.js +22 -66
- package/build/commands/inspect_rcfile.js +27 -55
- package/build/commands/list/routes.js +246 -116
- package/build/commands/make/command.js +15 -57
- package/build/commands/make/controller.js +43 -120
- package/build/commands/make/event.js +16 -62
- package/build/commands/make/exception.js +16 -62
- package/build/commands/make/listener.js +36 -93
- package/build/commands/make/middleware.js +41 -101
- package/build/commands/make/preload.js +47 -113
- package/build/commands/make/provider.js +47 -112
- package/build/commands/make/service.js +16 -55
- package/build/commands/make/test.js +47 -132
- package/build/commands/make/transformer.js +17 -64
- package/build/commands/make/validator.js +20 -80
- package/build/commands/make/view.js +15 -56
- package/build/commands/repl.js +17 -50
- package/build/commands/serve.js +80 -150
- package/build/commands/test.js +92 -202
- package/build/factories/app.js +2 -9
- package/build/factories/bodyparser.js +2 -9
- package/build/factories/core/ace.js +15 -46
- package/build/factories/core/ignitor.js +12 -180
- package/build/factories/core/main.js +22 -11
- package/build/factories/core/test_utils.js +19 -43
- package/build/factories/encryption.js +2 -9
- package/build/factories/events.js +2 -9
- package/build/factories/hash.js +2 -9
- package/build/factories/http.js +2 -9
- package/build/factories/logger.js +2 -9
- package/build/factories/stubs.js +28 -91
- package/build/index.js +13 -46
- package/build/modules/ace/codemods.js +222 -477
- package/build/modules/ace/main.js +2 -41
- package/build/modules/app.js +4 -26
- package/build/modules/bodyparser/bodyparser_middleware.js +2 -14
- package/build/modules/bodyparser/main.js +4 -9
- package/build/modules/config.js +4 -26
- package/build/modules/container.js +4 -9
- package/build/modules/dumper/main.js +6 -32
- package/build/modules/dumper/plugins/edge.js +2 -62
- package/build/modules/encryption.js +4 -26
- package/build/modules/env/editor.js +2 -9
- package/build/modules/env/main.js +2 -28
- package/build/modules/events.js +4 -9
- package/build/modules/hash/drivers/argon.js +2 -9
- package/build/modules/hash/drivers/bcrypt.js +2 -20
- package/build/modules/hash/drivers/scrypt.js +2 -9
- package/build/modules/hash/main.js +6 -28
- package/build/modules/hash/phc_formatter.js +2 -9
- package/build/modules/health.js +2 -9
- package/build/modules/http/main.js +4 -15
- package/build/modules/http/url_builder_client.js +2 -9
- package/build/modules/logger.d.ts +30 -0
- package/build/modules/logger.js +4 -9
- package/build/modules/repl.js +4 -9
- package/build/modules/transformers/main.js +4 -9
- package/build/providers/app_provider.js +147 -359
- package/build/providers/edge_provider.js +97 -165
- package/build/providers/hash_provider.js +29 -91
- package/build/providers/repl_provider.js +61 -152
- package/build/providers/vinejs_provider.d.ts +1 -1
- package/build/providers/vinejs_provider.js +20 -66
- package/build/services/ace.js +2 -17
- package/build/services/app.js +2 -21
- package/build/services/config.js +2 -13
- package/build/services/dumper.js +5 -21
- package/build/services/emitter.js +2 -14
- package/build/services/encryption.js +2 -14
- package/build/services/hash.js +2 -14
- package/build/services/logger.js +2 -14
- package/build/services/repl.js +2 -14
- package/build/services/router.js +2 -14
- package/build/services/server.js +2 -14
- package/build/services/test_utils.js +2 -17
- package/build/services/url_builder.js +5 -17
- package/build/src/exceptions.js +2 -49
- package/build/src/helpers/assert.js +2 -55
- package/build/src/helpers/http.js +2 -28
- package/build/src/helpers/is.js +3 -31
- package/build/src/helpers/main.js +5 -52
- package/build/src/helpers/string.js +2 -78
- package/build/src/helpers/types.js +26 -135
- package/build/src/helpers/verification_token.js +2 -120
- package/build/src/test_utils/main.js +5 -77
- package/build/src/types.js +0 -8
- package/build/src/vine.js +2 -105
- package/build/types/ace.js +2 -9
- package/build/types/app.js +2 -9
- package/build/types/bodyparser.js +2 -9
- package/build/types/common.js +2 -9
- package/build/types/container.js +2 -9
- package/build/types/encryption.js +2 -9
- package/build/types/events.js +2 -9
- package/build/types/hash.js +2 -9
- package/build/types/health.js +2 -9
- package/build/types/helpers.js +0 -8
- package/build/types/http.js +2 -9
- package/build/types/logger.js +2 -9
- package/build/types/repl.js +2 -9
- package/build/types/transformers.js +2 -9
- package/package.json +76 -19
- package/build/modules/ace/commands.js +0 -157
- package/build/modules/ace/create_kernel.js +0 -91
- package/build/modules/ace/kernel.js +0 -40
- package/build/modules/dumper/define_config.js +0 -36
- package/build/modules/dumper/dumper.js +0 -266
- package/build/modules/dumper/errors.js +0 -119
- package/build/modules/hash/define_config.js +0 -125
- package/build/modules/http/request_validator.js +0 -100
- package/build/src/assembler_hooks/index_entities.js +0 -112
- package/build/src/cli_formatters/routes_list.js +0 -397
- package/build/src/config_provider.js +0 -71
- package/build/src/debug.js +0 -25
- package/build/src/ignitor/ace.js +0 -102
- package/build/src/ignitor/http.js +0 -159
- package/build/src/ignitor/main.js +0 -124
- package/build/src/ignitor/test.js +0 -66
- package/build/src/test_utils/http.js +0 -82
- package/build/src/utils.js +0 -114
- package/build/stubs/main.js +0 -9
- package/build/toolkit/commands/index_commands.js +0 -30
- package/build/toolkit/main.js +0 -27
|
@@ -1,135 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { t as string_default } from "../../string-CJ7ewUFq.js";
|
|
2
|
+
import { f as BaseCommand, l as flags, o as args } from "../../main-Cn_x9YY5.js";
|
|
3
|
+
import { t as __decorate } from "../../decorate-DM0Sx1ye.js";
|
|
4
|
+
const ALLOWED_TYPES = [
|
|
5
|
+
"string",
|
|
6
|
+
"boolean",
|
|
7
|
+
"number",
|
|
8
|
+
"enum"
|
|
9
|
+
];
|
|
10
|
+
var EnvAdd = class extends BaseCommand {
|
|
11
|
+
static commandName = "env:add";
|
|
12
|
+
static description = "Add a new environment variable";
|
|
13
|
+
static options = { allowUnknownFlags: true };
|
|
14
|
+
#isTypeFlagValid() {
|
|
15
|
+
return ALLOWED_TYPES.includes(this.type);
|
|
16
|
+
}
|
|
17
|
+
async run() {
|
|
18
|
+
if (!this.name) this.name = await this.prompt.ask("Enter the variable name", {
|
|
19
|
+
validate: (value) => !!value,
|
|
20
|
+
format: (value) => string_default.snakeCase(value).toUpperCase()
|
|
21
|
+
});
|
|
22
|
+
if (!this.value) this.value = await this.prompt.ask("Enter the variable value");
|
|
23
|
+
if (!this.type) this.type = await this.prompt.choice("Select the variable type", ALLOWED_TYPES);
|
|
24
|
+
if (this.type === "enum" && !this.enumValues) this.enumValues = await this.prompt.ask("Enter the enum values separated by a comma", { result: (value) => value.split(",").map((one) => one.trim()) });
|
|
25
|
+
if (!this.#isTypeFlagValid()) {
|
|
26
|
+
this.logger.error(`Invalid type "${this.type}". Must be one of ${ALLOWED_TYPES.join(", ")}`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const codemods = await this.createCodemods();
|
|
30
|
+
const transformedName = string_default.snakeCase(this.name).toUpperCase();
|
|
31
|
+
await codemods.defineEnvVariables({ [transformedName]: this.value }, { omitFromExample: [transformedName] });
|
|
32
|
+
const validation = {
|
|
33
|
+
string: "Env.schema.string()",
|
|
34
|
+
number: "Env.schema.number()",
|
|
35
|
+
boolean: "Env.schema.boolean()",
|
|
36
|
+
enum: `Env.schema.enum(['${this.enumValues.join("','")}'] as const)`
|
|
37
|
+
}[this.type];
|
|
38
|
+
await codemods.defineEnvValidations({ variables: { [transformedName]: validation } });
|
|
39
|
+
this.logger.success("Environment variable added successfully");
|
|
40
|
+
}
|
|
14
41
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
* ace env:add LOG_LEVEL info --type=enum --enum-values=debug,info,warn,error
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
export default class EnvAdd extends BaseCommand {
|
|
34
|
-
/**
|
|
35
|
-
* The command name
|
|
36
|
-
*/
|
|
37
|
-
static commandName = 'env:add';
|
|
38
|
-
/**
|
|
39
|
-
* The command description
|
|
40
|
-
*/
|
|
41
|
-
static description = 'Add a new environment variable';
|
|
42
|
-
/**
|
|
43
|
-
* Command options configuration.
|
|
44
|
-
* Allows unknown flags to be passed through.
|
|
45
|
-
*/
|
|
46
|
-
static options = {
|
|
47
|
-
allowUnknownFlags: true,
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Validate that the provided type is one of the allowed types.
|
|
51
|
-
*
|
|
52
|
-
* @returns True if the type is valid, false otherwise
|
|
53
|
-
*/
|
|
54
|
-
#isTypeFlagValid() {
|
|
55
|
-
return ALLOWED_TYPES.includes(this.type);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Execute the command to add a new environment variable.
|
|
59
|
-
* Prompts for missing values, validates inputs, and updates all relevant files.
|
|
60
|
-
*/
|
|
61
|
-
async run() {
|
|
62
|
-
/**
|
|
63
|
-
* Prompt for missing name
|
|
64
|
-
*/
|
|
65
|
-
if (!this.name) {
|
|
66
|
-
this.name = await this.prompt.ask('Enter the variable name', {
|
|
67
|
-
validate: (value) => !!value,
|
|
68
|
-
format: (value) => stringHelpers.snakeCase(value).toUpperCase(),
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Prompt for missing value
|
|
73
|
-
*/
|
|
74
|
-
if (!this.value) {
|
|
75
|
-
this.value = await this.prompt.ask('Enter the variable value');
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Prompt for missing type
|
|
79
|
-
*/
|
|
80
|
-
if (!this.type) {
|
|
81
|
-
this.type = await this.prompt.choice('Select the variable type', ALLOWED_TYPES);
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Prompt for missing enum values if the selected env type is `enum`
|
|
85
|
-
*/
|
|
86
|
-
if (this.type === 'enum' && !this.enumValues) {
|
|
87
|
-
this.enumValues = await this.prompt.ask('Enter the enum values separated by a comma', {
|
|
88
|
-
result: (value) => value.split(',').map((one) => one.trim()),
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Validate inputs
|
|
93
|
-
*/
|
|
94
|
-
if (!this.#isTypeFlagValid()) {
|
|
95
|
-
this.logger.error(`Invalid type "${this.type}". Must be one of ${ALLOWED_TYPES.join(', ')}`);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Add the environment variable to the `.env` and `.env.example` files
|
|
100
|
-
*/
|
|
101
|
-
const codemods = await this.createCodemods();
|
|
102
|
-
const transformedName = stringHelpers.snakeCase(this.name).toUpperCase();
|
|
103
|
-
await codemods.defineEnvVariables({ [transformedName]: this.value }, { omitFromExample: [transformedName] });
|
|
104
|
-
/**
|
|
105
|
-
* Add the environment variable to the `start/env.ts` file
|
|
106
|
-
*/
|
|
107
|
-
const validation = {
|
|
108
|
-
string: 'Env.schema.string()',
|
|
109
|
-
number: 'Env.schema.number()',
|
|
110
|
-
boolean: 'Env.schema.boolean()',
|
|
111
|
-
enum: `Env.schema.enum(['${this.enumValues.join("','")}'] as const)`,
|
|
112
|
-
}[this.type];
|
|
113
|
-
await codemods.defineEnvValidations({ variables: { [transformedName]: validation } });
|
|
114
|
-
this.logger.success('Environment variable added successfully');
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
__decorate([
|
|
118
|
-
args.string({
|
|
119
|
-
description: 'Variable name. Will be converted to screaming snake case',
|
|
120
|
-
required: false,
|
|
121
|
-
})
|
|
122
|
-
], EnvAdd.prototype, "name", void 0);
|
|
123
|
-
__decorate([
|
|
124
|
-
args.string({ description: 'Variable value', required: false })
|
|
125
|
-
], EnvAdd.prototype, "value", void 0);
|
|
126
|
-
__decorate([
|
|
127
|
-
flags.string({ description: 'Type of the variable' })
|
|
128
|
-
], EnvAdd.prototype, "type", void 0);
|
|
129
|
-
__decorate([
|
|
130
|
-
flags.array({
|
|
131
|
-
description: 'Allowed values for the enum type in a comma-separated list',
|
|
132
|
-
default: [''],
|
|
133
|
-
required: false,
|
|
134
|
-
})
|
|
135
|
-
], EnvAdd.prototype, "enumValues", void 0);
|
|
42
|
+
__decorate([args.string({
|
|
43
|
+
description: "Variable name. Will be converted to screaming snake case",
|
|
44
|
+
required: false
|
|
45
|
+
})], EnvAdd.prototype, "name", void 0);
|
|
46
|
+
__decorate([args.string({
|
|
47
|
+
description: "Variable value",
|
|
48
|
+
required: false
|
|
49
|
+
})], EnvAdd.prototype, "value", void 0);
|
|
50
|
+
__decorate([flags.string({ description: "Type of the variable" })], EnvAdd.prototype, "type", void 0);
|
|
51
|
+
__decorate([flags.array({
|
|
52
|
+
description: "Allowed values for the enum type in a comma-separated list",
|
|
53
|
+
default: [""],
|
|
54
|
+
required: false
|
|
55
|
+
})], EnvAdd.prototype, "enumValues", void 0);
|
|
56
|
+
export { EnvAdd as default };
|
|
@@ -1,67 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { f as BaseCommand, l as flags } from "../main-Cn_x9YY5.js";
|
|
2
|
+
import { t as __decorate } from "../decorate-DM0Sx1ye.js";
|
|
3
|
+
import string from "@poppinss/utils/string";
|
|
4
|
+
import { EnvEditor } from "@adonisjs/env/editor";
|
|
5
|
+
var GenerateKey = class extends BaseCommand {
|
|
6
|
+
static commandName = "generate:key";
|
|
7
|
+
static description = "Generate a cryptographically secure random application key";
|
|
8
|
+
async run() {
|
|
9
|
+
let writeToFile = process.env.NODE_ENV !== "production";
|
|
10
|
+
if (this.force) writeToFile = true;
|
|
11
|
+
if (this.show) writeToFile = false;
|
|
12
|
+
const secureKey = string.random(32);
|
|
13
|
+
if (writeToFile) {
|
|
14
|
+
const editor = await EnvEditor.create(this.app.appRoot);
|
|
15
|
+
editor.add("APP_KEY", secureKey, true);
|
|
16
|
+
await editor.save();
|
|
17
|
+
this.logger.action("add APP_KEY to .env").succeeded();
|
|
18
|
+
} else this.logger.log(`APP_KEY = ${secureKey}`);
|
|
19
|
+
}
|
|
14
20
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The generate key command is used to generate the app key
|
|
20
|
-
* and write it inside the .env file.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```
|
|
24
|
-
* ace generate:key
|
|
25
|
-
* ace generate:key --show
|
|
26
|
-
* ace generate:key --force
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export default class GenerateKey extends BaseCommand {
|
|
30
|
-
/**
|
|
31
|
-
* The command name
|
|
32
|
-
*/
|
|
33
|
-
static commandName = 'generate:key';
|
|
34
|
-
/**
|
|
35
|
-
* The command description
|
|
36
|
-
*/
|
|
37
|
-
static description = 'Generate a cryptographically secure random application key';
|
|
38
|
-
async run() {
|
|
39
|
-
let writeToFile = process.env.NODE_ENV !== 'production';
|
|
40
|
-
if (this.force) {
|
|
41
|
-
writeToFile = true;
|
|
42
|
-
}
|
|
43
|
-
if (this.show) {
|
|
44
|
-
writeToFile = false;
|
|
45
|
-
}
|
|
46
|
-
const secureKey = string.random(32);
|
|
47
|
-
if (writeToFile) {
|
|
48
|
-
const editor = await EnvEditor.create(this.app.appRoot);
|
|
49
|
-
editor.add('APP_KEY', secureKey, true);
|
|
50
|
-
await editor.save();
|
|
51
|
-
this.logger.action('add APP_KEY to .env').succeeded();
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
this.logger.log(`APP_KEY = ${secureKey}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
__decorate([
|
|
59
|
-
flags.boolean({
|
|
60
|
-
description: 'Display the key on the terminal, instead of writing it to .env file',
|
|
61
|
-
})
|
|
62
|
-
], GenerateKey.prototype, "show", void 0);
|
|
63
|
-
__decorate([
|
|
64
|
-
flags.boolean({
|
|
65
|
-
description: 'Force update .env file in production environment',
|
|
66
|
-
})
|
|
67
|
-
], GenerateKey.prototype, "force", void 0);
|
|
21
|
+
__decorate([flags.boolean({ description: "Display the key on the terminal, instead of writing it to .env file" })], GenerateKey.prototype, "show", void 0);
|
|
22
|
+
__decorate([flags.boolean({ description: "Force update .env file in production environment" })], GenerateKey.prototype, "force", void 0);
|
|
23
|
+
export { GenerateKey as default };
|
|
@@ -1,55 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
static description = 'Inspect the RC file with its default values';
|
|
29
|
-
/**
|
|
30
|
-
* Execute the command to display RC file contents.
|
|
31
|
-
* Transforms provider, preload, and command entries to display their file paths
|
|
32
|
-
* as strings and formats the output as readable JSON.
|
|
33
|
-
*/
|
|
34
|
-
async run() {
|
|
35
|
-
const { raw, providers, preloads, commands, ...rest } = this.app.rcFile;
|
|
36
|
-
this.logger.log(JSON.stringify({
|
|
37
|
-
...rest,
|
|
38
|
-
providers: providers.map((provider) => {
|
|
39
|
-
return {
|
|
40
|
-
...provider,
|
|
41
|
-
file: provider.file.toString(),
|
|
42
|
-
};
|
|
43
|
-
}),
|
|
44
|
-
preloads: preloads.map((preload) => {
|
|
45
|
-
return {
|
|
46
|
-
...preload,
|
|
47
|
-
file: preload.file.toString(),
|
|
48
|
-
};
|
|
49
|
-
}),
|
|
50
|
-
commands: commands.map((command) => {
|
|
51
|
-
return command.toString();
|
|
52
|
-
}),
|
|
53
|
-
}, null, 2));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
1
|
+
import { f as BaseCommand } from "../main-Cn_x9YY5.js";
|
|
2
|
+
var InspectRCFile = class extends BaseCommand {
|
|
3
|
+
static commandName = "inspect:rcfile";
|
|
4
|
+
static description = "Inspect the RC file with its default values";
|
|
5
|
+
async run() {
|
|
6
|
+
const { raw, providers, preloads, commands, ...rest } = this.app.rcFile;
|
|
7
|
+
this.logger.log(JSON.stringify({
|
|
8
|
+
...rest,
|
|
9
|
+
providers: providers.map((provider) => {
|
|
10
|
+
return {
|
|
11
|
+
...provider,
|
|
12
|
+
file: provider.file.toString()
|
|
13
|
+
};
|
|
14
|
+
}),
|
|
15
|
+
preloads: preloads.map((preload) => {
|
|
16
|
+
return {
|
|
17
|
+
...preload,
|
|
18
|
+
file: preload.file.toString()
|
|
19
|
+
};
|
|
20
|
+
}),
|
|
21
|
+
commands: commands.map((command) => {
|
|
22
|
+
return command.toString();
|
|
23
|
+
})
|
|
24
|
+
}, null, 2));
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export { InspectRCFile as default };
|