@lightdash/cli 0.2104.4 → 0.2104.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -12,6 +12,7 @@ const config_1 = require("../config");
|
|
|
12
12
|
const globalState_1 = tslib_1.__importDefault(require("../globalState"));
|
|
13
13
|
const styles = tslib_1.__importStar(require("../styles"));
|
|
14
14
|
const apiClient_1 = require("./dbt/apiClient");
|
|
15
|
+
const getDbtVersion_1 = require("./dbt/getDbtVersion");
|
|
15
16
|
const generateExposuresHandler = async (options) => {
|
|
16
17
|
globalState_1.default.setVerbose(options.verbose);
|
|
17
18
|
await (0, apiClient_1.checkLightdashVersion)();
|
|
@@ -30,6 +31,11 @@ const generateExposuresHandler = async (options) => {
|
|
|
30
31
|
const spinner = globalState_1.default.startSpinner(` Generating Lightdash exposures .yml for project ${styles.bold(config.context.projectName || config.context.project)}`);
|
|
31
32
|
try {
|
|
32
33
|
const absoluteProjectPath = path.resolve(options.projectDir);
|
|
34
|
+
// Detect dbt version to determine format
|
|
35
|
+
const dbtVersionInfo = await (0, getDbtVersion_1.getDbtVersion)();
|
|
36
|
+
const isDbt110Plus = dbtVersionInfo.versionOption === common_1.DbtVersionOptionLatest.LATEST
|
|
37
|
+
? true
|
|
38
|
+
: (0, common_1.isDbtVersion110OrHigher)(dbtVersionInfo.versionOption);
|
|
33
39
|
const exposures = await (0, apiClient_1.lightdashApi)({
|
|
34
40
|
method: 'GET',
|
|
35
41
|
url: `/api/v1/projects/${config.context.project}/dbt-exposures`,
|
|
@@ -38,12 +44,28 @@ const generateExposuresHandler = async (options) => {
|
|
|
38
44
|
console.info(styles.info(`Found ${Object.keys(exposures).length} exposures`));
|
|
39
45
|
const outputFilePath = options.output ||
|
|
40
46
|
path.join(absoluteProjectPath, 'models', 'lightdash_exposures.yml');
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
// Transform exposures based on dbt version
|
|
48
|
+
const transformedExposures = Object.values(exposures).map(({ dependsOn, tags, ...rest }) => {
|
|
49
|
+
if (isDbt110Plus && tags) {
|
|
50
|
+
// For dbt 1.10+, move tags under config
|
|
51
|
+
return {
|
|
52
|
+
...rest,
|
|
53
|
+
depends_on: dependsOn,
|
|
54
|
+
config: {
|
|
55
|
+
tags,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
// For older versions, keep tags at top level
|
|
60
|
+
return {
|
|
44
61
|
...rest,
|
|
45
62
|
depends_on: dependsOn,
|
|
46
|
-
|
|
63
|
+
...(tags ? { tags } : {}),
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
const updatedYml = {
|
|
67
|
+
version: 2,
|
|
68
|
+
exposures: transformedExposures,
|
|
47
69
|
};
|
|
48
70
|
const ymlString = yaml.dump(updatedYml, {
|
|
49
71
|
quotingType: '"',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightdash/cli",
|
|
3
|
-
"version": "0.2104.
|
|
3
|
+
"version": "0.2104.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"lightdash": "dist/index.js"
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"parse-node-version": "^2.0.0",
|
|
34
34
|
"unique-names-generator": "^4.7.1",
|
|
35
35
|
"uuid": "^11.0.3",
|
|
36
|
-
"@lightdash/
|
|
37
|
-
"@lightdash/
|
|
36
|
+
"@lightdash/common": "0.2104.6",
|
|
37
|
+
"@lightdash/warehouses": "0.2104.6"
|
|
38
38
|
},
|
|
39
39
|
"description": "Lightdash CLI tool",
|
|
40
40
|
"devDependencies": {
|