Skip to content

Commit

Permalink
Merge branch 'component-peer' into component-marked-as-peer
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed Feb 9, 2024
2 parents 623f2fb + 19ff57f commit f4dc2c1
Show file tree
Hide file tree
Showing 176 changed files with 5,118 additions and 5,343 deletions.
240 changes: 120 additions & 120 deletions .bitmap

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ jobs:
- restore_cache:
key: bitsrc-registry10
- restore_cache:
key: core-aspect-env-v0.0.24-v2
key: core-aspect-env-v0.0.25-v2
- run: echo $BIT_FEATURES
- run: node -v
- run: npm -v
Expand Down Expand Up @@ -502,7 +502,7 @@ jobs:
name: bbit install
command: cd bit && bbit install
- save_cache:
key: core-aspect-env-v0.0.24-v2
key: core-aspect-env-v0.0.25-v2
paths:
- /home/circleci/Library/Caches/Bit/capsules/caec9a1075d4addee151dbe7e351b809aaa4b088
- run: cd bit && npm run link-bit-legacy
Expand Down Expand Up @@ -547,7 +547,7 @@ jobs:
- restore_cache:
key: v3-linux-bvm-folder-{{ checksum "version.txt" }}
- restore_cache:
key: core-aspect-env-v0.0.24-v2
key: core-aspect-env-v0.0.25-v2
# - update_ssh_agent
# temporary, check if we can remove it
- run: cd bit && bit cc
Expand Down Expand Up @@ -583,7 +583,7 @@ jobs:
- restore_cache:
key: v3-linux-bvm-folder-{{ checksum "version.txt" }}
- restore_cache:
key: core-aspect-env-v0.0.24-v2
key: core-aspect-env-v0.0.25-v2
- bit_config:
env: "hub"
- restore_cache:
Expand Down Expand Up @@ -895,7 +895,7 @@ jobs:
- restore_cache:
key: bitsrc-registry10
- restore_cache:
key: core-aspect-env-v0.0.24-v2
key: core-aspect-env-v0.0.25-v2
- run: npm view @teambit/bit version > ./version.txt
- restore_cache:
key: v3-linux-bvm-folder-{{ checksum "version.txt" }}
Expand Down
7 changes: 0 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,6 @@ Keep in mind that running the e2e-tests locally may take hours to complete, it's
npm run e2e-test:debug
```

- run e2e-tests for SSH (switch from exporting by using file-system to SSH approach). Make sure you are able to run 'ssh `whoami`@127.0.0.1' on your local.

```bash
npm run e2e-test:ssh
npm run e2e-test:ssh-debug
```

### Debugging

The code is heavy on promises, as such, some errors don't have a useful stack trace. Bluebird enables the long stack trace when the env is development or when `BLUEBIRD_DEBUG` is set. Normally, the full stack trace is not shown on the console but logged in the debug.log file. (located at /Users/your-use/Library/Caches/Bit/logs/debug.log on Mac).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,23 @@ if (isBrowser || '${runtime}' === 'main' || ${shouldRun}) render();
`;
}

function getRuntimeId(aspectDef: AspectDefinition) {
const runtimeId = getIdentifier(aspectDef, 'Runtime', 'runtimePath');
const AS_STR = ' as ';
const runtimeName = runtimeId.includes(AS_STR)
? runtimeId.substring(runtimeId.lastIndexOf(AS_STR) + AS_STR.length, runtimeId.length - 1)
: runtimeId;

return runtimeName;
}

function createAddRuntime(aspectDefs: AspectDefinition[], runtime: string) {
return aspectDefs
.map((aspectDef) => {
const aspectId = getIdentifier(aspectDef, 'Aspect', 'aspectFilePath');
const runtimeId = getIdentifier(aspectDef, 'Runtime', 'runtimePath');
const setRuntime = `${runtimeId}.runtime = "${runtime}";\n`;
return `${setRuntime}${aspectId}.addRuntime(${runtimeId});`;
const runtimeName = getRuntimeId(aspectDef);
const setRuntime = `${runtimeName}.runtime = "${runtime}";\n`;
return `${setRuntime}${aspectId}.addRuntime(${runtimeName});`;
})
.join('\n');
}
Expand Down
30 changes: 0 additions & 30 deletions e2e/commands/_scope.e2e.1.ts

This file was deleted.

2 changes: 1 addition & 1 deletion e2e/commands/export.e2e.1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ describe('bit export command', function () {
});
});
describe('when the group exists and the current user has permission to that group', function () {
if (isWin || process.env.npm_config_with_ssh) {
if (isWin) {
// @ts-ignore
this.skip;
} else {
Expand Down
53 changes: 53 additions & 0 deletions e2e/harmony/checkout-harmony.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { MissingBitMapComponent } from '../../src/consumer/bit-map/exceptions';
import { NewerVersionFound } from '../../src/consumer/exceptions';
import Helper, { FileStatusWithoutChalk } from '../../src/e2e-helper/e2e-helper';
import { FILE_CHANGES_CHECKOUT_MSG } from '../../src/constants';
import { UPDATE_DEPS_ON_IMPORT } from '../../src/api/consumer/lib/feature-toggle';

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

Expand Down Expand Up @@ -578,4 +579,56 @@ describe('bit checkout command', function () {
`);
});
});
describe('checkout head with deps having different versions than workspace.jsonc', () => {
let beforeCheckout: string;
const initWsWithVer = (ver: string) => {
helper.scopeHelper.getClonedLocalScope(beforeCheckout);
helper.workspaceJsonc.addPolicyToDependencyResolver({
dependencies: {
'lodash.get': ver,
},
});
helper.npm.addFakeNpmPackage('lodash.get', ver.replace('^', '').replace('~', ''));
helper.command.checkoutHead(undefined, '-x');
};

before(() => {
helper.scopeHelper.setNewLocalAndRemoteScopes();
helper.command.setFeatures(UPDATE_DEPS_ON_IMPORT);
helper.fixtures.populateComponents(1);
helper.command.tagAllWithoutBuild();
helper.command.export();
beforeCheckout = helper.scopeHelper.cloneLocalScope();

helper.fs.outputFile('comp1/foo.js', `const get = require('lodash.get'); console.log(get);`);
helper.workspaceJsonc.addPolicyToDependencyResolver({
dependencies: {
'lodash.get': '^4.4.2',
},
});
helper.npm.addFakeNpmPackage('lodash.get', '4.4.2');
helper.command.tagAllWithoutBuild();
helper.command.export();
});
it('if the ws has a lower range, it should update workspace.jsonc with the new range', () => {
initWsWithVer('^4.4.1');
const policy = helper.workspaceJsonc.getPolicyFromDependencyResolver();
expect(policy.dependencies['lodash.get']).to.equal('^4.4.2');
});

it('if the ws has a higher range, it should not update', () => {
initWsWithVer('^4.4.3');
const policy = helper.workspaceJsonc.getPolicyFromDependencyResolver();
expect(policy.dependencies['lodash.get']).to.equal('^4.4.3');
});

it('if the ws has a lower exact version, it should write a conflict', () => {
initWsWithVer('4.4.1');
const policy = helper.workspaceJsonc.readRaw();
expect(policy).to.have.string('<<<<<<< ours');
expect(policy).to.have.string('"lodash.get": "4.4.1"');
expect(policy).to.have.string('"lodash.get": "^4.4.2"');
expect(policy).to.have.string('>>>>>>> theirs');
});
});
});
53 changes: 53 additions & 0 deletions e2e/harmony/import-harmony.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,57 @@ describe('import functionality on Harmony', function () {
expect(policy).to.have.string('>>>>>>> theirs');
});
});
describe('import with --dependents', () => {
// create the following graph:
// comp1 -> comp2 -> comp3 -> comp4
// comp1 -> comp-a -> comp4
// comp1 -> comp-b
before(() => {
helper = new Helper();
helper.scopeHelper.setNewLocalAndRemoteScopes();
helper.fixtures.populateComponents(4);
helper.fs.outputFile('comp-a/index.js', `require('${helper.general.getPackageNameByCompName('comp4', false)}');`);
helper.fs.outputFile('comp-b/index.js');
helper.command.addComponent('comp-a');
helper.command.addComponent('comp-b');
helper.command.compile();
helper.fs.appendFile(
'comp1/index.js',
`\nrequire('${helper.general.getPackageNameByCompName('comp-a', false)}');`
);
helper.fs.appendFile(
'comp1/index.js',
`\nrequire('${helper.general.getPackageNameByCompName('comp-b', false)}');`
);

helper.command.tagAllWithoutBuild();
helper.command.export();

helper.scopeHelper.reInitLocalScope();
helper.scopeHelper.addRemoteScope();
helper.command.importComponent('comp1', '-x');
});
it('without "through" should import all graphs between the given component and the workspace', () => {
helper.command.importComponent('comp4', '--dependents -x --silent');
const bitMap = helper.bitMap.read();
expect(bitMap).to.have.property('comp2');
expect(bitMap).to.have.property('comp3');
expect(bitMap).to.have.property('comp4');
expect(bitMap).to.have.property('comp-a');
expect(bitMap).to.not.have.property('comp-b');
});
it('with --dependents-via should limit to graph traversing through the given id', () => {
helper.scopeHelper.reInitLocalScope();
helper.scopeHelper.addRemoteScope();
helper.command.importComponent('comp1', '-x');

helper.command.importComponent('comp4', `--dependents-via ${helper.scopes.remote}/comp2 -x --silent`);
const bitMap = helper.bitMap.read();
expect(bitMap).to.have.property('comp2');
expect(bitMap).to.have.property('comp3');
expect(bitMap).to.have.property('comp4');
expect(bitMap).to.not.have.property('comp-a');
expect(bitMap).to.not.have.property('comp-b');
});
});
});
1 change: 0 additions & 1 deletion e2e/harmony/lanes/lanes.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,6 @@ describe('bit lane command', function () {
helper.scopeHelper.getClonedLocalScope(afterExport);
helper.command.switchLocalLane('main', '-x');
helper.command.import();
helper.command.mergeLane('dev');
});
it('should merge successfully without throwing errors about missing objects', () => {
expect(() => helper.command.mergeLane('dev')).to.not.throw();
Expand Down
Loading

0 comments on commit f4dc2c1

Please sign in to comment.