This repository was archived by the owner on Jan 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuniformly.js
More file actions
141 lines (138 loc) · 4.23 KB
/
uniformly.js
File metadata and controls
141 lines (138 loc) · 4.23 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
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
#!/usr/bin/env node
'use strict';
const execute = require('./utils/execute');
const yargs = require('yargs');
const config = require('./utils/configure')();
yargs
.command(
['build', 'transpile'],
'builds the project',
yargs =>
yargs
.option('output', {
alias: ['out', 'o'],
type: 'string',
describe: 'the path where transpiled files should go',
default: 'lib/',
})
.option('source', {
alias: ['src', 'in', 'i'],
type: 'string',
describe: 'the source directory to transpile',
default: 'src/',
})
.option('target', {
alias: ['t'],
type: 'string',
describe: 'the target to transpile for (node version, or "browserslist"',
default: 'current',
})
.option('corejs', {
alias: ['cjs'],
type: 'string',
describe: 'the core-js version that Babel should use',
default: '3',
}),
({ source, out, env, target, corejs, ...others }) => {
process.env.NODE_ENV = env || 'development';
process.env.BABEL_ENV = env || 'development';
process.env.BABEL_TARGET = target;
process.env.CORE_JS_VERSION = corejs;
execute('babel', [
source,
'-d',
out,
'--extensions',
'.js,.jsx,.ts,.tsx',
'--config-file',
config.babel.config,
...others._.slice(1),
]);
}
)
.command(
'test',
'tests the project',
yargs => yargs,
({ env, ...others }) => {
process.env.NODE_ENV = env || 'test';
process.env.BABEL_ENV = env || 'test';
execute('jest', [
'--config',
config.jest.config,
...others._.slice(1),
]);
}
)
.command(
'declare-types',
'generates TypeScript declaration files',
yargs =>
yargs
.option('output', {
alias: ['out', 'o'],
type: 'string',
describe: 'the path where declaration files should go',
default: 'lib',
}),
({ output }) => {
execute('tsc', [
'-d',
'--declarationDir',
output.replace(/\//g, ''),
'--emitDeclarationOnly',
]);
}
)
.command(
'tidyup',
'tidies source code with Prettier',
yargs =>
yargs.option('source', {
alias: ['src', 'in', 'i'],
type: 'string',
describe: 'the source directory to tidy',
default: 'src/**/*',
}),
({ source, ...others }) => {
execute('prettier', [
'--config',
config.prettier.config,
'--write',
...others._.slice(1),
source,
]);
}
)
.command(
'lint',
'lints the project with ESLint',
yargs =>
yargs.option('source', {
alias: ['src', 'in', 'i'],
type: 'string',
describe: 'the source directory to lint',
default: 'src/',
}),
({ source, ...others }) => {
execute('eslint', [
'--ext',
'.js,.jsx,.ts,.tsx',
'--config',
config.eslint.config,
...others._.slice(1),
source,
]);
}
)
.option('env', {
alias: ['environment', 'node_env'],
type: 'string',
describe: 'overrides the value of NODE_ENV',
default: process.env.NODE_ENV,
})
.alias('v', 'version')
.describe('version', 'show version')
.strict()
.help()
.describe('help', 'show this help text').argv;