@adonisjs/core 7.0.0-next.1 → 7.0.0-next.11

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 (145) hide show
  1. package/build/commands/add.js +40 -110
  2. package/build/commands/build.js +51 -107
  3. package/build/commands/configure.js +82 -177
  4. package/build/commands/eject.js +17 -60
  5. package/build/commands/env/add.js +55 -134
  6. package/build/commands/generate_key.js +22 -66
  7. package/build/commands/inspect_rcfile.js +27 -55
  8. package/build/commands/list/routes.js +246 -116
  9. package/build/commands/make/command.js +15 -57
  10. package/build/commands/make/controller.js +43 -120
  11. package/build/commands/make/event.js +16 -62
  12. package/build/commands/make/exception.js +16 -62
  13. package/build/commands/make/listener.js +36 -93
  14. package/build/commands/make/middleware.js +41 -101
  15. package/build/commands/make/preload.js +47 -113
  16. package/build/commands/make/provider.js +47 -112
  17. package/build/commands/make/service.js +16 -55
  18. package/build/commands/make/test.js +47 -132
  19. package/build/commands/make/transformer.js +17 -64
  20. package/build/commands/make/validator.js +20 -80
  21. package/build/commands/make/view.js +15 -56
  22. package/build/commands/repl.js +17 -50
  23. package/build/commands/serve.js +80 -156
  24. package/build/commands/test.js +92 -208
  25. package/build/factories/app.js +2 -9
  26. package/build/factories/bodyparser.js +2 -9
  27. package/build/factories/core/ace.js +15 -46
  28. package/build/factories/core/ignitor.js +12 -180
  29. package/build/factories/core/main.js +22 -11
  30. package/build/factories/core/test_utils.js +19 -43
  31. package/build/factories/encryption.js +2 -9
  32. package/build/factories/events.js +2 -9
  33. package/build/factories/hash.js +2 -9
  34. package/build/factories/http.js +2 -9
  35. package/build/factories/logger.js +2 -9
  36. package/build/factories/stubs.js +28 -91
  37. package/build/index.js +13 -46
  38. package/build/modules/ace/codemods.d.ts +109 -14
  39. package/build/modules/ace/codemods.js +222 -374
  40. package/build/modules/ace/main.d.ts +30 -0
  41. package/build/modules/ace/main.js +2 -11
  42. package/build/modules/app.d.ts +17 -0
  43. package/build/modules/app.js +4 -9
  44. package/build/modules/bodyparser/bodyparser_middleware.js +2 -14
  45. package/build/modules/bodyparser/main.js +4 -9
  46. package/build/modules/config.d.ts +17 -0
  47. package/build/modules/config.js +4 -9
  48. package/build/modules/container.js +4 -9
  49. package/build/modules/dumper/dumper.d.ts +5 -0
  50. package/build/modules/dumper/main.d.ts +21 -0
  51. package/build/modules/dumper/main.js +6 -11
  52. package/build/modules/dumper/plugins/edge.js +2 -62
  53. package/build/modules/encryption.d.ts +17 -0
  54. package/build/modules/encryption.js +4 -9
  55. package/build/modules/env/editor.js +2 -9
  56. package/build/modules/env/main.d.ts +19 -0
  57. package/build/modules/env/main.js +2 -9
  58. package/build/modules/events.js +4 -9
  59. package/build/modules/hash/drivers/argon.js +2 -9
  60. package/build/modules/hash/drivers/bcrypt.d.ts +11 -0
  61. package/build/modules/hash/drivers/bcrypt.js +2 -9
  62. package/build/modules/hash/drivers/scrypt.js +2 -9
  63. package/build/modules/hash/main.d.ts +18 -0
  64. package/build/modules/hash/main.js +6 -10
  65. package/build/modules/hash/phc_formatter.js +2 -9
  66. package/build/modules/health.js +2 -9
  67. package/build/modules/http/main.js +4 -15
  68. package/build/modules/http/url_builder_client.d.ts +1 -0
  69. package/build/modules/http/url_builder_client.js +2 -0
  70. package/build/modules/logger.d.ts +30 -0
  71. package/build/modules/logger.js +4 -9
  72. package/build/modules/repl.js +4 -9
  73. package/build/modules/transformers/main.js +4 -9
  74. package/build/providers/app_provider.d.ts +9 -21
  75. package/build/providers/app_provider.js +147 -363
  76. package/build/providers/edge_provider.js +97 -104
  77. package/build/providers/hash_provider.js +29 -91
  78. package/build/providers/repl_provider.js +61 -152
  79. package/build/providers/vinejs_provider.d.ts +1 -1
  80. package/build/providers/vinejs_provider.js +20 -66
  81. package/build/services/ace.js +2 -17
  82. package/build/services/app.js +2 -21
  83. package/build/services/config.js +2 -13
  84. package/build/services/dumper.js +5 -21
  85. package/build/services/emitter.js +2 -14
  86. package/build/services/encryption.js +2 -14
  87. package/build/services/hash.js +2 -14
  88. package/build/services/logger.js +2 -14
  89. package/build/services/repl.js +2 -14
  90. package/build/services/router.js +2 -14
  91. package/build/services/server.js +2 -14
  92. package/build/services/test_utils.js +2 -17
  93. package/build/services/url_builder.js +5 -17
  94. package/build/src/exceptions.js +2 -49
  95. package/build/src/helpers/assert.js +2 -55
  96. package/build/src/helpers/http.d.ts +20 -0
  97. package/build/src/helpers/http.js +2 -0
  98. package/build/src/helpers/is.js +3 -31
  99. package/build/src/helpers/main.d.ts +1 -5
  100. package/build/src/helpers/main.js +5 -56
  101. package/build/src/helpers/string.js +2 -60
  102. package/build/src/helpers/types.js +26 -135
  103. package/build/src/helpers/verification_token.js +2 -120
  104. package/build/src/test_utils/main.js +5 -77
  105. package/build/src/types.d.ts +1 -0
  106. package/build/src/types.js +0 -8
  107. package/build/src/utils.d.ts +1 -1
  108. package/build/src/vine.js +2 -97
  109. package/build/types/ace.js +2 -9
  110. package/build/types/app.js +2 -9
  111. package/build/types/bodyparser.js +2 -9
  112. package/build/types/common.js +2 -9
  113. package/build/types/container.js +2 -9
  114. package/build/types/encryption.js +2 -9
  115. package/build/types/events.js +2 -9
  116. package/build/types/hash.js +2 -9
  117. package/build/types/health.js +2 -9
  118. package/build/types/helpers.d.ts +20 -0
  119. package/build/types/helpers.js +0 -8
  120. package/build/types/http.js +2 -9
  121. package/build/types/logger.js +2 -9
  122. package/build/types/repl.js +2 -9
  123. package/build/types/transformers.js +2 -9
  124. package/package.json +88 -30
  125. package/build/modules/ace/commands.js +0 -157
  126. package/build/modules/ace/create_kernel.js +0 -91
  127. package/build/modules/ace/kernel.js +0 -40
  128. package/build/modules/dumper/define_config.js +0 -36
  129. package/build/modules/dumper/dumper.js +0 -256
  130. package/build/modules/dumper/errors.js +0 -119
  131. package/build/modules/hash/define_config.js +0 -125
  132. package/build/modules/http/request_validator.js +0 -100
  133. package/build/src/assembler_hooks/index_entities.js +0 -106
  134. package/build/src/cli_formatters/routes_list.js +0 -381
  135. package/build/src/config_provider.js +0 -71
  136. package/build/src/debug.js +0 -25
  137. package/build/src/ignitor/ace.js +0 -102
  138. package/build/src/ignitor/http.js +0 -146
  139. package/build/src/ignitor/main.js +0 -124
  140. package/build/src/ignitor/test.js +0 -66
  141. package/build/src/test_utils/http.js +0 -82
  142. package/build/src/utils.js +0 -104
  143. package/build/stubs/main.js +0 -9
  144. package/build/toolkit/commands/index_commands.js +0 -30
  145. package/build/toolkit/main.js +0 -27
