@adonisjs/assembler 5.4.2 → 5.5.2-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 +107 -5
- 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 +49 -0
- package/build/commands/Test.js +145 -0
- package/build/config/paths.d.ts +1 -0
- package/build/config/paths.js +2 -1
- package/build/src/Contracts/index.d.ts +8 -0
- package/build/src/Contracts/index.js +10 -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 +317 -0
- package/build/src/Test/process.d.ts +22 -0
- package/build/src/Test/process.js +66 -0
- package/build/templates/test-entrypoint.txt +45 -0
- package/build/templates/test.txt +5 -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",
|
|
@@ -353,6 +385,76 @@
|
|
|
353
385
|
}
|
|
354
386
|
]
|
|
355
387
|
},
|
|
388
|
+
"test": {
|
|
389
|
+
"settings": {
|
|
390
|
+
"stayAlive": true
|
|
391
|
+
},
|
|
392
|
+
"commandPath": "./commands/Test",
|
|
393
|
+
"commandName": "test",
|
|
394
|
+
"description": "Run AdonisJS tests",
|
|
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
|
+
],
|
|
404
|
+
"aliases": [],
|
|
405
|
+
"flags": [
|
|
406
|
+
{
|
|
407
|
+
"name": "files",
|
|
408
|
+
"propertyName": "files",
|
|
409
|
+
"type": "array",
|
|
410
|
+
"description": "Run tests for the mentioned files only"
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
"name": "watch",
|
|
414
|
+
"propertyName": "watch",
|
|
415
|
+
"type": "boolean",
|
|
416
|
+
"description": "Watch for file changes and re-run tests on file change",
|
|
417
|
+
"alias": "w"
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
"name": "poll",
|
|
421
|
+
"propertyName": "poll",
|
|
422
|
+
"type": "boolean",
|
|
423
|
+
"description": "Detect file changes by polling files instead of listening to filesystem events",
|
|
424
|
+
"alias": "p"
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
"name": "node-args",
|
|
428
|
+
"propertyName": "nodeArgs",
|
|
429
|
+
"type": "array",
|
|
430
|
+
"description": "CLI options to pass to the node command line"
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
"name": "tags",
|
|
434
|
+
"propertyName": "tags",
|
|
435
|
+
"type": "array",
|
|
436
|
+
"description": "Filter tests by tags"
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
"name": "ignore-tags",
|
|
440
|
+
"propertyName": "ignoreTags",
|
|
441
|
+
"type": "array",
|
|
442
|
+
"description": "Filter tests by ignoring tags"
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
"name": "timeout",
|
|
446
|
+
"propertyName": "timeout",
|
|
447
|
+
"type": "number",
|
|
448
|
+
"description": "Customize tests timeout"
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
"name": "force-exit",
|
|
452
|
+
"propertyName": "forceExit",
|
|
453
|
+
"type": "boolean",
|
|
454
|
+
"description": "Force exit the tests runner process"
|
|
455
|
+
}
|
|
456
|
+
]
|
|
457
|
+
},
|
|
356
458
|
"type-check": {
|
|
357
459
|
"settings": {},
|
|
358
460
|
"commandPath": "./commands/TypeCheck",
|
|
@@ -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;
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
suites: string[];
|
|
12
|
+
/**
|
|
13
|
+
* Allows watching for file changes
|
|
14
|
+
*/
|
|
15
|
+
files: string[];
|
|
16
|
+
/**
|
|
17
|
+
* Allows watching for file changes
|
|
18
|
+
*/
|
|
19
|
+
watch: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Detect changes by polling files
|
|
22
|
+
*/
|
|
23
|
+
poll: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Arguments to pass to the `node` binary
|
|
26
|
+
*/
|
|
27
|
+
nodeArgs: string[];
|
|
28
|
+
/**
|
|
29
|
+
* Filter by tags
|
|
30
|
+
*/
|
|
31
|
+
tags: string[];
|
|
32
|
+
/**
|
|
33
|
+
* Filter by tags
|
|
34
|
+
*/
|
|
35
|
+
ignoreTags: string[];
|
|
36
|
+
/**
|
|
37
|
+
* Customize tests timeout
|
|
38
|
+
*/
|
|
39
|
+
timeout: number;
|
|
40
|
+
/**
|
|
41
|
+
* Force exit the tests runner
|
|
42
|
+
*/
|
|
43
|
+
forceExit: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Convert command flags to test filters
|
|
46
|
+
*/
|
|
47
|
+
private getTestFilters;
|
|
48
|
+
run(): Promise<void>;
|
|
49
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
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.files) {
|
|
64
|
+
filters['--files'] = this.files;
|
|
65
|
+
}
|
|
66
|
+
if (this.timeout !== undefined) {
|
|
67
|
+
filters['--timeout'] = this.timeout;
|
|
68
|
+
}
|
|
69
|
+
if (this.tags) {
|
|
70
|
+
filters['--tags'] = this.tags;
|
|
71
|
+
}
|
|
72
|
+
if (this.suites) {
|
|
73
|
+
filters._ = this.suites;
|
|
74
|
+
}
|
|
75
|
+
if (this.ignoreTags) {
|
|
76
|
+
filters['--ignore-tags'] = this.ignoreTags;
|
|
77
|
+
}
|
|
78
|
+
return filters;
|
|
79
|
+
}
|
|
80
|
+
async run() {
|
|
81
|
+
const { TestsServer } = await Promise.resolve().then(() => __importStar(require('../src/Test')));
|
|
82
|
+
try {
|
|
83
|
+
if (this.watch) {
|
|
84
|
+
await new TestsServer(this.application.appRoot, this.getTestFilters(), this.nodeArgs, this.logger).watch();
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
await new TestsServer(this.application.appRoot, this.getTestFilters(), this.nodeArgs, this.logger).run();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
this.exitCode = 1;
|
|
92
|
+
this.logger.fatal(error);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
Test.commandName = 'test';
|
|
97
|
+
Test.description = 'Run AdonisJS tests';
|
|
98
|
+
Test.settings = {
|
|
99
|
+
stayAlive: true,
|
|
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);
|
|
111
|
+
__decorate([
|
|
112
|
+
standalone_1.flags.boolean({
|
|
113
|
+
description: 'Watch for file changes and re-run tests on file change',
|
|
114
|
+
alias: 'w',
|
|
115
|
+
}),
|
|
116
|
+
__metadata("design:type", Boolean)
|
|
117
|
+
], Test.prototype, "watch", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
standalone_1.flags.boolean({
|
|
120
|
+
description: 'Detect file changes by polling files instead of listening to filesystem events',
|
|
121
|
+
alias: 'p',
|
|
122
|
+
}),
|
|
123
|
+
__metadata("design:type", Boolean)
|
|
124
|
+
], Test.prototype, "poll", void 0);
|
|
125
|
+
__decorate([
|
|
126
|
+
standalone_1.flags.array({ description: 'CLI options to pass to the node command line' }),
|
|
127
|
+
__metadata("design:type", Array)
|
|
128
|
+
], Test.prototype, "nodeArgs", void 0);
|
|
129
|
+
__decorate([
|
|
130
|
+
standalone_1.flags.array({ description: 'Filter tests by tags' }),
|
|
131
|
+
__metadata("design:type", Array)
|
|
132
|
+
], Test.prototype, "tags", void 0);
|
|
133
|
+
__decorate([
|
|
134
|
+
standalone_1.flags.array({ description: 'Filter tests by ignoring tags' }),
|
|
135
|
+
__metadata("design:type", Array)
|
|
136
|
+
], Test.prototype, "ignoreTags", void 0);
|
|
137
|
+
__decorate([
|
|
138
|
+
standalone_1.flags.number({ description: 'Customize tests timeout' }),
|
|
139
|
+
__metadata("design:type", Number)
|
|
140
|
+
], Test.prototype, "timeout", void 0);
|
|
141
|
+
__decorate([
|
|
142
|
+
standalone_1.flags.boolean({ description: 'Force exit the tests runner process' }),
|
|
143
|
+
__metadata("design:type", Boolean)
|
|
144
|
+
], Test.prototype, "forceExit", void 0);
|
|
145
|
+
exports.default = Test;
|