@adonisjs/core 6.1.5-5 → 6.1.5-7

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.
@@ -46,6 +46,22 @@ export default class Build extends BaseCommand {
46
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"',
47
47
  ].join('\n'));
48
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
+ }
49
65
  /**
50
66
  * Build application
51
67
  */
@@ -62,18 +78,8 @@ export default class Build extends BaseCommand {
62
78
  this.exitCode = 1;
63
79
  return;
64
80
  }
65
- const assetsBundler = await detectAssetsBundler(this.app);
66
81
  const bundler = new assembler.Bundler(this.app.appRoot, ts, {
67
- assets: assetsBundler
68
- ? {
69
- serve: this.assets === false ? false : true,
70
- driver: assetsBundler.name,
71
- cmd: assetsBundler.build.command,
72
- args: this.assetsArgs || [],
73
- }
74
- : {
75
- serve: false,
76
- },
82
+ assets: await this.#getAssetsBundlerConfig(),
77
83
  metaFiles: this.app.rcFile.metaFiles,
78
84
  });
79
85
  /**
@@ -1 +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":[],"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":{"allowUnknownFlags":true},"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":{"allowUnknownFlags":true},"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":{"allowUnknownFlags":true},"filePath":"make/event.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/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","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":{"allowUnknownFlags":true},"filePath":"make/middleware.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/middleware.js"},{"commandName":"make:prldfile","description":"Create a new preload file inside the start directory","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the preload file","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/prldfile.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/prldfile.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","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":{"allowUnknownFlags":true},"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":{"allowUnknownFlags":true},"filePath":"make/test.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/test.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":"ignoreTags","flagName":"ignore-tags","required":false,"type":"array","description":"Run tests that does not have mentioned 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":"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":"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
+ {"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":{"allowUnknownFlags":true},"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":{"allowUnknownFlags":true},"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":{"allowUnknownFlags":true},"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":{"allowUnknownFlags":true},"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":{"allowUnknownFlags":true},"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":{"allowUnknownFlags":true},"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":{"allowUnknownFlags":true},"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":{"allowUnknownFlags":true},"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":{"allowUnknownFlags":true},"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":{"allowUnknownFlags":true},"filePath":"make/test.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/test.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}
@@ -8,6 +8,7 @@ export default class Configure extends BaseCommand {
8
8
  static commandName: string;
9
9
  static description: string;
10
10
  name: string;
11
+ verbose?: boolean;
11
12
  /**
12
13
  * The root of the stubs directory. The value is defined after we import
13
14
  * the package
@@ -25,6 +26,19 @@ export default class Configure extends BaseCommand {
25
26
  * Update rcFile
26
27
  */
27
28
  updateRcFile(callback: (rcFileEditor: ApplicationService['rcFileEditor']) => Promise<void> | void): Promise<void>;
29
+ /**
30
+ * Install packages using the correct package manager
31
+ * You can specify version of each package by setting it in the
32
+ * name like :
33
+ *
34
+ * ```
35
+ * installPackages(['@adonisjs/lucid@next', '@adonisjs/auth@3.0.0'])
36
+ * ```
37
+ */
38
+ installPackages(packages: {
39
+ name: string;
40
+ isDevDependency: boolean;
41
+ }[]): Promise<void>;
28
42
  /**
29
43
  * List the packages one should install before using the packages
30
44
  */
@@ -13,8 +13,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
13
13
  return c > 3 && r && Object.defineProperty(target, key, r), r;
14
14
  };
15
15
  import { slash } from '@poppinss/utils';
16
+ import { installPackage, detectPackageManager } from '@antfu/install-pkg';
16
17
  import { EnvEditor } from '../modules/env.js';
17
- import { args, BaseCommand } from '../modules/ace/main.js';
18
+ import { args, BaseCommand, flags } from '../modules/ace/main.js';
18
19
  /**
19
20
  * The configure command is used to configure packages after installation
20
21
  */
@@ -86,6 +87,39 @@ export default class Configure extends BaseCommand {
86
87
  await this.app.rcFileEditor.save();
87
88
  this.logger.action('update .adonisrc.json file').succeeded();
88
89
  }
90
+ /**
91
+ * Install packages using the correct package manager
92
+ * You can specify version of each package by setting it in the
93
+ * name like :
94
+ *
95
+ * ```
96
+ * installPackages(['@adonisjs/lucid@next', '@adonisjs/auth@3.0.0'])
97
+ * ```
98
+ */
99
+ async installPackages(packages) {
100
+ const appPath = this.app.makePath();
101
+ const silent = this.verbose === true ? false : true;
102
+ const devDeps = packages.filter((pkg) => pkg.isDevDependency).map(({ name }) => name);
103
+ const deps = packages.filter((pkg) => !pkg.isDevDependency).map(({ name }) => name);
104
+ const packageManager = await detectPackageManager(appPath);
105
+ let spinner = this.logger
106
+ .await(`installing dependencies using ${packageManager || 'npm'}`)
107
+ .start();
108
+ try {
109
+ await installPackage(deps, { cwd: appPath, silent });
110
+ await installPackage(devDeps, { dev: true, cwd: appPath, silent });
111
+ spinner.stop();
112
+ this.logger.success('dependencies installed');
113
+ this.logger.log(devDeps.map((dep) => ` ${this.colors.dim('dev')} ${dep}`).join('\n'));
114
+ this.logger.log(deps.map((dep) => ` ${this.colors.dim('prod')} ${dep}`).join('\n'));
115
+ }
116
+ catch (error) {
117
+ spinner.update('unable to install dependencies');
118
+ spinner.stop();
119
+ this.exitCode = 1;
120
+ this.logger.fatal(error);
121
+ }
122
+ }
89
123
  /**
90
124
  * List the packages one should install before using the packages
91
125
  */
