@adonisjs/assembler 5.6.2 → 5.8.1

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.
@@ -223,8 +223,8 @@
223
223
  {
224
224
  "name": "environment",
225
225
  "propertyName": "environment",
226
- "type": "string",
227
- "description": "Define the environment in which you want to load this file"
226
+ "type": "array",
227
+ "description": "Define the preload file environment. Accepted values \"console,web,repl,test\""
228
228
  }
229
229
  ]
230
230
  },
@@ -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",
@@ -11,6 +11,10 @@ export default class Configure extends BaseCommand {
11
11
  * Use yarn when building for production to install dependencies
12
12
  */
13
13
  packages: string[];
14
+ /**
15
+ * Returns package manager for installing dependencies
16
+ */
17
+ private getPackageManager;
14
18
  /**
15
19
  * Configure encore
16
20
  */
@@ -29,6 +29,15 @@ class Configure extends standalone_1.BaseCommand {
29
29
  super(...arguments);
30
30
  this.appType = process.env['ADONIS_CREATE_APP_BOILERPLATE'] || 'web';
31
31
  }
32
+ /**
33
+ * Returns package manager for installing dependencies
34
+ */
35
+ getPackageManager() {
36
+ if (process.env['ADONIS_CREATE_APP_CLIENT']) {
37
+ return process.env['ADONIS_CREATE_APP_CLIENT'];
38
+ }
39
+ return sink_1.utils.getPackageManager(this.application.appRoot);
40
+ }
32
41
  /**
33
42
  * Configure encore
34
43
  */
@@ -54,6 +63,7 @@ class Configure extends standalone_1.BaseCommand {
54
63
  */
55
64
  const pkgFile = new sink_1.files.PackageJsonFile(this.application.appRoot);
56
65
  pkgFile.install('@symfony/webpack-encore');
66
+ pkgFile.useClient(this.getPackageManager());
57
67
  const spinner = sink_1.logger.await(sink_1.logger.colors.gray('installing @symfony/webpack-encore'));
58
68
  try {
59
69
  await pkgFile.commitAsync();
@@ -158,6 +168,7 @@ class Configure extends standalone_1.BaseCommand {
158
168
  const pkgFile = new sink_1.files.PackageJsonFile(this.application.appRoot);
159
169
  pkgFile.install('@japa/runner');
160
170
  pkgFile.install('@japa/preset-adonis');
171
+ pkgFile.useClient(this.getPackageManager());
161
172
  const spinner = sink_1.logger.await(sink_1.logger.colors.gray('installing @japa/runner, @japa/preset-adonis'));
162
173
  try {
163
174
  await pkgFile.commitAsync();
@@ -1,4 +1,5 @@
1
1
  import { BaseGenerator } from './Base';
2
+ import type { AppEnvironments } from '@ioc:Adonis/Core/Application';
2
3
  /**
3
4
  * Command to make a new preloaded file
4
5
  */
@@ -8,10 +9,6 @@ export default class MakePreloadFile extends BaseGenerator {
8
9
  */
9
10
  protected resourceName: string;
10
11
  protected createExact: boolean;
11
- /**
12
- * List of allowed environments
13
- */
14
- private allowedEnvironments;
15
12
  /**
16
13
  * Command name
17
14
  */
@@ -21,12 +18,11 @@ export default class MakePreloadFile extends BaseGenerator {
21
18
  */
22
19
  static description: string;
23
20
  name: string;
24
- environment: ('console' | 'web' | 'repl')[];
21
+ environment: AppEnvironments[];
25
22
  /**
26
- * Validates environments to ensure they are allowed. Especially when
27
- * defined as a flag.
23
+ * Check if the mentioned environments are valid
28
24
  */
29
- private validateEnvironments;
25
+ private isValidEnviroment;
30
26
  /**
31
27
  * Returns the template stub path
32
28
  */
@@ -35,7 +31,6 @@ export default class MakePreloadFile extends BaseGenerator {
35
31
  * Path to the start directory
36
32
  */
37
33
  protected getDestinationPath(): string;
38
- prepare(): Promise<void>;
39
34
  /**
40
35
  * Run command
41
36
  */
@@ -47,6 +47,7 @@ const slash_1 = __importDefault(require("slash"));
47
47
  const path_1 = require("path");
48
48
  const standalone_1 = require("@adonisjs/core/build/standalone");
49
49
  const Base_1 = require("./Base");
50
+ const ALLOWED_ENVIRONMENTS = ['console', 'web', 'repl', 'test'];
50
51
  /**
51
52
  * Command to make a new preloaded file
52
53
  */
@@ -54,17 +55,12 @@ class MakePreloadFile extends Base_1.BaseGenerator {
54
55
  constructor() {
55
56
  super(...arguments);
56
57
  this.createExact = true;
57
- /**
58
- * List of allowed environments
59
- */
60
- this.allowedEnvironments = ['console', 'web', 'repl'];
61
58
  }
62
59
  /**
63
- * Validates environments to ensure they are allowed. Especially when
64
- * defined as a flag.
60
+ * Check if the mentioned environments are valid
65
61
  */
66
- validateEnvironments(environments) {
67
- return !environments.find((environment) => !this.allowedEnvironments.includes(environment));
62
+ isValidEnviroment(environment) {
63
+ return !environment.find((one) => !ALLOWED_ENVIRONMENTS.includes(one));
68
64
  }
69
65
  /**
70
66
  * Returns the template stub path
@@ -78,40 +74,45 @@ class MakePreloadFile extends Base_1.BaseGenerator {
78
74
  getDestinationPath() {
79
75
  return this.application.rcFile.directories.start || 'start';
80
76
  }
81
- async prepare() {
82
- this.environment = await this.prompt.multiple('Select the environment(s) in which you want to load this file', [
83
- {
84
- name: 'console',
85
- message: 'During ace commands',
86
- },
87
- {
88
- name: 'repl',
89
- message: 'During repl session',
90
- },
91
- {
92
- name: 'web',
93
- message: 'During HTTP server',
94
- },
95
- ], {
96
- validate(choices) {
97
- return choices && choices.length ? true : 'Use space to select the environment';
98
- },
99
- });
100
- }
101
77
  /**
102
78
  * Run command
103
79
  */
104
80
  async run() {
105
- const environments = typeof this.environment === 'string'
106
- ? this.environment.split(',')
107
- : this.environment;
108
81
  /**
109
- * Show error when defined environments are invalid
82
+ * Ensure the environments are valid when provided via flag
110
83
  */
111
- if (!this.validateEnvironments(environments)) {
112
- this.logger.error(`Invalid environments "${environments}". Only "${this.allowedEnvironments}" are allowed`);
84
+ if (this.environment && this.environment.length && !this.isValidEnviroment(this.environment)) {
85
+ this.logger.error(`Invalid environment(s) "${this.environment}". Only "${ALLOWED_ENVIRONMENTS}" are allowed`);
113
86
  return;
114
87
  }
88
+ let environments = this.environment;
89
+ /**
90
+ * Prompt user to select one or more environments
91
+ */
92
+ if (!environments) {
93
+ environments = await this.prompt.multiple('Select the environment(s) in which you want to load this file', [
94
+ {
95
+ name: 'all',
96
+ message: 'Load file in all environments',
97
+ },
98
+ {
99
+ name: 'console',
100
+ message: 'Environment for ace commands',
101
+ },
102
+ {
103
+ name: 'repl',
104
+ message: 'Environment for the REPL session',
105
+ },
106
+ {
107
+ name: 'web',
108
+ message: 'Environment for HTTP requests',
109
+ },
110
+ {
111
+ name: 'test',
112
+ message: 'Environment for the test process',
113
+ },
114
+ ]);
115
+ }
115
116
  /**
116
117
  * Generate resource file
117
118
  */
@@ -126,11 +127,11 @@ class MakePreloadFile extends Base_1.BaseGenerator {
126
127
  const { files } = await Promise.resolve().then(() => __importStar(require('@adonisjs/sink')));
127
128
  const relativePath = file.toJSON().relativepath;
128
129
  const rcFile = new files.AdonisRcFile(this.application.appRoot);
129
- if (environments && environments.length) {
130
- rcFile.setPreload(`./${(0, slash_1.default)(relativePath).replace((0, path_1.extname)(relativePath), '')}`, environments);
130
+ if (!environments || !environments.length || environments.includes('all')) {
131
+ rcFile.setPreload(`./${(0, slash_1.default)(relativePath).replace((0, path_1.extname)(relativePath), '')}`);
131
132
  }
132
133
  else {
133
- rcFile.setPreload(`./${(0, slash_1.default)(relativePath).replace((0, path_1.extname)(relativePath), '')}`);
134
+ rcFile.setPreload(`./${(0, slash_1.default)(relativePath).replace((0, path_1.extname)(relativePath), '')}`, environments);
134
135
  }
135
136
  rcFile.commit();
136
137
  }
@@ -148,8 +149,8 @@ __decorate([
148
149
  __metadata("design:type", String)
149
150
  ], MakePreloadFile.prototype, "name", void 0);
150
151
  __decorate([
151
- standalone_1.flags.string({
152
- description: 'Define the environment in which you want to load this file',
152
+ standalone_1.flags.array({
153
+ description: `Define the preload file environment. Accepted values "${ALLOWED_ENVIRONMENTS}"`,
153
154
  }),
154
155
  __metadata("design:type", Array)
155
156
  ], MakePreloadFile.prototype, "environment", void 0);
@@ -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.8.1",
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,27 +44,30 @@
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.5",
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.9",
53
+ "@japa/spec-reporter": "^1.1.12",
50
54
  "@poppinss/dev-utils": "^2.0.3",
51
- "@types/node": "^17.0.24",
52
- "commitizen": "^4.2.4",
55
+ "@types/node": "^18.0.6",
56
+ "commitizen": "^4.2.5",
53
57
  "copyfiles": "^2.4.1",
54
58
  "cross-env": "^7.0.3",
55
59
  "cz-conventional-changelog": "^3.3.0",
56
- "del-cli": "^4.0.1",
57
- "eslint": "^8.13.0",
60
+ "del-cli": "^5.0.0",
61
+ "eslint": "^8.20.0",
58
62
  "eslint-config-prettier": "^8.5.0",
59
63
  "eslint-plugin-adonis": "^2.1.0",
60
- "eslint-plugin-prettier": "^4.0.0",
64
+ "eslint-plugin-prettier": "^4.2.1",
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
- "np": "^7.6.1",
66
- "prettier": "^2.6.2",
67
- "typescript": "^4.6.3"
68
+ "np": "^7.6.2",
69
+ "prettier": "^2.7.1",
70
+ "typescript": "^4.7.4"
68
71
  },
69
72
  "nyc": {
70
73
  "exclude": [
@@ -89,16 +92,16 @@
89
92
  "anyBranch": false
90
93
  },
91
94
  "dependencies": {
92
- "@adonisjs/application": "^5.2.4",
95
+ "@adonisjs/application": "^5.2.5",
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.4.0",
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",