Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
🔖 Release 2.0.0-beta.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Errorname committed May 25, 2020
1 parent 13a2d68 commit e8a86fd
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 80 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ npm i -g prisma-multi-tenant@beta
```
$> prisma-multi-tenant help
🧭 prisma-multi-tenant v2.0.0-beta.3
🧭 prisma-multi-tenant v2.0.0-beta.4
USAGE
Expand Down
6 changes: 1 addition & 5 deletions docs/examples/basic-js/multi-tenancy-example.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
const { MultiTenant } = require('prisma-multi-tenant')

require('dotenv').config({
path: 'prisma/.env'
})

// This is the name of your first tenant, try with another one
// This is the name of your first tenant, try with another one: "prod"
const name = 'dev'

const multiTenant = new MultiTenant()
Expand Down
38 changes: 15 additions & 23 deletions docs/examples/basic-js/package-lock.json

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

7 changes: 3 additions & 4 deletions docs/examples/basic-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@prisma/cli": "2.0.0-beta.3"
"@prisma/cli": "2.0.0-beta.4"
},
"dependencies": {
"@prisma/client": "2.0.0-beta.3",
"dotenv": "8.2.0",
"prisma-multi-tenant": "2.0.0-beta.3"
"@prisma/client": "2.0.0-beta.4",
"prisma-multi-tenant": "2.0.0-beta.4"
}
}
6 changes: 1 addition & 5 deletions docs/examples/basic-ts/multi-tenancy-example.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { PrismaClient } from '@prisma/client'
import { MultiTenant } from 'prisma-multi-tenant'

require('dotenv').config({
path: 'prisma/.env'
})

// This is the name of your first tenant, try with another one
// This is the name of your first tenant, try with another one: "prod"
const name = 'dev'

const multiTenant = new MultiTenant<PrismaClient>()
Expand Down
44 changes: 18 additions & 26 deletions docs/examples/basic-ts/package-lock.json

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

7 changes: 3 additions & 4 deletions docs/examples/basic-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@prisma/cli": "2.0.0-beta.3"
"@prisma/cli": "2.0.0-beta.4"
},
"dependencies": {
"@prisma/client": "2.0.0-beta.3",
"dotenv": "8.2.0",
"prisma-multi-tenant": "2.0.0-beta.3",
"@prisma/client": "2.0.0-beta.4",
"prisma-multi-tenant": "2.0.0-beta.4",
"ts-node": "8.6.2",
"typescript": "3.8.2"
}
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prisma-multi-tenant",
"version": "2.0.0-beta.3",
"version": "2.0.0-beta.4",
"description": "🧭 Use Prisma as a multi-tenant provider for your application",
"author": {
"name": "Thibaud Courtoison",
Expand Down Expand Up @@ -34,13 +34,13 @@
"inquirer": "^7.0.4"
},
"peerDependencies": {
"@prisma/cli": "^2.0.0-beta.3"
"@prisma/cli": "^2.0.0-beta.4"
},
"devDependencies": {
"@babel/core": "^7.8.3",
"@babel/preset-env": "^7.8.3",
"@babel/preset-typescript": "^7.8.3",
"@prisma/cli": "^2.0.0-beta.3",
"@prisma/cli": "^2.0.0-beta.4",
"@types/inquirer": "^6.5.0",
"@types/jest": "^25.1.0",
"@types/node": "^13.7.0",
Expand Down
4 changes: 3 additions & 1 deletion src/cli/helpers/checkCompatibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export default () => {
)
}
} catch {
console.warn(chalk.yellow`Warning: Couldn't verify version compatibility with @prisma/cli`)
console.warn(
chalk.yellow`Warning: Couldn't verify version compatibility with @prisma/cli. Did you forget to install it locally?`
)
}
}
10 changes: 10 additions & 0 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import path from 'path'
import { datasourceProviders } from '../shared/constants'
import { runDistantPrisma, requireDistant } from '../shared/shell'
import Management from '../shared/management'
Expand Down Expand Up @@ -31,6 +32,8 @@ class MultiTenant<PrismaClient extends { disconnect: () => Promise<void> }> {
constructor(options?: MultiTenantOptions) {
this.options = { ...defaultMultiTenantOptions, ...options }

this.loadEnv()

this.ClientTenant = this.requireTenant()

if (this.options.useManagement) {
Expand All @@ -40,6 +43,13 @@ class MultiTenant<PrismaClient extends { disconnect: () => Promise<void> }> {
this.tenants = {}
}

private loadEnv(): void {
// Try loading env variables
require('dotenv').config({
path: path.resolve(process.cwd(), 'prisma/.env')
})
}

private requireTenant(): any {
if (this.options.PrismaClient) {
return this.options.PrismaClient
Expand Down
2 changes: 1 addition & 1 deletion src/shared/constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const datasourceProviders = ['sqlite', 'mysql', 'postgresql']
export const clientManagementPath = '@prisma/prisma-multi-tenant/management'
export const clientManagementPath = '.prisma-multi-tenant/management'
2 changes: 1 addition & 1 deletion tests/lib/constructor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('constructor', () => {

test('PrismaClient & PrismaClientManagement', () => {
const PrismaClient = require(`@prisma/client`)
const PrismaClientManagement = require(`@prisma/prisma-multi-tenant/management`)
const PrismaClientManagement = require(`.prisma-multi-tenant/management`)

const multiTenant = new MultiTenant({
PrismaClient,
Expand Down
4 changes: 2 additions & 2 deletions tests/playground/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"@prisma/client": "2.0.0-beta.3"
"@prisma/client": "2.0.0-beta.4"
},
"devDependencies": {
"@prisma/cli": "2.0.0-beta.3"
"@prisma/cli": "2.0.0-beta.4"
},
"scripts": {
"dev": "node ./script.js"
Expand Down

0 comments on commit e8a86fd

Please sign in to comment.