@@ -144,3 +178,6 @@ export default class Configure extends BaseCommand {
144
178
  __decorate([
145
179
  args.string({ description: 'Package name' })
146
180
  ], Configure.prototype, "name", void 0);
181
+ __decorate([
182
+ flags.boolean({ description: 'Display logs in verbose mode' })
183
+ ], Configure.prototype, "verbose", void 0);
@@ -1,13 +1,13 @@
1
1
  import BaseCommand from './_base.js';
2
2
  /**
3
- * Make a new preload file
3
+ * Make a new exception class
4
4
  */
5
- export default class MakePreloadFile extends BaseCommand {
5
+ export default class MakeException extends BaseCommand {
6
6
  static commandName: string;
7
7
  static description: string;
8
8
  name: string;
9
9
  /**
10
- * The stub to use for generating the preload file
10
+ * The stub to use for generating the command class
11
11
  */
12
12
  protected stubPath: string;
13
13
  run(): Promise<void>;
@@ -15,27 +15,21 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
15
15
  import BaseCommand from './_base.js';
16
16
  import { args } from '../../modules/ace/main.js';
17
17
  /**
18
- * Make a new preload file
18
+ * Make a new exception class
19
19
  */
20
- export default class MakePreloadFile extends BaseCommand {
21
- static commandName = 'make:prldfile';
22
- static description = 'Create a new preload file inside the start directory';
20
+ export default class MakeException extends BaseCommand {
21
+ static commandName = 'make:exception';
22
+ static description = 'Create a new ace exception class';
23
23
  /**
24
- * The stub to use for generating the preload file
24
+ * The stub to use for generating the command class
25
25
  */
26
- stubPath = 'make/preload_file/main.stub';
26
+ stubPath = 'make/exception/main.stub';
27
27
  async run() {
28
- const output = await this.generate(this.stubPath, {
28
+ await this.generate(this.stubPath, {
29
29
  entity: this.app.generators.createEntity(this.name),
30
30
  });
31
- /**
32
- * Registering the preload file with the `.adonisrc.json` file. We register
33
- * the relative path, since we cannot be sure about aliases to exist.
34
- */
35
- const preloadImportPath = `./${output.relativeFileName.replace(/(\.js|\.ts)$/, '')}.js`;
36
- await this.app.rcFileEditor.addPreloadFile(preloadImportPath).save();
37
31
  }
38
32
  }
39
33
  __decorate([
40
- args.string({ description: 'Name of the preload file' })
41
- ], MakePreloadFile.prototype, "name", void 0);
34
+ args.string({ description: 'Name of the exception' })
35
+ ], MakeException.prototype, "name", void 0);
@@ -0,0 +1,22 @@
1
+ import BaseCommand from './_base.js';
2
+ declare const ALLOWED_ENVIRONMENTS: ("repl" | "web" | "console" | "test")[];
3
+ type AllowedAppEnvironments = typeof ALLOWED_ENVIRONMENTS;
4
+ /**
5
+ * Make a new preload file
6
+ */
7
+ export default class MakePreload extends BaseCommand {
8
+ #private;
9
+ static commandName: string;
10
+ static description: string;
11
+ name: string;
12
+ environments: AllowedAppEnvironments;
13
+ /**
14
+ * The stub to use for generating the preload file
15
+ */
16
+ protected stubPath: string;
17
+ /**
18
+ * Run command
19
+ */
20
+ run(): Promise<void>;
21
+ }
22
+ export {};
@@ -0,0 +1,95 @@
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;
14
+ };
15
+ import BaseCommand from './_base.js';
16
+ import { args, flags } from '../../modules/ace/main.js';
17
+ const ALLOWED_ENVIRONMENTS = ['web', 'console', 'test', 'repl'];
18
+ /**
19
+ * Make a new preload file
20
+ */
21
+ export default class MakePreload extends BaseCommand {
22
+ static commandName = 'make:preload';
23
+ static description = 'Create a new preload file inside the start directory';
24
+ /**
25
+ * The stub to use for generating the preload file
26
+ */
27
+ stubPath = 'make/preload_file/main.stub';
28
+ /**
29
+ * Check if the mentioned environments are valid
30
+ */
31
+ #isValidEnvironment(environment) {
32
+ return !environment.find((one) => !ALLOWED_ENVIRONMENTS.includes(one));
33
+ }
34
+ /**
35
+ * Validate the environments flag passed by the user
36
+ */
37
+ #isEnvironmentsFlagValid() {
38
+ if (!this.environments || !this.environments.length) {
39
+ return true;
40
+ }
41
+ return this.#isValidEnvironment(this.environments);
42
+ }
43
+ /**
44
+ * Prompt for the environments
45
+ */
46
+ async #promptForEnvironments() {
47
+ const selectedEnvironments = await this.prompt.multiple('Select the environment(s) in which you want to load this file', [
48
+ { name: 'all', message: 'Load file in all environments' },
49
+ { name: 'console', message: 'Environment for ace commands' },
50
+ { name: 'repl', message: 'Environment for the REPL session' },
51
+ { name: 'web', message: 'Environment for HTTP requests' },
52
+ { name: 'test', message: 'Environment for the test process' },
53
+ ]);
54
+ if (selectedEnvironments.includes('all')) {
55
+ return ['web', 'console', 'test', 'repl'];
56
+ }
57
+ return selectedEnvironments;
58
+ }
59
+ /**
60
+ * Run command
61
+ */
62
+ async run() {
63
+ let environments = this.environments;
64
+ /**
65
+ * Ensure the environments are valid when provided via flag
66
+ */
67
+ if (!this.#isEnvironmentsFlagValid()) {
68
+ this.logger.error(`Invalid environment(s) "${this.environments}". Only "${ALLOWED_ENVIRONMENTS}" are allowed`);
69
+ return;
70
+ }
71
+ /**
72
+ * Prompt for the environments when not defined
73
+ */
74
+ if (!environments) {
75
+ environments = await this.#promptForEnvironments();
76
+ }
77
+ const output = await this.generate(this.stubPath, {
78
+ entity: this.app.generators.createEntity(this.name),
79
+ });
80
+ /**
81
+ * Registering the preload file with the `.adonisrc.json` file. We register
82
+ * the relative path, since we cannot be sure about aliases to exist.
83
+ */
84
+ const preloadImportPath = `./${output.relativeFileName.replace(/(\.js|\.ts)$/, '')}.js`;
85
+ await this.app.rcFileEditor.addPreloadFile(preloadImportPath, environments).save();
86
+ }
87
+ }
88
+ __decorate([
89
+ args.string({ description: 'Name of the preload file' })
90
+ ], MakePreload.prototype, "name", void 0);
91
+ __decorate([
92
+ flags.array({
93
+ description: `Define the preload file's environment. Accepted values are "${ALLOWED_ENVIRONMENTS}"`,
94
+ })
95
+ ], MakePreload.prototype, "environments", void 0);
@@ -0,0 +1,14 @@
1
+ import { BaseCommand } from '../modules/ace/main.js';
2
+ import { CommandOptions } from '../types/ace.js';
3
+ /**
4
+ * The ReplCommand class is used to start the Repl server
5
+ */
6
+ export default class ReplCommand extends BaseCommand {
7
+ static commandName: string;
8
+ static description: string;
9
+ static options: CommandOptions;
10
+ /**
11
+ * Starts the REPL server process
12
+ */
13
+ run(): Promise<void>;
14
+ }
@@ -0,0 +1,30 @@
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 { BaseCommand } from '../modules/ace/main.js';
10
+ /**
11
+ * The ReplCommand class is used to start the Repl server
12
+ */
13
+ export default class ReplCommand extends BaseCommand {
14
+ static commandName = 'repl';
15
+ static description = 'Start a new REPL session';
16
+ static options = {
17
+ startApp: true,
18
+ staysAlive: true,
19
+ };
20
+ /**
21
+ * Starts the REPL server process
22
+ */
23
+ async run() {
24
+ const repl = await this.app.container.make('repl');
25
+ repl.start();
26
+ repl.server.on('exit', async () => {
27
+ await this.terminate();
28
+ });
29
+ }
30
+ }
@@ -1,3 +1,4 @@
1
+ import type { DevServer } from '@adonisjs/assembler';
1
2
  import type { CommandOptions } from '../types/ace.js';
