diff --git a/package-lock.json b/package-lock.json index 2eba2491..dc0dbb4e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,7 +37,6 @@ "peerDependencies": { "@amplication/code-gen-types": "^2.0.23", "@amplication/code-gen-utils": "^0.0.9", - "@babel/types": "7.24.0", "ast-types": "0.14.2", "dotenv": "16.3.2", "jest-mock-extended": "3.0.5", @@ -12276,7 +12275,7 @@ }, "plugins/auth-basic": { "name": "@amplication/plugin-auth-basic", - "version": "1.4.12", + "version": "1.4.13", "license": "ISC", "dependencies": { "@amplication/code-gen-types": "^2.0.23", diff --git a/plugins/auth-basic/package.json b/plugins/auth-basic/package.json index 2056afb4..4099c046 100644 --- a/plugins/auth-basic/package.json +++ b/plugins/auth-basic/package.json @@ -1,6 +1,6 @@ { "name": "@amplication/plugin-auth-basic", - "version": "1.4.12", + "version": "1.4.13", "description": "set basic auth for Amplication build", "main": "dist/index.js", "nx": {}, diff --git a/plugins/auth-basic/src/templates/seed.template.ts b/plugins/auth-basic/src/templates/seed.template.ts new file mode 100644 index 00000000..cafd7671 --- /dev/null +++ b/plugins/auth-basic/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"); +}