@adonisjs/core 6.2.3 → 6.3.1
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/add.d.ts +21 -0
- package/build/commands/add.js +143 -0
- package/build/commands/build.js +4 -0
- package/build/commands/commands.json +1 -1
- package/build/commands/make/controller.js +2 -2
- package/build/commands/serve.js +4 -0
- package/build/modules/ace/codemods.d.ts +15 -4
- package/build/modules/ace/codemods.js +75 -29
- package/build/src/internal_helpers.js +3 -0
- package/package.json +22 -20
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CommandOptions } from '../types/ace.js';
|
|
2
|
+
import { BaseCommand } from '../modules/ace/main.js';
|
|
3
|
+
/**
|
|
4
|
+
* The install command is used to `npm install` and `node ace configure` a new package
|
|
5
|
+
* in one go.
|
|
6
|
+
*/
|
|
7
|
+
export default class Add extends BaseCommand {
|
|
8
|
+
#private;
|
|
9
|
+
static commandName: string;
|
|
10
|
+
static description: string;
|
|
11
|
+
static options: CommandOptions;
|
|
12
|
+
name: string;
|
|
13
|
+
verbose?: boolean;
|
|
14
|
+
packageManager?: 'npm' | 'pnpm' | 'yarn';
|
|
15
|
+
dev?: boolean;
|
|
16
|
+
force?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Run method is invoked by ace automatically
|
|
19
|
+
*/
|
|
20
|
+
run(): Promise<void>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
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 { detectPackageManager, installPackage } from '@antfu/install-pkg';
|
|
16
|
+
import { args, BaseCommand, flags } from '../modules/ace/main.js';
|
|
17
|
+
/**
|
|
18
|
+
* The install command is used to `npm install` and `node ace configure` a new package
|
|
19
|
+
* in one go.
|
|
20
|
+
*/
|
|
21
|
+
export default class Add extends BaseCommand {
|
|
22
|
+
static commandName = 'add';
|
|
23
|
+
static description = 'Install and configure a package';
|
|
24
|
+
static options = {
|
|
25
|
+
allowUnknownFlags: true,
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Detect the package manager to use
|
|
29
|
+
*/
|
|
30
|
+
async #getPackageManager() {
|
|
31
|
+
const pkgManager = this.packageManager || (await detectPackageManager(this.app.makePath())) || 'npm';
|
|
32
|
+
if (['npm', 'pnpm', 'yarn'].includes(pkgManager)) {
|
|
33
|
+
return pkgManager;
|
|
34
|
+
}
|
|
35
|
+
throw new Error('Invalid package manager. Must be one of npm, pnpm or yarn');
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Configure the package by delegating the work to the `node ace configure` command
|
|
39
|
+
*/
|
|
40
|
+
async #configurePackage() {
|
|
41
|
+
/**
|
|
42
|
+
* Sending unknown flags to the configure command
|
|
43
|
+
*/
|
|
44
|
+
const flagValueArray = this.parsed.unknownFlags
|
|
45
|
+
.filter((flag) => !!this.parsed.flags[flag])
|
|
46
|
+
.map((flag) => `--${flag}=${this.parsed.flags[flag]}`);
|
|
47
|
+
const configureArgs = [
|
|
48
|
+
this.name,
|
|
49
|
+
this.force ? '--force' : undefined,
|
|
50
|
+
this.verbose ? '--verbose' : undefined,
|
|
51
|
+
...flagValueArray,
|
|
52
|
+
].filter(Boolean);
|
|
53
|
+
return await this.kernel.exec('configure', configureArgs);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Install the package using the selected package manager
|
|
57
|
+
*/
|
|
58
|
+
async #installPackage(npmPackageName) {
|
|
59
|
+
const colors = this.colors;
|
|
60
|
+
const spinner = this.logger
|
|
61
|
+
.await(`installing ${colors.green(this.name)} using ${colors.grey(this.packageManager)}`)
|
|
62
|
+
.start();
|
|
63
|
+
spinner.start();
|
|
64
|
+
try {
|
|
65
|
+
await installPackage(npmPackageName, {
|
|
66
|
+
dev: this.dev,
|
|
67
|
+
silent: this.verbose === true ? false : true,
|
|
68
|
+
cwd: this.app.makePath(),
|
|
69
|
+
packageManager: this.packageManager,
|
|
70
|
+
});
|
|
71
|
+
spinner.update('package installed successfully');
|
|
72
|
+
spinner.stop();
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
spinner.update('unable to install the package');
|
|
77
|
+
spinner.stop();
|
|
78
|
+
this.logger.fatal(error);
|
|
79
|
+
this.exitCode = 1;
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Run method is invoked by ace automatically
|
|
85
|
+
*/
|
|
86
|
+
async run() {
|
|
87
|
+
const colors = this.colors;
|
|
88
|
+
this.packageManager = await this.#getPackageManager();
|
|
89
|
+
/**
|
|
90
|
+
* Handle special packages to configure
|
|
91
|
+
*/
|
|
92
|
+
let npmPackageName = this.name;
|
|
93
|
+
if (this.name === 'vinejs') {
|
|
94
|
+
npmPackageName = '@vinejs/vine';
|
|
95
|
+
}
|
|
96
|
+
else if (this.name === 'edge') {
|
|
97
|
+
npmPackageName = 'edge.js';
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Prompt the user to confirm the installation
|
|
101
|
+
*/
|
|
102
|
+
const cmd = colors.grey(`${this.packageManager} add ${this.dev ? '-D ' : ''}${this.name}`);
|
|
103
|
+
this.logger.info(`Installing the package using the following command : ${cmd}`);
|
|
104
|
+
const shouldInstall = await this.prompt.confirm('Continue ?', { name: 'install' });
|
|
105
|
+
if (!shouldInstall) {
|
|
106
|
+
this.logger.info('Installation cancelled');
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Install package
|
|
111
|
+
*/
|
|
112
|
+
const pkgWasInstalled = await this.#installPackage(npmPackageName);
|
|
113
|
+
if (!pkgWasInstalled) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Configure package
|
|
118
|
+
*/
|
|
119
|
+
const { exitCode } = await this.#configurePackage();
|
|
120
|
+
this.exitCode = exitCode;
|
|
121
|
+
if (exitCode === 0) {
|
|
122
|
+
this.logger.success(`Installed and configured ${colors.green(this.name)}`);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
this.logger.fatal(`Unable to configure ${colors.green(this.name)}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
__decorate([
|
|
130
|
+
args.string({ description: 'Package name' })
|
|
131
|
+
], Add.prototype, "name", void 0);
|
|
132
|
+
__decorate([
|
|
133
|
+
flags.boolean({ description: 'Display logs in verbose mode' })
|
|
134
|
+
], Add.prototype, "verbose", void 0);
|
|
135
|
+
__decorate([
|
|
136
|
+
flags.string({ description: 'Select the package manager you want to use' })
|
|
137
|
+
], Add.prototype, "packageManager", void 0);
|
|
138
|
+
__decorate([
|
|
139
|
+
flags.boolean({ description: 'Should we install the package as a dev dependency', alias: 'D' })
|
|
140
|
+
], Add.prototype, "dev", void 0);
|
|
141
|
+
__decorate([
|
|
142
|
+
flags.boolean({ description: 'Forcefully overwrite existing files' })
|
|
143
|
+
], Add.prototype, "force", void 0);
|
package/build/commands/build.js
CHANGED
|
@@ -80,6 +80,10 @@ export default class Build extends BaseCommand {
|
|
|
80
80
|
const bundler = new assembler.Bundler(this.app.appRoot, ts, {
|
|
81
81
|
assets: await this.#getAssetsBundlerConfig(),
|
|
82
82
|
metaFiles: this.app.rcFile.metaFiles,
|
|
83
|
+
hooks: {
|
|
84
|
+
onBuildStarting: this.app.rcFile.unstable_assembler?.onBuildStarting,
|
|
85
|
+
onBuildCompleted: this.app.rcFile.unstable_assembler?.onBuildCompleted,
|
|
86
|
+
},
|
|
83
87
|
});
|
|
84
88
|
/**
|
|
85
89
|
* Share command logger with assembler, so that CLI flags like --no-ansi has
|
|
@@ -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":"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":"register","flagName":"register","required":false,"type":"boolean","description":"Auto register the preload file inside the .adonisrc.ts file","showNegatedVariantInHelp":true,"alias":"r"},{"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":"register","flagName":"register","required":false,"type":"boolean","description":"Auto register the provider inside the .adonisrc.ts file","showNegatedVariantInHelp":true,"alias":"r"},{"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
|
+
{"commands":[{"commandName":"add","description":"Install and configure a package","help":"","namespace":null,"aliases":[],"flags":[{"name":"verbose","flagName":"verbose","required":false,"type":"boolean","description":"Display logs in verbose mode"},{"name":"packageManager","flagName":"package-manager","required":false,"type":"string","description":"Select the package manager you want to use"},{"name":"dev","flagName":"dev","required":false,"type":"boolean","description":"Should we install the package as a dev dependency","alias":"D"},{"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":"add.js","absoluteFilePath":"/home/julienr/code/adonis/core/build/commands/add.js"},{"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":"/home/julienr/code/adonis/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":"/home/julienr/code/adonis/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":"/home/julienr/code/adonis/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":"/home/julienr/code/adonis/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":"/home/julienr/code/adonis/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":"/home/julienr/code/adonis/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":"/home/julienr/code/adonis/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 resourceful controller with methods to perform CRUD actions on a resource","alias":"r"},{"name":"api","flagName":"api","required":false,"type":"boolean","description":"Generate resourceful controller without 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":"/home/julienr/code/adonis/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":"/home/julienr/code/adonis/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":"/home/julienr/code/adonis/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":"/home/julienr/code/adonis/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":"/home/julienr/code/adonis/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":"register","flagName":"register","required":false,"type":"boolean","description":"Auto register the preload file inside the .adonisrc.ts file","showNegatedVariantInHelp":true,"alias":"r"},{"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":"/home/julienr/code/adonis/core/build/commands/make/preload.js"},{"commandName":"make:provider","description":"Create a new service provider class","help":"","namespace":"make","aliases":[],"flags":[{"name":"register","flagName":"register","required":false,"type":"boolean","description":"Auto register the provider inside the .adonisrc.ts file","showNegatedVariantInHelp":true,"alias":"r"},{"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":"/home/julienr/code/adonis/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":"/home/julienr/code/adonis/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":"/home/julienr/code/adonis/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":"/home/julienr/code/adonis/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":"/home/julienr/code/adonis/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":"/home/julienr/code/adonis/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":"/home/julienr/code/adonis/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":"/home/julienr/code/adonis/core/build/commands/test.js"}],"version":1}
|
|
@@ -88,13 +88,13 @@ __decorate([
|
|
|
88
88
|
], MakeController.prototype, "singular", void 0);
|
|
89
89
|
__decorate([
|
|
90
90
|
flags.boolean({
|
|
91
|
-
description: 'Generate controller with methods to perform CRUD actions on a resource',
|
|
91
|
+
description: 'Generate resourceful controller with methods to perform CRUD actions on a resource',
|
|
92
92
|
alias: 'r',
|
|
93
93
|
})
|
|
94
94
|
], MakeController.prototype, "resource", void 0);
|
|
95
95
|
__decorate([
|
|
96
96
|
flags.boolean({
|
|
97
|
-
description: 'Generate resourceful controller
|
|
97
|
+
description: 'Generate resourceful controller without the "edit" and the "create" methods',
|
|
98
98
|
alias: 'a',
|
|
99
99
|
})
|
|
100
100
|
], MakeController.prototype, "api", void 0);
|
package/build/commands/serve.js
CHANGED
|
@@ -81,6 +81,10 @@ export default class Serve extends BaseCommand {
|
|
|
81
81
|
scriptArgs: [],
|
|
82
82
|
assets: await this.#getAssetsBundlerConfig(),
|
|
83
83
|
metaFiles: this.app.rcFile.metaFiles,
|
|
84
|
+
hooks: {
|
|
85
|
+
onDevServerStarted: this.app.rcFile.unstable_assembler?.onDevServerStarted,
|
|
86
|
+
onSourceFileChanged: this.app.rcFile.unstable_assembler?.onSourceFileChanged,
|
|
87
|
+
},
|
|
84
88
|
});
|
|
85
89
|
/**
|
|
86
90
|
* Share command logger with assembler, so that CLI flags like --no-ansi has
|
|
@@ -25,6 +25,11 @@ export declare class Codemods extends EventEmitter {
|
|
|
25
25
|
* Define one or more environment variables
|
|
26
26
|
*/
|
|
27
27
|
defineEnvVariables(environmentVariables: Record<string, number | string | boolean>): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the TsMorph project instance
|
|
30
|
+
* See https://ts-morph.com/
|
|
31
|
+
*/
|
|
32
|
+
getTsMorphProject(): Promise<InstanceType<typeof import('@adonisjs/assembler/code_transformer').CodeTransformer>['project'] | undefined>;
|
|
28
33
|
/**
|
|
29
34
|
* Define validations for the environment variables
|
|
30
35
|
*/
|
|
@@ -44,7 +49,15 @@ export declare class Codemods extends EventEmitter {
|
|
|
44
49
|
*/
|
|
45
50
|
updateRcFile(...params: Parameters<CodeTransformer['updateRcFile']>): Promise<void>;
|
|
46
51
|
/**
|
|
47
|
-
*
|
|
52
|
+
* Register a new Vite plugin in the `vite.config.ts` file
|
|
53
|
+
*/
|
|
54
|
+
registerVitePlugin(...params: Parameters<CodeTransformer['addVitePlugin']>): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Register a new Japa plugin in the `tests/bootstrap.ts` file
|
|
57
|
+
*/
|
|
58
|
+
registerJapaPlugin(...params: Parameters<CodeTransformer['addJapaPlugin']>): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Generate the stub
|
|
48
61
|
*/
|
|
49
62
|
makeUsingStub(stubsRoot: string, stubPath: string, stubState: Record<string, any>): Promise<{
|
|
50
63
|
relativeFileName: string;
|
|
@@ -56,9 +69,7 @@ export declare class Codemods extends EventEmitter {
|
|
|
56
69
|
} | {
|
|
57
70
|
relativeFileName: string;
|
|
58
71
|
contents: string;
|
|
59
|
-
destination: any;
|
|
60
|
-
* Reference to lazily imported assembler code transformer
|
|
61
|
-
*/
|
|
72
|
+
destination: any;
|
|
62
73
|
attributes: Record<string, any>;
|
|
63
74
|
status: "force_created";
|
|
64
75
|
skipReason: null;
|
|
@@ -15,11 +15,6 @@ import { EnvEditor } from '@adonisjs/env/editor';
|
|
|
15
15
|
* inside user application.
|
|
16
16
|
*/
|
|
17
17
|
export class Codemods extends EventEmitter {
|
|
18
|
-
/**
|
|
19
|
-
* Flag to know if assembler is installed as a
|
|
20
|
-
* peer dependency or not.
|
|
21
|
-
*/
|
|
22
|
-
#isAssemblerInstalled;
|
|
23
18
|
/**
|
|
24
19
|
* Reference to lazily imported assembler code transformer
|
|
25
20
|
*/
|
|
@@ -47,12 +42,19 @@ export class Codemods extends EventEmitter {
|
|
|
47
42
|
this.#cliLogger = cliLogger;
|
|
48
43
|
}
|
|
49
44
|
/**
|
|
50
|
-
* Lazily
|
|
45
|
+
* - Lazily import the code transformer
|
|
46
|
+
* - Return a fresh or reused instance of the code transformer
|
|
51
47
|
*/
|
|
52
|
-
async #
|
|
53
|
-
|
|
54
|
-
this.#codeTransformer
|
|
55
|
-
|
|
48
|
+
async #getCodeTransformer() {
|
|
49
|
+
try {
|
|
50
|
+
if (!this.#codeTransformer) {
|
|
51
|
+
const { CodeTransformer } = await import('@adonisjs/assembler/code_transformer');
|
|
52
|
+
this.#codeTransformer = new CodeTransformer(this.#app.appRoot);
|
|
53
|
+
}
|
|
54
|
+
return this.#codeTransformer;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return null;
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
/**
|
|
@@ -88,16 +90,27 @@ export class Codemods extends EventEmitter {
|
|
|
88
90
|
await editor.save();
|
|
89
91
|
this.#cliLogger.action('update .env file').succeeded();
|
|
90
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Returns the TsMorph project instance
|
|
95
|
+
* See https://ts-morph.com/
|
|
96
|
+
*/
|
|
97
|
+
async getTsMorphProject() {
|
|
98
|
+
const transformer = await this.#getCodeTransformer();
|
|
99
|
+
if (!transformer) {
|
|
100
|
+
this.#cliLogger.warning('Cannot create CodeTransformer. Install "@adonisjs/assembler" to modify source files');
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
return transformer.project;
|
|
104
|
+
}
|
|
91
105
|
/**
|
|
92
106
|
* Define validations for the environment variables
|
|
93
107
|
*/
|
|
94
108
|
async defineEnvValidations(validations) {
|
|
95
|
-
await this.#
|
|
96
|
-
if (!
|
|
109
|
+
const transformer = await this.#getCodeTransformer();
|
|
110
|
+
if (!transformer) {
|
|
97
111
|
this.#cliLogger.warning('Cannot update "start/env.ts" file. Install "@adonisjs/assembler" to modify source files');
|
|
98
112
|
return;
|
|
99
113
|
}
|
|
100
|
-
const transformer = new this.#codeTransformer.CodeTransformer(this.#app.appRoot);
|
|
101
114
|
const action = this.#cliLogger.action('update start/env.ts file');
|
|
102
115
|
try {
|
|
103
116
|
await transformer.defineEnvValidations(validations);
|
|
@@ -112,12 +125,11 @@ export class Codemods extends EventEmitter {
|
|
|
112
125
|
* Define validations for the environment variables
|
|
113
126
|
*/
|
|
114
127
|
async registerMiddleware(stack, middleware) {
|
|
115
|
-
await this.#
|
|
116
|
-
if (!
|
|
128
|
+
const transformer = await this.#getCodeTransformer();
|
|
129
|
+
if (!transformer) {
|
|
117
130
|
this.#cliLogger.warning('Cannot update "start/kernel.ts" file. Install "@adonisjs/assembler" to modify source files');
|
|
118
131
|
return;
|
|
119
132
|
}
|
|
120
|
-
const transformer = new this.#codeTransformer.CodeTransformer(this.#app.appRoot);
|
|
121
133
|
const action = this.#cliLogger.action('update start/kernel.ts file');
|
|
122
134
|
try {
|
|
123
135
|
await transformer.addMiddlewareToStack(stack, middleware);
|
|
@@ -134,12 +146,11 @@ export class Codemods extends EventEmitter {
|
|
|
134
146
|
* file.
|
|
135
147
|
*/
|
|
136
148
|
async registerPolicies(policies) {
|
|
137
|
-
await this.#
|
|
138
|
-
if (!
|
|
149
|
+
const transformer = await this.#getCodeTransformer();
|
|
150
|
+
if (!transformer) {
|
|
139
151
|
this.#cliLogger.warning('Cannot update "app/policies/main.ts" file. Install "@adonisjs/assembler" to modify source files');
|
|
140
152
|
return;
|
|
141
153
|
}
|
|
142
|
-
const transformer = new this.#codeTransformer.CodeTransformer(this.#app.appRoot);
|
|
143
154
|
const action = this.#cliLogger.action('update app/policies/main.ts file');
|
|
144
155
|
try {
|
|
145
156
|
await transformer.addPolicies(policies);
|
|
@@ -154,12 +165,11 @@ export class Codemods extends EventEmitter {
|
|
|
154
165
|
* Update RCFile
|
|
155
166
|
*/
|
|
156
167
|
async updateRcFile(...params) {
|
|
157
|
-
await this.#
|
|
158
|
-
if (!
|
|
168
|
+
const transformer = await this.#getCodeTransformer();
|
|
169
|
+
if (!transformer) {
|
|
159
170
|
this.#cliLogger.warning('Cannot update "adonisrc.ts" file. Install "@adonisjs/assembler" to modify source files');
|
|
160
171
|
return;
|
|
161
172
|
}
|
|
162
|
-
const transformer = new this.#codeTransformer.CodeTransformer(this.#app.appRoot);
|
|
163
173
|
const action = this.#cliLogger.action('update adonisrc.ts file');
|
|
164
174
|
try {
|
|
165
175
|
await transformer.updateRcFile(...params);
|
|
@@ -171,7 +181,45 @@ export class Codemods extends EventEmitter {
|
|
|
171
181
|
}
|
|
172
182
|
}
|
|
173
183
|
/**
|
|
174
|
-
*
|
|
184
|
+
* Register a new Vite plugin in the `vite.config.ts` file
|
|
185
|
+
*/
|
|
186
|
+
async registerVitePlugin(...params) {
|
|
187
|
+
const transformer = await this.#getCodeTransformer();
|
|
188
|
+
if (!transformer) {
|
|
189
|
+
this.#cliLogger.warning('Cannot update "vite.config.ts" file. Install "@adonisjs/assembler" to modify source files');
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const action = this.#cliLogger.action('update vite.config.ts file');
|
|
193
|
+
try {
|
|
194
|
+
await transformer.addVitePlugin(...params);
|
|
195
|
+
action.succeeded();
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
this.emit('error', error);
|
|
199
|
+
action.failed(error.message);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Register a new Japa plugin in the `tests/bootstrap.ts` file
|
|
204
|
+
*/
|
|
205
|
+
async registerJapaPlugin(...params) {
|
|
206
|
+
const transformer = await this.#getCodeTransformer();
|
|
207
|
+
if (!transformer) {
|
|
208
|
+
this.#cliLogger.warning('Cannot update "tests/bootstrap.ts" file. Install "@adonisjs/assembler" to modify source files');
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
const action = this.#cliLogger.action('update tests/bootstrap.ts file');
|
|
212
|
+
try {
|
|
213
|
+
await transformer.addJapaPlugin(...params);
|
|
214
|
+
action.succeeded();
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
this.emit('error', error);
|
|
218
|
+
action.failed(error.message);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Generate the stub
|
|
175
223
|
*/
|
|
176
224
|
async makeUsingStub(stubsRoot, stubPath, stubState) {
|
|
177
225
|
const stubs = await this.#app.stubs.create();
|
|
@@ -196,18 +244,17 @@ export class Codemods extends EventEmitter {
|
|
|
196
244
|
* ```
|
|
197
245
|
*/
|
|
198
246
|
async installPackages(packages) {
|
|
199
|
-
await this.#
|
|
247
|
+
const transformer = await this.#getCodeTransformer();
|
|
200
248
|
const appPath = this.#app.makePath();
|
|
201
249
|
const colors = this.#cliLogger.getColors();
|
|
202
250
|
const devDependencies = packages.filter((pkg) => pkg.isDevDependency).map(({ name }) => name);
|
|
203
251
|
const dependencies = packages.filter((pkg) => !pkg.isDevDependency).map(({ name }) => name);
|
|
204
|
-
if (!
|
|
252
|
+
if (!transformer) {
|
|
205
253
|
this.#cliLogger.warning('Cannot install packages. Install "@adonisjs/assembler" or manually install following packages');
|
|
206
254
|
this.#cliLogger.log(`devDependencies: ${devDependencies.join(',')}`);
|
|
207
255
|
this.#cliLogger.log(`dependencies: ${dependencies.join(',')}`);
|
|
208
256
|
return;
|
|
209
257
|
}
|
|
210
|
-
const transformer = new this.#codeTransformer.CodeTransformer(this.#app.appRoot);
|
|
211
258
|
const packageManager = await transformer.detectPackageManager(appPath);
|
|
212
259
|
const spinner = this.#cliLogger.await(`installing dependencies using ${packageManager || 'npm'} `);
|
|
213
260
|
const silentLogs = !this.verboseInstallOutput;
|
|
@@ -248,10 +295,9 @@ export class Codemods extends EventEmitter {
|
|
|
248
295
|
const devDependencies = packages.filter((pkg) => pkg.isDevDependency).map(({ name }) => name);
|
|
249
296
|
const dependencies = packages.filter((pkg) => !pkg.isDevDependency).map(({ name }) => name);
|
|
250
297
|
let packageManager = null;
|
|
251
|
-
|
|
252
|
-
|
|
298
|
+
const transformer = await this.#getCodeTransformer();
|
|
299
|
+
if (transformer)
|
|
253
300
|
packageManager = await transformer.detectPackageManager(appPath);
|
|
254
|
-
}
|
|
255
301
|
this.#cliLogger.log('Please install following packages');
|
|
256
302
|
this.#cliLogger.log(this.#getInstallationCommands(devDependencies, packageManager || 'npm', true));
|
|
257
303
|
this.#cliLogger.log(this.#getInstallationCommands(dependencies, packageManager || 'npm', false));
|
|
@@ -38,6 +38,9 @@ function generateJsFilenames(filename) {
|
|
|
38
38
|
* used when exists.
|
|
39
39
|
*/
|
|
40
40
|
export async function detectAssetsBundler(app) {
|
|
41
|
+
if (app.rcFile.assetsBundler === false) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
41
44
|
if (app.rcFile.assetsBundler) {
|
|
42
45
|
return app.rcFile.assetsBundler;
|
|
43
46
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/core",
|
|
3
3
|
"description": "Core of AdonisJS",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.3.1",
|
|
5
5
|
"engines": {
|
|
6
|
-
"node": ">=
|
|
6
|
+
"node": ">=20.6.0"
|
|
7
7
|
},
|
|
8
8
|
"main": "build/index.js",
|
|
9
9
|
"type": "module",
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"clean": "del-cli build",
|
|
65
65
|
"copy:templates": "copyfiles \"stubs/**/**/*.stub\" build",
|
|
66
66
|
"precompile": "npm run lint",
|
|
67
|
+
"prepare": "husky",
|
|
67
68
|
"compile": "npm run clean && tsc",
|
|
68
69
|
"postcompile": "npm run copy:templates && npm run index:commands",
|
|
69
70
|
"build": "npm run compile",
|
|
@@ -78,23 +79,23 @@
|
|
|
78
79
|
"index:commands": "node --loader=ts-node/esm toolkit/main.js index build/commands"
|
|
79
80
|
},
|
|
80
81
|
"devDependencies": {
|
|
81
|
-
"@adonisjs/assembler": "^7.
|
|
82
|
-
"@adonisjs/eslint-config": "^1.2.
|
|
83
|
-
"@adonisjs/prettier-config": "^1.2.
|
|
84
|
-
"@adonisjs/tsconfig": "^1.2.
|
|
85
|
-
"@commitlint/cli": "^18.
|
|
86
|
-
"@commitlint/config-conventional": "^18.
|
|
82
|
+
"@adonisjs/assembler": "^7.2.2",
|
|
83
|
+
"@adonisjs/eslint-config": "^1.2.1",
|
|
84
|
+
"@adonisjs/prettier-config": "^1.2.1",
|
|
85
|
+
"@adonisjs/tsconfig": "^1.2.1",
|
|
86
|
+
"@commitlint/cli": "^18.6.1",
|
|
87
|
+
"@commitlint/config-conventional": "^18.6.2",
|
|
87
88
|
"@japa/assert": "^2.1.0",
|
|
88
89
|
"@japa/expect-type": "^2.0.1",
|
|
89
90
|
"@japa/file-system": "^2.2.0",
|
|
90
91
|
"@japa/runner": "^3.1.1",
|
|
91
|
-
"@swc/core": "^1.
|
|
92
|
-
"@types/node": "^20.11.
|
|
92
|
+
"@swc/core": "^1.4.2",
|
|
93
|
+
"@types/node": "^20.11.20",
|
|
93
94
|
"@types/pretty-hrtime": "^1.0.3",
|
|
94
95
|
"@types/sinon": "^17.0.3",
|
|
95
96
|
"@types/supertest": "^6.0.2",
|
|
96
97
|
"@types/test-console": "^2.0.3",
|
|
97
|
-
"@vinejs/vine": "^1.7.
|
|
98
|
+
"@vinejs/vine": "^1.7.1",
|
|
98
99
|
"argon2": "^0.31.1",
|
|
99
100
|
"bcrypt": "^5.1.1",
|
|
100
101
|
"c8": "^9.1.0",
|
|
@@ -102,13 +103,13 @@
|
|
|
102
103
|
"cross-env": "^7.0.3",
|
|
103
104
|
"del-cli": "^5.1.0",
|
|
104
105
|
"edge.js": "^6.0.1",
|
|
105
|
-
"eslint": "^8.
|
|
106
|
+
"eslint": "^8.57.0",
|
|
106
107
|
"execa": "^8.0.1",
|
|
107
108
|
"get-port": "^7.0.0",
|
|
108
109
|
"github-label-sync": "^2.3.1",
|
|
109
|
-
"husky": "^
|
|
110
|
+
"husky": "^9.0.11",
|
|
110
111
|
"np": "^9.2.0",
|
|
111
|
-
"prettier": "^3.2.
|
|
112
|
+
"prettier": "^3.2.5",
|
|
112
113
|
"sinon": "^17.0.1",
|
|
113
114
|
"supertest": "^6.3.4",
|
|
114
115
|
"test-console": "^2.0.0",
|
|
@@ -117,7 +118,7 @@
|
|
|
117
118
|
},
|
|
118
119
|
"dependencies": {
|
|
119
120
|
"@adonisjs/ace": "^13.0.0",
|
|
120
|
-
"@adonisjs/application": "^8.0
|
|
121
|
+
"@adonisjs/application": "^8.1.0",
|
|
121
122
|
"@adonisjs/bodyparser": "^10.0.1",
|
|
122
123
|
"@adonisjs/config": "^5.0.1",
|
|
123
124
|
"@adonisjs/encryption": "^6.0.1",
|
|
@@ -125,19 +126,20 @@
|
|
|
125
126
|
"@adonisjs/events": "^9.0.1",
|
|
126
127
|
"@adonisjs/fold": "^10.0.1",
|
|
127
128
|
"@adonisjs/hash": "^9.0.1",
|
|
128
|
-
"@adonisjs/http-server": "^7.0
|
|
129
|
-
"@adonisjs/logger": "^6.0.
|
|
129
|
+
"@adonisjs/http-server": "^7.1.0",
|
|
130
|
+
"@adonisjs/logger": "^6.0.2",
|
|
130
131
|
"@adonisjs/repl": "^4.0.1",
|
|
132
|
+
"@antfu/install-pkg": "^0.3.1",
|
|
131
133
|
"@paralleldrive/cuid2": "^2.2.2",
|
|
132
134
|
"@poppinss/macroable": "^1.0.1",
|
|
133
|
-
"@poppinss/utils": "^6.7.
|
|
134
|
-
"@sindresorhus/is": "^6.0
|
|
135
|
+
"@poppinss/utils": "^6.7.2",
|
|
136
|
+
"@sindresorhus/is": "^6.1.0",
|
|
135
137
|
"@types/he": "^1.2.3",
|
|
136
138
|
"he": "^1.2.0",
|
|
137
139
|
"parse-imports": "^1.1.2",
|
|
138
140
|
"pretty-hrtime": "^1.0.3",
|
|
139
141
|
"string-width": "^7.1.0",
|
|
140
|
-
"youch": "^3.3.
|
|
142
|
+
"youch": "^3.3.3",
|
|
141
143
|
"youch-terminal": "^2.2.3"
|
|
142
144
|
},
|
|
143
145
|
"peerDependencies": {
|