@adonisjs/core 6.1.5-0 → 6.1.5-10

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 (175) 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 +36 -0
  5. package/build/commands/configure.js +84 -6
  6. package/build/commands/eject.d.ts +4 -0
  7. package/build/commands/eject.js +14 -7
  8. package/build/commands/generate_key.d.ts +4 -0
  9. package/build/commands/generate_key.js +14 -7
  10. package/build/commands/inspect_rcfile.d.ts +9 -0
  11. package/build/commands/inspect_rcfile.js +20 -0
  12. package/build/commands/list/routes.d.ts +36 -0
  13. package/build/commands/list/routes.js +94 -0
  14. package/build/commands/make/_base.d.ts +31 -1
  15. package/build/commands/make/_base.js +18 -10
  16. package/build/commands/make/command.d.ts +6 -0
  17. package/build/commands/make/command.js +15 -5
  18. package/build/commands/make/controller.d.ts +9 -0
  19. package/build/commands/make/controller.js +30 -11
  20. package/build/commands/make/event.d.ts +6 -0
  21. package/build/commands/make/event.js +15 -5
  22. package/build/commands/make/exception.d.ts +14 -0
  23. package/build/commands/make/exception.js +35 -0
  24. package/build/commands/make/listener.d.ts +7 -0
  25. package/build/commands/make/listener.js +20 -7
  26. package/build/commands/make/middleware.d.ts +7 -0
  27. package/build/commands/make/middleware.js +16 -5
  28. package/build/commands/make/preload.d.ts +22 -0
  29. package/build/commands/make/preload.js +95 -0
  30. package/build/commands/make/provider.d.ts +6 -0
  31. package/build/commands/make/provider.js +22 -6
  32. package/build/commands/make/service.d.ts +14 -0
  33. package/build/commands/make/service.js +35 -0
  34. package/build/commands/make/test.d.ts +19 -0
  35. package/build/commands/make/test.js +103 -0
  36. package/build/commands/repl.d.ts +14 -0
  37. package/build/commands/repl.js +30 -0
  38. package/build/commands/serve.d.ts +12 -0
  39. package/build/commands/serve.js +78 -27
  40. package/build/commands/test.d.ts +32 -0
  41. package/build/commands/test.js +203 -0
  42. package/build/factories/app.js +8 -0
  43. package/build/factories/bodyparser.js +8 -0
  44. package/build/factories/core/ace.d.ts +4 -1
  45. package/build/factories/core/ace.js +11 -0
  46. package/build/factories/core/ignitor.d.ts +20 -1
  47. package/build/factories/core/ignitor.js +35 -1
  48. package/build/factories/core/main.js +8 -0
  49. package/build/factories/core/test_utils.d.ts +4 -1
  50. package/build/factories/core/test_utils.js +11 -0
  51. package/build/factories/encryption.js +8 -0
  52. package/build/factories/events.js +8 -0
  53. package/build/factories/hash.js +8 -0
  54. package/build/factories/http.js +8 -0
  55. package/build/factories/logger.js +8 -0
  56. package/build/factories/stubs.d.ts +10 -0
  57. package/build/factories/stubs.js +21 -0
  58. package/build/index.d.ts +5 -1
  59. package/build/index.js +13 -0
  60. package/build/modules/ace/commands.d.ts +123 -0
  61. package/build/modules/ace/commands.js +79 -0
  62. package/build/modules/ace/create_kernel.d.ts +9 -0
  63. package/build/modules/ace/create_kernel.js +31 -0
  64. package/build/modules/ace/kernel.d.ts +4 -0
  65. package/build/modules/ace/kernel.js +12 -0
  66. package/build/modules/ace/main.d.ts +1 -1
  67. package/build/modules/ace/main.js +9 -1
  68. package/build/modules/ace/shell.d.ts +9 -1
  69. package/build/modules/ace/shell.js +21 -0
  70. package/build/modules/app.js +8 -0
  71. package/build/modules/bodyparser/bodyparser_middleware.d.ts +4 -0
  72. package/build/modules/bodyparser/bodyparser_middleware.js +12 -0
  73. package/build/modules/bodyparser/main.js +8 -0
  74. package/build/modules/config.js +8 -0
  75. package/build/modules/container.js +8 -0
  76. package/build/modules/encryption.js +8 -0
  77. package/build/modules/env.js +8 -0
  78. package/build/modules/events.js +8 -0
  79. package/build/modules/hash/define_config.d.ts +3 -0
  80. package/build/modules/hash/define_config.js +20 -0
  81. package/build/modules/hash/drivers_collection.d.ts +16 -4
  82. package/build/modules/hash/drivers_collection.js +31 -8
  83. package/build/modules/hash/main.d.ts +1 -0
  84. package/build/modules/hash/main.js +9 -0
  85. package/build/modules/http/main.d.ts +2 -0
  86. package/build/modules/http/main.js +10 -0
  87. package/build/modules/http/request_validator.d.ts +44 -0
  88. package/build/modules/http/request_validator.js +74 -0
  89. package/build/modules/logger.js +8 -0
  90. package/build/modules/repl.d.ts +1 -0
  91. package/build/modules/repl.js +9 -0
  92. package/build/providers/app_provider.d.ts +31 -2
  93. package/build/providers/app_provider.js +44 -15
  94. package/build/providers/hash_provider.d.ts +16 -0
  95. package/build/providers/hash_provider.js +31 -6
  96. package/build/providers/http_provider.d.ts +17 -0
  97. package/build/providers/http_provider.js +26 -1
  98. package/build/providers/repl_provider.d.ts +13 -0
  99. package/build/providers/repl_provider.js +37 -0
  100. package/build/services/ace.js +15 -0
  101. package/build/services/app.d.ts +8 -0
  102. package/build/services/app.js +16 -0
  103. package/build/services/config.js +11 -0
  104. package/build/services/emitter.js +13 -2
  105. package/build/services/encryption.js +13 -2
  106. package/build/services/hash.js +13 -2
  107. package/build/services/logger.js +13 -2
  108. package/build/services/repl.d.ts +3 -0
  109. package/build/services/repl.js +18 -0
  110. package/build/services/router.js +13 -2
  111. package/build/services/server.js +13 -2
  112. package/build/services/test_utils.js +15 -0
  113. package/build/src/bindings/repl.d.ts +6 -0
  114. package/build/src/bindings/repl.js +78 -0
  115. package/build/src/cli_formatters/routes_list.d.ts +63 -0
  116. package/build/src/cli_formatters/routes_list.js +376 -0
  117. package/build/src/debug.d.ts +1 -1
  118. package/build/src/debug.js +8 -0
  119. package/build/src/exceptions.d.ts +1 -0
  120. package/build/src/exceptions.js +9 -0
  121. package/build/src/helpers/is.js +8 -0
  122. package/build/src/helpers/main.d.ts +3 -1
  123. package/build/src/helpers/main.js +11 -1
  124. package/build/src/helpers/parse_binding_reference.d.ts +45 -0
  125. package/build/src/helpers/parse_binding_reference.js +83 -0
  126. package/build/src/helpers/string.d.ts +26 -0
  127. package/build/src/helpers/string.js +15 -0
  128. package/build/src/helpers/types.d.ts +7 -2
  129. package/build/src/helpers/types.js +13 -0
  130. package/build/src/ignitor/ace.d.ts +12 -0
  131. package/build/src/ignitor/ace.js +50 -1
  132. package/build/src/ignitor/http.d.ts +9 -2
  133. package/build/src/ignitor/http.js +67 -0
  134. package/build/src/ignitor/main.d.ts +29 -1
  135. package/build/src/ignitor/main.js +56 -0
  136. package/build/src/ignitor/test.d.ts +10 -0
  137. package/build/src/ignitor/test.js +25 -0
  138. package/build/src/internal_helpers.d.ts +12 -5
  139. package/build/src/internal_helpers.js +35 -7
  140. package/build/src/test_utils/http.d.ts +10 -2
  141. package/build/src/test_utils/http.js +19 -0
  142. package/build/src/test_utils/main.d.ts +21 -3
  143. package/build/src/test_utils/main.js +27 -1
  144. package/build/src/types.d.ts +61 -3
  145. package/build/src/types.js +8 -0
  146. package/build/src/vinejs/extensions/main.d.ts +1 -0
  147. package/build/src/vinejs/extensions/main.js +9 -0
  148. package/build/src/vinejs/extensions/validates_files.d.ts +22 -0
  149. package/build/src/vinejs/extensions/validates_files.js +76 -0
  150. package/build/stubs/index.js +8 -0
  151. package/build/stubs/make/exception/main.stub +10 -0
  152. package/build/stubs/make/preload_file/main.stub +4 -0
  153. package/build/stubs/make/service/main.stub +4 -0
  154. package/build/stubs/make/test/main.stub +11 -0
  155. package/build/toolkit/commands/index_commands.d.ts +4 -0
  156. package/build/toolkit/commands/index_commands.js +13 -5
  157. package/build/toolkit/main.js +11 -0
  158. package/build/types/ace.js +8 -0
  159. package/build/types/app.js +8 -0
  160. package/build/types/bodyparser.js +8 -0
  161. package/build/types/container.js +8 -0
  162. package/build/types/encryption.js +8 -0
  163. package/build/types/events.js +8 -0
  164. package/build/types/hash.js +8 -0
  165. package/build/types/http.js +8 -0
  166. package/build/types/logger.js +8 -0
  167. package/build/types/repl.d.ts +1 -0
  168. package/build/types/repl.js +9 -0
  169. package/package.json +76 -123
  170. package/build/legacy/validator.d.ts +0 -1
  171. package/build/legacy/validator.js +0 -1
  172. package/build/modules/http.d.ts +0 -1
  173. package/build/modules/http.js +0 -1
  174. package/build/src/helpers/string_builder.d.ts +0 -23
  175. package/build/src/helpers/string_builder.js +0 -86