@@ -1,111 +1,41 @@
1
- /*
2
- * @adonisjs/core
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
10
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1
+ import { f as BaseCommand, l as flags, o as args } from "../main-Cn_x9YY5.js";
2
+ import { t as __decorate } from "../decorate-DM0Sx1ye.js";
3
+ var Add = class extends BaseCommand {
4
+ static commandName = "add";
5
+ static description = "Install and configure a package";
6
+ static options = { allowUnknownFlags: true };
7
+ async #configurePackage() {
8
+ const flagValueArray = this.parsed.unknownFlags.filter((flag) => !!this.parsed.flags[flag]).map((flag) => [`--${flag}`, this.parsed.flags[flag].toString()]);
9
+ const configureArgs = [
10
+ this.name,
11
+ this.force ? "--force" : void 0,
12
+ this.verbose ? "--verbose" : void 0,
13
+ ...flagValueArray.flat()
14
+ ].filter(Boolean);
15
+ return await this.kernel.exec("configure", configureArgs);
16
+ }
17
+ async run() {
18
+ let npmPackageName = this.name;
19
+ if (this.name === "vinejs") npmPackageName = "@vinejs/vine";
20
+ else if (this.name === "edge") npmPackageName = "edge.js";
21
+ const codemods = await this.createCodemods();
22
+ codemods.verboseInstallOutput = !!this.verbose;
23
+ if (!await codemods.installPackages([{
24
+ name: npmPackageName,
25
+ isDevDependency: !!this.dev
26
+ }], this.packageManager)) return;
27
+ const { exitCode } = await this.#configurePackage();
28
+ this.exitCode = exitCode;
29
+ if (exitCode === 0) this.logger.success(`Installed and configured ${this.colors.green(this.name)}`);
30
+ else this.logger.fatal(`Unable to configure ${this.colors.green(this.name)}`);
31
+ }
14
32
  };
15
- import { args, BaseCommand, flags } from "../modules/ace/main.js";
16
- /**
17
- * The install command is used to `npm install` and `node ace configure` a new package
18
- * in one go.
19
- *
20
- * @example
21
- * ```
22
- * ace add @adonisjs/lucid
23
- * ace add @adonisjs/session --dev
24
- * ace add vinejs --force
25
- * ace add edge --package-manager=pnpm
26
- * ```
27
- */
28
- export default class Add extends BaseCommand {
29
- /**
30
- * The command name
31
- */
32
- static commandName = 'add';
33
- /**
34
- * The command description
35
- */
36
- static description = 'Install and configure a package';
37
- /**
38
- * Command options configuration
39
- */
40
- static options = {
41
- allowUnknownFlags: true,
42
- };
43
- /**
44
- * Configure the package by delegating the work to the `node ace configure` command
45
- */
46
- async #configurePackage() {
47
- /**
48
- * Sending unknown flags to the configure command
49
- */
50
- const flagValueArray = this.parsed.unknownFlags
51
- .filter((flag) => !!this.parsed.flags[flag])
52
- .map((flag) => [`--${flag}`, this.parsed.flags[flag].toString()]);
53
- const configureArgs = [
54
- this.name,
55
- this.force ? '--force' : undefined,
56
- this.verbose ? '--verbose' : undefined,
57
- ...flagValueArray.flat(),
58
- ].filter(Boolean);
59
- return await this.kernel.exec('configure', configureArgs);
60
- }
61
- /**
62
- * Run method is invoked by ace automatically
63
- */
64
- async run() {
65
- /**
66
- * Handle special packages to configure
67
- */
68
- let npmPackageName = this.name;
69
- if (this.name === 'vinejs') {
70
- npmPackageName = '@vinejs/vine';
71
- }
72
- else if (this.name === 'edge') {
73
- npmPackageName = 'edge.js';
74
- }
75
- /**
76
- * Install package
77
- */
78
- const codemods = await this.createCodemods();
79
- codemods.verboseInstallOutput = !!this.verbose;
80
- const pkgWasInstalled = await codemods.installPackages([{ name: npmPackageName, isDevDependency: !!this.dev }], this.packageManager);
81
- if (!pkgWasInstalled) {
82
- return;
83
- }
84
- /**
85
- * Configure package
86
- */
87
- const { exitCode } = await this.#configurePackage();
88
- this.exitCode = exitCode;
89
- if (exitCode === 0) {
90
- this.logger.success(`Installed and configured ${this.colors.green(this.name)}`);
91
- }
92
- else {
93
- this.logger.fatal(`Unable to configure ${this.colors.green(this.name)}`);
94
- }
95
- }
96
- }
97
- __decorate([
98
- args.string({ description: 'Package name' })
99
- ], Add.prototype, "name", void 0);
100
- __decorate([
101
- flags.boolean({ description: 'Display logs in verbose mode' })
102
- ], Add.prototype, "verbose", void 0);
103
- __decorate([
104
- flags.string({ description: 'Define the package manager you want to use' })
105
- ], Add.prototype, "packageManager", void 0);
106
- __decorate([
107
- flags.boolean({ description: 'Should we install the package as a dev dependency', alias: 'D' })
108
- ], Add.prototype, "dev", void 0);
109
- __decorate([
110
- flags.boolean({ description: 'Forcefully overwrite existing files' })
111
- ], Add.prototype, "force", void 0);
33
+ __decorate([args.string({ description: "Package name" })], Add.prototype, "name", void 0);
34
+ __decorate([flags.boolean({ description: "Display logs in verbose mode" })], Add.prototype, "verbose", void 0);
35
+ __decorate([flags.string({ description: "Define the package manager you want to use" })], Add.prototype, "packageManager", void 0);
36
+ __decorate([flags.boolean({
37
+ description: "Should we install the package as a dev dependency",
38
+ alias: "D"
39
+ })], Add.prototype, "dev", void 0);
40
+ __decorate([flags.boolean({ description: "Forcefully overwrite existing files" })], Add.prototype, "force", void 0);
41
+ export { Add as default };
@@ -1,108 +1,52 @@
1
- /*
2
- * @adonisjs/core
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
10
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1
+ import { n as importTypeScript, t as importAssembler } from "../utils-CNQ4tlGM.js";
2
+ import { f as BaseCommand, l as flags } from "../main-Cn_x9YY5.js";
3
+ import { t as __decorate } from "../decorate-DM0Sx1ye.js";
4
+ var Build = class extends BaseCommand {
5
+ static commandName = "build";
6
+ static description = "Build application for production by compiling frontend assets and TypeScript source to JavaScript";
7
+ static help = [
8
+ "Create the production build using the following command.",
9
+ "```",
10
+ "{{ binaryName }} build",
11
+ "```",
12
+ "",
13
+ "The assets bundler dev server runs automatically after detecting vite config or webpack config files",
14
+ "You may pass vite CLI args using the --assets-args command line flag.",
15
+ "```",
16
+ "{{ binaryName }} build --assets-args=\"--debug --base=/public\"",
17
+ "```"
18
+ ];
19
+ #logMissingDevelopmentDependency(dependency) {
20
+ this.logger.error([
21
+ `Cannot find package "${dependency}"`,
22
+ "",
23
+ `The "${dependency}" package is a development dependency and therefore you should use the build command with development dependencies installed.`,
24
+ "",
25
+ "If you are using the build command inside a CI or with a deployment platform, make sure the NODE_ENV is set to \"development\""
26
+ ].join("\n"));
27
+ }
28
+ async run() {
29
+ const assembler = await importAssembler(this.app);
30
+ if (!assembler) {
31
+ this.#logMissingDevelopmentDependency("@adonisjs/assembler");
32
+ this.exitCode = 1;
33
+ return;
34
+ }
35
+ const ts = await importTypeScript(this.app);
36
+ if (!ts) {
37
+ this.#logMissingDevelopmentDependency("typescript");
38
+ this.exitCode = 1;
39
+ return;
40
+ }
41
+ const bundler = new assembler.Bundler(this.app.appRoot, ts, {
42
+ metaFiles: this.app.rcFile.metaFiles,
43
+ hooks: this.app.rcFile.hooks
44
+ });
45
+ bundler.ui.logger = this.logger;
46
+ const stopOnError = this.ignoreTsErrors === true ? false : true;
47
+ if (!await bundler.bundle(stopOnError, this.packageManager)) this.exitCode = 1;
48
+ }
14
49
  };
15
- import { BaseCommand, flags } from "../modules/ace/main.js";
16
- import { importAssembler, importTypeScript } from "../src/utils.js";
17
- /**
18
- * Create the production build by compiling TypeScript source and the
19
- * frontend assets
20
- *
21
- * @example
22
- * ```
23
- * ace build
24
- * ace build --ignore-ts-errors
25
- * ace build --package-manager=pnpm
26
- * ```
27
- */
28
- export default class Build extends BaseCommand {
29
- /**
30
- * The command name
31
- */
32
- static commandName = 'build';
33
- /**
34
- * The command description
35
- */
36
- static description = 'Build application for production by compiling frontend assets and TypeScript source to JavaScript';
37
- /**
38
- * Help text for the command
39
- */
40
- static help = [
41
- 'Create the production build using the following command.',
42
- '```',
43
- '{{ binaryName }} build',
44
- '```',
45
- '',
46
- 'The assets bundler dev server runs automatically after detecting vite config or webpack config files',
47
- 'You may pass vite CLI args using the --assets-args command line flag.',
48
- '```',
49
- '{{ binaryName }} build --assets-args="--debug --base=/public"',
50
- '```',
51
- ];
52
- /**
53
- * Log a development dependency is missing
54
- *
55
- * @param dependency - The name of the missing dependency
56
- */
57
- #logMissingDevelopmentDependency(dependency) {
58
- this.logger.error([
59
- `Cannot find package "${dependency}"`,
60
- '',
61
- `The "${dependency}" package is a development dependency and therefore you should use the build command with development dependencies installed.`,
62
- '',
63
- 'If you are using the build command inside a CI or with a deployment platform, make sure the NODE_ENV is set to "development"',
64
- ].join('\n'));
65
- }
66
- /**
67
- * Build application
68
- */
69
- async run() {
70
- const assembler = await importAssembler(this.app);
71
- if (!assembler) {
72
- this.#logMissingDevelopmentDependency('@adonisjs/assembler');
73
- this.exitCode = 1;
74
- return;
75
- }
76
- const ts = await importTypeScript(this.app);
77
- if (!ts) {
78
- this.#logMissingDevelopmentDependency('typescript');
79
- this.exitCode = 1;
80
- return;
81
- }
82
- const bundler = new assembler.Bundler(this.app.appRoot, ts, {
83
- metaFiles: this.app.rcFile.metaFiles,
84
- hooks: this.app.rcFile.hooks,
85
- });
86
- /**
87
- * Share command logger with assembler, so that CLI flags like --no-ansi has
88
- * similar impact for assembler logs as well.
89
- */
90
- bundler.ui.logger = this.logger;
91
- /**
92
- * Bundle project for production
93
- */
94
- const stopOnError = this.ignoreTsErrors === true ? false : true;
95
- const builtSuccessfully = await bundler.bundle(stopOnError, this.packageManager);
96
- if (!builtSuccessfully) {
97
- this.exitCode = 1;
98
- }
99
- }
100
- }
101
- __decorate([
102
- flags.boolean({ description: 'Ignore TypeScript errors and continue with the build process' })
103
- ], Build.prototype, "ignoreTsErrors", void 0);
104
- __decorate([
105
- flags.string({
106
- description: 'Define the package manager to copy the appropriate lock file',
107
- })
108
- ], Build.prototype, "packageManager", void 0);
50
+ __decorate([flags.boolean({ description: "Ignore TypeScript errors and continue with the build process" })], Build.prototype, "ignoreTsErrors", void 0);
51
+ __decorate([flags.string({ description: "Define the package manager to copy the appropriate lock file" })], Build.prototype, "packageManager", void 0);
52
+ export { Build as default };
@@ -1,178 +1,83 @@
1
- /*
2
- * @adonisjs/core
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
10
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1
+ import { t as stubsRoot } from "../main-kn40V-hF.js";
2
+ import { f as BaseCommand, l as flags, o as args } from "../main-Cn_x9YY5.js";
3
+ import { t as __decorate } from "../decorate-DM0Sx1ye.js";
4
+ import { RuntimeException } from "@poppinss/utils/exception";
5
+ var Configure = class extends BaseCommand {
6
+ static commandName = "configure";
7
+ static description = "Configure a package after it has been installed";
8
+ static options = { allowUnknownFlags: true };
9
+ get parsedFlags() {
10
+ return this.parsed.flags;
11
+ }
12
+ get parsedArgs() {
13
+ return this.parsed._;
14
+ }
15
+ async #getPackageSource(packageName) {
16
+ try {
17
+ return await this.app.import(packageName);
18
+ } catch (error) {
19
+ if (error.code && error.code === "ERR_MODULE_NOT_FOUND" || error.message.startsWith("Cannot find module")) return null;
20
+ throw error;
21
+ }
22
+ }
23
+ async #configureVineJS() {
24
+ await (await this.createCodemods()).updateRcFile((rcFile) => {
25
+ rcFile.addProvider("@adonisjs/core/providers/vinejs_provider");
26
+ });
27
+ }
28
+ async #configureEdge() {
29
+ await (await this.createCodemods()).updateRcFile((rcFile) => {
30
+ rcFile.addProvider("@adonisjs/core/providers/edge_provider");
31
+ rcFile.addMetaFile("resources/views/**/*.edge", false);
32
+ });
33
+ }
34
+ async #configureHealthChecks() {
35
+ const codemods = await this.createCodemods();
36
+ await codemods.makeUsingStub(stubsRoot, "make/health/main.stub", {
37
+ flags: this.parsed.flags,
38
+ entity: this.app.generators.createEntity("health")
39
+ });
40
+ await codemods.makeUsingStub(stubsRoot, "make/health/controller.stub", {
41
+ flags: this.parsed.flags,
42
+ entity: this.app.generators.createEntity("health_checks")
43
+ });
44
+ }
45
+ async createCodemods() {
46
+ const codemods = await super.createCodemods();
47
+ codemods.overwriteExisting = this.force === true;
48
+ codemods.verboseInstallOutput = this.verbose === true;
49
+ return codemods;
50
+ }
51
+ async run() {
52
+ if (this.name === "vinejs") return this.#configureVineJS();
53
+ if (this.name === "edge") return this.#configureEdge();
54
+ if (this.name === "health_checks") return this.#configureHealthChecks();
55
+ const packageExports = await this.#getPackageSource(this.name);
56
+ if (!packageExports) {
57
+ this.logger.error(`Cannot find module "${this.name}". Make sure to install it`);
58
+ this.exitCode = 1;
59
+ return;
60
+ }
61
+ if (!packageExports.configure) {
62
+ this.logger.error(`Cannot configure module "${this.name}". The module does not export the configure hook`);
63
+ this.exitCode = 1;
64
+ return;
65
+ }
66
+ if (packageExports.stubsRoot) this.stubsRoot = packageExports.stubsRoot;
67
+ try {
68
+ await packageExports.configure(this);
69
+ } catch (error) {
70
+ throw new RuntimeException(`Unable to configure package "${this.name}"`, { cause: error });
71
+ }
72
+ }
14
73
  };
