@adonisjs/core 7.0.0-next.9 → 7.0.1

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 (210) hide show
  1. package/README.md +62 -1
  2. package/build/chunk-iKc69rpz.js +26 -0
  3. package/build/commands/add.d.ts +4 -3
  4. package/build/commands/add.js +73 -110
  5. package/build/commands/build.js +51 -107
  6. package/build/commands/commands.json +1 -1
  7. package/build/commands/configure.js +81 -177
  8. package/build/commands/eject.js +17 -60
  9. package/build/commands/env/add.js +55 -134
  10. package/build/commands/generate_key.js +22 -66
  11. package/build/commands/inspect_rcfile.js +27 -55
  12. package/build/commands/list/routes.js +246 -116
  13. package/build/commands/make/command.d.ts +5 -0
  14. package/build/commands/make/command.js +16 -57
  15. package/build/commands/make/controller.d.ts +5 -0
  16. package/build/commands/make/controller.js +44 -120
  17. package/build/commands/make/event.d.ts +5 -0
  18. package/build/commands/make/event.js +17 -62
  19. package/build/commands/make/exception.d.ts +5 -0
  20. package/build/commands/make/exception.js +17 -62
  21. package/build/commands/make/listener.d.ts +5 -0
  22. package/build/commands/make/listener.js +37 -93
  23. package/build/commands/make/middleware.d.ts +5 -0
  24. package/build/commands/make/middleware.js +42 -101
  25. package/build/commands/make/preload.d.ts +5 -0
  26. package/build/commands/make/preload.js +48 -113
  27. package/build/commands/make/provider.d.ts +5 -0
  28. package/build/commands/make/provider.js +48 -112
  29. package/build/commands/make/service.d.ts +5 -0
  30. package/build/commands/make/service.js +17 -55
  31. package/build/commands/make/test.d.ts +5 -0
  32. package/build/commands/make/test.js +48 -132
  33. package/build/commands/make/transformer.d.ts +5 -0
  34. package/build/commands/make/transformer.js +18 -64
  35. package/build/commands/make/validator.d.ts +5 -0
  36. package/build/commands/make/validator.js +21 -80
  37. package/build/commands/make/view.d.ts +5 -0
  38. package/build/commands/make/view.js +16 -56
  39. package/build/commands/repl.js +17 -50
  40. package/build/commands/serve.js +80 -150
  41. package/build/commands/test.js +92 -202
  42. package/build/config_provider-FIAUgvae.js +13 -0
  43. package/build/core-IpCOCkUL.js +146 -0
  44. package/build/create_kernel-B7ILNhuP.js +38 -0
  45. package/build/create_kernel-BD0Iqi8e.js +3 -0
  46. package/build/debug-CGQmxzGt.js +3 -0
  47. package/build/decorate-DmrZA614.js +7 -0
  48. package/build/define_config-0oHaj43l.js +86 -0
  49. package/build/dumper-BBgqFX5a.js +147 -0
  50. package/build/errors-CrCO-k44.js +8 -0
  51. package/build/factories/app.js +2 -9
  52. package/build/factories/bodyparser.js +2 -9
  53. package/build/factories/core/ace.js +22 -45
  54. package/build/factories/core/ignitor.js +74 -180
  55. package/build/factories/core/main.js +18 -11
  56. package/build/factories/core/test_utils.js +19 -42
  57. package/build/factories/encryption.d.ts +1 -1
  58. package/build/factories/encryption.js +2 -9
  59. package/build/factories/events.js +2 -9
  60. package/build/factories/hash.js +2 -9
  61. package/build/factories/http.js +2 -9
  62. package/build/factories/logger.js +2 -9
  63. package/build/factories/stubs.d.ts +1 -6
  64. package/build/factories/stubs.js +24 -91
  65. package/build/index.d.ts +1 -1
  66. package/build/index.js +10 -46
  67. package/build/main--nXd7T-C.js +73 -0
  68. package/build/main-Cxz0TyIw.js +173 -0
  69. package/build/main-DN2qEEg5.js +41 -0
  70. package/build/main-DkNgvceD.js +52 -0
  71. package/build/main-MBAMnmJb.js +81 -0
  72. package/build/main-kn40V-hF.js +2 -0
  73. package/build/{stubs/make → make}/health/controller.stub +5 -2
  74. package/build/modules/ace/codemods.d.ts +75 -23
  75. package/build/modules/ace/codemods.js +291 -476
  76. package/build/modules/ace/main.js +2 -41
  77. package/build/modules/app.js +6 -26
  78. package/build/modules/bodyparser/bodyparser_middleware.js +3 -14
  79. package/build/modules/bodyparser/main.js +6 -9
  80. package/build/modules/config.js +6 -26
  81. package/build/modules/container.js +6 -9
  82. package/build/modules/dumper/main.js +6 -32
  83. package/build/modules/dumper/plugins/edge.js +46 -61
  84. package/build/modules/encryption/define_config.d.ts +161 -0
  85. package/build/modules/encryption/drivers/aes_256_cbc.d.ts +20 -0
  86. package/build/modules/encryption/drivers/aes_256_cbc.js +2 -0
  87. package/build/modules/encryption/drivers/aes_256_gcm.d.ts +21 -0
  88. package/build/modules/encryption/drivers/aes_256_gcm.js +2 -0
  89. package/build/modules/encryption/drivers/aes_siv.d.ts +19 -0
  90. package/build/modules/encryption/drivers/aes_siv.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/drivers/legacy.d.ts +84 -0
  94. package/build/modules/encryption/drivers/legacy.js +57 -0
  95. package/build/modules/encryption/errors.d.ts +16 -0
  96. package/build/modules/encryption/main.d.ts +89 -0
  97. package/build/modules/encryption/main.js +6 -0
  98. package/build/modules/env/editor.js +2 -9
  99. package/build/modules/env/main.js +2 -28
  100. package/build/modules/events.js +6 -9
  101. package/build/modules/hash/drivers/argon.js +2 -9
  102. package/build/modules/hash/drivers/bcrypt.js +2 -20
  103. package/build/modules/hash/drivers/scrypt.js +2 -9
  104. package/build/modules/hash/main.js +6 -28
  105. package/build/modules/hash/phc_formatter.js +2 -9
  106. package/build/modules/health.js +2 -9
  107. package/build/modules/http/helpers.d.ts +1 -0
  108. package/build/modules/http/helpers.js +2 -0
  109. package/build/modules/http/main.js +4 -15
  110. package/build/modules/http/request_validator.d.ts +3 -4
  111. package/build/modules/http/url_builder_client.js +2 -9
  112. package/build/modules/logger.d.ts +30 -0
  113. package/build/modules/logger.js +14 -9
  114. package/build/modules/repl.js +6 -9
  115. package/build/modules/transformers/main.js +2 -9
  116. package/build/providers/app_provider.d.ts +5 -13
  117. package/build/providers/app_provider.js +153 -359
  118. package/build/providers/edge_provider.js +98 -164
  119. package/build/providers/hash_provider.js +29 -91
  120. package/build/providers/repl_provider.js +66 -152
  121. package/build/providers/vinejs_provider.d.ts +1 -1
  122. package/build/providers/vinejs_provider.js +21 -65
  123. package/build/services/ace.js +1 -16
  124. package/build/services/app.js +3 -19
  125. package/build/services/config.js +1 -12
  126. package/build/services/dumper.js +4 -20
  127. package/build/services/emitter.js +1 -13
  128. package/build/services/encryption.js +1 -13
  129. package/build/services/hash.js +1 -13
  130. package/build/services/logger.js +1 -13
  131. package/build/services/repl.js +1 -13
  132. package/build/services/router.js +1 -13
  133. package/build/services/server.js +1 -13
  134. package/build/services/test_utils.js +1 -16
  135. package/build/services/url_builder.d.ts +3 -3
  136. package/build/services/url_builder.js +4 -16
  137. package/build/src/assembler_hooks/index_entities.d.ts +34 -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.js +2 -28
  142. package/build/src/helpers/is.js +3 -31
  143. package/build/src/helpers/main.js +5 -52
  144. package/build/src/helpers/string.js +26 -76
  145. package/build/src/helpers/types.js +25 -134
  146. package/build/src/helpers/verification_token.js +46 -120
  147. package/build/src/test_utils/main.js +8 -77
  148. package/build/src/types.d.ts +53 -99
  149. package/build/src/types.js +0 -8
  150. package/build/src/utils.d.ts +1 -1
  151. package/build/src/vine.js +29 -101
  152. package/build/toolkit/main.js +19 -21
  153. package/build/types/ace.js +2 -9
  154. package/build/types/app.js +2 -9
  155. package/build/types/bodyparser.js +2 -9
  156. package/build/types/common.js +2 -9
  157. package/build/types/container.js +2 -9
  158. package/build/types/encryption.d.ts +53 -1
  159. package/build/types/encryption.js +1 -9
  160. package/build/types/events.js +2 -9
  161. package/build/types/hash.js +2 -9
  162. package/build/types/health.js +2 -9
  163. package/build/types/helpers.js +0 -8
  164. package/build/types/http.js +2 -9
  165. package/build/types/logger.js +2 -9
  166. package/build/types/repl.js +2 -9
  167. package/build/types/transformers.js +2 -9
  168. package/build/utils-rRkbAPnP.js +42 -0
  169. package/package.json +117 -62
  170. package/build/modules/ace/commands.js +0 -157
  171. package/build/modules/ace/create_kernel.js +0 -91
  172. package/build/modules/ace/kernel.js +0 -40
  173. package/build/modules/dumper/define_config.js +0 -36
  174. package/build/modules/dumper/dumper.js +0 -266
  175. package/build/modules/dumper/errors.js +0 -119
  176. package/build/modules/encryption.d.ts +0 -18
  177. package/build/modules/encryption.js +0 -26
  178. package/build/modules/hash/define_config.js +0 -125
  179. package/build/modules/http/request_validator.js +0 -100
  180. package/build/src/assembler_hooks/index_entities.js +0 -112
  181. package/build/src/cli_formatters/routes_list.js +0 -397
  182. package/build/src/config_provider.js +0 -71
  183. package/build/src/debug.js +0 -25
  184. package/build/src/ignitor/ace.js +0 -102
  185. package/build/src/ignitor/http.js +0 -159
  186. package/build/src/ignitor/main.js +0 -124
  187. package/build/src/ignitor/test.js +0 -66
  188. package/build/src/test_utils/http.js +0 -82
  189. package/build/src/utils.js +0 -114
  190. package/build/stubs/main.js +0 -9
  191. package/build/toolkit/commands/index_commands.js +0 -30
  192. /package/build/{stubs/make → make}/command/main.stub +0 -0
  193. /package/build/{stubs/make → make}/controller/actions.stub +0 -0
  194. /package/build/{stubs/make → make}/controller/api.stub +0 -0
  195. /package/build/{stubs/make → make}/controller/main.stub +0 -0
  196. /package/build/{stubs/make → make}/controller/resource.stub +0 -0
  197. /package/build/{stubs/make → make}/event/main.stub +0 -0
  198. /package/build/{stubs/make → make}/exception/main.stub +0 -0
  199. /package/build/{stubs/make → make}/health/main.stub +0 -0
  200. /package/build/{stubs/make → make}/listener/for_event.stub +0 -0
  201. /package/build/{stubs/make → make}/listener/main.stub +0 -0
  202. /package/build/{stubs/make → make}/middleware/main.stub +0 -0
  203. /package/build/{stubs/make → make}/preload/main.stub +0 -0
  204. /package/build/{stubs/make → make}/provider/main.stub +0 -0
  205. /package/build/{stubs/make → make}/service/main.stub +0 -0
  206. /package/build/{stubs/make → make}/test/main.stub +0 -0
  207. /package/build/{stubs/make → make}/transformer/main.stub +0 -0
  208. /package/build/{stubs/make → make}/validator/main.stub +0 -0
  209. /package/build/{stubs/make → make}/validator/resource.stub +0 -0
  210. /package/build/{stubs/make → make}/view/main.stub +0 -0
