@adonisjs/core 7.0.0-next.2 → 7.0.0-next.20

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 (217) hide show
  1. package/build/ace-sWl9sgM1.js +16 -0
  2. package/build/app-B6oge7b3.js +5 -0
  3. package/build/app-DNvbxVWl.js +5 -0
  4. package/build/bodyparser_middleware-BmARtnYe.js +3 -0
  5. package/build/chunk-B88MteZI.js +26 -0
  6. package/build/commands/add.d.ts +4 -3
  7. package/build/commands/add.js +76 -110
  8. package/build/commands/build.js +51 -107
  9. package/build/commands/commands.json +1 -1
  10. package/build/commands/configure.js +82 -177
  11. package/build/commands/eject.js +17 -60
  12. package/build/commands/env/add.js +55 -134
  13. package/build/commands/generate_key.js +22 -66
  14. package/build/commands/inspect_rcfile.js +27 -55
  15. package/build/commands/list/routes.js +246 -116
  16. package/build/commands/make/command.js +15 -57
  17. package/build/commands/make/controller.js +43 -120
  18. package/build/commands/make/event.js +16 -62
  19. package/build/commands/make/exception.js +16 -62
  20. package/build/commands/make/listener.js +36 -93
  21. package/build/commands/make/middleware.js +41 -101
  22. package/build/commands/make/preload.js +47 -113
  23. package/build/commands/make/provider.js +47 -112
  24. package/build/commands/make/service.js +16 -55
  25. package/build/commands/make/test.js +47 -132
  26. package/build/commands/make/transformer.js +17 -64
  27. package/build/commands/make/validator.js +20 -80
  28. package/build/commands/make/view.js +15 -56
  29. package/build/commands/repl.js +17 -50
  30. package/build/commands/serve.js +80 -156
  31. package/build/commands/test.js +92 -208
  32. package/build/config-Dd2H6-_e.js +5 -0
  33. package/build/config_provider-DWVFHOQX.js +15 -0
  34. package/build/container-uxa8LpGI.js +5 -0
  35. package/build/core-BuPP8K6N.js +140 -0
  36. package/build/create_kernel-Cn8zVtvt.js +3 -0
  37. package/build/create_kernel-Cpqqa931.js +38 -0
  38. package/build/decorate-CJcHOoD-.js +7 -0
  39. package/build/define_config-CoWy5lbf.js +62 -0
  40. package/build/dumper-BTjb8j4y.js +147 -0
  41. package/build/edge-BVYR-Vjr.js +47 -0
  42. package/build/events-C4d0OPUI.js +5 -0
  43. package/build/exceptions-DNMesP42.js +2 -0
  44. package/build/factories/app.js +2 -9
  45. package/build/factories/bodyparser.js +2 -9
  46. package/build/factories/core/ace.js +16 -46
  47. package/build/factories/core/ignitor.js +13 -180
  48. package/build/factories/core/main.js +24 -11
  49. package/build/factories/core/test_utils.js +21 -43
  50. package/build/factories/encryption.d.ts +1 -1
  51. package/build/factories/encryption.js +2 -9
  52. package/build/factories/events.js +2 -9
  53. package/build/factories/hash.js +2 -9
  54. package/build/factories/http.js +2 -9
  55. package/build/factories/logger.js +2 -9
  56. package/build/factories/stubs.js +27 -91
  57. package/build/ignitor-BrmVPN5N.js +71 -0
  58. package/build/index.d.ts +1 -1
  59. package/build/index.js +12 -46
  60. package/build/logger-0KKSqgPG.js +13 -0
  61. package/build/main-BU8NWUEG.js +73 -0
  62. package/build/main-Bfnr5tAw.js +2 -0
  63. package/build/main-BlJhxJJ2.js +81 -0
  64. package/build/main-C4B2SPOT.js +5 -0
  65. package/build/main-CZZ21eXm.js +171 -0
  66. package/build/main-D-WhqOOn.js +51 -0
  67. package/build/main-DOY5Q8Av.js +5 -0
  68. package/build/main-kn40V-hF.js +2 -0
  69. package/build/main-nojlltNo.js +30 -0
  70. package/build/{stubs/make → make}/health/controller.stub +5 -2
  71. package/build/modules/ace/codemods.d.ts +109 -14
  72. package/build/modules/ace/codemods.js +222 -382
  73. package/build/modules/ace/main.d.ts +30 -0
  74. package/build/modules/ace/main.js +2 -11
  75. package/build/modules/app.d.ts +17 -0
  76. package/build/modules/app.js +4 -9
  77. package/build/modules/bodyparser/bodyparser_middleware.js +2 -14
  78. package/build/modules/bodyparser/main.js +4 -9
  79. package/build/modules/config.d.ts +17 -0
  80. package/build/modules/config.js +4 -9
  81. package/build/modules/container.js +4 -9
  82. package/build/modules/dumper/dumper.d.ts +5 -0
  83. package/build/modules/dumper/main.d.ts +21 -0
  84. package/build/modules/dumper/main.js +6 -11
  85. package/build/modules/dumper/plugins/edge.js +2 -62
  86. package/build/modules/encryption/define_config.d.ts +128 -0
  87. package/build/modules/encryption/drivers/aes_256_cbc.d.ts +20 -0
  88. package/build/modules/encryption/drivers/aes_256_cbc.js +2 -0
  89. package/build/modules/encryption/drivers/aes_256_gcm.d.ts +21 -0
  90. package/build/modules/encryption/drivers/aes_256_gcm.js +2 -0
  91. package/build/modules/encryption/drivers/chacha20_poly1305.d.ts +21 -0
  92. package/build/modules/encryption/drivers/chacha20_poly1305.js +2 -0
  93. package/build/modules/encryption/main.d.ts +85 -0
  94. package/build/modules/encryption/main.js +5 -0
  95. package/build/modules/env/editor.js +2 -9
  96. package/build/modules/env/main.d.ts +19 -0
  97. package/build/modules/env/main.js +2 -9
  98. package/build/modules/events.js +4 -9
  99. package/build/modules/hash/drivers/argon.js +2 -9
  100. package/build/modules/hash/drivers/bcrypt.d.ts +11 -0
  101. package/build/modules/hash/drivers/bcrypt.js +2 -9
  102. package/build/modules/hash/drivers/scrypt.js +2 -9
  103. package/build/modules/hash/main.d.ts +18 -0
  104. package/build/modules/hash/main.js +5 -10
  105. package/build/modules/hash/phc_formatter.js +2 -9
  106. package/build/modules/health.js +2 -9
  107. package/build/modules/http/main.js +4 -15
  108. package/build/modules/http/request_validator.d.ts +1 -3
  109. package/build/modules/http/url_builder_client.d.ts +1 -0
  110. package/build/modules/http/url_builder_client.js +2 -0
  111. package/build/modules/logger.d.ts +30 -0
  112. package/build/modules/logger.js +4 -9
  113. package/build/modules/repl.js +4 -9
  114. package/build/modules/transformers/main.js +4 -9
  115. package/build/providers/app_provider.d.ts +14 -25
  116. package/build/providers/app_provider.js +155 -363
  117. package/build/providers/edge_provider.js +97 -114
  118. package/build/providers/hash_provider.js +28 -91
  119. package/build/providers/repl_provider.js +66 -152
  120. package/build/providers/vinejs_provider.d.ts +1 -1
  121. package/build/providers/vinejs_provider.js +19 -66
  122. package/build/repl-GSxgovJQ.js +5 -0
  123. package/build/services/ace.js +2 -17
  124. package/build/services/app.js +2 -21
  125. package/build/services/config.js +2 -13
  126. package/build/services/dumper.js +5 -21
  127. package/build/services/emitter.js +2 -14
  128. package/build/services/encryption.js +2 -14
  129. package/build/services/hash.js +2 -14
  130. package/build/services/logger.js +2 -14
  131. package/build/services/repl.js +2 -14
  132. package/build/services/router.js +2 -14
  133. package/build/services/server.js +2 -14
  134. package/build/services/test_utils.js +2 -17
  135. package/build/services/url_builder.d.ts +3 -3
  136. package/build/services/url_builder.js +5 -17
  137. package/build/src/assembler_hooks/index_entities.d.ts +29 -1
  138. package/build/src/debug.d.ts +1 -1
  139. package/build/src/exceptions.js +2 -49
  140. package/build/src/helpers/assert.js +2 -55
  141. package/build/src/helpers/http.d.ts +20 -0
  142. package/build/src/helpers/http.js +2 -0
  143. package/build/src/helpers/is.js +3 -31
  144. package/build/src/helpers/main.d.ts +1 -5
  145. package/build/src/helpers/main.js +5 -56
  146. package/build/src/helpers/string.js +2 -60
  147. package/build/src/helpers/types.js +26 -135
  148. package/build/src/helpers/verification_token.js +2 -120
  149. package/build/src/test_utils/main.js +8 -77
  150. package/build/src/types.d.ts +53 -99
  151. package/build/src/types.js +0 -8
  152. package/build/src/utils.d.ts +1 -1
  153. package/build/src/vine.js +2 -97
  154. package/build/string-Cx6q_win.js +28 -0
  155. package/build/test_utils-hkQDmNpX.js +10 -0
  156. package/build/toolkit/main.js +19 -21
  157. package/build/types/ace.js +2 -9
  158. package/build/types/app.js +2 -9
  159. package/build/types/bodyparser.js +2 -9
  160. package/build/types/common.js +2 -9
  161. package/build/types/container.js +2 -9
  162. package/build/types/encryption.d.ts +39 -1
  163. package/build/types/encryption.js +1 -9
  164. package/build/types/events.js +2 -9
  165. package/build/types/hash.js +2 -9
  166. package/build/types/health.js +2 -9
  167. package/build/types/helpers.d.ts +20 -0
  168. package/build/types/helpers.js +0 -8
  169. package/build/types/http.js +2 -9
  170. package/build/types/logger.js +2 -9
  171. package/build/types/repl.js +2 -9
  172. package/build/types/transformers.js +2 -9
  173. package/build/utils-CtGytdtt.js +42 -0
  174. package/build/verification_token-DrdoU4RH.js +46 -0
  175. package/build/vine-DGint2rk.js +32 -0
  176. package/package.json +113 -60
  177. package/build/modules/ace/commands.js +0 -157
  178. package/build/modules/ace/create_kernel.js +0 -91
  179. package/build/modules/ace/kernel.js +0 -40
  180. package/build/modules/dumper/define_config.js +0 -36
  181. package/build/modules/dumper/dumper.js +0 -256
  182. package/build/modules/dumper/errors.js +0 -119
  183. package/build/modules/encryption.d.ts +0 -1
  184. package/build/modules/encryption.js +0 -9
  185. package/build/modules/hash/define_config.js +0 -125
  186. package/build/modules/http/request_validator.js +0 -100
  187. package/build/src/assembler_hooks/index_entities.js +0 -107
  188. package/build/src/cli_formatters/routes_list.js +0 -381
  189. package/build/src/config_provider.js +0 -71
  190. package/build/src/debug.js +0 -25
  191. package/build/src/ignitor/ace.js +0 -102
  192. package/build/src/ignitor/http.js +0 -146
  193. package/build/src/ignitor/main.js +0 -124
  194. package/build/src/ignitor/test.js +0 -66
  195. package/build/src/test_utils/http.js +0 -82
  196. package/build/src/utils.js +0 -104
  197. package/build/stubs/main.js +0 -9
  198. package/build/toolkit/commands/index_commands.js +0 -30
  199. /package/build/{stubs/make → make}/command/main.stub +0 -0
  200. /package/build/{stubs/make → make}/controller/actions.stub +0 -0
  201. /package/build/{stubs/make → make}/controller/api.stub +0 -0
  202. /package/build/{stubs/make → make}/controller/main.stub +0 -0
  203. /package/build/{stubs/make → make}/controller/resource.stub +0 -0
  204. /package/build/{stubs/make → make}/event/main.stub +0 -0
  205. /package/build/{stubs/make → make}/exception/main.stub +0 -0
  206. /package/build/{stubs/make → make}/health/main.stub +0 -0
  207. /package/build/{stubs/make → make}/listener/for_event.stub +0 -0
  208. /package/build/{stubs/make → make}/listener/main.stub +0 -0
  209. /package/build/{stubs/make → make}/middleware/main.stub +0 -0
  210. /package/build/{stubs/make → make}/preload/main.stub +0 -0
  211. /package/build/{stubs/make → make}/provider/main.stub +0 -0
  212. /package/build/{stubs/make → make}/service/main.stub +0 -0
  213. /package/build/{stubs/make → make}/test/main.stub +0 -0
  214. /package/build/{stubs/make → make}/transformer/main.stub +0 -0
  215. /package/build/{stubs/make → make}/validator/main.stub +0 -0
  216. /package/build/{stubs/make → make}/validator/resource.stub +0 -0
  217. /package/build/{stubs/make → make}/view/main.stub +0 -0