15
- import { RuntimeException } from '@poppinss/utils/exception';
16
- import { stubsRoot } from "../stubs/main.js";
17
- import { args, BaseCommand, flags } from "../modules/ace/main.js";
18
- /**
19
- * Command to configure packages after installation by running their configuration hooks.
20
- * Supports built-in configurations for VineJS, Edge, and health checks, or can execute
21
- * custom configure functions exported by packages.
22
- *
23
- * @example
24
- * ```
25
- * ace configure @adonisjs/lucid
26
- * ace configure vinejs
27
- * ace configure edge
28
- * ace configure health_checks
29
- * ace configure @adonisjs/auth --force --verbose
30
- * ```
31
- */
32
- export default class Configure extends BaseCommand {
33
- /**
34
- * The command name
35
- */
36
- static commandName = 'configure';
37
- /**
38
- * The command description
39
- */
40
- static description = 'Configure a package after it has been installed';
41
- /**
42
- * Command options configuration.
43
- * Allows unknown flags to be passed to package configure functions.
44
- */
45
- static options = {
46
- allowUnknownFlags: true,
47
- };
48
- /**
49
- * Expose all flags from the protected property "parsed" for access by package configure functions
50
- */
51
- get parsedFlags() {
52
- return this.parsed.flags;
53
- }
54
- /**
55
- * Expose all arguments from the protected property "parsed" for access by package configure functions
56
- */
57
- get parsedArgs() {
58
- return this.parsed._;
59
- }
60
- /**
61
- * Import and return the main exports of a package.
62
- * Returns null if the package is not found, rethrows other errors.
63
- *
64
- * @param packageName - The name of the package to import
65
- * @returns The package exports or null if not found
66
- */
67
- async #getPackageSource(packageName) {
68
- try {
69
- const packageExports = await this.app.import(packageName);
70
- return packageExports;
71
- }
72
- catch (error) {
73
- if ((error.code && error.code === 'ERR_MODULE_NOT_FOUND') ||
74
- error.message.startsWith('Cannot find module')) {
75
- return null;
76
- }
77
- throw error;
78
- }
79
- }
80
- /**
81
- * Configure VineJS validation library by registering its provider in the RC file
82
- */
83
- async #configureVineJS() {
84
- const codemods = await this.createCodemods();
85
- await codemods.updateRcFile((rcFile) => {
86
- rcFile.addProvider('@adonisjs/core/providers/vinejs_provider');
87
- });
88
- }
89
- /**
90
- * Configure Edge template engine by registering its provider and adding view meta files
91
- */
92
- async #configureEdge() {
93
- const codemods = await this.createCodemods();
94
- await codemods.updateRcFile((rcFile) => {
95
- rcFile.addProvider('@adonisjs/core/providers/edge_provider');
96
- rcFile.addMetaFile('resources/views/**/*.edge', false);
97
- });
98
- }
99
- /**
100
- * Configure health checks feature by generating the main health file and controller
101
- */
102
- async #configureHealthChecks() {
103
- const codemods = await this.createCodemods();
104
- await codemods.makeUsingStub(stubsRoot, 'make/health/main.stub', {
105
- flags: this.parsed.flags,
106
- entity: this.app.generators.createEntity('health'),
107
- });
108
- await codemods.makeUsingStub(stubsRoot, 'make/health/controller.stub', {
109
- flags: this.parsed.flags,
110
- entity: this.app.generators.createEntity('health_checks'),
111
- });
112
- }
113
- /**
114
- * Create a codemods instance configured with command options.
115
- * Sets overwrite and verbose flags based on command arguments.
116
- */
117
- async createCodemods() {
118
- const codemods = await super.createCodemods();
119
- codemods.overwriteExisting = this.force === true;
120
- codemods.verboseInstallOutput = this.verbose === true;
121
- return codemods;
122
- }
123
- /**
124
- * Execute the configure command. Handles built-in configurations for VineJS, Edge,
125
- * and health checks, or imports and executes the configure function from the specified package.
126
- */
127
- async run() {
128
- if (this.name === 'vinejs') {
129
- return this.#configureVineJS();
130
- }
131
- if (this.name === 'edge') {
132
- return this.#configureEdge();
133
- }
134
- if (this.name === 'health_checks') {
135
- return this.#configureHealthChecks();
136
- }
137
- const packageExports = await this.#getPackageSource(this.name);
138
- if (!packageExports) {
139
- this.logger.error(`Cannot find module "${this.name}". Make sure to install it`);
140
- this.exitCode = 1;
141
- return;
142
- }
143
- /**
144
- * Warn, there are not instructions to run
145
- */
146
- if (!packageExports.configure) {
147
- this.logger.error(`Cannot configure module "${this.name}". The module does not export the configure hook`);
148
- this.exitCode = 1;
149
- return;
150
- }
151
- /**
152
- * Set stubsRoot property when package exports it
153
- */
154
- if (packageExports.stubsRoot) {
155
- this.stubsRoot = packageExports.stubsRoot;
156
- }
157
- /**
158
- * Run instructions
159
- */
160
- try {
161
- await packageExports.configure(this);
162
- }
163
- catch (error) {
164
- throw new RuntimeException(`Unable to configure package "${this.name}"`, {
165
- cause: error,
166
- });
167
- }
168
- }
169
- }
170
- __decorate([
171
- args.string({ description: 'Package name' })
172
- ], Configure.prototype, "name", void 0);
173
- __decorate([
174
- flags.boolean({ description: 'Display logs in verbose mode', alias: 'v' })
175
- ], Configure.prototype, "verbose", void 0);
176
- __decorate([
177
- flags.boolean({ description: 'Forcefully overwrite existing files', alias: 'f' })
178
- ], Configure.prototype, "force", void 0);
74
+ __decorate([args.string({ description: "Package name" })], Configure.prototype, "name", void 0);
75
+ __decorate([flags.boolean({
76
+ description: "Display logs in verbose mode",
77
+ alias: "v"
78
+ })], Configure.prototype, "verbose", void 0);
79
+ __decorate([flags.boolean({
80
+ description: "Forcefully overwrite existing files",
81
+ alias: "f"
82
+ })], Configure.prototype, "force", void 0);
83
+ export { Configure as default };
@@ -1,61 +1,18 @@
1
- /*
2
- * @adonisjs/core
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
10
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1
+ import { t as string_default } from "../string-CJ7ewUFq.js";
2
+ import { f as BaseCommand, l as flags, o as args } from "../main-Cn_x9YY5.js";
3
+ import { t as __decorate } from "../decorate-DM0Sx1ye.js";
4
+ var Eject = class extends BaseCommand {
5
+ static commandName = "eject";
6
+ static description = "Eject scaffolding stubs to your application root";
7
+ async run() {
8
+ (await (await this.app.stubs.create()).copy(this.stubPath, { pkg: this.pkg })).forEach((stubPath) => {
9
+ this.logger.success(`eject ${string_default.toUnixSlash(this.app.relativePath(stubPath))}`);
10
+ });
11
+ }
14
12
  };
15
- import { args, BaseCommand, flags } from "../modules/ace/main.js";
16
- import stringHelpers from "../src/helpers/string.js";
17
- /**
18
- * Command to eject scaffolding stubs from packages to your application root.
19
- * This allows you to customize templates used by make commands and other
20
- * code generation features by copying them to your local application.
21
- *
22
- * @example
23
- * ```
24
- * ace eject make/controller
25
- * ace eject make/controller --pkg=@adonisjs/lucid
26
- * ace eject stubs/
27
- * ```
28
- */
29
- export default class Eject extends BaseCommand {
30
- /**
31
- * The command name
32
- */
33
- static commandName = 'eject';
34
- /**
35
- * The command description
36
- */
37
- static description = 'Eject scaffolding stubs to your application root';
38
- /**
39
- * Execute the command to eject stubs from the specified package.
40
- * Copies the stubs to the application root and logs success messages
41
- * for each ejected file.
42
- */
43
- async run() {
44
- const stubs = await this.app.stubs.create();
45
- const copied = await stubs.copy(this.stubPath, {
46
- pkg: this.pkg,
47
- });
48
- copied.forEach((stubPath) => {
49
- this.logger.success(`eject ${stringHelpers.toUnixSlash(this.app.relativePath(stubPath))}`);
50
- });
51
- }
52
- }
53
- __decorate([
54
- args.string({ description: 'Path to the stubs directory or a single stub file' })
55
- ], Eject.prototype, "stubPath", void 0);
56
- __decorate([
57
- flags.string({
58
- description: 'Mention package name for searching stubs',
59
- default: '@adonisjs/core',
60
- })
61
- ], Eject.prototype, "pkg", void 0);
13
+ __decorate([args.string({ description: "Path to the stubs directory or a single stub file" })], Eject.prototype, "stubPath", void 0);
14
+ __decorate([flags.string({
15
+ description: "Mention package name for searching stubs",
16
+ default: "@adonisjs/core"
17
+ })], Eject.prototype, "pkg", void 0);
18
+ export { Eject as default };