@@ -1,151 +1,81 @@
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 importAssembler } from "../utils-rRkbAPnP.js";
2
+ import { f as BaseCommand, l as flags } from "../main-MBAMnmJb.js";
3
+ import { t as __decorate } from "../decorate-DmrZA614.js";
4
+ var Serve = class extends BaseCommand {
5
+ static commandName = "serve";
6
+ static description = "Start the development HTTP server along with the file watcher to perform restarts on file change";
7
+ static help = [
8
+ "Start the development server with file watcher using the following command.",
9
+ "```",
10
+ "{{ binaryName }} serve --watch",
11
+ "```",
12
+ "",
13
+ "You can also start the server with HMR support using the following command.",
14
+ "```",
15
+ "{{ binaryName }} serve --hmr",
16
+ "```",
17
+ "",
18
+ "The assets bundler dev server runs automatically after detecting vite config or webpack config files",
19
+ "You may pass vite CLI args using the --assets-args command line flag.",
20
+ "```",
21
+ "{{ binaryName }} serve --assets-args=\"--debug --base=/public\"",
22
+ "```"
23
+ ];
24
+ static options = { staysAlive: true };
25
+ #logMissingDevelopmentDependency(dependency) {
26
+ this.logger.error([
27
+ `Cannot find package "${dependency}"`,
28
+ "",
29
+ `The "${dependency}" package is a development dependency and therefore you should use the serve command during development only.`,
30
+ "",
31
+ "If you are running your application in production, then use \"node bin/server.js\" command to start the HTTP server"
32
+ ].join("\n"));
33
+ }
34
+ async run() {
35
+ const assembler = await importAssembler(this.app);
36
+ if (!assembler) {
37
+ this.#logMissingDevelopmentDependency("@adonisjs/assembler");
38
+ this.exitCode = 1;
39
+ return;
40
+ }
41
+ if (this.watch && this.hmr) {
42
+ this.logger.error("Cannot use --watch and --hmr flags together. Choose one of them");
43
+ this.exitCode = 1;
44
+ return;
45
+ }
46
+ this.devServer = new assembler.DevServer(this.app.appRoot, {
47
+ hmr: this.hmr === true ? true : false,
48
+ clearScreen: this.clear === false ? false : true,
49
+ nodeArgs: this.parsed.nodeArgs,
50
+ scriptArgs: [],
51
+ metaFiles: this.app.rcFile.metaFiles,
52
+ hooks: this.app.rcFile.hooks
53
+ });
54
+ this.devServer.ui.logger = this.logger;
55
+ this.devServer.onClose((exitCode) => {
56
+ this.exitCode = exitCode;
57
+ this.terminate();
58
+ });
59
+ this.devServer.onError(() => {
60
+ this.exitCode = 1;
61
+ this.terminate();
62
+ });
63
+ if (this.watch) await this.devServer.startAndWatch({ poll: this.poll || false });
64
+ else await this.devServer.start();
65
+ }
14
66
  };
