forked from siddharthkp/nps-i
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package-scripts.js
119 lines (116 loc) · 4.92 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
const npsUtils = require('nps-utils');
// We use nps-utils to combine some of the scripts and run them either concurrently or in series.
// https://github.com/kentcdodds/nps-utils
// Here we overcomplicate things to build a fancy header.
const hr = '**************************';
const title = '** SERVER SCRIPTS 3000™ **';
const message = 'Choose wisely...';
const fancyHeader = `\n\n ${hr}\n ${title}\n ${hr}\n\n ${message}\n\n`;
module.exports = {
// Set a custom message for the prompt. Default is 'Which script would you like to run?\n\n'. We'll use our fancy header instead.
message: fancyHeader,
// Set the page size for the autocomplete prompt. Default is 15.
pageSize: 20,
scripts: {
server: {
start: {
description: 'Start the server and insert dummy files into the buckets',
script: npsUtils.series.nps('server.startSimple', 'server.insertDummyFiles')
},
restart: {
description: 'Restart the server and insert dummy files into the buckets',
script: npsUtils.series.nps('server.stop', 'server.start')
},
stop: {
description: 'Stop the server',
script: 'supabase stop'
},
startSimple: {
// This option will not be visible in the interactive prompt (hiddenFromInteractive: true).
description: 'Simply start the server',
script: 'supabase start',
hiddenFromInteractive: true
},
insertDummyFiles: {
// This option will also be hidden (hiddenFromInteractive: true).
description: 'Insert dummy files into the buckets',
script: 'node ./_scripts/upload-file-to-storage.js',
hiddenFromInteractive: true
}
},
'backup-db': {
full: {
local: {
script: `pg_dump --clean --if-exists --quote-all-identifiers -h localhost -p 54322 -U postgres > ./_backups/local/dump-local-full.sql`,
description: 'Full backup of the local database'
},
server1: {
script: `pg_dump --clean --if-exists --quote-all-identifiers -h db.abc.supabase.co -U postgres > ./_backups/server1/dump-server1-full.sql`,
description: 'Full backup of the database on server 1'
},
server2: {
script: `pg_dump --clean --if-exists --quote-all-identifiers -h db.xyz.supabase.co -U postgres > ./_backups/server2/dump-server2-full.sql`,
description: 'Full backup of the database on server 2'
},
all: {
script: npsUtils.concurrent.nps('backup-db.db.local', 'backup-db.db.server1', 'backup-db.db.server2'),
description: 'Full backup of all databases'
}
},
schema: {
local: {
script: `pg_dump --clean --schema-only --if-exists --quote-all-identifiers -h localhost -p 54322 -U postgres > ./_backups/local/dump-local-schema.sql`,
description: 'Schema backup of the local database'
},
server1: {
script: `pg_dump --clean --schema-only --if-exists --quote-all-identifiers -h db.abc.supabase.co -U postgres > ./_backups/server1/dump-server1-schema.sql`,
description: 'Schema backup of the database on server 1'
},
server2: {
script: `pg_dump --clean --schema-only --if-exists --quote-all-identifiers -h db.xyz.supabase.co -U postgres > ./_backups/server2/dump-server2-schema.sql`,
description: 'Schema backup of the database on server 2'
},
all: {
script: npsUtils.concurrent.nps('backup-db.schema.local', 'backup-db.schema.server1', 'backup-db.schema.server2'),
description: 'Schema backup of all databases'
}
},
data: {
local: {
script: `pg_dump --data-only --quote-all-identifiers -h localhost -p 54322 -U postgres > ./_backups/local/dump-local-data.sql`,
description: 'Data backup of the local database'
},
server1: {
script: `pg_dump --data-only --quote-all-identifiers -h db.abc.supabase.co -U postgres > ./_backups/server1/dump-server1-data.sql`,
description: 'Data backup of the database on server 1'
},
server2: {
script: `pg_dump --data-only --quote-all-identifiers -h db.xyz.supabase.co -U postgres > ./_backups/server2/dump-server2-data.sql`,
description: 'Data backup of the database on server 2'
},
all: {
script: npsUtils.concurrent.nps('backup-db.data.local', 'backup-db.data.server1', 'backup-db.data.server2'),
description: 'Data backup of all databases'
}
},
split: {
local: {
script: npsUtils.series.nps('backup-db.schema.local', 'backup-db.data.local'),
description: 'Separate schema & data backup of the local database'
},
server1: {
script: npsUtils.series.nps('backup-db.schema.server1', 'backup-db.data.server1'),
description: 'Separate schema & data backup of the database on server 1'
},
server2: {
script: npsUtils.series.nps('backup-db.schema.server2', 'backup-db.data.server2'),
description: 'Separate schema & data backup of the database on server 2'
},
all: {
script: npsUtils.concurrent.nps('backup-db.split.local', 'backup-db.split.server1', 'backup-db.split.server2'),
description: 'Separate schema & data backup of all databases'
}
}
}
}
};