-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
82 lines (70 loc) · 2.57 KB
/
Gruntfile.js
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
/*eslint-env node */
const { homedir } = require('os');
const { join } = require('path');
const c8 = "npx c8 -x Gruntfile.js -x wdio.conf.js -x wasm_exec.js -x 'test/**'";
module.exports = function (grunt) {
grunt.initConfig({
env: {
test: {
TMPDIR: join(homedir(), 'tmp')
}
},
eslint: {
default: {
src: [ '*.js', 'test/**/*.js', '!wasm_exec.js' ]
},
typescript: {
src: 'typescript/**/*.ts'
}
},
exec: {
build_go: [
'GOARCH=wasm GOOS=js go build -o webauthn4js.wasm webauthn4js.go user.go',
'go build genschema.go user.go',
'./genschema > schemas/schemas.autogen.json',
"npx jme schemas/schemas.autogen.json schemas/schemas.doc.json > schemas/schemas.json"
].join('&&'),
build_ts: [
'node typescript/schemas-to-zod.mjs > typescript/schemas.zod.ts',
'npx tsc --target es2017 --moduleResolution node typescript/schemas.zod.ts',
// https://github.com/microsoft/TypeScript/issues/18442
'mv typescript/schemas.zod.js typescript/schemas.zod.mjs',
'node typescript/zod-to-ts.mjs > typescript/webauthn.d.ts',
'npx tsc -p typescript',
'mv typescript/example.js typescript/example.mjs'
].join('&&'),
test: 'npx wdio',
cover: `${c8} npx grunt test`,
cover_report: `${c8} report -r lcov -r text`,
cover_check: `${c8} check-coverage --statements 100 --branches 100 --functions 100 --lines 100`,
docs: [
'npx typedoc index.d.ts',
'asciidoc -b docbook -o - README.adoc | pandoc -f docbook -t gfm -o README.md'
].join('&&')
}
});
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-exec');
grunt.loadNpmTasks('grunt-env');
grunt.registerTask('build', [
'exec:build_go',
'exec:build_ts'
]);
grunt.registerTask('lint', [
'eslint:default',
'eslint:typescript'
]);
grunt.registerTask('test', ['env:test', 'exec:test']);
grunt.registerTask('coverage', [
'exec:cover',
'exec:cover_report',
'exec:cover_check'
]);
grunt.registerTask('coveralls', 'exec:coveralls');
grunt.registerTask('docs', [
'exec:build_go',
'exec:build_ts',
'exec:docs'
]);
grunt.registerTask('default', ['lint', 'test']);
};