@teambit/workspace 0.0.829 → 0.0.832

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.
@@ -1,12 +1,90 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
+ exports[`makeOutdatedPkgChoices should group component model updates of the same dependency 1`] = `
4
+ Array [
5
+ Object {
6
+ "choices": Array [
7
+ Object {
8
+ "message": "foo (runtime) * ❯ 2.0.0 because of comp1 and 1 other components ",
9
+ "name": "foo",
10
+ "value": Object {
11
+ "currentRange": "1.0.0",
12
+ "dependentComponents": Array [
13
+ "comp1",
14
+ "comp2",
15
+ ],
16
+ "hasDifferentRanges": true,
17
+ "latestRange": "2.0.0",
18
+ "name": "foo",
19
+ "source": "rootPolicy",
20
+ "targetField": "dependencies",
21
+ },
22
+ },
23
+ ],
24
+ "message": "Root policies",
25
+ },
26
+ ]
27
+ `;
28
+
29
+ exports[`makeOutdatedPkgChoices should group component model updates of the same dependency and display the current range when all components use the same range 1`] = `
30
+ Array [
31
+ Object {
32
+ "choices": Array [
33
+ Object {
34
+ "message": "foo (runtime) ^1.2.3 ❯ 2.0.0 because of comp1 and 1 other components ",
35
+ "name": "foo",
36
+ "value": Object {
37
+ "currentRange": "^1.2.3",
38
+ "dependentComponents": Array [
39
+ "comp1",
40
+ "comp2",
41
+ ],
42
+ "latestRange": "2.0.0",
43
+ "name": "foo",
44
+ "source": "rootPolicy",
45
+ "targetField": "dependencies",
46
+ },
47
+ },
48
+ ],
49
+ "message": "Root policies",
50
+ },
51
+ ]
52
+ `;
53
+
54
+ exports[`makeOutdatedPkgChoices should group component model updates of the same dependency and use * as current range when can't compare ranges 1`] = `
55
+ Array [
56
+ Object {
57
+ "choices": Array [
58
+ Object {
59
+ "message": "foo (runtime) * ❯ 2.0.0 because of comp1 and 1 other components ",
60
+ "name": "foo",
61
+ "value": Object {
62
+ "currentRange": "*",
63
+ "dependentComponents": Array [
64
+ "comp1",
65
+ "comp2",
66
+ ],
67
+ "hasDifferentRanges": true,
68
+ "latestRange": "2.0.0",
69
+ "name": "foo",
70
+ "source": "rootPolicy",
71
+ "targetField": "dependencies",
72
+ },
73
+ },
74
+ ],
75
+ "message": "Root policies",
76
+ },
77
+ ]
78
+ `;
79
+
3
80
  exports[`makeOutdatedPkgChoices should render choices in correct order 1`] = `
4
81
  Array [
5
82
  Object {
6
83
  "choices": Array [
7
84
  Object {
8
- "message": "foo (runtime) 1.0.0 ❯ 2.0.0 ",
9
- "name": Object {
85
+ "message": "foo (runtime) 1.0.0 ❯ 2.0.0 ",
86
+ "name": "foo",
87
+ "value": Object {
10
88
  "currentRange": "1.0.0",
11
89
  "latestRange": "2.0.0",
12
90
  "name": "foo",
@@ -15,8 +93,9 @@ Array [
15
93
  },
16
94
  },
17
95
  Object {
18
- "message": "qar (runtime) 1.0.0 ❯ 1.1.0 ",
19
- "name": Object {
96
+ "message": "qar (runtime) 1.0.0 ❯ 1.1.0 ",
97
+ "name": "qar",
98
+ "value": Object {
20
99
  "currentRange": "1.0.0",
21
100
  "latestRange": "1.1.0",
22
101
  "name": "qar",
@@ -25,8 +104,9 @@ Array [
25
104
  },
26
105
  },
27
106
  Object {
28
- "message": "zoo (dev) 1.0.0 ❯ 1.1.0 ",
29
- "name": Object {
107
+ "message": "zoo (dev) 1.0.0 ❯ 1.1.0 ",
108
+ "name": "zoo",
109
+ "value": Object {
30
110
  "currentRange": "1.0.0",
31
111
  "latestRange": "1.1.0",
32
112
  "name": "zoo",
@@ -35,8 +115,9 @@ Array [
35
115
  },
36
116
  },
37
117
  Object {
38
- "message": "bar (peer) 1.0.0 ❯ 1.1.0 ",
39
- "name": Object {
118
+ "message": "bar (peer) 1.0.0 ❯ 1.1.0 ",
119
+ "name": "bar",
120
+ "value": Object {
40
121
  "currentRange": "1.0.0",
41
122
  "latestRange": "1.1.0",
42
123
  "name": "bar",
@@ -55,8 +136,9 @@ Array [
55
136
  Object {
56
137
  "choices": Array [
57
138
  Object {
58
- "message": "foo (runtime) 1.0.0 ❯ 2.0.0 ",
59
- "name": Object {
139
+ "message": "foo (runtime) 1.0.0 ❯ 2.0.0 ",
140
+ "name": "foo",
141
+ "value": Object {
60
142
  "componentId": "comp1",
61
143
  "currentRange": "1.0.0",
62
144
  "latestRange": "2.0.0",
@@ -71,8 +153,9 @@ Array [
71
153
  Object {
72
154
  "choices": Array [
73
155
  Object {
74
- "message": "bar (peer) 1.0.0 ❯ 1.1.0 ",
75
- "name": Object {
156
+ "message": "bar (peer) 1.0.0 ❯ 1.1.0 ",
157
+ "name": "bar",
158
+ "value": Object {
76
159
  "currentRange": "1.0.0",
77
160
  "latestRange": "1.1.0",
78
161
  "name": "bar",
@@ -1,11 +1,88 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
+ exports[`makeOutdatedPkgChoices should group component model updates of the same dependency 1`] = `
4
+ Array [
5
+ Object {
6
+ "choices": Array [
7
+ Object {
8
+ "message": "foo (runtime) * ❯ 2.0.0 because of comp1 and 1 other components ",
9
+ "name": "foo",
10
+ "value": Object {
11
+ "currentRange": "1.0.0",
12
+ "dependentComponents": Array [
13
+ "comp1",
14
+ "comp2",
15
+ ],
16
+ "hasDifferentRanges": true,
17
+ "latestRange": "2.0.0",
18
+ "name": "foo",
19
+ "source": "rootPolicy",
20
+ "targetField": "dependencies",
21
+ },
22
+ },
23
+ ],
24
+ "message": "Root policies",
25
+ },
26
+ ]
27
+ `;
28
+
29
+ exports[`makeOutdatedPkgChoices should group component model updates of the same dependency and display the current range when all components use the same range 1`] = `
30
+ Array [
31
+ Object {
32
+ "choices": Array [
33
+ Object {
34
+ "message": "foo (runtime) ^1.2.3 ❯ 2.0.0 because of comp1 and 1 other components ",
35
+ "name": "foo",
36
+ "value": Object {
37
+ "currentRange": "^1.2.3",
38
+ "dependentComponents": Array [
39
+ "comp1",
40
+ "comp2",
41
+ ],
42
+ "latestRange": "2.0.0",
43
+ "name": "foo",
44
+ "source": "rootPolicy",
45
+ "targetField": "dependencies",
46
+ },
47
+ },
48
+ ],
49
+ "message": "Root policies",
50
+ },
51
+ ]
52
+ `;
53
+
54
+ exports[`makeOutdatedPkgChoices should group component model updates of the same dependency and use * as current range when can't compare ranges 1`] = `
55
+ Array [
56
+ Object {
57
+ "choices": Array [
58
+ Object {
59
+ "message": "foo (runtime) * ❯ 2.0.0 because of comp1 and 1 other components ",
60
+ "name": "foo",
61
+ "value": Object {
62
+ "currentRange": "*",
63
+ "dependentComponents": Array [
64
+ "comp1",
65
+ "comp2",
66
+ ],
67
+ "hasDifferentRanges": true,
68
+ "latestRange": "2.0.0",
69
+ "name": "foo",
70
+ "source": "rootPolicy",
71
+ "targetField": "dependencies",
72
+ },
73
+ },
74
+ ],
75
+ "message": "Root policies",
76
+ },
77
+ ]
78
+ `;
79
+
3
80
  exports[`makeOutdatedPkgChoices should render choices in correct order 1`] = `
