Skip to content

Commit 2764bd8

Browse files
emmaling27Convex, Inc.
authored and
Convex, Inc.
committed
Enable components in js-integration-tests (#27632)
GitOrigin-RevId: 6a3c452b4fc133911b9ad7af8ab24c7674815711
1 parent 61cf30d commit 2764bd8

File tree

8 files changed

+41
-38
lines changed

8 files changed

+41
-38
lines changed

crates/application/src/tests/components.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ use crate::{
6666
Application,
6767
};
6868

69-
// $ COMPONENTS_ENABLED=true cargo test -p application --lib -- --ignored
69+
// $ cargo test -p application --lib -- --ignored
7070
// component_v8 --nocapture
7171
#[ignore]
7272
#[convex_macro::test_runtime]

crates/common/src/components/mod.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
use std::{
2-
str::FromStr,
3-
sync::LazyLock,
4-
};
1+
use std::str::FromStr;
52

6-
use cmd_util::env::env_config;
73
use value::{
84
InternalId,
95
TableNamespace,
@@ -35,9 +31,6 @@ pub use self::{
3531
},
3632
};
3733

38-
pub static COMPONENTS_ENABLED: LazyLock<bool> =
39-
LazyLock::new(|| env_config("COMPONENTS_ENABLED", false));
40-
4134
// Globally unique system-assigned ID for a component.
4235
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
4336
pub enum ComponentId {

npm-packages/convex/src/cli/deploy.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
isNonProdBuildEnvironment,
2222
suggestedEnvVarName,
2323
} from "./lib/envvars.js";
24-
import { PushOptions, runPush } from "./lib/push.js";
24+
import { PushOptions } from "./lib/push.js";
2525
import {
2626
CONVEX_DEPLOY_KEY_ENV_VAR_NAME,
2727
bigBrainAPI,
@@ -36,6 +36,7 @@ import {
3636
getConfiguredDeploymentFromEnvVar,
3737
isPreviewDeployKey,
3838
} from "./lib/deployment.js";
39+
import { runPush } from "./lib/components.js";
3940

4041
export const deploy = new Command("deploy")
4142
.summary("Deploy to your prod deployment")
@@ -229,7 +230,6 @@ async function deployToNewPreviewDeployment(
229230
debugBundlePath: options.debugBundlePath,
230231
codegen: options.codegen === "enable",
231232
url: previewUrl,
232-
enableComponents: false,
233233
};
234234
showSpinner(ctx, `Deploying to ${previewUrl}...`);
235235
await runPush(oneoffContext, pushOptions);
@@ -317,7 +317,6 @@ async function deployToExistingDeployment(
317317
debugBundlePath: options.debugBundlePath,
318318
codegen: options.codegen === "enable",
319319
url,
320-
enableComponents: false,
321320
};
322321
showSpinner(
323322
ctx,

npm-packages/convex/src/cli/dev.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
} from "../bundler/context.js";
1616
import { deploymentCredentialsOrConfigure } from "./configure.js";
1717
import { checkAuthorization, performLogin } from "./lib/login.js";
18-
import { PushOptions, runPush } from "./lib/push.js";
18+
import { PushOptions } from "./lib/push.js";
1919
import {
2020
formatDuration,
2121
getCurrentTimeString,
@@ -27,7 +27,7 @@ import { watchLogs } from "./lib/logs.js";
2727
import { runFunctionAndLog, subscribe } from "./lib/run.js";
2828
import { Value } from "../values/index.js";
2929
import { usageStateWarning } from "./lib/usage.js";
30-
import { runComponentsPush } from "./lib/components.js";
30+
import { runPush } from "./lib/components.js";
3131

3232
export const dev = new Command("dev")
3333
.summary("Develop against a dev deployment, watching for changes")
@@ -96,7 +96,6 @@ export const dev = new Command("dev")
9696
.addOption(new Option("--admin-key <adminKey>").hideHelp())
9797
.addOption(new Option("--url <url>").hideHelp())
9898
.addOption(new Option("--debug-bundle-path <path>").hideHelp())
99-
.addOption(new Option("--experimental-components").hideHelp())
10099
// Options for testing
101100
.addOption(new Option("--override-auth-url <url>").hideHelp())
102101
.addOption(new Option("--override-auth-client <id>").hideHelp())
@@ -144,7 +143,6 @@ export const dev = new Command("dev")
144143
debug: false,
145144
debugBundlePath: cmdOptions.debugBundlePath,
146145
codegen: cmdOptions.codegen === "enable",
147-
enableComponents: !!cmdOptions.experimentalComponents,
148146
},
149147
cmdOptions,
150148
),
@@ -177,11 +175,7 @@ export async function watchAndPush(
177175
const ctx = new WatchContext(cmdOptions.traceEvents);
178176
showSpinner(ctx, "Preparing Convex functions...");
179177
try {
180-
if (options.enableComponents) {
181-
await runComponentsPush(ctx, options);
182-
} else {
183-
await runPush(ctx, options);
184-
}
178+
await runPush(ctx, options);
185179
const end = performance.now();
186180
numFailures = 0;
187181
logFinishedStep(

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

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import path from "path";
22
import { 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";
48
import { finishPush, startPush, waitForSchema } from "./deploy2.js";
59
import { version } from "../version.js";
6-
import { PushOptions } from "./push.js";
10+
import { PushOptions, runNonComponentsPush } from "./push.js";
711
import { ensureHasConvexDependency, functionsDir } from "./utils.js";
812
import {
913
bundleDefinitions,
@@ -21,16 +25,30 @@ import {
2125
} from "./deployApi/definitionConfig.js";
2226
import { typeCheckFunctionsInMode } from "./typecheck.js";
2327
import { 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

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import {
88
import { doCodegen } from "./codegen.js";
99
import {
1010
Config,
11+
ProjectConfig,
1112
configFromProjectConfig,
1213
diffConfig,
1314
pullConfig,
1415
pushConfig,
15-
readProjectConfig,
1616
} from "./config.js";
1717
import { pushSchema } from "./indexes.js";
1818
import { typeCheckFunctionsInMode } from "./typecheck.js";
@@ -28,12 +28,15 @@ export type PushOptions = {
2828
debugBundlePath?: string;
2929
codegen: boolean;
3030
url: string;
31-
enableComponents: boolean;
3231
};
3332

34-
export async function runPush(ctx: Context, options: PushOptions) {
33+
export async function runNonComponentsPush(
34+
ctx: Context,
35+
options: PushOptions,
36+
configPath: string,
37+
projectConfig: ProjectConfig,
38+
) {
3539
const timeRunPushStarts = performance.now();
36-
const { configPath, projectConfig } = await readProjectConfig(ctx);
3740
const origin = options.url;
3841
const verbose = options.verbose || options.dryRun;
3942
await ensureHasConvexDependency(ctx, "push");

npm-packages/convex/src/cli/run.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ export const run = new Command("run")
7878
debug: false,
7979
codegen: options.codegen === "enable",
8080
url: deploymentUrl,
81-
enableComponents: false,
8281
},
8382
{
8483
once: true,

npm-packages/convex/src/server/components/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,9 @@ export function defineComponent<Args extends PropertyValidators = {}>(
233233
}
234234

235235
/**
236-
* @internal
236+
* Experimental - DO NOT USE.
237237
*/
238+
// TODO Make this not experimental.
238239
export function defineApp(): AppDefinition {
239240
const ret: RuntimeAppDefinition = {
240241
_isRoot: true,

0 commit comments

Comments
 (0)