From 7fe9b5c5414809f4a81e56bb2dc1322899d89ad3 Mon Sep 17 00:00:00 2001 From: mulygottlieb Date: Sun, 31 Mar 2024 17:22:32 +0300 Subject: [PATCH 1/2] fix(plugins): add seed template to auth-jwt plugin --- package-lock.json | 95 ++++++++++++++----- plugins/auth-jwt/package.json | 2 +- .../auth-jwt/src/templates/seed.template.ts | 44 +++++++++ 3 files changed, 116 insertions(+), 25 deletions(-) create mode 100644 plugins/auth-jwt/src/templates/seed.template.ts diff --git a/package-lock.json b/package-lock.json index fe60970b..696285af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,10 @@ "name": "@amplication/plugins", "version": "0.0.0", "license": "MIT", - "workspaces": ["plugins/*", "libs/*"], + "workspaces": [ + "plugins/*", + "libs/*" + ], "devDependencies": { "@nx/eslint": "18.0.7", "@nx/eslint-plugin": "^18.0.7", @@ -3202,10 +3205,14 @@ "version": "18.0.7", "resolved": "https://registry.npmjs.org/@nx/nx-darwin-arm64/-/nx-darwin-arm64-18.0.7.tgz", "integrity": "sha512-0ZCgalq5NwJy0SPJGisFcT+kHftWoyMyb78yFNFeFCL7dPmLUq2QqbLR2HFo2SIuPFY5+DVv9FBB63ZbdPXTJw==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["darwin"], + "os": [ + "darwin" + ], "engines": { "node": ">= 10" } @@ -3214,10 +3221,14 @@ "version": "18.0.7", "resolved": "https://registry.npmjs.org/@nx/nx-darwin-x64/-/nx-darwin-x64-18.0.7.tgz", "integrity": "sha512-yA5bXhsw0C4YjUcJcsXgsN/Pv8nSM3xo8hJ+RJCjgkh15f3ylXzYvBa+xL6qWTyZqhICULDInfJwsw9x5GTQWg==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["darwin"], + "os": [ + "darwin" + ], "engines": { "node": ">= 10" } @@ -3226,10 +3237,14 @@ "version": "18.0.7", "resolved": "https://registry.npmjs.org/@nx/nx-freebsd-x64/-/nx-freebsd-x64-18.0.7.tgz", "integrity": "sha512-KplveiJ59HeMLUN6S6dWMVjIgzLYx0v/1W9RdmTJB8EAAiduJdtDip0GLjSj902pEXbIhr3n9p4USPWFnrdL5w==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["freebsd"], + "os": [ + "freebsd" + ], "engines": { "node": ">= 10" } @@ -3238,10 +3253,14 @@ "version": "18.0.7", "resolved": "https://registry.npmjs.org/@nx/nx-linux-arm-gnueabihf/-/nx-linux-arm-gnueabihf-18.0.7.tgz", "integrity": "sha512-Uj4OF7yZLK9US/+4a33FiFpyP6SaDB34HLHIht9ROjL6dGxv1iUs8Ut+JaUQ6DaP/XBwV6/+CDBH5uXMfMWLww==", - "cpu": ["arm"], + "cpu": [ + "arm" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">= 10" } @@ -3250,10 +3269,14 @@ "version": "18.0.7", "resolved": "https://registry.npmjs.org/@nx/nx-linux-arm64-gnu/-/nx-linux-arm64-gnu-18.0.7.tgz", "integrity": "sha512-hGuM7mtOsZTuxnBTm9uLKNBmkRL0zQs0ZtFomHscSt/reN8WBgduKSPWJ18LLj5D7Z1otxI3ooUf8+5/jwmr3A==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">= 10" } @@ -3262,10 +3285,14 @@ "version": "18.0.7", "resolved": "https://registry.npmjs.org/@nx/nx-linux-arm64-musl/-/nx-linux-arm64-musl-18.0.7.tgz", "integrity": "sha512-34Xb5mZT3p2E6mM0D6cFIpPF5hJtF3aDzBnzeitP/lZe70n+S0PUpgB/2Vi9j3IHW2xjci5jU2UYsdF2RIEWTQ==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">= 10" } @@ -3274,10 +3301,14 @@ "version": "18.0.7", "resolved": "https://registry.npmjs.org/@nx/nx-linux-x64-gnu/-/nx-linux-x64-gnu-18.0.7.tgz", "integrity": "sha512-tn1puRzCk/Sn8f7d1134Zyob1CT25kovPWPvUadvEoqqetMgRgVxMqTr7Ud/2hu61iGSKQEmOlQ2bVM/NMeRvA==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">= 10" } @@ -3286,10 +3317,14 @@ "version": "18.0.7", "resolved": "https://registry.npmjs.org/@nx/nx-linux-x64-musl/-/nx-linux-x64-musl-18.0.7.tgz", "integrity": "sha512-at1nI9mBMNMCIC5BrY8oJ+7ptknZPhQwu7j4jhRAgcHd2JOZZtgJSo4FI2chBTbzf3SLQL1omts0zKB1syas1w==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">= 10" } @@ -3298,10 +3333,14 @@ "version": "18.0.7", "resolved": "https://registry.npmjs.org/@nx/nx-win32-arm64-msvc/-/nx-win32-arm64-msvc-18.0.7.tgz", "integrity": "sha512-DTn5X5NhnjpG1LZgESM0EmBPLnwoeZzOaJfjt92Loib1TmALEHUIdVRcshb8FJfoXY4zNEdNUCmZ+M3us4xb9A==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["win32"], + "os": [ + "win32" + ], "engines": { "node": ">= 10" } @@ -3310,10 +3349,14 @@ "version": "18.0.7", "resolved": "https://registry.npmjs.org/@nx/nx-win32-x64-msvc/-/nx-win32-x64-msvc-18.0.7.tgz", "integrity": "sha512-/2Ue0kTuvXQpF0QfJGtBZ5yqhpRVcDTidDcZSgdFdNEkqUXK2GgXG4lPQtw8zf2Ja9Q+93lXwH6NMhQWCB8cNA==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["win32"], + "os": [ + "win32" + ], "engines": { "node": ">= 10" } @@ -5621,7 +5664,9 @@ "version": "1.6.2", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "engines": ["node >= 0.8"], + "engines": [ + "node >= 0.8" + ], "dependencies": { "buffer-from": "^1.0.0", "inherits": "^2.0.3", @@ -7162,7 +7207,9 @@ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", "hasInstallScript": true, "optional": true, - "os": ["darwin"], + "os": [ + "darwin" + ], "engines": { "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } @@ -12284,7 +12331,7 @@ }, "plugins/auth-jwt": { "name": "@amplication/plugin-auth-jwt", - "version": "1.4.12", + "version": "1.4.13", "license": "ISC", "dependencies": { "@amplication/code-gen-types": "^2.0.23", diff --git a/plugins/auth-jwt/package.json b/plugins/auth-jwt/package.json index 08aeeb4e..0635a1d9 100644 --- a/plugins/auth-jwt/package.json +++ b/plugins/auth-jwt/package.json @@ -1,6 +1,6 @@ { "name": "@amplication/plugin-auth-jwt", - "version": "1.4.12", + "version": "1.4.13", "description": "set jwt as provider for Amplication build", "main": "dist/index.js", "nx": {}, diff --git a/plugins/auth-jwt/src/templates/seed.template.ts b/plugins/auth-jwt/src/templates/seed.template.ts new file mode 100644 index 00000000..cafd7671 --- /dev/null +++ b/plugins/auth-jwt/src/templates/seed.template.ts @@ -0,0 +1,44 @@ +/*** + * This file was auto-generated by Amplication and should not be modified by hand. + * The file will be re-generated with every new build, and all changes will be lost. + * To add a custom seed script, you can safely edit the content of ./customSeed.ts + ***/ + +import * as dotenv from "dotenv"; +import { PrismaClient } from "@prisma/client"; +import { customSeed } from "./customSeed"; + +declare const DATA: { username: string }; + +if (require.main === module) { + dotenv.config(); + + const { BCRYPT_SALT } = process.env; + + if (!BCRYPT_SALT) { + throw new Error("BCRYPT_SALT environment variable must be defined"); + } + + seed().catch((error) => { + console.error(error); + process.exit(1); + }); +} + +async function seed() { + console.info("Seeding database..."); + + const client = new PrismaClient(); + const data = DATA; + await client.user.upsert({ + where: { username: data.username }, + update: {}, + create: data, + }); + void client.$disconnect(); + + console.info("Seeding database with custom seed..."); + customSeed(); + + console.info("Seeded database successfully"); +} From a76af9ce79df834075cf57d5b82b915160fd9427 Mon Sep 17 00:00:00 2001 From: mulygottlieb Date: Sun, 31 Mar 2024 17:43:04 +0300 Subject: [PATCH 2/2] chore(plugins): bump auth-jwt version over the versions already published to npm in the past --- package-lock.json | 2 +- plugins/auth-jwt/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 696285af..fc7f3e76 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12331,7 +12331,7 @@ }, "plugins/auth-jwt": { "name": "@amplication/plugin-auth-jwt", - "version": "1.4.13", + "version": "1.4.14", "license": "ISC", "dependencies": { "@amplication/code-gen-types": "^2.0.23", diff --git a/plugins/auth-jwt/package.json b/plugins/auth-jwt/package.json index 0635a1d9..bc65e472 100644 --- a/plugins/auth-jwt/package.json +++ b/plugins/auth-jwt/package.json @@ -1,6 +1,6 @@ { "name": "@amplication/plugin-auth-jwt", - "version": "1.4.13", + "version": "1.4.14", "description": "set jwt as provider for Amplication build", "main": "dist/index.js", "nx": {},