@adonisjs/core 6.1.5-2 → 6.1.5-21

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 (189) hide show
  1. package/build/commands/build.d.ts +10 -0
  2. package/build/commands/build.js +65 -22
  3. package/build/commands/commands.json +1 -1
  4. package/build/commands/configure.d.ts +30 -3
  5. package/build/commands/configure.js +103 -25
  6. package/build/commands/eject.d.ts +4 -0
  7. package/build/commands/eject.js +16 -8
  8. package/build/commands/generate_key.d.ts +4 -0
  9. package/build/commands/generate_key.js +15 -8
  10. package/build/commands/inspect_rcfile.d.ts +9 -0
  11. package/build/commands/inspect_rcfile.js +36 -0
  12. package/build/commands/list/routes.d.ts +23 -0
  13. package/build/commands/list/routes.js +29 -13
  14. package/build/commands/main.d.ts +4 -0
  15. package/build/commands/make/command.d.ts +7 -1
  16. package/build/commands/make/command.js +20 -7
  17. package/build/commands/make/controller.d.ts +10 -1
  18. package/build/commands/make/controller.js +35 -14
  19. package/build/commands/make/event.d.ts +7 -1
  20. package/build/commands/make/event.js +20 -8
  21. package/build/commands/make/exception.d.ts +14 -0
  22. package/build/commands/make/exception.js +37 -0
  23. package/build/commands/make/listener.d.ts +8 -1
  24. package/build/commands/make/listener.js +28 -12
  25. package/build/commands/make/middleware.d.ts +8 -1
  26. package/build/commands/make/middleware.js +21 -8
  27. package/build/commands/make/preload.d.ts +22 -0
  28. package/build/commands/make/preload.js +99 -0
  29. package/build/commands/make/provider.d.ts +7 -1
  30. package/build/commands/make/provider.js +28 -8
  31. package/build/commands/make/service.d.ts +14 -0
  32. package/build/commands/make/service.js +37 -0
  33. package/build/commands/make/test.d.ts +10 -1
  34. package/build/commands/make/test.js +46 -10
  35. package/build/commands/make/validator.d.ts +14 -0
  36. package/build/commands/make/validator.js +37 -0
  37. package/build/commands/make/view.d.ts +14 -0
  38. package/build/commands/make/view.js +37 -0
  39. package/build/commands/repl.d.ts +14 -0
  40. package/build/commands/repl.js +30 -0
  41. package/build/commands/serve.d.ts +12 -0
  42. package/build/commands/serve.js +78 -27
  43. package/build/commands/test.d.ts +32 -0
  44. package/build/commands/test.js +203 -0
  45. package/build/factories/app.js +8 -0
  46. package/build/factories/bodyparser.js +8 -0
  47. package/build/factories/core/ace.d.ts +4 -1
  48. package/build/factories/core/ace.js +11 -0
  49. package/build/factories/core/ignitor.d.ts +20 -1
  50. package/build/factories/core/ignitor.js +35 -1
  51. package/build/factories/core/main.js +8 -0
  52. package/build/factories/core/test_utils.d.ts +4 -1
  53. package/build/factories/core/test_utils.js +11 -0
  54. package/build/factories/encryption.js +8 -0
  55. package/build/factories/events.js +8 -0
  56. package/build/factories/hash.js +8 -0
  57. package/build/factories/http.js +8 -0
  58. package/build/factories/logger.js +8 -0
  59. package/build/factories/stubs.d.ts +10 -0
  60. package/build/factories/stubs.js +23 -1
  61. package/build/index.d.ts +6 -2
  62. package/build/index.js +14 -1
  63. package/build/modules/ace/codemods.d.ts +54 -0
  64. package/build/modules/ace/codemods.js +133 -0
  65. package/build/modules/ace/commands.d.ts +48 -0
  66. package/build/modules/ace/commands.js +54 -0
  67. package/build/modules/ace/create_kernel.d.ts +9 -0
  68. package/build/modules/ace/create_kernel.js +32 -1
  69. package/build/modules/ace/kernel.d.ts +4 -0
  70. package/build/modules/ace/kernel.js +12 -0
  71. package/build/modules/ace/main.js +8 -0
  72. package/build/modules/ace/shell.d.ts +9 -1
  73. package/build/modules/ace/shell.js +21 -0
  74. package/build/modules/app.js +8 -0
  75. package/build/modules/bodyparser/bodyparser_middleware.d.ts +4 -0
  76. package/build/modules/bodyparser/bodyparser_middleware.js +12 -0
  77. package/build/modules/bodyparser/main.js +8 -0
  78. package/build/modules/config.js +8 -0
  79. package/build/modules/container.js +8 -0
  80. package/build/modules/encryption.js +8 -0
  81. package/build/modules/env.js +8 -0
  82. package/build/modules/events.js +8 -0
  83. package/build/modules/hash/define_config.d.ts +4 -0
  84. package/build/modules/hash/define_config.js +23 -0
  85. package/build/modules/hash/drivers/argon.d.ts +1 -0
  86. package/build/modules/hash/drivers/argon.js +9 -0
  87. package/build/modules/hash/drivers/bcrypt.d.ts +1 -0
  88. package/build/modules/hash/drivers/bcrypt.js +9 -0
  89. package/build/modules/hash/drivers/scrypt.d.ts +1 -0
  90. package/build/modules/hash/drivers/scrypt.js +9 -0
  91. package/build/modules/hash/drivers_collection.d.ts +16 -4
  92. package/build/modules/hash/drivers_collection.js +31 -8
  93. package/build/modules/hash/main.d.ts +1 -0
  94. package/build/modules/hash/main.js +9 -0
  95. package/build/modules/http/main.d.ts +2 -0
  96. package/build/modules/http/main.js +10 -0
  97. package/build/modules/http/request_validator.d.ts +34 -0
  98. package/build/modules/http/request_validator.js +66 -0
  99. package/build/modules/logger.js +8 -0
  100. package/build/modules/repl.d.ts +1 -0
  101. package/build/modules/repl.js +9 -0
  102. package/build/providers/app_provider.d.ts +31 -2
  103. package/build/providers/app_provider.js +44 -15
  104. package/build/providers/edge_provider.d.ts +31 -0
  105. package/build/providers/edge_provider.js +69 -0
  106. package/build/providers/hash_provider.d.ts +22 -2
  107. package/build/providers/hash_provider.js +49 -7
  108. package/build/providers/http_provider.d.ts +17 -0
  109. package/build/providers/http_provider.js +26 -1
  110. package/build/providers/repl_provider.d.ts +13 -0
  111. package/build/providers/repl_provider.js +98 -0
  112. package/build/providers/vinejs_provider.d.ts +33 -0
  113. package/build/providers/vinejs_provider.js +84 -0
  114. package/build/services/ace.js +15 -0
  115. package/build/services/app.d.ts +8 -0
  116. package/build/services/app.js +16 -0
  117. package/build/services/config.js +11 -0
  118. package/build/services/emitter.js +13 -2
  119. package/build/services/encryption.js +13 -2
  120. package/build/services/hash.js +13 -2
  121. package/build/services/logger.js +13 -2
  122. package/build/services/repl.d.ts +3 -0
  123. package/build/services/repl.js +18 -0
  124. package/build/services/router.js +13 -2
  125. package/build/services/server.js +13 -2
  126. package/build/services/test_utils.js +15 -0
  127. package/build/src/cli_formatters/routes_list.d.ts +24 -1
  128. package/build/src/cli_formatters/routes_list.js +118 -0
  129. package/build/src/debug.d.ts +1 -1
  130. package/build/src/debug.js +8 -0
  131. package/build/src/exceptions.d.ts +1 -0
  132. package/build/src/exceptions.js +9 -0
  133. package/build/src/helpers/is.js +8 -0
  134. package/build/src/helpers/main.d.ts +1 -1
  135. package/build/src/helpers/main.js +9 -1
  136. package/build/src/helpers/parse_binding_reference.d.ts +40 -0
  137. package/build/src/helpers/parse_binding_reference.js +60 -0
  138. package/build/src/helpers/string.d.ts +26 -0
  139. package/build/src/helpers/string.js +15 -0
  140. package/build/src/helpers/types.d.ts +114 -16
  141. package/build/src/helpers/types.js +13 -0
  142. package/build/src/ignitor/ace.d.ts +12 -0
  143. package/build/src/ignitor/ace.js +50 -1
  144. package/build/src/ignitor/http.d.ts +9 -2
  145. package/build/src/ignitor/http.js +67 -0
  146. package/build/src/ignitor/main.d.ts +29 -1
  147. package/build/src/ignitor/main.js +56 -0
  148. package/build/src/ignitor/test.d.ts +10 -0
  149. package/build/src/ignitor/test.js +25 -0
  150. package/build/src/internal_helpers.d.ts +12 -5
  151. package/build/src/internal_helpers.js +35 -7
  152. package/build/src/test_utils/http.d.ts +10 -2
  153. package/build/src/test_utils/http.js +19 -0
  154. package/build/src/test_utils/main.d.ts +21 -3
  155. package/build/src/test_utils/main.js +27 -1
  156. package/build/src/types.d.ts +65 -4
  157. package/build/src/types.js +8 -0
  158. package/build/stubs/main.js +10 -0
  159. package/build/stubs/make/exception/main.stub +10 -0
  160. package/build/stubs/make/preload_file/main.stub +4 -0
  161. package/build/stubs/make/service/main.stub +4 -0
  162. package/build/stubs/make/validator/main.stub +5 -0
  163. package/build/stubs/make/view/main.stub +4 -0
  164. package/build/toolkit/commands/index_commands.d.ts +4 -0
  165. package/build/toolkit/commands/index_commands.js +13 -5
  166. package/build/toolkit/main.js +11 -0
  167. package/build/types/ace.js +8 -0
  168. package/build/types/app.js +8 -0
  169. package/build/types/bodyparser.js +8 -0
  170. package/build/types/container.js +8 -0
  171. package/build/types/encryption.js +8 -0
  172. package/build/types/events.js +8 -0
  173. package/build/types/hash.js +8 -0
  174. package/build/types/http.d.ts +7 -0
  175. package/build/types/http.js +8 -0
  176. package/build/types/logger.js +8 -0
  177. package/build/types/repl.d.ts +1 -0
  178. package/build/types/repl.js +9 -0
  179. package/package.json +83 -121
  180. package/build/commands/make/_base.d.ts +0 -6
  181. package/build/commands/make/_base.js +0 -19
  182. package/build/legacy/validator.d.ts +0 -1
  183. package/build/legacy/validator.js +0 -1
  184. package/build/modules/http.d.ts +0 -1
  185. package/build/modules/http.js +0 -1
  186. package/build/src/helpers/string_builder.d.ts +0 -23
  187. package/build/src/helpers/string_builder.js +0 -86
  188. package/build/stubs/index.js +0 -2
  189. /package/build/stubs/{index.d.ts → main.d.ts} +0 -0
