@lightdash/cli 0.2389.4 → 0.2391.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/handlers/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAMH,OAAO,EACP,YAAY,EAUf,MAAM,mBAAmB,CAAC;AAY3B,OAAO,EAAE,iBAAiB,EAA8B,MAAM,eAAe,CAAC;AAI9E,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,GAAG;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACxC,CAAC;AA4DF,eAAO,MAAM,OAAO,YAAmB,qBAAqB,wCAuM3D,CAAC;AACF,eAAO,MAAM,cAAc,oBACN,qBAAqB,kBAuBzC,CAAC"}
1
+ {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/handlers/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAMH,OAAO,EACP,YAAY,EAUf,MAAM,mBAAmB,CAAC;AAY3B,OAAO,EAAE,iBAAiB,EAA8B,MAAM,eAAe,CAAC;AAI9E,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,GAAG;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACxC,CAAC;AA4DF,eAAO,MAAM,OAAO,YAAmB,qBAAqB,wCAiO3D,CAAC;AACF,eAAO,MAAM,cAAc,oBACN,qBAAqB,kBAuBzC,CAAC"}
@@ -139,18 +139,39 @@ const compile = async (options) => {
139
139
  explores = [...validExplores, ...failedExplores];
140
140
  dbtMetrics = manifest.metrics;
141
141
  }
142
+ let errors = 0;
143
+ let partialSuccess = 0;
144
+ let success = 0;
142
145
  explores.forEach((e) => {
143
- const status = (0, common_1.isExploreError)(e)
144
- ? styles.error('ERROR')
145
- : styles.success('SUCCESS');
146
- const errors = (0, common_1.isExploreError)(e)
147
- ? `: ${styles.error(e.errors.map((err) => err.message).join(', '))}`
148
- : '';
149
- console.error(`- ${status}> ${e.name} ${errors}`);
146
+ let status;
147
+ let messages = '';
148
+ if ((0, common_1.isExploreError)(e)) {
149
+ status = styles.error('ERROR');
150
+ messages = `: ${styles.error(e.errors.map((err) => err.message).join(', '))}`;
151
+ errors += 1;
152
+ }
153
+ else if (process.env.PARTIAL_COMPILATION_ENABLED === 'true' &&
154
+ 'warnings' in e &&
155
+ e.warnings &&
156
+ e.warnings.length > 0) {
157
+ status = styles.warning('PARTIAL_SUCCESS');
158
+ messages = `: ${styles.warning(e.warnings.map((warning) => warning.message).join(', '))}`;
159
+ partialSuccess += 1;
160
+ }
161
+ else {
162
+ status = styles.success('SUCCESS');
163
+ success += 1;
164
+ }
165
+ console.error(`- ${status}> ${e.name} ${messages}`);
150
166
  });
151
167
  console.error('');
152
- const errors = explores.filter((e) => (0, common_1.isExploreError)(e)).length;
153
- console.error(`Compiled ${explores.length} explores, SUCCESS=${explores.length - errors} ERRORS=${errors}`);
168
+ if (process.env.PARTIAL_COMPILATION_ENABLED === 'true' &&
169
+ partialSuccess > 0) {
170
+ console.error(`Compiled ${explores.length} explores, SUCCESS=${success} PARTIAL_SUCCESS=${partialSuccess} ERRORS=${errors}`);
171
+ }
172
+ else {
173
+ console.error(`Compiled ${explores.length} explores, SUCCESS=${success} ERRORS=${errors}`);
174
+ }
154
175
  const metricsCount = dbtMetrics === null ? 0 : Object.values(dbtMetrics).length;
155
176
  await analytics_1.LightdashAnalytics.track({
156
177
  event: 'compile.completed',
@@ -4,6 +4,7 @@ const tslib_1 = require("tslib");
4
4
  const promises_1 = tslib_1.__importDefault(require("fs/promises"));
5
5
  const os = tslib_1.__importStar(require("os"));
6
6
  const path = tslib_1.__importStar(require("path"));
7
+ const styles = tslib_1.__importStar(require("../styles"));
7
8
  const compile_1 = require("./compile");
8
9
  jest.mock('execa');
9
10
  jest.mock('../analytics/analytics');
@@ -87,4 +88,114 @@ dimensions:
87
88
  expect(startedCall).toBeDefined();
88
89
  expect(startedCall[0].properties.dbtVersion).toBeUndefined();
89
90
  });
91
+ test('should display PARTIAL_SUCCESS with warning messages', () => {
92
+ // Mock console.error to capture output
93
+ const consoleSpy = jest.spyOn(console, 'error').mockImplementation();
94
+ // Set environment variable for partial compilation
95
+ const originalEnv = process.env.PARTIAL_COMPILATION_ENABLED;
96
+ process.env.PARTIAL_COMPILATION_ENABLED = 'true';
97
+ try {
98
+ // Create mock explores array with different statuses
99
+ const mockExplores = [
100
+ {
101
+ name: 'successful_explore',
102
+ label: 'Successful Explore',
103
+ tags: [],
104
+ baseTable: 'table1',
105
+ // No warnings or errors - should be SUCCESS
106
+ },
107
+ {
108
+ name: 'explore_with_warnings',
109
+ label: 'Explore with Warnings',
110
+ tags: [],
111
+ baseTable: 'table2',
112
+ warnings: [
113
+ {
114
+ type: 'MISSING_TABLE',
115
+ message: 'Join to table "missing_table" was skipped',
116
+ },
117
+ {
118
+ type: 'FIELD_ERROR',
119
+ message: 'Field compilation warning',
120
+ },
121
+ ],
122
+ },
123
+ {
124
+ name: 'failed_explore',
125
+ label: 'Failed Explore',
126
+ tags: [],
127
+ errors: [
128
+ {
129
+ type: 'NO_DIMENSIONS_FOUND',
130
+ message: 'No dimensions found in model',
131
+ },
132
+ ],
133
+ },
134
+ ];
135
+ // Simulate the explore display logic from compile.ts
136
+ let errors = 0;
137
+ let partialSuccess = 0;
138
+ let success = 0;
139
+ mockExplores.forEach((e) => {
140
+ let status;
141
+ let messages = '';
142
+ if ('errors' in e && e.errors) {
143
+ status = styles.error('ERROR');
144
+ messages = `: ${styles.error(e.errors.map((err) => err.message).join(', '))}`;
145
+ errors += 1;
146
+ }
147
+ else if (process.env.PARTIAL_COMPILATION_ENABLED === 'true' &&
148
+ 'warnings' in e &&
149
+ e.warnings &&
150
+ e.warnings.length > 0) {
151
+ status = styles.warning('PARTIAL_SUCCESS');
152
+ messages = `: ${styles.warning(e.warnings
153
+ .map((warning) => warning.message)
154
+ .join(', '))}`;
155
+ partialSuccess += 1;
156
+ }
157
+ else {
158
+ status = styles.success('SUCCESS');
159
+ success += 1;
160
+ }
161
+ console.error(`- ${status}> ${e.name} ${messages}`);
162
+ });
163
+ console.error('');
164
+ // Display summary
165
+ if (process.env.PARTIAL_COMPILATION_ENABLED === 'true' &&
166
+ partialSuccess > 0) {
167
+ console.error(`Compiled ${mockExplores.length} explores, SUCCESS=${success} PARTIAL_SUCCESS=${partialSuccess} ERRORS=${errors}`);
168
+ }
169
+ else {
170
+ console.error(`Compiled ${mockExplores.length} explores, SUCCESS=${success} ERRORS=${errors}`);
171
+ }
172
+ // Verify the output
173
+ const calls = consoleSpy.mock.calls.map((call) => call[0]);
174
+ // Check that PARTIAL_SUCCESS status is displayed
175
+ const partialSuccessCall = calls.find((call) => typeof call === 'string' &&
176
+ call.includes('PARTIAL_SUCCESS> explore_with_warnings'));
177
+ expect(partialSuccessCall).toBeDefined();
178
+ expect(partialSuccessCall).toContain('Join to table "missing_table" was skipped');
179
+ expect(partialSuccessCall).toContain('Field compilation warning');
180
+ // Check that SUCCESS status is displayed
181
+ const successCall = calls.find((call) => typeof call === 'string' &&
182
+ call.includes('SUCCESS> successful_explore'));
183
+ expect(successCall).toBeDefined();
184
+ // Check that ERROR status is displayed
185
+ const errorCall = calls.find((call) => typeof call === 'string' &&
186
+ call.includes('ERROR> failed_explore'));
187
+ expect(errorCall).toBeDefined();
188
+ // Check the summary includes PARTIAL_SUCCESS count
189
+ const summaryCall = calls.find((call) => typeof call === 'string' &&
190
+ call.includes('Compiled') &&
191
+ call.includes('PARTIAL_SUCCESS='));
192
+ expect(summaryCall).toBeDefined();
193
+ expect(summaryCall).toContain('SUCCESS=1 PARTIAL_SUCCESS=1 ERRORS=1');
194
+ }
195
+ finally {
196
+ // Clean up
197
+ consoleSpy.mockRestore();
198
+ process.env.PARTIAL_COMPILATION_ENABLED = originalEnv;
199
+ }
200
+ });
90
201
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash/cli",
3
- "version": "0.2389.4",
3
+ "version": "0.2391.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -38,8 +38,8 @@
38
38
  "unique-names-generator": "^4.7.1",
39
39
  "uuid": "^11.0.3",
40
40
  "yaml": "^2.7.0",
41
- "@lightdash/common": "0.2389.4",
42
- "@lightdash/warehouses": "0.2389.4"
41
+ "@lightdash/common": "0.2391.0",
42
+ "@lightdash/warehouses": "0.2391.0"
43
43
  },
44
44
  "description": "Lightdash CLI tool",
45
45
  "devDependencies": {