@a_team/prisma 3.0.22-macos → 3.1.0-linux

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.
package/README.md CHANGED
@@ -1,58 +1,108 @@
1
- # @a_team/prisma
1
+ # A.Team prisma library
2
2
 
3
- This package contains a shared Prisma schema, organized into [multiple files](https://www.prisma.io/blog/organize-your-prisma-schema-with-multi-file-support), to be used across multiple projects. By centralizing the schema definitions, we ensure consistency and reduce duplication of effort:
3
+ - This package contains a shared Prisma schema, organized into [multiple files](https://www.prisma.io/blog/organize-your-prisma-schema-with-multi-file-support), to be used across multiple projects.
4
+ - By centralizing the schema definitions, we ensure consistency and reduce duplication of effort:
5
+ - **Consistency**: We are targeting the same MongoDB database. If we use different schema definition files, there's a risk of having inconsistent model definitions, which could lead to conflicts and data overrides.
6
+ - **Efficiency**: A single schema definition can reduce redundant work. Currently, the schema file has over 300 lines, and this could easily grow to 1000+ lines as we onboard more collections. By working collaboratively on a single schema definition, we can streamline our efforts and improve the overall quality.
4
7
 
5
- 1. **Consistency**: We are targeting the same MongoDB database. If we use different schema definition files, there's a risk of having inconsistent model definitions, which could lead to conflicts and data overrides.
6
- 1. **Efficiency**: A single schema definition can reduce redundant work. Currently, the schema file has over 300 lines, and this could easily grow to 1000+ lines as we onboard more collections. By working collaboratively on a single schema definition, we can streamline our efforts and improve the overall quality.
8
+ ### Installation
7
9
 
8
- ## Installation
10
+ - To install this package, add the following optional dependencies (where `X.Y.Z` represents the version):
9
11
 
10
- To install this package, use the following command:
11
-
12
- ```sh
13
- yarn add @a_team/prisma
12
+ ```json
13
+ "optionalDependencies": {
14
+ "@a_team/prisma-win": "npm:@a_team/prisma@X.Y.Z-win",
15
+ "@a_team/prisma-macos": "npm:@a_team/prisma@X.Y.Z-macos",
16
+ "@a_team/prisma-linux": "npm:@a_team/prisma@X.Y.Z-linux"
17
+ }
14
18
  ```
15
19
 
16
- ## Usage
20
+ - Add the following script as `postinstall` & change per need in your service:
21
+
22
+ ```javascript
23
+ const fs = require('fs');
24
+ const path = require('path');
25
+
26
+ const getPlatformPackage = () => {
27
+ switch (process.platform) {
28
+ case 'darwin':
29
+ return '@a_team/prisma-macos';
30
+ case 'win32':
31
+ return '@a_team/prisma-win';
32
+ default:
33
+ return '@a_team/prisma-linux';
34
+ }
35
+ };
36
+
37
+ const platformPackage = getPlatformPackage();
38
+ const nodeModulesPath = path.join(__dirname, '..', 'node_modules');
39
+ const sourcePath = path.join(nodeModulesPath, platformPackage);
40
+ const targetPath = path.join(nodeModulesPath, '@a_team/prisma');
41
+
42
+ if (fs.existsSync(sourcePath)) {
43
+ if (fs.existsSync(targetPath)) {
44
+ fs.rmSync(targetPath, { recursive: true, force: true });
45
+ }
46
+
47
+ fs.renameSync(sourcePath, targetPath);
48
+ console.log(`Renamed ${platformPackage} to @a_team/prisma`);
49
+ } else {
50
+ console.error(`Platform-specific package ${platformPackage} not found`);
51
+ process.exit(1);
52
+ }
17
53
 
18
- To use the shared Prisma client:
54
+ ```
19
55
 
20
- ```typescript
21
- import { PrismaClient } from "@prisma/client";
56
+ - The script above will link the required OS dependency as the main one.
22
57
 
23
- const prisma = new PrismaClient();
24
- ```
58
+ ### Usage
25
59
 
26
- ## Playground
60
+ - To use the library:
27
61
 
28
- The playground is a dedicated space where you can test and experiment with the Prisma client and schema. It contains various scripts that demonstrate how to interact with your database models.
62
+ ```typescript
63
+ import { ATeamPrismaClient } from '@a_team/prisma';
29
64
 
30
- Before running any playground scripts, make sure to set up your environment variables. First, copy the `.env.sample` file to `.env`:
65
+ export class DbClient extends ATeamPrismaClient {
66
+ constructor(connectionUrl: string) {
67
+ super(connectionUrl);
68
+ }
31
69
 
32
- ```sh
33
- cp .env.sample .env
70
+ async onModuleInit() {
71
+ await this.connect();
72
+ }
73
+
74
+ async onModuleDestroy() {
75
+ await this.disconnect();
76
+ }
77
+ }
34
78
  ```
35
79
 
36
- Then, fill in the required environment variables in the `.env` file.
80
+ ### Playground
37
81
 
38
- To run a playground script, use the following command:
82
+ - The playground is a dedicated space where you can test and experiment with the prisma client and schema.
83
+ - It contains various scripts that demonstrate how to interact with your database models.
84
+ - Before running any playground scripts, make sure to set up your environment variables. First, copy the `.env.sample` file to `.env`:
39
85
 
40
86
  ```sh
41
- npx ts-node playground/missionSpec.ts
87
+ cp .env.sample .env
42
88
  ```
43
89
 
44
- ## Publishing
45
-
46
- To publish updates to this package, use the following command:
90
+ - Then, fill in the required environment variables in the `.env` file.
91
+ - To run a playground script, use the following command:
47
92
 
48
93
  ```sh
49
- yarn build && yarn publish
94
+ npx ts-node playground/missionSpec.ts
50
95
  ```
51
96
 
52
- ## Additional Information
97
+ ### Publishing a new version
53
98
 
54
- The package is available on npm at: [@a_team/prisma](https://www.npmjs.com/package/@a_team/prisma).
99
+ - Pull the latest changes on the `main` branch and push the following tag to the repository:
55
100
 
56
- ### Reference
101
+ ```bash
102
+ git tag v<major>.<minor>.<patch> # matches v0.0.1
103
+ git push origin tag v<major>.<minor>.<patch> # runs the publishing process
104
+ ```
57
105
 
58
- [Sharing Prisma Between Multiple Applications](https://medium.com/@nolawnchairs/sharing-prisma-between-multiple-applications-5c7a7d131519)
106
+ - This tag creates the new package versions needed and pushes them towards the npm repository,
107
+ - A `release` on the `github` repository is generated,
108
+ - A slack notification is sent to the required channel with the release changes.