File tree Expand file tree Collapse file tree 3 files changed +43
-20
lines changed Expand file tree Collapse file tree 3 files changed +43
-20
lines changed Original file line number Diff line number Diff line change @@ -222,7 +222,7 @@ jobs:
222
222
with :
223
223
path : |
224
224
${{ format('{0}/algoliasearch-core/src/com/algolia/api/{1}.java', matrix.client.path, matrix.client.api) }}
225
- ${{ format('{0}/algoliasearch-core/src/com/algolia/model/{1}/**', matrix.client.path, matrix.client.name ) }}
225
+ ${{ format('{0}/algoliasearch-core/src/com/algolia/model/{1}/**', matrix.client.path, matrix.client.camelizedName ) }}
226
226
key : |
227
227
${{ env.CACHE_VERSION }}-${{
228
228
hashFiles(
Original file line number Diff line number Diff line change 1
1
import { CLIENTS , GENERATORS } from '../common' ;
2
- import { createClientName } from '../cts/utils' ;
2
+ import { camelize , createClientName } from '../cts/utils' ;
3
3
import type { Language } from '../types' ;
4
4
5
5
import { getNbGitDiff } from './utils' ;
@@ -16,9 +16,10 @@ type BaseMatrix = {
16
16
} ;
17
17
18
18
type ClientMatrix = BaseMatrix & {
19
- config ?: string ;
20
- api ?: string ;
21
- capitalizedName ?: string ;
19
+ config : string ;
20
+ api : string ;
21
+ capitalizedName : string ;
22
+ camelizedName : string ;
22
23
} ;
23
24
24
25
type SpecMatrix = BaseMatrix ;
@@ -56,18 +57,16 @@ async function getClientMatrix({
56
57
continue ;
57
58
}
58
59
59
- const matchedGenerator : ClientMatrix = {
60
- name : client ,
61
- path : output ,
62
- } ;
63
-
64
60
const clientName = createClientName ( client , language ) ;
65
61
66
- matchedGenerator . config = `${ clientName } Config` ;
67
- matchedGenerator . api = `${ clientName } Client` ;
68
- matchedGenerator . capitalizedName = clientName ;
69
-
70
- matrix . client . push ( matchedGenerator ) ;
62
+ matrix . client . push ( {
63
+ name : client ,
64
+ path : output ,
65
+ config : `${ clientName } Config` ,
66
+ api : `${ clientName } Client` ,
67
+ capitalizedName : clientName ,
68
+ camelizedName : camelize ( client ) ,
69
+ } ) ;
71
70
}
72
71
73
72
return matrix ;
Original file line number Diff line number Diff line change @@ -14,23 +14,47 @@ export async function* walk(
14
14
}
15
15
}
16
16
17
+ /**
18
+ * Sets the first letter of the given string in capital.
19
+ *
20
+ * `searchClient` -> `SearchClient`.
21
+ */
17
22
export function capitalize ( str : string ) : string {
18
23
return str . charAt ( 0 ) . toUpperCase ( ) + str . slice ( 1 ) ;
19
24
}
20
25
21
- export function createClientName ( client : string , language : string ) : string {
22
- const clientName = client
23
- . split ( '-' )
26
+ /**
27
+ * Splits a string for a given `delimiter` (defaults to `-`) and capitalize each
28
+ * parts except the first letter.
29
+ *
30
+ * `search-client` -> `searchClient`.
31
+ */
32
+ export function camelize ( str : string , delimiter : string = '-' ) : string {
33
+ return str
34
+ . split ( delimiter )
24
35
. map ( ( part , i ) => {
25
- if ( language === 'javascript' && i === 0 ) {
36
+ if ( i === 0 ) {
26
37
return part ;
27
38
}
28
39
29
40
return capitalize ( part ) ;
30
41
} )
31
42
. join ( '' ) ;
43
+ }
44
+
45
+ /**
46
+ * Returns the client name with the correct casing for its language.
47
+ *
48
+ * `search-client`, `java` -> `SearchClient`.
49
+ *
50
+ * `search-client`, `javascript` -> `searchClient`.
51
+ */
52
+ export function createClientName ( client : string , language : string ) : string {
53
+ if ( language === 'javascript' ) {
54
+ return camelize ( client ) ;
55
+ }
32
56
33
- return clientName ;
57
+ return capitalize ( camelize ( client ) ) ;
34
58
}
35
59
36
60
export async function createOutputDir ( {
You can’t perform that action at this time.
0 commit comments