@@ -5,24 +5,33 @@ import { dataform } from "df/protos/ts";
5
5
6
6
export function createGenIndexConfig ( compileConfig : dataform . ICompileConfig ) : string {
7
7
const includePaths : string [ ] = [ ] ;
8
- glob . sync ( "includes/*.js" , { cwd : compileConfig . projectDir } ) . forEach ( path => {
9
- if ( includePaths . indexOf ( path ) < 0 ) {
10
- includePaths . push ( path ) ;
11
- }
12
- } ) ;
8
+ glob
9
+ . sync ( "includes/*.js" , { cwd : compileConfig . projectDir } )
10
+ . sort ( alphabetically )
11
+ . forEach ( path => {
12
+ if ( includePaths . indexOf ( path ) < 0 ) {
13
+ includePaths . push ( path ) ;
14
+ }
15
+ } ) ;
13
16
14
17
const definitionPaths : string [ ] = [ ] ;
15
- glob . sync ( "definitions/**/*.{js,sql,sqlx}" , { cwd : compileConfig . projectDir } ) . forEach ( path => {
16
- if ( definitionPaths . indexOf ( path ) < 0 ) {
17
- definitionPaths . push ( path ) ;
18
- }
19
- } ) ;
18
+ glob
19
+ . sync ( "definitions/**/*.{js,sql,sqlx}" , { cwd : compileConfig . projectDir } )
20
+ . sort ( alphabetically )
21
+ . forEach ( path => {
22
+ if ( definitionPaths . indexOf ( path ) < 0 ) {
23
+ definitionPaths . push ( path ) ;
24
+ }
25
+ } ) ;
20
26
// Support projects that don't use the new project structure.
21
- glob . sync ( "models/**/*.{js,sql,sqlx}" , { cwd : compileConfig . projectDir } ) . forEach ( path => {
22
- if ( definitionPaths . indexOf ( path ) < 0 ) {
23
- definitionPaths . push ( path ) ;
24
- }
25
- } ) ;
27
+ glob
28
+ . sync ( "models/**/*.{js,sql,sqlx}" , { cwd : compileConfig . projectDir } )
29
+ . sort ( alphabetically )
30
+ . forEach ( path => {
31
+ if ( definitionPaths . indexOf ( path ) < 0 ) {
32
+ definitionPaths . push ( path ) ;
33
+ }
34
+ } ) ;
26
35
return encode64 ( dataform . GenerateIndexConfig , {
27
36
compileConfig,
28
37
includePaths,
@@ -35,11 +44,18 @@ export function createGenIndexConfig(compileConfig: dataform.ICompileConfig): st
35
44
*/
36
45
export function createCoreExecutionRequest ( compileConfig : dataform . ICompileConfig ) : string {
37
46
const filePaths = Array . from (
38
- new Set < string > ( glob . sync ( "!(node_modules)/**/*.*" , { cwd : compileConfig . projectDir } ) )
47
+ new Set < string > (
48
+ glob . sync ( "!(node_modules)/**/*.*" , { cwd : compileConfig . projectDir } ) . sort ( alphabetically )
49
+ )
39
50
) ;
40
51
41
52
return encode64 ( dataform . CoreExecutionRequest , {
42
53
// Add the list of file paths to the compile config if not already set.
43
54
compile : { compileConfig : { filePaths, ...compileConfig } }
44
55
} ) ;
45
56
}
57
+
58
+ // NOTE: this is used to sort results of `glob.sync()` above.
59
+ // This sort is only required for compatibility with @dataform /core <= 2.6.5.
60
+ // If/when the CLI drops support for those versions, we can remove the sorting.
61
+ const alphabetically = ( a : string , b : string ) => a . localeCompare ( b ) ;
0 commit comments