@adonisjs/core 5.9.0 → 6.0.1-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. package/README.md +6 -15
  2. package/build/commands/commands.json +1 -0
  3. package/build/commands/eject.d.ts +8 -0
  4. package/build/commands/eject.js +34 -0
  5. package/build/commands/{GenerateKey.d.ts → generate_key.d.ts} +3 -4
  6. package/build/commands/generate_key.js +47 -0
  7. package/build/commands/main.js +36 -0
  8. package/build/commands/make/_base.d.ts +6 -0
  9. package/build/commands/make/_base.js +19 -0
  10. package/build/commands/make/command.d.ts +8 -0
  11. package/build/commands/make/command.js +25 -0
  12. package/build/commands/make/controller.d.ts +12 -0
  13. package/build/commands/make/controller.js +57 -0
  14. package/build/commands/make/event.d.ts +8 -0
  15. package/build/commands/make/event.js +25 -0
  16. package/build/commands/make/listener.d.ts +10 -0
  17. package/build/commands/make/listener.js +48 -0
  18. package/build/commands/make/middleware.d.ts +8 -0
  19. package/build/commands/make/middleware.js +25 -0
  20. package/build/commands/make/provider.d.ts +8 -0
  21. package/build/commands/make/provider.js +25 -0
  22. package/build/factories/app.d.ts +1 -0
  23. package/build/factories/app.js +1 -0
  24. package/build/factories/bodyparser.d.ts +1 -0
  25. package/build/factories/bodyparser.js +1 -0
  26. package/build/factories/core/ace.d.ts +8 -0
  27. package/build/factories/core/ace.js +19 -0
  28. package/build/factories/core/ignitor.d.ts +16 -0
  29. package/build/factories/core/ignitor.js +76 -0
  30. package/build/factories/core/main.d.ts +4 -0
  31. package/build/factories/core/main.js +4 -0
  32. package/build/factories/core/test_utils.d.ts +8 -0
  33. package/build/factories/core/test_utils.js +15 -0
  34. package/build/factories/encryption.d.ts +1 -0
  35. package/build/factories/encryption.js +1 -0
  36. package/build/factories/events.d.ts +1 -0
  37. package/build/factories/events.js +1 -0
  38. package/build/factories/hash.d.ts +1 -0
  39. package/build/factories/hash.js +1 -0
  40. package/build/factories/http.d.ts +1 -0
  41. package/build/factories/http.js +1 -0
  42. package/build/factories/logger.d.ts +1 -0
  43. package/build/factories/logger.js +1 -0
  44. package/build/factories/stubs.d.ts +15 -0
  45. package/build/factories/stubs.js +20 -0
  46. package/build/index.d.ts +140 -0
  47. package/build/index.js +21 -0
  48. package/build/legacy/validator.d.ts +1 -0
  49. package/build/legacy/validator.js +1 -0
  50. package/build/modules/ace/commands.d.ts +26 -0
  51. package/build/modules/ace/commands.js +63 -0
  52. package/build/modules/ace/create_kernel.d.ts +3 -0
  53. package/build/modules/ace/create_kernel.js +33 -0
  54. package/build/modules/ace/kernel.d.ts +7 -0
  55. package/build/modules/ace/kernel.js +14 -0
  56. package/build/modules/ace/main.d.ts +3 -0
  57. package/build/modules/ace/main.js +3 -0
  58. package/build/modules/app.d.ts +1 -0
  59. package/build/modules/app.js +1 -0
  60. package/build/modules/bodyparser/bodyparser_middleware.d.ts +2 -0
  61. package/build/modules/bodyparser/bodyparser_middleware.js +2 -0
  62. package/build/modules/bodyparser/main.d.ts +1 -0
  63. package/build/modules/bodyparser/main.js +1 -0
  64. package/build/modules/config.d.ts +1 -0
  65. package/build/modules/config.js +1 -0
  66. package/build/modules/container.d.ts +1 -0
  67. package/build/modules/container.js +1 -0
  68. package/build/modules/encryption.d.ts +1 -0
  69. package/build/modules/encryption.js +1 -0
  70. package/build/modules/env.d.ts +1 -0
  71. package/build/modules/env.js +1 -0
  72. package/build/modules/events.d.ts +1 -0
  73. package/build/modules/events.js +1 -0
  74. package/build/modules/hash/define_config.d.ts +15 -0
  75. package/build/modules/hash/define_config.js +19 -0
  76. package/build/modules/hash/drivers_collection.d.ts +9 -0
  77. package/build/modules/hash/drivers_collection.js +22 -0
  78. package/build/modules/hash/main.d.ts +2 -0
  79. package/build/modules/hash/main.js +2 -0
  80. package/build/modules/http.d.ts +1 -0
  81. package/build/modules/http.js +1 -0
  82. package/build/modules/logger.d.ts +1 -0
  83. package/build/modules/logger.js +1 -0
  84. package/build/providers/app_provider.d.ts +16 -0
  85. package/build/providers/app_provider.js +74 -0
  86. package/build/providers/hash_provider.d.ts +9 -0
  87. package/build/providers/hash_provider.js +29 -0
  88. package/build/providers/http_provider.d.ts +9 -0
  89. package/build/providers/http_provider.js +36 -0
  90. package/build/services/ace.d.ts +3 -0
  91. package/build/services/ace.js +6 -0
  92. package/build/services/app.d.ts +4 -12
  93. package/build/services/app.js +5 -12
  94. package/build/services/config.d.ts +3 -3
  95. package/build/services/config.js +6 -12
  96. package/build/services/emitter.d.ts +3 -0
  97. package/build/services/emitter.js +7 -0
  98. package/build/services/encryption.d.ts +3 -3
  99. package/build/services/encryption.js +7 -12
  100. package/build/services/hash.d.ts +3 -3
  101. package/build/services/hash.js +7 -12
  102. package/build/services/logger.d.ts +3 -0
  103. package/build/services/logger.js +7 -0
  104. package/build/services/router.d.ts +3 -0
  105. package/build/services/router.js +7 -0
  106. package/build/services/server.d.ts +3 -0
  107. package/build/services/server.js +7 -0
  108. package/build/services/test_utils.d.ts +3 -0
  109. package/build/services/test_utils.js +6 -0
  110. package/build/src/debug.d.ts +3 -0
  111. package/build/src/debug.js +2 -0
  112. package/build/src/helpers/is.d.ts +2 -0
  113. package/build/src/helpers/is.js +2 -0
  114. package/build/src/helpers/main.d.ts +2 -0
  115. package/build/src/helpers/main.js +2 -0
  116. package/build/src/helpers/string.d.ts +17 -0
  117. package/build/src/helpers/string.js +26 -0
  118. package/build/src/helpers/string_builder.d.ts +23 -0
  119. package/build/src/helpers/string_builder.js +86 -0
  120. package/build/src/helpers/types.d.ts +24 -0
  121. package/build/src/helpers/types.js +29 -0
  122. package/build/src/ignitor/ace.d.ts +8 -0
  123. package/build/src/ignitor/ace.js +31 -0
  124. package/build/src/ignitor/http.d.ts +10 -0
  125. package/build/src/ignitor/http.js +62 -0
  126. package/build/src/ignitor/main.d.ts +17 -0
  127. package/build/src/ignitor/main.js +45 -0
  128. package/build/src/ignitor/test.d.ts +8 -0
  129. package/build/src/ignitor/test.js +18 -0
  130. package/build/src/test_utils/http.d.ts +10 -0
  131. package/build/src/test_utils/http.js +42 -0
  132. package/build/src/test_utils/main.d.ts +19 -0
  133. package/build/src/test_utils/main.js +33 -0
  134. package/build/src/types.d.ts +63 -0
  135. package/build/src/types.js +1 -0
  136. package/build/stubs/index.d.ts +1 -0
  137. package/build/stubs/index.js +2 -0
  138. package/build/stubs/make/command/main.stub +19 -0
  139. package/build/stubs/make/controller/api.stub +33 -0
  140. package/build/stubs/make/controller/main.stub +9 -0
  141. package/build/stubs/make/controller/resource.stub +43 -0
  142. package/build/stubs/make/event/main.stub +15 -0
  143. package/build/stubs/make/listener/for_event.stub +13 -0
  144. package/build/stubs/make/listener/main.stub +7 -0
  145. package/build/stubs/make/middleware/main.stub +22 -0
  146. package/build/stubs/make/provider/main.stub +35 -0
  147. package/build/types/ace.d.ts +5 -0
  148. package/build/types/ace.js +1 -0
  149. package/build/types/app.d.ts +1 -0
  150. package/build/types/app.js +1 -0
  151. package/build/types/bodyparser.d.ts +1 -0
  152. package/build/types/bodyparser.js +1 -0
  153. package/build/types/container.d.ts +1 -0
  154. package/build/types/container.js +1 -0
  155. package/build/types/encryption.d.ts +1 -0
  156. package/build/types/encryption.js +1 -0
  157. package/build/types/events.d.ts +1 -0
  158. package/build/types/events.js +1 -0
  159. package/build/types/hash.d.ts +1 -0
  160. package/build/types/hash.js +1 -0
  161. package/build/types/http.d.ts +1 -0
  162. package/build/types/http.js +1 -0
  163. package/build/types/logger.d.ts +1 -0
  164. package/build/types/logger.js +1 -0
  165. package/package.json +235 -245
  166. package/build/adonis-typings/ace.d.ts +0 -5
  167. package/build/adonis-typings/ace.js +0 -8
  168. package/build/adonis-typings/assets-manager.d.ts +0 -92
  169. package/build/adonis-typings/assets-manager.js +0 -8
  170. package/build/adonis-typings/container.d.ts +0 -14
  171. package/build/adonis-typings/container.js +0 -8
  172. package/build/adonis-typings/cors.d.ts +0 -15
  173. package/build/adonis-typings/cors.js +0 -8
  174. package/build/adonis-typings/exception-handler.d.ts +0 -31
  175. package/build/adonis-typings/exception-handler.js +0 -8
  176. package/build/adonis-typings/health-check.d.ts +0 -40
  177. package/build/adonis-typings/health-check.js +0 -8
  178. package/build/adonis-typings/index.d.ts +0 -17
  179. package/build/adonis-typings/index.js +0 -25
  180. package/build/adonis-typings/static.d.ts +0 -15
  181. package/build/adonis-typings/static.js +0 -8
  182. package/build/adonis-typings/test-utils.d.ts +0 -24
  183. package/build/adonis-typings/test-utils.js +0 -8
  184. package/build/adonis-typings/tests.d.ts +0 -13
  185. package/build/adonis-typings/tests.js +0 -11
  186. package/build/commands/DumpRc.d.ts +0 -13
  187. package/build/commands/DumpRc.js +0 -33
  188. package/build/commands/GenerateKey.js +0 -25
  189. package/build/commands/ListRoutes/Renderers/Base.d.ts +0 -31
  190. package/build/commands/ListRoutes/Renderers/Base.js +0 -70
  191. package/build/commands/ListRoutes/Renderers/PrettyRenderer.d.ts +0 -51
  192. package/build/commands/ListRoutes/Renderers/PrettyRenderer.js +0 -135
  193. package/build/commands/ListRoutes/Renderers/TableRenderer.d.ts +0 -36
  194. package/build/commands/ListRoutes/Renderers/TableRenderer.js +0 -137
  195. package/build/commands/ListRoutes/index.d.ts +0 -75
  196. package/build/commands/ListRoutes/index.js +0 -166
  197. package/build/commands/index.d.ts +0 -2
  198. package/build/commands/index.js +0 -15
  199. package/build/config.d.ts +0 -2
  200. package/build/config.js +0 -15
  201. package/build/instructions.js +0 -81
  202. package/build/providers/AppProvider.d.ts +0 -68
  203. package/build/providers/AppProvider.js +0 -201
  204. package/build/services/base.d.ts +0 -3
  205. package/build/services/base.js +0 -23
  206. package/build/services/bodyparser.d.ts +0 -2
  207. package/build/services/bodyparser.js +0 -12
  208. package/build/services/drive.d.ts +0 -3
  209. package/build/services/drive.js +0 -12
  210. package/build/services/event.d.ts +0 -3
  211. package/build/services/event.js +0 -12
  212. package/build/services/healthChecks.d.ts +0 -3
  213. package/build/services/healthChecks.js +0 -12
  214. package/build/services/httpContext.d.ts +0 -3
  215. package/build/services/httpContext.js +0 -12
  216. package/build/services/route.d.ts +0 -3
  217. package/build/services/route.js +0 -12
  218. package/build/services/validator.d.ts +0 -3
  219. package/build/services/validator.js +0 -12
  220. package/build/src/AssetsManager/Drivers/Base.d.ts +0 -27
  221. package/build/src/AssetsManager/Drivers/Base.js +0 -66
  222. package/build/src/AssetsManager/Drivers/Encore.d.ts +0 -58
  223. package/build/src/AssetsManager/Drivers/Encore.js +0 -93
  224. package/build/src/AssetsManager/Drivers/Fake.d.ts +0 -38
  225. package/build/src/AssetsManager/Drivers/Fake.js +0 -61
  226. package/build/src/AssetsManager/Drivers/Vite.d.ts +0 -84
  227. package/build/src/AssetsManager/Drivers/Vite.js +0 -139
  228. package/build/src/AssetsManager/index.d.ts +0 -87
  229. package/build/src/AssetsManager/index.js +0 -184
  230. package/build/src/Bindings/Repl.d.ts +0 -8
  231. package/build/src/Bindings/Repl.js +0 -90
  232. package/build/src/Bindings/Tests.d.ts +0 -7
  233. package/build/src/Bindings/Tests.js +0 -66
  234. package/build/src/HealthCheck/Checkers/AppKey.d.ts +0 -6
  235. package/build/src/HealthCheck/Checkers/AppKey.js +0 -60
  236. package/build/src/HealthCheck/Checkers/Env.d.ts +0 -6
  237. package/build/src/HealthCheck/Checkers/Env.js +0 -42
  238. package/build/src/HealthCheck/index.d.ts +0 -48
  239. package/build/src/HealthCheck/index.js +0 -99
  240. package/build/src/Hooks/Cors/index.d.ts +0 -70
  241. package/build/src/Hooks/Cors/index.js +0 -314
  242. package/build/src/Hooks/Static/index.d.ts +0 -18
  243. package/build/src/Hooks/Static/index.js +0 -66
  244. package/build/src/HttpExceptionHandler/index.d.ts +0 -82
  245. package/build/src/HttpExceptionHandler/index.js +0 -213
  246. package/build/src/Ignitor/Ace/App/index.d.ts +0 -60
  247. package/build/src/Ignitor/Ace/App/index.js +0 -236
  248. package/build/src/Ignitor/Ace/Exceptions/index.d.ts +0 -4
  249. package/build/src/Ignitor/Ace/Exceptions/index.js +0 -19
  250. package/build/src/Ignitor/Ace/GenerateManifest/index.d.ts +0 -28
  251. package/build/src/Ignitor/Ace/GenerateManifest/index.js +0 -75
  252. package/build/src/Ignitor/Ace/index.d.ts +0 -11
  253. package/build/src/Ignitor/Ace/index.js +0 -36
  254. package/build/src/Ignitor/HttpServer/index.d.ts +0 -56
  255. package/build/src/Ignitor/HttpServer/index.js +0 -127
  256. package/build/src/Ignitor/Kernel/index.d.ts +0 -56
  257. package/build/src/Ignitor/Kernel/index.js +0 -123
  258. package/build/src/Ignitor/SignalsListener/index.d.ts +0 -23
  259. package/build/src/Ignitor/SignalsListener/index.js +0 -66
  260. package/build/src/Ignitor/index.d.ts +0 -32
  261. package/build/src/Ignitor/index.js +0 -58
  262. package/build/src/TestUtils/HttpServer/index.d.ts +0 -27
  263. package/build/src/TestUtils/HttpServer/index.js +0 -56
  264. package/build/src/TestUtils/index.d.ts +0 -24
  265. package/build/src/TestUtils/index.js +0 -43
  266. package/build/src/utils/index.d.ts +0 -18
  267. package/build/src/utils/index.js +0 -82
  268. package/build/standalone.d.ts +0 -9
  269. package/build/standalone.js +0 -52
  270. package/build/templates/config/app.txt +0 -303
  271. package/build/templates/config/bodyparser.txt +0 -211
  272. package/build/templates/config/cors.txt +0 -134
  273. package/build/templates/config/drive.txt +0 -149
  274. package/build/templates/config/hash.txt +0 -96
  275. package/build/templates/config/static.txt +0 -89
  276. package/build/templates/contracts/drive.txt +0 -13
  277. package/build/templates/contracts/env.txt +0 -24
  278. package/build/templates/contracts/events.txt +0 -31
  279. package/build/templates/contracts/hash.txt +0 -13
  280. package/build/templates/env.txt +0 -31
@@ -1,60 +0,0 @@
1
- /**
2
- * Exposes the API to execute app commands registered under
3
- * the manifest file.
4
- */
5
- export declare class App {
6
- private appRoot;
7
- private commandName;
8
- /**
9
- * Returns a boolean if mentioned command is an assembler
10
- * command
11
- */
12
- private get isAssemblerCommand();
13
- /**
14
- * Reference to the app kernel
15
- */
16
- private kernel;
17
- /**
18
- * Reference to the ace kernel
19
- */
20
- private ace;
21
- /**
22
- * Source root always points to the compiled source
23
- * code.
24
- */
25
- constructor(appRoot: string);
26
- /**
27
- * Print commands help
28
- */
29
- private printHelp;
30
- /**
31
- * Print framework version
32
- */
33
- private printVersion;
34
- /**
35
- * Invoked before command source will be read from the
36
- * disk
37
- */
38
- private onFind;
39
- /**
40
- * Invoked before command is about to run.
41
- */
42
- private onRun;
43
- /**
44
- * Hooks into ace lifecycle events to conditionally
45
- * load the app.
46
- */
47
- private registerAceHooks;
48
- /**
49
- * Adding flags
50
- */
51
- private registerAceFlags;
52
- /**
53
- * Load commands using manifest loader
54
- */
55
- loadCommands(): Promise<void>;
56
- /**
57
- * Handle application command
58
- */
59
- handle(argv: string[]): Promise<void>;
60
- }
@@ -1,236 +0,0 @@
1
- "use strict";
2
- /*
3
- * @adonisjs/core
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.App = void 0;
12
- const ace_1 = require("@adonisjs/ace");
13
- const cliui_1 = require("@poppinss/cliui");
14
- const helpers_1 = require("@poppinss/utils/build/helpers");
15
- const Kernel_1 = require("../../Kernel");
16
- const utils_1 = require("../../../utils");
17
- const GenerateManifest_1 = require("../GenerateManifest");
18
- /**
19
- * A local list of assembler commands. We need this, so that when assembler
20
- * is not installed (probably in production) and someone is trying to
21
- * build the project by running `serve` or `build`, we should give
22
- * them a better descriptive error.
23
- *
24
- * Also, do note that at times this list will be stale, but we get it back
25
- * in sync over time.
26
- */
27
- const ASSEMBLER_COMMANDS = [
28
- 'build',
29
- 'serve',
30
- 'invoke',
31
- 'make:command',
32
- 'make:controller',
33
- 'make:exception',
34
- 'make:listener',
35
- 'make:middleware',
36
- 'make:prldfile',
37
- 'make:provider',
38
- 'make:validator',
39
- 'make:view',
40
- ];
41
- /**
42
- * Exposes the API to execute app commands registered under
43
- * the manifest file.
44
- */
45
- class App {
46
- /**
47
- * Returns a boolean if mentioned command is an assembler
48
- * command
49
- */
50
- get isAssemblerCommand() {
51
- return ASSEMBLER_COMMANDS.includes(this.commandName);
52
- }
53
- /**
54
- * Source root always points to the compiled source
55
- * code.
56
- */
57
- constructor(appRoot) {
58
- this.appRoot = appRoot;
59
- /**
60
- * Reference to the app kernel
61
- */
62
- this.kernel = new Kernel_1.AppKernel(this.appRoot, 'console');
63
- /**
64
- * Reference to the ace kernel
65
- */
66
- this.ace = new ace_1.Kernel(this.kernel.application);
67
- }
68
- /**
69
- * Print commands help
70
- */
71
- printHelp(value, command) {
72
- if (!value) {
73
- return;
74
- }
75
- this.ace.printHelp(command, [GenerateManifest_1.GenerateManifest.getManifestJSON()]);
76
- process.exit(0);
77
- }
78
- /**
79
- * Print framework version
80
- */
81
- printVersion(value) {
82
- if (!value) {
83
- return;
84
- }
85
- const appVersion = this.kernel.application.version;
86
- const adonisVersion = this.kernel.application.adonisVersion;
87
- let assemblerVersion = 'Not Installed';
88
- try {
89
- assemblerVersion = require((0, helpers_1.resolveFrom)(this.appRoot, '@adonisjs/assembler/package.json')).version;
90
- }
91
- catch (error) { }
92
- (0, cliui_1.sticker)()
93
- .heading('node ace --version')
94
- .add(`App version: ${cliui_1.logger.colors.cyan(appVersion ? appVersion.version : 'NA')}`)
95
- .add(`Framework version: ${cliui_1.logger.colors.cyan(adonisVersion ? adonisVersion.version : 'NA')}`)
96
- .add(`Assembler version: ${cliui_1.logger.colors.cyan(assemblerVersion)}`)
97
- .render();
98
- process.exit(0);
99
- }
100
- /**
101
- * Invoked before command source will be read from the
102
- * disk
103
- */
104
- async onFind(command) {
105
- if (!command) {
106
- return;
107
- }
108
- /**
109
- * Register ts hook when
110
- *
111
- * - Haven't registered it already
112
- * - Is a typescript project
113
- * - Is not an assembler command
114
- */
115
- if (!this.isAssemblerCommand) {
116
- this.kernel.registerTsCompilerHook();
117
- }
118
- /**
119
- * Only main command can load the application or switch
120
- * the environment.
121
- *
122
- * If a sub-command needs application, then the main command
123
- * should set "loadApp" to true as well.
124
- */
125
- if (command.commandName === this.commandName || command.aliases.includes(this.commandName)) {
126
- /**
127
- * Switch environment before wiring the app
128
- */
129
- if (command.settings.environment) {
130
- this.kernel.application.switchEnvironment(command.settings.environment);
131
- }
132
- if (command.settings.loadApp) {
133
- /**
134
- * Set ace instance within the container, so that the underlying
135
- * commands or the app can access it from the container
136
- */
137
- this.kernel.application.container.singleton('Adonis/Core/Ace', () => this.ace);
138
- await this.kernel.boot();
139
- }
140
- }
141
- }
142
- /**
143
- * Invoked before command is about to run.
144
- */
145
- async onRun() {
146
- if (this.kernel.hasBooted) {
147
- await this.kernel.start();
148
- }
149
- }
150
- /**
151
- * Hooks into ace lifecycle events to conditionally
152
- * load the app.
153
- */
154
- registerAceHooks() {
155
- this.ace.before('find', async (command) => this.onFind(command));
156
- this.ace.before('run', async () => this.onRun());
157
- }
158
- /**
159
- * Adding flags
160
- */
161
- registerAceFlags() {
162
- /**
163
- * Showing help including core commands
164
- */
165
- this.ace.flag('help', async (value, _, command) => this.printHelp(value, command), {
166
- alias: 'h',
167
- });
168
- /**
169
- * Showing app and AdonisJs version
170
- */
171
- this.ace.flag('version', async (value) => this.printVersion(value), { alias: 'v' });
172
- }
173
- /**
174
- * Load commands using manifest loader
175
- */
176
- async loadCommands() {
177
- await (0, utils_1.loadAceCommands)(this.kernel.application, this.ace);
178
- }
179
- /**
180
- * Handle application command
181
- */
182
- async handle(argv) {
183
- try {
184
- /**
185
- * Manifest files to load
186
- */
187
- await this.loadCommands();
188
- /**
189
- * Define ace hooks to wire the application (if required)
190
- */
191
- this.registerAceHooks();
192
- /**
193
- * Define global flags
194
- */
195
- this.registerAceFlags();
196
- /**
197
- * Print help when no arguments have been passed
198
- */
199
- if (!argv.length) {
200
- this.printHelp(true);
201
- return;
202
- }
203
- /**
204
- * Hold reference to the command name. We will use this to decide whether
205
- * or not to exit the process forcefully after the command has been
206
- * executed
207
- */
208
- this.commandName = argv[0];
209
- /**
210
- * Listen for the exit signal on ace kernel
211
- */
212
- this.ace.onExit(async () => {
213
- if (this.kernel.hasBooted) {
214
- await this.kernel.close();
215
- }
216
- if (!this.ace.error) {
217
- process.exit(this.ace.exitCode);
218
- }
219
- return this.kernel
220
- .handleError(this.ace.error)
221
- .finally(() => process.exit(this.ace.exitCode));
222
- });
223
- /**
224
- * Handle command
225
- */
226
- await this.ace.handle(argv);
227
- }
228
- catch (error) {
229
- if (!error) {
230
- process.exit(1);
231
- }
232
- this.kernel.handleError(error).finally(() => process.exit(1));
233
- }
234
- }
235
- }
236
- exports.App = App;
@@ -1,4 +0,0 @@
1
- import { Exception } from '@poppinss/utils';
2
- export declare class AceRuntimeException extends Exception {
3
- handle(error: AceRuntimeException): void;
4
- }
@@ -1,19 +0,0 @@
1
- "use strict";
2
- /*
3
- * @adonisjs/core
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.AceRuntimeException = void 0;
12
- const cliui_1 = require("@poppinss/cliui");
13
- const utils_1 = require("@poppinss/utils");
14
- class AceRuntimeException extends utils_1.Exception {
15
- handle(error) {
16
- cliui_1.logger.error(error.message);
17
- }
18
- }
19
- exports.AceRuntimeException = AceRuntimeException;
@@ -1,28 +0,0 @@
1
- /**
2
- * Exposes the API to generate the manifest file
3
- */
4
- export declare class GenerateManifest {
5
- private appRoot;
6
- private kernel;
7
- /**
8
- * Source root always points to the compiled source
9
- * code.
10
- */
11
- constructor(appRoot: string);
12
- /**
13
- * Returns manifest object for showing help
14
- */
15
- static getManifestJSON(): {
16
- commandName: string;
17
- description: string;
18
- args: never[];
19
- flags: never[];
20
- settings: {};
21
- aliases: never[];
22
- commandPath: string;
23
- };
24
- /**
25
- * Generates the manifest file for commands
26
- */
27
- handle(): Promise<void>;
28
- }
@@ -1,75 +0,0 @@
1
- "use strict";
2
- /*
3
- * @adonisjs/core
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.GenerateManifest = void 0;
12
- const cliui_1 = require("@poppinss/cliui");
13
- const ace_1 = require("@adonisjs/ace");
14
- const Kernel_1 = require("../../Kernel");
15
- const Exceptions_1 = require("../Exceptions");
16
- /**
17
- * Exposes the API to generate the manifest file
18
- */
19
- class GenerateManifest {
20
- /**
21
- * Source root always points to the compiled source
22
- * code.
23
- */
24
- constructor(appRoot) {
25
- this.appRoot = appRoot;
26
- this.kernel = new Kernel_1.AppKernel(this.appRoot, 'console');
27
- }
28
- /**
29
- * Returns manifest object for showing help
30
- */
31
- static getManifestJSON() {
32
- return {
33
- commandName: 'generate:manifest',
34
- description: 'Generate ace commands manifest file. Manifest file speeds up commands lookup',
35
- args: [],
36
- flags: [],
37
- settings: {},
38
- aliases: [],
39
- commandPath: '',
40
- };
41
- }
42
- /**
43
- * Generates the manifest file for commands
44
- */
45
- async handle() {
46
- try {
47
- this.kernel.registerTsCompilerHook();
48
- const commands = this.kernel.application.rcFile.commands;
49
- /**
50
- * Generating manifest requires us to import the command files to read their
51
- * meta data defined as class static properties. However, at this stage
52
- * the application is not booted and hence top level IoC container
53
- * imports will break
54
- */
55
- this.kernel.application.container.trap((namespace) => {
56
- if (namespace === 'Adonis/Core/Application') {
57
- return this.kernel.application;
58
- }
59
- return {
60
- __esModule: new Proxy({ namespace }, {
61
- get(target) {
62
- throw new Exceptions_1.AceRuntimeException(`Top level import for module "${target.namespace}" is not allowed in commands. Learn more https://docs.adonisjs.com/guides/ace-commandline#top-level-imports-are-not-allowed`);
63
- },
64
- }),
65
- };
66
- });
67
- await new ace_1.ManifestGenerator(this.appRoot, commands).generate();
68
- cliui_1.logger.action('create').succeeded('ace-manifest.json file');
69
- }
70
- catch (error) {
71
- await this.kernel.handleError(error).finally(() => process.exit(1));
72
- }
73
- }
74
- }
75
- exports.GenerateManifest = GenerateManifest;
@@ -1,11 +0,0 @@
1
- /**
2
- * Exposes the API to execute ace commands.
3
- */
4
- export declare class Ace {
5
- private appRoot;
6
- constructor(appRoot: string);
7
- /**
8
- * Handles the ace command
9
- */
10
- handle(argv: string[]): Promise<void>;
11
- }
@@ -1,36 +0,0 @@
1
- "use strict";
2
- /*
3
- * @adonisjs/core
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.Ace = void 0;
12
- const App_1 = require("./App");
13
- const GenerateManifest_1 = require("./GenerateManifest");
14
- /**
15
- * Exposes the API to execute ace commands.
16
- */
17
- class Ace {
18
- constructor(appRoot) {
19
- this.appRoot = appRoot;
20
- }
21
- /**
22
- * Handles the ace command
23
- */
24
- async handle(argv) {
25
- process.env.ADONIS_ACE_CWD = this.appRoot;
26
- if (argv[0] === 'generate:manifest' && !argv.includes('--help')) {
27
- await new GenerateManifest_1.GenerateManifest(this.appRoot).handle();
28
- return;
29
- }
30
- /**
31
- * Proxy over to application commands
32
- */
33
- await new App_1.App(this.appRoot).handle(argv);
34
- }
35
- }
36
- exports.Ace = Ace;
@@ -1,56 +0,0 @@
1
- import { CustomServerCallback } from '@ioc:Adonis/Core/TestUtils';
2
- import { AppKernel } from '../Kernel';
3
- /**
4
- * Exposes the API to setup the application for starting the HTTP
5
- * server.
6
- *
7
- * - Calling "kill" explicitly exists the process.
8
- * - The "error" event emitted on the server instance explicitly exists the process.
9
- * - SIGINT and in some case SIGTERM explicitly exists the process.
10
- */
11
- export declare class HttpServer {
12
- private appRoot;
13
- /**
14
- * Reference to the HTTP server.
15
- */
16
- private server;
17
- /**
18
- * Reference to the app kernel
19
- */
20
- kernel: AppKernel;
21
- application: import("@adonisjs/application").Application;
22
- constructor(appRoot: string);
23
- /**
24
- * Closes the underlying HTTP server
25
- */
26
- private closeHttpServer;
27
- /**
28
- * Monitors the HTTP server for close and error events, so that
29
- * we can perform a graceful shutdown.
30
- */
31
- private monitorHttpServer;
32
- /**
33
- * Creates the HTTP server to handle incoming requests. The server is just
34
- * created but not listening on any port.
35
- */
36
- createServer(serverCallback?: CustomServerCallback): void;
37
- /**
38
- * Starts the http server a given host and port
39
- */
40
- listen(): Promise<void>;
41
- /**
42
- * Start the HTTP server by wiring up the application
43
- */
44
- start(serverCallback?: CustomServerCallback): Promise<void>;
45
- /**
46
- * Prepares the application for shutdown. This method will invoke `shutdown`
47
- * lifecycle method on the providers and closes the `httpServer`.
48
- */
49
- close(): Promise<void>;
50
- /**
51
- * Kills the http server process by attempting to perform a graceful
52
- * shutdown or killing the app forcefully as waiting for configured
53
- * seconds.
54
- */
55
- kill(waitTimeout?: number): Promise<void>;
56
- }
@@ -1,127 +0,0 @@
1
- "use strict";
2
- /*
3
- * @adonisjs/core
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.HttpServer = void 0;
12
- const Kernel_1 = require("../Kernel");
13
- const utils_1 = require("../../utils");
14
- /**
15
- * Exposes the API to setup the application for starting the HTTP
16
- * server.
17
- *
18
- * - Calling "kill" explicitly exists the process.
19
- * - The "error" event emitted on the server instance explicitly exists the process.
20
- * - SIGINT and in some case SIGTERM explicitly exists the process.
21
- */
22
- class HttpServer {
23
- constructor(appRoot) {
24
- this.appRoot = appRoot;
25
- /**
26
- * Reference to the app kernel
27
- */
28
- this.kernel = new Kernel_1.AppKernel(this.appRoot, 'web');
29
- this.application = this.kernel.application;
30
- }
31
- /**
32
- * Closes the underlying HTTP server
33
- */
34
- closeHttpServer() {
35
- return new Promise((resolve) => this.server.instance.close(() => resolve()));
36
- }
37
- /**
38
- * Monitors the HTTP server for close and error events, so that
39
- * we can perform a graceful shutdown.
40
- */
41
- monitorHttpServer() {
42
- this.server.instance.on('close', async () => {
43
- this.application.logger.trace('closing http server');
44
- this.server.instance.removeAllListeners();
45
- this.application.isShuttingDown = true;
46
- });
47
- this.server.instance.on('error', async (error) => {
48
- this.application.logger.error(error, error.message);
49
- await this.kill(3000);
50
- });
51
- }
52
- /**
53
- * Creates the HTTP server to handle incoming requests. The server is just
54
- * created but not listening on any port.
55
- */
56
- createServer(serverCallback) {
57
- this.server = this.application.container.use('Adonis/Core/Server');
58
- (0, utils_1.createHttpServer)(this.application, this.server, serverCallback);
59
- }
60
- /**
61
- * Starts the http server a given host and port
62
- */
63
- listen() {
64
- return new Promise(async (resolve, reject) => {
65
- try {
66
- await this.kernel.start(() => this.close());
67
- const host = this.application.env.get('HOST', '0.0.0.0');
68
- const port = Number(this.application.env.get('PORT', '3333'));
69
- this.server.instance.listen(port, host, () => {
70
- this.application.logger.info('started server on %s:%s', host, port);
71
- this.kernel.ready({ port: port, host: host });
72
- resolve();
73
- });
74
- }
75
- catch (error) {
76
- reject(error);
77
- }
78
- });
79
- }
80
- /**
81
- * Start the HTTP server by wiring up the application
82
- */
83
- async start(serverCallback) {
84
- try {
85
- await this.kernel.boot();
86
- this.createServer(serverCallback);
87
- this.monitorHttpServer();
88
- await this.listen();
89
- }
90
- catch (error) {
91
- await this.kernel.handleError(error);
92
- }
93
- }
94
- /**
95
- * Prepares the application for shutdown. This method will invoke `shutdown`
96
- * lifecycle method on the providers and closes the `httpServer`.
97
- */
98
- async close() {
99
- /**
100
- * Close the HTTP server before excuting the `shutdown` hooks. This ensures that
101
- * we are not accepting any new request during cool off.
102
- */
103
- await this.closeHttpServer();
104
- await this.kernel.close();
105
- }
106
- /**
107
- * Kills the http server process by attempting to perform a graceful
108
- * shutdown or killing the app forcefully as waiting for configured
109
- * seconds.
110
- */
111
- async kill(waitTimeout = 3000) {
112
- this.application.logger.trace('forcefully killing http server');
113
- try {
114
- await Promise.race([
115
- this.close(),
116
- new Promise((resolve) => {
117
- setTimeout(resolve, waitTimeout);
118
- }),
119
- ]);
120
- process.exit(0);
121
- }
122
- catch (error) {
123
- await this.kernel.handleError(error).finally(() => process.exit(1));
124
- }
125
- }
126
- }
127
- exports.HttpServer = HttpServer;