@adonisjs/assembler 5.5.0-0 → 5.5.3-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 +55 -27
- package/build/commands/Invoke.d.ts +9 -1
- package/build/commands/Invoke.js +103 -41
- package/build/commands/Make/Test.d.ts +35 -0
- package/build/commands/Make/Test.js +96 -0
- package/build/commands/Test.d.ts +17 -3
- package/build/commands/Test.js +19 -24
- package/build/src/Contracts/index.d.ts +1 -3
- package/build/src/Test/index.js +3 -9
- package/build/src/Test/process.js +3 -1
- package/build/templates/test-entrypoint.txt +45 -0
- package/build/templates/test.txt +5 -0
- package/build/templates/tests/bootstrap.txt +69 -0
- package/build/templates/tests/functional/hello_world.spec.txt +8 -0
- package/build/templates/tests-contract.txt +18 -0
- package/package.json +21 -20
package/build/ace-manifest.json
CHANGED
|
@@ -51,14 +51,14 @@
|
|
|
51
51
|
"settings": {},
|
|
52
52
|
"commandPath": "./commands/Invoke",
|
|
53
53
|
"commandName": "configure",
|
|
54
|
-
"description": "Configure
|
|
54
|
+
"description": "Configure one or more AdonisJS packages",
|
|
55
55
|
"args": [
|
|
56
56
|
{
|
|
57
|
-
"type": "
|
|
58
|
-
"propertyName": "
|
|
59
|
-
"name": "
|
|
57
|
+
"type": "spread",
|
|
58
|
+
"propertyName": "packages",
|
|
59
|
+
"name": "packages",
|
|
60
60
|
"required": true,
|
|
61
|
-
"description": "Name of the package you want to configure"
|
|
61
|
+
"description": "Name of the package(s) you want to configure"
|
|
62
62
|
}
|
|
63
63
|
],
|
|
64
64
|
"aliases": [
|
|
@@ -259,6 +259,38 @@
|
|
|
259
259
|
}
|
|
260
260
|
]
|
|
261
261
|
},
|
|
262
|
+
"make:test": {
|
|
263
|
+
"settings": {},
|
|
264
|
+
"commandPath": "./commands/Make/Test",
|
|
265
|
+
"commandName": "make:test",
|
|
266
|
+
"description": "Make a new test",
|
|
267
|
+
"args": [
|
|
268
|
+
{
|
|
269
|
+
"type": "string",
|
|
270
|
+
"propertyName": "suite",
|
|
271
|
+
"name": "suite",
|
|
272
|
+
"required": true,
|
|
273
|
+
"description": "Name of the test suite"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"type": "string",
|
|
277
|
+
"propertyName": "name",
|
|
278
|
+
"name": "name",
|
|
279
|
+
"required": true,
|
|
280
|
+
"description": "Name of the test file"
|
|
281
|
+
}
|
|
282
|
+
],
|
|
283
|
+
"aliases": [],
|
|
284
|
+
"flags": [
|
|
285
|
+
{
|
|
286
|
+
"name": "exact",
|
|
287
|
+
"propertyName": "exact",
|
|
288
|
+
"type": "boolean",
|
|
289
|
+
"description": "Create the test file with the exact name as provided",
|
|
290
|
+
"alias": "e"
|
|
291
|
+
}
|
|
292
|
+
]
|
|
293
|
+
},
|
|
262
294
|
"make:validator": {
|
|
263
295
|
"settings": {},
|
|
264
296
|
"commandPath": "./commands/Make/Validator",
|
|
@@ -360,9 +392,23 @@
|
|
|
360
392
|
"commandPath": "./commands/Test",
|
|
361
393
|
"commandName": "test",
|
|
362
394
|
"description": "Run AdonisJS tests",
|
|
363
|
-
"args": [
|
|
395
|
+
"args": [
|
|
396
|
+
{
|
|
397
|
+
"type": "spread",
|
|
398
|
+
"propertyName": "suites",
|
|
399
|
+
"name": "suites",
|
|
400
|
+
"required": false,
|
|
401
|
+
"description": "Run tests for only the specified suites"
|
|
402
|
+
}
|
|
403
|
+
],
|
|
364
404
|
"aliases": [],
|
|
365
405
|
"flags": [
|
|
406
|
+
{
|
|
407
|
+
"name": "files",
|
|
408
|
+
"propertyName": "files",
|
|
409
|
+
"type": "array",
|
|
410
|
+
"description": "Run tests for the mentioned files only"
|
|
411
|
+
},
|
|
366
412
|
{
|
|
367
413
|
"name": "watch",
|
|
368
414
|
"propertyName": "watch",
|
|
@@ -387,37 +433,19 @@
|
|
|
387
433
|
"name": "tags",
|
|
388
434
|
"propertyName": "tags",
|
|
389
435
|
"type": "array",
|
|
390
|
-
"description": "
|
|
436
|
+
"description": "Filter tests by tags"
|
|
391
437
|
},
|
|
392
438
|
{
|
|
393
439
|
"name": "ignore-tags",
|
|
394
440
|
"propertyName": "ignoreTags",
|
|
395
441
|
"type": "array",
|
|
396
|
-
"description": "
|
|
442
|
+
"description": "Filter tests by ignoring tags"
|
|
397
443
|
},
|
|
398
444
|
{
|
|
399
445
|
"name": "timeout",
|
|
400
446
|
"propertyName": "timeout",
|
|
401
447
|
"type": "number",
|
|
402
|
-
"description": "
|
|
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"
|
|
448
|
+
"description": "Customize tests timeout"
|
|
421
449
|
},
|
|
422
450
|
{
|
|
423
451
|
"name": "force-exit",
|
|
@@ -9,11 +9,19 @@ export default class Configure extends BaseCommand {
|
|
|
9
9
|
/**
|
|
10
10
|
* Use yarn when building for production to install dependencies
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
packages: string[];
|
|
13
13
|
/**
|
|
14
14
|
* Configure encore
|
|
15
15
|
*/
|
|
16
16
|
private configureEncore;
|
|
17
|
+
/**
|
|
18
|
+
* Configure tests
|
|
19
|
+
*/
|
|
20
|
+
private configureTests;
|
|
21
|
+
/**
|
|
22
|
+
* Configure a give package
|
|
23
|
+
*/
|
|
24
|
+
private configurePackage;
|
|
17
25
|
/**
|
|
18
26
|
* Invoked automatically by ace
|
|
19
27
|
*/
|
package/build/commands/Invoke.js
CHANGED
|
@@ -7,40 +7,18 @@
|
|
|
7
7
|
* For the full copyright and license information, please view the LICENSE
|
|
8
8
|
* file that was distributed with this source code.
|
|
9
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
10
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
27
11
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
28
12
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
29
13
|
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
14
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31
15
|
};
|
|
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
16
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
40
17
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
41
18
|
};
|
|
42
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
20
|
const path_1 = require("path");
|
|
21
|
+
const sink_1 = require("@adonisjs/sink");
|
|
44
22
|
const standalone_1 = require("@adonisjs/core/build/standalone");
|
|
45
23
|
const Manifest_1 = require("../src/Manifest");
|
|
46
24
|
/**
|
|
@@ -51,55 +29,139 @@ class Configure extends standalone_1.BaseCommand {
|
|
|
51
29
|
* Configure encore
|
|
52
30
|
*/
|
|
53
31
|
async configureEncore() {
|
|
54
|
-
const { files, logger } = await Promise.resolve().then(() => __importStar(require('@adonisjs/sink')));
|
|
55
32
|
/**
|
|
56
33
|
* Create the webpack config file
|
|
57
34
|
*/
|
|
58
|
-
const webpackConfigFile = new files.MustacheFile(this.application.appRoot, 'webpack.config.js', (0, path_1.join)(__dirname, '..', 'templates/webpack.config.txt'));
|
|
35
|
+
const webpackConfigFile = new sink_1.files.MustacheFile(this.application.appRoot, 'webpack.config.js', (0, path_1.join)(__dirname, '..', 'templates/webpack.config.txt'));
|
|
59
36
|
if (!webpackConfigFile.exists()) {
|
|
60
37
|
webpackConfigFile.apply({}).commit();
|
|
61
|
-
logger.action('create').succeeded('webpack.config.js');
|
|
38
|
+
sink_1.logger.action('create').succeeded('webpack.config.js');
|
|
62
39
|
}
|
|
63
40
|
/**
|
|
64
41
|
* Create app.js entrypoint
|
|
65
42
|
*/
|
|
66
|
-
const entryPointFile = new files.NewLineFile(this.application.appRoot, 'resources/js/app.js');
|
|
43
|
+
const entryPointFile = new sink_1.files.NewLineFile(this.application.appRoot, 'resources/js/app.js');
|
|
67
44
|
if (!entryPointFile.exists()) {
|
|
68
45
|
entryPointFile.add('// app entrypoint').commit();
|
|
69
|
-
logger.action('create').succeeded('resources/js/app.js');
|
|
46
|
+
sink_1.logger.action('create').succeeded('resources/js/app.js');
|
|
70
47
|
}
|
|
71
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Install Encore
|
|
50
|
+
*/
|
|
51
|
+
const pkgFile = new sink_1.files.PackageJsonFile(this.application.appRoot);
|
|
72
52
|
pkgFile.install('@symfony/webpack-encore');
|
|
73
|
-
const spinner = logger.await(logger.colors.gray('installing @symfony/webpack-encore'));
|
|
53
|
+
const spinner = sink_1.logger.await(sink_1.logger.colors.gray('installing @symfony/webpack-encore'));
|
|
74
54
|
try {
|
|
75
55
|
await pkgFile.commitAsync();
|
|
76
56
|
spinner.update('Installed');
|
|
57
|
+
spinner.stop();
|
|
77
58
|
}
|
|
78
59
|
catch (error) {
|
|
79
60
|
spinner.update('Unable to install the package');
|
|
80
|
-
|
|
61
|
+
spinner.stop();
|
|
62
|
+
sink_1.logger.fatal(error);
|
|
81
63
|
}
|
|
82
64
|
}
|
|
83
65
|
/**
|
|
84
|
-
*
|
|
66
|
+
* Configure tests
|
|
85
67
|
*/
|
|
86
|
-
async
|
|
87
|
-
|
|
68
|
+
async configureTests() {
|
|
69
|
+
/**
|
|
70
|
+
* Create "test.ts" file
|
|
71
|
+
*/
|
|
72
|
+
const testsEntryPointFile = new sink_1.files.MustacheFile(this.application.appRoot, 'test.ts', (0, path_1.join)(__dirname, '..', 'templates/test-entrypoint.txt'));
|
|
73
|
+
if (!testsEntryPointFile.exists()) {
|
|
74
|
+
testsEntryPointFile.apply({}).commit();
|
|
75
|
+
sink_1.logger.action('create').succeeded('test.ts');
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Create "tests/bootstrap.ts" file
|
|
79
|
+
*/
|
|
80
|
+
const testsBootstrapFile = new sink_1.files.MustacheFile(this.application.appRoot, 'tests/bootstrap.ts', (0, path_1.join)(__dirname, '..', 'templates/tests/bootstrap.txt'));
|
|
81
|
+
if (!testsBootstrapFile.exists()) {
|
|
82
|
+
testsBootstrapFile.apply({}).commit();
|
|
83
|
+
sink_1.logger.action('create').succeeded('tests/bootstrap.ts');
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Create "tests/functional/hello_world.spec.ts" file
|
|
87
|
+
*/
|
|
88
|
+
const helloWorldTestFile = new sink_1.files.MustacheFile(this.application.appRoot, 'tests/functional/hello_world.spec.ts', (0, path_1.join)(__dirname, '..', 'templates/tests/functional/hello_world.spec.txt'));
|
|
89
|
+
if (!helloWorldTestFile.exists()) {
|
|
90
|
+
helloWorldTestFile.apply({}).commit();
|
|
91
|
+
sink_1.logger.action('create').succeeded('tests/functional/hello_world.spec.ts');
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Create "contracts/tests.ts" file
|
|
95
|
+
*/
|
|
96
|
+
const testsContractsFile = new sink_1.files.MustacheFile(this.application.appRoot, 'contracts/tests.ts', (0, path_1.join)(__dirname, '..', 'templates/tests-contract.txt'));
|
|
97
|
+
if (!testsContractsFile.exists()) {
|
|
98
|
+
testsContractsFile.apply({}).commit();
|
|
99
|
+
sink_1.logger.action('create').succeeded('contracts/tests.ts');
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Update AdonisRc file with test suites
|
|
103
|
+
*/
|
|
104
|
+
const rcFile = new sink_1.files.AdonisRcFile(this.application.appRoot);
|
|
105
|
+
rcFile.set('tests', {
|
|
106
|
+
suites: [
|
|
107
|
+
{
|
|
108
|
+
name: 'functional',
|
|
109
|
+
files: ['tests/functional/**/*.spec(.ts|.js)'],
|
|
110
|
+
timeout: 60 * 1000,
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
});
|
|
114
|
+
rcFile.commit();
|
|
115
|
+
sink_1.logger.action('update').succeeded('.adonisrc.json');
|
|
116
|
+
/**
|
|
117
|
+
* Install required dependencies
|
|
118
|
+
*/
|
|
119
|
+
const pkgFile = new sink_1.files.PackageJsonFile(this.application.appRoot);
|
|
120
|
+
pkgFile.install('@japa/runner');
|
|
121
|
+
pkgFile.install('@japa/preset-adonis');
|
|
122
|
+
const spinner = sink_1.logger.await(sink_1.logger.colors.gray('installing @japa/runner, @japa/preset-adonis'));
|
|
123
|
+
try {
|
|
124
|
+
await pkgFile.commitAsync();
|
|
125
|
+
spinner.update('Installed');
|
|
126
|
+
spinner.stop();
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
spinner.update('Unable to install packages');
|
|
130
|
+
spinner.stop();
|
|
131
|
+
sink_1.logger.fatal(error);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Configure a give package
|
|
136
|
+
*/
|
|
137
|
+
async configurePackage(name) {
|
|
138
|
+
if (name === 'encore') {
|
|
88
139
|
await this.configureEncore();
|
|
89
140
|
return;
|
|
90
141
|
}
|
|
91
|
-
|
|
92
|
-
|
|
142
|
+
if (name === 'tests') {
|
|
143
|
+
await this.configureTests();
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
await new sink_1.tasks.Instructions(name, this.application.appRoot, this.application, true).execute();
|
|
93
147
|
await new Manifest_1.Manifest(this.application.appRoot, this.logger).generate();
|
|
94
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Invoked automatically by ace
|
|
151
|
+
*/
|
|
152
|
+
async run() {
|
|
153
|
+
for (let name of this.packages) {
|
|
154
|
+
await this.configurePackage(name);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
95
157
|
}
|
|
96
158
|
Configure.commandName = 'configure';
|
|
97
|
-
Configure.description = 'Configure
|
|
159
|
+
Configure.description = 'Configure one or more AdonisJS packages';
|
|
98
160
|
Configure.aliases = ['invoke'];
|
|
99
161
|
__decorate([
|
|
100
|
-
standalone_1.args.
|
|
101
|
-
description: 'Name of the package you want to configure',
|
|
162
|
+
standalone_1.args.spread({
|
|
163
|
+
description: 'Name of the package(s) you want to configure',
|
|
102
164
|
}),
|
|
103
|
-
__metadata("design:type",
|
|
104
|
-
], Configure.prototype, "
|
|
165
|
+
__metadata("design:type", Array)
|
|
166
|
+
], Configure.prototype, "packages", void 0);
|
|
105
167
|
exports.default = Configure;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BaseGenerator } from './Base';
|
|
2
|
+
/**
|
|
3
|
+
* Command to make a new test
|
|
4
|
+
*/
|
|
5
|
+
export default class MakeTest extends BaseGenerator {
|
|
6
|
+
/**
|
|
7
|
+
* Required by BaseGenerator
|
|
8
|
+
*/
|
|
9
|
+
protected extname: string;
|
|
10
|
+
protected form: "singular";
|
|
11
|
+
protected pattern: "snakecase";
|
|
12
|
+
protected resourceName: string;
|
|
13
|
+
protected createExact: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Command meta data
|
|
16
|
+
*/
|
|
17
|
+
static commandName: string;
|
|
18
|
+
static description: string;
|
|
19
|
+
suite: string;
|
|
20
|
+
name: string;
|
|
21
|
+
exact: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the template stub path
|
|
24
|
+
*/
|
|
25
|
+
protected getStub(): string;
|
|
26
|
+
/**
|
|
27
|
+
* The file is created inside the parent directory of the first
|
|
28
|
+
* glob pattern
|
|
29
|
+
*/
|
|
30
|
+
protected getDestinationPath(): string;
|
|
31
|
+
protected templateData(): {
|
|
32
|
+
name: string;
|
|
33
|
+
};
|
|
34
|
+
run(): Promise<void>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
11
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
13
|
+
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;
|
|
14
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
15
|
+
};
|
|
16
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
17
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
18
|
+
};
|
|
19
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
20
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
const path_1 = require("path");
|
|
24
|
+
const glob_parent_1 = __importDefault(require("glob-parent"));
|
|
25
|
+
const helpers_1 = require("@poppinss/utils/build/helpers");
|
|
26
|
+
const standalone_1 = require("@adonisjs/core/build/standalone");
|
|
27
|
+
const Base_1 = require("./Base");
|
|
28
|
+
/**
|
|
29
|
+
* Command to make a new test
|
|
30
|
+
*/
|
|
31
|
+
class MakeTest extends Base_1.BaseGenerator {
|
|
32
|
+
constructor() {
|
|
33
|
+
super(...arguments);
|
|
34
|
+
/**
|
|
35
|
+
* Required by BaseGenerator
|
|
36
|
+
*/
|
|
37
|
+
this.extname = '.spec.ts';
|
|
38
|
+
this.form = 'singular';
|
|
39
|
+
this.pattern = 'snakecase';
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns the template stub path
|
|
43
|
+
*/
|
|
44
|
+
getStub() {
|
|
45
|
+
return (0, path_1.join)(__dirname, '..', '..', 'templates', 'test.txt');
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The file is created inside the parent directory of the first
|
|
49
|
+
* glob pattern
|
|
50
|
+
*/
|
|
51
|
+
getDestinationPath() {
|
|
52
|
+
const testSuites = this.application.rcFile.tests.suites;
|
|
53
|
+
const mentionedSuite = testSuites.find(({ name }) => this.suite === name);
|
|
54
|
+
const suiteGlob = Array.isArray(mentionedSuite.files)
|
|
55
|
+
? mentionedSuite.files[0]
|
|
56
|
+
: mentionedSuite.files;
|
|
57
|
+
return (0, glob_parent_1.default)(suiteGlob);
|
|
58
|
+
}
|
|
59
|
+
templateData() {
|
|
60
|
+
return {
|
|
61
|
+
name: helpers_1.string.sentenceCase(this.name),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async run() {
|
|
65
|
+
const testSuites = this.application.rcFile.tests.suites;
|
|
66
|
+
const mentionedSuite = testSuites.find(({ name }) => this.suite === name);
|
|
67
|
+
if (!mentionedSuite) {
|
|
68
|
+
this.logger.error(`Invalid suite "${this.suite}". Make sure the suite is registered inside the .adonisrc.json file`);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.resourceName = this.name;
|
|
72
|
+
this.createExact = this.exact;
|
|
73
|
+
await super.generate();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Command meta data
|
|
78
|
+
*/
|
|
79
|
+
MakeTest.commandName = 'make:test';
|
|
80
|
+
MakeTest.description = 'Make a new test';
|
|
81
|
+
__decorate([
|
|
82
|
+
standalone_1.args.string({ description: 'Name of the test suite' }),
|
|
83
|
+
__metadata("design:type", String)
|
|
84
|
+
], MakeTest.prototype, "suite", void 0);
|
|
85
|
+
__decorate([
|
|
86
|
+
standalone_1.args.string({ description: 'Name of the test file' }),
|
|
87
|
+
__metadata("design:type", String)
|
|
88
|
+
], MakeTest.prototype, "name", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
standalone_1.flags.boolean({
|
|
91
|
+
description: 'Create the test file with the exact name as provided',
|
|
92
|
+
alias: 'e',
|
|
93
|
+
}),
|
|
94
|
+
__metadata("design:type", Boolean)
|
|
95
|
+
], MakeTest.prototype, "exact", void 0);
|
|
96
|
+
exports.default = MakeTest;
|
package/build/commands/Test.d.ts
CHANGED
|
@@ -8,6 +8,11 @@ export default class Test extends BaseCommand {
|
|
|
8
8
|
static settings: {
|
|
9
9
|
stayAlive: boolean;
|
|
10
10
|
};
|
|
11
|
+
suites: string[];
|
|
12
|
+
/**
|
|
13
|
+
* Allows watching for file changes
|
|
14
|
+
*/
|
|
15
|
+
files: string[];
|
|
11
16
|
/**
|
|
12
17
|
* Allows watching for file changes
|
|
13
18
|
*/
|
|
@@ -20,12 +25,21 @@ export default class Test extends BaseCommand {
|
|
|
20
25
|
* Arguments to pass to the `node` binary
|
|
21
26
|
*/
|
|
22
27
|
nodeArgs: string[];
|
|
28
|
+
/**
|
|
29
|
+
* Filter by tags
|
|
30
|
+
*/
|
|
23
31
|
tags: string[];
|
|
32
|
+
/**
|
|
33
|
+
* Filter by tags
|
|
34
|
+
*/
|
|
24
35
|
ignoreTags: string[];
|
|
36
|
+
/**
|
|
37
|
+
* Customize tests timeout
|
|
38
|
+
*/
|
|
25
39
|
timeout: number;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Force exit the tests runner
|
|
42
|
+
*/
|
|
29
43
|
forceExit: boolean;
|
|
30
44
|
/**
|
|
31
45
|
* Convert command flags to test filters
|
package/build/commands/Test.js
CHANGED
|
@@ -60,21 +60,18 @@ class Test extends standalone_1.BaseCommand {
|
|
|
60
60
|
if (this.forceExit) {
|
|
61
61
|
filters['--force-exit'] = true;
|
|
62
62
|
}
|
|
63
|
+
if (this.files) {
|
|
64
|
+
filters['--files'] = this.files;
|
|
65
|
+
}
|
|
63
66
|
if (this.timeout !== undefined) {
|
|
64
67
|
filters['--timeout'] = this.timeout;
|
|
65
68
|
}
|
|
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
69
|
if (this.tags) {
|
|
76
70
|
filters['--tags'] = this.tags;
|
|
77
71
|
}
|
|
72
|
+
if (this.suites) {
|
|
73
|
+
filters._ = this.suites;
|
|
74
|
+
}
|
|
78
75
|
if (this.ignoreTags) {
|
|
79
76
|
filters['--ignore-tags'] = this.ignoreTags;
|
|
80
77
|
}
|
|
@@ -101,6 +98,16 @@ Test.description = 'Run AdonisJS tests';
|
|
|
101
98
|
Test.settings = {
|
|
102
99
|
stayAlive: true,
|
|
103
100
|
};
|
|
101
|
+
__decorate([
|
|
102
|
+
standalone_1.args.spread({ description: 'Run tests for only the specified suites', required: false }),
|
|
103
|
+
__metadata("design:type", Array)
|
|
104
|
+
], Test.prototype, "suites", void 0);
|
|
105
|
+
__decorate([
|
|
106
|
+
standalone_1.flags.array({
|
|
107
|
+
description: 'Run tests for the mentioned files only',
|
|
108
|
+
}),
|
|
109
|
+
__metadata("design:type", Array)
|
|
110
|
+
], Test.prototype, "files", void 0);
|
|
104
111
|
__decorate([
|
|
105
112
|
standalone_1.flags.boolean({
|
|
106
113
|
description: 'Watch for file changes and re-run tests on file change',
|
|
@@ -120,29 +127,17 @@ __decorate([
|
|
|
120
127
|
__metadata("design:type", Array)
|
|
121
128
|
], Test.prototype, "nodeArgs", void 0);
|
|
122
129
|
__decorate([
|
|
123
|
-
standalone_1.flags.array({ description: '
|
|
130
|
+
standalone_1.flags.array({ description: 'Filter tests by tags' }),
|
|
124
131
|
__metadata("design:type", Array)
|
|
125
132
|
], Test.prototype, "tags", void 0);
|
|
126
133
|
__decorate([
|
|
127
|
-
standalone_1.flags.array({ description: '
|
|
134
|
+
standalone_1.flags.array({ description: 'Filter tests by ignoring tags' }),
|
|
128
135
|
__metadata("design:type", Array)
|
|
129
136
|
], Test.prototype, "ignoreTags", void 0);
|
|
130
137
|
__decorate([
|
|
131
|
-
standalone_1.flags.number({ description: '
|
|
138
|
+
standalone_1.flags.number({ description: 'Customize tests timeout' }),
|
|
132
139
|
__metadata("design:type", Number)
|
|
133
140
|
], 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
141
|
__decorate([
|
|
147
142
|
standalone_1.flags.boolean({ description: 'Force exit the tests runner process' }),
|
|
148
143
|
__metadata("design:type", Boolean)
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
export declare type JapaFlags = Partial<{
|
|
2
|
-
'
|
|
2
|
+
'_': string[];
|
|
3
3
|
'--tags': string[];
|
|
4
|
-
'--groups': string[];
|
|
5
4
|
'--ignore-tags': string[];
|
|
6
5
|
'--files': string[];
|
|
7
6
|
'--timeout': number;
|
|
8
|
-
'--suites': string[];
|
|
9
7
|
'--force-exit': boolean;
|
|
10
8
|
}>;
|
package/build/src/Test/index.js
CHANGED
|
@@ -253,9 +253,7 @@ class TestsServer {
|
|
|
253
253
|
return;
|
|
254
254
|
}
|
|
255
255
|
this.logger.action('create').succeeded(relativePath);
|
|
256
|
-
|
|
257
|
-
await this.run();
|
|
258
|
-
}
|
|
256
|
+
await this.run();
|
|
259
257
|
});
|
|
260
258
|
/**
|
|
261
259
|
* File changed
|
|
@@ -274,9 +272,7 @@ class TestsServer {
|
|
|
274
272
|
return;
|
|
275
273
|
}
|
|
276
274
|
this.logger.action('update').succeeded(relativePath);
|
|
277
|
-
|
|
278
|
-
await this.run();
|
|
279
|
-
}
|
|
275
|
+
await this.run();
|
|
280
276
|
});
|
|
281
277
|
/**
|
|
282
278
|
* File removed
|
|
@@ -301,9 +297,7 @@ class TestsServer {
|
|
|
301
297
|
return;
|
|
302
298
|
}
|
|
303
299
|
this.logger.action('delete').succeeded(relativePath);
|
|
304
|
-
|
|
305
|
-
await this.run();
|
|
306
|
-
}
|
|
300
|
+
await this.run();
|
|
307
301
|
});
|
|
308
302
|
/**
|
|
309
303
|
* Start the watcher
|
|
@@ -35,7 +35,9 @@ class TestProcess {
|
|
|
35
35
|
this.logger.info('running tests...');
|
|
36
36
|
const filters = Object.keys(this.filters).reduce((result, filter) => {
|
|
37
37
|
const value = this.filters[filter];
|
|
38
|
-
|
|
38
|
+
if (filter !== '_') {
|
|
39
|
+
result.push(filter);
|
|
40
|
+
}
|
|
39
41
|
if (Array.isArray(value)) {
|
|
40
42
|
result.push(...value);
|
|
41
43
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|--------------------------------------------------------------------------
|
|
3
|
+
| Tests
|
|
4
|
+
|--------------------------------------------------------------------------
|
|
5
|
+
|
|
|
6
|
+
| The contents in this file boots the AdonisJS application and configures
|
|
7
|
+
| the Japa tests runner.
|
|
8
|
+
|
|
|
9
|
+
| For the most part you will never edit this file. The configuration
|
|
10
|
+
| for the tests can be controlled via ".adonisrc.json" and
|
|
11
|
+
| "tests/bootstrap.ts" files.
|
|
12
|
+
|
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
process.env.NODE_ENV = 'testing'
|
|
16
|
+
|
|
17
|
+
import 'reflect-metadata'
|
|
18
|
+
import sourceMapSupport from 'source-map-support'
|
|
19
|
+
import { Ignitor } from '@adonisjs/core/build/standalone'
|
|
20
|
+
import { configure, processCliArgs, run, RunnerHooksHandler } from '@japa/runner'
|
|
21
|
+
|
|
22
|
+
sourceMapSupport.install({ handleUncaughtExceptions: false })
|
|
23
|
+
|
|
24
|
+
const kernel = new Ignitor(__dirname).kernel('test')
|
|
25
|
+
|
|
26
|
+
kernel
|
|
27
|
+
.boot()
|
|
28
|
+
.then(() => import('./tests/bootstrap'))
|
|
29
|
+
.then(({ runnerHooks, ...config }) => {
|
|
30
|
+
const app: RunnerHooksHandler[] = [() => kernel.start()]
|
|
31
|
+
|
|
32
|
+
configure({
|
|
33
|
+
...kernel.application.rcFile.tests,
|
|
34
|
+
...processCliArgs(process.argv.slice(2)),
|
|
35
|
+
...config,
|
|
36
|
+
...{
|
|
37
|
+
importer: (filePath) => import(filePath),
|
|
38
|
+
setup: app.concat(runnerHooks.setup),
|
|
39
|
+
teardown: runnerHooks.teardown,
|
|
40
|
+
},
|
|
41
|
+
cwd: kernel.application.appRoot
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
run()
|
|
45
|
+
})
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File source: https://bit.ly/3ukaHTz
|
|
3
|
+
*
|
|
4
|
+
* Feel free to let us know via PR, if you find something broken in this contract
|
|
5
|
+
* file.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { Config } from '@japa/runner'
|
|
9
|
+
import TestUtils from '@ioc:Adonis/Core/TestUtils'
|
|
10
|
+
import { assert, runFailedTests, specReporter, apiClient } from '@japa/preset-adonis'
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
|--------------------------------------------------------------------------
|
|
14
|
+
| Japa Plugins
|
|
15
|
+
|--------------------------------------------------------------------------
|
|
16
|
+
|
|
|
17
|
+
| Japa plugins allows you to add additional features to Japa. By default
|
|
18
|
+
| we register the assertion plugin.
|
|
19
|
+
|
|
|
20
|
+
| Feel free to remove existing plugins or add more.
|
|
21
|
+
|
|
|
22
|
+
*/
|
|
23
|
+
export const plugins: Config['plugins'] = [assert(), runFailedTests(), apiClient()]
|
|
24
|
+
|
|
25
|
+
/*
|
|
26
|
+
|--------------------------------------------------------------------------
|
|
27
|
+
| Japa Reporters
|
|
28
|
+
|--------------------------------------------------------------------------
|
|
29
|
+
|
|
|
30
|
+
| Japa reporters displays/saves the progress of tests as they are executed.
|
|
31
|
+
| By default, we register the spec reporter to show a detailed report
|
|
32
|
+
| of tests on the terminal.
|
|
33
|
+
|
|
|
34
|
+
*/
|
|
35
|
+
export const reporters: Config['reporters'] = [specReporter()]
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
|--------------------------------------------------------------------------
|
|
39
|
+
| Runner hooks
|
|
40
|
+
|--------------------------------------------------------------------------
|
|
41
|
+
|
|
|
42
|
+
| Runner hooks are executed after booting the AdonisJS app and
|
|
43
|
+
| before the test files are imported.
|
|
44
|
+
|
|
|
45
|
+
| You can perform actions like starting the HTTP server or running migrations
|
|
46
|
+
| within the runner hooks
|
|
47
|
+
|
|
|
48
|
+
*/
|
|
49
|
+
export const runnerHooks: Required<Pick<Config, 'setup' | 'teardown'>> = {
|
|
50
|
+
setup: [() => TestUtils.ace().loadCommands()],
|
|
51
|
+
teardown: [],
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/*
|
|
55
|
+
|--------------------------------------------------------------------------
|
|
56
|
+
| Configure individual suites
|
|
57
|
+
|--------------------------------------------------------------------------
|
|
58
|
+
|
|
|
59
|
+
| The configureSuite method gets called for every test suite registered
|
|
60
|
+
| within ".adonisrc.json" file.
|
|
61
|
+
|
|
|
62
|
+
| You can use this method to configure suites. For example: Only start
|
|
63
|
+
| the HTTP server when it is a functional suite.
|
|
64
|
+
*/
|
|
65
|
+
export const configureSuite: Config['configureSuite'] = (suite) => {
|
|
66
|
+
if (suite.name === 'functional') {
|
|
67
|
+
suite.setup(() => TestUtils.httpServer().start())
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract source: https://bit.ly/3DP1ypf
|
|
3
|
+
*
|
|
4
|
+
* Feel free to let us know via PR, if you find something broken in this contract
|
|
5
|
+
* file.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import '@japa/runner'
|
|
9
|
+
|
|
10
|
+
declare module '@japa/runner' {
|
|
11
|
+
interface TestContext {
|
|
12
|
+
// Extend context
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface Test<DataSet> {
|
|
16
|
+
// Extend test
|
|
17
|
+
}
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/assembler",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.3-0",
|
|
4
4
|
"description": "Core commands to compiler and build AdonisJs project",
|
|
5
5
|
"main": "build/ace-manifest.json",
|
|
6
6
|
"files": [
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"lint": "eslint . --ext=.ts",
|
|
20
20
|
"clean": "del build",
|
|
21
21
|
"compile": "npm run lint && npm run clean && tsc",
|
|
22
|
-
"build": "npm run compile && node build/bin/index.js && copyfiles \"templates
|
|
22
|
+
"build": "npm run compile && node build/bin/index.js && copyfiles \"templates/**\" build",
|
|
23
23
|
"commit": "git-cz",
|
|
24
24
|
"release": "np --message=\"chore(release): %s\"",
|
|
25
25
|
"version": "npm run build",
|
|
@@ -44,27 +44,27 @@
|
|
|
44
44
|
},
|
|
45
45
|
"homepage": "https://github.com/adonisjs/assembler#readme",
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@adonisjs/ace": "^11.2.
|
|
48
|
-
"@adonisjs/core": "^5.
|
|
49
|
-
"@adonisjs/mrm-preset": "^5.0.
|
|
50
|
-
"@poppinss/dev-utils": "^2.0.
|
|
51
|
-
"@types/node": "^17.0.
|
|
47
|
+
"@adonisjs/ace": "^11.2.3",
|
|
48
|
+
"@adonisjs/core": "^5.6.2",
|
|
49
|
+
"@adonisjs/mrm-preset": "^5.0.3",
|
|
50
|
+
"@poppinss/dev-utils": "^2.0.3",
|
|
51
|
+
"@types/node": "^17.0.23",
|
|
52
52
|
"commitizen": "^4.2.4",
|
|
53
53
|
"copyfiles": "^2.4.1",
|
|
54
54
|
"cross-env": "^7.0.3",
|
|
55
55
|
"cz-conventional-changelog": "^3.3.0",
|
|
56
56
|
"del-cli": "^4.0.1",
|
|
57
|
-
"eslint": "^8.
|
|
57
|
+
"eslint": "^8.12.0",
|
|
58
58
|
"eslint-config-prettier": "^8.5.0",
|
|
59
59
|
"eslint-plugin-adonis": "^2.1.0",
|
|
60
60
|
"eslint-plugin-prettier": "^4.0.0",
|
|
61
|
-
"github-label-sync": "^2.0
|
|
61
|
+
"github-label-sync": "^2.2.0",
|
|
62
62
|
"husky": "^7.0.4",
|
|
63
63
|
"japa": "^4.0.0",
|
|
64
|
-
"mrm": "^
|
|
65
|
-
"np": "^7.6.
|
|
66
|
-
"prettier": "^2.
|
|
67
|
-
"typescript": "^4.6.
|
|
64
|
+
"mrm": "^4.0.0",
|
|
65
|
+
"np": "^7.6.1",
|
|
66
|
+
"prettier": "^2.6.2",
|
|
67
|
+
"typescript": "^4.6.3"
|
|
68
68
|
},
|
|
69
69
|
"nyc": {
|
|
70
70
|
"exclude": [
|
|
@@ -89,19 +89,20 @@
|
|
|
89
89
|
"anyBranch": false
|
|
90
90
|
},
|
|
91
91
|
"dependencies": {
|
|
92
|
-
"@adonisjs/application": "^5.2.
|
|
93
|
-
"@adonisjs/env": "^3.0.
|
|
92
|
+
"@adonisjs/application": "^5.2.1",
|
|
93
|
+
"@adonisjs/env": "^3.0.8",
|
|
94
94
|
"@adonisjs/ioc-transformer": "^2.3.3",
|
|
95
|
-
"@adonisjs/require-ts": "^2.0.
|
|
95
|
+
"@adonisjs/require-ts": "^2.0.11",
|
|
96
96
|
"@adonisjs/sink": "^5.2.2",
|
|
97
|
-
"@poppinss/chokidar-ts": "^3.3.
|
|
98
|
-
"@poppinss/cliui": "^3.0.
|
|
99
|
-
"@poppinss/utils": "^4.0.
|
|
97
|
+
"@poppinss/chokidar-ts": "^3.3.5",
|
|
98
|
+
"@poppinss/cliui": "^3.0.2",
|
|
99
|
+
"@poppinss/utils": "^4.0.3",
|
|
100
100
|
"cpy": "^8.1.2",
|
|
101
|
-
"emittery": "^0.10.
|
|
101
|
+
"emittery": "^0.10.2",
|
|
102
102
|
"execa": "^5.1.1",
|
|
103
103
|
"fs-extra": "^10.0.1",
|
|
104
104
|
"get-port": "^5.1.1",
|
|
105
|
+
"glob-parent": "^6.0.2",
|
|
105
106
|
"has-yarn": "^2.1.0",
|
|
106
107
|
"picomatch": "^2.3.1",
|
|
107
108
|
"slash": "^3.0.0"
|