fix: admin wizard crash and prisma enum generator path resolution (#28244)
* fix: admin wizard crash and prisma enum generator path resolution
1. Fix TypeError in WizardForm when license step is skipped:
- defaultStep was set to 3 (APPS) but only 2 steps existed when
hasValidLicense=true, causing steps[2] to be undefined
- Removed redundant double onNext() call in AdminUser onSuccess
- Extracted hasLicenseStep variable for clarity
2. Fix prisma enum generator not being directory-safe:
- Created run-enum-generator.js wrapper resolved by Prisma relative
to schema directory, so npx prisma commands work from any directory
Co-Authored-By: alex@cal.com <me@alexvanandel.com>
* fix: use bin entry for prisma enum generator path resolution
Changed provider from './run-enum-generator.js' (which Prisma doesn't
resolve relative to schema dir) to 'prisma-enum-generator' bin registered
in package.json. This ensures the generator is found via PATH regardless
of CWD.
Co-Authored-By: alex@cal.com <me@alexvanandel.com>
* chore: Also add new bin to the lockfile
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Devin AI
parent
5b88eefed4
commit
1b21ead011
@@ -30,16 +30,19 @@ export function Setup(props: PageProps) {
|
||||
props.hasValidLicense ? "EXISTING" : "FREE"
|
||||
);
|
||||
|
||||
const hasLicenseStep = !props.hasValidLicense && !hasPickedAGPLv3;
|
||||
|
||||
const defaultStep = useMemo(() => {
|
||||
if (props.userCount > 0) {
|
||||
if (!props.hasValidLicense && !hasPickedAGPLv3) {
|
||||
if (hasLicenseStep) {
|
||||
return SETUP_VIEW_SETPS.LICENSE;
|
||||
} else {
|
||||
return SETUP_VIEW_SETPS.APPS;
|
||||
// License step is not shown, so apps step is at position 2 instead of 3
|
||||
return SETUP_VIEW_SETPS.APPS - 1;
|
||||
}
|
||||
}
|
||||
return SETUP_VIEW_SETPS.ADMIN_USER;
|
||||
}, [props.userCount, props.hasValidLicense, hasPickedAGPLv3]);
|
||||
}, [props.userCount, hasLicenseStep]);
|
||||
|
||||
const steps: WizardStep[] = [
|
||||
{
|
||||
@@ -52,13 +55,7 @@ export function Setup(props: PageProps) {
|
||||
setIsPending(true);
|
||||
}}
|
||||
onSuccess={() => {
|
||||
// If there's already a valid license or user picked AGPLv3, skip to apps step
|
||||
if (props.hasValidLicense || hasPickedAGPLv3) {
|
||||
nav.onNext();
|
||||
nav.onNext(); // Skip license step
|
||||
} else {
|
||||
nav.onNext();
|
||||
}
|
||||
nav.onNext();
|
||||
}}
|
||||
onError={() => {
|
||||
setIsPending(false);
|
||||
@@ -71,7 +68,7 @@ export function Setup(props: PageProps) {
|
||||
];
|
||||
|
||||
// Only show license selection step if there's no valid license already and AGPLv3 wasn't picked
|
||||
if (!props.hasValidLicense && !hasPickedAGPLv3) {
|
||||
if (hasLicenseStep) {
|
||||
steps.push({
|
||||
title: t("choose_a_license"),
|
||||
description: t("choose_license_description"),
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
"name": "@calcom/prisma",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"bin": {
|
||||
"prisma-enum-generator": "./run-enum-generator.js"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rm -rf .turbo && rm -rf node_modules",
|
||||
"build": "ts-node --transpile-only ./auto-migrations.ts",
|
||||
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
// Wrapper script for the enum generator that ensures correct path resolution
|
||||
// regardless of the current working directory (e.g., running prisma from repo root).
|
||||
// Prisma resolves providers starting with "./" relative to the schema file directory.
|
||||
require("ts-node").register({ transpileOnly: true });
|
||||
require("./enum-generator.ts");
|
||||
@@ -36,7 +36,7 @@ generator kysely {
|
||||
}
|
||||
|
||||
generator enums {
|
||||
provider = "ts-node --transpile-only ./enum-generator.ts"
|
||||
provider = "prisma-enum-generator"
|
||||
}
|
||||
|
||||
enum SchedulingType {
|
||||
|
||||
Reference in New Issue
Block a user