Skip to content

Commit 154b726

Browse files
authored
Fix @dataform/cli to be compatible with versions of @dataform/core <= 2.6.5. (#1527)
See https://issuetracker.google.com/issues/296162656#comment3 for details.
1 parent a8279e1 commit 154b726

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

sandbox/vm/create_config.ts

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,33 @@ import { dataform } from "df/protos/ts";
55

66
export function createGenIndexConfig(compileConfig: dataform.ICompileConfig): string {
77
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+
});
1316

1417
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+
});
2026
// 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+
});
2635
return encode64(dataform.GenerateIndexConfig, {
2736
compileConfig,
2837
includePaths,
@@ -35,11 +44,18 @@ export function createGenIndexConfig(compileConfig: dataform.ICompileConfig): st
3544
*/
3645
export function createCoreExecutionRequest(compileConfig: dataform.ICompileConfig): string {
3746
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+
)
3950
);
4051

4152
return encode64(dataform.CoreExecutionRequest, {
4253
// Add the list of file paths to the compile config if not already set.
4354
compile: { compileConfig: { filePaths, ...compileConfig } }
4455
});
4556
}
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);

version.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# NOTE: If you change the format of this line, you must change the bash command
22
# in /scripts/publish to extract the version string correctly.
3-
DF_VERSION = "2.6.4"
3+
DF_VERSION = "2.6.5"

0 commit comments

Comments
 (0)