@adonisjs/core 6.1.5-32 → 6.1.5-34
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.
- package/build/commands/build.d.ts +3 -5
- package/build/commands/build.js +5 -9
- package/build/commands/commands.json +1 -1
- package/build/commands/configure.d.ts +20 -21
- package/build/commands/configure.js +38 -90
- package/build/commands/generate_key.js +1 -1
- package/build/commands/make/controller.js +5 -5
- package/build/commands/make/exception.js +1 -1
- package/build/commands/make/listener.js +1 -1
- package/build/commands/make/middleware.d.ts +1 -0
- package/build/commands/make/middleware.js +39 -3
- package/build/commands/make/preload.d.ts +1 -1
- package/build/commands/make/preload.js +13 -36
- package/build/commands/make/provider.d.ts +5 -0
- package/build/commands/make/provider.js +33 -5
- package/build/commands/make/test.js +1 -1
- package/build/commands/make/validator.d.ts +5 -0
- package/build/commands/make/validator.js +19 -3
- package/build/commands/serve.js +7 -4
- package/build/commands/test.js +2 -2
- package/build/factories/core/ignitor.js +6 -5
- package/build/modules/ace/codemods.d.ts +38 -4
- package/build/modules/ace/codemods.js +100 -2
- package/build/modules/ace/commands.js +5 -1
- package/build/providers/app_provider.js +6 -4
- package/build/providers/repl_provider.js +11 -2
- package/build/src/helpers/main.d.ts +1 -1
- package/build/src/helpers/main.js +1 -1
- package/build/src/types.d.ts +3 -4
- package/build/stubs/make/validator/resource.stub +26 -0
- package/package.json +32 -32
- /package/build/stubs/make/{preload_file → preload}/main.stub +0 -0
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { BaseCommand } from '../modules/ace/main.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* system changes
|
|
3
|
+
* Create the production build by compiling TypeScript source and the
|
|
4
|
+
* frontend assets
|
|
6
5
|
*/
|
|
7
6
|
export default class Build extends BaseCommand {
|
|
8
7
|
#private;
|
|
9
8
|
static commandName: string;
|
|
10
9
|
static description: string;
|
|
11
10
|
static help: string[];
|
|
12
|
-
watch?: boolean;
|
|
13
11
|
ignoreTsErrors?: boolean;
|
|
14
|
-
packageManager?: 'npm' | 'pnpm' | 'yarn';
|
|
12
|
+
packageManager?: 'npm' | 'pnpm' | 'yarn' | 'bun';
|
|
15
13
|
assets?: boolean;
|
|
16
14
|
assetsArgs?: string[];
|
|
17
15
|
/**
|
package/build/commands/build.js
CHANGED
|
@@ -15,9 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
15
15
|
import { BaseCommand, flags } from '../modules/ace/main.js';
|
|
16
16
|
import { detectAssetsBundler, importAssembler, importTypeScript } from '../src/internal_helpers.js';
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* system changes
|
|
18
|
+
* Create the production build by compiling TypeScript source and the
|
|
19
|
+
* frontend assets
|
|
21
20
|
*/
|
|
22
21
|
export default class Build extends BaseCommand {
|
|
23
22
|
static commandName = 'build';
|
|
@@ -53,13 +52,13 @@ export default class Build extends BaseCommand {
|
|
|
53
52
|
const assetsBundler = await detectAssetsBundler(this.app);
|
|
54
53
|
return assetsBundler
|
|
55
54
|
? {
|
|
56
|
-
|
|
55
|
+
enabled: this.assets === false ? false : true,
|
|
57
56
|
driver: assetsBundler.name,
|
|
58
57
|
cmd: assetsBundler.build.command,
|
|
59
58
|
args: (assetsBundler.build.args || []).concat(this.assetsArgs || []),
|
|
60
59
|
}
|
|
61
60
|
: {
|
|
62
|
-
|
|
61
|
+
enabled: false,
|
|
63
62
|
};
|
|
64
63
|
}
|
|
65
64
|
/**
|
|
@@ -97,15 +96,12 @@ export default class Build extends BaseCommand {
|
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
|
-
__decorate([
|
|
101
|
-
flags.boolean({ description: 'Watch filesystem and restart the HTTP server on file change' })
|
|
102
|
-
], Build.prototype, "watch", void 0);
|
|
103
99
|
__decorate([
|
|
104
100
|
flags.boolean({ description: 'Ignore TypeScript errors and continue with the build process' })
|
|
105
101
|
], Build.prototype, "ignoreTsErrors", void 0);
|
|
106
102
|
__decorate([
|
|
107
103
|
flags.string({
|
|
108
|
-
description: '
|
|
104
|
+
description: 'Define the package manager to copy the appropriate lock file',
|
|
109
105
|
})
|
|
110
106
|
], Build.prototype, "packageManager", void 0);
|
|
111
107
|
__decorate([
|
|
@@ -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":[{"name":"verbose","flagName":"verbose","required":false,"type":"boolean","description":"Display logs in verbose mode"},{"name":"force","flagName":"force","required":false,"type":"boolean","description":"Forcefully overwrite existing files"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"Package name","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"configure.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/configure.js"},{"commandName":"eject","description":"Eject scaffolding stubs to your application root","help":"","namespace":null,"aliases":[],"flags":[{"name":"pkg","flagName":"pkg","required":false,"type":"string","description":"Mention package name for searching stubs","default":"@adonisjs/core"}],"args":[{"name":"stubPath","argumentName":"stub-path","required":true,"description":"Path to the stubs directory or a single stub file","type":"string"}],"options":{},"filePath":"eject.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/eject.js"},{"commandName":"generate:key","description":"Generate a secure random application key","help":"","namespace":"generate","aliases":[],"flags":[{"name":"show","flagName":"show","required":false,"type":"boolean","description":"Display the key on the terminal, instead of writing it to .env file"},{"name":"force","flagName":"force","required":false,"type":"boolean","description":"Force update .env file in production environment"}],"args":[],"options":{},"filePath":"generate_key.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/generate_key.js"},{"commandName":"inspect:rcfile","description":"Inspect the RC file with its default values","help":"","namespace":"inspect","aliases":[],"flags":[],"args":[],"options":{},"filePath":"inspect_rcfile.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/inspect_rcfile.js"},{"commandName":"list:routes","description":"List application routes. This command will boot the application in the console environment","help":"","namespace":"list","aliases":[],"flags":[{"name":"middleware","flagName":"middleware","required":false,"type":"array","description":"View routes that includes all the mentioned middleware names. Use * to see routes that are using one or more middleware"},{"name":"ignoreMiddleware","flagName":"ignore-middleware","required":false,"type":"array","description":"View routes that does not include all the mentioned middleware names. Use * to see routes that are using zero middleware"},{"name":"json","flagName":"json","required":false,"type":"boolean","description":"Get routes list as a JSON string"},{"name":"table","flagName":"table","required":false,"type":"boolean","description":"View list of routes as a table"}],"args":[{"name":"match","argumentName":"match","required":false,"description":"Find routes matching the given keyword. Route name, pattern and controller name will be searched against the keyword","type":"string"}],"options":{"startApp":true},"filePath":"list/routes.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/list/routes.js"},{"commandName":"make:command","description":"Create a new ace command class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the command","type":"string"}],"options":{},"filePath":"make/command.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/command.js"},{"commandName":"make:controller","description":"Create a new HTTP controller class","help":"","namespace":"make","aliases":[],"flags":[{"name":"singular","flagName":"singular","required":false,"type":"boolean","description":"Convert controller class and file name to its singular form","alias":"r"},{"name":"resource","flagName":"resource","required":false,"type":"boolean","description":"Generate controller with resource actions","alias":"r"},{"name":"api","flagName":"api","required":false,"type":"boolean","description":"Generate controller with api resource actions","alias":"a"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"The name of the controller","type":"string"},{"name":"actions","argumentName":"actions","required":false,"description":"Method names to pre-define on the controller","type":"spread"}],"options":{},"filePath":"make/controller.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/controller.js"},{"commandName":"make:event","description":"Create a new event class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the event","type":"string"}],"options":{},"filePath":"make/event.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/event.js"},{"commandName":"make:exception","description":"Create a new ace exception class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the exception","type":"string"}],"options":{},"filePath":"make/exception.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/exception.js"},{"commandName":"make:listener","description":"Create a new event listener class","help":"","namespace":"make","aliases":[],"flags":[{"name":"event","flagName":"event","required":false,"type":"string","description":"Generate an event class alongside the listener","alias":"e"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the listener","type":"string"}],"options":{},"filePath":"make/listener.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/listener.js"},{"commandName":"make:middleware","description":"Create a new middleware class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the middleware","type":"string"}],"options":{},"filePath":"make/middleware.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/middleware.js"},{"commandName":"make:preload","description":"Create a new preload file inside the start directory","help":"","namespace":"make","aliases":[],"flags":[{"name":"environments","flagName":"environments","required":false,"type":"array","description":"Define the preload file's environment. Accepted values are \"web,console,test,repl\""}],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the preload file","type":"string"}],"options":{},"filePath":"make/preload.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/preload.js"},{"commandName":"make:provider","description":"Create a new service provider class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the provider","type":"string"}],"options":{},"filePath":"make/provider.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/provider.js"},{"commandName":"make:service","description":"Create a new service class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the service","type":"string"}],"options":{},"filePath":"make/service.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/service.js"},{"commandName":"make:test","description":"Create a new Japa test file","help":"","namespace":"make","aliases":[],"flags":[{"name":"suite","flagName":"suite","required":false,"type":"string","description":"The suite for which to create the test file"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the test file","type":"string"}],"options":{},"filePath":"make/test.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/test.js"},{"commandName":"make:validator","description":"Create a new VineJS validator","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the validator","type":"string"}],"options":{},"filePath":"make/validator.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/validator.js"},{"commandName":"make:view","description":"Create a new Edge.js template file","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the template","type":"string"}],"options":{},"filePath":"make/view.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/view.js"},{"commandName":"repl","description":"Start a new REPL session","help":"","namespace":null,"aliases":[],"flags":[],"args":[],"options":{"startApp":true,"staysAlive":true},"filePath":"repl.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/repl.js"},{"commandName":"serve","description":"Start the development HTTP server along with the file watcher to perform restarts on file change","help":["Start the development server with file watcher using the following command.","```","{{ binaryName }} serve --watch","```","","The assets bundler dev server runs automatically after detecting vite config or webpack config files","You may pass vite CLI args using the --assets-args command line flag.","```","{{ binaryName }} serve --assets-args=\"--debug --base=/public\"","```"],"namespace":null,"aliases":[],"flags":[{"name":"watch","flagName":"watch","required":false,"type":"boolean","description":"Watch filesystem and restart the HTTP server on file change"},{"name":"poll","flagName":"poll","required":false,"type":"boolean","description":"Use polling to detect filesystem changes"},{"name":"clear","flagName":"clear","required":false,"type":"boolean","description":"Clear the terminal for new logs after file change","showNegatedVariantInHelp":true,"default":true},{"name":"assets","flagName":"assets","required":false,"type":"boolean","description":"Start assets bundler dev server","showNegatedVariantInHelp":true,"default":true},{"name":"assetsArgs","flagName":"assets-args","required":false,"type":"array","description":"Define CLI arguments to pass to the assets bundler"}],"args":[],"options":{"staysAlive":true},"filePath":"serve.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/serve.js"},{"commandName":"test","description":"Run tests along with the file watcher to re-run tests on file change","help":"","namespace":null,"aliases":[],"flags":[{"name":"files","flagName":"files","required":false,"type":"array","description":"Filter tests by the filename"},{"name":"tags","flagName":"tags","required":false,"type":"array","description":"Filter tests by tags"},{"name":"groups","flagName":"groups","required":false,"type":"array","description":"Filter tests by parent group title"},{"name":"tests","flagName":"tests","required":false,"type":"array","description":"Filter tests by test title"},{"name":"reporters","flagName":"reporters","required":false,"type":"array","description":"Activate one or more test reporters"},{"name":"watch","flagName":"watch","required":false,"type":"boolean","description":"Watch filesystem and re-run tests on file change"},{"name":"poll","flagName":"poll","required":false,"type":"boolean","description":"Use polling to detect filesystem changes"},{"name":"timeout","flagName":"timeout","required":false,"type":"number","description":"Define default timeout for all tests"},{"name":"retries","flagName":"retries","required":false,"type":"number","description":"Define default retries for all tests"},{"name":"failed","flagName":"failed","required":false,"type":"boolean","description":"Execute tests failed during the last run"},{"name":"clear","flagName":"clear","required":false,"type":"boolean","description":"Clear the terminal for new logs after file change","showNegatedVariantInHelp":true,"default":true},{"name":"assets","flagName":"assets","required":false,"type":"boolean","description":"Start assets bundler dev server.","showNegatedVariantInHelp":true,"default":true},{"name":"assetsArgs","flagName":"assets-args","required":false,"type":"array","description":"Define CLI arguments to pass to the assets bundler"}],"args":[{"name":"suites","argumentName":"suites","required":false,"description":"Mention suite names to run tests for selected suites","type":"spread"}],"options":{"allowUnknownFlags":true,"staysAlive":true},"filePath":"test.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/test.js"}],"version":1}
|
|
1
|
+
{"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":"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":"Define the package manager to copy the appropriate lock file"},{"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 after it has been installed","help":"","namespace":null,"aliases":[],"flags":[{"name":"verbose","flagName":"verbose","required":false,"type":"boolean","description":"Display logs in verbose mode","alias":"v"},{"name":"force","flagName":"force","required":false,"type":"boolean","description":"Forcefully overwrite existing files","alias":"f"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"Package name","type":"string"}],"options":{"allowUnknownFlags":true},"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 cryptographically secure random application key","help":"","namespace":"generate","aliases":[],"flags":[{"name":"show","flagName":"show","required":false,"type":"boolean","description":"Display the key on the terminal, instead of writing it to .env file"},{"name":"force","flagName":"force","required":false,"type":"boolean","description":"Force update .env file in production environment"}],"args":[],"options":{},"filePath":"generate_key.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/generate_key.js"},{"commandName":"inspect:rcfile","description":"Inspect the RC file with its default values","help":"","namespace":"inspect","aliases":[],"flags":[],"args":[],"options":{},"filePath":"inspect_rcfile.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/inspect_rcfile.js"},{"commandName":"list:routes","description":"List application routes. This command will boot the application in the console environment","help":"","namespace":"list","aliases":[],"flags":[{"name":"middleware","flagName":"middleware","required":false,"type":"array","description":"View routes that includes all the mentioned middleware names. Use * to see routes that are using one or more middleware"},{"name":"ignoreMiddleware","flagName":"ignore-middleware","required":false,"type":"array","description":"View routes that does not include all the mentioned middleware names. Use * to see routes that are using zero middleware"},{"name":"json","flagName":"json","required":false,"type":"boolean","description":"Get routes list as a JSON string"},{"name":"table","flagName":"table","required":false,"type":"boolean","description":"View list of routes as a table"}],"args":[{"name":"match","argumentName":"match","required":false,"description":"Find routes matching the given keyword. Route name, pattern and controller name will be searched against the keyword","type":"string"}],"options":{"startApp":true},"filePath":"list/routes.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/list/routes.js"},{"commandName":"make:command","description":"Create a new ace command class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the command","type":"string"}],"options":{},"filePath":"make/command.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/command.js"},{"commandName":"make:controller","description":"Create a new HTTP controller class","help":"","namespace":"make","aliases":[],"flags":[{"name":"singular","flagName":"singular","required":false,"type":"boolean","description":"Generate controller in singular form","alias":"s"},{"name":"resource","flagName":"resource","required":false,"type":"boolean","description":"Generate controller with methods to perform CRUD actions on a resource","alias":"r"},{"name":"api","flagName":"api","required":false,"type":"boolean","description":"Generate resourceful controller with the \"edit\" and the \"create\" methods","alias":"a"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"The name of the controller","type":"string"},{"name":"actions","argumentName":"actions","required":false,"description":"Create controller with custom method names","type":"spread"}],"options":{},"filePath":"make/controller.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/controller.js"},{"commandName":"make:event","description":"Create a new event class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the event","type":"string"}],"options":{},"filePath":"make/event.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/event.js"},{"commandName":"make:exception","description":"Create a new custom exception class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the exception","type":"string"}],"options":{},"filePath":"make/exception.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/exception.js"},{"commandName":"make:listener","description":"Create a new event listener class","help":"","namespace":"make","aliases":[],"flags":[{"name":"event","flagName":"event","required":false,"type":"string","description":"Generate an event class alongside the listener","alias":"e"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the event listener","type":"string"}],"options":{},"filePath":"make/listener.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/listener.js"},{"commandName":"make:middleware","description":"Create a new middleware class for HTTP requests","help":"","namespace":"make","aliases":[],"flags":[{"name":"stack","flagName":"stack","required":false,"type":"string","description":"The stack in which to register the middleware","alias":"s"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the middleware","type":"string"}],"options":{},"filePath":"make/middleware.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/middleware.js"},{"commandName":"make:preload","description":"Create a new preload file inside the start directory","help":"","namespace":"make","aliases":[],"flags":[{"name":"environments","flagName":"environments","required":false,"type":"array","description":"Define the preload file's environment. Accepted values are \"web,console,test,repl\"","alias":"e"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the preload file","type":"string"}],"options":{},"filePath":"make/preload.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/preload.js"},{"commandName":"make:provider","description":"Create a new service provider class","help":"","namespace":"make","aliases":[],"flags":[{"name":"environments","flagName":"environments","required":false,"type":"array","description":"Define the provider environment. Accepted values are \"web,console,test,repl\"","alias":"e"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the provider","type":"string"}],"options":{},"filePath":"make/provider.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/provider.js"},{"commandName":"make:service","description":"Create a new service class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the service","type":"string"}],"options":{},"filePath":"make/service.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/service.js"},{"commandName":"make:test","description":"Create a new Japa test file","help":"","namespace":"make","aliases":[],"flags":[{"name":"suite","flagName":"suite","required":false,"type":"string","description":"The suite for which to create the test file","alias":"s"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the test file","type":"string"}],"options":{},"filePath":"make/test.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/test.js"},{"commandName":"make:validator","description":"Create a new file to define VineJS validators","help":"","namespace":"make","aliases":[],"flags":[{"name":"resource","flagName":"resource","required":false,"type":"boolean","description":"Create a file with pre-defined validators for create and update actions"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the validator file","type":"string"}],"options":{},"filePath":"make/validator.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/validator.js"},{"commandName":"make:view","description":"Create a new Edge.js template file","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the template","type":"string"}],"options":{},"filePath":"make/view.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/make/view.js"},{"commandName":"repl","description":"Start a new REPL session","help":"","namespace":null,"aliases":[],"flags":[],"args":[],"options":{"startApp":true,"staysAlive":true},"filePath":"repl.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/repl.js"},{"commandName":"serve","description":"Start the development HTTP server along with the file watcher to perform restarts on file change","help":["Start the development server with file watcher using the following command.","```","{{ binaryName }} serve --watch","```","","The assets bundler dev server runs automatically after detecting vite config or webpack config files","You may pass vite CLI args using the --assets-args command line flag.","```","{{ binaryName }} serve --assets-args=\"--debug --base=/public\"","```"],"namespace":null,"aliases":[],"flags":[{"name":"watch","flagName":"watch","required":false,"type":"boolean","description":"Watch filesystem and restart the HTTP server on file change","alias":"w"},{"name":"poll","flagName":"poll","required":false,"type":"boolean","description":"Use polling to detect filesystem changes","alias":"p"},{"name":"clear","flagName":"clear","required":false,"type":"boolean","description":"Clear the terminal for new logs after file change","showNegatedVariantInHelp":true,"default":true},{"name":"assets","flagName":"assets","required":false,"type":"boolean","description":"Start assets bundler dev server","showNegatedVariantInHelp":true,"default":true},{"name":"assetsArgs","flagName":"assets-args","required":false,"type":"array","description":"Define CLI arguments to pass to the assets bundler"}],"args":[],"options":{"staysAlive":true},"filePath":"serve.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/serve.js"},{"commandName":"test","description":"Run tests along with the file watcher to re-run tests on file change","help":"","namespace":null,"aliases":[],"flags":[{"name":"files","flagName":"files","required":false,"type":"array","description":"Filter tests by the filename"},{"name":"tags","flagName":"tags","required":false,"type":"array","description":"Filter tests by tags"},{"name":"groups","flagName":"groups","required":false,"type":"array","description":"Filter tests by parent group title"},{"name":"tests","flagName":"tests","required":false,"type":"array","description":"Filter tests by test title"},{"name":"reporters","flagName":"reporters","required":false,"type":"array","description":"Activate one or more test reporters"},{"name":"watch","flagName":"watch","required":false,"type":"boolean","description":"Watch filesystem and re-run tests on file change"},{"name":"poll","flagName":"poll","required":false,"type":"boolean","description":"Use polling to detect filesystem changes"},{"name":"timeout","flagName":"timeout","required":false,"type":"number","description":"Define default timeout for all tests"},{"name":"retries","flagName":"retries","required":false,"type":"number","description":"Define default retries for all tests"},{"name":"failed","flagName":"failed","required":false,"type":"boolean","description":"Execute tests failed during the last run"},{"name":"clear","flagName":"clear","required":false,"type":"boolean","description":"Clear the terminal for new logs after file change","showNegatedVariantInHelp":true,"default":true},{"name":"assets","flagName":"assets","required":false,"type":"boolean","description":"Start assets bundler dev server.","showNegatedVariantInHelp":true,"default":true},{"name":"assetsArgs","flagName":"assets-args","required":false,"type":"array","description":"Define CLI arguments to pass to the assets bundler"}],"args":[{"name":"suites","argumentName":"suites","required":false,"description":"Mention suite names to run tests for selected suites","type":"spread"}],"options":{"allowUnknownFlags":true,"staysAlive":true},"filePath":"test.js","absoluteFilePath":"/Users/virk/code/adonisjs/core/core/build/commands/test.js"}],"version":1}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { CommandOptions } from '../types/ace.js';
|
|
1
2
|
import { BaseCommand } from '../modules/ace/main.js';
|
|
2
|
-
import { CommandOptions } from '../types/ace.js';
|
|
3
3
|
/**
|
|
4
4
|
* The configure command is used to configure packages after installation
|
|
5
5
|
*/
|
|
@@ -8,42 +8,41 @@ export default class Configure extends BaseCommand {
|
|
|
8
8
|
static commandName: string;
|
|
9
9
|
static description: string;
|
|
10
10
|
static options: CommandOptions;
|
|
11
|
+
/**
|
|
12
|
+
* Exposing all flags from the protected property "parsed"
|
|
13
|
+
*/
|
|
11
14
|
get parsedFlags(): {
|
|
12
15
|
[argName: string]: any;
|
|
13
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Exposing all args from the protected property "parsed"
|
|
19
|
+
*/
|
|
14
20
|
get parsedArgs(): (string | number)[];
|
|
21
|
+
/**
|
|
22
|
+
* Name of the package to configure
|
|
23
|
+
*/
|
|
15
24
|
name: string;
|
|
25
|
+
/**
|
|
26
|
+
* Turn on verbose mode for packages installation
|
|
27
|
+
*/
|
|
16
28
|
verbose?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Forcefully overwrite existing files.
|
|
31
|
+
*/
|
|
17
32
|
force?: boolean;
|
|
18
33
|
/**
|
|
19
34
|
* The root of the stubs directory. The value is defined after we import
|
|
20
35
|
* the package
|
|
21
36
|
*/
|
|
22
37
|
stubsRoot: string;
|
|
38
|
+
/**
|
|
39
|
+
* Creates codemods as per configure command options
|
|
40
|
+
*/
|
|
41
|
+
createCodemods(): Promise<import("../modules/ace/codemods.js").Codemods>;
|
|
23
42
|
/**
|
|
24
43
|
* Publish a stub file to the user project
|
|
25
44
|
*/
|
|
26
45
|
publishStub(stubPath: string, stubData?: Record<string, any>): Promise<void>;
|
|
27
|
-
/**
|
|
28
|
-
* Install packages using the correct package manager
|
|
29
|
-
* You can specify version of each package by setting it in the
|
|
30
|
-
* name like :
|
|
31
|
-
*
|
|
32
|
-
* ```
|
|
33
|
-
* installPackages(['@adonisjs/lucid@next', '@adonisjs/auth@3.0.0'])
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
installPackages(packages: {
|
|
37
|
-
name: string;
|
|
38
|
-
isDevDependency: boolean;
|
|
39
|
-
}[]): Promise<void>;
|
|
40
|
-
/**
|
|
41
|
-
* List the packages one should install before using the packages
|
|
42
|
-
*/
|
|
43
|
-
listPackagesToInstall(packages: {
|
|
44
|
-
name: string;
|
|
45
|
-
isDevDependency: boolean;
|
|
46
|
-
}[]): void;
|
|
47
46
|
/**
|
|
48
47
|
* Run method is invoked by ace automatically
|
|
49
48
|
*/
|
|
@@ -13,45 +13,42 @@ 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';
|
|
17
16
|
import { args, BaseCommand, flags } from '../modules/ace/main.js';
|
|
18
17
|
/**
|
|
19
18
|
* The configure command is used to configure packages after installation
|
|
20
19
|
*/
|
|
21
20
|
export default class Configure extends BaseCommand {
|
|
22
21
|
static commandName = 'configure';
|
|
23
|
-
static description = 'Configure a package
|
|
22
|
+
static description = 'Configure a package after it has been installed';
|
|
24
23
|
static options = {
|
|
25
24
|
allowUnknownFlags: true,
|
|
26
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Exposing all flags from the protected property "parsed"
|
|
28
|
+
*/
|
|
27
29
|
get parsedFlags() {
|
|
28
30
|
return this.parsed.flags;
|
|
29
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Exposing all args from the protected property "parsed"
|
|
34
|
+
*/
|
|
30
35
|
get parsedArgs() {
|
|
31
36
|
return this.parsed._;
|
|
32
37
|
}
|
|
33
38
|
/**
|
|
34
39
|
* Returns the package main exports
|
|
35
40
|
*/
|
|
36
|
-
#getPackageSource(packageName) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
* Returns the installation command for different
|
|
41
|
-
* package managers
|
|
42
|
-
*/
|
|
43
|
-
#getInstallationCommands(packages, packageManager, isDev) {
|
|
44
|
-
if (!packages.length) {
|
|
45
|
-
return '';
|
|
41
|
+
async #getPackageSource(packageName) {
|
|
42
|
+
try {
|
|
43
|
+
const packageExports = await this.app.import(packageName);
|
|
44
|
+
return packageExports;
|
|
46
45
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
case 'pnpm':
|
|
54
|
-
return `${this.colors.yellow(`pnpm add${devFlag}`)} ${packages.join(' ')}`;
|
|
46
|
+
catch (error) {
|
|
47
|
+
if ((error.code && error.code === 'ERR_MODULE_NOT_FOUND') ||
|
|
48
|
+
error.message.startsWith('Cannot find module')) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
throw error;
|
|
55
52
|
}
|
|
56
53
|
}
|
|
57
54
|
/**
|
|
@@ -73,6 +70,15 @@ export default class Configure extends BaseCommand {
|
|
|
73
70
|
rcFile.addMetaFile('resources/views/**/*.edge', false);
|
|
74
71
|
});
|
|
75
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Creates codemods as per configure command options
|
|
75
|
+
*/
|
|
76
|
+
async createCodemods() {
|
|
77
|
+
const codemods = await super.createCodemods();
|
|
78
|
+
codemods.overwriteExisting = this.force === true;
|
|
79
|
+
codemods.verboseInstallOutput = this.verbose === true;
|
|
80
|
+
return codemods;
|
|
81
|
+
}
|
|
76
82
|
/**
|
|
77
83
|
* Publish a stub file to the user project
|
|
78
84
|
*/
|
|
@@ -93,67 +99,6 @@ export default class Configure extends BaseCommand {
|
|
|
93
99
|
}
|
|
94
100
|
this.logger.action(`create ${entityFileName}`).succeeded();
|
|
95
101
|
}
|
|
96
|
-
/**
|
|
97
|
-
* Install packages using the correct package manager
|
|
98
|
-
* You can specify version of each package by setting it in the
|
|
99
|
-
* name like :
|
|
100
|
-
*
|
|
101
|
-
* ```
|
|
102
|
-
* installPackages(['@adonisjs/lucid@next', '@adonisjs/auth@3.0.0'])
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
|
-
async installPackages(packages) {
|
|
106
|
-
const appPath = this.app.makePath();
|
|
107
|
-
const silent = this.verbose === true ? false : true;
|
|
108
|
-
const devDeps = packages.filter((pkg) => pkg.isDevDependency).map(({ name }) => name);
|
|
109
|
-
const deps = packages.filter((pkg) => !pkg.isDevDependency).map(({ name }) => name);
|
|
110
|
-
const packageManager = await detectPackageManager(appPath);
|
|
111
|
-
let spinner = this.logger
|
|
112
|
-
.await(`installing dependencies using ${packageManager || 'npm'}`)
|
|
113
|
-
.start();
|
|
114
|
-
try {
|
|
115
|
-
await installPackage(deps, { cwd: appPath, silent });
|
|
116
|
-
await installPackage(devDeps, { dev: true, cwd: appPath, silent });
|
|
117
|
-
spinner.stop();
|
|
118
|
-
this.logger.success('dependencies installed');
|
|
119
|
-
this.logger.log(devDeps.map((dep) => ` ${this.colors.dim('dev')} ${dep}`).join('\n'));
|
|
120
|
-
this.logger.log(deps.map((dep) => ` ${this.colors.dim('prod')} ${dep}`).join('\n'));
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
spinner.update('unable to install dependencies');
|
|
124
|
-
spinner.stop();
|
|
125
|
-
this.exitCode = 1;
|
|
126
|
-
this.logger.fatal(error);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* List the packages one should install before using the packages
|
|
131
|
-
*/
|
|
132
|
-
listPackagesToInstall(packages) {
|
|
133
|
-
const devDependencies = packages.filter((pkg) => pkg.isDevDependency).map(({ name }) => name);
|
|
134
|
-
const prodDependencies = packages.filter((pkg) => !pkg.isDevDependency).map(({ name }) => name);
|
|
135
|
-
const instructions = this.ui.sticker().heading('Please install following packages');
|
|
136
|
-
[
|
|
137
|
-
this.colors.dim('# npm'),
|
|
138
|
-
this.#getInstallationCommands(devDependencies, 'npm', true),
|
|
139
|
-
this.#getInstallationCommands(prodDependencies, 'npm', false),
|
|
140
|
-
' ',
|
|
141
|
-
]
|
|
142
|
-
.concat([
|
|
143
|
-
this.colors.dim('# yarn'),
|
|
144
|
-
this.#getInstallationCommands(devDependencies, 'yarn', true),
|
|
145
|
-
this.#getInstallationCommands(prodDependencies, 'yarn', false),
|
|
146
|
-
' ',
|
|
147
|
-
])
|
|
148
|
-
.concat([
|
|
149
|
-
this.colors.dim('# pnpm'),
|
|
150
|
-
this.#getInstallationCommands(devDependencies, 'pnpm', true),
|
|
151
|
-
this.#getInstallationCommands(prodDependencies, 'pnpm', false),
|
|
152
|
-
])
|
|
153
|
-
.filter((line) => line.length)
|
|
154
|
-
.forEach((line) => instructions.add(line));
|
|
155
|
-
instructions.render();
|
|
156
|
-
}
|
|
157
102
|
/**
|
|
158
103
|
* Run method is invoked by ace automatically
|
|
159
104
|
*/
|
|
@@ -165,22 +110,25 @@ export default class Configure extends BaseCommand {
|
|
|
165
110
|
return this.#configureEdge();
|
|
166
111
|
}
|
|
167
112
|
const packageExports = await this.#getPackageSource(this.name);
|
|
113
|
+
if (!packageExports) {
|
|
114
|
+
this.logger.error(`Cannot find module "${this.name}". Make sure to install it`);
|
|
115
|
+
this.exitCode = 1;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
168
118
|
/**
|
|
169
119
|
* Warn, there are not instructions to run
|
|
170
120
|
*/
|
|
171
121
|
if (!packageExports.configure) {
|
|
172
|
-
this.logger.
|
|
122
|
+
this.logger.error(`Cannot configure module "${this.name}". The module does not export the configure hook`);
|
|
123
|
+
this.exitCode = 1;
|
|
173
124
|
return;
|
|
174
125
|
}
|
|
175
126
|
/**
|
|
176
|
-
*
|
|
127
|
+
* Set stubsRoot property when package exports it
|
|
177
128
|
*/
|
|
178
|
-
if (
|
|
179
|
-
this.
|
|
180
|
-
this.exitCode = 1;
|
|
181
|
-
return;
|
|
129
|
+
if (packageExports.stubsRoot) {
|
|
130
|
+
this.stubsRoot = packageExports.stubsRoot;
|
|
182
131
|
}
|
|
183
|
-
this.stubsRoot = packageExports.stubsRoot;
|
|
184
132
|
/**
|
|
185
133
|
* Run instructions
|
|
186
134
|
*/
|
|
@@ -191,8 +139,8 @@ __decorate([
|
|
|
191
139
|
args.string({ description: 'Package name' })
|
|
192
140
|
], Configure.prototype, "name", void 0);
|
|
193
141
|
__decorate([
|
|
194
|
-
flags.boolean({ description: 'Display logs in verbose mode' })
|
|
142
|
+
flags.boolean({ description: 'Display logs in verbose mode', alias: 'v' })
|
|
195
143
|
], Configure.prototype, "verbose", void 0);
|
|
196
144
|
__decorate([
|
|
197
|
-
flags.boolean({ description: 'Forcefully overwrite existing files' })
|
|
145
|
+
flags.boolean({ description: 'Forcefully overwrite existing files', alias: 'f' })
|
|
198
146
|
], Configure.prototype, "force", void 0);
|
|
@@ -21,7 +21,7 @@ import { BaseCommand, flags } from '../modules/ace/main.js';
|
|
|
21
21
|
*/
|
|
22
22
|
export default class GenerateKey extends BaseCommand {
|
|
23
23
|
static commandName = 'generate:key';
|
|
24
|
-
static description = 'Generate a secure random application key';
|
|
24
|
+
static description = 'Generate a cryptographically secure random application key';
|
|
25
25
|
async run() {
|
|
26
26
|
let writeToFile = process.env.NODE_ENV !== 'production';
|
|
27
27
|
if (this.force) {
|
|
@@ -77,23 +77,23 @@ __decorate([
|
|
|
77
77
|
args.string({ description: 'The name of the controller' })
|
|
78
78
|
], MakeController.prototype, "name", void 0);
|
|
79
79
|
__decorate([
|
|
80
|
-
args.spread({ description: '
|
|
80
|
+
args.spread({ description: 'Create controller with custom method names', required: false })
|
|
81
81
|
], MakeController.prototype, "actions", void 0);
|
|
82
82
|
__decorate([
|
|
83
83
|
flags.boolean({
|
|
84
|
-
description: '
|
|
85
|
-
alias: '
|
|
84
|
+
description: 'Generate controller in singular form',
|
|
85
|
+
alias: 's',
|
|
86
86
|
})
|
|
87
87
|
], MakeController.prototype, "singular", void 0);
|
|
88
88
|
__decorate([
|
|
89
89
|
flags.boolean({
|
|
90
|
-
description: 'Generate controller with
|
|
90
|
+
description: 'Generate controller with methods to perform CRUD actions on a resource',
|
|
91
91
|
alias: 'r',
|
|
92
92
|
})
|
|
93
93
|
], MakeController.prototype, "resource", void 0);
|
|
94
94
|
__decorate([
|
|
95
95
|
flags.boolean({
|
|
96
|
-
description: 'Generate controller with
|
|
96
|
+
description: 'Generate resourceful controller with the "edit" and the "create" methods',
|
|
97
97
|
alias: 'a',
|
|
98
98
|
})
|
|
99
99
|
], MakeController.prototype, "api", void 0);
|
|
@@ -19,7 +19,7 @@ import { args, BaseCommand } from '../../modules/ace/main.js';
|
|
|
19
19
|
*/
|
|
20
20
|
export default class MakeException extends BaseCommand {
|
|
21
21
|
static commandName = 'make:exception';
|
|
22
|
-
static description = 'Create a new
|
|
22
|
+
static description = 'Create a new custom exception class';
|
|
23
23
|
/**
|
|
24
24
|
* The stub to use for generating the command class
|
|
25
25
|
*/
|
|
@@ -54,7 +54,7 @@ export default class MakeListener extends BaseCommand {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
__decorate([
|
|
57
|
-
args.string({ description: 'Name of the listener' })
|
|
57
|
+
args.string({ description: 'Name of the event listener' })
|
|
58
58
|
], MakeListener.prototype, "name", void 0);
|
|
59
59
|
__decorate([
|
|
60
60
|
flags.string({
|
|
@@ -12,27 +12,63 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
12
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
13
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
14
|
};
|
|
15
|
+
import string from '@poppinss/utils/string';
|
|
16
|
+
import { basename, extname } from 'node:path';
|
|
15
17
|
import { stubsRoot } from '../../stubs/main.js';
|
|
16
|
-
import { args, BaseCommand } from '../../modules/ace/main.js';
|
|
18
|
+
import { args, BaseCommand, flags } from '../../modules/ace/main.js';
|
|
17
19
|
/**
|
|
18
20
|
* The make middleware command to create a new middleware
|
|
19
21
|
* class.
|
|
20
22
|
*/
|
|
21
23
|
export default class MakeMiddleware extends BaseCommand {
|
|
22
24
|
static commandName = 'make:middleware';
|
|
23
|
-
static description = 'Create a new middleware class';
|
|
25
|
+
static description = 'Create a new middleware class for HTTP requests';
|
|
24
26
|
/**
|
|
25
27
|
* The stub to use for generating the middleware
|
|
26
28
|
*/
|
|
27
29
|
stubPath = 'make/middleware/main.stub';
|
|
28
30
|
async run() {
|
|
31
|
+
const stackChoices = ['server', 'router', 'named'];
|
|
32
|
+
/**
|
|
33
|
+
* Prompt to select the stack under which to register
|
|
34
|
+
* the middleware
|
|
35
|
+
*/
|
|
36
|
+
if (!this.stack) {
|
|
37
|
+
this.stack = await this.prompt.choice('Under which stack you want to register the middleware?', stackChoices);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Error out when mentioned stack is invalid
|
|
41
|
+
*/
|
|
42
|
+
if (!stackChoices.includes(this.stack)) {
|
|
43
|
+
this.exitCode = 1;
|
|
44
|
+
this.logger.error(`Invalid middleware stack "${this.stack}". Select from "${stackChoices.join(', ')}"`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Create middleware
|
|
49
|
+
*/
|
|
29
50
|
const codemods = await this.createCodemods();
|
|
30
|
-
await codemods.makeUsingStub(stubsRoot, this.stubPath, {
|
|
51
|
+
const { relativeFileName } = await codemods.makeUsingStub(stubsRoot, this.stubPath, {
|
|
31
52
|
flags: this.parsed.flags,
|
|
32
53
|
entity: this.app.generators.createEntity(this.name),
|
|
33
54
|
});
|
|
55
|
+
/**
|
|
56
|
+
* Register middleware
|
|
57
|
+
*/
|
|
58
|
+
const middlewareFileName = basename(relativeFileName).replace(extname(relativeFileName), '');
|
|
59
|
+
const importPath = `#middleware/${middlewareFileName}`;
|
|
60
|
+
const namedReference = string.camelCase(middlewareFileName.replace(/_middleware$/, ''));
|
|
61
|
+
await codemods.registerMiddleware(this.stack, [
|
|
62
|
+
{
|
|
63
|
+
name: namedReference,
|
|
64
|
+
path: importPath,
|
|
65
|
+
},
|
|
66
|
+
]);
|
|
34
67
|
}
|
|
35
68
|
}
|
|
36
69
|
__decorate([
|
|
37
70
|
args.string({ description: 'Name of the middleware' })
|
|
38
71
|
], MakeMiddleware.prototype, "name", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
flags.string({ description: 'The stack in which to register the middleware', alias: 's' })
|
|
74
|
+
], MakeMiddleware.prototype, "stack", void 0);
|
|
@@ -9,7 +9,7 @@ export default class MakePreload extends BaseCommand {
|
|
|
9
9
|
static commandName: string;
|
|
10
10
|
static description: string;
|
|
11
11
|
name: string;
|
|
12
|
-
environments
|
|
12
|
+
environments?: AllowedAppEnvironments;
|
|
13
13
|
/**
|
|
14
14
|
* The stub to use for generating the preload file
|
|
15
15
|
*/
|