Repository navigation
Expand file tree
/
Copy pathrun.js
More file actions
90 lines (80 loc) · 2.62 KB
/
Copy pathrun.js
File metadata and controls
90 lines (80 loc) · 2.62 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
* WordPress Playground regression dispatcher.
*
* Usage: node run.js <launch|stop|capture|compare|harness> --root <dir> [flags]
*/
/**
* WordPress plugin regression via Playground
* Copyright (C) 2026 Sybre Waaijer, CyberWire B.V. (https://cyberwire.nl/)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
const { parseArgs } = require( './lib/args' );
const { launch } = require( './lib/launch' );
const { stop } = require( './lib/stop' );
const { capture } = require( './lib/capture' );
const { compare } = require( './lib/compare' );
const { harness } = require( './lib/harness' );
const { printSurfaces } = require( './lib/surfaces' );
const { loadPluginJson } = require( './lib/state' );
const USAGE = `Usage: node run.js <command> --root <consumer> [--plugin-json <file>]
Commands: launch, stop, capture, compare, harness, surfaces
stop drops runs for this workspace. stop --all drops every consumer.
`;
/**
* Runs one command.
*/
async function main() {
const argv = process.argv.slice( 2 );
const command = argv[0];
const parsed = parseArgs( argv.slice( 1 ) );
const flags = parsed.flags;
if ( ! command || command.startsWith( '--' ) ) {
process.stderr.write( USAGE );
process.exit( 1 );
}
try {
if (
[ 'launch', 'capture', 'compare', 'surfaces' ].includes( command )
&& ! flags['plugin-json']
) {
throw new Error( '--plugin-json is required.' );
}
switch ( command ) {
case 'launch':
await launch( loadPluginJson( flags['plugin-json'] ), flags );
break;
case 'stop':
stop( flags );
break;
case 'capture':
await capture( loadPluginJson( flags['plugin-json'] ), flags );
break;
case 'compare':
compare( loadPluginJson( flags['plugin-json'] ), flags );
break;
case 'harness':
await harness( flags, parsed.rest );
break;
case 'surfaces':
printSurfaces( loadPluginJson( flags['plugin-json'] ) );
break;
default:
throw new Error( `Unknown command ${command}.` );
}
} catch ( err ) {
process.stderr.write( `${err.message}\n` );
process.exit( 1 );
}
}
main();