Skip to content

Commit

Permalink
[Function Metadata] Finalize the function-spec CLI command (#28819)
Browse files Browse the repository at this point in the history
Cleans up the instructions for the command, includes the instance url (so we can pipe this into a convex-helpers CLI command), and unhides this command so it will show up in the next `npm` release.

GitOrigin-RevId: 6d40f6f109ad22a4d1446cbb7bba1cde51f49752
  • Loading branch information
jordanhunt22 authored and Convex, Inc. committed Aug 8, 2024
1 parent 6d5c544 commit 7d99d72
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions npm-packages/convex/src/cli/functionSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const functionSpec = new Command("function-spec")
"List argument and return values to your Convex functions.\n\n" +
"By default, this inspects your dev deployment.",
)
.addOption(new Option("--path", "Output as JSON to this file path."))
.addOption(new Option("--file", "Output as JSON to a file."))
.addDeploymentSelectionOptions(
actionDescription("Read function metadata from"),
)
Expand All @@ -37,9 +37,13 @@ export const functionSpec = new Command("function-spec")
{},
)) as any[];

const output = JSON.stringify(functions, null, 2);
const output = JSON.stringify(
{ url: deploymentUrl, functions: functions },
null,
2,
);

if (options.path) {
if (options.file) {
const fileName = `function_spec_${Date.now().valueOf()}.json`;
ctx.fs.writeUtf8File(fileName, output);
logOutput(ctx, chalk.green(`Wrote function spec to ${fileName}`));
Expand Down
2 changes: 1 addition & 1 deletion npm-packages/convex/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async function main() {
.addCommand(update)
.addCommand(logout)
.addCommand(networkTest, { hidden: true })
.addCommand(functionSpec, { hidden: true })
.addCommand(functionSpec)
.addHelpCommand("help <command>", "Show help for given <command>")
.version(version)
// Hide version and help so they don't clutter
Expand Down

0 comments on commit 7d99d72

Please sign in to comment.