@adonisjs/assembler 5.9.2 → 5.9.4
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/commands/Build.d.ts +37 -37
- package/build/commands/Build.js +138 -138
- package/build/commands/Invoke.d.ts +34 -34
- package/build/commands/Invoke.js +234 -221
- package/build/commands/Make/Base.d.ts +30 -30
- package/build/commands/Make/Base.js +75 -75
- package/build/commands/Make/Command.d.ts +35 -35
- package/build/commands/Make/Command.js +82 -82
- package/build/commands/Make/Controller.d.ts +37 -37
- package/build/commands/Make/Controller.js +89 -89
- package/build/commands/Make/Exception.d.ts +32 -32
- package/build/commands/Make/Exception.js +75 -75
- package/build/commands/Make/Listener.d.ts +30 -30
- package/build/commands/Make/Listener.js +70 -70
- package/build/commands/Make/Middleware.d.ts +31 -31
- package/build/commands/Make/Middleware.js +87 -87
- package/build/commands/Make/PreloadFile.d.ts +38 -38
- package/build/commands/Make/PreloadFile.js +157 -157
- package/build/commands/Make/Provider.d.ts +31 -31
- package/build/commands/Make/Provider.js +114 -114
- package/build/commands/Make/Suite.d.ts +41 -41
- package/build/commands/Make/Suite.js +120 -120
- package/build/commands/Make/Test.d.ts +35 -35
- package/build/commands/Make/Test.js +96 -96
- package/build/commands/Make/Validator.d.ts +31 -31
- package/build/commands/Make/Validator.js +71 -71
- package/build/commands/Make/View.d.ts +30 -30
- package/build/commands/Make/View.js +70 -70
- package/build/commands/Serve.d.ts +33 -33
- package/build/commands/Serve.js +112 -112
- package/build/commands/Test.d.ts +57 -57
- package/build/commands/Test.js +159 -159
- package/build/commands/TypeCheck.d.ts +16 -16
- package/build/commands/TypeCheck.js +85 -85
- package/build/config/paths.d.ts +7 -7
- package/build/config/paths.js +18 -18
- package/build/register.d.ts +1 -1
- package/build/register.js +15 -15
- package/build/src/AssetsBundler/index.d.ts +76 -76
- package/build/src/AssetsBundler/index.js +216 -216
- package/build/src/Compiler/index.d.ts +62 -62
- package/build/src/Compiler/index.js +287 -287
- package/build/src/Contracts/index.d.ts +8 -8
- package/build/src/Contracts/index.js +10 -10
- package/build/src/DevServer/index.d.ts +70 -70
- package/build/src/DevServer/index.js +306 -306
- package/build/src/EnvParser/index.d.ts +21 -23
- package/build/src/EnvParser/index.js +48 -52
- package/build/src/HttpServer/index.d.ts +34 -34
- package/build/src/HttpServer/index.js +87 -87
- package/build/src/Manifest/index.d.ts +32 -32
- package/build/src/Manifest/index.js +88 -88
- package/build/src/RcFile/index.d.ts +72 -72
- package/build/src/RcFile/index.js +174 -174
- package/build/src/Test/index.d.ts +75 -75
- package/build/src/Test/index.js +346 -346
- package/build/src/Test/process.d.ts +22 -22
- package/build/src/Test/process.js +68 -68
- package/build/src/Ts/index.d.ts +24 -24
- package/build/src/Ts/index.js +55 -55
- package/build/src/requireHook/index.d.ts +5 -5
- package/build/src/requireHook/index.js +28 -28
- package/build/src/requireHook/ioc-transformer.d.ts +6 -6
- package/build/src/requireHook/ioc-transformer.js +21 -21
- package/build/templates/tests/bootstrap.txt +4 -4
- package/package.json +11 -11
|
@@ -1,114 +1,114 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
43
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
44
|
-
};
|
|
45
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
-
const slash_1 = __importDefault(require("slash"));
|
|
47
|
-
const path_1 = require("path");
|
|
48
|
-
const standalone_1 = require("@adonisjs/core/build/standalone");
|
|
49
|
-
const Base_1 = require("./Base");
|
|
50
|
-
/**
|
|
51
|
-
* Command to make a new provider
|
|
52
|
-
*/
|
|
53
|
-
class MakeProvider extends Base_1.BaseGenerator {
|
|
54
|
-
constructor() {
|
|
55
|
-
super(...arguments);
|
|
56
|
-
/**
|
|
57
|
-
* Required by BaseGenerator
|
|
58
|
-
*/
|
|
59
|
-
this.suffix = 'Provider';
|
|
60
|
-
this.form = 'singular';
|
|
61
|
-
this.pattern = 'pascalcase';
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Returns the template stub path
|
|
65
|
-
*/
|
|
66
|
-
getStub() {
|
|
67
|
-
return (0, path_1.join)(__dirname, '..', '..', 'templates', 'provider.txt');
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Path to the providers directory
|
|
71
|
-
*/
|
|
72
|
-
getDestinationPath() {
|
|
73
|
-
return this.application.rcFile.directories.providers || 'providers';
|
|
74
|
-
}
|
|
75
|
-
async run() {
|
|
76
|
-
this.resourceName = this.name;
|
|
77
|
-
this.createExact = this.exact;
|
|
78
|
-
const file = await super.generate();
|
|
79
|
-
if (!file) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
const { files } = await Promise.resolve().then(() => __importStar(require('@adonisjs/sink')));
|
|
83
|
-
const relativePath = file.toJSON().relativepath;
|
|
84
|
-
const rcFile = new files.AdonisRcFile(this.application.appRoot);
|
|
85
|
-
if (this.ace) {
|
|
86
|
-
rcFile.addAceProvider(`./${(0, slash_1.default)(relativePath).replace((0, path_1.extname)(relativePath), '')}`);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
rcFile.addProvider(`./${(0, slash_1.default)(relativePath).replace((0, path_1.extname)(relativePath), '')}`);
|
|
90
|
-
}
|
|
91
|
-
rcFile.commit();
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Command meta data
|
|
96
|
-
*/
|
|
97
|
-
MakeProvider.commandName = 'make:provider';
|
|
98
|
-
MakeProvider.description = 'Make a new provider class';
|
|
99
|
-
__decorate([
|
|
100
|
-
standalone_1.args.string({ description: 'Name of the provider class' }),
|
|
101
|
-
__metadata("design:type", String)
|
|
102
|
-
], MakeProvider.prototype, "name", void 0);
|
|
103
|
-
__decorate([
|
|
104
|
-
standalone_1.flags.boolean({ description: 'Register provider under the ace providers array' }),
|
|
105
|
-
__metadata("design:type", Boolean)
|
|
106
|
-
], MakeProvider.prototype, "ace", void 0);
|
|
107
|
-
__decorate([
|
|
108
|
-
standalone_1.flags.boolean({
|
|
109
|
-
description: 'Create the provider with the exact name as provided',
|
|
110
|
-
alias: 'e',
|
|
111
|
-
}),
|
|
112
|
-
__metadata("design:type", Boolean)
|
|
113
|
-
], MakeProvider.prototype, "exact", void 0);
|
|
114
|
-
exports.default = MakeProvider;
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
43
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
const slash_1 = __importDefault(require("slash"));
|
|
47
|
+
const path_1 = require("path");
|
|
48
|
+
const standalone_1 = require("@adonisjs/core/build/standalone");
|
|
49
|
+
const Base_1 = require("./Base");
|
|
50
|
+
/**
|
|
51
|
+
* Command to make a new provider
|
|
52
|
+
*/
|
|
53
|
+
class MakeProvider extends Base_1.BaseGenerator {
|
|
54
|
+
constructor() {
|
|
55
|
+
super(...arguments);
|
|
56
|
+
/**
|
|
57
|
+
* Required by BaseGenerator
|
|
58
|
+
*/
|
|
59
|
+
this.suffix = 'Provider';
|
|
60
|
+
this.form = 'singular';
|
|
61
|
+
this.pattern = 'pascalcase';
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Returns the template stub path
|
|
65
|
+
*/
|
|
66
|
+
getStub() {
|
|
67
|
+
return (0, path_1.join)(__dirname, '..', '..', 'templates', 'provider.txt');
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Path to the providers directory
|
|
71
|
+
*/
|
|
72
|
+
getDestinationPath() {
|
|
73
|
+
return this.application.rcFile.directories.providers || 'providers';
|
|
74
|
+
}
|
|
75
|
+
async run() {
|
|
76
|
+
this.resourceName = this.name;
|
|
77
|
+
this.createExact = this.exact;
|
|
78
|
+
const file = await super.generate();
|
|
79
|
+
if (!file) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const { files } = await Promise.resolve().then(() => __importStar(require('@adonisjs/sink')));
|
|
83
|
+
const relativePath = file.toJSON().relativepath;
|
|
84
|
+
const rcFile = new files.AdonisRcFile(this.application.appRoot);
|
|
85
|
+
if (this.ace) {
|
|
86
|
+
rcFile.addAceProvider(`./${(0, slash_1.default)(relativePath).replace((0, path_1.extname)(relativePath), '')}`);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
rcFile.addProvider(`./${(0, slash_1.default)(relativePath).replace((0, path_1.extname)(relativePath), '')}`);
|
|
90
|
+
}
|
|
91
|
+
rcFile.commit();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Command meta data
|
|
96
|
+
*/
|
|
97
|
+
MakeProvider.commandName = 'make:provider';
|
|
98
|
+
MakeProvider.description = 'Make a new provider class';
|
|
99
|
+
__decorate([
|
|
100
|
+
standalone_1.args.string({ description: 'Name of the provider class' }),
|
|
101
|
+
__metadata("design:type", String)
|
|
102
|
+
], MakeProvider.prototype, "name", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
standalone_1.flags.boolean({ description: 'Register provider under the ace providers array' }),
|
|
105
|
+
__metadata("design:type", Boolean)
|
|
106
|
+
], MakeProvider.prototype, "ace", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
standalone_1.flags.boolean({
|
|
109
|
+
description: 'Create the provider with the exact name as provided',
|
|
110
|
+
alias: 'e',
|
|
111
|
+
}),
|
|
112
|
+
__metadata("design:type", Boolean)
|
|
113
|
+
], MakeProvider.prototype, "exact", void 0);
|
|
114
|
+
exports.default = MakeProvider;
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { BaseCommand } from '@adonisjs/core/build/standalone';
|
|
2
|
-
/**
|
|
3
|
-
* Create a new test suite
|
|
4
|
-
*/
|
|
5
|
-
export default class CreateSuite extends BaseCommand {
|
|
6
|
-
static commandName: string;
|
|
7
|
-
static description: string;
|
|
8
|
-
/**
|
|
9
|
-
* Name of the test suite to be created
|
|
10
|
-
*/
|
|
11
|
-
suite: string;
|
|
12
|
-
/**
|
|
13
|
-
* Glob pattern for the test suite, or only location to the test suite
|
|
14
|
-
*/
|
|
15
|
-
location: string;
|
|
16
|
-
/**
|
|
17
|
-
* Should add a sample test file
|
|
18
|
-
*/
|
|
19
|
-
withExampleTest: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Get the destination path for the sample test file
|
|
22
|
-
*/
|
|
23
|
-
private getExampleTestDestinationPath;
|
|
24
|
-
/**
|
|
25
|
-
* Generate suite glob pattern based on `location` argument
|
|
26
|
-
*/
|
|
27
|
-
private generateSuiteGlobPattern;
|
|
28
|
-
/**
|
|
29
|
-
* Check if the suite name is already defined in RcFile
|
|
30
|
-
*/
|
|
31
|
-
private checkIfSuiteExists;
|
|
32
|
-
/**
|
|
33
|
-
* Add the new test suite to the AdonisRC File and save it
|
|
34
|
-
*/
|
|
35
|
-
private addSuiteToRcFile;
|
|
36
|
-
/**
|
|
37
|
-
* Add a sample test file to the new suite folder
|
|
38
|
-
*/
|
|
39
|
-
private createSampleTestFile;
|
|
40
|
-
run(): Promise<void>;
|
|
41
|
-
}
|
|
1
|
+
import { BaseCommand } from '@adonisjs/core/build/standalone';
|
|
2
|
+
/**
|
|
3
|
+
* Create a new test suite
|
|
4
|
+
*/
|
|
5
|
+
export default class CreateSuite extends BaseCommand {
|
|
6
|
+
static commandName: string;
|
|
7
|
+
static description: string;
|
|
8
|
+
/**
|
|
9
|
+
* Name of the test suite to be created
|
|
10
|
+
*/
|
|
11
|
+
suite: string;
|
|
12
|
+
/**
|
|
13
|
+
* Glob pattern for the test suite, or only location to the test suite
|
|
14
|
+
*/
|
|
15
|
+
location: string;
|
|
16
|
+
/**
|
|
17
|
+
* Should add a sample test file
|
|
18
|
+
*/
|
|
19
|
+
withExampleTest: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Get the destination path for the sample test file
|
|
22
|
+
*/
|
|
23
|
+
private getExampleTestDestinationPath;
|
|
24
|
+
/**
|
|
25
|
+
* Generate suite glob pattern based on `location` argument
|
|
26
|
+
*/
|
|
27
|
+
private generateSuiteGlobPattern;
|
|
28
|
+
/**
|
|
29
|
+
* Check if the suite name is already defined in RcFile
|
|
30
|
+
*/
|
|
31
|
+
private checkIfSuiteExists;
|
|
32
|
+
/**
|
|
33
|
+
* Add the new test suite to the AdonisRC File and save it
|
|
34
|
+
*/
|
|
35
|
+
private addSuiteToRcFile;
|
|
36
|
+
/**
|
|
37
|
+
* Add a sample test file to the new suite folder
|
|
38
|
+
*/
|
|
39
|
+
private createSampleTestFile;
|
|
40
|
+
run(): Promise<void>;
|
|
41
|
+
}
|
|
@@ -1,120 +1,120 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* @adonisjs/assembler
|
|
4
|
-
*
|
|
5
|
-
* (c) AdonisJS
|
|
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 standalone_1 = require("@adonisjs/core/build/standalone");
|
|
24
|
-
const sink_1 = require("@adonisjs/sink");
|
|
25
|
-
const glob_parent_1 = __importDefault(require("glob-parent"));
|
|
26
|
-
const path_1 = require("path");
|
|
27
|
-
/**
|
|
28
|
-
* Create a new test suite
|
|
29
|
-
*/
|
|
30
|
-
class CreateSuite extends standalone_1.BaseCommand {
|
|
31
|
-
constructor() {
|
|
32
|
-
super(...arguments);
|
|
33
|
-
/**
|
|
34
|
-
* Glob pattern for the test suite, or only location to the test suite
|
|
35
|
-
*/
|
|
36
|
-
this.location = '';
|
|
37
|
-
/**
|
|
38
|
-
* Should add a sample test file
|
|
39
|
-
*/
|
|
40
|
-
this.withExampleTest = true;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Get the destination path for the sample test file
|
|
44
|
-
*/
|
|
45
|
-
getExampleTestDestinationPath() {
|
|
46
|
-
return (0, glob_parent_1.default)(this.location) + '/test.spec.ts';
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Generate suite glob pattern based on `location` argument
|
|
50
|
-
*/
|
|
51
|
-
generateSuiteGlobPattern() {
|
|
52
|
-
if (!this.location) {
|
|
53
|
-
this.location = `tests/${this.suite}`;
|
|
54
|
-
}
|
|
55
|
-
if (!['*', '.js', '.ts'].find((keyword) => this.location.includes(keyword))) {
|
|
56
|
-
this.location = `${this.location}/**/*.spec(.ts|.js)`;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Check if the suite name is already defined in RcFile
|
|
61
|
-
*/
|
|
62
|
-
checkIfSuiteExists(rcFile) {
|
|
63
|
-
const existingSuites = rcFile.get('tests.suites') || [];
|
|
64
|
-
const existingSuitesNames = existingSuites.map((suite) => suite.name);
|
|
65
|
-
return existingSuitesNames.includes(this.suite);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Add the new test suite to the AdonisRC File and save it
|
|
69
|
-
*/
|
|
70
|
-
async addSuiteToRcFile() {
|
|
71
|
-
const rcFile = new sink_1.files.AdonisRcFile(this.application.appRoot);
|
|
72
|
-
const existingSuites = rcFile.get('tests.suites') || [];
|
|
73
|
-
if (this.checkIfSuiteExists(rcFile)) {
|
|
74
|
-
return sink_1.logger.action('update').skipped(`Suite ${this.suite} already exists`);
|
|
75
|
-
}
|
|
76
|
-
rcFile.set('tests.suites', [
|
|
77
|
-
...existingSuites,
|
|
78
|
-
{
|
|
79
|
-
name: this.suite,
|
|
80
|
-
files: [this.location],
|
|
81
|
-
timeout: 60 * 1000,
|
|
82
|
-
},
|
|
83
|
-
]);
|
|
84
|
-
rcFile.commit();
|
|
85
|
-
sink_1.logger.action('update').succeeded('.adonisrc.json');
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Add a sample test file to the new suite folder
|
|
89
|
-
*/
|
|
90
|
-
createSampleTestFile() {
|
|
91
|
-
const path = this.getExampleTestDestinationPath();
|
|
92
|
-
const testFile = new sink_1.files.MustacheFile(this.application.appRoot, path, (0, path_1.join)(__dirname, '../..', 'templates/test.txt'));
|
|
93
|
-
if (!testFile.exists()) {
|
|
94
|
-
testFile.apply({}).commit();
|
|
95
|
-
sink_1.logger.action('create').succeeded(path);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
async run() {
|
|
99
|
-
this.generateSuiteGlobPattern();
|
|
100
|
-
await this.addSuiteToRcFile();
|
|
101
|
-
if (this.withExampleTest) {
|
|
102
|
-
this.createSampleTestFile();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
CreateSuite.commandName = 'make:suite';
|
|
107
|
-
CreateSuite.description = 'Create a new test suite';
|
|
108
|
-
__decorate([
|
|
109
|
-
standalone_1.args.string({ description: 'Name of the test suite' }),
|
|
110
|
-
__metadata("design:type", String)
|
|
111
|
-
], CreateSuite.prototype, "suite", void 0);
|
|
112
|
-
__decorate([
|
|
113
|
-
standalone_1.args.string({ description: 'Path to the test suite directory', required: false }),
|
|
114
|
-
__metadata("design:type", String)
|
|
115
|
-
], CreateSuite.prototype, "location", void 0);
|
|
116
|
-
__decorate([
|
|
117
|
-
standalone_1.flags.boolean({ description: 'Add a sample test file' }),
|
|
118
|
-
__metadata("design:type", Boolean)
|
|
119
|
-
], CreateSuite.prototype, "withExampleTest", void 0);
|
|
120
|
-
exports.default = CreateSuite;
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* @adonisjs/assembler
|
|
4
|
+
*
|
|
5
|
+
* (c) AdonisJS
|
|
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 standalone_1 = require("@adonisjs/core/build/standalone");
|
|
24
|
+
const sink_1 = require("@adonisjs/sink");
|
|
25
|
+
const glob_parent_1 = __importDefault(require("glob-parent"));
|
|
26
|
+
const path_1 = require("path");
|
|
27
|
+
/**
|
|
28
|
+
* Create a new test suite
|
|
29
|
+
*/
|
|
30
|
+
class CreateSuite extends standalone_1.BaseCommand {
|
|
31
|
+
constructor() {
|
|
32
|
+
super(...arguments);
|
|
33
|
+
/**
|
|
34
|
+
* Glob pattern for the test suite, or only location to the test suite
|
|
35
|
+
*/
|
|
36
|
+
this.location = '';
|
|
37
|
+
/**
|
|
38
|
+
* Should add a sample test file
|
|
39
|
+
*/
|
|
40
|
+
this.withExampleTest = true;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get the destination path for the sample test file
|
|
44
|
+
*/
|
|
45
|
+
getExampleTestDestinationPath() {
|
|
46
|
+
return (0, glob_parent_1.default)(this.location) + '/test.spec.ts';
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Generate suite glob pattern based on `location` argument
|
|
50
|
+
*/
|
|
51
|
+
generateSuiteGlobPattern() {
|
|
52
|
+
if (!this.location) {
|
|
53
|
+
this.location = `tests/${this.suite}`;
|
|
54
|
+
}
|
|
55
|
+
if (!['*', '.js', '.ts'].find((keyword) => this.location.includes(keyword))) {
|
|
56
|
+
this.location = `${this.location}/**/*.spec(.ts|.js)`;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Check if the suite name is already defined in RcFile
|
|
61
|
+
*/
|
|
62
|
+
checkIfSuiteExists(rcFile) {
|
|
63
|
+
const existingSuites = rcFile.get('tests.suites') || [];
|
|
64
|
+
const existingSuitesNames = existingSuites.map((suite) => suite.name);
|
|
65
|
+
return existingSuitesNames.includes(this.suite);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Add the new test suite to the AdonisRC File and save it
|
|
69
|
+
*/
|
|
70
|
+
async addSuiteToRcFile() {
|
|
71
|
+
const rcFile = new sink_1.files.AdonisRcFile(this.application.appRoot);
|
|
72
|
+
const existingSuites = rcFile.get('tests.suites') || [];
|
|
73
|
+
if (this.checkIfSuiteExists(rcFile)) {
|
|
74
|
+
return sink_1.logger.action('update').skipped(`Suite ${this.suite} already exists`);
|
|
75
|
+
}
|
|
76
|
+
rcFile.set('tests.suites', [
|
|
77
|
+
...existingSuites,
|
|
78
|
+
{
|
|
79
|
+
name: this.suite,
|
|
80
|
+
files: [this.location],
|
|
81
|
+
timeout: 60 * 1000,
|
|
82
|
+
},
|
|
83
|
+
]);
|
|
84
|
+
rcFile.commit();
|
|
85
|
+
sink_1.logger.action('update').succeeded('.adonisrc.json');
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Add a sample test file to the new suite folder
|
|
89
|
+
*/
|
|
90
|
+
createSampleTestFile() {
|
|
91
|
+
const path = this.getExampleTestDestinationPath();
|
|
92
|
+
const testFile = new sink_1.files.MustacheFile(this.application.appRoot, path, (0, path_1.join)(__dirname, '../..', 'templates/test.txt'));
|
|
93
|
+
if (!testFile.exists()) {
|
|
94
|
+
testFile.apply({}).commit();
|
|
95
|
+
sink_1.logger.action('create').succeeded(path);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async run() {
|
|
99
|
+
this.generateSuiteGlobPattern();
|
|
100
|
+
await this.addSuiteToRcFile();
|
|
101
|
+
if (this.withExampleTest) {
|
|
102
|
+
this.createSampleTestFile();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
CreateSuite.commandName = 'make:suite';
|
|
107
|
+
CreateSuite.description = 'Create a new test suite';
|
|
108
|
+
__decorate([
|
|
109
|
+
standalone_1.args.string({ description: 'Name of the test suite' }),
|
|
110
|
+
__metadata("design:type", String)
|
|
111
|
+
], CreateSuite.prototype, "suite", void 0);
|
|
112
|
+
__decorate([
|
|
113
|
+
standalone_1.args.string({ description: 'Path to the test suite directory', required: false }),
|
|
114
|
+
__metadata("design:type", String)
|
|
115
|
+
], CreateSuite.prototype, "location", void 0);
|
|
116
|
+
__decorate([
|
|
117
|
+
standalone_1.flags.boolean({ description: 'Add a sample test file' }),
|
|
118
|
+
__metadata("design:type", Boolean)
|
|
119
|
+
], CreateSuite.prototype, "withExampleTest", void 0);
|
|
120
|
+
exports.default = CreateSuite;
|
|
@@ -1,35 +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
|
-
}
|
|
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
|
+
}
|