@mks2508/coolify-mks-cli-mcp 0.4.1 → 0.4.2
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/dist/cli/index.js +19 -6
- package/dist/coolify/index.d.ts.map +1 -1
- package/dist/index.cjs +22 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -1
- package/dist/index.js.map +1 -1
- package/dist/server/stdio.js +19 -6
- package/package.json +1 -1
- package/src/coolify/index.ts +21 -7
package/dist/server/stdio.js
CHANGED
|
@@ -17293,13 +17293,26 @@ class CoolifyService {
|
|
|
17293
17293
|
for (const [key, value] of Object.entries(envVars)) {
|
|
17294
17294
|
const result = await this.request(`/applications/${appUuid}/envs`, {
|
|
17295
17295
|
method: "POST",
|
|
17296
|
-
body: JSON.stringify({
|
|
17297
|
-
key,
|
|
17298
|
-
value,
|
|
17299
|
-
is_preview: false
|
|
17300
|
-
})
|
|
17296
|
+
body: JSON.stringify({ key, value, is_preview: false })
|
|
17301
17297
|
});
|
|
17302
|
-
if (result.error) {
|
|
17298
|
+
if (result.error && result.error.includes("already exists")) {
|
|
17299
|
+
const listResult = await this.request(`/applications/${appUuid}/envs`);
|
|
17300
|
+
const existing = listResult.data?.find((v) => v.key === key);
|
|
17301
|
+
if (existing) {
|
|
17302
|
+
const patchResult = await this.request(`/applications/${appUuid}/envs/${existing.uuid}`, {
|
|
17303
|
+
method: "PATCH",
|
|
17304
|
+
body: JSON.stringify({ key, value, is_preview: false })
|
|
17305
|
+
});
|
|
17306
|
+
if (patchResult.error) {
|
|
17307
|
+
log.error(`Failed to update env var ${key}: ${patchResult.error}`);
|
|
17308
|
+
return err(new Error(`Failed to update ${key}: ${patchResult.error}`));
|
|
17309
|
+
}
|
|
17310
|
+
log.debug(`Updated existing env var: ${key}`);
|
|
17311
|
+
} else {
|
|
17312
|
+
log.error(`Failed to set env var ${key}: ${result.error}`);
|
|
17313
|
+
return err(new Error(`Failed to set ${key}: ${result.error}`));
|
|
17314
|
+
}
|
|
17315
|
+
} else if (result.error) {
|
|
17303
17316
|
log.error(`Failed to set env var ${key}: ${result.error}`);
|
|
17304
17317
|
return err(new Error(`Failed to set ${key}: ${result.error}`));
|
|
17305
17318
|
}
|
package/package.json
CHANGED
package/src/coolify/index.ts
CHANGED
|
@@ -364,18 +364,32 @@ export class CoolifyService {
|
|
|
364
364
|
): Promise<Result<void, Error>> {
|
|
365
365
|
log.info(`Setting ${Object.keys(envVars).length} environment variables for ${appUuid}`)
|
|
366
366
|
|
|
367
|
-
// Coolify API
|
|
367
|
+
// Coolify API: POST to create, PATCH to update existing
|
|
368
368
|
for (const [key, value] of Object.entries(envVars)) {
|
|
369
369
|
const result = await this.request(`/applications/${appUuid}/envs`, {
|
|
370
370
|
method: 'POST',
|
|
371
|
-
body: JSON.stringify({
|
|
372
|
-
key,
|
|
373
|
-
value,
|
|
374
|
-
is_preview: false,
|
|
375
|
-
}),
|
|
371
|
+
body: JSON.stringify({ key, value, is_preview: false }),
|
|
376
372
|
})
|
|
377
373
|
|
|
378
|
-
if (result.error) {
|
|
374
|
+
if (result.error && result.error.includes('already exists')) {
|
|
375
|
+
// Var exists — find its UUID and PATCH
|
|
376
|
+
const listResult = await this.request<Array<{ uuid: string; key: string }>>(`/applications/${appUuid}/envs`)
|
|
377
|
+
const existing = listResult.data?.find((v) => v.key === key)
|
|
378
|
+
if (existing) {
|
|
379
|
+
const patchResult = await this.request(`/applications/${appUuid}/envs/${existing.uuid}`, {
|
|
380
|
+
method: 'PATCH',
|
|
381
|
+
body: JSON.stringify({ key, value, is_preview: false }),
|
|
382
|
+
})
|
|
383
|
+
if (patchResult.error) {
|
|
384
|
+
log.error(`Failed to update env var ${key}: ${patchResult.error}`)
|
|
385
|
+
return err(new Error(`Failed to update ${key}: ${patchResult.error}`))
|
|
386
|
+
}
|
|
387
|
+
log.debug(`Updated existing env var: ${key}`)
|
|
388
|
+
} else {
|
|
389
|
+
log.error(`Failed to set env var ${key}: ${result.error}`)
|
|
390
|
+
return err(new Error(`Failed to set ${key}: ${result.error}`))
|
|
391
|
+
}
|
|
392
|
+
} else if (result.error) {
|
|
379
393
|
log.error(`Failed to set env var ${key}: ${result.error}`)
|
|
380
394
|
return err(new Error(`Failed to set ${key}: ${result.error}`))
|
|
381
395
|
}
|