2
3
  import { BaseCommand } from '../modules/ace/main.js';
3
4
  /**
@@ -11,6 +12,7 @@ export default class Serve extends BaseCommand {
11
12
  static description: string;
12
13
  static help: string[];
13
14
  static options: CommandOptions;
15
+ devServer: DevServer;
14
16
  watch?: boolean;
15
17
  poll?: boolean;
16
18
  clear?: boolean;
@@ -49,6 +49,22 @@ export default class Serve extends BaseCommand {
49
49
  'If you are running your application in production, then use "node bin/server.js" command to start the HTTP server',
50
50
  ].join('\n'));
51
51
  }
52
+ /**
53
+ * Returns the assets bundler config
54
+ */
55
+ async #getAssetsBundlerConfig() {
56
+ const assetsBundler = await detectAssetsBundler(this.app);
57
+ return assetsBundler
58
+ ? {
59
+ serve: this.assets === false ? false : true,
60
+ driver: assetsBundler.name,
61
+ cmd: assetsBundler.devServer.command,
62
+ args: (assetsBundler.devServer.args || []).concat(this.assetsArgs || []),
63
+ }
64
+ : {
65
+ serve: false,
66
+ };
67
+ }
52
68
  /**
53
69
  * Runs the HTTP server
54
70
  */
@@ -59,39 +75,31 @@ export default class Serve extends BaseCommand {
59
75
  this.exitCode = 1;
60
76
  return;
61
77
  }
