-
Notifications
You must be signed in to change notification settings - Fork 122
Expand file tree
/
Copy pathwpt.js
More file actions
88 lines (78 loc) · 2.24 KB
/
wpt.js
File metadata and controls
88 lines (78 loc) · 2.24 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
import fs from 'node:fs';
import path from 'node:path';
import Request from '../../lib/request.js';
import CLI from '../../lib/cli.js';
import auth from '../../lib/auth.js';
import {
WPTUpdater,
ResourcesUpdater,
InterfacesUpdater
} from '../../lib/wpt/index.js';
import { runPromise } from '../../lib/run.js';
export const command = 'wpt <name>';
export const describe = 'Updates WPT suite';
export function builder(yargs) {
return yargs
.positional('name', {
describe: 'Subset of the WPT to update',
type: 'string'
})
.options({
commit: {
describe: 'A specific commit the subset should be updated to',
type: 'string',
default: undefined
},
nodedir: {
describe: 'Path to the node.js project directory',
type: 'string',
default: '.'
}
});
}
async function main(argv) {
const { name, nodedir, commit } = argv;
const cli = new CLI();
const credentials = await auth({
github: true
});
const request = new Request(credentials);
const updaters = [];
const statusFolder = path.join(nodedir, 'test', 'wpt', 'status');
let supported = [
'dom',
'html',
'webcrypto'
];
if (fs.existsSync(statusFolder)) {
const jsons = fs.readdirSync(statusFolder);
supported = supported.concat(
jsons.map(item => path.basename(item, path.extname(item))));
} else {
cli.warn(`Please create the status JSON files in ${statusFolder}`);
}
if (name === 'all' || name === 'resources') {
updaters.push(new ResourcesUpdater(cli, request, nodedir, commit));
}
if (name === 'all' || name === 'interfaces') {
updaters.push(new InterfacesUpdater(cli, request, nodedir,
commit, supported));
}
if (name === 'all') {
for (const item of supported) {
updaters.push(new WPTUpdater(item, cli, request, nodedir, commit));
}
} else if (name !== 'resources' && name !== 'interfaces') {
if (!supported.includes(name)) {
cli.warn(`Please create ${name}.json in ${statusFolder}`);
}
updaters.push(new WPTUpdater(name, cli, request, nodedir, commit));
}
for (const updater of updaters) {
await updater.update();
}
updaters[0].updateLicense();
}
export function handler(argv) {
runPromise(main(argv));
}