@adonisjs/core 6.1.1-0 → 6.1.3-0

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.
@@ -0,0 +1,10 @@
1
+ import { BaseCommand } from '../modules/ace/main.js';
2
+ export default class Build extends BaseCommand {
3
+ #private;
4
+ static commandName: string;
5
+ static description: string;
6
+ watch?: boolean;
7
+ ignoreTsErrors?: boolean;
8
+ packageManager?: 'npm' | 'pnpm' | 'yarn';
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,72 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { BaseCommand, flags } from '../modules/ace/main.js';
11
+ export default class Build extends BaseCommand {
12
+ static commandName = 'build';
13
+ static description = 'Build application for production by compiling frontend assets and TypeScript source to JavaScript';
14
+ async #importAssembler() {
15
+ try {
16
+ return await this.app.import('@adonisjs/assembler');
17
+ }
18
+ catch {
19
+ this.logger.error([
20
+ 'Unable to import "@adonisjs/assembler"',
21
+ '',
22
+ 'The "@adonisjs/assembler" package is a development dependency and therefore you should use the build command during development only.',
23
+ '',
24
+ 'If you are using the build command inside a CI or with a deployment platform, make sure the NODE_ENV is set to "development"',
25
+ ].join('\n'));
26
+ this.exitCode = 1;
27
+ }
28
+ }
29
+ async #importTypeScript() {
30
+ try {
31
+ return await this.app.import('typescript');
32
+ }
33
+ catch {
34
+ this.logger.error([
35
+ 'Unable to import "typescript"',
36
+ '',
37
+ 'The "typescript" package is a development dependency and therefore you should use the build command during development only.',
38
+ '',
39
+ 'If you are using the build command inside a CI or with a deployment platform, make sure the NODE_ENV is set to "development"',
40
+ ].join('\n'));
41
+ this.exitCode = 1;
42
+ }
43
+ }
44
+ async run() {
45
+ const assembler = await this.#importAssembler();
46
+ const ts = await this.#importTypeScript();
47
+ if (!assembler || !ts) {
48
+ return;
49
+ }
50
+ const bundler = new assembler.Bundler(this.app.appRoot, ts.default, {});
51
+ bundler.setLogger(this.logger);
52
+ const stopOnError = this.ignoreTsErrors === true ? false : true;
53
+ const builtSuccessfully = await bundler.bundle(stopOnError, this.packageManager);
54
+ if (!builtSuccessfully) {
55
+ this.exitCode = 1;
56
+ }
57
+ }
58
+ }
59
+ __decorate([
60
+ flags.boolean({ description: 'Watch filesystem and restart the HTTP server on file change' }),
61
+ __metadata("design:type", Boolean)
62
+ ], Build.prototype, "watch", void 0);
63
+ __decorate([
64
+ flags.boolean({ description: 'Ignore TypeScript errors and continue with the build process' }),
65
+ __metadata("design:type", Boolean)
66
+ ], Build.prototype, "ignoreTsErrors", void 0);
67
+ __decorate([
68
+ flags.string({
69
+ description: 'Select the package manager you want to use to install production dependencies',
70
+ }),
71
+ __metadata("design:type", String)
72
+ ], Build.prototype, "packageManager", void 0);
@@ -1 +1 @@
1
- {"commands":[{"commandName":"configure","description":"Configure a package post installation","help":"","namespace":null,"aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Package name","type":"string"}],"options":{},"filePath":"configure.js"},{"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"},{"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"},{"commandName":"make:command","description":"Create a new ace command class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the command","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/command.js"},{"commandName":"make:controller","description":"Create a new HTTP controller class","help":"","namespace":"make","aliases":[],"flags":[{"name":"singular","flagName":"singular","required":false,"type":"boolean","description":"Convert controller class and file name to its singular form","alias":"r"},{"name":"resource","flagName":"resource","required":false,"type":"boolean","description":"Generate controller with resource actions","alias":"r"},{"name":"api","flagName":"api","required":false,"type":"boolean","description":"Generate controller with api resource actions","alias":"a"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"The name of the controller","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/controller.js"},{"commandName":"make:event","description":"Create a new event class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the event","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/event.js"},{"commandName":"make:listener","description":"Create a new event listener class","help":"","namespace":"make","aliases":[],"flags":[{"name":"event","flagName":"event","required":false,"type":"string","description":"Generate an event class alongside the listener","alias":"e"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the listener","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/listener.js"},{"commandName":"make:middleware","description":"Create a new middleware class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the middleware","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/middleware.js"},{"commandName":"make:provider","description":"Create a new service provider class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the provider","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/provider.js"}],"version":1}
1
+ {"commands":[{"commandName":"build","description":"Build application for production by compiling frontend assets and TypeScript source to JavaScript","help":"","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"}],"args":[],"options":{},"filePath":"build.js"},{"commandName":"configure","description":"Configure a package post installation","help":"","namespace":null,"aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Package name","type":"string"}],"options":{},"filePath":"configure.js"},{"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"},{"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"},{"commandName":"make:command","description":"Create a new ace command class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the command","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/command.js"},{"commandName":"make:controller","description":"Create a new HTTP controller class","help":"","namespace":"make","aliases":[],"flags":[{"name":"singular","flagName":"singular","required":false,"type":"boolean","description":"Convert controller class and file name to its singular form","alias":"r"},{"name":"resource","flagName":"resource","required":false,"type":"boolean","description":"Generate controller with resource actions","alias":"r"},{"name":"api","flagName":"api","required":false,"type":"boolean","description":"Generate controller with api resource actions","alias":"a"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"The name of the controller","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/controller.js"},{"commandName":"make:event","description":"Create a new event class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the event","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/event.js"},{"commandName":"make:listener","description":"Create a new event listener class","help":"","namespace":"make","aliases":[],"flags":[{"name":"event","flagName":"event","required":false,"type":"string","description":"Generate an event class alongside the listener","alias":"e"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the listener","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/listener.js"},{"commandName":"make:middleware","description":"Create a new middleware class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the middleware","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/middleware.js"},{"commandName":"make:provider","description":"Create a new service provider class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the provider","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/provider.js"},{"commandName":"serve","description":"Start the development HTTP server along with the file watcher to perform restarts on file change","help":"","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"}],"args":[],"options":{"staysAlive":true},"filePath":"serve.js"}],"version":1}
@@ -0,0 +1,11 @@
1
+ import { BaseCommand } from '../modules/ace/main.js';
2
+ import { CommandOptions } from '../types/ace.js';
3
+ export default class Serve extends BaseCommand {
4
+ #private;
5
+ static commandName: string;
6
+ static description: string;
7
+ static options: CommandOptions;
8
+ watch?: boolean;
9
+ poll?: boolean;
10
+ run(): Promise<void>;
11
+ }
@@ -0,0 +1,83 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { BaseCommand, flags } from '../modules/ace/main.js';
11
+ export default class Serve extends BaseCommand {
12
+ static commandName = 'serve';
13
+ static description = 'Start the development HTTP server along with the file watcher to perform restarts on file change';
14
+ static options = {
15
+ staysAlive: true,
16
+ };
17
+ async #importAssembler() {
18
+ try {
19
+ return await this.app.import('@adonisjs/assembler');
20
+ }
21
+ catch {
22
+ this.logger.error([
23
+ 'Unable to import "@adonisjs/assembler"',
24
+ '',
25
+ 'The "@adonisjs/assembler" package is a development dependency and therefore you should use the serve command during development only.',
26
+ '',
27
+ 'If you are running your application in production, then use "node bin/server.js" command to start the HTTP server',
28
+ ].join('\n'));
29
+ this.exitCode = 1;
30
+ }
31
+ }
32
+ async #importTypeScript() {
33
+ try {
34
+ return await this.app.import('typescript');
35
+ }
36
+ catch {
37
+ this.logger.error([
38
+ 'Unable to import "typescript"',
39
+ '',
40
+ 'The "typescript" package is a development dependency and therefore you should use the serve command during development only.',
41
+ '',
42
+ 'If you are running your application in production, then use "node bin/server.js" command to start the HTTP server',
43
+ ].join('\n'));
44
+ this.exitCode = 1;
45
+ }
46
+ }
47
+ async run() {
48
+ const assembler = await this.#importAssembler();
49
+ if (!assembler) {
50
+ return;
51
+ }
52
+ const devServer = new assembler.DevServer(this.app.appRoot, {
53
+ nodeArgs: this.parsed.nodeArgs,
54
+ scriptArgs: [],
55
+ metaFiles: this.app.rcFile.metaFiles,
56
+ });
57
+ devServer.setLogger(this.logger);
58
+ devServer.onClose((exitCode) => {
59
+ this.exitCode = exitCode;
60
+ });
61
+ devServer.onError(() => {
62
+ this.exitCode = 1;
63
+ });
64
+ if (this.watch) {
65
+ const ts = await this.#importTypeScript();
66
+ if (!ts) {
67
+ return;
68
+ }
69
+ await devServer.startAndWatch(ts.default, { poll: this.poll || false });
70
+ }
71
+ else {
72
+ await devServer.start();
73
+ }
74
+ }
75
+ }
76
+ __decorate([
77
+ flags.boolean({ description: 'Watch filesystem and restart the HTTP server on file change' }),
78
+ __metadata("design:type", Boolean)
79
+ ], Serve.prototype, "watch", void 0);
80
+ __decorate([
81
+ flags.boolean({ description: 'Use polling to detect filesystem changes' }),
82
+ __metadata("design:type", Boolean)
83
+ ], Serve.prototype, "poll", void 0);
@@ -0,0 +1,4 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ export declare function aceShell(cwd: URL): {
3
+ handle(argv: string[]): Promise<void>;
4
+ };
@@ -0,0 +1,29 @@
1
+ const DEFAULT_NODE_ARGS = [
2
+ '--loader=ts-node/esm',
3
+ '--no-warnings',
4
+ '--experimental-import-meta-resolve',
5
+ ];
6
+ export function aceShell(cwd) {
7
+ return {
8
+ async handle(argv) {
9
+ const { execaNode } = await import('execa');
10
+ const childProcess = execaNode('bin/console.js', argv, {
11
+ nodeOptions: DEFAULT_NODE_ARGS,
12
+ preferLocal: true,
13
+ windowsHide: false,
14
+ localDir: cwd,
15
+ cwd,
16
+ buffer: false,
17
+ stdio: 'inherit',
18
+ });
19
+ try {
20
+ const result = await childProcess;
21
+ process.exitCode = result.exitCode;
22
+ }
23
+ catch (error) {
24
+ console.error(error);
25
+ process.exitCode = 1;
26
+ }
27
+ },
28
+ };
29
+ }
@@ -5,7 +5,7 @@
5
5
  to: {{ app.commandsPath(entity.path, commandFileName) }}
6
6
  ---
7
7
  import { BaseCommand } from '@adonisjs/core/ace'
8
- import { CommandOptions } from '@adonisjs/core/types'
8
+ import { CommandOptions } from '@adonisjs/core/types/ace'
9
9
 
10
10
  export default class {{ commandName }} extends BaseCommand {
11
11
  static commandName = '{{ commandTerminalName }}'
@@ -14,6 +14,6 @@ export default class {{ commandName }} extends BaseCommand {
14
14
  static options: CommandOptions = {}
15
15
 
16
16
  async run() {
17
- this.info('Hello world from "{{ commandName }}"')
17
+ this.logger.info('Hello world from "{{ commandName }}"')
18
18
  }
19
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adonisjs/core",
3
- "version": "6.1.1-0",
3
+ "version": "6.1.3-0",
4
4
  "description": "Core of AdonisJS",
5
5
  "main": "build/index.js",
6
6
  "type": "module",
@@ -48,6 +48,7 @@
48
48
  "./services/logger": "./build/services/logger.js",
49
49
  "./services/router": "./build/services/router.js",
50
50
  "./services/server": "./build/services/server.js",
51
+ "./services/test_utils": "./build/services/test_utils.js",
51
52
  "./providers/app_provider": "./build/providers/app_provider.js",
52
53
  "./providers/hash_provider": "./build/providers/hash_provider.js",
53
54
  "./providers/http_provider": "./build/providers/http_provider.js",
@@ -57,6 +58,7 @@
57
58
  "./helpers/types": "./build/src/helpers/types.js",
58
59
  "./helpers/string": "./build/src/helpers/string.js",
59
60
  "./helpers/string_builder": "./build/src/helpers/string_builder.js",
61
+ "./ace/shell": "./build/modules/ace/shell.js",
60
62
  "./ace": "./build/modules/ace/main.js",
61
63
  "./bodyparser": "./build/modules/bodyparser/main.js",
62
64
  "./bodyparser_middleware": "./build/modules/bodyparser/bodyparser_middleware.js",
@@ -97,6 +99,7 @@
97
99
  "author": "virk,adonisjs",
98
100
  "license": "MIT",
99
101
  "devDependencies": {
102
+ "@adonisjs/assembler": "^6.1.0-0",
100
103
  "@commitlint/cli": "^17.4.4",
101
104
  "@commitlint/config-conventional": "^17.4.4",
102
105
  "@japa/assert": "^1.4.1",
@@ -106,9 +109,9 @@
106
109
  "@japa/run-failed-tests": "^1.1.1",
107
110
  "@japa/runner": "^2.5.0",
108
111
  "@japa/spec-reporter": "^1.3.3",
109
- "@swc/core": "^1.3.35",
112
+ "@swc/core": "^1.3.37",
110
113
  "@types/fs-extra": "^11.0.1",
111
- "@types/node": "^18.14.0",
114
+ "@types/node": "^18.14.2",
112
115
  "@types/pretty-hrtime": "^1.0.1",
113
116
  "@types/sinon": "^10.0.13",
114
117
  "@types/supertest": "^2.0.12",
@@ -117,7 +120,7 @@
117
120
  "copyfiles": "^2.4.1",
118
121
  "cross-env": "^7.0.3",
119
122
  "del-cli": "^5.0.0",
120
- "eslint": "^8.34.0",
123
+ "eslint": "^8.35.0",
121
124
  "eslint-config-prettier": "^8.6.0",
122
125
  "eslint-plugin-adonis": "^3.0.3",
123
126
  "eslint-plugin-prettier": "^4.2.1",
@@ -135,7 +138,7 @@
135
138
  "typescript": "^4.9.5"
136
139
  },
137
140
  "dependencies": {
138
- "@adonisjs/ace": "^12.2.0-0",
141
+ "@adonisjs/ace": "^12.3.0-0",
139
142
  "@adonisjs/application": "^7.1.0-0",
140
143
  "@adonisjs/bodyparser": "^9.3.0-0",
141
144
  "@adonisjs/config": "^4.2.0-0",
@@ -152,12 +155,14 @@
152
155
  "@sindresorhus/is": "^5.3.0",
153
156
  "@types/he": "^1.2.0",
154
157
  "cuid": "^3.0.0",
158
+ "execa": "^7.0.0",
155
159
  "he": "^1.2.0",
156
160
  "pretty-hrtime": "^1.0.3",
157
161
  "youch": "^3.2.3",
158
162
  "youch-terminal": "^2.2.0"
159
163
  },
160
164
  "peerDependencies": {
165
+ "@adonisjs/assembler": "^6.1.0-0",
161
166
  "argon2": "^0.30.3",
162
167
  "bcrypt": "^5.0.1"
163
168
  },
@@ -167,6 +172,9 @@
167
172
  },
168
173
  "bcrypt": {
169
174
  "optional": true
175
+ },
176
+ "@adonisjs/assembler": {
177
+ "optional": true
170
178
  }
171
179
  },
172
180
  "repository": {