Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/cli/src/cli/commands/agents/pull.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { dirname, join } from "node:path";
import type { Command } from "commander";
import type { CLIContext, RunCommandResult } from "@/cli/types.js";
import { Base44Command, runTask } from "@/cli/utils/index.js";
import { Base44Command } from "@/cli/utils/index.js";
import { readProjectConfig } from "@/core/index.js";
import { fetchAgents, writeAgents } from "@/core/resources/agent/index.js";

async function pullAgentsAction({
log,
runTask,
}: CLIContext): Promise<RunCommandResult> {
const { project } = await readProjectConfig();

Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/cli/commands/agents/push.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { Command } from "commander";
import type { CLIContext, RunCommandResult } from "@/cli/types.js";
import { Base44Command, runTask } from "@/cli/utils/index.js";
import { Base44Command } from "@/cli/utils/index.js";
import { readProjectConfig } from "@/core/index.js";
import { pushAgents } from "@/core/resources/agent/index.js";

async function pushAgentsAction({
log,
runTask,
}: CLIContext): Promise<RunCommandResult> {
const { agents } = await readProjectConfig();

Expand Down
12 changes: 9 additions & 3 deletions packages/cli/src/cli/commands/auth/login-flow.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Logger } from "@base44-cli/logger";
import pWaitFor from "p-wait-for";
import type { CLIContext, RunCommandResult } from "@/cli/types.js";
import { runTask } from "@/cli/utils/index.js";
import type { RunTaskFn } from "@/cli/utils/runTask.js";
import { theme } from "@/cli/utils/theme.js";
import type {
DeviceCodeResponse,
Expand All @@ -17,6 +17,7 @@ import {

async function generateAndDisplayDeviceCode(
log: Logger,
runTask: RunTaskFn,
): Promise<DeviceCodeResponse> {
const deviceCodeResponse = await runTask(
"Generating device code...",
Expand All @@ -41,6 +42,7 @@ async function waitForAuthentication(
deviceCode: string,
expiresIn: number,
interval: number,
runTask: RunTaskFn,
): Promise<TokenResponse> {
let tokenResponse: TokenResponse | undefined;

Expand Down Expand Up @@ -101,13 +103,17 @@ async function saveAuthData(
* Execute the login flow (device code authentication).
* This function is separate from the command to avoid circular dependencies.
*/
export async function login({ log }: CLIContext): Promise<RunCommandResult> {
const deviceCodeResponse = await generateAndDisplayDeviceCode(log);
export async function login({
log,
runTask,
}: CLIContext): Promise<RunCommandResult> {
const deviceCodeResponse = await generateAndDisplayDeviceCode(log, runTask);

const token = await waitForAuthentication(
deviceCodeResponse.deviceCode,
deviceCodeResponse.expiresIn,
deviceCodeResponse.interval,
runTask,
);

const userInfo = await getUserInfo(token.accessToken);
Expand Down
8 changes: 2 additions & 6 deletions packages/cli/src/cli/commands/connectors/list-available.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import type { Command } from "commander";
import type { CLIContext, RunCommandResult } from "@/cli/types.js";
import {
Base44Command,
formatYaml,
runTask,
YAML_INDENT,
} from "@/cli/utils/index.js";
import { Base44Command, formatYaml, YAML_INDENT } from "@/cli/utils/index.js";
import { listAvailableIntegrations } from "@/core/resources/connector/index.js";

async function listAvailableAction({
log,
runTask,
}: CLIContext): Promise<RunCommandResult> {
const { integrations } = await runTask(
"Fetching available integrations from Base44",
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/cli/commands/connectors/pull.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { dirname, join } from "node:path";
import type { Command } from "commander";
import type { CLIContext, RunCommandResult } from "@/cli/types.js";
import { Base44Command, runTask } from "@/cli/utils/index.js";
import { Base44Command } from "@/cli/utils/index.js";
import { readProjectConfig } from "@/core/index.js";
import {
pullAllConnectors,
Expand All @@ -10,6 +10,7 @@ import {

async function pullConnectorsAction({
log,
runTask,
}: CLIContext): Promise<RunCommandResult> {
const { project } = await readProjectConfig();

Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/cli/commands/connectors/push.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Logger } from "@base44-cli/logger";
import type { Command } from "commander";
import type { CLIContext, RunCommandResult } from "@/cli/types.js";
import { Base44Command, runTask, theme } from "@/cli/utils/index.js";
import { Base44Command, theme } from "@/cli/utils/index.js";
import { getConnectorsUrl } from "@/cli/utils/urls.js";
import { readProjectConfig } from "@/core/index.js";
import {
Expand Down Expand Up @@ -93,6 +93,7 @@ function printSummary(
async function pushConnectorsAction({
isNonInteractive,
log,
runTask,
}: CLIContext): Promise<RunCommandResult> {
const { connectors } = await readProjectConfig();

Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/cli/commands/entities/push.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Command } from "commander";
import type { CLIContext, RunCommandResult } from "@/cli/types.js";
import { Base44Command, runTask } from "@/cli/utils/index.js";
import { Base44Command } from "@/cli/utils/index.js";
import { readProjectConfig } from "@/core/index.js";
import { pushEntities } from "@/core/resources/entity/index.js";

async function pushEntitiesAction({
log,
runTask,
}: CLIContext): Promise<RunCommandResult> {
const { entities } = await readProjectConfig();

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/cli/commands/functions/delete.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { Command } from "commander";
import type { CLIContext, RunCommandResult } from "@/cli/types.js";
import { Base44Command, runTask } from "@/cli/utils/index.js";
import { Base44Command } from "@/cli/utils/index.js";
import { ApiError } from "@/core/errors.js";
import { deleteSingleFunction } from "@/core/resources/function/api.js";

async function deleteFunctionsAction(
_ctx: CLIContext,
{ runTask }: CLIContext,
names: string[],
): Promise<RunCommandResult> {
let deleted = 0;
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/cli/commands/functions/list.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { Command } from "commander";
import type { CLIContext, RunCommandResult } from "@/cli/types.js";
import { Base44Command, runTask, theme } from "@/cli/utils/index.js";
import { Base44Command, theme } from "@/cli/utils/index.js";
import { listDeployedFunctions } from "@/core/resources/function/api.js";

async function listFunctionsAction({
log,
runTask,
}: CLIContext): Promise<RunCommandResult> {
const { functions } = await runTask(
"Fetching functions...",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/cli/commands/functions/pull.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { dirname, join } from "node:path";
import type { Command } from "commander";
import type { CLIContext, RunCommandResult } from "@/cli/types.js";
import { Base44Command, runTask } from "@/cli/utils/index.js";
import { Base44Command } from "@/cli/utils/index.js";
import { readProjectConfig } from "@/core/index.js";
import { listDeployedFunctions } from "@/core/resources/function/api.js";
import { writeFunctions } from "@/core/resources/function/pull.js";

async function pullFunctionsAction(
{ log }: CLIContext,
{ log, runTask }: CLIContext,
name: string | undefined,
): Promise<RunCommandResult> {
const { project } = await readProjectConfig();
Expand Down
22 changes: 11 additions & 11 deletions packages/cli/src/cli/commands/project/create.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { basename, join, resolve } from "node:path";
import type { Logger } from "@base44-cli/logger";
import type { Option } from "@clack/prompts";
import { confirm, group, isCancel, select, text } from "@clack/prompts";
import { Argument, type Command } from "commander";
Expand All @@ -10,7 +9,6 @@ import {
Base44Command,
getDashboardUrl,
onPromptCancel,
runTask,
theme,
} from "@/cli/utils/index.js";
import { InvalidInputError } from "@/core/errors.js";
Expand Down Expand Up @@ -57,7 +55,7 @@ function validateNonInteractiveFlags(command: Command): void {

async function createInteractive(
options: CreateOptions,
log: Logger,
ctx: Pick<CLIContext, "log" | "runTask">,
): Promise<RunCommandResult> {
const templates = await listTemplates();
const templateOptions: Option<Template>[] = templates.map((t) => ({
Expand Down Expand Up @@ -112,15 +110,15 @@ async function createInteractive(
skills: options.skills,
isInteractive: true,
},
log,
ctx,
);
}

async function createNonInteractive(
options: CreateOptions,
log: Logger,
ctx: Pick<CLIContext, "log" | "runTask">,
): Promise<RunCommandResult> {
log.info(`Creating a new project at ${resolve(options.path!)}`);
ctx.log.info(`Creating a new project at ${resolve(options.path!)}`);

const template = await getTemplateById(
options.template ?? DEFAULT_TEMPLATE_ID,
Expand All @@ -135,7 +133,7 @@ async function createNonInteractive(
skills: options.skills,
isInteractive: false,
},
log,
ctx,
);
}

Expand All @@ -157,7 +155,7 @@ async function executeCreate(
skills?: boolean;
isInteractive: boolean;
},
log: Logger,
{ log, runTask }: Pick<CLIContext, "log" | "runTask">,
): Promise<RunCommandResult> {
const name = rawName.trim();
const resolvedPath = resolve(projectPath);
Expand Down Expand Up @@ -295,7 +293,7 @@ async function executeCreate(
}

async function createAction(
{ log, isNonInteractive }: CLIContext,
{ log, runTask, isNonInteractive }: CLIContext,
name: string | undefined,
options: CreateOptions,
): Promise<RunCommandResult> {
Expand All @@ -318,13 +316,15 @@ async function createAction(
);
}

const ctx = { log, runTask };

if (skipPrompts) {
return await createNonInteractive(
{ name: options.name ?? name, ...options },
log,
ctx,
);
}
return await createInteractive({ name, ...options }, log);
return await createInteractive({ name, ...options }, ctx);
}

export function getCreateCommand(): Command {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/cli/commands/project/eject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import kebabCase from "lodash/kebabCase";
import { deployAction } from "@/cli/commands/project/deploy.js";
import { CLIExitError } from "@/cli/errors.js";
import type { CLIContext, RunCommandResult } from "@/cli/types.js";
import { Base44Command, runTask, theme } from "@/cli/utils/index.js";
import { Base44Command, theme } from "@/cli/utils/index.js";
import type { Project } from "@/core/index.js";
import {
createProject,
Expand All @@ -31,7 +31,7 @@ async function eject(
ctx: CLIContext,
options: EjectOptions,
): Promise<RunCommandResult> {
const { log, isNonInteractive } = ctx;
const { log, runTask, isNonInteractive } = ctx;

if (isNonInteractive && !options.projectId) {
throw new InvalidInputError(
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/cli/commands/project/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
Base44Command,
getDashboardUrl,
onPromptCancel,
runTask,
theme,
} from "@/cli/utils/index.js";
import {
Expand Down Expand Up @@ -130,7 +129,7 @@ async function link(
ctx: CLIContext,
options: LinkOptions,
): Promise<RunCommandResult> {
const { log, isNonInteractive } = ctx;
const { log, runTask, isNonInteractive } = ctx;

const skipPrompts = !!options.create || !!options.projectId;
if (!skipPrompts && isNonInteractive) {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/cli/commands/secrets/delete.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Command } from "commander";
import type { CLIContext, RunCommandResult } from "@/cli/types.js";
import { Base44Command, runTask } from "@/cli/utils/index.js";
import { Base44Command } from "@/cli/utils/index.js";
import { deleteSecret } from "@/core/resources/secret/index.js";

async function deleteSecretAction(
_ctx: CLIContext,
{ runTask }: CLIContext,
key: string,
): Promise<RunCommandResult> {
await runTask(
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/cli/commands/secrets/list.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { Command } from "commander";
import type { CLIContext, RunCommandResult } from "@/cli/types.js";
import { Base44Command, runTask } from "@/cli/utils/index.js";
import { Base44Command } from "@/cli/utils/index.js";
import { listSecrets } from "@/core/resources/secret/index.js";

async function listSecretsAction({
log,
runTask,
}: CLIContext): Promise<RunCommandResult> {
const secrets = await runTask(
"Fetching secrets from Base44",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/cli/commands/secrets/set.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { resolve } from "node:path";
import type { Command } from "commander";
import type { CLIContext, RunCommandResult } from "@/cli/types.js";
import { Base44Command, runTask } from "@/cli/utils/index.js";
import { Base44Command } from "@/cli/utils/index.js";
import { InvalidInputError } from "@/core/errors.js";
import { setSecrets } from "@/core/resources/secret/index.js";
import { parseEnvFile } from "@/core/utils/index.js";
Expand Down Expand Up @@ -50,7 +50,7 @@ function validateInput(entries: string[], options: { envFile?: string }): void {
}

async function setSecretsAction(
{ log }: CLIContext,
{ log, runTask }: CLIContext,
entries: string[],
options: { envFile?: string },
): Promise<RunCommandResult> {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/cli/commands/site/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { resolve } from "node:path";
import { confirm, isCancel } from "@clack/prompts";
import type { Command } from "commander";
import type { CLIContext, RunCommandResult } from "@/cli/types.js";
import { Base44Command, runTask } from "@/cli/utils/index.js";
import { Base44Command } from "@/cli/utils/index.js";
import { ConfigNotFoundError, InvalidInputError } from "@/core/errors.js";
import { readProjectConfig } from "@/core/project/index.js";
import { deploySite } from "@/core/site/index.js";
Expand All @@ -12,7 +12,7 @@ interface DeployOptions {
}

async function deployAction(
{ isNonInteractive }: CLIContext,
{ isNonInteractive, runTask }: CLIContext,
options: DeployOptions,
): Promise<RunCommandResult> {
if (isNonInteractive && !options.yes) {
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/cli/commands/types/generate.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { Command } from "commander";
import type { CLIContext, RunCommandResult } from "@/cli/types.js";
import { Base44Command, runTask } from "@/cli/utils/index.js";
import { Base44Command } from "@/cli/utils/index.js";
import { readProjectConfig } from "@/core/index.js";
import { generateTypesFile, updateProjectConfig } from "@/core/types/index.js";

const TYPES_FILE_PATH = "base44/.types/types.d.ts";

async function generateTypesAction(
_ctx: CLIContext,
): Promise<RunCommandResult> {
async function generateTypesAction({
runTask,
}: CLIContext): Promise<RunCommandResult> {
const { entities, functions, agents, connectors, project } =
await readProjectConfig();

Expand Down
Loading
Loading