Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor, remove many unused files from legacy #8875

Merged
merged 8 commits into from
May 13, 2024
2 changes: 1 addition & 1 deletion e2e/commands/status.e2e.2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ describe('bit status command', function () {
expect(output).to.have.string('component files were deleted');
});
describe('running bit diff', () => {
it('should throw an exception MissingFilesFromComponent', () => {
it('should throw an exception ComponentNotFoundInPath', () => {
const diffFunc = () => helper.command.diff('bar/foo');
const error = new ComponentNotFoundInPath('bar');
helper.general.expectToThrow(diffFunc, error);
Expand Down
2 changes: 1 addition & 1 deletion e2e/functionalities/auto-tagging.e2e.2.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import chai, { expect } from 'chai';
import { AUTO_TAGGED_MSG } from '../../src/api/consumer/lib/tag';
import { AUTO_TAGGED_MSG } from '@teambit/snapping';
import Helper from '../../src/e2e-helper/e2e-helper';

chai.use(require('chai-fs'));
Expand Down
1 change: 1 addition & 0 deletions scopes/component/snapping/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export type { SnappingMain, TagResults, SnapResults } from './snapping.main.runt
export default SnappingAspect;
export { SnappingAspect };
export type { onTagIdTransformer } from './tag-model-component';
export { AUTO_TAGGED_MSG, NOTHING_TO_TAG_MSG } from './tag-cmd';
4 changes: 3 additions & 1 deletion scopes/component/snapping/tag-cmd.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import chalk from 'chalk';
import { ComponentIdList, ComponentID } from '@teambit/component-id';
import { Command, CommandOptions } from '@teambit/cli';
import { NOTHING_TO_TAG_MSG, AUTO_TAGGED_MSG } from '@teambit/legacy/dist/api/consumer/lib/tag';
import ConsumerComponent from '@teambit/legacy/dist/consumer/component/consumer-component';
import {
DEFAULT_BIT_RELEASE_TYPE,
Expand All @@ -16,6 +15,9 @@ import { Logger } from '@teambit/logger';
import { TagResults, SnappingMain } from './snapping.main.runtime';
import { BasicTagParams } from './tag-model-component';

export const NOTHING_TO_TAG_MSG = 'nothing to tag';
export const AUTO_TAGGED_MSG = 'auto-tagged dependents';

const RELEASE_TYPES = ['major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease'];

export class TagCmd implements Command {
Expand Down
2 changes: 1 addition & 1 deletion scopes/component/snapping/tag-from-scope.cmd.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import chalk from 'chalk';
import { Command, CommandOptions } from '@teambit/cli';
import { NOTHING_TO_TAG_MSG, AUTO_TAGGED_MSG } from '@teambit/legacy/dist/api/consumer/lib/tag';
import { NOTHING_TO_TAG_MSG, AUTO_TAGGED_MSG } from './tag-cmd';
import { DEFAULT_BIT_RELEASE_TYPE } from '@teambit/legacy/dist/constants';
import { getHarmonyVersion } from '@teambit/legacy/dist/bootstrap';
import { IssuesClasses } from '@teambit/component-issues';
Expand Down
3 changes: 2 additions & 1 deletion scopes/pipelines/builder/artifact/artifact-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { flatten } from 'lodash';
import { ArtifactFiles } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';
import { Component, ComponentMap } from '@teambit/component';
import { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';
import { PathLinux } from '@teambit/legacy/dist/utils/path';
import { ArtifactDefinition } from './artifact-definition';
import { DefaultResolver } from '../storage';
import { ArtifactList } from './artifact-list';
Expand All @@ -18,7 +19,7 @@ export type ArtifactMap = ComponentMap<ArtifactList<FsArtifact>>;
export class ArtifactFactory {
resolvePaths(root: string, def: ArtifactDefinition): string[] {
const patternsFlattened = flatten(def.globPatterns);
const patternsFlattenedLinux = patternsFlattened.map(pathNormalizeToLinux);
const patternsFlattenedLinux: PathLinux[] = patternsFlattened.map(pathNormalizeToLinux);
const paths = globby.sync(patternsFlattenedLinux, { cwd: root });
return paths;
}
Expand Down
9 changes: 8 additions & 1 deletion scopes/scope/importer/import.cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
import { ComponentIdList, ComponentID } from '@teambit/component-id';
import { BitError } from '@teambit/bit-error';
import { immutableUnshift } from '@teambit/legacy/dist/utils';
import { formatPlainComponentItem } from '@teambit/legacy/dist/cli/chalk-box';
import { ImporterMain } from './importer.main.runtime';
import { ImportOptions, ImportDetails, ImportStatus, ImportResult } from './import-components';

Expand Down Expand Up @@ -291,6 +290,14 @@ Also, check that the requested version exists on main or the checked out lane`;
return `${title}\n${subTitle}\n${body}`;
}

function formatPlainComponentItem({ scope, name, version, deprecated }: any) {
return chalk.cyan(
`- ${scope ? `${scope}/` : ''}${name}@${version ? version.toString() : 'latest'} ${
deprecated ? chalk.yellow('[deprecated]') : ''
}`
);
}

function formatPlainComponentItemWithVersions(bitId: ComponentID, importDetails: ImportDetails) {
const status: ImportStatus = importDetails.status;
const id = bitId.toStringWithoutVersion();
Expand Down
9 changes: 0 additions & 9 deletions scopes/scope/scope/scope.main.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import LegacyScope, { LegacyOnTagResult } from '@teambit/legacy/dist/scope/scope
import { LegacyComponentLog as ComponentLog } from '@teambit/legacy-component-log';
import { loadScopeIfExist } from '@teambit/legacy/dist/scope/scope-loader';
import { getDivergeData } from '@teambit/legacy/dist/scope/component-ops/get-diverge-data';
import { PersistOptions } from '@teambit/legacy/dist/scope/types';
import { ExportPersist, PostSign } from '@teambit/legacy/dist/scope/actions';
import { DependencyResolverAspect, DependencyResolverMain, NodeLinker } from '@teambit/dependency-resolver';
import { getScopeRemotes } from '@teambit/legacy/dist/scope/scope-remotes';
Expand Down Expand Up @@ -433,14 +432,6 @@ export class ScopeMain implements ComponentFactory {
*/
fetch(ids: ComponentIdList) {} // eslint-disable-line @typescript-eslint/no-unused-vars

/**
* This function will get a component and sealed it's current state into the scope
*
* @param {Component[]} components A list of components to seal with specific persist options (such as message and version number)
* @param {PersistOptions} persistGeneralOptions General persistence options such as verbose
*/
persist(components: Component[], options: PersistOptions) {} // eslint-disable-line @typescript-eslint/no-unused-vars

async delete(
{ ids, force, lanes }: { ids: string[]; force: boolean; lanes: boolean },
headers?: Record<string, any>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { ModelComponent } from '@teambit/legacy/dist/scope/models';
import { MissingBitMapComponent } from '@teambit/legacy/dist/consumer/bit-map/exceptions';
import ComponentsPendingImport from '@teambit/legacy/dist/consumer/component-ops/exceptions/components-pending-import';
import ComponentNotFoundInPath from '@teambit/legacy/dist/consumer/component/exceptions/component-not-found-in-path';
import MissingFilesFromComponent from '@teambit/legacy/dist/consumer/component/exceptions/missing-files-from-component';
import ComponentOutOfSync from '@teambit/legacy/dist/consumer/exceptions/component-out-of-sync';
import { Workspace } from '..';

Expand Down Expand Up @@ -82,11 +81,7 @@ export class ComponentStatusLoader {
}
componentFromFileSystem = components[0];
} catch (err: any) {
if (
err instanceof MissingFilesFromComponent ||
err instanceof ComponentNotFoundInPath ||
err instanceof MissingBitMapComponent
) {
if (err instanceof ComponentNotFoundInPath || err instanceof MissingBitMapComponent) {
// the file/s have been deleted or the component doesn't exist in bit.map file
if (componentFromModel) status.deleted = true;
else status.notExist = true;
Expand Down
4 changes: 0 additions & 4 deletions scopes/workspace/workspace/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import { GetBitMapComponentOptions } from '@teambit/legacy/dist/consumer/bit-map
import { getMaxSizeForComponents, InMemoryCache } from '@teambit/legacy/dist/cache/in-memory-cache';
import { createInMemoryCache } from '@teambit/legacy/dist/cache/cache-factory';
import ComponentsList from '@teambit/legacy/dist/consumer/component/components-list';
import { NoComponentDir } from '@teambit/legacy/dist/consumer/component/exceptions/no-component-dir';
import { ExtensionDataList, ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config/extension-data';
import { pathIsInside } from '@teambit/legacy/dist/utils';
import {
Expand Down Expand Up @@ -1207,9 +1206,6 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
): PathOsBased {
const componentMap = this.consumer.bitMap.getComponent(bitId, bitMapOptions);
const relativeComponentDir = componentMap.getComponentDir();
if (!relativeComponentDir) {
throw new NoComponentDir(bitId.toString());
}
if (options.relative) {
return relativeComponentDir;
}
Expand Down
3 changes: 0 additions & 3 deletions src/api/consumer/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import getComponentLogs from './lib/get-component-logs';
import getConsumerComponent from './lib/get-consumer-component';
import getScopeComponent from './lib/get-scope-component';
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
import config from './lib/global-config';
import init from './lib/init';
import { listScope } from './lib/list-scope';
import { add as remoteAdd, list as remoteList, remove as remoteRm } from './lib/remote';
Expand All @@ -11,7 +9,6 @@ import { clearCache } from './lib/clear-cache';

export {
init,
config,
listScope,
getConsumerComponent,
getScopeComponent,
Expand Down
10 changes: 0 additions & 10 deletions src/api/consumer/lib/exceptions/config-key-not-found.ts

This file was deleted.

12 changes: 0 additions & 12 deletions src/api/consumer/lib/exceptions/id-exported-already.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/api/consumer/lib/exceptions/invalid-version.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/api/consumer/lib/tag.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/cli/chalk-box.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/cli/commands/exceptions/remote-undefined.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/cli/commands/public-cmds/init-cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export default class Init implements LegacyCommand {
'set the default directory pattern to import/create components into',
],
['', 'default-scope <default-scope>', 'set the default scope for components in the workspace'],
['p', 'package-manager <package-manager>', 'set the package manager (npm or yarn) to be used in the workspace'],
['f', 'force', 'force workspace initialization without clearing local objects'],
] as CommandOptions;

Expand All @@ -68,7 +67,6 @@ export default class Init implements LegacyCommand {
force,
defaultDirectory,
defaultScope,
packageManager,
} = flags;
if (path) path = pathlib.resolve(path);
if (bare) {
Expand All @@ -88,7 +86,6 @@ export default class Init implements LegacyCommand {
const workspaceConfigFileProps: WorkspaceConfigProps = {
componentsDefaultDirectory: defaultDirectory ?? getSync(CFG_INIT_DEFAULT_DIRECTORY),
defaultScope: defaultScope ?? getSync(CFG_INIT_DEFAULT_SCOPE),
packageManager,
};
return init(
path,
Expand Down
8 changes: 1 addition & 7 deletions src/cli/commands/public-cmds/remote-cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { forEach, isEmpty } from 'lodash';
import { remoteAdd, remoteList, remoteRm } from '../../../api/consumer';
import { Group } from '../../command-groups';
import { CommandOptions, LegacyCommand } from '../../legacy-command';
import RemoteUndefined from '../exceptions/remote-undefined';

class RemoteAdd implements LegacyCommand {
name = 'add <url>';
Expand All @@ -18,12 +17,7 @@ for example: "http://localhost:3000", "file:///tmp/local-scope"`;
opts = [['g', 'global', 'configure a remote bit scope']] as CommandOptions;

action([url]: [string], { global }: { global: boolean }): Promise<any> {
try {
if (!url) return Promise.reject(new RemoteUndefined());
return remoteAdd(url, global);
} catch (err: any) {
return Promise.reject(err);
}
return remoteAdd(url, global);
}

report({ name, host }: { name: string; host: string }): string {
Expand Down