-
Notifications
You must be signed in to change notification settings - Fork 0
/
package-scripts.js
76 lines (73 loc) · 2.71 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
// @ts-check
const { concurrent, series, rimraf } = require('nps-utils');
const { lightFormat } = require('date-fns');
if (process.env.NODE_ENV !== 'production') {
require('dotenv-safe').config({
path: './api/.env',
example: './api/.env.example',
});
}
// sent to mixpanel, serves as a version tag
// formatted to look like 20191103131121
process.env.REACT_APP_VERSION = lightFormat(new Date(), 'yyyyMMddHHmmss');
module.exports.scripts = {
default: 'nps dev',
deploy: {
web: series.nps('clean', 'build.types', 'build.web'),
api: series.nps('clean', 'build.types', 'build.api'),
beta: series.nps('clean', 'build.types', 'build.beta'),
admin: series('nps clean', 'nps build.types', 'cd admin', 'npm run deploy'),
},
dev: {
default: concurrent.nps(
'dev.types',
'dev.web',
'dev.api',
'dev.admin',
),
types: 'graphql-codegen --config codegen.yml --watch',
web: series('cd web', 'yarn dev'),
beta: series('cd beta', 'yarn dev'),
api: series('cd api', 'yarn dev'),
admin: series('cd admin', 'npm run dev'),
},
build: {
default: series(
'nps clean',
'nps build.types',
concurrent.nps('build.web', 'build.api', 'build.admin'),
),
types: 'graphql-codegen --config codegen.yml',
web: series('cd web', 'npm run build'),
api: series('cd api', 'npm run build'),
admin: series('cd admin', 'npm run build'),
beta: series('cd beta', 'yarn build'),
},
clean: rimraf('.cache web/build api/dist'),
start: {
default: concurrent.nps('start.api', 'start.web'),
api: series('cd api', 'npm run start'),
web: series('cd web', 'npm run start'),
admin: series('cd admin', 'npm run start'),
},
db: {
info: [
'psql',
`--command="select table_name, column_name, data_type, is_nullable from information_schema.columns where table_schema = 'public' and column_name != 'created_at' and column_name != 'updated_at' order by table_name, column_name;"`,
process.env.DATABASE_URL,
].join(' '),
cli: `psql ${process.env.DATABASE_URL}`,
// based on https://stackoverflow.com/questions/10673630/how-do-i-transfer-production-database-to-staging-on-heroku-using-pgbackups-gett/24005476#30495448
prepare: series(
'heroku maintenance:on --app nuffread-staging',
'heroku pg:copy nuffread::DATABASE_URL DATABASE_URL --app nuffread-staging --verbose --confirm nuffread-staging',
'heroku maintenance:off --app nuffread-staging',
),
},
pretty: 'prettier web/src api/src admin/src --write',
logs: {
default:
'heroku logs -a nuffread -s app -d web -n 5000 | cut -c46- - | grep \'{"level":50\' > heroku.log',
tail: 'heroku logs -a nuffread -s app -d web -t | cut -c46- -',
},
};