Skip to content

Commit a04cccb

Browse files
thomasballingerConvex, Inc.
authored andcommitted
Components CLI parity (#30650)
Add `--run-component` flag in `convex dev --run foo:bar --run-component baz` and stop hiding component-related functionality in the CLI. GitOrigin-RevId: 5a7e089607fe567641111dd714c0709d22875ee3
1 parent 701354b commit a04cccb

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

src/cli/convexImport.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ export const convexImport = new Command("import")
8080
new Option(
8181
"--component <path>",
8282
"Path to the component in the component tree defined in convex.config.ts",
83-
// TODO(ENG-6967): Remove hideHelp before launching components
84-
).hideHelp(),
83+
),
8584
)
8685
.addDeploymentSelectionOptions(actionDescription("Import data into"))
8786
.argument("<path>", "Path to the input file")

src/cli/data.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export const data = new Command("data")
4949
"--component <path>",
5050
"Path to the component in the component tree defined in convex.config.ts.\n" +
5151
" By default, inspects data in the root component",
52-
// TODO(ENG-6967): Remove hideHelp before launching components
5352
).hideHelp(),
5453
)
5554
.addDeploymentSelectionOptions(actionDescription("Inspect the database in"))

src/cli/dev.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ export const dev = new Command("dev")
8585
"The identifier of the function to run in step 3, " +
8686
"like `init` or `dir/file:myFunction`",
8787
)
88+
.option(
89+
"--run-component <functionName>",
90+
"If --run is used and the function is in a component, the path the component tree defined in convex.config.ts. " +
91+
"Components are a beta feature. This flag is unstable and may change in subsequent releases.",
92+
)
8893
.addOption(
8994
new Option(
9095
"--prod",
@@ -128,6 +133,15 @@ export const dev = new Command("dev")
128133
await ctx.flushAndExit(-2);
129134
});
130135

136+
if (cmdOptions.runComponent && !cmdOptions.run) {
137+
return await ctx.crash({
138+
exitCode: 1,
139+
errorType: "fatal",
140+
printedMessage:
141+
"Can't specify `--run-component` option without `--run`",
142+
});
143+
}
144+
131145
if (cmdOptions.debugBundlePath !== undefined && !cmdOptions.once) {
132146
return await ctx.crash({
133147
exitCode: 1,
@@ -221,6 +235,7 @@ export async function watchAndPush(
221235
options: PushOptions,
222236
cmdOptions: {
223237
run?: string;
238+
runComponent?: string;
224239
once: boolean;
225240
untilSuccess: boolean;
226241
traceEvents: boolean;
@@ -250,7 +265,12 @@ export async function watchAndPush(
250265
)})`,
251266
);
252267
if (cmdOptions.run !== undefined && !ran) {
253-
await runFunctionInDev(ctx, options, cmdOptions.run);
268+
await runFunctionInDev(
269+
ctx,
270+
options,
271+
cmdOptions.run,
272+
cmdOptions.runComponent,
273+
);
254274
ran = true;
255275
}
256276
pushed = true;
@@ -339,14 +359,15 @@ async function runFunctionInDev(
339359
adminKey: string;
340360
},
341361
functionName: string,
362+
componentPath: string | undefined,
342363
) {
343364
await runFunctionAndLog(
344365
ctx,
345366
credentials.url,
346367
credentials.adminKey,
347368
functionName,
348369
{},
349-
undefined,
370+
componentPath,
350371
{
351372
onSuccess: () => {
352373
logFinishedStep(ctx, `Finished running function "${functionName}"`);

0 commit comments

Comments
 (0)