-
Notifications
You must be signed in to change notification settings - Fork 27
/
package-scripts.js
111 lines (106 loc) · 3.4 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
const { dirname } = require('path');
const { sync } = require('find-up');
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; node linkFiles.js'
),
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(
'QUALIA_ONE_BUNDLE_TYPE=modern NODE_OPTIONS="--max_old_space_size=8192" cd frog && meteor',
'Starting Meteor'
),
test: {
default: fromRoot(
`nps -s eslint.normal flow jest`,
'Running Flow, ESLint and Jest'
),
ci: fromRoot(
`nps -s lockfiles eslint.normal flow jest`,
'Running LockFiles, Flow, ESLint and Jest'
)
},
eslint: {
default: fromRoot(
'fastlint --working-copy --print0 origin/develop --glob "**/*.{js,jsx}" | xargs -0 eslint --cache -c .eslintrc-prettier.js --ext ".js,.jsx"',
'Running ESLint'
),
fix: fromRoot(
'fastlint --working-copy --print0 origin/develop --glob "**/*.{js,jsx}" | xargs -0 eslint --fix --cache -c .eslintrc-prettier.js --ext ".js,.jsx"',
'Running ESLint in Fix mode'
),
normal: fromRoot(
'eslint --cache -c .eslintrc-prettier.js --ext .js,.jsx frog/',
'Running ESLint in normal mode'
),
normalfix: fromRoot(
'eslint --fix --cache -c .eslintrc-prettier.js --ext .js,.jsx frog/',
'Running ESLint in normal 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')
},
cypress: {
default: fromRoot('cypress open', 'Starting Cypress'),
run: fromRoot('cypress run', 'Starting Cypress in headless mode')
},
storybook: fromRoot('start-storybook -p 6006', 'Starting Storybook'),
lockfiles: fromRoot(
'cmp --silent yarn.lock yarn.lock.orig || (echo Error: yarn.lock is modified after a fresh install; exit 1)'
),
help
},
options: {
silent: true
}
};