nodestatus-server 1.2.0-beta → 1.2.2-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,33 +0,0 @@
1
- const cp = require('child_process');
2
- const fs = require('fs');
3
- const path = require('path');
4
- const { homedir, platform } = require('os');
5
- const { resolve } = require('path');
6
- const dotenv = require('dotenv');
7
- const { backupDatabase } = require('./utils');
8
-
9
- dotenv.config({ path: path.resolve(homedir(), '.nodestatus/.env.local') });
10
-
11
- const dbPath = process.env.DATABASE || (
12
- platform() === 'win32'
13
- ? resolve(homedir(), '.nodestatus/db.sqlite')
14
- : '/usr/local/NodeStatus/server/db.sqlite'
15
- );
16
-
17
- fs.mkdirSync(path.dirname(dbPath), { recursive: true });
18
- fs.existsSync(dbPath) && backupDatabase(dbPath);
19
- let cmd = 'prisma';
20
- platform() === 'win32' && (cmd += '.cmd');
21
- const prisma = cp.spawn(cmd, ['db', 'push', '--accept-data-loss'], {
22
- env: { BINARY_TARGETS: '["native"]', DATABASE_URL: `file:${dbPath}`, ...process.env },
23
- cwd: resolve(__dirname, '../'),
24
- stdio: 'inherit'
25
- });
26
- prisma.on('close', code => {
27
- if (code) {
28
- console.log('Something wrong while updating database schema.');
29
- process.exit(1);
30
- } else {
31
- console.log(`Database file location: ${dbPath}`);
32
- }
33
- });
@@ -1,16 +0,0 @@
1
- /* Initializing database for Docker */
2
- const cp = require('child_process');
3
- const { resolve, dirname } = require('path');
4
- const fs = require('fs');
5
- const { backupDatabase } = require('./utils');
6
-
7
- if (process.env.IS_DOCKER === 'true') {
8
- const dbPath = process.env.DATABASE || '/usr/local/NodeStatus/server/db.sqlite';
9
- fs.mkdirSync(dirname(dbPath), { recursive: true });
10
- fs.existsSync(dbPath) && backupDatabase(dbPath);
11
- cp.spawn('prisma', ['db', 'push', '--accept-data-loss', '--skip-generate'], {
12
- env: { BINARY_TARGETS: '["native"]', DATABASE_URL: `file:${dbPath}`, ...process.env },
13
- cwd: resolve(__dirname, '../'),
14
- stdio: 'inherit'
15
- });
16
- }
package/scripts/utils.js DELETED
@@ -1,13 +0,0 @@
1
- const fs = require('fs');
2
-
3
- function backupDatabase(dbPath) {
4
- console.log('The database file is detected to already exist.');
5
- console.log('Trying to update database schema.....');
6
- const date = new Date();
7
- fs.copyFileSync(
8
- dbPath,
9
- `${dbPath}_${date.getFullYear()}_${date.getMonth() + 1}_${date.getDate()}_${date.getHours()}_${date.getMinutes()}_${date.getSeconds()}.bak`
10
- );
11
- }
12
-
13
- module.exports = { backupDatabase };