@adonisjs/assembler 5.4.0 → 5.5.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/build/ace-manifest.json +74 -0
- package/build/commands/Build.js +5 -1
- package/build/commands/Invoke.js +5 -1
- package/build/commands/Make/Controller.js +1 -0
- package/build/commands/Make/PreloadFile.js +5 -1
- package/build/commands/Make/Provider.js +5 -1
- package/build/commands/Serve.js +5 -1
- package/build/commands/Test.d.ts +35 -0
- package/build/commands/Test.js +150 -0
- package/build/commands/TypeCheck.js +5 -1
- package/build/config/paths.d.ts +1 -0
- package/build/config/paths.js +2 -1
- package/build/src/Contracts/index.d.ts +10 -0
- package/build/src/Contracts/index.js +10 -0
- package/build/src/HttpServer/index.js +1 -1
- package/build/src/Manifest/index.js +3 -0
- package/build/src/RcFile/index.d.ts +9 -0
- package/build/src/RcFile/index.js +30 -0
- package/build/src/Test/index.d.ts +66 -0
- package/build/src/Test/index.js +323 -0
- package/build/src/Test/process.d.ts +22 -0
- package/build/src/Test/process.js +64 -0
- package/build/templates/controller.txt +1 -1
- package/build/templates/event-listener.txt +1 -1
- package/build/templates/middleware.txt +1 -1
- package/build/templates/provider.txt +1 -1
- package/build/templates/resource-controller.txt +1 -1
- package/build/templates/self-handle-exception.txt +1 -1
- package/build/templates/validator.txt +1 -1
- package/package.json +19 -19
package/build/ace-manifest.json
CHANGED
|
@@ -353,6 +353,80 @@
|
|
|
353
353
|
}
|
|
354
354
|
]
|
|
355
355
|
},
|
|
356
|
+
"test": {
|
|
357
|
+
"settings": {
|
|
358
|
+
"stayAlive": true
|
|
359
|
+
},
|
|
360
|
+
"commandPath": "./commands/Test",
|
|
361
|
+
"commandName": "test",
|
|
362
|
+
"description": "Run AdonisJS tests",
|
|
363
|
+
"args": [],
|
|
364
|
+
"aliases": [],
|
|
365
|
+
"flags": [
|
|
366
|
+
{
|
|
367
|
+
"name": "watch",
|
|
368
|
+
"propertyName": "watch",
|
|
369
|
+
"type": "boolean",
|
|
370
|
+
"description": "Watch for file changes and re-run tests on file change",
|
|
371
|
+
"alias": "w"
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
"name": "poll",
|
|
375
|
+
"propertyName": "poll",
|
|
376
|
+
"type": "boolean",
|
|
377
|
+
"description": "Detect file changes by polling files instead of listening to filesystem events",
|
|
378
|
+
"alias": "p"
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
"name": "node-args",
|
|
382
|
+
"propertyName": "nodeArgs",
|
|
383
|
+
"type": "array",
|
|
384
|
+
"description": "CLI options to pass to the node command line"
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
"name": "tags",
|
|
388
|
+
"propertyName": "tags",
|
|
389
|
+
"type": "array",
|
|
390
|
+
"description": "Run tests for only specified tags"
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
"name": "ignore-tags",
|
|
394
|
+
"propertyName": "ignoreTags",
|
|
395
|
+
"type": "array",
|
|
396
|
+
"description": "Run all the tests except the tests using specified tags"
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
"name": "timeout",
|
|
400
|
+
"propertyName": "timeout",
|
|
401
|
+
"type": "number",
|
|
402
|
+
"description": "Define timeout for tests"
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
"name": "suites",
|
|
406
|
+
"propertyName": "suites",
|
|
407
|
+
"type": "array",
|
|
408
|
+
"description": "Run tests for only the specified suites"
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
"name": "groups",
|
|
412
|
+
"propertyName": "groups",
|
|
413
|
+
"type": "array",
|
|
414
|
+
"description": "Run tests for only the specified groups"
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
"name": "tests",
|
|
418
|
+
"propertyName": "tests",
|
|
419
|
+
"type": "array",
|
|
420
|
+
"description": "Run tests with the specified titles"
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
"name": "force-exit",
|
|
424
|
+
"propertyName": "forceExit",
|
|
425
|
+
"type": "boolean",
|
|
426
|
+
"description": "Force exit the tests runner process"
|
|
427
|
+
}
|
|
428
|
+
]
|
|
429
|
+
},
|
|
356
430
|
"type-check": {
|
|
357
431
|
"settings": {},
|
|
358
432
|
"commandPath": "./commands/TypeCheck",
|
package/build/commands/Build.js
CHANGED
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
*/
|
|
10
10
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
11
|
if (k2 === undefined) k2 = k;
|
|
12
|
-
Object.
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
13
17
|
}) : (function(o, m, k, k2) {
|
|
14
18
|
if (k2 === undefined) k2 = k;
|
|
15
19
|
o[k2] = m[k];
|
package/build/commands/Invoke.js
CHANGED
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
*/
|
|
10
10
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
11
|
if (k2 === undefined) k2 = k;
|
|
12
|
-
Object.
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
13
17
|
}) : (function(o, m, k, k2) {
|
|
14
18
|
if (k2 === undefined) k2 = k;
|
|
15
19
|
o[k2] = m[k];
|
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
*/
|
|
10
10
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
11
|
if (k2 === undefined) k2 = k;
|
|
12
|
-
Object.
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
13
17
|
}) : (function(o, m, k, k2) {
|
|
14
18
|
if (k2 === undefined) k2 = k;
|
|
15
19
|
o[k2] = m[k];
|
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
*/
|
|
10
10
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
11
|
if (k2 === undefined) k2 = k;
|
|
12
|
-
Object.
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
13
17
|
}) : (function(o, m, k, k2) {
|
|
14
18
|
if (k2 === undefined) k2 = k;
|
|
15
19
|
o[k2] = m[k];
|
package/build/commands/Serve.js
CHANGED
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
*/
|
|
10
10
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
11
|
if (k2 === undefined) k2 = k;
|
|
12
|
-
Object.
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
13
17
|
}) : (function(o, m, k, k2) {
|
|
14
18
|
if (k2 === undefined) k2 = k;
|
|
15
19
|
o[k2] = m[k];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BaseCommand } from '@adonisjs/core/build/standalone';
|
|
2
|
+
/**
|
|
3
|
+
* Run tests
|
|
4
|
+
*/
|
|
5
|
+
export default class Test extends BaseCommand {
|
|
6
|
+
static commandName: string;
|
|
7
|
+
static description: string;
|
|
8
|
+
static settings: {
|
|
9
|
+
stayAlive: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Allows watching for file changes
|
|
13
|
+
*/
|
|
14
|
+
watch: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Detect changes by polling files
|
|
17
|
+
*/
|
|
18
|
+
poll: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Arguments to pass to the `node` binary
|
|
21
|
+
*/
|
|
22
|
+
nodeArgs: string[];
|
|
23
|
+
tags: string[];
|
|
24
|
+
ignoreTags: string[];
|
|
25
|
+
timeout: number;
|
|
26
|
+
suites: string[];
|
|
27
|
+
groups: string[];
|
|
28
|
+
tests: string[];
|
|
29
|
+
forceExit: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Convert command flags to test filters
|
|
32
|
+
*/
|
|
33
|
+
private getTestFilters;
|
|
34
|
+
run(): Promise<void>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}) : (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
o[k2] = m[k];
|
|
20
|
+
}));
|
|
21
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
+
}) : function(o, v) {
|
|
24
|
+
o["default"] = v;
|
|
25
|
+
});
|
|
26
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
27
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
28
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
29
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
30
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31
|
+
};
|
|
32
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
40
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
const standalone_1 = require("@adonisjs/core/build/standalone");
|
|
44
|
+
/**
|
|
45
|
+
* Run tests
|
|
46
|
+
*/
|
|
47
|
+
class Test extends standalone_1.BaseCommand {
|
|
48
|
+
constructor() {
|
|
49
|
+
super(...arguments);
|
|
50
|
+
/**
|
|
51
|
+
* Arguments to pass to the `node` binary
|
|
52
|
+
*/
|
|
53
|
+
this.nodeArgs = [];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Convert command flags to test filters
|
|
57
|
+
*/
|
|
58
|
+
getTestFilters() {
|
|
59
|
+
const filters = {};
|
|
60
|
+
if (this.forceExit) {
|
|
61
|
+
filters['--force-exit'] = true;
|
|
62
|
+
}
|
|
63
|
+
if (this.timeout !== undefined) {
|
|
64
|
+
filters['--timeout'] = this.timeout;
|
|
65
|
+
}
|
|
66
|
+
if (this.tests) {
|
|
67
|
+
filters['--tests'] = this.tests;
|
|
68
|
+
}
|
|
69
|
+
if (this.groups) {
|
|
70
|
+
filters['--groups'] = this.groups;
|
|
71
|
+
}
|
|
72
|
+
if (this.suites) {
|
|
73
|
+
filters['--suites'] = this.suites;
|
|
74
|
+
}
|
|
75
|
+
if (this.tags) {
|
|
76
|
+
filters['--tags'] = this.tags;
|
|
77
|
+
}
|
|
78
|
+
if (this.ignoreTags) {
|
|
79
|
+
filters['--ignore-tags'] = this.ignoreTags;
|
|
80
|
+
}
|
|
81
|
+
return filters;
|
|
82
|
+
}
|
|
83
|
+
async run() {
|
|
84
|
+
const { TestsServer } = await Promise.resolve().then(() => __importStar(require('../src/Test')));
|
|
85
|
+
try {
|
|
86
|
+
if (this.watch) {
|
|
87
|
+
await new TestsServer(this.application.appRoot, this.getTestFilters(), this.nodeArgs, this.logger).watch();
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
await new TestsServer(this.application.appRoot, this.getTestFilters(), this.nodeArgs, this.logger).run();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
this.exitCode = 1;
|
|
95
|
+
this.logger.fatal(error);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
Test.commandName = 'test';
|
|
100
|
+
Test.description = 'Run AdonisJS tests';
|
|
101
|
+
Test.settings = {
|
|
102
|
+
stayAlive: true,
|
|
103
|
+
};
|
|
104
|
+
__decorate([
|
|
105
|
+
standalone_1.flags.boolean({
|
|
106
|
+
description: 'Watch for file changes and re-run tests on file change',
|
|
107
|
+
alias: 'w',
|
|
108
|
+
}),
|
|
109
|
+
__metadata("design:type", Boolean)
|
|
110
|
+
], Test.prototype, "watch", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
standalone_1.flags.boolean({
|
|
113
|
+
description: 'Detect file changes by polling files instead of listening to filesystem events',
|
|
114
|
+
alias: 'p',
|
|
115
|
+
}),
|
|
116
|
+
__metadata("design:type", Boolean)
|
|
117
|
+
], Test.prototype, "poll", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
standalone_1.flags.array({ description: 'CLI options to pass to the node command line' }),
|
|
120
|
+
__metadata("design:type", Array)
|
|
121
|
+
], Test.prototype, "nodeArgs", void 0);
|
|
122
|
+
__decorate([
|
|
123
|
+
standalone_1.flags.array({ description: 'Run tests for only specified tags' }),
|
|
124
|
+
__metadata("design:type", Array)
|
|
125
|
+
], Test.prototype, "tags", void 0);
|
|
126
|
+
__decorate([
|
|
127
|
+
standalone_1.flags.array({ description: 'Run all the tests except the tests using specified tags' }),
|
|
128
|
+
__metadata("design:type", Array)
|
|
129
|
+
], Test.prototype, "ignoreTags", void 0);
|
|
130
|
+
__decorate([
|
|
131
|
+
standalone_1.flags.number({ description: 'Define timeout for tests' }),
|
|
132
|
+
__metadata("design:type", Number)
|
|
133
|
+
], Test.prototype, "timeout", void 0);
|
|
134
|
+
__decorate([
|
|
135
|
+
standalone_1.flags.array({ description: 'Run tests for only the specified suites' }),
|
|
136
|
+
__metadata("design:type", Array)
|
|
137
|
+
], Test.prototype, "suites", void 0);
|
|
138
|
+
__decorate([
|
|
139
|
+
standalone_1.flags.array({ description: 'Run tests for only the specified groups' }),
|
|
140
|
+
__metadata("design:type", Array)
|
|
141
|
+
], Test.prototype, "groups", void 0);
|
|
142
|
+
__decorate([
|
|
143
|
+
standalone_1.flags.array({ description: 'Run tests with the specified titles' }),
|
|
144
|
+
__metadata("design:type", Array)
|
|
145
|
+
], Test.prototype, "tests", void 0);
|
|
146
|
+
__decorate([
|
|
147
|
+
standalone_1.flags.boolean({ description: 'Force exit the tests runner process' }),
|
|
148
|
+
__metadata("design:type", Boolean)
|
|
149
|
+
], Test.prototype, "forceExit", void 0);
|
|
150
|
+
exports.default = Test;
|
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
*/
|
|
10
10
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
11
|
if (k2 === undefined) k2 = k;
|
|
12
|
-
Object.
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
13
17
|
}) : (function(o, m, k, k2) {
|
|
14
18
|
if (k2 === undefined) k2 = k;
|
|
15
19
|
o[k2] = m[k];
|
package/build/config/paths.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export declare const DEFAULT_BUILD_DIR = "build";
|
|
|
3
3
|
export declare const RCFILE_NAME = ".adonisrc.json";
|
|
4
4
|
export declare const ENV_FILES: string[];
|
|
5
5
|
export declare const SERVER_ENTRY_FILE = "server.ts";
|
|
6
|
+
export declare const TESTS_ENTRY_FILE = "tests.ts";
|
|
6
7
|
export declare const TSCONFIG_FILE_NAME = "tsconfig.json";
|
package/build/config/paths.js
CHANGED
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
* file that was distributed with this source code.
|
|
9
9
|
*/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.TSCONFIG_FILE_NAME = exports.SERVER_ENTRY_FILE = exports.ENV_FILES = exports.RCFILE_NAME = exports.DEFAULT_BUILD_DIR = exports.ACE_FILE_NAME = void 0;
|
|
11
|
+
exports.TSCONFIG_FILE_NAME = exports.TESTS_ENTRY_FILE = exports.SERVER_ENTRY_FILE = exports.ENV_FILES = exports.RCFILE_NAME = exports.DEFAULT_BUILD_DIR = exports.ACE_FILE_NAME = void 0;
|
|
12
12
|
exports.ACE_FILE_NAME = 'ace';
|
|
13
13
|
exports.DEFAULT_BUILD_DIR = 'build';
|
|
14
14
|
exports.RCFILE_NAME = '.adonisrc.json';
|
|
15
15
|
exports.ENV_FILES = ['.env', '.env.testing'];
|
|
16
16
|
exports.SERVER_ENTRY_FILE = 'server.ts';
|
|
17
|
+
exports.TESTS_ENTRY_FILE = 'tests.ts';
|
|
17
18
|
exports.TSCONFIG_FILE_NAME = 'tsconfig.json';
|
|
@@ -0,0 +1,10 @@
|
|
|
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 });
|
|
@@ -60,7 +60,7 @@ class HttpServer extends emittery_1.default {
|
|
|
60
60
|
* Notify about server events
|
|
61
61
|
*/
|
|
62
62
|
this.childProcess.on('message', (message) => {
|
|
63
|
-
if (message && message['
|
|
63
|
+
if (message && message['isAdonisJS'] && message['environment'] === 'web') {
|
|
64
64
|
this.emit('ready', message);
|
|
65
65
|
}
|
|
66
66
|
});
|
|
@@ -18,6 +18,10 @@ export declare class RcFile {
|
|
|
18
18
|
* A matcher to know if a file is part of the meta files globs
|
|
19
19
|
*/
|
|
20
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;
|
|
21
25
|
/**
|
|
22
26
|
* A matcher to know if a file is part of the restart server files globs
|
|
23
27
|
*/
|
|
@@ -47,6 +51,10 @@ export declare class RcFile {
|
|
|
47
51
|
* to be copied
|
|
48
52
|
*/
|
|
49
53
|
getMetaFilesGlob(): string[];
|
|
54
|
+
/**
|
|
55
|
+
* Returns an array of globs for the test files
|
|
56
|
+
*/
|
|
57
|
+
getTestsFileGlob(): string[];
|
|
50
58
|
/**
|
|
51
59
|
* Reloads the rcfile.json
|
|
52
60
|
*/
|
|
@@ -59,5 +67,6 @@ export declare class RcFile {
|
|
|
59
67
|
reload: boolean;
|
|
60
68
|
rcFile: boolean;
|
|
61
69
|
metaFile: boolean;
|
|
70
|
+
testFile: boolean;
|
|
62
71
|
};
|
|
63
72
|
}
|
|
@@ -39,6 +39,10 @@ class RcFile {
|
|
|
39
39
|
* A matcher to know if a file is part of the meta files globs
|
|
40
40
|
*/
|
|
41
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());
|
|
42
46
|
/**
|
|
43
47
|
* A matcher to know if a file is part of the restart server files globs
|
|
44
48
|
*/
|
|
@@ -90,6 +94,17 @@ class RcFile {
|
|
|
90
94
|
.map(({ pattern }) => pattern)
|
|
91
95
|
.concat([paths_1.ACE_FILE_NAME]);
|
|
92
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
|
+
}
|
|
93
108
|
/**
|
|
94
109
|
* Reloads the rcfile.json
|
|
95
110
|
*/
|
|
@@ -109,6 +124,7 @@ class RcFile {
|
|
|
109
124
|
reload: true,
|
|
110
125
|
rcFile: true,
|
|
111
126
|
metaFile: true,
|
|
127
|
+
testFile: false,
|
|
112
128
|
};
|
|
113
129
|
}
|
|
114
130
|
/**
|
|
@@ -119,6 +135,7 @@ class RcFile {
|
|
|
119
135
|
reload: true,
|
|
120
136
|
rcFile: false,
|
|
121
137
|
metaFile: true,
|
|
138
|
+
testFile: false,
|
|
122
139
|
};
|
|
123
140
|
}
|
|
124
141
|
/**
|
|
@@ -129,6 +146,18 @@ class RcFile {
|
|
|
129
146
|
reload: false,
|
|
130
147
|
rcFile: false,
|
|
131
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,
|
|
132
161
|
};
|
|
133
162
|
}
|
|
134
163
|
/**
|
|
@@ -138,6 +167,7 @@ class RcFile {
|
|
|
138
167
|
reload: false,
|
|
139
168
|
rcFile: false,
|
|
140
169
|
metaFile: false,
|
|
170
|
+
testFile: false,
|
|
141
171
|
};
|
|
142
172
|
}
|
|
143
173
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
* Returns the glob paths for test suites. Returns all if no
|
|
49
|
+
* filter is applied. Otherwise only the filtered suites
|
|
50
|
+
* are picked.
|
|
51
|
+
*/
|
|
52
|
+
private getFilesForSelectedSuites;
|
|
53
|
+
/**
|
|
54
|
+
* Kill current process
|
|
55
|
+
*/
|
|
56
|
+
private kill;
|
|
57
|
+
/**
|
|
58
|
+
* Run tests. Use [[watch]] to also watch for file
|
|
59
|
+
* changes
|
|
60
|
+
*/
|
|
61
|
+
run(filePath?: string): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Build and watch for file changes
|
|
64
|
+
*/
|
|
65
|
+
watch(poll?: boolean): Promise<void>;
|
|
66
|
+
}
|
|
@@ -0,0 +1,323 @@
|
|
|
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.TestsServer = void 0;
|
|
15
|
+
const path_1 = require("path");
|
|
16
|
+
const picomatch_1 = __importDefault(require("picomatch"));
|
|
17
|
+
const cliui_1 = require("@poppinss/cliui");
|
|
18
|
+
const require_ts_1 = require("@adonisjs/require-ts");
|
|
19
|
+
const Ts_1 = require("../Ts");
|
|
20
|
+
const RcFile_1 = require("../RcFile");
|
|
21
|
+
const Manifest_1 = require("../Manifest");
|
|
22
|
+
const process_1 = require("./process");
|
|
23
|
+
const paths_1 = require("../../config/paths");
|
|
24
|
+
/**
|
|
25
|
+
* Exposes the API to watch project for compilition changes and
|
|
26
|
+
* run/re-run tests
|
|
27
|
+
*/
|
|
28
|
+
class TestsServer {
|
|
29
|
+
constructor(appRoot, filters, nodeArgs = [], logger = cliui_1.logger) {
|
|
30
|
+
this.appRoot = appRoot;
|
|
31
|
+
this.filters = filters;
|
|
32
|
+
this.nodeArgs = nodeArgs;
|
|
33
|
+
this.logger = logger;
|
|
34
|
+
/**
|
|
35
|
+
* A boolean to know if we are watching for filesystem
|
|
36
|
+
*/
|
|
37
|
+
this.watchingFileSystem = false;
|
|
38
|
+
/**
|
|
39
|
+
* Boolean to hold the current state of tests. This is avoid
|
|
40
|
+
* re-running the tests when one run is in progress
|
|
41
|
+
*/
|
|
42
|
+
this.busy = false;
|
|
43
|
+
/**
|
|
44
|
+
* Reference to the typescript compiler
|
|
45
|
+
*/
|
|
46
|
+
this.ts = new Ts_1.Ts(this.appRoot, this.logger);
|
|
47
|
+
/**
|
|
48
|
+
* Reference to the RCFile
|
|
49
|
+
*/
|
|
50
|
+
this.rcFile = new RcFile_1.RcFile(this.appRoot);
|
|
51
|
+
/**
|
|
52
|
+
* Manifest instance to generate ace manifest file
|
|
53
|
+
*/
|
|
54
|
+
this.manifest = new Manifest_1.Manifest(this.appRoot, this.logger);
|
|
55
|
+
/**
|
|
56
|
+
* Require-ts watch helpers
|
|
57
|
+
*/
|
|
58
|
+
this.watchHelpers = (0, require_ts_1.getWatcherHelpers)(this.appRoot);
|
|
59
|
+
/**
|
|
60
|
+
* A method to know if the file is part of the selected suites
|
|
61
|
+
* or not
|
|
62
|
+
*/
|
|
63
|
+
this.isTestSuiteFile = (0, picomatch_1.default)(this.getFilesForSelectedSuites());
|
|
64
|
+
/**
|
|
65
|
+
* Find if the test file part of the applied file filters
|
|
66
|
+
*/
|
|
67
|
+
this.isTestFile = (filePath) => {
|
|
68
|
+
if (!this.filters['--files']) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
const fileName = filePath.replace((0, path_1.extname)(filePath), '');
|
|
72
|
+
return !!this.filters['--files'].find((filter) => {
|
|
73
|
+
if (filePath.endsWith(filter)) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
return fileName.endsWith(filter) || fileName.endsWith(`${filter}.spec`);
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Returns the glob paths for test suites. Returns all if no
|
|
82
|
+
* filter is applied. Otherwise only the filtered suites
|
|
83
|
+
* are picked.
|
|
84
|
+
*/
|
|
85
|
+
getFilesForSelectedSuites() {
|
|
86
|
+
return this.rcFile.application.rcFile.tests.suites.reduce((result, suite) => {
|
|
87
|
+
if (!suite.files) {
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
if (!this.filters['--suites'] || this.filters['--suites'].includes(suite.name)) {
|
|
91
|
+
result = result.concat(suite.files);
|
|
92
|
+
}
|
|
93
|
+
return result;
|
|
94
|
+
}, []);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Kill current process
|
|
98
|
+
*/
|
|
99
|
+
kill() {
|
|
100
|
+
process.exit();
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Run tests. Use [[watch]] to also watch for file
|
|
104
|
+
* changes
|
|
105
|
+
*/
|
|
106
|
+
async run(filePath) {
|
|
107
|
+
if (this.busy) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const filters = { ...this.filters };
|
|
111
|
+
/**
|
|
112
|
+
* Overwrite files filter when a specific file path
|
|
113
|
+
* is mentioned
|
|
114
|
+
*/
|
|
115
|
+
if (filePath) {
|
|
116
|
+
filters['--files'] = [filePath];
|
|
117
|
+
}
|
|
118
|
+
this.busy = true;
|
|
119
|
+
const { hasErrors } = await new process_1.TestProcess(paths_1.TESTS_ENTRY_FILE, this.appRoot, filters, this.nodeArgs, this.logger, {}).run();
|
|
120
|
+
this.busy = false;
|
|
121
|
+
if (!this.watchingFileSystem) {
|
|
122
|
+
if (hasErrors) {
|
|
123
|
+
process.exitCode = 1;
|
|
124
|
+
}
|
|
125
|
+
this.kill();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Build and watch for file changes
|
|
130
|
+
*/
|
|
131
|
+
async watch(poll = false) {
|
|
132
|
+
this.watchingFileSystem = true;
|
|
133
|
+
/**
|
|
134
|
+
* Clear require-ts cache
|
|
135
|
+
*/
|
|
136
|
+
this.watchHelpers.clear();
|
|
137
|
+
/**
|
|
138
|
+
* Run tests
|
|
139
|
+
*/
|
|
140
|
+
await this.run();
|
|
141
|
+
/**
|
|
142
|
+
* Parse config to find the files excluded inside
|
|
143
|
+
* tsconfig file
|
|
144
|
+
*/
|
|
145
|
+
const config = this.ts.parseConfig();
|
|
146
|
+
if (!config) {
|
|
147
|
+
this.logger.warning('Cannot start watcher because of errors in the tsconfig file');
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Stick file watcher
|
|
152
|
+
*/
|
|
153
|
+
const watcher = this.ts.tsCompiler.watcher(config, 'raw');
|
|
154
|
+
/**
|
|
155
|
+
* Watcher is ready after first compile
|
|
156
|
+
*/
|
|
157
|
+
watcher.on('watcher:ready', () => {
|
|
158
|
+
this.logger.info('watching file system for changes');
|
|
159
|
+
});
|
|
160
|
+
/**
|
|
161
|
+
* Source file removed
|
|
162
|
+
*/
|
|
163
|
+
watcher.on('source:unlink', async ({ absPath, relativePath }) => {
|
|
164
|
+
this.watchHelpers.clear(absPath);
|
|
165
|
+
if (this.busy) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
this.logger.action('delete').succeeded(relativePath);
|
|
169
|
+
/**
|
|
170
|
+
* Generate manifest when filePath is a commands path
|
|
171
|
+
*/
|
|
172
|
+
if (this.rcFile.isCommandsPath(relativePath)) {
|
|
173
|
+
this.manifest.generate();
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Run all tests when any of the source, except the
|
|
177
|
+
* test file changes
|
|
178
|
+
*/
|
|
179
|
+
if (!this.rcFile.isTestsFile(relativePath)) {
|
|
180
|
+
await this.run();
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
/**
|
|
184
|
+
* Source file added
|
|
185
|
+
*/
|
|
186
|
+
watcher.on('source:add', async ({ absPath, relativePath }) => {
|
|
187
|
+
this.watchHelpers.clear(absPath);
|
|
188
|
+
if (this.busy) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
this.logger.action('add').succeeded(relativePath);
|
|
192
|
+
/**
|
|
193
|
+
* Run all tests when any of the source, except the
|
|
194
|
+
* test file changes
|
|
195
|
+
*/
|
|
196
|
+
if (!this.rcFile.isTestsFile(relativePath)) {
|
|
197
|
+
await this.run();
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Run only the changed file if it part of the test
|
|
202
|
+
* suites (respecting filters)
|
|
203
|
+
*/
|
|
204
|
+
if (this.isTestSuiteFile(relativePath) && this.isTestFile(relativePath)) {
|
|
205
|
+
await this.run(relativePath);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
/**
|
|
209
|
+
* Source file changed
|
|
210
|
+
*/
|
|
211
|
+
watcher.on('source:change', async ({ absPath, relativePath }) => {
|
|
212
|
+
this.watchHelpers.clear(absPath);
|
|
213
|
+
if (this.busy) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
this.logger.action('update').succeeded(relativePath);
|
|
217
|
+
/**
|
|
218
|
+
* Generate manifest when filePath is a commands path
|
|
219
|
+
*/
|
|
220
|
+
if (this.rcFile.isCommandsPath(relativePath)) {
|
|
221
|
+
this.manifest.generate();
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Run all tests when any of the source, except the
|
|
225
|
+
* test file changes
|
|
226
|
+
*/
|
|
227
|
+
if (!this.rcFile.isTestsFile(relativePath)) {
|
|
228
|
+
await this.run();
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Run only the changed file if it part of the test
|
|
233
|
+
* suites (respecting filters)
|
|
234
|
+
*/
|
|
235
|
+
if (this.isTestSuiteFile(relativePath) && this.isTestFile(relativePath)) {
|
|
236
|
+
await this.run(relativePath);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
/**
|
|
240
|
+
* New file added
|
|
241
|
+
*/
|
|
242
|
+
watcher.on('add', async ({ relativePath }) => {
|
|
243
|
+
if (this.busy) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
if (paths_1.ENV_FILES.includes(relativePath)) {
|
|
247
|
+
this.logger.action('create').succeeded(relativePath);
|
|
248
|
+
await this.run();
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const metaData = this.rcFile.getMetaData(relativePath);
|
|
252
|
+
if (!metaData.metaFile) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
this.logger.action('create').succeeded(relativePath);
|
|
256
|
+
if (metaData.reload) {
|
|
257
|
+
await this.run();
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
/**
|
|
261
|
+
* File changed
|
|
262
|
+
*/
|
|
263
|
+
watcher.on('change', async ({ relativePath }) => {
|
|
264
|
+
if (this.busy) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (paths_1.ENV_FILES.includes(relativePath)) {
|
|
268
|
+
this.logger.action('update').succeeded(relativePath);
|
|
269
|
+
await this.run();
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
const metaData = this.rcFile.getMetaData(relativePath);
|
|
273
|
+
if (!metaData.metaFile) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
this.logger.action('update').succeeded(relativePath);
|
|
277
|
+
if (metaData.reload || metaData.rcFile) {
|
|
278
|
+
await this.run();
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
/**
|
|
282
|
+
* File removed
|
|
283
|
+
*/
|
|
284
|
+
watcher.on('unlink', async ({ relativePath }) => {
|
|
285
|
+
if (this.busy) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
if (paths_1.ENV_FILES.includes(relativePath)) {
|
|
289
|
+
this.logger.action('delete').succeeded(relativePath);
|
|
290
|
+
await this.run();
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
const metaData = this.rcFile.getMetaData(relativePath);
|
|
294
|
+
if (!metaData.metaFile) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (metaData.rcFile) {
|
|
298
|
+
this.logger.info('cannot continue after deletion of .adonisrc.json file');
|
|
299
|
+
watcher.chokidar.close();
|
|
300
|
+
this.kill();
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
this.logger.action('delete').succeeded(relativePath);
|
|
304
|
+
if (metaData.reload) {
|
|
305
|
+
await this.run();
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
/**
|
|
309
|
+
* Start the watcher
|
|
310
|
+
*/
|
|
311
|
+
watcher.watch(['.'], {
|
|
312
|
+
usePolling: poll,
|
|
313
|
+
});
|
|
314
|
+
/**
|
|
315
|
+
* Kill when watcher recieves an error
|
|
316
|
+
*/
|
|
317
|
+
watcher.chokidar.on('error', (error) => {
|
|
318
|
+
this.logger.fatal(error);
|
|
319
|
+
this.kill();
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
exports.TestsServer = TestsServer;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { logger as uiLogger } from '@poppinss/cliui';
|
|
2
|
+
import { JapaFlags } from '../Contracts';
|
|
3
|
+
/**
|
|
4
|
+
* Exposes the API to run tests as a child process.
|
|
5
|
+
*/
|
|
6
|
+
export declare class TestProcess {
|
|
7
|
+
private sourceFile;
|
|
8
|
+
private projectRoot;
|
|
9
|
+
private filters;
|
|
10
|
+
private logger;
|
|
11
|
+
private env;
|
|
12
|
+
private nodeArgs;
|
|
13
|
+
constructor(sourceFile: string, projectRoot: string, filters: JapaFlags, nodeArgs: string[] | undefined, logger: typeof uiLogger, env?: {
|
|
14
|
+
[key: string]: string;
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Start the HTTP server as a child process.
|
|
18
|
+
*/
|
|
19
|
+
run(): Promise<{
|
|
20
|
+
hasErrors: boolean;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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.TestProcess = void 0;
|
|
15
|
+
const execa_1 = __importDefault(require("execa"));
|
|
16
|
+
/**
|
|
17
|
+
* Exposes the API to run tests as a child process.
|
|
18
|
+
*/
|
|
19
|
+
class TestProcess {
|
|
20
|
+
constructor(sourceFile, projectRoot, filters, nodeArgs = [], logger, env = {}) {
|
|
21
|
+
this.sourceFile = sourceFile;
|
|
22
|
+
this.projectRoot = projectRoot;
|
|
23
|
+
this.filters = filters;
|
|
24
|
+
this.logger = logger;
|
|
25
|
+
this.env = env;
|
|
26
|
+
this.nodeArgs = nodeArgs.reduce((result, arg) => {
|
|
27
|
+
result = result.concat(arg.split(' '));
|
|
28
|
+
return result;
|
|
29
|
+
}, []);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Start the HTTP server as a child process.
|
|
33
|
+
*/
|
|
34
|
+
async run() {
|
|
35
|
+
this.logger.info('running tests...');
|
|
36
|
+
const filters = Object.keys(this.filters).reduce((result, filter) => {
|
|
37
|
+
const value = this.filters[filter];
|
|
38
|
+
result.push(filter);
|
|
39
|
+
if (Array.isArray(value)) {
|
|
40
|
+
result.push(...value);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
result.push(value);
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}, []);
|
|
47
|
+
try {
|
|
48
|
+
await execa_1.default.node(this.sourceFile, filters, {
|
|
49
|
+
stdio: 'inherit',
|
|
50
|
+
cwd: this.projectRoot,
|
|
51
|
+
env: {
|
|
52
|
+
FORCE_COLOR: 'true',
|
|
53
|
+
...this.env,
|
|
54
|
+
},
|
|
55
|
+
nodeOptions: ['-r', '@adonisjs/assembler/build/register'].concat(this.nodeArgs),
|
|
56
|
+
});
|
|
57
|
+
return { hasErrors: false };
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return { hasErrors: true };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.TestProcess = TestProcess;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Exception } from '@adonisjs/core/build/standalone'
|
|
2
|
-
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
|
2
|
+
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
|
3
3
|
|
|
4
4
|
/*
|
|
5
5
|
|--------------------------------------------------------------------------
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { schema } from '@ioc:Adonis/Core/Validator'
|
|
2
|
-
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
|
2
|
+
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
|
3
3
|
|
|
4
4
|
export default class {{ filename }} {
|
|
5
5
|
constructor(protected ctx: HttpContextContract) {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/assembler",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0-0",
|
|
4
4
|
"description": "Core commands to compiler and build AdonisJs project",
|
|
5
5
|
"main": "build/ace-manifest.json",
|
|
6
6
|
"files": [
|
|
@@ -44,19 +44,18 @@
|
|
|
44
44
|
},
|
|
45
45
|
"homepage": "https://github.com/adonisjs/assembler#readme",
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@adonisjs/ace": "^11.
|
|
48
|
-
"@adonisjs/core": "^5.
|
|
47
|
+
"@adonisjs/ace": "^11.2.2",
|
|
48
|
+
"@adonisjs/core": "^5.5.3",
|
|
49
49
|
"@adonisjs/mrm-preset": "^5.0.2",
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"@types/node": "^17.0.9",
|
|
50
|
+
"@poppinss/dev-utils": "^2.0.2",
|
|
51
|
+
"@types/node": "^17.0.21",
|
|
53
52
|
"commitizen": "^4.2.4",
|
|
54
53
|
"copyfiles": "^2.4.1",
|
|
55
54
|
"cross-env": "^7.0.3",
|
|
56
55
|
"cz-conventional-changelog": "^3.3.0",
|
|
57
56
|
"del-cli": "^4.0.1",
|
|
58
|
-
"eslint": "^8.
|
|
59
|
-
"eslint-config-prettier": "^8.
|
|
57
|
+
"eslint": "^8.10.0",
|
|
58
|
+
"eslint-config-prettier": "^8.5.0",
|
|
60
59
|
"eslint-plugin-adonis": "^2.1.0",
|
|
61
60
|
"eslint-plugin-prettier": "^4.0.0",
|
|
62
61
|
"github-label-sync": "^2.0.2",
|
|
@@ -65,7 +64,7 @@
|
|
|
65
64
|
"mrm": "^3.0.10",
|
|
66
65
|
"np": "^7.6.0",
|
|
67
66
|
"prettier": "^2.5.1",
|
|
68
|
-
"typescript": "^4.
|
|
67
|
+
"typescript": "^4.6.2"
|
|
69
68
|
},
|
|
70
69
|
"nyc": {
|
|
71
70
|
"exclude": [
|
|
@@ -90,17 +89,18 @@
|
|
|
90
89
|
"anyBranch": false
|
|
91
90
|
},
|
|
92
91
|
"dependencies": {
|
|
93
|
-
"@adonisjs/application": "^5.
|
|
94
|
-
"@adonisjs/env": "^3.0.
|
|
95
|
-
"@adonisjs/ioc-transformer": "^2.3.
|
|
96
|
-
"@adonisjs/
|
|
97
|
-
"@
|
|
98
|
-
"@poppinss/
|
|
99
|
-
"@poppinss/
|
|
92
|
+
"@adonisjs/application": "^5.2.0",
|
|
93
|
+
"@adonisjs/env": "^3.0.7",
|
|
94
|
+
"@adonisjs/ioc-transformer": "^2.3.3",
|
|
95
|
+
"@adonisjs/require-ts": "^2.0.10",
|
|
96
|
+
"@adonisjs/sink": "^5.2.2",
|
|
97
|
+
"@poppinss/chokidar-ts": "^3.3.4",
|
|
98
|
+
"@poppinss/cliui": "^3.0.1",
|
|
99
|
+
"@poppinss/utils": "^4.0.2",
|
|
100
100
|
"cpy": "^8.1.2",
|
|
101
|
-
"emittery": "^0.10.
|
|
101
|
+
"emittery": "^0.10.1",
|
|
102
102
|
"execa": "^5.1.1",
|
|
103
|
-
"fs-extra": "^10.0.
|
|
103
|
+
"fs-extra": "^10.0.1",
|
|
104
104
|
"get-port": "^5.1.1",
|
|
105
105
|
"has-yarn": "^2.1.0",
|
|
106
106
|
"picomatch": "^2.3.1",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
},
|
|
112
112
|
"publishConfig": {
|
|
113
113
|
"access": "public",
|
|
114
|
-
"tag": "
|
|
114
|
+
"tag": "next"
|
|
115
115
|
},
|
|
116
116
|
"mrmConfig": {
|
|
117
117
|
"core": true,
|