@@ -1,178 +1,83 @@
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 stubsRoot } from "../main-kn40V-hF.js";
2
+ import { f as BaseCommand, l as flags, o as args } from "../main-BlJhxJJ2.js";
3
+ import { t as __decorate } from "../decorate-CJcHOoD-.js";
4
+ import { RuntimeException } from "@poppinss/utils/exception";
5
+ var Configure = class extends BaseCommand {
6
+ static commandName = "configure";
7
+ static description = "Configure a package after it has been installed";
8
+ static options = { allowUnknownFlags: true };
9
+ get parsedFlags() {
10
+ return this.parsed.flags;
11
+ }
12
+ get parsedArgs() {
13
+ return this.parsed._;
14
+ }
15
+ async #getPackageSource(packageName) {
16
+ try {
17
+ return await this.app.import(packageName);
18
+ } catch (error) {
19
+ if (error.code && error.code === "ERR_MODULE_NOT_FOUND" || error.message.startsWith("Cannot find module")) return null;
20
+ throw error;
21
+ }
22
+ }
23
+ async #configureVineJS() {
24
+ await (await this.createCodemods()).updateRcFile((rcFile) => {
25
+ rcFile.addProvider("@adonisjs/core/providers/vinejs_provider");
26
+ });
27
+ }
28
+ async #configureEdge() {
29
+ await (await this.createCodemods()).updateRcFile((rcFile) => {
30
+ rcFile.addProvider("@adonisjs/core/providers/edge_provider");
31
+ rcFile.addMetaFile("resources/views/**/*.edge", false);
32
+ });
33
+ }
34
+ async #configureHealthChecks() {
35
+ const codemods = await this.createCodemods();
36
+ await codemods.makeUsingStub(stubsRoot, "make/health/main.stub", {
37
+ flags: this.parsed.flags,
38
+ entity: this.app.generators.createEntity("health")
39
+ });
40
+ await codemods.makeUsingStub(stubsRoot, "make/health/controller.stub", {
41
+ flags: this.parsed.flags,
42
+ entity: this.app.generators.createEntity("health_checks")
43
+ });
44
+ }
45
+ async createCodemods() {
46
+ const codemods = await super.createCodemods();
47
+ codemods.overwriteExisting = this.force === true;
48
+ codemods.verboseInstallOutput = this.verbose === true;
49
+ return codemods;
50
+ }
51
+ async run() {
52
+ if (this.name === "vinejs") return this.#configureVineJS();
53
+ if (this.name === "edge") return this.#configureEdge();
54
+ if (this.name === "health_checks") return this.#configureHealthChecks();
55
+ const packageExports = await this.#getPackageSource(this.name);
56
+ if (!packageExports) {
57
+ this.logger.error(`Cannot find module "${this.name}". Make sure to install it`);
58
+ this.exitCode = 1;
59
+ return;
60
+ }
61
+ if (!packageExports.configure) {
62
+ this.logger.error(`Cannot configure module "${this.name}". The module does not export the configure hook`);
63
+ this.exitCode = 1;
64
+ return;
65
+ }
66
+ if (packageExports.stubsRoot) this.stubsRoot = packageExports.stubsRoot;
67
+ try {
68
+ await packageExports.configure(this);
69
+ } catch (error) {
70
+ throw new RuntimeException(`Unable to configure package "${this.name}"`, { cause: error });
71
+ }
72
+ }
14
73
  };
