@cocreate/config 1.11.0 → 1.12.1
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 +23 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.12.1](https://github.com/CoCreate-app/CoCreate-config/compare/v1.12.0...v1.12.1) (2024-01-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* removed test logs ([5956d42](https://github.com/CoCreate-app/CoCreate-config/commit/5956d42fa2b5c1d13a5ab8c45bc5397e50d0e947))
|
|
7
|
+
|
|
8
|
+
# [1.12.0](https://github.com/CoCreate-app/CoCreate-config/compare/v1.11.0...v1.12.0) (2024-01-09)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* define config based on current git branch ([27c7fb3](https://github.com/CoCreate-app/CoCreate-config/commit/27c7fb3b1969c94063c2383cfaad352c255599e6))
|
|
14
|
+
|
|
1
15
|
# [1.11.0](https://github.com/CoCreate-app/CoCreate-config/compare/v1.10.0...v1.11.0) (2024-01-08)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.1",
|
|
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,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 = {};
|
|
@@ -131,9 +152,9 @@ module.exports = async function (items, env = true, global = true, configPath =
|
|
|
131
152
|
} else {
|
|
132
153
|
let localKey, globalKey
|
|
133
154
|
if (localKey = getValueFromObject(localConfig, key)) {
|
|
134
|
-
config[key] = localKey;
|
|
155
|
+
config[key] = await getValue(localKey);
|
|
135
156
|
} else if (globalKey = getValueFromObject(globalConfig, key)) {
|
|
136
|
-
config[key] = globalKey;
|
|
157
|
+
config[key] = await getValue(globalKey);
|
|
137
158
|
} else if (prompt || prompt === '') {
|
|
138
159
|
config[key] = await promptForInput(prompt || `${key}: `);
|
|
139
160
|
if (global) update = true;
|