diff --git a/packages/cli/README.md b/packages/cli/README.md index a048574f..1663701d 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -45,6 +45,7 @@ Options: -k, --token the authentication token to use (or set env FLATFILE_API_KEY or FLATFILE_BEARER_TOKEN) -h, --api-url (optional) the API URL to use (or set env FLATFILE_API_URL) -e, --env (optional) the Environment to use (or set env FLATFILE_ENVIRONMENT_ID) + --skip-deployed-check (optional) skip check for deployed agents --help display help for command ``` diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 5cd8a601..a7537d48 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -10,13 +10,13 @@ import { writeErrorToFile } from './shared/utils/error' import { switchInit } from './switch.init' import { switchVersion } from './switch.version' import { createEnvironmentAction } from './x/actions/create.environment.action' -import { deployAction } from './x/actions/deploy.action' import { deleteAction } from './x/actions/delete.action' +import { deployAction } from './x/actions/deploy.action' import { developAction } from './x/actions/develop.action' +import { listAgentsAction } from './x/actions/list-agents.action' import { publishAction } from './x/actions/publish.action' import { publishPubSub } from './x/actions/publish.pubsub' import { quickstartAction } from './x/actions/quickstart.action' -import { listAgentsAction } from './x/actions/list-agents.action' dotenv.config() @@ -78,6 +78,10 @@ program '-e, --env ', '(optional) the Environment to use (or set env FLATFILE_ENVIRONMENT_ID)' ) + .option( + '--skip-deployed-check', + '(optional) bypass check for deployed agents' + ) .action(developAction) program diff --git a/packages/cli/src/x/actions/develop.action.ts b/packages/cli/src/x/actions/develop.action.ts index 22ae5dec..94ed8692 100644 --- a/packages/cli/src/x/actions/develop.action.ts +++ b/packages/cli/src/x/actions/develop.action.ts @@ -1,6 +1,6 @@ import { Client } from '@flatfile/listener' -import { program } from 'commander' import { PubSubDriver } from '@flatfile/listener-driver-pubsub' +import { program } from 'commander' import fs from 'fs' // @ts-expect-error import ncc from '@vercel/ncc' @@ -8,10 +8,10 @@ import ora from 'ora' import path from 'path' import prompts from 'prompts' -import { apiKeyClient } from './auth.action' import { getAuth } from '../../shared/get-auth' import { getEntryFile } from '../../shared/get-entry-file' import { messages } from '../../shared/messages' +import { apiKeyClient } from './auth.action' export async function developAction( file?: string | null | undefined, @@ -19,6 +19,7 @@ export async function developAction( apiUrl: string token: string env: string + skipDeployedCheck: boolean }> ): Promise { const outDir = path.join(process.cwd(), '.flatfile') @@ -54,25 +55,30 @@ export async function developAction( // Check if any agents are listed for environment const apiClient = apiKeyClient({ apiUrl, apiKey: apiKey! }) + const skipDeployedCheck = + options?.skipDeployedCheck ?? + (process.env.FLATFILE_SKIP_DEPLOYED_CHECK ?? '').trim().toLowerCase() === + 'true' + const agents = await apiClient.agents.list({ environmentId: environment.id, }) if (agents?.data && agents?.data?.length > 0) { console.error(messages.warnDeployedAgents(agents.data)) - - const { developLocally } = await prompts({ - type: 'confirm', - name: 'developLocally', - message: 'Would you like to proceed listening locally? (y/n)', - }) - - if (!developLocally) { - ora({ - text: `Local development aborted`, - }).fail() - process.exit(1) + if (!skipDeployedCheck) { + const { developLocally } = await prompts({ + type: 'confirm', + name: 'developLocally', + message: 'Would you like to proceed listening locally? (y/n)', + }) + + if (!developLocally) { + ora({ + text: `Local development aborted`, + }).fail() + process.exit(1) + } } - } const driver = new PubSubDriver(environment.id)