15
- import { importAssembler } from "../src/utils.js";
16
- import { BaseCommand, flags } from "../modules/ace/main.js";
17
- /**
18
- * Serve command is used to run the AdonisJS HTTP server during development. The
19
- * command under the hood runs the "bin/server.ts" file and watches for file
20
- * system changes
21
- *
22
- * @example
23
- * ```
24
- * ace serve
25
- * ace serve --watch
26
- * ace serve --hmr
27
- * ace serve --poll
28
- * ace serve --no-clear
29
- * ```
30
- */
31
- export default class Serve extends BaseCommand {
32
- /**
33
- * The command name
34
- */
35
- static commandName = 'serve';
36
- /**
37
- * The command description
38
- */
39
- static description = 'Start the development HTTP server along with the file watcher to perform restarts on file change';
40
- /**
41
- * Help text for the command
42
- */
43
- static help = [
44
- 'Start the development server with file watcher using the following command.',
45
- '```',
46
- '{{ binaryName }} serve --watch',
47
- '```',
48
- '',
49
- 'You can also start the server with HMR support using the following command.',
50
- '```',
51
- '{{ binaryName }} serve --hmr',
52
- '```',
53
- '',
54
- 'The assets bundler dev server runs automatically after detecting vite config or webpack config files',
55
- 'You may pass vite CLI args using the --assets-args command line flag.',
56
- '```',
57
- '{{ binaryName }} serve --assets-args="--debug --base=/public"',
58
- '```',
59
- ];
60
- /**
61
- * Command options configuration
62
- */
63
- static options = {
64
- staysAlive: true,
65
- };
66
- /**
67
- * Log a development dependency is missing
68
- *
69
- * @param dependency - The name of the missing dependency
70
- */
71
- #logMissingDevelopmentDependency(dependency) {
72
- this.logger.error([
73
- `Cannot find package "${dependency}"`,
74
- '',
75
- `The "${dependency}" package is a development dependency and therefore you should use the serve command during development only.`,
76
- '',
77
- 'If you are running your application in production, then use "node bin/server.js" command to start the HTTP server',
78
- ].join('\n'));
79
- }
80
- /**
81
- * Runs the HTTP server
82
- */
83
- async run() {
84
- const assembler = await importAssembler(this.app);
85
- if (!assembler) {
86
- this.#logMissingDevelopmentDependency('@adonisjs/assembler');
87
- this.exitCode = 1;
88
- return;
89
- }
90
- if (this.watch && this.hmr) {
91
- this.logger.error('Cannot use --watch and --hmr flags together. Choose one of them');
92
- this.exitCode = 1;
93
- return;
94
- }
95
- this.devServer = new assembler.DevServer(this.app.appRoot, {
96
- hmr: this.hmr === true ? true : false,
97
- clearScreen: this.clear === false ? false : true,
98
- nodeArgs: this.parsed.nodeArgs,
99
- scriptArgs: [],
100
- metaFiles: this.app.rcFile.metaFiles,
101
- hooks: this.app.rcFile.hooks,
102
- });
103
- /**
104
- * Share command logger with assembler, so that CLI flags like --no-ansi has
105
- * similar impact for assembler logs as well.
106
- */
107
- this.devServer.ui.logger = this.logger;
108
- /**
109
- * Exit command when the dev server is closed
110
- */
111
- this.devServer.onClose((exitCode) => {
112
- this.exitCode = exitCode;
113
- this.terminate();
114
- });
115
- /**
116
- * Exit command when the dev server crashes
117
- */
118
- this.devServer.onError(() => {
119
- this.exitCode = 1;
120
- this.terminate();
121
- });
122
- /**
123
- * Start the development server
124
- */
125
- if (this.watch) {
126
- await this.devServer.startAndWatch({ poll: this.poll || false });
127
- }
128
- else {
129
- await this.devServer.start();
130
- }
131
- }
132
- }
133
- __decorate([
134
- flags.boolean({ description: 'Start the server with HMR support' })
135
- ], Serve.prototype, "hmr", void 0);
136
- __decorate([
137
- flags.boolean({
138
- description: 'Watch filesystem and restart the HTTP server on file change',
139
- alias: 'w',
140
- })
141
- ], Serve.prototype, "watch", void 0);
142
- __decorate([
143
- flags.boolean({ description: 'Use polling to detect filesystem changes', alias: 'p' })
144
- ], Serve.prototype, "poll", void 0);
145
- __decorate([
146
- flags.boolean({
147
- description: 'Clear the terminal for new logs after file change',
148
- showNegatedVariantInHelp: true,
149
- default: true,
150
- })
151
- ], Serve.prototype, "clear", void 0);
67
+ __decorate([flags.boolean({ description: "Start the server with HMR support" })], Serve.prototype, "hmr", void 0);
68
+ __decorate([flags.boolean({
69
+ description: "Watch filesystem and restart the HTTP server on file change",
70
+ alias: "w"
71
+ })], Serve.prototype, "watch", void 0);
72
+ __decorate([flags.boolean({
73
+ description: "Use polling to detect filesystem changes",
74
+ alias: "p"
75
+ })], Serve.prototype, "poll", void 0);
76
+ __decorate([flags.boolean({
77
+ description: "Clear the terminal for new logs after file change",
78
+ showNegatedVariantInHelp: true,
79
+ default: true
80
+ })], Serve.prototype, "clear", void 0);
81
+ export { Serve as default };
@@ -1,203 +1,93 @@
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 importAssembler } from "../utils-rRkbAPnP.js";
2
+ import { f as BaseCommand, l as flags, o as args } from "../main-MBAMnmJb.js";
3
+ import { t as __decorate } from "../decorate-DmrZA614.js";
4
+ var Test = class extends BaseCommand {
5
+ static commandName = "test";
6
+ static description = "Run tests along with the file watcher to re-run tests on file change";
7
+ static options = {
8
+ allowUnknownFlags: true,
9
+ staysAlive: true
10
+ };
11
+ #logMissingDevelopmentDependency(dependency) {
12
+ this.logger.error([
13
+ `Cannot find package "${dependency}"`,
14
+ "",
15
+ `The "${dependency}" package is a development dependency and therefore you should run tests with development dependencies installed.`,
16
+ "",
17
+ "If you are run tests inside a CI, make sure the NODE_ENV is set to \"development\""
18
+ ].join("\n"));
19
+ }
20
+ #getPassthroughFlags() {
21
+ return this.parsed.unknownFlags.map((flag) => {
22
+ const value = this.parsed.flags[flag];
23
+ if (value === true) return [`--${flag}`];
24
+ if (Array.isArray(value)) return value.map((v) => [`--${flag}`, v]);
25
+ return [`--${flag}`, value];
26
+ }).flat(2);
27
+ }
28
+ async run() {
29
+ process.env.NODE_ENV = "test";
30
+ const assembler = await importAssembler(this.app);
31
+ if (!assembler) {
32
+ this.#logMissingDevelopmentDependency("@adonisjs/assembler");
33
+ this.exitCode = 1;
34
+ return;
35
+ }
36
+ this.testsRunner = new assembler.TestRunner(this.app.appRoot, {
37
+ clearScreen: this.clear === false ? false : true,
38
+ nodeArgs: this.parsed.nodeArgs,
39
+ scriptArgs: this.#getPassthroughFlags(),
40
+ filters: {
41
+ suites: this.suites,
42
+ files: this.files,
43
+ groups: this.groups,
44
+ tags: this.tags,
45
+ tests: this.tests
46
+ },
47
+ failed: this.failed,
48
+ retries: this.retries,
49
+ timeout: this.timeout,
50
+ reporters: this.reporters,
51
+ suites: this.app.rcFile.tests.suites.map((suite) => {
52
+ return {
53
+ name: suite.name,
54
+ files: suite.files
55
+ };
56
+ }),
57
+ env: { NODE_ENV: "test" },
58
+ hooks: this.app.rcFile.hooks,
59
+ metaFiles: this.app.rcFile.metaFiles
60
+ });
61
+ this.testsRunner.ui.logger = this.logger;
62
+ this.testsRunner.onClose((exitCode) => {
63
+ this.exitCode = exitCode;
64
+ this.terminate();
65
+ });
66
+ this.testsRunner.onError(() => {
67
+ this.exitCode = 1;
68
+ this.terminate();
69
+ });
70
+ if (this.watch) await this.testsRunner.runAndWatch({ poll: this.poll || false });
71
+ else await this.testsRunner.run();
72
+ }
14
73
  };
