chatgpt-api/packages/cli/src/commands/publish.ts

58 wiersze
1.6 KiB
TypeScript
Czysty Zwykły widok Historia

2025-05-21 12:18:39 +00:00
import { Command } from 'commander'
2025-05-26 17:35:19 +00:00
import type { Context } from '../types'
import { resolveDeployment } from '../lib/resolve-deployment'
import { AuthStore } from '../lib/store'
export function registerPublishCommand({ client, program, logger }: Context) {
const command = new Command('publish')
.description('Publishes a deployment')
.argument('[deploymentIdentifier]', 'Deployment identifier')
.option(
'-c, --cwd <dir>',
'The directory to load the Agentic project config from (defaults to cwd). This directory must contain an "agentic.config.{ts,js,json}" project file.'
)
.action(async (deploymentIdentifier, opts) => {
AuthStore.requireAuth()
if (deploymentIdentifier) {
// TODO: parseFaasIdentifier
}
const deployment = await resolveDeployment({
client,
deploymentIdentifier,
fuzzyDeploymentIdentifierVersion: 'dev',
cwd: opts.cwd,
populate: ['project']
})
if (deployment.published) {
logger.error(
deploymentIdentifier
? `Deployment "${deploymentIdentifier}" is already published`
: `Latest deployment "${deployment.identifier}" is already published`
)
return
}
// TODO
// const version = deployment.version
// // TODO: prompt user for version or bump
// await client.publishDeployment(
// {
// version
// },
// {
// deploymentId: deployment.id
// }
// )
logger.log(deployment)
})
program.addCommand(command)
}