@claryai/cli 0.1.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.
- package/LICENSE +25 -0
- package/README.md +197 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/ajv.d.ts +3 -0
- package/dist/ajv.d.ts.map +1 -0
- package/dist/ajv.js +13 -0
- package/dist/analytics/analytics.d.ts +370 -0
- package/dist/analytics/analytics.d.ts.map +1 -0
- package/dist/analytics/analytics.js +143 -0
- package/dist/config.d.ts +34 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +134 -0
- package/dist/dbt/context.d.ts +14 -0
- package/dist/dbt/context.d.ts.map +1 -0
- package/dist/dbt/context.js +76 -0
- package/dist/dbt/context.test.d.ts +2 -0
- package/dist/dbt/context.test.d.ts.map +1 -0
- package/dist/dbt/context.test.js +152 -0
- package/dist/dbt/manifest.d.ts +7 -0
- package/dist/dbt/manifest.d.ts.map +1 -0
- package/dist/dbt/manifest.js +23 -0
- package/dist/dbt/models.d.ts +43 -0
- package/dist/dbt/models.d.ts.map +1 -0
- package/dist/dbt/models.js +256 -0
- package/dist/dbt/models.test.d.ts +2 -0
- package/dist/dbt/models.test.d.ts.map +1 -0
- package/dist/dbt/models.test.js +19 -0
- package/dist/dbt/profile.d.ts +9 -0
- package/dist/dbt/profile.d.ts.map +1 -0
- package/dist/dbt/profile.js +86 -0
- package/dist/dbt/profiles.test.d.ts +2 -0
- package/dist/dbt/profiles.test.d.ts.map +1 -0
- package/dist/dbt/profiles.test.js +50 -0
- package/dist/dbt/schema.d.ts +31 -0
- package/dist/dbt/schema.d.ts.map +1 -0
- package/dist/dbt/schema.js +49 -0
- package/dist/dbt/targets/Bigquery/index.d.ts +18 -0
- package/dist/dbt/targets/Bigquery/index.d.ts.map +1 -0
- package/dist/dbt/targets/Bigquery/index.js +105 -0
- package/dist/dbt/targets/Bigquery/oauth.d.ts +2 -0
- package/dist/dbt/targets/Bigquery/oauth.d.ts.map +1 -0
- package/dist/dbt/targets/Bigquery/oauth.js +43 -0
- package/dist/dbt/targets/Bigquery/serviceAccount.d.ts +35 -0
- package/dist/dbt/targets/Bigquery/serviceAccount.d.ts.map +1 -0
- package/dist/dbt/targets/Bigquery/serviceAccount.js +149 -0
- package/dist/dbt/targets/Databricks/oauth.d.ts +21 -0
- package/dist/dbt/targets/Databricks/oauth.d.ts.map +1 -0
- package/dist/dbt/targets/Databricks/oauth.js +184 -0
- package/dist/dbt/targets/athena.d.ts +21 -0
- package/dist/dbt/targets/athena.d.ts.map +1 -0
- package/dist/dbt/targets/athena.js +91 -0
- package/dist/dbt/targets/athena.test.d.ts +2 -0
- package/dist/dbt/targets/athena.test.d.ts.map +1 -0
- package/dist/dbt/targets/athena.test.js +60 -0
- package/dist/dbt/targets/clickhouse.d.ts +24 -0
- package/dist/dbt/targets/clickhouse.d.ts.map +1 -0
- package/dist/dbt/targets/clickhouse.js +90 -0
- package/dist/dbt/targets/databricks.d.ts +27 -0
- package/dist/dbt/targets/databricks.d.ts.map +1 -0
- package/dist/dbt/targets/databricks.js +138 -0
- package/dist/dbt/targets/duckdb.d.ts +16 -0
- package/dist/dbt/targets/duckdb.d.ts.map +1 -0
- package/dist/dbt/targets/duckdb.js +63 -0
- package/dist/dbt/targets/duckdb.test.d.ts +2 -0
- package/dist/dbt/targets/duckdb.test.d.ts.map +1 -0
- package/dist/dbt/targets/duckdb.test.js +37 -0
- package/dist/dbt/targets/postgres.d.ts +26 -0
- package/dist/dbt/targets/postgres.d.ts.map +1 -0
- package/dist/dbt/targets/postgres.js +142 -0
- package/dist/dbt/targets/redshift.d.ts +23 -0
- package/dist/dbt/targets/redshift.d.ts.map +1 -0
- package/dist/dbt/targets/redshift.js +96 -0
- package/dist/dbt/targets/snowflake.d.ts +4 -0
- package/dist/dbt/targets/snowflake.d.ts.map +1 -0
- package/dist/dbt/targets/snowflake.js +134 -0
- package/dist/dbt/targets/trino.d.ts +16 -0
- package/dist/dbt/targets/trino.d.ts.map +1 -0
- package/dist/dbt/targets/trino.js +65 -0
- package/dist/dbt/templating.d.ts +15 -0
- package/dist/dbt/templating.d.ts.map +1 -0
- package/dist/dbt/templating.js +50 -0
- package/dist/dbt/templating.test.d.ts +2 -0
- package/dist/dbt/templating.test.d.ts.map +1 -0
- package/dist/dbt/templating.test.js +51 -0
- package/dist/dbt/types.d.ts +17 -0
- package/dist/dbt/types.d.ts.map +1 -0
- package/dist/dbt/types.js +2 -0
- package/dist/dbt/validation.d.ts +9 -0
- package/dist/dbt/validation.d.ts.map +1 -0
- package/dist/dbt/validation.js +54 -0
- package/dist/env.d.ts +12 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +40 -0
- package/dist/error.d.ts +2 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +12 -0
- package/dist/globalState.d.ts +29 -0
- package/dist/globalState.d.ts.map +1 -0
- package/dist/globalState.js +67 -0
- package/dist/handlers/asyncQuery.d.ts +7 -0
- package/dist/handlers/asyncQuery.d.ts.map +1 -0
- package/dist/handlers/asyncQuery.js +50 -0
- package/dist/handlers/compile.d.ts +16 -0
- package/dist/handlers/compile.d.ts.map +1 -0
- package/dist/handlers/compile.js +277 -0
- package/dist/handlers/compile.test.d.ts +2 -0
- package/dist/handlers/compile.test.d.ts.map +1 -0
- package/dist/handlers/compile.test.js +201 -0
- package/dist/handlers/createProject.d.ts +37 -0
- package/dist/handlers/createProject.d.ts.map +1 -0
- package/dist/handlers/createProject.js +272 -0
- package/dist/handlers/dbt/apiClient.d.ts +14 -0
- package/dist/handlers/dbt/apiClient.d.ts.map +1 -0
- package/dist/handlers/dbt/apiClient.js +167 -0
- package/dist/handlers/dbt/compile.d.ts +35 -0
- package/dist/handlers/dbt/compile.d.ts.map +1 -0
- package/dist/handlers/dbt/compile.js +220 -0
- package/dist/handlers/dbt/getDbtProfileTargetName.d.ts +9 -0
- package/dist/handlers/dbt/getDbtProfileTargetName.d.ts.map +1 -0
- package/dist/handlers/dbt/getDbtProfileTargetName.js +44 -0
- package/dist/handlers/dbt/getDbtVersion.d.ts +16 -0
- package/dist/handlers/dbt/getDbtVersion.d.ts.map +1 -0
- package/dist/handlers/dbt/getDbtVersion.js +141 -0
- package/dist/handlers/dbt/getDbtVersion.mocks.d.ts +11 -0
- package/dist/handlers/dbt/getDbtVersion.mocks.d.ts.map +1 -0
- package/dist/handlers/dbt/getDbtVersion.mocks.js +70 -0
- package/dist/handlers/dbt/getDbtVersion.test.d.ts +2 -0
- package/dist/handlers/dbt/getDbtVersion.test.d.ts.map +1 -0
- package/dist/handlers/dbt/getDbtVersion.test.js +97 -0
- package/dist/handlers/dbt/getWarehouseClient.d.ts +24 -0
- package/dist/handlers/dbt/getWarehouseClient.d.ts.map +1 -0
- package/dist/handlers/dbt/getWarehouseClient.js +312 -0
- package/dist/handlers/dbt/refresh.d.ts +11 -0
- package/dist/handlers/dbt/refresh.d.ts.map +1 -0
- package/dist/handlers/dbt/refresh.js +114 -0
- package/dist/handlers/dbt/run.d.ts +14 -0
- package/dist/handlers/dbt/run.d.ts.map +1 -0
- package/dist/handlers/dbt/run.js +67 -0
- package/dist/handlers/deploy.d.ts +26 -0
- package/dist/handlers/deploy.d.ts.map +1 -0
- package/dist/handlers/deploy.js +377 -0
- package/dist/handlers/diagnostics.d.ts +11 -0
- package/dist/handlers/diagnostics.d.ts.map +1 -0
- package/dist/handlers/diagnostics.js +194 -0
- package/dist/handlers/download.d.ts +29 -0
- package/dist/handlers/download.d.ts.map +1 -0
- package/dist/handlers/download.js +955 -0
- package/dist/handlers/exportChartImage.d.ts +7 -0
- package/dist/handlers/exportChartImage.d.ts.map +1 -0
- package/dist/handlers/exportChartImage.js +33 -0
- package/dist/handlers/generate.d.ts +13 -0
- package/dist/handlers/generate.d.ts.map +1 -0
- package/dist/handlers/generate.js +159 -0
- package/dist/handlers/generateExposures.d.ts +8 -0
- package/dist/handlers/generateExposures.d.ts.map +1 -0
- package/dist/handlers/generateExposures.js +100 -0
- package/dist/handlers/getProject.d.ts +6 -0
- package/dist/handlers/getProject.d.ts.map +1 -0
- package/dist/handlers/getProject.js +43 -0
- package/dist/handlers/installSkills.d.ts +12 -0
- package/dist/handlers/installSkills.d.ts.map +1 -0
- package/dist/handlers/installSkills.js +321 -0
- package/dist/handlers/lint/ajvToSarif.d.ts +66 -0
- package/dist/handlers/lint/ajvToSarif.d.ts.map +1 -0
- package/dist/handlers/lint/ajvToSarif.js +222 -0
- package/dist/handlers/lint/sarifFormatter.d.ts +14 -0
- package/dist/handlers/lint/sarifFormatter.d.ts.map +1 -0
- package/dist/handlers/lint/sarifFormatter.js +111 -0
- package/dist/handlers/lint.d.ts +8 -0
- package/dist/handlers/lint.d.ts.map +1 -0
- package/dist/handlers/lint.js +308 -0
- package/dist/handlers/listProjects.d.ts +6 -0
- package/dist/handlers/listProjects.d.ts.map +1 -0
- package/dist/handlers/listProjects.js +53 -0
- package/dist/handlers/login/oauth.d.ts +2 -0
- package/dist/handlers/login/oauth.d.ts.map +1 -0
- package/dist/handlers/login/oauth.js +27 -0
- package/dist/handlers/login/pat.d.ts +2 -0
- package/dist/handlers/login/pat.d.ts.map +1 -0
- package/dist/handlers/login/pat.js +31 -0
- package/dist/handlers/login.d.ts +15 -0
- package/dist/handlers/login.d.ts.map +1 -0
- package/dist/handlers/login.js +239 -0
- package/dist/handlers/metadataFile.d.ts +9 -0
- package/dist/handlers/metadataFile.d.ts.map +1 -0
- package/dist/handlers/metadataFile.js +34 -0
- package/dist/handlers/oauthLogin.d.ts +6 -0
- package/dist/handlers/oauthLogin.d.ts.map +1 -0
- package/dist/handlers/oauthLogin.js +191 -0
- package/dist/handlers/preview.d.ts +29 -0
- package/dist/handlers/preview.d.ts.map +1 -0
- package/dist/handlers/preview.js +415 -0
- package/dist/handlers/renameHandler.d.ts +16 -0
- package/dist/handlers/renameHandler.d.ts.map +1 -0
- package/dist/handlers/renameHandler.js +160 -0
- package/dist/handlers/runChart.d.ts +10 -0
- package/dist/handlers/runChart.d.ts.map +1 -0
- package/dist/handlers/runChart.js +105 -0
- package/dist/handlers/selectProject.d.ts +20 -0
- package/dist/handlers/selectProject.d.ts.map +1 -0
- package/dist/handlers/selectProject.js +91 -0
- package/dist/handlers/setProject.d.ts +14 -0
- package/dist/handlers/setProject.d.ts.map +1 -0
- package/dist/handlers/setProject.js +131 -0
- package/dist/handlers/setWarehouse.d.ts +14 -0
- package/dist/handlers/setWarehouse.d.ts.map +1 -0
- package/dist/handlers/setWarehouse.js +94 -0
- package/dist/handlers/sql.d.ts +9 -0
- package/dist/handlers/sql.d.ts.map +1 -0
- package/dist/handlers/sql.js +89 -0
- package/dist/handlers/utils.d.ts +11 -0
- package/dist/handlers/utils.d.ts.map +1 -0
- package/dist/handlers/utils.js +36 -0
- package/dist/handlers/validate.d.ts +22 -0
- package/dist/handlers/validate.d.ts.map +1 -0
- package/dist/handlers/validate.js +201 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +581 -0
- package/dist/lightdash/loader.d.ts +21 -0
- package/dist/lightdash/loader.d.ts.map +1 -0
- package/dist/lightdash/loader.js +122 -0
- package/dist/lightdash/projectType.d.ts +84 -0
- package/dist/lightdash/projectType.d.ts.map +1 -0
- package/dist/lightdash/projectType.js +75 -0
- package/dist/lightdash-config/index.d.ts +2 -0
- package/dist/lightdash-config/index.d.ts.map +1 -0
- package/dist/lightdash-config/index.js +41 -0
- package/dist/lightdash-config/lightdash-config.test.d.ts +2 -0
- package/dist/lightdash-config/lightdash-config.test.d.ts.map +1 -0
- package/dist/lightdash-config/lightdash-config.test.js +70 -0
- package/dist/styles.d.ts +10 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +14 -0
- package/entitlements.plist +33 -0
- package/package.json +71 -0
- package/track.sh +116 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@lightdash/common");
|
|
6
|
+
const commander_1 = require("commander");
|
|
7
|
+
const uuid_1 = require("uuid");
|
|
8
|
+
const env_1 = require("./env");
|
|
9
|
+
const error_1 = require("./error");
|
|
10
|
+
const globalState_1 = tslib_1.__importDefault(require("./globalState"));
|
|
11
|
+
const compile_1 = require("./handlers/compile");
|
|
12
|
+
const refresh_1 = require("./handlers/dbt/refresh");
|
|
13
|
+
const run_1 = require("./handlers/dbt/run");
|
|
14
|
+
const deploy_1 = require("./handlers/deploy");
|
|
15
|
+
const diagnostics_1 = require("./handlers/diagnostics");
|
|
16
|
+
const download_1 = require("./handlers/download");
|
|
17
|
+
const exportChartImage_1 = require("./handlers/exportChartImage");
|
|
18
|
+
const generate_1 = require("./handlers/generate");
|
|
19
|
+
const generateExposures_1 = require("./handlers/generateExposures");
|
|
20
|
+
const getProject_1 = require("./handlers/getProject");
|
|
21
|
+
const installSkills_1 = require("./handlers/installSkills");
|
|
22
|
+
const lint_1 = require("./handlers/lint");
|
|
23
|
+
const listProjects_1 = require("./handlers/listProjects");
|
|
24
|
+
const login_1 = require("./handlers/login");
|
|
25
|
+
const preview_1 = require("./handlers/preview");
|
|
26
|
+
const renameHandler_1 = require("./handlers/renameHandler");
|
|
27
|
+
const runChart_1 = require("./handlers/runChart");
|
|
28
|
+
const setProject_1 = require("./handlers/setProject");
|
|
29
|
+
const setWarehouse_1 = require("./handlers/setWarehouse");
|
|
30
|
+
const sql_1 = require("./handlers/sql");
|
|
31
|
+
const validate_1 = require("./handlers/validate");
|
|
32
|
+
const styles = tslib_1.__importStar(require("./styles"));
|
|
33
|
+
// Trigger CLI tests
|
|
34
|
+
// Suppress AWS SDK V2 warning, imported by snowflake SDK
|
|
35
|
+
process.env.AWS_SDK_JS_SUPPRESS_MAINTENANCE_MODE_MESSAGE = "1";
|
|
36
|
+
function parseIntArgument(value) {
|
|
37
|
+
const parsedValue = parseInt(value, 10);
|
|
38
|
+
if (Number.isNaN(parsedValue)) {
|
|
39
|
+
throw new commander_1.InvalidArgumentError("Not a number.");
|
|
40
|
+
}
|
|
41
|
+
return parsedValue;
|
|
42
|
+
}
|
|
43
|
+
function parseStartOfWeekArgument(value) {
|
|
44
|
+
const number = parseIntArgument(value);
|
|
45
|
+
if (number < 0 || number > 6) {
|
|
46
|
+
throw new commander_1.InvalidArgumentError("Not a valid number. Please use a number from 0 (Monday) to 6 (Sunday)");
|
|
47
|
+
}
|
|
48
|
+
return number;
|
|
49
|
+
}
|
|
50
|
+
function parseUseDbtListOption(value) {
|
|
51
|
+
if (value === undefined) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
return value.toLowerCase() !== "false";
|
|
55
|
+
}
|
|
56
|
+
function parseDisableTimestampConversionOption(value) {
|
|
57
|
+
if (value === undefined) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
return value.toLowerCase() === "true";
|
|
61
|
+
}
|
|
62
|
+
function parseProjectArgument(value) {
|
|
63
|
+
if (value === undefined) {
|
|
64
|
+
throw new commander_1.InvalidArgumentError("No project argument provided.");
|
|
65
|
+
}
|
|
66
|
+
const isValidUuid = (0, uuid_1.validate)(value);
|
|
67
|
+
if (!isValidUuid) {
|
|
68
|
+
throw new commander_1.InvalidArgumentError("Not a valid project UUID.");
|
|
69
|
+
}
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
commander_1.program
|
|
73
|
+
.version((0, installSkills_1.getVersionWithSkills)())
|
|
74
|
+
.name(styles.title("⚡️clary"))
|
|
75
|
+
.description("Developer tools for dbt and Clary.\nSee https://docs.getclary.com for more help and examples")
|
|
76
|
+
.option("--non-interactive", "Disable all interactive prompts. Commands fail with helpful error if required input is missing.")
|
|
77
|
+
.hook("preAction", (thisCommand) => {
|
|
78
|
+
const opts = thisCommand.opts();
|
|
79
|
+
if (opts.nonInteractive) {
|
|
80
|
+
globalState_1.default.setNonInteractive(true);
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
.showHelpAfterError(styles.bold("Run ⚡️clary help [command] for more information"))
|
|
84
|
+
.addHelpText("after", `
|
|
85
|
+
${styles.bold("Examples:")}
|
|
86
|
+
${styles.title("⚡")}️clary ${styles.bold("generate")} ${styles.secondary("-- generates .yml file for all dbt models")}
|
|
87
|
+
${styles.title("⚡")}️clary ${styles.bold("generate")} -s mymodel ${styles.secondary("-- generates .yml file for a single dbt model")}
|
|
88
|
+
${styles.title("⚡")}️clary ${styles.bold("generate")} -s model1 model2 ${styles.secondary("-- generates .yml for multiple dbt models")}
|
|
89
|
+
${styles.title("⚡")}️clary ${styles.bold("generate")} -s tag:sales ${styles.secondary("-- generates .yml for all dbt models tagged as sales")}
|
|
90
|
+
${styles.title("⚡")}️clary ${styles.bold("generate")} -s +mymodel ${styles.secondary("-- generates .yml for mymodel and all it's parents")}
|
|
91
|
+
${styles.title("⚡")}️clary ${styles.bold("generate")} --help ${styles.secondary('-- shows detailed help for the "generate" command')}
|
|
92
|
+
${styles.title("⚡")}️clary ${styles.bold("dbt run")} ${styles.secondary("-- runs dbt for all models and updates .yml for all models")}
|
|
93
|
+
${styles.title("⚡")}️clary ${styles.bold("dbt run")} -s model1 model2+ tag:dev ${styles.secondary("-- runs dbt for models and generates .yml for affected models")}
|
|
94
|
+
${styles.title("⚡")}️clary ${styles.bold("dbt run")} --help ${styles.secondary('-- shows detailed help for the "dbt run" command')}
|
|
95
|
+
${styles.title("⚡")}️clary ${styles.bold("compile")} ${styles.secondary("-- compiles Clary metrics and dimensions")}
|
|
96
|
+
${styles.title("⚡")}️clary ${styles.bold("deploy")} ${styles.secondary("-- compiles and deploys Clary metrics to active project")}
|
|
97
|
+
${styles.title("⚡")}️clary ${styles.bold("login https://clary.domain.com")} ${styles.secondary("-- logs in to a Clary instance")}
|
|
98
|
+
`);
|
|
99
|
+
// LOGIN
|
|
100
|
+
commander_1.program
|
|
101
|
+
.command("login [url]")
|
|
102
|
+
.description("Logs in to a Clary instance")
|
|
103
|
+
.description('Logs in to a Clary instance using OAuth2 (opens browser). Use --token to bypass OAuth.\n\nURL is optional - if not provided, uses the last URL you logged into. URL can be flexible: single words like "app" become "https://app.getclary.com", protocol defaults to https, and paths are ignored.\n\n👀 See https://docs.getclary.com/guides/cli/cli-authentication for more help and examples')
|
|
104
|
+
.addHelpText("after", `
|
|
105
|
+
${styles.bold("Examples:")}
|
|
106
|
+
${styles.title("⚡")}️clary ${styles.bold("login")} ${styles.secondary("-- Uses previously saved URL (opens browser for OAuth)")}
|
|
107
|
+
${styles.title("⚡")}️clary ${styles.bold("login")} app ${styles.secondary("-- Short form for https://app.getclary.com (opens browser for OAuth)")}
|
|
108
|
+
${styles.title("⚡")}️clary ${styles.bold("login")} eu1 ${styles.secondary("-- Short form for https://eu1.getclary.com (opens browser for OAuth)")}
|
|
109
|
+
${styles.title("⚡")}️clary ${styles.bold("login")} app.getclary.com ${styles.secondary("-- Adds https:// automatically (opens browser for OAuth)")}
|
|
110
|
+
${styles.title("⚡")}️clary ${styles.bold("login")} https://custom.clary.domain/projects/123 ${styles.secondary("-- Strips path, uses https://custom.clary.domain (opens browser for OAuth)")}
|
|
111
|
+
${styles.title("⚡")}️clary ${styles.bold("login")} http://localhost:3000 ${styles.secondary("-- Preserves http protocol for local development")}
|
|
112
|
+
${styles.title("⚡")}️clary ${styles.bold("login")} --token 12345 ${styles.secondary("-- Logs in with API token using saved URL (bypasses OAuth)")}
|
|
113
|
+
${styles.title("⚡")}️clary ${styles.bold("login")} http://localhost:3000 --email demo@getclary.com ${styles.secondary("-- Local dev only: prompts for password securely")}
|
|
114
|
+
`)
|
|
115
|
+
.option("--token <token>", "Login with an API access token", undefined)
|
|
116
|
+
.addOption(new commander_1.Option("--project <project uuid>", "Select a project by UUID after login")
|
|
117
|
+
.argParser(parseProjectArgument)
|
|
118
|
+
.conflicts("skipProjectSelection"))
|
|
119
|
+
.option("--email <email>", "Login with email and password", undefined)
|
|
120
|
+
.option("--oauth-port <port>", "Port for the local OAuth callback server (default: random available port)", (value) => {
|
|
121
|
+
const port = parseInt(value, 10);
|
|
122
|
+
if (Number.isNaN(port) || port < 1 || port > 65535) {
|
|
123
|
+
throw new Error("Port must be a number between 1 and 65535");
|
|
124
|
+
}
|
|
125
|
+
return port;
|
|
126
|
+
}, undefined)
|
|
127
|
+
.option("--verbose", undefined, false)
|
|
128
|
+
.action(login_1.login);
|
|
129
|
+
// CONFIG
|
|
130
|
+
const configProgram = commander_1.program
|
|
131
|
+
.command("config")
|
|
132
|
+
.description("Sets configuration");
|
|
133
|
+
configProgram
|
|
134
|
+
.command("set-project")
|
|
135
|
+
.description("Choose project.\nSee https://docs.getclary.com/guides/cli/cli-authentication#set-active-project for more help and examples")
|
|
136
|
+
.option("--verbose", undefined, false)
|
|
137
|
+
.addOption(new commander_1.Option("--name <project_name>", "Set the project non-interactively by passing a project name."))
|
|
138
|
+
.addOption(new commander_1.Option("--uuid <project_uuid>", "Set the project non-interactively by passing a project uuid.").conflicts("name"))
|
|
139
|
+
.action(setProject_1.setProjectHandler);
|
|
140
|
+
configProgram
|
|
141
|
+
.command("list-projects")
|
|
142
|
+
.description("List all projects in the organization (excludes preview projects)")
|
|
143
|
+
.option("--verbose", undefined, false)
|
|
144
|
+
.action(listProjects_1.listProjectsHandler);
|
|
145
|
+
configProgram
|
|
146
|
+
.command("get-project")
|
|
147
|
+
.description("Show the currently selected project")
|
|
148
|
+
.option("--verbose", undefined, false)
|
|
149
|
+
.action(getProject_1.getProjectHandler);
|
|
150
|
+
configProgram
|
|
151
|
+
.command("unset-project")
|
|
152
|
+
.description("Clear the currently selected project")
|
|
153
|
+
.option("--verbose", undefined, false)
|
|
154
|
+
.action(setProject_1.unsetProjectHandler);
|
|
155
|
+
const dbtProgram = commander_1.program.command("dbt").description("Runs dbt commands");
|
|
156
|
+
dbtProgram
|
|
157
|
+
.command("run")
|
|
158
|
+
.description("Runs dbt and then generates .yml for affected models")
|
|
159
|
+
.addHelpText("after", `
|
|
160
|
+
${styles.bold("Examples:")}
|
|
161
|
+
${styles.title("⚡")}️clary ${styles.bold("dbt run")} ${styles.secondary("-- run all models and generate .yml files")}
|
|
162
|
+
${styles.title("⚡")}️clary ${styles.bold("dbt run")} -s mymodel ${styles.secondary("-- runs a single model and generates .yml")}
|
|
163
|
+
${styles.title("⚡")}️clary ${styles.bold("dbt run")} -s model1 model2 ${styles.secondary("-- runs multiple models and generates .yml")}
|
|
164
|
+
${styles.title("⚡")}️clary ${styles.bold("dbt run")} -s tag:sales ${styles.secondary('-- runs all models tagged as "sales" and generates .yml')}
|
|
165
|
+
${styles.title("⚡")}️clary ${styles.bold("dbt run")} -s +mymodel ${styles.secondary("-- runs mymodel and its parents and generates .yml")}
|
|
166
|
+
`)
|
|
167
|
+
.option("--project-dir <path>", "The directory of the dbt project", env_1.DEFAULT_DBT_PROJECT_DIR)
|
|
168
|
+
.option("--profiles-dir <path>", "The directory of the dbt profiles", env_1.DEFAULT_DBT_PROFILES_DIR)
|
|
169
|
+
.option("--profile <name>")
|
|
170
|
+
.option("-t, --target <target>")
|
|
171
|
+
.option("-x, --fail-fast")
|
|
172
|
+
.option("--threads <threads>")
|
|
173
|
+
.option("--no-version-check")
|
|
174
|
+
.option("-s, --select, <select> [selects...]")
|
|
175
|
+
.option("--state <state>")
|
|
176
|
+
.option("--defer", "dbt property. Resolve unselected nodes by deferring to the manifest within the --state directory.", undefined)
|
|
177
|
+
.option("--no-defer", "dbt property. Do not resolve unselected nodes by deferring to the manifest within the --state directory.", undefined)
|
|
178
|
+
.option("--favor-state", "dbt property. When deferring, prioritize node definitions from the --state directory.", undefined)
|
|
179
|
+
.option("--full-refresh")
|
|
180
|
+
.option("--exclude-meta", "exclude Clary metadata from the generated .yml", false)
|
|
181
|
+
.option("--verbose", undefined, false)
|
|
182
|
+
.option("-y, --assume-yes", "assume yes to prompts", false)
|
|
183
|
+
.option("-no, --assume-no", "assume no to prompts", false)
|
|
184
|
+
.option("--preserve-column-case", "preserve original casing of column names in generated schema files", false)
|
|
185
|
+
.action(run_1.dbtRunHandler);
|
|
186
|
+
commander_1.program
|
|
187
|
+
.command("compile")
|
|
188
|
+
.description("Compiles Clary resources")
|
|
189
|
+
.option("--project-dir <path>", "The directory of the dbt project", env_1.DEFAULT_DBT_PROJECT_DIR)
|
|
190
|
+
.option("--profiles-dir <path>", "The directory of the dbt profiles", env_1.DEFAULT_DBT_PROFILES_DIR)
|
|
191
|
+
.option("--profile <name>", "The name of the profile to use (defaults to profile name in dbt_project.yml)", undefined)
|
|
192
|
+
.option("--target <name>", "target to use in profiles.yml file", undefined)
|
|
193
|
+
.option("--target-path <path>", "The target directory for dbt (overrides DBT_TARGET_PATH and dbt_project.yml)", undefined)
|
|
194
|
+
.option("--vars <vars>")
|
|
195
|
+
.option("--threads <number>")
|
|
196
|
+
.option("--no-version-check")
|
|
197
|
+
.option("-s, --select <models...>", "specify models (accepts dbt selection syntax)")
|
|
198
|
+
.option("-m, --models <models...>", "specify models (accepts dbt selection syntax)")
|
|
199
|
+
.option("--exclude <models...>")
|
|
200
|
+
.option("--selector <selector_name>")
|
|
201
|
+
.option("--state <state>")
|
|
202
|
+
.option("--full-refresh")
|
|
203
|
+
.option("--verbose", undefined, false)
|
|
204
|
+
.option("--skip-warehouse-catalog", "Skip fetch warehouse catalog and use types in yml", false)
|
|
205
|
+
.option("--skip-dbt-compile", "Skip `dbt compile` and deploy from the existing ./target/manifest.json", false)
|
|
206
|
+
.option("--defer", "dbt property. Resolve unselected nodes by deferring to the manifest within the --state directory.", undefined)
|
|
207
|
+
.option("--no-defer", "dbt property. Do not resolve unselected nodes by deferring to the manifest within the --state directory.", undefined)
|
|
208
|
+
.option("--favor-state", "dbt property. When deferring, prioritize node definitions from the --state directory.", undefined)
|
|
209
|
+
.option("--no-warehouse-credentials", "Compile without any warehouse credentials. Skips dbt compile + warehouse catalog")
|
|
210
|
+
.option("--use-dbt-list [true|false]", "Use `dbt list` instead of `dbt compile` to generate dbt manifest.json", parseUseDbtListOption, true)
|
|
211
|
+
.option("--disable-timestamp-conversion [true|false]", "Disable timestamp conversion to UTC for Snowflake warehouses. Only use this if your timestamp values are already in UTC.", parseDisableTimestampConversionOption, false)
|
|
212
|
+
.action(compile_1.compileHandler);
|
|
213
|
+
commander_1.program
|
|
214
|
+
.command("preview")
|
|
215
|
+
.description("Creates a new preview project - waits for a keypress to stop")
|
|
216
|
+
.option("--name <preview name>", "Custom name for the preview. If a name is not provided, a unique, randomly generated name will be created.")
|
|
217
|
+
.option("--project-dir <path>", "The directory of the dbt project", env_1.DEFAULT_DBT_PROJECT_DIR)
|
|
218
|
+
.option("--profiles-dir <path>", "The directory of the dbt profiles", env_1.DEFAULT_DBT_PROFILES_DIR)
|
|
219
|
+
.option("--profile <name>", "The name of the profile to use (defaults to profile name in dbt_project.yml)", undefined)
|
|
220
|
+
.option("--target <name>", "target to use in profiles.yml file", undefined)
|
|
221
|
+
.option("--target-path <path>", "The target directory for dbt (overrides DBT_TARGET_PATH and dbt_project.yml)", undefined)
|
|
222
|
+
.option("--vars <vars>")
|
|
223
|
+
.option("--defer", "dbt property. Resolve unselected nodes by deferring to the manifest within the --state directory.", undefined)
|
|
224
|
+
.option("--no-defer", "dbt property. Do not resolve unselected nodes by deferring to the manifest within the --state directory.", undefined)
|
|
225
|
+
.option("--favor-state", "dbt property. When deferring, prioritize node definitions from the --state directory.", undefined)
|
|
226
|
+
.option("--threads <number>")
|
|
227
|
+
.option("--no-version-check")
|
|
228
|
+
.option("-s, --select <models...>", "specify models (accepts dbt selection syntax)")
|
|
229
|
+
.option("-m, --models <models...>", "specify models (accepts dbt selection syntax)")
|
|
230
|
+
.option("--exclude <models...>")
|
|
231
|
+
.option("--selector <selector_name>")
|
|
232
|
+
.option("--state <state>")
|
|
233
|
+
.option("--full-refresh")
|
|
234
|
+
.option("--verbose", undefined, false)
|
|
235
|
+
.option("--start-of-week <number>", "Specifies the first day of the week (used by week-related date functions). 0 (Monday) to 6 (Sunday)", parseStartOfWeekArgument)
|
|
236
|
+
.option("--skip-dbt-compile", "Skip `dbt compile` and deploy from the existing ./target/manifest.json", false)
|
|
237
|
+
.option("--skip-warehouse-catalog", "Skip fetch warehouse catalog and use types in yml", false)
|
|
238
|
+
.option("--use-dbt-list [true|false]", "Use `dbt list` instead of `dbt compile` to generate dbt manifest.json", parseUseDbtListOption, true)
|
|
239
|
+
.option("--ignore-errors", "Allows deploy with errors on compile", false)
|
|
240
|
+
.option("--table-configuration <prod|all>", `If set to 'prod' it will copy the table configuration from prod project`, "all")
|
|
241
|
+
.option("--skip-copy-content", "Skip copying content from the source project", false)
|
|
242
|
+
.option("--disable-timestamp-conversion [true|false]", "Disable timestamp conversion to UTC for Snowflake warehouses. Only use this if your timestamp values are already in UTC.", parseDisableTimestampConversionOption, false)
|
|
243
|
+
.option("--no-warehouse-credentials", "Create preview without warehouse credentials. Copies credentials from upstream project.")
|
|
244
|
+
.option("--organization-credentials <name>", "Use organization warehouse credentials with the specified name (Enterprise Edition feature)")
|
|
245
|
+
.option("--use-batched-deploy", "Use the new batched deploy feature to upload explores in batches", false)
|
|
246
|
+
.option("--batch-size <number>", "Number of explores to deploy in each batch (default: 50)", "50")
|
|
247
|
+
.option("--parallel-batches <number>", "Number of batches to send in parallel (default: 1, use higher values with caution)", "1")
|
|
248
|
+
.action(preview_1.previewHandler);
|
|
249
|
+
commander_1.program
|
|
250
|
+
.command("start-preview")
|
|
251
|
+
.description("Creates a new preview project")
|
|
252
|
+
.option("--name [preview name]", "[required] Name for the preview project. If a preview project with this name already exists, it will be updated, otherwise it will create a new preview project ")
|
|
253
|
+
.option("--project-dir <path>", "The directory of the dbt project", env_1.DEFAULT_DBT_PROJECT_DIR)
|
|
254
|
+
.option("--profiles-dir <path>", "The directory of the dbt profiles", env_1.DEFAULT_DBT_PROFILES_DIR)
|
|
255
|
+
.option("--profile <name>", "The name of the profile to use (defaults to profile name in dbt_project.yml)", undefined)
|
|
256
|
+
.option("--target <name>", "target to use in profiles.yml file", undefined)
|
|
257
|
+
.option("--target-path <path>", "The target directory for dbt (overrides DBT_TARGET_PATH and dbt_project.yml)", undefined)
|
|
258
|
+
.option("--vars <vars>")
|
|
259
|
+
.option("--defer", "dbt property. Resolve unselected nodes by deferring to the manifest within the --state directory.", undefined)
|
|
260
|
+
.option("--no-defer", "dbt property. Do not resolve unselected nodes by deferring to the manifest within the --state directory.", undefined)
|
|
261
|
+
.option("--favor-state", "dbt property. When deferring, prioritize node definitions from the --state directory.", undefined)
|
|
262
|
+
.option("--threads <number>")
|
|
263
|
+
.option("--no-version-check")
|
|
264
|
+
.option("-s, --select <models...>", "specify models (accepts dbt selection syntax)")
|
|
265
|
+
.option("-m, --models <models...>", "specify models (accepts dbt selection syntax)")
|
|
266
|
+
.option("--exclude <models...>")
|
|
267
|
+
.option("--selector <selector_name>")
|
|
268
|
+
.option("--state <state>")
|
|
269
|
+
.option("--full-refresh")
|
|
270
|
+
.option("--verbose", undefined, false)
|
|
271
|
+
.option("--start-of-week <number>", "Specifies the first day of the week (used by week-related date functions). 0 (Monday) to 6 (Sunday)", parseStartOfWeekArgument)
|
|
272
|
+
.option("--skip-dbt-compile", "Skip `dbt compile` and deploy from the existing ./target/manifest.json", false)
|
|
273
|
+
.option("--skip-warehouse-catalog", "Skip fetch warehouse catalog and use types in yml", false)
|
|
274
|
+
.option("--use-dbt-list [true|false]", "Use `dbt list` instead of `dbt compile` to generate dbt manifest.json", parseUseDbtListOption, true)
|
|
275
|
+
.option("--ignore-errors", "Allows deploy with errors on compile", false)
|
|
276
|
+
.option("--table-configuration <prod|all>", `If set to 'prod' it will copy the table configuration from prod project`, "all")
|
|
277
|
+
.option("--skip-copy-content", "Skip copying content from the source project", false)
|
|
278
|
+
.option("--disable-timestamp-conversion [true|false]", "Disable timestamp conversion to UTC for Snowflake warehouses. Only use this if your timestamp values are already in UTC.", parseDisableTimestampConversionOption, false)
|
|
279
|
+
.option("--no-warehouse-credentials", "Create preview without warehouse credentials. Copies credentials from upstream project.")
|
|
280
|
+
.option("-y, --assume-yes", "assume yes to prompts", false)
|
|
281
|
+
.option("--use-batched-deploy", "Use the new batched deploy feature to upload explores in batches", false)
|
|
282
|
+
.option("--batch-size <number>", "Number of explores to deploy in each batch (default: 50)", "50")
|
|
283
|
+
.option("--parallel-batches <number>", "Number of batches to send in parallel (default: 1, use higher values with caution)", "1")
|
|
284
|
+
.action(preview_1.startPreviewHandler);
|
|
285
|
+
commander_1.program
|
|
286
|
+
.command("stop-preview")
|
|
287
|
+
.description("Deletes preview project")
|
|
288
|
+
.option("--name [preview name]", "[required] Name for the preview project to be deleted")
|
|
289
|
+
.option("--verbose", undefined, false)
|
|
290
|
+
.action(preview_1.stopPreviewHandler);
|
|
291
|
+
commander_1.program
|
|
292
|
+
.command('download')
|
|
293
|
+
.description('Downloads charts and dashboards as code')
|
|
294
|
+
.option('--verbose', undefined, false)
|
|
295
|
+
.option('-c, --charts <charts...>', 'specify chart slugs, uuids, or urls to download', [])
|
|
296
|
+
.option('-d, --dashboards <dashboards...>', 'specify dashboard slugs, uuids or urls to download', [])
|
|
297
|
+
.option('-l, --language-map', 'generate a language maps for the downloaded charts and dashboards', false)
|
|
298
|
+
.option('-p, --path <path>', 'specify a custom path to download charts and dashboards', undefined)
|
|
299
|
+
.option('--nested', 'organize downloads in nested folders by project and space (default: flat structure)', false)
|
|
300
|
+
.option('--project <project uuid>', 'specify a project UUID to download', parseProjectArgument, undefined)
|
|
301
|
+
.option('--skip-spaces', 'skip writing space metadata files during download', false)
|
|
302
|
+
.action(download_1.downloadHandler);
|
|
303
|
+
commander_1.program
|
|
304
|
+
.command("upload")
|
|
305
|
+
.description("Uploads charts and dashboards as code")
|
|
306
|
+
.option("--verbose", undefined, false)
|
|
307
|
+
.option("-c, --charts <charts...>", "specify chart slugs to force upload", [])
|
|
308
|
+
.option("-d, --dashboards <dashboards...>", "specify dashboard slugs to force upload", [])
|
|
309
|
+
.option("--force", "Force upload even if local files have not changed, use this when you want to upload files to a new project", false)
|
|
310
|
+
.option("-p, --path <path>", "specify a custom path to upload charts and dashboards from", undefined)
|
|
311
|
+
.option("--project <project uuid>", "specify a project UUID to upload", parseProjectArgument, undefined)
|
|
312
|
+
.option("--skip-space-create", "Skip space creation if it does not exist", false)
|
|
313
|
+
.option("--public", "Create new spaces as public instead of private", false)
|
|
314
|
+
.option("--concurrency <number>", "Number of parallel uploads (default: 1)", "1")
|
|
315
|
+
.option("--include-charts", "Include charts updates when uploading dashboards", false)
|
|
316
|
+
.option("--validate", "Validate charts and dashboards after upload", false)
|
|
317
|
+
.option("--gzip", "Enable gzip compression for request bodies", false)
|
|
318
|
+
.action(download_1.uploadHandler);
|
|
319
|
+
commander_1.program
|
|
320
|
+
.command("deploy")
|
|
321
|
+
.description("Compiles and deploys a Clary project")
|
|
322
|
+
.option("--project-dir <path>", "The directory of the dbt project", env_1.DEFAULT_DBT_PROJECT_DIR)
|
|
323
|
+
.option("--profiles-dir <path>", "The directory of the dbt profiles", env_1.DEFAULT_DBT_PROFILES_DIR)
|
|
324
|
+
.option("--profile <name>", "The name of the profile to use (defaults to profile name in dbt_project.yml)", undefined)
|
|
325
|
+
.option("--target <name>", "target to use in profiles.yml file", undefined)
|
|
326
|
+
.option("--target-path <path>", "The target directory for dbt (overrides DBT_TARGET_PATH and dbt_project.yml)", undefined)
|
|
327
|
+
.option("--vars <vars>")
|
|
328
|
+
.option("--threads <number>")
|
|
329
|
+
.option("--no-version-check")
|
|
330
|
+
.option("-s, --select <models...>", "specify models (accepts dbt selection syntax)")
|
|
331
|
+
.option("-m, --models <models...>", "specify models (accepts dbt selection syntax)")
|
|
332
|
+
.option("--exclude <models...>")
|
|
333
|
+
.option("--selector <selector_name>")
|
|
334
|
+
.option("--state <state>")
|
|
335
|
+
.option("--full-refresh")
|
|
336
|
+
.option("--defer", "dbt property. Resolve unselected nodes by deferring to the manifest within the --state directory.", undefined)
|
|
337
|
+
.option("--no-defer", "dbt property. Do not resolve unselected nodes by deferring to the manifest within the --state directory.", undefined)
|
|
338
|
+
.option("--favor-state", "dbt property. When deferring, prioritize node definitions from the --state directory.", undefined)
|
|
339
|
+
.option("--verbose", undefined, false)
|
|
340
|
+
.option("--create [project_name]", "Create a new project. If a project name is not provided, you'll be prompted for one on creation.", undefined)
|
|
341
|
+
.option("--ignore-errors", "Allows deploy with errors on compile", false)
|
|
342
|
+
.option("--start-of-week <number>", "Specifies the first day of the week (used by week-related date functions). 0 (Monday) to 6 (Sunday)", parseStartOfWeekArgument)
|
|
343
|
+
.option("--skip-dbt-compile", "Skip `dbt compile` and deploy from the existing ./target/manifest.json", false)
|
|
344
|
+
.option("--skip-warehouse-catalog", "Skip fetch warehouse catalog and use types in yml", false)
|
|
345
|
+
.option("--use-dbt-list [true|false]", "Use `dbt list` instead of `dbt compile` to generate dbt manifest.json", parseUseDbtListOption, true)
|
|
346
|
+
.option("--no-warehouse-credentials", "Create project without warehouse credentials. Skips dbt compile + warehouse catalog")
|
|
347
|
+
.option("--organization-credentials <name>", "Use organization warehouse credentials with the specified name (Enterprise Edition feature)")
|
|
348
|
+
.option("--disable-timestamp-conversion [true|false]", "Disable timestamp conversion to UTC for Snowflake warehouses. Only use this if your timestamp values are already in UTC.", parseDisableTimestampConversionOption, false)
|
|
349
|
+
.option("-y, --assume-yes", "assume yes to prompts", false)
|
|
350
|
+
.option("--use-batched-deploy", "Use batched deploy for large projects (sends explores in batches)", false)
|
|
351
|
+
.option("--batch-size <number>", "Number of explores per batch (default: 50)", "50")
|
|
352
|
+
.option("--parallel-batches <number>", "Number of batches to send in parallel (default: 1, use higher values with caution)", "1")
|
|
353
|
+
.option("--gzip", "Enable gzip compression for request bodies", false)
|
|
354
|
+
.action(deploy_1.deployHandler);
|
|
355
|
+
commander_1.program
|
|
356
|
+
.command("refresh")
|
|
357
|
+
.description("Refreshes Clary project with remote repository")
|
|
358
|
+
.addHelpText("after", `
|
|
359
|
+
${styles.bold("Examples:")}
|
|
360
|
+
${styles.title("⚡")}️clary ${styles.bold("refresh")}
|
|
361
|
+
`)
|
|
362
|
+
.option("--verbose", undefined, false)
|
|
363
|
+
.action(refresh_1.refreshHandler);
|
|
364
|
+
commander_1.program
|
|
365
|
+
.command("validate")
|
|
366
|
+
.description("Validates a project")
|
|
367
|
+
.option("--project <project uuid>", "Project UUID to validate, if not provided, the last preview will be used")
|
|
368
|
+
.option("--verbose", undefined, false)
|
|
369
|
+
.option("--project-dir <path>", "The directory of the dbt project", env_1.DEFAULT_DBT_PROJECT_DIR)
|
|
370
|
+
.option("--profiles-dir <path>", "The directory of the dbt profiles", env_1.DEFAULT_DBT_PROFILES_DIR)
|
|
371
|
+
.option("--profile <name>", "The name of the profile to use (defaults to profile name in dbt_project.yml)", undefined)
|
|
372
|
+
.option("--target <name>", "target to use in profiles.yml file", undefined)
|
|
373
|
+
.option("--vars <vars>")
|
|
374
|
+
.option("--threads <number>")
|
|
375
|
+
.option("--no-version-check")
|
|
376
|
+
.option("--preview", "Validate the last preview if available", false)
|
|
377
|
+
.option("-s, --select <models...>", "specify models (accepts dbt selection syntax)")
|
|
378
|
+
.option("-m, --models <models...>", "specify models (accepts dbt selection syntax)")
|
|
379
|
+
.option("--exclude <models...>")
|
|
380
|
+
.option("--selector <selector_name>")
|
|
381
|
+
.option("--state <state>")
|
|
382
|
+
.option("--full-refresh")
|
|
383
|
+
.option("--verbose", undefined, false)
|
|
384
|
+
.option("--skip-dbt-compile", "Skip `dbt compile` and deploy from the existing ./target/manifest.json", false)
|
|
385
|
+
.option("--skip-warehouse-catalog", "Skip fetch warehouse catalog and use types in yml", false)
|
|
386
|
+
.option("--use-dbt-list [true|false]", "Use `dbt list` instead of `dbt compile` to generate dbt manifest.json", parseUseDbtListOption, true)
|
|
387
|
+
.option("--disable-timestamp-conversion [true|false]", "Disable timestamp conversion to UTC for Snowflake warehouses. Only use this if your timestamp values are already in UTC.", parseDisableTimestampConversionOption, false)
|
|
388
|
+
.option("--show-chart-configuration-warnings", "Show chart configuration warnings (e.g., unused dimensions). These are hidden by default.", false)
|
|
389
|
+
.addOption(new commander_1.Option("--only <elems...>", "Specify project elements to validate")
|
|
390
|
+
.choices(Object.values(common_1.ValidationTarget))
|
|
391
|
+
.default(Object.values(common_1.ValidationTarget)))
|
|
392
|
+
.action(validate_1.validateHandler);
|
|
393
|
+
commander_1.program
|
|
394
|
+
.command("generate")
|
|
395
|
+
.description("Generates a new schema.yml file for model")
|
|
396
|
+
.addHelpText("after", `
|
|
397
|
+
${styles.bold("Examples:")}
|
|
398
|
+
${styles.title("⚡")}️clary ${styles.bold("generate")} ${styles.secondary("-- generates .yml file for all dbt models")}
|
|
399
|
+
${styles.title("⚡")}️clary ${styles.bold("generate")} -s mymodel ${styles.secondary("-- generates .yml file for a single dbt model")}
|
|
400
|
+
${styles.title("⚡")}️clary ${styles.bold("generate")} -s model1 model2 ${styles.secondary("-- generates .yml for multiple dbt models")}
|
|
401
|
+
${styles.title("⚡")}️clary ${styles.bold("generate")} -s tag:sales ${styles.secondary("-- generates .yml for all dbt models tagged as sales")}
|
|
402
|
+
${styles.title("⚡")}️clary ${styles.bold("generate")} -s +mymodel ${styles.secondary("-- generates .yml for mymodel and all it's parents")}
|
|
403
|
+
`)
|
|
404
|
+
.option("-s, --select <models...>", "specify models (accepts dbt selection syntax)")
|
|
405
|
+
.option("-e, --exclude <models...>", "specify models (accepts dbt selection syntax)")
|
|
406
|
+
.option("-m, --models <models...>", "specify models (accepts dbt selection syntax)")
|
|
407
|
+
.option("--project-dir <path>", "The directory of the dbt project", env_1.DEFAULT_DBT_PROJECT_DIR)
|
|
408
|
+
.option("--profiles-dir <path>", "The directory of the dbt profiles", env_1.DEFAULT_DBT_PROFILES_DIR)
|
|
409
|
+
.option("--profile <name>", "The name of the profile to use (defaults to profile name in dbt_project.yml)", undefined)
|
|
410
|
+
.option("--target <name>", "target to use in profiles.yml file", undefined)
|
|
411
|
+
.option("--target-path <path>", "The target directory for dbt (overrides DBT_TARGET_PATH and dbt_project.yml)", undefined)
|
|
412
|
+
.option("--vars <vars>")
|
|
413
|
+
.option("-y, --assume-yes", "assume yes to prompts", false)
|
|
414
|
+
.option("--skip-existing", "skip files that already exist", false)
|
|
415
|
+
.option("--exclude-meta", "exclude Clary metadata from the generated .yml", false)
|
|
416
|
+
.option("--preserve-column-case", "preserve original casing of column names in generated schema files", false)
|
|
417
|
+
.option("--verbose", undefined, false)
|
|
418
|
+
.action(generate_1.generateHandler);
|
|
419
|
+
commander_1.program
|
|
420
|
+
.command("rename")
|
|
421
|
+
.description("Rename models and fields on Clary content")
|
|
422
|
+
.option("--verbose", undefined, false)
|
|
423
|
+
.option("-p, --project <project uuid>", "specify a project UUID to rename", parseProjectArgument, undefined)
|
|
424
|
+
.option("-m, --model <model>", "When renaming a field, specify which model the field belongs to", undefined)
|
|
425
|
+
.option("-y, --assume-yes", "assume yes to prompts", false)
|
|
426
|
+
.requiredOption("-t, --type <type>", "model or field", common_1.RenameType.MODEL)
|
|
427
|
+
.requiredOption("--from <from>", "Name to replace from", undefined)
|
|
428
|
+
.requiredOption("--to <to>", "Name to replace to", undefined)
|
|
429
|
+
.option("--dry-run", "Test the rename, no changes will be made", false)
|
|
430
|
+
.option("--list", "List all charts and dashboards that are renamed", false)
|
|
431
|
+
.action(renameHandler_1.renameHandler);
|
|
432
|
+
commander_1.program
|
|
433
|
+
.command("generate-exposures")
|
|
434
|
+
.description("[Experimental command] Generates a .yml file for Clary exposures")
|
|
435
|
+
.addHelpText("after", `
|
|
436
|
+
${styles.bold("Examples:")}
|
|
437
|
+
${styles.title("⚡")}️clary ${styles.bold("generate-exposures")} ${styles.secondary("-- generates .yml file for all clary exposures")}
|
|
438
|
+
`)
|
|
439
|
+
.option("--project-dir <path>", "The directory of the dbt project", env_1.DEFAULT_DBT_PROJECT_DIR)
|
|
440
|
+
.option("--verbose", undefined, false)
|
|
441
|
+
.option("--output <path>", "The path where the output exposures YAML file will be written", undefined)
|
|
442
|
+
.action(generateExposures_1.generateExposuresHandler);
|
|
443
|
+
commander_1.program
|
|
444
|
+
.command("diagnostics")
|
|
445
|
+
.description("Shows diagnostic information about the CLI environment")
|
|
446
|
+
.addHelpText("after", `
|
|
447
|
+
${styles.bold("Examples:")}
|
|
448
|
+
${styles.title("⚡")}️clary ${styles.bold("diagnostics")} ${styles.secondary("-- shows CLI version, Node.js version, and auth status")}
|
|
449
|
+
${styles.title("⚡")}️clary ${styles.bold("diagnostics")} --dbt ${styles.secondary("-- includes dbt debug output")}
|
|
450
|
+
${styles.title("⚡")}️clary ${styles.bold("diagnostics")} --dbt --project-dir ./my-dbt-project ${styles.secondary("-- runs dbt debug with custom project directory")}
|
|
451
|
+
`)
|
|
452
|
+
.option("--dbt", "Include dbt debug information", false)
|
|
453
|
+
.option("--project-dir <path>", "The directory of the dbt project (used with --dbt flag)", env_1.DEFAULT_DBT_PROJECT_DIR)
|
|
454
|
+
.option("--profiles-dir <path>", "The directory of the dbt profiles (used with --dbt flag)", env_1.DEFAULT_DBT_PROFILES_DIR)
|
|
455
|
+
.option("--defer", "dbt property. Resolve unselected nodes by deferring to the manifest within the --state directory.", undefined)
|
|
456
|
+
.option("--no-defer", "dbt property. Do not resolve unselected nodes by deferring to the manifest within the --state directory.", undefined)
|
|
457
|
+
.action(diagnostics_1.diagnosticsHandler);
|
|
458
|
+
commander_1.program
|
|
459
|
+
.command("lint")
|
|
460
|
+
.description("Validates Clary Code files (models, charts, dashboards) against JSON schemas")
|
|
461
|
+
.addHelpText("after", `
|
|
462
|
+
${styles.bold("Examples:")}
|
|
463
|
+
${styles.title("⚡")}️clary ${styles.bold("lint")} ${styles.secondary("-- validates all Clary Code files in current directory")}
|
|
464
|
+
${styles.title("⚡")}️clary ${styles.bold("lint")} --path ./chart.yml ${styles.secondary("-- validates a single chart file")}
|
|
465
|
+
${styles.title("⚡")}️clary ${styles.bold("lint")} --path ./clary ${styles.secondary("-- validates files in a specific directory")}
|
|
466
|
+
${styles.title("⚡")}️clary ${styles.bold("lint")} --verbose ${styles.secondary("-- shows detailed validation output")}
|
|
467
|
+
${styles.title("⚡")}️clary ${styles.bold("lint")} --format json ${styles.secondary("-- outputs results in SARIF JSON format")}
|
|
468
|
+
`)
|
|
469
|
+
.option("-p, --path <path>", "Path to a file or directory to lint (defaults to current directory)", undefined)
|
|
470
|
+
.option("--verbose", "Show detailed output", false)
|
|
471
|
+
.option("-f, --format <format>", "Output format: cli (default) or json (SARIF format)", "cli")
|
|
472
|
+
.action(lint_1.lintHandler);
|
|
473
|
+
commander_1.program
|
|
474
|
+
.command("sql")
|
|
475
|
+
.description("Run raw SQL query against the warehouse using project credentials")
|
|
476
|
+
.argument("<query>", "SQL query to execute")
|
|
477
|
+
.requiredOption("-o, --output <file>", "Output file path for CSV results")
|
|
478
|
+
.option("--limit <number>", "Maximum rows to return from query", parseIntArgument)
|
|
479
|
+
.option("--page-size <number>", "Number of rows per page (default: 500, max: 5000)", parseIntArgument)
|
|
480
|
+
.option("--verbose", "Show detailed output", false)
|
|
481
|
+
.action(sql_1.sqlHandler);
|
|
482
|
+
commander_1.program
|
|
483
|
+
.command("run-chart")
|
|
484
|
+
.description("Execute a chart YAML to verify the query runs")
|
|
485
|
+
.requiredOption("-p, --path <path>", "Path to chart YAML file")
|
|
486
|
+
.option("-o, --output <file>", "Output file path for CSV results")
|
|
487
|
+
.option("-l, --limit <number>", "Row limit for query", parseIntArgument)
|
|
488
|
+
.option("--page-size <number>", "Number of rows per page (default: 500)", parseIntArgument)
|
|
489
|
+
.option("--verbose", "Show detailed output", false)
|
|
490
|
+
.action(runChart_1.runChartHandler);
|
|
491
|
+
commander_1.program
|
|
492
|
+
.command("set-warehouse")
|
|
493
|
+
.description("Update a project's warehouse connection from dbt profiles.yml. Use --assume-yes for non-interactive/CI usage. For organization-managed credentials, use the Clary UI.")
|
|
494
|
+
.option("--project-dir <path>", "The directory of the dbt project", env_1.DEFAULT_DBT_PROJECT_DIR)
|
|
495
|
+
.option("--profiles-dir <path>", "The directory of the dbt profiles", env_1.DEFAULT_DBT_PROFILES_DIR)
|
|
496
|
+
.option("--profile <name>", "The name of the profile to use (defaults to profile name in dbt_project.yml)", undefined)
|
|
497
|
+
.option("--target <name>", "target to use in profiles.yml file", undefined)
|
|
498
|
+
.option("--target-path <path>", "The target directory for dbt (overrides DBT_TARGET_PATH and dbt_project.yml)", undefined)
|
|
499
|
+
.option("--project <uuid>", "Clary project UUID to update (defaults to currently selected project)", undefined)
|
|
500
|
+
.option("--start-of-week <number>", "Specifies the first day of the week (used by week-related date functions). 0 (Monday) to 6 (Sunday)", parseStartOfWeekArgument)
|
|
501
|
+
.option("-y, --assume-yes", "assume yes to prompts", false)
|
|
502
|
+
.option("--verbose", "Show detailed output", false)
|
|
503
|
+
.action(setWarehouse_1.setWarehouseHandler);
|
|
504
|
+
commander_1.program
|
|
505
|
+
.command("export-chart-image")
|
|
506
|
+
.description("Export a deployed chart as a PNG image. The chart must already exist on the server.")
|
|
507
|
+
.argument("<chart>", "Chart slug")
|
|
508
|
+
.requiredOption("-o, --output <file>", "Output file path for the PNG image")
|
|
509
|
+
.option("--verbose", "Show detailed output", false)
|
|
510
|
+
.action(exportChartImage_1.exportChartImageHandler);
|
|
511
|
+
commander_1.program
|
|
512
|
+
.command('install-skills')
|
|
513
|
+
.description('Installs clary skills for AI coding assistants (Claude, Cursor, Codex)')
|
|
514
|
+
.addHelpText('after', `
|
|
515
|
+
${styles.bold('Examples:')}
|
|
516
|
+
${styles.title('⚡')}️clary ${styles.bold('install-skills')} ${styles.secondary('-- installs skills for Claude at git root (default)')}
|
|
517
|
+
${styles.title('⚡')}️clary ${styles.bold('install-skills')} --agent cursor ${styles.secondary('-- installs skills for Cursor')}
|
|
518
|
+
${styles.title('⚡')}️clary ${styles.bold('install-skills')} --global ${styles.secondary('-- installs skills globally to ~/.claude/skills/')}
|
|
519
|
+
${styles.title('⚡')}️clary ${styles.bold('install-skills')} --agent codex --global ${styles.secondary('-- installs skills globally for Codex')}
|
|
520
|
+
${styles.title('⚡')}️clary ${styles.bold('install-skills')} --path ./my-project ${styles.secondary('-- installs skills to a specific path')}
|
|
521
|
+
${styles.title('⚡')}️clary ${styles.bold('install-skills')} --source my-org/clary-fork ${styles.secondary('-- installs skills from a custom GitHub repo')}
|
|
522
|
+
|
|
523
|
+
${styles.bold("Installation paths:")}
|
|
524
|
+
${styles.secondary("Project-level (default):")}
|
|
525
|
+
.claude/skills/ (Claude)
|
|
526
|
+
.cursor/skills/ (Cursor)
|
|
527
|
+
.codex/skills/ (Codex)
|
|
528
|
+
|
|
529
|
+
${styles.secondary("Global (--global):")}
|
|
530
|
+
~/.claude/skills/ (Claude)
|
|
531
|
+
~/.cursor/skills/ (Cursor)
|
|
532
|
+
~/.codex/skills/ (Codex)
|
|
533
|
+
`)
|
|
534
|
+
.option('--verbose', 'Show detailed output', false)
|
|
535
|
+
.addOption(new commander_1.Option('--agent <agent>', 'Target agent for skill installation')
|
|
536
|
+
.choices(['claude', 'cursor', 'codex'])
|
|
537
|
+
.default('claude'))
|
|
538
|
+
.option('--global', 'Install skills globally to home directory instead of project', false)
|
|
539
|
+
.option('--path <path>', 'Override the install path (skills directory will be created inside)', undefined)
|
|
540
|
+
.option('--source <org/repo>', 'Override the GitHub repository to download skills from (default: clary/clary)', undefined)
|
|
541
|
+
.action(installSkills_1.installSkillsHandler);
|
|
542
|
+
const errorHandler = (err) => {
|
|
543
|
+
// Use error message with fallback for safety
|
|
544
|
+
const errorMessage = (0, common_1.getErrorMessage)(err) || "An unexpected error occurred";
|
|
545
|
+
console.error(styles.error(errorMessage));
|
|
546
|
+
if (err.name === 'ForbiddenError' || err instanceof common_1.ForbiddenError) {
|
|
547
|
+
// For permission errors, show clear message with fallback
|
|
548
|
+
const permissionMessage = err.message || "You don't have permission to perform this action";
|
|
549
|
+
if (permissionMessage !== errorMessage) {
|
|
550
|
+
console.error(styles.error(permissionMessage));
|
|
551
|
+
}
|
|
552
|
+
console.error(`\n💡 Contact your Clary administrator to request project creation access or if you believe this is incorrect.\n`);
|
|
553
|
+
}
|
|
554
|
+
else if (err.name === 'AuthorizationError') {
|
|
555
|
+
console.error(`Looks like you did not authenticate or the personal access token expired.\n\n👀 See https://docs.getclary.com/guides/cli/cli-authentication for help and examples`);
|
|
556
|
+
}
|
|
557
|
+
else if (!(err instanceof common_1.LightdashError)) {
|
|
558
|
+
console.error(err);
|
|
559
|
+
if (err.stack) {
|
|
560
|
+
console.error(err.stack);
|
|
561
|
+
}
|
|
562
|
+
console.error('\nReport this issue with 1-click:\n');
|
|
563
|
+
console.error(` 🐛 https://github.com/claryai/clary-issues/issues/new?assignees=&labels=🐛+bug&template=bug_report.md&title=${encodeURIComponent(err.message)}`);
|
|
564
|
+
}
|
|
565
|
+
if (err.message.includes('ENOENT: dbt')) {
|
|
566
|
+
console.error(styles.error(`\n You must have dbt installed to use this command. See https://docs.getdbt.com/docs/core/installation for installation instructions`));
|
|
567
|
+
}
|
|
568
|
+
const diagnosticsHint = (0, error_1.getDiagnosticsHint)();
|
|
569
|
+
if (diagnosticsHint) {
|
|
570
|
+
console.error(diagnosticsHint);
|
|
571
|
+
}
|
|
572
|
+
if (env_1.NODE_VERSION.major !== env_1.OPTIMIZED_NODE_VERSION) {
|
|
573
|
+
console.warn(styles.warning(`⚠️ You are using Node.js version ${process.version}. Clary CLI is optimized for v${env_1.OPTIMIZED_NODE_VERSION} so you might experience issues.`));
|
|
574
|
+
}
|
|
575
|
+
process.exit(1);
|
|
576
|
+
};
|
|
577
|
+
const successHandler = () => {
|
|
578
|
+
console.error(`Done 🕶`);
|
|
579
|
+
process.exit(0);
|
|
580
|
+
};
|
|
581
|
+
commander_1.program.parseAsync().then(successHandler).catch(errorHandler);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loader for Lightdash YAML model files
|
|
3
|
+
*/
|
|
4
|
+
import { type LightdashModel } from '@lightdash/common';
|
|
5
|
+
/**
|
|
6
|
+
* Load a single Lightdash YAML model file
|
|
7
|
+
*/
|
|
8
|
+
export declare function loadLightdashModel(filePath: string): Promise<LightdashModel>;
|
|
9
|
+
/**
|
|
10
|
+
* Find all Lightdash YAML model files in a directory
|
|
11
|
+
* Looks for files in models/ or lightdash/models/ directory that contain `type: model`
|
|
12
|
+
*
|
|
13
|
+
* This explicitly checks the YAML content for `type: model` (or versioned variants)
|
|
14
|
+
* to avoid false positives from other YAML files (e.g., content-as-code spaces).
|
|
15
|
+
*/
|
|
16
|
+
export declare function findLightdashModelFiles(projectDir: string): Promise<string[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Load all Lightdash YAML models from a project directory
|
|
19
|
+
*/
|
|
20
|
+
export declare function loadLightdashModels(projectDir: string): Promise<LightdashModel[]>;
|
|
21
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/lightdash/loader.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAMpE;;GAEG;AACH,wBAAsB,kBAAkB,CACpC,QAAQ,EAAE,MAAM,GACjB,OAAO,CAAC,cAAc,CAAC,CA6BzB;AAuBD;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CACzC,UAAU,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,EAAE,CAAC,CAqDnB;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACrC,UAAU,EAAE,MAAM,GACnB,OAAO,CAAC,cAAc,EAAE,CAAC,CAwB3B"}
|