Skip to content

non interactive runTask function#441

Open
kfirstri wants to merge 1 commit intomainfrom
non-tty-run-task
Open

non interactive runTask function#441
kfirstri wants to merge 1 commit intomainfrom
non-tty-run-task

Conversation

@kfirstri
Copy link
Collaborator

@kfirstri kfirstri commented Mar 24, 2026

Note

Description

This PR refactors runTask from a single module-level function into a factory pattern with two implementations: createInteractiveRunTask() (uses a clack spinner) and createSimpleRunTask(log) (uses the logger). The chosen implementation is created at startup based on TTY detection and injected into CLIContext, so commands now receive runTask via dependency injection rather than importing it directly. This also fixes non-interactive environments where the spinner was previously used even when stdout was not a TTY.

Related Issue

None

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe):

Changes Made

  • Extracted RunTaskFn type and replaced the single runTask export with createInteractiveRunTask() and createSimpleRunTask(log) factory functions in runTask.ts
  • Added runTask: RunTaskFn field to CLIContext and removed runTask from the utils/index.ts barrel export
  • Instantiated the correct runTask implementation in cli/index.ts based on TTY detection (isNonInteractive) and injected it into CLIContext
  • Updated all 17 command files to destructure runTask from CLIContext instead of importing it directly

Testing

  • I have tested these changes locally
  • I have added/updated tests as needed
  • All tests pass (npm test)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have updated docs/ (AGENTS.md) if I made architectural changes

Additional Notes

The createSimpleRunTask implementation logs the start message via log.info, progress updates via log.info, success via log.success, and errors via log.error — mirroring the spinner lifecycle for non-interactive consumers.


🤖 Generated by Claude | 2026-03-24 00:00 UTC

@kfirstri kfirstri requested a review from artemdemo March 24, 2026 14:53
@kfirstri kfirstri self-assigned this Mar 24, 2026
@github-actions
Copy link
Contributor

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.0.47-pr.441.3070a4f

Prefer not to change any import paths? Install using npm alias so your code still imports base44:

npm i "base44@npm:@base44-preview/cli@0.0.47-pr.441.3070a4f"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.0.47-pr.441.3070a4f"
  }
}

Preview published to npm registry — try new features instantly!

@kfirstri
Copy link
Collaborator Author

@artemdemo I wonder what do you think about this. moving the runTask to be injected from the CLIContext.

  • It's nice to have it support non interactive and such
  • I feel that maybe it's not the right place for runTask 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant