chore(deps): update to Prisma 4.3.1
+ 122
- 122
@@ -1,8 +1,17 @@
-# GitFOSS
+# ❇️ GitFOSS
+
+GitFOSS is a small, simple, free and open-source Git Forge built w/ Node.JS, Fastify,
+Prisma and React! 🪄
 
 ## Run it
 
-First step, clone this git repository and cd into it.
+In order to run your own instance of GitFOSS, the first step is to clone this
+git repository and cd into it:
+
+```sh
+$ git clone "https://gitfoss.io:ethicdevs/gitfoss.git"
+$ cd gitfoss/
+```
 
 ### Locally via Node/Yarn
 

...
@@ -12,15 +21,16 @@ Make sure your `.env.local` file is correctly setup and includes all the environ
 variables present in the example `.env` file. Make sure no value is set to `fake`.
 
 ```sh
-$ yarn dev
-$ yarn typecheck
-$ yarn test
+$ yarn dev # Run dev 'server'
+$ yarn typecheck # Check TypeScript types validity
+$ yarn test # Run app tests
 ```
 
-Also when changing the Prisma schema don't forget to make a migration with:
+Also when performing changes to the Prisma schema, don't forget to make a new
+migration files using the following command:
 
 ```sh
-$ yarn migrate:dev
+$ yarn migrate:dev # Create a new migration file interactively
 ```
 
 #### Production-like mode

...
@@ -40,20 +50,25 @@ $ yarn start
 ```sh
 $ docker run -p 1337:1337 \
   -e COOKIE_NAME='gitfoss_ssid' \
-  -e COOKIE_SECRET='gitfoss-cookie-secret' \
-  -e DATABASE_URL='postgresql://postgres:change_me_password@gitfoss_db:5432/gitfoss?sslmode=disable&connection_limit=3' \
+  -e COOKIE_SECRET='change_me_cookie_secret' \
+  -e DATABASE_URL='postgresql://...from.env.production...' \
   -e DEPLOYMENT_DOMAIN='local-app.localhost' \
   -e DEPLOYMENT_SCHEME='http' \
   -e GIT_REPOSITORIES_ROOT='/var/lib/gitfoss/repos' \
-  docker.io/library/gitfoss_web:latest;
+  docker.io/library/gitfoss_web:latest
 
 # Get the container id then run migrations
-$ docker exec -it container_id_here yarn migrate:deploy
+$ docker exec -it <container_id_here> yarn migrate:deploy
 ```
 
-### Using Docker Compose
+### Using docker-compose
 
 ```sh
 $ docker-compose up -d
 $ docker-compose exec web yarn migrate:deploy
+$ docker-compose exec traefik cat /var/log/traefik/traefik.log
 ```
+
+## License
+
+This project is licensed under the [MIT](LICENSE) license.

app/services/organization/getOrganizationRepositories.ts
@@ -20,6 +20,9 @@ const getOrganizationRepositories: ServiceMethodFactory<
           id: org.id,
         },
       },
+      orderBy: {
+        lastPushedAt: "desc",
+      },
     });
 
     return orgRepos.map(({ organization: parentOrg, ...repo }) => ({

app/services/repository/getRepositoryExploreCollection.ts
@@ -23,6 +23,9 @@ const makeGetRepositoryExploreCollection: ServiceMethodFactory<
       where: {
         visibility: ResourceVisibility.PUBLIC,
       },
+      orderBy: {
+        lastPushedAt: "desc",
+      },
     });
 
     const repositoriesWithMetas = await Promise.all(

app/services/user/getUserRepositories.ts
@@ -33,6 +33,9 @@ const getUserRepositories: ServiceMethodFactory<
           },
         ],
       },
