Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions src/commands/diff/diff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,27 +292,6 @@ describe('diff', () => {
.it('identifies aliased variables specified in config file', (ctx) => {
expect(ctx.stdout).toMatchSnapshot()
})

test.stdout()
.command([
'diff',
'--file',
'test-utils/fixtures/diff/auto-alias-transform',
'--no-api',
'--repo-config-path',
'./test-utils/fixtures/configs/autoAliasConfig.yml',
])
.it(
'resolves aliases from generated types file using key transformation',
(ctx) => {
// Should NOT show "could not be identified" warnings
expect(ctx.stdout).not.toContain('could not be identified')
// Should identify the variables
expect(ctx.stdout).toContain('my-test-variable')
expect(ctx.stdout).toContain('enable-feature')
expect(ctx.stdout).toContain('removed-variable')
},
)
test.stdout()
.command([
'diff',
Expand Down
7 changes: 1 addition & 6 deletions src/commands/diff/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import VarAliasFlag, { getVariableAliases } from '../../flags/var-alias'
import ShowRegexFlag, { showRegex } from '../../flags/show-regex'
import { Variable } from '../../api/schemas'
import { FileFilters } from '../../utils/FileFilters'
import { keyToConstant } from '../../utils/keyToConstant'

const EMOJI = {
add: '🟢',
Expand Down Expand Up @@ -163,11 +162,7 @@ export default class Diff extends Base {
Object.values(matchesBySdk).forEach((matches) => {
matches.forEach((m) => {
const match = { ...m }
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the keyToConstant transformation fallback means that aliases must now match exactly. Consider documenting this behavior change in the codebase or user-facing documentation to help users understand that the generated constant names from the types file must be used directly, without any automatic kebab-case transformation.

Suggested change
const match = { ...m }
const match = { ...m }
// NOTE: The removal of the keyToConstant transformation fallback means that aliases must now match exactly.
// The generated constant names from the types file must be used directly, without any automatic kebab-case transformation.

Copilot uses AI. Check for mistakes.
// Try to find alias by direct match first, then by transformed constant name
// This handles cases where the generated types file creates constants like MY_VARIABLE
// for a variable key like 'my-variable'
const aliasedName =
aliasMap[match.name] || aliasMap[keyToConstant(match.name)]
const aliasedName = aliasMap[match.name]
if (match.isUnknown && aliasedName) {
match.alias = match.name
match.name = aliasedName
Expand Down
4 changes: 2 additions & 2 deletions src/commands/generate/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { fetchAllVariables } from '../../api/variables'
import { Flags } from '@oclif/core'
import { Feature, Project, Variable, CustomProperty } from '../../api/schemas'
import { OrganizationMember, fetchOrganizationMembers } from '../../api/members'
import { upperCase } from 'lodash'
import { createHash } from 'crypto'
import path from 'path'
import { keyToConstant } from '../../utils/keyToConstant'
import {
fetchAllCompletedOrArchivedFeatures,
fetchFeatures,
Expand Down Expand Up @@ -353,7 +353,7 @@ export const ${constantName} = '${hashedKey}' as const`
}

getVariableGeneratedName(variable: Variable) {
let constantName = keyToConstant(variable.key)
let constantName = upperCase(variable.key).replace(/\s/g, '_')
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This logic is now duplicated from the removed keyToConstant utility. While the utility was only used in one other place, consider extracting this transformation to a helper function within this file (e.g., private keyToConstant(key: string)) to make the transformation logic more explicit and maintainable, especially since it's a critical part of the variable name generation.

Copilot uses AI. Check for mistakes.

if (this.methodNames[constantName]?.length) {
constantName = `${constantName}_${this.methodNames[constantName].length}`
Expand Down
10 changes: 0 additions & 10 deletions src/utils/keyToConstant.ts

This file was deleted.

13 changes: 0 additions & 13 deletions test-utils/fixtures/configs/autoAliasConfig.yml

This file was deleted.

5 changes: 0 additions & 5 deletions test-utils/fixtures/configs/mockTypes.ts

This file was deleted.

17 changes: 0 additions & 17 deletions test-utils/fixtures/diff/auto-alias-transform

This file was deleted.