@madgex/fert 4.2.5 → 4.2.6
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/bin/utils/configs.js +13 -7
- package/package.json +1 -1
package/bin/utils/configs.js
CHANGED
|
@@ -157,7 +157,8 @@ const updateProjectConfigs = async (
|
|
|
157
157
|
const { toRemove, toSet } = collateConfigs(api, localConfigs);
|
|
158
158
|
|
|
159
159
|
spinner.text = 'Updating configs…';
|
|
160
|
-
await
|
|
160
|
+
await setConfigs(api, toSet, spinner);
|
|
161
|
+
await removeConfigs(api, toRemove, spinner);
|
|
161
162
|
|
|
162
163
|
const { host } = new URL(api.options.apiUrl);
|
|
163
164
|
spinner.succeed(`Project configs applied to ${chalk.bold(host)}`);
|
|
@@ -226,24 +227,28 @@ const getUnsetKeysWithDefaults = (defaults = {}, config = {}) => {
|
|
|
226
227
|
return diff;
|
|
227
228
|
};
|
|
228
229
|
|
|
229
|
-
const removeConfigs = async (api, toRemove) => {
|
|
230
|
+
const removeConfigs = async (api, toRemove, spinner) => {
|
|
230
231
|
const deletePromises = Object.entries(toRemove).flatMap(
|
|
231
232
|
([configName, keys]) =>
|
|
232
|
-
keys.map((key) =>
|
|
233
|
-
|
|
233
|
+
keys.map(async (key) => {
|
|
234
|
+
try {
|
|
235
|
+
await api.deleteConfig(configName, key);
|
|
236
|
+
spinner.text = `Removed key ${chalk.bold(key)} from config: ${chalk.bold(configName)}`;
|
|
237
|
+
} catch (error) {
|
|
234
238
|
log.error('Failed to remove config', { configName, key, error });
|
|
235
|
-
}
|
|
236
|
-
)
|
|
239
|
+
}
|
|
240
|
+
})
|
|
237
241
|
);
|
|
238
242
|
|
|
239
243
|
await Promise.all(deletePromises);
|
|
240
244
|
};
|
|
241
245
|
|
|
242
|
-
const setConfigs = async (api, toSet) => {
|
|
246
|
+
const setConfigs = async (api, toSet, spinner) => {
|
|
243
247
|
const setPromises = Object.entries(toSet).flatMap(([configName, config]) =>
|
|
244
248
|
Object.entries(config).map(async ([key, value]) => {
|
|
245
249
|
try {
|
|
246
250
|
await api.setConfig(configName, key, value);
|
|
251
|
+
spinner.text = `Set key ${chalk.bold(key)} for config: ${chalk.bold(configName)}`;
|
|
247
252
|
} catch (error) {
|
|
248
253
|
log.error('Failed to set config', { configName, key, value, error });
|
|
249
254
|
}
|
|
@@ -252,6 +257,7 @@ const setConfigs = async (api, toSet) => {
|
|
|
252
257
|
|
|
253
258
|
await Promise.all(setPromises);
|
|
254
259
|
};
|
|
260
|
+
|
|
255
261
|
module.exports = {
|
|
256
262
|
getConfigAPI,
|
|
257
263
|
validateLocalConfigs,
|