From 20ddb5ea0afc7a2169ffeae599673c875b6d4aad Mon Sep 17 00:00:00 2001 From: Hassad Date: Thu, 19 Mar 2026 20:25:34 +0100 Subject: [PATCH] refactor(deploy): rename boolean functions with does/is prefix Rename boolean-returning functions in the deploy package to follow the does/is naming convention for better readability: - clientTomlExistsInProject -> doesClientTomlExistInProject - serverTomlExistsInProject -> doesServerTomlExistInProject - localTomlExists -> doesLocalTomlExist - flyctlExists -> doesFlyctlExist - secretExists -> doesSecretExist - buildDirExists -> doesBuildDirExist --- waspc/data/packages/deploy/src/common/waspProject.ts | 2 +- .../packages/deploy/src/providers/fly/CommonOps.ts | 8 ++++---- .../deploy/src/providers/fly/commands/cmd/cmd.ts | 4 ++-- .../src/providers/fly/commands/createDb/createDb.ts | 4 ++-- .../src/providers/fly/commands/deploy/deploy.ts | 12 ++++++------ .../src/providers/fly/commands/launch/launch.ts | 8 ++++---- .../deploy/src/providers/fly/commands/setup/setup.ts | 8 ++++---- .../data/packages/deploy/src/providers/fly/flyCli.ts | 8 ++++---- .../packages/deploy/src/providers/fly/tomlFile.ts | 8 ++++---- 9 files changed, 31 insertions(+), 31 deletions(-) diff --git a/waspc/data/packages/deploy/src/common/waspProject.ts b/waspc/data/packages/deploy/src/common/waspProject.ts index 04bc09687f..956a039eef 100644 --- a/waspc/data/packages/deploy/src/common/waspProject.ts +++ b/waspc/data/packages/deploy/src/common/waspProject.ts @@ -32,7 +32,7 @@ export function assertWaspProjectDirIsAbsoluteAndPresent( assertDirExists(waspProjectDir, dirNameInError); } -export function buildDirExists(waspProjectDir: WaspProjectDir): boolean { +export function doesBuildDirExist(waspProjectDir: WaspProjectDir): boolean { return fs.existsSync(getWaspBuildDir(waspProjectDir)); } diff --git a/waspc/data/packages/deploy/src/providers/fly/CommonOps.ts b/waspc/data/packages/deploy/src/providers/fly/CommonOps.ts index db0d8c787a..9dd5b234e8 100644 --- a/waspc/data/packages/deploy/src/providers/fly/CommonOps.ts +++ b/waspc/data/packages/deploy/src/providers/fly/CommonOps.ts @@ -5,12 +5,12 @@ import { getServerDeploymentDir, } from "../../common/waspProject.js"; import { - clientTomlExistsInProject, + doesClientTomlExistInProject, copyLocalClientTomlToProject, copyLocalServerTomlToProject, copyProjectClientTomlLocally, copyProjectServerTomlLocally, - serverTomlExistsInProject, + doesServerTomlExistInProject, TomlFilePaths, } from "./tomlFile.js"; @@ -48,7 +48,7 @@ function createClientCommonOps( waspProjectDir, paths, cdToDeploymentDir: () => cd(getClientDeploymentDir(waspProjectDir)), - tomlExistsInProject: () => clientTomlExistsInProject(paths), + tomlExistsInProject: () => doesClientTomlExistInProject(paths), copyLocalTomlToProject: () => copyLocalClientTomlToProject(paths), copyProjectTomlLocally: () => copyProjectClientTomlLocally(paths), }; @@ -62,7 +62,7 @@ function createServerCommonOps( waspProjectDir, paths, cdToDeploymentDir: () => cd(getServerDeploymentDir(waspProjectDir)), - tomlExistsInProject: () => serverTomlExistsInProject(paths), + tomlExistsInProject: () => doesServerTomlExistInProject(paths), copyLocalTomlToProject: () => copyLocalServerTomlToProject(paths), copyProjectTomlLocally: () => copyProjectServerTomlLocally(paths), }; diff --git a/waspc/data/packages/deploy/src/providers/fly/commands/cmd/cmd.ts b/waspc/data/packages/deploy/src/providers/fly/commands/cmd/cmd.ts index 9c5e042830..018067df20 100644 --- a/waspc/data/packages/deploy/src/providers/fly/commands/cmd/cmd.ts +++ b/waspc/data/packages/deploy/src/providers/fly/commands/cmd/cmd.ts @@ -6,7 +6,7 @@ import { CommonOps, getCommonOps } from "../../CommonOps.js"; import { deleteLocalToml, getTomlFilePaths, - localTomlExists, + doesLocalTomlExist, } from "../../tomlFile.js"; import { CmdCmdOptions } from "./CmdCmdOptions.js"; @@ -48,7 +48,7 @@ async function runFlyctlCommand( await $`flyctl ${flyctlArgs}`; - if (localTomlExists()) { + if (doesLocalTomlExist()) { commonOps.copyLocalTomlToProject(); } } diff --git a/waspc/data/packages/deploy/src/providers/fly/commands/createDb/createDb.ts b/waspc/data/packages/deploy/src/providers/fly/commands/createDb/createDb.ts index f546e71da4..2abe822da8 100644 --- a/waspc/data/packages/deploy/src/providers/fly/commands/createDb/createDb.ts +++ b/waspc/data/packages/deploy/src/providers/fly/commands/createDb/createDb.ts @@ -7,7 +7,7 @@ import { flyDeployCommand, flySetupCommand } from "../../index.js"; import { getInferredBasenameFromServerToml, getTomlFilePaths, - serverTomlExistsInProject, + doesServerTomlExistInProject, } from "../../tomlFile.js"; import { CreateDbCmdOptions } from "./CreateDbCmdOptions.js"; @@ -19,7 +19,7 @@ export async function createDb( const tomlFilePaths = getTomlFilePaths(cmdOptions); - if (!serverTomlExistsInProject(tomlFilePaths)) { + if (!doesServerTomlExistInProject(tomlFilePaths)) { throw new Error( `${ tomlFilePaths.serverTomlPath diff --git a/waspc/data/packages/deploy/src/providers/fly/commands/deploy/deploy.ts b/waspc/data/packages/deploy/src/providers/fly/commands/deploy/deploy.ts index bbc54a4e77..8a6bc90c5a 100644 --- a/waspc/data/packages/deploy/src/providers/fly/commands/deploy/deploy.ts +++ b/waspc/data/packages/deploy/src/providers/fly/commands/deploy/deploy.ts @@ -16,10 +16,10 @@ import { DeploymentInstructions, } from "../../DeploymentInstructions.js"; import { getFlyAppUrl } from "../../flyAppUrl.js"; -import { secretExists } from "../../flyCli.js"; +import { doesSecretExist } from "../../flyCli.js"; import { flySetupCommand } from "../../index.js"; import { - clientTomlExistsInProject, + doesClientTomlExistInProject, copyLocalClientTomlToProject, copyLocalServerTomlToProject, copyProjectClientTomlLocally, @@ -27,7 +27,7 @@ import { getInferredBasenameFromClientToml, getInferredBasenameFromServerToml, getTomlFilePaths, - serverTomlExistsInProject, + doesServerTomlExistInProject, } from "../../tomlFile.js"; import { DeployCmdOptions } from "./DeployCmdOptions.js"; @@ -40,7 +40,7 @@ export async function deploy(cmdOptions: DeployCmdOptions): Promise { // NOTE: Below, it would be nice if we could store the client, server, and DB names somewhere. // For now we just rely on the suffix naming convention and infer from toml files. - if (!serverTomlExistsInProject(tomlFilePaths)) { + if (!doesServerTomlExistInProject(tomlFilePaths)) { waspSays( `${ tomlFilePaths.serverTomlPath @@ -60,7 +60,7 @@ export async function deploy(cmdOptions: DeployCmdOptions): Promise { await deployServer(deploymentInstructions, cmdOptions); } - if (!clientTomlExistsInProject(tomlFilePaths)) { + if (!doesClientTomlExistInProject(tomlFilePaths)) { waspSays( `${ tomlFilePaths.clientTomlPath @@ -91,7 +91,7 @@ async function deployServer( copyProjectServerTomlLocally(deploymentInstructions.tomlFilePaths); // Make sure we have a DATABASE_URL present. If not, they need to create/attach their DB first. - const databaseUrlSet = await secretExists("DATABASE_URL"); + const databaseUrlSet = await doesSecretExist("DATABASE_URL"); if (!databaseUrlSet) { throw new Error( "Your server app does not have a DATABASE_URL secret set. Perhaps you need to create or attach your database?", diff --git a/waspc/data/packages/deploy/src/providers/fly/commands/launch/launch.ts b/waspc/data/packages/deploy/src/providers/fly/commands/launch/launch.ts index e9f43ebfdc..0dfb97f970 100644 --- a/waspc/data/packages/deploy/src/providers/fly/commands/launch/launch.ts +++ b/waspc/data/packages/deploy/src/providers/fly/commands/launch/launch.ts @@ -1,8 +1,8 @@ import { waspSays } from "../../../../common/terminal.js"; import { - clientTomlExistsInProject, + doesClientTomlExistInProject, getTomlFilePaths, - serverTomlExistsInProject, + doesServerTomlExistInProject, } from "../../tomlFile.js"; import { createDb } from "../createDb/createDb.js"; import { deploy } from "../deploy/deploy.js"; @@ -18,8 +18,8 @@ export async function launch( const tomlFilePaths = getTomlFilePaths(cmdOptions); if ( - serverTomlExistsInProject(tomlFilePaths) || - clientTomlExistsInProject(tomlFilePaths) + doesServerTomlExistInProject(tomlFilePaths) || + doesClientTomlExistInProject(tomlFilePaths) ) { throw new Error( "You already have Fly toml files. The launch command is intended to be run one time on a new Fly project. Please try a different command.", diff --git a/waspc/data/packages/deploy/src/providers/fly/commands/setup/setup.ts b/waspc/data/packages/deploy/src/providers/fly/commands/setup/setup.ts index 6c67e5c675..2df10cceae 100644 --- a/waspc/data/packages/deploy/src/providers/fly/commands/setup/setup.ts +++ b/waspc/data/packages/deploy/src/providers/fly/commands/setup/setup.ts @@ -15,14 +15,14 @@ import { import { getFlyAppUrl } from "../../flyAppUrl.js"; import { createFlyDbCommand } from "../../index.js"; import { - clientTomlExistsInProject, + doesClientTomlExistInProject, copyLocalClientTomlToProject, copyLocalServerTomlToProject, deleteLocalToml, doesLocalTomlContainLine, getTomlFilePaths, replaceLineInLocalToml, - serverTomlExistsInProject, + doesServerTomlExistInProject, } from "../../tomlFile.js"; import { SetupCmdOptions } from "./SetupCmdOptions.js"; @@ -47,13 +47,13 @@ export async function setup( tomlFilePaths, }); - if (serverTomlExistsInProject(tomlFilePaths)) { + if (doesServerTomlExistInProject(tomlFilePaths)) { waspSays(`${tomlFilePaths.serverTomlPath} exists. Skipping server setup.`); } else { await setupServer(deploymentInstructions); } - if (clientTomlExistsInProject(tomlFilePaths)) { + if (doesClientTomlExistInProject(tomlFilePaths)) { waspSays(`${tomlFilePaths.clientTomlPath} exists. Skipping client setup.`); } else { await setupClient(deploymentInstructions); diff --git a/waspc/data/packages/deploy/src/providers/fly/flyCli.ts b/waspc/data/packages/deploy/src/providers/fly/flyCli.ts index 2ce9be73b6..54335d9576 100644 --- a/waspc/data/packages/deploy/src/providers/fly/flyCli.ts +++ b/waspc/data/packages/deploy/src/providers/fly/flyCli.ts @@ -7,7 +7,7 @@ import { FlySecretListSchema, } from "./jsonOutputSchemas.js"; -export async function flyctlExists(): Promise { +export async function doesFlyctlExist(): Promise { try { await $`flyctl version`; return true; @@ -48,8 +48,8 @@ async function ensureUserLoggedIn(): Promise { } export async function ensureFlyReady(): Promise { - const doesFlyctlExist = await flyctlExists(); - if (!doesFlyctlExist) { + const flyctlExists = await doesFlyctlExist(); + if (!flyctlExists) { throw new Error( `The Fly.io CLI is not available on this system.\nPlease install the flyctl here: https://fly.io/docs/hands-on/install-flyctl`, ); @@ -79,7 +79,7 @@ async function regionExists(regionCode: string): Promise { }); } -export async function secretExists(secretName: string): Promise { +export async function doesSecretExist(secretName: string): Promise { const proc = await $`flyctl secrets list -j`; const secrets = FlySecretListSchema.parse(proc.json()); return secrets.some((s) => s.name === secretName); diff --git a/waspc/data/packages/deploy/src/providers/fly/tomlFile.ts b/waspc/data/packages/deploy/src/providers/fly/tomlFile.ts index 93ba261749..b1d7ab33d8 100644 --- a/waspc/data/packages/deploy/src/providers/fly/tomlFile.ts +++ b/waspc/data/packages/deploy/src/providers/fly/tomlFile.ts @@ -20,7 +20,7 @@ export function getTomlFilePaths(cmdOptions: CommonCmdOptions): TomlFilePaths { }; } -export function serverTomlExistsInProject(paths: TomlFilePaths): boolean { +export function doesServerTomlExistInProject(paths: TomlFilePaths): boolean { return fs.existsSync(paths.serverTomlPath); } @@ -32,7 +32,7 @@ export function copyProjectServerTomlLocally(paths: TomlFilePaths): void { fs.copyFileSync(paths.serverTomlPath, "fly.toml"); } -export function clientTomlExistsInProject(paths: TomlFilePaths): boolean { +export function doesClientTomlExistInProject(paths: TomlFilePaths): boolean { return fs.existsSync(paths.clientTomlPath); } @@ -44,12 +44,12 @@ export function copyProjectClientTomlLocally(paths: TomlFilePaths): void { fs.copyFileSync(paths.clientTomlPath, "fly.toml"); } -export function localTomlExists(): boolean { +export function doesLocalTomlExist(): boolean { return fs.existsSync("fly.toml"); } export function deleteLocalToml(): void { - if (localTomlExists()) { + if (doesLocalTomlExist()) { fs.unlinkSync("fly.toml"); } }