+      orderBy: {
+        lastPushedAt: "desc",
+      },
     });
 
     return userRepos.map(({ organization: parentOrg, ...repo }) => ({

@@ -1,6 +1,6 @@
 generator client {
   provider        = "prisma-client-js"
-  previewFeatures = ["filterJson", "fullTextSearch"]
+  previewFeatures = ["fullTextSearch","interactiveTransactions"]
   binaryTargets   = ["native", "linux-musl", "debian-openssl-1.1.x"]
 }
 

...
@@ -9,123 +9,99 @@ datasource db {
   url      = env("DATABASE_URL")
 }
 
-// enums
-
-enum GlobalRole {
-  GUEST
-  CUSTOMER
-  ADMIN
-  SUPER_ADMIN
-}
-
-enum OrganizationKind {
-  PERSONAL
-  COMPANY
-}
-
-enum OrganizationRole {
-  REVIEWER
-  COMITTER
-  ADMIN
-  OWNER
-}
-
-enum ResourceVisibility {
-  PUBLIC
-  UNLISTED
-  PRIVATE
-}
-
-// models
-
 model Organization {
-  id   String           @id @default(cuid())
-  slug String           @unique
-  kind OrganizationKind @default(PERSONAL)
-
-  createdAt DateTime @default(now())
-  updatedAt DateTime @updatedAt
-
-  avatarUri   String?
-  displayName String?
-  visibility  ResourceVisibility @default(PRIVATE)
-  websiteUrl  String?
-
+  id           String                   @id @default(cuid())
+  slug         String                   @unique
+  createdAt    DateTime                 @default(now())
+  updatedAt    DateTime                 @updatedAt
+  avatarUri    String?
+  displayName  String?
+  websiteUrl   String?
+  ownerId      String
+  visibility   ResourceVisibility       @default(PRIVATE)
+  kind         OrganizationKind         @default(PERSONAL)
+  owner        User                     @relation("ManyOwnedOrganizationsToOneOwnerUser", fields: [ownerId], references: [id])
   memberships  OrganizationMembership[] @relation("OneOrganizationMembershipToOneOrganization")
   repositories Repository[]             @relation("ManyRepositoriesToOneOrganization")
-
-  owner   User   @relation("ManyOwnedOrganizationsToOneOwnerUser", fields: [ownerId], references: [id])
-  ownerId String
 }
 
 model OrganizationMembership {
-  id String @id @default(cuid())
-
-  createdAt DateTime  @default(now())
-  updatedAt DateTime  @updatedAt
-  expiresAt DateTime?
-  revokedAt DateTime?
-
-  organization   Organization @relation("OneOrganizationMembershipToOneOrganization", fields: [organizationId], references: [id])
+  id             String           @id @default(cuid())
+  createdAt      DateTime         @default(now())
+  updatedAt      DateTime         @updatedAt
+  expiresAt      DateTime?
+  revokedAt      DateTime?
   organizationId String
-
-  user   User   @relation("OneOrganizationMembershipToOneUser", fields: [userId], references: [id])
-  userId String
-
-  role OrganizationRole @default(REVIEWER)
+  userId         String
+  role           OrganizationRole @default(REVIEWER)
+  organization   Organization     @relation("OneOrganizationMembershipToOneOrganization", fields: [organizationId], references: [id])
+  user           User             @relation("OneOrganizationMembershipToOneUser", fields: [userId], references: [id])
 }
 
 model Repository {
-  id   String @id @default(cuid())
-  slug String @unique
-
-  createdAt DateTime @default(now())
-  updatedAt DateTime @updatedAt
-  lastPushedAt DateTime?
-
+  id               String             @id @default(cuid())
+  slug             String             @unique
+  createdAt        DateTime           @default(now())
+  updatedAt        DateTime           @updatedAt
   avatarUri        String?
   displayName      String?
   keywords         String[]
   shortDescription String?
-  visibility       ResourceVisibility @default(PRIVATE)
   websiteUrl       String?
-  isFork           Boolean @default(false)
+  organizationId   String
+  visibility       ResourceVisibility @default(PRIVATE)
   forkedFromRepoId String?
-
-  organization   Organization @relation("ManyRepositoriesToOneOrganization", fields: [organizationId], references: [id])
-  organizationId String
+  isFork           Boolean            @default(false)
+  lastPushedAt     DateTime?
+  organization     Organization       @relation("ManyRepositoriesToOneOrganization", fields: [organizationId], references: [id])
 }
 
 model Session {
-  id        String @id @default(cuid())
-  sessionId String @unique
-
-  createdAt DateTime  @default(now())
-  updatedAt DateTime  @updatedAt
-  expiresAt DateTime?
-
-  data Json?
-
-  detectedUserAgent String @default("")
-  detectedIPAddress String @default("")
-
-  // activities ActivityLog[] @relation("OneSessionToManyActivityLogs")
+  id                String    @id @default(cuid())
+  sessionId         String    @unique
+  createdAt         DateTime  @default(now())
+  updatedAt         DateTime  @updatedAt
+  expiresAt         DateTime?
+  data              Json?
+  detectedUserAgent String    @default("")
+  detectedIPAddress String    @default("")
 }
 
 model User {
-  id   String     @id @default(cuid())
-  role GlobalRole @default(CUSTOMER)
+  id                      String                   @id @default(cuid())
+  role                    GlobalRole               @default(CUSTOMER)
+  createdAt               DateTime                 @default(now())
+  updatedAt               DateTime                 @updatedAt
+  username                String                   @unique
+  email                   String                   @unique
+  hashedPassword          String
+  displayName             String?
+  avatarUri               String?
+  organizations           Organization[]           @relation("ManyOwnedOrganizationsToOneOwnerUser")
+  organizationMemberships OrganizationMembership[] @relation("OneOrganizationMembershipToOneUser")
+}
 
-  createdAt DateTime @default(now())
-  updatedAt DateTime @updatedAt
+enum GlobalRole {
+  GUEST
+  CUSTOMER
+  ADMIN
+  SUPER_ADMIN
+}
 
-  username       String @unique
-  email          String @unique
-  hashedPassword String
+enum OrganizationKind {
+  PERSONAL
+  COMPANY
+}
 
-  displayName String?
-  avatarUri   String?
+enum OrganizationRole {
+  REVIEWER
+  COMITTER
+  ADMIN
+  OWNER
+}
 
-  organizations           Organization[]           @relation("ManyOwnedOrganizationsToOneOwnerUser")
-  organizationMemberships OrganizationMembership[] @relation("OneOrganizationMembershipToOneUser")
+enum ResourceVisibility {
+  PUBLIC
+  UNLISTED
+  PRIVATE
 }

@@ -32,7 +32,7 @@
     "@ethicdevs/react-monolith": "^1.6.1",
     "@fastify/cookie": "6.0.0",
     "@fastify/formbody": "6.0.0",
-    "@prisma/client": "3.15.2",
+    "@prisma/client": "^4.3.1",
     "cross-fetch": "^3.1.5",
     "cuid": "^2.1.8",
     "diffparser": "^2.0.1",

...
@@ -73,7 +73,7 @@
     "exoframe": "^6.2.0",
     "jest": "^27.5.1",
     "npm-run-all": "^4.1.5",
-    "prisma": "3.15.2",
+    "prisma": "^4.3.1",
     "ts-node-dev": "^2.0.0",
     "tslib": "^2.4.0",
     "typescript": "^4.6.2"

@@ -743,19 +743,19 @@
   version "1.0.0"
   resolved "https://registry.yarnpkg.com/@panva/asn1.js/-/asn1.js-1.0.0.tgz#dd55ae7b8129e02049f009408b97c61ccf9032f6"
 
-"@prisma/client@3.15.2":
-  version "3.15.2"
-  resolved "https://registry.yarnpkg.com/@prisma/client/-/client-3.15.2.tgz#2181398147afc79bfe0d83c03a88dc45b49bd365"
+"@prisma/client@^4.3.1":
+  version "4.3.1"
+  resolved "https://registry.yarnpkg.com/@prisma/client/-/client-4.3.1.tgz#b9aad9bd9bd43e7f715ec1d763c8bd9273688800"
   dependencies:
-    "@prisma/engines-version" "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e"
+    "@prisma/engines-version" "4.3.0-32.c875e43600dfe042452e0b868f7a48b817b9640b"
 
-"@prisma/engines-version@3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e":
-  version "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e"
-  resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e.tgz#bf5e2373ca68ce7556b967cb4965a7095e93fe53"
+"@prisma/engines-version@4.3.0-32.c875e43600dfe042452e0b868f7a48b817b9640b":
+  version "4.3.0-32.c875e43600dfe042452e0b868f7a48b817b9640b"
+  resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-4.3.0-32.c875e43600dfe042452e0b868f7a48b817b9640b.tgz#a564dd6fb6f25405fe06164989ebd8a1e4bb3508"
 
-"@prisma/engines@3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e":
-  version "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e"
-  resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e.tgz#f691893df506b93e3cb1ccc15ec6e5ac64e8e570"
+"@prisma/engines@4.3.1":
+  version "4.3.1"
+  resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-4.3.1.tgz#fb0ad69eded13827fb4cd81995a351c234e8327f"
 
 "@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2":
   version "1.1.2"

...
@@ -4097,11 +4097,11 @@ pretty-format@^28.0.0, pretty-format@^28.1.3:
     ansi-styles "^5.0.0"
     react-is "^18.0.0"
 
-prisma@3.15.2:
-  version "3.15.2"
-  resolved "https://registry.yarnpkg.com/prisma/-/prisma-3.15.2.tgz#4ebe32fb284da3ac60c49fbc16c75e56ecf32067"
+prisma@^4.3.1:
+  version "4.3.1"
+  resolved "https://registry.yarnpkg.com/prisma/-/prisma-4.3.1.tgz#9e4c24e49710392be40ee75fb3d9341d7487881e"
   dependencies:
-    "@prisma/engines" "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e"
+    "@prisma/engines" "4.3.1"
 
 prismjs@^1.29.0:
   version "1.29.0"