Skip to content

Commit

Permalink
more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel3108 committed Jan 12, 2025
1 parent 98af668 commit 39d1aa4
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions packages/cli/commands/add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export async function runAddCommand(
options: Options,
selectedAddonIds: string[]
): Promise<{ nextSteps?: string; packageManager?: AgentName | null }> {
console.log('run add command');
console.log('run add command 2');

const selectedAddons: SelectedAddon[] = selectedAddonIds.map((id) => ({
type: 'official',
Expand Down Expand Up @@ -341,31 +341,37 @@ export async function runAddCommand(

// run precondition checks
if (options.preconditions && selectedAddons.length > 0) {
// add global checks
const addons = selectedAddons.map(({ addon }) => addon);
const { preconditions } = getGlobalPreconditions(options.cwd, addons, addonSetupResults);

const fails: Array<{ name: string; message?: string }> = [];
for (const condition of preconditions) {
const { message, success } = await condition.run();
if (!success) fails.push({ name: condition.name, message });
}
try {
console.log('precondition checks');
// add global checks
const addons = selectedAddons.map(({ addon }) => addon);
const { preconditions } = getGlobalPreconditions(options.cwd, addons, addonSetupResults);
console.log(preconditions);

const fails: Array<{ name: string; message?: string }> = [];
for (const condition of preconditions) {
const { message, success } = await condition.run();
if (!success) fails.push({ name: condition.name, message });
}

if (fails.length > 0) {
const message = fails
.map(({ name, message }) => pc.yellow(`${name} (${message})`))
.join('\n- ');
if (fails.length > 0) {
const message = fails
.map(({ name, message }) => pc.yellow(`${name} (${message})`))
.join('\n- ');

p.note(`- ${message}`, 'Preconditions not met');
p.note(`- ${message}`, 'Preconditions not met');

const force = await p.confirm({
message: 'Preconditions failed. Do you wish to continue?',
initialValue: false
});
if (p.isCancel(force) || !force) {
p.cancel('Operation cancelled.');
process.exit(1);
const force = await p.confirm({
message: 'Preconditions failed. Do you wish to continue?',
initialValue: false
});
if (p.isCancel(force) || !force) {
p.cancel('Operation cancelled.');
process.exit(1);
}
}
} catch (error) {
console.log('Error', error);
}
}

Expand Down

0 comments on commit 39d1aa4

Please sign in to comment.