@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.
- package/build/ace-manifest.json +17 -11
- package/build/commands/Build.d.ts +37 -37
- package/build/commands/Build.js +138 -138
- package/build/commands/Invoke.d.ts +34 -34
- package/build/commands/Invoke.js +221 -217
- package/build/commands/Make/Base.d.ts +30 -30
- package/build/commands/Make/Base.js +75 -75
- package/build/commands/Make/Command.d.ts +35 -35
- package/build/commands/Make/Command.js +82 -82
- package/build/commands/Make/Controller.d.ts +37 -37
- package/build/commands/Make/Controller.js +89 -89
- package/build/commands/Make/Exception.d.ts +32 -32
- package/build/commands/Make/Exception.js +75 -75
- package/build/commands/Make/Listener.d.ts +30 -30
- package/build/commands/Make/Listener.js +70 -70
- package/build/commands/Make/Middleware.d.ts +31 -31
- package/build/commands/Make/Middleware.js +87 -87
- package/build/commands/Make/PreloadFile.d.ts +38 -38
- package/build/commands/Make/PreloadFile.js +157 -157
- package/build/commands/Make/Provider.d.ts +31 -31
- package/build/commands/Make/Provider.js +114 -114
- package/build/commands/Make/Suite.d.ts +41 -41
- package/build/commands/Make/Suite.js +120 -120
- package/build/commands/Make/Test.d.ts +35 -35
- package/build/commands/Make/Test.js +96 -96
- package/build/commands/Make/Validator.d.ts +31 -31
- package/build/commands/Make/Validator.js +71 -71
- package/build/commands/Make/View.d.ts +30 -30
- package/build/commands/Make/View.js +70 -70
- package/build/commands/Serve.d.ts +33 -33
- package/build/commands/Serve.js +112 -112
- package/build/commands/Test.d.ts +57 -53
- package/build/commands/Test.js +159 -152
- package/build/commands/TypeCheck.d.ts +16 -16
- package/build/commands/TypeCheck.js +85 -85
- package/build/config/paths.d.ts +7 -7
- package/build/config/paths.js +18 -18
- package/build/register.d.ts +1 -1
- package/build/register.js +15 -15
- package/build/src/AssetsBundler/index.d.ts +76 -76
- package/build/src/AssetsBundler/index.js +216 -216
- package/build/src/Compiler/index.d.ts +62 -62
- package/build/src/Compiler/index.js +287 -287
- package/build/src/Contracts/index.d.ts +8 -8
- package/build/src/Contracts/index.js +10 -10
- package/build/src/DevServer/index.d.ts +70 -70
- package/build/src/DevServer/index.js +306 -306
- package/build/src/EnvParser/index.d.ts +23 -23
- package/build/src/EnvParser/index.js +52 -52
- package/build/src/HttpServer/index.d.ts +34 -34
- package/build/src/HttpServer/index.js +87 -87
- package/build/src/Manifest/index.d.ts +32 -32
- package/build/src/Manifest/index.js +88 -88
- package/build/src/RcFile/index.d.ts +72 -72
- package/build/src/RcFile/index.js +174 -174
- package/build/src/Test/index.d.ts +75 -75
- package/build/src/Test/index.js +346 -346
- package/build/src/Test/process.d.ts +22 -22
- package/build/src/Test/process.js +68 -68
- package/build/src/Ts/index.d.ts +24 -24
- package/build/src/Ts/index.js +55 -55
- package/build/src/requireHook/index.d.ts +5 -5
- package/build/src/requireHook/index.js +28 -28
- package/build/src/requireHook/ioc-transformer.d.ts +6 -6
- package/build/src/requireHook/ioc-transformer.js +21 -21
- package/package.json +16 -16
|
@@ -1,52 +1,52 @@
|
|
|
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 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,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;
|