15
- import { RuntimeException } from '@poppinss/utils/exception';
16
- import { stubsRoot } from "../stubs/main.js";
17
- import { args, BaseCommand, flags } from "../modules/ace/main.js";
18
- /**
19
- * Command to configure packages after installation by running their configuration hooks.
20
- * Supports built-in configurations for VineJS, Edge, and health checks, or can execute
21
- * custom configure functions exported by packages.
22
- *
23
- * @example
24
- * ```
25
- * ace configure @adonisjs/lucid
26
- * ace configure vinejs
27
- * ace configure edge
28
- * ace configure health_checks
29
- * ace configure @adonisjs/auth --force --verbose
30
- * ```
31
- */
32
- export default class Configure extends BaseCommand {
33
- /**
34
- * The command name
35
- */
36
- static commandName = 'configure';
37
- /**
38
- * The command description
39
- */
40
- static description = 'Configure a package after it has been installed';
41
- /**
42
- * Command options configuration.
43
- * Allows unknown flags to be passed to package configure functions.
44
- */
45
- static options = {
46
- allowUnknownFlags: true,
47
- };
48
- /**
49
- * Expose all flags from the protected property "parsed" for access by package configure functions
50
- */
51
- get parsedFlags() {
52
- return this.parsed.flags;
53
- }
54
- /**
55
- * Expose all arguments from the protected property "parsed" for access by package configure functions
56
- */
57
- get parsedArgs() {
58
- return this.parsed._;
59
- }
60
- /**
61
- * Import and return the main exports of a package.
62
- * Returns null if the package is not found, rethrows other errors.
63
- *
64
- * @param packageName - The name of the package to import
65
- * @returns The package exports or null if not found
66
- */
67
- async #getPackageSource(packageName) {
68
- try {
69
- const packageExports = await this.app.import(packageName);
70
- return packageExports;
71
- }
72
- catch (error) {
73
- if ((error.code && error.code === 'ERR_MODULE_NOT_FOUND') ||
74
- error.message.startsWith('Cannot find module')) {
75
- return null;
76
- }
77
- throw error;
78
- }
79
- }
80
- /**
81
- * Configure VineJS validation library by registering its provider in the RC file
82
- */
83
- async #configureVineJS() {
84
- const codemods = await this.createCodemods();
85
- await codemods.updateRcFile((rcFile) => {
86
- rcFile.addProvider('@adonisjs/core/providers/vinejs_provider');
87
- });
88
- }
89
- /**
90
- * Configure Edge template engine by registering its provider and adding view meta files
91
- */
92
- async #configureEdge() {
93
- const codemods = await this.createCodemods();
94
- await codemods.updateRcFile((rcFile) => {
95
- rcFile.addProvider('@adonisjs/core/providers/edge_provider');
96
- rcFile.addMetaFile('resources/views/**/*.edge', false);
97
- });
98
- }
99
- /**
100
- * Configure health checks feature by generating the main health file and controller
101
- */
102
- async #configureHealthChecks() {
103
- const codemods = await this.createCodemods();
104
- await codemods.makeUsingStub(stubsRoot, 'make/health/main.stub', {
105
- flags: this.parsed.flags,
106
- entity: this.app.generators.createEntity('health'),
107
- });
108
- await codemods.makeUsingStub(stubsRoot, 'make/health/controller.stub', {
109
- flags: this.parsed.flags,
110
- entity: this.app.generators.createEntity('health_checks'),
111
- });
112
- }
113
- /**
114
- * Create a codemods instance configured with command options.
115
- * Sets overwrite and verbose flags based on command arguments.
116
- */
117
- async createCodemods() {
118
- const codemods = await super.createCodemods();
119
- codemods.overwriteExisting = this.force === true;
120
- codemods.verboseInstallOutput = this.verbose === true;
121
- return codemods;
122
- }
123
- /**
124
- * Execute the configure command. Handles built-in configurations for VineJS, Edge,
125
- * and health checks, or imports and executes the configure function from the specified package.
126
- */
127
- async run() {
128
- if (this.name === 'vinejs') {
129
- return this.#configureVineJS();
130
- }
131
- if (this.name === 'edge') {
132
- return this.#configureEdge();
133
- }
134
- if (this.name === 'health_checks') {
135
- return this.#configureHealthChecks();
136
- }
137
- const packageExports = await this.#getPackageSource(this.name);
138
- if (!packageExports) {
139
- this.logger.error(`Cannot find module "${this.name}". Make sure to install it`);
140
- this.exitCode = 1;
141
- return;
142
- }
143
- /**
144
- * Warn, there are not instructions to run
145
- */
146
- if (!packageExports.configure) {
147
- this.logger.error(`Cannot configure module "${this.name}". The module does not export the configure hook`);
148
- this.exitCode = 1;
149
- return;
150
- }
151
- /**
152
- * Set stubsRoot property when package exports it
153
- */
154
- if (packageExports.stubsRoot) {
155
- this.stubsRoot = packageExports.stubsRoot;
156
- }
157
- /**
158
- * Run instructions
159
- */
160
- try {
161
- await packageExports.configure(this);
162
- }
163
- catch (error) {
164
- throw new RuntimeException(`Unable to configure package "${this.name}"`, {
165
- cause: error,
166
- });
167
- }
168
- }
169
- }
170
- __decorate([
171
- args.string({ description: 'Package name' })
172
- ], Configure.prototype, "name", void 0);
173
- __decorate([
174
- flags.boolean({ description: 'Display logs in verbose mode', alias: 'v' })
175
- ], Configure.prototype, "verbose", void 0);
176
- __decorate([
177
- flags.boolean({ description: 'Forcefully overwrite existing files', alias: 'f' })
178
- ], Configure.prototype, "force", void 0);
74
+ __decorate([args.string({ description: "Package name" })], Configure.prototype, "name", void 0);
75
+ __decorate([flags.boolean({
76
+ description: "Display logs in verbose mode",
77
+ alias: "v"
78
+ })], Configure.prototype, "verbose", void 0);
79
+ __decorate([flags.boolean({
80
+ description: "Forcefully overwrite existing files",
81
+ alias: "f"
82
+ })], Configure.prototype, "force", void 0);
83
+ export { Configure as default };
@@ -1,61 +1,18 @@
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-Cx6q_win.js";
2
+ import { f as BaseCommand, l as flags, o as args } from "../main-BlJhxJJ2.js";
3
+ import { t as __decorate } from "../decorate-CJcHOoD-.js";
4
+ var Eject = class extends BaseCommand {
5
+ static commandName = "eject";
6
+ static description = "Eject scaffolding stubs to your application root";
7
+ async run() {
8
+ (await (await this.app.stubs.create()).copy(this.stubPath, { pkg: this.pkg })).forEach((stubPath) => {
9
+ this.logger.success(`eject ${string_default.toUnixSlash(this.app.relativePath(stubPath))}`);
10
+ });
11
+ }
14
12
  };
