@teambit/workspace-root 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.findWorkspaceRootMap = findWorkspaceRootMap;
7
+ exports.isWorkspaceRootComponent = isWorkspaceRootComponent;
8
+ exports.readWorkspaceRoot = readWorkspaceRoot;
9
+ exports.writeWorkspaceRoot = writeWorkspaceRoot;
10
+ function _componentId() {
11
+ const data = require("@teambit/component-id");
12
+ _componentId = function () {
13
+ return data;
14
+ };
15
+ return data;
16
+ }
17
+ function _legacy() {
18
+ const data = require("@teambit/legacy.extension-data");
19
+ _legacy = function () {
20
+ return data;
21
+ };
22
+ return data;
23
+ }
24
+ function _workspaceRoot() {
25
+ const data = require("./workspace-root.aspect");
26
+ _workspaceRoot = function () {
27
+ return data;
28
+ };
29
+ return data;
30
+ }
31
+ /**
32
+ * the aspect data of a workspace-root component and of its members. it is data, not config, on
33
+ * purpose: a Version's hash covers the extensions' config only, so neither entry ever makes a
34
+ * component modified, and the root moving on does not touch its members.
35
+ */
36
+
37
+ /**
38
+ * the entry of the component that owns the workspace root (rootDir "."), if the workspace has one.
39
+ *
40
+ * a root created on another lane, or removed, stays in `.bitmap` so a switch back can restore it.
41
+ * it is not this workspace's root though, and tagging or snapping would otherwise bring it along.
42
+ */
43
+ function findWorkspaceRootMap(bitMap) {
44
+ return bitMap.getWorkspaceRootMap();
45
+ }
46
+ function findData(extensions) {
47
+ return extensions.findCoreExtension(_workspaceRoot().WorkspaceRootAspect.id)?.data;
48
+ }
49
+
50
+ /**
51
+ * whether the component is a workspace-root component, by the marker its versions carry.
52
+ */
53
+ function isWorkspaceRootComponent(extensions) {
54
+ return Boolean(findData(extensions)?.isRoot);
55
+ }
56
+ function readWorkspaceRoot(extensions) {
57
+ const root = findData(extensions)?.root;
58
+ return root ? _componentId().ComponentID.fromString(root) : undefined;
59
+ }
60
+
61
+ /**
62
+ * nothing clears this data: it is not inherited from the version before it. the loader supplies the
63
+ * aspect's data on every load, so a component arrives with the root of the workspace it is in now, or
64
+ * with none - what an earlier workspace recorded never reaches the next version. the data is replaced
65
+ * wholesale rather than merged, so a component that changes role (a member tracked at "." later, or a
66
+ * root moved into a directory of its own) does not keep the marker of the role it left.
67
+ */
68
+ function writeWorkspaceRoot(extensions, rootId) {
69
+ const data = {
70
+ root: rootId.toString()
71
+ };
72
+ const existing = extensions.findCoreExtension(_workspaceRoot().WorkspaceRootAspect.id);
73
+ if (existing) {
74
+ existing.data = data;
75
+ return;
76
+ }
77
+ // core aspects are keyed by name in the extensions list, the same way the component loader adds
78
+ // aspect data (see WorkspaceComponentLoader.getDataEntry)
79
+ extensions.push(new (_legacy().ExtensionDataEntry)(undefined, undefined, _workspaceRoot().WorkspaceRootAspect.id, undefined, data));
80
+ }
81
+
82
+ //# sourceMappingURL=workspace-root-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_componentId","data","require","_legacy","_workspaceRoot","findWorkspaceRootMap","bitMap","getWorkspaceRootMap","findData","extensions","findCoreExtension","WorkspaceRootAspect","id","isWorkspaceRootComponent","Boolean","isRoot","readWorkspaceRoot","root","ComponentID","fromString","undefined","writeWorkspaceRoot","rootId","toString","existing","push","ExtensionDataEntry"],"sources":["workspace-root-data.ts"],"sourcesContent":["import { ComponentID } from '@teambit/component-id';\nimport type { BitMap, ComponentMap } from '@teambit/legacy.bit-map';\nimport type { ExtensionDataList } from '@teambit/legacy.extension-data';\nimport { ExtensionDataEntry } from '@teambit/legacy.extension-data';\nimport { WorkspaceRootAspect } from './workspace-root.aspect';\n\n/**\n * the aspect data of a workspace-root component and of its members. it is data, not config, on\n * purpose: a Version's hash covers the extensions' config only, so neither entry ever makes a\n * component modified, and the root moving on does not touch its members.\n */\nexport type WorkspaceRootData = {\n /**\n * on the workspace-root component itself. set when it is loaded in a workspace and saved with\n * every version, so the root is told from the model alone - by an import onto \".\", a CI, a clone -\n * and not by the files it happens to carry.\n */\n isRoot?: boolean;\n /**\n * on a member: the root of the workspace it was snapped in, at the version the root had at that\n * moment, e.g. \"my-org.my-scope/my-root@0.0.7\". tag and snap bring a new or modified root into\n * their batch, so a member they made always has the version.\n */\n root?: string;\n};\n\n/**\n * the entry of the component that owns the workspace root (rootDir \".\"), if the workspace has one.\n *\n * a root created on another lane, or removed, stays in `.bitmap` so a switch back can restore it.\n * it is not this workspace's root though, and tagging or snapping would otherwise bring it along.\n */\nexport function findWorkspaceRootMap(bitMap: BitMap): ComponentMap | undefined {\n return bitMap.getWorkspaceRootMap();\n}\n\nfunction findData(extensions: ExtensionDataList): WorkspaceRootData | undefined {\n return extensions.findCoreExtension(WorkspaceRootAspect.id)?.data;\n}\n\n/**\n * whether the component is a workspace-root component, by the marker its versions carry.\n */\nexport function isWorkspaceRootComponent(extensions: ExtensionDataList): boolean {\n return Boolean(findData(extensions)?.isRoot);\n}\n\nexport function readWorkspaceRoot(extensions: ExtensionDataList): ComponentID | undefined {\n const root = findData(extensions)?.root;\n return root ? ComponentID.fromString(root) : undefined;\n}\n\n/**\n * nothing clears this data: it is not inherited from the version before it. the loader supplies the\n * aspect's data on every load, so a component arrives with the root of the workspace it is in now, or\n * with none - what an earlier workspace recorded never reaches the next version. the data is replaced\n * wholesale rather than merged, so a component that changes role (a member tracked at \".\" later, or a\n * root moved into a directory of its own) does not keep the marker of the role it left.\n */\nexport function writeWorkspaceRoot(extensions: ExtensionDataList, rootId: ComponentID): void {\n const data: WorkspaceRootData = { root: rootId.toString() };\n const existing = extensions.findCoreExtension(WorkspaceRootAspect.id);\n if (existing) {\n existing.data = data;\n return;\n }\n // core aspects are keyed by name in the extensions list, the same way the component loader adds\n // aspect data (see WorkspaceComponentLoader.getDataEntry)\n extensions.push(new ExtensionDataEntry(undefined, undefined, WorkspaceRootAspect.id, undefined, data));\n}\n"],"mappings":";;;;;;;;;AAAA,SAAAA,aAAA;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;EACrE,IAAIY,QAAQ,EAAE;IACZA,QAAQ,CAACvB,IAAI,GAAGA,IAAI;IACpB;EACF;EACA;EACA;EACAQ,UAAU,CAACgB,IAAI,CAAC,KAAIC,4BAAkB,EAACN,SAAS,EAAEA,SAAS,EAAET,oCAAmB,CAACC,EAAE,EAAEQ,SAAS,EAAEnB,IAAI,CAAC,CAAC;AACxG","ignoreList":[]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+
3
+ function _chai() {
4
+ const data = require("chai");
5
+ _chai = function () {
6
+ return data;
7
+ };
8
+ return data;
9
+ }
10
+ function _componentId() {
11
+ const data = require("@teambit/component-id");
12
+ _componentId = function () {
13
+ return data;
14
+ };
15
+ return data;
16
+ }
17
+ function _legacy() {
18
+ const data = require("@teambit/legacy.bit-map");
19
+ _legacy = function () {
20
+ return data;
21
+ };
22
+ return data;
23
+ }
24
+ function _legacy2() {
25
+ const data = require("@teambit/legacy.constants");
26
+ _legacy2 = function () {
27
+ return data;
28
+ };
29
+ return data;
30
+ }
31
+ function _legacy3() {
32
+ const data = require("@teambit/legacy.extension-data");
33
+ _legacy3 = function () {
34
+ return data;
35
+ };
36
+ return data;
37
+ }
38
+ function _workspaceRootData() {
39
+ const data = require("./workspace-root-data");
40
+ _workspaceRootData = function () {
41
+ return data;
42
+ };
43
+ return data;
44
+ }
45
+ function _workspaceRoot() {
46
+ const data = require("./workspace-root.aspect");
47
+ _workspaceRoot = function () {
48
+ return data;
49
+ };
50
+ return data;
51
+ }
52
+ const rootId = _componentId().ComponentID.fromString('my-scope/my-root@0.0.7');
53
+ describe('workspace-root data', () => {
54
+ describe('findWorkspaceRootMap', () => {
55
+ // a real BitMap rather than a stand-in: the rule lives on it (getWorkspaceRootMap), and a mock
56
+ // that answers isRemoved() itself would only be testing the mock
57
+ const bitMapWith = async entries => {
58
+ const bitMap = await _legacy().BitMap.load(__dirname, '');
59
+ bitMap.loadComponents(entries, 'my-scope');
60
+ return bitMap;
61
+ };
62
+ const rootEntry = {
63
+ name: 'my-root',
64
+ scope: 'my-scope',
65
+ version: '0.0.7',
66
+ mainFile: 'README.md',
67
+ rootDir: '.'
68
+ };
69
+ const nestedEntry = {
70
+ name: 'comp1',
71
+ scope: 'my-scope',
72
+ version: '0.0.1',
73
+ mainFile: 'index.js',
74
+ rootDir: 'comp1'
75
+ };
76
+ it('should return the entry tracked at the workspace root', async () => {
77
+ const bitMap = await bitMapWith({
78
+ 'my-scope/comp1': nestedEntry,
79
+ 'my-scope/my-root': rootEntry
80
+ });
81
+ (0, _chai().expect)((0, _workspaceRootData().findWorkspaceRootMap)(bitMap)?.id.toString()).to.equal(rootId.toString());
82
+ });
83
+ it('should return undefined when no component owns the workspace root', async () => {
84
+ const bitMap = await bitMapWith({
85
+ 'my-scope/comp1': nestedEntry
86
+ });
87
+ (0, _chai().expect)((0, _workspaceRootData().findWorkspaceRootMap)(bitMap)).to.be.undefined;
88
+ });
89
+ it('should ignore a root of another lane, this lane is rootless', async () => {
90
+ // it stays in .bitmap so a switch back can restore it. snapping here would otherwise tag it along
91
+ const bitMap = await bitMapWith({
92
+ 'my-scope/my-root': rootEntry
93
+ });
94
+ bitMap.components[0].isAvailableOnCurrentLane = false;
95
+ (0, _chai().expect)((0, _workspaceRootData().findWorkspaceRootMap)(bitMap)).to.be.undefined;
96
+ });
97
+ it('should ignore a removed root', async () => {
98
+ const bitMap = await bitMapWith({
99
+ 'my-scope/my-root': rootEntry
100
+ });
101
+ bitMap.components[0].config = {
102
+ [_legacy2().Extensions.remove]: {
103
+ removed: true
104
+ }
105
+ };
106
+ (0, _chai().expect)((0, _workspaceRootData().findWorkspaceRootMap)(bitMap)).to.be.undefined;
107
+ });
108
+ });
109
+ describe('isWorkspaceRootComponent', () => {
110
+ const withData = data => _legacy3().ExtensionDataList.fromArray([new (_legacy3().ExtensionDataEntry)(undefined, undefined, _workspaceRoot().WorkspaceRootAspect.id, undefined, data)]);
111
+ it('should recognize the marker the root carries', () => {
112
+ (0, _chai().expect)((0, _workspaceRootData().isWorkspaceRootComponent)(withData({
113
+ isRoot: true
114
+ }))).to.be.true;
115
+ });
116
+ it('should not take a member, which carries the pointer to its root, for a root', () => {
117
+ (0, _chai().expect)((0, _workspaceRootData().isWorkspaceRootComponent)(withData({
118
+ root: rootId.toString()
119
+ }))).to.be.false;
120
+ });
121
+ it('should be false for a component with no data of this aspect', () => {
122
+ (0, _chai().expect)((0, _workspaceRootData().isWorkspaceRootComponent)(_legacy3().ExtensionDataList.fromArray([]))).to.be.false;
123
+ });
124
+ });
125
+ describe('writeWorkspaceRoot and readWorkspaceRoot', () => {
126
+ it('should round-trip the root id with its version', () => {
127
+ const extensions = _legacy3().ExtensionDataList.fromArray([]);
128
+ (0, _workspaceRootData().writeWorkspaceRoot)(extensions, rootId);
129
+ (0, _chai().expect)((0, _workspaceRootData().readWorkspaceRoot)(extensions)?.toString()).to.equal('my-scope/my-root@0.0.7');
130
+ });
131
+ it('should replace an existing pointer rather than add a second entry', () => {
132
+ const extensions = _legacy3().ExtensionDataList.fromArray([]);
133
+ (0, _workspaceRootData().writeWorkspaceRoot)(extensions, rootId);
134
+ (0, _workspaceRootData().writeWorkspaceRoot)(extensions, rootId.changeVersion('0.0.8'));
135
+ (0, _chai().expect)(extensions).to.have.lengthOf(1);
136
+ (0, _chai().expect)((0, _workspaceRootData().readWorkspaceRoot)(extensions)?.version).to.equal('0.0.8');
137
+ });
138
+ it('should keep a root that was never snapped without a version', () => {
139
+ const extensions = _legacy3().ExtensionDataList.fromArray([]);
140
+ (0, _workspaceRootData().writeWorkspaceRoot)(extensions, _componentId().ComponentID.fromString('my-scope/my-root'));
141
+ (0, _chai().expect)((0, _workspaceRootData().readWorkspaceRoot)(extensions)?.hasVersion()).to.be.false;
142
+ });
143
+ it('should return undefined for a component with no pointer', () => {
144
+ (0, _chai().expect)((0, _workspaceRootData().readWorkspaceRoot)(_legacy3().ExtensionDataList.fromArray([]))).to.be.undefined;
145
+ });
146
+ it('should replace the data rather than merge into it, so a former root is not both', () => {
147
+ // a root moved out of "." into a directory of its own becomes an ordinary member. merging would
148
+ // leave the isRoot marker behind and the version would claim both roles at once
149
+ const extensions = _legacy3().ExtensionDataList.fromArray([new (_legacy3().ExtensionDataEntry)(undefined, undefined, _workspaceRoot().WorkspaceRootAspect.id, undefined, {
150
+ isRoot: true
151
+ })]);
152
+ (0, _workspaceRootData().writeWorkspaceRoot)(extensions, rootId);
153
+ (0, _chai().expect)((0, _workspaceRootData().isWorkspaceRootComponent)(extensions)).to.be.false;
154
+ (0, _chai().expect)((0, _workspaceRootData().readWorkspaceRoot)(extensions)?.toString()).to.equal(rootId.toString());
155
+ });
156
+ });
157
+ });
158
+
159
+ //# sourceMappingURL=workspace-root-data.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_chai","data","require","_componentId","_legacy","_legacy2","_legacy3","_workspaceRootData","_workspaceRoot","rootId","ComponentID","fromString","describe","bitMapWith","entries","bitMap","BitMap","load","__dirname","loadComponents","rootEntry","name","scope","version","mainFile","rootDir","nestedEntry","it","expect","findWorkspaceRootMap","id","toString","to","equal","be","undefined","components","isAvailableOnCurrentLane","config","Extensions","remove","removed","withData","ExtensionDataList","fromArray","ExtensionDataEntry","WorkspaceRootAspect","isWorkspaceRootComponent","isRoot","true","root","false","extensions","writeWorkspaceRoot","readWorkspaceRoot","changeVersion","have","lengthOf","hasVersion"],"sources":["workspace-root-data.spec.ts"],"sourcesContent":["import { expect } from 'chai';\nimport { ComponentID } from '@teambit/component-id';\nimport { BitMap } from '@teambit/legacy.bit-map';\nimport { Extensions } from '@teambit/legacy.constants';\nimport { ExtensionDataEntry, ExtensionDataList } from '@teambit/legacy.extension-data';\nimport {\n findWorkspaceRootMap,\n isWorkspaceRootComponent,\n readWorkspaceRoot,\n writeWorkspaceRoot,\n} from './workspace-root-data';\nimport { WorkspaceRootAspect } from './workspace-root.aspect';\n\nconst rootId = ComponentID.fromString('my-scope/my-root@0.0.7');\n\ndescribe('workspace-root data', () => {\n describe('findWorkspaceRootMap', () => {\n // a real BitMap rather than a stand-in: the rule lives on it (getWorkspaceRootMap), and a mock\n // that answers isRemoved() itself would only be testing the mock\n const bitMapWith = async (entries: Record<string, any>) => {\n const bitMap = await BitMap.load(__dirname, '');\n bitMap.loadComponents(entries, 'my-scope');\n return bitMap;\n };\n const rootEntry = { name: 'my-root', scope: 'my-scope', version: '0.0.7', mainFile: 'README.md', rootDir: '.' };\n const nestedEntry = { name: 'comp1', scope: 'my-scope', version: '0.0.1', mainFile: 'index.js', rootDir: 'comp1' };\n it('should return the entry tracked at the workspace root', async () => {\n const bitMap = await bitMapWith({ 'my-scope/comp1': nestedEntry, 'my-scope/my-root': rootEntry });\n expect(findWorkspaceRootMap(bitMap)?.id.toString()).to.equal(rootId.toString());\n });\n it('should return undefined when no component owns the workspace root', async () => {\n const bitMap = await bitMapWith({ 'my-scope/comp1': nestedEntry });\n expect(findWorkspaceRootMap(bitMap)).to.be.undefined;\n });\n it('should ignore a root of another lane, this lane is rootless', async () => {\n // it stays in .bitmap so a switch back can restore it. snapping here would otherwise tag it along\n const bitMap = await bitMapWith({ 'my-scope/my-root': rootEntry });\n bitMap.components[0].isAvailableOnCurrentLane = false;\n expect(findWorkspaceRootMap(bitMap)).to.be.undefined;\n });\n it('should ignore a removed root', async () => {\n const bitMap = await bitMapWith({ 'my-scope/my-root': rootEntry });\n bitMap.components[0].config = { [Extensions.remove]: { removed: true } };\n expect(findWorkspaceRootMap(bitMap)).to.be.undefined;\n });\n });\n describe('isWorkspaceRootComponent', () => {\n const withData = (data: Record<string, any>) =>\n ExtensionDataList.fromArray([\n new ExtensionDataEntry(undefined, undefined, WorkspaceRootAspect.id, undefined, data),\n ]);\n it('should recognize the marker the root carries', () => {\n expect(isWorkspaceRootComponent(withData({ isRoot: true }))).to.be.true;\n });\n it('should not take a member, which carries the pointer to its root, for a root', () => {\n expect(isWorkspaceRootComponent(withData({ root: rootId.toString() }))).to.be.false;\n });\n it('should be false for a component with no data of this aspect', () => {\n expect(isWorkspaceRootComponent(ExtensionDataList.fromArray([]))).to.be.false;\n });\n });\n describe('writeWorkspaceRoot and readWorkspaceRoot', () => {\n it('should round-trip the root id with its version', () => {\n const extensions = ExtensionDataList.fromArray([]);\n writeWorkspaceRoot(extensions, rootId);\n expect(readWorkspaceRoot(extensions)?.toString()).to.equal('my-scope/my-root@0.0.7');\n });\n it('should replace an existing pointer rather than add a second entry', () => {\n const extensions = ExtensionDataList.fromArray([]);\n writeWorkspaceRoot(extensions, rootId);\n writeWorkspaceRoot(extensions, rootId.changeVersion('0.0.8'));\n expect(extensions).to.have.lengthOf(1);\n expect(readWorkspaceRoot(extensions)?.version).to.equal('0.0.8');\n });\n it('should keep a root that was never snapped without a version', () => {\n const extensions = ExtensionDataList.fromArray([]);\n writeWorkspaceRoot(extensions, ComponentID.fromString('my-scope/my-root'));\n expect(readWorkspaceRoot(extensions)?.hasVersion()).to.be.false;\n });\n it('should return undefined for a component with no pointer', () => {\n expect(readWorkspaceRoot(ExtensionDataList.fromArray([]))).to.be.undefined;\n });\n it('should replace the data rather than merge into it, so a former root is not both', () => {\n // a root moved out of \".\" into a directory of its own becomes an ordinary member. merging would\n // leave the isRoot marker behind and the version would claim both roles at once\n const extensions = ExtensionDataList.fromArray([\n new ExtensionDataEntry(undefined, undefined, WorkspaceRootAspect.id, undefined, { isRoot: true }),\n ]);\n writeWorkspaceRoot(extensions, rootId);\n expect(isWorkspaceRootComponent(extensions)).to.be.false;\n expect(readWorkspaceRoot(extensions)?.toString()).to.equal(rootId.toString());\n });\n });\n});\n"],"mappings":";;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,aAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,YAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,O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AC5E,CAAC,CAAC;IACFR,EAAE,CAAC,iFAAiF,EAAE,MAAM;MAC1F;MACA;MACA,MAAMyB,UAAU,GAAGT,4BAAiB,CAACC,SAAS,CAAC,CAC7C,KAAIC,6BAAkB,EAACV,SAAS,EAAEA,SAAS,EAAEW,oCAAmB,CAAChB,EAAE,EAAEK,SAAS,EAAE;QAAEa,MAAM,EAAE;MAAK,CAAC,CAAC,CAClG,CAAC;MACF,IAAAK,uCAAkB,EAACD,UAAU,EAAE3C,MAAM,CAAC;MACtC,IAAAmB,cAAM,EAAC,IAAAmB,6CAAwB,EAACK,UAAU,CAAC,CAAC,CAACpB,EAAE,CAACE,EAAE,CAACiB,KAAK;MACxD,IAAAvB,cAAM,EAAC,IAAA0B,sCAAiB,EAACF,UAAU,CAAC,EAAErB,QAAQ,CAAC,CAAC,CAAC,CAACC,EAAE,CAACC,KAAK,CAACxB,MAAM,CAACsB,QAAQ,CAAC,CAAC,CAAC;IAC/E,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import { Aspect } from '@teambit/harmony';
2
+ export declare const WorkspaceRootAspect: Aspect;
3
+ export default WorkspaceRootAspect;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.WorkspaceRootAspect = void 0;
7
+ function _harmony() {
8
+ const data = require("@teambit/harmony");
9
+ _harmony = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ const WorkspaceRootAspect = exports.WorkspaceRootAspect = _harmony().Aspect.create({
15
+ id: 'teambit.workspace/workspace-root'
16
+ });
17
+ var _default = exports.default = WorkspaceRootAspect;
18
+
19
+ //# sourceMappingURL=workspace-root.aspect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_harmony","data","require","WorkspaceRootAspect","exports","Aspect","create","id","_default","default"],"sources":["workspace-root.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const WorkspaceRootAspect = Aspect.create({\n id: 'teambit.workspace/workspace-root',\n});\n\nexport default WorkspaceRootAspect;\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAME,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAGE,iBAAM,CAACC,MAAM,CAAC;EAC/CC,EAAE,EAAE;AACN,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAAJ,OAAA,CAAAK,OAAA,GAEYN,mBAAmB","ignoreList":[]}
@@ -0,0 +1,62 @@
1
+ ---
2
+ description: The component that owns the workspace root, and the record its members keep of it
3
+ labels: ['core aspect', 'workspace', 'workspace-root']
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ A workspace-root component is tracked at the workspace root (`rootDir: "."`). It versions the
9
+ workspace's own files, such as `workspace.jsonc`, `.bitmap`, the lockfile and repo-level scripts and
10
+ configs, and a git-free workspace is restored from it.
11
+
12
+ This aspect owns two pieces of data, both saved with every version. The root marks itself, so it is
13
+ told from the model alone rather than by the files it happens to carry:
14
+
15
+ ```json
16
+ "teambit.workspace/workspace-root": {
17
+ "data": { "isRoot": true }
18
+ }
19
+ ```
20
+
21
+ Every member the workspace snaps records which root it was snapped in and at which version:
22
+
23
+ ```json
24
+ "teambit.workspace/workspace-root": {
25
+ "data": { "root": "my-org.my-scope/my-root@0.0.7" }
26
+ }
27
+ ```
28
+
29
+ A new or modified root joins every `bit tag` and `bit snap` of its members, so the recorded version
30
+ is always the one that has the files the member was made with. A root tagged along is bumped as a
31
+ patch, whatever version the members were given.
32
+
33
+ Both are aspect data, not config, so they never make a component modified and the root moving on
34
+ does not touch its members. Their consumers are tools that need the root's files a version was made
35
+ with, such as a CI building the component or a workspace clone.
36
+
37
+ ## Cloning a workspace
38
+
39
+ `bit clone <root-id> [dir]` makes a workspace out of a workspace-root component, the way `git clone`
40
+ makes a working tree out of a repository. It runs outside a workspace, in an empty or absent
41
+ directory (default: the component name), and needs no `bit init`:
42
+
43
+ - the root's files land at the workspace root, `workspace.jsonc` included;
44
+ - every component the root's versioned `.bitmap` lists is imported into the directory it records;
45
+ - the dependencies are installed and the components compiled (`--skip-dependency-installation` to skip).
46
+
47
+ The versioned `.bitmap` holds no versions, only which components exist and where, so the components
48
+ come at their heads on main. `--lane <scope>/<name>` clones the workspace as it is on a lane: the
49
+ workspace comes out on the lane and the components at their heads there. A version on the root id
50
+ pins the root files only. A component the root lists that its remote does not have, one never
51
+ exported for instance, is reported and the clone goes on without it.
52
+
53
+ A clone comes out with nothing modified. What the root versions of its `.bitmap` is normalized to the
54
+ part an export does not change, so the map the clone writes is the map the root carries.
55
+
56
+ Scopes on bit.cloud resolve by name. For a self-hosted scope that is not in the global remotes,
57
+ `--remote <url>` registers it in the new workspace first.
58
+
59
+ ## Terminology
60
+
61
+ "Workspace-root component", because "root component" is taken by the dependency-resolver's
62
+ `rootComponents`, and "workspace component" means any component loaded from a workspace.
@@ -0,0 +1,21 @@
1
+ import type { Component, ShowFragment } from '@teambit/component';
2
+ import type { WorkspaceRootMain } from './workspace-root.main.runtime';
3
+ export declare class WorkspaceRootFragment implements ShowFragment {
4
+ private workspaceRoot;
5
+ constructor(workspaceRoot: WorkspaceRootMain);
6
+ title: string;
7
+ renderRow(component: Component): Promise<{
8
+ title: string;
9
+ content: string;
10
+ }>;
11
+ json(component: Component): Promise<{
12
+ title: string;
13
+ json: {
14
+ isRoot: true;
15
+ root?: undefined;
16
+ } | {
17
+ isRoot?: undefined;
18
+ root: string;
19
+ } | undefined;
20
+ }>;
21
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.WorkspaceRootFragment = void 0;
7
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
9
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ class WorkspaceRootFragment {
11
+ constructor(workspaceRoot) {
12
+ this.workspaceRoot = workspaceRoot;
13
+ _defineProperty(this, "title", 'workspace root');
14
+ }
15
+ async renderRow(component) {
16
+ return {
17
+ title: this.title,
18
+ content: this.workspaceRoot.isWorkspaceRootComponent(component) ? 'this component' : this.workspaceRoot.getRootOf(component)?.toString() ?? ''
19
+ };
20
+ }
21
+ async json(component) {
22
+ const isRoot = this.workspaceRoot.isWorkspaceRootComponent(component);
23
+ const root = this.workspaceRoot.getRootOf(component)?.toString();
24
+ return {
25
+ title: this.title,
26
+ json: isRoot ? {
27
+ isRoot
28
+ } : root ? {
29
+ root
30
+ } : undefined
31
+ };
32
+ }
33
+ }
34
+ exports.WorkspaceRootFragment = WorkspaceRootFragment;
35
+
36
+ //# sourceMappingURL=workspace-root.fragment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["WorkspaceRootFragment","constructor","workspaceRoot","_defineProperty","renderRow","component","title","content","isWorkspaceRootComponent","getRootOf","toString","json","isRoot","root","undefined","exports"],"sources":["workspace-root.fragment.ts"],"sourcesContent":["import type { Component, ShowFragment } from '@teambit/component';\nimport type { WorkspaceRootMain } from './workspace-root.main.runtime';\n\nexport class WorkspaceRootFragment implements ShowFragment {\n constructor(private workspaceRoot: WorkspaceRootMain) {}\n\n title = 'workspace root';\n\n async renderRow(component: Component) {\n return {\n title: this.title,\n content: this.workspaceRoot.isWorkspaceRootComponent(component)\n ? 'this component'\n : (this.workspaceRoot.getRootOf(component)?.toString() ?? ''),\n };\n }\n\n async json(component: Component) {\n const isRoot = this.workspaceRoot.isWorkspaceRootComponent(component);\n const root = this.workspaceRoot.getRootOf(component)?.toString();\n return {\n title: this.title,\n json: isRoot ? { isRoot } : root ? { root } : undefined,\n };\n }\n}\n"],"mappings":";;;;;;;;;AAGO,MAAMA,qBAAqB,CAAyB;EACzDC,WAAWA,CAASC,aAAgC,EAAE;IAAA,KAAlCA,aAAgC,GAAhCA,aAAgC;IAAAC,eAAA,gBAE5C,gBAAgB;EAF+B;EAIvD,MAAMC,SAASA,CAACC,SAAoB,EAAE;IACpC,OAAO;MACLC,KAAK,EAAE,IAAI,CAACA,KAAK;MACjBC,OAAO,EAAE,IAAI,CAACL,aAAa,CAACM,wBAAwB,CAACH,SAAS,CAAC,GAC3D,gBAAgB,GACf,IAAI,CAACH,aAAa,CAACO,SAAS,CAACJ,SAAS,CAAC,EAAEK,QAAQ,CAAC,CAAC,IAAI;IAC9D,CAAC;EACH;EAEA,MAAMC,IAAIA,CAACN,SAAoB,EAAE;IAC/B,MAAMO,MAAM,GAAG,IAAI,CAACV,aAAa,CAACM,wBAAwB,CAACH,SAAS,CAAC;IACrE,MAAMQ,IAAI,GAAG,IAAI,CAACX,aAAa,CAACO,SAAS,CAACJ,SAAS,CAAC,EAAEK,QAAQ,CAAC,CAAC;IAChE,OAAO;MACLJ,KAAK,EAAE,IAAI,CAACA,KAAK;MACjBK,IAAI,EAAEC,MAAM,GAAG;QAAEA;MAAO,CAAC,GAAGC,IAAI,GAAG;QAAEA;MAAK,CAAC,GAAGC;IAChD,CAAC;EACH;AACF;AAACC,OAAA,CAAAf,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -0,0 +1,51 @@
1
+ import type { CLIMain } from '@teambit/cli';
2
+ import type { Component, ComponentMain } from '@teambit/component';
3
+ import { ComponentID } from '@teambit/component-id';
4
+ import type { Workspace } from '@teambit/workspace';
5
+ import type { CloneOptions, CloneResult, LoadBit } from './clone';
6
+ /**
7
+ * the workspace-root component is the one tracked at the workspace root (rootDir "."). it versions
8
+ * the workspace's own files - workspace.jsonc, .bitmap, the lockfile, repo scripts and configs - and
9
+ * a git-free workspace is restored from it. this aspect is the home of that concept: the marker that
10
+ * tells a root apart wherever it is, and the record every member carries of the root it was snapped
11
+ * in.
12
+ *
13
+ * "workspace-root component" rather than "root component", which is the dependency-resolver's
14
+ * rootComponents, or "workspace component", which is every component loaded from a workspace.
15
+ */
16
+ export declare class WorkspaceRootMain {
17
+ private workspace?;
18
+ private loadBit?;
19
+ constructor(workspace?: Workspace | undefined);
20
+ /**
21
+ * a clone loads bit for the new workspace, in a process that started outside of one. the function
22
+ * belongs to the bit aspect, which depends on this one, so it is handed over rather than imported
23
+ * (see load-bit.ts).
24
+ */
25
+ setLoadBit(loadBit: LoadBit): void;
26
+ /**
27
+ * make a workspace out of a workspace-root component: its files at the root, every component it
28
+ * lists in the directory it records, then install. see cloneWorkspace.
29
+ */
30
+ clone(idStr: string, dir: string | undefined, options?: CloneOptions): Promise<CloneResult>;
31
+ /**
32
+ * the id of the component that owns the workspace root, if the workspace has one.
33
+ */
34
+ getRootComponentId(): ComponentID | undefined;
35
+ /**
36
+ * whether the component is a workspace-root component. read from its aspect data, so it works
37
+ * for a component loaded from a scope as well as from a workspace.
38
+ */
39
+ isWorkspaceRootComponent(component: Component): boolean;
40
+ /**
41
+ * the workspace-root component a component was snapped in, at the version the root had then. the
42
+ * snap records it as aspect data, so it is available wherever the component is, a bare scope
43
+ * included. it is the way to know which root files (lockfile, tsconfig, scripts) a version was
44
+ * made with. a component snapped in a workspace without a root component has none.
45
+ */
46
+ getRootOf(component: Component): ComponentID | undefined;
47
+ private extensionsOf;
48
+ static runtime: import("@teambit/harmony").RuntimeDefinition;
49
+ static dependencies: import("@teambit/harmony").Aspect[];
50
+ static provider([workspace, component, cli]: [Workspace | undefined, ComponentMain, CLIMain]): Promise<WorkspaceRootMain>;
51
+ }