@cocreate/config 1.0.5 → 1.0.7
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 +14 -0
- package/package.json +1 -1
- package/src/server.js +15 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.0.7](https://github.com/CoCreate-app/CoCreate-config/compare/v1.0.6...v1.0.7) (2023-06-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Add getValueFromObject to @cocreate/utils ([cefebf6](https://github.com/CoCreate-app/CoCreate-config/commit/cefebf6f630563f77ac6d997a494d65c00a10dc1))
|
|
7
|
+
|
|
8
|
+
## [1.0.6](https://github.com/CoCreate-app/CoCreate-config/compare/v1.0.5...v1.0.6) (2023-06-15)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* return config after dotNotationToObject ([97f0e63](https://github.com/CoCreate-app/CoCreate-config/commit/97f0e633f05d502dac7f88bb0deb216ac5143374))
|
|
14
|
+
|
|
1
15
|
## [1.0.5](https://github.com/CoCreate-app/CoCreate-config/compare/v1.0.4...v1.0.5) (2023-06-14)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/config",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
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",
|
package/src/server.js
CHANGED
|
@@ -2,7 +2,7 @@ const readline = require('readline');
|
|
|
2
2
|
const os = require('os');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const fs = require('fs');
|
|
5
|
-
const { dotNotationToObject } = require('@cocreate/utils');
|
|
5
|
+
const { dotNotationToObject, getValueFromObject } = require('@cocreate/utils');
|
|
6
6
|
|
|
7
7
|
module.exports = async function (items, env = true, global = true) {
|
|
8
8
|
async function promptForInput(question) {
|
|
@@ -58,20 +58,26 @@ module.exports = async function (items, env = true, global = true) {
|
|
|
58
58
|
await getConfig(choice);
|
|
59
59
|
}
|
|
60
60
|
} else if (variable) {
|
|
61
|
-
|
|
61
|
+
let variableValue = localConfig[key] || globalConfig[key]
|
|
62
|
+
if (!variableValue) {
|
|
63
|
+
variables[`{{${variable}}}`] = value || await promptForInput(prompt || `${variable}: `);
|
|
64
|
+
} else {
|
|
65
|
+
variables[`{{${variable}}}`] = Object.keys(variableValue)[0]
|
|
66
|
+
}
|
|
62
67
|
} else {
|
|
63
|
-
// TODO: handle dotnotation
|
|
64
68
|
if (value || value === "") {
|
|
65
69
|
config[key] = value;
|
|
66
70
|
if (global)
|
|
67
71
|
update = true;
|
|
68
72
|
} else if (process.env[key]) {
|
|
73
|
+
// TODO: if JSON.String object.parse()
|
|
69
74
|
config[key] = process.env[key];
|
|
70
75
|
} else {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
let localKey, globalKey
|
|
77
|
+
if (localKey = getValueFromObject(localConfig, key)) {
|
|
78
|
+
config[key] = localKey;
|
|
79
|
+
} else if (globalKey = getValueFromObject(globalConfig, key)) {
|
|
80
|
+
config[key] = globalKey;
|
|
75
81
|
} else if (prompt || prompt === '') {
|
|
76
82
|
config[key] = await promptForInput(prompt || `${key}: `);
|
|
77
83
|
if (global) update = true;
|
|
@@ -117,5 +123,6 @@ module.exports = async function (items, env = true, global = true) {
|
|
|
117
123
|
};
|
|
118
124
|
}
|
|
119
125
|
|
|
120
|
-
|
|
126
|
+
config = dotNotationToObject(config);
|
|
127
|
+
return config
|
|
121
128
|
}
|