@adonisjs/assembler 5.9.4 → 6.0.0-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/LICENSE.md +1 -1
- package/build/index.d.ts +2 -0
- package/build/index.js +2 -0
- package/build/src/bundler.d.ts +10 -0
- package/build/src/bundler.js +133 -0
- package/build/src/dev_server.d.ts +13 -0
- package/build/src/dev_server.js +189 -0
- package/build/src/run.d.ts +3 -0
- package/build/src/run.js +19 -0
- package/build/src/types.d.ts +26 -0
- package/build/src/watch.d.ts +8 -0
- package/build/src/watch.js +18 -0
- package/package.json +77 -99
- package/build/ace-manifest.json +0 -521
- package/build/commands/Build.d.ts +0 -37
- package/build/commands/Build.js +0 -138
- package/build/commands/Invoke.d.ts +0 -34
- package/build/commands/Invoke.js +0 -234
- package/build/commands/Make/Base.d.ts +0 -30
- package/build/commands/Make/Base.js +0 -75
- package/build/commands/Make/Command.d.ts +0 -35
- package/build/commands/Make/Command.js +0 -82
- package/build/commands/Make/Controller.d.ts +0 -37
- package/build/commands/Make/Controller.js +0 -89
- package/build/commands/Make/Exception.d.ts +0 -32
- package/build/commands/Make/Exception.js +0 -75
- package/build/commands/Make/Listener.d.ts +0 -30
- package/build/commands/Make/Listener.js +0 -70
- package/build/commands/Make/Middleware.d.ts +0 -31
- package/build/commands/Make/Middleware.js +0 -87
- package/build/commands/Make/PreloadFile.d.ts +0 -38
- package/build/commands/Make/PreloadFile.js +0 -157
- package/build/commands/Make/Provider.d.ts +0 -31
- package/build/commands/Make/Provider.js +0 -114
- package/build/commands/Make/Suite.d.ts +0 -41
- package/build/commands/Make/Suite.js +0 -120
- package/build/commands/Make/Test.d.ts +0 -35
- package/build/commands/Make/Test.js +0 -96
- package/build/commands/Make/Validator.d.ts +0 -31
- package/build/commands/Make/Validator.js +0 -71
- package/build/commands/Make/View.d.ts +0 -30
- package/build/commands/Make/View.js +0 -70
- package/build/commands/Serve.d.ts +0 -33
- package/build/commands/Serve.js +0 -112
- package/build/commands/Test.d.ts +0 -57
- package/build/commands/Test.js +0 -159
- package/build/commands/TypeCheck.d.ts +0 -16
- package/build/commands/TypeCheck.js +0 -85
- package/build/config/paths.d.ts +0 -7
- package/build/config/paths.js +0 -18
- package/build/register.js +0 -15
- package/build/src/AssetsBundler/index.d.ts +0 -76
- package/build/src/AssetsBundler/index.js +0 -216
- package/build/src/Compiler/index.d.ts +0 -62
- package/build/src/Compiler/index.js +0 -287
- package/build/src/Contracts/index.d.ts +0 -8
- package/build/src/Contracts/index.js +0 -10
- package/build/src/DevServer/index.d.ts +0 -70
- package/build/src/DevServer/index.js +0 -306
- package/build/src/EnvParser/index.d.ts +0 -21
- package/build/src/EnvParser/index.js +0 -48
- package/build/src/HttpServer/index.d.ts +0 -34
- package/build/src/HttpServer/index.js +0 -87
- package/build/src/Manifest/index.d.ts +0 -32
- package/build/src/Manifest/index.js +0 -88
- package/build/src/RcFile/index.d.ts +0 -72
- package/build/src/RcFile/index.js +0 -174
- package/build/src/Test/index.d.ts +0 -75
- package/build/src/Test/index.js +0 -346
- package/build/src/Test/process.d.ts +0 -22
- package/build/src/Test/process.js +0 -68
- package/build/src/Ts/index.d.ts +0 -24
- package/build/src/Ts/index.js +0 -55
- package/build/src/requireHook/index.d.ts +0 -5
- package/build/src/requireHook/index.js +0 -28
- package/build/src/requireHook/ioc-transformer.d.ts +0 -6
- package/build/src/requireHook/ioc-transformer.js +0 -21
- package/build/templates/command.txt +0 -33
- package/build/templates/controller.txt +0 -3
- package/build/templates/event-listener.txt +0 -3
- package/build/templates/exception.txt +0 -15
- package/build/templates/middleware.txt +0 -8
- package/build/templates/preload-file.txt +0 -9
- package/build/templates/provider.txt +0 -40
- package/build/templates/resource-controller.txt +0 -17
- package/build/templates/self-handle-exception.txt +0 -32
- package/build/templates/test-entrypoint.txt +0 -45
- package/build/templates/test.txt +0 -5
- package/build/templates/tests/bootstrap.txt +0 -69
- package/build/templates/tests/functional/hello_world_api.spec.txt +0 -8
- package/build/templates/tests/functional/hello_world_slim.spec.txt +0 -8
- package/build/templates/tests/functional/hello_world_web.spec.txt +0 -8
- package/build/templates/tests-contract.txt +0 -18
- package/build/templates/validator.txt +0 -40
- package/build/templates/view.txt +0 -0
- package/build/templates/webpack.config.txt +0 -214
- /package/build/{register.d.ts → src/types.js} +0 -0
package/build/src/Test/index.js
DELETED
|
@@ -1,346 +0,0 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.TestsServer = void 0;
|
|
15
|
-
const path_1 = require("path");
|
|
16
|
-
const picomatch_1 = __importDefault(require("picomatch"));
|
|
17
|
-
const cliui_1 = require("@poppinss/cliui");
|
|
18
|
-
const require_ts_1 = require("@adonisjs/require-ts");
|
|
19
|
-
const Ts_1 = require("../Ts");
|
|
20
|
-
const RcFile_1 = require("../RcFile");
|
|
21
|
-
const Manifest_1 = require("../Manifest");
|
|
22
|
-
const process_1 = require("./process");
|
|
23
|
-
const paths_1 = require("../../config/paths");
|
|
24
|
-
const EnvParser_1 = require("../EnvParser");
|
|
25
|
-
const get_port_1 = __importDefault(require("get-port"));
|
|
26
|
-
/**
|
|
27
|
-
* Exposes the API to watch project for compilition changes and
|
|
28
|
-
* run/re-run tests
|
|
29
|
-
*/
|
|
30
|
-
class TestsServer {
|
|
31
|
-
constructor(appRoot, filters, nodeArgs = [], logger = cliui_1.logger) {
|
|
32
|
-
this.appRoot = appRoot;
|
|
33
|
-
this.filters = filters;
|
|
34
|
-
this.nodeArgs = nodeArgs;
|
|
35
|
-
this.logger = logger;
|
|
36
|
-
/**
|
|
37
|
-
* A boolean to know if we are watching for filesystem
|
|
38
|
-
*/
|
|
39
|
-
this.watchingFileSystem = false;
|
|
40
|
-
/**
|
|
41
|
-
* Boolean to hold the current state of tests. This is avoid
|
|
42
|
-
* re-running the tests when one run is in progress
|
|
43
|
-
*/
|
|
44
|
-
this.busy = false;
|
|
45
|
-
/**
|
|
46
|
-
* Reference to the typescript compiler
|
|
47
|
-
*/
|
|
48
|
-
this.ts = new Ts_1.Ts(this.appRoot, this.logger);
|
|
49
|
-
/**
|
|
50
|
-
* Reference to the RCFile
|
|
51
|
-
*/
|
|
52
|
-
this.rcFile = new RcFile_1.RcFile(this.appRoot);
|
|
53
|
-
/**
|
|
54
|
-
* Manifest instance to generate ace manifest file
|
|
55
|
-
*/
|
|
56
|
-
this.manifest = new Manifest_1.Manifest(this.appRoot, this.logger);
|
|
57
|
-
/**
|
|
58
|
-
* Require-ts watch helpers
|
|
59
|
-
*/
|
|
60
|
-
this.watchHelpers = (0, require_ts_1.getWatcherHelpers)(this.appRoot);
|
|
61
|
-
/**
|
|
62
|
-
* A method to know if the file is part of the selected suites
|
|
63
|
-
* or not
|
|
64
|
-
*/
|
|
65
|
-
this.isTestSuiteFile = (0, picomatch_1.default)(this.getFilesForSelectedSuites());
|
|
66
|
-
/**
|
|
67
|
-
* Find if the test file part of the applied file filters
|
|
68
|
-
*/
|
|
69
|
-
this.isTestFile = (filePath) => {
|
|
70
|
-
if (!this.filters['--files']) {
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
const fileName = filePath.replace((0, path_1.extname)(filePath), '');
|
|
74
|
-
return !!this.filters['--files'].find((filter) => {
|
|
75
|
-
if (filePath.endsWith(filter)) {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
return fileName.endsWith(filter) || fileName.endsWith(`${filter}.spec`);
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Clear terminal screen
|
|
84
|
-
*/
|
|
85
|
-
clearScreen() {
|
|
86
|
-
process.stdout.write('\u001Bc');
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Returns the glob paths for test suites. Returns all if no
|
|
90
|
-
* filter is applied. Otherwise only the filtered suites
|
|
91
|
-
* are picked.
|
|
92
|
-
*/
|
|
93
|
-
getFilesForSelectedSuites() {
|
|
94
|
-
return this.rcFile.application.rcFile.tests.suites.reduce((result, suite) => {
|
|
95
|
-
if (!suite.files) {
|
|
96
|
-
return result;
|
|
97
|
-
}
|
|
98
|
-
if (!this.filters['--suites'] || this.filters['--suites'].includes(suite.name)) {
|
|
99
|
-
result = result.concat(suite.files);
|
|
100
|
-
}
|
|
101
|
-
return result;
|
|
102
|
-
}, []);
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Kill current process
|
|
106
|
-
*/
|
|
107
|
-
kill() {
|
|
108
|
-
process.exit();
|
|
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();
|
|
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
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Run tests. Use [[watch]] to also watch for file
|
|
132
|
-
* changes
|
|
133
|
-
*/
|
|
134
|
-
async run(filePath) {
|
|
135
|
-
if (this.busy) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
this.clearScreen();
|
|
139
|
-
const filters = { ...this.filters };
|
|
140
|
-
/**
|
|
141
|
-
* Overwrite files filter when a specific file path
|
|
142
|
-
* is mentioned
|
|
143
|
-
*/
|
|
144
|
-
if (filePath) {
|
|
145
|
-
filters['--files'] = [filePath.replace(/\\/g, '/')];
|
|
146
|
-
}
|
|
147
|
-
this.busy = true;
|
|
148
|
-
const { hasErrors } = await new process_1.TestProcess(paths_1.TESTS_ENTRY_FILE, this.appRoot, filters, this.nodeArgs, this.logger, await this.getEnvironmentVariables()).run();
|
|
149
|
-
this.busy = false;
|
|
150
|
-
if (!this.watchingFileSystem) {
|
|
151
|
-
if (hasErrors) {
|
|
152
|
-
process.exitCode = 1;
|
|
153
|
-
}
|
|
154
|
-
this.kill();
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Build and watch for file changes
|
|
159
|
-
*/
|
|
160
|
-
async watch(poll = false) {
|
|
161
|
-
this.watchingFileSystem = true;
|
|
162
|
-
/**
|
|
163
|
-
* Clear require-ts cache
|
|
164
|
-
*/
|
|
165
|
-
this.watchHelpers.clear();
|
|
166
|
-
/**
|
|
167
|
-
* Run tests
|
|
168
|
-
*/
|
|
169
|
-
await this.run();
|
|
170
|
-
/**
|
|
171
|
-
* Parse config to find the files excluded inside
|
|
172
|
-
* tsconfig file
|
|
173
|
-
*/
|
|
174
|
-
const config = this.ts.parseConfig();
|
|
175
|
-
if (!config) {
|
|
176
|
-
this.logger.warning('Cannot start watcher because of errors in the tsconfig file');
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Stick file watcher
|
|
181
|
-
*/
|
|
182
|
-
const watcher = this.ts.tsCompiler.watcher(config, 'raw');
|
|
183
|
-
/**
|
|
184
|
-
* Watcher is ready after first compile
|
|
185
|
-
*/
|
|
186
|
-
watcher.on('watcher:ready', () => {
|
|
187
|
-
this.logger.info('watching file system for changes');
|
|
188
|
-
});
|
|
189
|
-
/**
|
|
190
|
-
* Source file removed
|
|
191
|
-
*/
|
|
192
|
-
watcher.on('source:unlink', async ({ absPath, relativePath }) => {
|
|
193
|
-
this.watchHelpers.clear(absPath);
|
|
194
|
-
if (this.busy) {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
this.logger.action('delete').succeeded(relativePath);
|
|
198
|
-
/**
|
|
199
|
-
* Generate manifest when filePath is a commands path
|
|
200
|
-
*/
|
|
201
|
-
if (this.rcFile.isCommandsPath(relativePath)) {
|
|
202
|
-
this.manifest.generate();
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Run all tests when any of the source, except the
|
|
206
|
-
* test file changes
|
|
207
|
-
*/
|
|
208
|
-
if (!this.rcFile.isTestsFile(relativePath)) {
|
|
209
|
-
await this.run();
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
/**
|
|
213
|
-
* Source file added
|
|
214
|
-
*/
|
|
215
|
-
watcher.on('source:add', async ({ absPath, relativePath }) => {
|
|
216
|
-
this.watchHelpers.clear(absPath);
|
|
217
|
-
if (this.busy) {
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
this.logger.action('add').succeeded(relativePath);
|
|
221
|
-
/**
|
|
222
|
-
* Run all tests when any of the source, except the
|
|
223
|
-
* test file changes
|
|
224
|
-
*/
|
|
225
|
-
if (!this.rcFile.isTestsFile(relativePath)) {
|
|
226
|
-
await this.run();
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Run only the changed file if it part of the test
|
|
231
|
-
* suites (respecting filters)
|
|
232
|
-
*/
|
|
233
|
-
if (this.isTestSuiteFile(relativePath) && this.isTestFile(relativePath)) {
|
|
234
|
-
await this.run(relativePath);
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
/**
|
|
238
|
-
* Source file changed
|
|
239
|
-
*/
|
|
240
|
-
watcher.on('source:change', async ({ absPath, relativePath }) => {
|
|
241
|
-
this.watchHelpers.clear(absPath);
|
|
242
|
-
if (this.busy) {
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
this.logger.action('update').succeeded(relativePath);
|
|
246
|
-
/**
|
|
247
|
-
* Generate manifest when filePath is a commands path
|
|
248
|
-
*/
|
|
249
|
-
if (this.rcFile.isCommandsPath(relativePath)) {
|
|
250
|
-
this.manifest.generate();
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Run all tests when any of the source, except the
|
|
254
|
-
* test file changes
|
|
255
|
-
*/
|
|
256
|
-
if (!this.rcFile.isTestsFile(relativePath)) {
|
|
257
|
-
await this.run();
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Run only the changed file if it part of the test
|
|
262
|
-
* suites (respecting filters)
|
|
263
|
-
*/
|
|
264
|
-
if (this.isTestSuiteFile(relativePath) && this.isTestFile(relativePath)) {
|
|
265
|
-
await this.run(relativePath);
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
/**
|
|
269
|
-
* New file added
|
|
270
|
-
*/
|
|
271
|
-
watcher.on('add', async ({ relativePath }) => {
|
|
272
|
-
if (this.busy) {
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
if (paths_1.ENV_FILES.includes(relativePath)) {
|
|
276
|
-
this.logger.action('create').succeeded(relativePath);
|
|
277
|
-
await this.run();
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
const metaData = this.rcFile.getMetaData(relativePath);
|
|
281
|
-
if (!metaData.metaFile) {
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
this.logger.action('create').succeeded(relativePath);
|
|
285
|
-
await this.run();
|
|
286
|
-
});
|
|
287
|
-
/**
|
|
288
|
-
* File changed
|
|
289
|
-
*/
|
|
290
|
-
watcher.on('change', async ({ relativePath }) => {
|
|
291
|
-
if (this.busy) {
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
if (paths_1.ENV_FILES.includes(relativePath)) {
|
|
295
|
-
this.logger.action('update').succeeded(relativePath);
|
|
296
|
-
await this.run();
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
const metaData = this.rcFile.getMetaData(relativePath);
|
|
300
|
-
if (!metaData.metaFile) {
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
this.logger.action('update').succeeded(relativePath);
|
|
304
|
-
await this.run();
|
|
305
|
-
});
|
|
306
|
-
/**
|
|
307
|
-
* File removed
|
|
308
|
-
*/
|
|
309
|
-
watcher.on('unlink', async ({ relativePath }) => {
|
|
310
|
-
if (this.busy) {
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
if (paths_1.ENV_FILES.includes(relativePath)) {
|
|
314
|
-
this.logger.action('delete').succeeded(relativePath);
|
|
315
|
-
await this.run();
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
const metaData = this.rcFile.getMetaData(relativePath);
|
|
319
|
-
if (!metaData.metaFile) {
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
if (metaData.rcFile) {
|
|
323
|
-
this.logger.info('cannot continue after deletion of .adonisrc.json file');
|
|
324
|
-
watcher.chokidar.close();
|
|
325
|
-
this.kill();
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
this.logger.action('delete').succeeded(relativePath);
|
|
329
|
-
await this.run();
|
|
330
|
-
});
|
|
331
|
-
/**
|
|
332
|
-
* Start the watcher
|
|
333
|
-
*/
|
|
334
|
-
watcher.watch(['.'], {
|
|
335
|
-
usePolling: poll,
|
|
336
|
-
});
|
|
337
|
-
/**
|
|
338
|
-
* Kill when watcher recieves an error
|
|
339
|
-
*/
|
|
340
|
-
watcher.chokidar.on('error', (error) => {
|
|
341
|
-
this.logger.fatal(error);
|
|
342
|
-
this.kill();
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
exports.TestsServer = TestsServer;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { logger as uiLogger } from '@poppinss/cliui';
|
|
2
|
-
import { JapaFlags } from '../Contracts';
|
|
3
|
-
/**
|
|
4
|
-
* Exposes the API to run tests as a child process.
|
|
5
|
-
*/
|
|
6
|
-
export declare class TestProcess {
|
|
7
|
-
private sourceFile;
|
|
8
|
-
private projectRoot;
|
|
9
|
-
private filters;
|
|
10
|
-
private logger;
|
|
11
|
-
private env;
|
|
12
|
-
private nodeArgs;
|
|
13
|
-
constructor(sourceFile: string, projectRoot: string, filters: JapaFlags, nodeArgs: string[] | undefined, logger: typeof uiLogger, env?: {
|
|
14
|
-
[key: string]: string;
|
|
15
|
-
});
|
|
16
|
-
/**
|
|
17
|
-
* Start the HTTP server as a child process.
|
|
18
|
-
*/
|
|
19
|
-
run(): Promise<{
|
|
20
|
-
hasErrors: boolean;
|
|
21
|
-
}>;
|
|
22
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.TestProcess = void 0;
|
|
15
|
-
const execa_1 = __importDefault(require("execa"));
|
|
16
|
-
/**
|
|
17
|
-
* Exposes the API to run tests as a child process.
|
|
18
|
-
*/
|
|
19
|
-
class TestProcess {
|
|
20
|
-
constructor(sourceFile, projectRoot, filters, nodeArgs = [], logger, env = {}) {
|
|
21
|
-
this.sourceFile = sourceFile;
|
|
22
|
-
this.projectRoot = projectRoot;
|
|
23
|
-
this.filters = filters;
|
|
24
|
-
this.logger = logger;
|
|
25
|
-
this.env = env;
|
|
26
|
-
this.nodeArgs = nodeArgs.reduce((result, arg) => {
|
|
27
|
-
result = result.concat(arg.split(' '));
|
|
28
|
-
return result;
|
|
29
|
-
}, []);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Start the HTTP server as a child process.
|
|
33
|
-
*/
|
|
34
|
-
async run() {
|
|
35
|
-
this.logger.info('running tests...');
|
|
36
|
-
const filters = Object.keys(this.filters).reduce((result, filter) => {
|
|
37
|
-
const value = this.filters[filter];
|
|
38
|
-
if (filter === '_') {
|
|
39
|
-
result.push(...value);
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
result.push(filter);
|
|
43
|
-
if (Array.isArray(value)) {
|
|
44
|
-
result.push(value.join(','));
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
result.push(value);
|
|
48
|
-
}
|
|
49
|
-
return result;
|
|
50
|
-
}, []);
|
|
51
|
-
try {
|
|
52
|
-
await execa_1.default.node(this.sourceFile, filters, {
|
|
53
|
-
stdio: 'inherit',
|
|
54
|
-
cwd: this.projectRoot,
|
|
55
|
-
env: {
|
|
56
|
-
FORCE_COLOR: 'true',
|
|
57
|
-
...this.env,
|
|
58
|
-
},
|
|
59
|
-
nodeOptions: ['-r', '@adonisjs/assembler/build/register'].concat(this.nodeArgs),
|
|
60
|
-
});
|
|
61
|
-
return { hasErrors: false };
|
|
62
|
-
}
|
|
63
|
-
catch {
|
|
64
|
-
return { hasErrors: true };
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
exports.TestProcess = TestProcess;
|
package/build/src/Ts/index.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import tsStatic from 'typescript';
|
|
2
|
-
import { logger as uiLogger } from '@poppinss/cliui';
|
|
3
|
-
import { TypescriptCompiler } from '@poppinss/chokidar-ts';
|
|
4
|
-
/**
|
|
5
|
-
* Exposes the API to work with the Typescript compiler API
|
|
6
|
-
*/
|
|
7
|
-
export declare class Ts {
|
|
8
|
-
private appRoot;
|
|
9
|
-
private logger;
|
|
10
|
-
private tsconfig;
|
|
11
|
-
/**
|
|
12
|
-
* Reference to the typescript compiler
|
|
13
|
-
*/
|
|
14
|
-
tsCompiler: TypescriptCompiler;
|
|
15
|
-
constructor(appRoot: string, logger: typeof uiLogger, tsconfig?: string);
|
|
16
|
-
/**
|
|
17
|
-
* Render ts diagnostics
|
|
18
|
-
*/
|
|
19
|
-
renderDiagnostics(diagnostics: tsStatic.Diagnostic[], host: tsStatic.CompilerHost): void;
|
|
20
|
-
/**
|
|
21
|
-
* Parses the tsconfig file
|
|
22
|
-
*/
|
|
23
|
-
parseConfig(): undefined | tsStatic.ParsedCommandLine;
|
|
24
|
-
}
|
package/build/src/Ts/index.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.Ts = void 0;
|
|
12
|
-
const path_1 = require("path");
|
|
13
|
-
const chokidar_ts_1 = require("@poppinss/chokidar-ts");
|
|
14
|
-
const helpers_1 = require("@poppinss/utils/build/helpers");
|
|
15
|
-
const paths_1 = require("../../config/paths");
|
|
16
|
-
/**
|
|
17
|
-
* Exposes the API to work with the Typescript compiler API
|
|
18
|
-
*/
|
|
19
|
-
class Ts {
|
|
20
|
-
constructor(appRoot, logger, tsconfig = paths_1.TSCONFIG_FILE_NAME) {
|
|
21
|
-
this.appRoot = appRoot;
|
|
22
|
-
this.logger = logger;
|
|
23
|
-
this.tsconfig = tsconfig;
|
|
24
|
-
/**
|
|
25
|
-
* Reference to the typescript compiler
|
|
26
|
-
*/
|
|
27
|
-
this.tsCompiler = new chokidar_ts_1.TypescriptCompiler(this.appRoot, this.tsconfig, require((0, helpers_1.resolveFrom)(this.appRoot, 'typescript/lib/typescript')));
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Render ts diagnostics
|
|
31
|
-
*/
|
|
32
|
-
renderDiagnostics(diagnostics, host) {
|
|
33
|
-
console.error(this.tsCompiler.ts.formatDiagnosticsWithColorAndContext(diagnostics, host));
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Parses the tsconfig file
|
|
37
|
-
*/
|
|
38
|
-
parseConfig() {
|
|
39
|
-
const { error, config } = this.tsCompiler.configParser().parse();
|
|
40
|
-
if (error) {
|
|
41
|
-
this.logger.error(`unable to parse ${this.tsconfig}`);
|
|
42
|
-
this.renderDiagnostics([error], this.tsCompiler.ts.createCompilerHost({}));
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (config && config.errors.length) {
|
|
46
|
-
this.logger.error(`unable to parse ${this.tsconfig}`);
|
|
47
|
-
this.renderDiagnostics(config.errors, this.tsCompiler.ts.createCompilerHost(config.options));
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
config.options.rootDir = config.options.rootDir || this.appRoot;
|
|
51
|
-
config.options.outDir = config.options.outDir || (0, path_1.join)(this.appRoot, paths_1.DEFAULT_BUILD_DIR);
|
|
52
|
-
return config;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.Ts = Ts;
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
const require_ts_1 = require("@adonisjs/require-ts");
|
|
12
|
-
/**
|
|
13
|
-
* Exports the function to be used for registering require hook
|
|
14
|
-
* for AdonisJS applications
|
|
15
|
-
*/
|
|
16
|
-
function registerForAdonis(appRoot) {
|
|
17
|
-
return (0, require_ts_1.register)(appRoot, {
|
|
18
|
-
cache: true,
|
|
19
|
-
transformers: {
|
|
20
|
-
after: [
|
|
21
|
-
{
|
|
22
|
-
transform: '@adonisjs/assembler/build/src/requireHook/ioc-transformer',
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
exports.default = registerForAdonis;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type tsStatic from 'typescript';
|
|
2
|
-
/**
|
|
3
|
-
* Transformer to transform AdonisJS IoC container import
|
|
4
|
-
* statements
|
|
5
|
-
*/
|
|
6
|
-
export default function (ts: typeof tsStatic, appRoot: string): (ctx: tsStatic.TransformationContext) => (sourceFile: tsStatic.SourceFile) => tsStatic.SourceFile;
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
const path_1 = require("path");
|
|
12
|
-
const application_1 = require("@adonisjs/application");
|
|
13
|
-
const ioc_transformer_1 = require("@adonisjs/ioc-transformer");
|
|
14
|
-
/**
|
|
15
|
-
* Transformer to transform AdonisJS IoC container import
|
|
16
|
-
* statements
|
|
17
|
-
*/
|
|
18
|
-
function default_1(ts, appRoot) {
|
|
19
|
-
return (0, ioc_transformer_1.iocTransformer)(ts, application_1.rcParser.parse(require((0, path_1.join)(appRoot, '.adonisrc.json'))));
|
|
20
|
-
}
|
|
21
|
-
exports.default = default_1;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { BaseCommand } from '@adonisjs/core/build/standalone'
|
|
2
|
-
|
|
3
|
-
export default class {{ filename }} extends BaseCommand {
|
|
4
|
-
/**
|
|
5
|
-
* Command name is used to run the command
|
|
6
|
-
*/
|
|
7
|
-
public static commandName = '{{#toCommandName}}{{ filename }}{{/toCommandName}}'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Command description is displayed in the "help" output
|
|
11
|
-
*/
|
|
12
|
-
public static description = ''
|
|
13
|
-
|
|
14
|
-
public static settings = {
|
|
15
|
-
/**
|
|
16
|
-
* Set the following value to true, if you want to load the application
|
|
17
|
-
* before running the command. Don't forget to call `node ace generate:manifest`
|
|
18
|
-
* afterwards.
|
|
19
|
-
*/
|
|
20
|
-
loadApp: false,
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Set the following value to true, if you want this command to keep running until
|
|
24
|
-
* you manually decide to exit the process. Don't forget to call
|
|
25
|
-
* `node ace generate:manifest` afterwards.
|
|
26
|
-
*/
|
|
27
|
-
stayAlive: false,
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public async run() {
|
|
31
|
-
this.logger.info('Hello world!')
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Exception } from '@adonisjs/core/build/standalone'
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
|--------------------------------------------------------------------------
|
|
5
|
-
| Exception
|
|
6
|
-
|--------------------------------------------------------------------------
|
|
7
|
-
|
|
|
8
|
-
| The Exception class imported from `@adonisjs/core` allows defining
|
|
9
|
-
| a status code and error code for every exception.
|
|
10
|
-
|
|
|
11
|
-
| @example
|
|
12
|
-
| new {{ filename }}('message', 500, 'E_RUNTIME_EXCEPTION')
|
|
13
|
-
|
|
|
14
|
-
*/
|
|
15
|
-
export default class {{ filename }} extends Exception {}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
|
2
|
-
|
|
3
|
-
export default class {{ filename }} {
|
|
4
|
-
public async handle({}: HttpContextContract, next: () => Promise<void>) {
|
|
5
|
-
// code for middleware goes here. ABOVE THE NEXT CALL
|
|
6
|
-
await next()
|
|
7
|
-
}
|
|
8
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|--------------------------------------------------------------------------
|
|
3
|
-
| Preloaded File
|
|
4
|
-
|--------------------------------------------------------------------------
|
|
5
|
-
|
|
|
6
|
-
| Any code written inside this file will be executed during the application
|
|
7
|
-
| boot.
|
|
8
|
-
|
|
|
9
|
-
*/
|