这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions api/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion cli/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ts_library(
name = "cli",
srcs = glob(["**/*.ts"]),
deps = [
"//api",
"//cli/api",
"//core",
"//protos:ts",
"//sqlx:format",
Expand Down
6 changes: 3 additions & 3 deletions api/BUILD → cli/api/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ ts_library(
exclude = ["utils/**/*.*"],
),
deps = [
"//api/utils",
"//cli/api/utils",
"//common/errors",
"//common/flags",
"//common/promises",
"//common/protos",
"//common/strings",
"//core",
"//protos:ts",
"//sandbox/vm:compile_loader",
"//cli/vm:compile_loader",
"//sqlx",
"//sandbox/vm:vm",
"//cli/vm:vm",
"@npm//@google-cloud/bigquery",
"@npm//@types/glob",
"@npm//@types/js-beautify",
Expand Down
8 changes: 4 additions & 4 deletions api/commands/build.ts → cli/api/commands/build.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { prune } from "df/api/commands/prune";
import { state } from "df/api/commands/state";
import * as dbadapters from "df/api/dbadapters";
import { ExecutionSql } from "df/api/dbadapters/execution_sql";
import { prune } from "df/cli/api/commands/prune";
import { state } from "df/cli/api/commands/state";
import * as dbadapters from "df/cli/api/dbadapters";
import { ExecutionSql } from "df/cli/api/dbadapters/execution_sql";
import { StringifiedMap, StringifiedSet } from "df/common/strings/stringifier";
import { targetStringifier } from "df/core/targets";
import * as utils from "df/core/utils";
Expand Down
4 changes: 2 additions & 2 deletions api/commands/compile.ts → cli/api/commands/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as semver from "semver";

import { ChildProcess, fork } from "child_process";
import deepmerge from "deepmerge";
import { validWarehouses } from "df/api/dbadapters";
import { validWarehouses } from "df/cli/api/dbadapters";
import { coerceAsError, ErrorWithCause } from "df/common/errors/errors";
import { decode64 } from "df/common/protos";
import { setOrValidateTableEnumType } from "df/core/utils";
Expand Down Expand Up @@ -77,7 +77,7 @@ export class CompileChildProcess {
const workerBundlePath = require.resolve("./worker_bundle");
return workerBundlePath;
} catch (e) {
return require.resolve("../../sandbox/vm/compile_loader");
return require.resolve("../../vm/compile_loader");
}
};
const forkScript = findForkScript();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from "fs";

import * as dbadapters from "df/api/dbadapters";
import * as dbadapters from "df/cli/api/dbadapters";
import { dataform } from "df/protos/ts";

export const CREDENTIALS_FILENAME = ".df-credentials.json";
Expand Down
6 changes: 3 additions & 3 deletions api/commands/init.ts → cli/api/commands/init.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as fs from "fs";
import * as path from "path";

import { CREDENTIALS_FILENAME } from "df/api/commands/credentials";
import { install } from "df/api/commands/install";
import { prettyJsonStringify } from "df/api/utils";
import { CREDENTIALS_FILENAME } from "df/cli/api/commands/credentials";
import { install } from "df/cli/api/commands/install";
import { prettyJsonStringify } from "df/cli/api/utils";
import { version } from "df/core/version";
import { dataform } from "df/protos/ts";

Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions api/commands/query.ts → cli/api/commands/query.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as dbadapters from "df/api/dbadapters";
import { CancellablePromise } from "df/api/utils/cancellable_promise";
import * as dbadapters from "df/cli/api/dbadapters";
import { CancellablePromise } from "df/cli/api/utils/cancellable_promise";
import { dataform } from "df/protos/ts";

export function run(
Expand Down
4 changes: 2 additions & 2 deletions api/commands/run.ts → cli/api/commands/run.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import EventEmitter from "events";
import Long from "long";

import * as dbadapters from "df/api/dbadapters";
import { IBigQueryExecutionOptions } from "df/api/dbadapters/bigquery";
import * as dbadapters from "df/cli/api/dbadapters";
import { IBigQueryExecutionOptions } from "df/cli/api/dbadapters/bigquery";
import { Flags } from "df/common/flags";
import { retry } from "df/common/promises";
import { deepClone, equals } from "df/common/protos";
Expand Down
2 changes: 1 addition & 1 deletion api/commands/state.ts → cli/api/commands/state.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IDbAdapter } from "df/api/dbadapters";
import { IDbAdapter } from "df/cli/api/dbadapters";
import { dataform } from "df/protos/ts";

export async function state(
Expand Down
2 changes: 1 addition & 1 deletion api/commands/table.ts → cli/api/commands/table.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as dbadapters from "df/api/dbadapters";
import * as dbadapters from "df/cli/api/dbadapters";
import { dataform } from "df/protos/ts";

export async function list(dbadapter: dbadapters.IDbAdapter): Promise<dataform.ITarget[]> {
Expand Down
2 changes: 1 addition & 1 deletion api/commands/test.ts → cli/api/commands/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as dbadapters from "df/api/dbadapters";
import * as dbadapters from "df/cli/api/dbadapters";
import { dataform } from "df/protos/ts";

export async function test(
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions api/dbadapters/bigquery.ts → cli/api/dbadapters/bigquery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
TableField,
TableMetadata
} from "@google-cloud/bigquery";
import { Credentials } from "df/api/commands/credentials";
import { collectEvaluationQueries, QueryOrAction } from "df/api/dbadapters/execution_sql";
import { IDbAdapter, IDbClient, IExecutionResult, OnCancel } from "df/api/dbadapters/index";
import { parseBigqueryEvalError } from "df/api/utils/error_parsing";
import { LimitedResultSet } from "df/api/utils/results";
import { Credentials } from "df/cli/api/commands/credentials";
import { collectEvaluationQueries, QueryOrAction } from "df/cli/api/dbadapters/execution_sql";
import { IDbAdapter, IDbClient, IExecutionResult, OnCancel } from "df/cli/api/dbadapters/index";
import { parseBigqueryEvalError } from "df/cli/api/utils/error_parsing";
import { LimitedResultSet } from "df/cli/api/utils/results";
import { coerceAsError } from "df/common/errors/errors";
import { retry } from "df/common/promises";
import { dataform } from "df/protos/ts";
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions api/dbadapters/index.ts → cli/api/dbadapters/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Credentials } from "df/api/commands/credentials";
import { BigQueryDbAdapter } from "df/api/dbadapters/bigquery";
import { QueryOrAction } from "df/api/dbadapters/execution_sql";
import { Credentials } from "df/cli/api/commands/credentials";
import { BigQueryDbAdapter } from "df/cli/api/dbadapters/bigquery";
import { QueryOrAction } from "df/cli/api/dbadapters/execution_sql";
import { dataform } from "df/protos/ts";

export type OnCancel = (handleCancel: () => void) => void;
Expand Down
File renamed without changes.
25 changes: 25 additions & 0 deletions cli/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { build, Builder } from "df/cli/api/commands/build";
import { compile } from "df/cli/api/commands/compile";
import * as credentials from "df/cli/api/commands/credentials";
import { init } from "df/cli/api/commands/init";
import { install } from "df/cli/api/commands/install";
import { prune } from "df/cli/api/commands/prune";
import * as query from "df/cli/api/commands/query";
import { run, Runner } from "df/cli/api/commands/run";
import * as table from "df/cli/api/commands/table";
import { test } from "df/cli/api/commands/test";

export {
init,
install,
credentials,
compile,
test,
build,
run,
query,
table,
Runner,
Builder,
prune
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 14 additions & 9 deletions cli/console.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { IInitResult } from "df/api/commands/init";
import { prettyJsonStringify } from "df/api/utils";
import { IInitResult } from "df/cli/api/commands/init";
import { prettyJsonStringify } from "df/cli/api/utils";
import { setOrValidateTableEnumType, tableTypeEnumToString } from "df/core/utils";
import { dataform } from "df/protos/ts";
import * as readlineSync from "readline-sync";

// Support disabling colors in CLI output by using informal standard from https://no-color.org/
// NO_COLOR=1, NO_COLOR=true, NO_COLOR=yes
const noColor = process.env.NO_COLOR && ["1", "true", "yes"].includes(process.env.NO_COLOR.toLowerCase());
const noColor =
process.env.NO_COLOR && ["1", "true", "yes"].includes(process.env.NO_COLOR.toLowerCase());

const ansiColorCodes = Object.freeze({
red: 91,
green: 32,
yellow: 93,
cyan: 36
})
red: 91,
green: 32,
yellow: 93,
cyan: 36
});

function output(text: string, ansiColorCode: number): string {
if (noColor) {
Expand Down Expand Up @@ -134,7 +135,11 @@ export function printCompiledGraph(graph: dataform.ICompiledGraph, verbose: bool
writeStdOut(`${graph.tables.length} dataset(s):`);
graph.tables.forEach(compiledTable => {
writeStdOut(
`${datasetString(compiledTable.target, tableTypeEnumToString(compiledTable.enumType), compiledTable.disabled)}`,
`${datasetString(
compiledTable.target,
tableTypeEnumToString(compiledTable.enumType),
compiledTable.disabled
)}`,
1
);
});
Expand Down
8 changes: 4 additions & 4 deletions cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import * as path from "path";
import yargs from "yargs";

import * as chokidar from "chokidar";
import { build, compile, credentials, init, install, run, table, test } from "df/api";
import { CREDENTIALS_FILENAME } from "df/api/commands/credentials";
import * as dbadapters from "df/api/dbadapters";
import { prettyJsonStringify } from "df/api/utils";
import { trackError, trackOption } from "df/cli/analytics";
import { build, compile, credentials, init, install, run, table, test } from "df/cli/api";
import { CREDENTIALS_FILENAME } from "df/cli/api/commands/credentials";
import * as dbadapters from "df/cli/api/dbadapters";
import { prettyJsonStringify } from "df/cli/api/utils";
import {
print,
printCompiledGraph,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion sandbox/vm/compile.ts → cli/vm/compile.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as path from "path";
import { CompilerFunction, NodeVM } from "vm2";

import { createCoreExecutionRequest, createGenIndexConfig } from "df/cli/vm/create_config";
import { dataform } from "df/protos/ts";
import { createCoreExecutionRequest, createGenIndexConfig } from "df/sandbox/vm/create_config";

function missingValidCorePackageError() {
return new Error(
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions packages/@dataform/cli/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ ts_library(
name = "cli",
srcs = glob(["*.ts"]),
deps = [
"//api",
"//cli",
"//sandbox/vm",
"//cli/vm:compile_loader",
],
)

Expand Down
2 changes: 1 addition & 1 deletion packages/@dataform/cli/worker.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import { listenForCompileRequest } from "df/sandbox/vm/compile";
import { listenForCompileRequest } from "df/cli/vm/compile";
listenForCompileRequest();
4 changes: 2 additions & 2 deletions tests/api/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ ts_test_suite(
"//examples/never_finishes_compiling:node_modules",
],
deps = [
"//api",
"//api/utils",
"//cli/api",
"//cli/api/utils",
"//common/promises",
"//common/strings",
"//core",
Expand Down
6 changes: 3 additions & 3 deletions tests/api/api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { assert, config, expect } from "chai";
import Long from "long";
import { anyString, anything, instance, mock, verify, when } from "ts-mockito";

import { Builder, credentials, prune, Runner } from "df/api";
import { IDbAdapter } from "df/api/dbadapters";
import { BigQueryDbAdapter } from "df/api/dbadapters/bigquery";
import { Builder, credentials, prune, Runner } from "df/cli/api";
import { IDbAdapter } from "df/cli/api/dbadapters";
import { BigQueryDbAdapter } from "df/cli/api/dbadapters/bigquery";
import { sleep, sleepUntil } from "df/common/promises";
import { targetAsReadableString, targetsAreEqual } from "df/core/targets";
import { dataform } from "df/protos/ts";
Expand Down
2 changes: 1 addition & 1 deletion tests/api/examples.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { fail } from "assert";
import { expect } from "chai";
import * as path from "path";

import { Builder, compile } from "df/api";
import { Builder, compile } from "df/cli/api";
import { JSONObjectStringifier, StringifiedSet } from "df/common/strings/stringifier";
import { targetAsReadableString } from "df/core/targets";
import { dataform } from "df/protos/ts";
Expand Down
2 changes: 1 addition & 1 deletion tests/api/utils/cancellable_promise.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from "chai";

import { CancellablePromise } from "df/api/utils/cancellable_promise";
import { CancellablePromise } from "df/cli/api/utils/cancellable_promise";
import { suite, test } from "df/testing";

suite("cancellable_promise", () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/api/utils/error_parsing.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from "chai";

import { parseBigqueryEvalError } from "df/api/utils/error_parsing";
import { parseBigqueryEvalError } from "df/cli/api/utils/error_parsing";
import { suite, test } from "df/testing";

suite("error_parsing", () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/api/validate.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from "chai";

import { checkDataformJsonValidity } from "df/api/commands/compile";
import { checkDataformJsonValidity } from "df/cli/api/commands/compile";
import { suite, test } from "df/testing";

suite("@dataform/api/validate", () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ ts_test_suite(
"//tests/integration/bigquery_project:node_modules",
],
deps = [
"//api",
"//api/utils",
"//cli/api",
"//cli/api/utils",
"//common/promises",
"//core",
"//protos:ts",
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/bigquery.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { expect } from "chai";
import Long from "long";

import * as dfapi from "df/api";
import * as dbadapters from "df/api/dbadapters";
import { BigQueryDbAdapter } from "df/api/dbadapters/bigquery";
import { ExecutionSql } from "df/api/dbadapters/execution_sql";
import * as dfapi from "df/cli/api";
import * as dbadapters from "df/cli/api/dbadapters";
import { BigQueryDbAdapter } from "df/cli/api/dbadapters/bigquery";
import { ExecutionSql } from "df/cli/api/dbadapters/execution_sql";
import { targetAsReadableString } from "df/core/targets";
import { dataform } from "df/protos/ts";
import { suite, test } from "df/testing";
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect } from "chai";

import * as dfapi from "df/api";
import * as dbadapters from "df/api/dbadapters";
import { ExecutionSql } from "df/api/dbadapters/execution_sql";
import * as dfapi from "df/cli/api";
import * as dbadapters from "df/cli/api/dbadapters";
import { ExecutionSql } from "df/cli/api/dbadapters/execution_sql";
import { dataform } from "df/protos/ts";

export function keyBy<V>(values: V[], keyFn: (value: V) => string): { [key: string]: V } {
Expand Down
2 changes: 1 addition & 1 deletion vscode/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ts_library(
name = "vscode",
srcs = glob(["**/*.ts"]),
deps = [
"//api",
"//cli/api",
"//protos:ts",
"@npm//@types/node",
"@npm//@types/vscode",
Expand Down