File tree Expand file tree Collapse file tree 8 files changed +54
-9
lines changed Expand file tree Collapse file tree 8 files changed +54
-9
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ const homedir = join(__dirname, '..');
5
5
const buildInfoFileName = 'build.json' ;
6
6
const dataZipFileName = 'data.zip' ;
7
7
8
-
9
8
const staticDir = process . env . BUILD_TYPE === 'ELECTRON' && process [ 'resourcesPath' ]
10
9
? join ( process [ 'resourcesPath' ] , 'static' )
11
10
: join ( __dirname , '..' , 'static' ) ;
@@ -17,6 +16,7 @@ const defaultsDir = process.env.BUILD_TYPE === 'ELECTRON' && process['resourcesP
17
16
export default {
18
17
dir_path : {
19
18
homedir,
19
+ prevHomedir : homedir ,
20
20
staticDir,
21
21
defaultsDir,
22
22
logs : join ( homedir , 'logs' ) ,
Original file line number Diff line number Diff line change @@ -2,11 +2,14 @@ import { join } from 'path';
2
2
import * as os from 'os' ;
3
3
4
4
const homedir = process . env . APP_FOLDER_ABSOLUTE_PATH
5
- || ( join ( os . homedir ( ) , process . env . APP_FOLDER_NAME || '.redisinsight-preview' ) ) ;
5
+ || ( join ( os . homedir ( ) , process . env . APP_FOLDER_NAME || '.redisinsight-v2' ) ) ;
6
+
7
+ const prevHomedir = join ( os . homedir ( ) , '.redisinsight-preview' ) ;
6
8
7
9
export default {
8
10
dir_path : {
9
11
homedir,
12
+ prevHomedir,
10
13
logs : join ( homedir , 'logs' ) ,
11
14
customPlugins : join ( homedir , 'plugins' ) ,
12
15
commands : join ( homedir , 'commands' ) ,
Original file line number Diff line number Diff line change @@ -2,11 +2,14 @@ import { join } from 'path';
2
2
import * as os from 'os' ;
3
3
4
4
const homedir = process . env . APP_FOLDER_ABSOLUTE_PATH
5
- || ( join ( os . homedir ( ) , process . env . APP_FOLDER_NAME || '.redisinsight-v2.0-stage' ) ) ;
5
+ || ( join ( os . homedir ( ) , process . env . APP_FOLDER_NAME || '.redisinsight-v2-stage' ) ) ;
6
+
7
+ const prevHomedir = join ( os . homedir ( ) , '.redisinsight-v2.0-stage' ) ;
6
8
7
9
export default {
8
10
dir_path : {
9
11
homedir,
12
+ prevHomedir,
10
13
logs : join ( homedir , 'logs' ) ,
11
14
customPlugins : join ( homedir , 'plugins' ) ,
12
15
commands : join ( homedir , 'commands' ) ,
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " redisinsight-api" ,
3
- "version" : " 2.0.0 " ,
3
+ "version" : " 2.0.5 " ,
4
4
"description" : " RedisInsight API" ,
5
5
"private" : true ,
6
6
"author" : {
Original file line number Diff line number Diff line change
1
+ import * as fs from 'fs-extra' ;
2
+ import config from 'src/utils/config' ;
3
+ import { join } from 'path' ;
4
+
5
+ const PATH_CONFIG = config . get ( 'dir_path' ) ;
6
+ const DB_CONFIG = config . get ( 'db' ) ;
7
+
8
+ /**
9
+ * Copy source if exists
10
+ * @param source
11
+ * @param destination
12
+ */
13
+ const copySource = async ( source , destination ) => {
14
+ if ( await fs . pathExists ( source ) ) {
15
+ await fs . copy ( source , destination ) . catch ( ) ;
16
+ }
17
+ } ;
18
+
19
+ /**
20
+ * Migrate data from previous home folder defined in configs
21
+ */
22
+ export const migrateHomeFolder = async ( ) => {
23
+ try {
24
+ if ( ! ( await fs . pathExists ( DB_CONFIG . database ) ) && await fs . pathExists ( PATH_CONFIG . prevHomedir ) ) {
25
+ await fs . ensureDir ( PATH_CONFIG . homedir ) ;
26
+
27
+ await Promise . all ( [
28
+ 'redisinsight.db' ,
29
+ 'plugins' ,
30
+ ] . map ( ( target ) => copySource (
31
+ join ( PATH_CONFIG . prevHomedir , target ) ,
32
+ join ( PATH_CONFIG . homedir , target ) ,
33
+ ) ) ) ;
34
+ }
35
+ } catch ( e ) {
36
+ // continue initialization even without migration
37
+ }
38
+ } ;
Original file line number Diff line number Diff line change 1
- import 'dotenv/config'
1
+ import 'dotenv/config' ;
2
2
import { NestFactory } from '@nestjs/core' ;
3
3
import { SwaggerModule } from '@nestjs/swagger' ;
4
4
import { NestApplicationOptions } from '@nestjs/common' ;
5
5
import * as bodyParser from 'body-parser' ;
6
6
import { WinstonModule } from 'nest-winston' ;
7
7
import { GlobalExceptionFilter } from 'src/exceptions/global-exception.filter' ;
8
+ import { get } from 'src/utils' ;
9
+ import { migrateHomeFolder } from 'src/init-helper' ;
8
10
import { AppModule } from './app.module' ;
9
11
import SWAGGER_CONFIG from '../config/swagger' ;
10
12
import LOGGER_CONFIG from '../config/logger' ;
11
- import config from './utils/config' ;
12
13
13
14
export default async function bootstrap ( ) {
14
- const serverConfig = config . get ( 'server' ) ;
15
+ await migrateHomeFolder ( ) ;
16
+
17
+ const serverConfig = get ( 'server' ) ;
15
18
const port = process . env . API_PORT || serverConfig . port ;
16
19
const logger = WinstonModule . createLogger ( LOGGER_CONFIG ) ;
17
20
Original file line number Diff line number Diff line change 1
- APP_DATA_HOMEDIR = /root/.redisinsight-v2.0
2
1
COV_FOLDER = ./coverage
3
2
ID = defaultid
4
3
RTE = defaultrte
Original file line number Diff line number Diff line change 1
- APP_DATA_HOMEDIR = /root/.redisinsight-2.0
2
1
COV_FOLDER = ./coverage
3
2
ID = defaultid
4
3
RTE = defaultrte
You can’t perform that action at this time.
0 commit comments