@ductape/cli 0.4.5 → 0.4.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.
@@ -306,7 +306,22 @@ export async function configureProductApp(ctx, productRef, appRef, updates) {
306
306
  const accessTag = String(link.access_tag ?? '');
307
307
  if (!accessTag)
308
308
  throw new Error(`Connected App "${appRef}" has no access tag`);
309
- const existing = Array.isArray(link.envs) ? link.envs : [];
309
+ // A freshly-connected app env is persisted with `auth: {}` — a truthy but empty placeholder,
310
+ // not an absent field. `validateAppEnvs()`/`validateAppAuth()` (server-side) unconditionally
311
+ // tries to resolve ANY truthy `auth`, so that placeholder throws "app_auth undefined not found"
312
+ // for any App with zero auth schemes — the documented `credentials`-only path for such an App
313
+ // (DT-085). Only an `auth` with real content (at least an auth_tag) is worth keeping; an empty
314
+ // object is equivalent to "no auth configured yet" and must be stripped everywhere it could
315
+ // reach the outgoing request — not just on the env(s) this call happens to update. `envs` below
316
+ // sends every env on the link (existing untouched ones included, since the backend replaces the
317
+ // whole array), so an untouched env's own stale placeholder would fail identically otherwise.
318
+ const hasMeaningfulAuth = (value) => Boolean(value && typeof value === 'object' && Object.keys(value).length > 0);
319
+ const existing = (Array.isArray(link.envs) ? link.envs : []).map((env) => {
320
+ const clean = { ...env };
321
+ if (!hasMeaningfulAuth(clean.auth))
322
+ delete clean.auth;
323
+ return clean;
324
+ });
310
325
  const byProductEnv = new Map(existing.map((env) => [String(env.product_env_slug ?? ''), { ...env }]));
311
326
  for (const update of updates) {
312
327
  const productEnv = String(update.product_env_slug ?? '');
@@ -315,15 +330,24 @@ export async function configureProductApp(ctx, productRef, appRef, updates) {
315
330
  throw new Error('Each connection env requires product_env_slug and app_env_slug');
316
331
  }
317
332
  const previous = byProductEnv.get(productEnv) ?? {};
318
- byProductEnv.set(productEnv, {
333
+ const merged = {
319
334
  ...previous,
320
335
  ...update,
321
- // Omission means preserve; explicit auth/variables replace that field.
322
- ...(!Object.prototype.hasOwnProperty.call(update, 'auth') && previous.auth !== undefined
323
- ? { auth: previous.auth } : {}),
336
+ // Omission means preserve; explicit variables replaces that field.
324
337
  ...(!Object.prototype.hasOwnProperty.call(update, 'variables') && previous.variables !== undefined
325
338
  ? { variables: previous.variables } : {}),
326
- });
339
+ };
340
+ // auth needs explicit resolution rather than spread order: update's own auth (if any) always
341
+ // wins; otherwise only a genuinely meaningful previous.auth survives, and a non-meaningful one
342
+ // (the {} placeholder, or one inherited from the initial ...previous spread) is removed rather
343
+ // than left in place.
344
+ if (!Object.prototype.hasOwnProperty.call(update, 'auth')) {
345
+ if (hasMeaningfulAuth(previous.auth))
346
+ merged.auth = previous.auth;
347
+ else
348
+ delete merged.auth;
349
+ }
350
+ byProductEnv.set(productEnv, merged);
327
351
  }
328
352
  const envs = [...byProductEnv.values()];
329
353
  await proxy(ctx).execute('product', 'apps.update', [productTag, accessTag, { envs }]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ductape/cli",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "Ductape CLI — local platform, login, link projects, and manage resources via the proxy (Workbench-compatible)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",