@@ -2,25 +2,148 @@ import { BaseCommand as AceBaseCommand, ListCommand as AceListCommand } from '@a
2
2
  import { Kernel } from './kernel.js';
3
3
  import type { ApplicationService } from '../../src/types.js';
4
4
  import type { CommandOptions, ParsedOutput, UIPrimitives } from '../../types/ace.js';
5
+ /**
6
+ * Wrapper around the stub generation logic.
7
+ * Allow commands to easily generate files from given stubs
8
+ */
9
+ declare class StubGenerator {
10
+ #private;
11
+ constructor(command: BaseCommand, flags: Record<string, any>);
12
+ generate(stubsRoot: string, stubPath: string, stubState: Record<string, any>): Promise<{
13
+ relativeFileName: string;
14
+ contents: any;
15
+ destination: any;
16
+ attributes: any;
17
+ status: "created";
18
+ skipReason: null;
19
+ } | {
20
+ relativeFileName: string;
21
+ contents: any;
22
+ destination: any;
23
+ attributes: any;
24
+ status: "force_created";
25
+ skipReason: null;
26
+ } | {
27
+ relativeFileName: string;
28
+ contents: any;
29
+ destination: any;
30
+ attributes: any;
31
+ status: "skipped";
32
+ skipReason: string;
33
+ }>;
34
+ }
35
+ /**
36
+ * The base command to create custom ace commands. The AdonisJS base commands
37
+ * receives the application instance
38
+ */
5
39
  export declare class BaseCommand extends AceBaseCommand {
6
40
  app: ApplicationService;
7
41
  kernel: Kernel;
42
+ stubGenerator: StubGenerator;
8
43
  static options: CommandOptions;
9
44
  get staysAlive(): boolean | undefined;
10
45
  get startApp(): boolean | undefined;
11
46
  constructor(app: ApplicationService, kernel: Kernel, parsed: ParsedOutput, ui: UIPrimitives, prompt: Kernel['prompt']);
47
+ /**
48
+ * The prepare template method is used to prepare the
49
+ * state for the command. This is the first method
50
+ * executed on a given command instance.
51
+ */
12
52
  prepare?(..._: any[]): any;
53
+ /**
54
+ * The interact template method is used to display the prompts
55
+ * to the user. The method is called after the prepare
56
+ * method.
57
+ */
13
58
  interact?(..._: any[]): any;
59
+ /**
60
+ * The completed method is the method invoked after the command
61
+ * finishes or results in an error.
62
+ *
63
+ * You can access the command error using the `this.error` property.
64
+ * Returning `true` from completed method supresses the error
65
+ * reporting to the kernel layer.
66
+ */
14
67
  completed?(..._: any[]): any;
68
+ /**
69
+ * Make a new file using the given stub
70
+ */
71
+ makeUsingStub(stubPath: string, stubState: Record<string, any>, stubsRoot: string): Promise<{
72
+ relativeFileName: string;
73
+ contents: any;
74
+ destination: any;
75
+ attributes: any;
76
+ status: "created";
77
+ skipReason: null;
78
+ } | {
79
+ relativeFileName: string;
80
+ contents: any;
81
+ destination: any;
82
+ attributes: any;
83
+ status: "force_created";
84
+ skipReason: null;
85
+ } | {
86
+ relativeFileName: string;
87
+ contents: any;
88
+ destination: any;
89
+ attributes: any;
90
+ status: "skipped";
91
+ skipReason: string;
92
+ }>;
93
+ /**
94
+ * Executes the command
95
+ */
15
96
  exec(): Promise<any>;
97
+ /**
98
+ * Terminate the app. A command should prefer calling this method
99
+ * over the "app.terminate", because this method only triggers
100
+ * app termination when the current command is in the charge
101
+ * of the process.
102
+ */
16
103
  terminate(): Promise<void>;
17
104
  }
