@adonisjs/assembler 5.6.2 → 5.7.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.
@@ -259,6 +259,37 @@
259
259
  }
260
260
  ]
261
261
  },
262
+ "make:suite": {
263
+ "settings": {},
264
+ "commandPath": "./commands/Make/Suite",
265
+ "commandName": "make:suite",
266
+ "description": "Create a new test suite",
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": "location",
278
+ "name": "location",
279
+ "required": false,
280
+ "description": "Path to the test suite directory"
281
+ }
282
+ ],
283
+ "aliases": [],
284
+ "flags": [
285
+ {
286
+ "name": "with-example-test",
287
+ "propertyName": "withExampleTest",
288
+ "type": "boolean",
289
+ "description": "Add a sample test file"
290
+ }
291
+ ]
292
+ },
262
293
  "make:test": {
263
294
  "settings": {},
264
295
  "commandPath": "./commands/Make/Test",
@@ -441,6 +472,12 @@
441
472
  "type": "array",
442
473
  "description": "Filter tests by ignoring tags"
443
474
  },
475
+ {
476
+ "name": "tests",
477
+ "propertyName": "tests",
478
+ "type": "array",
479
+ "description": "Filter tests by title"
480
+ },
444
481
  {
445
482
  "name": "timeout",
446
483
  "propertyName": "timeout",
@@ -0,0 +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
+ }
@@ -0,0 +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;
@@ -33,6 +33,10 @@ export default class Test extends BaseCommand {
33
33
  * Filter by tags
34
34
  */
35
35
  ignoreTags: string[];
36
+ /**
37
+ * Filter by test title
38
+ */
39
+ tests: string[];
36
40
  /**
37
41
  * Customize tests timeout
38
42
  */
@@ -75,6 +75,9 @@ class Test extends standalone_1.BaseCommand {
75
75
  if (this.ignoreTags) {
76
76
  filters['--ignore-tags'] = this.ignoreTags;
77
77
  }
78
+ if (this.tests) {
79
+ filters['--tests'] = this.tests;
80
+ }
78
81
  return filters;
79
82
  }
80
83
  async run() {
@@ -134,6 +137,10 @@ __decorate([
134
137
  standalone_1.flags.array({ description: 'Filter tests by ignoring tags' }),
135
138
  __metadata("design:type", Array)
136
139
  ], Test.prototype, "ignoreTags", void 0);
140
+ __decorate([
141
+ standalone_1.flags.array({ description: 'Filter tests by title' }),
142
+ __metadata("design:type", Array)
143
+ ], Test.prototype, "tests", void 0);
137
144
  __decorate([
138
145
  standalone_1.flags.number({ description: 'Customize tests timeout' }),
139
146
  __metadata("design:type", Number)
@@ -35,11 +35,13 @@ 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
- if (filter !== '_') {
39
- result.push(filter);
38
+ if (filter === '_') {
39
+ result.push(...value);
40
+ return result;
40
41
  }
42
+ result.push(filter);
41
43
  if (Array.isArray(value)) {
42
- result.push(...value);
44
+ result.push(value.join(','));
43
45
  }
44
46
  else {
45
47
  result.push(value);
@@ -1,4 +1,4 @@
1
- import { schema } from '@ioc:Adonis/Core/Validator'
1
+ import { schema, CustomMessages } from '@ioc:Adonis/Core/Validator'
2
2
  import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
3
3
 
4
4
  export default class {{ filename }} {
@@ -36,5 +36,5 @@ export default class {{ filename }} {
36
36
  * }
37
37
  *
38
38
  */
39
- public messages = {}
39
+ public messages: CustomMessages = {}
40
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adonisjs/assembler",
3
- "version": "5.6.2",
3
+ "version": "5.7.0",
4
4
  "description": "Core commands to compiler and build AdonisJs project",
5
5
  "main": "build/ace-manifest.json",
6
6
  "files": [
@@ -15,9 +15,9 @@
15
15
  "scripts": {
16
16
  "mrm": "mrm --preset=@adonisjs/mrm-preset",
17
17
  "pretest": "npm run lint",
18
- "test": "cross-env FORCE_COLOR=true node .bin/test.js",
18
+ "test": "cross-env FORCE_COLOR=true node -r @adonisjs/require-ts/build/register ./bin/test.ts",
19
19
  "lint": "eslint . --ext=.ts",
20
- "clean": "del build",
20
+ "clean": "del-cli build",
21
21
  "compile": "npm run lint && npm run clean && tsc",
22
22
  "build": "npm run compile && node build/bin/index.js && copyfiles \"templates/**\" build",
23
23
  "commit": "git-cz",
@@ -44,23 +44,26 @@
44
44
  },
45
45
  "homepage": "https://github.com/adonisjs/assembler#readme",
46
46
  "devDependencies": {
47
- "@adonisjs/ace": "^11.2.3",
48
- "@adonisjs/core": "^5.7.4",
47
+ "@adonisjs/ace": "^11.3.1",
48
+ "@adonisjs/core": "^5.8.2",
49
49
  "@adonisjs/mrm-preset": "^5.0.3",
50
+ "@japa/assert": "^1.3.4",
51
+ "@japa/run-failed-tests": "^1.0.7",
52
+ "@japa/runner": "^2.0.8",
53
+ "@japa/spec-reporter": "^1.1.12",
50
54
  "@poppinss/dev-utils": "^2.0.3",
51
- "@types/node": "^17.0.24",
55
+ "@types/node": "^17.0.35",
52
56
  "commitizen": "^4.2.4",
53
57
  "copyfiles": "^2.4.1",
54
58
  "cross-env": "^7.0.3",
55
59
  "cz-conventional-changelog": "^3.3.0",
56
60
  "del-cli": "^4.0.1",
57
- "eslint": "^8.13.0",
61
+ "eslint": "^8.16.0",
58
62
  "eslint-config-prettier": "^8.5.0",
59
63
  "eslint-plugin-adonis": "^2.1.0",
60
64
  "eslint-plugin-prettier": "^4.0.0",
61
65
  "github-label-sync": "^2.2.0",
62
- "husky": "^7.0.4",
63
- "japa": "^4.0.0",
66
+ "husky": "^8.0.1",
64
67
  "mrm": "^4.0.0",
65
68
  "np": "^7.6.1",
66
69
  "prettier": "^2.6.2",
@@ -91,14 +94,14 @@
91
94
  "dependencies": {
92
95
  "@adonisjs/application": "^5.2.4",
93
96
  "@adonisjs/env": "^3.0.9",
94
- "@adonisjs/ioc-transformer": "^2.3.3",
95
- "@adonisjs/require-ts": "^2.0.11",
96
- "@adonisjs/sink": "^5.2.3",
97
+ "@adonisjs/ioc-transformer": "^2.3.4",
98
+ "@adonisjs/require-ts": "^2.0.12",
99
+ "@adonisjs/sink": "^5.3.2",
97
100
  "@poppinss/chokidar-ts": "^3.3.5",
98
101
  "@poppinss/cliui": "^3.0.2",
99
102
  "@poppinss/utils": "^4.0.4",
100
103
  "cpy": "^8.1.2",
101
- "emittery": "^0.10.2",
104
+ "emittery": "^0.11.0",
102
105
  "execa": "^5.1.1",
103
106
  "fs-extra": "^10.0.1",
104
107
  "get-port": "^5.1.1",