@adonisjs/assembler 5.9.4 → 6.0.0-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.
- package/LICENSE.md +1 -1
- package/build/index.d.ts +2 -0
- package/build/index.js +2 -0
- package/build/src/bundler.d.ts +10 -0
- package/build/src/bundler.js +133 -0
- package/build/src/dev_server.d.ts +13 -0
- package/build/src/dev_server.js +189 -0
- package/build/src/run.d.ts +3 -0
- package/build/src/run.js +19 -0
- package/build/src/types.d.ts +26 -0
- package/build/src/watch.d.ts +8 -0
- package/build/src/watch.js +18 -0
- package/package.json +77 -99
- package/build/ace-manifest.json +0 -521
- package/build/commands/Build.d.ts +0 -37
- package/build/commands/Build.js +0 -138
- package/build/commands/Invoke.d.ts +0 -34
- package/build/commands/Invoke.js +0 -234
- package/build/commands/Make/Base.d.ts +0 -30
- package/build/commands/Make/Base.js +0 -75
- package/build/commands/Make/Command.d.ts +0 -35
- package/build/commands/Make/Command.js +0 -82
- package/build/commands/Make/Controller.d.ts +0 -37
- package/build/commands/Make/Controller.js +0 -89
- package/build/commands/Make/Exception.d.ts +0 -32
- package/build/commands/Make/Exception.js +0 -75
- package/build/commands/Make/Listener.d.ts +0 -30
- package/build/commands/Make/Listener.js +0 -70
- package/build/commands/Make/Middleware.d.ts +0 -31
- package/build/commands/Make/Middleware.js +0 -87
- package/build/commands/Make/PreloadFile.d.ts +0 -38
- package/build/commands/Make/PreloadFile.js +0 -157
- package/build/commands/Make/Provider.d.ts +0 -31
- package/build/commands/Make/Provider.js +0 -114
- package/build/commands/Make/Suite.d.ts +0 -41
- package/build/commands/Make/Suite.js +0 -120
- package/build/commands/Make/Test.d.ts +0 -35
- package/build/commands/Make/Test.js +0 -96
- package/build/commands/Make/Validator.d.ts +0 -31
- package/build/commands/Make/Validator.js +0 -71
- package/build/commands/Make/View.d.ts +0 -30
- package/build/commands/Make/View.js +0 -70
- package/build/commands/Serve.d.ts +0 -33
- package/build/commands/Serve.js +0 -112
- package/build/commands/Test.d.ts +0 -57
- package/build/commands/Test.js +0 -159
- package/build/commands/TypeCheck.d.ts +0 -16
- package/build/commands/TypeCheck.js +0 -85
- package/build/config/paths.d.ts +0 -7
- package/build/config/paths.js +0 -18
- package/build/register.js +0 -15
- package/build/src/AssetsBundler/index.d.ts +0 -76
- package/build/src/AssetsBundler/index.js +0 -216
- package/build/src/Compiler/index.d.ts +0 -62
- package/build/src/Compiler/index.js +0 -287
- package/build/src/Contracts/index.d.ts +0 -8
- package/build/src/Contracts/index.js +0 -10
- package/build/src/DevServer/index.d.ts +0 -70
- package/build/src/DevServer/index.js +0 -306
- package/build/src/EnvParser/index.d.ts +0 -21
- package/build/src/EnvParser/index.js +0 -48
- package/build/src/HttpServer/index.d.ts +0 -34
- package/build/src/HttpServer/index.js +0 -87
- package/build/src/Manifest/index.d.ts +0 -32
- package/build/src/Manifest/index.js +0 -88
- package/build/src/RcFile/index.d.ts +0 -72
- package/build/src/RcFile/index.js +0 -174
- package/build/src/Test/index.d.ts +0 -75
- package/build/src/Test/index.js +0 -346
- package/build/src/Test/process.d.ts +0 -22
- package/build/src/Test/process.js +0 -68
- package/build/src/Ts/index.d.ts +0 -24
- package/build/src/Ts/index.js +0 -55
- package/build/src/requireHook/index.d.ts +0 -5
- package/build/src/requireHook/index.js +0 -28
- package/build/src/requireHook/ioc-transformer.d.ts +0 -6
- package/build/src/requireHook/ioc-transformer.js +0 -21
- package/build/templates/command.txt +0 -33
- package/build/templates/controller.txt +0 -3
- package/build/templates/event-listener.txt +0 -3
- package/build/templates/exception.txt +0 -15
- package/build/templates/middleware.txt +0 -8
- package/build/templates/preload-file.txt +0 -9
- package/build/templates/provider.txt +0 -40
- package/build/templates/resource-controller.txt +0 -17
- package/build/templates/self-handle-exception.txt +0 -32
- package/build/templates/test-entrypoint.txt +0 -45
- package/build/templates/test.txt +0 -5
- package/build/templates/tests/bootstrap.txt +0 -69
- package/build/templates/tests/functional/hello_world_api.spec.txt +0 -8
- package/build/templates/tests/functional/hello_world_slim.spec.txt +0 -8
- package/build/templates/tests/functional/hello_world_web.spec.txt +0 -8
- package/build/templates/tests-contract.txt +0 -18
- package/build/templates/validator.txt +0 -40
- package/build/templates/view.txt +0 -0
- package/build/templates/webpack.config.txt +0 -214
- /package/build/{register.d.ts → src/types.js} +0 -0
|
@@ -1,48 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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,72 +0,0 @@
|
|
|
1
|
-
import { Application } from '@adonisjs/application';
|
|
2
|
-
/**
|
|
3
|
-
* Exposes the API to pull meta files from the `.adonisrc.json` file and
|
|
4
|
-
* also match relative file paths against the defined globs.
|
|
5
|
-
*/
|
|
6
|
-
export declare class RcFile {
|
|
7
|
-
private appRoot;
|
|
8
|
-
rcFilePath: string;
|
|
9
|
-
/**
|
|
10
|
-
* Raw rcfile contents
|
|
11
|
-
*/
|
|
12
|
-
raw: any;
|
|
13
|
-
/**
|
|
14
|
-
* Reference to application
|
|
15
|
-
*/
|
|
16
|
-
application: Application;
|
|
17
|
-
/**
|
|
18
|
-
* A matcher to know if a file is part of the meta files globs
|
|
19
|
-
*/
|
|
20
|
-
isMetaFile: (filePath: string) => boolean;
|
|
21
|
-
/**
|
|
22
|
-
* A matcher to know if file is a test file or not
|
|
23
|
-
*/
|
|
24
|
-
isTestsFile: (filePath: string) => boolean;
|
|
25
|
-
/**
|
|
26
|
-
* A matcher to know if a file is part of the restart server files globs
|
|
27
|
-
*/
|
|
28
|
-
isRestartServerFile: (filePath: string) => boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Commands match to know, if file path is part of the commands paths defined
|
|
31
|
-
* inside `.adonisrc.json` file
|
|
32
|
-
*/
|
|
33
|
-
isCommandsPath: (filePath: string) => boolean;
|
|
34
|
-
constructor(appRoot: string);
|
|
35
|
-
/**
|
|
36
|
-
* Returns an array of globs for the meta files that has `reloadServer`
|
|
37
|
-
* set to true
|
|
38
|
-
*/
|
|
39
|
-
private getRestartServerFilesGlob;
|
|
40
|
-
/**
|
|
41
|
-
* Returns the commands glob for registered commands. We convert the
|
|
42
|
-
* command paths to glob pattern
|
|
43
|
-
*/
|
|
44
|
-
private commandsGlob;
|
|
45
|
-
/**
|
|
46
|
-
* Returns true when file is `.adonisrc.json` itself
|
|
47
|
-
*/
|
|
48
|
-
private isRcFile;
|
|
49
|
-
/**
|
|
50
|
-
* Returns an array of globs for the meta files
|
|
51
|
-
* to be copied
|
|
52
|
-
*/
|
|
53
|
-
getMetaFilesGlob(): string[];
|
|
54
|
-
/**
|
|
55
|
-
* Returns an array of globs for the test files
|
|
56
|
-
*/
|
|
57
|
-
getTestsFileGlob(): string[];
|
|
58
|
-
/**
|
|
59
|
-
* Reloads the rcfile.json
|
|
60
|
-
*/
|
|
61
|
-
getDiskContents(): any;
|
|
62
|
-
/**
|
|
63
|
-
* Returns metadata for a given file path. The metadata can
|
|
64
|
-
* be used to execute certain actions during file watch.
|
|
65
|
-
*/
|
|
66
|
-
getMetaData(filePath: string): {
|
|
67
|
-
reload: boolean;
|
|
68
|
-
rcFile: boolean;
|
|
69
|
-
metaFile: boolean;
|
|
70
|
-
testFile: boolean;
|
|
71
|
-
};
|
|
72
|
-
}
|
|
@@ -1,174 +0,0 @@
|
|
|
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.RcFile = void 0;
|
|
15
|
-
const slash_1 = __importDefault(require("slash"));
|
|
16
|
-
const picomatch_1 = __importDefault(require("picomatch"));
|
|
17
|
-
const path_1 = require("path");
|
|
18
|
-
const fs_extra_1 = require("fs-extra");
|
|
19
|
-
const application_1 = require("@adonisjs/application");
|
|
20
|
-
const helpers_1 = require("@poppinss/utils/build/helpers");
|
|
21
|
-
const paths_1 = require("../../config/paths");
|
|
22
|
-
/**
|
|
23
|
-
* Exposes the API to pull meta files from the `.adonisrc.json` file and
|
|
24
|
-
* also match relative file paths against the defined globs.
|
|
25
|
-
*/
|
|
26
|
-
class RcFile {
|
|
27
|
-
constructor(appRoot) {
|
|
28
|
-
this.appRoot = appRoot;
|
|
29
|
-
this.rcFilePath = (0, helpers_1.resolveFrom)(this.appRoot, `./${paths_1.RCFILE_NAME}`);
|
|
30
|
-
/**
|
|
31
|
-
* Raw rcfile contents
|
|
32
|
-
*/
|
|
33
|
-
this.raw = this.getDiskContents();
|
|
34
|
-
/**
|
|
35
|
-
* Reference to application
|
|
36
|
-
*/
|
|
37
|
-
this.application = new application_1.Application(this.appRoot, 'console', this.raw);
|
|
38
|
-
/**
|
|
39
|
-
* A matcher to know if a file is part of the meta files globs
|
|
40
|
-
*/
|
|
41
|
-
this.isMetaFile = (0, picomatch_1.default)(this.getMetaFilesGlob());
|
|
42
|
-
/**
|
|
43
|
-
* A matcher to know if file is a test file or not
|
|
44
|
-
*/
|
|
45
|
-
this.isTestsFile = (0, picomatch_1.default)(this.getTestsFileGlob());
|
|
46
|
-
/**
|
|
47
|
-
* A matcher to know if a file is part of the restart server files globs
|
|
48
|
-
*/
|
|
49
|
-
this.isRestartServerFile = (0, picomatch_1.default)(this.getRestartServerFilesGlob());
|
|
50
|
-
/**
|
|
51
|
-
* Commands match to know, if file path is part of the commands paths defined
|
|
52
|
-
* inside `.adonisrc.json` file
|
|
53
|
-
*/
|
|
54
|
-
this.isCommandsPath = (0, picomatch_1.default)(this.commandsGlob());
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Returns an array of globs for the meta files that has `reloadServer`
|
|
58
|
-
* set to true
|
|
59
|
-
*/
|
|
60
|
-
getRestartServerFilesGlob() {
|
|
61
|
-
return this.application.rcFile.metaFiles
|
|
62
|
-
.filter(({ reloadServer, pattern }) => {
|
|
63
|
-
return reloadServer === true && ![paths_1.RCFILE_NAME, paths_1.ACE_FILE_NAME].includes(pattern);
|
|
64
|
-
})
|
|
65
|
-
.map(({ pattern }) => pattern);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Returns the commands glob for registered commands. We convert the
|
|
69
|
-
* command paths to glob pattern
|
|
70
|
-
*/
|
|
71
|
-
commandsGlob() {
|
|
72
|
-
const commands = this.application.rcFile.commands.reduce((result, commandPath) => {
|
|
73
|
-
if (/^(.){1,2}\//.test(commandPath)) {
|
|
74
|
-
commandPath = (0, slash_1.default)((0, path_1.relative)(this.appRoot, (0, path_1.join)(this.appRoot, commandPath)));
|
|
75
|
-
result = result.concat([`${commandPath}.*`, `${commandPath}/**/*`]);
|
|
76
|
-
}
|
|
77
|
-
return result;
|
|
78
|
-
}, []);
|
|
79
|
-
return commands;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Returns true when file is `.adonisrc.json` itself
|
|
83
|
-
*/
|
|
84
|
-
isRcFile(filePath) {
|
|
85
|
-
return filePath === paths_1.RCFILE_NAME;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Returns an array of globs for the meta files
|
|
89
|
-
* to be copied
|
|
90
|
-
*/
|
|
91
|
-
getMetaFilesGlob() {
|
|
92
|
-
return this.application.rcFile.metaFiles
|
|
93
|
-
.filter(({ pattern }) => ![paths_1.RCFILE_NAME, paths_1.ACE_FILE_NAME].includes(pattern))
|
|
94
|
-
.map(({ pattern }) => pattern)
|
|
95
|
-
.concat([paths_1.ACE_FILE_NAME]);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Returns an array of globs for the test files
|
|
99
|
-
*/
|
|
100
|
-
getTestsFileGlob() {
|
|
101
|
-
return this.application.rcFile.tests.suites.reduce((result, suite) => {
|
|
102
|
-
if (suite.files) {
|
|
103
|
-
result = result.concat(suite.files);
|
|
104
|
-
}
|
|
105
|
-
return result;
|
|
106
|
-
}, []);
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Reloads the rcfile.json
|
|
110
|
-
*/
|
|
111
|
-
getDiskContents() {
|
|
112
|
-
return (0, fs_extra_1.readJSONSync)(this.rcFilePath);
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Returns metadata for a given file path. The metadata can
|
|
116
|
-
* be used to execute certain actions during file watch.
|
|
117
|
-
*/
|
|
118
|
-
getMetaData(filePath) {
|
|
119
|
-
/**
|
|
120
|
-
* File path === '.adonisrc.json'
|
|
121
|
-
*/
|
|
122
|
-
if (this.isRcFile(filePath)) {
|
|
123
|
-
return {
|
|
124
|
-
reload: true,
|
|
125
|
-
rcFile: true,
|
|
126
|
-
metaFile: true,
|
|
127
|
-
testFile: false,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* File is part of `reloadServer` metadata file globs
|
|
132
|
-
*/
|
|
133
|
-
if (this.isRestartServerFile(filePath)) {
|
|
134
|
-
return {
|
|
135
|
-
reload: true,
|
|
136
|
-
rcFile: false,
|
|
137
|
-
metaFile: true,
|
|
138
|
-
testFile: false,
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* File is part of metadata file globs, but reload = false
|
|
143
|
-
*/
|
|
144
|
-
if (this.isMetaFile(filePath)) {
|
|
145
|
-
return {
|
|
146
|
-
reload: false,
|
|
147
|
-
rcFile: false,
|
|
148
|
-
metaFile: true,
|
|
149
|
-
testFile: false,
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* File is part of one of the tests suite
|
|
154
|
-
*/
|
|
155
|
-
if (this.isTestsFile(filePath)) {
|
|
156
|
-
return {
|
|
157
|
-
reload: false,
|
|
158
|
-
rcFile: false,
|
|
159
|
-
metaFile: false,
|
|
160
|
-
testFile: true,
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Out of scope
|
|
165
|
-
*/
|
|
166
|
-
return {
|
|
167
|
-
reload: false,
|
|
168
|
-
rcFile: false,
|
|
169
|
-
metaFile: false,
|
|
170
|
-
testFile: false,
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
exports.RcFile = RcFile;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { logger as uiLogger } from '@poppinss/cliui';
|
|
2
|
-
import { JapaFlags } from '../Contracts';
|
|
3
|
-
/**
|
|
4
|
-
* Exposes the API to watch project for compilition changes and
|
|
5
|
-
* run/re-run tests
|
|
6
|
-
*/
|
|
7
|
-
export declare class TestsServer {
|
|
8
|
-
private appRoot;
|
|
9
|
-
private filters;
|
|
10
|
-
private nodeArgs;
|
|
11
|
-
private logger;
|
|
12
|
-
/**
|
|
13
|
-
* A boolean to know if we are watching for filesystem
|
|
14
|
-
*/
|
|
15
|
-
private watchingFileSystem;
|
|
16
|
-
/**
|
|
17
|
-
* Boolean to hold the current state of tests. This is avoid
|
|
18
|
-
* re-running the tests when one run is in progress
|
|
19
|
-
*/
|
|
20
|
-
private busy;
|
|
21
|
-
/**
|
|
22
|
-
* Reference to the typescript compiler
|
|
23
|
-
*/
|
|
24
|
-
private ts;
|
|
25
|
-
/**
|
|
26
|
-
* Reference to the RCFile
|
|
27
|
-
*/
|
|
28
|
-
private rcFile;
|
|
29
|
-
/**
|
|
30
|
-
* Manifest instance to generate ace manifest file
|
|
31
|
-
*/
|
|
32
|
-
private manifest;
|
|
33
|
-
/**
|
|
34
|
-
* Require-ts watch helpers
|
|
35
|
-
*/
|
|
36
|
-
private watchHelpers;
|
|
37
|
-
/**
|
|
38
|
-
* A method to know if the file is part of the selected suites
|
|
39
|
-
* or not
|
|
40
|
-
*/
|
|
41
|
-
private isTestSuiteFile;
|
|
42
|
-
/**
|
|
43
|
-
* Find if the test file part of the applied file filters
|
|
44
|
-
*/
|
|
45
|
-
private isTestFile;
|
|
46
|
-
constructor(appRoot: string, filters: JapaFlags, nodeArgs?: string[], logger?: typeof uiLogger);
|
|
47
|
-
/**
|
|
48
|
-
* Clear terminal screen
|
|
49
|
-
*/
|
|
50
|
-
private clearScreen;
|
|
51
|
-
/**
|
|
52
|
-
* Returns the glob paths for test suites. Returns all if no
|
|
53
|
-
* filter is applied. Otherwise only the filtered suites
|
|
54
|
-
* are picked.
|
|
55
|
-
*/
|
|
56
|
-
private getFilesForSelectedSuites;
|
|
57
|
-
/**
|
|
58
|
-
* Kill current process
|
|
59
|
-
*/
|
|
60
|
-
private kill;
|
|
61
|
-
/**
|
|
62
|
-
* Returns the HOST and the PORT environment variables
|
|
63
|
-
* for the HTTP server
|
|
64
|
-
*/
|
|
65
|
-
private getEnvironmentVariables;
|
|
66
|
-
/**
|
|
67
|
-
* Run tests. Use [[watch]] to also watch for file
|
|
68
|
-
* changes
|
|
69
|
-
*/
|
|
70
|
-
run(filePath?: string): Promise<void>;
|
|
71
|
-
/**
|
|
72
|
-
* Build and watch for file changes
|
|
73
|
-
*/
|
|
74
|
-
watch(poll?: boolean): Promise<void>;
|
|
75
|
-
}
|