@adonisjs/assembler 5.5.3-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.
- package/build/commands/Invoke.d.ts +1 -0
- package/build/commands/Invoke.js +19 -1
- package/build/config/paths.d.ts +1 -1
- package/build/config/paths.js +1 -1
- package/build/src/EnvParser/index.d.ts +2 -0
- package/build/src/EnvParser/index.js +3 -2
- package/build/src/Test/index.d.ts +5 -0
- package/build/src/Test/index.js +23 -1
- package/build/templates/test-entrypoint.txt +1 -1
- package/build/templates/tests/functional/hello_world_api.spec.txt +8 -0
- package/build/templates/tests/functional/hello_world_slim.spec.txt +8 -0
- package/build/templates/tests/functional/{hello_world.spec.txt → hello_world_web.spec.txt} +0 -0
- package/package.json +1 -1
package/build/commands/Invoke.js
CHANGED
|
@@ -25,6 +25,10 @@ const Manifest_1 = require("../src/Manifest");
|
|
|
25
25
|
* Configure a package
|
|
26
26
|
*/
|
|
27
27
|
class Configure extends standalone_1.BaseCommand {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
this.appType = process.env['ADONIS_CREATE_APP_BOILERPLATE'] || 'web';
|
|
31
|
+
}
|
|
28
32
|
/**
|
|
29
33
|
* Configure encore
|
|
30
34
|
*/
|
|
@@ -85,7 +89,7 @@ class Configure extends standalone_1.BaseCommand {
|
|
|
85
89
|
/**
|
|
86
90
|
* Create "tests/functional/hello_world.spec.ts" file
|
|
87
91
|
*/
|
|
88
|
-
const helloWorldTestFile = new sink_1.files.MustacheFile(this.application.appRoot, 'tests/functional/hello_world.spec.ts', (0, path_1.join)(__dirname, '..',
|
|
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`));
|
|
89
93
|
if (!helloWorldTestFile.exists()) {
|
|
90
94
|
helloWorldTestFile.apply({}).commit();
|
|
91
95
|
sink_1.logger.action('create').succeeded('tests/functional/hello_world.spec.ts');
|
|
@@ -113,6 +117,20 @@ class Configure extends standalone_1.BaseCommand {
|
|
|
113
117
|
});
|
|
114
118
|
rcFile.commit();
|
|
115
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
|
+
}
|
|
116
134
|
/**
|
|
117
135
|
* Install required dependencies
|
|
118
136
|
*/
|
package/build/config/paths.d.ts
CHANGED
|
@@ -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 = "
|
|
6
|
+
export declare const TESTS_ENTRY_FILE = "test.ts";
|
|
7
7
|
export declare const TSCONFIG_FILE_NAME = "tsconfig.json";
|
package/build/config/paths.js
CHANGED
|
@@ -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 = '
|
|
17
|
+
exports.TESTS_ENTRY_FILE = 'test.ts';
|
|
18
18
|
exports.TSCONFIG_FILE_NAME = 'tsconfig.json';
|
|
@@ -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,
|
|
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
|
package/build/src/Test/index.js
CHANGED
|
@@ -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,
|
|
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) {
|
|
File without changes
|