@cocreate/config 1.10.0 → 1.12.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 +14 -0
- package/package.json +2 -3
- package/src/server.js +26 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [1.12.0](https://github.com/CoCreate-app/CoCreate-config/compare/v1.11.0...v1.12.0) (2024-01-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* define config based on current git branch ([27c7fb3](https://github.com/CoCreate-app/CoCreate-config/commit/27c7fb3b1969c94063c2383cfaad352c255599e6))
|
|
7
|
+
|
|
8
|
+
# [1.11.0](https://github.com/CoCreate-app/CoCreate-config/compare/v1.10.0...v1.11.0) (2024-01-08)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* bumped CoCreate dependencies to their latest versions ([cbf3a42](https://github.com/CoCreate-app/CoCreate-config/commit/cbf3a4287e7063b1b1d2580d58cd3e558ae6f680))
|
|
14
|
+
|
|
1
15
|
# [1.10.0](https://github.com/CoCreate-app/CoCreate-config/compare/v1.9.0...v1.10.0) (2023-12-01)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.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",
|
|
7
|
-
"chain-functions",
|
|
8
7
|
"cocreate",
|
|
9
8
|
"low-code-framework",
|
|
10
9
|
"no-code-framework",
|
|
@@ -59,6 +58,6 @@
|
|
|
59
58
|
"webpack-log": "^3.0.1"
|
|
60
59
|
},
|
|
61
60
|
"dependencies": {
|
|
62
|
-
"@cocreate/utils": "^1.
|
|
61
|
+
"@cocreate/utils": "^1.30.0"
|
|
63
62
|
}
|
|
64
63
|
}
|
package/src/server.js
CHANGED
|
@@ -2,6 +2,9 @@ const readline = require('readline');
|
|
|
2
2
|
const os = require('os');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const fs = require('fs');
|
|
5
|
+
const util = require('node:util');
|
|
6
|
+
const exec = util.promisify(require('node:child_process').exec);
|
|
7
|
+
|
|
5
8
|
const { dotNotationToObject, getValueFromObject } = require('@cocreate/utils');
|
|
6
9
|
|
|
7
10
|
/**
|
|
@@ -69,6 +72,24 @@ module.exports = async function (items, env = true, global = true, configPath =
|
|
|
69
72
|
);
|
|
70
73
|
};
|
|
71
74
|
|
|
75
|
+
async function getValue(value) {
|
|
76
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
77
|
+
return value;
|
|
78
|
+
} else if (value.$branch) {
|
|
79
|
+
try {
|
|
80
|
+
const { stdout } = await exec('git branch --show-current');
|
|
81
|
+
return value.$branch[stdout.trim()];
|
|
82
|
+
} catch (error) {
|
|
83
|
+
console.error(`exec error: ${error}`);
|
|
84
|
+
// Handle the error or return a default value
|
|
85
|
+
return null; // or a default value as per your logic
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
return value;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
72
93
|
let config = {};
|
|
73
94
|
let update = false;
|
|
74
95
|
let variables = {};
|
|
@@ -121,6 +142,9 @@ module.exports = async function (items, env = true, global = true, configPath =
|
|
|
121
142
|
variables[`{{${variable}}}`] = Object.keys(variableValue)[0]
|
|
122
143
|
}
|
|
123
144
|
} else {
|
|
145
|
+
if (key === 'host')
|
|
146
|
+
console.log(key)
|
|
147
|
+
|
|
124
148
|
if (value || value === "") {
|
|
125
149
|
config[key] = value;
|
|
126
150
|
if (global)
|
|
@@ -131,9 +155,9 @@ module.exports = async function (items, env = true, global = true, configPath =
|
|
|
131
155
|
} else {
|
|
132
156
|
let localKey, globalKey
|
|
133
157
|
if (localKey = getValueFromObject(localConfig, key)) {
|
|
134
|
-
config[key] = localKey;
|
|
158
|
+
config[key] = await getValue(localKey);
|
|
135
159
|
} else if (globalKey = getValueFromObject(globalConfig, key)) {
|
|
136
|
-
config[key] = globalKey;
|
|
160
|
+
config[key] = await getValue(globalKey);
|
|
137
161
|
} else if (prompt || prompt === '') {
|
|
138
162
|
config[key] = await promptForInput(prompt || `${key}: `);
|
|
139
163
|
if (global) update = true;
|