@teambit/isolator 1.0.228 → 1.0.229

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,75 @@
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
+ }
@@ -0,0 +1,14 @@
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
+ }
@@ -0,0 +1,35 @@
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
+ }
@@ -0,0 +1,3 @@
1
+ export { default as Capsule } from './capsule';
2
+ export { default as FsContainer } from './container';
3
+ export { default as ContainerExec } from './container-exec';
@@ -0,0 +1,21 @@
1
+ import type { Component } from '@teambit/component';
2
+ import { DependencyResolverMain } from '@teambit/dependency-resolver';
3
+ import { Graph } from '@teambit/graph.cleargraph';
4
+ import { ComponentID } from '@teambit/component-id';
5
+ import { Capsule } from './capsule';
6
+ export default class CapsuleList extends Array<Capsule> {
7
+ getCapsule(id: ComponentID): Capsule | undefined;
8
+ getCapsuleByLegacyId(id: ComponentID): Capsule | undefined;
9
+ getCapsuleIgnoreVersion(id: ComponentID): Capsule | undefined;
10
+ getAllCapsuleDirs(): string[];
11
+ getIdByPathInCapsule(pathInCapsule: string): ComponentID | null;
12
+ getAllComponents(): Component[];
13
+ getGraphIds(): Graph<Component, string>;
14
+ toposort(depResolver: DependencyResolverMain): Promise<CapsuleList>;
15
+ static fromArray(capsules: Capsule[]): CapsuleList;
16
+ /**
17
+ * determines whether or not a capsule can theoretically use the dists saved in the last snap, rather than re-compile them.
18
+ * practically, this optimization is used for components that have typescript as their compiler.
19
+ */
20
+ static capsuleUsePreviouslySavedDists(component: Component): Promise<boolean>;
21
+ }
@@ -0,0 +1,6 @@
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';
@@ -0,0 +1,2 @@
1
+ import { Aspect } from '@teambit/harmony';
2
+ export declare const IsolatorAspect: Aspect;
@@ -0,0 +1 @@
1
+ export declare const Logo: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,264 @@
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 {};
@@ -0,0 +1,122 @@
1
+ import { ComponentID } from '@teambit/component';
2
+ import { PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';
3
+ import CapsuleList from './capsule-list';
4
+ /**
5
+ * collection of isolated components (capsules).
6
+ * normally, "seeders" are the components that this network was created for.
7
+ * "graphCapsules" is the graph created from the seeders and it includes also the dependencies.
8
+ *
9
+ * however, during "bit build"/"bit tag"/"bit snap", things are more complex because there is one more variable in the
10
+ * picture, which is the "env". the Network is created per env.
11
+ * in practice, for "build-task", a task is called per env, and the network passed to the task is relevant to that env.
12
+ * the "originalSeeders" are the ones the network was created for, but only for this env.
13
+ * the "seeders" are similar to the "graphCapsules" above, which contains also the dependencies, but only for this env.
14
+ * the "graphCapsules" is the entire graph, including capsules from other envs.
15
+ *
16
+ * for example:
17
+ * comp1 depends on comp2. comp1 env is "react". comp2 env is "aspect".
18
+ *
19
+ * when the user is running "bit build comp1", two `Network` instances will be created with the following:
20
+ * Network for "react" env: originalSeeders: ['comp1'], seeders: ['comp1'], graphCapsules: ['comp1', 'comp2'].
21
+ * Network for "aspect" env: originalSeeders: [], seeders: ['comp2'], graphCapsules: ['comp2'].
22
+ *
23
+ * on the other hand, when the user is running "bit capsule create comp1", only one `Network` instance is created:
24
+ * Network: originalSeeders: ['comp1'], seeders: ['comp1'], graphCapsules: ['comp1', 'comp2'].
25
+ *
26
+ * (as a side note, another implementation was attempt to have the "seeders" as the original-seeders for build,
27
+ * however, it's failed. see https://github.com/teambit/bit/pull/5407 for more details).
28
+ *
29
+ *
30
+ * A more detailed explanation about the "seeders" vs "originalSeeders" vs "graphCapsules" is provided below:
31
+ * an example: comp1 -> comp2 -> comp3 (as in comp1 uses comp2, comp2 uses comp3).
32
+ * I changed only comp2.
33
+ * From comp2 perspective, comp1 is a “dependent”, comp3 is a “dependency”.
34
+ *
35
+ * When I run bit build with no args, it finds only one modified component: comp2, however, it doesn’t stop here. It also look for the dependents, in this case, comp1. So the seeders of this bit-build command are two: “comp1” and “comp2".
36
+ * The reason why the dependents are included is because you modified comp2, it’s possible you broke comp1. We want to build comp1 as well to make sure it’s still okay.
37
+ * (btw, bit test command also include dependents when it provided with no args).
38
+ *
39
+ * Keep in mind that also bit tag normally runs on the dependents as well (when it runs the build pipeline), because these are the “auto-tag”.
40
+ * With these two seeders it builds the graph. The graph calculates all the dependencies of the given seeders recursively. Eventually, it puts them in an instance of Network class.
41
+ * In our case, if all components use the same env, the Network consist of:
42
+ * seedersCapsules: [comp1, comp2]
43
+ * originalSeedersCapsules: [comp1, comp2]
44
+ * graphCapsules: [comp1, comp2, comp3].
45
+ *
46
+ * It gets more complex when multiple envs involved.
47
+ * Imagine that comp1 uses env1, comp2 uses env2 and comp3 uses env3.
48
+ * Because bit build runs the tasks per env, it needs to create 3 networks. Each per env.
49
+ * The “seeders” refer to the seeders of the same env and includes only components from the same env.
50
+ * The “originalSeeders” refer to the ones that originally started the build command and are from the same env.
51
+ * Network1:
52
+ * seedersCapsules: [comp1]
53
+ * originalSeedersCapsules: [comp1]
54
+ * graphCapsules: [comp1, comp2, comp3].
55
+ * Network2:
56
+ * seedersCapsules: [comp2]
57
+ * originalSeedersCapsules: [comp2]
58
+ * graphCapsules: [comp2, comp3].
59
+ * Network3:
60
+ * seedersCapsules: [comp3]
61
+ * originalSeedersCapsules: []
62
+ * graphCapsules: [comp3].
63
+ * As you can see, in network3, the originalSeeders is empty, because comp3 wasn’t part of the original seeders.
64
+ * These 3 networks are created for build-pipeline. This pipeline asks for all components in the graph and then create the network per env.
65
+ * Snap/Tag pipelines are different. They ask only for the components about to tag/snap, which are the original-seeders, and create the network per env. For them, we end up with 2 network instances only. network1 and network2. Also, the seedersCapsules and originalSeedersCapsules are the same because we create the network instances out of the seeders only, without the dependencies.
66
+ * A build-task provides context with a network instance to the execute() method. (it also provide Component[] which are the “seeders”. not “originalSeeders”).
67
+ *
68
+ * Each build-task can decide on what components to operate. It has 3 options:
69
+ * run on graphCapsules. If you do that, you risk running your task multiple times on the same components. In the example above, a task of build-pipeline, will run 3 times on comp3, because this component is part of the graphCapsules in each one of the network instance. So this is probably not recommended for most tasks.
70
+ * run on seedersCapsules. With this option you make sure that your task is running for each one of the capsules and it runs only once. This is good for example for the compiler task. It needs to make sure all capsules are built. Otherwise, if it’s running only on originalSeedersCapsules, the comp3 won’t be compiled, the dists will be missing and comp2 won’t be able to run its tests.
71
+ * run on originalSeedersCapsules . With this option you ensure that your task runs only on the ids you started with and you don’t run them on the dependencies. This is the option that most tasks probably need. An example is the test task, it should test only the seeders, no need to test the dependencies.
72
+ *
73
+ * Again, the distinction between seedersCapsules and originalSeedersCapsules is relevant for build-pipeline only. For tag-pipeline and snap-pipeline, these two are the same. You can see for example that Publisher task runs on seedersCapsules and that’s fine, it won’t be running on dependencies unexpectedly, only on the components it’s now tagging.
74
+ */
75
+ export declare class Network {
76
+ private _graphCapsules;
77
+ private seedersIds;
78
+ private _capsulesRootDir;
79
+ _originalSeeders: ComponentID[] | undefined;
80
+ constructor(_graphCapsules: CapsuleList, seedersIds: ComponentID[], _capsulesRootDir: string);
81
+ /**
82
+ * for non build-tasks, this includes the original components the network was created for.
83
+ *
84
+ * for build-tasks (during bit build/tag/snap), this `Network` instance is created per env, and it depends on the pipeline.
85
+ * build-pipeline: includes the component graph (meaning include the dependencies) of the current env.
86
+ * snap/tag pipeline: it's the same as `this.originalSeedersCapsules`. it includes only the original to
87
+ * tag/snap/build of the current env.
88
+ *
89
+ * for example comp1 of env1 is using comp2 of env2. when running build/tag/snap on comp1 only, two networks are created
90
+ * for build pipeline:
91
+ * network1: seedersCapsules: [comp1], originalSeedersCapsules: [comp1], graphCapsules: [comp1, comp2]
92
+ * network2: seedersCapsules: [comp2], originalSeedersCapsules: [], graphCapsules: [comp2]
93
+ *
94
+ * for snap/tag pipeline, only network1 is created, and it includes only the originalSeedersCapsules.
95
+ *
96
+ * see the description of this Network class for more info.
97
+ */
98
+ get seedersCapsules(): CapsuleList;
99
+ /**
100
+ * for non build-tasks, this is the same as `this.seedersCapsules`, which includes the original components the
101
+ * network was created for.
102
+ *
103
+ * for build-tasks (during bit build/tag/snap), this includes the component to build/tag/snap of the current env.
104
+ * see the description of this Network class for more info.
105
+ */
106
+ get originalSeedersCapsules(): CapsuleList;
107
+ /**
108
+ * some of the capsules (non-modified) are written already with the dists files, so no need to re-compile them.
109
+ * this method helps optimizing compilers that are running on the capsules.
110
+ */
111
+ getCapsulesToCompile(): Promise<CapsuleList>;
112
+ /**
113
+ * originalSeeders are not always set (currently, only during build process), so if they're missing, just provide the
114
+ * seeders, which are probably the original-seeders
115
+ */
116
+ private getOriginalSeeders;
117
+ /**
118
+ * all capsules, including the dependencies of the seeders. (even when they belong to another env)
119
+ */
120
+ get graphCapsules(): CapsuleList;
121
+ get capsulesRootDir(): PathOsBasedAbsolute;
122
+ }
@@ -1,5 +1,5 @@
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';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_isolator@1.0.229/dist/isolator.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_isolator@1.0.229/dist/isolator.docs.md';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -0,0 +1,6 @@
1
+ import { LinkDetail } from '@teambit/dependency-resolver';
2
+ import { Logger } from '@teambit/logger';
3
+ import { Capsule } from './capsule';
4
+ import CapsuleList from './capsule-list';
5
+ export declare function symlinkDependenciesToCapsules(capsules: Capsule[], capsuleList: CapsuleList, logger: Logger): Promise<Record<string, Record<string, string>>>;
6
+ export declare function symlinkOnCapsuleRoot(capsuleList: CapsuleList, logger: Logger, capsuleRoot: string): Promise<LinkDetail[]>;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/isolator",
3
- "version": "1.0.228",
3
+ "version": "1.0.229",
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.228"
9
+ "version": "1.0.229"
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.228",
30
- "@teambit/dependency-resolver": "1.0.228",
31
- "@teambit/aspect-loader": "1.0.228",
32
- "@teambit/cli": "0.0.861",
29
+ "@teambit/component": "1.0.229",
30
+ "@teambit/dependency-resolver": "1.0.229",
31
+ "@teambit/aspect-loader": "1.0.229",
32
+ "@teambit/cli": "0.0.862",
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.864",
36
- "@teambit/graph": "1.0.228",
37
- "@teambit/logger": "0.0.954",
35
+ "@teambit/global-config": "0.0.865",
36
+ "@teambit/graph": "1.0.229",
37
+ "@teambit/logger": "0.0.955",
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.30"
48
+ "@teambit/harmony.envs.core-aspect-env": "0.0.33"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "react": "^17.0.0 || ^18.0.0",
package/tsconfig.json CHANGED
@@ -20,8 +20,7 @@
20
20
  "emitDeclarationOnly": true,
21
21
  "strict": true,
22
22
  "strictPropertyInitialization": false,
23
- "noImplicitAny": false,
24
- "composite": true
23
+ "noImplicitAny": false
25
24
  },
26
25
  "exclude": [
27
26
  "artifacts",
@@ -36,25 +35,5 @@
36
35
  "include": [
37
36
  "**/*",
38
37
  "**/*.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
- }
59
38
  ]
60
39
  }