-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBedrockManual.ts
More file actions
61 lines (51 loc) · 2.3 KB
/
BedrockManual.ts
File metadata and controls
61 lines (51 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { Attempt } from './bedrock/core/Attempt';
import * as Version from './bedrock/core/Version';
import * as RunnerRoutes from './bedrock/server/RunnerRoutes';
import * as BunDevServer from './bedrock/server/BunDevServer';
import { BedrockManualSettings } from './bedrock/core/Settings';
import { ExitCodes } from './bedrock/util/ExitCodes';
import * as SettingsResolver from './bedrock/core/SettingsResolver';
export const go = (bedrockManualSettings: BedrockManualSettings): void => {
console.log('bedrock-manual ' + Version.get() + ' starting...');
const settings = SettingsResolver.resolveAndLog(bedrockManualSettings);
const basePage = 'src/resources/html/bedrock.html';
const routes = RunnerRoutes.generate('manual', settings.projectdir, settings.basedir, settings.config, settings.bundler, settings.testfiles, settings.chunk, 0, settings.singleTimeout, true, basePage, settings.coverage, settings.polyfills, settings.turbo);
routes.then(async (runner) => {
const serveSettings: BunDevServer.BunDevServerSettings = {
...settings,
driver: Attempt.failed('There is no webdriver for manual mode'),
master: null,
runner,
stickyFirstSession: false,
skipResetMousePosition: true,
enableHotReload: true,
watchFiles: settings.testfiles
};
try {
const service = await BunDevServer.startBunDevServer(serveSettings);
service.enableHud();
console.log('bedrock-manual ' + Version.get() + ' available at: http://localhost:' + service.port);
// Setup graceful shutdown handlers
const shutdown = async (signal: string) => {
console.log(`\n${signal} received, shutting down gracefully...`);
try {
await service.shutdown();
console.log('Server closed successfully');
process.exit(0);
} catch (error) {
console.error('Error during shutdown:', error);
process.exit(1);
}
};
process.on('SIGINT', () => shutdown('SIGINT'));
process.on('SIGTERM', () => shutdown('SIGTERM'));
process.on('SIGQUIT', () => shutdown('SIGQUIT'));
// Prevent the process from exiting
process.stdin.resume();
} catch (err) {
console.error(err);
process.exit(ExitCodes.failures.error);
}
});
};
export const mode = 'forManual';