Skip to content

Commit fcdb2d3

Browse files
thomasballingerConvex, Inc.
authored andcommitted
Allow pushing code when convex is a peer dependency. (#27422)
Allow pushing code when a package has convex as a peer dependency. This is useful when writing example apps in libraries: the repo might contain convex functions to push for testing but convex isn't a dependency of the project. It's possible but confusing to list a dependency as both a devDependency and a peerDependency. So just allow 'convex' to be in peerDependencies. GitOrigin-RevId: d8afec97e917f408b9eca2b1b29ac4a87112df70
1 parent 91981ab commit fcdb2d3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

npm-packages/convex/src/cli/lib/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ export async function validateOrSelectProject(
508508
*/
509509
export async function loadPackageJson(
510510
ctx: Context,
511+
includePeerDeps = false,
511512
): Promise<Record<string, string>> {
512513
let packageJson;
513514
try {
@@ -533,14 +534,15 @@ export async function loadPackageJson(
533534
return await ctx.crash(1, "invalid filesystem data");
534535
}
535536
const packages = {
537+
...(includePeerDeps ? obj.peerDependencies ?? {} : {}),
536538
...(obj.dependencies ?? {}),
537539
...(obj.devDependencies ?? {}),
538540
};
539541
return packages;
540542
}
541543

542544
export async function ensureHasConvexDependency(ctx: Context, cmd: string) {
543-
const packages = await loadPackageJson(ctx);
545+
const packages = await loadPackageJson(ctx, true);
544546
const hasConvexDependency = "convex" in packages;
545547
if (!hasConvexDependency) {
546548
logFailure(

0 commit comments

Comments
 (0)