105
+ /**
106
+ * The List command is used to display a list of commands
107
+ */
18
108
  export declare class ListCommand extends AceListCommand implements BaseCommand {
19
109
  app: ApplicationService;
20
110
  kernel: Kernel;
111
+ stubGenerator: StubGenerator;
21
112
  static options: CommandOptions;
22
113
  get staysAlive(): boolean | undefined;
23
114
  get startApp(): boolean | undefined;
24
115
  constructor(app: ApplicationService, kernel: Kernel, parsed: ParsedOutput, ui: UIPrimitives, prompt: Kernel['prompt']);
116
+ /**
117
+ * Make a new file using the given stub
118
+ */
119
+ makeUsingStub(stubPath: string, stubState: Record<string, any>, stubsRoot: string): Promise<{
120
+ relativeFileName: string;
121
+ contents: any;
122
+ destination: any;
123
+ attributes: any;
124
+ status: "created";
125
+ skipReason: null;
126
+ } | {
127
+ relativeFileName: string;
128
+ contents: any;
129
+ destination: any;
130
+ attributes: any;
131
+ status: "force_created";
132
+ skipReason: null;
133
+ } | {
134
+ relativeFileName: string;
135
+ contents: any;
136
+ destination: any;
137
+ attributes: any;
138
+ status: "skipped";
139
+ skipReason: string;
140
+ }>;
141
+ /**
142
+ * Terminate the app. A command should prefer calling this method
143
+ * over the "app.terminate", because this method only triggers
144
+ * app termination when the current command is in the charge
145
+ * of the process.
146
+ */
25
147
  terminate(): Promise<void>;
26
148
  }
