@teambit/isolator 0.0.917 → 0.0.918

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,4 +1,5 @@
1
1
  import type { Component, ComponentID } from '@teambit/component';
2
+ import { DependencyResolverMain } from '@teambit/dependency-resolver';
2
3
  import { BitId } from '@teambit/legacy-bit-id';
3
4
  import { Capsule } from './capsule';
4
5
  export default class CapsuleList extends Array<Capsule> {
@@ -9,5 +10,6 @@ export default class CapsuleList extends Array<Capsule> {
9
10
  getAllCapsuleDirs(): string[];
10
11
  getIdByPathInCapsule(pathInCapsule: string): ComponentID | null;
11
12
  getAllComponents(): Component[];
13
+ toposort(depResolver: DependencyResolverMain): Promise<CapsuleList>;
12
14
  static fromArray(capsules: Capsule[]): CapsuleList;
13
15
  }
@@ -1,10 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  require("core-js/modules/es.array.iterator.js");
4
+ require("core-js/modules/es.promise.js");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
9
+ function _graph() {
10
+ const data = require("@teambit/graph.cleargraph");
11
+ _graph = function () {
12
+ return data;
13
+ };
14
+ return data;
15
+ }
8
16
  function _path() {
9
17
  const data = require("path");
10
18
  _path = function () {
@@ -38,6 +46,26 @@ class CapsuleList extends Array {
38
46
  getAllComponents() {
39
47
  return this.map(c => c.component);
40
48
  }
49
+ // Sort the capsules by their dependencies. The capsules with no dependencies will be first. Returns a new array.
50
+ async toposort(depResolver) {
51
+ const components = this.getAllComponents();
52
+ const graph = new (_graph().Graph)();
53
+ components.forEach(comp => graph.setNode(new (_graph().Node)(comp.id.toString(), comp)));
54
+ for (const comp of components) {
55
+ // eslint-disable-next-line no-await-in-loop
56
+ const deps = await depResolver.getComponentDependencies(comp);
57
+ deps.forEach(dep => {
58
+ const depCompId = dep.componentId;
59
+ if (graph.hasNode(depCompId.toString())) {
60
+ graph.setEdge(new (_graph().Edge)(comp.id.toString(), depCompId.toString(), dep.lifecycle));
61
+ }
62
+ });
63
+ }
64
+ const sortedSeeders = graph.toposort(true);
65
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
66
+ const sortedCapsules = sortedSeeders.map(node => this.getCapsule(node.attr.id));
67
+ return CapsuleList.fromArray(sortedCapsules);
68
+ }
41
69
  static fromArray(capsules) {
42
70
  return new CapsuleList(...capsules);
43
71
  }
@@ -1 +1 @@
1
- {"version":3,"names":["CapsuleList","Array","getCapsule","id","find","capsule","component","isEqual","getCapsuleByLegacyId","_legacy","getCapsuleIgnoreVersion","ignoreVersion","getCapsuleIgnoreScopeAndVersion","isEqualWithoutScopeAndVersion","getAllCapsuleDirs","map","path","getIdByPathInCapsule","pathInCapsule","normalizedPathInCapsule","normalize","found","getAllComponents","c","fromArray","capsules"],"sources":["capsule-list.ts"],"sourcesContent":["import type { Component, ComponentID } from '@teambit/component';\nimport { normalize } from 'path';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { Capsule } from './capsule';\n\nexport default class CapsuleList extends Array<Capsule> {\n getCapsule(id: ComponentID): Capsule | undefined {\n return this.find((capsule) => capsule.component.id.isEqual(id));\n }\n getCapsuleByLegacyId(id: BitId): Capsule | undefined {\n return this.find((capsule) => capsule.component.id._legacy.isEqual(id));\n }\n getCapsuleIgnoreVersion(id: ComponentID): Capsule | undefined {\n return this.find((capsule) => capsule.component.id.isEqual(id, { ignoreVersion: true }));\n }\n getCapsuleIgnoreScopeAndVersion(id: ComponentID): Capsule | undefined {\n return this.find((capsule) => capsule.component.id._legacy.isEqualWithoutScopeAndVersion(id._legacy));\n }\n getAllCapsuleDirs(): string[] {\n return this.map((capsule) => capsule.path);\n }\n getIdByPathInCapsule(pathInCapsule: string): ComponentID | null {\n const normalizedPathInCapsule = normalize(pathInCapsule);\n const found = this.find((capsule) => normalizedPathInCapsule === normalize(capsule.path));\n return found ? found.component.id : null;\n }\n getAllComponents(): Component[] {\n return this.map((c) => c.component);\n }\n static f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EAAE,GAAG,IAAI;EAC1C;EACAmB,gBAAgB,GAAgB;IAC9B,OAAO,IAAI,CAACP,GAAG,CAAEQ,CAAC,IAAKA,CAAC,CAACjB,SAAS,CAAC;EACrC;EACA,OAAOkB,SAAS,CAACC,QAAmB,EAAE;IACpC,OAAO,IAAIzB,WAAW,CAAC,GAAGyB,QAAQ,CAAC;EACrC;AACF;AAAC"}
1
+ {"version":3,"names":["CapsuleList","Array","getCapsule","id","find","capsule","component","isEqual","getCapsuleByLegacyId","_legacy","getCapsuleIgnoreVersion","ignoreVersion","getCapsuleIgnoreScopeAndVersion","isEqualWithoutScopeAndVersion","getAllCapsuleDirs","map","path","getIdByPathInCapsule","pathInCapsule","normalizedPathInCapsule","normalize","found","getAllComponents","c","toposort","depResolver","components","graph","Graph","forEach","comp","setNode","Node","toString","deps","getComponentDependencies","dep","depCompId","componentId","hasNode","setEdge","Edge","lifecycle","sortedSeeders","sortedCapsules","node","attr","fromArray","capsules"],"sources":["capsule-list.ts"],"sourcesContent":["import type { Component, ComponentID } from '@teambit/component';\nimport { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { Edge, Graph, Node } from '@teambit/graph.cleargraph';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { normalize } from 'path';\nimport { Capsule } from './capsule';\n\nexport default class CapsuleList extends Array<Capsule> {\n getCapsule(id: ComponentID): Capsule | undefined {\n return this.find((capsule) => capsule.component.id.isEqual(id));\n }\n getCapsuleByLegacyId(id: BitId): Capsule | undefined {\n return this.find((capsule) => capsule.component.id._legacy.isEqual(id));\n }\n getCapsuleIgnoreVersion(id: ComponentID): Capsule | undefined {\n return this.find((capsule) => capsule.component.id.isEqual(id, { ignoreVersion: true }));\n }\n getCapsuleIgnoreScopeAndVersion(id: ComponentID): Capsule | undefined {\n return this.find((capsule) => capsule.component.id._legacy.isEqualWithoutScopeAndVersion(id._legacy));\n }\n getAllCapsuleDirs(): string[] {\n return this.map((capsule) => capsule.path);\n }\n getIdByPathInCapsule(pathInCapsule: string): ComponentID | null {\n const normalizedPathInCapsule = normalize(pathInCapsule);\n const found = this.find((capsule) => normalizedPathInCapsule === normalize(capsule.path));\n return found ? found.component.id : null;\n }\n getAllComponents(): Component[] {\n return this.map((c) => c.component);\n }\n // Sort the capsules by their dependencies. The capsules with no dependencies will be first. Returns a new array.\n async toposort(depResolver: DependencyResolverMain): Promise<CapsuleList> {\n const components = this.getAllComponents();\n const graph = new Graph<Component, string>();\n\n components.forEach((comp) => graph.setNode(new Node(comp.id.toString(), comp)));\n\n for (const comp of components) {\n // eslint-disable-next-line no-await-in-loop\n const deps = await depResolver.getComponentDependencies(comp);\n deps.forEach((dep) => {\n const depCompId = dep.componentId;\n if (graph.hasNode(depCompId.toString())) {\n graph.setEdge(new Edge(comp.id.toString(), depCompId.toString(), dep.lifecycle));\n }\n });\n }\n\n const sortedSeeders = graph.toposort(true);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const sortedCapsules: Capsule[] = sortedSeeders.map((node: Node<Component>) => this.getCapsule(node.attr.id)!);\n return CapsuleList.fromArray(sortedCapsules);\n }\n static fromArray(capsules: Capsule[]) {\n return new CapsuleList(...capsules);\n }\n}\n"],"mappings":";;;;;;;;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGe,MAAMA,WAAW,SAASC,KAAK,CAAU;EACtDC,UAAU,CAACC,EAAe,EAAuB;IAC/C,OAAO,IAAI,CAACC,IAAI,CAAEC,OAAO,IAAKA,OAAO,CAACC,SAAS,CAACH,EAAE,CAACI,OAAO,CAACJ,EAAE,CAAC,CAAC;EACjE;EACAK,oBAAoB,CAACL,EAAS,EAAuB;IACnD,OAAO,IAAI,CAACC,IAAI,CAAEC,OAAO,IAAKA,OAAO,CAACC,SAAS,CAACH,EAAE,CAACM,OAAO,CAACF,OAAO,CAACJ,EAAE,CAAC,CAAC;EACzE;EACAO,uBAAuB,CAACP,EAAe,EAAuB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AMQ,IAAI,GAAG,MAAMT,WAAW,CAACU,wBAAwB,CAACL,IAAI,CAAC;MAC7DI,IAAI,CAACL,OAAO,CAAEO,GAAG,IAAK;QACpB,MAAMC,SAAS,GAAGD,GAAG,CAACE,WAAW;QACjC,IAAIX,KAAK,CAACY,OAAO,CAACF,SAAS,CAACJ,QAAQ,EAAE,CAAC,EAAE;UACvCN,KAAK,CAACa,OAAO,CAAC,KAAIC,aAAI,EAACX,IAAI,CAAC3B,EAAE,CAAC8B,QAAQ,EAAE,EAAEI,SAAS,CAACJ,QAAQ,EAAE,EAAEG,GAAG,CAACM,SAAS,CAAC,CAAC;QAClF;MACF,CAAC,CAAC;IACJ;IAEA,MAAMC,aAAa,GAAGhB,KAAK,CAACH,QAAQ,CAAC,IAAI,CAAC;IAC1C;IACA,MAAMoB,cAAyB,GAAGD,aAAa,CAAC5B,GAAG,CAAE8B,IAAqB,IAAK,IAAI,CAAC3C,UAAU,CAAC2C,IAAI,CAACC,IAAI,CAAC3C,EAAE,CAAE,CAAC;IAC9G,OAAOH,WAAW,CAAC+C,SAAS,CAACH,cAAc,CAAC;EAC9C;EACA,OAAOG,SAAS,CAACC,QAAmB,EAAE;IACpC,OAAO,IAAIhD,WAAW,CAAC,GAAGgD,QAAQ,CAAC;EACrC;AACF;AAAC"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/isolator",
3
- "version": "0.0.917",
3
+ "version": "0.0.918",
4
4
  "homepage": "https://bit.dev/teambit/component/isolator",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.component",
8
8
  "name": "isolator",
9
- "version": "0.0.917"
9
+ "version": "0.0.918"
10
10
  },
11
11
  "dependencies": {
12
12
  "fs-extra": "10.0.0",
@@ -23,16 +23,17 @@
23
23
  "execa": "2.1.0",
24
24
  "@babel/runtime": "7.20.0",
25
25
  "core-js": "^3.0.0",
26
+ "@teambit/graph.cleargraph": "0.0.1",
26
27
  "@teambit/harmony": "0.3.3",
27
- "@teambit/component": "0.0.917",
28
+ "@teambit/component": "0.0.918",
29
+ "@teambit/dependency-resolver": "0.0.918",
28
30
  "@teambit/legacy-bit-id": "0.0.421",
29
- "@teambit/aspect-loader": "0.0.917",
30
- "@teambit/cli": "0.0.613",
31
+ "@teambit/aspect-loader": "0.0.918",
32
+ "@teambit/cli": "0.0.614",
31
33
  "@teambit/component-package-version": "0.0.421",
32
- "@teambit/dependency-resolver": "0.0.917",
33
- "@teambit/global-config": "0.0.615",
34
- "@teambit/graph": "0.0.917",
35
- "@teambit/logger": "0.0.706"
34
+ "@teambit/global-config": "0.0.616",
35
+ "@teambit/graph": "0.0.918",
36
+ "@teambit/logger": "0.0.707"
36
37
  },
37
38
  "devDependencies": {
38
39
  "@types/react": "^17.0.8",
@@ -48,7 +49,7 @@
48
49
  "@types/node": "12.20.4"
49
50
  },
50
51
  "peerDependencies": {
51
- "@teambit/legacy": "1.0.391",
52
+ "@teambit/legacy": "1.0.395",
52
53
  "react-dom": "^16.8.0 || ^17.0.0",
53
54
  "react": "^16.8.0 || ^17.0.0"
54
55
  },
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_isolator@0.0.917/dist/isolator.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_isolator@0.0.917/dist/isolator.docs.md';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_isolator@0.0.918/dist/isolator.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_isolator@0.0.918/dist/isolator.docs.md';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];