buddy-workbench 0.1.63 → 0.1.65
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/package.json +1 -1
- package/server/routes/settings.js +7 -4
- package/server/services/dev-configurations.js +38 -31
- package/ui/dist/assets/index-CcRPCrZX.js +567 -0
- package/ui/dist/assets/index-CttT8YZu.css +1 -0
- package/ui/dist/index.html +2 -2
- package/ui/dist/sw.js +2 -2
- package/ui/dist/assets/index-BLZTK59v.css +0 -1
- package/ui/dist/assets/index-BwG59AsB.js +0 -548
package/package.json
CHANGED
|
@@ -13,11 +13,14 @@ router.get('/dev-configurations', async (_req, res) => {
|
|
|
13
13
|
try { res.json({ ...(await readDevConfigurations()), nvm: await readNvmConfiguration() }); } catch (error) { res.status(500).json({ error: error.message }); }
|
|
14
14
|
});
|
|
15
15
|
router.put('/dev-configurations', async (req, res) => {
|
|
16
|
-
const {
|
|
17
|
-
if (!npm
|
|
18
|
-
return res.status(400).json({ error: '
|
|
16
|
+
const { section } = req.body || {};
|
|
17
|
+
if (!['npm', 'git', 'nvm'].includes(section)) {
|
|
18
|
+
return res.status(400).json({ error: 'A valid configuration section is required.' });
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
if (!req.body?.[section] || typeof req.body[section] !== 'object') {
|
|
21
|
+
return res.status(400).json({ error: `${section.toUpperCase()} configuration is required.` });
|
|
22
|
+
}
|
|
23
|
+
try { res.json({ ...(await saveDevConfigurations({ [section]: req.body[section] }, { section })), nvm: await readNvmConfiguration() }); } catch (error) { res.status(500).json({ error: error.message }); }
|
|
21
24
|
});
|
|
22
25
|
router.post('/dev-configurations/nvm/install', async (req, res) => {
|
|
23
26
|
try { res.json(await installNvmVersion(req.body?.version)); } catch (error) { res.status(400).json({ error: error.message }); }
|
|
@@ -224,41 +224,48 @@ async function setNpmConfig(key, value) {
|
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
export async function saveDevConfigurations(configurations = {}) {
|
|
227
|
+
export async function saveDevConfigurations(configurations = {}, options = {}) {
|
|
228
|
+
const section = options.section || '';
|
|
228
229
|
const npm = configurations.npm || {};
|
|
229
230
|
const git = configurations.git || {};
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
for (const [key, value] of Object.entries(gitValues)) {
|
|
241
|
-
if (value) await run('git', ['config', '--global', `user.${key}`, value]);
|
|
242
|
-
else {
|
|
243
|
-
try { await run('git', ['config', '--global', '--unset', `user.${key}`]); } catch {}
|
|
244
|
-
}
|
|
231
|
+
if (!section || section === 'npm') {
|
|
232
|
+
const npmValues = {
|
|
233
|
+
prefix: String(npm.prefix || '').trim(),
|
|
234
|
+
registry: String(npm.registry || '').trim() || 'https://registry.npmjs.org/',
|
|
235
|
+
'strict-ssl': npm.strictSsl === false ? 'false' : 'true',
|
|
236
|
+
cache: String(npm.cache || '').trim(),
|
|
237
|
+
proxy: String(npm.proxy || '').trim(),
|
|
238
|
+
'https-proxy': String(npm.httpsProxy || '').trim()
|
|
239
|
+
};
|
|
240
|
+
for (const key of NPM_KEYS) await setNpmConfig(key, npmValues[key]);
|
|
245
241
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
242
|
+
if (!section || section === 'git') {
|
|
243
|
+
const gitValues = { name: String(git.name || '').trim(), email: String(git.email || '').trim() };
|
|
244
|
+
for (const [key, value] of Object.entries(gitValues)) {
|
|
245
|
+
if (value) await run('git', ['config', '--global', `user.${key}`, value]);
|
|
246
|
+
else {
|
|
247
|
+
try { await run('git', ['config', '--global', '--unset', `user.${key}`]); } catch {}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
const sshKey = String(git.sshKey || '').trim();
|
|
251
|
+
if (sshKey) {
|
|
252
|
+
const resolvedKey = sshKey.startsWith('~/') ? `${homedir()}/${sshKey.slice(2)}` : sshKey;
|
|
253
|
+
const quotedKey = `"${resolvedKey.replaceAll('"', '\\"')}"`;
|
|
254
|
+
await run('git', ['config', '--global', 'core.sshCommand', `ssh -i ${quotedKey} -o IdentitiesOnly=yes`]);
|
|
255
|
+
} else {
|
|
256
|
+
try { await run('git', ['config', '--global', '--unset', 'core.sshCommand']); } catch {}
|
|
257
|
+
}
|
|
253
258
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
259
|
+
if (!section || section === 'nvm') {
|
|
260
|
+
const nvm = configurations.nvm || {};
|
|
261
|
+
const mirror = String(nvm.nodeJsMirror || '').trim().replace(/\/$/, '');
|
|
262
|
+
if (mirror && !/^https?:\/\/[^\s]+$/i.test(mirror)) throw new Error('Invalid NVM Node.js download mirror URL.');
|
|
263
|
+
updateNvmMirror(mirror);
|
|
264
|
+
if (String(nvm.defaultVersion || '').trim()) {
|
|
265
|
+
const version = String(nvm.defaultVersion).trim();
|
|
266
|
+
if (!/^(?:v?\d+(?:\.\d+){0,2}|node|lts\/[\w.-]+)$/.test(version)) throw new Error('Invalid NVM default version.');
|
|
267
|
+
await runNvm(`nvm alias default ${shellQuote(version)}`);
|
|
268
|
+
}
|
|
262
269
|
}
|
|
263
270
|
return readDevConfigurations();
|
|
264
271
|
}
|