@lightdash/cli 0.2049.0 → 0.2050.1

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.
@@ -26,8 +26,17 @@ const getDbtContext = async ({ projectDir, initialProjectDir, }) => {
26
26
  const msg = (0, common_1.getErrorMessage)(e);
27
27
  throw new common_1.ParseError(`Is ${initialProjectDir} a valid dbt project directory? Couldn't find a valid dbt_project.yml on ${initialProjectDir} or any of its parents:\n ${msg}`);
28
28
  }
29
- // Render Jinja templating (e.g., env_var) before parsing YAML
30
- const renderedFile = (0, templating_1.renderProfilesYml)(file);
29
+ // Try to render Jinja templating (e.g., env_var) before parsing YAML
30
+ // If rendering fails, fall back to parsing the raw file for back compat
31
+ let renderedFile;
32
+ try {
33
+ renderedFile = (0, templating_1.renderTemplatedYml)(file);
34
+ }
35
+ catch (e) {
36
+ globalState_1.default.debug(`> Warning: Failed to render Jinja in dbt_project.yml: ${(0, common_1.getErrorMessage)(e)}`);
37
+ globalState_1.default.debug('> Falling back to parsing raw YAML without Jinja rendering');
38
+ renderedFile = file;
39
+ }
31
40
  const config = yaml.load(renderedFile);
32
41
  const targetSubDir = config['target-path'] || './target';
33
42
  globalState_1.default.debug(`> dbt target directory: ${targetSubDir}`);
@@ -1 +1,14 @@
1
+ /**
2
+ * Render a dbt YAML file with Jinja templating (env_var, var, filters)
3
+ * @param raw - Raw YAML content as string
4
+ * @param context - Additional context variables to pass to the template
5
+ * @returns Rendered YAML string with Jinja expressions resolved
6
+ */
7
+ export declare const renderTemplatedYml: (raw: string, context?: Record<string, unknown>) => string;
8
+ /**
9
+ * Render a profiles.yml file with Jinja templating and private key handling
10
+ * @param raw - Raw profiles.yml content as string
11
+ * @param context - Additional context variables to pass to the template
12
+ * @returns Rendered profiles.yml string with Jinja expressions resolved and private keys escaped
13
+ */
1
14
  export declare const renderProfilesYml: (raw: string, context?: Record<string, unknown>) => string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renderProfilesYml = void 0;
3
+ exports.renderProfilesYml = exports.renderTemplatedYml = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const nunjucks = tslib_1.__importStar(require("nunjucks"));
6
6
  // jinja filters
@@ -20,12 +20,28 @@ const nunjucksContext = {
20
20
  },
21
21
  var: (key) => JSON.parse(process.argv[process.argv.indexOf('--vars') + 1])[key],
22
22
  };
23
- const renderProfilesYml = (raw, context) => {
23
+ /**
24
+ * Render a dbt YAML file with Jinja templating (env_var, var, filters)
25
+ * @param raw - Raw YAML content as string
26
+ * @param context - Additional context variables to pass to the template
27
+ * @returns Rendered YAML string with Jinja expressions resolved
28
+ */
29
+ const renderTemplatedYml = (raw, context) => {
24
30
  const template = nunjucks.compile(raw, nunjucksEnv);
25
- const rendered = template.render({
31
+ return template.render({
26
32
  ...nunjucksContext,
27
33
  ...(context || {}),
28
34
  });
35
+ };
36
+ exports.renderTemplatedYml = renderTemplatedYml;
37
+ /**
38
+ * Render a profiles.yml file with Jinja templating and private key handling
39
+ * @param raw - Raw profiles.yml content as string
40
+ * @param context - Additional context variables to pass to the template
41
+ * @returns Rendered profiles.yml string with Jinja expressions resolved and private keys escaped
42
+ */
43
+ const renderProfilesYml = (raw, context) => {
44
+ const rendered = (0, exports.renderTemplatedYml)(raw, context);
29
45
  // Fix multiline privatekey strings
30
46
  // Prevents error: Error: error:1E08010C:DECODER routines::unsupported
31
47
  const privateKeyRegex = /(-----BEGIN(?:\s+ENCRYPTED)?\s+PRIVATE KEY-----[\s\S]*?-----END(?:\s+ENCRYPTED)?\s+PRIVATE KEY-----)/g;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash/cli",
3
- "version": "0.2049.0",
3
+ "version": "0.2050.1",
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/warehouses": "0.2049.0",
37
- "@lightdash/common": "0.2049.0"
36
+ "@lightdash/common": "0.2050.1",
37
+ "@lightdash/warehouses": "0.2050.1"
38
38
  },
39
39
  "description": "Lightdash CLI tool",
40
40
  "devDependencies": {