15
- import { args, BaseCommand, flags } from "../modules/ace/main.js";
16
- import stringHelpers from "../src/helpers/string.js";
17
- /**
18
- * Command to eject scaffolding stubs from packages to your application root.
19
- * This allows you to customize templates used by make commands and other
20
- * code generation features by copying them to your local application.
21
- *
22
- * @example
23
- * ```
24
- * ace eject make/controller
25
- * ace eject make/controller --pkg=@adonisjs/lucid
26
- * ace eject stubs/
27
- * ```
28
- */
29
- export default class Eject extends BaseCommand {
30
- /**
31
- * The command name
32
- */
33
- static commandName = 'eject';
34
- /**
35
- * The command description
36
- */
37
- static description = 'Eject scaffolding stubs to your application root';
38
- /**
39
- * Execute the command to eject stubs from the specified package.
40
- * Copies the stubs to the application root and logs success messages
41
- * for each ejected file.
42
- */
43
- async run() {
44
- const stubs = await this.app.stubs.create();
45
- const copied = await stubs.copy(this.stubPath, {
46
- pkg: this.pkg,
47
- });
48
- copied.forEach((stubPath) => {
49
- this.logger.success(`eject ${stringHelpers.toUnixSlash(this.app.relativePath(stubPath))}`);
50
- });
51
- }
52
- }
53
- __decorate([
54
- args.string({ description: 'Path to the stubs directory or a single stub file' })
55
- ], Eject.prototype, "stubPath", void 0);
56
- __decorate([
57
- flags.string({
58
- description: 'Mention package name for searching stubs',
59
- default: '@adonisjs/core',
60
- })
61
- ], Eject.prototype, "pkg", void 0);
13
+ __decorate([args.string({ description: "Path to the stubs directory or a single stub file" })], Eject.prototype, "stubPath", void 0);
14
+ __decorate([flags.string({
15
+ description: "Mention package name for searching stubs",
16
+ default: "@adonisjs/core"
17
+ })], Eject.prototype, "pkg", void 0);
18
+ export { Eject as default };
@@ -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-Cx6q_win.js";
2
+ import { f as BaseCommand, l as flags, o as args } from "../../main-BlJhxJJ2.js";
3
+ import { t as __decorate } from "../../decorate-CJcHOoD-.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-BlJhxJJ2.js";
2
+ import { t as __decorate } from "../decorate-CJcHOoD-.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 };