@cocreate/config
Advanced tools
Comparing version 1.9.0 to 1.10.0
@@ -0,1 +1,8 @@ | ||
# [1.10.0](https://github.com/CoCreate-app/CoCreate-config/compare/v1.9.0...v1.10.0) (2023-12-01) | ||
### Features | ||
* get config using CoCreate-config ([d6e0b22](https://github.com/CoCreate-app/CoCreate-config/commit/d6e0b2266674c34582cdddc0f36f6836ba1c11f1)) | ||
# [1.9.0](https://github.com/CoCreate-app/CoCreate-config/compare/v1.8.0...v1.9.0) (2023-11-25) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "@cocreate/config", | ||
"version": "1.9.0", | ||
"version": "1.10.0", | ||
"description": "A convenient chain handler allows user to chain multiple CoCreate components together. When one action is complete next one will start. The sequence goes untill all config completed. Grounded on Vanilla javascript, easily configured using HTML5 attributes and/or JavaScript API.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -7,2 +7,38 @@ const readline = require('readline'); | ||
/** | ||
* Asynchronously retrieves configuration values. This function allows for | ||
* fetching values from project-specific configuration, global configuration, or | ||
* environment variables. Project configuration takes precedence over global and | ||
* environment settings. It also supports interactive prompts to gather critical values | ||
* from the user if they are not already defined in the configuration. | ||
* | ||
* @async | ||
* @param {Object} items - An object representing the configuration items to retrieve. | ||
* The keys are the config paths, and the values are objects | ||
* specifying the prompt and any variable substitutions. | ||
* @param {boolean} [env=true] - Flag to consider environment variables during config lookup. | ||
* @param {boolean} [global=true] - Flag to consider global configuration during config lookup. | ||
* @param {string} [configPath='CoCreate.config.js'] - Path to the project-specific configuration file. | ||
* @returns {Promise<Object>} A promise that resolves with the configuration object. | ||
* | ||
* @example | ||
* // Usage of the Config function | ||
* async function initConfig() { | ||
* this.config = await Config({ | ||
* 'organization_id': { prompt: 'Enter your organization_id: ' }, | ||
* 'storage': { | ||
* prompt: 'Enter a friendly name for the new storage: ', | ||
* variable: 'name' | ||
* }, | ||
* 'storage.{{name}}.provider': { | ||
* prompt: 'Enter the storage provider, ex mongodb: ' | ||
* }, | ||
* 'storage.{{name}}.url': { | ||
* prompt: 'Enter the storage providers url: ' | ||
* } | ||
* }); | ||
* | ||
* const lazyLoadConfig = await Config('lazyload', false, false); | ||
* } | ||
*/ | ||
module.exports = async function (items, env = true, global = true, configPath = 'CoCreate.config.js') { | ||
@@ -42,2 +78,4 @@ async function promptForInput(question) { | ||
async function getConfig(items) { | ||
if (typeof items === 'string') | ||
items = { [items]: '' } | ||
for (let key of Object.keys(items)) { | ||
@@ -44,0 +82,0 @@ let { value, prompt, choices, variable } = items[key]; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
92437
338