@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,419 @@
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 _fsExtra() {
11
+ const data = _interopRequireDefault(require("fs-extra"));
12
+ _fsExtra = function () {
13
+ return data;
14
+ };
15
+ return data;
16
+ }
17
+ function _os() {
18
+ const data = _interopRequireDefault(require("os"));
19
+ _os = function () {
20
+ return data;
21
+ };
22
+ return data;
23
+ }
24
+ function _path() {
25
+ const data = _interopRequireDefault(require("path"));
26
+ _path = function () {
27
+ return data;
28
+ };
29
+ return data;
30
+ }
31
+ function _componentId() {
32
+ const data = require("@teambit/component-id");
33
+ _componentId = function () {
34
+ return data;
35
+ };
36
+ return data;
37
+ }
38
+ function _legacy() {
39
+ const data = require("@teambit/legacy.bit-map");
40
+ _legacy = function () {
41
+ return data;
42
+ };
43
+ return data;
44
+ }
45
+ function _clone() {
46
+ const data = require("./clone");
47
+ _clone = function () {
48
+ return data;
49
+ };
50
+ return data;
51
+ }
52
+ function _clone2() {
53
+ const data = require("./clone.cmd");
54
+ _clone2 = function () {
55
+ return data;
56
+ };
57
+ return data;
58
+ }
59
+ function _workspaceRootMain() {
60
+ const data = require("./workspace-root.main.runtime");
61
+ _workspaceRootMain = function () {
62
+ return data;
63
+ };
64
+ return data;
65
+ }
66
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
67
+ describe('resolveClonePath', () => {
68
+ const rootId = _componentId().ComponentID.fromString('my-org.my-scope/my-root');
69
+ it('should default the directory to the component name, as git names a working tree', () => {
70
+ (0, _chai().expect)((0, _clone().resolveClonePath)(undefined, rootId)).to.equal(_path().default.resolve('my-root'));
71
+ });
72
+ it('should take the directory given, relative to the cwd', () => {
73
+ (0, _chai().expect)((0, _clone().resolveClonePath)('some-dir', rootId)).to.equal(_path().default.resolve('some-dir'));
74
+ });
75
+ it('should keep an absolute directory as given', () => {
76
+ const absolute = _path().default.resolve(_os().default.tmpdir(), 'elsewhere');
77
+ (0, _chai().expect)((0, _clone().resolveClonePath)(absolute, rootId)).to.equal(absolute);
78
+ });
79
+ });
80
+ describe('resolveComponentDir', () => {
81
+ const workspacePath = _path().default.resolve(_os().default.tmpdir(), 'ws');
82
+ it('should resolve a root-dir inside the workspace', () => {
83
+ (0, _chai().expect)((0, _clone().resolveComponentDir)(workspacePath, {
84
+ id: 'a',
85
+ rootDir: 'comps/a'
86
+ })).to.equal(_path().default.join(workspacePath, 'comps', 'a'));
87
+ });
88
+ it('should refuse a root-dir that climbs out of the workspace, the list comes from a remote', () => {
89
+ const resolve = () => (0, _clone().resolveComponentDir)(workspacePath, {
90
+ id: 'a',
91
+ rootDir: '../a'
92
+ });
93
+ (0, _chai().expect)(resolve).to.throw('not a directory inside the workspace');
94
+ });
95
+ it('should refuse an absolute root-dir', () => {
96
+ const resolve = () => (0, _clone().resolveComponentDir)(workspacePath, {
97
+ id: 'a',
98
+ rootDir: _path().default.resolve(_os().default.tmpdir(), 'elsewhere')
99
+ });
100
+ (0, _chai().expect)(resolve).to.throw('not a directory inside the workspace');
101
+ });
102
+ it('should refuse an absolute root-dir that points inside the workspace too', () => {
103
+ // it resolves to a directory of this workspace, so every check but the absolute one lets it
104
+ // through - and it is still the path of the machine the root was snapped on
105
+ const resolve = () => (0, _clone().resolveComponentDir)(workspacePath, {
106
+ id: 'a',
107
+ rootDir: _path().default.join(workspacePath, 'comps', 'a')
108
+ });
109
+ (0, _chai().expect)(resolve).to.throw('not a directory inside the workspace');
110
+ });
111
+ it('should refuse the workspace root itself, only the root component owns it', () => {
112
+ const resolve = () => (0, _clone().resolveComponentDir)(workspacePath, {
113
+ id: 'a',
114
+ rootDir: '.'
115
+ });
116
+ (0, _chai().expect)(resolve).to.throw('not a directory inside the workspace');
117
+ });
118
+ it('should refuse a root-dir that is not a string, the map came from a remote', () => {
119
+ // the parser asserts the entry's shape, not its values, so this reaches here as it was written
120
+ const resolve = () => (0, _clone().resolveComponentDir)(workspacePath, {
121
+ id: 'a',
122
+ rootDir: 42
123
+ });
124
+ (0, _chai().expect)(resolve).to.throw('not a directory inside the workspace');
125
+ });
126
+ it('should refuse an entry without a root-dir rather than fail on it later', () => {
127
+ const resolve = () => (0, _clone().resolveComponentDir)(workspacePath, {
128
+ id: 'a'
129
+ });
130
+ (0, _chai().expect)(resolve).to.throw('not a directory inside the workspace');
131
+ });
132
+ it('should refuse a directory bit or git keeps for itself, the map came from a remote', () => {
133
+ // .bit holds the objects this very clone is being read from
134
+ ['.bit/evil', '.git/hooks', 'node_modules/evil', '.bitTmp/x'].forEach(rootDir => {
135
+ const resolve = () => (0, _clone().resolveComponentDir)(workspacePath, {
136
+ id: 'a',
137
+ rootDir
138
+ });
139
+ (0, _chai().expect)(resolve, rootDir).to.throw('not a directory inside the workspace');
140
+ });
141
+ });
142
+ it('should refuse one of them at any depth, not only at the workspace root', () => {
143
+ const resolve = () => (0, _clone().resolveComponentDir)(workspacePath, {
144
+ id: 'a',
145
+ rootDir: 'packages/node_modules/a'
146
+ });
147
+ (0, _chai().expect)(resolve).to.throw('not a directory inside the workspace');
148
+ });
149
+ it('should refuse one of them spelled in another case, a filesystem may read it as the same dir', () => {
150
+ ['.BIT/objects', '.Git/hooks', 'NODE_MODULES/evil', '.bittmp/x'].forEach(rootDir => {
151
+ const resolve = () => (0, _clone().resolveComponentDir)(workspacePath, {
152
+ id: 'a',
153
+ rootDir
154
+ });
155
+ (0, _chai().expect)(resolve, rootDir).to.throw('not a directory inside the workspace');
156
+ });
157
+ });
158
+ it('should accept a directory whose name starts with dots, it is not a way out', () => {
159
+ (0, _chai().expect)((0, _clone().resolveComponentDir)(workspacePath, {
160
+ id: 'a',
161
+ rootDir: '..cache'
162
+ })).to.equal(_path().default.join(workspacePath, '..cache'));
163
+ });
164
+ });
165
+ describe('resolveThroughExistingAncestors', () => {
166
+ let base;
167
+ beforeEach(async () => {
168
+ // realpath'd, so that the assertions below compare against what the resolve returns - on macOS
169
+ // the temp directory is itself reached through a link
170
+ base = await _fsExtra().default.realpath(await _fsExtra().default.mkdtemp(_path().default.join(_os().default.tmpdir(), 'bit-clone-anc-')));
171
+ });
172
+ afterEach(async () => {
173
+ await _fsExtra().default.remove(base);
174
+ });
175
+ it('should resolve a symbolic link above an absent destination, the writes go through it', async () => {
176
+ const real = _path().default.join(base, 'real');
177
+ await _fsExtra().default.ensureDir(real);
178
+ await _fsExtra().default.symlink(real, _path().default.join(base, 'link'));
179
+ (0, _chai().expect)(await (0, _clone().resolveThroughExistingAncestors)(_path().default.join(base, 'link', 'ws'))).to.equal(_path().default.join(real, 'ws'));
180
+ });
181
+ it('should resolve it through several levels that do not exist yet', async () => {
182
+ const real = _path().default.join(base, 'real');
183
+ await _fsExtra().default.ensureDir(real);
184
+ await _fsExtra().default.symlink(real, _path().default.join(base, 'link'));
185
+ (0, _chai().expect)(await (0, _clone().resolveThroughExistingAncestors)(_path().default.join(base, 'link', 'a', 'b'))).to.equal(_path().default.join(real, 'a', 'b'));
186
+ });
187
+ it('should leave a destination with no link above it as it is, the ordinary case', async () => {
188
+ (0, _chai().expect)(await (0, _clone().resolveThroughExistingAncestors)(_path().default.join(base, 'ws'))).to.equal(_path().default.join(base, 'ws'));
189
+ });
190
+ it('should not resolve a link at the destination itself, which is refused rather than followed', async () => {
191
+ // ensureEmptyDir is what refuses it, and it only can while the last segment is left alone
192
+ const real = _path().default.join(base, 'real');
193
+ await _fsExtra().default.ensureDir(real);
194
+ const link = _path().default.join(base, 'link');
195
+ await _fsExtra().default.symlink(real, link);
196
+ (0, _chai().expect)(await (0, _clone().resolveThroughExistingAncestors)(link)).to.equal(link);
197
+ });
198
+ });
199
+ describe('topmostAbsentDir', () => {
200
+ let base;
201
+ beforeEach(async () => {
202
+ base = await _fsExtra().default.realpath(await _fsExtra().default.mkdtemp(_path().default.join(_os().default.tmpdir(), 'bit-clone-top-')));
203
+ });
204
+ afterEach(async () => {
205
+ await _fsExtra().default.remove(base);
206
+ });
207
+ it('should be undefined for a destination that is already there, nothing was made for it', async () => {
208
+ (0, _chai().expect)(await (0, _clone().topmostAbsentDir)(base)).to.equal(undefined);
209
+ });
210
+ it('should be the destination itself when only it is missing', async () => {
211
+ (0, _chai().expect)(await (0, _clone().topmostAbsentDir)(_path().default.join(base, 'ws'))).to.equal(_path().default.join(base, 'ws'));
212
+ });
213
+ it('should be the highest level made on the way to it, so removing that one takes the rest', async () => {
214
+ // "clone into new-parent/ws": removing only "ws" would leave "new-parent" standing empty
215
+ (0, _chai().expect)(await (0, _clone().topmostAbsentDir)(_path().default.join(base, 'new-parent', 'ws'))).to.equal(_path().default.join(base, 'new-parent'));
216
+ });
217
+ it('should reach up through several missing levels', async () => {
218
+ (0, _chai().expect)(await (0, _clone().topmostAbsentDir)(_path().default.join(base, 'a', 'b', 'c'))).to.equal(_path().default.join(base, 'a'));
219
+ });
220
+ });
221
+ describe('ensureEmptyDir', () => {
222
+ const expectToReject = async (dir, message) => {
223
+ try {
224
+ await (0, _clone().ensureEmptyDir)(dir);
225
+ } catch (err) {
226
+ (0, _chai().expect)(err.message).to.have.string(message);
227
+ return;
228
+ }
229
+ throw new Error(`expected ensureEmptyDir("${dir}") to throw "${message}"`);
230
+ };
231
+ let tmpDir;
232
+ beforeEach(async () => {
233
+ tmpDir = await _fsExtra().default.mkdtemp(_path().default.join(_os().default.tmpdir(), 'bit-clone-'));
234
+ });
235
+ afterEach(async () => {
236
+ await _fsExtra().default.remove(tmpDir);
237
+ });
238
+ it('should create a directory that does not exist and say so, a failed clone removes it', async () => {
239
+ const dirPath = _path().default.join(tmpDir, 'new-ws');
240
+ (0, _chai().expect)(await (0, _clone().ensureEmptyDir)(dirPath)).to.be.true;
241
+ (0, _chai().expect)(await _fsExtra().default.pathExists(dirPath)).to.be.true;
242
+ });
243
+ it('should accept an existing empty directory without claiming it created it', async () => {
244
+ (0, _chai().expect)(await (0, _clone().ensureEmptyDir)(tmpDir)).to.be.false;
245
+ });
246
+ it('should refuse a directory that is not empty', async () => {
247
+ await _fsExtra().default.outputFile(_path().default.join(tmpDir, 'file.txt'), 'x');
248
+ await expectToReject(tmpDir, 'the directory is not empty');
249
+ });
250
+ it('should refuse a file', async () => {
251
+ const filePath = _path().default.join(tmpDir, 'file.txt');
252
+ await _fsExtra().default.outputFile(filePath, 'x');
253
+ await expectToReject(filePath, 'it is not a directory');
254
+ });
255
+ it('should refuse a symbolic link to an empty directory, the workspace would be written through it', async () => {
256
+ // and the cleanup of a failed clone would then empty whatever it points at
257
+ const target = _path().default.join(tmpDir, 'elsewhere');
258
+ const link = _path().default.join(tmpDir, 'link');
259
+ await _fsExtra().default.ensureDir(target);
260
+ await _fsExtra().default.symlink(target, link);
261
+ await expectToReject(link, 'it is a symbolic link');
262
+ });
263
+ });
264
+ describe('clone from a workspace', () => {
265
+ it('should refuse, a clone is a new workspace and this one is already loaded', async () => {
266
+ // the check comes before anything is fetched or written, so no workspace is needed to reach it
267
+ const workspaceRoot = new (_workspaceRootMain().WorkspaceRootMain)({
268
+ path: '/ws'
269
+ });
270
+ try {
271
+ await workspaceRoot.clone('my-scope/ws-root', undefined, {});
272
+ } catch (err) {
273
+ (0, _chai().expect)(err.message).to.have.string('unable to clone inside the workspace at "/ws"');
274
+ return;
275
+ }
276
+ throw new Error('expected clone to throw');
277
+ });
278
+ });
279
+ describe('formatCloneResult', () => {
280
+ const resultWith = missing => ({
281
+ rootId: _componentId().ComponentID.fromString('my-org.my-scope/my-root'),
282
+ workspacePath: '/tmp/my-root',
283
+ components: [_componentId().ComponentID.fromString('my-org.my-scope/comp1')],
284
+ missing
285
+ });
286
+ it('should name the components the root lists that their remote does not have', () => {
287
+ // the clone succeeded without them, so the summary still reports it - the missing ones are their
288
+ // own section, and a user who reads only the summary would not know the workspace is short
289
+ const output = (0, _clone2().formatCloneResult)(resultWith(['my-org.my-scope/comp2']), 'my-root');
290
+ (0, _chai().expect)(output).to.have.string('my-org.my-scope/comp2');
291
+ (0, _chai().expect)(output).to.have.string('not on their remote');
292
+ (0, _chai().expect)(output).to.have.string('cloned my-org.my-scope/my-root');
293
+ });
294
+ it('should leave the section out when the root got everything it lists', () => {
295
+ const output = (0, _clone2().formatCloneResult)(resultWith([]), 'my-root');
296
+ (0, _chai().expect)(output).to.not.have.string('not on their remote');
297
+ });
298
+ });
299
+ describe('throwForOverlappingDirs', () => {
300
+ const ws = _path().default.resolve(_os().default.tmpdir(), 'ws');
301
+ it('should accept members in directories of their own, the ordinary case', () => {
302
+ const dirs = {
303
+ a: _path().default.join(ws, 'comps/a'),
304
+ b: _path().default.join(ws, 'comps/b')
305
+ };
306
+ (0, _chai().expect)(() => (0, _clone().throwForOverlappingDirs)(dirs)).to.not.throw();
307
+ });
308
+ it('should refuse two members sharing a directory, the later one would land on the earlier', () => {
309
+ const dirs = {
310
+ a: _path().default.join(ws, 'comps/a'),
311
+ b: _path().default.join(ws, 'comps/a')
312
+ };
313
+ (0, _chai().expect)(() => (0, _clone().throwForOverlappingDirs)(dirs)).to.throw('overlaps the directory');
314
+ });
315
+ it('should refuse a member inside another member, whatever the depth', () => {
316
+ const dirs = {
317
+ a: _path().default.join(ws, 'comps/a'),
318
+ b: _path().default.join(ws, 'comps/a/src/b')
319
+ };
320
+ (0, _chai().expect)(() => (0, _clone().throwForOverlappingDirs)(dirs)).to.throw('overlaps the directory');
321
+ });
322
+ it('should not read a shared prefix as containment', () => {
323
+ const dirs = {
324
+ a: _path().default.join(ws, 'comps/a'),
325
+ b: _path().default.join(ws, 'comps/a-b')
326
+ };
327
+ (0, _chai().expect)(() => (0, _clone().throwForOverlappingDirs)(dirs)).to.not.throw();
328
+ });
329
+ it('should refuse two directories a case-insensitive filesystem reads as one', () => {
330
+ const dirs = {
331
+ a: _path().default.join(ws, 'Packages/Foo'),
332
+ b: _path().default.join(ws, 'packages/foo')
333
+ };
334
+ (0, _chai().expect)(() => (0, _clone().throwForOverlappingDirs)(dirs)).to.throw('overlaps the directory');
335
+ });
336
+ it('should refuse containment that differs only by case at a level above', () => {
337
+ const dirs = {
338
+ a: _path().default.join(ws, 'Comps/A'),
339
+ b: _path().default.join(ws, 'comps/a/src/b')
340
+ };
341
+ (0, _chai().expect)(() => (0, _clone().throwForOverlappingDirs)(dirs)).to.throw('overlaps the directory');
342
+ });
343
+ });
344
+ describe('resolveWriteToPathPerId', () => {
345
+ const ws = _path().default.resolve(_os().default.tmpdir(), 'ws');
346
+ const rootId = _componentId().ComponentID.fromString('my-org.my-scope/my-root');
347
+ it('should place every member the root lists at the directory it recorded', () => {
348
+ const entries = [{
349
+ id: 'scope/a',
350
+ rootDir: 'comps/a'
351
+ }, {
352
+ id: 'scope/b',
353
+ rootDir: 'comps/b'
354
+ }];
355
+ (0, _chai().expect)((0, _clone().resolveWriteToPathPerId)(ws, entries, rootId)).to.deep.equal({
356
+ 'scope/a': _path().default.join(ws, 'comps/a'),
357
+ 'scope/b': _path().default.join(ws, 'comps/b')
358
+ });
359
+ });
360
+ it('should leave out the root itself, it is written before the members', () => {
361
+ const entries = [{
362
+ id: 'my-org.my-scope/my-root',
363
+ rootDir: _legacy().WORKSPACE_ROOT_DIR
364
+ }, {
365
+ id: 'scope/a',
366
+ rootDir: 'comps/a'
367
+ }];
368
+ (0, _chai().expect)(Object.keys((0, _clone().resolveWriteToPathPerId)(ws, entries, rootId))).to.deep.equal(['scope/a']);
369
+ });
370
+ it('should leave out a root listed by another scope, an unexported root names its default one', () => {
371
+ const entries = [{
372
+ id: 'some-other-scope/my-root',
373
+ rootDir: _legacy().WORKSPACE_ROOT_DIR
374
+ }];
375
+ (0, _chai().expect)((0, _clone().resolveWriteToPathPerId)(ws, entries, rootId)).to.deep.equal({});
376
+ });
377
+ it('should refuse a member the map puts at the workspace root, only the root occupies it', () => {
378
+ const entries = [{
379
+ id: 'my-org.my-scope/my-root',
380
+ rootDir: _legacy().WORKSPACE_ROOT_DIR
381
+ }, {
382
+ id: 'scope/a',
383
+ rootDir: _legacy().WORKSPACE_ROOT_DIR
384
+ }];
385
+ (0, _chai().expect)(() => (0, _clone().resolveWriteToPathPerId)(ws, entries, rootId)).to.throw('at the workspace root');
386
+ });
387
+ it('should refuse a second entry at the workspace root even when it names the root again', () => {
388
+ const entries = [{
389
+ id: 'my-org.my-scope/my-root',
390
+ rootDir: _legacy().WORKSPACE_ROOT_DIR
391
+ }, {
392
+ id: 'my-org.my-scope/my-root',
393
+ rootDir: _legacy().WORKSPACE_ROOT_DIR
394
+ }];
395
+ (0, _chai().expect)(() => (0, _clone().resolveWriteToPathPerId)(ws, entries, rootId)).to.throw('at the workspace root');
396
+ });
397
+ it('should keep an id reading __proto__ rather than let it set the prototype and vanish', () => {
398
+ // a remote map names it, so the id is not bit's to trust. assigned onto an object literal it
399
+ // would leave no own property and the member would be dropped from the import, unreported
400
+ const result = (0, _clone().resolveWriteToPathPerId)(ws, [{
401
+ id: '__proto__',
402
+ rootDir: 'comps/a'
403
+ }], rootId);
404
+ (0, _chai().expect)(Object.keys(result)).to.deep.equal(['__proto__']);
405
+ (0, _chai().expect)(Object.getPrototypeOf(result)).to.equal(Object.prototype);
406
+ });
407
+ it('should refuse two entries resolving to one id, the later would overwrite the earlier', () => {
408
+ const entries = [{
409
+ id: 'scope/a',
410
+ rootDir: 'comps/a'
411
+ }, {
412
+ id: 'scope/a',
413
+ rootDir: 'comps/a-again'
414
+ }];
415
+ (0, _chai().expect)(() => (0, _clone().resolveWriteToPathPerId)(ws, entries, rootId)).to.throw('more than once');
416
+ });
417
+ });
418
+
419
+ //# sourceMappingURL=clone.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_chai","data","require","_fsExtra","_interopRequireDefault","_os","_path","_componentId","_legacy","_clone","_clone2","_workspaceRootMain","e","__esModule","default","describe","rootId","ComponentID","fromString","it","expect","resolveClonePath","undefined","to","equal","path","resolve","absolute","os","tmpdir","workspacePath","resolveComponentDir","id","rootDir","join","throw","forEach","base","beforeEach","fs","realpath","mkdtemp","afterEach","remove","real","ensureDir","symlink","resolveThroughExistingAncestors","link","topmostAbsentDir","expectToReject","dir","message","ensureEmptyDir","err","have","string","Error","tmpDir","dirPath","be","true","pathExists","false","outputFile","filePath","target","workspaceRoot","WorkspaceRootMain","clone","resultWith","missing","components","output","formatCloneResult","not","ws","dirs","a","b","throwForOverlappingDirs","entries","resolveWriteToPathPerId","deep","WORKSPACE_ROOT_DIR","Object","keys","result","getPrototypeOf","prototype"],"sources":["clone.spec.ts"],"sourcesContent":["import { expect } from 'chai';\nimport fs from 'fs-extra';\nimport os from 'os';\nimport path from 'path';\nimport { ComponentID } from '@teambit/component-id';\nimport { WORKSPACE_ROOT_DIR } from '@teambit/legacy.bit-map';\nimport {\n ensureEmptyDir,\n resolveClonePath,\n resolveComponentDir,\n resolveThroughExistingAncestors,\n resolveWriteToPathPerId,\n throwForOverlappingDirs,\n topmostAbsentDir,\n} from './clone';\nimport type { CloneResult } from './clone';\nimport { formatCloneResult } from './clone.cmd';\nimport { WorkspaceRootMain } from './workspace-root.main.runtime';\n\ndescribe('resolveClonePath', () => {\n const rootId = ComponentID.fromString('my-org.my-scope/my-root');\n it('should default the directory to the component name, as git names a working tree', () => {\n expect(resolveClonePath(undefined, rootId)).to.equal(path.resolve('my-root'));\n });\n it('should take the directory given, relative to the cwd', () => {\n expect(resolveClonePath('some-dir', rootId)).to.equal(path.resolve('some-dir'));\n });\n it('should keep an absolute directory as given', () => {\n const absolute = path.resolve(os.tmpdir(), 'elsewhere');\n expect(resolveClonePath(absolute, rootId)).to.equal(absolute);\n });\n});\n\ndescribe('resolveComponentDir', () => {\n const workspacePath = path.resolve(os.tmpdir(), 'ws');\n it('should resolve a root-dir inside the workspace', () => {\n expect(resolveComponentDir(workspacePath, { id: 'a', rootDir: 'comps/a' })).to.equal(\n path.join(workspacePath, 'comps', 'a')\n );\n });\n it('should refuse a root-dir that climbs out of the workspace, the list comes from a remote', () => {\n const resolve = () => resolveComponentDir(workspacePath, { id: 'a', rootDir: '../a' });\n expect(resolve).to.throw('not a directory inside the workspace');\n });\n it('should refuse an absolute root-dir', () => {\n const resolve = () =>\n resolveComponentDir(workspacePath, { id: 'a', rootDir: path.resolve(os.tmpdir(), 'elsewhere') });\n expect(resolve).to.throw('not a directory inside the workspace');\n });\n it('should refuse an absolute root-dir that points inside the workspace too', () => {\n // it resolves to a directory of this workspace, so every check but the absolute one lets it\n // through - and it is still the path of the machine the root was snapped on\n const resolve = () =>\n resolveComponentDir(workspacePath, { id: 'a', rootDir: path.join(workspacePath, 'comps', 'a') });\n expect(resolve).to.throw('not a directory inside the workspace');\n });\n it('should refuse the workspace root itself, only the root component owns it', () => {\n const resolve = () => resolveComponentDir(workspacePath, { id: 'a', rootDir: '.' });\n expect(resolve).to.throw('not a directory inside the workspace');\n });\n it('should refuse a root-dir that is not a string, the map came from a remote', () => {\n // the parser asserts the entry's shape, not its values, so this reaches here as it was written\n const resolve = () => resolveComponentDir(workspacePath, { id: 'a', rootDir: 42 as unknown as string });\n expect(resolve).to.throw('not a directory inside the workspace');\n });\n it('should refuse an entry without a root-dir rather than fail on it later', () => {\n const resolve = () => resolveComponentDir(workspacePath, { id: 'a' });\n expect(resolve).to.throw('not a directory inside the workspace');\n });\n it('should refuse a directory bit or git keeps for itself, the map came from a remote', () => {\n // .bit holds the objects this very clone is being read from\n ['.bit/evil', '.git/hooks', 'node_modules/evil', '.bitTmp/x'].forEach((rootDir) => {\n const resolve = () => resolveComponentDir(workspacePath, { id: 'a', rootDir });\n expect(resolve, rootDir).to.throw('not a directory inside the workspace');\n });\n });\n it('should refuse one of them at any depth, not only at the workspace root', () => {\n const resolve = () => resolveComponentDir(workspacePath, { id: 'a', rootDir: 'packages/node_modules/a' });\n expect(resolve).to.throw('not a directory inside the workspace');\n });\n it('should refuse one of them spelled in another case, a filesystem may read it as the same dir', () => {\n ['.BIT/objects', '.Git/hooks', 'NODE_MODULES/evil', '.bittmp/x'].forEach((rootDir) => {\n const resolve = () => resolveComponentDir(workspacePath, { id: 'a', rootDir });\n expect(resolve, rootDir).to.throw('not a directory inside the workspace');\n });\n });\n it('should accept a directory whose name starts with dots, it is not a way out', () => {\n expect(resolveComponentDir(workspacePath, { id: 'a', rootDir: '..cache' })).to.equal(\n path.join(workspacePath, '..cache')\n );\n });\n});\n\ndescribe('resolveThroughExistingAncestors', () => {\n let base: string;\n beforeEach(async () => {\n // realpath'd, so that the assertions below compare against what the resolve returns - on macOS\n // the temp directory is itself reached through a link\n base = await fs.realpath(await fs.mkdtemp(path.join(os.tmpdir(), 'bit-clone-anc-')));\n });\n afterEach(async () => {\n await fs.remove(base);\n });\n\n it('should resolve a symbolic link above an absent destination, the writes go through it', async () => {\n const real = path.join(base, 'real');\n await fs.ensureDir(real);\n await fs.symlink(real, path.join(base, 'link'));\n expect(await resolveThroughExistingAncestors(path.join(base, 'link', 'ws'))).to.equal(path.join(real, 'ws'));\n });\n\n it('should resolve it through several levels that do not exist yet', async () => {\n const real = path.join(base, 'real');\n await fs.ensureDir(real);\n await fs.symlink(real, path.join(base, 'link'));\n expect(await resolveThroughExistingAncestors(path.join(base, 'link', 'a', 'b'))).to.equal(\n path.join(real, 'a', 'b')\n );\n });\n\n it('should leave a destination with no link above it as it is, the ordinary case', async () => {\n expect(await resolveThroughExistingAncestors(path.join(base, 'ws'))).to.equal(path.join(base, 'ws'));\n });\n\n it('should not resolve a link at the destination itself, which is refused rather than followed', async () => {\n // ensureEmptyDir is what refuses it, and it only can while the last segment is left alone\n const real = path.join(base, 'real');\n await fs.ensureDir(real);\n const link = path.join(base, 'link');\n await fs.symlink(real, link);\n expect(await resolveThroughExistingAncestors(link)).to.equal(link);\n });\n});\n\ndescribe('topmostAbsentDir', () => {\n let base: string;\n beforeEach(async () => {\n base = await fs.realpath(await fs.mkdtemp(path.join(os.tmpdir(), 'bit-clone-top-')));\n });\n afterEach(async () => {\n await fs.remove(base);\n });\n\n it('should be undefined for a destination that is already there, nothing was made for it', async () => {\n expect(await topmostAbsentDir(base)).to.equal(undefined);\n });\n\n it('should be the destination itself when only it is missing', async () => {\n expect(await topmostAbsentDir(path.join(base, 'ws'))).to.equal(path.join(base, 'ws'));\n });\n\n it('should be the highest level made on the way to it, so removing that one takes the rest', async () => {\n // \"clone into new-parent/ws\": removing only \"ws\" would leave \"new-parent\" standing empty\n expect(await topmostAbsentDir(path.join(base, 'new-parent', 'ws'))).to.equal(path.join(base, 'new-parent'));\n });\n\n it('should reach up through several missing levels', async () => {\n expect(await topmostAbsentDir(path.join(base, 'a', 'b', 'c'))).to.equal(path.join(base, 'a'));\n });\n});\n\ndescribe('ensureEmptyDir', () => {\n const expectToReject = async (dir: string, message: string) => {\n try {\n await ensureEmptyDir(dir);\n } catch (err: any) {\n expect(err.message).to.have.string(message);\n return;\n }\n throw new Error(`expected ensureEmptyDir(\"${dir}\") to throw \"${message}\"`);\n };\n let tmpDir: string;\n beforeEach(async () => {\n tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), 'bit-clone-'));\n });\n afterEach(async () => {\n await fs.remove(tmpDir);\n });\n it('should create a directory that does not exist and say so, a failed clone removes it', async () => {\n const dirPath = path.join(tmpDir, 'new-ws');\n expect(await ensureEmptyDir(dirPath)).to.be.true;\n expect(await fs.pathExists(dirPath)).to.be.true;\n });\n it('should accept an existing empty directory without claiming it created it', async () => {\n expect(await ensureEmptyDir(tmpDir)).to.be.false;\n });\n it('should refuse a directory that is not empty', async () => {\n await fs.outputFile(path.join(tmpDir, 'file.txt'), 'x');\n await expectToReject(tmpDir, 'the directory is not empty');\n });\n it('should refuse a file', async () => {\n const filePath = path.join(tmpDir, 'file.txt');\n await fs.outputFile(filePath, 'x');\n await expectToReject(filePath, 'it is not a directory');\n });\n it('should refuse a symbolic link to an empty directory, the workspace would be written through it', async () => {\n // and the cleanup of a failed clone would then empty whatever it points at\n const target = path.join(tmpDir, 'elsewhere');\n const link = path.join(tmpDir, 'link');\n await fs.ensureDir(target);\n await fs.symlink(target, link);\n await expectToReject(link, 'it is a symbolic link');\n });\n});\n\ndescribe('clone from a workspace', () => {\n it('should refuse, a clone is a new workspace and this one is already loaded', async () => {\n // the check comes before anything is fetched or written, so no workspace is needed to reach it\n const workspaceRoot = new WorkspaceRootMain({ path: '/ws' } as any);\n try {\n await workspaceRoot.clone('my-scope/ws-root', undefined, {});\n } catch (err: any) {\n expect(err.message).to.have.string('unable to clone inside the workspace at \"/ws\"');\n return;\n }\n throw new Error('expected clone to throw');\n });\n});\n\ndescribe('formatCloneResult', () => {\n const resultWith = (missing: string[]): CloneResult => ({\n rootId: ComponentID.fromString('my-org.my-scope/my-root'),\n workspacePath: '/tmp/my-root',\n components: [ComponentID.fromString('my-org.my-scope/comp1')],\n missing,\n });\n\n it('should name the components the root lists that their remote does not have', () => {\n // the clone succeeded without them, so the summary still reports it - the missing ones are their\n // own section, and a user who reads only the summary would not know the workspace is short\n const output = formatCloneResult(resultWith(['my-org.my-scope/comp2']), 'my-root');\n expect(output).to.have.string('my-org.my-scope/comp2');\n expect(output).to.have.string('not on their remote');\n expect(output).to.have.string('cloned my-org.my-scope/my-root');\n });\n\n it('should leave the section out when the root got everything it lists', () => {\n const output = formatCloneResult(resultWith([]), 'my-root');\n expect(output).to.not.have.string('not on their remote');\n });\n});\n\ndescribe('throwForOverlappingDirs', () => {\n const ws = path.resolve(os.tmpdir(), 'ws');\n it('should accept members in directories of their own, the ordinary case', () => {\n const dirs = { a: path.join(ws, 'comps/a'), b: path.join(ws, 'comps/b') };\n expect(() => throwForOverlappingDirs(dirs)).to.not.throw();\n });\n it('should refuse two members sharing a directory, the later one would land on the earlier', () => {\n const dirs = { a: path.join(ws, 'comps/a'), b: path.join(ws, 'comps/a') };\n expect(() => throwForOverlappingDirs(dirs)).to.throw('overlaps the directory');\n });\n it('should refuse a member inside another member, whatever the depth', () => {\n const dirs = { a: path.join(ws, 'comps/a'), b: path.join(ws, 'comps/a/src/b') };\n expect(() => throwForOverlappingDirs(dirs)).to.throw('overlaps the directory');\n });\n it('should not read a shared prefix as containment', () => {\n const dirs = { a: path.join(ws, 'comps/a'), b: path.join(ws, 'comps/a-b') };\n expect(() => throwForOverlappingDirs(dirs)).to.not.throw();\n });\n it('should refuse two directories a case-insensitive filesystem reads as one', () => {\n const dirs = { a: path.join(ws, 'Packages/Foo'), b: path.join(ws, 'packages/foo') };\n expect(() => throwForOverlappingDirs(dirs)).to.throw('overlaps the directory');\n });\n it('should refuse containment that differs only by case at a level above', () => {\n const dirs = { a: path.join(ws, 'Comps/A'), b: path.join(ws, 'comps/a/src/b') };\n expect(() => throwForOverlappingDirs(dirs)).to.throw('overlaps the directory');\n });\n});\n\ndescribe('resolveWriteToPathPerId', () => {\n const ws = path.resolve(os.tmpdir(), 'ws');\n const rootId = ComponentID.fromString('my-org.my-scope/my-root');\n it('should place every member the root lists at the directory it recorded', () => {\n const entries = [\n { id: 'scope/a', rootDir: 'comps/a' },\n { id: 'scope/b', rootDir: 'comps/b' },\n ];\n expect(resolveWriteToPathPerId(ws, entries, rootId)).to.deep.equal({\n 'scope/a': path.join(ws, 'comps/a'),\n 'scope/b': path.join(ws, 'comps/b'),\n });\n });\n it('should leave out the root itself, it is written before the members', () => {\n const entries = [\n { id: 'my-org.my-scope/my-root', rootDir: WORKSPACE_ROOT_DIR },\n { id: 'scope/a', rootDir: 'comps/a' },\n ];\n expect(Object.keys(resolveWriteToPathPerId(ws, entries, rootId))).to.deep.equal(['scope/a']);\n });\n it('should leave out a root listed by another scope, an unexported root names its default one', () => {\n const entries = [{ id: 'some-other-scope/my-root', rootDir: WORKSPACE_ROOT_DIR }];\n expect(resolveWriteToPathPerId(ws, entries, rootId)).to.deep.equal({});\n });\n it('should refuse a member the map puts at the workspace root, only the root occupies it', () => {\n const entries = [\n { id: 'my-org.my-scope/my-root', rootDir: WORKSPACE_ROOT_DIR },\n { id: 'scope/a', rootDir: WORKSPACE_ROOT_DIR },\n ];\n expect(() => resolveWriteToPathPerId(ws, entries, rootId)).to.throw('at the workspace root');\n });\n it('should refuse a second entry at the workspace root even when it names the root again', () => {\n const entries = [\n { id: 'my-org.my-scope/my-root', rootDir: WORKSPACE_ROOT_DIR },\n { id: 'my-org.my-scope/my-root', rootDir: WORKSPACE_ROOT_DIR },\n ];\n expect(() => resolveWriteToPathPerId(ws, entries, rootId)).to.throw('at the workspace root');\n });\n it('should keep an id reading __proto__ rather than let it set the prototype and vanish', () => {\n // a remote map names it, so the id is not bit's to trust. assigned onto an object literal it\n // would leave no own property and the member would be dropped from the import, unreported\n const result = resolveWriteToPathPerId(ws, [{ id: '__proto__', rootDir: 'comps/a' }], rootId);\n expect(Object.keys(result)).to.deep.equal(['__proto__']);\n expect(Object.getPrototypeOf(result)).to.equal(Object.prototype);\n });\n it('should refuse two entries resolving to one id, the later would overwrite the earlier', () => {\n const entries = [\n { id: 'scope/a', rootDir: 'comps/a' },\n { id: 'scope/a', rootDir: 'comps/a-again' },\n ];\n expect(() => resolveWriteToPathPerId(ws, entries, rootId)).to.throw('more than once');\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,SAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,IAAA;EAAA,MAAAJ,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAG,GAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,MAAA;EAAA,MAAAL,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAI,KAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,aAAA;EAAA,MAAAN,IAAA,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C;EAClE,CAAC,CAAC;EACFtE,EAAE,CAAC,sFAAsF,EAAE,MAAM;IAC/F,MAAM8D,OAAO,GAAG,CACd;MAAEjD,EAAE,EAAE,SAAS;MAAEC,OAAO,EAAE;IAAU,CAAC,EACrC;MAAED,EAAE,EAAE,SAAS;MAAEC,OAAO,EAAE;IAAgB,CAAC,CAC5C;IACD,IAAAb,cAAM,EAAC,MAAM,IAAA8D,gCAAuB,EAACN,EAAE,EAAEK,OAAO,EAAEjE,MAAM,CAAC,CAAC,CAACO,EAAE,CAACY,KAAK,CAAC,gBAAgB,CAAC;EACvF,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ export { WorkspaceRootAspect, default } from './workspace-root.aspect';
2
+ export type { WorkspaceRootMain } from './workspace-root.main.runtime';
3
+ export type { WorkspaceRootData } from './workspace-root-data';
4
+ export type { CloneOptions, CloneResult } from './clone';
5
+ export { findWorkspaceRootMap, isWorkspaceRootComponent, readWorkspaceRoot, writeWorkspaceRoot, } from './workspace-root-data';
package/dist/index.js ADDED
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "WorkspaceRootAspect", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _workspaceRoot().WorkspaceRootAspect;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "default", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _workspaceRoot().default;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "findWorkspaceRootMap", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _workspaceRootData().findWorkspaceRootMap;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "isWorkspaceRootComponent", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _workspaceRootData().isWorkspaceRootComponent;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "readWorkspaceRoot", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _workspaceRootData().readWorkspaceRoot;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "writeWorkspaceRoot", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _workspaceRootData().writeWorkspaceRoot;
40
+ }
41
+ });
42
+ function _workspaceRoot() {
43
+ const data = _interopRequireWildcard(require("./workspace-root.aspect"));
44
+ _workspaceRoot = function () {
45
+ return data;
46
+ };
47
+ return data;
48
+ }
49
+ function _workspaceRootData() {
50
+ const data = require("./workspace-root-data");
51
+ _workspaceRootData = function () {
52
+ return data;
53
+ };
54
+ return data;
55
+ }
56
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
57
+
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_workspaceRoot","data","_interopRequireWildcard","require","_workspaceRootData","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor"],"sources":["index.ts"],"sourcesContent":["export { WorkspaceRootAspect, default } from './workspace-root.aspect';\nexport type { WorkspaceRootMain } from './workspace-root.main.runtime';\nexport type { WorkspaceRootData } from './workspace-root-data';\nexport type { CloneOptions, CloneResult } from './clone';\nexport {\n findWorkspaceRootMap,\n isWorkspaceRootComponent,\n readWorkspaceRoot,\n writeWorkspaceRoot,\n} from './workspace-root-data';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAAA,eA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1,7 @@
1
+ ;
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace-root@0.0.1/dist/workspace-root.docs.mdx';
3
+
4
+ export const compositions = [];
5
+ export const overview = [overview_0];
6
+
7
+ export const compositions_metadata = {"compositions":[]};
@@ -0,0 +1,42 @@
1
+ import { ComponentID } from '@teambit/component-id';
2
+ import type { BitMap, ComponentMap } from '@teambit/legacy.bit-map';
3
+ import type { ExtensionDataList } from '@teambit/legacy.extension-data';
4
+ /**
5
+ * the aspect data of a workspace-root component and of its members. it is data, not config, on
6
+ * purpose: a Version's hash covers the extensions' config only, so neither entry ever makes a
7
+ * component modified, and the root moving on does not touch its members.
8
+ */
9
+ export type WorkspaceRootData = {
10
+ /**
11
+ * on the workspace-root component itself. set when it is loaded in a workspace and saved with
12
+ * every version, so the root is told from the model alone - by an import onto ".", a CI, a clone -
13
+ * and not by the files it happens to carry.
14
+ */
15
+ isRoot?: boolean;
16
+ /**
17
+ * on a member: the root of the workspace it was snapped in, at the version the root had at that
18
+ * moment, e.g. "my-org.my-scope/my-root@0.0.7". tag and snap bring a new or modified root into
19
+ * their batch, so a member they made always has the version.
20
+ */
21
+ root?: string;
22
+ };
23
+ /**
24
+ * the entry of the component that owns the workspace root (rootDir "."), if the workspace has one.
25
+ *
26
+ * a root created on another lane, or removed, stays in `.bitmap` so a switch back can restore it.
27
+ * it is not this workspace's root though, and tagging or snapping would otherwise bring it along.
28
+ */
29
+ export declare function findWorkspaceRootMap(bitMap: BitMap): ComponentMap | undefined;
30
+ /**
31
+ * whether the component is a workspace-root component, by the marker its versions carry.
32
+ */
33
+ export declare function isWorkspaceRootComponent(extensions: ExtensionDataList): boolean;
34
+ export declare function readWorkspaceRoot(extensions: ExtensionDataList): ComponentID | undefined;
35
+ /**
36
+ * nothing clears this data: it is not inherited from the version before it. the loader supplies the
37
+ * aspect's data on every load, so a component arrives with the root of the workspace it is in now, or
38
+ * with none - what an earlier workspace recorded never reaches the next version. the data is replaced
39
+ * wholesale rather than merged, so a component that changes role (a member tracked at "." later, or a
40
+ * root moved into a directory of its own) does not keep the marker of the role it left.
41
+ */
42
+ export declare function writeWorkspaceRoot(extensions: ExtensionDataList, rootId: ComponentID): void;