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, move legacy e2e-helper to a new component teambit.legacy/e2e-helper #9022

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
14 changes: 14 additions & 0 deletions .bitmap
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,20 @@
"mainFile": "index.ts",
"rootDir": "scopes/harmony/doctor"
},
"e2e-helper": {
"name": "e2e-helper",
"scope": "",
"version": "",
"defaultScope": "teambit.legacy",
"mainFile": "index.ts",
"rootDir": "components/legacy/e2e-helper",
"config": {
"teambit.node/envs/node-babel-mocha@0.0.1": {},
"teambit.envs/envs": {
"env": "teambit.node/envs/node-babel-mocha"
}
}
},
"eject": {
"name": "eject",
"scope": "teambit.workspace",
Expand Down
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
e2e/fixtures
components/legacy/e2e-helper/fixtures
scopes/semantics/schema/mock

# A temp file should be required from outside (via npm) so no point to fix it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect } from 'chai';
import fs from 'fs-extra';
import * as path from 'path';

import { BIT_MAP } from '../constants';
import { BIT_MAP } from '@teambit/legacy/dist/constants';
import { LANE_KEY, SCHEMA_FIELD } from '@teambit/legacy.bit-map';
import FsHelper from './e2e-fs-helper';
import ScopesData from './e2e-scopes';
Expand All @@ -18,6 +18,7 @@ export default class BitMapHelper {

read(bitMapPath: string = path.join(this.scopes.localPath, BIT_MAP), withoutComment = true) {
const map = fs.readFileSync(bitMapPath) || {};
// @ts-ignore todo: remove after deleting teambit.legacy
return json.parse(map.toString('utf8'), undefined, withoutComment);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import tar from 'tar';
import { LANE_REMOTE_DELIMITER } from '@teambit/lane-id';
import { NOTHING_TO_TAG_MSG } from '@teambit/snapping';
import { ENV_VAR_FEATURE_TOGGLE } from '@teambit/harmony.modules.feature-toggle';
import { Extensions, NOTHING_TO_SNAP_MSG } from '../constants';
import { Extensions, NOTHING_TO_SNAP_MSG } from '@teambit/legacy/dist/constants';
import { removeChalkCharacters } from '@teambit/legacy.utils';
import ScopesData from './e2e-scopes';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { assign, stringify } from 'comment-json';
import fs from 'fs-extra';
import * as path from 'path';

import { COMPONENT_CONFIG_FILE_NAME } from '../constants';
import { COMPONENT_CONFIG_FILE_NAME } from '@teambit/legacy/dist/constants';
import ScopesData from './e2e-scopes';

// TODO: improve this by combine into a base class shared between this and e2e-bit-json-helper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import R from 'ramda';

import { getCloudDomain, CFG_GIT_EXECUTABLE_PATH } from '../constants';
import { getCloudDomain, CFG_GIT_EXECUTABLE_PATH } from '@teambit/legacy/dist/constants';
import CommandHelper from './e2e-command-helper';

export default class ConfigHelper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,68 @@ import FixtureHelper, { GenerateEnvJsoncOptions } from './e2e-fixtures-helper';
import FsHelper from './e2e-fs-helper';
import ScopeHelper from './e2e-scope-helper';
import ScopesData from './e2e-scopes';
import { ENV_POLICY } from '../../e2e/harmony/dependencies/env-jsonc-policies.e2e';

type SetCustomEnvOpts = {
skipInstall?: boolean;
skipCompile?: boolean;
skipLink?: boolean;
};

export const ENV_POLICY = {
peers: [
{
name: 'react',
version: '^18.0.0',
supportedRange: '^17.0.0 || ^18.0.0',
},
{
name: 'react-dom',
version: '^18.0.0',
supportedRange: '^17.0.0 || ^18.0.0',
},
{
name: 'graphql',
version: '14.7.0',
supportedRange: '^14.7.0',
},
],
dev: [
{
name: '@types/react',
version: '18.0.25',
hidden: true,
force: true,
},
{
name: '@types/react-dom',
version: '^18.0.0',
hidden: true,
force: true,
},
{
name: '@types/jest',
version: '29.2.2',
hidden: true,
force: true,
},
],
runtime: [
{
name: 'is-positive',
version: '2.0.0',
},
{
name: 'is-string',
version: '1.0.7',
},
{
name: 'is-odd',
version: '3.0.1',
force: true,
},
],
};

export default class EnvHelper {
command: CommandHelper;
fs: FsHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { capitalize } from 'lodash';
import * as path from 'path';
import tar from 'tar';

import * as fixtures from '../../src/fixtures/fixtures';
import * as fixtures from './fixtures/fixtures';
import CommandHelper from './e2e-command-helper';
import FsHelper from './e2e-fs-helper';
import NpmHelper from './e2e-npm-helper';
Expand Down Expand Up @@ -77,7 +77,7 @@ export default class FixtureHelper {
return this.command.tagWithoutBuild('bar/foo');
}
getFixturesDir() {
return path.join(__dirname, '../../e2e/fixtures');
return path.join(__dirname, '../fixtures');
}

copyFixtureDir(src: string, dest: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import chai, { expect } from 'chai';
import glob from 'glob';
import * as path from 'path';
import { generateRandomStr } from '@teambit/toolbox.string.random';
import * as fixtures from '../../src/fixtures/fixtures';
import * as fixtures from './fixtures/fixtures';
import { ensureAndWriteJson } from './e2e-helper';
import ScopesData from './e2e-scopes';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ import { compact } from 'lodash';
import tar from 'tar';
import { DEFAULT_LANE } from '@teambit/lane-id';
import { generateRandomStr } from '@teambit/toolbox.string.random';
import defaultErrorHandler from '../cli/default-error-handler';
import { BIT_HIDDEN_DIR, BIT_VERSION, MergeConfigFilename, REMOTE_REFS_DIR, WORKSPACE_JSONC } from '../constants';
import defaultErrorHandler from '@teambit/legacy/dist/cli/default-error-handler';
import {
BIT_HIDDEN_DIR,
BIT_VERSION,
MergeConfigFilename,
REMOTE_REFS_DIR,
WORKSPACE_JSONC,
} from '@teambit/legacy/dist/constants';
import { removeChalkCharacters } from '@teambit/legacy.utils';
import CommandHelper from './e2e-command-helper';
import { ensureAndWriteJson } from './e2e-helper';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs-extra';
import R from 'ramda';
import { FileStatus } from '@teambit/merging';
import { VERSION_DELIMITER } from '../constants';
import { VERSION_DELIMITER } from '@teambit/legacy/dist/constants';
import { removeChalkCharacters } from '@teambit/legacy.utils';
import WorkspaceJsoncHelper from './e2e-workspace-jsonc-helper';
import BitMapHelper from './e2e-bitmap-helper';
Expand All @@ -24,7 +24,7 @@ import CapsulesHelper from './e2e-capsules-helper';
export type HelperOptions = {
scopesOptions?: ScopesOptions;
};
export default class Helper {
export class Helper {
debugMode: boolean;
scopes: ScopesData;
scopeJson: ScopeJsonHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as yaml from 'yaml';
import * as ini from 'ini';
import { createLinkOrSymlink } from '@teambit/toolbox.fs.link-or-symlink';
import { generateRandomStr } from '@teambit/toolbox.string.random';
import { IS_WINDOWS } from '../constants';
import { IS_WINDOWS } from '@teambit/legacy/dist/constants';
import CommandHelper from './e2e-command-helper';
import FsHelper from './e2e-fs-helper';
import NpmHelper from './e2e-npm-helper';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { assign, parse, stringify } from 'comment-json';
import fs from 'fs-extra';
import * as path from 'path';

import { WORKSPACE_JSONC } from '../constants';
import { WORKSPACE_JSONC } from '@teambit/legacy/dist/constants';
import ScopesData from './e2e-scopes';

// TODO: improve this by combine into a base class shared between this and e2e-bit-json-helper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @bit-no-check
// @ts-nocheck
import { MdxEnv } from '@teambit/mdx.mdx-env';

export class MyMdxEnv extends MdxEnv {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @bit-no-check
// @ts-nocheck
import { NodeEnv } from '@teambit/node.node';

export class MyNodeEnv extends NodeEnv {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @bit-no-check
// @ts-nocheck
import { EnvsMain, EnvsAspect } from '@teambit/envs';
import { NodeMain, NodeAspect } from '@teambit/node';
import get from 'lodash.get'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @bit-no-check
// @ts-nocheck
import { ReactEnv } from '@teambit/react.react-env';
import type { ReactEnvInterface } from '@teambit/react.react-env';

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// @bit-no-check
// @ts-nocheck

/**
* this env extends react-env
* @see https://bit.cloud/teambit/react/react-env
Expand Down
44 changes: 44 additions & 0 deletions components/legacy/e2e-helper/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import WorkspaceJsoncHelper from './e2e-workspace-jsonc-helper';
import BitMapHelper from './e2e-bitmap-helper';
import CommandHelper from './e2e-command-helper';
import ComponentJsonHelper from './e2e-component-json-helper';
import ConfigHelper from './e2e-config-helper';
import EnvHelper from './e2e-env-helper';
import ExtensionsHelper from './e2e-extensions-helper';
import FixtureHelper from './e2e-fixtures-helper';
import FsHelper from './e2e-fs-helper';
import GeneralHelper from './e2e-general-helper';
import GitHelper from './e2e-git-helper';
import NpmHelper from './e2e-npm-helper';
import PackageJsonHelper from './e2e-package-json-helper';
import ScopeHelper from './e2e-scope-helper';
import ScopeJsonHelper from './e2e-scope-json-helper';
import ScopesData, { ScopesOptions, DEFAULT_OWNER } from './e2e-scopes';
import CapsulesHelper from './e2e-capsules-helper';
import * as fixtures from './fixtures/fixtures';

export {
ScopesData,
ScopesOptions,
WorkspaceJsoncHelper,
BitMapHelper,
CommandHelper,
ComponentJsonHelper,
ConfigHelper,
EnvHelper,
ExtensionsHelper,
FixtureHelper,
FsHelper,
GeneralHelper,
GitHelper,
NpmHelper,
PackageJsonHelper,
ScopeHelper,
ScopeJsonHelper,
CapsulesHelper,
fixtures,
DEFAULT_OWNER,
};

export { Helper, FileStatusWithoutChalk } from './e2e-helper';
export { ENV_POLICY } from './e2e-env-helper';
2 changes: 1 addition & 1 deletion e2e/commands/add.e2e.1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { InvalidName } from '@teambit/legacy-bit-id';
import { statusInvalidComponentsMsg } from '../../src/constants';
import { MainFileIsDir, PathOutsideConsumer, VersionShouldBeRemoved } from '@teambit/tracker';
import { MissingMainFile } from '@teambit/legacy.bit-map';
import Helper from '../../src/e2e-helper/e2e-helper';
import { Helper } from '@teambit/legacy.e2e-helper';

chai.use(require('chai-fs'));

Expand Down
2 changes: 1 addition & 1 deletion e2e/commands/config.e2e.1.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';

import Helper from '../../src/e2e-helper/e2e-helper';
import { Helper } from '@teambit/legacy.e2e-helper';

describe('bit config', function () {
this.timeout(0);
Expand Down
3 changes: 1 addition & 2 deletions e2e/commands/diff.e2e.1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import fs from 'fs-extra';
import * as path from 'path';

import { MissingBitMapComponent } from '@teambit/legacy.bit-map';
import Helper from '../../src/e2e-helper/e2e-helper';
import * as fixtures from '../../src/fixtures/fixtures';
import { Helper, fixtures } from '@teambit/legacy.e2e-helper';
import { VersionNotFound } from '../../src/scope/exceptions';

const barFooV1 = "module.exports = function foo() { return 'got foo'; };\n";
Expand Down
2 changes: 1 addition & 1 deletion e2e/commands/export.e2e.1.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chai, { expect } from 'chai';
import fs from 'fs-extra';
import * as path from 'path';
import Helper from '../../src/e2e-helper/e2e-helper';
import { Helper } from '@teambit/legacy.e2e-helper';

chai.use(require('chai-fs'));

Expand Down
2 changes: 1 addition & 1 deletion e2e/commands/import-all.e2e.1.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';

import Helper from '../../src/e2e-helper/e2e-helper';
import { Helper } from '@teambit/legacy.e2e-helper';

describe('bit import command with no ids', function () {
this.timeout(0);
Expand Down
2 changes: 1 addition & 1 deletion e2e/commands/import.e2e.1.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chai, { expect } from 'chai';
import fs from 'fs-extra';
import * as path from 'path';
import Helper from '../../src/e2e-helper/e2e-helper';
import { Helper } from '@teambit/legacy.e2e-helper';

chai.use(require('chai-fs'));
const assertArrays = require('chai-arrays');
Expand Down
2 changes: 1 addition & 1 deletion e2e/commands/init.e2e.1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fs from 'fs-extra';
import * as path from 'path';
import { CURRENT_BITMAP_SCHEMA, SCHEMA_FIELD, InvalidBitMap } from '@teambit/legacy.bit-map';
import { BIT_GIT_DIR, BIT_HIDDEN_DIR, BIT_MAP } from '../../src/constants';
import Helper from '../../src/e2e-helper/e2e-helper';
import { Helper } from '@teambit/legacy.e2e-helper';

const assertArrays = require('chai-arrays');

Expand Down
2 changes: 1 addition & 1 deletion e2e/commands/list.e2e.1.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';

import Helper from '../../src/e2e-helper/e2e-helper';
import { Helper } from '@teambit/legacy.e2e-helper';

describe('bit list command', function () {
this.timeout(0);
Expand Down
2 changes: 1 addition & 1 deletion e2e/commands/move.e2e.1.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chai, { expect } from 'chai';
import * as path from 'path';

import Helper from '../../src/e2e-helper/e2e-helper';
import { Helper } from '@teambit/legacy.e2e-helper';

chai.use(require('chai-fs'));

Expand Down
2 changes: 1 addition & 1 deletion e2e/commands/remote.e2e.1.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import * as path from 'path';

import Helper from '../../src/e2e-helper/e2e-helper';
import { Helper } from '@teambit/legacy.e2e-helper';
import { ScopeNotFound } from '../../src/scope/exceptions';

describe('bit remote command', function () {
Expand Down
3 changes: 1 addition & 2 deletions e2e/commands/remove.e2e.1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import chai, { expect } from 'chai';
import * as path from 'path';
import { Extensions } from '../../src/constants';

import Helper from '../../src/e2e-helper/e2e-helper';
import * as fixtures from '../../src/fixtures/fixtures';
import { Helper, fixtures } from '@teambit/legacy.e2e-helper';

chai.use(require('chai-fs'));

Expand Down
Loading