@adonisjs/assembler 5.9.2 → 5.9.3

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 (65) hide show
  1. package/build/commands/Build.d.ts +37 -37
  2. package/build/commands/Build.js +138 -138
  3. package/build/commands/Invoke.d.ts +34 -34
  4. package/build/commands/Invoke.js +221 -221
  5. package/build/commands/Make/Base.d.ts +30 -30
  6. package/build/commands/Make/Base.js +75 -75
  7. package/build/commands/Make/Command.d.ts +35 -35
  8. package/build/commands/Make/Command.js +82 -82
  9. package/build/commands/Make/Controller.d.ts +37 -37
  10. package/build/commands/Make/Controller.js +89 -89
  11. package/build/commands/Make/Exception.d.ts +32 -32
  12. package/build/commands/Make/Exception.js +75 -75
  13. package/build/commands/Make/Listener.d.ts +30 -30
  14. package/build/commands/Make/Listener.js +70 -70
  15. package/build/commands/Make/Middleware.d.ts +31 -31
  16. package/build/commands/Make/Middleware.js +87 -87
  17. package/build/commands/Make/PreloadFile.d.ts +38 -38
  18. package/build/commands/Make/PreloadFile.js +157 -157
  19. package/build/commands/Make/Provider.d.ts +31 -31
  20. package/build/commands/Make/Provider.js +114 -114
  21. package/build/commands/Make/Suite.d.ts +41 -41
  22. package/build/commands/Make/Suite.js +120 -120
  23. package/build/commands/Make/Test.d.ts +35 -35
  24. package/build/commands/Make/Test.js +96 -96
  25. package/build/commands/Make/Validator.d.ts +31 -31
  26. package/build/commands/Make/Validator.js +71 -71
  27. package/build/commands/Make/View.d.ts +30 -30
  28. package/build/commands/Make/View.js +70 -70
  29. package/build/commands/Serve.d.ts +33 -33
  30. package/build/commands/Serve.js +112 -112
  31. package/build/commands/Test.d.ts +57 -57
  32. package/build/commands/Test.js +159 -159
  33. package/build/commands/TypeCheck.d.ts +16 -16
  34. package/build/commands/TypeCheck.js +85 -85
  35. package/build/config/paths.d.ts +7 -7
  36. package/build/config/paths.js +18 -18
  37. package/build/register.d.ts +1 -1
  38. package/build/register.js +15 -15
  39. package/build/src/AssetsBundler/index.d.ts +76 -76
  40. package/build/src/AssetsBundler/index.js +216 -216
  41. package/build/src/Compiler/index.d.ts +62 -62
  42. package/build/src/Compiler/index.js +287 -287
  43. package/build/src/Contracts/index.d.ts +8 -8
  44. package/build/src/Contracts/index.js +10 -10
  45. package/build/src/DevServer/index.d.ts +70 -70
  46. package/build/src/DevServer/index.js +306 -306
  47. package/build/src/EnvParser/index.d.ts +21 -23
  48. package/build/src/EnvParser/index.js +48 -52
  49. package/build/src/HttpServer/index.d.ts +34 -34
  50. package/build/src/HttpServer/index.js +87 -87
  51. package/build/src/Manifest/index.d.ts +32 -32
  52. package/build/src/Manifest/index.js +88 -88
  53. package/build/src/RcFile/index.d.ts +72 -72
  54. package/build/src/RcFile/index.js +174 -174
  55. package/build/src/Test/index.d.ts +75 -75
  56. package/build/src/Test/index.js +346 -346
  57. package/build/src/Test/process.d.ts +22 -22
  58. package/build/src/Test/process.js +68 -68
  59. package/build/src/Ts/index.d.ts +24 -24
  60. package/build/src/Ts/index.js +55 -55
  61. package/build/src/requireHook/index.d.ts +5 -5
  62. package/build/src/requireHook/index.js +28 -28
  63. package/build/src/requireHook/ioc-transformer.d.ts +6 -6
  64. package/build/src/requireHook/ioc-transformer.js +21 -21
  65. package/package.json +5 -5
