1+ import * as crypto from "crypto" ;
2+ import * as fs from "fs" ;
3+ import * as path from "path" ;
4+ import { merge } from "lodash" ;
5+ import * as deepFreeze from "deep-freeze" ;
16
2- 'use strict'
3-
4- const crypto = require ( 'crypto' )
5- const fs = require ( 'fs' )
6- const path = require ( 'path' )
7- const { merge } = require ( 'lodash' )
8- const deepFreeze = require ( 'deep-freeze' )
9- const { Environment, Permission } = require ( './enum' )
10- const logger = require ( '../logger' )
11- const { getGitCommit, getGitHubURL } = require ( './utils' )
7+ import { Environment , Permission } from "./enum" ;
8+ import * as logger from "../logger" ;
9+ import { getGitCommit , getGitHubURL } from "./utils" ;
1210
1311const appRootPath = path . resolve ( __dirname , '../../' )
1412const env = process . env . NODE_ENV || Environment . development
@@ -17,7 +15,7 @@ const debugConfig = {
1715}
1816
1917// Get version string from package.json
20- const { version, repository } = require ( path . join ( appRootPath , 'package.json' ) )
18+ const { version, repository} = require ( path . join ( appRootPath , 'package.json' ) )
2119
2220const commitID = getGitCommit ( appRootPath )
2321const sourceURL = getGitHubURL ( repository . url , commitID || version )
@@ -31,7 +29,7 @@ const packageConfig = {
3129}
3230
3331const configFilePath = path . resolve ( appRootPath , process . env . CMD_CONFIG_FILE ||
34- 'config.json' )
32+ 'config.json' )
3533const fileConfig = fs . existsSync ( configFilePath ) ? require ( configFilePath ) [ env ] : undefined
3634
3735let config = require ( './default' )
@@ -43,7 +41,7 @@ merge(config, require('./environment'))
4341merge ( config , require ( './dockerSecret' ) )
4442
4543if ( [ 'debug' , 'verbose' , 'info' , 'warn' , 'error' ] . includes ( config . loglevel ) ) {
46- logger . level = config . loglevel
44+ logger . setLevel ( config . loglevel )
4745} else {
4846 logger . error ( 'Selected loglevel %s doesn\'t exist, using default level \'debug\'. Available options: debug, verbose, info, warn, error' , config . loglevel )
4947}
@@ -79,15 +77,15 @@ if (!(config.defaultPermission in config.permission)) {
7977}
8078
8179// cache result, cannot change config in runtime!!!
82- config . isStandardHTTPsPort = ( function isStandardHTTPsPort ( ) {
80+ config . isStandardHTTPsPort = ( function isStandardHTTPsPort ( ) {
8381 return config . useSSL && config . port === 443
8482} ) ( )
85- config . isStandardHTTPPort = ( function isStandardHTTPPort ( ) {
83+ config . isStandardHTTPPort = ( function isStandardHTTPPort ( ) {
8684 return ! config . useSSL && config . port === 80
8785} ) ( )
8886
8987// cache serverURL
90- config . serverURL = ( function getserverurl ( ) {
88+ config . serverURL = ( function getserverurl ( ) {
9189 var url = ''
9290 if ( config . domain ) {
9391 var protocol = config . protocolUseSSL ? 'https://' : 'http://'
@@ -147,8 +145,8 @@ for (let i = keys.length; i--;) {
147145 // and the config with uppercase is not set
148146 // we set the new config using the old key.
149147 if ( uppercase . test ( keys [ i ] ) &&
150- config [ lowercaseKey ] !== undefined &&
151- fileConfig [ keys [ i ] ] === undefined ) {
148+ config [ lowercaseKey ] !== undefined &&
149+ fileConfig [ keys [ i ] ] === undefined ) {
152150 logger . warn ( 'config.js contains deprecated lowercase setting for ' + keys [ i ] + '. Please change your config.js file to replace ' + lowercaseKey + ' with ' + keys [ i ] )
153151 config [ keys [ i ] ] = config [ lowercaseKey ]
154152 }
0 commit comments