@lightdash/cli 0.1464.3 → 0.1465.0
Sign up to get free protection for your applications and to get access to all the features.
package/dist/handlers/deploy.js
CHANGED
@@ -11,11 +11,24 @@ const analytics_1 = require("../analytics/analytics");
|
|
11
11
|
const config_1 = require("../config");
|
12
12
|
const context_1 = require("../dbt/context");
|
13
13
|
const globalState_1 = tslib_1.__importDefault(require("../globalState"));
|
14
|
+
const lightdash_config_1 = require("../lightdash-config");
|
14
15
|
const styles = tslib_1.__importStar(require("../styles"));
|
15
16
|
const compile_1 = require("./compile");
|
16
17
|
const createProject_1 = require("./createProject");
|
17
18
|
const apiClient_1 = require("./dbt/apiClient");
|
18
19
|
const getDbtVersion_1 = require("./dbt/getDbtVersion");
|
20
|
+
const replaceProjectYamlTags = async (projectUuid, lightdashProjectConfig) => {
|
21
|
+
const yamlTags = Object.entries(lightdashProjectConfig.spotlight?.categories ?? {}).map(([yamlReference, category]) => ({
|
22
|
+
yamlReference,
|
23
|
+
name: category.label,
|
24
|
+
color: category.color ?? 'gray',
|
25
|
+
}));
|
26
|
+
await (0, apiClient_1.lightdashApi)({
|
27
|
+
method: 'PUT',
|
28
|
+
url: `/api/v1/projects/${projectUuid}/tags/yaml`,
|
29
|
+
body: JSON.stringify(yamlTags),
|
30
|
+
});
|
31
|
+
};
|
19
32
|
const deploy = async (explores, options) => {
|
20
33
|
if (explores.length === 0) {
|
21
34
|
globalState_1.default.log(styles.warning('No explores found'));
|
@@ -31,6 +44,8 @@ const deploy = async (explores, options) => {
|
|
31
44
|
process.exit(1);
|
32
45
|
}
|
33
46
|
}
|
47
|
+
const lightdashProjectConfig = await (0, lightdash_config_1.loadLightdashProjectConfig)(path_1.default.join(options.projectDir, 'lightdash.config.yml'));
|
48
|
+
await replaceProjectYamlTags(options.projectUuid, lightdashProjectConfig);
|
34
49
|
await (0, apiClient_1.lightdashApi)({
|
35
50
|
method: 'PUT',
|
36
51
|
url: `/api/v1/projects/${options.projectUuid}/explores`,
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.loadLightdashProjectConfig = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const common_1 = require("@lightdash/common");
|
6
|
+
const better_ajv_errors_1 = tslib_1.__importDefault(require("better-ajv-errors"));
|
7
|
+
const fs_1 = require("fs");
|
8
|
+
const yaml = tslib_1.__importStar(require("js-yaml"));
|
9
|
+
const ajv_1 = require("../ajv");
|
10
|
+
const loadLightdashProjectConfig = async (configPath) => {
|
11
|
+
try {
|
12
|
+
const configFile = yaml.load(await fs_1.promises.readFile(configPath, 'utf8'));
|
13
|
+
const validate = ajv_1.ajv.compile(common_1.lightdashProjectConfigSchema);
|
14
|
+
if (!validate(configFile)) {
|
15
|
+
const errors = (0, better_ajv_errors_1.default)(common_1.lightdashProjectConfigSchema, configFile, validate.errors || [], { indent: 2 });
|
16
|
+
throw new common_1.ParseError(`Invalid lightdash.config.yml at ${configPath}\n${errors}`);
|
17
|
+
}
|
18
|
+
return configFile;
|
19
|
+
}
|
20
|
+
catch (e) {
|
21
|
+
if (e instanceof Error && 'code' in e && e.code === 'ENOENT') {
|
22
|
+
// Return default config if file doesn't exist
|
23
|
+
return {
|
24
|
+
spotlight: common_1.DEFAULT_SPOTLIGHT_CONFIG,
|
25
|
+
};
|
26
|
+
}
|
27
|
+
throw e;
|
28
|
+
}
|
29
|
+
};
|
30
|
+
exports.loadLightdashProjectConfig = loadLightdashProjectConfig;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lightdash/cli",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.1465.0",
|
4
4
|
"license": "MIT",
|
5
5
|
"bin": {
|
6
6
|
"lightdash": "dist/index.js"
|
@@ -30,8 +30,8 @@
|
|
30
30
|
"parse-node-version": "^2.0.0",
|
31
31
|
"unique-names-generator": "^4.7.1",
|
32
32
|
"uuid": "^11.0.3",
|
33
|
-
"@lightdash/common": "0.
|
34
|
-
"@lightdash/warehouses": "0.
|
33
|
+
"@lightdash/common": "0.1465.0",
|
34
|
+
"@lightdash/warehouses": "0.1465.0"
|
35
35
|
},
|
36
36
|
"description": "Lightdash CLI tool",
|
37
37
|
"devDependencies": {
|