@lightdash/cli 0.1456.1 → 0.1457.0

Sign up to get free protection for your applications and to get access to all the features.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Telescope Technologies Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,4 +1,4 @@
1
- import { DbtDoc, DbtManifest, DbtModelNode } from '@lightdash/common';
1
+ import { DbtDoc, DbtModelNode } from '@lightdash/common';
2
2
  import { WarehouseClient, WarehouseTableSchema } from '@lightdash/warehouses';
3
3
  import { YamlSchema } from './schema';
4
4
  type CompiledModel = {
@@ -29,7 +29,6 @@ export declare const findAndUpdateModelYaml: ({ model, table, docs, includeMeta,
29
29
  updatedYml: YamlSchema;
30
30
  outputFilePath: string;
31
31
  }>;
32
- export declare const getModelsFromManifest: (manifest: DbtManifest) => DbtModelNode[];
33
32
  export declare const getCompiledModels: (models: DbtModelNode[], args: {
34
33
  select: string[] | undefined;
35
34
  exclude: string[] | undefined;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCompiledModels = exports.getModelsFromManifest = exports.findAndUpdateModelYaml = exports.isDocBlock = exports.getWarehouseTableForModel = void 0;
3
+ exports.getCompiledModels = exports.findAndUpdateModelYaml = exports.isDocBlock = exports.getWarehouseTableForModel = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const common_1 = require("@lightdash/common");
6
6
  const execa_1 = tslib_1.__importDefault(require("execa"));
@@ -191,19 +191,6 @@ const findAndUpdateModelYaml = async ({ model, table, docs, includeMeta, project
191
191
  };
192
192
  };
193
193
  exports.findAndUpdateModelYaml = findAndUpdateModelYaml;
194
- const getModelsFromManifest = (manifest) => {
195
- const models = Object.values(manifest.nodes).filter((node) => node.resource_type === 'model' &&
196
- node.config?.materialized !== 'ephemeral');
197
- if (!(0, common_1.isSupportedDbtAdapter)(manifest.metadata)) {
198
- throw new common_1.ParseError(`dbt adapter not supported. Lightdash does not support adapter ${manifest.metadata.adapter_type}`, {});
199
- }
200
- const adapterType = manifest.metadata.adapter_type;
201
- return models
202
- .filter((model) => model.config?.materialized &&
203
- model.config.materialized !== 'ephemeral')
204
- .map((model) => (0, common_1.normaliseModelDatabase)(model, adapterType));
205
- };
206
- exports.getModelsFromManifest = getModelsFromManifest;
207
194
  const getCompiledModels = async (models, args) => {
208
195
  let allModelIds = models.map((model) => model.unique_id);
209
196
  if (args.select || args.exclude) {
@@ -8,7 +8,6 @@ const uuid_1 = require("uuid");
8
8
  const analytics_1 = require("../analytics/analytics");
9
9
  const context_1 = require("../dbt/context");
10
10
  const manifest_1 = require("../dbt/manifest");
11
- const models_1 = require("../dbt/models");
12
11
  const validation_1 = require("../dbt/validation");
13
12
  const globalState_1 = tslib_1.__importDefault(require("../globalState"));
14
13
  const styles = tslib_1.__importStar(require("../styles"));
@@ -42,8 +41,8 @@ const compile = async (options) => {
42
41
  const compiledModelIds = await (0, compile_1.maybeCompileModelsAndJoins)({ targetDir: context.targetDir }, options);
43
42
  const manifest = await (0, manifest_1.loadManifest)({ targetDir: context.targetDir });
44
43
  const manifestVersion = (0, common_1.getDbtManifestVersion)(manifest);
45
- const manifestModels = (0, models_1.getModelsFromManifest)(manifest);
46
- const compiledModels = (0, compile_1.getCompiledModels)(manifestModels, compiledModelIds);
44
+ const manifestModels = (0, common_1.getModelsFromManifest)(manifest);
45
+ const compiledModels = (0, common_1.getCompiledModels)(manifestModels, compiledModelIds);
47
46
  const adapterType = manifest.metadata.adapter_type;
48
47
  const { valid: validModels, invalid: failedExplores } = await (0, validation_1.validateDbtModel)(adapterType, manifestVersion, compiledModels);
49
48
  if (failedExplores.length > 0) {
@@ -1,4 +1,3 @@
1
- import { DbtModelNode } from '@lightdash/common';
2
1
  import { LoadManifestArgs } from '../../dbt/manifest';
3
2
  export type DbtCompileOptions = {
4
3
  profilesDir: string | undefined;
@@ -19,5 +18,4 @@ export type DbtCompileOptions = {
19
18
  useDbtList: boolean | undefined;
20
19
  };
21
20
  export declare const dbtCompile: (options: DbtCompileOptions) => Promise<void>;
22
- export declare function getCompiledModels(manifestModels: DbtModelNode[], compiledModelIds?: string[]): DbtModelNode[];
23
21
  export declare function maybeCompileModelsAndJoins(loadManifestOpts: LoadManifestArgs, initialOptions: DbtCompileOptions): Promise<string[] | undefined>;
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.maybeCompileModelsAndJoins = exports.getCompiledModels = exports.dbtCompile = void 0;
3
+ exports.maybeCompileModelsAndJoins = exports.dbtCompile = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const common_1 = require("@lightdash/common");
6
6
  const execa_1 = tslib_1.__importDefault(require("execa"));
7
7
  const lodash_1 = require("lodash");
8
8
  const manifest_1 = require("../../dbt/manifest");
9
- const models_1 = require("../../dbt/models");
10
9
  const globalState_1 = tslib_1.__importDefault(require("../../globalState"));
11
10
  const getDbtVersion_1 = require("./getDbtVersion");
12
11
  const dbtCompileArgs = [
@@ -53,15 +52,6 @@ const dbtCompile = async (options) => {
53
52
  }
54
53
  };
55
54
  exports.dbtCompile = dbtCompile;
56
- function getCompiledModels(manifestModels, compiledModelIds) {
57
- return manifestModels.filter((model) => {
58
- if (compiledModelIds) {
59
- return compiledModelIds.includes(model.unique_id);
60
- }
61
- return model.compiled;
62
- });
63
- }
64
- exports.getCompiledModels = getCompiledModels;
65
55
  const getJoinedModelsRecursively = (modelNode, allModelNodes, visited = new Set()) => {
66
56
  if (visited.has(modelNode.name)) {
67
57
  globalState_1.default.debug(`Already visited ${modelNode.name}. Skipping.`);
@@ -148,8 +138,8 @@ async function maybeCompileModelsAndJoins(loadManifestOpts, initialOptions) {
148
138
  }
149
139
  // Load manifest and get all models
150
140
  const manifest = await (0, manifest_1.loadManifest)(loadManifestOpts);
151
- const allManifestModels = (0, models_1.getModelsFromManifest)(manifest);
152
- const currCompiledModels = getCompiledModels(allManifestModels, compiledModelIds);
141
+ const allManifestModels = (0, common_1.getModelsFromManifest)(manifest);
142
+ const currCompiledModels = (0, common_1.getCompiledModels)(allManifestModels, compiledModelIds);
153
143
  // Get models and their joined models
154
144
  const requiredModels = new Set(currCompiledModels.reduce((acc, model) => {
155
145
  const joinedModelNames = getJoinedModelsRecursively(model, allManifestModels, new Set(acc));
@@ -59,7 +59,7 @@ const generateHandler = async (options) => {
59
59
  startOfWeek: options.startOfWeek,
60
60
  });
61
61
  const manifest = await (0, manifest_1.loadManifest)({ targetDir: context.targetDir });
62
- const models = (0, models_1.getModelsFromManifest)(manifest);
62
+ const models = (0, common_1.getModelsFromManifest)(manifest);
63
63
  const compiledModels = await (0, models_1.getCompiledModels)(models, {
64
64
  projectDir: dbtVersion.isDbtCloudCLI ? undefined : absoluteProjectPath,
65
65
  profilesDir: dbtVersion.isDbtCloudCLI
package/dist/index.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,58 +1,59 @@
1
1
  {
2
- "name": "@lightdash/cli",
3
- "version": "0.1456.1",
4
- "license": "MIT",
5
- "bin": {
6
- "lightdash": "dist/index.js"
7
- },
8
- "files": [
9
- "dist/**/*",
10
- "track.sh"
11
- ],
12
- "dependencies": {
13
- "@actions/core": "^1.11.1",
14
- "@lightdash/common": "workspace:*",
15
- "@lightdash/warehouses": "workspace:*",
16
- "@types/columnify": "^1.5.1",
17
- "ajv": "^8.11.0",
18
- "ajv-formats": "^2.1.1",
19
- "better-ajv-errors": "^1.2.0",
20
- "chalk": "4.1.2",
21
- "chokidar": "^3.5.3",
22
- "columnify": "^1.6.0",
23
- "commander": "^9.2.0",
24
- "execa": "^5",
25
- "google-auth-library": "^8.5.1",
26
- "inquirer": "^8.2.4",
27
- "js-yaml": "^4.1.0",
28
- "lodash": "^4.17.21",
29
- "node-fetch": "^2.7.0",
30
- "nunjucks": "^3.2.3",
31
- "ora": "5.4.1",
32
- "parse-node-version": "^2.0.0",
33
- "unique-names-generator": "^4.7.1",
34
- "uuid": "^11.0.3"
35
- },
36
- "description": "Lightdash CLI tool",
37
- "devDependencies": {
38
- "@types/inquirer": "^8.2.1",
39
- "@types/js-yaml": "^4.0.9",
40
- "@types/lodash": "^4.14.185",
41
- "@types/node-fetch": "2.x",
42
- "@types/nunjucks": "^3.2.1",
43
- "@types/parse-node-version": "^1.0.0",
44
- "@types/uuid": "^10.0.0"
45
- },
46
- "scripts": {
47
- "test": "jest",
48
- "build": "tsc --build tsconfig.json",
49
- "linter": "eslint -c .eslintrc.js --ignore-path ./../../.gitignore",
50
- "formatter": "prettier --config .prettierrc.js --ignore-unknown --ignore-path ./../../.gitignore",
51
- "lint": "pnpm run linter ./src",
52
- "fix-lint": "pnpm run linter ./src --fix",
53
- "format": "pnpm run formatter ./src --check",
54
- "fix-format": "pnpm run formatter ./src --write",
55
- "preinstall": "bash track.sh started || echo 'skipping preinstall'",
56
- "postinstall": "bash track.sh completed || echo 'skipping postinstall'"
57
- }
58
- }
2
+ "name": "@lightdash/cli",
3
+ "version": "0.1457.0",
4
+ "license": "MIT",
5
+ "bin": {
6
+ "lightdash": "dist/index.js"
7
+ },
8
+ "files": [
9
+ "dist/**/*",
10
+ "track.sh"
11
+ ],
12
+ "dependencies": {
13
+ "@actions/core": "^1.11.1",
14
+ "@types/columnify": "^1.5.1",
15
+ "ajv": "^8.11.0",
16
+ "ajv-formats": "^2.1.1",
17
+ "better-ajv-errors": "^1.2.0",
18
+ "chalk": "4.1.2",
19
+ "chokidar": "^3.5.3",
20
+ "columnify": "^1.6.0",
21
+ "commander": "^9.2.0",
22
+ "execa": "^5",
23
+ "google-auth-library": "^8.5.1",
24
+ "inquirer": "^8.2.4",
25
+ "js-yaml": "^4.1.0",
26
+ "lodash": "^4.17.21",
27
+ "node-fetch": "^2.7.0",
28
+ "nunjucks": "^3.2.3",
29
+ "ora": "5.4.1",
30
+ "parse-node-version": "^2.0.0",
31
+ "unique-names-generator": "^4.7.1",
32
+ "uuid": "^11.0.3",
33
+ "@lightdash/common": "0.1457.0",
34
+ "@lightdash/warehouses": "0.1457.0"
35
+ },
36
+ "description": "Lightdash CLI tool",
37
+ "devDependencies": {
38
+ "@types/inquirer": "^8.2.1",
39
+ "@types/js-yaml": "^4.0.9",
40
+ "@types/lodash": "^4.14.185",
41
+ "@types/node-fetch": "2.x",
42
+ "@types/nunjucks": "^3.2.1",
43
+ "@types/parse-node-version": "^1.0.0",
44
+ "@types/uuid": "^10.0.0"
45
+ },
46
+ "scripts": {
47
+ "test": "jest",
48
+ "build": "tsc --build tsconfig.json",
49
+ "linter": "eslint -c .eslintrc.js --ignore-path ./../../.gitignore",
50
+ "formatter": "prettier --config .prettierrc.js --ignore-unknown --ignore-path ./../../.gitignore",
51
+ "lint": "pnpm run linter ./src",
52
+ "fix-lint": "pnpm run linter ./src --fix",
53
+ "format": "pnpm run formatter ./src --check",
54
+ "fix-format": "pnpm run formatter ./src --write",
55
+ "preinstall": "bash track.sh started || echo 'skipping preinstall'",
56
+ "postinstall": "bash track.sh completed || echo 'skipping postinstall'",
57
+ "release": "pnpm publish --no-git-checks"
58
+ }
59
+ }