@sqlanvil/cli 1.16.0 → 1.17.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.
Files changed (2) hide show
  1. package/bundle.js +53 -11
  2. package/package.json +1 -1
package/bundle.js CHANGED
@@ -48751,7 +48751,7 @@ function collectEvaluationQueries(queryOrAction, concatenate, queryModifier = (q
48751
48751
  .filter(validationQuery => !!validationQuery.query);
48752
48752
  }
48753
48753
 
48754
- const version = "1.16.0";
48754
+ const version = "1.17.0";
48755
48755
  const dataformVersion = "3.0.61";
48756
48756
 
48757
48757
  async function build(compiledGraph, runConfig, dbadapter) {
@@ -53463,6 +53463,13 @@ const fullRefreshOption = option("full-refresh", {
53463
53463
  type: "boolean",
53464
53464
  default: false
53465
53465
  });
53466
+ const graphFileOption = option("graph", {
53467
+ describe: "Path to a stored compiled graph (the JSON emitted by `compile --json`). Runs it directly, " +
53468
+ "without compiling the project — what executes is exactly what was compiled, including any " +
53469
+ "environment overrides baked in at compile time.",
53470
+ type: "string",
53471
+ coerce: (rawPath) => (rawPath ? actuallyResolve(rawPath) : rawPath)
53472
+ });
53466
53473
  const actionsOption = option("actions", {
53467
53474
  describe: "A list of action names or patterns to run. Can include '*' wildcards.",
53468
53475
  type: "array",
@@ -54116,6 +54123,7 @@ function runCli() {
54116
54123
  actionsOption,
54117
54124
  credentialsOption,
54118
54125
  fullRefreshOption,
54126
+ graphFileOption,
54119
54127
  includeDepsOption,
54120
54128
  includeDependentsOption,
54121
54129
  credentialsOption,
@@ -54132,23 +54140,57 @@ function runCli() {
54132
54140
  `--${dryRunOptionName} option is enabled`);
54133
54141
  return;
54134
54142
  }
54135
- if (!argv[jsonOutputOption.name]) {
54136
- print("Compiling...\n");
54143
+ const graphPath = argv[graphFileOption.name];
54144
+ let compiledGraph;
54145
+ if (graphPath) {
54146
+ if (argv[ProjectConfigOptions.environment.name]) {
54147
+ printError(`--${graphFileOption.name} runs a frozen graph: its environment overrides were baked ` +
54148
+ `in at compile time. Compile with --environment instead, and pass --credentials ` +
54149
+ `explicitly for this run.`);
54150
+ return 1;
54151
+ }
54152
+ assertPathExists(graphPath);
54153
+ try {
54154
+ compiledGraph = sqlanvil.CompiledGraph.fromObject(JSON.parse(fs__namespace$1.readFileSync(graphPath, "utf8")));
54155
+ }
54156
+ catch (e) {
54157
+ printError(`Failed to load compiled graph from ${graphPath}: ${e.message}`);
54158
+ return 1;
54159
+ }
54160
+ const graphCore = compiledGraph.sqlanvilCoreVersion;
54161
+ const majorMinor = (v) => v.split(".").slice(0, 2).join(".");
54162
+ if (graphCore && majorMinor(graphCore) !== majorMinor(version)) {
54163
+ print(`WARNING: graph was compiled by core ${graphCore}; this CLI is ${version}. ` +
54164
+ `Recompile the graph if the run misbehaves.\n`);
54165
+ }
54166
+ if (!argv[jsonOutputOption.name]) {
54167
+ printSuccess(`Loaded compiled graph (core ${graphCore || "unknown"}) from ${graphPath}\n`);
54168
+ }
54169
+ }
54170
+ else {
54171
+ if (!argv[jsonOutputOption.name]) {
54172
+ print("Compiling...\n");
54173
+ }
54174
+ compiledGraph = await compile({
54175
+ projectDir: argv[projectDirOption.name],
54176
+ projectConfigOverride: projectConfigOverrideWithEnvironment(argv[projectDirOption.name], argv),
54177
+ timeoutMillis: argv[timeoutOption.name] || undefined
54178
+ });
54179
+ if (!argv[jsonOutputOption.name] && !compiledGraphHasErrors(compiledGraph)) {
54180
+ printSuccess("Compiled successfully.\n");
54181
+ }
54137
54182
  }
54138
- const compiledGraph = await compile({
54139
- projectDir: argv[projectDirOption.name],
54140
- projectConfigOverride: projectConfigOverrideWithEnvironment(argv[projectDirOption.name], argv),
54141
- timeoutMillis: argv[timeoutOption.name] || undefined
54142
- });
54143
54183
  if (compiledGraphHasErrors(compiledGraph)) {
54144
54184
  printCompiledGraphErrors(compiledGraph.graphErrors, argv[quietCompileOption.name]);
54145
54185
  return 1;
54146
54186
  }
54147
- if (!argv[jsonOutputOption.name]) {
54148
- printSuccess("Compiled successfully.\n");
54149
- }
54150
54187
  const warehouse = compiledGraph.projectConfig.warehouse || "bigquery";
54151
54188
  if (argv[dryRunOptionName] && warehouse.toLowerCase() !== "bigquery") {
54189
+ if (graphPath) {
54190
+ printError(`--${dryRunOptionName} on ${warehouse} validates by recompiling the project source, ` +
54191
+ `which --${graphFileOption.name} bypasses. Run \`sqlanvil validate\` on the project instead.`);
54192
+ return 1;
54193
+ }
54152
54194
  return runValidate(argv);
54153
54195
  }
54154
54196
  const readCredentials = read(credentialsPathWithEnvironment(argv[projectDirOption.name], argv), warehouse);
package/package.json CHANGED
@@ -64,7 +64,7 @@
64
64
  "bin": {
65
65
  "sqlanvil": "bundle.js"
66
66
  },
67
- "version": "1.16.0",
67
+ "version": "1.17.0",
68
68
  "name": "@sqlanvil/cli",
69
69
  "description": "sqlanvil command line interface.",
70
70
  "main": "bundle.js"