@adonisjs/assembler 5.8.1 → 5.9.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.
Files changed (66) hide show
  1. package/build/ace-manifest.json +17 -11
  2. package/build/commands/Build.d.ts +37 -37
  3. package/build/commands/Build.js +138 -138
  4. package/build/commands/Invoke.d.ts +34 -34
  5. package/build/commands/Invoke.js +221 -217
  6. package/build/commands/Make/Base.d.ts +30 -30
  7. package/build/commands/Make/Base.js +75 -75
  8. package/build/commands/Make/Command.d.ts +35 -35
  9. package/build/commands/Make/Command.js +82 -82
  10. package/build/commands/Make/Controller.d.ts +37 -37
  11. package/build/commands/Make/Controller.js +89 -89
  12. package/build/commands/Make/Exception.d.ts +32 -32
  13. package/build/commands/Make/Exception.js +75 -75
  14. package/build/commands/Make/Listener.d.ts +30 -30
  15. package/build/commands/Make/Listener.js +70 -70
  16. package/build/commands/Make/Middleware.d.ts +31 -31
  17. package/build/commands/Make/Middleware.js +87 -87
  18. package/build/commands/Make/PreloadFile.d.ts +38 -38
  19. package/build/commands/Make/PreloadFile.js +157 -157
  20. package/build/commands/Make/Provider.d.ts +31 -31
  21. package/build/commands/Make/Provider.js +114 -114
  22. package/build/commands/Make/Suite.d.ts +41 -41
  23. package/build/commands/Make/Suite.js +120 -120
  24. package/build/commands/Make/Test.d.ts +35 -35
  25. package/build/commands/Make/Test.js +96 -96
  26. package/build/commands/Make/Validator.d.ts +31 -31
  27. package/build/commands/Make/Validator.js +71 -71
  28. package/build/commands/Make/View.d.ts +30 -30
  29. package/build/commands/Make/View.js +70 -70
  30. package/build/commands/Serve.d.ts +33 -33
  31. package/build/commands/Serve.js +112 -112
  32. package/build/commands/Test.d.ts +57 -53
  33. package/build/commands/Test.js +159 -152
  34. package/build/commands/TypeCheck.d.ts +16 -16
  35. package/build/commands/TypeCheck.js +85 -85
  36. package/build/config/paths.d.ts +7 -7
  37. package/build/config/paths.js +18 -18
  38. package/build/register.d.ts +1 -1
  39. package/build/register.js +15 -15
  40. package/build/src/AssetsBundler/index.d.ts +76 -76
  41. package/build/src/AssetsBundler/index.js +216 -216
  42. package/build/src/Compiler/index.d.ts +62 -62
  43. package/build/src/Compiler/index.js +287 -287
  44. package/build/src/Contracts/index.d.ts +8 -8
  45. package/build/src/Contracts/index.js +10 -10
  46. package/build/src/DevServer/index.d.ts +70 -70
  47. package/build/src/DevServer/index.js +306 -306
  48. package/build/src/EnvParser/index.d.ts +23 -23
  49. package/build/src/EnvParser/index.js +52 -52
  50. package/build/src/HttpServer/index.d.ts +34 -34
  51. package/build/src/HttpServer/index.js +87 -87
  52. package/build/src/Manifest/index.d.ts +32 -32
  53. package/build/src/Manifest/index.js +88 -88
  54. package/build/src/RcFile/index.d.ts +72 -72
  55. package/build/src/RcFile/index.js +174 -174
  56. package/build/src/Test/index.d.ts +75 -75
  57. package/build/src/Test/index.js +346 -346
  58. package/build/src/Test/process.d.ts +22 -22
  59. package/build/src/Test/process.js +68 -68
  60. package/build/src/Ts/index.d.ts +24 -24
  61. package/build/src/Ts/index.js +55 -55
  62. package/build/src/requireHook/index.d.ts +5 -5
  63. package/build/src/requireHook/index.js +28 -28
  64. package/build/src/requireHook/ioc-transformer.d.ts +6 -6
  65. package/build/src/requireHook/ioc-transformer.js +21 -21
  66. package/package.json +16 -16
