@lightdash/cli 0.2202.1 → 0.2204.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":"ajvToSarif.d.ts","sourceRoot":"","sources":["../../../src/handlers/lint/ajvToSarif.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAEvC,KAAK,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEjE,KAAK,oBAAoB,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,UAAU,EAAE,OAAO,GAAG,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"ajvToSarif.d.ts","sourceRoot":"","sources":["../../../src/handlers/lint/ajvToSarif.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAEvC,KAAK,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEjE,KAAK,oBAAoB,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,UAAU,EAAE,OAAO,GAAG,WAAW,GAAG,OAAO,CAAC;CAC/C,CAAC;AAGF,MAAM,MAAM,QAAQ,GAAG;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EA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ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../src/handlers/lint.ts"],"names":[],"mappings":"AAcA,KAAK,WAAW,GAAG;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CAC3B,CAAC;AAsOF,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAmGrE"}
|
package/dist/handlers/lint.js
CHANGED
|
@@ -12,6 +12,7 @@ const ajvToSarif_1 = require("./lint/ajvToSarif");
|
|
|
12
12
|
const sarifFormatter_1 = require("./lint/sarifFormatter");
|
|
13
13
|
const validateChartSchema = ajv_1.ajv.compile(common_1.chartAsCodeSchema);
|
|
14
14
|
const validateDashboardSchema = ajv_1.ajv.compile(common_1.dashboardAsCodeSchema);
|
|
15
|
+
const validateModelSchema = ajv_1.ajv.compile(common_1.modelAsCodeSchema);
|
|
15
16
|
/**
|
|
16
17
|
* Find all YAML and JSON files in a path (file or directory).
|
|
17
18
|
* If a file path is provided, returns it if it's a .yml/.yaml/.json file.
|
|
@@ -130,6 +131,23 @@ function validateFile(filePath) {
|
|
|
130
131
|
};
|
|
131
132
|
}
|
|
132
133
|
const dataObj = data;
|
|
134
|
+
// Check if this is a model (has type: "model", "model/v1beta", or "model/v1")
|
|
135
|
+
if (dataObj.type === 'model' ||
|
|
136
|
+
dataObj.type === 'model/v1beta' ||
|
|
137
|
+
dataObj.type === 'model/v1') {
|
|
138
|
+
const valid = validateModelSchema(data);
|
|
139
|
+
if (!valid && validateModelSchema.errors) {
|
|
140
|
+
return {
|
|
141
|
+
filePath,
|
|
142
|
+
valid: false,
|
|
143
|
+
errors: validateModelSchema.errors,
|
|
144
|
+
fileContent,
|
|
145
|
+
locationMap,
|
|
146
|
+
type: 'model',
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
return { filePath, valid: true, type: 'model' };
|
|
150
|
+
}
|
|
133
151
|
// Check if this is a chart (has version and metricQuery)
|
|
134
152
|
if (dataObj.version === 1 && dataObj.metricQuery && !dataObj.tiles) {
|
|
135
153
|
const valid = validateChartSchema(data);
|
|
@@ -199,7 +217,7 @@ async function lintHandler(options) {
|
|
|
199
217
|
const results = [];
|
|
200
218
|
for (const file of codeFiles) {
|
|
201
219
|
const result = validateFile(file);
|
|
202
|
-
// Only track Lightdash Code files (
|
|
220
|
+
// Only track Lightdash Code files (models, charts, dashboards)
|
|
203
221
|
if (result.type) {
|
|
204
222
|
results.push(result);
|
|
205
223
|
}
|
|
@@ -207,7 +225,7 @@ async function lintHandler(options) {
|
|
|
207
225
|
if (results.length === 0) {
|
|
208
226
|
if (outputFormat === 'cli') {
|
|
209
227
|
console.log(chalk_1.default.yellow('No Lightdash Code files found.'));
|
|
210
|
-
console.log(chalk_1.default.dim('
|
|
228
|
+
console.log(chalk_1.default.dim('Models must have type: model (or model/v1, model/v1beta), charts must have version: 1 + metricQuery, dashboards must have version: 1 + tiles'));
|
|
211
229
|
}
|
|
212
230
|
return;
|
|
213
231
|
}
|
package/dist/index.js
CHANGED
|
@@ -376,7 +376,7 @@ ${styles.bold('Examples:')}
|
|
|
376
376
|
.action(diagnostics_1.diagnosticsHandler);
|
|
377
377
|
commander_1.program
|
|
378
378
|
.command('lint')
|
|
379
|
-
.description('Validates Lightdash Code files (charts, dashboards) against JSON schemas')
|
|
379
|
+
.description('Validates Lightdash Code files (models, charts, dashboards) against JSON schemas')
|
|
380
380
|
.addHelpText('after', `
|
|
381
381
|
${styles.bold('Examples:')}
|
|
382
382
|
${styles.title('⚡')}️lightdash ${styles.bold('lint')} ${styles.secondary('-- validates all Lightdash Code files in current directory')}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightdash/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2204.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"lightdash": "dist/index.js"
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"unique-names-generator": "^4.7.1",
|
|
35
35
|
"uuid": "^11.0.3",
|
|
36
36
|
"yaml": "^2.7.0",
|
|
37
|
-
"@lightdash/common": "0.
|
|
38
|
-
"@lightdash/warehouses": "0.
|
|
37
|
+
"@lightdash/common": "0.2204.0",
|
|
38
|
+
"@lightdash/warehouses": "0.2204.0"
|
|
39
39
|
},
|
|
40
40
|
"description": "Lightdash CLI tool",
|
|
41
41
|
"devDependencies": {
|