diff --git a/packages/dbos-cloud/applications/deploy-app-code.ts b/packages/dbos-cloud/applications/deploy-app-code.ts index ff061cfa4..ec0d2c8c6 100644 --- a/packages/dbos-cloud/applications/deploy-app-code.ts +++ b/packages/dbos-cloud/applications/deploy-app-code.ts @@ -12,6 +12,8 @@ import { dbosEnvPath, CloudAPIErrorResponse, CLILogger, + retrieveApplicationLanguage, + AppLanguages, } from "../cloudutils.js"; import path from "path"; import { Application } from "./types.js"; @@ -91,13 +93,28 @@ export async function deployAppCode( } logger.debug(` ... app name is ${appName}.`); - // Verify lock file exists - logger.debug("Checking for package-lock.json..."); - const packageLockJsonExists = existsSync(path.join(process.cwd(), "package-lock.json")); - logger.debug(` ... package-lock.json found: ${packageLockJsonExists}`); + const appLanguage = retrieveApplicationLanguage(); - if (!packageLockJsonExists) { - logger.error("No package-lock.json found. Please run 'npm install' before deploying."); + if (appLanguage === AppLanguages.Node as string) { + logger.debug("Checking for package-lock.json..."); + const packageLockJsonExists = existsSync(path.join(process.cwd(), "package-lock.json")); + logger.debug(` ... package-lock.json found: ${packageLockJsonExists}`); + + if (!packageLockJsonExists) { + logger.error("No package-lock.json found. Please run 'npm install' before deploying."); + return 1; + } + } else if (appLanguage === AppLanguages.Python as string) { + logger.debug("Checking for requirements.txt..."); + const requirementsTxtExists = existsSync(path.join(process.cwd(), "requirements.txt")); + logger.debug(` ... requirements.txt found: ${requirementsTxtExists}`); + + if (!requirementsTxtExists) { + logger.error("No requirements.txt found. Please create one before deploying."); + return 1; + } + } else { + logger.error(`dbos-config.yaml contains invalid language ${appLanguage}`) return 1; } diff --git a/packages/dbos-cloud/applications/register-app.ts b/packages/dbos-cloud/applications/register-app.ts index 4dada0ba6..8926eb169 100644 --- a/packages/dbos-cloud/applications/register-app.ts +++ b/packages/dbos-cloud/applications/register-app.ts @@ -1,5 +1,5 @@ import axios, { AxiosError } from "axios"; -import { handleAPIErrors, getCloudCredentials, getLogger, isCloudAPIErrorResponse, retrieveApplicationName, CloudAPIErrorResponse } from "../cloudutils.js"; +import { handleAPIErrors, getCloudCredentials, getLogger, isCloudAPIErrorResponse, retrieveApplicationName, CloudAPIErrorResponse, retrieveApplicationLanguage } from "../cloudutils.js"; import chalk from "chalk"; export async function registerApp(dbname: string, host: string, appName?: string): Promise { @@ -11,14 +11,16 @@ export async function registerApp(dbname: string, host: string, appName?: string if (!appName) { return 1; } - logger.info(`Registering application: ${appName}`); + const appLanguage = retrieveApplicationLanguage(); try { + logger.info(`Registering application: ${appName}`); const register = await axios.put( `https://${host}/v1alpha1/${userCredentials.organization}/applications`, { name: appName, database: dbname, + language: appLanguage, }, { headers: { diff --git a/packages/dbos-cloud/cloudutils.ts b/packages/dbos-cloud/cloudutils.ts index 857b25bef..7ed86fa1f 100644 --- a/packages/dbos-cloud/cloudutils.ts +++ b/packages/dbos-cloud/cloudutils.ts @@ -20,6 +20,11 @@ export interface UserProfile { SubscriptionPlan: string; } +export enum AppLanguages { + Node = "node", + Python = "python", +} + export const dbosConfigFilePath = "dbos-config.yaml"; export const DBOSCloudHost = process.env.DBOS_DOMAIN || "cloud.dbos.dev"; export const dbosEnvPath = ".dbos"; @@ -45,6 +50,11 @@ export function retrieveApplicationName(logger: Logger, silent: boolean = false) return appName; } +export function retrieveApplicationLanguage() { + const configFile = loadConfigFile(dbosConfigFilePath); + return configFile.language || AppLanguages.Node; +} + export type CLILogger = ReturnType; let curLogger: Logger | undefined = undefined; export function getLogger(verbose?: boolean): CLILogger {