@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.
Files changed (128) hide show
  1. package/build/commands/add.js +40 -110
  2. package/build/commands/build.js +51 -107
  3. package/build/commands/configure.js +82 -177
  4. package/build/commands/eject.js +17 -60
  5. package/build/commands/env/add.js +55 -134
  6. package/build/commands/generate_key.js +22 -66
  7. package/build/commands/inspect_rcfile.js +27 -55
  8. package/build/commands/list/routes.js +246 -116
  9. package/build/commands/make/command.js +15 -57
  10. package/build/commands/make/controller.js +43 -120
  11. package/build/commands/make/event.js +16 -62
  12. package/build/commands/make/exception.js +16 -62
  13. package/build/commands/make/listener.js +36 -93
  14. package/build/commands/make/middleware.js +41 -101
  15. package/build/commands/make/preload.js +47 -113
  16. package/build/commands/make/provider.js +47 -112
  17. package/build/commands/make/service.js +16 -55
  18. package/build/commands/make/test.js +47 -132
  19. package/build/commands/make/transformer.js +17 -64
  20. package/build/commands/make/validator.js +20 -80
  21. package/build/commands/make/view.js +15 -56
  22. package/build/commands/repl.js +17 -50
  23. package/build/commands/serve.js +80 -150
  24. package/build/commands/test.js +92 -202
  25. package/build/factories/app.js +2 -9
  26. package/build/factories/bodyparser.js +2 -9
  27. package/build/factories/core/ace.js +15 -46
  28. package/build/factories/core/ignitor.js +12 -180
  29. package/build/factories/core/main.js +22 -11
  30. package/build/factories/core/test_utils.js +19 -43
  31. package/build/factories/encryption.js +2 -9
  32. package/build/factories/events.js +2 -9
  33. package/build/factories/hash.js +2 -9
  34. package/build/factories/http.js +2 -9
  35. package/build/factories/logger.js +2 -9
  36. package/build/factories/stubs.js +28 -91
  37. package/build/index.js +13 -46
  38. package/build/modules/ace/codemods.js +222 -477
  39. package/build/modules/ace/main.js +2 -41
  40. package/build/modules/app.js +4 -26
  41. package/build/modules/bodyparser/bodyparser_middleware.js +2 -14
  42. package/build/modules/bodyparser/main.js +4 -9
  43. package/build/modules/config.js +4 -26
  44. package/build/modules/container.js +4 -9
  45. package/build/modules/dumper/main.js +6 -32
  46. package/build/modules/dumper/plugins/edge.js +2 -62
  47. package/build/modules/encryption.js +4 -26
  48. package/build/modules/env/editor.js +2 -9
  49. package/build/modules/env/main.js +2 -28
  50. package/build/modules/events.js +4 -9
  51. package/build/modules/hash/drivers/argon.js +2 -9
  52. package/build/modules/hash/drivers/bcrypt.js +2 -20
  53. package/build/modules/hash/drivers/scrypt.js +2 -9
  54. package/build/modules/hash/main.js +6 -28
  55. package/build/modules/hash/phc_formatter.js +2 -9
  56. package/build/modules/health.js +2 -9
  57. package/build/modules/http/main.js +4 -15
  58. package/build/modules/http/url_builder_client.js +2 -9
  59. package/build/modules/logger.d.ts +30 -0
  60. package/build/modules/logger.js +4 -9
  61. package/build/modules/repl.js +4 -9
  62. package/build/modules/transformers/main.js +4 -9
  63. package/build/providers/app_provider.js +147 -359
  64. package/build/providers/edge_provider.js +97 -165
  65. package/build/providers/hash_provider.js +29 -91
  66. package/build/providers/repl_provider.js +61 -152
  67. package/build/providers/vinejs_provider.d.ts +1 -1
  68. package/build/providers/vinejs_provider.js +20 -66
  69. package/build/services/ace.js +2 -17
  70. package/build/services/app.js +2 -21
  71. package/build/services/config.js +2 -13
  72. package/build/services/dumper.js +5 -21
  73. package/build/services/emitter.js +2 -14
  74. package/build/services/encryption.js +2 -14
  75. package/build/services/hash.js +2 -14
  76. package/build/services/logger.js +2 -14
  77. package/build/services/repl.js +2 -14
  78. package/build/services/router.js +2 -14
  79. package/build/services/server.js +2 -14
  80. package/build/services/test_utils.js +2 -17
  81. package/build/services/url_builder.js +5 -17
  82. package/build/src/exceptions.js +2 -49
  83. package/build/src/helpers/assert.js +2 -55
  84. package/build/src/helpers/http.js +2 -28
  85. package/build/src/helpers/is.js +3 -31
  86. package/build/src/helpers/main.js +5 -52
  87. package/build/src/helpers/string.js +2 -78
  88. package/build/src/helpers/types.js +26 -135
  89. package/build/src/helpers/verification_token.js +2 -120
  90. package/build/src/test_utils/main.js +5 -77
  91. package/build/src/types.js +0 -8
  92. package/build/src/vine.js +2 -105
  93. package/build/types/ace.js +2 -9
  94. package/build/types/app.js +2 -9
  95. package/build/types/bodyparser.js +2 -9
  96. package/build/types/common.js +2 -9
  97. package/build/types/container.js +2 -9
  98. package/build/types/encryption.js +2 -9
  99. package/build/types/events.js +2 -9
  100. package/build/types/hash.js +2 -9
  101. package/build/types/health.js +2 -9
  102. package/build/types/helpers.js +0 -8
  103. package/build/types/http.js +2 -9
  104. package/build/types/logger.js +2 -9
  105. package/build/types/repl.js +2 -9
  106. package/build/types/transformers.js +2 -9
  107. package/package.json +76 -19
  108. package/build/modules/ace/commands.js +0 -157
  109. package/build/modules/ace/create_kernel.js +0 -91
  110. package/build/modules/ace/kernel.js +0 -40
  111. package/build/modules/dumper/define_config.js +0 -36
  112. package/build/modules/dumper/dumper.js +0 -266
  113. package/build/modules/dumper/errors.js +0 -119
  114. package/build/modules/hash/define_config.js +0 -125
  115. package/build/modules/http/request_validator.js +0 -100
  116. package/build/src/assembler_hooks/index_entities.js +0 -112
  117. package/build/src/cli_formatters/routes_list.js +0 -397
  118. package/build/src/config_provider.js +0 -71
  119. package/build/src/debug.js +0 -25
  120. package/build/src/ignitor/ace.js +0 -102
  121. package/build/src/ignitor/http.js +0 -159
  122. package/build/src/ignitor/main.js +0 -124
  123. package/build/src/ignitor/test.js +0 -66
  124. package/build/src/test_utils/http.js +0 -82
  125. package/build/src/utils.js +0 -114
  126. package/build/stubs/main.js +0 -9
  127. package/build/toolkit/commands/index_commands.js +0 -30
  128. package/build/toolkit/main.js +0 -27
