@teambit/isolator 1.0.226 → 1.0.228

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.
@@ -41,6 +41,21 @@ class CapsuleList extends Array {
41
41
  getAllComponents() {
42
42
  return this.map(c => c.component);
43
43
  }
44
+ getGraphIds() {
45
+ const components = this.getAllComponents();
46
+ const graph = new (_graph().Graph)();
47
+ components.forEach(comp => graph.setNode(new (_graph().Node)(comp.id.toString(), comp)));
48
+ const compIdsStr = components.map(c => c.id.toString());
49
+ components.forEach(comp => {
50
+ const deps = comp.getDependencies();
51
+ deps.forEach(dep => {
52
+ if (compIdsStr.includes(dep.id)) {
53
+ graph.setEdge(new (_graph().Edge)(comp.id.toString(), dep.id, dep.type));
54
+ }
55
+ });
56
+ });
57
+ return graph;
58
+ }
44
59
  // Sort the capsules by their dependencies. The capsules with no dependencies will be first. Returns a new array.
45
60
  async toposort(depResolver) {
46
61
  const components = this.getAllComponents();
@@ -1 +1 @@
1
- {"version":3,"names":["_graph","data","require","_path","CapsuleList","Array","getCapsule","id","find","capsule","component","isEqual","getCapsuleByLegacyId","getCapsuleIgnoreVersion","ignoreVersion","getAllCapsuleDirs","map","path","getIdByPathInCapsule","pathInCapsule","normalizedPathInCapsule","normalize","found","getAllComponents","c","toposort","depResolver","components","graph","Graph","forEach","comp","setNode","Node","getPackageName","node","nodes","deps","getDependencies","attr","dep","depPkgName","hasNode","setEdge","Edge","lifecycle","sortedSeeders","sortedCapsules","fromArray","capsules","capsuleUsePreviouslySavedDists","isModified","buildStatus","exports","default"],"sources":["capsule-list.ts"],"sourcesContent":["import type { Component } from '@teambit/component';\nimport { Dependency, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { Edge, Graph, Node } from '@teambit/graph.cleargraph';\nimport { ComponentID } from '@teambit/component-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: ComponentID): Capsule | undefined {\n return this.find((capsule) => capsule.component.id.isEqual(id));\n }\n getCapsuleIgnoreVersion(id: ComponentID): Capsule | undefined {\n return this.find((capsule) => capsule.component.id.isEqual(id, { ignoreVersion: true }));\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 // Build a graph with all the components from the current capsule list\n components.forEach((comp: Component) => graph.setNode(new Node(depResolver.getPackageName(comp), comp)));\n\n // Add edges between the components according to their interdependencies\n for (const node of graph.nodes) {\n // eslint-disable-next-line no-await-in-loop\n const deps = await depResolver.getDependencies(node.attr);\n deps.forEach((dep: Dependency) => {\n const depPkgName = dep.getPackageName?.();\n if (depPkgName && graph.hasNode(depPkgName)) {\n graph.setEdge(new Edge(node.id, depPkgName, 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 * determines whether or not a capsule can theoretically use the dists saved in the last snap, rather than re-compile them.\n * practically, this optimization is used for components that have typescript as their compiler.\n */\n static async capsuleUsePreviouslySavedDists(component: Component): Promise<boolean> {\n const isModified = await component.isModified();\n return component.buildStatus === 'succeed' && !isModified;\n }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EAAE;IACpC,OAAO,IAAI7C,WAAW,CAAC,GAAG6C,QAAQ,CAAC;EACrC;EACA;AACF;AACA;AACA;EACE,aAAaC,8BAA8BA,CAACxC,SAAoB,EAAoB;IAClF,MAAMyC,UAAU,GAAG,MAAMzC,SAAS,CAACyC,UAAU,CAAC,CAAC;IAC/C,OAAOzC,SAAS,CAAC0C,WAAW,KAAK,SAAS,IAAI,CAACD,UAAU;EAC3D;AACF;AAACE,OAAA,CAAAC,OAAA,GAAAlD,WAAA","ignoreList":[]}
1
+ {"version":3,"names":["_graph","data","require","_path","CapsuleList","Array","getCapsule","id","find","capsule","component","isEqual","getCapsuleByLegacyId","getCapsuleIgnoreVersion","ignoreVersion","getAllCapsuleDirs","map","path","getIdByPathInCapsule","pathInCapsule","normalizedPathInCapsule","normalize","found","getAllComponents","c","getGraphIds","components","graph","Graph","forEach","comp","setNode","Node","toString","compIdsStr","deps","getDependencies","dep","includes","setEdge","Edge","type","toposort","depResolver","getPackageName","node","nodes","attr","depPkgName","hasNode","lifecycle","sortedSeeders","sortedCapsules","fromArray","capsules","capsuleUsePreviouslySavedDists","isModified","buildStatus","exports","default"],"sources":["capsule-list.ts"],"sourcesContent":["import type { Component } from '@teambit/component';\nimport { Dependency, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { Edge, Graph, Node } from '@teambit/graph.cleargraph';\nimport { ComponentID } from '@teambit/component-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: ComponentID): Capsule | undefined {\n return this.find((capsule) => capsule.component.id.isEqual(id));\n }\n getCapsuleIgnoreVersion(id: ComponentID): Capsule | undefined {\n return this.find((capsule) => capsule.component.id.isEqual(id, { ignoreVersion: true }));\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 getGraphIds(): Graph<Component, string> {\n const components = this.getAllComponents();\n const graph = new Graph<Component, string>();\n\n components.forEach((comp: Component) => graph.setNode(new Node(comp.id.toString(), comp)));\n const compIdsStr = components.map((c) => c.id.toString());\n\n components.forEach((comp) => {\n const deps = comp.getDependencies();\n deps.forEach((dep) => {\n if (compIdsStr.includes(dep.id)) {\n graph.setEdge(new Edge(comp.id.toString(), dep.id, dep.type));\n }\n });\n });\n\n return graph;\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 // Build a graph with all the components from the current capsule list\n components.forEach((comp: Component) => graph.setNode(new Node(depResolver.getPackageName(comp), comp)));\n\n // Add edges between the components according to their interdependencies\n for (const node of graph.nodes) {\n // eslint-disable-next-line no-await-in-loop\n const deps = await depResolver.getDependencies(node.attr);\n deps.forEach((dep: Dependency) => {\n const depPkgName = dep.getPackageName?.();\n if (depPkgName && graph.hasNode(depPkgName)) {\n graph.setEdge(new Edge(node.id, depPkgName, 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 * determines whether or not a capsule can theoretically use the dists saved in the last snap, rather than re-compile them.\n * practically, this optimization is used for components that have typescript as their compiler.\n */\n static async capsuleUsePreviouslySavedDists(component: Component): Promise<boolean> {\n const isModified = await component.isModified();\n return component.buildStatus === 'succe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 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_isolator@1.0.226/dist/isolator.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_isolator@1.0.226/dist/isolator.docs.md';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_isolator@1.0.228/dist/isolator.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_isolator@1.0.228/dist/isolator.docs.md';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/isolator",
3
- "version": "1.0.226",
3
+ "version": "1.0.228",
4
4
  "homepage": "https://bit.cloud/teambit/component/isolator",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.component",
8
8
  "name": "isolator",
9
- "version": "1.0.226"
9
+ "version": "1.0.228"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
@@ -26,15 +26,15 @@
26
26
  "@teambit/component-id": "1.2.0",
27
27
  "@teambit/graph.cleargraph": "0.0.8",
28
28
  "@teambit/harmony": "0.4.6",
29
- "@teambit/component": "1.0.226",
30
- "@teambit/dependency-resolver": "1.0.226",
31
- "@teambit/aspect-loader": "1.0.226",
32
- "@teambit/cli": "0.0.859",
29
+ "@teambit/component": "1.0.228",
30
+ "@teambit/dependency-resolver": "1.0.228",
31
+ "@teambit/aspect-loader": "1.0.228",
32
+ "@teambit/cli": "0.0.861",
33
33
  "@teambit/component-package-version": "0.0.433",
34
34
  "@teambit/dependencies.fs.linked-dependencies": "0.0.9",
35
- "@teambit/global-config": "0.0.862",
36
- "@teambit/graph": "1.0.226",
37
- "@teambit/logger": "0.0.952",
35
+ "@teambit/global-config": "0.0.864",
36
+ "@teambit/graph": "1.0.228",
37
+ "@teambit/logger": "0.0.954",
38
38
  "@teambit/workspace.modules.node-modules-linker": "0.0.167"
39
39
  },
40
40
  "devDependencies": {
@@ -45,7 +45,7 @@
45
45
  "@types/uuid": "8.3.4",
46
46
  "@types/mocha": "9.1.0",
47
47
  "chai": "4.3.0",
48
- "@teambit/harmony.envs.core-aspect-env": "0.0.27"
48
+ "@teambit/harmony.envs.core-aspect-env": "0.0.30"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "react": "^17.0.0 || ^18.0.0",
package/tsconfig.json CHANGED
@@ -20,7 +20,8 @@
20
20
  "emitDeclarationOnly": true,
21
21
  "strict": true,
22
22
  "strictPropertyInitialization": false,
23
- "noImplicitAny": false
23
+ "noImplicitAny": false,
24
+ "composite": true
24
25
  },
25
26
  "exclude": [
26
27
  "artifacts",
@@ -35,5 +36,25 @@
35
36
  "include": [
36
37
  "**/*",
37
38
  "**/*.json"
39
+ ],
40
+ "references": [
41
+ {
42
+ "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@1.0.228"
43
+ },
44
+ {
45
+ "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_aspect-loader@1.0.228"
46
+ },
47
+ {
48
+ "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.861"
49
+ },
50
+ {
51
+ "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_global-config@0.0.864"
52
+ },
53
+ {
54
+ "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_graph@1.0.228"
55
+ },
56
+ {
57
+ "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_logger@0.0.954"
58
+ }
38
59
  ]
39
60
  }
@@ -1,75 +0,0 @@
1
- import { NodeFS } from '@teambit/any-fs';
2
- import { Capsule as CapsuleTemplate, Console, Exec, State } from '@teambit/capsule';
3
- import { Component } from '@teambit/component';
4
- import FsContainer, { BitExecOption } from './container';
5
- import ContainerExec from './container-exec';
6
- export default class Capsule extends CapsuleTemplate<Exec, NodeFS> {
7
- /**
8
- * container implementation the capsule is being executed within.
9
- */
10
- protected container: FsContainer;
11
- /**
12
- * the capsule's file system.
13
- */
14
- readonly fs: NodeFS;
15
- /**
16
- * console for controlling process streams as stdout, stdin and stderr.
17
- */
18
- readonly console: Console;
19
- /**
20
- * capsule's state.
21
- */
22
- readonly state: State;
23
- readonly component: Component;
24
- private _wrkDir;
25
- constructor(
26
- /**
27
- * container implementation the capsule is being executed within.
28
- */
29
- container: FsContainer,
30
- /**
31
- * the capsule's file system.
32
- */
33
- fs: NodeFS,
34
- /**
35
- * console for controlling process streams as stdout, stdin and stderr.
36
- */
37
- console: Console,
38
- /**
39
- * capsule's state.
40
- */
41
- state: State, component: Component);
42
- /**
43
- * @deprecated please use `this.path`
44
- */
45
- get wrkDir(): string;
46
- get path(): string;
47
- start(): Promise<any>;
48
- execNode(executable: string, args: any, exec: ContainerExec): Promise<ContainerExec>;
49
- typedExec(opts: BitExecOption, exec?: ContainerExec): Promise<ContainerExec>;
50
- outputFile(file: string, data: any, options?: any): Promise<any>;
51
- removePath(dir: string): Promise<any>;
52
- symlink(src: string, dest: string): Promise<any>;
53
- execute(cmd: string, options?: Record<string, any> | null | undefined): Promise<unknown>;
54
- /**
55
- * @todo: fix.
56
- * it skips the capsule fs because for some reason `capsule.fs.promises.readdir` doesn't work
57
- * the same as `capsule.fs.readdir` and it doesn't have the capsule dir as pwd.
58
- *
59
- * returns the paths inside the capsule
60
- */
61
- getAllFilesPaths(dir?: string, options?: {
62
- ignore?: string[];
63
- }): any;
64
- static getCapsuleDirName(component: Component, config?: {
65
- alwaysNew?: boolean;
66
- name?: string;
67
- }): string;
68
- static getCapsuleRootDir(component: Component, baseDir: string, config?: {
69
- alwaysNew?: boolean;
70
- name?: string;
71
- }): string;
72
- static createFromComponent(component: Component, baseDir: string, config?: {
73
- alwaysNew?: boolean;
74
- }): Promise<Capsule>;
75
- }
@@ -1,14 +0,0 @@
1
- /// <reference types="node" />
2
- import { DuplexBufferStream, Exec, ExecStatus } from '@teambit/capsule';
3
- import { EventEmitter } from 'events';
4
- export default class ContainerExec extends EventEmitter implements Exec {
5
- private _code;
6
- constructor(_code?: number);
7
- stdout: DuplexBufferStream;
8
- stderr: DuplexBufferStream;
9
- stdin: DuplexBufferStream;
10
- setStatus(status: number): void;
11
- get code(): number;
12
- inspect(): Promise<ExecStatus>;
13
- abort(): Promise<void>;
14
- }
@@ -1,35 +0,0 @@
1
- /// <reference types="node" />
2
- import { AnyFS, NodeFS } from '@teambit/any-fs';
3
- import { Container, ContainerFactoryOptions, ContainerStatus, Exec, ExecOptions } from '@teambit/capsule';
4
- import execa from 'execa';
5
- import { Stream } from 'stream';
6
- import ContainerExec from './container-exec';
7
- export interface BitExecOption extends ExecOptions {
8
- cwd: string;
9
- stdio?: 'pipe' | 'ipc' | 'ignore' | 'inherit' | Stream | number | undefined;
10
- }
11
- export interface BitContainerConfig extends ContainerFactoryOptions {
12
- other?: string;
13
- }
14
- export default class FsContainer implements Container<Exec, AnyFS> {
15
- readonly wrkDir: string;
16
- id: string;
17
- fs: NodeFS;
18
- constructor(wrkDir: string);
19
- getPath(): string;
20
- private composePath;
21
- outputFile(file: any, data: any, options: any): Promise<void>;
22
- removePath(dir: string): Promise<any>;
23
- symlink(src: string, dest: string): Promise<any>;
24
- exec(execOptions: BitExecOption, exec?: ContainerExec): Promise<ContainerExec>;
25
- execP(execOptions: BitExecOption): Promise<string>;
26
- terminal(): Promise<execa.ExecaReturnValue<string>>;
27
- start(): Promise<void>;
28
- inspect(): Promise<ContainerStatus>;
29
- pause(): Promise<void>;
30
- resume(): Promise<void>;
31
- stop(ttl?: number | undefined): Promise<void>;
32
- destroy(): Promise<void>;
33
- log(): Promise<Exec>;
34
- on(event: string, fn: (data: any) => void): void;
35
- }
@@ -1,3 +0,0 @@
1
- export { default as Capsule } from './capsule';
2
- export { default as FsContainer } from './container';
3
- export { default as ContainerExec } from './container-exec';
@@ -1,19 +0,0 @@
1
- import type { Component } from '@teambit/component';
2
- import { DependencyResolverMain } from '@teambit/dependency-resolver';
3
- import { ComponentID } from '@teambit/component-id';
4
- import { Capsule } from './capsule';
5
- export default class CapsuleList extends Array<Capsule> {
6
- getCapsule(id: ComponentID): Capsule | undefined;
7
- getCapsuleByLegacyId(id: ComponentID): Capsule | undefined;
8
- getCapsuleIgnoreVersion(id: ComponentID): Capsule | undefined;
9
- getAllCapsuleDirs(): string[];
10
- getIdByPathInCapsule(pathInCapsule: string): ComponentID | null;
11
- getAllComponents(): Component[];
12
- toposort(depResolver: DependencyResolverMain): Promise<CapsuleList>;
13
- static fromArray(capsules: Capsule[]): CapsuleList;
14
- /**
15
- * determines whether or not a capsule can theoretically use the dists saved in the last snap, rather than re-compile them.
16
- * practically, this optimization is used for components that have typescript as their compiler.
17
- */
18
- static capsuleUsePreviouslySavedDists(component: Component): Promise<boolean>;
19
- }
package/dist/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export { CAPSULE_READY_FILE } from './isolator.main.runtime';
2
- export { Network } from './network';
3
- export { FsContainer, Capsule, ContainerExec } from './capsule';
4
- export type { IsolatorMain, IsolateComponentsOptions } from './isolator.main.runtime';
5
- export { IsolatorAspect } from './isolator.aspect';
6
- export { default as CapsuleList } from './capsule-list';
@@ -1,2 +0,0 @@
1
- import { Aspect } from '@teambit/harmony';
2
- export declare const IsolatorAspect: Aspect;
@@ -1 +0,0 @@
1
- export declare const Logo: () => import("react/jsx-runtime").JSX.Element;
@@ -1,264 +0,0 @@
1
- import { CLIMain } from '@teambit/cli';
2
- import { AspectLoaderMain } from '@teambit/aspect-loader';
3
- import { Component } from '@teambit/component';
4
- import type { ComponentMain, ComponentFactory } from '@teambit/component';
5
- import { GraphMain } from '@teambit/graph';
6
- import { SlotRegistry } from '@teambit/harmony';
7
- import { DependencyResolverMain, LinkingOptions, NodeLinker } from '@teambit/dependency-resolver';
8
- import { Logger, LoggerMain } from '@teambit/logger';
9
- import { ComponentID, ComponentIdList } from '@teambit/component-id';
10
- import LegacyScope from '@teambit/legacy/dist/scope/scope';
11
- import { GlobalConfigMain } from '@teambit/global-config';
12
- import { PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';
13
- import { Scope } from '@teambit/legacy/dist/scope';
14
- import DataToPersist from '@teambit/legacy/dist/consumer/component/sources/data-to-persist';
15
- import { Capsule } from './capsule';
16
- import { Network } from './network';
17
- export type ListResults = {
18
- capsules: string[];
19
- };
20
- export type CapsuleTransferFn = (sourceDir: string, targetDir: string) => Promise<void>;
21
- export type CapsuleTransferSlot = SlotRegistry<CapsuleTransferFn>;
22
- /**
23
- * Context for the isolation process
24
- */
25
- export type IsolationContext = {
26
- /**
27
- * Whether the isolation done for aspects (as opposed to regular components)
28
- */
29
- aspects?: boolean;
30
- /**
31
- * Workspace name where the isolation starts from
32
- */
33
- workspaceName?: string;
34
- };
35
- export type IsolateComponentsInstallOptions = {
36
- installPackages?: boolean;
37
- dedupe?: boolean;
38
- copyPeerToRuntimeOnComponents?: boolean;
39
- copyPeerToRuntimeOnRoot?: boolean;
40
- installPeersFromEnvs?: boolean;
41
- installTeambitBit?: boolean;
42
- packageManagerConfigRootDir?: string;
43
- useNesting?: boolean;
44
- };
45
- type CreateGraphOptions = {
46
- /**
47
- * include components that exists in nested hosts. for example include components that exist in scope but not in the workspace
48
- */
49
- includeFromNestedHosts?: boolean;
50
- /**
51
- * Force specific host to get the component from.
52
- */
53
- host?: ComponentFactory;
54
- };
55
- export type IsolateComponentsOptions = CreateGraphOptions & {
56
- name?: string;
57
- /**
58
- * absolute path to put all the capsules dirs inside.
59
- */
60
- rootBaseDir?: string;
61
- /**
62
- * the capsule root-dir based on a *hash* of this baseDir, not on the baseDir itself.
63
- * A folder with this hash as its name will be created in the rootBaseDir
64
- * By default this value will be the host path
65
- */
66
- baseDir?: string;
67
- /**
68
- * Whether to use hash function (of base dir) as capsules root dir name
69
- */
70
- useHash?: boolean;
71
- /**
72
- * create a new capsule with a random string attached to the path suffix
73
- */
74
- alwaysNew?: boolean;
75
- /**
76
- * If this is true -
77
- * the isolator will check if there are missing capsules in the base dir
78
- * if yes, it will create the capsule in a special dir inside a dir with the current date (without time)
79
- * then inside that dir, it will create a dir with a random hash
80
- * at the end of the process it will move missing capsules from the temp dir to the base dir so they can be used in
81
- * the next iteration
82
- */
83
- useDatedDirs?: boolean;
84
- /**
85
- * If this is true -
86
- * the isolator will do few things:
87
- * 1. in the end of the process it will only move the lock file (pnpm-lock.yaml) into the capsule cache
88
- * 2. in the beginning of the process it will check if there is a lock file in the capsule cache, if yes it will move
89
- * it to the temp dated dir
90
- * 3. it will write env's file into the dated dir (as it only contain the lock file)
91
- * 4. it will run install in the dated dir (as there is no node_modules there yet)
92
- */
93
- cacheLockFileOnly?: boolean;
94
- /**
95
- * If set, along with useDatedDirs, then we will use the same hash dir for all capsules created with the same
96
- * datedDirId
97
- */
98
- datedDirId?: string;
99
- /**
100
- * installation options
101
- */
102
- installOptions?: IsolateComponentsInstallOptions;
103
- linkingOptions?: LinkingOptions;
104
- /**
105
- * delete the capsule rootDir first. it makes sure that the isolation process starts fresh with
106
- * no previous capsules. for build and tag this is true.
107
- */
108
- emptyRootDir?: boolean;
109
- /**
110
- * skip the reproduction of the capsule in case it exists.
111
- */
112
- skipIfExists?: boolean;
113
- /**
114
- * get existing capsule without doing any changes, no writes, no installations.
115
- */
116
- getExistingAsIs?: boolean;
117
- /**
118
- * place the package-manager cache on the capsule-root
119
- */
120
- cachePackagesOnCapsulesRoot?: boolean;
121
- /**
122
- * do not build graph with all dependencies. isolate the seeders only.
123
- */
124
- seedersOnly?: boolean;
125
- /**
126
- * relevant for tagging from scope, where we tag an existing snap without any code-changes.
127
- * the idea is to have all build artifacts from the previous snap and run deploy pipeline on top of it.
128
- */
129
- populateArtifactsFrom?: ComponentID[];
130
- /**
131
- * Force specific host to get the component from.
132
- */
133
- host?: ComponentFactory;
134
- /**
135
- * Use specific package manager for the isolation process (override the package manager from the dep resolver config)
136
- */
137
- packageManager?: string;
138
- /**
139
- * Use specific node linker for the isolation process (override the package manager from the dep resolver config)
140
- */
141
- nodeLinker?: NodeLinker;
142
- /**
143
- * Dir where to read the package manager config from
144
- * usually used when running package manager in the capsules dir to use the config
145
- * from the workspace dir
146
- */
147
- packageManagerConfigRootDir?: string;
148
- context?: IsolationContext;
149
- /**
150
- * Root dir of capsulse cache (used mostly to copy lock file if used with cache lock file only option)
151
- */
152
- cacheCapsulesDir?: string;
153
- };
154
- type GetCapsuleDirOpts = Pick<IsolateComponentsOptions, 'datedDirId' | 'useHash' | 'rootBaseDir' | 'useDatedDirs' | 'cacheLockFileOnly'> & {
155
- baseDir: string;
156
- };
157
- /**
158
- * File name to indicate that the capsule is ready (all packages are installed and links are created)
159
- */
160
- export declare const CAPSULE_READY_FILE = ".bit-capsule-ready";
161
- export declare class IsolatorMain {
162
- private dependencyResolver;
163
- private logger;
164
- private componentAspect;
165
- private graph;
166
- private cli;
167
- private globalConfig;
168
- private aspectLoader;
169
- private capsuleTransferSlot;
170
- static runtime: import("@teambit/harmony").RuntimeDefinition;
171
- static dependencies: import("@teambit/harmony").Aspect[];
172
- static slots: ((registerFn: () => string) => SlotRegistry<CapsuleTransferFn>)[];
173
- static defaultConfig: {};
174
- _componentsPackagesVersionCache: {
175
- [idStr: string]: string;
176
- };
177
- _datedHashForName: Map<string, string>;
178
- _movedLockFiles: Set<unknown>;
179
- static provider([dependencyResolver, loggerExtension, componentAspect, graphMain, globalConfig, aspectLoader, cli]: [
180
- DependencyResolverMain,
181
- LoggerMain,
182
- ComponentMain,
183
- GraphMain,
184
- GlobalConfigMain,
185
- AspectLoaderMain,
186
- CLIMain
187
- ], _config: any, [capsuleTransferSlot]: [CapsuleTransferSlot]): Promise<IsolatorMain>;
188
- constructor(dependencyResolver: DependencyResolverMain, logger: Logger, componentAspect: ComponentMain, graph: GraphMain, cli: CLIMain, globalConfig: GlobalConfigMain, aspectLoader: AspectLoaderMain, capsuleTransferSlot: CapsuleTransferSlot);
189
- isolateComponents(seeders: ComponentID[], opts: IsolateComponentsOptions, legacyScope?: LegacyScope): Promise<Network>;
190
- private createGraph;
191
- private registerMoveCapsuleOnProcessExit;
192
- private getAllCapsulesDirsFromRoot;
193
- private moveCapsulesLockFileToTargetDir;
194
- private moveCapsulesToTargetDir;
195
- /**
196
- * The function moves a directory from a source location to a target location using a temporary directory.
197
- * This is using temp dir because sometime the source dir and target dir might be in different FS
198
- * (for example different mounts) which means the move might take a long time
199
- * during the time of moving, another process will see that the capsule is not ready and will try to remove then
200
- * move it again, which lead to the first process throwing an error
201
- * @param sourceDir - The source directory from where the files or directories will be moved.
202
- * @param targetDir - The target directory where the source directory will be moved to.
203
- */
204
- private moveWithTempName;
205
- /**
206
- * Re-create the core aspects links in the real capsule dir
207
- * This is required mainly for the first time when that folder is empty
208
- */
209
- private relinkCoreAspectsInCapsuleDir;
210
- private shouldUseDatedDirs;
211
- /**
212
- *
213
- * @param originalCapsule the capsule that contains the original component
214
- * @param newBaseDir relative path. (it will be saved inside `this.getRootDirOfAllCapsules()`. the final path of the capsule will be getRootDirOfAllCapsules() + newBaseDir + filenameify(component.id))
215
- * @returns a new capsule with the same content of the original capsule but with a new baseDir and all packages
216
- * installed in the newBaseDir.
217
- */
218
- cloneCapsule(originalCapsule: Capsule, newBaseDir: string): Promise<Capsule>;
219
- /**
220
- * Create capsules for the provided components
221
- * do not use this outside directly, use isolate components which build the entire network
222
- * @param components
223
- * @param opts
224
- * @param legacyScope
225
- */
226
- private createCapsules;
227
- private markCapsulesAsReady;
228
- private markCapsuleAsReady;
229
- private removeCapsuleReadyFileSync;
230
- private writeCapsuleReadyFileSync;
231
- private getCapsuleReadyFilePath;
232
- private installInCapsules;
233
- private linkInCapsules;
234
- private linkInCapsulesRoot;
235
- private toLocalLinks;
236
- private linkDetailToLocalDepEntry;
237
- private getCapsulesWithModifiedPackageJson;
238
- private writeComponentsInCapsules;
239
- private getWorkspacePeersOnlyPolicy;
240
- private toComponentMap;
241
- list(rootDir: string): Promise<ListResults>;
242
- registerCapsuleTransferFn(fn: CapsuleTransferFn): void;
243
- private getCapsuleTransferFn;
244
- private getDefaultCapsuleTransferFn;
245
- /** @deprecated use the new function signature with an object parameter instead */
246
- getCapsulesRootDir(baseDir: string, rootBaseDir?: string, useHash?: boolean): PathOsBasedAbsolute;
247
- getCapsulesRootDir(getCapsuleDirOpts: GetCapsuleDirOpts): PathOsBasedAbsolute;
248
- deleteCapsules(rootDir?: string): Promise<string>;
249
- private createCapsulesFromComponents;
250
- private getRootDirOfAllCapsules;
251
- private wereDependenciesInPackageJsonChanged;
252
- private getCapsulesPreviousPackageJson;
253
- private updateWithCurrentPackageJsonData;
254
- private getCurrentPackageJson;
255
- populateComponentsFilesToWriteForCapsule(component: Component, ids: ComponentIdList, legacyScope?: Scope, opts?: IsolateComponentsOptions): Promise<DataToPersist>;
256
- private preparePackageJsonToWrite;
257
- /**
258
- * currently, it writes all artifacts.
259
- * later, this responsibility might move to pkg extension, which could write only artifacts
260
- * that are set in package.json.files[], to have a similar structure of a package.
261
- */
262
- private getArtifacts;
263
- }
264
- export {};