Skip to content

Commit a05b492

Browse files
committed
fix(scripts): preserve acronyms in uppercase (K8S, S2S) when generating export names
1 parent 47f4e16 commit a05b492

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

scripts/generatePackages.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ const exportProductVersions = ({ productDir }: { productDir: string }) => {
104104
)
105105
}
106106
}
107+
// Add final newline to match existing files
108+
appendFileSync(pathFile, '\n')
107109
}
108110

109111
/**

scripts/helpers.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
const upperFirst = (str: string) =>
22
str.slice(0, 1).toUpperCase() + str.slice(1, str.length)
33

4+
// Special handling for known acronyms that should be all uppercase
5+
const ACRONYMS = new Set(['k8s', 's2s', 'api', 'http', 'https', 'url', 'uri'])
6+
7+
const handleAcronym = (str: string): string => {
8+
const lower = str.toLowerCase()
9+
if (ACRONYMS.has(lower)) {
10+
return str.toUpperCase()
11+
}
12+
return upperFirst(str)
13+
}
14+
415
export const snakeToPascal = (str: string) =>
516
str
617
.split('_')
7-
.map(s => upperFirst(s.split('/').map(upperFirst).join('/')))
18+
.map(s => handleAcronym(s.split('/').map(handleAcronym).join('/')))
819
.join('')
920

1021
export const unionTocamelCase = (str: string) =>

0 commit comments

Comments
 (0)