@@ -1,135 +1,56 @@
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
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
10
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
- return c > 3 && r && Object.defineProperty(target, key, r), r;
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
- import stringHelpers from "../../src/helpers/string.js";
16
- import { args, BaseCommand, flags } from "../../modules/ace/main.js";
17
- const ALLOWED_TYPES = ['string', 'boolean', 'number', 'enum'];
18
- /**
19
- * Command to add a new environment variable to the application.
20
- * Updates .env, .env.example, and start/env.ts files with the new variable,
21
- * including appropriate validation schema based on the variable type.
22
- *
23
- * @example
24
- * ```
25
- * ace env:add
26
- * ace env:add DATABASE_URL postgres://localhost:5432/mydb
27
- * ace env:add API_KEY secret --type=string
28
- * ace env:add PORT 3333 --type=number
29
- * ace env:add DEBUG true --type=boolean
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
- * @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
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
10
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
- return c > 3 && r && Object.defineProperty(target, key, r), r;
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
- import string from '@poppinss/utils/string';
16
- import { EnvEditor } from '@adonisjs/env/editor';
17
- import { BaseCommand, flags } from "../modules/ace/main.js";
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
- * @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
- import { BaseCommand } from "../modules/ace/main.js";
10
- /**
11
- * Command to inspect and display the AdonisJS RC file contents with default values.
12
- * The RC file contains configuration for providers, preloads, commands, and other
13
- * application settings. This command formats and displays the contents in a readable JSON format.
14
- *
15
- * @example
16
- * ```
17
- * ace inspect:rcfile
18
- * ```
19
- */
20
- export default class InspectRCFile extends BaseCommand {
21
- /**
22
- * The command name
23
- */
24
- static commandName = 'inspect:rcfile';
25
- /**
26
- * The command description
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 };