@@ -1,76 +1,76 @@
1
- import Emittery from 'emittery';
2
- import { logger as uiLogger } from '@poppinss/cliui';
3
- export declare type DevServerResponse = {
4
- state: 'not-installed' | 'no-assets';
5
- } | {
6
- state: 'running';
7
- port: string;
8
- host: string;
9
- };
10
- /**
11
- * Assets bundler uses webpack encore to build frontend dependencies
12
- */
13
- export declare class AssetsBundler extends Emittery {
14
- private projectRoot;
15
- private buildAssets;
16
- private logger;
17
- private env;
18
- /**
19
- * Binary to execute
20
- */
21
- private binaryName;
22
- private encoreArgs;
23
- /**
24
- * Options passed to spawn a child process
25
- */
26
- private execaOptions;
27
- constructor(projectRoot: string, encoreArgs: string[] | undefined, buildAssets: boolean, logger: typeof uiLogger, env?: {
28
- [key: string]: string;
29
- });
30
- /**
31
- * Find if encore is installed
32
- */
33
- private isEncoreInstalled;
34
- /**
35
- * Notify user that we are about use encore
36
- */
37
- private notifyAboutEncore;
38
- /**
39
- * Logs the line to stdout
40
- */
41
- private log;
42
- /**
43
- * Logs the line to stderr
44
- */
45
- private logError;
46
- /**
47
- * Returns the custom port defined using the `--port` flag in encore
48
- * flags
49
- */
50
- private findCustomPort;
51
- /**
52
- * Returns the custom host defined using the `--host` flag in encore
53
- * flags
54
- */
55
- private findCustomHost;
56
- /**
57
- * Execute command
58
- */
59
- private exec;
60
- /**
61
- * Build assets using encore
62
- */
63
- build(): Promise<{
64
- hasErrors: boolean;
65
- }>;
66
- /**
67
- * Build assets for production
68
- */
69
- buildForProduction(): Promise<{
70
- hasErrors: boolean;
71
- }>;
72
- /**
73
- * Start the webpack dev server
74
- */
75
- startDevServer(): Promise<DevServerResponse>;
76
- }
1
+ import Emittery from 'emittery';
2
+ import { logger as uiLogger } from '@poppinss/cliui';
3
+ export declare type DevServerResponse = {
4
+ state: 'not-installed' | 'no-assets';
5
+ } | {
6
+ state: 'running';
7
+ port: string;
8
+ host: string;
9
+ };
10
+ /**
11
+ * Assets bundler uses webpack encore to build frontend dependencies
12
+ */
13
+ export declare class AssetsBundler extends Emittery {
14
+ private projectRoot;
15
+ private buildAssets;
16
+ private logger;
17
+ private env;
18
+ /**
19
+ * Binary to execute
20
+ */
21
+ private binaryName;
22
+ private encoreArgs;
23
+ /**
24
+ * Options passed to spawn a child process
25
+ */
26
+ private execaOptions;
27
+ constructor(projectRoot: string, encoreArgs: string[] | undefined, buildAssets: boolean, logger: typeof uiLogger, env?: {
28
+ [key: string]: string;
29
+ });
30
+ /**
31
+ * Find if encore is installed
32
+ */
33
+ private isEncoreInstalled;
34
+ /**
35
+ * Notify user that we are about use encore
36
+ */
37
+ private notifyAboutEncore;
38
+ /**
39
+ * Logs the line to stdout
40
+ */
41
+ private log;
42
+ /**
43
+ * Logs the line to stderr
44
+ */
45
+ private logError;
46
+ /**
47
+ * Returns the custom port defined using the `--port` flag in encore
48
+ * flags
49
+ */
50
+ private findCustomPort;
51
+ /**
52
+ * Returns the custom host defined using the `--host` flag in encore
53
+ * flags
54
+ */
55
+ private findCustomHost;
56
+ /**
57
+ * Execute command
58
+ */
59
+ private exec;
60
+ /**
61
+ * Build assets using encore
62
+ */
63
+ build(): Promise<{
64
+ hasErrors: boolean;
65
+ }>;
66
+ /**
67
+ * Build assets for production
68
+ */
69
+ buildForProduction(): Promise<{
70
+ hasErrors: boolean;
71
+ }>;
72
+ /**
73
+ * Start the webpack dev server
74
+ */
75
+ startDevServer(): Promise<DevServerResponse>;
76
+ }
@@ -1,216 +1,216 @@
1
- "use strict";
2
- /*
3
- * @adonisjs/assembler
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- var __importDefault = (this && this.__importDefault) || function (mod) {
11
- return (mod && mod.__esModule) ? mod : { "default": mod };
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.AssetsBundler = void 0;
15
- const execa_1 = __importDefault(require("execa"));
16
- const get_port_1 = __importDefault(require("get-port"));
17
- const emittery_1 = __importDefault(require("emittery"));
18
- const helpers_1 = require("@poppinss/utils/build/helpers");
19
- /**
20
- * Assets bundler uses webpack encore to build frontend dependencies
21
- */
22
- class AssetsBundler extends emittery_1.default {
23
- constructor(projectRoot, encoreArgs = [], buildAssets = true, logger, env = {}) {
24
- super();
25
- this.projectRoot = projectRoot;
26
- this.buildAssets = buildAssets;
27
- this.logger = logger;
28
- this.env = env;
29
- /**
30
- * Binary to execute
31
- */
32
- this.binaryName = 'encore';
33
- this.encoreArgs = [];
34
- /**
35
- * Options passed to spawn a child process
36
- */
37
- this.execaOptions = {
38
- preferLocal: true,
39
- buffer: false,
40
- stdio: 'pipe',
41
- localDir: this.projectRoot,
42
- cwd: this.projectRoot,
43
- windowsHide: false,
44
- env: {
45
- FORCE_COLOR: 'true',
46
- ...this.env,
47
- },
48
- };
49
- this.encoreArgs = encoreArgs.reduce((result, arg) => {
50
- result = result.concat(arg.split(' '));
51
- return result;
52
- }, []);
53
- }
54
- /**
55
- * Find if encore is installed
56
- */
57
- isEncoreInstalled() {
58
- try {
59
- (0, helpers_1.resolveDir)(this.projectRoot, '@symfony/webpack-encore');
60
- return true;
61
- }
62
- catch {
63
- return false;
64
- }
65
- }
66
- /**
67
- * Notify user that we are about use encore
68
- */
69
- notifyAboutEncore() {
70
- this.logger.info(`detected { ${this.logger.colors.dim().yellow('@symfony/webpack-encore')} }`);
71
- this.logger.info(`building frontend assets. Use { ${this.logger.colors
72
- .dim()
73
- .yellow('--no-assets')} } to disable`);
74
- }
75
- /**
76
- * Logs the line to stdout
77
- */
78
- log(line) {
79
- line = line.toString().trim();
80
- if (!line.length) {
81
- return;
82
- }
83
- console.log(`[ ${this.logger.colors.cyan('encore')} ] ${line}`);
84
- }
85
- /**
86
- * Logs the line to stderr
87
- */
88
- logError(line) {
89
- line = line.toString().trim();
90
- if (!line.length) {
91
- return;
92
- }
93
- console.error(`[ ${this.logger.colors.cyan('encore')} ] ${line}`);
94
- }
95
- /**
96
- * Returns the custom port defined using the `--port` flag in encore
97
- * flags
98
- */
99
- findCustomPort() {
100
- let portIndex = this.encoreArgs.findIndex((arg) => arg === '--port');
101
- if (portIndex > -1) {
102
- return this.encoreArgs[portIndex + 1];
103
- }
104
- portIndex = this.encoreArgs.findIndex((arg) => arg.includes('--port'));
105
- if (portIndex > -1) {
106
- const tokens = this.encoreArgs[portIndex].split('=');
107
- return tokens[1] && tokens[1].trim();
108
- }
109
- }
110
- /**
111
- * Returns the custom host defined using the `--host` flag in encore
112
- * flags
113
- */
114
- findCustomHost() {
115
- let hostIndex = this.encoreArgs.findIndex((arg) => arg === '--host');
116
- if (hostIndex > -1) {
117
- return this.encoreArgs[hostIndex + 1];
118
- }
119
- hostIndex = this.encoreArgs.findIndex((arg) => arg.includes('--host'));
120
- if (hostIndex > -1) {
121
- const tokens = this.encoreArgs[hostIndex].split('=');
122
- return tokens[1] && tokens[1].trim();
123
- }
124
- }
125
- /**
126
- * Execute command
127
- */
128
- exec(args) {
129
- return new Promise((resolve, reject) => {
130
- const childProcess = (0, execa_1.default)(this.binaryName, args, this.execaOptions);
131
- childProcess.stdout?.on('data', (line) => this.log(line));
132
- childProcess.stderr?.on('data', (line) => this.logError(line));
133
- childProcess.on('error', (error) => reject(error));
134
- childProcess.on('close', (code) => {
135
- if (code && code !== 0) {
136
- reject(`Process exited with code ${code}`);
137
- }
138
- else {
139
- resolve();
140
- }
141
- });
142
- });
143
- }
144
- /**
145
- * Build assets using encore
146
- */
147
- async build() {
148
- if (!this.buildAssets) {
149
- return { hasErrors: false };
150
- }
151
- if (!this.isEncoreInstalled()) {
152
- return { hasErrors: false };
153
- }
154
- this.notifyAboutEncore();
155
- try {
156
- await this.exec(['dev'].concat(this.encoreArgs));
157
- return { hasErrors: false };
158
- }
159
- catch (error) {
160
- return { hasErrors: true };
161
- }
162
- }
163
- /**
164
- * Build assets for production
165
- */
166
- async buildForProduction() {
167
- if (!this.buildAssets) {
168
- return { hasErrors: false };
169
- }
170
- if (!this.isEncoreInstalled()) {
171
- return { hasErrors: false };
172
- }
173
- this.notifyAboutEncore();
174
- try {
175
- await this.exec(['production'].concat(this.encoreArgs));
176
- return { hasErrors: false };
177
- }
178
- catch (error) {
179
- return { hasErrors: true };
180
- }
181
- }
182
- /**
183
- * Start the webpack dev server
184
- */
185
- async startDevServer() {
186
- if (!this.isEncoreInstalled()) {
187
- return { state: 'not-installed' };
188
- }
189
- if (!this.buildAssets) {
190
- return { state: 'no-assets' };
191
- }
192
- const customHost = this.findCustomHost() || 'localhost';
193
- /**
194
- * Define a random port when the "--port" flag is not passed.
195
- *
196
- * Encore anyways doesn't allow defining port inside the webpack.config.js
197
- * file for generating the manifest and entrypoints file.
198
- *
199
- * @see
200
- * https://github.com/symfony/webpack-encore/issues/941#issuecomment-787568811
201
- */
202
- let customPort = this.findCustomPort();
203
- if (!customPort) {
204
- const randomPort = await (0, get_port_1.default)({ port: 8080, host: 'localhost' });
205
- customPort = String(randomPort);
206
- this.encoreArgs.push('--port', customPort);
207
- }
208
- const childProcess = (0, execa_1.default)(this.binaryName, ['dev-server'].concat(this.encoreArgs), this.execaOptions);
209
- childProcess.stdout?.on('data', (line) => this.log(line));
210
- childProcess.stderr?.on('data', (line) => this.logError(line));
211
- childProcess.on('close', (code, signal) => this.emit('close', { code, signal }));
212
- childProcess.on('exit', (code, signal) => this.emit('exit', { code, signal }));
213
- return { state: 'running', port: customPort, host: customHost };
214
- }
215
- }
216
- exports.AssetsBundler = AssetsBundler;
1
+ "use strict";
2
+ /*
3
+ * @adonisjs/assembler
4
+ *
5
+ * (c) Harminder Virk <virk@adonisjs.com>
6
+ *
7
+ * For the full copyright and license information, please view the LICENSE
8
+ * file that was distributed with this source code.
9
+ */
10
+ var __importDefault = (this && this.__importDefault) || function (mod) {
11
+ return (mod && mod.__esModule) ? mod : { "default": mod };
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.AssetsBundler = void 0;
15
+ const execa_1 = __importDefault(require("execa"));
16
+ const get_port_1 = __importDefault(require("get-port"));
17
+ const emittery_1 = __importDefault(require("emittery"));
18
+ const helpers_1 = require("@poppinss/utils/build/helpers");
19
+ /**
20
+ * Assets bundler uses webpack encore to build frontend dependencies
21
+ */
22
+ class AssetsBundler extends emittery_1.default {
23
+ constructor(projectRoot, encoreArgs = [], buildAssets = true, logger, env = {}) {
24
+ super();
25
+ this.projectRoot = projectRoot;
26
+ this.buildAssets = buildAssets;
27
+ this.logger = logger;
28
+ this.env = env;
29
+ /**
30
+ * Binary to execute
31
+ */
32
+ this.binaryName = 'encore';
33
+ this.encoreArgs = [];
34
+ /**
35
+ * Options passed to spawn a child process
36
+ */
37
+ this.execaOptions = {
38
+ preferLocal: true,
39
+ buffer: false,
40
+ stdio: 'pipe',
41
+ localDir: this.projectRoot,
42
+ cwd: this.projectRoot,
43
+ windowsHide: false,
44
+ env: {
45
+ FORCE_COLOR: 'true',
46
+ ...this.env,
47
+ },
48
+ };
49
+ this.encoreArgs = encoreArgs.reduce((result, arg) => {
50
+ result = result.concat(arg.split(' '));
51
+ return result;
52
+ }, []);
53
+ }
54
+ /**
55
+ * Find if encore is installed
56
+ */
57
+ isEncoreInstalled() {
58
+ try {
59
+ (0, helpers_1.resolveDir)(this.projectRoot, '@symfony/webpack-encore');
60
+ return true;
61
+ }
62
+ catch {
63
+ return false;
64
+ }
65
+ }
66
+ /**
67
+ * Notify user that we are about use encore
68
+ */
69
+ notifyAboutEncore() {
70
+ this.logger.info(`detected { ${this.logger.colors.dim().yellow('@symfony/webpack-encore')} }`);
71
+ this.logger.info(`building frontend assets. Use { ${this.logger.colors
72
+ .dim()
73
+ .yellow('--no-assets')} } to disable`);
74
+ }
75
+ /**
76
+ * Logs the line to stdout
77
+ */
78
+ log(line) {
79
+ line = line.toString().trim();
80
+ if (!line.length) {
81
+ return;
82
+ }
83
+ console.log(`[ ${this.logger.colors.cyan('encore')} ] ${line}`);
84
+ }
85
+ /**
86
+ * Logs the line to stderr
87
+ */
88
+ logError(line) {
89
+ line = line.toString().trim();
90
+ if (!line.length) {
91
+ return;
92
+ }
93
+ console.error(`[ ${this.logger.colors.cyan('encore')} ] ${line}`);
94
+ }
95
+ /**
96
+ * Returns the custom port defined using the `--port` flag in encore
97
+ * flags
98
+ */
99
+ findCustomPort() {
100
+ let portIndex = this.encoreArgs.findIndex((arg) => arg === '--port');
101
+ if (portIndex > -1) {
102
+ return this.encoreArgs[portIndex + 1];
103
+ }
104
+ portIndex = this.encoreArgs.findIndex((arg) => arg.includes('--port'));
105
+ if (portIndex > -1) {
106
+ const tokens = this.encoreArgs[portIndex].split('=');
107
+ return tokens[1] && tokens[1].trim();
108
+ }
109
+ }
110
+ /**
111
+ * Returns the custom host defined using the `--host` flag in encore
112
+ * flags
113
+ */
114
+ findCustomHost() {
115
+ let hostIndex = this.encoreArgs.findIndex((arg) => arg === '--host');
116
+ if (hostIndex > -1) {
117
+ return this.encoreArgs[hostIndex + 1];
118
+ }
119
+ hostIndex = this.encoreArgs.findIndex((arg) => arg.includes('--host'));
120
+ if (hostIndex > -1) {
121
+ const tokens = this.encoreArgs[hostIndex].split('=');
122
+ return tokens[1] && tokens[1].trim();
123
+ }
124
+ }
125
+ /**
126
+ * Execute command
127
+ */
128
+ exec(args) {
129
+ return new Promise((resolve, reject) => {
130
+ const childProcess = (0, execa_1.default)(this.binaryName, args, this.execaOptions);
131
+ childProcess.stdout?.on('data', (line) => this.log(line));
132
+ childProcess.stderr?.on('data', (line) => this.logError(line));
133
+ childProcess.on('error', (error) => reject(error));
134
+ childProcess.on('close', (code) => {
135
+ if (code && code !== 0) {
136
+ reject(`Process exited with code ${code}`);
137
+ }
138
+ else {
139
+ resolve();
140
+ }
141
+ });
142
+ });
143
+ }
144
+ /**
145
+ * Build assets using encore
146
+ */
147
+ async build() {
148
+ if (!this.buildAssets) {
149
+ return { hasErrors: false };
150
+ }
151
+ if (!this.isEncoreInstalled()) {
152
+ return { hasErrors: false };
153
+ }
154
+ this.notifyAboutEncore();
155
+ try {
156
+ await this.exec(['dev'].concat(this.encoreArgs));
157
+ return { hasErrors: false };
158
+ }
159
+ catch (error) {
160
+ return { hasErrors: true };
161
+ }
162
+ }
163
+ /**
164
+ * Build assets for production
165
+ */
166
+ async buildForProduction() {
167
+ if (!this.buildAssets) {
168
+ return { hasErrors: false };
169
+ }
170
+ if (!this.isEncoreInstalled()) {
171
+ return { hasErrors: false };
172
+ }
173
+ this.notifyAboutEncore();
174
+ try {
175
+ await this.exec(['production'].concat(this.encoreArgs));
176
+ return { hasErrors: false };
177
+ }
178
+ catch (error) {
179
+ return { hasErrors: true };
180
+ }
181
+ }
182
+ /**
183
+ * Start the webpack dev server
184
+ */
185
+ async startDevServer() {
186
+ if (!this.isEncoreInstalled()) {
187
+ return { state: 'not-installed' };
188
+ }
189
+ if (!this.buildAssets) {
190
+ return { state: 'no-assets' };
191
+ }
192
+ const customHost = this.findCustomHost() || 'localhost';
193
+ /**
194
+ * Define a random port when the "--port" flag is not passed.
195
+ *
196
+ * Encore anyways doesn't allow defining port inside the webpack.config.js
197
+ * file for generating the manifest and entrypoints file.
198
+ *
199
+ * @see
200
+ * https://github.com/symfony/webpack-encore/issues/941#issuecomment-787568811
201
+ */
202
+ let customPort = this.findCustomPort();
203
+ if (!customPort) {
204
+ const randomPort = await (0, get_port_1.default)({ port: 8080, host: 'localhost' });
205
+ customPort = String(randomPort);
206
+ this.encoreArgs.push('--port', customPort);
207
+ }
208
+ const childProcess = (0, execa_1.default)(this.binaryName, ['dev-server'].concat(this.encoreArgs), this.execaOptions);
209
+ childProcess.stdout?.on('data', (line) => this.log(line));
210
+ childProcess.stderr?.on('data', (line) => this.logError(line));
211
+ childProcess.on('close', (code, signal) => this.emit('close', { code, signal }));
212
+ childProcess.on('exit', (code, signal) => this.emit('exit', { code, signal }));
213
+ return { state: 'running', port: customPort, host: customHost };
214
+ }
215
+ }
216
+ exports.AssetsBundler = AssetsBundler;