4
81
  Array [
5
82
  Object {
6
83
  "choices": Array [
7
84
  Object {
8
- "message": "foo (runtime) 1.0.0 ❯ 2.0.0 ",
85
+ "message": "foo (runtime) 1.0.0 ❯ 2.0.0 ",
9
86
  "name": "foo",
10
87
  "value": Object {
11
88
  "currentRange": "1.0.0",
@@ -16,7 +93,7 @@ Array [
16
93
  },
17
94
  },
18
95
  Object {
19
- "message": "qar (runtime) 1.0.0 ❯ 1.1.0 ",
96
+ "message": "qar (runtime) 1.0.0 ❯ 1.1.0 ",
20
97
  "name": "qar",
21
98
  "value": Object {
22
99
  "currentRange": "1.0.0",
@@ -27,7 +104,7 @@ Array [
27
104
  },
28
105
  },
29
106
  Object {
30
- "message": "zoo (dev) 1.0.0 ❯ 1.1.0 ",
107
+ "message": "zoo (dev) 1.0.0 ❯ 1.1.0 ",
31
108
  "name": "zoo",
32
109
  "value": Object {
33
110
  "currentRange": "1.0.0",
@@ -38,7 +115,7 @@ Array [
38
115
  },
39
116
  },
40
117
  Object {
41
- "message": "bar (peer) 1.0.0 ❯ 1.1.0 ",
118
+ "message": "bar (peer) 1.0.0 ❯ 1.1.0 ",
42
119
  "name": "bar",
43
120
  "value": Object {
44
121
  "currentRange": "1.0.0",
@@ -59,7 +136,7 @@ Array [
59
136
  Object {
60
137
  "choices": Array [
61
138
  Object {
62
- "message": "foo (runtime) 1.0.0 ❯ 2.0.0 ",
139
+ "message": "foo (runtime) 1.0.0 ❯ 2.0.0 ",
63
140
  "name": "foo",
64
141
  "value": Object {
65
142
  "componentId": "comp1",
@@ -76,7 +153,7 @@ Array [
76
153
  Object {
77
154
  "choices": Array [
78
155
  Object {
79
- "message": "bar (peer) 1.0.0 ❯ 1.1.0 ",
156
+ "message": "bar (peer) 1.0.0 ❯ 1.1.0 ",
80
157
  "name": "bar",
81
158
  "value": Object {
82
159
  "currentRange": "1.0.0",
@@ -1,12 +1,90 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
+ exports[`makeOutdatedPkgChoices should group component model updates of the same dependency 1`] = `
4
+ Array [
5
+ Object {
6
+ "choices": Array [
7
+ Object {
8
+ "message": "foo (runtime) * ❯ 2.0.0 because of comp1 and 1 other components ",
9
+ "name": "foo",
10
+ "value": Object {
11
+ "currentRange": "1.0.0",
12
+ "dependentComponents": Array [
13
+ "comp1",
14
+ "comp2",
15
+ ],
16
+ "hasDifferentRanges": true,
17
+ "latestRange": "2.0.0",
18
+ "name": "foo",
19
+ "source": "rootPolicy",
20
+ "targetField": "dependencies",
21
+ },
22
+ },
23
+ ],
24
+ "message": "Root policies",
25
+ },
26
+ ]
27
+ `;
28
+
29
+ exports[`makeOutdatedPkgChoices should group component model updates of the same dependency and display the current range when all components use the same range 1`] = `
30
+ Array [
31
+ Object {
32
+ "choices": Array [
33
+ Object {
34
+ "message": "foo (runtime) ^1.2.3 ❯ 2.0.0 because of comp1 and 1 other components ",
35
+ "name": "foo",
36
+ "value": Object {
37
+ "currentRange": "^1.2.3",
38
+ "dependentComponents": Array [
39
+ "comp1",
40
+ "comp2",
41
+ ],
42
+ "latestRange": "2.0.0",
43
+ "name": "foo",
44
+ "source": "rootPolicy",
45
+ "targetField": "dependencies",
46
+ },
47
+ },
48
+ ],
49
+ "message": "Root policies",
50
+ },
51
+ ]
52
+ `;
53
+
54
+ exports[`makeOutdatedPkgChoices should group component model updates of the same dependency and use * as current range when can't compare ranges 1`] = `
55
+ Array [
56
+ Object {
57
+ "choices": Array [
58
+ Object {
59
+ "message": "foo (runtime) * ❯ 2.0.0 because of comp1 and 1 other components ",
60
+ "name": "foo",
61
+ "value": Object {
62
+ "currentRange": "*",
63
+ "dependentComponents": Array [
64
+ "comp1",
65
+ "comp2",
66
+ ],
67
+ "hasDifferentRanges": true,
68
+ "latestRange": "2.0.0",
69
+ "name": "foo",
70
+ "source": "rootPolicy",
71
+ "targetField": "dependencies",
72
+ },
73
+ },
74
+ ],
75
+ "message": "Root policies",
76
+ },
77
+ ]
78
+ `;
79
+
3
80
  exports[`makeOutdatedPkgChoices should render choices in correct order 1`] = `
4
81
  Array [
5
82
  Object {
6
83
  "choices": Array [
7
84
  Object {
8
- "message": "foo (runtime) 1.0.0 ❯ 2.0.0 ",
9
- "name": Object {
85
+ "message": "foo (runtime) 1.0.0 ❯ 2.0.0 ",
86
+ "name": "foo",
87
+ "value": Object {
10
88
  "currentRange": "1.0.0",
11
89
  "latestRange": "2.0.0",
12
90
  "name": "foo",
@@ -15,8 +93,9 @@ Array [
15
93
  },
16
94
  },
17
95
  Object {
18
- "message": "qar (runtime) 1.0.0 ❯ 1.1.0 ",
19
- "name": Object {
96
+ "message": "qar (runtime) 1.0.0 ❯ 1.1.0 ",
97
+ "name": "qar",
98
+ "value": Object {
20
99
  "currentRange": "1.0.0",
21
100
  "latestRange": "1.1.0",
22
101
  "name": "qar",
@@ -25,8 +104,9 @@ Array [
25
104
  },
26
105
  },
27
106
  Object {
28
- "message": "zoo (dev) 1.0.0 ❯ 1.1.0 ",
29
- "name": Object {
107
+ "message": "zoo (dev) 1.0.0 ❯ 1.1.0 ",
108
+ "name": "zoo",
109
+ "value": Object {
30
110
  "currentRange": "1.0.0",
31
111
  "latestRange": "1.1.0",
32
112
  "name": "zoo",
@@ -35,8 +115,9 @@ Array [
35
115
  },
36
116
  },
37
117
  Object {
38
- "message": "bar (peer) 1.0.0 ❯ 1.1.0 ",
39
- "name": Object {
118
+ "message": "bar (peer) 1.0.0 ❯ 1.1.0 ",
119
+ "name": "bar",
120
+ "value": Object {
40
121
  "currentRange": "1.0.0",
41
122
  "latestRange": "1.1.0",
42
123
  "name": "bar",
@@ -55,8 +136,9 @@ Array [
55
136
  Object {
56
137
  "choices": Array [
57
138
  Object {
58
- "message": "foo (runtime) 1.0.0 ❯ 2.0.0 ",
59
- "name": Object {
139
+ "message": "foo (runtime) 1.0.0 ❯ 2.0.0 ",
140
+ "name": "foo",
141
+ "value": Object {
60
142
  "componentId": "comp1",
61
143
  "currentRange": "1.0.0",
62
144
  "latestRange": "2.0.0",
@@ -71,8 +153,9 @@ Array [
71
153
  Object {
72
154
  "choices": Array [
73
155
  Object {
74
- "message": "bar (peer) 1.0.0 ❯ 1.1.0 ",
75
- "name": Object {
156
+ "message": "bar (peer) 1.0.0 ❯ 1.1.0 ",
157
+ "name": "bar",
158
+ "value": Object {
76
159
  "currentRange": "1.0.0",
77
160
  "latestRange": "1.1.0",
78
161
  "name": "bar",
package/dist/bit-map.d.ts CHANGED
@@ -36,6 +36,7 @@ export declare class BitMap {
36
36
  * components that were not tagged yet are safe to rename them from the .bitmap file.
37
37
  */
38
38
  renameNewComponent(sourceId: ComponentID, targetId: ComponentID): void;
39
+ removeComponent(id: ComponentID): void;
39
40
  /**
40
41
  * this is the lane-id of the recently exported lane. in case of a new lane, which was not exported yet, this will be
41
42
  * empty.
package/dist/bit-map.js CHANGED
@@ -206,6 +206,10 @@ class BitMap {
206
206
  bitMapEntry.id = targetId._legacy;
207
207
  this.legacyBitMap.setComponent(bitMapEntry.id, bitMapEntry);
208
208
  }
209
+
210
+ removeComponent(id) {
211
+ this.legacyBitMap.removeComponent(id._legacy);
212
+ }
209
213
  /**
210
214
  * this is the lane-id of the recently exported lane. in case of a new lane, which was not exported yet, this will be
211
215
  * empty.
@@ -1 +1 @@
1
- {"version":3,"names":["BitMap","constructor","legacyBitMap","consumer","addComponentConfig","id","aspectId","config","shouldMergeConfig","Error","bitMapEntry","getBitmapEntry","ignoreScopeAndVersion","currentConfig","isEqual","getNewConfig","merge","newConfig","markAsChanged","removeComponentConfig","markWithMinusIfNotExist","REMOVE_EXTENSION_SPECIAL_SIGN","removeEntireConfig","setEntireConfig","removeDefaultScope","defaultScope","setDefaultScope","write","writeBitMap","ignoreVersion","getComponent","_legacy","getAspectIdFromConfig","componentId","ignoreAspectVersion","undefined","toString","allVersions","Object","keys","filter","startsWith","toStringWithoutVersion","length","BitError","join","renameNewComponent","sourceId","targetId","hasVersion","removeComponent","setComponent","getExportedLaneId","isLaneExported","laneId","hasChanged"],"sources":["bit-map.ts"],"sourcesContent":["import { isEqual, merge } from 'lodash';\nimport { ComponentID } from '@teambit/component-id';\nimport LegacyBitMap from '@teambit/legacy/dist/consumer/bit-map';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport { GetBitMapComponentOptions } from '@teambit/legacy/dist/consumer/bit-map/bit-map';\nimport ComponentMap from '@teambit/legacy/dist/consumer/bit-map/component-map';\nimport { REMOVE_EXTENSION_SPECIAL_SIGN } from '@teambit/legacy/dist/consumer/config';\nimport { BitError } from '@teambit/bit-error';\nimport { LaneId } from '@teambit/lane-id';\n/**\n * consider extracting to a new component.\n * (pro: making Workspace aspect smaller. con: it's an implementation details of the workspace)\n */\nexport class BitMap {\n constructor(private legacyBitMap: LegacyBitMap, private consumer: Consumer) {}\n\n /**\n * adds component config to the .bitmap file.\n * later, upon `bit tag`, the data is saved in the scope.\n * returns a boolean indicating whether a change has been made.\n */\n addComponentConfig(\n id: ComponentID,\n aspectId: string,\n config: Record<string, any> = {},\n shouldMergeConfig = false\n ): boolean {\n if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n const currentConfig = (bitMapEntry.config ||= {})[aspectId];\n if (isEqual(currentConfig, config)) {\n return false; // no changes\n }\n const getNewConfig = () => {\n if (!config) return null;\n if (!shouldMergeConfig) return config;\n // should merge\n if (!currentConfig) return config;\n if (currentConfig === '-') return config;\n // lodash merge performs a deep merge. (the native concatenation don't)\n return merge(currentConfig, config);\n };\n const newConfig = getNewConfig();\n if (newConfig) {\n bitMapEntry.config[aspectId] = newConfig;\n } else {\n delete bitMapEntry.config[aspectId];\n }\n this.legacyBitMap.markAsChanged();\n\n return true; // changes have been made\n }\n\n removeComponentConfig(id: ComponentID, aspectId: string, markWithMinusIfNotExist: boolean): boolean {\n if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n const currentConfig = (bitMapEntry.config ||= {})[aspectId];\n if (currentConfig) {\n delete bitMapEntry.config[aspectId];\n } else {\n if (!markWithMinusIfNotExist) {\n return false; // no changes\n }\n bitMapEntry.config[aspectId] = REMOVE_EXTENSION_SPECIAL_SIGN;\n }\n\n this.legacyBitMap.markAsChanged();\n\n return true; // changes have been made\n }\n\n removeEntireConfig(id: ComponentID): boolean {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n if (!bitMapEntry.config) return false;\n delete bitMapEntry.config;\n this.legacyBitMap.markAsChanged();\n return true;\n }\n\n setEntireConfig(id: ComponentID, config: Record<string, any>) {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n bitMapEntry.config = config;\n this.legacyBitMap.markAsChanged();\n }\n\n removeDefaultScope(id: ComponentID) {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n if (bitMapEntry.defaultScope) {\n delete bitMapEntry.defaultScope;\n this.legacyBitMap.markAsChanged();\n }\n }\n\n setDefaultScope(id: ComponentID, defaultScope: string) {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n bitMapEntry.defaultScope = defaultScope;\n this.legacyBitMap.markAsChanged();\n }\n\n /**\n * write .bitmap object to the filesystem\n */\n async write() {\n await this.consumer.writeBitMap();\n }\n\n /**\n * get the data saved in the .bitmap file for this component-id.\n */\n getBitmapEntry(\n id: ComponentID,\n { ignoreVersion, ignoreScopeAndVersion }: GetBitMapComponentOptions = {}\n ): ComponentMap {\n return this.legacyBitMap.getComponent(id._legacy, { ignoreVersion, ignoreScopeAndVersion });\n }\n\n getAspectIdFromConfig(\n componentId: ComponentID,\n aspectId: ComponentID,\n ignoreAspectVersion = false\n ): string | undefined {\n const bitMapEntry = this.getBitmapEntry(componentId);\n const config = bitMapEntry.config;\n if (!config) {\n return undefined;\n }\n if (config[aspectId.toString()]) {\n return aspectId.toString();\n }\n if (!ignoreAspectVersion) {\n return undefined;\n }\n const allVersions = Object.keys(config).filter((id) => id.startsWith(`${aspectId.toStringWithoutVersion()}@`));\n if (allVersions.length > 1) {\n throw new BitError(\n `error: the same aspect ${\n aspectId.toStringWithoutVersion\n } configured multiple times for \"${componentId.toString()}\"\\n${allVersions.join('\\n')}`\n );\n }\n return allVersions.length === 1 ? allVersions[0] : undefined;\n }\n\n /**\n * components that were not tagged yet are safe to rename them from the .bitmap file.\n */\n renameNewComponent(sourceId: ComponentID, targetId: ComponentID) {\n const bitMapEntry = this.getBitmapEntry(sourceId);\n if (bitMapEntry.id.hasVersion()) {\n throw new Error(`unable to rename tagged or exported component: ${bitMapEntry.id.toString()}`);\n }\n this.legacyBitMap.removeComponent(bitMapEntry.id);\n bitMapEntry.id = targetId._legacy;\n this.legacyBitMap.setComponent(bitMapEntry.id, bitMapEntry);\n }\n\n /**\n * this is the lane-id of the recently exported lane. in case of a new lane, which was not exported yet, this will be\n * empty.\n */\n getExportedLaneId(): LaneId | undefined {\n return this.legacyBitMap.isLaneExported ? this.legacyBitMap.laneId : undefined;\n }\n\n /**\n * whether .bitmap file has changed in-memory\n */\n hasChanged(): boolean {\n return this.legacyBitMap.hasChanged;\n }\n}\n"],"mappings":";;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAMA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;AACA;AACA;AACA;AACO,MAAMA,MAAN,CAAa;EAClBC,WAAW,CAASC,YAAT,EAA6CC,QAA7C,EAAiE;IAAA,KAAxDD,YAAwD,GAAxDA,YAAwD;IAAA,KAApBC,QAAoB,GAApBA,QAAoB;EAAE;EAE9E;AACF;AACA;AACA;AACA;;;EACEC,kBAAkB,CAChBC,EADgB,EAEhBC,QAFgB,EAGhBC,MAA2B,GAAG,EAHd,EAIhBC,iBAAiB,GAAG,KAJJ,EAKP;IACT,IAAI,CAACF,QAAD,IAAa,OAAOA,QAAP,KAAoB,QAArC,EAA+C,MAAM,IAAIG,KAAJ,CAAW,qCAAoCH,QAAS,EAAxD,CAAN;IAC/C,MAAMI,WAAW,GAAG,KAAKC,cAAL,CAAoBN,EAApB,EAAwB;MAAEO,qBAAqB,EAAE;IAAzB,CAAxB,CAApB;IACA,MAAMC,aAAa,GAAG,CAACH,WAAW,CAACH,MAAb,KAACG,WAAW,CAACH,MAAb,GAAwB,EAAxB,GAA4BD,QAA5B,CAAtB;;IACA,IAAI,IAAAQ,iBAAA,EAAQD,aAAR,EAAuBN,MAAvB,CAAJ,EAAoC;MAClC,OAAO,KAAP,CADkC,CACpB;IACf;;IACD,MAAMQ,YAAY,GAAG,MAAM;MACzB,IAAI,CAACR,MAAL,EAAa,OAAO,IAAP;MACb,IAAI,CAACC,iBAAL,EAAwB,OAAOD,MAAP,CAFC,CAGzB;;MACA,IAAI,CAACM,aAAL,EAAoB,OAAON,MAAP;MACpB,IAAIM,aAAa,KAAK,GAAtB,EAA2B,OAAON,MAAP,CALF,CAMzB;;M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,CAACjB,OAA1B;IACA,KAAK7B,YAAL,CAAkBiD,YAAlB,CAA+BzC,WAAW,CAACL,EAA3C,EAA+CK,WAA/C;EACD;EAED;AACF;AACA;AACA;;;EACE0C,iBAAiB,GAAuB;IACtC,OAAO,KAAKlD,YAAL,CAAkBmD,cAAlB,GAAmC,KAAKnD,YAAL,CAAkBoD,MAArD,GAA8DnB,SAArE;EACD;EAED;AACF;AACA;;;EACEoB,UAAU,GAAY;IACpB,OAAO,KAAKrD,YAAL,CAAkBqD,UAAzB;EACD;;AA5JiB"}
1
+ {"version":3,"names":["BitMap","constructor","legacyBitMap","consumer","addComponentConfig","id","aspectId","config","shouldMergeConfig","Error","bitMapEntry","getBitmapEntry","ignoreScopeAndVersion","currentConfig","isEqual","getNewConfig","merge","newConfig","markAsChanged","removeComponentConfig","markWithMinusIfNotExist","REMOVE_EXTENSION_SPECIAL_SIGN","removeEntireConfig","setEntireConfig","removeDefaultScope","defaultScope","setDefaultScope","write","writeBitMap","ignoreVersion","getComponent","_legacy","getAspectIdFromConfig","componentId","ignoreAspectVersion","undefined","toString","allVersions","Object","keys","filter","startsWith","toStringWithoutVersion","length","BitError","join","renameNewComponent","sourceId","targetId","hasVersion","removeComponent","setComponent","getExportedLaneId","isLaneExported","laneId","hasChanged"],"sources":["bit-map.ts"],"sourcesContent":["import { isEqual, merge } from 'lodash';\nimport { ComponentID } from '@teambit/component-id';\nimport LegacyBitMap from '@teambit/legacy/dist/consumer/bit-map';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport { GetBitMapComponentOptions } from '@teambit/legacy/dist/consumer/bit-map/bit-map';\nimport ComponentMap from '@teambit/legacy/dist/consumer/bit-map/component-map';\nimport { REMOVE_EXTENSION_SPECIAL_SIGN } from '@teambit/legacy/dist/consumer/config';\nimport { BitError } from '@teambit/bit-error';\nimport { LaneId } from '@teambit/lane-id';\n/**\n * consider extracting to a new component.\n * (pro: making Workspace aspect smaller. con: it's an implementation details of the workspace)\n */\nexport class BitMap {\n constructor(private legacyBitMap: LegacyBitMap, private consumer: Consumer) {}\n\n /**\n * adds component config to the .bitmap file.\n * later, upon `bit tag`, the data is saved in the scope.\n * returns a boolean indicating whether a change has been made.\n */\n addComponentConfig(\n id: ComponentID,\n aspectId: string,\n config: Record<string, any> = {},\n shouldMergeConfig = false\n ): boolean {\n if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n const currentConfig = (bitMapEntry.config ||= {})[aspectId];\n if (isEqual(currentConfig, config)) {\n return false; // no changes\n }\n const getNewConfig = () => {\n if (!config) return null;\n if (!shouldMergeConfig) return config;\n // should merge\n if (!currentConfig) return config;\n if (currentConfig === '-') return config;\n // lodash merge performs a deep merge. (the native concatenation don't)\n return merge(currentConfig, config);\n };\n const newConfig = getNewConfig();\n if (newConfig) {\n bitMapEntry.config[aspectId] = newConfig;\n } else {\n delete bitMapEntry.config[aspectId];\n }\n this.legacyBitMap.markAsChanged();\n\n return true; // changes have been made\n }\n\n removeComponentConfig(id: ComponentID, aspectId: string, markWithMinusIfNotExist: boolean): boolean {\n if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n const currentConfig = (bitMapEntry.config ||= {})[aspectId];\n if (currentConfig) {\n delete bitMapEntry.config[aspectId];\n } else {\n if (!markWithMinusIfNotExist) {\n return false; // no changes\n }\n bitMapEntry.config[aspectId] = REMOVE_EXTENSION_SPECIAL_SIGN;\n }\n\n this.legacyBitMap.markAsChanged();\n\n return true; // changes have been made\n }\n\n removeEntireConfig(id: ComponentID): boolean {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n if (!bitMapEntry.config) return false;\n delete bitMapEntry.config;\n this.legacyBitMap.markAsChanged();\n return true;\n }\n\n setEntireConfig(id: ComponentID, config: Record<string, any>) {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n bitMapEntry.config = config;\n this.legacyBitMap.markAsChanged();\n }\n\n removeDefaultScope(id: ComponentID) {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n if (bitMapEntry.defaultScope) {\n delete bitMapEntry.defaultScope;\n this.legacyBitMap.markAsChanged();\n }\n }\n\n setDefaultScope(id: ComponentID, defaultScope: string) {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n bitMapEntry.defaultScope = defaultScope;\n this.legacyBitMap.markAsChanged();\n }\n\n /**\n * write .bitmap object to the filesystem\n */\n async write() {\n await this.consumer.writeBitMap();\n }\n\n /**\n * get the data saved in the .bitmap file for this component-id.\n */\n getBitmapEntry(\n id: ComponentID,\n { ignoreVersion, ignoreScopeAndVersion }: GetBitMapComponentOptions = {}\n ): ComponentMap {\n return this.legacyBitMap.getComponent(id._legacy, { ignoreVersion, ignoreScopeAndVersion });\n }\n\n getAspectIdFromConfig(\n componentId: ComponentID,\n aspectId: ComponentID,\n ignoreAspectVersion = false\n ): string | undefined {\n const bitMapEntry = this.getBitmapEntry(componentId);\n const config = bitMapEntry.config;\n if (!config) {\n return undefined;\n }\n if (config[aspectId.toString()]) {\n return aspectId.toString();\n }\n if (!ignoreAspectVersion) {\n return undefined;\n }\n const allVersions = Object.keys(config).filter((id) => id.startsWith(`${aspectId.toStringWithoutVersion()}@`));\n if (allVersions.length > 1) {\n throw new BitError(\n `error: the same aspect ${\n aspectId.toStringWithoutVersion\n } configured multiple times for \"${componentId.toString()}\"\\n${allVersions.join('\\n')}`\n );\n }\n return allVersions.length === 1 ? allVersions[0] : undefined;\n }\n\n /**\n * components that were not tagged yet are safe to rename them from the .bitmap file.\n */\n renameNewComponent(sourceId: ComponentID, targetId: ComponentID) {\n const bitMapEntry = this.getBitmapEntry(sourceId);\n if (bitMapEntry.id.hasVersion()) {\n throw new Error(`unable to rename tagged or exported component: ${bitMapEntry.id.toString()}`);\n }\n this.legacyBitMap.removeComponent(bitMapEntry.id);\n bitMapEntry.id = targetId._legacy;\n this.legacyBitMap.setComponent(bitMapEntry.id, bitMapEntry);\n }\n\n removeComponent(id: ComponentID) {\n this.legacyBitMap.removeComponent(id._legacy);\n }\n\n /**\n * this is the lane-id of the recently exported lane. in case of a new lane, which was not exported yet, this will be\n * empty.\n */\n getExportedLaneId(): LaneId | undefined {\n return this.legacyBitMap.isLaneExported ? this.legacyBitMap.laneId : undefined;\n }\n\n /**\n * whether .bitmap file has changed in-memory\n */\n hasChanged(): boolean {\n return this.legacyBitMap.hasChanged;\n }\n}\n"],"mappings":";;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAMA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;AACA;AACA;AACA;AACO,MAAMA,MAAN,CAAa;EAClBC,WAAW,CAASC,YAAT,EAA6CC,QAA7C,EAAiE;IAAA,KAAxDD,YAAwD,GAAxDA,YAAwD;IAAA,KAApBC,QAAoB,GAApBA,QAAoB;EAAE;EAE9E;AACF;AACA;AACA;AACA;;;EACEC,kBAAkB,CAChBC,EADgB,EAEhBC,QAFgB,EAGhBC,MAA2B,GAAG,EAHd,EAIhBC,iBAAiB,GAAG,KAJJ,EAKP;IACT,IAAI,CAACF,QAAD,IAAa,OAAOA,QAAP,KAAoB,QAArC,EAA+C,MAAM,IAAIG,KAAJ,CAAW,qCAAoCH,QAAS,EAAxD,CAAN;IAC/C,MAAMI,WAAW,GAAG,KAAKC,cAAL,CAAoBN,EAApB,EAAwB;MAAEO,qBAAqB,EAAE;IAAzB,CAAxB,CAApB;IACA,MAAMC,aAAa,GAAG,CAACH,WAAW,CAACH,MAAb,KAACG,WAAW,CAACH,MAAb,GAAwB,EAAxB,GAA4BD,QAA5B,CAAtB;;IACA,IAAI,IAAAQ,iBAAA,EAAQD,aAAR,EA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KC,cAAL,CAAoBoC,QAApB,CAApB;;IACA,IAAIrC,WAAW,CAACL,EAAZ,CAAe4C,UAAf,EAAJ,EAAiC;MAC/B,MAAM,IAAIxC,KAAJ,CAAW,kDAAiDC,WAAW,CAACL,EAAZ,CAAe+B,QAAf,EAA0B,EAAtF,CAAN;IACD;;IACD,KAAKlC,YAAL,CAAkBgD,eAAlB,CAAkCxC,WAAW,CAACL,EAA9C;IACAK,WAAW,CAACL,EAAZ,GAAiB2C,QAAQ,CAACjB,OAA1B;IACA,KAAK7B,YAAL,CAAkBiD,YAAlB,CAA+BzC,WAAW,CAACL,EAA3C,EAA+CK,WAA/C;EACD;;EAEDwC,eAAe,CAAC7C,EAAD,EAAkB;IAC/B,KAAKH,YAAL,CAAkBgD,eAAlB,CAAkC7C,EAAE,CAAC0B,OAArC;EACD;EAED;AACF;AACA;AACA;;;EACEqB,iBAAiB,GAAuB;IACtC,OAAO,KAAKlD,YAAL,CAAkBmD,cAAlB,GAAmC,KAAKnD,YAAL,CAAkBoD,MAArD,GAA8DnB,SAArE;EACD;EAED;AACF;AACA;;;EACEoB,UAAU,GAAY;IACpB,OAAO,KAAKrD,YAAL,CAAkBqD,UAAzB;EACD;;AAhKiB"}
@@ -233,7 +233,7 @@ class GraphFromFsBuilder {
233
233
  throw err;
234
234
  }
235
235
  });
236
- return components;
236
+ return (0, _lodash2().default)(components);
237
237
  }
238
238
 
239
239
  async loadComponent(componentId) {
@@ -1 +1 @@
1
- {"version":3,"names":["GraphFromFsBuilder","constructor","workspace","logger","ignoreIds","BitIds","shouldLoadItsDeps","LegacyGraph","consumer","buildGraph","ids","debug","length","start","Date","now","components","loadManyComponents","processManyComponents","graph","getAllDepsUnfiltered","component","getAllDependenciesIds","difference","getAllDepsFiltered","depsWithoutIgnore","shouldLoadFunc","deps","mapSeries","depId","shouldLoad","push","fromArray","compact","depth","importObjects","allDependencies","processOneComponent","allDependenciesFlattened","flatten","allDeps","map","c","flat","allDepsWithScope","filter","dep","hasScope","scopeComponentsImporter","ScopeComponentsImporter","scope","importMany","uniqFromArray","throwForDependencyNotFound","shouldThrowOnMissingDep","idStr","id","toString","completed","includes","allIds","Object","entries","depsIdsGroupedByType","forEach","depType","depsIds","has","hasNode","Error","setEdge","componentsIds","dependenciesOf","comp","fromGraph","node","loadComponent","setNode","err","ComponentNotFound","BitError","error","componentId","compId","resolveComponentId","get","state","_consumer"],"sources":["build-graph-from-fs.ts"],"sourcesContent":["import mapSeries from 'p-map-series';\nimport { flatten } from 'lodash';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport BitIds from '@teambit/legacy/dist/bit-id/bit-ids';\nimport Component from '@teambit/legacy/dist/consumer/component/consumer-component';\nimport LegacyGraph from '@teambit/legacy/dist/scope/graph/graph';\nimport ScopeComponentsImporter from '@teambit/legacy/dist/scope/component-ops/scope-components-importer';\nimport compact from 'lodash.compact';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { Logger } from '@teambit/logger';\nimport { ComponentNotFound } from '@teambit/scope';\nimport { BitError } from '@teambit/bit-error';\nimport { Workspace } from './workspace';\n\nexport type ShouldLoadFunc = (bitId: BitId) => Promise<boolean>;\n\nexport class GraphFromFsBuilder {\n private graph = new LegacyGraph();\n private completed: string[] = [];\n private depth = 1;\n private shouldThrowOnMissingDep = true;\n private consumer: Consumer;\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private ignoreIds = new BitIds(),\n private shouldLoadItsDeps?: ShouldLoadFunc\n ) {\n this.consumer = this.workspace.consumer;\n }\n\n /**\n * create a graph with all dependencies and flattened dependencies of the given components.\n * the nodes are components and the edges has a label of the dependency type.\n *\n * the way how it is done is iterations by depths. each depth we gather all the dependencies of\n * that depths, make sure all objects exist and then check their dependencies for the next depth.\n * once there is no dependency left, we're on the last depth level and the graph is ready.\n *\n * for example, imagine the following graph:\n * A1 -> A2 -> A3\n * B1 -> B2 -> B3\n * C1 -> C2 -> C3\n *\n * where the buildGraph is given [A1, B1, C1].\n * first, it saves all these components as nodes in the graph. then, it finds the dependencies of\n * the next level, in this case they're [A2, B2, C2]. it runs `importMany` in case some objects\n * are missing. then, it loads them all (some from FS, some from the model) and sets the edges\n * between the component and the dependencies.\n * once done, it finds all their dependencies, which are [A3, B3, C3] and repeat the process\n * above. since there are no more dependencies, the graph is completed.\n * in this case, the total depth levels are 3.\n *\n * even with a huge project, there are not many depth levels. by iterating through depth levels\n * we keep performance sane as the importMany doesn't run multiple time and therefore the round\n * trips to the remotes are minimal.\n *\n * normally, one importMany of the seeders is enough as importMany knows to fetch all flattened.\n * however, since this buildGraph is performed on the workspace, a dependency may be new or\n * modified and as such, we don't know its flattened yet.\n */\n async buildGraph(ids: BitId[]): Promise<LegacyGraph> {\n this.logger.debug(`GraphFromFsBuilder, buildGraph with ${ids.length} seeders`);\n const start = Date.now();\n const components = await this.loadManyComponents(ids, '<none>');\n await this.processManyComponents(components);\n this.logger.debug(\n `GraphFromFsBuilder, buildGraph with ${ids.length} seeders completed (${(Date.now() - start) / 1000} sec)`\n );\n return this.graph;\n }\n\n private getAllDepsUnfiltered(component: Component) {\n return component.getAllDependenciesIds().difference(this.ignoreIds);\n }\n\n private async getAllDepsFiltered(component: Component): Promise<BitIds> {\n const depsWithoutIgnore = this.getAllDepsUnfiltered(component);\n const shouldLoadFunc = this.shouldLoadItsDeps;\n if (!shouldLoadFunc) return depsWithoutIgnore;\n const deps = await mapSeries(depsWithoutIgnore, async (depId) => {\n const shouldLoad = await shouldLoadFunc(depId);\n if (!shouldLoad) this.ignoreIds.push(depId);\n return shouldLoad ? depId : null;\n });\n return BitIds.fromArray(compact(deps));\n }\n\n private async processManyComponents(components: Component[]) {\n this.logger.debug(`GraphFromFsBuilder.processManyComponents depth ${this.depth}, ${components.length} components`);\n this.depth += 1;\n await this.importObjects(components);\n const allDependencies = await mapSeries(components, (component) => this.processOneComponent(component));\n const allDependenciesFlattened = flatten(allDependencies);\n if (allDependenciesFlattened.length) await this.processManyComponents(allDependenciesFlattened);\n }\n\n private async importObjects(components: Component[]) {\n const allDeps = components.map((c) => this.getAllDepsUnfiltered(c)).flat();\n const allDepsWithScope = allDeps.filter((dep) => dep.hasScope());\n const scopeComponentsImporter = new ScopeComponentsImporter(this.consumer.scope);\n await scopeComponentsImporter.importMany({\n ids: BitIds.uniqFromArray(allDepsWithScope),\n throwForDependencyNotFound: this.shouldThrowOnMissingDep,\n });\n }\n\n private async processOneComponent(component: Component) {\n const idStr = component.id.toString();\n if (this.completed.includes(idStr)) return [];\n const allIds = await this.getAllDepsFiltered(component);\n\n const allDependencies = await this.loadManyComponents(allIds, idStr);\n Object.entries(component.depsIdsGroupedByType).forEach(([depType, depsIds]) => {\n depsIds.forEach((depId) => {\n if (this.ignoreIds.has(depId)) return;\n if (!this.graph.hasNode(depId.toString())) {\n throw new Error(`buildOneComponent: missing node of ${depId.toString()}`);\n }\n this.graph.setEdge(idStr, depId.toString(), depType);\n });\n });\n this.completed.push(idStr);\n return allDependencies;\n }\n\n private async loadManyComponents(componentsIds: BitId[], dependenciesOf: string): Promise<Component[]> {\n const components = await mapSeries(componentsIds, async (comp: BitId) => {\n const idStr = comp.toString();\n const fromGraph = this.graph.node(idStr);\n if (fromGraph) return fromGraph;\n try {\n const component = await this.loadComponent(comp);\n this.graph.setNode(idStr, component);\n return component;\n } catch (err: any) {\n if (err instanceof ComponentNotFound) {\n throw new BitError(\n `error: component \"${idStr}\" was not found.\\nthis component is a dependency of \"${dependenciesOf}\" and is needed as part of the graph generation`\n );\n }\n this.logger.error(`failed loading dependencies of ${dependenciesOf}`);\n throw err;\n }\n });\n return components;\n }\n private async loadComponent(componentId: BitId): Promise<Component> {\n const compId = await this.workspace.resolveComponentId(componentId);\n const comp = await this.workspace.get(compId);\n return comp.state._consumer;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;I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f,CAAmBF,MAAnB,CAAnB;IACA,OAAOV,IAAI,CAACa,KAAL,CAAWC,SAAlB;EACD;;AAvI6B"}
1
+ {"version":3,"names":["GraphFromFsBuilder","constructor","workspace","logger","ignoreIds","BitIds","shouldLoadItsDeps","LegacyGraph","consumer","buildGraph","ids","debug","length","start","Date","now","components","loadManyComponents","processManyComponents","graph","getAllDepsUnfiltered","component","getAllDependenciesIds","difference","getAllDepsFiltered","depsWithoutIgnore","shouldLoadFunc","deps","mapSeries","depId","shouldLoad","push","fromArray","compact","depth","importObjects","allDependencies","processOneComponent","allDependenciesFlattened","flatten","allDeps","map","c","flat","allDepsWithScope","filter","dep","hasScope","scopeComponentsImporter","ScopeComponentsImporter","scope","importMany","uniqFromArray","throwForDependencyNotFound","shouldThrowOnMissingDep","idStr","id","toString","completed","includes","allIds","Object","entries","depsIdsGroupedByType","forEach","depType","depsIds","has","hasNode","Error","setEdge","componentsIds","dependenciesOf","comp","fromGraph","node","loadComponent","setNode","err","ComponentNotFound","BitError","error","componentId","compId","resolveComponentId","get","state","_consumer"],"sources":["build-graph-from-fs.ts"],"sourcesContent":["import mapSeries from 'p-map-series';\nimport { flatten } from 'lodash';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport BitIds from '@teambit/legacy/dist/bit-id/bit-ids';\nimport Component from '@teambit/legacy/dist/consumer/component/consumer-component';\nimport LegacyGraph from '@teambit/legacy/dist/scope/graph/graph';\nimport ScopeComponentsImporter from '@teambit/legacy/dist/scope/component-ops/scope-components-importer';\nimport compact from 'lodash.compact';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { Logger } from '@teambit/logger';\nimport { ComponentNotFound } from '@teambit/scope';\nimport { BitError } from '@teambit/bit-error';\nimport { Workspace } from './workspace';\n\nexport type ShouldLoadFunc = (bitId: BitId) => Promise<boolean>;\n\nexport class GraphFromFsBuilder {\n private graph = new LegacyGraph();\n private completed: string[] = [];\n private depth = 1;\n private shouldThrowOnMissingDep = true;\n private consumer: Consumer;\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private ignoreIds = new BitIds(),\n private shouldLoadItsDeps?: ShouldLoadFunc\n ) {\n this.consumer = this.workspace.consumer;\n }\n\n /**\n * create a graph with all dependencies and flattened dependencies of the given components.\n * the nodes are components and the edges has a label of the dependency type.\n *\n * the way how it is done is iterations by depths. each depth we gather all the dependencies of\n * that depths, make sure all objects exist and then check their dependencies for the next depth.\n * once there is no dependency left, we're on the last depth level and the graph is ready.\n *\n * for example, imagine the following graph:\n * A1 -> A2 -> A3\n * B1 -> B2 -> B3\n * C1 -> C2 -> C3\n *\n * where the buildGraph is given [A1, B1, C1].\n * first, it saves all these components as nodes in the graph. then, it finds the dependencies of\n * the next level, in this case they're [A2, B2, C2]. it runs `importMany` in case some objects\n * are missing. then, it loads them all (some from FS, some from the model) and sets the edges\n * between the component and the dependencies.\n * once done, it finds all their dependencies, which are [A3, B3, C3] and repeat the process\n * above. since there are no more dependencies, the graph is completed.\n * in this case, the total depth levels are 3.\n *\n * even with a huge project, there are not many depth levels. by iterating through depth levels\n * we keep performance sane as the importMany doesn't run multiple time and therefore the round\n * trips to the remotes are minimal.\n *\n * normally, one importMany of the seeders is enough as importMany knows to fetch all flattened.\n * however, since this buildGraph is performed on the workspace, a dependency may be new or\n * modified and as such, we don't know its flattened yet.\n */\n async buildGraph(ids: BitId[]): Promise<LegacyGraph> {\n this.logger.debug(`GraphFromFsBuilder, buildGraph with ${ids.length} seeders`);\n const start = Date.now();\n const components = await this.loadManyComponents(ids, '<none>');\n await this.processManyComponents(components);\n this.logger.debug(\n `GraphFromFsBuilder, buildGraph with ${ids.length} seeders completed (${(Date.now() - start) / 1000} sec)`\n );\n return this.graph;\n }\n\n private getAllDepsUnfiltered(component: Component) {\n return component.getAllDependenciesIds().difference(this.ignoreIds);\n }\n\n private async getAllDepsFiltered(component: Component): Promise<BitIds> {\n const depsWithoutIgnore = this.getAllDepsUnfiltered(component);\n const shouldLoadFunc = this.shouldLoadItsDeps;\n if (!shouldLoadFunc) return depsWithoutIgnore;\n const deps = await mapSeries(depsWithoutIgnore, async (depId) => {\n const shouldLoad = await shouldLoadFunc(depId);\n if (!shouldLoad) this.ignoreIds.push(depId);\n return shouldLoad ? depId : null;\n });\n return BitIds.fromArray(compact(deps));\n }\n\n private async processManyComponents(components: Component[]) {\n this.logger.debug(`GraphFromFsBuilder.processManyComponents depth ${this.depth}, ${components.length} components`);\n this.depth += 1;\n await this.importObjects(components);\n const allDependencies = await mapSeries(components, (component) => this.processOneComponent(component));\n const allDependenciesFlattened = flatten(allDependencies);\n if (allDependenciesFlattened.length) await this.processManyComponents(allDependenciesFlattened);\n }\n\n private async importObjects(components: Component[]) {\n const allDeps = components.map((c) => this.getAllDepsUnfiltered(c)).flat();\n const allDepsWithScope = allDeps.filter((dep) => dep.hasScope());\n const scopeComponentsImporter = new ScopeComponentsImporter(this.consumer.scope);\n await scopeComponentsImporter.importMany({\n ids: BitIds.uniqFromArray(allDepsWithScope),\n throwForDependencyNotFound: this.shouldThrowOnMissingDep,\n });\n }\n\n private async processOneComponent(component: Component) {\n const idStr = component.id.toString();\n if (this.completed.includes(idStr)) return [];\n const allIds = await this.getAllDepsFiltered(component);\n\n const allDependencies = await this.loadManyComponents(allIds, idStr);\n Object.entries(component.depsIdsGroupedByType).forEach(([depType, depsIds]) => {\n depsIds.forEach((depId) => {\n if (this.ignoreIds.has(depId)) return;\n if (!this.graph.hasNode(depId.toString())) {\n throw new Error(`buildOneComponent: missing node of ${depId.toString()}`);\n }\n this.graph.setEdge(idStr, depId.toString(), depType);\n });\n });\n this.completed.push(idStr);\n return allDependencies;\n }\n\n private async loadManyComponents(componentsIds: BitId[], dependenciesOf: string): Promise<Component[]> {\n const components = await mapSeries(componentsIds, async (comp: BitId) => {\n const idStr = comp.toString();\n const fromGraph = this.graph.node(idStr);\n if (fromGraph) return fromGraph;\n try {\n const component = await this.loadComponent(comp);\n this.graph.setNode(idStr, component);\n return component;\n } catch (err: any) {\n if (err instanceof ComponentNotFound) {\n throw new BitError(\n `error: component \"${idStr}\" was not found.\\nthis component is a dependency of \"${dependenciesOf}\" and is needed as part of the graph generation`\n );\n }\n this.logger.error(`failed loading dependencies of ${dependenciesOf}`);\n throw err;\n }\n });\n return compact(components);\n }\n private async loadComponent(componentId: BitId): Promise<Component> {\n const compId = await this.workspace.resolveComponentId(componentId);\n const comp = await this.workspace.get(compId);\n return comp.state._consumer;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAKO,MAAMA,kBAAN,CAAyB;EAM9BC,WAAW,CACDC,SADC,EAEDC,MAFC,EAGDC,SAAS,GAAG,KAAIC,iBAAJ,GAHX,EAIDC,iBAJC,EAKT;IAAA,KAJQJ,SAIR,GAJQA,SAIR;IAAA,KAHQC,MAGR,GAHQA,MAGR;IAAA,KAFQC,SAER,GAFQA,SAER;IAAA,KADQE,iBACR,GADQA,iBACR;IAAA,+CAVc,KAAIC,gBAAJ,GAUd;IAAA,mDAT4B,EAS5B;IAAA,+CARc,CAQd;IAAA,iEAPgC,IAOhC;IAAA;IACA,KAAKC,QAAL,GAAgB,KAAKN,SAAL,CAAeM,QAA/B;EACD;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;EACk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0BAAnB,EAAsC;UACpC,MAAM,KAAIC,oBAAJ,EACH,qBAAoBzB,KAAM,wDAAuDiB,cAAe,iDAD7F,CAAN;QAGD;;QACD,KAAKrE,MAAL,CAAY8E,KAAZ,CAAmB,kCAAiCT,cAAe,EAAnE;QACA,MAAMM,GAAN;MACD;IACF,CAjBwB,CAAzB;IAkBA,OAAO,IAAA7C,kBAAA,EAAQjB,UAAR,CAAP;EACD;;EAC0B,MAAb4D,aAAa,CAACM,WAAD,EAAyC;IAClE,MAAMC,MAAM,GAAG,MAAM,KAAKjF,SAAL,CAAekF,kBAAf,CAAkCF,WAAlC,CAArB;IACA,MAAMT,IAAI,GAAG,MAAM,KAAKvE,SAAL,CAAemF,GAAf,CAAmBF,MAAnB,CAAnB;IACA,OAAOV,IAAI,CAACa,KAAL,CAAWC,SAAlB;EACD;;AAvI6B"}
@@ -2,7 +2,7 @@ import { OutdatedPkg } from '@teambit/dependency-resolver';
2
2
  /**
3
3
  * Lets the user pick the packages that should be updated.
4
4
  */
5
- export declare function pickOutdatedPkgs(outdatedPkgs: OutdatedPkg[]): Promise<OutdatedPkg[]>;
5
+ export declare function pickOutdatedPkgs(outdatedPkgs: OutdatedPkg[]): Promise<MergedOutdatedPkg[]>;
6
6
  /**
7
7
  * Groups the outdated packages and makes choices for enquirer's prompt.
8
8
  */
@@ -10,3 +10,7 @@ export declare function makeOutdatedPkgChoices(outdatedPkgs: OutdatedPkg[]): {
10
10
  message: string;
11
11
  choices: unknown;
12
12
  }[];
13
+ export interface MergedOutdatedPkg extends OutdatedPkg {
14
+ dependentComponents?: string[];
15
+ hasDifferentRanges?: boolean;
16
+ }