@cocreate/cli 1.33.9 → 1.34.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/CoCreate.config.js +4 -0
- package/package.json +3 -6
- package/src/coc.js +1 -1
- package/src/commands/config.js +7 -121
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.34.1](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.34.0...v1.34.1) (2023-06-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Update dependencies versions for [@cocreate](https://github.com/cocreate) libraries ([0fa4419](https://github.com/CoCreate-app/CoCreate-cli/commit/0fa44194edaed9431f9fdfa9ab04ae938c6780c1))
|
|
7
|
+
|
|
8
|
+
# [1.34.0](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.33.9...v1.34.0) (2023-06-13)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* coc config --keyName=value ([472326f](https://github.com/CoCreate-app/CoCreate-cli/commit/472326faba5ff39de53e9edcb537f252c2c695e6))
|
|
14
|
+
|
|
1
15
|
## [1.33.9](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.33.8...v1.33.9) (2023-06-11)
|
|
2
16
|
|
|
3
17
|
|
package/CoCreate.config.js
CHANGED
|
@@ -78,6 +78,10 @@ module.exports = {
|
|
|
78
78
|
'path': '../CoCreate-conditional-logic',
|
|
79
79
|
'repo': 'github.com/CoCreate-app/CoCreate-conditional-logic.git'
|
|
80
80
|
},
|
|
81
|
+
{
|
|
82
|
+
'path': '../CoCreate-config',
|
|
83
|
+
'repo': 'github.com/CoCreate-app/CoCreate-config.git'
|
|
84
|
+
},
|
|
81
85
|
{
|
|
82
86
|
'path': '../CoCreate-crdt',
|
|
83
87
|
'repo': 'github.com/CoCreate-app/CoCreate-crdt.git',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.34.1",
|
|
4
4
|
"description": "Polyrepo management bash CLI tool. Run all git commands and yarn commands on multiple repositories. Also includes a few custom macros for cloning, installing, etc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -56,12 +56,9 @@
|
|
|
56
56
|
"bin": {
|
|
57
57
|
"coc": "src/coc.js"
|
|
58
58
|
},
|
|
59
|
-
"devdependencies": {
|
|
60
|
-
"@cocreate/cli": "^1.29.3"
|
|
61
|
-
},
|
|
62
59
|
"dependencies": {
|
|
63
|
-
"@cocreate/
|
|
64
|
-
"@cocreate/file": "^1.3.
|
|
60
|
+
"@cocreate/config": "^1.0.2",
|
|
61
|
+
"@cocreate/file": "^1.3.4",
|
|
65
62
|
"glob": "^7.1.7",
|
|
66
63
|
"prettier": "^2.3.2"
|
|
67
64
|
}
|
package/src/coc.js
CHANGED
package/src/commands/config.js
CHANGED
|
@@ -1,126 +1,12 @@
|
|
|
1
|
-
const
|
|
2
|
-
const os = require('os');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const fs = require('fs');
|
|
1
|
+
const config = require('@cocreate/config')
|
|
5
2
|
|
|
6
|
-
module.exports = async function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
return new Promise((resolve) => {
|
|
14
|
-
rl.question(question, (answer) => {
|
|
15
|
-
rl.close();
|
|
16
|
-
resolve(answer.trim());
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const filterEmptyValues = (obj) => {
|
|
22
|
-
return Object.fromEntries(
|
|
23
|
-
Object.entries(obj).filter(([_, value]) => {
|
|
24
|
-
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
25
|
-
return Object.keys(value).length > 0;
|
|
26
|
-
} else if (Array.isArray(value)) {
|
|
27
|
-
return value.length > 0;
|
|
28
|
-
} else {
|
|
29
|
-
return value !== '';
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
let config = {};
|
|
36
|
-
let update = false;
|
|
37
|
-
|
|
38
|
-
async function getConfig(items) {
|
|
39
|
-
if (!Array.isArray(items)) {
|
|
40
|
-
items = [items];
|
|
41
|
-
}
|
|
42
|
-
for (let i = 0; i < items.length; i++) {
|
|
43
|
-
let { key, prompt, choices } = items[i];
|
|
44
|
-
if (!key) {
|
|
45
|
-
if (!prompt && prompt !== '' || !choices) continue;
|
|
46
|
-
for (let choice of Object.keys(choices)) {
|
|
47
|
-
// if (!Array.isArray(choiceItems)) {
|
|
48
|
-
// choiceItems = [choiceItems];
|
|
49
|
-
// }
|
|
50
|
-
// for (let choice of choiceItems) {
|
|
51
|
-
let choiceKey = choices[choice].key
|
|
52
|
-
if (process.env[choiceKey]) {
|
|
53
|
-
config[choiceKey] = process.env[choiceKey];
|
|
54
|
-
return;
|
|
55
|
-
} else if (localConfig[choiceKey]) {
|
|
56
|
-
config[choiceKey] = localConfig[choiceKey];
|
|
57
|
-
return;
|
|
58
|
-
|
|
59
|
-
} else if (globalConfig[choiceKey]) {
|
|
60
|
-
config[choiceKey] = globalConfig[choiceKey];
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
// }
|
|
65
|
-
const answer = await promptForInput(prompt || `${key}: `);
|
|
66
|
-
const choice = choices[answer];
|
|
67
|
-
if (choice) {
|
|
68
|
-
await getConfig(choice);
|
|
69
|
-
}
|
|
70
|
-
} else {
|
|
71
|
-
|
|
72
|
-
if (process.env[key]) {
|
|
73
|
-
config[key] = process.env[key];
|
|
74
|
-
} else {
|
|
75
|
-
if (localConfig[key]) {
|
|
76
|
-
config[key] = localConfig[key];
|
|
77
|
-
} else if (globalConfig[key]) {
|
|
78
|
-
config[key] = globalConfig[key];
|
|
79
|
-
} else if (prompt || prompt === '') {
|
|
80
|
-
config[key] = await promptForInput(prompt || `${key}: `);
|
|
81
|
-
if (updateGlobal) update = true;
|
|
82
|
-
}
|
|
83
|
-
if (processEnv) {
|
|
84
|
-
if (typeof config[key] === 'object')
|
|
85
|
-
process.env[key] = JSON.stringify(config[key]);
|
|
86
|
-
else
|
|
87
|
-
process.env[key] = config[key];
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
3
|
+
module.exports = async function (repos, args) {
|
|
4
|
+
let object = {}
|
|
5
|
+
for (let arg of args) {
|
|
6
|
+
arg = arg.split('=')
|
|
7
|
+
object[arg[0].substring(2)] = { value: arg[1] }
|
|
92
8
|
}
|
|
93
9
|
|
|
94
|
-
|
|
95
|
-
const localConfigPath = path.resolve(process.cwd(), 'CoCreate.config.js');
|
|
96
|
-
if (fs.existsSync(localConfigPath)) {
|
|
97
|
-
localConfig = require(localConfigPath);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
let globalConfig = {};
|
|
101
|
-
const globalConfigPath = path.resolve(os.homedir(), 'CoCreate.config.js');
|
|
102
|
-
if (fs.existsSync(globalConfigPath)) {
|
|
103
|
-
globalConfig = require(globalConfigPath);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (items) {
|
|
107
|
-
await getConfig(items);
|
|
108
|
-
|
|
109
|
-
if (update) {
|
|
110
|
-
const updatedGlobalConfig = {
|
|
111
|
-
...filterEmptyValues(globalConfig),
|
|
112
|
-
...filterEmptyValues(config)
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const globalConfigString = `module.exports = ${JSON.stringify(updatedGlobalConfig, null, 2)};`;
|
|
116
|
-
fs.writeFileSync(globalConfigPath, globalConfigString);
|
|
117
|
-
}
|
|
118
|
-
} else {
|
|
119
|
-
config = {
|
|
120
|
-
...filterEmptyValues(globalConfig),
|
|
121
|
-
...filterEmptyValues(localConfig)
|
|
122
|
-
};
|
|
123
|
-
}
|
|
10
|
+
await config(object)
|
|
124
11
|
|
|
125
|
-
return config;
|
|
126
12
|
}
|