Repository navigation
fix(environments): skip env:update when flags match the current settings #296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v2-dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,18 +4,19 @@ 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, | ||
| environmentNoChangesLine, | ||
| 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), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Low A
Fix: treat — 🤖 launch-pr-review-agent (Claude) Generated by Claude Code |
||
| 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)) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Low This adds a code comment, which the repo's AGENTS.md forbids ("Do not create code comments for any changes").
The rotation case is already pinned by the test "still enables password protection that is already on, so its credentials can be rotated", so the comment adds nothing the test doesn't already guard.
Fix: remove the comment.
— 🤖 launch-pr-review-agent (Claude)
Generated by Claude Code