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