149
+ export {};
@@ -1,7 +1,45 @@
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 { slash } from '@poppinss/utils';
1
10
  import { BaseCommand as AceBaseCommand, ListCommand as AceListCommand } from '@adonisjs/ace';
11
+ /**
12
+ * Wrapper around the stub generation logic.
13
+ * Allow commands to easily generate files from given stubs
14
+ */
15
+ class StubGenerator {
16
+ #command;
17
+ #flags;
18
+ constructor(command, flags) {
19
+ this.#command = command;
20
+ this.#flags = flags;
21
+ }
22
+ async generate(stubsRoot, stubPath, stubState) {
23
+ const stub = await this.#command.app.stubs.build(stubPath, { source: stubsRoot });
24
+ const output = await stub.generate(Object.assign({ flags: this.#flags }, stubState));
25
+ const entityFileName = slash(this.#command.app.relativePath(output.destination));
26
+ const result = { ...output, relativeFileName: entityFileName };
27
+ if (output.status === 'skipped') {
28
+ this.#command.logger.action(`create ${entityFileName}`).skipped(output.skipReason);
29
+ return result;
30
+ }
31
+ this.#command.logger.action(`create ${entityFileName}`).succeeded();
32
+ return result;
33
+ }
34
+ }
35
+ /**
36
+ * The base command to create custom ace commands. The AdonisJS base commands
37
+ * receives the application instance
38
+ */
2
39
  export class BaseCommand extends AceBaseCommand {
3
40
  app;
4
41
  kernel;
42
+ stubGenerator = new StubGenerator(this, this.parsed?.flags || {});
5
43
  static options = {};
6
44
  get staysAlive() {
7
45
  return this.constructor.options.staysAlive;
@@ -14,12 +52,27 @@ export class BaseCommand extends AceBaseCommand {
14
52
  this.app = app;
15
53
  this.kernel = kernel;
16
54
  }
55
+ /**
56
+ * Make a new file using the given stub
57
+ */
58
+ async makeUsingStub(stubPath, stubState, stubsRoot) {
59
+ return this.stubGenerator.generate(stubsRoot, stubPath, stubState);
60
+ }
61
+ /**
62
+ * Executes the command
63
+ */
17
64
  async exec() {
18
65
  this.hydrate();
19
66
  try {
67
+ /**
68
+ * Executing the template methods
69
+ */
20
70
  this.prepare && (await this.app.container.call(this, 'prepare'));
21
71
  this.interact && (await this.app.container.call(this, 'interact'));
22
72
  const result = await this.app.container.call(this, 'run');
73
+ /**
74
+ * Set exit code
75
+ */
23
76
  this.result = this.result === undefined ? result : this.result;
24
77
  this.exitCode = this.exitCode ?? 0;
25
78
  }
@@ -27,6 +80,10 @@ export class BaseCommand extends AceBaseCommand {
27
80
  this.error = error;
28
81
  this.exitCode = this.exitCode ?? 1;
29
82
  }
83
+ /**
84
+ * Run the completed method (if exists) and check if has handled
85
+ * the error
86
+ */
30
87
  let errorHandled = this.completed
31
88
  ? await this.app.container.call(this, 'completed')
32
89
  : false;
@@ -35,15 +92,25 @@ export class BaseCommand extends AceBaseCommand {
35
92
  }
36
93
  return this.result;
37
94
  }
95
+ /**
96
+ * Terminate the app. A command should prefer calling this method
97
+ * over the "app.terminate", because this method only triggers
98
+ * app termination when the current command is in the charge
99
+ * of the process.
100
+ */
38
101
  async terminate() {
39
102
  if (this.kernel.getMainCommand() === this) {
40
103
  await this.app.terminate();
41
104
  }
42
105
  }
43
106
  }
107
+ /**
108
+ * The List command is used to display a list of commands
109
+ */
44
110
  export class ListCommand extends AceListCommand {
45
111
  app;
46
112
  kernel;
113
+ stubGenerator = new StubGenerator(this, this.parsed?.flags || {});
47
114
  static options = {};
48
115
  get staysAlive() {
49
116
  return this.constructor.options.staysAlive;
@@ -56,6 +123,18 @@ export class ListCommand extends AceListCommand {
56
123
  this.app = app;
57
124
  this.kernel = kernel;
58
125
  }
126
+ /**
127
+ * Make a new file using the given stub
128
+ */
129
+ async makeUsingStub(stubPath, stubState, stubsRoot) {
130
+ return this.stubGenerator.generate(stubsRoot, stubPath, stubState);
131
+ }
132
+ /**
133
+ * Terminate the app. A command should prefer calling this method
134
+ * over the "app.terminate", because this method only triggers
135
+ * app termination when the current command is in the charge
136
+ * of the process.
137
+ */
59
138
  async terminate() {
60
139
  if (this.kernel.getMainCommand() === this) {
61
140
  await this.app.terminate();
@@ -1,3 +1,12 @@
1
1
  import { Kernel } from './main.js';
2
2
  import type { ApplicationService } from '../../src/types.js';
3
+ /**
4
+ * We abstract the logic for creating the ace kernel in this
5
+ * file. So that both the "console" environment and rest
6
+ * of the environments can configure and use ace.
7
+ *
8
+ * - In console environment, ace manages the lifecycle of the process
9
+ * - In other environments, ace can be pulled from the container to
10
+ * run commands
11
+ */
3
12
  export declare function createAceKernel(app: ApplicationService): Kernel;
@@ -1,11 +1,36 @@
1
+ /*
2
+ * @adonisjs/ace
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
  import { Kernel } from './main.js';
2
10
  import { FsLoader, HelpCommand } from '../../modules/ace/main.js';
11
+ /**
12
+ * We abstract the logic for creating the ace kernel in this
13
+ * file. So that both the "console" environment and rest
14
+ * of the environments can configure and use ace.
15
+ *
16
+ * - In console environment, ace manages the lifecycle of the process
17
+ * - In other environments, ace can be pulled from the container to
18
+ * run commands
19
+ */
3
20
  export function createAceKernel(app) {
4
21
  const kernel = new Kernel(app);
5
22
  kernel.addLoader(new FsLoader(app.commandsPath()));
23
+ kernel.info.set('binary', 'node ace');
24
+ /**
25
+ * Lazy import commands mentioned in the "commands" array
26
+ * of rcFile
27
+ */
6
28
  app.rcFile.commands.forEach((commandModule) => {
7
29
  kernel.addLoader(() => app.import(commandModule));
8
30
  });
31
+ /**
32
+ * Custom global flags
33
+ */
9
34
  kernel.defineFlag('ansi', {
10
35
  type: 'boolean',
11
36
  showNegatedVariantInHelp: true,
@@ -15,6 +40,9 @@ export function createAceKernel(app) {
15
40
  type: 'boolean',
16
41
  description: HelpCommand.description,
17
42
  });
43
+ /**
44
+ * Flag listener to turn colors on/off
45
+ */
18
46
  kernel.on('ansi', (_, $kernel, parsed) => {
19
47
  if (parsed.flags.ansi === false) {
20
48
  $kernel.ui.switchMode('silent');
@@ -23,6 +51,9 @@ export function createAceKernel(app) {
23
51
  $kernel.ui.switchMode('normal');
24
52
  }
25
53
  });
54
+ /**
55
+ * Flag listener to display the help
56
+ */
26
57
  kernel.on('help', async (command, $kernel, parsed) => {
27
58
  parsed.args.unshift(command.commandName);
28
59
  const help = new HelpCommand($kernel, parsed, kernel.ui, kernel.prompt);
@@ -1,6 +1,10 @@
1
1
  import { Kernel as AceKernel } from '@adonisjs/ace';
2
2
  import { BaseCommand } from './commands.js';
3
3
  import type { ApplicationService } from '../../src/types.js';
4
+ /**
5
+ * The base command to create custom ace commands. The AdonisJS base commands
6
+ * receives the application instance
7
+ */
4
8
  export declare class Kernel extends AceKernel<typeof BaseCommand> {
5
9
  app: ApplicationService;
6
10
  constructor(app: ApplicationService);
@@ -1,5 +1,17 @@
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
  import { Kernel as AceKernel } from '@adonisjs/ace';
2
10
  import { ListCommand } from './commands.js';
11
+ /**
12
+ * The base command to create custom ace commands. The AdonisJS base commands
13
+ * receives the application instance
14
+ */
3
15
  export class Kernel extends AceKernel {
4
16
  app;
5
17
  constructor(app) {
@@ -1,3 +1,3 @@
1
1
  export { Kernel } from './kernel.js';
2
2
  export { BaseCommand, ListCommand } from './commands.js';
3
- export { args, flags, errors, Parser, FsLoader, ListLoader, HelpCommand, IndexGenerator, } from '@adonisjs/ace';
3
+ export { args, flags, errors, Parser, FsLoader, ListLoader, cliHelpers, HelpCommand, IndexGenerator, } from '@adonisjs/ace';
@@ -1,3 +1,11 @@
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
  export { Kernel } from './kernel.js';
2
10
  export { BaseCommand, ListCommand } from './commands.js';
3
- export { args, flags, errors, Parser, FsLoader, ListLoader, HelpCommand, IndexGenerator, } from '@adonisjs/ace';
11
+ export { args, flags, errors, Parser, FsLoader, ListLoader, cliHelpers, HelpCommand, IndexGenerator, } from '@adonisjs/ace';
@@ -1,4 +1,12 @@
1
- /// <reference types="node" resolution-mode="require"/>
1
+ /// <reference types="@types/node" resolution-mode="require"/>
2
+ /**
3
+ * Ace shell is used to run the ace commands inside a TypeScript project
4
+ * without pre-compiling TypeScript source files.
5
+ *
6
+ * Under the hood a child process is used to execute the "bin/console.ts" file. This
7
+ * is required because we have to use "ts-node/esm" loader in order to run TypeScript
8
+ * files.
9
+ */
2
10
  export declare function aceShell(cwd: URL): {
3
11
  handle(argv: string[]): Promise<void>;
4
12
  };
@@ -1,8 +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
  const DEFAULT_NODE_ARGS = [
10
+ // Use ts-node/esm loader. The project must install it
2
11
  '--loader=ts-node/esm',
12
+ // Disable annonying warnings
3
13
  '--no-warnings',
14
+ // Enable expiremental meta resolve for cases where someone uses magic import string
4
15
  '--experimental-import-meta-resolve',
16
+ // Enable source maps, since TSNode source maps are broken
17
+ '--enable-source-maps',
5
18
  ];
19
+ /**
20
+ * Ace shell is used to run the ace commands inside a TypeScript project
21
+ * without pre-compiling TypeScript source files.
22
+ *
23
+ * Under the hood a child process is used to execute the "bin/console.ts" file. This
24
+ * is required because we have to use "ts-node/esm" loader in order to run TypeScript
25
+ * files.
26
+ */
6
27
  export function aceShell(cwd) {
7
28
  return {
8
29
  async handle(argv) {
@@ -1 +1,9 @@
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
  export * from '@adonisjs/application';
@@ -1,2 +1,6 @@
1
1
  import { BodyParserMiddleware } from '@adonisjs/bodyparser/bodyparser_middleware';
2
+ /**
3
+ * Default export allows lazy importing middleware with
4
+ * destructuring the named exports
5
+ */
2
6
  export default BodyParserMiddleware;
@@ -1,2 +1,14 @@
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
  import { BodyParserMiddleware } from '@adonisjs/bodyparser/bodyparser_middleware';
10
+ /**
11
+ * Default export allows lazy importing middleware with
12
+ * destructuring the named exports
13
+ */
2
14
  export default BodyParserMiddleware;
@@ -1 +1,9 @@
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
  export * from '@adonisjs/bodyparser';
@@ -1 +1,9 @@
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
  export * from '@adonisjs/config';
@@ -1 +1,9 @@
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
  export * from '@adonisjs/fold';
@@ -1 +1,9 @@
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
  export * from '@adonisjs/encryption';
@@ -1 +1,9 @@
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
  export * from '@adonisjs/env';
@@ -1 +1,9 @@
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
  export * from '@adonisjs/events';
@@ -1,5 +1,8 @@
1
1
  import type { HashDriversList } from '../../src/types.js';
2
2
  import type { ManagerDriverFactory } from '../../types/hash.js';
3
+ /**
4
+ * Define config for the hash service.
5
+ */
3
6
  export declare function defineConfig<KnownHashers extends Record<string, {
4
7
  [K in keyof HashDriversList]: {
5
8
  driver: K;
@@ -1,12 +1,32 @@
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
  import { InvalidArgumentsException } from '@poppinss/utils';
2
10
  import driversCollection from './drivers_collection.js';
11
+ /**
12
+ * Define config for the hash service.
13
+ */
3
14
  export function defineConfig(config) {
15
+ /**
16
+ * Hashers list should always be provided
17
+ */
4
18
  if (!config.list) {
5
19
  throw new InvalidArgumentsException('Missing "list" property in hash config');
6
20
  }
21
+ /**
22
+ * The default hasher should be mentioned in the list
23
+ */
7
24
  if (config.default && !config.list[config.default]) {
8
25
  throw new InvalidArgumentsException(`Missing "list.${String(config.default)}" in hash config. It is referenced by the "default" property`);
9
26
  }
27
+ /**
28
+ * Converting list config to a collection that hash manager can use
29
+ */
10
30
  const managerHashers = Object.keys(config.list).reduce((result, disk) => {
11
31
  const hasherConfig = config.list[disk];
12
32
  result[disk] = () => driversCollection.create(hasherConfig.driver, hasherConfig);
@@ -1,9 +1,21 @@
1
- import { Argon, Bcrypt, Scrypt } from './main.js';
2
1
  import type { HashDriversList } from '../../src/types.js';
2
+ /**
3
+ * A global collection of Hash drivers
4
+ */
3
5
  declare class HashDriversCollection {
6
+ /**
7
+ * List of registered drivers
8
+ */
4
9
  list: Partial<HashDriversList>;
10
+ /**
11
+ * Extend drivers collection and add a custom
12
+ * driver to it.
13
+ */
5
14
  extend<Name extends keyof HashDriversList>(driverName: Name, factoryCallback: HashDriversList[Name]): this;
6
- create<Name extends keyof HashDriversList>(name: Name, config: Parameters<HashDriversList[Name]>[0]): Bcrypt | Argon | Scrypt;
15
+ /**
16
+ * Creates the driver instance with config
17
+ */
18
+ create<Name extends keyof HashDriversList>(name: Name, config: Parameters<HashDriversList[Name]>[0]): import("@adonisjs/hash").Bcrypt | import("@adonisjs/hash").Argon | import("@adonisjs/hash").Scrypt;
7
19
  }
8
- declare const hashDriversCollection: HashDriversCollection;
9
- export default hashDriversCollection;
20
+ declare const _default: HashDriversCollection;
21
+ export default _default;
@@ -1,15 +1,39 @@
1
- import { Argon, Bcrypt, Scrypt } from './main.js';
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
+ /**
10
+ * This class exists in the core, because it maintains a list of
11
+ * globally available drivers applicable to the hash manager
12
+ * instance registered with the container.
13
+ *
14
+ * In other words, these drivers are not needed by the hash module
15
+ * regular usage and specific to AdonisJS container flow.
16
+ */
2
17
  import { RuntimeException } from '@poppinss/utils';
18
+ /**
19
+ * A global collection of Hash drivers
20
+ */
3
21
  class HashDriversCollection {
4
- list = {
5
- bcrypt: (config) => new Bcrypt(config),
6
- argon2: (config) => new Argon(config),
7
- scrypt: (config) => new Scrypt(config),
8
- };
22
+ /**
23
+ * List of registered drivers
24
+ */
25
+ list = {};
26
+ /**
27
+ * Extend drivers collection and add a custom
28
+ * driver to it.
29
+ */
9
30
  extend(driverName, factoryCallback) {
10
31
  this.list[driverName] = factoryCallback;
11
32
  return this;
12
33
  }
34
+ /**
35
+ * Creates the driver instance with config
36
+ */
13
37
  create(name, config) {
14
38
  const driverFactory = this.list[name];
15
39
  if (!driverFactory) {
@@ -18,5 +42,4 @@ class HashDriversCollection {
18
42
  return driverFactory(config);
19
43
  }
20
44
  }
21
- const hashDriversCollection = new HashDriversCollection();
22
- export default hashDriversCollection;
45
+ export default new HashDriversCollection();
@@ -1,2 +1,3 @@
1
1
  export * from '@adonisjs/hash';
2
2
  export { defineConfig } from './define_config.js';
3
+ export { default as driversList } from './drivers_collection.js';