@adonisjs/assembler 5.5.1-0 → 5.5.4-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.
@@ -51,14 +51,14 @@
51
51
  "settings": {},
52
52
  "commandPath": "./commands/Invoke",
53
53
  "commandName": "configure",
54
- "description": "Configure a given AdonisJS package",
54
+ "description": "Configure one or more AdonisJS packages",
55
55
  "args": [
56
56
  {
57
- "type": "string",
58
- "propertyName": "name",
59
- "name": "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",
@@ -371,6 +403,12 @@
371
403
  ],
372
404
  "aliases": [],
373
405
  "flags": [
406
+ {
407
+ "name": "files",
408
+ "propertyName": "files",
409
+ "type": "array",
410
+ "description": "Run tests for the mentioned files only"
411
+ },
374
412
  {
375
413
  "name": "watch",
376
414
  "propertyName": "watch",
@@ -6,14 +6,23 @@ export default class Configure extends BaseCommand {
6
6
  static commandName: string;
7
7
  static description: string;
8
8
  static aliases: string[];
9
+ private appType;
9
10
  /**
10
11
  * Use yarn when building for production to install dependencies
11
12
  */
12
- name: string;
13
+ packages: string[];
13
14
  /**
14
15
  * Configure encore
15
16
  */
16
17
  private configureEncore;
18
+ /**
19
+ * Configure tests
20
+ */
21
+ private configureTests;
22
+ /**
23
+ * Configure a give package
24
+ */
25
+ private configurePackage;
17
26
  /**
18
27
  * Invoked automatically by ace
19
28
  */
@@ -7,99 +7,179 @@
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
  /**
47
25
  * Configure a package
48
26
  */
49
27
  class Configure extends standalone_1.BaseCommand {
28
+ constructor() {
29
+ super(...arguments);
30
+ this.appType = process.env['ADONIS_CREATE_APP_BOILERPLATE'] || 'web';
31
+ }
50
32
  /**
51
33
  * Configure encore
52
34
  */
53
35
  async configureEncore() {
54
- const { files, logger } = await Promise.resolve().then(() => __importStar(require('@adonisjs/sink')));
55
36
  /**
56
37
  * Create the webpack config file
57
38
  */
58
- const webpackConfigFile = new files.MustacheFile(this.application.appRoot, 'webpack.config.js', (0, path_1.join)(__dirname, '..', 'templates/webpack.config.txt'));
39
+ const webpackConfigFile = new sink_1.files.MustacheFile(this.application.appRoot, 'webpack.config.js', (0, path_1.join)(__dirname, '..', 'templates/webpack.config.txt'));
59
40
  if (!webpackConfigFile.exists()) {
60
41
  webpackConfigFile.apply({}).commit();
61
- logger.action('create').succeeded('webpack.config.js');
42
+ sink_1.logger.action('create').succeeded('webpack.config.js');
62
43
  }
63
44
  /**
64
45
  * Create app.js entrypoint
65
46
  */
66
- const entryPointFile = new files.NewLineFile(this.application.appRoot, 'resources/js/app.js');
47
+ const entryPointFile = new sink_1.files.NewLineFile(this.application.appRoot, 'resources/js/app.js');
67
48
  if (!entryPointFile.exists()) {
68
49
  entryPointFile.add('// app entrypoint').commit();
69
- logger.action('create').succeeded('resources/js/app.js');
50
+ sink_1.logger.action('create').succeeded('resources/js/app.js');
70
51
  }
71
- const pkgFile = new files.PackageJsonFile(this.application.appRoot);
52
+ /**
53
+ * Install Encore
54
+ */
55
+ const pkgFile = new sink_1.files.PackageJsonFile(this.application.appRoot);
72
56
  pkgFile.install('@symfony/webpack-encore');
73
- const spinner = logger.await(logger.colors.gray('installing @symfony/webpack-encore'));
57
+ const spinner = sink_1.logger.await(sink_1.logger.colors.gray('installing @symfony/webpack-encore'));
74
58
  try {
75
59
  await pkgFile.commitAsync();
76
60
  spinner.update('Installed');
61
+ spinner.stop();
77
62
  }
78
63
  catch (error) {
79
64
  spinner.update('Unable to install the package');
80
- logger.fatal(error);
65
+ spinner.stop();
66
+ sink_1.logger.fatal(error);
81
67
  }
82
68
  }
83
69
  /**
84
- * Invoked automatically by ace
70
+ * Configure tests
85
71
  */
86
- async run() {
87
- if (this.name === 'encore') {
72
+ async configureTests() {
73
+ /**
74
+ * Create "test.ts" file
75
+ */
76
+ const testsEntryPointFile = new sink_1.files.MustacheFile(this.application.appRoot, 'test.ts', (0, path_1.join)(__dirname, '..', 'templates/test-entrypoint.txt'));
77
+ if (!testsEntryPointFile.exists()) {
78
+ testsEntryPointFile.apply({}).commit();
79
+ sink_1.logger.action('create').succeeded('test.ts');
80
+ }
81
+ /**
82
+ * Create "tests/bootstrap.ts" file
83
+ */
84
+ const testsBootstrapFile = new sink_1.files.MustacheFile(this.application.appRoot, 'tests/bootstrap.ts', (0, path_1.join)(__dirname, '..', 'templates/tests/bootstrap.txt'));
85
+ if (!testsBootstrapFile.exists()) {
86
+ testsBootstrapFile.apply({}).commit();
87
+ sink_1.logger.action('create').succeeded('tests/bootstrap.ts');
88
+ }
89
+ /**
90
+ * Create "tests/functional/hello_world.spec.ts" file
91
+ */
92
+ 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_${this.appType}.spec.txt`));
93
+ if (!helloWorldTestFile.exists()) {
94
+ helloWorldTestFile.apply({}).commit();
95
+ sink_1.logger.action('create').succeeded('tests/functional/hello_world.spec.ts');
96
+ }
97
+ /**
98
+ * Create "contracts/tests.ts" file
99
+ */
100
+ const testsContractsFile = new sink_1.files.MustacheFile(this.application.appRoot, 'contracts/tests.ts', (0, path_1.join)(__dirname, '..', 'templates/tests-contract.txt'));
101
+ if (!testsContractsFile.exists()) {
102
+ testsContractsFile.apply({}).commit();
103
+ sink_1.logger.action('create').succeeded('contracts/tests.ts');
104
+ }
105
+ /**
106
+ * Update AdonisRc file with test suites
107
+ */
108
+ const rcFile = new sink_1.files.AdonisRcFile(this.application.appRoot);
109
+ rcFile.set('tests', {
110
+ suites: [
111
+ {
112
+ name: 'functional',
113
+ files: ['tests/functional/**/*.spec(.ts|.js)'],
114
+ timeout: 60 * 1000,
115
+ },
116
+ ],
117
+ });
118
+ rcFile.commit();
119
+ sink_1.logger.action('update').succeeded('.adonisrc.json');
120
+ /**
121
+ * Create ".env.test" file
122
+ */
123
+ const testEnvFile = new sink_1.files.NewLineFile(this.application.appRoot, '.env.test');
124
+ if (!testEnvFile.exists()) {
125
+ testEnvFile.add('NODE_ENV=test');
126
+ /**
127
+ * Set additional .env variables for "web" boilerplate
128
+ */
129
+ if (this.appType === 'web') {
130
+ testEnvFile.add(['ASSETS_DRIVER=fake', 'SESSION_DRIVER=memory']);
131
+ }
132
+ sink_1.logger.action('create').succeeded('.env.test');
133
+ }
134
+ /**
135
+ * Install required dependencies
136
+ */
137
+ const pkgFile = new sink_1.files.PackageJsonFile(this.application.appRoot);
138
+ pkgFile.install('@japa/runner');
139
+ pkgFile.install('@japa/preset-adonis');
140
+ const spinner = sink_1.logger.await(sink_1.logger.colors.gray('installing @japa/runner, @japa/preset-adonis'));
141
+ try {
142
+ await pkgFile.commitAsync();
143
+ spinner.update('Installed');
144
+ spinner.stop();
145
+ }
146
+ catch (error) {
147
+ spinner.update('Unable to install packages');
148
+ spinner.stop();
149
+ sink_1.logger.fatal(error);
150
+ }
151
+ }
152
+ /**
153
+ * Configure a give package
154
+ */
155
+ async configurePackage(name) {
156
+ if (name === 'encore') {
88
157
  await this.configureEncore();
89
158
  return;
90
159
  }
91
- const { tasks } = await Promise.resolve().then(() => __importStar(require('@adonisjs/sink')));
92
- await new tasks.Instructions(this.name, this.application.appRoot, this.application, true).execute();
160
+ if (name === 'tests') {
161
+ await this.configureTests();
162
+ return;
163
+ }
164
+ await new sink_1.tasks.Instructions(name, this.application.appRoot, this.application, true).execute();
93
165
  await new Manifest_1.Manifest(this.application.appRoot, this.logger).generate();
94
166
  }
167
+ /**
168
+ * Invoked automatically by ace
169
+ */
170
+ async run() {
171
+ for (let name of this.packages) {
172
+ await this.configurePackage(name);
173
+ }
174
+ }
95
175
  }
96
176
  Configure.commandName = 'configure';
97
- Configure.description = 'Configure a given AdonisJS package';
177
+ Configure.description = 'Configure one or more AdonisJS packages';
98
178
  Configure.aliases = ['invoke'];
99
179
  __decorate([
100
- standalone_1.args.string({
101
- description: 'Name of the package you want to configure',
180
+ standalone_1.args.spread({
181
+ description: 'Name of the package(s) you want to configure',
102
182
  }),
103
- __metadata("design:type", String)
104
- ], Configure.prototype, "name", void 0);
183
+ __metadata("design:type", Array)
184
+ ], Configure.prototype, "packages", void 0);
105
185
  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;
@@ -9,6 +9,10 @@ export default class Test extends BaseCommand {
9
9
  stayAlive: boolean;
10
10
  };
11
11
  suites: string[];
12
+ /**
13
+ * Allows watching for file changes
14
+ */
15
+ files: string[];
12
16
  /**
13
17
  * Allows watching for file changes
14
18
  */
@@ -60,6 +60,9 @@ 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
  }
@@ -99,6 +102,12 @@ __decorate([
99
102
  standalone_1.args.spread({ description: 'Run tests for only the specified suites', required: false }),
100
103
  __metadata("design:type", Array)
101
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);
102
111
  __decorate([
103
112
  standalone_1.flags.boolean({
104
113
  description: 'Watch for file changes and re-run tests on file change',
@@ -3,5 +3,5 @@ export declare const DEFAULT_BUILD_DIR = "build";
3
3
  export declare const RCFILE_NAME = ".adonisrc.json";
4
4
  export declare const ENV_FILES: string[];
5
5
  export declare const SERVER_ENTRY_FILE = "server.ts";
6
- export declare const TESTS_ENTRY_FILE = "tests.ts";
6
+ export declare const TESTS_ENTRY_FILE = "test.ts";
7
7
  export declare const TSCONFIG_FILE_NAME = "tsconfig.json";
@@ -14,5 +14,5 @@ exports.DEFAULT_BUILD_DIR = 'build';
14
14
  exports.RCFILE_NAME = '.adonisrc.json';
15
15
  exports.ENV_FILES = ['.env', '.env.testing'];
16
16
  exports.SERVER_ENTRY_FILE = 'server.ts';
17
- exports.TESTS_ENTRY_FILE = 'tests.ts';
17
+ exports.TESTS_ENTRY_FILE = 'test.ts';
18
18
  exports.TSCONFIG_FILE_NAME = 'tsconfig.json';
@@ -2,8 +2,10 @@
2
2
  * Parses the env file inside the project root.
3
3
  */
4
4
  export declare class EnvParser {
5
+ private envFileName;
5
6
  private envContents;
6
7
  private parser;
8
+ constructor(envFileName?: string);
7
9
  /**
8
10
  * Parse .env file contents
9
11
  */
@@ -16,7 +16,8 @@ const env_1 = require("@adonisjs/env");
16
16
  * Parses the env file inside the project root.
17
17
  */
18
18
  class EnvParser {
19
- constructor() {
19
+ constructor(envFileName = '.env') {
20
+ this.envFileName = envFileName;
20
21
  this.envContents = {};
21
22
  this.parser = new env_1.EnvParser(false);
22
23
  }
@@ -25,7 +26,7 @@ class EnvParser {
25
26
  */
26
27
  async parse(rootDir) {
27
28
  try {
28
- this.envContents = this.parser.parse(await (0, fs_extra_1.readFile)((0, path_1.join)(rootDir, '.env'), 'utf-8'));
29
+ this.envContents = this.parser.parse(await (0, fs_extra_1.readFile)((0, path_1.join)(rootDir, this.envFileName), 'utf-8'));
29
30
  }
30
31
  catch { }
31
32
  }
@@ -54,6 +54,11 @@ export declare class TestsServer {
54
54
  * Kill current process
55
55
  */
56
56
  private kill;
57
+ /**
58
+ * Returns the HOST and the PORT environment variables
59
+ * for the HTTP server
60
+ */
61
+ private getEnvironmentVariables;
57
62
  /**
58
63
  * Run tests. Use [[watch]] to also watch for file
59
64
  * changes
@@ -21,6 +21,8 @@ const RcFile_1 = require("../RcFile");
21
21
  const Manifest_1 = require("../Manifest");
22
22
  const process_1 = require("./process");
23
23
  const paths_1 = require("../../config/paths");
24
+ const EnvParser_1 = require("../EnvParser");
25
+ const get_port_1 = __importDefault(require("get-port"));
24
26
  /**
25
27
  * Exposes the API to watch project for compilition changes and
26
28
  * run/re-run tests
@@ -99,6 +101,26 @@ class TestsServer {
99
101
  kill() {
100
102
  process.exit();
101
103
  }
104
+ /**
105
+ * Returns the HOST and the PORT environment variables
106
+ * for the HTTP server
107
+ */
108
+ async getEnvironmentVariables() {
109
+ const envParser = new EnvParser_1.EnvParser('.env.test');
110
+ await envParser.parse(this.appRoot);
111
+ const envOptions = envParser.asEnvObject(['PORT', 'TZ', 'HOST']);
112
+ const HOST = process.env.HOST || envOptions.HOST || '0.0.0.0';
113
+ let PORT = Number(process.env.PORT || envOptions.PORT);
114
+ /**
115
+ * Use the port defined inside ".env.test" file or use
116
+ * a random port
117
+ */
118
+ PORT = await (0, get_port_1.default)({
119
+ port: !isNaN(PORT) ? [PORT] : [],
120
+ host: HOST,
121
+ });
122
+ return { HOST, PORT: String(PORT) };
123
+ }
102
124
  /**
103
125
  * Run tests. Use [[watch]] to also watch for file
104
126
  * changes
@@ -116,7 +138,7 @@ class TestsServer {
116
138
  filters['--files'] = [filePath];
117
139
  }
118
140
  this.busy = true;
119
- const { hasErrors } = await new process_1.TestProcess(paths_1.TESTS_ENTRY_FILE, this.appRoot, filters, this.nodeArgs, this.logger, {}).run();
141
+ const { hasErrors } = await new process_1.TestProcess(paths_1.TESTS_ENTRY_FILE, this.appRoot, filters, this.nodeArgs, this.logger, await this.getEnvironmentVariables()).run();
120
142
  this.busy = false;
121
143
  if (!this.watchingFileSystem) {
122
144
  if (hasErrors) {
@@ -253,9 +275,7 @@ class TestsServer {
253
275
  return;
254
276
  }
255
277
  this.logger.action('create').succeeded(relativePath);
256
- if (metaData.reload) {
257
- await this.run();
258
- }
278
+ await this.run();
259
279
  });
260
280
  /**
261
281
  * File changed
@@ -274,9 +294,7 @@ class TestsServer {
274
294
  return;
275
295
  }
276
296
  this.logger.action('update').succeeded(relativePath);
277
- if (metaData.reload || metaData.rcFile) {
278
- await this.run();
279
- }
297
+ await this.run();
280
298
  });
281
299
  /**
282
300
  * File removed
@@ -301,9 +319,7 @@ class TestsServer {
301
319
  return;
302
320
  }
303
321
  this.logger.action('delete').succeeded(relativePath);
304
- if (metaData.reload) {
305
- await this.run();
306
- }
322
+ await this.run();
307
323
  });
308
324
  /**
309
325
  * Start the watcher
@@ -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 = 'test'
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,5 @@
1
+ import { test } from '@japa/runner'
2
+
3
+ test.group('{{ name }}', () => {
4
+ // Write your test here
5
+ })
@@ -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,8 @@
1
+ import { test } from '@japa/runner'
2
+
3
+ test('display welcome page', async ({ client }) => {
4
+ const response = await client.get('/')
5
+
6
+ response.assertStatus(200)
7
+ response.assertBodyContains({ hello: 'world' })
8
+ })
@@ -0,0 +1,8 @@
1
+ import { test } from '@japa/runner'
2
+
3
+ test('display welcome page', async ({ client }) => {
4
+ const response = await client.get('/')
5
+
6
+ response.assertStatus(200)
7
+ response.assertTextIncludes('hello world')
8
+ })
@@ -0,0 +1,8 @@
1
+ import { test } from '@japa/runner'
2
+
3
+ test('display welcome page', async ({ client }) => {
4
+ const response = await client.get('/')
5
+
6
+ response.assertStatus(200)
7
+ response.assertTextIncludes('<h1 class="title"> It Works! </h1>')
8
+ })
@@ -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.1-0",
3
+ "version": "5.5.4-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/*\" build",
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.2",
48
- "@adonisjs/core": "^5.5.3",
49
- "@adonisjs/mrm-preset": "^5.0.2",
50
- "@poppinss/dev-utils": "^2.0.2",
51
- "@types/node": "^17.0.21",
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.10.0",
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.2",
61
+ "github-label-sync": "^2.2.0",
62
62
  "husky": "^7.0.4",
63
63
  "japa": "^4.0.0",
64
- "mrm": "^3.0.10",
65
- "np": "^7.6.0",
66
- "prettier": "^2.5.1",
67
- "typescript": "^4.6.2"
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.0",
93
- "@adonisjs/env": "^3.0.7",
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.10",
95
+ "@adonisjs/require-ts": "^2.0.11",
96
96
  "@adonisjs/sink": "^5.2.2",
97
- "@poppinss/chokidar-ts": "^3.3.4",
98
- "@poppinss/cliui": "^3.0.1",
99
- "@poppinss/utils": "^4.0.2",
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.1",
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"