Skip to content
Merged
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
10 changes: 5 additions & 5 deletions e2e/commands/reset.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe('bit reset command', function () {
untagOutput = helper.command.resetAll();
});
it('should display a descriptive successful message', () => {
expect(untagOutput).to.have.string('2 component(s) were reset');
expect(untagOutput).to.have.string('2 component(s) reset successfully');
});
it('should remove only local components from the model', () => {
const output = helper.command.listLocalScope();
Expand All @@ -151,7 +151,7 @@ describe('bit reset command', function () {
untagOutput = helper.command.resetAll('--head');
});
it('should display a descriptive successful message', () => {
expect(untagOutput).to.have.string('3 component(s) were reset');
expect(untagOutput).to.have.string('3 component(s) reset successfully');
});
it('should remove only the specified version from the model', () => {
const output = helper.command.listLocalScope();
Expand Down Expand Up @@ -195,7 +195,7 @@ describe('bit reset command', function () {
untagOutput = helper.command.reset('utils/is-type', undefined, '--force');
});
it('should untag successfully', () => {
expect(untagOutput).to.have.string('1 component(s) were reset');
expect(untagOutput).to.have.string('1 component(s) reset successfully');
});
});
describe('after exporting the component and tagging the scope', () => {
Expand Down Expand Up @@ -236,7 +236,7 @@ describe('bit reset command', function () {
untagOutput = helper.command.reset('utils/is-string');
});
it('should untag successfully the dependent', () => {
expect(untagOutput).to.have.string('1 component(s) were reset');
expect(untagOutput).to.have.string('1 component(s) reset successfully');
expect(untagOutput).to.have.string('utils/is-string');
});
it('should leave the dependency intact', () => {
Expand All @@ -263,7 +263,7 @@ describe('bit reset command', function () {
output = helper.command.reset('utils/is-string');
});
it('should untag successfully', () => {
expect(output).to.have.string('1 component(s) were reset');
expect(output).to.have.string('1 component(s) reset successfully');
expect(output).to.have.string('utils/is-string');
});
});
Expand Down
2 changes: 1 addition & 1 deletion e2e/flows/id-with-wildcard.e2e.2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ describe('component id with wildcard', function () {
output = helper.command.reset('"**/*/is/*"');
});
it('should indicate the untagged components', () => {
expect(output).to.have.string('2 component(s) were reset');
expect(output).to.have.string('2 component(s) reset successfully');
expect(output).to.have.string('utils/is/string');
expect(output).to.have.string('utils/is/type');
});
Expand Down
2 changes: 1 addition & 1 deletion e2e/harmony/checkout-harmony.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ describe('bit checkout command', function () {
expect(list).to.have.lengthOf(3);
});
it('should show the new components in the output', () => {
expect(output).to.have.string('successfully imported the following new components from the defaultScope');
expect(output).to.have.string('new components from scope');
expect(output).to.have.string('comp2');
expect(output).to.have.string('comp3');
});
Expand Down
2 changes: 1 addition & 1 deletion e2e/harmony/delete.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ describe('bit delete command', function () {
output = helper.command.resetAll();
});
it('should reset the deleted component', () => {
expect(output).to.have.string('2 component(s) were reset');
expect(output).to.have.string('2 component(s) reset successfully');
});
it('should revert the .bitmap entry of the deleted component as it was before', () => {
const bitmap = helper.bitMap.read();
Expand Down
2 changes: 1 addition & 1 deletion e2e/harmony/lanes/lane-snapping.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ describe('bit lane snapping and tagging', function () {
output = helper.command.resetAll();
});
it('should untag successfully', () => {
expect(output).to.have.string('1 component(s) were reset');
expect(output).to.have.string('1 component(s) reset successfully');
});
it('should change the component to be new', () => {
const status = helper.command.statusJson();
Expand Down
6 changes: 3 additions & 3 deletions e2e/harmony/lanes/merge-lanes-remote.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('merge lanes - remote lane operations', function () {
mergeOutput = helper.command.mergeLane(`${helper.scopes.remote}/dev`, `--workspace --verbose`);
});
it('should indicate that the components were not merge because they are not in the workspace', () => {
expect(mergeOutput).to.have.string('merge skipped for the following component(s)');
expect(mergeOutput).to.have.string('merge skipped');
expect(mergeOutput).to.have.string('not in the workspace');
});
it('bitmap should not save any component', () => {
Expand Down Expand Up @@ -137,12 +137,12 @@ describe('merge lanes - remote lane operations', function () {
it('bit lane --merged should not show the lane as it was not merged into main yet', () => {
const merged = helper.command.listLanes('--merged');
expect(merged).to.not.have.string('dev');
expect(merged).to.have.string('None of the lanes is merged');
expect(merged).to.have.string('none of the lanes is merged');
});
it('bit lane --unmerged should show the lane', () => {
const merged = helper.command.listLanes('--not-merged');
expect(merged).to.have.string('dev');
expect(merged).to.not.have.string('All lanes are merged');
expect(merged).to.not.have.string('all lanes are merged');
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion e2e/harmony/lanes/switch-lanes.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ describe('bit lane command', function () {
});
it('should switch the component on the lane only', () => {
expect(switchOutput).to.have.string('switched 1 components');
expect(switchOutput).to.have.string('skipped legitimately for 1 component(s)');
expect(switchOutput).to.have.string('switch skipped for 1 component(s)');
});
});
});
6 changes: 3 additions & 3 deletions e2e/harmony/snap.e2e.2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ describe('bit snap command', function () {
resolveOutput = helper.command.merge('bar/foo --resolve');
});
it('should resolve successfully', () => {
expect(resolveOutput).to.have.string('successfully resolved component');
expect(resolveOutput).to.have.string('resolved components');
});
it('bit status should not show the component as during merge state', () => {
const status = helper.command.statusJson();
Expand Down Expand Up @@ -481,7 +481,7 @@ describe('bit snap command', function () {
resolveOutput = helper.command.merge('bar/foo --resolve');
});
it('should resolve the conflicts successfully', () => {
expect(resolveOutput).to.have.string('successfully resolved component');
expect(resolveOutput).to.have.string('resolved components');
});
it('bit status should not show the component as if it has conflicts', () => {
const status = helper.command.statusJson();
Expand Down Expand Up @@ -509,7 +509,7 @@ describe('bit snap command', function () {
abortOutput = helper.command.merge('bar/foo --abort');
});
it('should abort the merge successfully', () => {
expect(abortOutput).to.have.string('successfully aborted the merge');
expect(abortOutput).to.have.string('merge aborted');
});
it('bit status should show the same state as before the merge', () => {
const status = helper.command.statusJson();
Expand Down
68 changes: 35 additions & 33 deletions scopes/component/checkout/checkout-cmd.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import chalk from 'chalk';
import type { Command, CommandOptions } from '@teambit/cli';
import { compact } from 'lodash';
import {
formatTitle,
formatSection,
formatItem,
formatSuccessSummary,
formatHint,
warnSymbol,
joinSections,
} from '@teambit/cli';
import type { ApplyVersionResults, MergeStrategy } from '@teambit/component.modules.merge-helper';
import {
applyVersionReport,
Expand Down Expand Up @@ -189,51 +197,47 @@ export function checkoutOutput(
const getNotCheckedOutOutput = () => {
if (!notCheckedOutComponents.length) return '';
if (!verbose && all) {
return chalk.green(
`checkout was not needed for ${chalk.bold(
notCheckedOutComponents.length.toString()
)} components (use --verbose to get more details)\n`
return formatHint(
`checkout was not needed for ${notCheckedOutComponents.length} components (use --verbose to get more details)`
);
}
const title = 'checkout was not required for the following component(s)';
const body = notCheckedOutComponents
.map((failedComponent) => `${failedComponent.id.toString()} - ${failedComponent.unchangedMessage}`)
.join('\n');
return `${chalk.underline(title)}\n${body}`;
const items = notCheckedOutComponents.map((failedComponent) =>
formatItem(`${failedComponent.id.toString()} - ${failedComponent.unchangedMessage}`)
);
return formatSection('checkout skipped', '', items);
};
const getWsConfigUpdateLogs = () => {
const logs = workspaceConfigUpdateResult?.logs;
if (!logs || !logs.length) return '';
const logsStr = logs.join('\n');
return `${chalk.underline('verbose logs of workspace config update')}\n${logsStr}`;
return `${formatTitle('verbose logs of workspace config update')}\n${logsStr}`;
};
const getConflictSummary = () => {
if (!components || !components.length || !leftUnresolvedConflicts) return '';
const title = `files with conflicts summary\n`;
const suggestion = `\n\nfix the conflicts above manually and then run "bit install".
once ready, snap/tag the components to persist the changes`;
const title = formatTitle(`${warnSymbol} files with conflicts summary`);
const conflictSummary = conflictSummaryReport(components);
return chalk.underline(title) + conflictSummary.conflictStr + chalk.yellow(suggestion);
const suggestion = formatHint(
`fix the conflicts above manually and then run "bit install".\nonce ready, snap/tag the components to persist the changes`
);
return `${title}\n${conflictSummary.conflictStr}\n\n${suggestion}`;
};
const getSuccessfulOutput = () => {
if (!components || !components.length) return '';
const newLine = '\n';
const switchedOrReverted = revert ? 'reverted' : 'switched';
if (components.length === 1) {
const component = components[0];
const componentName = reset ? component.id.toString() : component.id.toStringWithoutVersion();
if (reset) return `successfully reset ${chalk.bold(componentName)}\n`;
if (reset) return formatSuccessSummary(`successfully reset ${chalk.bold(componentName)}`);
const title =
alternativeTitle ||
`successfully ${switchedOrReverted} ${chalk.bold(componentName)} to version ${chalk.bold(
head || latest ? component.id.version : version
)}`;
return chalk.bold(title) + newLine + applyVersionReport(components, false);
return [formatSuccessSummary(title), applyVersionReport(components, false)].filter(Boolean).join('\n');
}
if (reset) {
const title = 'successfully reset the following components\n\n';
const body = components.map((component) => chalk.bold(component.id.toString())).join('\n');
return chalk.underline(title) + body;
const items = components.map((component) => formatItem(component.id.toString()));
return formatSection('reset components', '', items);
}
const getVerOutput = () => {
if (head) return 'their head version';
Expand All @@ -245,26 +249,24 @@ once ready, snap/tag the components to persist the changes`;
const title =
alternativeTitle || `successfully ${switchedOrReverted} ${components.length} components to ${versionOutput}`;
const showVersion = head || reset;
return chalk.bold(title) + newLine + applyVersionReport(components, true, showVersion);
return [formatSuccessSummary(title), applyVersionReport(components, true, showVersion)].filter(Boolean).join('\n');
};
const getNewOnLaneOutput = () => {
if (!newFromLane?.length) return '';
const title = newFromLaneAdded
? `successfully added the following components from the lane`
: `the following components exist on the lane but were not added to the workspace. omit --workspace-only flag to add them`;
const body = newFromLane.join('\n');
return `${chalk.underline(title)}\n${body}`;
const title = newFromLaneAdded ? 'new components from lane' : 'new components on lane (not added)';
const desc = newFromLaneAdded ? '' : 'omit --workspace-only flag to add them';
const items = newFromLane.map((c) => formatItem(c.toString()));
return formatSection(title, desc, items);
};
const getNewFromScopeOutput = () => {
if (!newFromScope?.length) return '';
const title = `successfully imported the following new components from the defaultScope`;
const body = newFromScope.join('\n');
return `${chalk.underline(title)}\n${body}`;
const items = newFromScope.map((c) => formatItem(c.toString()));
return formatSection('new components from scope', '', items);
};
const getSummary = () => {
const checkedOut = components?.length || 0;
const notCheckedOutLegitimately = notCheckedOutComponents.length;
const title = chalk.bold.underline('Summary');
const title = formatTitle('Checkout Summary');
const checkedOutStr = `\nTotal Changed: ${chalk.bold(checkedOut.toString())}`;
const unchangedLegitimatelyStr = `\nTotal Unchanged: ${chalk.bold(notCheckedOutLegitimately.toString())}`;
const newOnLaneNum = newFromLane?.length || 0;
Expand All @@ -280,7 +282,7 @@ once ready, snap/tag the components to persist the changes`;
return title + checkedOutStr + unchangedLegitimatelyStr + newOnLaneStr + newFromScopeStr;
};

return compact([
return joinSections([
getWsConfigUpdateLogs(),
getNotCheckedOutOutput(),
getSuccessfulOutput(),
Expand All @@ -293,5 +295,5 @@ once ready, snap/tag the components to persist the changes`;
getSummary(),
installationErrorOutput(installationError),
compilationErrorOutput(compilationError),
]).join('\n\n');
]);
}
10 changes: 7 additions & 3 deletions scopes/component/component-log/log-cmd.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import c from 'chalk';
import Table from 'cli-table';
import type { Command, CommandOptions } from '@teambit/cli';
import { warnSymbol, errorSymbol } from '@teambit/cli';
import type { LegacyComponentLog } from '@teambit/legacy-component-log';
import type { ComponentLogMain, LogOpts } from './component-log.main.runtime';

Expand Down Expand Up @@ -93,11 +94,14 @@ export function paintAuthor(email: string | null | undefined, username: string |

function paintLog(log: LegacyComponentLog): string {
const { message, date, tag, hash, username, email, deleted, deprecated } = log;
const deletedStr = deleted ? c.red(' [deleted]') : '';
const deprecatedStr = !deleted && deprecated ? c.yellow(' [deprecated]') : '';
const title = tag ? `tag ${tag} (${hash})${deletedStr}${deprecatedStr}\n` : `snap ${hash}\n`;
const deletedStr = deleted ? ` ${c.red(`${errorSymbol} deleted`)}` : '';
const deprecatedStr = !deleted && deprecated ? ` ${c.yellow(`${warnSymbol} deprecated`)}` : '';
const title = tag ? `tag ${tag} (${hash})` : `snap ${hash}`;
return (
c.yellow(title) +
deletedStr +
deprecatedStr +
'\n' +
paintAuthor(email, username) +
(date ? c.white(`date: ${date}\n`) : '') +
(message ? c.white(`\n ${message}\n`) : '')
Expand Down
Loading