Skip to content

Commit

Permalink
Merge branch 'master' into ui/code-view-monaco-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
luvkapur authored May 29, 2023
2 parents 8bf7e24 + b6db098 commit 79bc946
Show file tree
Hide file tree
Showing 67 changed files with 1,765 additions and 1,414 deletions.
328 changes: 164 additions & 164 deletions .bitmap

Large diffs are not rendered by default.

36 changes: 30 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,39 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/).
and this project adheres to [Semantic Versioning](http://semver.org/).

## [[0.1.52] - 2023-05-28](https://github.com/teambit/bit/releases/tag/v0.1.52)

### New Features

- Use the `--fail-fast` option to exist the build process (and log the error) when a build task fails (use with `bit build`/`bit snap` /`bit tag` (#7444)
- Enable injecting raw strings to the HTML Injector (#7274)
- Use the `--squash` option, when merging one lane to another, to squsash snaps (this was previously only available when merging to 'main') (#7448)

### Bug Fixes

- Remove margines from the `<body` of built component previews (now concistent with previews in development) (#7451)
- Throw an error if a process in the remote does not complete in 30 minutes (#7456)
- `bit show --remote` should display the remote lane info (#7445)
- `bit start` should be able to render the preview of only a selected group of components (#7415)
- Fix `getComponentDevPatterns` for `TesterMain` (#7454)

### Internal

- Upgrade @babel/types to fix compilation issues.
- Avoid loading the version object for `idOnLane` (#7449)
- Change occurrences of --soft to --delete (#7447)
- Add a new express route "api/vscode" to communicate with vscode extension (#7441)
- Introduce a POC of `bit stash` (#7436)
- Restore the public `buildUiHash` API (#7438)
- deprecate `importManyDeltaWithoutDeps` and `importManyIfMissingWithoutDeps` (#7428)

## [[0.1.48] - 2023-05-21](https://github.com/teambit/bit/releases/tag/v0.1.48)

### New Features

- Better handking of missing dependencies (use `bit install --add-missing-deps` to automatically install missing dependencies) (#7412, #7264)
-`bit insight --include-deps` shows circular dependencies of extenral dependnecies (i.e, dependencies not maintained in the same workspace) (#7407)
- Better handking of missing dependencies (use `bit install --add-missing-deps` to automatically install missing dependencies) (#7412, #7264) -`bit insight --include-deps` shows circular dependencies of extenral dependnecies (i.e, dependencies not maintained in the same workspace) (#7407)
- Ignore the builds of specific dependencies. The "preinstall", "install", and "postinstall" scripts of the listed packages will not be executed during installation.
For example `{ "@teambit.dependencies/dependency-resolver": { "neverBuiltDependencies": ["fsevents", "level"]}}` (#7387)
For example `{ "@teambit.dependencies/dependency-resolver": { "neverBuiltDependencies": ["fsevents", "level"]}}` (#7387)

### Changes

Expand All @@ -27,15 +52,14 @@ For example `{ "@teambit.dependencies/dependency-resolver": { "neverBuiltDepend

- `bit artifacts COMPONENT_PATTERN` supports using component to retrieve artifacts of staged componetns (#7423)
- Fetch and save original lane when --lanes was used (#7425)
- Output fix. Remove suggestion for tag [version] which is not supported anymore (#7424)
- Output fix. Remove suggestion for tag [version] which is not supported anymore (#7424)
- Fix error message when soft-remove from a new lane to suggest the new flag --delete (#7420)
- Fix error "Cannot read properties of undefined when poilicies are missing (#7431)
- Remove dists and symlinks from node_modules/component-package-dir upon file removal. This makes sure removed components are not available for consumption. (#7411)


### Internal

- Repeat the warning message when a scope is not responsive (#7426)
- Repeat the warning message when a scope is not responsive (#7426)
- Update pnpm (#7421)
- Write original pnpm error to debug.log (#7418)
- Change import methods to work with one lane instead of an array (#7414)
Expand Down
104 changes: 101 additions & 3 deletions e2e/harmony/custom-env.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'fs-extra';
import path from 'path';
import chai, { expect } from 'chai';
import { resolveFrom } from '@teambit/toolbox.modules.module-resolver';
import { IssuesClasses } from '../../scopes/component/component-issues';
import { Extensions, IS_WINDOWS } from '../../src/constants';
import Helper from '../../src/e2e-helper/e2e-helper';
Expand Down Expand Up @@ -31,6 +32,33 @@ describe('custom env', function () {
);
});
});
describe('non loaded env', () => {
let envId;
let envName;
before(async () => {
helper.scopeHelper.setNewLocalAndRemoteScopes();
helper.bitJsonc.setPackageManager('teambit.dependencies/pnpm');
envName = helper.env.setCustomEnv(undefined, { skipCompile: true, skipInstall: true });
envId = `${helper.scopes.remote}/${envName}`;
helper.fixtures.populateComponents(1, undefined, undefined, false);
helper.extensions.addExtensionToVariant('*', envId);
// Clean the node_modules as we want to run tests when node_modules is empty
fs.rmdirSync(path.join(helper.scopes.localPath, 'node_modules'), { recursive: true });
});
it('should show the correct env in bit show (with no loaded indication)', () => {
const componentShowParsed = helper.command.showComponentParsedHarmonyByTitle('comp1', 'env');
expect(componentShowParsed).to.equal(envId);
const regularShowOutput = helper.command.showComponent('comp1');
expect(regularShowOutput).to.contain(`${envId} (not loaded)`);
});
it('should show the correct env in bit envs (with no loaded indication)', () => {
const envsOutput = helper.command.envs();
expect(envsOutput).to.contain(`${envId} (not loaded)`);
});
it('should show a component issue in bit status', () => {
helper.command.expectStatusToHaveIssue(IssuesClasses.NonLoadedEnv.name);
});
});
describe('custom env with 3 components', () => {
let wsAllNew;
let envId;
Expand Down Expand Up @@ -129,6 +157,72 @@ describe('custom env', function () {
expect(env).to.include(envId);
});
});
(supportNpmCiRegistryTesting ? describe : describe.skip)('load env from env root', () => {
let envId;
let envName;
let npmCiRegistry: NpmCiRegistry;
before(async () => {
helper = new Helper({ scopesOptions: { remoteScopeWithDot: true } });
helper.scopeHelper.setNewLocalAndRemoteScopes();
helper.bitJsonc.setPackageManager('teambit.dependencies/pnpm');
npmCiRegistry = new NpmCiRegistry(helper);
await npmCiRegistry.init();
npmCiRegistry.configureCiInPackageJsonHarmony();
helper.bitJsonc.setupDefault();
envName = helper.env.setCustomNewEnv(undefined, undefined, {
policy: {
peers: [
{
name: 'react',
version: '^16.8.0',
supportedRange: '^16.8.0',
},
],
},
});
envId = `${helper.scopes.remote}/${envName}`;
helper.command.showComponent(envId);
helper.command.tagAllComponents();
helper.command.export();

helper.scopeHelper.reInitLocalScope();
// Clean the capsule dir to make sure it's empty before we continue
const scopeAspectsCapsulesRootDir = helper.command.capsuleListParsed().scopeAspectsCapsulesRootDir;
if (fs.pathExistsSync(scopeAspectsCapsulesRootDir)) {
fs.rmdirSync(scopeAspectsCapsulesRootDir, { recursive: true });
}

helper.scopeHelper.addRemoteScope();
helper.extensions.bitJsonc.addKeyValToDependencyResolver('rootComponents', true);
helper.extensions.bitJsonc.addKeyValToWorkspace('resolveEnvsFromRoots', true);
helper.fixtures.populateComponents(1);
helper.command.setEnv('comp1', envId);
helper.command.install();
});
after(() => {
npmCiRegistry.destroy();
helper = new Helper();
});
it('should load the env without issue', () => {
helper.command.expectStatusToNotHaveIssue(IssuesClasses.NonLoadedEnv.name);
const showOutput = helper.command.showComponent('comp1');
expect(showOutput).to.have.string(envId);
expect(showOutput).to.not.have.string('not loaded');
});
it('should have the env installed in its root', () => {
const envRootDir = helper.env.rootCompDir(`${envId}@0.0.1`);
const resolvedInstalledEnv = resolveFrom(envRootDir, [
`@ci/${helper.scopes.remote.replace(/^ci\./, '')}.react-based-env`,
]);
expect(envRootDir).to.be.a.path();
expect(resolvedInstalledEnv).to.be.a.path();
});
it('should not create scope aspect capsule', () => {
const scopeAspectsCapsulesRootDir = helper.command.capsuleListParsed().scopeAspectsCapsulesRootDir;
expect(scopeAspectsCapsulesRootDir).to.not.be.a.path();
});
});

(supportNpmCiRegistryTesting ? describe : describe.skip)('custom env installed as a package', () => {
let envId;
let envName;
Expand All @@ -151,21 +245,25 @@ describe('custom env', function () {
helper.scopeHelper.addRemoteScope();
helper.bitJsonc.setupDefault();
});
after(() => {
npmCiRegistry.destroy();
helper = new Helper();
});
describe('setting up the external env without a version', () => {
before(() => {
helper.fixtures.populateComponents(1);
helper.extensions.addExtensionToVariant('*', envId);
});
it('should show a descriptive error when tagging the component', () => {
expect(() => helper.command.tagAllComponents()).to.throw(
`if this is an external env/extension/aspect configured in workspace.jsonc, make sure it is set with a version`
);
const tagOutput = helper.general.runWithTryCatch('bit tag -m msg');
expect(tagOutput).to.have.string('failed loading env - external env without a version');
});
describe('running any other command', () => {
// @Gilad TODO
it.skip('should warn or error about the misconfigured env and suggest to enter the version', () => {});
});
});

describe('set up the env using bit env set without a version', () => {
before(() => {
helper.scopeHelper.reInitLocalScope();
Expand Down
49 changes: 32 additions & 17 deletions e2e/harmony/install-and-compile.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs from 'fs';
// import fs from 'fs';
import chai, { expect } from 'chai';
import path from 'path';
import Helper from '../../src/e2e-helper/e2e-helper';
Expand All @@ -12,31 +12,37 @@ describe('all custom envs are compiled during installation', function () {
helper = new Helper();
helper.scopeHelper.setNewLocalAndRemoteScopes();
helper.command.create('node-env', 'custom-env1');
helper.fixtures.generateEnvJsoncFile(`${helper.scopes.remoteWithoutOwner}/custom-env1`, {
policy: {
runtime: [
{
name: 'is-negative',
version: '1.0.0',
force: true,
},
],
},
});
helper.fs.outputFile(
`${helper.scopes.remoteWithoutOwner}/custom-env1/custom-env1.main.runtime.ts`,
`
import { MainRuntime } from '@teambit/cli';
import { NodeAspect, NodeMain } from '@teambit/node'
import { EnvsAspect, EnvsMain } from '@teambit/envs';
import { EnvAspect, EnvMain } from '@teambit/env';
import isPositive from 'is-positive'
import { CustomEnv1Aspect } from './custom-env1.aspect';
export class CustomEnv1Main {
static slots = [];
static dependencies = [NodeAspect, EnvsAspect];
static dependencies = [EnvAspect, EnvsAspect];
static runtime = MainRuntime;
static async provider([node, envs]: [NodeMain, EnvsMain]) {
static async provider([env, envs]: [EnvMain, EnvsMain]) {
console.log(isPositive(1));
const CustomEnv1Env = node.compose([
node.overrideDependencies({
dependencies: {
'is-negative': '1.0.0'
},
})
]);
const CustomEnv1Env = env.compose([]);
envs.registerEnv(CustomEnv1Env);
return new CustomEnv1Main();
}
Expand All @@ -46,6 +52,17 @@ CustomEnv1Aspect.addRuntime(CustomEnv1Main);
`
);
helper.command.create('node-env', 'custom-env2');
helper.fixtures.generateEnvJsoncFile(`${helper.scopes.remoteWithoutOwner}/custom-env2`, {
policy: {
runtime: [
{
name: 'is-odd',
version: '1.0.0',
force: true,
},
],
},
});
helper.fs.outputFile(
`${helper.scopes.remoteWithoutOwner}/custom-env2/custom-env2.main.runtime.ts`,
`
Expand All @@ -69,11 +86,6 @@ export class CustomEnv2Main {
const comp = mdx.createCompiler({ ignoredPatterns: [], babelTransformOptions: babelConfig });
const CustomEnv2Env = node.compose([
node.overrideCompiler(comp),
node.overrideDependencies({
dependencies: {
'is-odd': '1.0.0',
},
})
]);
envs.registerEnv(CustomEnv2Env);
return new CustomEnv2Main();
Expand All @@ -98,7 +110,10 @@ export function comp() {
helper.fs.outputFile(`${helper.scopes.remoteWithoutOwner}/comp/comp.mdx`, '');
helper.command.setEnv(`comp`, `custom-env2`);
helper.command.install('is-positive'); // installing the dependency of custom-env1
fs.rmdirSync(path.join(helper.scopes.localPath, 'node_modules'), { recursive: true });
// TODO: since we disabled the install compile loop this isn't working right now
// as in the first install we can't load the custom env.
// disable this rm for now, but we need to see how we fix it.
// fs.rmdirSync(path.join(helper.scopes.localPath, 'node_modules'), { recursive: true });
helper.command.install();
}
describe('using pnpm', function () {
Expand Down
62 changes: 61 additions & 1 deletion e2e/harmony/install.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import stripAnsi from 'strip-ansi';
import path from 'path';
import fs from 'fs-extra';
import { addDistTag } from '@pnpm/registry-mock';
import { IssuesClasses } from '@teambit/component-issues';
import { expect } from 'chai';
import { getAnotherInstallRequiredOutput } from '@teambit/install/install.cmd';
import chai, { expect } from 'chai';
import Helper from '../../src/e2e-helper/e2e-helper';
import { IS_WINDOWS } from '../../src/constants';
import NpmCiRegistry, { supportNpmCiRegistryTesting } from '../npm-ci-registry';

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

describe('install command', function () {
this.timeout(0);
let helper: Helper;
Expand Down Expand Up @@ -37,6 +42,61 @@ describe('install command', function () {
helper.command.expectStatusToHaveIssue(IssuesClasses.DuplicateComponentAndPackage.name);
});
});

describe('install with old envs in the workspace', () => {
let wsEmptyNM: string;
let envId;
let envName;
let output;
before(async () => {
helper.scopeHelper.setNewLocalAndRemoteScopes();
helper.bitJsonc.setPackageManager('teambit.dependencies/pnpm');
envName = helper.env.setCustomEnv('env-add-dependencies', { skipCompile: true, skipInstall: true });
envId = `${helper.scopes.remote}/${envName}`;
helper.fixtures.populateComponents(1, undefined, undefined, false);
helper.extensions.addExtensionToVariant('*', envId);
// Clean the node_modules as we want to run tests when node_modules is empty
fs.rmdirSync(path.join(helper.scopes.localPath, 'node_modules'), { recursive: true });
wsEmptyNM = helper.scopeHelper.cloneLocalScope(IS_WINDOWS);
});
describe('without --recurring-install', () => {
before(async () => {
output = helper.command.install();
});
it('should show a warning that the workspace has old env without env.jsonc so another install might be required', async () => {
const msg = stripAnsi(getAnotherInstallRequiredOutput(false, [envId]));
expect(output).to.have.string(msg);
});
it('should not install deps that were configured in the env in first install', async () => {
expect(path.join(helper.fixtures.scopes.localPath, 'node_modules/lodash.get')).to.not.be.a.path();
});
describe('without --recurring-install - second install', () => {
before(async () => {
output = helper.command.install();
});
it('should not show a warning that the workspace has old env without env.jsonc so another install might be required', async () => {
const msg = stripAnsi(getAnotherInstallRequiredOutput(false, [envId]));
expect(output).to.not.have.string(msg);
});
it('should install deps that were configured in the env in second install', async () => {
expect(path.join(helper.fixtures.scopes.localPath, 'node_modules/lodash.get')).to.be.a.path();
});
});
});
describe('with --recurring-install', () => {
before(() => {
helper.scopeHelper.getClonedLocalScope(wsEmptyNM);
output = helper.command.install(undefined, { 'recurring-install': '' });
});
it('should show a warning that the workspace has old env without env.jsonc but not offer the recurring-install flag', async () => {
const msg = stripAnsi(getAnotherInstallRequiredOutput(true, [envId]));
expect(output).to.have.string(msg);
});
it('should install deps that were configured in the env', async () => {
expect(path.join(helper.fixtures.scopes.localPath, 'node_modules/lodash.get')).to.be.a.path();
});
});
});
});

(supportNpmCiRegistryTesting ? describe : describe.skip)('install --no-optional', function () {
Expand Down
Loading

0 comments on commit 79bc946

Please sign in to comment.