Skip to content

Register the top-level setup command in the CLI #1604

Closed

Description

@propr-dev

Context

Users need a first-class propr setup command that discovers the environment, launches the interactive wizard when possible, and falls back to the sequential wizard when requested or required.

Requirements

  • Add createSetupCommand().
  • Register it in commands/index.ts and packages/cli/src/index.ts.
  • Add help text explaining that setup is safe to re-run.
  • Support --root, --no-tui, and --skip-remote-image-check.
  • Use Ink when stdin/stdout are TTY and no fallback flag is provided.

Implementation Specification

Create packages/cli/src/commands/setupCommand.ts; update command barrel and CLI entrypoint.

Acceptance Criteria

  • propr setup --help shows the command and options.
  • propr setup --no-tui uses the sequential fallback.
  • propr setup attempts Ink first and falls back to sequential if Ink cannot render.

Created by ProPR AI Planner

Activity

  1. propr-dev commented on Jun 22, 2026

    @propr-dev
    ContributorAuthor

    Suggested Implementation:

    Implementation Approach

    The command action stays thin: resolve root, select renderer, and handle errors. All setup logic lives in the engine so command registration does not become hard to maintain. We register setup near other control-plane commands because it is the recommended guided path over check, init stack, and start.

    File: packages/cli/src/commands/setupCommand.ts (new file)

    Why this file: This file exposes setup as a Commander command and chooses between the Ink and sequential renderers.

    import { Command } from 'commander';
    import { resolveSetupRoot } from './setup/state.js';
    import { runSequentialSetup } from './setup/sequential.js';
    import type { SetupRunOptions } from './setup/types.js';
    
    function canUseTui(options: { noTui?: boolean }): boolean {
      return !options.noTui && Boolean(process.stdin.isTTY && process.stdout.isTTY) && process.env.NO_COLOR === undefined;
    }
    
    function isTuiFallbackError(error: unknown): boolean {
      const message = error instanceof Error ? error.message : String(error);
      return /raw mode|setRawMode|stdin.*tty|not a tty|ink|setup cancelled/i.test(message);
    }
    
    export function createSetupCommand(): Command {
      return new Command('setup')
        .description('Run the guided ProPR setup wizard')
        .option('--root <dir>', 'Stack root directory where .env/data/logs/repos live')
        .option('--no-tui', 'Use the sequential text wizard instead of the Ink TUI')
        .option('--skip-remote-image-check', 'Skip registry freshness checks during setup')
        .addHelpText('after', `
    Setup combines environment checks, stack initialization, selective image pulls,
    agent authentication guidance, GitHub setup, stack startup, whitelist setup,
    optional repository setup, and Web UI access.
    
    The command is safe to re-run: it preserves existing stack data and does not
    rewrite .env wholesale. Use it later to adjust basic setup choices.
    
    Examples:
      $ propr setup
      $ propr setup --root /srv/propr
      $ propr setup --no-tui
    `)
        .action(async (options: { root?: string; noTui?: boolean; skipRemoteImageCheck?: boolean }) => {
          try {
            const rootDir = await resolveSetupRoot(options.root);
            const runOptions: SetupRunOptions = {
              root: rootDir,
              noTui: options.noTui,
              skipRemoteImageCheck: options.skipRemoteImageCheck,
            };
    
            if (canUseTui(options)) {
              try {
                const { renderSetupWizard } = await import('../tui/app.js');
                const finalState = await renderSetupWizard(rootDir, runOptions);
                const webStep = finalState.steps.find((step) => step.id === 'web-ui');
                if (webStep?.detail) console.log(webStep.detail);
                return;
              } catch (error) {
                if (!isTuiFallbackError(error)) throw error;
                // Fall back instead of failing because many otherwise-interactive
                // SSH terminals cannot support Ink raw mode reliably.
                console.log('Interactive TUI is not available; falling back to the sequential setup wizard.');
              }
            }
    
            const finalState = await runSequentialSetup(rootDir, runOptions);
            const webStep = finalState.steps.find((step) => step.id === 'web-ui');
            if (webStep?.detail) console.log(webStep.detail);
          } catch (error) {
            console.error(`Error running setup: ${(error as Error).message}`);
            process.exit(1);
          }
        });
    }

    File: packages/cli/src/commands/index.ts

    Why this file: The command barrel is the integration surface used by the CLI entrypoint. Exporting setup here matches existing command registration patterns.

    --- a/packages/cli/src/commands/index.ts
    +++ b/packages/cli/src/commands/index.ts
    @@
     export { createInitCommand } from './initCommands.js';
    +export { createSetupCommand } from './setupCommand.js';

    File: packages/cli/src/index.ts

    Why this file: The CLI entrypoint must import and register the new top-level command so users can run propr setup.

    --- a/packages/cli/src/index.ts
    +++ b/packages/cli/src/index.ts
    @@
       createInitCommand,
    +  createSetupCommand,
    @@
     Quick Start (local stack):
    +  $ propr setup                     Guided setup wizard (recommended)
       $ propr                           Verify the environment (same as 'propr check')
    @@
    -  Control Plane:  check, images, init [repo|stack], start, status, stop, ui, docs, tank
    +  Control Plane:  setup, check, images, init [repo|stack], start, status, stop, ui, docs, tank
    @@
     program.addCommand(createCheckCommand());
    +program.addCommand(createSetupCommand());
     program.addCommand(createImagesCommand());
  2. propr-dev commented on Jun 22, 2026

    @propr-dev
    ContributorAuthor

    🤖 AI processing has started for this issue using claude agent with claude-opus-4-8 model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: claude
    • Model: claude-opus-4-8
    • Branch: 1604/claude-opus-4-8-register-the-top-level-se-20260622-1041-vh9
    • Base Branch: 1599-epic-build-comprehensive-b5c
    • Worktree: issue-1604-20260622-1041-claude-opus-4-8-vh9

    🔍 Track Task Execution

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions