mirror of
https://github.com/eyaltoledano/claude-task-master.git
synced 2026-01-30 06:12:05 +00:00
refactor(auth): rename forcePrompt to forceSelection and fix AuthManager type
CHANGES: - Rename forcePrompt option to forceSelection in EnsureOrgOptions interface - Update all call sites in export.command.ts and commands.js - Fix AuthManager type in export.command.ts by importing from @tm/core - Replace dirty (this.taskMasterCore.auth as any).authManager hack with AuthManager.getInstance() - Use type import for AuthManager in org-selection.ts
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import {
|
||||
AuthManager,
|
||||
FileStorage,
|
||||
type GenerateBriefResult,
|
||||
type InvitationResult,
|
||||
@@ -337,21 +338,19 @@ export class ExportCommand extends Command {
|
||||
|
||||
// Force org selection after tag selection
|
||||
// User can choose which org to export to, with current org pre-selected
|
||||
const authManager = (this.taskMasterCore!.auth as any).authManager;
|
||||
if (authManager) {
|
||||
const orgResult = await ensureOrgSelected(authManager, {
|
||||
promptMessage: 'Select an organization to export to:',
|
||||
forcePrompt: true
|
||||
});
|
||||
if (!orgResult.success) {
|
||||
console.log(chalk.gray('\n Export cancelled.\n'));
|
||||
this.lastResult = {
|
||||
success: false,
|
||||
action: 'cancelled',
|
||||
message: orgResult.message || 'Organization selection cancelled'
|
||||
};
|
||||
return;
|
||||
}
|
||||
const authManager = AuthManager.getInstance();
|
||||
const orgResult = await ensureOrgSelected(authManager, {
|
||||
promptMessage: 'Select an organization to export to:',
|
||||
forceSelection: true
|
||||
});
|
||||
if (!orgResult.success) {
|
||||
console.log(chalk.gray('\n Export cancelled.\n'));
|
||||
this.lastResult = {
|
||||
success: false,
|
||||
action: 'cancelled',
|
||||
message: orgResult.message || 'Organization selection cancelled'
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle multiple tags export
|
||||
@@ -992,9 +991,8 @@ export class ExportCommand extends Command {
|
||||
try {
|
||||
if (!this.taskMasterCore) return;
|
||||
|
||||
// Get AuthManager from TmCore
|
||||
const authManager = (this.taskMasterCore.auth as any).authManager;
|
||||
if (!authManager) return;
|
||||
// Get AuthManager singleton
|
||||
const authManager = AuthManager.getInstance();
|
||||
|
||||
// Use the selectBriefFromInput utility which properly resolves
|
||||
// the brief and sets all context fields (org, brief details, etc.)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Provides reusable org selection flow for commands that require org context.
|
||||
*/
|
||||
|
||||
import { AuthManager } from '@tm/core';
|
||||
import type { AuthManager } from '@tm/core';
|
||||
import chalk from 'chalk';
|
||||
import inquirer from 'inquirer';
|
||||
import * as ui from './ui.js';
|
||||
@@ -28,7 +28,7 @@ export interface EnsureOrgOptions {
|
||||
/** Custom message to show when prompting */
|
||||
promptMessage?: string;
|
||||
/** If true, always prompt for org selection even if one is already set */
|
||||
forcePrompt?: boolean;
|
||||
forceSelection?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,13 +57,13 @@ export async function ensureOrgSelected(
|
||||
authManager: AuthManager,
|
||||
options: EnsureOrgOptions = {}
|
||||
): Promise<OrgSelectionResult> {
|
||||
const { silent = false, promptMessage, forcePrompt = false } = options;
|
||||
const { silent = false, promptMessage, forceSelection = false } = options;
|
||||
|
||||
try {
|
||||
const context = authManager.getContext();
|
||||
|
||||
// If org is already selected and we're not forcing a prompt, return it
|
||||
if (context?.orgId && !forcePrompt) {
|
||||
// If org is already selected and we're not forcing selection, return it
|
||||
if (context?.orgId && !forceSelection) {
|
||||
return {
|
||||
success: true,
|
||||
orgId: context.orgId,
|
||||
@@ -121,10 +121,7 @@ export async function ensureOrgSelected(
|
||||
name: 'orgId',
|
||||
message: promptMessage || 'Select an organization:',
|
||||
choices: orgs.map((org) => ({
|
||||
name:
|
||||
org.id === context?.orgId
|
||||
? `${org.name} (current)`
|
||||
: org.name,
|
||||
name: org.id === context?.orgId ? `${org.name} (current)` : org.name,
|
||||
value: org.id
|
||||
})),
|
||||
default: defaultOrg >= 0 ? defaultOrg : 0
|
||||
|
||||
Reference in New Issue
Block a user