@@ -1,11 +1,21 @@
1
1
  import { BaseCommand } from '../modules/ace/main.js';
2
+ /**
3
+ * Serve command is used to run the AdonisJS HTTP server during development. The
4
+ * command under the hood runs the "bin/server.ts" file and watches for file
5
+ * system changes
6
+ */
2
7
  export default class Build extends BaseCommand {
3
8
  #private;
4
9
  static commandName: string;
5
10
  static description: string;
11
+ static help: string[];
6
12
  watch?: boolean;
7
13
  ignoreTsErrors?: boolean;
8
14
  packageManager?: 'npm' | 'pnpm' | 'yarn';
9
15
  assets?: boolean;
16
+ assetsArgs?: string[];
17
+ /**
18
+ * Build application
19
+ */
10
20
  run(): Promise<void>;
11
21
  }
@@ -1,26 +1,70 @@
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
+ */
1
9
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
10
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
11
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
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;
5
13
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
14
  };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
15
  import { BaseCommand, flags } from '../modules/ace/main.js';
11
16
  import { detectAssetsBundler, importAssembler, importTypeScript } from '../src/internal_helpers.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
+ */
12
22
  export default class Build extends BaseCommand {
13
23
  static commandName = 'build';
14
24
  static description = 'Build application for production by compiling frontend assets and TypeScript source to JavaScript';
25
+ static help = [
26
+ 'Create the production build using the following command.',
27
+ '```',
28
+ '{{ binaryName }} build',
29
+ '```',
30
+ '',
31
+ 'The assets bundler dev server runs automatically after detecting vite config or webpack config files',
32
+ 'You may pass vite CLI args using the --assets-args command line flag.',
33
+ '```',
34
+ '{{ binaryName }} build --assets-args="--debug --base=/public"',
35
+ '```',
36
+ ];
37
+ /**
38
+ * Log a development dependency is missing
39
+ */
15
40
  #logMissingDevelopmentDependency(dependency) {
16
41
  this.logger.error([
17
42
  `Cannot find package "${dependency}"`,
18
43
  '',
19
- `The "${dependency}" package is a development dependency and therefore you should use the serve command during development only.`,
44
+ `The "${dependency}" package is a development dependency and therefore you should use the build command with development dependencies installed.`,
20
45
  '',
21
46
  'If you are using the build command inside a CI or with a deployment platform, make sure the NODE_ENV is set to "development"',
22
47
  ].join('\n'));
23
48
  }
49
+ /**
50
+ * Returns the assets bundler config
51
+ */
52
+ async #getAssetsBundlerConfig() {
53
+ const assetsBundler = await detectAssetsBundler(this.app);
54
+ return assetsBundler
55
+ ? {
56
+ serve: this.assets === false ? false : true,
57
+ driver: assetsBundler.name,
58
+ cmd: assetsBundler.build.command,
59
+ args: (assetsBundler.build.args || []).concat(this.assetsArgs || []),
60
+ }
61
+ : {
62
+ serve: false,
63
+ };
64
+ }
65
+ /**
66
+ * Build application
67
+ */
24
68
  async run() {
25
69
  const assembler = await importAssembler(this.app);
26
70
  if (!assembler) {
@@ -34,20 +78,18 @@ export default class Build extends BaseCommand {
34
78
  this.exitCode = 1;
35
79
  return;
36
80
  }
37
- const assetsBundler = await detectAssetsBundler(this.app);
38
81
  const bundler = new assembler.Bundler(this.app.appRoot, ts, {
39
- assets: assetsBundler
40
- ? {
41
- serve: this.assets === false ? false : true,
42
- driver: assetsBundler.name,
43
- cmd: assetsBundler.buildCommand,
44
- }
45
- : {
46
- serve: false,
47
- },
82
+ assets: await this.#getAssetsBundlerConfig(),
48
83
  metaFiles: this.app.rcFile.metaFiles,
49
84
  });
85
+ /**
86
+ * Share command logger with assembler, so that CLI flags like --no-ansi has
87
+ * similar impact for assembler logs as well.
88
+ */
50
89
  bundler.setLogger(this.logger);
90
+ /**
91
+ * Bundle project for production
92
+ */
51
93
  const stopOnError = this.ignoreTsErrors === true ? false : true;
52
94
  const builtSuccessfully = await bundler.bundle(stopOnError, this.packageManager);
53
95
  if (!builtSuccessfully) {
@@ -56,24 +98,25 @@ export default class Build extends BaseCommand {
56
98
  }
57
99
  }
58
100
  __decorate([
59
- flags.boolean({ description: 'Watch filesystem and restart the HTTP server on file change' }),
60
- __metadata("design:type", Boolean)
101
+ flags.boolean({ description: 'Watch filesystem and restart the HTTP server on file change' })
61
102
  ], Build.prototype, "watch", void 0);
62
103
  __decorate([
63
- flags.boolean({ description: 'Ignore TypeScript errors and continue with the build process' }),
64
- __metadata("design:type", Boolean)
104
+ flags.boolean({ description: 'Ignore TypeScript errors and continue with the build process' })
65
105
  ], Build.prototype, "ignoreTsErrors", void 0);
66
106
  __decorate([
67
107
  flags.string({
68
108
  description: 'Select the package manager you want to use to install production dependencies',
69
- }),
70
- __metadata("design:type", String)
109
+ })
71
110
  ], Build.prototype, "packageManager", void 0);
72
111
  __decorate([
73
112
  flags.boolean({
74
113
  description: 'Build frontend assets',
75
114
  showNegatedVariantInHelp: true,
76
115
  default: true,
77
- }),
78
- __metadata("design:type", Boolean)
116
+ })
79
117
  ], Build.prototype, "assets", void 0);
118
+ __decorate([
119
+ flags.array({
120
+ description: 'Define CLI arguments to pass to the assets bundler',
121
+ })
122
+ ], Build.prototype, "assetsArgs", void 0);
@@ -1 +1 @@
1
- {"commands":[{"commandName":"build","description":"Build application for production by compiling frontend assets and TypeScript source to JavaScript","help":"","namespace":null,"aliases":[],"flags":[{"name":"watch","flagName":"watch","required":false,"type":"boolean","description":"Watch filesystem and restart the HTTP server on file change"},{"name":"ignoreTsErrors","flagName":"ignore-ts-errors","required":false,"type":"boolean","description":"Ignore TypeScript errors and continue with the build process"},{"name":"packageManager","flagName":"package-manager","required":false,"type":"string","description":"Select the package manager you want to use to install production dependencies"},{"name":"assets","flagName":"assets","required":false,"type":"boolean","description":"Build frontend assets","showNegatedVariantInHelp":true,"default":true}],"args":[],"options":{},"filePath":"build.js"},{"commandName":"configure","description":"Configure a package post installation","help":"","namespace":null,"aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Package name","type":"string"}],"options":{},"filePath":"configure.js"},{"commandName":"eject","description":"Eject scaffolding stubs to your application root","help":"","namespace":null,"aliases":[],"flags":[{"name":"pkg","flagName":"pkg","required":false,"type":"string","description":"Mention package name for searching stubs","default":"@adonisjs/core"}],"args":[{"name":"stubPath","argumentName":"stub-path","required":true,"description":"Path to the stubs directory or a single stub file","type":"string"}],"options":{},"filePath":"eject.js"},{"commandName":"generate:key","description":"Generate a secure random application key","help":"","namespace":"generate","aliases":[],"flags":[{"name":"show","flagName":"show","required":false,"type":"boolean","description":"Display the key on the terminal, instead of writing it to .env file"},{"name":"force","flagName":"force","required":false,"type":"boolean","description":"Force update .env file in production environment"}],"args":[],"options":{},"filePath":"generate_key.js"},{"commandName":"list:routes","description":"List application routes. This command will boot the application in the console environment","help":"","namespace":"list","aliases":[],"flags":[{"name":"middleware","flagName":"middleware","required":false,"type":"array","description":"View routes that includes all the mentioned middleware names. Use * to see routes that are using one or more middleware"},{"name":"ignoreMiddleware","flagName":"ignore-middleware","required":false,"type":"array","description":"View routes that does not include all the mentioned middleware names. Use * to see routes that are using zero middleware"},{"name":"json","flagName":"json","required":false,"type":"boolean","description":"Get routes list as a JSON string"},{"name":"table","flagName":"table","required":false,"type":"boolean","description":"View list of routes as a table"}],"args":[{"name":"match","argumentName":"match","required":false,"description":"Find routes matching the given keyword. Route name, pattern and controller name will be searched against the keyword","type":"string"}],"options":{"startApp":true},"filePath":"list/routes.js"},{"commandName":"make:command","description":"Create a new ace command class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the command","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/command.js"},{"commandName":"make:controller","description":"Create a new HTTP controller class","help":"","namespace":"make","aliases":[],"flags":[{"name":"singular","flagName":"singular","required":false,"type":"boolean","description":"Convert controller class and file name to its singular form","alias":"r"},{"name":"resource","flagName":"resource","required":false,"type":"boolean","description":"Generate controller with resource actions","alias":"r"},{"name":"api","flagName":"api","required":false,"type":"boolean","description":"Generate controller with api resource actions","alias":"a"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"The name of the controller","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/controller.js"},{"commandName":"make:event","description":"Create a new event class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the event","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/event.js"},{"commandName":"make:listener","description":"Create a new event listener class","help":"","namespace":"make","aliases":[],"flags":[{"name":"event","flagName":"event","required":false,"type":"string","description":"Generate an event class alongside the listener","alias":"e"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the listener","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/listener.js"},{"commandName":"make:middleware","description":"Create a new middleware class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the middleware","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/middleware.js"},{"commandName":"make:provider","description":"Create a new service provider class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the provider","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/provider.js"},{"commandName":"make:test","description":"Create a new Japa test file","help":"","namespace":"make","aliases":[],"flags":[{"name":"suite","flagName":"suite","required":false,"type":"string","description":"The suite for which to create the test file"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the test file","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/test.js"},{"commandName":"serve","description":"Start the development HTTP server along with the file watcher to perform restarts on file change","help":"","namespace":null,"aliases":[],"flags":[{"name":"watch","flagName":"watch","required":false,"type":"boolean","description":"Watch filesystem and restart the HTTP server on file change"},{"name":"poll","flagName":"poll","required":false,"type":"boolean","description":"Use polling to detect filesystem changes"},{"name":"clear","flagName":"clear","required":false,"type":"boolean","description":"Clear the terminal for new logs after file change","showNegatedVariantInHelp":true,"default":true},{"name":"assets","flagName":"assets","required":false,"type":"boolean","description":"Start assets bundler dev server","showNegatedVariantInHelp":true,"default":true}],"args":[],"options":{"staysAlive":true},"filePath":"serve.js"}],"version":1}
1
+ {"commands":[{"commandName":"build","description":"Build application for production by compiling frontend assets and TypeScript source to JavaScript","help":["Create the production build using the following command.","```","{{ binaryName }} build","```","","The assets bundler dev server runs automatically after detecting vite config or webpack config files","You may pass vite CLI args using the --assets-args command line flag.","```","{{ binaryName }} build --assets-args=\"--debug --base=/public\"","```"],"namespace":null,"aliases":[],"flags":[{"name":"watch","flagName":"watch","required":false,"type":"boolean","description":"Watch filesystem and restart the HTTP server on file change"},{"name":"ignoreTsErrors","flagName":"ignore-ts-errors","required":false,"type":"boolean","description":"Ignore TypeScript errors and continue with the build process"},{"name":"packageManager","flagName":"package-manager","required":false,"type":"string","description":"Select the package manager you want to use to install production dependencies"},{"name":"assets","flagName":"assets","required":false,"type":"boolean","description":"Build frontend assets","showNegatedVariantInHelp":true,"default":true},{"name":"assetsArgs","flagName":"assets-args","required":false,"type":"array","description":"Define CLI arguments to pass to the assets bundler"}],"args":[],"options":{},"filePath":"build.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/build.js"},{"commandName":"configure","description":"Configure a package post installation","help":"","namespace":null,"aliases":[],"flags":[{"name":"verbose","flagName":"verbose","required":false,"type":"boolean","description":"Display logs in verbose mode"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"Package name","type":"string"}],"options":{},"filePath":"configure.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/configure.js"},{"commandName":"eject","description":"Eject scaffolding stubs to your application root","help":"","namespace":null,"aliases":[],"flags":[{"name":"pkg","flagName":"pkg","required":false,"type":"string","description":"Mention package name for searching stubs","default":"@adonisjs/core"}],"args":[{"name":"stubPath","argumentName":"stub-path","required":true,"description":"Path to the stubs directory or a single stub file","type":"string"}],"options":{},"filePath":"eject.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/eject.js"},{"commandName":"generate:key","description":"Generate a secure random application key","help":"","namespace":"generate","aliases":[],"flags":[{"name":"show","flagName":"show","required":false,"type":"boolean","description":"Display the key on the terminal, instead of writing it to .env file"},{"name":"force","flagName":"force","required":false,"type":"boolean","description":"Force update .env file in production environment"}],"args":[],"options":{},"filePath":"generate_key.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/generate_key.js"},{"commandName":"inspect:rcfile","description":"Inspect the RC file with its default values","help":"","namespace":"inspect","aliases":[],"flags":[],"args":[],"options":{},"filePath":"inspect_rcfile.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/inspect_rcfile.js"},{"commandName":"list:routes","description":"List application routes. This command will boot the application in the console environment","help":"","namespace":"list","aliases":[],"flags":[{"name":"middleware","flagName":"middleware","required":false,"type":"array","description":"View routes that includes all the mentioned middleware names. Use * to see routes that are using one or more middleware"},{"name":"ignoreMiddleware","flagName":"ignore-middleware","required":false,"type":"array","description":"View routes that does not include all the mentioned middleware names. Use * to see routes that are using zero middleware"},{"name":"json","flagName":"json","required":false,"type":"boolean","description":"Get routes list as a JSON string"},{"name":"table","flagName":"table","required":false,"type":"boolean","description":"View list of routes as a table"}],"args":[{"name":"match","argumentName":"match","required":false,"description":"Find routes matching the given keyword. Route name, pattern and controller name will be searched against the keyword","type":"string"}],"options":{"startApp":true},"filePath":"list/routes.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/list/routes.js"},{"commandName":"make:command","description":"Create a new ace command class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the command","type":"string"}],"options":{},"filePath":"make/command.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/command.js"},{"commandName":"make:controller","description":"Create a new HTTP controller class","help":"","namespace":"make","aliases":[],"flags":[{"name":"singular","flagName":"singular","required":false,"type":"boolean","description":"Convert controller class and file name to its singular form","alias":"r"},{"name":"resource","flagName":"resource","required":false,"type":"boolean","description":"Generate controller with resource actions","alias":"r"},{"name":"api","flagName":"api","required":false,"type":"boolean","description":"Generate controller with api resource actions","alias":"a"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"The name of the controller","type":"string"}],"options":{},"filePath":"make/controller.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/controller.js"},{"commandName":"make:event","description":"Create a new event class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the event","type":"string"}],"options":{},"filePath":"make/event.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/event.js"},{"commandName":"make:exception","description":"Create a new ace exception class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the exception","type":"string"}],"options":{},"filePath":"make/exception.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/exception.js"},{"commandName":"make:listener","description":"Create a new event listener class","help":"","namespace":"make","aliases":[],"flags":[{"name":"event","flagName":"event","required":false,"type":"string","description":"Generate an event class alongside the listener","alias":"e"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the listener","type":"string"}],"options":{},"filePath":"make/listener.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/listener.js"},{"commandName":"make:middleware","description":"Create a new middleware class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the middleware","type":"string"}],"options":{},"filePath":"make/middleware.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/middleware.js"},{"commandName":"make:preload","description":"Create a new preload file inside the start directory","help":"","namespace":"make","aliases":[],"flags":[{"name":"environments","flagName":"environments","required":false,"type":"array","description":"Define the preload file's environment. Accepted values are \"web,console,test,repl\""}],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the preload file","type":"string"}],"options":{},"filePath":"make/preload.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/preload.js"},{"commandName":"make:provider","description":"Create a new service provider class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the provider","type":"string"}],"options":{},"filePath":"make/provider.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/provider.js"},{"commandName":"make:service","description":"Create a new service class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the service","type":"string"}],"options":{},"filePath":"make/service.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/service.js"},{"commandName":"make:test","description":"Create a new Japa test file","help":"","namespace":"make","aliases":[],"flags":[{"name":"suite","flagName":"suite","required":false,"type":"string","description":"The suite for which to create the test file"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the test file","type":"string"}],"options":{},"filePath":"make/test.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/test.js"},{"commandName":"make:validator","description":"Create a new VineJS validator","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the validator","type":"string"}],"options":{},"filePath":"make/validator.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/validator.js"},{"commandName":"make:view","description":"Create a new Edge.js template file","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the template","type":"string"}],"options":{},"filePath":"make/view.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/view.js"},{"commandName":"repl","description":"Start a new REPL session","help":"","namespace":null,"aliases":[],"flags":[],"args":[],"options":{"startApp":true,"staysAlive":true},"filePath":"repl.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/repl.js"},{"commandName":"serve","description":"Start the development HTTP server along with the file watcher to perform restarts on file change","help":["Start the development server with file watcher using the following command.","```","{{ binaryName }} serve --watch","```","","The assets bundler dev server runs automatically after detecting vite config or webpack config files","You may pass vite CLI args using the --assets-args command line flag.","```","{{ binaryName }} serve --assets-args=\"--debug --base=/public\"","```"],"namespace":null,"aliases":[],"flags":[{"name":"watch","flagName":"watch","required":false,"type":"boolean","description":"Watch filesystem and restart the HTTP server on file change"},{"name":"poll","flagName":"poll","required":false,"type":"boolean","description":"Use polling to detect filesystem changes"},{"name":"clear","flagName":"clear","required":false,"type":"boolean","description":"Clear the terminal for new logs after file change","showNegatedVariantInHelp":true,"default":true},{"name":"assets","flagName":"assets","required":false,"type":"boolean","description":"Start assets bundler dev server","showNegatedVariantInHelp":true,"default":true},{"name":"assetsArgs","flagName":"assets-args","required":false,"type":"array","description":"Define CLI arguments to pass to the assets bundler"}],"args":[],"options":{"staysAlive":true},"filePath":"serve.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/serve.js"},{"commandName":"test","description":"Run tests along with the file watcher to re-run tests on file change","help":"","namespace":null,"aliases":[],"flags":[{"name":"files","flagName":"files","required":false,"type":"array","description":"Filter tests by the filename"},{"name":"tags","flagName":"tags","required":false,"type":"array","description":"Filter tests by tags"},{"name":"groups","flagName":"groups","required":false,"type":"array","description":"Filter tests by parent group title"},{"name":"tests","flagName":"tests","required":false,"type":"array","description":"Filter tests by test title"},{"name":"reporters","flagName":"reporters","required":false,"type":"array","description":"Activate one or more test reporters"},{"name":"watch","flagName":"watch","required":false,"type":"boolean","description":"Watch filesystem and re-run tests on file change"},{"name":"poll","flagName":"poll","required":false,"type":"boolean","description":"Use polling to detect filesystem changes"},{"name":"timeout","flagName":"timeout","required":false,"type":"number","description":"Define default timeout for all tests"},{"name":"retries","flagName":"retries","required":false,"type":"number","description":"Define default retries for all tests"},{"name":"failed","flagName":"failed","required":false,"type":"boolean","description":"Execute tests failed during the last run"},{"name":"clear","flagName":"clear","required":false,"type":"boolean","description":"Clear the terminal for new logs after file change","showNegatedVariantInHelp":true,"default":true},{"name":"assets","flagName":"assets","required":false,"type":"boolean","description":"Start assets bundler dev server.","showNegatedVariantInHelp":true,"default":true},{"name":"assetsArgs","flagName":"assets-args","required":false,"type":"array","description":"Define CLI arguments to pass to the assets bundler"}],"args":[{"name":"suites","argumentName":"suites","required":false,"description":"Mention suite names to run tests for selected suites","type":"spread"}],"options":{"allowUnknownFlags":true,"staysAlive":true},"filePath":"test.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/test.js"}],"version":1}
@@ -1,17 +1,44 @@
1
- import type { ApplicationService } from '../src/types.js';
2
1
  import { BaseCommand } from '../modules/ace/main.js';
2
+ /**
3
+ * The configure command is used to configure packages after installation
4
+ */
3
5
  export default class Configure extends BaseCommand {
4
6
  #private;
5
7
  static commandName: string;
6
8
  static description: string;
7
9
  name: string;
10
+ verbose?: boolean;
11
+ /**
12
+ * The root of the stubs directory. The value is defined after we import
13
+ * the package
14
+ */
8
15
  stubsRoot: string;
16
+ /**
17
+ * Publish a stub file to the user project
18
+ */
9
19
  publishStub(stubPath: string, stubData?: Record<string, any>): Promise<void>;
10
- defineEnvVariables(environmentVariables: Record<string, number | string | boolean>): Promise<void>;
11
- updateRcFile(callback: (rcFileEditor: ApplicationService['rcFileEditor']) => Promise<void> | void): Promise<void>;
20
+ /**
21
+ * Install packages using the correct package manager
22
+ * You can specify version of each package by setting it in the
23
+ * name like :
24
+ *
25
+ * ```
26
+ * installPackages(['@adonisjs/lucid@next', '@adonisjs/auth@3.0.0'])
27
+ * ```
28
+ */
29
+ installPackages(packages: {
30
+ name: string;
31
+ isDevDependency: boolean;
32
+ }[]): Promise<void>;
33
+ /**
34
+ * List the packages one should install before using the packages
35
+ */
12
36
  listPackagesToInstall(packages: {
13
37
  name: string;
14
38
  isDevDependency: boolean;
15
39
  }[]): void;
40
+ /**
41
+ * Run method is invoked by ace automatically
42
+ */
16
43
  run(): Promise<void>;
17
44
  }
@@ -1,21 +1,36 @@
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
+ */
1
9
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
10
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
11
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
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;
5
13
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
14
  };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
15
  import { slash } from '@poppinss/utils';
11
- import { EnvEditor } from '../modules/env.js';
12
- import { args, BaseCommand } from '../modules/ace/main.js';
16
+ import { installPackage, detectPackageManager } from '@antfu/install-pkg';
17
+ import { args, BaseCommand, flags } from '../modules/ace/main.js';
18
+ /**
19
+ * The configure command is used to configure packages after installation
20
+ */
13
21
  export default class Configure extends BaseCommand {
14
22
  static commandName = 'configure';
15
23
  static description = 'Configure a package post installation';
24
+ /**
25
+ * Returns the package main exports
26
+ */
16
27
  #getPackageSource(packageName) {
17
28
  return this.app.import(packageName);
18
29
  }
30
+ /**
31
+ * Returns the installation command for different
32
+ * package managers
33
+ */
19
34
  #getInstallationCommands(packages, packageManager, isDev) {
20
35
  if (!packages.length) {
21
36
  return '';
@@ -30,35 +45,78 @@ export default class Configure extends BaseCommand {
30
45
  return `${this.colors.yellow(`pnpm add${devFlag}`)} ${packages.join(' ')}`;
31
46
  }
32
47
  }
48
+ /**
49
+ * Registers VineJS provider
50
+ */
51
+ async #configureVineJS() {
52
+ const codemods = await this.createCodemods();
53
+ await codemods.updateRcFile((rcFile) => {
54
+ rcFile.addProvider('@adonisjs/core/providers/vinejs_provider');
55
+ });
56
+ }
57
+ /**
58
+ * Registers Edge provider
59
+ */
60
+ async #configureEdge() {
61
+ const codemods = await this.createCodemods();
62
+ await codemods.updateRcFile((rcFile) => {
63
+ rcFile.addProvider('@adonisjs/core/providers/edge_provider');
64
+ });
65
+ }
66
+ /**
67
+ * Publish a stub file to the user project
68
+ */
33
69
  async publishStub(stubPath, stubData) {
34
- const stub = await this.app.stubs.build(stubPath, {
70
+ const stubs = await this.app.stubs.create();
71
+ const stub = await stubs.build(stubPath, {
35
72
  source: this.stubsRoot,
36
73
  });
37
74
  const output = await stub.generate(stubData || {});
75
+ /**
76
+ * Log message
77
+ */
38
78
  const entityFileName = slash(this.app.relativePath(output.destination));
39
79
  if (output.status === 'skipped') {
40
80
  return this.logger.action(`create ${entityFileName}`).skipped(output.skipReason);
41
81
  }
42
82
  this.logger.action(`create ${entityFileName}`).succeeded();
43
83
  }
44
- async defineEnvVariables(environmentVariables) {
45
- const logs = [];
46
- const editor = new EnvEditor(this.app.appRoot);
47
- await editor.load();
48
- Object.keys(environmentVariables).forEach((key) => {
49
- const value = environmentVariables[key];
50
- editor.add(key, value);
51
- logs.push(` ${this.colors.dim(`${key}=${value}`)}`);
52
- });
53
- await editor.save();
54
- this.logger.action('update .env file').succeeded();
55
- this.logger.log(logs.join('\n'));
56
- }
57
- async updateRcFile(callback) {
58
- await callback(this.app.rcFileEditor);
59
- await this.app.rcFileEditor.save();
60
- this.logger.action('update .adonisrc.json file').succeeded();
84
+ /**
85
+ * Install packages using the correct package manager
86
+ * You can specify version of each package by setting it in the
87
+ * name like :
88
+ *
89
+ * ```
90
+ * installPackages(['@adonisjs/lucid@next', '@adonisjs/auth@3.0.0'])
91
+ * ```
92
+ */
93
+ async installPackages(packages) {
94
+ const appPath = this.app.makePath();
95
+ const silent = this.verbose === true ? false : true;
96
+ const devDeps = packages.filter((pkg) => pkg.isDevDependency).map(({ name }) => name);
97
+ const deps = packages.filter((pkg) => !pkg.isDevDependency).map(({ name }) => name);
98
+ const packageManager = await detectPackageManager(appPath);
99
+ let spinner = this.logger
100
+ .await(`installing dependencies using ${packageManager || 'npm'}`)
101
+ .start();
102
+ try {
103
+ await installPackage(deps, { cwd: appPath, silent });
104
+ await installPackage(devDeps, { dev: true, cwd: appPath, silent });
105
+ spinner.stop();
106
+ this.logger.success('dependencies installed');
107
+ this.logger.log(devDeps.map((dep) => ` ${this.colors.dim('dev')} ${dep}`).join('\n'));
108
+ this.logger.log(deps.map((dep) => ` ${this.colors.dim('prod')} ${dep}`).join('\n'));
109
+ }
110
+ catch (error) {
111
+ spinner.update('unable to install dependencies');
112
+ spinner.stop();
113
+ this.exitCode = 1;
114
+ this.logger.fatal(error);
115
+ }
61
116
  }
117
+ /**
118
+ * List the packages one should install before using the packages
119
+ */
62
120
  listPackagesToInstall(packages) {
63
121
  const devDependencies = packages.filter((pkg) => pkg.isDevDependency).map(({ name }) => name);
64
122
  const prodDependencies = packages.filter((pkg) => !pkg.isDevDependency).map(({ name }) => name);
@@ -84,22 +142,42 @@ export default class Configure extends BaseCommand {
84
142
  .forEach((line) => instructions.add(line));
85
143
  instructions.render();
86
144
  }
145
+ /**
146
+ * Run method is invoked by ace automatically
147
+ */
87
148
  async run() {
149
+ if (this.name === 'vinejs') {
150
+ return this.#configureVineJS();
151
+ }
152
+ if (this.name === 'edge') {
153
+ return this.#configureEdge();
154
+ }
88
155
  const packageExports = await this.#getPackageSource(this.name);
156
+ /**
157
+ * Warn, there are not instructions to run
158
+ */
89
159
  if (!packageExports.configure) {
90
160
  this.logger.warning(`Cannot configure "${this.name}" package. The package does not export the configure hook`);
91
161
  return;
92
162
  }
163
+ /**
164
+ * Instructions needs stubs root
165
+ */
93
166
  if (!packageExports.stubsRoot) {
94
167
  this.logger.error(`Missing "stubsRoot" export from "${this.name}" package. The stubsRoot variable is required to lookup package stubs`);
95
168
  this.exitCode = 1;
96
169
  return;
97
170
  }
98
171
  this.stubsRoot = packageExports.stubsRoot;
172
+ /**
173
+ * Run instructions
174
+ */
99
175
  await packageExports.configure(this);
100
176
  }
101
177
  }
102
178
  __decorate([
103
- args.string({ description: 'Package name' }),
104
- __metadata("design:type", String)
179
+ args.string({ description: 'Package name' })
105
180
  ], Configure.prototype, "name", void 0);
181
+ __decorate([
182
+ flags.boolean({ description: 'Display logs in verbose mode' })
183
+ ], Configure.prototype, "verbose", void 0);
@@ -1,4 +1,8 @@
1
1
  import { BaseCommand } from '../modules/ace/main.js';
2
+ /**
3
+ * The eject command is used to eject templates to the user
4
+ * application codebase for customizing them
5
+ */
2
6
  export default class Eject extends BaseCommand {
3
7
  static commandName: string;
4
8
  static description: string;
@@ -1,19 +1,29 @@
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
+ */
1
9
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
10
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
11
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
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;
5
13
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
14
  };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
15
  import { slash } from '@poppinss/utils';
11
16
  import { args, BaseCommand, flags } from '../modules/ace/main.js';
17
+ /**
18
+ * The eject command is used to eject templates to the user
19
+ * application codebase for customizing them
20
+ */
12
21
  export default class Eject extends BaseCommand {
13
22
  static commandName = 'eject';
14
23
  static description = 'Eject scaffolding stubs to your application root';
15
24
  async run() {
16
- const copied = await this.app.stubs.copy(this.stubPath, {
25
+ const stubs = await this.app.stubs.create();
26
+ const copied = await stubs.copy(this.stubPath, {
17
27
  pkg: this.pkg,
18
28
  });
19
29
  copied.forEach((stubPath) => {
@@ -22,13 +32,11 @@ export default class Eject extends BaseCommand {
22
32
  }
23
33
  }
24
34
  __decorate([
25
- args.string({ description: 'Path to the stubs directory or a single stub file' }),
26
- __metadata("design:type", String)
35
+ args.string({ description: 'Path to the stubs directory or a single stub file' })
27
36
  ], Eject.prototype, "stubPath", void 0);
28
37
  __decorate([
29
38
  flags.string({
30
39
  description: 'Mention package name for searching stubs',
31
40
  default: '@adonisjs/core',
32
- }),
33
- __metadata("design:type", String)
41
+ })
34
42
  ], Eject.prototype, "pkg", void 0);
@@ -1,4 +1,8 @@
1
1
  import { BaseCommand } from '../modules/ace/main.js';
2
+ /**
3
+ * The generate key command is used to generate the app key
4
+ * and write it inside the .env file.
5
+ */
2
6
  export default class GenerateKey extends BaseCommand {
3
7
  static commandName: string;
4
8
  static description: string;
@@ -1,15 +1,24 @@
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
+ */
1
9
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
10
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
11
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
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;
5
13
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
14
  };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
15
  import string from '@poppinss/utils/string';
11
- import { EnvEditor } from '../modules/env.js';
16
+ import { EnvEditor } from '@adonisjs/env/editor';
12
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
+ */
13
22
  export default class GenerateKey extends BaseCommand {
14
23
  static commandName = 'generate:key';
15
24
  static description = 'Generate a secure random application key';
@@ -36,12 +45,10 @@ export default class GenerateKey extends BaseCommand {
36
45
  __decorate([
37
46
  flags.boolean({
38
47
  description: 'Display the key on the terminal, instead of writing it to .env file',
39
- }),
40
- __metadata("design:type", Boolean)
48
+ })
41
49
  ], GenerateKey.prototype, "show", void 0);
42
50
  __decorate([
43
51
  flags.boolean({
44
52
  description: 'Force update .env file in production environment',
45
- }),
46
- __metadata("design:type", Boolean)
53
+ })
47
54
  ], GenerateKey.prototype, "force", void 0);
@@ -0,0 +1,9 @@
1
+ import { BaseCommand } from '../modules/ace/main.js';
2
+ /**
3
+ * Prints the RcFile file contents to the terminal
4
+ */
5
+ export default class InspectRCFile extends BaseCommand {
6
+ static commandName: string;
7
+ static description: string;
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,36 @@
1
+ /*
2
+ * @adonisjs/core
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ import lodash from '@poppinss/utils/lodash';
10
+ import { BaseCommand } from '../modules/ace/main.js';
11
+ /**
12
+ * Prints the RcFile file contents to the terminal
13
+ */
14
+ export default class InspectRCFile extends BaseCommand {
15
+ static commandName = 'inspect:rcfile';
16
+ static description = 'Inspect the RC file with its default values';
17
+ async run() {
18
+ const rcContents = lodash.omit(this.app.rcFile, ['raw']);
19
+ rcContents.providers = rcContents.providers?.map((provider) => {
20
+ return {
21
+ ...provider,
22
+ file: provider.file.toString(),
23
+ };
24
+ });
25
+ rcContents.preloads = rcContents.preloads?.map((preload) => {
26
+ return {
27
+ ...preload,
28
+ file: preload.file.toString(),
29
+ };
30
+ });
31
+ rcContents.commands = rcContents.commands?.map((command) => {
32
+ return command.toString();
33
+ });
34
+ this.logger.log(JSON.stringify(rcContents, null, 2));
35
+ }
36
+ }