-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage-scripts.js
executable file
·191 lines (180 loc) · 6.42 KB
/
package-scripts.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/* eslint-disable */
const {
concurrent,
series,
nps,
run,
rollup,
typedoc,
jest,
prettier,
eslint,
serve,
remove,
copy
} = require('./nps-tooling');
const paths = {
grammarFile: './src/grammar/gbb-grammar.ne',
grammarOutput: './src/grammar/gbb-grammar.js',
grammarDocs: './docs/gbb-parser.html'
};
function nearleyCompiler(path, output) {
return `nearleyc ${path} -o ${output}`;
}
module.exports = {
scripts: {
default: 'nps help',
dev: {
script: series(
nps('clean.parser'),
nps('generate.parser'),
run({ file: './src/index.ts' })
),
description: 'Run "index.ts" in development mode',
watch: {
script: series(
nps('clean.parser'),
nps('generate.parser'),
run({ file: './src/index.ts', watch: './src/**/*.ts' })
),
description: 'Run "index.ts" in development mode and watch for changes'
}
},
build: {
script: series(
nps('clean.dist'),
nps('clean.parser'),
nps('generate.parser'),
rollup()
),
description: 'Build the application into "dist" folder',
watch: {
script: series(
nps('clean.dist'),
nps('clean.parser'),
nps('generate.parser'),
rollup({ watch: './src/**/*' })
),
description: 'Build the application into "dist" folder and watch for changes'
}
},
test: {
script: series(nps('clean.coverage'), nps('lint'), jest({ coverage: true })),
description: 'Run the tests, including linting',
watch: {
script: series(jest({ coverage: true, watch: true })),
description: 'Run the tests with no linting, and wait for changes'
},
serve: {
script: series(
nps('clean.coverage'),
jest({ coverage: true, noThreshold: true }),
serve('./coverage')
),
description:
'Run the tests, including linting, and serve the coverage reports in HTML',
watch: {
script: series(
nps('clean.coverage'),
concurrent(
jest({ coverage: true, noThreshold: true, watch: true }),
serve('./coverage')
)
),
description:
'Run the tests with no linting, and wait for changes, and serve the coverage report'
}
}
},
doc: {
script: series(
nps('clean.docs'),
typedoc(),
copy({ src: './docs/index.html', dest: './docs/globals.html' })
),
description: 'Run Typedoc and generate docs',
watch: {
script: series(nps('doc'), typedoc({ watch: true })),
description: 'Run Typedoc and generate docs and watch for changes.'
},
serve: {
script: series(nps('doc'), serve('./docs')),
description: 'Run Typedoc and generate docs, then serve the docs as HTML',
watch: {
script: series(
nps('doc'),
concurrent(typedoc({ watch: true }), serve('./docs'))
),
description:
'Run Typedoc and generate docs and watch for changes while serving the docs as HTML'
}
}
},
generate: {
parser: {
script: nearleyCompiler(paths.grammarFile, paths.grammarOutput),
description:
'Compile the grammar in a source file. Used only for local running and testing',
hiddenFromHelp: true,
silent: true
},
parser_doc: {
script: `nearley-railroad ${paths.grammarFile} -o ${paths.grammarDocs}`,
description:
'Generate an HTML Documentation file with Railroad diagrams for the language',
hiddenFromHelp: true,
silent: true
},
test_board: {
script: `nearley-unparse ${paths.grammarFile} -n 1`,
description: 'Generate a board that complies with the grammar',
hiddenFromHelp: true,
silent: true
}
},
clean: {
script: series(
nps('clean.parser'),
nps('clean.dist'),
nps('clean.docs'),
nps('clean.coverage')
),
description: 'Remove all automatically generated files and folders',
parser: {
script: remove({ files: './src/grammar/gbb-grammar.js' }),
description: 'Delete the generated parser',
silent: true
},
dist: {
script: remove({ files: './dist' }),
description: 'Delete the dist folder',
silent: true
},
docs: {
script: remove({ files: './docs' }),
description: 'Delete the docs folder',
silent: true
},
coverage: {
script: remove({ files: './coverage' }),
description: 'Delete the coverage folder',
silent: true
}
},
lint: {
script: series(eslint({ files: './src' }), eslint({ files: './test' })),
description: 'Run ESLint on all the files (src and tests)',
fix: {
script: series(
eslint({ files: './src', fix: true }),
eslint({ files: './test', fix: true })
),
description: 'Run ESLint on all the files (src and tests) with --fix option'
}
},
prettify: {
script: prettier({ files: './src/**/*.ts' }),
description: 'Run Prettier on all the files, writing the results'
}
}
};