@cocreate/config 1.8.0 → 1.10.0

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ # [1.10.0](https://github.com/CoCreate-app/CoCreate-config/compare/v1.9.0...v1.10.0) (2023-12-01)
2
+
3
+
4
+ ### Features
5
+
6
+ * get config using CoCreate-config ([d6e0b22](https://github.com/CoCreate-app/CoCreate-config/commit/d6e0b2266674c34582cdddc0f36f6836ba1c11f1))
7
+
8
+ # [1.9.0](https://github.com/CoCreate-app/CoCreate-config/compare/v1.8.0...v1.9.0) (2023-11-25)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * update licensing details ([0384b70](https://github.com/CoCreate-app/CoCreate-config/commit/0384b7042e18ee576d98dd92d32c32c7b0b9fba3))
14
+
15
+
16
+ ### Features
17
+
18
+ * upgrade dependencies for latest features and fixes ([8003f7d](https://github.com/CoCreate-app/CoCreate-config/commit/8003f7dbeedcb6a87e4f3031b0e33aa05efc498e))
19
+
1
20
  # [1.8.0](https://github.com/CoCreate-app/CoCreate-config/compare/v1.7.0...v1.8.0) (2023-11-25)
2
21
 
3
22
 
package/README.md CHANGED
@@ -68,18 +68,14 @@ Please Email the Developer Experience Team [here](mailto:develop@cocreate.app) i
68
68
 
69
69
  CoCreate-config is maintained and funded by CoCreate. The names and logos for CoCreate are trademarks of CoCreate, LLC.
70
70
 
71
- <a name="contribute"></a>
72
-
73
- # How to Contribute
74
-
75
- We encourage contribution to our libraries (you might even score some nifty swag), please see our [CONTRIBUTING](https://github.com/CoCreate-app/CoCreate-config/blob/master/CONTRIBUTING.md) guide for details.
71
+ <a name="license"></a>
76
72
 
77
- We want this library to be community-driven, and CoCreate led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create [issues](https://github.com/CoCreate-app/CoCreate-config/issues) and [pull requests](https://github.com/CoCreate-app/CoCreate-config/pulls) or merely upvote or comment on existing issues or pull requests.
73
+ # License
78
74
 
79
- We appreciate your continued support, thank you!
75
+ This software is dual-licensed under the GNU Affero General Public License version 3 (AGPLv3) and a commercial license.
80
76
 
81
- <a name="license"></a>
77
+ - **Open Source Use**: For open-source projects and non-commercial use, this software is available under the AGPLv3. The AGPLv3 allows you to freely use, modify, and distribute this software, provided that all modifications and derivative works are also licensed under the AGPLv3. For the full license text, see the [LICENSE file](https://github.com/CoCreate-app/CoCreate-config/blob/master/LICENSE).
82
78
 
83
- # License
79
+ - **Commercial Use**: For-profit companies and individuals intending to use this software for commercial purposes must obtain a commercial license. The commercial license is available when you sign up for an API key on our [website](https://cocreate.app). This license permits proprietary use and modification of the software without the copyleft requirements of the AGPLv3. It is ideal for integrating this software into proprietary commercial products and applications.
84
80
 
85
- [The MIT License (MIT)](https://github.com/CoCreate-app/CoCreate-config/blob/master/LICENSE)
81
+ If you have not purchased a commercial license and intend to use this software for commercial purposes, you are required to sign up for an API key on our website.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/config",
3
- "version": "1.8.0",
3
+ "version": "1.10.0",
4
4
  "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
5
  "keywords": [
6
6
  "config",
@@ -59,6 +59,6 @@
59
59
  "webpack-log": "^3.0.1"
60
60
  },
61
61
  "dependencies": {
62
- "@cocreate/utils": "^1.28.0"
62
+ "@cocreate/utils": "^1.29.0"
63
63
  }
64
64
  }
package/src/server.js CHANGED
@@ -4,6 +4,42 @@ const path = require('path');
4
4
  const fs = require('fs');
5
5
  const { dotNotationToObject, getValueFromObject } = require('@cocreate/utils');
6
6
 
7
+ /**
8
+ * Asynchronously retrieves configuration values. This function allows for
9
+ * fetching values from project-specific configuration, global configuration, or
10
+ * environment variables. Project configuration takes precedence over global and
11
+ * environment settings. It also supports interactive prompts to gather critical values
12
+ * from the user if they are not already defined in the configuration.
13
+ *
14
+ * @async
15
+ * @param {Object} items - An object representing the configuration items to retrieve.
16
+ * The keys are the config paths, and the values are objects
17
+ * specifying the prompt and any variable substitutions.
18
+ * @param {boolean} [env=true] - Flag to consider environment variables during config lookup.
19
+ * @param {boolean} [global=true] - Flag to consider global configuration during config lookup.
20
+ * @param {string} [configPath='CoCreate.config.js'] - Path to the project-specific configuration file.
21
+ * @returns {Promise<Object>} A promise that resolves with the configuration object.
22
+ *
23
+ * @example
24
+ * // Usage of the Config function
25
+ * async function initConfig() {
26
+ * this.config = await Config({
27
+ * 'organization_id': { prompt: 'Enter your organization_id: ' },
28
+ * 'storage': {
29
+ * prompt: 'Enter a friendly name for the new storage: ',
30
+ * variable: 'name'
31
+ * },
32
+ * 'storage.{{name}}.provider': {
33
+ * prompt: 'Enter the storage provider, ex mongodb: '
34
+ * },
35
+ * 'storage.{{name}}.url': {
36
+ * prompt: 'Enter the storage providers url: '
37
+ * }
38
+ * });
39
+ *
40
+ * const lazyLoadConfig = await Config('lazyload', false, false);
41
+ * }
42
+ */
7
43
  module.exports = async function (items, env = true, global = true, configPath = 'CoCreate.config.js') {
8
44
  async function promptForInput(question) {
9
45
  const rl = readline.createInterface({
@@ -38,6 +74,8 @@ module.exports = async function (items, env = true, global = true, configPath =
38
74
  let variables = {};
39
75
 
40
76
  async function getConfig(items) {
77
+ if (typeof items === 'string')
78
+ items = { [items]: '' }
41
79
  for (let key of Object.keys(items)) {
42
80
  let { value, prompt, choices, variable } = items[key];
43
81