@adonisjs/assembler 6.1.3-2 → 6.1.3-21
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/README.md +3 -6
- package/build/index.d.ts +1 -0
- package/build/index.js +9 -0
- package/build/src/assets_dev_server.d.ts +32 -0
- package/build/src/assets_dev_server.js +158 -0
- package/build/src/bundler.d.ts +9 -0
- package/build/src/bundler.js +70 -17
- package/build/src/code_transformer/main.d.ts +28 -0
- package/build/src/code_transformer/main.js +201 -0
- package/build/src/code_transformer/rc_file_transformer.d.ts +43 -0
- package/build/src/code_transformer/rc_file_transformer.js +272 -0
- package/build/src/debug.d.ts +3 -0
- package/build/src/debug.js +10 -0
- package/build/src/dev_server.d.ts +32 -0
- package/build/src/dev_server.js +146 -179
- package/build/src/helpers.d.ts +50 -0
- package/build/src/helpers.js +183 -0
- package/build/src/test_runner.d.ts +47 -0
- package/build/src/test_runner.js +310 -0
- package/build/src/types.d.ts +102 -0
- package/build/src/types.js +8 -0
- package/package.json +52 -66
- package/build/src/parse_config.d.ts +0 -3
- package/build/src/parse_config.js +0 -15
- package/build/src/run.d.ts +0 -4
- package/build/src/run.js +0 -37
- package/build/src/watch.d.ts +0 -8
- package/build/src/watch.js +0 -12
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import type tsStatic from 'typescript';
|
|
3
|
+
import { type Logger } from '@poppinss/cliui';
|
|
4
|
+
import type { TestRunnerOptions } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Exposes the API to start the development. Optionally, the watch API can be
|
|
7
|
+
* used to watch for file changes and restart the development server.
|
|
8
|
+
*
|
|
9
|
+
* The Dev server performs the following actions
|
|
10
|
+
*
|
|
11
|
+
* - Assigns a random PORT, when PORT inside .env file is in use
|
|
12
|
+
* - Uses tsconfig.json file to collect a list of files to watch.
|
|
13
|
+
* - Uses metaFiles from .adonisrc.json file to collect a list of files to watch.
|
|
14
|
+
* - Restart HTTP server on every file change.
|
|
15
|
+
*/
|
|
16
|
+
export declare class TestRunner {
|
|
17
|
+
#private;
|
|
18
|
+
constructor(cwd: URL, options: TestRunnerOptions);
|
|
19
|
+
/**
|
|
20
|
+
* Set a custom CLI UI logger
|
|
21
|
+
*/
|
|
22
|
+
setLogger(logger: Logger): this;
|
|
23
|
+
/**
|
|
24
|
+
* Add listener to get notified when dev server is
|
|
25
|
+
* closed
|
|
26
|
+
*/
|
|
27
|
+
onClose(callback: (exitCode: number) => any): this;
|
|
28
|
+
/**
|
|
29
|
+
* Add listener to get notified when dev server exists
|
|
30
|
+
* with an error
|
|
31
|
+
*/
|
|
32
|
+
onError(callback: (error: any) => any): this;
|
|
33
|
+
/**
|
|
34
|
+
* Close watchers and running child processes
|
|
35
|
+
*/
|
|
36
|
+
close(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Runs tests
|
|
39
|
+
*/
|
|
40
|
+
run(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Run tests in watch mode
|
|
43
|
+
*/
|
|
44
|
+
runAndWatch(ts: typeof tsStatic, options?: {
|
|
45
|
+
poll: boolean;
|
|
46
|
+
}): Promise<void>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @adonisjs/assembler
|
|
3
|
+
*
|
|
4
|
+
* (c) AdonisJS
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
import picomatch from 'picomatch';
|
|
10
|
+
import { cliui } from '@poppinss/cliui';
|
|
11
|
+
import { AssetsDevServer } from './assets_dev_server.js';
|
|
12
|
+
import { getPort, isDotEnvFile, runNode, watch } from './helpers.js';
|
|
13
|
+
/**
|
|
14
|
+
* Instance of CLIUI
|
|
15
|
+
*/
|
|
16
|
+
const ui = cliui();
|
|
17
|
+
/**
|
|
18
|
+
* Exposes the API to start the development. Optionally, the watch API can be
|
|
19
|
+
* used to watch for file changes and restart the development server.
|
|
20
|
+
*
|
|
21
|
+
* The Dev server performs the following actions
|
|
22
|
+
*
|
|
23
|
+
* - Assigns a random PORT, when PORT inside .env file is in use
|
|
24
|
+
* - Uses tsconfig.json file to collect a list of files to watch.
|
|
25
|
+
* - Uses metaFiles from .adonisrc.json file to collect a list of files to watch.
|
|
26
|
+
* - Restart HTTP server on every file change.
|
|
27
|
+
*/
|
|
28
|
+
export class TestRunner {
|
|
29
|
+
#cwd;
|
|
30
|
+
#logger = ui.logger;
|
|
31
|
+
#options;
|
|
32
|
+
#scriptFile = 'bin/test.js';
|
|
33
|
+
#isMetaFile;
|
|
34
|
+
#isTestFile;
|
|
35
|
+
#scriptArgs;
|
|
36
|
+
#initialFiltersArgs;
|
|
37
|
+
/**
|
|
38
|
+
* In watch mode, after a file is changed, we wait for the current
|
|
39
|
+
* set of tests to finish before triggering a re-run. Therefore,
|
|
40
|
+
* we use this flag to know if we are already busy in running
|
|
41
|
+
* tests and ignore file-changes.
|
|
42
|
+
*/
|
|
43
|
+
#isBusy = false;
|
|
44
|
+
#onError;
|
|
45
|
+
#onClose;
|
|
46
|
+
#testScript;
|
|
47
|
+
#watcher;
|
|
48
|
+
#assetsServer;
|
|
49
|
+
/**
|
|
50
|
+
* Getting reference to colors library from logger
|
|
51
|
+
*/
|
|
52
|
+
get #colors() {
|
|
53
|
+
return this.#logger.getColors();
|
|
54
|
+
}
|
|
55
|
+
constructor(cwd, options) {
|
|
56
|
+
this.#cwd = cwd;
|
|
57
|
+
this.#options = options;
|
|
58
|
+
this.#isMetaFile = picomatch((this.#options.metaFiles || []).map(({ pattern }) => pattern));
|
|
59
|
+
this.#isTestFile = picomatch(this.#options.suites
|
|
60
|
+
.filter((suite) => {
|
|
61
|
+
if (this.#options.filters.suites) {
|
|
62
|
+
return this.#options.filters.suites.includes(suite.name);
|
|
63
|
+
}
|
|
64
|
+
return true;
|
|
65
|
+
})
|
|
66
|
+
.map((suite) => suite.files)
|
|
67
|
+
.flat(1));
|
|
68
|
+
this.#scriptArgs = this.#convertOptionsToArgs().concat(this.#options.scriptArgs);
|
|
69
|
+
this.#initialFiltersArgs = this.#convertFiltersToArgs(this.#options.filters);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Converts options to CLI args
|
|
73
|
+
*/
|
|
74
|
+
#convertOptionsToArgs() {
|
|
75
|
+
const args = [];
|
|
76
|
+
if (this.#options.reporters) {
|
|
77
|
+
args.push('--reporters');
|
|
78
|
+
args.push(this.#options.reporters.join(','));
|
|
79
|
+
}
|
|
80
|
+
if (this.#options.timeout !== undefined) {
|
|
81
|
+
args.push('--timeout');
|
|
82
|
+
args.push(String(this.#options.timeout));
|
|
83
|
+
}
|
|
84
|
+
if (this.#options.failed) {
|
|
85
|
+
args.push('--failed');
|
|
86
|
+
}
|
|
87
|
+
if (this.#options.retries !== undefined) {
|
|
88
|
+
args.push('--retries');
|
|
89
|
+
args.push(String(this.#options.retries));
|
|
90
|
+
}
|
|
91
|
+
return args;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Converts all known filters to CLI args.
|
|
95
|
+
*
|
|
96
|
+
* The following code snippet may seem like repetitive code. But, it
|
|
97
|
+
* is done intentionally to have visibility around how each filter
|
|
98
|
+
* is converted to an arg.
|
|
99
|
+
*/
|
|
100
|
+
#convertFiltersToArgs(filters) {
|
|
101
|
+
const args = [];
|
|
102
|
+
if (filters.suites) {
|
|
103
|
+
args.push(...filters.suites);
|
|
104
|
+
}
|
|
105
|
+
if (filters.files) {
|
|
106
|
+
args.push('--files');
|
|
107
|
+
args.push(filters.files.join(','));
|
|
108
|
+
}
|
|
109
|
+
if (filters.groups) {
|
|
110
|
+
args.push('--groups');
|
|
111
|
+
args.push(filters.groups.join(','));
|
|
112
|
+
}
|
|
113
|
+
if (filters.tags) {
|
|
114
|
+
args.push('--tags');
|
|
115
|
+
args.push(filters.tags.join(','));
|
|
116
|
+
}
|
|
117
|
+
if (filters.tests) {
|
|
118
|
+
args.push('--tests');
|
|
119
|
+
args.push(filters.tests.join(','));
|
|
120
|
+
}
|
|
121
|
+
return args;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Conditionally clear the terminal screen
|
|
125
|
+
*/
|
|
126
|
+
#clearScreen() {
|
|
127
|
+
if (this.#options.clearScreen) {
|
|
128
|
+
process.stdout.write('\u001Bc');
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Runs tests
|
|
133
|
+
*/
|
|
134
|
+
#runTests(port, mode, filters) {
|
|
135
|
+
this.#isBusy = true;
|
|
136
|
+
const scriptArgs = filters
|
|
137
|
+
? this.#convertFiltersToArgs(filters).concat(this.#scriptArgs)
|
|
138
|
+
: this.#initialFiltersArgs.concat(this.#scriptArgs);
|
|
139
|
+
this.#testScript = runNode(this.#cwd, {
|
|
140
|
+
script: this.#scriptFile,
|
|
141
|
+
env: { PORT: port, ...this.#options.env },
|
|
142
|
+
nodeArgs: this.#options.nodeArgs,
|
|
143
|
+
scriptArgs,
|
|
144
|
+
});
|
|
145
|
+
this.#testScript
|
|
146
|
+
.then((result) => {
|
|
147
|
+
if (mode === 'nonblocking') {
|
|
148
|
+
this.#onClose?.(result.exitCode);
|
|
149
|
+
this.close();
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
.catch((error) => {
|
|
153
|
+
if (mode === 'nonblocking') {
|
|
154
|
+
this.#onError?.(error);
|
|
155
|
+
this.close();
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
.finally(() => {
|
|
159
|
+
this.#isBusy = false;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Restarts the HTTP server
|
|
164
|
+
*/
|
|
165
|
+
#rerunTests(port, filters) {
|
|
166
|
+
if (this.#testScript) {
|
|
167
|
+
this.#testScript.removeAllListeners();
|
|
168
|
+
this.#testScript.kill('SIGKILL');
|
|
169
|
+
}
|
|
170
|
+
this.#runTests(port, 'blocking', filters);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Starts the assets server
|
|
174
|
+
*/
|
|
175
|
+
#startAssetsServer() {
|
|
176
|
+
this.#assetsServer = new AssetsDevServer(this.#cwd, this.#options.assets);
|
|
177
|
+
this.#assetsServer.setLogger(this.#logger);
|
|
178
|
+
this.#assetsServer.start();
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Handles a non TypeScript file change
|
|
182
|
+
*/
|
|
183
|
+
#handleFileChange(action, port, relativePath) {
|
|
184
|
+
if (this.#isBusy) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (isDotEnvFile(relativePath) || this.#isMetaFile(relativePath)) {
|
|
188
|
+
this.#clearScreen();
|
|
189
|
+
this.#logger.log(`${this.#colors.green(action)} ${relativePath}`);
|
|
190
|
+
this.#rerunTests(port);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Handles TypeScript source file change
|
|
195
|
+
*/
|
|
196
|
+
#handleSourceFileChange(action, port, relativePath) {
|
|
197
|
+
if (this.#isBusy) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
this.#clearScreen();
|
|
201
|
+
this.#logger.log(`${this.#colors.green(action)} ${relativePath}`);
|
|
202
|
+
/**
|
|
203
|
+
* If changed file is a test file after considering the initial filters,
|
|
204
|
+
* then only run that file
|
|
205
|
+
*/
|
|
206
|
+
if (this.#isTestFile(relativePath)) {
|
|
207
|
+
this.#rerunTests(port, {
|
|
208
|
+
...this.#options.filters,
|
|
209
|
+
files: [relativePath],
|
|
210
|
+
});
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
this.#rerunTests(port);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Set a custom CLI UI logger
|
|
217
|
+
*/
|
|
218
|
+
setLogger(logger) {
|
|
219
|
+
this.#logger = logger;
|
|
220
|
+
this.#assetsServer?.setLogger(logger);
|
|
221
|
+
return this;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Add listener to get notified when dev server is
|
|
225
|
+
* closed
|
|
226
|
+
*/
|
|
227
|
+
onClose(callback) {
|
|
228
|
+
this.#onClose = callback;
|
|
229
|
+
return this;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Add listener to get notified when dev server exists
|
|
233
|
+
* with an error
|
|
234
|
+
*/
|
|
235
|
+
onError(callback) {
|
|
236
|
+
this.#onError = callback;
|
|
237
|
+
return this;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Close watchers and running child processes
|
|
241
|
+
*/
|
|
242
|
+
async close() {
|
|
243
|
+
await this.#watcher?.close();
|
|
244
|
+
this.#assetsServer?.stop();
|
|
245
|
+
if (this.#testScript) {
|
|
246
|
+
this.#testScript.removeAllListeners();
|
|
247
|
+
this.#testScript.kill('SIGKILL');
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Runs tests
|
|
252
|
+
*/
|
|
253
|
+
async run() {
|
|
254
|
+
const port = String(await getPort(this.#cwd));
|
|
255
|
+
this.#clearScreen();
|
|
256
|
+
this.#startAssetsServer();
|
|
257
|
+
this.#logger.info('booting application to run tests...');
|
|
258
|
+
this.#runTests(port, 'nonblocking');
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Run tests in watch mode
|
|
262
|
+
*/
|
|
263
|
+
async runAndWatch(ts, options) {
|
|
264
|
+
const port = String(await getPort(this.#cwd));
|
|
265
|
+
this.#clearScreen();
|
|
266
|
+
this.#startAssetsServer();
|
|
267
|
+
this.#logger.info('booting application to run tests...');
|
|
268
|
+
this.#runTests(port, 'blocking');
|
|
269
|
+
/**
|
|
270
|
+
* Create watcher using tsconfig.json file
|
|
271
|
+
*/
|
|
272
|
+
const output = watch(this.#cwd, ts, options || {});
|
|
273
|
+
if (!output) {
|
|
274
|
+
this.#onClose?.(1);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Storing reference to watcher, so that we can close it
|
|
279
|
+
* when HTTP server exists with error
|
|
280
|
+
*/
|
|
281
|
+
this.#watcher = output.chokidar;
|
|
282
|
+
/**
|
|
283
|
+
* Notify the watcher is ready
|
|
284
|
+
*/
|
|
285
|
+
output.watcher.on('watcher:ready', () => {
|
|
286
|
+
this.#logger.info('watching file system for changes...');
|
|
287
|
+
});
|
|
288
|
+
/**
|
|
289
|
+
* Cleanup when watcher dies
|
|
290
|
+
*/
|
|
291
|
+
output.chokidar.on('error', (error) => {
|
|
292
|
+
this.#logger.warning('file system watcher failure');
|
|
293
|
+
this.#logger.fatal(error);
|
|
294
|
+
this.#onError?.(error);
|
|
295
|
+
output.chokidar.close();
|
|
296
|
+
});
|
|
297
|
+
/**
|
|
298
|
+
* Changes in TypeScript source file
|
|
299
|
+
*/
|
|
300
|
+
output.watcher.on('source:add', ({ relativePath }) => this.#handleSourceFileChange('add', port, relativePath));
|
|
301
|
+
output.watcher.on('source:change', ({ relativePath }) => this.#handleSourceFileChange('update', port, relativePath));
|
|
302
|
+
output.watcher.on('source:unlink', ({ relativePath }) => this.#handleSourceFileChange('delete', port, relativePath));
|
|
303
|
+
/**
|
|
304
|
+
* Changes in non-TypeScript source files
|
|
305
|
+
*/
|
|
306
|
+
output.watcher.on('add', ({ relativePath }) => this.#handleFileChange('add', port, relativePath));
|
|
307
|
+
output.watcher.on('change', ({ relativePath }) => this.#handleFileChange('update', port, relativePath));
|
|
308
|
+
output.watcher.on('unlink', ({ relativePath }) => this.#handleFileChange('delete', port, relativePath));
|
|
309
|
+
}
|
|
310
|
+
}
|
package/build/src/types.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/**
|
|
3
|
+
* Options needed to run a script file
|
|
4
|
+
*/
|
|
2
5
|
export type RunOptions = {
|
|
3
6
|
script: string;
|
|
4
7
|
scriptArgs: string[];
|
|
@@ -6,22 +9,43 @@ export type RunOptions = {
|
|
|
6
9
|
stdio?: 'pipe' | 'inherit';
|
|
7
10
|
env?: NodeJS.ProcessEnv;
|
|
8
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Watcher options
|
|
14
|
+
*/
|
|
9
15
|
export type WatchOptions = {
|
|
10
16
|
poll?: boolean;
|
|
11
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* Meta file config defined in ".adonisrc.json" file
|
|
20
|
+
*/
|
|
12
21
|
export type MetaFile = {
|
|
13
22
|
pattern: string;
|
|
14
23
|
reloadServer: boolean;
|
|
15
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Test suite defined in ".adonisrc.json" file
|
|
27
|
+
*/
|
|
28
|
+
export type Suite = {
|
|
29
|
+
files: string | string[];
|
|
30
|
+
name: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Options accepted by assets bundler
|
|
34
|
+
*/
|
|
16
35
|
export type AssetsBundlerOptions = {
|
|
17
36
|
serve: false;
|
|
37
|
+
args?: string[];
|
|
18
38
|
driver?: string;
|
|
19
39
|
cmd?: string;
|
|
20
40
|
} | {
|
|
21
41
|
serve: true;
|
|
42
|
+
args: string[];
|
|
22
43
|
driver: string;
|
|
23
44
|
cmd: string;
|
|
24
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Options accepted by the dev server
|
|
48
|
+
*/
|
|
25
49
|
export type DevServerOptions = {
|
|
26
50
|
scriptArgs: string[];
|
|
27
51
|
nodeArgs: string[];
|
|
@@ -30,7 +54,85 @@ export type DevServerOptions = {
|
|
|
30
54
|
metaFiles?: MetaFile[];
|
|
31
55
|
assets?: AssetsBundlerOptions;
|
|
32
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* Options accepted by the test runner
|
|
59
|
+
*/
|
|
60
|
+
export type TestRunnerOptions = {
|
|
61
|
+
/**
|
|
62
|
+
* Filter arguments are provided as a key-value
|
|
63
|
+
* pair, so that we can mutate them (if needed)
|
|
64
|
+
*/
|
|
65
|
+
filters: Partial<{
|
|
66
|
+
tests: string[];
|
|
67
|
+
suites: string[];
|
|
68
|
+
groups: string[];
|
|
69
|
+
files: string[];
|
|
70
|
+
tags: string[];
|
|
71
|
+
}>;
|
|
72
|
+
reporters?: string[];
|
|
73
|
+
timeout?: number;
|
|
74
|
+
retries?: number;
|
|
75
|
+
failed?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* All other tags are provided as a collection of
|
|
78
|
+
* arguments
|
|
79
|
+
*/
|
|
80
|
+
scriptArgs: string[];
|
|
81
|
+
nodeArgs: string[];
|
|
82
|
+
clearScreen?: boolean;
|
|
83
|
+
env?: NodeJS.ProcessEnv;
|
|
84
|
+
metaFiles?: MetaFile[];
|
|
85
|
+
assets?: AssetsBundlerOptions;
|
|
86
|
+
suites: Suite[];
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Options accepted by the project bundler
|
|
90
|
+
*/
|
|
33
91
|
export type BundlerOptions = {
|
|
34
92
|
metaFiles?: MetaFile[];
|
|
35
93
|
assets?: AssetsBundlerOptions;
|
|
36
94
|
};
|
|
95
|
+
/**
|
|
96
|
+
* Entry to add a middleware to a given middleware stack
|
|
97
|
+
* via the CodeTransformer
|
|
98
|
+
*/
|
|
99
|
+
export type AddMiddlewareEntry = {
|
|
100
|
+
/**
|
|
101
|
+
* If you are adding a named middleware, then you must
|
|
102
|
+
* define the name.
|
|
103
|
+
*/
|
|
104
|
+
name?: string;
|
|
105
|
+
/**
|
|
106
|
+
* The path to the middleware file
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* `@adonisjs/static/static_middleware`
|
|
110
|
+
* `#middlewares/silent_auth.js`
|
|
111
|
+
*/
|
|
112
|
+
path: string;
|
|
113
|
+
/**
|
|
114
|
+
* The position to add the middleware. If `before`
|
|
115
|
+
* middleware will be added at the first position and
|
|
116
|
+
* therefore will be run before all others
|
|
117
|
+
*
|
|
118
|
+
* @default 'after'
|
|
119
|
+
*/
|
|
120
|
+
position?: 'before' | 'after';
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Defines the structure of an environment variable validation
|
|
124
|
+
* definition
|
|
125
|
+
*/
|
|
126
|
+
export type EnvValidationDefinition = {
|
|
127
|
+
/**
|
|
128
|
+
* Write a leading comment on top of your variables
|
|
129
|
+
*/
|
|
130
|
+
leadingComment?: string;
|
|
131
|
+
/**
|
|
132
|
+
* A key-value pair of env variables and their validation
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* MY_VAR: 'Env.schema.string.optional()'
|
|
136
|
+
*/
|
|
137
|
+
variables: Record<string, string>;
|
|
138
|
+
};
|
package/build/src/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/assembler",
|
|
3
|
-
"version": "6.1.3-2",
|
|
4
3
|
"description": "Provides utilities to run AdonisJS development server and build project for production",
|
|
4
|
+
"version": "6.1.3-21",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=18.16.0"
|
|
7
|
+
},
|
|
5
8
|
"main": "build/index.js",
|
|
6
9
|
"type": "module",
|
|
7
10
|
"files": [
|
|
@@ -11,13 +14,15 @@
|
|
|
11
14
|
],
|
|
12
15
|
"exports": {
|
|
13
16
|
".": "./build/index.js",
|
|
17
|
+
"./code_transformer": "./build/src/code_transformer/main.js",
|
|
14
18
|
"./types": "./build/src/types.js"
|
|
15
19
|
},
|
|
16
20
|
"scripts": {
|
|
17
21
|
"pretest": "npm run lint",
|
|
18
|
-
"test": "cross-env NODE_DEBUG=chokidar:ts c8 npm run
|
|
22
|
+
"test": "cross-env NODE_DEBUG=chokidar:ts c8 npm run quick:test",
|
|
19
23
|
"lint": "eslint . --ext=.ts",
|
|
20
24
|
"clean": "del-cli build",
|
|
25
|
+
"typecheck": "tsc --noEmit",
|
|
21
26
|
"compile": "npm run lint && npm run clean && tsc",
|
|
22
27
|
"build": "npm run compile",
|
|
23
28
|
"release": "np",
|
|
@@ -25,54 +30,54 @@
|
|
|
25
30
|
"sync-labels": "github-label-sync --labels .github/labels.json adonisjs/assembler",
|
|
26
31
|
"format": "prettier --write .",
|
|
27
32
|
"prepublishOnly": "npm run build",
|
|
28
|
-
"
|
|
33
|
+
"quick:test": "node --enable-source-maps --loader=ts-node/esm bin/test.ts"
|
|
29
34
|
},
|
|
30
|
-
"keywords": [
|
|
31
|
-
"adonisjs",
|
|
32
|
-
"build",
|
|
33
|
-
"ts"
|
|
34
|
-
],
|
|
35
|
-
"author": "virk,adonisjs",
|
|
36
|
-
"license": "MIT",
|
|
37
35
|
"devDependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@japa/
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"
|
|
36
|
+
"@adonisjs/application": "^7.1.2-12",
|
|
37
|
+
"@adonisjs/eslint-config": "^1.1.8",
|
|
38
|
+
"@adonisjs/prettier-config": "^1.1.8",
|
|
39
|
+
"@adonisjs/tsconfig": "^1.1.8",
|
|
40
|
+
"@commitlint/cli": "^17.6.7",
|
|
41
|
+
"@commitlint/config-conventional": "^17.6.7",
|
|
42
|
+
"@japa/assert": "^2.0.0-1",
|
|
43
|
+
"@japa/file-system": "^2.0.0-1",
|
|
44
|
+
"@japa/runner": "^3.0.0-6",
|
|
45
|
+
"@japa/snapshot": "2.0.0-1",
|
|
46
|
+
"@swc/core": "^1.3.71",
|
|
47
|
+
"@types/node": "^20.4.5",
|
|
48
|
+
"@types/picomatch": "^2.3.0",
|
|
49
|
+
"c8": "^8.0.1",
|
|
48
50
|
"cross-env": "^7.0.3",
|
|
51
|
+
"dedent": "^1.5.1",
|
|
49
52
|
"del-cli": "^5.0.0",
|
|
50
|
-
"eslint": "^8.
|
|
51
|
-
"eslint-config-prettier": "^8.7.0",
|
|
52
|
-
"eslint-plugin-adonis": "^3.0.3",
|
|
53
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
53
|
+
"eslint": "^8.45.0",
|
|
54
54
|
"github-label-sync": "^2.3.1",
|
|
55
55
|
"husky": "^8.0.3",
|
|
56
|
-
"np": "^
|
|
57
|
-
"p-event": "^
|
|
58
|
-
"prettier": "^
|
|
56
|
+
"np": "^8.0.4",
|
|
57
|
+
"p-event": "^6.0.0",
|
|
58
|
+
"prettier": "^3.0.0",
|
|
59
59
|
"ts-node": "^10.9.1",
|
|
60
|
-
"typescript": "^
|
|
60
|
+
"typescript": "^5.1.6"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@adonisjs/env": "^4.2.0-
|
|
64
|
-
"@poppinss/chokidar-ts": "^4.1.0-
|
|
65
|
-
"@poppinss/cliui": "^6.1.1-
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"get-port": "^
|
|
63
|
+
"@adonisjs/env": "^4.2.0-3",
|
|
64
|
+
"@poppinss/chokidar-ts": "^4.1.0-6",
|
|
65
|
+
"@poppinss/cliui": "^6.1.1-3",
|
|
66
|
+
"cpy": "^10.1.0",
|
|
67
|
+
"execa": "^7.1.1",
|
|
68
|
+
"fast-glob": "^3.3.1",
|
|
69
|
+
"get-port": "^7.0.0",
|
|
70
|
+
"junk": "^4.0.1",
|
|
70
71
|
"picomatch": "^2.3.1",
|
|
71
|
-
"slash": "^5.
|
|
72
|
+
"slash": "^5.1.0",
|
|
73
|
+
"ts-morph": "^19.0.0"
|
|
72
74
|
},
|
|
73
75
|
"peerDependencies": {
|
|
74
76
|
"typescript": "^4.0.0 || ^5.0.0"
|
|
75
77
|
},
|
|
78
|
+
"author": "virk,adonisjs",
|
|
79
|
+
"license": "MIT",
|
|
80
|
+
"homepage": "https://github.com/adonisjs/assembler#readme",
|
|
76
81
|
"repository": {
|
|
77
82
|
"type": "git",
|
|
78
83
|
"url": "git+ssh://git@github.com/adonisjs/assembler.git"
|
|
@@ -80,37 +85,15 @@
|
|
|
80
85
|
"bugs": {
|
|
81
86
|
"url": "https://github.com/adonisjs/assembler/issues"
|
|
82
87
|
},
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
"
|
|
86
|
-
|
|
87
|
-
"prettier"
|
|
88
|
-
],
|
|
89
|
-
"plugins": [
|
|
90
|
-
"prettier"
|
|
91
|
-
],
|
|
92
|
-
"rules": {
|
|
93
|
-
"prettier/prettier": [
|
|
94
|
-
"error",
|
|
95
|
-
{
|
|
96
|
-
"endOfLine": "auto"
|
|
97
|
-
}
|
|
98
|
-
]
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
"eslintIgnore": [
|
|
102
|
-
"build"
|
|
88
|
+
"keywords": [
|
|
89
|
+
"adonisjs",
|
|
90
|
+
"build",
|
|
91
|
+
"ts"
|
|
103
92
|
],
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"semi": false,
|
|
107
|
-
"singleQuote": true,
|
|
108
|
-
"useTabs": false,
|
|
109
|
-
"quoteProps": "consistent",
|
|
110
|
-
"bracketSpacing": true,
|
|
111
|
-
"arrowParens": "always",
|
|
112
|
-
"printWidth": 100
|
|
93
|
+
"eslintConfig": {
|
|
94
|
+
"extends": "@adonisjs/eslint-config/package"
|
|
113
95
|
},
|
|
96
|
+
"prettier": "@adonisjs/prettier-config",
|
|
114
97
|
"commitlint": {
|
|
115
98
|
"extends": [
|
|
116
99
|
"@commitlint/config-conventional"
|
|
@@ -134,7 +117,10 @@
|
|
|
134
117
|
"exclude": [
|
|
135
118
|
"tests/**",
|
|
136
119
|
"build/**",
|
|
137
|
-
"examples/**"
|
|
120
|
+
"examples/**",
|
|
121
|
+
"src/dev_server.ts",
|
|
122
|
+
"src/test_runner.ts",
|
|
123
|
+
"src/assets_dev_server.ts"
|
|
138
124
|
]
|
|
139
125
|
}
|
|
140
126
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ConfigParser } from '@poppinss/chokidar-ts';
|
|
2
|
-
export function parseConfig(cwd, ts) {
|
|
3
|
-
const { config, error } = new ConfigParser(cwd, 'tsconfig.json', ts).parse();
|
|
4
|
-
if (error) {
|
|
5
|
-
const compilerHost = ts.createCompilerHost({});
|
|
6
|
-
console.log(ts.formatDiagnosticsWithColorAndContext([error], compilerHost));
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
if (config.errors.length) {
|
|
10
|
-
const compilerHost = ts.createCompilerHost({});
|
|
11
|
-
console.log(ts.formatDiagnosticsWithColorAndContext(config.errors, compilerHost));
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
return config;
|
|
15
|
-
}
|