15
- import { importAssembler } from "../src/utils.js";
16
- import { BaseCommand, flags, args } from "../modules/ace/main.js";
17
- /**
18
- * Command to run application tests using the Japa test runner.
19
- * Supports filtering tests by suites, files, tags, groups, and individual tests.
20
- * Can run in watch mode to automatically re-run tests when files change.
21
- *
22
- * @example
23
- * ```
24
- * ace test
25
- * ace test unit integration
26
- * ace test --watch
27
- * ace test --files=user.spec.ts
28
- * ace test --tags=slow --groups="User tests"
29
- * ace test --reporters=spec,dot
30
- * ace test --timeout=5000 --retries=2
31
- * ```
32
- */
33
- export default class Test extends BaseCommand {
34
- /**
35
- * The command name
36
- */
37
- static commandName = 'test';
38
- /**
39
- * The command description
40
- */
41
- static description = 'Run tests along with the file watcher to re-run tests on file change';
42
- /**
43
- * Command options configuration.
44
- * Allows unknown flags to be passed to Japa and keeps the process alive.
45
- */
46
- static options = {
47
- allowUnknownFlags: true,
48
- staysAlive: true,
49
- };
50
- /**
51
- * Log an error message when a required development dependency is missing.
52
- * Provides helpful instructions for resolving the issue.
53
- *
54
- * @param dependency - The name of the missing dependency package
55
- */
56
- #logMissingDevelopmentDependency(dependency) {
57
- this.logger.error([
58
- `Cannot find package "${dependency}"`,
59
- '',
60
- `The "${dependency}" package is a development dependency and therefore you should run tests with development dependencies installed.`,
61
- '',
62
- 'If you are run tests inside a CI, make sure the NODE_ENV is set to "development"',
63
- ].join('\n'));
64
- }
65
- /**
66
- * Collect unknown flags and format them to pass to the Japa test runner.
67
- * Handles boolean flags, arrays, and single values appropriately.
68
- *
69
- * @returns Array of formatted command-line arguments for Japa
70
- */
71
- #getPassthroughFlags() {
72
- return this.parsed.unknownFlags
73
- .map((flag) => {
74
- const value = this.parsed.flags[flag];
75
- /**
76
- * Not mentioning value when value is "true"
77
- */
78
- if (value === true) {
79
- return [`--${flag}`];
80
- }
81
- /**
82
- * Repeating flag multiple times when value is an array
83
- */
84
- if (Array.isArray(value)) {
85
- return value.map((v) => [`--${flag}`, v]);
86
- }
87
- return [`--${flag}`, value];
88
- })
89
- .flat(2);
90
- }
91
- /**
92
- * Execute the test command. Sets up the test runner with all configured options
93
- * and filters, then runs tests either once or in watch mode. Handles missing
94
- * dependencies and properly configures the test environment.
95
- */
96
- async run() {
97
- process.env.NODE_ENV = 'test';
98
- const assembler = await importAssembler(this.app);
99
- if (!assembler) {
100
- this.#logMissingDevelopmentDependency('@adonisjs/assembler');
101
- this.exitCode = 1;
102
- return;
103
- }
104
- this.testsRunner = new assembler.TestRunner(this.app.appRoot, {
105
- clearScreen: this.clear === false ? false : true,
106
- nodeArgs: this.parsed.nodeArgs,
107
- scriptArgs: this.#getPassthroughFlags(),
108
- filters: {
109
- suites: this.suites,
110
- files: this.files,
111
- groups: this.groups,
112
- tags: this.tags,
113
- tests: this.tests,
114
- },
115
- failed: this.failed,
116
- retries: this.retries,
117
- timeout: this.timeout,
118
- reporters: this.reporters,
119
- suites: this.app.rcFile.tests.suites.map((suite) => {
120
- return {
121
- name: suite.name,
122
- files: suite.files,
123
- };
124
- }),
125
- env: {
126
- NODE_ENV: 'test',
127
- },
128
- hooks: this.app.rcFile.hooks,
129
- metaFiles: this.app.rcFile.metaFiles,
130
- });
131
- /**
132
- * Share command logger with assembler, so that CLI flags like --no-ansi has
133
- * similar impact for assembler logs as well.
134
- */
135
- this.testsRunner.ui.logger = this.logger;
136
- /**
137
- * Exit command when the test runner is closed
138
- */
139
- this.testsRunner.onClose((exitCode) => {
140
- this.exitCode = exitCode;
141
- this.terminate();
142
- });
143
- /**
144
- * Exit command when the dev server crashes
145
- */
146
- this.testsRunner.onError(() => {
147
- this.exitCode = 1;
148
- this.terminate();
149
- });
150
- /**
151
- * Start the test runner in watch mode
152
- */
153
- if (this.watch) {
154
- await this.testsRunner.runAndWatch({ poll: this.poll || false });
155
- }
156
- else {
157
- await this.testsRunner.run();
158
- }
159
- }
160
- }
161
- __decorate([
162
- args.spread({
163
- description: 'Mention suite names to run tests for selected suites',
164
- required: false,
165
- })
166
- ], Test.prototype, "suites", void 0);
167
- __decorate([
168
- flags.array({ description: 'Filter tests by the filename' })
169
- ], Test.prototype, "files", void 0);
170
- __decorate([
171
- flags.array({ description: 'Filter tests by tags' })
172
- ], Test.prototype, "tags", void 0);
173
- __decorate([
174
- flags.array({ description: 'Filter tests by parent group title' })
175
- ], Test.prototype, "groups", void 0);
176
- __decorate([
177
- flags.array({ description: 'Filter tests by test title' })
178
- ], Test.prototype, "tests", void 0);
179
- __decorate([
180
- flags.array({ description: 'Activate one or more test reporters' })
181
- ], Test.prototype, "reporters", void 0);
182
- __decorate([
183
- flags.boolean({ description: 'Watch filesystem and re-run tests on file change' })
184
- ], Test.prototype, "watch", void 0);
185
- __decorate([
186
- flags.boolean({ description: 'Use polling to detect filesystem changes' })
187
- ], Test.prototype, "poll", void 0);
188
- __decorate([
189
- flags.number({ description: 'Define default timeout for all tests' })
190
- ], Test.prototype, "timeout", void 0);
191
- __decorate([
192
- flags.number({ description: 'Define default retries for all tests' })
193
- ], Test.prototype, "retries", void 0);
194
- __decorate([
195
- flags.boolean({ description: 'Execute tests failed during the last run' })
196
- ], Test.prototype, "failed", void 0);
197
- __decorate([
198
- flags.boolean({
199
- description: 'Clear the terminal for new logs after file change',
200
- showNegatedVariantInHelp: true,
201
- default: true,
202
- })
203
- ], Test.prototype, "clear", void 0);
74
+ __decorate([args.spread({
75
+ description: "Mention suite names to run tests for selected suites",
76
+ required: false
77
+ })], Test.prototype, "suites", void 0);
78
+ __decorate([flags.array({ description: "Filter tests by the filename" })], Test.prototype, "files", void 0);
79
+ __decorate([flags.array({ description: "Filter tests by tags" })], Test.prototype, "tags", void 0);
80
+ __decorate([flags.array({ description: "Filter tests by parent group title" })], Test.prototype, "groups", void 0);
81
+ __decorate([flags.array({ description: "Filter tests by test title" })], Test.prototype, "tests", void 0);
82
+ __decorate([flags.array({ description: "Activate one or more test reporters" })], Test.prototype, "reporters", void 0);
83
+ __decorate([flags.boolean({ description: "Watch filesystem and re-run tests on file change" })], Test.prototype, "watch", void 0);
84
+ __decorate([flags.boolean({ description: "Use polling to detect filesystem changes" })], Test.prototype, "poll", void 0);
85
+ __decorate([flags.number({ description: "Define default timeout for all tests" })], Test.prototype, "timeout", void 0);
86
+ __decorate([flags.number({ description: "Define default retries for all tests" })], Test.prototype, "retries", void 0);
87
+ __decorate([flags.boolean({ description: "Execute tests failed during the last run" })], Test.prototype, "failed", void 0);
88
+ __decorate([flags.boolean({
89
+ description: "Clear the terminal for new logs after file change",
90
+ showNegatedVariantInHelp: true,
91
+ default: true
92
+ })], Test.prototype, "clear", void 0);
93
+ export { Test as default };
@@ -0,0 +1,13 @@
1
+ const configProvider = {
2
+ create(resolver) {
3
+ return {
4
+ type: "provider",
5
+ resolver
6
+ };
7
+ },
8
+ async resolve(app, provider) {
9
+ if (provider && typeof provider === "object" && "type" in provider) return provider.resolver(app);
10
+ return null;
11
+ }
12
+ };
13
+ export { configProvider as t };