forked from chili-epfl/FROG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage-scripts.js
95 lines (90 loc) · 2.67 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
const { sync } = require('find-up');
const { dirname } = require('path');
const help = `echo '
FROG scripts:
test - run all tests
eslint - run ESLint
eslint.fix - run ESLint --fix, will format with Prettier
flow - run Flow
flow.quiet - run Flow --quiet
jest - run Jest
jest.watch - run Jest in watch mode
server - run server (can be run from any directory)
'
`;
let dir;
const findDir = sync('.git');
if (findDir) {
dir = dirname(findDir);
} else {
// for Docker CI
dir = '/usr/src/frog';
}
const fromRoot = (cmd, msg) =>
`echo ${msg ||
''} & cd ${dir}/ && PATH=${dir}/node_modules/.bin:$PATH ${cmd}`;
module.exports = {
scripts: {
unlink: fromRoot(
'rm -rf frog/node_modules',
'Unlinked, you can run Yarn commands now'
),
link: fromRoot(
'rm -rf frog/node_modules; ln -s `pwd`/node_modules frog',
'Relinked, you can run Meteor now'
),
cleanCache: fromRoot(
'rm -rf ./frog/.meteor/local/build ./frog/.meteor/local/bundler-cache ./frog/.meteor/local/plugin-cache'
),
yarn: fromRoot(
'rm -rf frog/node_modules; yarn; rm -rf frog/node_modules; ln -s `pwd`/node_modules frog',
'Unlinked, ran yarn, and relinked, all set to go'
),
setup: {
default: fromRoot(
'git clean -fdx; ./initial_setup.sh',
'Cleaning all files and running initial setup'
),
clean: fromRoot(
'killall -9 node; git clean -fdx; ./initial_setup.sh',
'Killing Node, cleaning all files and running initial setup'
)
},
server: fromRoot('cd frog && meteor', 'Starting Meteor'),
test: {
default: fromRoot(
`nps -s flow.quiet eslint jest`,
'Running Flow, ESLint and Jest'
),
ci: fromRoot(
`nps -s lockfiles flow.quiet eslint jest`,
'Running LockFiles, Flow, ESLint and Jest'
)
},
eslint: {
default: fromRoot(
'eslint -c .eslintrc-prettier.js --ext .js,.jsx .',
'Running ESLint'
),
fix: fromRoot(
'eslint --fix -c .eslintrc-prettier.js --ext .js,.jsx .',
'Running ESLint in Fix mode'
)
},
flow: {
default: fromRoot('flow', 'Running Flow'),
quiet: fromRoot('flow --quiet', 'Running Flow quietly')
},
jest: {
default: fromRoot('jest', 'Starting Jest'),
watch: fromRoot('jest --watch', 'Starting Jest in watch mode')
},
lockfiles: fromRoot(
'cmp --silent package-lock.json package-lock.json.orig && cmp --silent yarn.lock yarn.lock.orig || (echo Error: package-lock.json or yarn.lock is modified after a fresh install; exit 1)'
),
help
},
options: {
silent: true
}
};