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

Implement Lanes and Snaps features #2754

Merged
merged 183 commits into from Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
183 commits
Select commit Hold shift + click to select a range
0f522d1
(wip) start working on bit-snap
davidfirst Oct 24, 2019
f4dfa8c
disconnect the hash calculation of a Version object from its path, it…
davidfirst Oct 31, 2019
de27c6e
(wip) continue working on bit-snap. bit snap command is working, but …
davidfirst Oct 31, 2019
9502a06
snap and tag are working in conjunction
davidfirst Nov 1, 2019
48698f2
snap - have head snap as Ref in memory
davidfirst Nov 1, 2019
2999fe3
fix tests
davidfirst Nov 1, 2019
b95e948
fix bit status
davidfirst Nov 1, 2019
6e7aba6
add e2e-tests
davidfirst Nov 1, 2019
8a1bc14
fix e2e-tests
davidfirst Nov 1, 2019
18e94e0
fix lint issues
davidfirst Nov 1, 2019
f7790b5
fix modified status after snap
davidfirst Nov 1, 2019
394fe19
change parent hash prop if version hash is changed
davidfirst Nov 4, 2019
492c3c1
change parent prop to be an array of parents
davidfirst Nov 4, 2019
9043e17
fix conflicts
davidfirst Nov 4, 2019
042c376
fix unit tests
davidfirst Nov 4, 2019
1a26ef6
fix tests
davidfirst Nov 4, 2019
bb940d6
fix snap head upon untag
davidfirst Nov 5, 2019
b797099
fix untag for snaps
davidfirst Nov 5, 2019
eb36c4c
Merge branch 'master' into feature/snap
davidfirst Nov 5, 2019
6006c53
provide a more descriptive error message when a hash is missing
davidfirst Nov 6, 2019
92b215d
fix e2e-tests
davidfirst Nov 6, 2019
fb47a35
Merge branch 'master' into feature/snap
davidfirst Nov 6, 2019
eb62b91
fix e2e-tests
davidfirst Nov 6, 2019
55082c8
avoid fetching all versions when not needed
davidfirst Nov 6, 2019
3f87d81
fix bug of second tag after snap
davidfirst Nov 7, 2019
3410bed
Merge branch 'master' into feature/snap
davidfirst Nov 7, 2019
703313e
fix import
davidfirst Nov 7, 2019
4d0236f
fix bit-log to show snaps. support diverged snaps history. fix import…
davidfirst Nov 8, 2019
f51a626
fix lint issues
davidfirst Nov 8, 2019
b42d1a6
fix tests
davidfirst Nov 11, 2019
77b2059
fix tests
davidfirst Nov 11, 2019
14cd1ca
fix conflicts
davidfirst Nov 14, 2019
f2f55c2
Merge branch 'master' into feature/snap
davidfirst Nov 14, 2019
d379d0e
fix tests after merge from master
davidfirst Nov 14, 2019
0a191c9
Merge branch 'master' into feature/snap
davidfirst Nov 15, 2019
cb72ee2
fix e2e-tests
davidfirst Nov 15, 2019
f621395
fix e2e-tests
davidfirst Nov 15, 2019
0f36949
implement import --object when the local head is different than the r…
davidfirst Nov 15, 2019
2469856
fix e2e-tests
davidfirst Nov 15, 2019
45757e4
fix unit tests
davidfirst Nov 15, 2019
69a1a5d
Merge branch 'master' into feature/snap
davidfirst Nov 18, 2019
dd20bb1
(wip) started working on bit lane command
davidfirst Nov 19, 2019
43d7c8e
Merge branch 'master' into feature/snap
davidfirst Nov 21, 2019
452dffe
minor fixes
davidfirst Nov 21, 2019
4c68529
revert the implementation of saving different "Component" objects per…
davidfirst Nov 21, 2019
b23f476
implement Lane object (inherit BitObject)
davidfirst Nov 22, 2019
ac3e226
add missing files
davidfirst Nov 23, 2019
d0f6d9e
fix e2e-tests
davidfirst Nov 25, 2019
b248724
fix errors, get "bit lane --components" work again
davidfirst Nov 25, 2019
e0e8472
add basic validation for "lane" object, introduce "bit cat-lane" comm…
davidfirst Nov 25, 2019
50efd46
fix lint and e2e-tests, remove scope-name from lane-id
davidfirst Nov 26, 2019
40274a3
fix bit diff to work with snaps
davidfirst Nov 26, 2019
7160588
bit checkout is working for Snaps
davidfirst Nov 26, 2019
fe6f41b
add tests for bit merge with snaps
davidfirst Nov 26, 2019
6855262
recognize diverged components, suggest to merge them in bit status an…
davidfirst Nov 27, 2019
51a626e
fix tsc errors
davidfirst Nov 27, 2019
d0d88ce
Merge branch 'master' into feature/snap
davidfirst Nov 27, 2019
9d3e3fd
fix tests
davidfirst Nov 27, 2019
109568d
fix unit tests
davidfirst Nov 28, 2019
1fa2ac0
fix status of merge-pending to show the number of snaps existing on l…
davidfirst Nov 28, 2019
5cfd456
add the common snap before diverge data into the diverge results
davidfirst Nov 28, 2019
d16ca6f
implement a snap-merge of diverged components
davidfirst Nov 29, 2019
9cba88d
fix tsc errors
davidfirst Nov 29, 2019
6bb2e25
fix bit-status to show an unresolved component as such, implement bit…
davidfirst Dec 2, 2019
3a55d36
implement merge --abort
davidfirst Dec 2, 2019
a48a58c
fix e2e-tests
davidfirst Dec 2, 2019
6353a8e
prevent tag/snap/checkout/merge a component with conflicts, enable un…
davidfirst Dec 3, 2019
3ea36b4
basic lane export is working
davidfirst Dec 11, 2019
4b3d90d
fix e2e-tests and lint
davidfirst Dec 12, 2019
3e882b3
fix tests
davidfirst Dec 12, 2019
d1fdede
fix conflicts after merging master into feature/snap
davidfirst Dec 12, 2019
daebaf5
write exported components heads into refs/remote
davidfirst Dec 12, 2019
aa7ed41
minor fix
davidfirst Dec 12, 2019
fb0c997
started implementing "bit import" lanes
davidfirst Dec 13, 2019
6831e93
fix tests
davidfirst Dec 17, 2019
e6c90de
move current-local-name from .bitmap to scope.json
davidfirst Dec 17, 2019
a23c678
basic funtionality of switching between master to a lane is working
davidfirst Dec 19, 2019
0dd907a
fix e2e-tests
davidfirst Dec 19, 2019
b499822
fix tsc errors
davidfirst Dec 20, 2019
1e1fd05
add test for "bit diff" when on a lane, fix "bit status" when snapped…
davidfirst Dec 20, 2019
ac48912
started working on "bit merge" for lanes. fix tag & checkout lane for…
davidfirst Dec 20, 2019
b0c38ad
fix e2e-tests
davidfirst Dec 20, 2019
6507505
fix tests, fix exporting from master to write the snaps into the remo…
davidfirst Dec 20, 2019
da65fd5
fix e2e-tests
davidfirst Dec 23, 2019
bbd93e6
basic "bit merge" of lanes is working
davidfirst Dec 25, 2019
f7953bc
fix merging from a remote lane into master
davidfirst Dec 25, 2019
a56fd08
fix e2e-test
davidfirst Dec 26, 2019
8d08375
start working on noSnap flag
davidfirst Dec 26, 2019
01b3d86
rename snap-merge to merge-snaps
davidfirst Dec 26, 2019
1882ed6
consolidating merge-lanes with snap-merge logic. add merge-snaps output
davidfirst Dec 26, 2019
3bf980e
implement --no-snap and --message flags of bit-merge
davidfirst Dec 26, 2019
a0d86e3
add existingOnWorkspaceOnly flag for bit-merge
davidfirst Dec 27, 2019
0b39071
Merge branch 'master' into feature/snap
davidfirst Dec 27, 2019
34f2f28
add e2e-test and output when using --existing flag for bit-merge
davidfirst Dec 27, 2019
5a9317b
implement bit lane --merge and --not-merged flags
davidfirst Dec 27, 2019
deed9d6
add a flag "new-lane-name" for bit-checkout
davidfirst Dec 27, 2019
55f4a0a
introduce new flags for "bit import": --new-lane-name and --checkout
davidfirst Dec 31, 2019
273ef05
fix e2e-tests
davidfirst Dec 31, 2019
7ae128b
fix conflicts after merging from master
davidfirst Dec 31, 2019
5f28a35
copy components data from origin lane to a newly created lane (except…
davidfirst Jan 1, 2020
1f9da59
fix conflicts after merging master
davidfirst Jan 2, 2020
34bb75d
introduce "bit switch" to switch/create/import lanes
davidfirst Jan 2, 2020
014a42b
introduce "bit fetch" command to fetch remote objects
davidfirst Jan 3, 2020
f283adb
improve lane-id
davidfirst Jan 3, 2020
f10429a
bit fetch is working, change tests to work with bit-switch and bit-fetch
davidfirst Jan 3, 2020
b4d354e
fix lint issues
davidfirst Jan 3, 2020
4edac93
fix e2e-tests on Windows
davidfirst Jan 4, 2020
05c3243
basic case of switching from a lane back to master is working
davidfirst Jan 6, 2020
f888e3d
basic case of importing a component when checked out to a lane
davidfirst Jan 7, 2020
277b942
change bit-lane to function only as list/show not as "add". change th…
davidfirst Jan 8, 2020
5ceef4b
Merge branch 'master' into feature/snap
davidfirst Jan 8, 2020
f95d82c
started working on workspace-lanes
davidfirst Jan 9, 2020
4f0dfc6
fix conflicts after merging from master
davidfirst Jan 9, 2020
0654258
implement workspace-lane object to save the current (checked out) ver…
davidfirst Jan 14, 2020
22d937d
fix lint issues
davidfirst Jan 14, 2020
1662f71
export with no ids when checked out to a lane, exports the lane
davidfirst Jan 14, 2020
23727e5
change the export output to indicate that lanes were exported
davidfirst Jan 14, 2020
b926dc1
fix some more bugs
davidfirst Jan 14, 2020
206b400
separate getAllBitIds and getAllIdsAvailableOnLane methods to not use…
davidfirst Jan 14, 2020
ae25217
implement remove local lanes
davidfirst Jan 14, 2020
8026e28
refactoring: extract lanes code from scope into a new class Lanes
davidfirst Jan 15, 2020
514d638
enable fetching lane list from a remote
davidfirst Jan 15, 2020
c088382
add missing files
davidfirst Jan 15, 2020
6d115c0
fix unit tests
davidfirst Jan 15, 2020
09c12aa
rename ObjectsToPush class to CompsAndLanesObjects
davidfirst Jan 15, 2020
5e61c73
rename objects-to-push.ts file to comps-and-lanes-objects.ts
davidfirst Jan 15, 2020
aedd015
fix paths after the rename
davidfirst Jan 15, 2020
f2d9180
when user is checked out to a lane, "bit remove" removes the componen…
davidfirst Jan 15, 2020
6e2b4dd
fix types
davidfirst Jan 15, 2020
5f58a42
enable removing remote lanes
davidfirst Jan 16, 2020
920cc2f
add missing files
davidfirst Jan 16, 2020
ae58b3a
block tagging when on a lane for now. we might change it later
davidfirst Jan 16, 2020
63e7aa1
fix lints
davidfirst Jan 16, 2020
212d01b
implement auto-snap
davidfirst Jan 17, 2020
f658bc9
trying to see what breaks when fetching all parents recursively
davidfirst Jan 17, 2020
a49f559
fix tests
davidfirst Jan 17, 2020
c94321a
skip a test about fetching dependencies parents for now, it will be b…
davidfirst Jan 17, 2020
c6c2357
implement auto-snap on lanes
davidfirst Jan 17, 2020
afe48b2
fix ModelComponent.latest() to always work with the current lane
davidfirst Jan 17, 2020
9af8538
skip an e2e-test for now until backward compatibility is implemented
davidfirst Jan 20, 2020
526d62a
support feature-toggle mechanism
davidfirst Jan 20, 2020
7952e6c
backward compatibility: do not save snaps.head and component parents …
davidfirst Jan 20, 2020
8d4cf12
backward compatibility - fix import from old clients
davidfirst Jan 20, 2020
238ebf6
throw errors when trying to use lanes/snaps and the feature is disabled
davidfirst Jan 20, 2020
1f76690
lint issues
davidfirst Jan 21, 2020
1bd5421
Merge branch 'master' into feature/snap
davidfirst Jan 21, 2020
c0d5300
re-enable some tests now that backward compatibility is supported
davidfirst Jan 21, 2020
e40f02d
extract create-lane functionality to a new file
davidfirst Jan 21, 2020
f4e2416
extract export-lanes functionality to a new file
davidfirst Jan 21, 2020
f0b47c7
refactoring. make sure fetch api gets bit-ids or remote-lane-ids. (re…
davidfirst Jan 21, 2020
3491f52
fix lint
davidfirst Jan 21, 2020
5330dd7
clean some unneeded flags on checkout command
davidfirst Jan 22, 2020
2a44293
fix MergeConflictOnRemote to be backward compatible
davidfirst Jan 22, 2020
d837624
refactoring and mark lane flags as experimental
davidfirst Jan 22, 2020
fd99c11
more refactoring
davidfirst Jan 22, 2020
515df76
remove some dups snap/tag
davidfirst Jan 22, 2020
f4e43b0
fix lint issues
davidfirst Jan 22, 2020
7aacbf4
extract switch lane logic from checkout-version.ts to switch-lanes.ts
davidfirst Jan 23, 2020
fd386a2
consolidate snap-model-component into tag-model-component
davidfirst Jan 23, 2020
8758091
fix Windows tests
davidfirst Jan 23, 2020
70f5968
clear confusion between remoteHead and laneHeadRemote
davidfirst Jan 23, 2020
b34648f
extract merge-lanes code to a new file merge-lanes.ts, refactor Remot…
davidfirst Jan 23, 2020
a3ffb31
extract the diverge-data into a new file, add a new prop "remoteHead"…
davidfirst Jan 24, 2020
db47807
extract the logic of version traversal into a new file
davidfirst Jan 24, 2020
beeeb16
remove the hack of reseting the model-component heads
davidfirst Jan 24, 2020
3ef264c
fix some forward compatibility issues with index.json
davidfirst Jan 24, 2020
0bf1488
fix RemoteLaneId to indicate that a scope is mandatory
davidfirst Jan 24, 2020
9506073
change ModelComponent.snaps.head to ModelComponent.head
davidfirst Jan 24, 2020
bd05574
fix bug when merging components to master
davidfirst Jan 25, 2020
319c235
change variables with snapHead to head
davidfirst Jan 27, 2020
51a7284
fix conflicts after merging master to lanes
davidfirst Jun 18, 2020
a5ff822
fix e2e-tests
davidfirst Jun 18, 2020
12f7596
fix tests
davidfirst Jun 18, 2020
a0e14fc
fix e2e-tests
davidfirst Jun 18, 2020
91b4a4c
fix e2e-tests
davidfirst Jun 19, 2020
37822a4
fix unit tests
davidfirst Jun 19, 2020
7e0a476
fix e2e-tests
davidfirst Jun 19, 2020
efade59
fix lint errors
davidfirst Jun 19, 2020
4eb230b
bump version
GiladShoham Jul 9, 2020
4605600
fix conflicts after merging from master
davidfirst Jul 16, 2020
d35c5fb
fix package-lock.json conflicts
davidfirst Jul 16, 2020
803f79d
fix tests
davidfirst Jul 16, 2020
3520677
revert the package-lock.json to be the same as master
davidfirst Jul 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Expand Up @@ -54,7 +54,7 @@ module.exports = {
'promise/always-return': 'off',
'promise/no-nesting': 'off',
// END ERRORS OF 'plugin:promise/recommended'

'import/prefer-default-export': 'off', // typescript works better without default export
'import/export': 'off', // typescript does allow multiple export default when overloading. not sure why it's enabled here. rule source: https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md
'prefer-object-spread': 'off',
'import/no-duplicates': 'off',
Expand Down
4 changes: 2 additions & 2 deletions e2e/commands/add.e2e.1.ts
Expand Up @@ -691,7 +691,7 @@ describe('bit add command', function() {
helper.command.addComponent('bar/*');
});
it('should generate a short id out of the directory only', () => {
const bitMap = helper.bitMap.readWithoutVersion();
const bitMap = helper.bitMap.readComponentsMapOnly();
const ids = Object.keys(bitMap);
expect(ids).to.include('baz1');
expect(ids).to.include('baz2');
Expand All @@ -703,7 +703,7 @@ describe('bit add command', function() {
helper.command.addComponent('bar/baz1/foo.js bar/baz2/foo.js');
});
it('should generate id out of the directory and the filename to not have a conflict', () => {
const bitMap = helper.bitMap.readWithoutVersion();
const bitMap = helper.bitMap.readComponentsMapOnly();
const ids = Object.keys(bitMap);
expect(ids).to.include('baz1/foo');
expect(ids).to.include('baz2/foo');
Expand Down
5 changes: 4 additions & 1 deletion e2e/commands/export.e2e.1.ts
Expand Up @@ -383,14 +383,17 @@ describe('bit export command', function() {
const isType = helper.command.catComponent(`${helper.scopes.remote}/utils/is-type@0.0.2`, remote2Path);
expect(isType).to.have.property('files');
});
// @todo: this fails when lane features is enabled because it has "parents" and this "parents"
// causes dependencies to be fetched completely.
it('should not have is-type@0.0.1 on that remote', () => {
let isType;
try {
isType = helper.command.catComponent(`${helper.scopes.remote}/utils/is-type@0.0.1`, remote2Path);
} catch (err) {
isType = err.toString();
}
expect(isType).to.have.string('component was not found');
expect(isType).to.have.string('component');
expect(isType).to.have.string('was not found');
});
describe('export a component is-string1 with a dependency is-type of version 0.0.1', () => {
before(() => {
Expand Down
821 changes: 821 additions & 0 deletions e2e/commands/lane.e2e.1.ts

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions e2e/commands/log.e2e.1.ts
Expand Up @@ -25,6 +25,8 @@ describe('bit log', function() {
helper.scopeHelper.addRemoteScope();
helper.command.importComponent('bar/foo');
});
// @todo: this fails when lane features is enabled because it has "parents" and this "parents"
// causes dependencies to be fetched completely.
it('should not throw an error and should indicate that that version has no data', () => {
const output = helper.command.log('utils/is-string');
expect(output).to.have.string('0.0.1');
Expand Down
676 changes: 676 additions & 0 deletions e2e/commands/snap.e2e.2.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion e2e/commands/status.e2e.2.ts
Expand Up @@ -634,7 +634,7 @@ describe('bit status command', function() {
// an intermediate step, make sure bar/foo is before utils/is-string
// so then when bit-javascript resolves dependencies of utils/is-string it finds them in the
// cache
const bitMap = helper.bitMap.readWithoutVersion();
const bitMap = helper.bitMap.readComponentsMapOnly();
const components = Object.keys(bitMap);
expect(components[0]).to.equal('bar/foo');
expect(components[1]).to.equal('utils/is-string');
Expand Down
10 changes: 5 additions & 5 deletions e2e/commands/untrack.e2e.2.ts
Expand Up @@ -50,7 +50,7 @@ describe('bit untrack command', function() {
helper.fs.createFile('bar', 'foo2.js');
helper.command.addComponent(path.normalize('bar/foo2.js'), { i: 'bar/foo2' });
helper.command.untrackComponent('bar/foo');
const bitMap = helper.bitMap.readWithoutVersion();
const bitMap = helper.bitMap.readComponentsMapOnly();
expect(Object.keys(bitMap)).to.be.ofSize(1);
expect(bitMap).to.have.property('bar/foo2');
});
Expand All @@ -59,7 +59,7 @@ describe('bit untrack command', function() {
helper.command.addComponent(path.normalize('bar/foo.js'), { i: 'bar/foo' });
helper.command.tagComponent('bar/foo');
const output = helper.command.untrackComponent('bar/foo');
const bitMap = helper.bitMap.readWithoutVersion();
const bitMap = helper.bitMap.readComponentsMapOnly();
expect(output).to.have.string('error: unable to untrack bar/foo, please use the bit remove command.');
expect(Object.keys(bitMap)).to.be.ofSize(1);
expect(bitMap).to.have.property('bar/foo@0.0.1');
Expand All @@ -68,7 +68,7 @@ describe('bit untrack command', function() {
helper.fs.createFile('bar', 'foo.js');
helper.command.addComponent(path.normalize('bar/foo.js'), { i: 'bar' });
helper.command.untrackComponent('bar');
const bitMap = helper.bitMap.readWithoutVersion();
const bitMap = helper.bitMap.readComponentsMapOnly();
expect(Object.keys(bitMap)).to.be.ofSize(0);
});
it('Should remove 2 new components and keep tagged component', () => {
Expand All @@ -80,7 +80,7 @@ describe('bit untrack command', function() {
helper.fs.createFile('bar', 'foo3.js');
helper.command.addComponent(path.normalize('bar/foo3.js'), { i: 'bar/foo3' });
helper.command.untrackComponent('bar/foo bar/foo3');
const bitMap = helper.bitMap.readWithoutVersion();
const bitMap = helper.bitMap.readComponentsMapOnly();
expect(Object.keys(bitMap)).to.be.ofSize(1);
expect(bitMap).to.have.property('bar/foo2@0.0.1');
});
Expand All @@ -93,7 +93,7 @@ describe('bit untrack command', function() {
helper.fs.createFile('bar', 'foo3.js');
helper.command.addComponent(path.normalize('bar/foo3.js'), { i: 'bar/foo3' });
helper.command.untrackComponent('', true);
const bitMap = helper.bitMap.readWithoutVersion();
const bitMap = helper.bitMap.readComponentsMapOnly();
expect(Object.keys(bitMap)).to.be.ofSize(1);
expect(bitMap).to.have.property('bar/foo2@0.0.1');
});
Expand Down
10 changes: 10 additions & 0 deletions e2e/fixtures/scopes/hash-mismatch-case/index.json
@@ -0,0 +1,10 @@
[
{
"id": {
"scope": "hash-mismatch-case",
"name": "foo"
},
"isSymlink": false,
"hash": "b2eef1ea7be63c86e6cd6942125df6c1413958f7"
}
]
@@ -0,0 +1 @@
x��A@0Pk��]�Ht�%N`��tjS&!��ݾG���<&d��(ǘ D�����q$����C��s�b�������
@@ -0,0 +1,3 @@
x�}R�n�0� �"�a�T ġ'TU�T=l�kp�ؑ"$Ŀw4jEӓ�ݝ��_���(q�,4�X�$�P�t1��t��r 8�R�\�d"NB���X�]ob)r��pY
i��RQZ(SJ̳f
tZ$b,<UК����S;7��[��绥Њ��*��},j0vs�KJc���֓6G&K�2\��X�DM!�.60���[��Y&�UVÇ@�&����hc|�3��*F1�qn�jb�8��2<�Ot*f��!5d��2�#��T�n؁�g�׿p�Q�d ������ՠf_�2 ހ���~��m������ \s�?����\��t[�u��~�뀧��jvǵ�57���:~�K�� ,9�
Expand Down
@@ -0,0 +1 @@
x�m��n� ��(�9�+��zj���a�ae#`�n�߽���������|���Hq�hA�8��$�K��ʡ\t�I�[� ]��E��m���`�T�MZ�i�<]��73]f*�Ik�)fw`7v�E��2>8�v�c�� '{��0��B˔r�8*�1������ꗭܴ��dp# ��9S�G���s%�����i��F%�k��u>+��ƺ����/ ����ْY�h��U���y�f�
Expand Down
5 changes: 5 additions & 0 deletions e2e/fixtures/scopes/hash-mismatch-case/scope.json
@@ -0,0 +1,5 @@
{
"name": "hash-mismatch-case",
"remotes": {},
"version": "14.4.3"
}
48 changes: 48 additions & 0 deletions e2e/flows/hash-mismatch.e2e.3.ts
@@ -0,0 +1,48 @@
import { expect } from 'chai';
import Helper from '../../src/e2e-helper/e2e-helper';

/**
* previously, when a Version hash was changed, you'd get an error upon importing the component
*
* ➜ bit import hash-mismatch-case/foo
found hash mismatch of hash-mismatch-case/foo, version 0.0.1.
originalHash: 6bd019fe5dbf11a5adf2f68d0099457ad077fa8c.
currentHash: d24622f13dbbbc8b1f59535a8bea342924b8867a
this usually happens when a component is old and the migration script was not running or interrupted
*
* it's impossible to change the calculated hash during the e2e-tests. so we can't generate this
* case on the fly. instead, we prepared such a scope from advance and copied it into the fixtures
* directory. (at fixtures/scopes/hash-mismatch-case). this dir contains a complete bare scope that
* has one component "foo" and its version (0.0.1) has a hash that was calculated after some
* manipulation. as a result, when importing this component "foo" to a local scope, the original
* hash is different than the currently calculated hash.
* in Bit version <= 14.4.3, when importing this component, you'd get the exact same error as above.
* now, we expect the import to work with no errors and to save the version object into the
* original hash path (6b/d019fe5dbf11a5adf2f68d0099457ad077fa8c).
*/
describe('hash mismatch', function() {
this.timeout(0);
const helper = new Helper();
after(() => {
helper.scopeHelper.destroy();
});
describe('mismatch', () => {
let output: string;
before(() => {
helper.scopeHelper.reInitLocalScope();
helper.scopes.setRemoteScope(false, undefined, 'hash-mismatch-case');
helper.scopeHelper.reInitRemoteScope();
helper.scopeHelper.addRemoteScope();
helper.fixtures.copyFixtureDir('scopes/hash-mismatch-case/', helper.scopes.remotePath);
output = helper.command.importComponent('foo');
});
it('should be able to import the component', () => {
expect(output).to.have.string('successfully imported one component');
});
it('should save the Version object into the original hash', () => {
const objectsFiles = helper.fs.getObjectFiles();
expect(objectsFiles).to.have.lengthOf(4);
expect(objectsFiles).to.deep.include(`6b/d019fe5dbf11a5adf2f68d0099457ad077fa8c`);
});
});
});
29 changes: 9 additions & 20 deletions e2e/functionalities/components-index.e2e.2.ts
Expand Up @@ -14,17 +14,6 @@ describe('scope components index mechanism', function() {
after(() => {
helper.scopeHelper.destroy();
});
describe('when a scope has no components', () => {
before(() => {
helper.scopeHelper.reInitLocalScope();
helper.command.listLocalScope();
});
it('the index.json file should be an empty array', () => {
expect(helper.general.indexJsonPath()).to.be.a.file();
const indexJson = helper.general.getIndexJson();
expect(indexJson).to.deep.equal([]);
});
});
describe('after tagging a component', () => {
before(() => {
helper.scopeHelper.setNewLocalAndRemoteScopes();
Expand All @@ -33,7 +22,7 @@ describe('scope components index mechanism', function() {
helper.fixtures.tagComponentBarFoo();
});
it('should save the component in the index.json file', () => {
const indexJson = helper.general.getIndexJson();
const indexJson = helper.general.getComponentsFromIndexJson();
expect(indexJson).to.have.lengthOf(1);
const indexItem = indexJson[0];
expect(indexItem).to.have.property('id');
Expand All @@ -48,12 +37,12 @@ describe('scope components index mechanism', function() {
helper.command.exportAllComponents();
});
it('should create a new record with the new scope', () => {
const indexJson = helper.general.getIndexJson();
const indexJson = helper.general.getComponentsFromIndexJson();
const scopes = indexJson.map(item => item.id.scope);
expect(scopes).to.contain(helper.scopes.remote);
});
it('should change the previous record to be a symlink', () => {
const indexJson = helper.general.getIndexJson();
const indexJson = helper.general.getComponentsFromIndexJson();
const indexItem = indexJson.find(item => !item.id.scope);
expect(indexItem.isSymlink).to.be.true;
});
Expand All @@ -68,7 +57,7 @@ describe('scope components index mechanism', function() {
helper.command.removeComponent('bar/foo', '-s');
});
it('should remove the record from index.json', () => {
const indexJson = helper.general.getIndexJson();
const indexJson = helper.general.getComponentsFromIndexJson();
expect(indexJson).to.have.lengthOf(0);
});
it('bit list should show zero components', () => {
Expand All @@ -83,15 +72,15 @@ describe('scope components index mechanism', function() {
helper.command.importComponent('bar/foo');
});
it('should populate the index.json', () => {
const indexJson = helper.general.getIndexJson();
const indexJson = helper.general.getComponentsFromIndexJson();
expect(indexJson).to.have.lengthOf(1);
});
describe('removing the component', () => {
before(() => {
helper.command.removeComponent('bar/foo', '-s');
});
it('should remove the record from index.json', () => {
const indexJson = helper.general.getIndexJson();
const indexJson = helper.general.getComponentsFromIndexJson();
expect(indexJson).to.have.lengthOf(0);
});
it('bit list should show zero components', () => {
Expand Down Expand Up @@ -128,7 +117,7 @@ describe('scope components index mechanism', function() {
helper.command.runCmd('bit init --reset');
});
it('should rebuild index.json with the missing components', () => {
const indexJson = helper.general.getIndexJson();
const indexJson = helper.general.getComponentsFromIndexJson();
expect(indexJson).to.have.lengthOf(1);
});
it('bit list should show 1 component', () => {
Expand All @@ -144,14 +133,14 @@ describe('scope components index mechanism', function() {
helper.fixtures.createComponentBarFoo();
helper.fixtures.addComponentBarFoo();
helper.command.tagAllComponents();
const indexJsonWithBarFoo = helper.general.getIndexJson();
const indexJsonWithBarFoo = helper.general.getComponentsFromIndexJson();
helper.command.untag('bar/foo');
helper.general.writeIndexJson(indexJsonWithBarFoo);
// now, index.json has barFoo, however the scope doesn't have it
});
it('bit status should throw an error for the first time and then should work on the second run', () => {
// used to show "Cannot read property 'scope' of null"
const error = new OutdatedIndexJson('bar/foo', helper.general.indexJsonPath());
const error = new OutdatedIndexJson('component "bar/foo"', helper.general.indexJsonPath());
const statusCmd = () => helper.command.status();
helper.general.expectToThrow(statusCmd, error);

Expand Down
2 changes: 1 addition & 1 deletion e2e/functionalities/dynamic-namespaces.e2e.3.ts
Expand Up @@ -86,7 +86,7 @@ describe('dynamic namespaces', function() {
it('should throw an error and not allow the import', () => {
const output = helper.general.runWithTryCatch(`bit import ${helper.scopes.remote}/foo`);
expect(output).to.have.string('unable to import');
const bitMap = helper.bitMap.readWithoutVersion();
const bitMap = helper.bitMap.readComponentsMapOnly();
expect(Object.keys(bitMap)).to.have.lengthOf(1);
});
it('should throw an error also after tagging', () => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/functionalities/merge.e2e.3.ts
Expand Up @@ -45,7 +45,7 @@ describe('merge functionality', function() {
{ id: `${helper.scopes.remote}/bar/foo`, versions: ['0.0.2'] },
{ id: `${helper.scopes.remote}/bar2/foo2`, versions: ['0.0.2'] }
];
const error = new MergeConflictOnRemote(idsAndVersions);
const error = new MergeConflictOnRemote(idsAndVersions, []);
helper.general.expectToThrow(exportFunc, error);
});
it('should throw MergeConflict error when importing the component', () => {
Expand Down
5 changes: 2 additions & 3 deletions e2e/functionalities/symlink-object-without-component.e2e.3.ts
@@ -1,4 +1,3 @@
import R from 'ramda';
import chai, { expect } from 'chai';
import Helper from '../../src/e2e-helper/e2e-helper';
import { DIAGNOSIS_NAME } from '../../src/doctor/core-diagnoses/orphan-symlink-objects';
Expand Down Expand Up @@ -38,8 +37,8 @@ describe('scope with a symlink object reference to a non-exist component', funct
expect(scopeAfterDelete).to.have.lengthOf(1);

const indexJson = helper.general.getIndexJson();
const componentIndex = indexJson.filter(i => i.isSymlink === false);
helper.general.writeIndexJson(R.without(componentIndex, indexJson));
const componentIndex = indexJson.components.filter(i => i.isSymlink === true);
helper.general.writeIndexJson(componentIndex);
});
it('bit import should throw a descriptive error', () => {
const output = helper.general.runWithTryCatch('bit import bar/foo');
Expand Down
24 changes: 24 additions & 0 deletions fixtures/component-model-object.json
@@ -0,0 +1,24 @@
{
"name": "bar/foo",
"scope": "remote-scope",
"versions": {
"0.0.1": "125a37bdb17220bdc1406a9a28a3dde4eec91225"
},
"lang": "javascript",
"deprecated": false,
"bindingPrefix": "@bit",
"remotes": [
{
"url": "file:///tmp/remote-scope",
"name": "remote-scope",
"date": "1572532837438"
}
],
"state": {
"versions": {
"0.0.1": {
"local": true
}
}
}
}
10 changes: 9 additions & 1 deletion src/api/consumer/index.ts
Expand Up @@ -4,6 +4,7 @@ import remove from './lib/remove';
import { deprecate, undeprecate } from './lib/deprecation';
import { listScope } from './lib/list-scope';
import { tagAction, tagAllAction } from './lib/tag';
import { snapAction } from './lib/snap';
import status from './lib/status';
import { build, buildAll } from './lib/build';
import importAction from './lib/import';
Expand Down Expand Up @@ -31,6 +32,9 @@ import dependencyStatus from './lib/dependency_status';
import login from './lib/login';
import show from './lib/show';
import paintGraph from './lib/paint-graph';
import lane from './lib/lane';
import switchAction from './lib/switch';
import fetch from './lib/fetch';

export {
init,
Expand All @@ -44,6 +48,7 @@ export {
listScope,
tagAction,
tagAllAction,
snapAction,
status,
build,
importAction,
Expand All @@ -70,5 +75,8 @@ export {
ejectAction,
login,
show,
paintGraph
paintGraph,
lane,
switchAction,
fetch
};
5 changes: 4 additions & 1 deletion src/api/consumer/lib/build.ts
Expand Up @@ -21,7 +21,10 @@ export async function build(

export async function buildAll(noCache: boolean, verbose: boolean): Promise<Record<string, any>> {
const consumer: Consumer = await loadConsumer();
const authoredAndImportedIds = consumer.bitMap.getAllBitIds([COMPONENT_ORIGINS.IMPORTED, COMPONENT_ORIGINS.AUTHORED]);
const authoredAndImportedIds = consumer.bitMap.getAllIdsAvailableOnLane([
COMPONENT_ORIGINS.IMPORTED,
COMPONENT_ORIGINS.AUTHORED
]);
if (R.isEmpty(authoredAndImportedIds)) {
return {};
}
Expand Down