@@ -1,52 +1,48 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.EnvParser = void 0;
12
- const path_1 = require("path");
13
- const fs_extra_1 = require("fs-extra");
14
- const env_1 = require("@adonisjs/env");
15
- /**
16
- * Parses the env file inside the project root.
17
- */
18
- class EnvParser {
19
- constructor(envFileName = '.env') {
20
- this.envFileName = envFileName;
21
- this.envContents = {};
22
- this.parser = new env_1.EnvParser(false);
23
- }
24
- /**
25
- * Parse .env file contents
26
- */
27
- async parse(rootDir) {
28
- try {
29
- this.envContents = this.parser.parse(await (0, fs_extra_1.readFile)((0, path_1.join)(rootDir, this.envFileName), 'utf-8'));
30
- }
31
- catch { }
32
- }
33
- /**
34
- * Returns value for a key inside the `.env` file
35
- */
36
- get(key) {
37
- return this.envContents[key];
38
- }
39
- /**
40
- * Returns an env object for the keys that has defined values
41
- */
42
- asEnvObject(keys) {
43
- return keys.reduce((result, key) => {
44
- const value = this.get(key);
45
- if (value !== undefined) {
46
- result[key] = value;
47
- }
48
- return result;
49
- }, {});
50
- }
51
- }
52
- exports.EnvParser = EnvParser;
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
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.EnvParser = void 0;
12
+ const env_1 = require("@adonisjs/env");
13
+ /**
14
+ * Parses the env file inside the project root.
15
+ */
16
+ class EnvParser {
17
+ constructor() {
18
+ this.envContents = {};
19
+ }
20
+ /**
21
+ * Parse .env file contents
22
+ */
23
+ async parse(rootDir) {
24
+ const { envContents, testEnvContent } = (0, env_1.envLoader)(rootDir);
25
+ const envVars = new env_1.EnvParser(true).parse(envContents);
26
+ const testEnvVars = new env_1.EnvParser(true).parse(testEnvContent);
27
+ this.envContents = { ...envVars, ...testEnvVars };
28
+ }
29
+ /**
30
+ * Returns value for a key inside the `.env` file
31
+ */
32
+ get(key) {
33
+ return this.envContents[key];
34
+ }
35
+ /**
36
+ * Returns an env object for the keys that has defined values
37
+ */
38
+ asEnvObject(keys) {
39
+ return keys.reduce((result, key) => {
40
+ const value = this.get(key);
41
+ if (value !== undefined) {
42
+ result[key] = value;
43
+ }
44
+ return result;
45
+ }, {});
46
+ }
47
+ }
48
+ exports.EnvParser = EnvParser;
@@ -1,34 +1,34 @@
1
- import Emittery from 'emittery';
2
- import { logger as uiLogger } from '@poppinss/cliui';
3
- /**
4
- * Exposes the API to start Node.js HTTP server as a child process. The
5
- * child process is full managed and cleans up when parent process
6
- * dies.
7
- */
8
- export declare class HttpServer extends Emittery {
9
- private sourceFile;
10
- private projectRoot;
11
- private logger;
12
- private env;
13
- private childProcess?;
14
- private nodeArgs;
15
- constructor(sourceFile: string, projectRoot: string, nodeArgs: string[] | undefined, logger: typeof uiLogger, env?: {
16
- [key: string]: string;
17
- });
18
- /**
19
- * Whether or not the underlying process is connected
20
- */
21
- get isConnected(): boolean | undefined;
22
- /**
23
- * Start the HTTP server as a child process.
24
- */
25
- start(): void;
26
- /**
27
- * Stop the underlying process
28
- */
29
- stop(): void;
30
- /**
31
- * Restart the server by killing the old one
32
- */
33
- restart(): void;
34
- }
1
+ import Emittery from 'emittery';
2
+ import { logger as uiLogger } from '@poppinss/cliui';
3
+ /**
4
+ * Exposes the API to start Node.js HTTP server as a child process. The
5
+ * child process is full managed and cleans up when parent process
6
+ * dies.
7
+ */
8
+ export declare class HttpServer extends Emittery {
9
+ private sourceFile;
10
+ private projectRoot;
11
+ private logger;
12
+ private env;
13
+ private childProcess?;
14
+ private nodeArgs;
15
+ constructor(sourceFile: string, projectRoot: string, nodeArgs: string[] | undefined, logger: typeof uiLogger, env?: {
16
+ [key: string]: string;
17
+ });
18
+ /**
19
+ * Whether or not the underlying process is connected
20
+ */
21
+ get isConnected(): boolean | undefined;
22
+ /**
23
+ * Start the HTTP server as a child process.
24
+ */
25
+ start(): void;
26
+ /**
27
+ * Stop the underlying process
28
+ */
29
+ stop(): void;
30
+ /**
31
+ * Restart the server by killing the old one
32
+ */
33
+ restart(): void;
34
+ }
@@ -1,87 +1,87 @@
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.HttpServer = void 0;
15
- const execa_1 = __importDefault(require("execa"));
16
- const emittery_1 = __importDefault(require("emittery"));
17
- /**
18
- * Exposes the API to start Node.js HTTP server as a child process. The
19
- * child process is full managed and cleans up when parent process
20
- * dies.
21
- */
22
- class HttpServer extends emittery_1.default {
23
- constructor(sourceFile, projectRoot, nodeArgs = [], logger, env = {}) {
24
- super();
25
- this.sourceFile = sourceFile;
26
- this.projectRoot = projectRoot;
27
- this.logger = logger;
28
- this.env = env;
29
- this.nodeArgs = [];
30
- this.nodeArgs = nodeArgs.reduce((result, arg) => {
31
- result = result.concat(arg.split(' '));
32
- return result;
33
- }, []);
34
- }
35
- /**
36
- * Whether or not the underlying process is connected
37
- */
38
- get isConnected() {
39
- return this.childProcess && this.childProcess.connected && !this.childProcess.killed;
40
- }
41
- /**
42
- * Start the HTTP server as a child process.
43
- */
44
- start() {
45
- if (this.isConnected) {
46
- throw new Error('Http server is already connected. Call restart instead');
47
- }
48
- this.logger.info(this.childProcess ? 're-starting http server...' : 'starting http server...');
49
- this.childProcess = execa_1.default.node(this.sourceFile, [], {
50
- buffer: false,
51
- stdio: 'inherit',
52
- cwd: this.projectRoot,
53
- env: {
54
- FORCE_COLOR: 'true',
55
- ...this.env,
56
- },
57
- nodeOptions: ['-r', '@adonisjs/assembler/build/register'].concat(this.nodeArgs),
58
- });
59
- /**
60
- * Notify about server events
61
- */
62
- this.childProcess.on('message', (message) => {
63
- if (message && message['isAdonisJS'] && message['environment'] === 'web') {
64
- this.emit('ready', message);
65
- }
66
- });
67
- this.childProcess.on('close', (code, signal) => this.emit('close', { code, signal }));
68
- this.childProcess.on('exit', (code, signal) => this.emit('exit', { code, signal }));
69
- }
70
- /**
71
- * Stop the underlying process
72
- */
73
- stop() {
74
- if (this.childProcess) {
75
- this.childProcess.removeAllListeners();
76
- this.childProcess.kill('SIGKILL');
77
- }
78
- }
79
- /**
80
- * Restart the server by killing the old one
81
- */
82
- restart() {
83
- this.stop();
84
- this.start();
85
- }
86
- }
87
- exports.HttpServer = HttpServer;
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.HttpServer = void 0;
15
+ const execa_1 = __importDefault(require("execa"));
16
+ const emittery_1 = __importDefault(require("emittery"));
17
+ /**
18
+ * Exposes the API to start Node.js HTTP server as a child process. The
19
+ * child process is full managed and cleans up when parent process
20
+ * dies.
21
+ */
22
+ class HttpServer extends emittery_1.default {
23
+ constructor(sourceFile, projectRoot, nodeArgs = [], logger, env = {}) {
24
+ super();
25
+ this.sourceFile = sourceFile;
26
+ this.projectRoot = projectRoot;
27
+ this.logger = logger;
28
+ this.env = env;
29
+ this.nodeArgs = [];
30
+ this.nodeArgs = nodeArgs.reduce((result, arg) => {
31
+ result = result.concat(arg.split(' '));
32
+ return result;
33
+ }, []);
34
+ }
35
+ /**
36
+ * Whether or not the underlying process is connected
37
+ */
38
+ get isConnected() {
39
+ return this.childProcess && this.childProcess.connected && !this.childProcess.killed;
40
+ }
41
+ /**
42
+ * Start the HTTP server as a child process.
43
+ */
44
+ start() {
45
+ if (this.isConnected) {
46
+ throw new Error('Http server is already connected. Call restart instead');
47
+ }
48
+ this.logger.info(this.childProcess ? 're-starting http server...' : 'starting http server...');
49
+ this.childProcess = execa_1.default.node(this.sourceFile, [], {
50
+ buffer: false,
51
+ stdio: 'inherit',
52
+ cwd: this.projectRoot,
53
+ env: {
54
+ FORCE_COLOR: 'true',
55
+ ...this.env,
56
+ },
57
+ nodeOptions: ['-r', '@adonisjs/assembler/build/register'].concat(this.nodeArgs),
58
+ });
59
+ /**
60
+ * Notify about server events
61
+ */
62
+ this.childProcess.on('message', (message) => {
63
+ if (message && message['isAdonisJS'] && message['environment'] === 'web') {
64
+ this.emit('ready', message);
65
+ }
66
+ });
67
+ this.childProcess.on('close', (code, signal) => this.emit('close', { code, signal }));
68
+ this.childProcess.on('exit', (code, signal) => this.emit('exit', { code, signal }));
69
+ }
70
+ /**
71
+ * Stop the underlying process
72
+ */
73
+ stop() {
74
+ if (this.childProcess) {
75
+ this.childProcess.removeAllListeners();
76
+ this.childProcess.kill('SIGKILL');
77
+ }
78
+ }
79
+ /**
80
+ * Restart the server by killing the old one
81
+ */
82
+ restart() {
83
+ this.stop();
84
+ this.start();
85
+ }
86
+ }
87
+ exports.HttpServer = HttpServer;
@@ -1,32 +1,32 @@
1
- import { logger as uiLogger } from '@poppinss/cliui';
2
- /**
3
- * Exposes the API to execute generate manifest file
4
- */
5
- export declare class Manifest {
6
- private appRoot;
7
- private logger;
8
- /**
9
- * The maximum number of times we should attempt to generate
10
- * the manifest file before giving up.
11
- *
12
- * This number may sound too big, but in real world scanerio, we
13
- * have seen encountered malformed JSON between 10-12 times.
14
- *
15
- * The JSON gets malformed, when a parallel process (node ace serve --watch)
16
- * is trying to update it.
17
- */
18
- private maxAttempts;
19
- private attempts;
20
- constructor(appRoot: string, logger: typeof uiLogger);
21
- /**
22
- * Returns a boolean telling if the error message is pointing
23
- * towards invalid or empty JSON file read attempt.
24
- */
25
- private isMalformedJSONError;
26
- /**
27
- * Generates the manifest file. We ignore `generate:manifest` errors for
28
- * now, since it's a secondary task for us and one should run it
29
- * in seperate process to find the actual errors.
30
- */
31
- generate(): Promise<boolean>;
32
- }
1
+ import { logger as uiLogger } from '@poppinss/cliui';
2
+ /**
3
+ * Exposes the API to execute generate manifest file
4
+ */
5
+ export declare class Manifest {
6
+ private appRoot;
7
+ private logger;
8
+ /**
9
+ * The maximum number of times we should attempt to generate
10
+ * the manifest file before giving up.
11
+ *
12
+ * This number may sound too big, but in real world scanerio, we
13
+ * have seen encountered malformed JSON between 10-12 times.
14
+ *
15
+ * The JSON gets malformed, when a parallel process (node ace serve --watch)
16
+ * is trying to update it.
17
+ */
18
+ private maxAttempts;
19
+ private attempts;
20
+ constructor(appRoot: string, logger: typeof uiLogger);
21
+ /**
22
+ * Returns a boolean telling if the error message is pointing
23
+ * towards invalid or empty JSON file read attempt.
24
+ */
25
+ private isMalformedJSONError;
26
+ /**
27
+ * Generates the manifest file. We ignore `generate:manifest` errors for
28
+ * now, since it's a secondary task for us and one should run it
29
+ * in seperate process to find the actual errors.
30
+ */
31
+ generate(): Promise<boolean>;
32
+ }
@@ -1,88 +1,88 @@
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.Manifest = void 0;
15
- const execa_1 = __importDefault(require("execa"));
16
- const WARN_MESSAGE = [
17
- 'Unable to generate manifest file.',
18
- 'Check the following error for more info',
19
- ].join(' ');
20
- /**
21
- * Exposes the API to execute generate manifest file
22
- */
23
- class Manifest {
24
- constructor(appRoot, logger) {
25
- this.appRoot = appRoot;
26
- this.logger = logger;
27
- /**
28
- * The maximum number of times we should attempt to generate
29
- * the manifest file before giving up.
30
- *
31
- * This number may sound too big, but in real world scanerio, we
32
- * have seen encountered malformed JSON between 10-12 times.
33
- *
34
- * The JSON gets malformed, when a parallel process (node ace serve --watch)
35
- * is trying to update it.
36
- */
37
- this.maxAttempts = 15;
38
- this.attempts = 0;
39
- }
40
- /**
41
- * Returns a boolean telling if the error message is pointing
42
- * towards invalid or empty JSON file read attempt.
43
- */
44
- isMalformedJSONError(error) {
45
- return error.includes('Unexpected end of JSON input');
46
- }
47
- /**
48
- * Generates the manifest file. We ignore `generate:manifest` errors for
49
- * now, since it's a secondary task for us and one should run it
50
- * in seperate process to find the actual errors.
51
- */
52
- async generate() {
53
- try {
54
- const response = await (0, execa_1.default)(process.execPath, ['ace', 'generate:manifest'], {
55
- buffer: true,
56
- cwd: this.appRoot,
57
- env: {
58
- FORCE_COLOR: 'true',
59
- },
60
- });
61
- /**
62
- * Log success
63
- */
64
- if (response.stdout) {
65
- this.logger.log(response.stdout);
66
- }
67
- return true;
68
- }
69
- catch (error) {
70
- if (this.isMalformedJSONError(error.stderr) && this.attempts < this.maxAttempts) {
71
- this.attempts++;
72
- return this.generate();
73
- }
74
- /**
75
- * Print warning on error
76
- */
77
- this.logger.warning(WARN_MESSAGE);
78
- if (error.stderr) {
79
- this.logger.logError(error.stderr);
80
- }
81
- if (error.stdout) {
82
- this.logger.logError(error.stdout);
83
- }
84
- return false;
85
- }
86
- }
87
- }
88
- exports.Manifest = Manifest;
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.Manifest = void 0;
15
+ const execa_1 = __importDefault(require("execa"));
16
+ const WARN_MESSAGE = [
17
+ 'Unable to generate manifest file.',
18
+ 'Check the following error for more info',
19
+ ].join(' ');
20
+ /**
21
+ * Exposes the API to execute generate manifest file
22
+ */
23
+ class Manifest {
24
+ constructor(appRoot, logger) {
25
+ this.appRoot = appRoot;
26
+ this.logger = logger;
27
+ /**
28
+ * The maximum number of times we should attempt to generate
29
+ * the manifest file before giving up.
30
+ *
31
+ * This number may sound too big, but in real world scanerio, we
32
+ * have seen encountered malformed JSON between 10-12 times.
33
+ *
34
+ * The JSON gets malformed, when a parallel process (node ace serve --watch)
35
+ * is trying to update it.
36
+ */
37
+ this.maxAttempts = 15;
38
+ this.attempts = 0;
39
+ }
40
+ /**
41
+ * Returns a boolean telling if the error message is pointing
42
+ * towards invalid or empty JSON file read attempt.
43
+ */
44
+ isMalformedJSONError(error) {
45
+ return error.includes('Unexpected end of JSON input');
46
+ }
47
+ /**
48
+ * Generates the manifest file. We ignore `generate:manifest` errors for
49
+ * now, since it's a secondary task for us and one should run it
50
+ * in seperate process to find the actual errors.
51
+ */
52
+ async generate() {
53
+ try {
54
+ const response = await (0, execa_1.default)(process.execPath, ['ace', 'generate:manifest'], {
55
+ buffer: true,
56
+ cwd: this.appRoot,
57
+ env: {
58
+ FORCE_COLOR: 'true',
59
+ },
60
+ });
61
+ /**
62
+ * Log success
63
+ */
64
+ if (response.stdout) {
65
+ this.logger.log(response.stdout);
66
+ }
67
+ return true;
68
+ }
69
+ catch (error) {
70
+ if (this.isMalformedJSONError(error.stderr) && this.attempts < this.maxAttempts) {
71
+ this.attempts++;
72
+ return this.generate();
73
+ }
74
+ /**
75
+ * Print warning on error
76
+ */
77
+ this.logger.warning(WARN_MESSAGE);
78
+ if (error.stderr) {
79
+ this.logger.logError(error.stderr);
80
+ }
81
+ if (error.stdout) {
82
+ this.logger.logError(error.stdout);
83
+ }
84
+ return false;
85
+ }
86
+ }
87
+ }
88
+ exports.Manifest = Manifest;