@lightdash/cli 0.2029.1 → 0.2030.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.
@@ -7,6 +7,7 @@ export type DownloadHandlerOptions = {
7
7
  project?: string;
8
8
  languageMap: boolean;
9
9
  skipSpaceCreate: boolean;
10
+ includeCharts: boolean;
10
11
  };
11
12
  export declare const downloadContent: (ids: string[], type: "charts" | "dashboards", projectId: string, customPath?: string, languageMap?: boolean) => Promise<[number, string[]]>;
12
13
  export declare const downloadHandler: (options: DownloadHandlerOptions) => Promise<void>;
@@ -349,6 +349,20 @@ const upsertResources = async (type, projectId, changes, force, slugs, customPat
349
349
  }
350
350
  return { changes, total: filteredItems.length };
351
351
  };
352
+ const getDashboardChartSlugs = async (dashboardSlugs, customPath) => {
353
+ const dashboardItems = await readCodeFiles('dashboards', customPath);
354
+ const filteredDashboardItems = dashboardSlugs.length > 0
355
+ ? dashboardItems.filter((dashboard) => dashboardSlugs.includes(dashboard.slug))
356
+ : dashboardItems;
357
+ return filteredDashboardItems.reduce((acc, dashboard) => {
358
+ const dashboardChartSlugs = dashboard.tiles
359
+ .map((tile) => 'chartSlug' in tile.properties
360
+ ? tile.properties.chartSlug
361
+ : undefined)
362
+ .filter((dashboardChartSlug) => !!dashboardChartSlug);
363
+ return [...acc, ...dashboardChartSlugs];
364
+ }, []);
365
+ };
352
366
  const uploadHandler = async (options) => {
353
367
  globalState_1.default.setVerbose(options.verbose);
354
368
  await (0, apiClient_1.checkLightdashVersion)();
@@ -377,11 +391,18 @@ const uploadHandler = async (options) => {
377
391
  // If any filter is provided, we skip those items without filters
378
392
  // eg: if a --charts filter is provided, we skip dashboards if no --dashboards filter is provided
379
393
  const hasFilters = options.charts.length > 0 || options.dashboards.length > 0;
380
- if (hasFilters && options.charts.length === 0) {
394
+ // Always include the charts from dashboards if includeCharts is true regardless of the charts filters
395
+ const chartSlugs = options.includeCharts
396
+ ? Array.from(new Set([
397
+ ...options.charts,
398
+ ...(await getDashboardChartSlugs(options.dashboards, options.path)),
399
+ ]))
400
+ : options.charts;
401
+ if (hasFilters && chartSlugs.length === 0) {
381
402
  console.info(styles.warning(`No charts filters provided, skipping`));
382
403
  }
383
404
  else {
384
- const { changes: chartChanges, total } = await upsertResources('charts', projectId, changes, options.force, options.charts, options.path, options.skipSpaceCreate);
405
+ const { changes: chartChanges, total } = await upsertResources('charts', projectId, changes, options.force, chartSlugs, options.path, options.skipSpaceCreate);
385
406
  changes = chartChanges;
386
407
  chartTotal = total;
387
408
  }
package/dist/index.js CHANGED
@@ -236,6 +236,7 @@ commander_1.program
236
236
  .option('-p, --path <path>', 'specify a custom path to upload charts and dashboards from', undefined)
237
237
  .option('--project <project uuid>', 'specify a project UUID to upload', parseProjectArgument, undefined)
238
238
  .option('--skip-space-create', 'Skip space creation if it does not exist', false)
239
+ .option('--include-charts', 'Include charts updates when uploading dashboards', false)
239
240
  .action(download_1.uploadHandler);
240
241
  commander_1.program
241
242
  .command('deploy')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash/cli",
3
- "version": "0.2029.1",
3
+ "version": "0.2030.1",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "lightdash": "dist/index.js"
@@ -32,8 +32,8 @@
32
32
  "parse-node-version": "^2.0.0",
33
33
  "unique-names-generator": "^4.7.1",
34
34
  "uuid": "^11.0.3",
35
- "@lightdash/common": "0.2029.1",
36
- "@lightdash/warehouses": "0.2029.1"
35
+ "@lightdash/common": "0.2030.1",
36
+ "@lightdash/warehouses": "0.2030.1"
37
37
  },
38
38
  "description": "Lightdash CLI tool",
39
39
  "devDependencies": {