11import path from "path" ;
22import { Context , changeSpinner , logError } from "../../bundler/context.js" ;
3- import { configFromProjectConfig , readProjectConfig } from "./config.js" ;
3+ import {
4+ ProjectConfig ,
5+ configFromProjectConfig ,
6+ readProjectConfig ,
7+ } from "./config.js" ;
48import { finishPush , startPush , waitForSchema } from "./deploy2.js" ;
59import { version } from "../version.js" ;
6- import { PushOptions } from "./push.js" ;
10+ import { PushOptions , runNonComponentsPush } from "./push.js" ;
711import { ensureHasConvexDependency , functionsDir } from "./utils.js" ;
812import {
913 bundleDefinitions ,
@@ -21,16 +25,30 @@ import {
2125} from "./deployApi/definitionConfig.js" ;
2226import { typeCheckFunctionsInMode } from "./typecheck.js" ;
2327import { withTmpDir } from "../../bundler/fs.js" ;
28+ import { ROOT_DEFINITION_FILENAME } from "./components/constants.js" ;
2429
25- export async function runComponentsPush ( ctx : Context , options : PushOptions ) {
30+ export async function runPush ( ctx : Context , options : PushOptions ) {
2631 const { configPath, projectConfig } = await readProjectConfig ( ctx ) ;
32+ const convexDir = functionsDir ( configPath , projectConfig ) ;
33+ const componentRootPath = path . resolve (
34+ path . join ( convexDir , ROOT_DEFINITION_FILENAME ) ,
35+ ) ;
36+ if ( ctx . fs . exists ( componentRootPath ) ) {
37+ await runComponentsPush ( ctx , options , configPath , projectConfig ) ;
38+ } else {
39+ await runNonComponentsPush ( ctx , options , configPath , projectConfig ) ;
40+ }
41+ }
42+
43+ export async function runComponentsPush (
44+ ctx : Context ,
45+ options : PushOptions ,
46+ configPath : string ,
47+ projectConfig : ProjectConfig ,
48+ ) {
2749 const verbose = options . verbose || options . dryRun ;
2850 await ensureHasConvexDependency ( ctx , "push" ) ;
2951
30- if ( ! options . codegen ) {
31- logError ( ctx , "disabling codegen not allowed" ) ;
32- await ctx . crash ( 1 , "fatal" ) ;
33- }
3452 if ( options . dryRun ) {
3553 logError ( ctx , "dryRun not allowed yet" ) ;
3654 await ctx . crash ( 1 , "fatal" ) ;
@@ -39,10 +57,6 @@ export async function runComponentsPush(ctx: Context, options: PushOptions) {
3957 logError ( ctx , "debugBundlePath not allowed yet" ) ;
4058 await ctx . crash ( 1 , "fatal" ) ;
4159 }
42- if ( ! options . enableComponents ) {
43- logError ( ctx , "enableComponents must be true" ) ;
44- await ctx . crash ( 1 , "fatal" ) ;
45- }
4660
4761 const convexDir = functionsDir ( configPath , projectConfig ) ;
4862
0 commit comments