62
- const assetsBundler = await detectAssetsBundler(this.app);
63
- const devServer = new assembler.DevServer(this.app.appRoot, {
78
+ this.devServer = new assembler.DevServer(this.app.appRoot, {
64
79
  clearScreen: this.clear === false ? false : true,
65
80
  nodeArgs: this.parsed.nodeArgs,
66
81
  scriptArgs: [],
67
- assets: assetsBundler
68
- ? {
69
- serve: this.assets === false ? false : true,
70
- driver: assetsBundler.name,
71
- cmd: assetsBundler.devServer.command,
72
- args: this.assetsArgs || [],
73
- }
74
- : {
75
- serve: false,
76
- },
82
+ assets: await this.#getAssetsBundlerConfig(),
77
83
  metaFiles: this.app.rcFile.metaFiles,
78
84
  });
79
85
  /**
80
86
  * Share command logger with assembler, so that CLI flags like --no-ansi has
81
87
  * similar impact for assembler logs as well.
82
88
  */
83
- devServer.setLogger(this.logger);
89
+ this.devServer.setLogger(this.logger);
84
90
  /**
85
91
  * Exit command when the dev server is closed
86
92
  */
87
- devServer.onClose((exitCode) => {
93
+ this.devServer.onClose((exitCode) => {
88
94
  this.exitCode = exitCode;
95
+ this.terminate();
89
96
  });
90
97
  /**
91
98
  * Exit command when the dev server crashes
92
99
  */
93
- devServer.onError(() => {
100
+ this.devServer.onError(() => {
94
101
  this.exitCode = 1;
102
+ this.terminate();
95
103
  });
96
104
  /**
97
105
  * Start the development server
@@ -103,10 +111,10 @@ export default class Serve extends BaseCommand {
103
111
  this.exitCode = 1;
104
112
  return;
105
113
  }
106
- await devServer.startAndWatch(ts, { poll: this.poll || false });
114
+ await this.devServer.startAndWatch(ts, { poll: this.poll || false });
107
115
  }
108
116
  else {
109
- await devServer.start();
117
+ await this.devServer.start();
110
118
  }
111
119
  }
112
120
  }
@@ -1,3 +1,4 @@
1
+ import type { TestRunner } from '@adonisjs/assembler';
1
2
  import type { CommandOptions } from '../types/ace.js';
2
3
  import { BaseCommand } from '../modules/ace/main.js';
3
4
  /**
@@ -9,14 +10,18 @@ export default class Test extends BaseCommand {
9
10
  static commandName: string;
10
11
  static description: string;
11
12
  static options: CommandOptions;
13
+ testsRunner: TestRunner;
12
14
  suites?: string[];
13
15
  files?: string[];
14
16
  tags?: string[];
15
- ignoreTags?: string[];
16
17
  groups?: string[];
17
18
  tests?: string[];
19
+ reporters?: string[];
18
20
  watch?: boolean;
19
21
  poll?: boolean;
22
+ timeout?: number;
23
+ retries?: number;
24
+ failed?: boolean;
20
25
  clear?: boolean;
21
26
  assets?: boolean;
22
27
  assetsArgs?: string[];
@@ -37,6 +37,45 @@ export default class Test extends BaseCommand {
37
37
  'If you are run tests inside a CI, make sure the NODE_ENV is set to "development"',
38
38
  ].join('\n'));
39
39
  }
40
+ /**
41
+ * Collection of unknown flags to pass to Japa
42
+ */
43
+ #getPassthroughFlags() {
44
+ return this.parsed.unknownFlags
45
+ .map((flag) => {
46
+ const value = this.parsed.flags[flag];
47
+ /**
48
+ * Not mentioning value when value is "true"
49
+ */
50
+ if (value === true) {
51
+ return [`--${flag}`];
52
+ }
53
+ /**
54
+ * Repeating flag multiple times when value is an array
55
+ */
56
+ if (Array.isArray(value)) {
57
+ return value.map((v) => [`--${flag}`, v]);
58
+ }
59
+ return [`--${flag}`, value];
60
+ })
61
+ .flat(2);
62
+ }
63
+ /**
64
+ * Returns the assets bundler config
65
+ */
66
+ async #getAssetsBundlerConfig() {
67
+ const assetsBundler = await detectAssetsBundler(this.app);
68
+ return assetsBundler
69
+ ? {
70
+ serve: this.assets === false ? false : true,
71
+ driver: assetsBundler.name,
72
+ cmd: assetsBundler.devServer.command,
73
+ args: (assetsBundler.devServer.args || []).concat(this.assetsArgs || []),
74
+ }
75
+ : {
76
+ serve: false,
77
+ };
78
+ }
40
79
  /**
41
80
  * Runs tests
42
81
  */
@@ -47,50 +86,26 @@ export default class Test extends BaseCommand {
47
86
  this.exitCode = 1;
48
87
  return;
49
88
  }
50
- const assetsBundler = await detectAssetsBundler(this.app);
51
- const testRunner = new assembler.TestRunner(this.app.appRoot, {
89
+ this.testsRunner = new assembler.TestRunner(this.app.appRoot, {
52
90
  clearScreen: this.clear === false ? false : true,
53
91
  nodeArgs: this.parsed.nodeArgs,
54
- scriptArgs: this.parsed.unknownFlags
55
- .map((flag) => {
56
- const value = this.parsed.flags[flag];
57
- /**
58
- * Not mentioning value when value is "true"
59
- */
60
- if (value === true) {
61
- return [`--${flag}`];
62
- }
63
- /**
64
- * Repeating flag multiple times when value is an array
65
- */
66
- if (Array.isArray(value)) {
67
- return value.map((v) => [`--${flag}`, v]);
68
- }
69
- return [`--${flag}`, value];
70
- })
71
- .flat(2),
72
- assets: assetsBundler
73
- ? {
74
- serve: this.assets === false ? false : true,
75
- driver: assetsBundler.name,
76
- cmd: assetsBundler.devServer.command,
77
- args: this.assetsArgs || [],
78
- }
79
- : {
80
- serve: false,
81
- },
92
+ scriptArgs: this.#getPassthroughFlags(),
93
+ assets: await this.#getAssetsBundlerConfig(),
82
94
  filters: {
83
95
  suites: this.suites,
84
96
  files: this.files,
85
97
  groups: this.groups,
86
98
  tags: this.tags,
87
- ignoreTags: this.ignoreTags,
88
99
  tests: this.tests,
89
100
  },
101
+ failed: this.failed,
102
+ retries: this.retries,
103
+ timeout: this.timeout,
104
+ reporters: this.reporters,
90
105
  suites: this.app.rcFile.tests.suites.map((suite) => {
91
106
  return {
92
107
  name: suite.name,
93
- files: Array.isArray(suite.files) ? suite.files : [suite.files],
108
+ files: suite.files,
94
109
  };
95
110
  }),
96
111
  metaFiles: this.app.rcFile.metaFiles,
@@ -99,18 +114,20 @@ export default class Test extends BaseCommand {
99
114
  * Share command logger with assembler, so that CLI flags like --no-ansi has
100
115
  * similar impact for assembler logs as well.
101
116
  */
102
- testRunner.setLogger(this.logger);
117
+ this.testsRunner.setLogger(this.logger);
103
118
  /**
104
119
  * Exit command when the test runner is closed
105
120
  */
106
- testRunner.onClose((exitCode) => {
121
+ this.testsRunner.onClose((exitCode) => {
107
122
  this.exitCode = exitCode;
123
+ this.terminate();
108
124
  });
109
125
  /**
110
126
  * Exit command when the dev server crashes
111
127
  */
112
- testRunner.onError(() => {
128
+ this.testsRunner.onError(() => {
113
129
  this.exitCode = 1;
130
+ this.terminate();
114
131
  });
115
132
  /**
116
133
  * Start the test runner in watch mode
@@ -122,10 +139,10 @@ export default class Test extends BaseCommand {
122
139
  this.exitCode = 1;
123
140
  return;
124
141
  }
125
- await testRunner.runAndWatch(ts, { poll: this.poll || false });
142
+ await this.testsRunner.runAndWatch(ts, { poll: this.poll || false });
126
143
  }
127
144
  else {
128
- await testRunner.run();
145
+ await this.testsRunner.run();
129
146
  }
130
147
  }
131
148
  }
@@ -141,21 +158,30 @@ __decorate([
141
158
  __decorate([
142
159
  flags.array({ description: 'Filter tests by tags' })
143
160
  ], Test.prototype, "tags", void 0);
144
- __decorate([
145
- flags.array({ description: 'Run tests that does not have mentioned tags' })
146
- ], Test.prototype, "ignoreTags", void 0);
147
161
  __decorate([
148
162
  flags.array({ description: 'Filter tests by parent group title' })
149
163
  ], Test.prototype, "groups", void 0);
150
164
  __decorate([
151
165
  flags.array({ description: 'Filter tests by test title' })
152
166
  ], Test.prototype, "tests", void 0);
167
+ __decorate([
168
+ flags.array({ description: 'Activate one or more test reporters' })
169
+ ], Test.prototype, "reporters", void 0);
153
170
  __decorate([
154
171
  flags.boolean({ description: 'Watch filesystem and re-run tests on file change' })
155
172
  ], Test.prototype, "watch", void 0);
156
173
  __decorate([
157
174
  flags.boolean({ description: 'Use polling to detect filesystem changes' })
158
175
  ], Test.prototype, "poll", void 0);
176
+ __decorate([
177
+ flags.number({ description: 'Define default timeout for all tests' })
178
+ ], Test.prototype, "timeout", void 0);
179
+ __decorate([
180
+ flags.number({ description: 'Define default retries for all tests' })
181
+ ], Test.prototype, "retries", void 0);
182
+ __decorate([
183
+ flags.boolean({ description: 'Execute tests failed during the last run' })
184
+ ], Test.prototype, "failed", void 0);
159
185
  __decorate([
160
186
  flags.boolean({
161
187
  description: 'Clear the terminal for new logs after file change',
@@ -36,6 +36,7 @@ export class IgnitorFactory {
36
36
  '@adonisjs/core/providers/app_provider',
37
37
  '@adonisjs/core/providers/hash_provider',
38
38
  '@adonisjs/core/providers/http_provider',
39
+ '@adonisjs/core/providers/repl_provider',
39
40
  ].concat(providers || []);
40
41
  }
41
42
  /**
@@ -6,8 +6,8 @@
6
6
  * For the full copyright and license information, please view the LICENSE
7
7
  * file that was distributed with this source code.
8
8
  */
9
- import { BaseCommand as AceBaseCommand, ListCommand as AceListCommand } from '@adonisjs/ace';
10
9
  import { slash } from '@poppinss/utils';
10
+ import { BaseCommand as AceBaseCommand, ListCommand as AceListCommand } from '@adonisjs/ace';
11
11
  /**
12
12
  * Wrapper around the stub generation logic.
13
13
  * Allow commands to easily generate files from given stubs
@@ -13,6 +13,8 @@ const DEFAULT_NODE_ARGS = [
13
13
  '--no-warnings',
14
14
  // Enable expiremental meta resolve for cases where someone uses magic import string
15
15
  '--experimental-import-meta-resolve',
16
+ // Enable source maps, since TSNode source maps are broken
17
+ '--enable-source-maps',
16
18
  ];
17
19
  /**
18
20
  * Ace shell is used to run the ace commands inside a TypeScript project
@@ -0,0 +1 @@
1
+ export * from '@adonisjs/repl';
@@ -0,0 +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
+ */
9
+ export * from '@adonisjs/repl';
@@ -0,0 +1,13 @@
1
+ import type { ApplicationService } from '../src/types.js';
2
+ export default class ReplServiceProvider {
3
+ protected app: ApplicationService;
4
+ constructor(app: ApplicationService);
5
+ /**
6
+ * Registers the REPL binding
7
+ */
8
+ register(): void;
9
+ /**
10
+ * Registering REPL bindings during provider boot
11
+ */
12
+ boot(): Promise<void>;
13
+ }
@@ -0,0 +1,33 @@
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
+ export default class ReplServiceProvider {
10
+ app;
11
+ constructor(app) {
12
+ this.app = app;
13
+ }
14
+ /**
15
+ * Registers the REPL binding
16
+ */
17
+ register() {
18
+ this.app.container.singleton('repl', async () => {
19
+ const { Repl } = await import('../modules/repl.js');
20
+ return new Repl();
21
+ });
22
+ }
23
+ /**
24
+ * Registering REPL bindings during provider boot
25
+ */
26
+ async boot() {
27
+ if (this.app.getEnvironment() === 'repl') {
28
+ const repl = await this.app.container.make('repl');
29
+ const { defineReplBindings } = await import('../src/bindings/repl.js');
30
+ defineReplBindings(this.app, repl);
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,3 @@
1
+ import type { Repl } from '../modules/repl.js';
2
+ declare let repl: Repl;
3
+ export { repl as default };
@@ -0,0 +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
+ import app from './app.js';
10
+ let repl;
11
+ /**
12
+ * Returns a singleton instance of the Repl class from
13
+ * the container
14
+ */
15
+ await app.booted(async () => {
16
+ repl = await app.container.make('repl');
17
+ });
18
+ export { repl as default };
@@ -0,0 +1,6 @@
1
+ import type { Repl } from '../../modules/repl.js';
2
+ import { ApplicationService } from '../types.js';
3
+ /**
4
+ * Registers REPL methods
5
+ */
6
+ export declare function defineReplBindings(app: ApplicationService, repl: Repl): void;
@@ -0,0 +1,78 @@
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
+ * Resolves a container binding and sets it on the REPL
11
+ * context
12
+ */
13
+ async function resolveBindingForRepl(app, repl, binding) {
14
+ repl.server.context[binding] = await app.container.make(binding);
15
+ repl.notify(`Loaded "${binding}" service. You can access it using the "${repl.colors.underline(binding)}" variable`);
16
+ }
17
+ /**
18
+ * Registers REPL methods
19
+ */
20
+ export function defineReplBindings(app, repl) {
21
+ repl.addMethod('importDefault', (_, modulePath) => {
22
+ return app.importDefault(modulePath);
23
+ }, {
24
+ description: 'Returns the default export for a module',
25
+ });
26
+ repl.addMethod('make', (_, service, runtimeValues) => {
27
+ return app.container.make(service, runtimeValues);
28
+ }, {
29
+ description: 'Make class instance using "container.make" method',
30
+ });
31
+ repl.addMethod('loadApp', () => {
32
+ return resolveBindingForRepl(app, repl, 'app');
33
+ }, {
34
+ description: 'Load "app" service in the REPL context',
35
+ });
36
+ repl.addMethod('loadEncryption', () => {
37
+ return resolveBindingForRepl(app, repl, 'encryption');
38
+ }, {
39
+ description: 'Load "encryption" service in the REPL context',
40
+ });
41
+ repl.addMethod('loadHash', () => {
42
+ return resolveBindingForRepl(app, repl, 'hash');
43
+ }, {
44
+ description: 'Load "hash" service in the REPL context',
45
+ });
46
+ repl.addMethod('loadRouter', () => {
47
+ return resolveBindingForRepl(app, repl, 'router');
48
+ }, {
49
+ description: 'Load "router" service in the REPL context',
50
+ });
51
+ repl.addMethod('loadConfig', () => {
52
+ return resolveBindingForRepl(app, repl, 'config');
53
+ }, {
54
+ description: 'Load "config" service in the REPL context',
55
+ });
56
+ repl.addMethod('loadTestUtils', () => {
57
+ return resolveBindingForRepl(app, repl, 'testUtils');
58
+ }, {
59
+ description: 'Load "testUtils" service in the REPL context',
60
+ });
61
+ repl.addMethod('loadHelpers', async () => {
62
+ const { default: isModule } = await import('../helpers/is.js');
63
+ const { default: stringModule } = await import('../helpers/string.js');
64
+ const { base64, cuid, fsReadAll, slash, parseImports } = await import('../helpers/main.js');
65
+ repl.server.context.helpers = {
66
+ string: stringModule,
67
+ is: isModule,
68
+ base64,
69
+ cuid,
70
+ fsReadAll,
71
+ slash,
72
+ parseImports,
73
+ };
74
+ repl.notify(`Loaded "helpers" module. You can access it using the "${repl.colors.underline('helpers')}" variable`);
75
+ }, {
76
+ description: 'Load "helpers" module in the REPL context',
77
+ });
78
+ }
@@ -0,0 +1 @@
1
+ export { Exception, createError, RuntimeException, InvalidArgumentsException, } from '@poppinss/utils';
@@ -0,0 +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
+ */
9
+ export { Exception, createError, RuntimeException, InvalidArgumentsException, } from '@poppinss/utils';
@@ -8,8 +8,8 @@ export declare class AceProcess {
8
8
  #private;
9
9
  constructor(ignitor: Ignitor);
10
10
  /**
11
- * Register a callback that runs after booting the AdonisJS app
12
- * and just before the provider's ready hook
11
+ * Register a callback that can be used to configure the ace
12
+ * kernel before the handle method is called
13
13
  */
14
14
  configure(callback: (app: ApplicationService) => Promise<void> | void): this;
15
15
  /**
@@ -16,16 +16,16 @@ export class AceProcess {
16
16
  */
17
17
  #ignitor;
18
18
  /**
19
- * The callback that configures the tests runner. This callback
20
- * runs at the time of starting the app.
19
+ * The callback that configures the ace instance before the
20
+ * handle method is called
21
21
  */
22
22
  #configureCallback = () => { };
23
23
  constructor(ignitor) {
24
24
  this.#ignitor = ignitor;
25
25
  }
26
26
  /**
27
- * Register a callback that runs after booting the AdonisJS app
28
- * and just before the provider's ready hook
27
+ * Register a callback that can be used to configure the ace
28
+ * kernel before the handle method is called
29
29
  */
30
30
  configure(callback) {
31
31
  this.#configureCallback = callback;
@@ -50,6 +50,9 @@ export class AceProcess {
50
50
  */
51
51
  kernel.loading(async (metaData) => {
52
52
  if (metaData.options.startApp && !app.isReady) {
53
+ if (metaData.commandName === 'repl') {
54
+ app.setEnvironment('repl');
55
+ }
53
56
  await app.boot();
54
57
  await app.start(() => { });
55
58
  }
@@ -59,17 +62,19 @@ export class AceProcess {
59
62
  * Handle command line args
60
63
  */
61
64
  await kernel.handle(argv);
62
- /**
63
- * Update the process exit code
64
- */
65
- process.exitCode = kernel.exitCode;
66
65
  /**
67
66
  * Terminate the app when the command does not want to
68
67
  * hold a long running process
69
68
  */
70
69
  const mainCommand = kernel.getMainCommand();
71
70
  if (!mainCommand || !mainCommand.staysAlive) {
71
+ process.exitCode = kernel.exitCode;
72
72
  await app.terminate();
73
73
  }
74
+ else {
75
+ app.terminating(() => {
76
+ process.exitCode = mainCommand.exitCode;
77
+ });
78
+ }
74
79
  }
75
80
  }
@@ -1,3 +1,4 @@
1
+ import type { Repl } from '../modules/repl.js';
1
2
  import type { Importer } from '../types/app.js';
2
3
  import type { Emitter } from '../modules/events.js';
3
4
  import type { Kernel } from '../modules/ace/main.js';
@@ -116,4 +117,5 @@ export interface ContainerBindings {
116
117
  server: HttpServerService;
117
118
  router: HttpRouterService;
118
119
  testUtils: TestUtils;
120
+ repl: Repl;
119
121
  }
@@ -0,0 +1,10 @@
1
+ {{#var exceptionName = generators.exceptionName(entity.name)}}
2
+ {{#var exceptionFileName = generators.exceptionFileName(entity.name)}}
3
+ ---
4
+ to: {{ app.exceptionsPath(entity.path, exceptionFileName) }}
5
+ ---
6
+ import { Exception } from '@adonisjs/core/exceptions'
7
+
8
+ export default class {{ exceptionName }} extends Exception {
9
+ static status = 500
10
+ }
@@ -0,0 +1 @@
1
+ export * from '@adonisjs/repl/types';
@@ -0,0 +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
+ */
9
+ export * from '@adonisjs/repl/types';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adonisjs/core",
3
3
  "description": "Core of AdonisJS",
4
- "version": "6.1.5-5",
4
+ "version": "6.1.5-7",
5
5
  "engines": {
6
6
  "node": ">=18.16.0"
7
7
  },
@@ -26,45 +26,17 @@
26
26
  },
27
27
  "exports": {
28
28
  ".": "./build/index.js",
29
- "./commands": "./build/commands/main.js",
30
29
  "./commands/*": "./build/commands/*.js",
31
30
  "./factories": "./build/factories/core/main.js",
32
- "./factories/app": "./build/factories/app.js",
33
- "./factories/bodyparser": "./build/factories/bodyparser.js",
34
- "./factories/encryption": "./build/factories/encryption.js",
35
- "./factories/events": "./build/factories/events.js",
36
- "./factories/hash": "./build/factories/hash.js",
37
- "./factories/http": "./build/factories/http.js",
38
- "./factories/logger": "./build/factories/logger.js",
31
+ "./factories/*": "./build/factories/*.js",
39
32
  "./types": "./build/src/types.js",
40
- "./types/ace": "./build/types/ace.js",
41
- "./types/app": "./build/types/app.js",
42
- "./types/bodyparser": "./build/types/bodyparser.js",
43
- "./types/container": "./build/types/container.js",
44
- "./types/encryption": "./build/types/encryption.js",
45
- "./types/events": "./build/types/events.js",
46
- "./types/hash": "./build/types/hash.js",
47
- "./types/http": "./build/types/http.js",
48
- "./types/logger": "./build/types/logger.js",
49
- "./services/ace": "./build/services/ace.js",
50
- "./services/app": "./build/services/app.js",
51
- "./services/config": "./build/services/config.js",
52
- "./services/emitter": "./build/services/emitter.js",
53
- "./services/encryption": "./build/services/encryption.js",
54
- "./services/hash": "./build/services/hash.js",
55
- "./services/logger": "./build/services/logger.js",
56
- "./services/router": "./build/services/router.js",
57
- "./services/server": "./build/services/server.js",
58
- "./services/test_utils": "./build/services/test_utils.js",
59
- "./providers/app_provider": "./build/providers/app_provider.js",
60
- "./providers/hash_provider": "./build/providers/hash_provider.js",
61
- "./providers/http_provider": "./build/providers/http_provider.js",
33
+ "./types/*": "./build/types/*.js",
34
+ "./services/*": "./build/services/*.js",
35
+ "./providers/*": "./build/providers/*.js",
62
36
  "./helpers": "./build/src/helpers/main.js",
63
- "./helpers/is": "./build/src/helpers/is.js",
64
- "./helpers/types": "./build/src/helpers/types.js",
65
- "./helpers/string": "./build/src/helpers/string.js",
66
- "./ace/shell": "./build/modules/ace/shell.js",
37
+ "./helpers/*": "./build/src/helpers/*.js",
67
38
  "./ace": "./build/modules/ace/main.js",
39
+ "./ace/shell": "./build/modules/ace/shell.js",
68
40
  "./bodyparser": "./build/modules/bodyparser/main.js",
69
41
  "./bodyparser_middleware": "./build/modules/bodyparser/bodyparser_middleware.js",
70
42
  "./hash": "./build/modules/hash/main.js",
@@ -76,7 +48,9 @@
76
48
  "./events": "./build/modules/events.js",
77
49
  "./http": "./build/modules/http.js",
78
50
  "./logger": "./build/modules/logger.js",
79
- "./package.json": "./package.json"
51
+ "./repl": "./build/modules/repl.js",
52
+ "./package.json": "./package.json",
53
+ "./exceptions": "./build/src/exceptions.js"
80
54
  },
81
55
  "scripts": {
82
56
  "pretest": "npm run lint",
@@ -94,11 +68,11 @@
94
68
  "typecheck": "tsc --noEmit",
95
69
  "format": "prettier --write .",
96
70
  "sync-labels": "github-label-sync --labels .github/labels.json adonisjs/core",
97
- "quick:test": "node --loader=ts-node/esm --enable-source-maps --experimental-import-meta-resolve bin/test.ts",
71
+ "quick:test": "node --loader=ts-node/esm --enable-source-maps --experimental-import-meta-resolve bin/test.ts --force-exit",
98
72
  "index:commands": "node --loader=ts-node/esm toolkit/main.js index build/commands"
99
73
  },
100
74
  "devDependencies": {
101
- "@adonisjs/assembler": "^6.1.3-7",
75
+ "@adonisjs/assembler": "^6.1.3-12",
102
76
  "@adonisjs/eslint-config": "^1.1.7",
103
77
  "@adonisjs/prettier-config": "^1.1.7",
104
78
  "@adonisjs/tsconfig": "^1.1.7",
@@ -107,9 +81,9 @@
107
81
  "@japa/assert": "2.0.0-1",
108
82
  "@japa/expect-type": "2.0.0-0",
109
83
  "@japa/file-system": "2.0.0-1",
110
- "@japa/runner": "3.0.0-3",
111
- "@swc/core": "^1.3.67",
112
- "@types/node": "^20.3.3",
84
+ "@japa/runner": "^3.0.0-5",
85
+ "@swc/core": "^1.3.68",
86
+ "@types/node": "^20.4.1",
113
87
  "@types/pretty-hrtime": "^1.0.1",
114
88
  "@types/sinon": "^10.0.15",
115
89
  "@types/supertest": "^2.0.12",
@@ -131,17 +105,19 @@
131
105
  "typescript": "^5.1.6"
132
106
  },
133
107
  "dependencies": {
134
- "@adonisjs/ace": "^12.3.1-7",
135
- "@adonisjs/application": "^7.1.2-6",
108
+ "@adonisjs/ace": "^12.3.1-8",
109
+ "@adonisjs/application": "^7.1.2-8",
136
110
  "@adonisjs/bodyparser": "^9.3.2-6",
137
111
  "@adonisjs/config": "^4.2.1-2",
138
112
  "@adonisjs/encryption": "^5.1.2-2",
139
113
  "@adonisjs/env": "^4.2.0-3",
140
114
  "@adonisjs/events": "^8.4.9-3",
141
- "@adonisjs/fold": "^9.9.3-5",
115
+ "@adonisjs/fold": "^9.9.3-6",
142
116
  "@adonisjs/hash": "^8.3.1-3",
143
- "@adonisjs/http-server": "^6.8.2-7",
117
+ "@adonisjs/http-server": "^6.8.2-8",
144
118
  "@adonisjs/logger": "^5.4.2-3",
119
+ "@adonisjs/repl": "^4.0.0-5",
120
+ "@antfu/install-pkg": "^0.1.1",
145
121
  "@paralleldrive/cuid2": "^2.2.0",
146
122
  "@poppinss/macroable": "^1.0.0-7",
147
123
  "@poppinss/utils": "^6.5.0-3",
@@ -153,10 +129,10 @@
153
129
  "pretty-hrtime": "^1.0.3",
154
130
  "string-width": "^6.1.0",
155
131
  "youch": "^3.2.3",
156
- "youch-terminal": "^2.2.0"
132
+ "youch-terminal": "^2.2.2"
157
133
  },
158
134
  "peerDependencies": {
159
- "@adonisjs/assembler": "^6.1.3-6",
135
+ "@adonisjs/assembler": "^6.1.3-12",
160
136
  "argon2": "^0.30.3",
161
137
  "bcrypt": "^5.0.1"
162
138
  },