From 8dc67c6049c4062e3fa39958c8bff60e82f2a828 Mon Sep 17 00:00:00 2001 From: SakshiKoli-CS Date: Thu, 19 Nov 2026 12:32:13 +0530 Subject: [PATCH 1/5] CL-8833 | +Claude | skip env:update when flags match the current settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit launch:env:update sent a PUT whenever any flag was passed, even when every value equalled what the environment already had: it reported success and moved updatedAt. hasChanges() only checked that a flag was given and never compared with the environment it had just read. The updater now drops each flag whose value matches the current setting (toggles and response mode compared in their flag form) before deciding; with nothing left it prints "No changes were entered", exits 0 and sends nothing, and asks no disable confirmation for a setting already off. --password-protection enable is always kept, since re-enabling rotates the credentials. The interactive response-mode prompt defaults to the current mode when the API reports it. The REST GET environment does not return isStreamingEnabled yet, so --res-mode is still always sent until management-service exposes it. .talismanrc checksums refreshed for the three edited files. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .talismanrc | 14 +-- src/environments/environment.inputs.ts | 16 ++++ .../environment.update.prompt.test.ts | 16 ++++ src/environments/environment.update.prompt.ts | 25 +++--- src/environments/environment.update.test.ts | 85 ++++++++++++++++++- src/environments/environment.update.ts | 44 ++++++++-- src/environments/types.ts | 1 + test/integration/environments-update.test.ts | 29 ++++++- 8 files changed, 199 insertions(+), 31 deletions(-) diff --git a/.talismanrc b/.talismanrc index f29926f0..358b42c7 100644 --- a/.talismanrc +++ b/.talismanrc @@ -116,7 +116,7 @@ fileignoreconfig: allowed_patterns: - "assertArray\\(response, key, `\\$\\{key\\} response`\\)" - filename: src/environments/environment.inputs.ts - checksum: 3fc2802c79457f7c7e93cd5f32c00a7986dc6f686fe3c346de4b8436a66cc0b9 + checksum: 1d7e451146125afe8f489c980aef06c5124bcdee2b1ea77c03a2c08264651355 ignore_detectors: - filename - filename: src/environments/environment.builder.ts @@ -127,11 +127,11 @@ fileignoreconfig: - filename checksum: 8b7e3207630f19170dd08ca639ebca8af6bc0d70db633b98e66eedde6d2ea641 - filename: src/environments/environment.update.ts - checksum: b1e15e174f98a875f97e0683182638f93966ef4c498135d36df620a28338aacb + checksum: a34957100a694d97a14333c8a2c5dc238d7dd0a09c159f64839dc27f25955216 ignore_detectors: - filename - filename: src/environments/environment.update.test.ts - checksum: 5e90c3dd231ede1b890f7c750c7063412116a2e4be536d2f290d56d28205ceae + checksum: 615f87b080bea3972202d26d338326559f4d930d40cb39b22fe6528c5caabf92 ignore_detectors: - filename - filename: src/environments/environment.create.ts @@ -145,11 +145,11 @@ fileignoreconfig: ignore_detectors: - filename - filename: src/environments/environment.update.prompt.ts - checksum: 5f2da5ae044eda92f9e555c997d23f065b5454cda8a340c12595597795ecfbb9 + checksum: 60fa6750226d15fc5d70e8e55c6e2edc17558a55fbfe0b6d8bf653f924639ebe ignore_detectors: - filename - filename: src/environments/environment.update.prompt.test.ts - checksum: 6653e245baac00cef348acfc0aa2f32d03a7ff63ca3c320ee56a0c6250775004 + checksum: eeebb3e7a86c41056d7405b8666a42bc2883af177126739779404692403f0de6 ignore_detectors: - filename - filename: src/environments/environment.presenter.ts @@ -311,7 +311,7 @@ fileignoreconfig: - filename: test/credential-guard.setup.ts checksum: 519ccbeb0552fdb1d5f27308c56477c0258ee6cc0adec8f618e8e5bc047cbf6d - filename: src/environments/types.ts - checksum: 2825d0e70757022e518465b134878b8cc8f9eccaf4e9ad088d73a31b9a35a826 + checksum: d40a622cfd8f4425d017e12180b55d72159747a2663b67bb690ade6604d1bbe5 - filename: src/commands/launch/env/get.test.ts checksum: 6e739ef12bc0d887e652e23ee54d9fac30dd6a3505cf464cdaefc0e696cf3e51 - filename: test/integration/environments-delete.test.ts @@ -325,7 +325,7 @@ fileignoreconfig: - filename: src/core/prompt.test.ts checksum: 7be5497acf4cee870667751d44aa230e309784df76dc9e95d5ec2c4e6e6a57e0 - filename: test/integration/environments-update.test.ts - checksum: 249f27ad679b68f40eac3af90c616229838bceffad57ba508dd298ab053fa51a + checksum: 511fbfaac6e4ac978217da2d1ee99b84cd6b543cbacaa74e977c9ff5652d024b - filename: src/commands/launch/env/update.ts checksum: 06add97108d878eaf415e32160439b8963683e63a0e37ce77a56f66b88383c7a - filename: src/commands/launch/env/update.test.ts diff --git a/src/environments/environment.inputs.ts b/src/environments/environment.inputs.ts index 5c482469..1903ad37 100644 --- a/src/environments/environment.inputs.ts +++ b/src/environments/environment.inputs.ts @@ -36,6 +36,22 @@ export const TOGGLE_VALUES = ['enable', 'disable'] as const; export type ToggleValue = (typeof TOGGLE_VALUES)[number]; +export function toggleOf(value: boolean | undefined): ToggleValue | undefined { + if (value === undefined) { + return undefined; + } + + return value ? 'enable' : 'disable'; +} + +export function responseModeOf(streaming: boolean | undefined): ResponseMode | undefined { + if (streaming === undefined) { + return undefined; + } + + return streaming ? 'streaming' : 'buffered'; +} + export function frameworkPresetOf(value: string): FrameworkPreset { return FRAMEWORK_PRESET_BY_LABEL[oneOf('framework', value, FRAMEWORK_CHOICES).toLowerCase()]; } diff --git a/src/environments/environment.update.prompt.test.ts b/src/environments/environment.update.prompt.test.ts index 311488f8..d03805e2 100644 --- a/src/environments/environment.update.prompt.test.ts +++ b/src/environments/environment.update.prompt.test.ts @@ -168,6 +168,22 @@ describe('promptForEnvironmentUpdate', () => { expect(asked[1].default).toBe('buffered'); }); + it.each([ + [true, 'streaming', {}], + [true, 'buffered', { resMode: 'buffered' }], + [false, 'buffered', {}], + ])( + 'defaults the response mode to the current one when the API reports it (streaming %p) and drops an unchanged %s', + async (isStreamingEnabled, answer, expected) => { + const { services, asked } = servicesAnswering({ [SETTINGS_QUESTION]: ['resMode'], 'Response mode': answer }); + + await expect( + promptForEnvironmentUpdate(services, githubContext({ ...CURRENT, isStreamingEnabled })), + ).resolves.toEqual(expected); + expect(asked[1].default).toBe(isStreamingEnabled ? 'streaming' : 'buffered'); + }, + ); + it('skips the server command, saying why, when the framework it would run under takes none', async () => { const { services, asked, lines } = servicesAnswering({ [SETTINGS_QUESTION]: ['serverCmd'] }); diff --git a/src/environments/environment.update.prompt.ts b/src/environments/environment.update.prompt.ts index 56aabaf2..d7130c05 100644 --- a/src/environments/environment.update.prompt.ts +++ b/src/environments/environment.update.prompt.ts @@ -2,13 +2,14 @@ import { askChoices, askOption, askOptionalText, askText } from '../core/prompt' import type { ServiceContext } from '../core/service-context'; import { askBranch } from '../git/git.prompt'; import { frameworkLabelOf } from './environment.builder'; -import type { ToggleValue } from './environment.inputs'; import { ENVIRONMENT_DESCRIPTION_MAX_LENGTH, ENVIRONMENT_NAME_MAX_LENGTH, RESPONSE_MODES, TOGGLE_VALUES, frameworkPresetOf, + responseModeOf, + toggleOf, } from './environment.inputs'; import type { ProjectRepository } from './environment.rules'; import { gitScopeOf } from './environment.rules'; @@ -60,14 +61,6 @@ const SETTINGS: { setting: Setting; label: string; repositoryOnly?: boolean }[] { setting: 'passwordProtection', label: 'Password protection' }, ]; -function toggleOf(value: boolean | undefined): ToggleValue | undefined { - if (value === undefined) { - return undefined; - } - - return value ? 'enable' : 'disable'; -} - function changed(answer: T | undefined, current: T | undefined): T | undefined { return answer === current ? undefined : answer; } @@ -128,7 +121,7 @@ class SettingAsker { case 'outputDir': return this.text(askText(ux, 'Output directory', current.outputDirectory), current.outputDirectory); case 'resMode': - return askOption(ux, 'Response mode', RESPONSE_MODES.map((value) => ({ name: value, value })), 'buffered'); + return this.responseMode(); case 'autoDeploy': return this.toggle('Auto deploy', current.autoDeployOnPush); case 'csAuth': @@ -144,6 +137,18 @@ class SettingAsker { return changed(await answer, current); } + private async responseMode(): Promise { + const current = responseModeOf(this.context.current.isStreamingEnabled); + const answer = await askOption( + this.services.ux, + 'Response mode', + RESPONSE_MODES.map((value) => ({ name: value, value })), + current ?? 'buffered', + ); + + return changed(answer, current); + } + private async framework(): Promise { const current = this.context.current.frameworkPreset; const label = await askOption( diff --git a/src/environments/environment.update.test.ts b/src/environments/environment.update.test.ts index 435eb8e7..f50b7e48 100644 --- a/src/environments/environment.update.test.ts +++ b/src/environments/environment.update.test.ts @@ -21,6 +21,7 @@ interface Harness { fails?: 'project' | 'environment' | 'update'; passwordProtected?: boolean; piped?: string; + current?: Record; } function updaterUnderTest(harness: Harness = {}) { @@ -63,6 +64,7 @@ function updaterUnderTest(harness: Harness = {}) { uid: 'env1', frameworkPreset: 'frameworkPreset' in harness ? harness.frameworkPreset : 'NEXTJS', passwordProtection: { isEnabled: harness.passwordProtected ?? false }, + ...harness.current, }; }, update: async (params: unknown) => { @@ -99,7 +101,7 @@ function request(fields: Partial): EnvironmentUpdateRe describe('EnvironmentUpdater', () => { it('maps every supplied flag onto its body field and sends one PUT', async () => { - const { updater, sent, lines } = updaterUnderTest(); + const { updater, sent, lines } = updaterUnderTest({ frameworkPreset: 'GATSBY' }); await expect( updater.update( @@ -185,6 +187,81 @@ describe('EnvironmentUpdater', () => { expect(sent).toEqual([{ ...SCOPE, update: { name: 'renamed' } }]); }); + it.each([ + [{ resMode: 'streaming' as const }, { isStreamingEnabled: true }], + [{ resMode: 'buffered' as const }, { isStreamingEnabled: false }], + [{ csAuth: 'disable' as const }, { isContentstackAuthenticationEnabled: false }], + [{ autoDeploy: 'enable' as const }, { autoDeployOnPush: true }], + [{ cachePriming: 'disable' as const }, { isCachePrimingEnabled: false }], + [{ passwordProtection: 'disable' as const }, {}], + [ + { buildCmd: 'npm run build', outputDir: '.next', framework: 'NEXTJS' as const, branch: 'sample', name: 'staging' }, + { buildCommand: 'npm run build', outputDirectory: '.next', gitBranch: 'sample', name: 'staging' }, + ], + [{ description: 'the live site', serverCmd: 'npm start' }, { description: 'the live site', serverCommand: 'npm start' }], + ])( + 'says nothing changed, asks nothing and sends nothing when %p matches the current settings', + async (fields, current) => { + const { updater, calls, lines, questions } = updaterUnderTest({ current }); + + await expect(updater.update(request(fields))).resolves.toBe('unchanged'); + + expect(calls).not.toContain('update'); + expect(questions).toEqual([]); + expect(lines).toEqual(['Environment not updated. No changes were entered.']); + }, + ); + + it('sends only the flags whose values differ from the current settings', async () => { + const { updater, sent } = updaterUnderTest({ + current: { name: 'staging', isStreamingEnabled: true, isContentstackAuthenticationEnabled: false }, + }); + + await expect( + updater.update(request({ name: 'staging', resMode: 'streaming', csAuth: 'enable', buildCmd: 'npm run build' })), + ).resolves.toBe('updated'); + + expect(sent).toEqual([ + { ...SCOPE, update: { isContentstackAuthenticationEnabled: true, buildCommand: 'npm run build' } }, + ]); + }); + + it('checks a changed --server-cmd against the current framework when an unchanged --framework is dropped', async () => { + const { updater, sent } = updaterUnderTest({ frameworkPreset: 'NUXT' }); + + await expect(updater.update(request({ framework: 'NUXT', serverCmd: 'node server' }))).resolves.toBe('updated'); + + expect(sent).toEqual([{ ...SCOPE, update: { serverCommand: 'node server' } }]); + }); + + it('refuses a changed --server-cmd when an unchanged --framework is dropped and that framework takes none', async () => { + const { updater, calls } = updaterUnderTest({ frameworkPreset: 'GATSBY' }); + + await expect(updater.update(request({ framework: 'GATSBY', serverCmd: 'node server' }))).rejects.toThrow( + '--server-cmd is only supported when --framework is one of ANALOG, ANGULAR, NUXT, ASTRO, REMIX, OTHER; ' + + '--framework is GATSBY.', + ); + expect(calls).not.toContain('update'); + }); + + it('sends --res-mode when the environment does not report its current response mode', async () => { + const { updater, sent } = updaterUnderTest(); + + await updater.update(request({ resMode: 'streaming' })); + + expect(sent).toEqual([{ ...SCOPE, update: { isStreamingEnabled: true } }]); + }); + + it('still enables password protection that is already on, so its credentials can be rotated', async () => { + const { updater, sent } = updaterUnderTest({ passwordProtected: true, answers: { Password: NEW_PASSWORD } }); + + await expect(updater.update(request({ passwordProtection: 'enable', username: 'admin2' }))).resolves.toBe('updated'); + + expect(sent).toEqual([ + { ...SCOPE, update: { passwordProtection: { isEnabled: true, username: 'admin2', password: NEW_PASSWORD } } }, + ]); + }); + it('reads the project and the environment before sending the update', async () => { const { updater, calls } = updaterUnderTest({ projectType: 'FILEUPLOAD' }); @@ -257,7 +334,7 @@ describe('EnvironmentUpdater', () => { }); it('asks before disabling password protection and sends only isEnabled false once confirmed', async () => { - const { updater, questions, sent } = updaterUnderTest(); + const { updater, questions, sent } = updaterUnderTest({ passwordProtected: true }); await updater.update(request({ passwordProtection: 'disable' })); @@ -266,7 +343,7 @@ describe('EnvironmentUpdater', () => { }); it('asks both questions, cache priming first, when both are being disabled', async () => { - const { updater, questions } = updaterUnderTest(); + const { updater, questions } = updaterUnderTest({ passwordProtected: true }); await updater.update(request({ cachePriming: 'disable', passwordProtection: 'disable' })); @@ -279,7 +356,7 @@ describe('EnvironmentUpdater', () => { it.each([[[false]], [[true, false]]])( 'says the environment was not updated and sends nothing when an answer is no (%p)', async (confirmations) => { - const { updater, calls, lines } = updaterUnderTest({ confirmations }); + const { updater, calls, lines } = updaterUnderTest({ confirmations, passwordProtected: true }); await expect( updater.update(request({ cachePriming: 'disable', passwordProtection: 'disable' })), diff --git a/src/environments/environment.update.ts b/src/environments/environment.update.ts index 6234d3b7..bdf9e7ce 100644 --- a/src/environments/environment.update.ts +++ b/src/environments/environment.update.ts @@ -4,7 +4,7 @@ import { readPipedInput } from '../core/piped-input'; import { requireValueOf } from '../core/rules'; import type { ServiceContext } from '../core/service-context'; import type { ResponseMode, ToggleValue } from './environment.inputs'; -import { usernameOf } from './environment.inputs'; +import { responseModeOf, toggleOf, usernameOf } from './environment.inputs'; import { withoutRepositoryFlags } from './environment.rules'; import { disableQuestion, @@ -12,10 +12,11 @@ import { environmentNotUpdatedLine, environmentUpdatedLine, } from './environment.presenter'; +import type { EnvironmentChanges } from './environment.update.prompt'; import { promptForEnvironmentUpdate } from './environment.update.prompt'; import type { FrameworkPreset } from './frameworks'; import { SERVER_COMMAND_FRAMEWORKS } from './frameworks'; -import type { EnvironmentUpdate, PasswordProtectionUpdate } from './types'; +import type { Environment, EnvironmentUpdate, PasswordProtectionUpdate } from './types'; export interface EnvironmentUpdateRequest { org: string; @@ -80,6 +81,37 @@ function hasChanges(request: EnvironmentUpdateRequest): boolean { return UPDATABLE_FLAGS.some(([field]) => request[field] !== undefined); } +// Enabling password protection is never unchanged: enabling it again is how its credentials are rotated. +function currentValuesOf(existing: Environment): EnvironmentChanges { + return { + name: existing.name, + description: existing.description, + branch: existing.gitBranch, + framework: existing.frameworkPreset as FrameworkPreset | undefined, + buildCmd: existing.buildCommand, + serverCmd: existing.serverCommand, + outputDir: existing.outputDirectory, + resMode: responseModeOf(existing.isStreamingEnabled), + autoDeploy: toggleOf(existing.autoDeployOnPush), + csAuth: toggleOf(existing.isContentstackAuthenticationEnabled), + cachePriming: toggleOf(existing.isCachePrimingEnabled), + passwordProtection: existing.passwordProtection?.isEnabled === false ? 'disable' : undefined, + }; +} + +function withoutCurrentValues(request: EnvironmentUpdateRequest, existing: Environment): EnvironmentUpdateRequest { + const current = currentValuesOf(existing); + const kept = { ...request }; + + for (const field of Object.keys(current) as (keyof EnvironmentChanges)[]) { + if (current[field] !== undefined && kept[field] === current[field]) { + delete kept[field]; + } + } + + return kept; +} + function emptyUpdateMessage(): string { const flags = UPDATABLE_FLAGS.map(([, flag]) => `--${flag}`).join(', '); @@ -166,11 +198,9 @@ export class EnvironmentUpdater { })), } : given; - const request = withoutRepositoryFlags( - answered, - current.projectType, - this.services.ux, - this.services.outputIsTTY === true, + const request = withoutCurrentValues( + withoutRepositoryFlags(answered, current.projectType, this.services.ux, this.services.outputIsTTY === true), + existing, ); if (!hasChanges(request)) { diff --git a/src/environments/types.ts b/src/environments/types.ts index c725e78f..c20009c8 100644 --- a/src/environments/types.ts +++ b/src/environments/types.ts @@ -46,6 +46,7 @@ export interface Environment { serverCommand?: string; domains?: EnvironmentDomain[]; autoDeployOnPush?: boolean; + isStreamingEnabled?: boolean; isContentstackAuthenticationEnabled?: boolean; isCachePrimingEnabled?: boolean; passwordProtection?: EnvironmentPasswordProtection; diff --git a/test/integration/environments-update.test.ts b/test/integration/environments-update.test.ts index 80a28511..7861557a 100644 --- a/test/integration/environments-update.test.ts +++ b/test/integration/environments-update.test.ts @@ -41,12 +41,12 @@ function updateArgs(...extra: string[]): string[] { return ['launch:env:update', '--org', ORG_UID, '--project', PROJECT_UID, '--env', ENV_UID, '--data-dir', DATA_DIR, ...extra]; } -function reads(project: unknown = projectFixture) { +function reads(project: unknown = projectFixture, environment: unknown = getFixture) { projectOwnership(LAUNCH_HUB_URL, ORG_UID, PROJECT_UID); return [ nock(LAUNCH_HUB_URL).get(`/manage/projects/${PROJECT_UID}`).reply(200, project as nock.Body), - nock(LAUNCH_HUB_URL).get(ENV_PATH).reply(200, getFixture), + nock(LAUNCH_HUB_URL).get(ENV_PATH).reply(200, environment as nock.Body), ]; } @@ -107,6 +107,29 @@ describe('integration: launch:env:update on the wire', () => { expect(onWire).toEqual([]); }); + it('exits 0 saying nothing changed, and never sends the PUT, when every flag matches the current settings', async () => { + const [project, environment] = reads(); + const put = update([]); + + const { error, stdout } = await runCommand( + updateArgs( + '--name', 'production', + '--branch', 'main', + '--output-dir', './_site', + '--auto-deploy', 'enable', + '--cs-auth', 'enable', + '--cache-priming', 'disable', + '--password-protection', 'disable', + ), + config, + ); + + expect(error).toBeUndefined(); + expect([project.isDone(), environment.isDone(), put.isDone()]).toEqual([true, true, false]); + expect(stdout).toBe('Environment not updated. No changes were entered.\n'); + expect(onWire).toEqual([]); + }); + it('refuses a password value on the command line with exit 2 before any request, without echoing it', async () => { const password = randomBytes(8).toString('hex'); @@ -134,7 +157,7 @@ describe('integration: launch:env:update on the wire', () => { it('exits 2 naming --yes, and never sends the PUT, when disabling cache priming without a terminal', async () => { const sent: unknown[] = []; - reads(); + reads(projectFixture, { environment: { ...getFixture.environment, isCachePrimingEnabled: true } }); const put = update(sent); const { error } = await runCommand(updateArgs('--cache-priming', 'disable'), config); From a907f118f7451949edfe216dcbd681d046dd7c52 Mon Sep 17 00:00:00 2001 From: SakshiKoli-CS Date: Thu, 19 Nov 2026 16:11:47 +0530 Subject: [PATCH 2/5] CL-8833 | +Claude | refresh talisman checksums after merging v2-dev MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The v2-dev merge changed files that already have reviewed .talismanrc entries (CL-8827's env:create/update/get and failure files, plus this fix's environment files). Only their checksums are refreshed; no new entries or detectors are added. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .talismanrc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.talismanrc b/.talismanrc index b30b7aed..4af37956 100644 --- a/.talismanrc +++ b/.talismanrc @@ -6,7 +6,7 @@ fileignoreconfig: - filename: src/commands/launch/logs/get.test.ts checksum: d94d390de150956c799f64a84adfe0e02b5b21c66ddcc5cf55a1329aa67ec1a7 - filename: src/core/failure.test.ts - checksum: d8be306f3bde77249360475bbb76093ce67458f3530c3b4c5bd7e6a516a910aa + checksum: 3f5c731861dc816d141f6314c32bec55bc5197241447a4375bc76fa9f85339f0 - filename: test/integration/retired-commands.test.ts checksum: c38d6e8dae6bd4d2034ff48bff488e89cc00d950a7417c6df890168ac743ae37 - filename: test/integration/manage-base-path.test.ts @@ -116,7 +116,7 @@ fileignoreconfig: allowed_patterns: - "assertArray\\(response, key, `\\$\\{key\\} response`\\)" - filename: src/environments/environment.inputs.ts - checksum: 1d7e451146125afe8f489c980aef06c5124bcdee2b1ea77c03a2c08264651355 + checksum: 6fc02e91d0eddc16fea2b5d3159a3d23ca0f0c4b4c72e0a95e9b29c27a6c8915 ignore_detectors: - filename - filename: src/environments/environment.builder.ts @@ -127,7 +127,7 @@ fileignoreconfig: - filename checksum: 8b7e3207630f19170dd08ca639ebca8af6bc0d70db633b98e66eedde6d2ea641 - filename: src/environments/environment.update.ts - checksum: a34957100a694d97a14333c8a2c5dc238d7dd0a09c159f64839dc27f25955216 + checksum: c93c96884368a73c5b4a1c06e8e18febe59da710e7a97f8e890b993729b7b9d3 ignore_detectors: - filename - filename: src/environments/environment.update.test.ts @@ -145,19 +145,19 @@ fileignoreconfig: ignore_detectors: - filename - filename: src/environments/environment.update.prompt.ts - checksum: 60fa6750226d15fc5d70e8e55c6e2edc17558a55fbfe0b6d8bf653f924639ebe + checksum: d2a18e0ebd44539256a7578bf5fef96705f02138e29e378fa77c133854b0416d ignore_detectors: - filename - filename: src/environments/environment.update.prompt.test.ts - checksum: eeebb3e7a86c41056d7405b8666a42bc2883af177126739779404692403f0de6 + checksum: 37373e11ff627cf36ae48d08de3418755ec5c2b5d7dd7efc398503e4c23aa6a6 ignore_detectors: - filename - filename: src/environments/environment.presenter.ts - checksum: 3ca3e566a136fb0100cd794e9e973fce70a80c88224b6f93027d8190ac0b6882 + checksum: 3808d26ca5eb7f345568b56fe48f5756e14f0cdb15ef68b2ae72e9556bc6bab2 ignore_detectors: - filename - filename: src/environments/environment.presenter.test.ts - checksum: f5f6e5ec469a16ca8e1c9175ec88aa406a24c6318ef95520d534c444fdd3ab88 + checksum: 3e28f6188a450b47d874453a37e22193d9e5036762d34f55315118ed54a73c0a ignore_detectors: - filename - filename: src/environments/environment.resolver.ts @@ -311,9 +311,9 @@ fileignoreconfig: - filename: test/credential-guard.setup.ts checksum: 519ccbeb0552fdb1d5f27308c56477c0258ee6cc0adec8f618e8e5bc047cbf6d - filename: src/environments/types.ts - checksum: d40a622cfd8f4425d017e12180b55d72159747a2663b67bb690ade6604d1bbe5 + checksum: 5cee50642cb37067772ddaf8252c04d19f70881520ad588bb1b26c6cae0ae594 - filename: src/commands/launch/env/get.test.ts - checksum: 6e739ef12bc0d887e652e23ee54d9fac30dd6a3505cf464cdaefc0e696cf3e51 + checksum: 6b79822734553c7417c0a8774fae221609d008be22834113661c9925f17017b9 - filename: test/integration/environments-delete.test.ts checksum: a6f002256162971e5f4ace879153454c95199101d2acc853f2a54b39d1d48914 - filename: src/commands/launch/env/delete.test.ts @@ -327,11 +327,11 @@ fileignoreconfig: - filename: test/integration/environments-update.test.ts checksum: 511fbfaac6e4ac978217da2d1ee99b84cd6b543cbacaa74e977c9ff5652d024b - filename: src/commands/launch/env/update.ts - checksum: 06add97108d878eaf415e32160439b8963683e63a0e37ce77a56f66b88383c7a + checksum: 981c3267005bca0453131b532c9b62ca501bc67cfd25511c261e99082677882a - filename: src/commands/launch/env/update.test.ts - checksum: 2da219594e7bdd589adc0eff9ff035252a75aaa51dfa20514b18fd3266d7b752 + checksum: 82c76af721bfdfd8eb7cf49494ffbe15d98b988e98bca1015b9d34b42b5226bd - filename: README.md - checksum: a3c7d1fc273e7b5b818f0a7f05664fd7ddbb05c2f2eb44c28b5d496aad828508 + checksum: 73a32e3cce7d4647ff3a5e15200a9d455d3473155a4c964bcf09378ab6552015 allowed_patterns: - "password-protection" - "-p, --password" From 81ed2c2161e4d348d6fe4b6f908f815bf8962e81 Mon Sep 17 00:00:00 2001 From: SakshiKoli-CS Date: Thu, 19 Nov 2026 16:18:30 +0530 Subject: [PATCH 3/5] CL-8833 | +Claude | address review: null is not a known current value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - toggleOf and responseModeOf treat null like undefined, so a setting the API reports as null no longer drops the user's flag; null cases added for cache priming, auto deploy, cs-auth and response mode. - Remove the code comment on currentValuesOf (AGENTS.md: no code comments); the rotation test already pins that behaviour. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .talismanrc | 6 +++--- src/environments/environment.inputs.ts | 8 ++++---- src/environments/environment.update.test.ts | 17 +++++++++++++++++ src/environments/environment.update.ts | 1 - 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/.talismanrc b/.talismanrc index 4af37956..c114c0f1 100644 --- a/.talismanrc +++ b/.talismanrc @@ -116,7 +116,7 @@ fileignoreconfig: allowed_patterns: - "assertArray\\(response, key, `\\$\\{key\\} response`\\)" - filename: src/environments/environment.inputs.ts - checksum: 6fc02e91d0eddc16fea2b5d3159a3d23ca0f0c4b4c72e0a95e9b29c27a6c8915 + checksum: aad346ce288f2f72c7e88c3cea21e9bd6939dfc3c76d1cf997688cd31fcbf460 ignore_detectors: - filename - filename: src/environments/environment.builder.ts @@ -127,11 +127,11 @@ fileignoreconfig: - filename checksum: 8b7e3207630f19170dd08ca639ebca8af6bc0d70db633b98e66eedde6d2ea641 - filename: src/environments/environment.update.ts - checksum: c93c96884368a73c5b4a1c06e8e18febe59da710e7a97f8e890b993729b7b9d3 + checksum: 29922e4bf64d57e9bb893e18c03a8f860318089c7e2c87fb756e39e4fdfe92ee ignore_detectors: - filename - filename: src/environments/environment.update.test.ts - checksum: 10b04b99e3d6a1f70edbdd1fb362632e7bfea3e0f982aadc89f3ec7de45188d0 + checksum: cbf145ab0e7e80ad6189b6c46238bf9d64295ad15be9facaa56b4e44f68d83dc ignore_detectors: - filename - filename: src/environments/environment.create.ts diff --git a/src/environments/environment.inputs.ts b/src/environments/environment.inputs.ts index 3b0ffa10..e67aba98 100644 --- a/src/environments/environment.inputs.ts +++ b/src/environments/environment.inputs.ts @@ -33,16 +33,16 @@ export const TOGGLE_VALUES = ['enable', 'disable'] as const; export type ToggleValue = (typeof TOGGLE_VALUES)[number]; -export function toggleOf(value: boolean | undefined): ToggleValue | undefined { - if (value === undefined) { +export function toggleOf(value: boolean | null | undefined): ToggleValue | undefined { + if (value === undefined || value === null) { return undefined; } return value ? 'enable' : 'disable'; } -export function responseModeOf(streaming: boolean | undefined): ResponseMode | undefined { - if (streaming === undefined) { +export function responseModeOf(streaming: boolean | null | undefined): ResponseMode | undefined { + if (streaming === undefined || streaming === null) { return undefined; } diff --git a/src/environments/environment.update.test.ts b/src/environments/environment.update.test.ts index bebb55a0..325785da 100644 --- a/src/environments/environment.update.test.ts +++ b/src/environments/environment.update.test.ts @@ -210,6 +210,23 @@ describe('EnvironmentUpdater', () => { }, ); + it.each([ + [{ cachePriming: 'disable' as const }, { isCachePrimingEnabled: null }, { isCachePrimingEnabled: false }], + [{ autoDeploy: 'disable' as const }, { autoDeployOnPush: null }, { autoDeployOnPush: false }], + [ + { csAuth: 'disable' as const }, + { isContentstackAuthenticationEnabled: null }, + { isContentstackAuthenticationEnabled: false }, + ], + [{ resMode: 'buffered' as const }, { isStreamingEnabled: null }, { isStreamingEnabled: false }], + ])('sends %p when the API reports the current setting as null, since null is not a known value', async (fields, current, update) => { + const { updater, sent } = updaterUnderTest({ current }); + + await expect(updater.update(request(fields))).resolves.toBe('updated'); + + expect(sent).toEqual([{ ...SCOPE, update }]); + }); + it('sends only the flags whose values differ from the current settings', async () => { const { updater, sent } = updaterUnderTest({ current: { name: 'staging', isStreamingEnabled: true, isContentstackAuthenticationEnabled: false }, diff --git a/src/environments/environment.update.ts b/src/environments/environment.update.ts index b51bb18a..96295091 100644 --- a/src/environments/environment.update.ts +++ b/src/environments/environment.update.ts @@ -79,7 +79,6 @@ function hasChanges(request: EnvironmentUpdateRequest): boolean { return UPDATABLE_FLAGS.some(([field]) => request[field] !== undefined); } -// Enabling password protection is never unchanged: enabling it again is how its credentials are rotated. function currentValuesOf(existing: Environment): EnvironmentChanges { return { name: existing.name, From 04691cec653c9d4a4dcbecaae579fec00755127c Mon Sep 17 00:00:00 2001 From: SakshiKoli-CS Date: Thu, 19 Nov 2026 17:14:57 +0530 Subject: [PATCH 4/5] CL-8833 | +Claude | address review: name matching flags, allow null in Environment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - When flags were passed and every one matches the current settings, env:update now prints "Environment not updated: --cs-auth, --cache-priming already match the current settings." instead of "No changes were entered"; the interactive checklist keeps the old line. - Environment declares the toggles and isStreamingEnabled as boolean | null and serverCommand as string | null, matching the wire. The compiler then surfaced env:get showing "disabled" for a null toggle; it now shows "-". #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .talismanrc | 14 ++++---- .../environment.presenter.test.ts | 35 +++++++++++++++++++ src/environments/environment.presenter.ts | 15 +++++--- src/environments/environment.update.prompt.ts | 6 ++-- src/environments/environment.update.test.ts | 32 +++++++++++------ src/environments/environment.update.ts | 25 ++++++++++--- src/environments/types.ts | 10 +++--- test/integration/environments-update.test.ts | 5 ++- 8 files changed, 108 insertions(+), 34 deletions(-) diff --git a/.talismanrc b/.talismanrc index c114c0f1..046ece38 100644 --- a/.talismanrc +++ b/.talismanrc @@ -127,11 +127,11 @@ fileignoreconfig: - filename checksum: 8b7e3207630f19170dd08ca639ebca8af6bc0d70db633b98e66eedde6d2ea641 - filename: src/environments/environment.update.ts - checksum: 29922e4bf64d57e9bb893e18c03a8f860318089c7e2c87fb756e39e4fdfe92ee + checksum: b94619d9a9a70447f7cee8978a014c7b54da820c010f36971dc09cfe779f0d5b ignore_detectors: - filename - filename: src/environments/environment.update.test.ts - checksum: cbf145ab0e7e80ad6189b6c46238bf9d64295ad15be9facaa56b4e44f68d83dc + checksum: 1dd1ace001bb903ca0937964fc022e2c465e81ba33ac6f8b8da12091879bb280 ignore_detectors: - filename - filename: src/environments/environment.create.ts @@ -145,7 +145,7 @@ fileignoreconfig: ignore_detectors: - filename - filename: src/environments/environment.update.prompt.ts - checksum: d2a18e0ebd44539256a7578bf5fef96705f02138e29e378fa77c133854b0416d + checksum: a68cca8e5f2544bcb940c45825266b42c92e2d9639dee68dcc6d7a0e9db7270f ignore_detectors: - filename - filename: src/environments/environment.update.prompt.test.ts @@ -153,11 +153,11 @@ fileignoreconfig: ignore_detectors: - filename - filename: src/environments/environment.presenter.ts - checksum: 3808d26ca5eb7f345568b56fe48f5756e14f0cdb15ef68b2ae72e9556bc6bab2 + checksum: 505f5e76e34ab9081cb0d57d6c017799bf0c7d86a08bb77201c6737a1affbaef ignore_detectors: - filename - filename: src/environments/environment.presenter.test.ts - checksum: 3e28f6188a450b47d874453a37e22193d9e5036762d34f55315118ed54a73c0a + checksum: 9120a7bc0ce7e7307be8bc76e5e7133f13c0ed186bcb932de9e9fba364a30c99 ignore_detectors: - filename - filename: src/environments/environment.resolver.ts @@ -311,7 +311,7 @@ fileignoreconfig: - filename: test/credential-guard.setup.ts checksum: 519ccbeb0552fdb1d5f27308c56477c0258ee6cc0adec8f618e8e5bc047cbf6d - filename: src/environments/types.ts - checksum: 5cee50642cb37067772ddaf8252c04d19f70881520ad588bb1b26c6cae0ae594 + checksum: c45a2ed513e295ef56da5a6a014e31cb7de3612fc699a3d3b157e525843e8303 - filename: src/commands/launch/env/get.test.ts checksum: 6b79822734553c7417c0a8774fae221609d008be22834113661c9925f17017b9 - filename: test/integration/environments-delete.test.ts @@ -325,7 +325,7 @@ fileignoreconfig: - filename: src/core/prompt.test.ts checksum: 7be5497acf4cee870667751d44aa230e309784df76dc9e95d5ec2c4e6e6a57e0 - filename: test/integration/environments-update.test.ts - checksum: 511fbfaac6e4ac978217da2d1ee99b84cd6b543cbacaa74e977c9ff5652d024b + checksum: 970201a8562532f7cb5314680e8c49b5613d68b794a80f3cfe792ebcad0c7a41 - filename: src/commands/launch/env/update.ts checksum: 981c3267005bca0453131b532c9b62ca501bc67cfd25511c261e99082677882a - filename: src/commands/launch/env/update.test.ts diff --git a/src/environments/environment.presenter.test.ts b/src/environments/environment.presenter.test.ts index bb107d08..8dc0299c 100644 --- a/src/environments/environment.presenter.test.ts +++ b/src/environments/environment.presenter.test.ts @@ -5,6 +5,7 @@ import { ENVIRONMENT_VALUE_COLUMN, environmentColumns, environmentDeletedLine, + environmentAlreadyMatchesLine, environmentDetailRows, environmentNoChangesLine, environmentNotDeletedLine, @@ -94,6 +95,23 @@ describe('environmentDetailRows', () => { ]); }); + it('renders a placeholder, not "disabled", for a toggle or server command the API reports as null', () => { + const rows = environmentDetailRows({ + serverCommand: null, + autoDeployOnPush: null, + isCachePrimingEnabled: null, + isContentstackAuthenticationEnabled: null, + }); + const valueOf = (field: string) => rows.find((row) => row.field === field)?.value; + + expect(['SERVER COMMAND', 'AUTO DEPLOY', 'CACHE PRIMING', 'CONTENTSTACK AUTHENTICATION'].map(valueOf)).toEqual([ + '-', + '-', + '-', + '-', + ]); + }); + it('renders a placeholder for every field an environment arrives without, and a zero variable count', () => { expect(environmentDetailRows({}).map((row) => row.value)).toEqual([ '-', @@ -169,6 +187,23 @@ describe('environment delete wording', () => { }); }); +describe('environmentAlreadyMatchesLine', () => { + it('names one matching flag in the singular, in yellow on a terminal and plain otherwise', () => { + expect(environmentAlreadyMatchesLine(['cs-auth'], true)).toBe( + '\u001b[33mEnvironment not updated: --cs-auth already matches the current settings.\u001b[39m', + ); + expect(environmentAlreadyMatchesLine(['cs-auth'], false)).toBe( + 'Environment not updated: --cs-auth already matches the current settings.', + ); + }); + + it('names several matching flags in the plural, in the order given', () => { + expect(environmentAlreadyMatchesLine(['cs-auth', 'cache-priming'], false)).toBe( + 'Environment not updated: --cs-auth, --cache-priming already match the current settings.', + ); + }); +}); + describe('environmentNoChangesLine', () => { it('says nothing was changed in yellow on a terminal and plain otherwise', () => { expect(environmentNoChangesLine(true)).toBe('\u001b[33mEnvironment not updated. No changes were entered.\u001b[39m'); diff --git a/src/environments/environment.presenter.ts b/src/environments/environment.presenter.ts index 652aa7ce..de32a074 100644 --- a/src/environments/environment.presenter.ts +++ b/src/environments/environment.presenter.ts @@ -9,12 +9,12 @@ export interface DetailRow { value: string; } -function text(value: string | undefined): string { - return value === undefined || isAbsent(value) ? '-' : value; +function text(value: string | null | undefined): string { + return value === undefined || value === null || isAbsent(value) ? '-' : value; } -function toggle(value: boolean | undefined): string { - if (value === undefined) { +function toggle(value: boolean | null | undefined): string { + if (value === undefined || value === null) { return '-'; } @@ -124,3 +124,10 @@ export function environmentDeploymentFailureMessage(failure: EnvironmentDeployme export function environmentNoChangesLine(outputIsTTY: boolean): string { return styled('Environment not updated. No changes were entered.', 'yellow', outputIsTTY); } + +export function environmentAlreadyMatchesLine(flags: readonly string[], outputIsTTY: boolean): string { + const named = flags.map((flag) => `--${flag}`).join(', '); + const verb = flags.length === 1 ? 'matches' : 'match'; + + return styled(`Environment not updated: ${named} already ${verb} the current settings.`, 'yellow', outputIsTTY); +} diff --git a/src/environments/environment.update.prompt.ts b/src/environments/environment.update.prompt.ts index d772a305..93819246 100644 --- a/src/environments/environment.update.prompt.ts +++ b/src/environments/environment.update.prompt.ts @@ -166,7 +166,9 @@ class SettingAsker { return undefined; } - return this.text(askOptionalText(this.services.ux, 'Server command', current.serverCommand), current.serverCommand); + const serverCommand = current.serverCommand ?? undefined; + + return this.text(askOptionalText(this.services.ux, 'Server command', serverCommand), serverCommand); } private async passwordProtection(current: boolean | undefined): Promise { @@ -175,7 +177,7 @@ class SettingAsker { return answer ?? (current === true ? 'enable' : undefined); } - private async toggle(message: string, current: boolean | undefined): Promise { + private async toggle(message: string, current: boolean | null | undefined): Promise { const state = toggleOf(current); const answer = await askOption( this.services.ux, diff --git a/src/environments/environment.update.test.ts b/src/environments/environment.update.test.ts index 325785da..df00665d 100644 --- a/src/environments/environment.update.test.ts +++ b/src/environments/environment.update.test.ts @@ -186,30 +186,42 @@ describe('EnvironmentUpdater', () => { }); it.each([ - [{ resMode: 'streaming' as const }, { isStreamingEnabled: true }], - [{ resMode: 'buffered' as const }, { isStreamingEnabled: false }], - [{ csAuth: 'disable' as const }, { isContentstackAuthenticationEnabled: false }], - [{ autoDeploy: 'enable' as const }, { autoDeployOnPush: true }], - [{ cachePriming: 'disable' as const }, { isCachePrimingEnabled: false }], - [{ passwordProtection: 'disable' as const }, {}], + [{ resMode: 'streaming' as const }, { isStreamingEnabled: true }, '--res-mode already matches'], + [{ resMode: 'buffered' as const }, { isStreamingEnabled: false }, '--res-mode already matches'], + [{ csAuth: 'disable' as const }, { isContentstackAuthenticationEnabled: false }, '--cs-auth already matches'], + [{ autoDeploy: 'enable' as const }, { autoDeployOnPush: true }, '--auto-deploy already matches'], + [{ cachePriming: 'disable' as const }, { isCachePrimingEnabled: false }, '--cache-priming already matches'], + [{ passwordProtection: 'disable' as const }, {}, '--password-protection already matches'], [ { buildCmd: 'npm run build', outputDir: '.next', framework: 'NEXTJS' as const, branch: 'sample', name: 'staging' }, { buildCommand: 'npm run build', outputDirectory: '.next', gitBranch: 'sample', name: 'staging' }, + '--name, --branch, --framework, --build-cmd, --output-dir already match', ], - [{ serverCmd: 'npm start' }, { serverCommand: 'npm start' }], + [{ serverCmd: 'npm start' }, { serverCommand: 'npm start' }, '--server-cmd already matches'], ])( - 'says nothing changed, asks nothing and sends nothing when %p matches the current settings', - async (fields, current) => { + 'names the flags, asks nothing and sends nothing when %p matches the current settings', + async (fields, current, named) => { const { updater, calls, lines, questions } = updaterUnderTest({ current }); await expect(updater.update(request(fields))).resolves.toBe('unchanged'); expect(calls).not.toContain('update'); expect(questions).toEqual([]); - expect(lines).toEqual(['Environment not updated. No changes were entered.']); + expect(lines).toEqual([`Environment not updated: ${named} the current settings.`]); }, ); + it('names only the matching flags when a FileUpload project also drops a repository-only flag', async () => { + const { updater, lines } = updaterUnderTest({ projectType: 'FILEUPLOAD', current: { name: 'staging' } }); + + await expect(updater.update(request({ name: 'staging', branch: 'release' }))).resolves.toBe('unchanged'); + + expect(lines).toEqual([ + 'warn: --branch is not supported for FileUpload projects.', + 'Environment not updated: --name already matches the current settings.', + ]); + }); + it.each([ [{ cachePriming: 'disable' as const }, { isCachePrimingEnabled: null }, { isCachePrimingEnabled: false }], [{ autoDeploy: 'disable' as const }, { autoDeployOnPush: null }, { autoDeployOnPush: false }], diff --git a/src/environments/environment.update.ts b/src/environments/environment.update.ts index 96295091..7dff7566 100644 --- a/src/environments/environment.update.ts +++ b/src/environments/environment.update.ts @@ -8,6 +8,7 @@ import { responseModeOf, toggleOf, usernameOf } from './environment.inputs'; import { withoutRepositoryFlags } from './environment.rules'; import { disableQuestion, + environmentAlreadyMatchesLine, environmentNoChangesLine, environmentNotUpdatedLine, environmentUpdatedLine, @@ -85,7 +86,7 @@ function currentValuesOf(existing: Environment): EnvironmentChanges { branch: existing.gitBranch, framework: existing.frameworkPreset as FrameworkPreset | undefined, buildCmd: existing.buildCommand, - serverCmd: existing.serverCommand, + serverCmd: existing.serverCommand ?? undefined, outputDir: existing.outputDirectory, resMode: responseModeOf(existing.isStreamingEnabled), autoDeploy: toggleOf(existing.autoDeployOnPush), @@ -108,6 +109,12 @@ function withoutCurrentValues(request: EnvironmentUpdateRequest, existing: Envir return kept; } +function flagsMatchingCurrent(before: EnvironmentUpdateRequest, after: EnvironmentUpdateRequest): string[] { + return UPDATABLE_FLAGS.filter(([field]) => before[field] !== undefined && after[field] === undefined).map( + ([, flag]) => flag, + ); +} + function emptyUpdateMessage(): string { const flags = UPDATABLE_FLAGS.map(([, flag]) => `--${flag}`).join(', '); @@ -193,13 +200,21 @@ export class EnvironmentUpdater { })), } : given; - const request = withoutCurrentValues( - withoutRepositoryFlags(answered, current.projectType, this.services.ux, this.services.outputIsTTY === true), - existing, + const supported = withoutRepositoryFlags( + answered, + current.projectType, + this.services.ux, + this.services.outputIsTTY === true, ); + const request = withoutCurrentValues(supported, existing); if (!hasChanges(request)) { - this.services.ux.print(environmentNoChangesLine(this.services.outputIsTTY === true)); + const matching = asking ? [] : flagsMatchingCurrent(supported, request); + this.services.ux.print( + matching.length > 0 + ? environmentAlreadyMatchesLine(matching, this.services.outputIsTTY === true) + : environmentNoChangesLine(this.services.outputIsTTY === true), + ); return 'unchanged'; } diff --git a/src/environments/types.ts b/src/environments/types.ts index 7eee46fe..f7a2ae6d 100644 --- a/src/environments/types.ts +++ b/src/environments/types.ts @@ -42,12 +42,12 @@ export interface Environment { frameworkPreset?: string; buildCommand?: string; outputDirectory?: string; - serverCommand?: string; + serverCommand?: string | null; domains?: EnvironmentDomain[]; - autoDeployOnPush?: boolean; - isStreamingEnabled?: boolean; - isContentstackAuthenticationEnabled?: boolean; - isCachePrimingEnabled?: boolean; + autoDeployOnPush?: boolean | null; + isStreamingEnabled?: boolean | null; + isContentstackAuthenticationEnabled?: boolean | null; + isCachePrimingEnabled?: boolean | null; passwordProtection?: EnvironmentPasswordProtection; environmentVariables?: EnvironmentVariable[]; organizationUid?: string; diff --git a/test/integration/environments-update.test.ts b/test/integration/environments-update.test.ts index 7861557a..96de94ee 100644 --- a/test/integration/environments-update.test.ts +++ b/test/integration/environments-update.test.ts @@ -126,7 +126,10 @@ describe('integration: launch:env:update on the wire', () => { expect(error).toBeUndefined(); expect([project.isDone(), environment.isDone(), put.isDone()]).toEqual([true, true, false]); - expect(stdout).toBe('Environment not updated. No changes were entered.\n'); + expect(stdout).toBe( + 'Environment not updated: --name, --branch, --output-dir, --auto-deploy, --cs-auth, --cache-priming, ' + + '--password-protection already match the current settings.\n', + ); expect(onWire).toEqual([]); }); From 40af60c489d7a37c8157309737977f9aa79f945c Mon Sep 17 00:00:00 2001 From: SakshiKoli-CS Date: Thu, 19 Nov 2026 17:44:15 +0530 Subject: [PATCH 5/5] CL-8833 | +Claude | address review: always send --cs-auth, streaming-first response mode, server-cmd check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - --cs-auth is always sent, even when it matches the current setting, so the server re-applies Contentstack Authentication (it re-syncs the edge config on every write). The interactive answer is sent as given too. - The interactive Response mode prompt lists streaming first and starts on it while the API does not report the current mode. - --server-cmd is checked against the framework before unchanged flags are dropped, so an unchanged --server-cmd on a framework that takes none is refused instead of reported as matching. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .talismanrc | 10 +++---- .../environment.update.prompt.test.ts | 14 ++++++++-- src/environments/environment.update.prompt.ts | 16 +++++++---- src/environments/environment.update.test.ts | 28 ++++++++++++++++--- src/environments/environment.update.ts | 14 ++++++---- test/integration/environments-update.test.ts | 3 +- 6 files changed, 62 insertions(+), 23 deletions(-) diff --git a/.talismanrc b/.talismanrc index 046ece38..433590f2 100644 --- a/.talismanrc +++ b/.talismanrc @@ -127,11 +127,11 @@ fileignoreconfig: - filename checksum: 8b7e3207630f19170dd08ca639ebca8af6bc0d70db633b98e66eedde6d2ea641 - filename: src/environments/environment.update.ts - checksum: b94619d9a9a70447f7cee8978a014c7b54da820c010f36971dc09cfe779f0d5b + checksum: 3c667fee5d8c93de351ab117527acd9170dcb0444228022275fe12849fd70ede ignore_detectors: - filename - filename: src/environments/environment.update.test.ts - checksum: 1dd1ace001bb903ca0937964fc022e2c465e81ba33ac6f8b8da12091879bb280 + checksum: 7e5aa33a6958e9141a2f7215df87dfc8111b9bba03edc5a84407f42601b7213d ignore_detectors: - filename - filename: src/environments/environment.create.ts @@ -145,11 +145,11 @@ fileignoreconfig: ignore_detectors: - filename - filename: src/environments/environment.update.prompt.ts - checksum: a68cca8e5f2544bcb940c45825266b42c92e2d9639dee68dcc6d7a0e9db7270f + checksum: 0c93fdf5d542a9ef2e1655a4591d5cea8f0fd5e404d204a999c4d5b6a292e895 ignore_detectors: - filename - filename: src/environments/environment.update.prompt.test.ts - checksum: 37373e11ff627cf36ae48d08de3418755ec5c2b5d7dd7efc398503e4c23aa6a6 + checksum: 6130ccd6446fe9dba5736fc53b8ebb8f02dbd3956c68ae2c4aa24e3a22dbe105 ignore_detectors: - filename - filename: src/environments/environment.presenter.ts @@ -325,7 +325,7 @@ fileignoreconfig: - filename: src/core/prompt.test.ts checksum: 7be5497acf4cee870667751d44aa230e309784df76dc9e95d5ec2c4e6e6a57e0 - filename: test/integration/environments-update.test.ts - checksum: 970201a8562532f7cb5314680e8c49b5613d68b794a80f3cfe792ebcad0c7a41 + checksum: 312cbf02b41fd9fbfe2c20d78a92129f370753cc7172f0ecc244be3e3dd8eae7 - filename: src/commands/launch/env/update.ts checksum: 981c3267005bca0453131b532c9b62ca501bc67cfd25511c261e99082677882a - filename: src/commands/launch/env/update.test.ts diff --git a/src/environments/environment.update.prompt.test.ts b/src/environments/environment.update.prompt.test.ts index 00b60262..d5b483e7 100644 --- a/src/environments/environment.update.prompt.test.ts +++ b/src/environments/environment.update.prompt.test.ts @@ -156,11 +156,21 @@ describe('promptForEnvironmentUpdate', () => { expect(asked[1].default).toBe('NextJs'); }); - it('asks the response mode and always sends it, since the API never reports the current one', async () => { + it('lists streaming first and starts on it when the API does not report the current mode, sending the answer', async () => { const { services, asked } = servicesAnswering({ [SETTINGS_QUESTION]: ['resMode'], 'Response mode': 'buffered' }); await expect(promptForEnvironmentUpdate(services, githubContext())).resolves.toEqual({ resMode: 'buffered' }); - expect(asked[1].default).toBe('buffered'); + expect(asked[1].choices).toEqual([ + { name: 'streaming', value: 'streaming' }, + { name: 'buffered', value: 'buffered' }, + ]); + expect(asked[1].default).toBe('streaming'); + }); + + it('sends the Contentstack Authentication answer even when it matches the current setting', async () => { + const { services } = servicesAnswering({ [SETTINGS_QUESTION]: ['csAuth'], 'Contentstack Authentication': 'disable' }); + + await expect(promptForEnvironmentUpdate(services, githubContext())).resolves.toEqual({ csAuth: 'disable' }); }); it.each([ diff --git a/src/environments/environment.update.prompt.ts b/src/environments/environment.update.prompt.ts index 93819246..6f8642b8 100644 --- a/src/environments/environment.update.prompt.ts +++ b/src/environments/environment.update.prompt.ts @@ -18,6 +18,8 @@ import type { Environment } from './types'; export const SETTINGS_QUESTION = 'Select the fields to update:'; +const STREAMING_FIRST = [...RESPONSE_MODES].reverse(); + export type EnvironmentChanges = Partial< Pick< EnvironmentUpdateRequest, @@ -117,7 +119,7 @@ class SettingAsker { case 'autoDeploy': return this.toggle('Auto deploy', current.autoDeployOnPush); case 'csAuth': - return this.toggle('Contentstack Authentication', current.isContentstackAuthenticationEnabled); + return this.toggle('Contentstack Authentication', current.isContentstackAuthenticationEnabled, true); case 'cachePriming': return this.toggle('Cache priming', current.isCachePrimingEnabled); default: @@ -134,8 +136,8 @@ class SettingAsker { const answer = await askOption( this.services.ux, 'Response mode', - RESPONSE_MODES.map((value) => ({ name: value, value })), - current ?? 'buffered', + STREAMING_FIRST.map((value) => ({ name: value, value })), + current ?? 'streaming', ); return changed(answer, current); @@ -177,7 +179,11 @@ class SettingAsker { return answer ?? (current === true ? 'enable' : undefined); } - private async toggle(message: string, current: boolean | null | undefined): Promise { + private async toggle( + message: string, + current: boolean | null | undefined, + sendUnchanged = false, + ): Promise { const state = toggleOf(current); const answer = await askOption( this.services.ux, @@ -186,6 +192,6 @@ class SettingAsker { state, ); - return changed(answer, state); + return sendUnchanged ? answer : changed(answer, state); } } diff --git a/src/environments/environment.update.test.ts b/src/environments/environment.update.test.ts index df00665d..5143f5ee 100644 --- a/src/environments/environment.update.test.ts +++ b/src/environments/environment.update.test.ts @@ -108,7 +108,7 @@ describe('EnvironmentUpdater', () => { request({ name: 'renamed', branch: 'release', - framework: 'NEXTJS', + framework: 'NUXT', buildCmd: 'npm run build', serverCmd: 'npm start', outputDir: './.next', @@ -126,7 +126,7 @@ describe('EnvironmentUpdater', () => { update: { name: 'renamed', gitBranch: 'release', - frameworkPreset: 'NEXTJS', + frameworkPreset: 'NUXT', buildCommand: 'npm run build', serverCommand: 'npm start', outputDirectory: './.next', @@ -188,7 +188,6 @@ describe('EnvironmentUpdater', () => { it.each([ [{ resMode: 'streaming' as const }, { isStreamingEnabled: true }, '--res-mode already matches'], [{ resMode: 'buffered' as const }, { isStreamingEnabled: false }, '--res-mode already matches'], - [{ csAuth: 'disable' as const }, { isContentstackAuthenticationEnabled: false }, '--cs-auth already matches'], [{ autoDeploy: 'enable' as const }, { autoDeployOnPush: true }, '--auto-deploy already matches'], [{ cachePriming: 'disable' as const }, { isCachePrimingEnabled: false }, '--cache-priming already matches'], [{ passwordProtection: 'disable' as const }, {}, '--password-protection already matches'], @@ -197,7 +196,7 @@ describe('EnvironmentUpdater', () => { { buildCommand: 'npm run build', outputDirectory: '.next', gitBranch: 'sample', name: 'staging' }, '--name, --branch, --framework, --build-cmd, --output-dir already match', ], - [{ serverCmd: 'npm start' }, { serverCommand: 'npm start' }, '--server-cmd already matches'], + [{ serverCmd: 'npm start' }, { serverCommand: 'npm start', frameworkPreset: 'NUXT' }, '--server-cmd already matches'], ])( 'names the flags, asks nothing and sends nothing when %p matches the current settings', async (fields, current, named) => { @@ -211,6 +210,27 @@ describe('EnvironmentUpdater', () => { }, ); + it.each([ + [{ csAuth: 'enable' as const }, true, { isContentstackAuthenticationEnabled: true }], + [{ csAuth: 'disable' as const }, false, { isContentstackAuthenticationEnabled: false }], + ])('always sends %p, even when it matches, so the server re-applies Contentstack Authentication', async (fields, isEnabled, update) => { + const { updater, sent } = updaterUnderTest({ current: { isContentstackAuthenticationEnabled: isEnabled } }); + + await expect(updater.update(request(fields))).resolves.toBe('updated'); + + expect(sent).toEqual([{ ...SCOPE, update }]); + }); + + it('refuses an unchanged --server-cmd when the current framework takes no server command, sending nothing', async () => { + const { updater, calls } = updaterUnderTest({ current: { frameworkPreset: 'GATSBY', serverCommand: 'npm start' } }); + + await expect(updater.update(request({ serverCmd: 'npm start' }))).rejects.toThrow( + '--server-cmd is only supported when --framework is one of ANALOG, ANGULAR, NUXT, ASTRO, REMIX, OTHER; ' + + '--framework is GATSBY.', + ); + expect(calls).not.toContain('update'); + }); + it('names only the matching flags when a FileUpload project also drops a repository-only flag', async () => { const { updater, lines } = updaterUnderTest({ projectType: 'FILEUPLOAD', current: { name: 'staging' } }); diff --git a/src/environments/environment.update.ts b/src/environments/environment.update.ts index 7dff7566..7a356399 100644 --- a/src/environments/environment.update.ts +++ b/src/environments/environment.update.ts @@ -90,7 +90,6 @@ function currentValuesOf(existing: Environment): EnvironmentChanges { outputDir: existing.outputDirectory, resMode: responseModeOf(existing.isStreamingEnabled), autoDeploy: toggleOf(existing.autoDeployOnPush), - csAuth: toggleOf(existing.isContentstackAuthenticationEnabled), cachePriming: toggleOf(existing.isCachePrimingEnabled), passwordProtection: existing.passwordProtection?.isEnabled === false ? 'disable' : undefined, }; @@ -206,6 +205,15 @@ export class EnvironmentUpdater { this.services.ux, this.services.outputIsTTY === true, ); + if (supported.serverCmd !== undefined) { + requireValueOf( + 'server-cmd', + 'framework', + SERVER_COMMAND_FRAMEWORKS, + supported.framework ?? existing.frameworkPreset ?? 'not set', + ); + } + const request = withoutCurrentValues(supported, existing); if (!hasChanges(request)) { @@ -218,10 +226,6 @@ export class EnvironmentUpdater { return 'unchanged'; } - if (request.serverCmd !== undefined && request.framework === undefined) { - requireValueOf('server-cmd', 'framework', SERVER_COMMAND_FRAMEWORKS, existing.frameworkPreset ?? 'not set'); - } - if (!(await this.confirmDisabling(request))) { this.services.ux.print(environmentNotUpdatedLine(this.services.outputIsTTY === true)); return 'cancelled'; diff --git a/test/integration/environments-update.test.ts b/test/integration/environments-update.test.ts index 96de94ee..4b732b8c 100644 --- a/test/integration/environments-update.test.ts +++ b/test/integration/environments-update.test.ts @@ -117,7 +117,6 @@ describe('integration: launch:env:update on the wire', () => { '--branch', 'main', '--output-dir', './_site', '--auto-deploy', 'enable', - '--cs-auth', 'enable', '--cache-priming', 'disable', '--password-protection', 'disable', ), @@ -127,7 +126,7 @@ describe('integration: launch:env:update on the wire', () => { expect(error).toBeUndefined(); expect([project.isDone(), environment.isDone(), put.isDone()]).toEqual([true, true, false]); expect(stdout).toBe( - 'Environment not updated: --name, --branch, --output-dir, --auto-deploy, --cs-auth, --cache-priming, ' + + 'Environment not updated: --name, --branch, --output-dir, --auto-deploy, --cache-priming, ' + '--password-protection already match the current settings.\n', ); expect(onWire).toEqual([]);