@adonisjs/assembler 5.5.3-0 → 5.6.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.
- package/build/commands/Invoke.d.ts +1 -0
- package/build/commands/Invoke.js +40 -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 +9 -0
- package/build/src/Test/index.js +30 -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/build/templates/tests-contract.txt +1 -1
- package/package.json +7 -7
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');
|
|
@@ -111,8 +115,43 @@ class Configure extends standalone_1.BaseCommand {
|
|
|
111
115
|
},
|
|
112
116
|
],
|
|
113
117
|
});
|
|
118
|
+
rcFile.addProvider('@japa/preset-adonis/TestsProvider');
|
|
114
119
|
rcFile.commit();
|
|
115
120
|
sink_1.logger.action('update').succeeded('.adonisrc.json');
|
|
121
|
+
/**
|
|
122
|
+
* Create ".env.test" file
|
|
123
|
+
*/
|
|
124
|
+
const testEnvFile = new sink_1.files.NewLineFile(this.application.appRoot, '.env.test');
|
|
125
|
+
if (!testEnvFile.exists()) {
|
|
126
|
+
testEnvFile.add('NODE_ENV=test');
|
|
127
|
+
/**
|
|
128
|
+
* Set additional .env variables for "web" boilerplate
|
|
129
|
+
*/
|
|
130
|
+
if (this.appType === 'web') {
|
|
131
|
+
testEnvFile.add(['ASSETS_DRIVER=fake', 'SESSION_DRIVER=memory']);
|
|
132
|
+
}
|
|
133
|
+
testEnvFile.commit();
|
|
134
|
+
sink_1.logger.action('create').succeeded('.env.test');
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Update "tsconfig.json"
|
|
138
|
+
*/
|
|
139
|
+
const tsConfig = new sink_1.files.JsonFile(this.application.appRoot, 'tsconfig.json');
|
|
140
|
+
const existingTypes = tsConfig.get('compilerOptions.types') || [];
|
|
141
|
+
if (!existingTypes.includes('@japa/preset-adonis/build/adonis-typings')) {
|
|
142
|
+
existingTypes.push('@japa/preset-adonis/build/adonis-typings');
|
|
143
|
+
}
|
|
144
|
+
tsConfig.set('compilerOptions.types', existingTypes);
|
|
145
|
+
tsConfig.commit();
|
|
146
|
+
sink_1.logger.action('update').succeeded('tsconfig.json');
|
|
147
|
+
/**
|
|
148
|
+
* Set additional .env variables for "web" boilerplate
|
|
149
|
+
*/
|
|
150
|
+
if (this.appType === 'web') {
|
|
151
|
+
testEnvFile.add(['ASSETS_DRIVER=fake', 'SESSION_DRIVER=memory']);
|
|
152
|
+
}
|
|
153
|
+
testEnvFile.commit();
|
|
154
|
+
sink_1.logger.action('create').succeeded('.env.test');
|
|
116
155
|
/**
|
|
117
156
|
* Install required dependencies
|
|
118
157
|
*/
|
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
|
}
|
|
@@ -44,6 +44,10 @@ export declare class TestsServer {
|
|
|
44
44
|
*/
|
|
45
45
|
private isTestFile;
|
|
46
46
|
constructor(appRoot: string, filters: JapaFlags, nodeArgs?: string[], logger?: typeof uiLogger);
|
|
47
|
+
/**
|
|
48
|
+
* Clear terminal screen
|
|
49
|
+
*/
|
|
50
|
+
private clearScreen;
|
|
47
51
|
/**
|
|
48
52
|
* Returns the glob paths for test suites. Returns all if no
|
|
49
53
|
* filter is applied. Otherwise only the filtered suites
|
|
@@ -54,6 +58,11 @@ export declare class TestsServer {
|
|
|
54
58
|
* Kill current process
|
|
55
59
|
*/
|
|
56
60
|
private kill;
|
|
61
|
+
/**
|
|
62
|
+
* Returns the HOST and the PORT environment variables
|
|
63
|
+
* for the HTTP server
|
|
64
|
+
*/
|
|
65
|
+
private getEnvironmentVariables;
|
|
57
66
|
/**
|
|
58
67
|
* Run tests. Use [[watch]] to also watch for file
|
|
59
68
|
* 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
|
|
@@ -77,6 +79,12 @@ class TestsServer {
|
|
|
77
79
|
});
|
|
78
80
|
};
|
|
79
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Clear terminal screen
|
|
84
|
+
*/
|
|
85
|
+
clearScreen() {
|
|
86
|
+
process.stdout.write('\u001Bc');
|
|
87
|
+
}
|
|
80
88
|
/**
|
|
81
89
|
* Returns the glob paths for test suites. Returns all if no
|
|
82
90
|
* filter is applied. Otherwise only the filtered suites
|
|
@@ -99,6 +107,26 @@ class TestsServer {
|
|
|
99
107
|
kill() {
|
|
100
108
|
process.exit();
|
|
101
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Returns the HOST and the PORT environment variables
|
|
112
|
+
* for the HTTP server
|
|
113
|
+
*/
|
|
114
|
+
async getEnvironmentVariables() {
|
|
115
|
+
const envParser = new EnvParser_1.EnvParser('.env.test');
|
|
116
|
+
await envParser.parse(this.appRoot);
|
|
117
|
+
const envOptions = envParser.asEnvObject(['PORT', 'TZ', 'HOST']);
|
|
118
|
+
const HOST = process.env.HOST || envOptions.HOST || '0.0.0.0';
|
|
119
|
+
let PORT = Number(process.env.PORT || envOptions.PORT);
|
|
120
|
+
/**
|
|
121
|
+
* Use the port defined inside ".env.test" file or use
|
|
122
|
+
* a random port
|
|
123
|
+
*/
|
|
124
|
+
PORT = await (0, get_port_1.default)({
|
|
125
|
+
port: !isNaN(PORT) ? [PORT] : [],
|
|
126
|
+
host: HOST,
|
|
127
|
+
});
|
|
128
|
+
return { HOST, PORT: String(PORT) };
|
|
129
|
+
}
|
|
102
130
|
/**
|
|
103
131
|
* Run tests. Use [[watch]] to also watch for file
|
|
104
132
|
* changes
|
|
@@ -107,6 +135,7 @@ class TestsServer {
|
|
|
107
135
|
if (this.busy) {
|
|
108
136
|
return;
|
|
109
137
|
}
|
|
138
|
+
this.clearScreen();
|
|
110
139
|
const filters = { ...this.filters };
|
|
111
140
|
/**
|
|
112
141
|
* Overwrite files filter when a specific file path
|
|
@@ -116,7 +145,7 @@ class TestsServer {
|
|
|
116
145
|
filters['--files'] = [filePath];
|
|
117
146
|
}
|
|
118
147
|
this.busy = true;
|
|
119
|
-
const { hasErrors } = await new process_1.TestProcess(paths_1.TESTS_ENTRY_FILE, this.appRoot, filters, this.nodeArgs, this.logger,
|
|
148
|
+
const { hasErrors } = await new process_1.TestProcess(paths_1.TESTS_ENTRY_FILE, this.appRoot, filters, this.nodeArgs, this.logger, await this.getEnvironmentVariables()).run();
|
|
120
149
|
this.busy = false;
|
|
121
150
|
if (!this.watchingFileSystem) {
|
|
122
151
|
if (hasErrors) {
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/assembler",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.1",
|
|
4
4
|
"description": "Core commands to compiler and build AdonisJs project",
|
|
5
5
|
"main": "build/ace-manifest.json",
|
|
6
6
|
"files": [
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"homepage": "https://github.com/adonisjs/assembler#readme",
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@adonisjs/ace": "^11.2.3",
|
|
48
|
-
"@adonisjs/core": "^5.
|
|
48
|
+
"@adonisjs/core": "^5.7.3",
|
|
49
49
|
"@adonisjs/mrm-preset": "^5.0.3",
|
|
50
50
|
"@poppinss/dev-utils": "^2.0.3",
|
|
51
51
|
"@types/node": "^17.0.23",
|
|
@@ -54,7 +54,7 @@
|
|
|
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.
|
|
57
|
+
"eslint": "^8.13.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",
|
|
@@ -89,14 +89,14 @@
|
|
|
89
89
|
"anyBranch": false
|
|
90
90
|
},
|
|
91
91
|
"dependencies": {
|
|
92
|
-
"@adonisjs/application": "^5.2.
|
|
93
|
-
"@adonisjs/env": "^3.0.
|
|
92
|
+
"@adonisjs/application": "^5.2.3",
|
|
93
|
+
"@adonisjs/env": "^3.0.9",
|
|
94
94
|
"@adonisjs/ioc-transformer": "^2.3.3",
|
|
95
95
|
"@adonisjs/require-ts": "^2.0.11",
|
|
96
96
|
"@adonisjs/sink": "^5.2.2",
|
|
97
97
|
"@poppinss/chokidar-ts": "^3.3.5",
|
|
98
98
|
"@poppinss/cliui": "^3.0.2",
|
|
99
|
-
"@poppinss/utils": "^4.0.
|
|
99
|
+
"@poppinss/utils": "^4.0.4",
|
|
100
100
|
"cpy": "^8.1.2",
|
|
101
101
|
"emittery": "^0.10.2",
|
|
102
102
|
"execa": "^5.1.1",
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
},
|
|
113
113
|
"publishConfig": {
|
|
114
114
|
"access": "public",
|
|
115
|
-
"tag": "
|
|
115
|
+
"tag": "latest"
|
|
116
116
|
},
|
|
117
117
|
"mrmConfig": {
|
|
118
118
|
"core": true,
|