@adonisjs/assembler 8.0.0-next.6 → 8.0.0-next.8
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/{chunk-MC3FJR62.js → chunk-N6H4XTTC.js} +25 -31
- package/build/{chunk-F4RAGKQN.js → chunk-PORDZS62.js} +5 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +276 -72
- package/build/src/bundler.d.ts +4 -0
- package/build/src/code_scanners/routes_scanner/main.js +1 -1
- package/build/src/dev_server.d.ts +26 -7
- package/build/src/hooks.d.ts +224 -0
- package/build/src/index_generator/main.d.ts +4 -9
- package/build/src/index_generator/main.js +2 -2
- package/build/src/index_generator/source.d.ts +0 -6
- package/build/src/test_runner.d.ts +26 -7
- package/build/src/types/common.d.ts +7 -3
- package/build/src/types/hooks.d.ts +71 -14
- package/build/src/utils.d.ts +2 -5
- package/package.json +6 -4
package/build/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
IndexGenerator
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-N6H4XTTC.js";
|
|
4
4
|
import {
|
|
5
5
|
copyFiles,
|
|
6
6
|
debug_default,
|
|
@@ -12,15 +12,240 @@ import {
|
|
|
12
12
|
runNode,
|
|
13
13
|
throttle,
|
|
14
14
|
watch
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-PORDZS62.js";
|
|
16
|
+
|
|
17
|
+
// src/hooks.ts
|
|
18
|
+
var hooks = {
|
|
19
|
+
/**
|
|
20
|
+
* Hook called during application initialization. This is the first hook
|
|
21
|
+
* that gets executed when the assembler starts up.
|
|
22
|
+
*
|
|
23
|
+
* @param callback - Function to execute when the init event occurs
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```js
|
|
27
|
+
* hooks.init((app) => {
|
|
28
|
+
* console.log('Application is initializing')
|
|
29
|
+
* // Setup global configurations
|
|
30
|
+
* })
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
init(callback) {
|
|
34
|
+
return callback;
|
|
35
|
+
},
|
|
36
|
+
/**
|
|
37
|
+
* Hook called after routes have been committed to the router.
|
|
38
|
+
* This occurs after all route definitions have been processed.
|
|
39
|
+
*
|
|
40
|
+
* @param callback - Function to execute when routes are committed
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```js
|
|
44
|
+
* hooks.routesCommitted((router) => {
|
|
45
|
+
* console.log('All routes have been committed to the router')
|
|
46
|
+
* // Perform route-based setup
|
|
47
|
+
* })
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
routesCommitted(callback) {
|
|
51
|
+
return callback;
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* Hook called when the assembler starts scanning for route files.
|
|
55
|
+
* This happens before any route files are actually processed.
|
|
56
|
+
*
|
|
57
|
+
* @param callback - Function to execute when route scanning begins
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```js
|
|
61
|
+
* hooks.routesScanning(() => {
|
|
62
|
+
* console.log('Starting to scan for route files')
|
|
63
|
+
* // Setup route scanning configurations
|
|
64
|
+
* })
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
routesScanning(callback) {
|
|
68
|
+
return callback;
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* Hook called after all route files have been scanned and processed.
|
|
72
|
+
* This occurs once the route scanning phase is complete.
|
|
73
|
+
*
|
|
74
|
+
* @param callback - Function to execute when route scanning is finished
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```js
|
|
78
|
+
* hooks.routesScanned((scannedRoutes) => {
|
|
79
|
+
* console.log('Route scanning completed')
|
|
80
|
+
* // Process scanned route information
|
|
81
|
+
* })
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
routesScanned(callback) {
|
|
85
|
+
return callback;
|
|
86
|
+
},
|
|
87
|
+
/**
|
|
88
|
+
* Hook called when a file is modified during development.
|
|
89
|
+
* This is triggered by the file watcher when changes are detected.
|
|
90
|
+
*
|
|
91
|
+
* @param callback - Function to execute when a file changes
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```js
|
|
95
|
+
* hooks.fileChanged((filePath, stats) => {
|
|
96
|
+
* console.log(`File changed: ${filePath}`)
|
|
97
|
+
* // Handle file change logic
|
|
98
|
+
* })
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
fileChanged(callback) {
|
|
102
|
+
return callback;
|
|
103
|
+
},
|
|
104
|
+
/**
|
|
105
|
+
* Hook called when a new file is added during development.
|
|
106
|
+
* This is triggered by the file watcher when new files are created.
|
|
107
|
+
*
|
|
108
|
+
* @param callback - Function to execute when a file is added
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```js
|
|
112
|
+
* hooks.fileAdded((filePath, stats) => {
|
|
113
|
+
* console.log(`New file added: ${filePath}`)
|
|
114
|
+
* // Handle new file logic
|
|
115
|
+
* })
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
fileAdded(callback) {
|
|
119
|
+
return callback;
|
|
120
|
+
},
|
|
121
|
+
/**
|
|
122
|
+
* Hook called when a file is removed during development.
|
|
123
|
+
* This is triggered by the file watcher when files are deleted.
|
|
124
|
+
*
|
|
125
|
+
* @param callback - Function to execute when a file is removed
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```js
|
|
129
|
+
* hooks.fileRemoved((filePath) => {
|
|
130
|
+
* console.log(`File removed: ${filePath}`)
|
|
131
|
+
* // Handle file removal logic
|
|
132
|
+
* })
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
fileRemoved(callback) {
|
|
136
|
+
return callback;
|
|
137
|
+
},
|
|
138
|
+
/**
|
|
139
|
+
* Hook called when the development server is about to start.
|
|
140
|
+
* This occurs before the server begins listening for connections.
|
|
141
|
+
*
|
|
142
|
+
* @param callback - Function to execute when dev server is starting
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```js
|
|
146
|
+
* hooks.devServerStarting((server) => {
|
|
147
|
+
* console.log('Development server is starting')
|
|
148
|
+
* // Setup server configurations
|
|
149
|
+
* })
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
devServerStarting(callback) {
|
|
153
|
+
return callback;
|
|
154
|
+
},
|
|
155
|
+
/**
|
|
156
|
+
* Hook called after the development server has successfully started.
|
|
157
|
+
* This occurs once the server is listening and ready to accept requests.
|
|
158
|
+
*
|
|
159
|
+
* @param callback - Function to execute when dev server has started
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```js
|
|
163
|
+
* hooks.devServerStarted((server) => {
|
|
164
|
+
* console.log(`Development server started on port ${server.port}`)
|
|
165
|
+
* // Notify external services or open browser
|
|
166
|
+
* })
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
devServerStarted(callback) {
|
|
170
|
+
return callback;
|
|
171
|
+
},
|
|
172
|
+
/**
|
|
173
|
+
* Hook called when the build process is about to start.
|
|
174
|
+
* This occurs before any build tasks are executed.
|
|
175
|
+
*
|
|
176
|
+
* @param callback - Function to execute when build is starting
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```js
|
|
180
|
+
* hooks.buildStarting((buildConfig) => {
|
|
181
|
+
* console.log('Build process is starting')
|
|
182
|
+
* // Setup build configurations or clean directories
|
|
183
|
+
* })
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
buildStarting(callback) {
|
|
187
|
+
return callback;
|
|
188
|
+
},
|
|
189
|
+
/**
|
|
190
|
+
* Hook called after the build process has completed.
|
|
191
|
+
* This occurs once all build tasks have finished executing.
|
|
192
|
+
*
|
|
193
|
+
* @param callback - Function to execute when build is finished
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```js
|
|
197
|
+
* hooks.buildFinished((buildResult) => {
|
|
198
|
+
* console.log('Build process completed')
|
|
199
|
+
* // Deploy artifacts or notify build completion
|
|
200
|
+
* })
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
buildFinished(callback) {
|
|
204
|
+
return callback;
|
|
205
|
+
},
|
|
206
|
+
/**
|
|
207
|
+
* Hook called when the test suite is about to start.
|
|
208
|
+
* This occurs before any test files are executed.
|
|
209
|
+
*
|
|
210
|
+
* @param callback - Function to execute when tests are starting
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```js
|
|
214
|
+
* hooks.testsStarting((testConfig) => {
|
|
215
|
+
* console.log('Test suite is starting')
|
|
216
|
+
* // Setup test database or mock services
|
|
217
|
+
* })
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
testsStarting(callback) {
|
|
221
|
+
return callback;
|
|
222
|
+
},
|
|
223
|
+
/**
|
|
224
|
+
* Hook called after the test suite has completed.
|
|
225
|
+
* This occurs once all test files have finished executing.
|
|
226
|
+
*
|
|
227
|
+
* @param callback - Function to execute when tests are finished
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```js
|
|
231
|
+
* hooks.testsFinished((testResults) => {
|
|
232
|
+
* console.log('Test suite completed')
|
|
233
|
+
* // Generate test reports or cleanup test resources
|
|
234
|
+
* })
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
testsFinished(callback) {
|
|
238
|
+
return callback;
|
|
239
|
+
}
|
|
240
|
+
};
|
|
16
241
|
|
|
17
242
|
// src/bundler.ts
|
|
18
243
|
import dedent from "dedent";
|
|
19
244
|
import fs from "fs/promises";
|
|
20
245
|
import { cliui } from "@poppinss/cliui";
|
|
21
246
|
import { fileURLToPath } from "url";
|
|
22
|
-
import { join, relative } from "path";
|
|
23
247
|
import string from "@poppinss/utils/string";
|
|
248
|
+
import { join, relative } from "path/posix";
|
|
24
249
|
import { detectPackageManager } from "@antfu/install-pkg";
|
|
25
250
|
var SUPPORTED_PACKAGE_MANAGERS = {
|
|
26
251
|
"npm": {
|
|
@@ -45,10 +270,6 @@ var SUPPORTED_PACKAGE_MANAGERS = {
|
|
|
45
270
|
}
|
|
46
271
|
};
|
|
47
272
|
var Bundler = class {
|
|
48
|
-
/**
|
|
49
|
-
* The current working project directory path as string
|
|
50
|
-
*/
|
|
51
|
-
#cwdPath;
|
|
52
273
|
/**
|
|
53
274
|
* Reference to the TypeScript module
|
|
54
275
|
*/
|
|
@@ -57,6 +278,10 @@ var Bundler = class {
|
|
|
57
278
|
* Hooks to execute custom actions during the build process
|
|
58
279
|
*/
|
|
59
280
|
#hooks;
|
|
281
|
+
/**
|
|
282
|
+
* Index generator for managing auto-generated index files
|
|
283
|
+
*/
|
|
284
|
+
#indexGenerator;
|
|
60
285
|
/**
|
|
61
286
|
* CLI UI instance for displaying colorful messages and progress information
|
|
62
287
|
*/
|
|
@@ -65,6 +290,10 @@ var Bundler = class {
|
|
|
65
290
|
* The current working directory URL
|
|
66
291
|
*/
|
|
67
292
|
cwd;
|
|
293
|
+
/**
|
|
294
|
+
* The current working project directory path as string
|
|
295
|
+
*/
|
|
296
|
+
cwdPath;
|
|
68
297
|
/**
|
|
69
298
|
* Bundler configuration options including hooks and meta files
|
|
70
299
|
*/
|
|
@@ -79,7 +308,7 @@ var Bundler = class {
|
|
|
79
308
|
constructor(cwd, ts, options) {
|
|
80
309
|
this.cwd = cwd;
|
|
81
310
|
this.options = options;
|
|
82
|
-
this
|
|
311
|
+
this.cwdPath = string.toUnixSlash(fileURLToPath(this.cwd));
|
|
83
312
|
this.#ts = ts;
|
|
84
313
|
}
|
|
85
314
|
/**
|
|
@@ -87,7 +316,7 @@ var Bundler = class {
|
|
|
87
316
|
* file path
|
|
88
317
|
*/
|
|
89
318
|
#getRelativeName(filePath) {
|
|
90
|
-
return string.toUnixSlash(relative(this
|
|
319
|
+
return string.toUnixSlash(relative(this.cwdPath, filePath));
|
|
91
320
|
}
|
|
92
321
|
/**
|
|
93
322
|
* Cleans up the build directory
|
|
@@ -115,13 +344,13 @@ var Bundler = class {
|
|
|
115
344
|
*/
|
|
116
345
|
async #copyMetaFiles(outDir, additionalFilesToCopy) {
|
|
117
346
|
const metaFiles = (this.options.metaFiles || []).map((file) => file.pattern).concat(additionalFilesToCopy);
|
|
118
|
-
await copyFiles(metaFiles, this
|
|
347
|
+
await copyFiles(metaFiles, this.cwdPath, outDir);
|
|
119
348
|
}
|
|
120
349
|
/**
|
|
121
350
|
* Detect the package manager used by the project
|
|
122
351
|
*/
|
|
123
352
|
async #detectPackageManager() {
|
|
124
|
-
const pkgManager = await detectPackageManager(this
|
|
353
|
+
const pkgManager = await detectPackageManager(this.cwdPath);
|
|
125
354
|
if (pkgManager === "deno") {
|
|
126
355
|
return "npm";
|
|
127
356
|
}
|
|
@@ -163,12 +392,18 @@ var Bundler = class {
|
|
|
163
392
|
* const success = await bundler.bundle(true, 'npm')
|
|
164
393
|
*/
|
|
165
394
|
async bundle(stopOnError = true, client) {
|
|
166
|
-
this.#hooks = await loadHooks(this.options.hooks, ["buildStarting", "buildFinished"]);
|
|
167
395
|
this.packageManager = client ?? await this.#detectPackageManager() ?? "npm";
|
|
168
396
|
const config = parseConfig(this.cwd, this.#ts);
|
|
169
397
|
if (!config) {
|
|
170
398
|
return false;
|
|
171
399
|
}
|
|
400
|
+
this.ui.logger.info("loading hooks...");
|
|
401
|
+
this.#hooks = await loadHooks(this.options.hooks, ["init", "buildStarting", "buildFinished"]);
|
|
402
|
+
this.#indexGenerator = new IndexGenerator(this.cwdPath, this.ui.logger);
|
|
403
|
+
await this.#hooks.runner("init").run(this, this.#indexGenerator);
|
|
404
|
+
this.#hooks.clear("init");
|
|
405
|
+
this.ui.logger.info("generating indexes...");
|
|
406
|
+
await this.#indexGenerator.generate();
|
|
172
407
|
const outDir = config.options.outDir || fileURLToPath(new URL("build/", this.cwd));
|
|
173
408
|
this.ui.logger.info("cleaning up output directory", { suffix: this.#getRelativeName(outDir) });
|
|
174
409
|
await this.#cleanupBuildDirectory(outDir);
|
|
@@ -649,10 +884,6 @@ var DevServer = class _DevServer {
|
|
|
649
884
|
fullReload: true,
|
|
650
885
|
hotReloaded: false
|
|
651
886
|
};
|
|
652
|
-
/**
|
|
653
|
-
* File path computed from the cwd
|
|
654
|
-
*/
|
|
655
|
-
#cwdPath;
|
|
656
887
|
/**
|
|
657
888
|
* External listeners that are invoked when child process
|
|
658
889
|
* gets an error or closes
|
|
@@ -696,7 +927,7 @@ var DevServer = class _DevServer {
|
|
|
696
927
|
/**
|
|
697
928
|
* CLI UI instance for displaying colorful messages and progress information
|
|
698
929
|
*/
|
|
699
|
-
|
|
930
|
+
ui = cliui2();
|
|
700
931
|
/**
|
|
701
932
|
* Restarts the HTTP server and throttle concurrent calls to
|
|
702
933
|
* ensure we do not end up with a long loop of restarts
|
|
@@ -734,19 +965,6 @@ var DevServer = class _DevServer {
|
|
|
734
965
|
#cleanupKeyboardShortcuts() {
|
|
735
966
|
this.#shortcutsManager?.cleanup();
|
|
736
967
|
}
|
|
737
|
-
/**
|
|
738
|
-
* CLI UI instance to log colorful messages and progress information
|
|
739
|
-
*/
|
|
740
|
-
get ui() {
|
|
741
|
-
return this.#ui;
|
|
742
|
-
}
|
|
743
|
-
/**
|
|
744
|
-
* CLI UI instance to log colorful messages and progress information
|
|
745
|
-
*/
|
|
746
|
-
set ui(ui) {
|
|
747
|
-
this.#ui = ui;
|
|
748
|
-
this.#indexGenerator.setLogger(ui.logger);
|
|
749
|
-
}
|
|
750
968
|
/**
|
|
751
969
|
* The mode in which the DevServer is running.
|
|
752
970
|
*/
|
|
@@ -761,6 +979,10 @@ var DevServer = class _DevServer {
|
|
|
761
979
|
* The current working directory URL
|
|
762
980
|
*/
|
|
763
981
|
cwd;
|
|
982
|
+
/**
|
|
983
|
+
* File path computed from the cwd
|
|
984
|
+
*/
|
|
985
|
+
cwdPath;
|
|
764
986
|
/**
|
|
765
987
|
* Development server configuration options including hooks and environment variables
|
|
766
988
|
*/
|
|
@@ -774,8 +996,7 @@ var DevServer = class _DevServer {
|
|
|
774
996
|
constructor(cwd, options) {
|
|
775
997
|
this.cwd = cwd;
|
|
776
998
|
this.options = options;
|
|
777
|
-
this
|
|
778
|
-
this.#indexGenerator = new IndexGenerator(this.#cwdPath, this.ui.logger);
|
|
999
|
+
this.cwdPath = string3.toUnixSlash(fileURLToPath2(this.cwd));
|
|
779
1000
|
}
|
|
780
1001
|
/**
|
|
781
1002
|
* Type guard to check if child process message is from AdonisJS HTTP server
|
|
@@ -922,8 +1143,9 @@ var DevServer = class _DevServer {
|
|
|
922
1143
|
this.#mode = mode;
|
|
923
1144
|
this.#clearScreen();
|
|
924
1145
|
this.ui.logger.info(`starting server in ${this.#mode} mode...`);
|
|
1146
|
+
this.#indexGenerator = new IndexGenerator(this.cwdPath, this.ui.logger);
|
|
925
1147
|
this.#stickyPort = String(await getPort(this.cwd));
|
|
926
|
-
this.#fileSystem = new FileSystem(this
|
|
1148
|
+
this.#fileSystem = new FileSystem(this.cwdPath, tsConfig, this.options);
|
|
927
1149
|
this.ui.logger.info("loading hooks...");
|
|
928
1150
|
this.#hooks = await loadHooks(this.options.hooks, [
|
|
929
1151
|
"init",
|
|
@@ -972,7 +1194,7 @@ var DevServer = class _DevServer {
|
|
|
972
1194
|
} else if (this.#mode === "hmr" && this.#isHotHookMessage(message)) {
|
|
973
1195
|
debug_default("received hot-hook message %O", message);
|
|
974
1196
|
const absolutePath = message.path ? string3.toUnixSlash(message.path) : "";
|
|
975
|
-
const relativePath = relative3(this
|
|
1197
|
+
const relativePath = relative3(this.cwdPath, absolutePath);
|
|
976
1198
|
if (message.type === "hot-hook:file-changed") {
|
|
977
1199
|
const { action } = message;
|
|
978
1200
|
if (action === "add") {
|
|
@@ -1074,7 +1296,7 @@ var DevServer = class _DevServer {
|
|
|
1074
1296
|
await this.#startHTTPServer(this.#stickyPort);
|
|
1075
1297
|
this.#watcher = watch({
|
|
1076
1298
|
usePolling: options?.poll ?? false,
|
|
1077
|
-
cwd: this
|
|
1299
|
+
cwd: this.cwdPath,
|
|
1078
1300
|
ignoreInitial: true,
|
|
1079
1301
|
ignored: (file, stats) => {
|
|
1080
1302
|
if (!stats) {
|
|
@@ -1097,17 +1319,17 @@ var DevServer = class _DevServer {
|
|
|
1097
1319
|
});
|
|
1098
1320
|
this.#watcher.on("add", (filePath) => {
|
|
1099
1321
|
const relativePath = string3.toUnixSlash(filePath);
|
|
1100
|
-
const absolutePath = join2(this
|
|
1322
|
+
const absolutePath = join2(this.cwdPath, relativePath);
|
|
1101
1323
|
this.#hooks.runner("fileAdded").run(relativePath, absolutePath, this);
|
|
1102
1324
|
});
|
|
1103
1325
|
this.#watcher.on("change", (filePath) => {
|
|
1104
1326
|
const relativePath = string3.toUnixSlash(filePath);
|
|
1105
|
-
const absolutePath = join2(this
|
|
1327
|
+
const absolutePath = join2(this.cwdPath, relativePath);
|
|
1106
1328
|
this.#hooks.runner("fileChanged").run(relativePath, absolutePath, _DevServer.#WATCHER_INFO, this);
|
|
1107
1329
|
});
|
|
1108
1330
|
this.#watcher.on("unlink", (filePath) => {
|
|
1109
1331
|
const relativePath = string3.toUnixSlash(filePath);
|
|
1110
|
-
const absolutePath = join2(this
|
|
1332
|
+
const absolutePath = join2(this.cwdPath, relativePath);
|
|
1111
1333
|
this.#hooks.runner("fileRemoved").run(relativePath, absolutePath, this);
|
|
1112
1334
|
});
|
|
1113
1335
|
}
|
|
@@ -1148,10 +1370,6 @@ var TestRunner = class {
|
|
|
1148
1370
|
* Hooks to execute custom actions during the tests runner lifecycle
|
|
1149
1371
|
*/
|
|
1150
1372
|
#hooks;
|
|
1151
|
-
/**
|
|
1152
|
-
* The current working directory path as a string
|
|
1153
|
-
*/
|
|
1154
|
-
#cwdPath;
|
|
1155
1373
|
/**
|
|
1156
1374
|
* Index generator for managing auto-generated index files
|
|
1157
1375
|
*/
|
|
@@ -1159,7 +1377,7 @@ var TestRunner = class {
|
|
|
1159
1377
|
/**
|
|
1160
1378
|
* CLI UI instance for displaying colorful messages and progress information
|
|
1161
1379
|
*/
|
|
1162
|
-
|
|
1380
|
+
ui = cliui3();
|
|
1163
1381
|
/**
|
|
1164
1382
|
* Re-runs the test child process and throttle concurrent calls to
|
|
1165
1383
|
* ensure we do not end up with a long loop of restarts
|
|
@@ -1171,19 +1389,6 @@ var TestRunner = class {
|
|
|
1171
1389
|
}
|
|
1172
1390
|
await this.#runTests(this.#stickyPort, filters);
|
|
1173
1391
|
}, "reRunTests");
|
|
1174
|
-
/**
|
|
1175
|
-
* CLI UI instance to log colorful messages and progress information
|
|
1176
|
-
*/
|
|
1177
|
-
get ui() {
|
|
1178
|
-
return this.#ui;
|
|
1179
|
-
}
|
|
1180
|
-
/**
|
|
1181
|
-
* CLI UI instance to log colorful messages and progress information
|
|
1182
|
-
*/
|
|
1183
|
-
set ui(ui) {
|
|
1184
|
-
this.#ui = ui;
|
|
1185
|
-
this.#indexGenerator.setLogger(ui.logger);
|
|
1186
|
-
}
|
|
1187
1392
|
/**
|
|
1188
1393
|
* The script file to run as a child process
|
|
1189
1394
|
*/
|
|
@@ -1192,6 +1397,10 @@ var TestRunner = class {
|
|
|
1192
1397
|
* The current working directory URL
|
|
1193
1398
|
*/
|
|
1194
1399
|
cwd;
|
|
1400
|
+
/**
|
|
1401
|
+
* The current working directory path as a string
|
|
1402
|
+
*/
|
|
1403
|
+
cwdPath;
|
|
1195
1404
|
/**
|
|
1196
1405
|
* Test runner configuration options including filters, reporters, and hooks
|
|
1197
1406
|
*/
|
|
@@ -1205,8 +1414,7 @@ var TestRunner = class {
|
|
|
1205
1414
|
constructor(cwd, options) {
|
|
1206
1415
|
this.cwd = cwd;
|
|
1207
1416
|
this.options = options;
|
|
1208
|
-
this
|
|
1209
|
-
this.#indexGenerator = new IndexGenerator(this.#cwdPath, this.ui.logger);
|
|
1417
|
+
this.cwdPath = string4.toUnixSlash(fileURLToPath3(this.cwd));
|
|
1210
1418
|
}
|
|
1211
1419
|
/**
|
|
1212
1420
|
* Convert test runner options to the CLI args
|
|
@@ -1419,16 +1627,10 @@ var TestRunner = class {
|
|
|
1419
1627
|
*/
|
|
1420
1628
|
async run() {
|
|
1421
1629
|
this.#stickyPort = String(await getPort(this.cwd));
|
|
1630
|
+
this.#indexGenerator = new IndexGenerator(this.cwdPath, this.ui.logger);
|
|
1422
1631
|
this.#clearScreen();
|
|
1423
1632
|
this.ui.logger.info("loading hooks...");
|
|
1424
|
-
this.#hooks = await loadHooks(this.options.hooks, [
|
|
1425
|
-
"init",
|
|
1426
|
-
"testsStarting",
|
|
1427
|
-
"testsFinished",
|
|
1428
|
-
"fileAdded",
|
|
1429
|
-
"fileChanged",
|
|
1430
|
-
"fileRemoved"
|
|
1431
|
-
]);
|
|
1633
|
+
this.#hooks = await loadHooks(this.options.hooks, ["init", "testsStarting", "testsFinished"]);
|
|
1432
1634
|
await this.#hooks.runner("init").run(this, this.#indexGenerator);
|
|
1433
1635
|
this.#hooks.clear("init");
|
|
1434
1636
|
this.ui.logger.info("generating indexes...");
|
|
@@ -1454,7 +1656,8 @@ var TestRunner = class {
|
|
|
1454
1656
|
return;
|
|
1455
1657
|
}
|
|
1456
1658
|
this.#stickyPort = String(await getPort(this.cwd));
|
|
1457
|
-
this.#
|
|
1659
|
+
this.#indexGenerator = new IndexGenerator(this.cwdPath, this.ui.logger);
|
|
1660
|
+
this.#fileSystem = new FileSystem(this.cwdPath, tsConfig, {
|
|
1458
1661
|
...this.options,
|
|
1459
1662
|
suites: this.options.suites?.filter((suite) => {
|
|
1460
1663
|
if (this.options.filters.suites) {
|
|
@@ -1482,7 +1685,7 @@ var TestRunner = class {
|
|
|
1482
1685
|
await this.#runTests(this.#stickyPort);
|
|
1483
1686
|
this.#watcher = watch({
|
|
1484
1687
|
usePolling: options?.poll ?? false,
|
|
1485
|
-
cwd: this
|
|
1688
|
+
cwd: this.cwdPath,
|
|
1486
1689
|
ignoreInitial: true,
|
|
1487
1690
|
ignored: (file, stats) => {
|
|
1488
1691
|
if (!stats) {
|
|
@@ -1505,12 +1708,12 @@ var TestRunner = class {
|
|
|
1505
1708
|
});
|
|
1506
1709
|
this.#watcher.on("add", (filePath) => {
|
|
1507
1710
|
const relativePath = string4.toUnixSlash(filePath);
|
|
1508
|
-
const absolutePath = join3(this
|
|
1711
|
+
const absolutePath = join3(this.cwdPath, filePath);
|
|
1509
1712
|
this.#hooks.runner("fileAdded").run(relativePath, absolutePath, this);
|
|
1510
1713
|
});
|
|
1511
1714
|
this.#watcher.on("change", (filePath) => {
|
|
1512
1715
|
const relativePath = string4.toUnixSlash(filePath);
|
|
1513
|
-
const absolutePath = join3(this
|
|
1716
|
+
const absolutePath = join3(this.cwdPath, filePath);
|
|
1514
1717
|
this.#hooks.runner("fileChanged").run(
|
|
1515
1718
|
relativePath,
|
|
1516
1719
|
absolutePath,
|
|
@@ -1524,7 +1727,7 @@ var TestRunner = class {
|
|
|
1524
1727
|
});
|
|
1525
1728
|
this.#watcher.on("unlink", (filePath) => {
|
|
1526
1729
|
const relativePath = string4.toUnixSlash(filePath);
|
|
1527
|
-
const absolutePath = join3(this
|
|
1730
|
+
const absolutePath = join3(this.cwdPath, filePath);
|
|
1528
1731
|
this.#hooks.runner("fileRemoved").run(relativePath, absolutePath, this);
|
|
1529
1732
|
});
|
|
1530
1733
|
}
|
|
@@ -1533,5 +1736,6 @@ export {
|
|
|
1533
1736
|
Bundler,
|
|
1534
1737
|
DevServer,
|
|
1535
1738
|
SUPPORTED_PACKAGE_MANAGERS,
|
|
1536
|
-
TestRunner
|
|
1739
|
+
TestRunner,
|
|
1740
|
+
hooks
|
|
1537
1741
|
};
|
package/build/src/bundler.d.ts
CHANGED
|
@@ -52,6 +52,10 @@ export declare class Bundler {
|
|
|
52
52
|
* The current working directory URL
|
|
53
53
|
*/
|
|
54
54
|
cwd: URL;
|
|
55
|
+
/**
|
|
56
|
+
* The current working project directory path as string
|
|
57
|
+
*/
|
|
58
|
+
cwdPath: string;
|
|
55
59
|
/**
|
|
56
60
|
* Bundler configuration options including hooks and meta files
|
|
57
61
|
*/
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type tsStatic from 'typescript';
|
|
2
|
-
import { cliui } from '@poppinss/cliui';
|
|
3
2
|
import type { DevServerOptions } from './types/common.ts';
|
|
4
3
|
/**
|
|
5
4
|
* Exposes the API to start the development server in HMR, watch or static mode.
|
|
@@ -18,13 +17,29 @@ import type { DevServerOptions } from './types/common.ts';
|
|
|
18
17
|
export declare class DevServer {
|
|
19
18
|
#private;
|
|
20
19
|
/**
|
|
21
|
-
* CLI UI instance
|
|
20
|
+
* CLI UI instance for displaying colorful messages and progress information
|
|
22
21
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
ui: {
|
|
23
|
+
colors: import("@poppinss/colors/types").Colors;
|
|
24
|
+
logger: import("@poppinss/cliui").Logger;
|
|
25
|
+
table: (tableOptions?: Partial<import("@poppinss/cliui/types").TableOptions>) => import("@poppinss/cliui").Table;
|
|
26
|
+
tasks: (tasksOptions?: Partial<import("@poppinss/cliui/types").TaskManagerOptions>) => import("@poppinss/cliui").TaskManager;
|
|
27
|
+
icons: {
|
|
28
|
+
tick: string;
|
|
29
|
+
cross: string;
|
|
30
|
+
bullet: string;
|
|
31
|
+
nodejs: string;
|
|
32
|
+
pointer: string;
|
|
33
|
+
info: string;
|
|
34
|
+
warning: string;
|
|
35
|
+
squareSmallFilled: string;
|
|
36
|
+
};
|
|
37
|
+
sticker: () => import("@poppinss/cliui").Instructions;
|
|
38
|
+
instructions: () => import("@poppinss/cliui").Instructions;
|
|
39
|
+
switchMode(modeToUse: "raw" | "silent" | "normal"): void;
|
|
40
|
+
useRenderer(rendererToUse: import("@poppinss/cliui/types").RendererContract): void;
|
|
41
|
+
useColors(colorsToUse: import("@poppinss/colors/types").Colors): void;
|
|
42
|
+
};
|
|
28
43
|
/**
|
|
29
44
|
* The mode in which the DevServer is running.
|
|
30
45
|
*/
|
|
@@ -37,6 +52,10 @@ export declare class DevServer {
|
|
|
37
52
|
* The current working directory URL
|
|
38
53
|
*/
|
|
39
54
|
cwd: URL;
|
|
55
|
+
/**
|
|
56
|
+
* File path computed from the cwd
|
|
57
|
+
*/
|
|
58
|
+
cwdPath: string;
|
|
40
59
|
/**
|
|
41
60
|
* Development server configuration options including hooks and environment variables
|
|
42
61
|
*/
|