Skip to content

Commit

Permalink
Merge pull request #151 from tigrisdata/main
Browse files Browse the repository at this point in the history
Beta release
  • Loading branch information
adilansari authored Nov 1, 2022
2 parents 369ade2 + 89e215d commit 79e34b8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
16 changes: 16 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
"@types/jest": "^28.1.8",
"@typescript-eslint/eslint-plugin": "^5.35.1",
"@typescript-eslint/parser": "^5.35.1",
"chalk": "4.1.2",
"copyfiles": "^2.4.1",
"eslint": "^8.22.0",
"eslint-config-prettier": "^8.5.0",
Expand All @@ -107,6 +106,8 @@
},
"dependencies": {
"@grpc/grpc-js": "^1.6.10",
"app-root-path": "^3.1.0",
"chalk": "4.1.2",
"dotenv": "^16.0.3",
"google-protobuf": "^3.21.0",
"json-bigint": "^1.0.0",
Expand Down
15 changes: 10 additions & 5 deletions src/tigris.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
ListDatabasesRequest as ProtoListDatabasesRequest,
} from "./proto/server/v1/api_pb";
import { GetInfoRequest as ProtoGetInfoRequest } from "./proto/server/v1/observability_pb";

import path from "node:path";
import appRootPath from "app-root-path";
import * as dotenv from "dotenv";

import {
Expand Down Expand Up @@ -281,11 +282,15 @@ export class Tigris {
* Automatically provision Databases and Collections based on the directories
* and {@link TigrisSchema} definitions in file system
*
* @param absoluteSchemaPath - Directory location in file system from root
* directory (/) to load schemas from
* @param schemaPath - Directory location in file system. Recommended to
* provide an absolute path, else loader will try to access application's root
* path which may not be accurate.
*/
public async registerSchemas(absoluteSchemaPath: string) {
const manifest: TigrisManifest = loadTigrisManifest(absoluteSchemaPath);
public async registerSchemas(schemaPath: string) {
if (!path.isAbsolute(schemaPath)) {
schemaPath = path.join(appRootPath.toString(), schemaPath);
}
const manifest: TigrisManifest = loadTigrisManifest(schemaPath);

for (const dbManifest of manifest) {
// create DB
Expand Down
4 changes: 1 addition & 3 deletions src/utils/manifest-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ export function loadTigrisManifest(schemasPath: string): TigrisManifest {

if (!fs.existsSync(schemasPath)) {
Log.error(`Invalid path for Tigris schema: ${schemasPath}`);
throw new TigrisFileNotFoundError(
`Directory not found: ${schemasPath}. Provide a complete path.`
);
throw new TigrisFileNotFoundError(`Directory not found: ${schemasPath}`);
}

const tigrisFileManifest: TigrisManifest = new Array<DatabaseManifest>();
Expand Down

0 comments on commit 79e34b8

Please sign in to comment.