@athenna/config
Advanced tools
Comparing version 4.3.0 to 4.4.0
{ | ||
"name": "@athenna/config", | ||
"version": "4.3.0", | ||
"version": "4.4.0", | ||
"description": "Cache and handle environment variables and config files of Athenna.", | ||
@@ -53,8 +53,8 @@ "license": "MIT", | ||
"dotenv": "^16.3.1", | ||
"magicast": "^0.2.9", | ||
"magicast": "^0.2.10", | ||
"syntax-error": "^1.4.0" | ||
}, | ||
"devDependencies": { | ||
"@athenna/common": "^4.5.0", | ||
"@athenna/test": "^4.4.0", | ||
"@athenna/common": "^4.10.1", | ||
"@athenna/test": "^4.5.0", | ||
"@types/lodash": "^4.14.191", | ||
@@ -120,3 +120,3 @@ "@types/syntax-error": "^1.4.2", | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"trailingComma": "none", | ||
"arrowParens": "avoid", | ||
@@ -123,0 +123,0 @@ "endOfLine": "lf", |
@@ -19,3 +19,3 @@ /** | ||
Object.defineProperty(target, propKey, { | ||
value: Config.get(key, defaultValue), | ||
value: Config.get(key, defaultValue) | ||
}); | ||
@@ -22,0 +22,0 @@ return; |
@@ -9,3 +9,3 @@ /** | ||
*/ | ||
import { File, Json, Path, ObjectBuilder, Exec, Module, Is, } from '@athenna/common'; | ||
import { File, Json, Path, ObjectBuilder, Exec, Module, Is } from '@athenna/common'; | ||
import { debug } from '#src/debug'; | ||
@@ -24,3 +24,3 @@ import { loadFile, writeFile } from 'magicast'; | ||
ignoreUndefined: true, | ||
referencedValues: false, | ||
referencedValues: false | ||
}); } | ||
@@ -33,3 +33,3 @@ /** | ||
ignoreUndefined: true, | ||
referencedValues: false, | ||
referencedValues: false | ||
}); } | ||
@@ -44,3 +44,3 @@ static { this.fatherConfigPath = null; } | ||
ignoreUndefined: true, | ||
referencedValues: false, | ||
referencedValues: false | ||
}); | ||
@@ -158,4 +158,4 @@ return this; | ||
trailingComma: { | ||
objects: true, | ||
}, | ||
objects: true | ||
} | ||
}); | ||
@@ -162,0 +162,0 @@ } |
@@ -16,5 +16,5 @@ /** | ||
message: `The configuration ${key} does not exist or the value is a hardcoded undefined.`, | ||
help: `To solve this problem you can set a default value when trying to get your configuration or setting a value to your ${key} configuration.`, | ||
help: `To solve this problem you can set a default value when trying to get your configuration or setting a value to your ${key} configuration.` | ||
}); | ||
} | ||
} |
@@ -17,5 +17,5 @@ /** | ||
message: `Rewriting a single key such as ({bold,yellow} "${key}") in your configuration file is not supported.`, | ||
help: `To rewrite the key ({bold,yellow} "${key}") in your configuration file you can simple use the ({bold,green} "Config.set('${key}', ...)") method first. Then, you can use the ({bold,green} "Config.rewrite('${possibleConfigFileName}')") method to rewrite the entire configuration file.`, | ||
help: `To rewrite the key ({bold,yellow} "${key}") in your configuration file you can simple use the ({bold,green} "Config.set('${key}', ...)") method first. Then, you can use the ({bold,green} "Config.rewrite('${possibleConfigFileName}')") method to rewrite the entire configuration file.` | ||
}); | ||
} | ||
} |
@@ -16,5 +16,5 @@ /** | ||
message: `Rewriting the athenna rc file using ({bold,yellow} "Config.rewrite()") method is not supported.`, | ||
help: `To rewrite the values of your athenna rc file you can use the ({bold,green} "Rc") helper imported from ({bold,green} "@athenna/config").`, | ||
help: `To rewrite the values of your athenna rc file you can use the ({bold,green} "Rc") helper imported from ({bold,green} "@athenna/config").` | ||
}); | ||
} | ||
} |
@@ -16,5 +16,5 @@ /** | ||
message: `The configuration ${key} is not a valid array, and it is not possible to push values to it.`, | ||
help: `Try changing your configuration key when calling push and pushAll methods or transform the value of your configuration ${key} to an array.`, | ||
help: `Try changing your configuration key when calling push and pushAll methods or transform the value of your configuration ${key} to an array.` | ||
}); | ||
} | ||
} |
@@ -16,5 +16,5 @@ /** | ||
help: `Remove the Config.get('${configName}') in the file ${filePath}`, | ||
message: `Your configuration file ${filePath} is using Config.get() to an other configuration file that is using a Config.get('${configName}*'), creating an infinite recursive call.`, | ||
message: `Your configuration file ${filePath} is using Config.get() to an other configuration file that is using a Config.get('${configName}*'), creating an infinite recursive call.` | ||
}); | ||
} | ||
} |
@@ -63,3 +63,3 @@ /** | ||
path: Path.pwd('.env'), | ||
override: this.isToOverrideEnvs(), | ||
override: this.isToOverrideEnvs() | ||
}; | ||
@@ -66,0 +66,0 @@ if (environment) { |
@@ -49,7 +49,2 @@ /** | ||
private static toStringJson; | ||
/** | ||
* Verify if the file is a module or not. | ||
* TODO: move to @athenna/common. | ||
*/ | ||
private static isModule; | ||
} |
@@ -9,5 +9,5 @@ /** | ||
*/ | ||
import { debug } from '#src/debug'; | ||
import { loadFile, writeFile } from 'magicast'; | ||
import { File, ObjectBuilder } from '@athenna/common'; | ||
import { debug } from '#src/debug/index'; | ||
import { File, Is, ObjectBuilder } from '@athenna/common'; | ||
export class Rc { | ||
@@ -21,3 +21,3 @@ /** | ||
ignoreNull: false, | ||
ignoreUndefined: false, | ||
ignoreUndefined: false | ||
}); | ||
@@ -32,3 +32,3 @@ this.file = await new File(path).load(); | ||
ignoreNull: false, | ||
ignoreUndefined: false, | ||
ignoreUndefined: false | ||
}); | ||
@@ -86,3 +86,3 @@ this.content.set(mod.default); | ||
static async save() { | ||
if (this.isModule()) { | ||
if (Is.Module(this.file.path)) { | ||
const mod = await loadFile(this.file.path); | ||
@@ -94,4 +94,4 @@ mod.exports.default = this.content.get(); | ||
trailingComma: { | ||
objects: true, | ||
}, | ||
objects: true | ||
} | ||
}); | ||
@@ -115,15 +115,2 @@ return; | ||
} | ||
/** | ||
* Verify if the file is a module or not. | ||
* TODO: move to @athenna/common. | ||
*/ | ||
static isModule() { | ||
if (this.file.extension === '.js') { | ||
return true; | ||
} | ||
if (this.file.extension === '.ts') { | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
41697
1040
Updatedmagicast@^0.2.10