Skip to content

Commit 419d89d

Browse files
authored
refactor, remove bare-scope commands (teambit#9658)
1 parent ec03cef commit 419d89d

20 files changed

+54
-2716
lines changed

components/legacy/e2e-helper/e2e-command-helper.ts

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -831,43 +831,6 @@ export default class CommandHelper {
831831
mergeMoveLane(laneName: string, options = '') {
832832
return this.runCmd(`bit lane merge-move ${laneName} ${options}`);
833833
}
834-
mergeLaneFromScope(cwd: string, fromLane: string, options = '') {
835-
return this.runCmd(`bit _merge-lane ${fromLane} ${options}`, cwd);
836-
}
837-
mergeLaneFromScopeParsed(cwd: string, fromLane: string, options = ''): Record<string, any> {
838-
const output = this.mergeLaneFromScope(cwd, fromLane, `${options} --json`);
839-
return JSON.parse(output);
840-
}
841-
tagFromScope(cwd: string, data: Record<string, any>, options = '') {
842-
return this.runCmd(`bit _tag '${JSON.stringify(data)}' ${options}`, cwd);
843-
}
844-
snapFromScope(cwd: string, data: Record<string, any>, options = '') {
845-
data.forEach((dataItem) => {
846-
if (!dataItem.files) return;
847-
dataItem.files.forEach((file) => {
848-
if (file.content) {
849-
file.content = Buffer.from(file.content).toString('base64');
850-
}
851-
});
852-
});
853-
return this.runCmd(`bit _snap '${JSON.stringify(data)}' ${options}`, cwd);
854-
}
855-
snapFromScopeParsed(cwd: string, data: Record<string, any>, options = '') {
856-
const output = this.snapFromScope(cwd, data, `${options} --json`);
857-
return JSON.parse(output);
858-
}
859-
apply(data: Record<string, any>, options = '') {
860-
data.forEach((dataItem) => {
861-
if (!dataItem.files) return;
862-
dataItem.files.forEach((file) => {
863-
if (file.content) {
864-
file.content = Buffer.from(file.content).toString('base64');
865-
}
866-
});
867-
});
868-
// console.log('apply command', `bit apply '${JSON.stringify(data)}' ${options}`);
869-
return this.runCmd(`bit apply '${JSON.stringify(data)}' ${options}`);
870-
}
871834
diff(id = '') {
872835
const output = this.runCmd(`bit diff ${id}`);
873836
return removeChalkCharacters(output);

e2e/harmony/lanes/bit-checkout-on-lanes.e2e.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,14 @@ describe('bit checkout command when on a lane', function () {
6060
const list = helper.command.listParsed();
6161
expect(list).to.have.lengthOf(1);
6262

63-
// merge the lane from a bare-scope
64-
const bareMerge = helper.scopeHelper.getNewBareScope('-bare-merge');
65-
helper.scopeHelper.addRemoteScope(helper.scopes.remotePath, bareMerge.scopePath);
66-
helper.command.mergeLaneFromScope(bareMerge.scopePath, `${helper.scopes.remote}/dev`, '--push');
63+
// merge in another workspace
64+
const workspaceBeforeMerge = helper.scopeHelper.cloneWorkspace();
65+
helper.scopeHelper.reInitWorkspace();
66+
helper.scopeHelper.addRemoteScope();
67+
helper.command.mergeLane('dev', '-x');
68+
helper.command.export();
6769

70+
helper.scopeHelper.getClonedWorkspace(workspaceBeforeMerge);
6871
helper.command.checkoutHead('-x');
6972
});
7073
it('should make them available on main even without running bit-import before', () => {

e2e/harmony/lanes/bit-remove-on-lanes.e2e.ts

Lines changed: 20 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,6 @@ describe('bit lane command', function () {
477477
});
478478
});
479479
describe('remove on lane with --update-main then merge to main', () => {
480-
let localWs: string;
481-
let remoteScope: string;
482-
let headOnLane: string;
483480
before(() => {
484481
helper.scopeHelper.setWorkspaceWithRemoteScope();
485482
helper.fixtures.populateComponents(1, false);
@@ -488,67 +485,33 @@ describe('bit lane command', function () {
488485
helper.command.createLane();
489486
helper.command.softRemoveOnLane('comp1', '--update-main');
490487
helper.command.snapAllComponentsWithoutBuild();
491-
headOnLane = helper.command.getHeadOfLane('dev', 'comp1');
492488
helper.command.export();
493-
localWs = helper.scopeHelper.cloneWorkspace();
494-
remoteScope = helper.scopeHelper.cloneRemoteScope();
489+
helper.command.switchLocalLane('main', '-x');
490+
helper.command.mergeLane('dev', '-x');
495491
});
496-
describe('merge from the workspace', () => {
492+
it('should be marked as removed on main', () => {
493+
const removeData = helper.command.showAspectConfig('comp1', Extensions.remove);
494+
expect(removeData.config.removed).to.be.true;
495+
});
496+
it('bit status should show the component as staged', () => {
497+
const status = helper.command.statusJson();
498+
expect(status.stagedComponents).to.have.lengthOf(1);
499+
});
500+
it('bitmap should not have the component', () => {
501+
const bitMap = helper.bitMap.read();
502+
expect(bitMap).to.not.have.property('comp1');
503+
});
504+
describe('export and import the component to a new workspace', () => {
497505
before(() => {
498-
helper.command.switchLocalLane('main', '-x');
499-
helper.command.mergeLane('dev', '-x');
506+
helper.command.export();
507+
helper.scopeHelper.reInitWorkspace();
508+
helper.scopeHelper.addRemoteScope();
509+
helper.command.importComponent('comp1', '-x');
500510
});
501-
it('should be marked as removed on main', () => {
511+
it('should show the component as removed', () => {
502512
const removeData = helper.command.showAspectConfig('comp1', Extensions.remove);
503513
expect(removeData.config.removed).to.be.true;
504514
});
505-
it('bit status should show the component as staged', () => {
506-
const status = helper.command.statusJson();
507-
expect(status.stagedComponents).to.have.lengthOf(1);
508-
});
509-
it('bitmap should not have the component', () => {
510-
const bitMap = helper.bitMap.read();
511-
expect(bitMap).to.not.have.property('comp1');
512-
});
513-
describe('export and import the component to a new workspace', () => {
514-
before(() => {
515-
helper.command.export();
516-
helper.scopeHelper.reInitWorkspace();
517-
helper.scopeHelper.addRemoteScope();
518-
helper.command.importComponent('comp1', '-x');
519-
});
520-
it('should show the component as removed', () => {
521-
const removeData = helper.command.showAspectConfig('comp1', Extensions.remove);
522-
expect(removeData.config.removed).to.be.true;
523-
});
524-
});
525-
});
526-
describe('merge from scope', () => {
527-
let bareMerge;
528-
let mergeOutput: string;
529-
before(() => {
530-
helper.scopeHelper.getClonedWorkspace(localWs);
531-
helper.scopeHelper.getClonedRemoteScope(remoteScope);
532-
bareMerge = helper.scopeHelper.getNewBareScope('-bare-merge');
533-
helper.scopeHelper.addRemoteScope(helper.scopes.remotePath, bareMerge.scopePath);
534-
mergeOutput = helper.command.mergeLaneFromScope(bareMerge.scopePath, `${helper.scopes.remote}/dev`);
535-
});
536-
it('should indicate in the output the new head, not the only one', () => {
537-
expect(mergeOutput).to.have.string(headOnLane);
538-
expect(mergeOutput).to.not.have.string('0.0.1');
539-
});
540-
it('should merge successfully to main', () => {
541-
const headOnMain = helper.command.getHead('comp1', bareMerge.scopePath);
542-
expect(headOnMain).to.equal(headOnLane);
543-
});
544-
it('should be marked as removed on main', () => {
545-
const removeData = helper.command.showAspectConfig(
546-
`${helper.scopes.remote}/comp1`,
547-
Extensions.remove,
548-
bareMerge.scopePath
549-
);
550-
expect(removeData.config.removed).to.be.true;
551-
});
552515
});
553516
});
554517
describe('remove on lane with --update-main then merge to another lane', () => {

e2e/harmony/lanes/lanes.e2e.ts

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -639,54 +639,6 @@ describe('bit lane command', function () {
639639
helper.command.expectStatusToBeClean();
640640
});
641641
});
642-
describe('merging from scope', () => {
643-
let afterExport: string;
644-
before(() => {
645-
helper.scopeHelper.getClonedWorkspace(localScope);
646-
helper.scopeHelper.getClonedRemoteScope(remoteScope);
647-
helper.command.export();
648-
afterExport = helper.scopeHelper.cloneWorkspace();
649-
const bareMerge = helper.scopeHelper.getNewBareScope('-bare-merge');
650-
helper.scopeHelper.addRemoteScope(helper.scopes.remotePath, bareMerge.scopePath);
651-
helper.scopeHelper.addRemoteScope(anotherRemotePath, bareMerge.scopePath);
652-
helper.command.mergeLaneFromScope(bareMerge.scopePath, `${helper.scopes.remote}/dev`, '--push');
653-
});
654-
it('should push the artifacts to the original-scope', () => {
655-
const artifacts = helper.command.getArtifacts(`${anotherRemote}/bar2@latest`, anotherRemotePath);
656-
const pkgArtifacts = artifacts.find((a) => a.generatedBy === 'teambit.pkg/pkg');
657-
const hash = pkgArtifacts.files[0].file;
658-
expect(() => helper.command.catObject(hash, false, anotherRemotePath)).to.not.throw();
659-
});
660-
describe('tagging from scope', () => {
661-
before(() => {
662-
const bareTag = helper.scopeHelper.getNewBareScope('-bare-tag');
663-
helper.scopeHelper.addRemoteScope(helper.scopes.remotePath, bareTag.scopePath);
664-
helper.scopeHelper.addRemoteScope(anotherRemotePath, bareTag.scopePath);
665-
const data = [
666-
{
667-
componentId: `${helper.scopes.remote}/bar1`,
668-
},
669-
{
670-
componentId: `${anotherRemote}/bar2`,
671-
},
672-
];
673-
helper.command.tagFromScope(bareTag.scopePath, data, '--push');
674-
});
675-
describe('merging main into the lane', () => {
676-
before(() => {
677-
helper.scopeHelper.getClonedWorkspace(afterExport);
678-
helper.command.mergeLane('main', '-x');
679-
helper.command.export();
680-
helper.scopeHelper.getClonedWorkspace(afterExport);
681-
helper.command.switchLocalLane('main', '-x');
682-
helper.command.import();
683-
});
684-
it('should merge successfully without throwing errors about missing objects', () => {
685-
expect(() => helper.command.mergeLane('dev')).to.not.throw();
686-
});
687-
});
688-
});
689-
});
690642
});
691643
describe('multiple scopes when the components are new', () => {
692644
let anotherRemote: string;

0 commit comments

Comments
 (0)