-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
npx convex self-host function-spec (#34120)
refactor the function-spec CLI tool so it can be called from both `npx convex function-spec` and `npx convex self-host function-spec` GitOrigin-RevId: ab2d298f49b189b5533814ef46a71e72802550ad
- Loading branch information
Showing
3 changed files
with
61 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import chalk from "chalk"; | ||
import { logOutput } from "../../bundler/context.js"; | ||
import { runSystemQuery } from "./run.js"; | ||
import { Context } from "../../bundler/context.js"; | ||
|
||
export async function functionSpecForDeployment( | ||
ctx: Context, | ||
options: { | ||
deploymentUrl: string; | ||
adminKey: string; | ||
file: boolean; | ||
}, | ||
) { | ||
const functions = (await runSystemQuery(ctx, { | ||
deploymentUrl: options.deploymentUrl, | ||
adminKey: options.adminKey, | ||
functionName: "_system/cli/modules:apiSpec", | ||
componentPath: undefined, | ||
args: {}, | ||
})) as any[]; | ||
|
||
const output = JSON.stringify( | ||
{ url: options.deploymentUrl, functions: functions }, | ||
null, | ||
2, | ||
); | ||
|
||
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}`)); | ||
} else { | ||
logOutput(ctx, output); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters