@teambit/dependencies 1.0.227 → 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.
- package/artifacts/__bit_junit.xml +3 -3
- package/artifacts/schema.json +199 -53
- package/dist/dependencies-cmd.d.ts +169 -0
- package/dist/dependencies-loader/apply-overrides.d.ts +101 -0
- package/dist/dependencies-loader/auto-detect-deps.d.ts +164 -0
- package/dist/dependencies-loader/dependencies-data.d.ts +17 -0
- package/dist/dependencies-loader/dependencies-loader.d.ts +28 -0
- package/dist/dependencies-loader/dependencies-versions-resolver.d.ts +6 -0
- package/dist/dependencies-loader/index.d.ts +2 -0
- package/dist/dependencies-loader/overrides-dependencies.d.ts +17 -0
- package/dist/dependencies-loader/package-to-definetly-typed.d.ts +1 -0
- package/dist/dependencies-loader/package-to-definetly-typed.spec.d.ts +1 -0
- package/dist/dependencies.aspect.d.ts +2 -0
- package/dist/dependencies.main.runtime.d.ts +98 -0
- package/dist/dependencies.spec.d.ts +1 -0
- package/dist/index.d.ts +4 -0
- package/package.json +10 -10
- package/tsconfig.json +1 -22
- /package/dist/{preview-1712719054377.js → preview-1712822929999.js} +0 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { Command, CommandOptions } from '@teambit/cli';
|
|
2
|
+
import { DependenciesMain } from './dependencies.main.runtime';
|
|
3
|
+
type GetDependenciesFlags = {
|
|
4
|
+
tree: boolean;
|
|
5
|
+
scope?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export type SetDependenciesFlags = {
|
|
8
|
+
dev?: boolean;
|
|
9
|
+
optional?: boolean;
|
|
10
|
+
peer?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type RemoveDependenciesFlags = SetDependenciesFlags;
|
|
13
|
+
export declare class DependenciesGetCmd implements Command {
|
|
14
|
+
private deps;
|
|
15
|
+
name: string;
|
|
16
|
+
arguments: {
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
}[];
|
|
20
|
+
group: string;
|
|
21
|
+
description: string;
|
|
22
|
+
alias: string;
|
|
23
|
+
options: CommandOptions;
|
|
24
|
+
constructor(deps: DependenciesMain);
|
|
25
|
+
report([id]: [string], { tree, scope }: GetDependenciesFlags): Promise<any>;
|
|
26
|
+
}
|
|
27
|
+
export declare class DependenciesDebugCmd implements Command {
|
|
28
|
+
private deps;
|
|
29
|
+
name: string;
|
|
30
|
+
arguments: {
|
|
31
|
+
name: string;
|
|
32
|
+
description: string;
|
|
33
|
+
}[];
|
|
34
|
+
group: string;
|
|
35
|
+
description: string;
|
|
36
|
+
alias: string;
|
|
37
|
+
options: CommandOptions;
|
|
38
|
+
constructor(deps: DependenciesMain);
|
|
39
|
+
report([id]: [string]): Promise<string>;
|
|
40
|
+
}
|
|
41
|
+
export declare class DependenciesSetCmd implements Command {
|
|
42
|
+
private deps;
|
|
43
|
+
name: string;
|
|
44
|
+
arguments: {
|
|
45
|
+
name: string;
|
|
46
|
+
description: string;
|
|
47
|
+
}[];
|
|
48
|
+
group: string;
|
|
49
|
+
description: string;
|
|
50
|
+
alias: string;
|
|
51
|
+
options: CommandOptions;
|
|
52
|
+
constructor(deps: DependenciesMain);
|
|
53
|
+
report([pattern, packages]: [string, string[]], setDepsFlags: SetDependenciesFlags): Promise<string>;
|
|
54
|
+
}
|
|
55
|
+
export declare class DependenciesRemoveCmd implements Command {
|
|
56
|
+
private deps;
|
|
57
|
+
name: string;
|
|
58
|
+
arguments: {
|
|
59
|
+
name: string;
|
|
60
|
+
description: string;
|
|
61
|
+
}[];
|
|
62
|
+
group: string;
|
|
63
|
+
description: string;
|
|
64
|
+
alias: string;
|
|
65
|
+
options: CommandOptions;
|
|
66
|
+
constructor(deps: DependenciesMain);
|
|
67
|
+
report([pattern, packages]: [string, string[]], removeDepsFlags: RemoveDependenciesFlags): Promise<string>;
|
|
68
|
+
}
|
|
69
|
+
export declare class DependenciesUnsetCmd implements Command {
|
|
70
|
+
private deps;
|
|
71
|
+
name: string;
|
|
72
|
+
arguments: {
|
|
73
|
+
name: string;
|
|
74
|
+
description: string;
|
|
75
|
+
}[];
|
|
76
|
+
group: string;
|
|
77
|
+
description: string;
|
|
78
|
+
alias: string;
|
|
79
|
+
options: CommandOptions;
|
|
80
|
+
constructor(deps: DependenciesMain);
|
|
81
|
+
report([pattern, packages]: [string, string[]], removeDepsFlags: RemoveDependenciesFlags): Promise<string>;
|
|
82
|
+
}
|
|
83
|
+
export declare class DependenciesResetCmd implements Command {
|
|
84
|
+
private deps;
|
|
85
|
+
name: string;
|
|
86
|
+
arguments: {
|
|
87
|
+
name: string;
|
|
88
|
+
description: string;
|
|
89
|
+
}[];
|
|
90
|
+
group: string;
|
|
91
|
+
description: string;
|
|
92
|
+
alias: string;
|
|
93
|
+
options: CommandOptions;
|
|
94
|
+
constructor(deps: DependenciesMain);
|
|
95
|
+
report([pattern]: [string]): Promise<string>;
|
|
96
|
+
}
|
|
97
|
+
export declare class DependenciesEjectCmd implements Command {
|
|
98
|
+
private deps;
|
|
99
|
+
name: string;
|
|
100
|
+
arguments: {
|
|
101
|
+
name: string;
|
|
102
|
+
description: string;
|
|
103
|
+
}[];
|
|
104
|
+
group: string;
|
|
105
|
+
description: string;
|
|
106
|
+
alias: string;
|
|
107
|
+
options: CommandOptions;
|
|
108
|
+
constructor(deps: DependenciesMain);
|
|
109
|
+
report([pattern]: [string]): Promise<string>;
|
|
110
|
+
}
|
|
111
|
+
export declare class DependenciesBlameCmd implements Command {
|
|
112
|
+
private deps;
|
|
113
|
+
name: string;
|
|
114
|
+
arguments: {
|
|
115
|
+
name: string;
|
|
116
|
+
description: string;
|
|
117
|
+
}[];
|
|
118
|
+
group: string;
|
|
119
|
+
description: string;
|
|
120
|
+
alias: string;
|
|
121
|
+
options: CommandOptions;
|
|
122
|
+
constructor(deps: DependenciesMain);
|
|
123
|
+
report([compName, depName]: [string, string]): Promise<string>;
|
|
124
|
+
}
|
|
125
|
+
type DependenciesUsageCmdOptions = {
|
|
126
|
+
depth?: number;
|
|
127
|
+
};
|
|
128
|
+
export declare class DependenciesUsageCmd implements Command {
|
|
129
|
+
private deps;
|
|
130
|
+
name: string;
|
|
131
|
+
arguments: {
|
|
132
|
+
name: string;
|
|
133
|
+
description: string;
|
|
134
|
+
}[];
|
|
135
|
+
group: string;
|
|
136
|
+
description: string;
|
|
137
|
+
alias: string;
|
|
138
|
+
options: CommandOptions;
|
|
139
|
+
constructor(deps: DependenciesMain);
|
|
140
|
+
report([depName]: [string], options: DependenciesUsageCmdOptions): Promise<string>;
|
|
141
|
+
}
|
|
142
|
+
export declare class WhyCmd extends DependenciesUsageCmd {
|
|
143
|
+
name: string;
|
|
144
|
+
}
|
|
145
|
+
export declare class DependenciesCmd implements Command {
|
|
146
|
+
name: string;
|
|
147
|
+
alias: string;
|
|
148
|
+
description: string;
|
|
149
|
+
options: never[];
|
|
150
|
+
group: string;
|
|
151
|
+
commands: Command[];
|
|
152
|
+
helpUrl: string;
|
|
153
|
+
report([unrecognizedSubcommand]: [string]): Promise<string>;
|
|
154
|
+
}
|
|
155
|
+
export declare class SetPeerCmd implements Command {
|
|
156
|
+
private deps;
|
|
157
|
+
name: string;
|
|
158
|
+
arguments: {
|
|
159
|
+
name: string;
|
|
160
|
+
description: string;
|
|
161
|
+
}[];
|
|
162
|
+
group: string;
|
|
163
|
+
description: string;
|
|
164
|
+
alias: string;
|
|
165
|
+
options: never[];
|
|
166
|
+
constructor(deps: DependenciesMain);
|
|
167
|
+
report([componentId, range]: [string, string]): Promise<string>;
|
|
168
|
+
}
|
|
169
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ComponentID } from '@teambit/component-id';
|
|
2
|
+
import { IssuesList } from '@teambit/component-issues';
|
|
3
|
+
import Component from '@teambit/legacy/dist/consumer/component/consumer-component';
|
|
4
|
+
import { Workspace } from '@teambit/workspace';
|
|
5
|
+
import { Dependency } from '@teambit/legacy/dist/consumer/component/dependencies';
|
|
6
|
+
import { DependencyResolverMain } from '@teambit/dependency-resolver';
|
|
7
|
+
import Consumer from '@teambit/legacy/dist/consumer/consumer';
|
|
8
|
+
import OverridesDependencies from './overrides-dependencies';
|
|
9
|
+
import { DependenciesData } from './dependencies-data';
|
|
10
|
+
import { DebugDependencies } from './auto-detect-deps';
|
|
11
|
+
export type AllDependencies = {
|
|
12
|
+
dependencies: Dependency[];
|
|
13
|
+
devDependencies: Dependency[];
|
|
14
|
+
peerDependencies: Dependency[];
|
|
15
|
+
};
|
|
16
|
+
export type AllPackagesDependencies = {
|
|
17
|
+
packageDependencies: Record<string, string>;
|
|
18
|
+
devPackageDependencies: Record<string, string>;
|
|
19
|
+
peerPackageDependencies: Record<string, string>;
|
|
20
|
+
};
|
|
21
|
+
export declare class ApplyOverrides {
|
|
22
|
+
private component;
|
|
23
|
+
private depsResolver;
|
|
24
|
+
private workspace?;
|
|
25
|
+
componentId: ComponentID;
|
|
26
|
+
componentFromModel: Component;
|
|
27
|
+
allDependencies: AllDependencies;
|
|
28
|
+
allPackagesDependencies: AllPackagesDependencies;
|
|
29
|
+
/**
|
|
30
|
+
* This will store a copy of the package deps before removal
|
|
31
|
+
* in order to apply auto detected rules that are running after the removal
|
|
32
|
+
*/
|
|
33
|
+
originAllPackagesDependencies: AllPackagesDependencies;
|
|
34
|
+
issues: IssuesList;
|
|
35
|
+
coreAspects: string[];
|
|
36
|
+
processedFiles: string[];
|
|
37
|
+
overridesDependencies: OverridesDependencies;
|
|
38
|
+
debugDependenciesData: DebugDependencies;
|
|
39
|
+
autoDetectOverrides: Record<string, any> | undefined;
|
|
40
|
+
constructor(component: Component, depsResolver: DependencyResolverMain, workspace?: Workspace | undefined);
|
|
41
|
+
get consumer(): Consumer | undefined;
|
|
42
|
+
getDependenciesData(): Promise<{
|
|
43
|
+
dependenciesData: DependenciesData;
|
|
44
|
+
overridesDependencies: OverridesDependencies;
|
|
45
|
+
autoDetectOverrides?: Record<string, any>;
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* Given the tree of file dependencies from the driver, find the components of these files.
|
|
49
|
+
* Each dependency file has a path, use bit.map to search for the component name by that path.
|
|
50
|
+
* If the component is found, add it to "this.allDependencies.dependencies". Otherwise, add it to "this.issues.untrackedDependencies".
|
|
51
|
+
*
|
|
52
|
+
* For the found components, add their sourceRelativePath and destinationRelativePath, they are being used for
|
|
53
|
+
* generating links upon import:
|
|
54
|
+
* sourceRelativePath - location of the link file.
|
|
55
|
+
* destinationRelativePath - destination written inside the link file.
|
|
56
|
+
*
|
|
57
|
+
* When a dependency is found in a regular (implementation) file, it goes to `dependencies`. If
|
|
58
|
+
* it found on a test file, it goes to `devDependencies`.
|
|
59
|
+
* Similarly, when a package is found in a regular file, it goes to `packageDependencies`. When
|
|
60
|
+
* if found in a test file, it goes to `devPackageDependencies`.
|
|
61
|
+
* An exception for the above is when a package is required in a regular or test file but is also
|
|
62
|
+
* mentioned in the `package.json` file as a peerDependency, in that case, the package is added
|
|
63
|
+
* to `peerPackageDependencies` and removed from other places. Unless this package is overridden
|
|
64
|
+
* and marked as ignored in the consumer or component config file.
|
|
65
|
+
*/
|
|
66
|
+
private populateDependencies;
|
|
67
|
+
private removeIgnoredComponentsByOverrides;
|
|
68
|
+
private loadAutoDetectOverrides;
|
|
69
|
+
private cloneAllPackagesDependencies;
|
|
70
|
+
private removeIgnoredPackagesByOverrides;
|
|
71
|
+
private _resolvePackageData;
|
|
72
|
+
private _getComponentIdToAdd;
|
|
73
|
+
getDependenciesToAddManually(packageJson: Record<string, any> | null | undefined, existingDependencies: AllDependencies): {
|
|
74
|
+
components: Record<string, any>;
|
|
75
|
+
packages: Record<string, any>;
|
|
76
|
+
} | undefined;
|
|
77
|
+
private manuallyAddDependencies;
|
|
78
|
+
/**
|
|
79
|
+
* Remove the dependencies which appear both in dev and regular deps from the dev
|
|
80
|
+
* Because if a dependency is both dev dependency and regular dependency it should be treated as regular one
|
|
81
|
+
* Apply for both packages and components dependencies
|
|
82
|
+
*/
|
|
83
|
+
private removeDevAndEnvDepsIfTheyAlsoRegulars;
|
|
84
|
+
private applyPeersFromComponentModel;
|
|
85
|
+
private applyPackageJson;
|
|
86
|
+
private applyWorkspacePolicy;
|
|
87
|
+
/**
|
|
88
|
+
* It removes the @teambit/legacy dependency from the dependencies/devDeps and adds it as a peer dependency with ^.
|
|
89
|
+
*/
|
|
90
|
+
private makeLegacyAsPeer;
|
|
91
|
+
private applyAutoDetectOverridesOnComponent;
|
|
92
|
+
private applyAutoDetectedPeersFromEnvOnEnvItSelf;
|
|
93
|
+
/**
|
|
94
|
+
* returns `package.json` of the component when it's imported, or `package.json` of the workspace
|
|
95
|
+
* when it's authored.
|
|
96
|
+
*/
|
|
97
|
+
private _getPackageJson;
|
|
98
|
+
private _getPackageJsonFromComponentModel;
|
|
99
|
+
private setLegacyInsideHarmonyIssue;
|
|
100
|
+
private _pkgFieldMapping;
|
|
101
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { ComponentID } from '@teambit/component-id';
|
|
2
|
+
import { IssuesList } from '@teambit/component-issues';
|
|
3
|
+
import Consumer from '@teambit/legacy/dist/consumer/consumer';
|
|
4
|
+
import { PathOsBased } from '@teambit/legacy/dist/utils/path';
|
|
5
|
+
import ComponentMap from '@teambit/legacy/dist/consumer/bit-map/component-map';
|
|
6
|
+
import Component from '@teambit/legacy/dist/consumer/component/consumer-component';
|
|
7
|
+
import { DependencyResolverMain } from '@teambit/dependency-resolver';
|
|
8
|
+
import { DependenciesTree } from '@teambit/legacy/dist/consumer/component/dependencies/files-dependency-builder/types/dependency-tree-type';
|
|
9
|
+
import { DevFilesMain } from '@teambit/dev-files';
|
|
10
|
+
import { Workspace } from '@teambit/workspace';
|
|
11
|
+
import { AspectLoaderMain } from '@teambit/aspect-loader';
|
|
12
|
+
import { DependencyDetector } from '@teambit/legacy/dist/consumer/component/dependencies/files-dependency-builder/detector-hook';
|
|
13
|
+
import { DependenciesData } from './dependencies-data';
|
|
14
|
+
import { AllDependencies, AllPackagesDependencies } from './apply-overrides';
|
|
15
|
+
export type FileType = {
|
|
16
|
+
isTestFile: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type DebugDependencies = {
|
|
19
|
+
components: DebugComponentsDependency[];
|
|
20
|
+
unidentifiedPackages?: string[];
|
|
21
|
+
};
|
|
22
|
+
export type DebugComponentsDependency = {
|
|
23
|
+
id: ComponentID;
|
|
24
|
+
importSource?: string;
|
|
25
|
+
dependencyPackageJsonPath?: string;
|
|
26
|
+
dependentPackageJsonPath?: string;
|
|
27
|
+
versionResolvedFrom?: 'DependencyPkgJson' | 'DependentPkgJson' | 'BitMap' | 'Model' | 'MergeConfig' | string;
|
|
28
|
+
version?: string;
|
|
29
|
+
componentIdResolvedFrom?: 'DependencyPkgJson' | 'DependencyPath';
|
|
30
|
+
packageName?: string;
|
|
31
|
+
};
|
|
32
|
+
export declare class AutoDetectDeps {
|
|
33
|
+
private component;
|
|
34
|
+
private workspace;
|
|
35
|
+
private devFiles;
|
|
36
|
+
private depsResolver;
|
|
37
|
+
private aspectLoader;
|
|
38
|
+
componentId: ComponentID;
|
|
39
|
+
componentMap: ComponentMap;
|
|
40
|
+
componentFromModel: Component;
|
|
41
|
+
consumerPath: PathOsBased;
|
|
42
|
+
tree: DependenciesTree;
|
|
43
|
+
allDependencies: AllDependencies;
|
|
44
|
+
allPackagesDependencies: AllPackagesDependencies;
|
|
45
|
+
issues: IssuesList;
|
|
46
|
+
coreAspects: string[];
|
|
47
|
+
processedFiles: string[];
|
|
48
|
+
debugDependenciesData: DebugDependencies;
|
|
49
|
+
autoDetectConfigMerge: Record<string, any>;
|
|
50
|
+
constructor(component: Component, workspace: Workspace, devFiles: DevFilesMain, depsResolver: DependencyResolverMain, aspectLoader: AspectLoaderMain);
|
|
51
|
+
get consumer(): Consumer;
|
|
52
|
+
private setTree;
|
|
53
|
+
/**
|
|
54
|
+
* Resolve components and packages dependencies for a component.
|
|
55
|
+
* This method should NOT have any side-effect on the component. the DependenciesLoader class is
|
|
56
|
+
* responsible for saving this data on the component object.
|
|
57
|
+
*
|
|
58
|
+
* The process is as follows:
|
|
59
|
+
* 1) Use the language driver to parse the component files and find for each file its dependencies.
|
|
60
|
+
* 2) The results we get from the driver per file tells us what are the files and packages that depend on our file.
|
|
61
|
+
* and also whether there are missing packages and files.
|
|
62
|
+
* 3) Using the information from the driver, we go over each one of the dependencies files and find its counterpart
|
|
63
|
+
* component. The way how we find it, is by using the bit.map file which has a mapping between the component name and
|
|
64
|
+
* the file paths.
|
|
65
|
+
* 4) If we find a component to the file dependency, we add it to component.dependencies. Otherwise, it's added to
|
|
66
|
+
* component.issues.untrackedDependencies
|
|
67
|
+
* 5) Similarly, when we find the packages dependencies, they are added to component.packageDependencies. Otherwise,
|
|
68
|
+
* they're added to component.issues.missingPackagesDependenciesOnFs
|
|
69
|
+
* 6) In case the driver found a file dependency that is not on the file-system, we add that file to
|
|
70
|
+
* component.issues.missingDependenciesOnFs
|
|
71
|
+
*/
|
|
72
|
+
getDependenciesData(cacheResolvedDependencies: Record<string, any>, cacheProjectAst: Record<string, any> | undefined): Promise<{
|
|
73
|
+
dependenciesData: DependenciesData;
|
|
74
|
+
debugDependenciesData: DebugDependencies;
|
|
75
|
+
}>;
|
|
76
|
+
getEnvDetectors(): Promise<DependencyDetector[] | null>;
|
|
77
|
+
/**
|
|
78
|
+
* Given the tree of file dependencies from the driver, find the components of these files.
|
|
79
|
+
* Each dependency file has a path, use bit.map to search for the component name by that path.
|
|
80
|
+
* If the component is found, add it to "this.allDependencies.dependencies". Otherwise, add it to "this.issues.untrackedDependencies".
|
|
81
|
+
*
|
|
82
|
+
* For the found components, add their sourceRelativePath and destinationRelativePath, they are being used for
|
|
83
|
+
* generating links upon import:
|
|
84
|
+
* sourceRelativePath - location of the link file.
|
|
85
|
+
* destinationRelativePath - destination written inside the link file.
|
|
86
|
+
*
|
|
87
|
+
* When a dependency is found in a regular (implementation) file, it goes to `dependencies`. If
|
|
88
|
+
* it found on a test file, it goes to `devDependencies`.
|
|
89
|
+
* Similarly, when a package is found in a regular file, it goes to `packageDependencies`. When
|
|
90
|
+
* if found in a test file, it goes to `devPackageDependencies`.
|
|
91
|
+
* An exception for the above is when a package is required in a regular or test file but is also
|
|
92
|
+
* mentioned in the `package.json` file as a peerDependency, in that case, the package is added
|
|
93
|
+
* to `peerPackageDependencies` and removed from other places. Unless this package is overridden
|
|
94
|
+
* and marked as ignored in the consumer or component config file.
|
|
95
|
+
*/
|
|
96
|
+
private populateDependencies;
|
|
97
|
+
private throwForNonExistFile;
|
|
98
|
+
private getComponentIdByResolvedPackageData;
|
|
99
|
+
/**
|
|
100
|
+
* this happens when using relative paths between components, which is allowed on Legacy only.
|
|
101
|
+
* on Harmony, during the execution of this function, it recognizes the use of relative-paths, enter
|
|
102
|
+
* it to the "issues", then, later, it shows a warning on bit-status and block tagging.
|
|
103
|
+
*/
|
|
104
|
+
private getComponentIdByDepFile;
|
|
105
|
+
private processDepFiles;
|
|
106
|
+
private processOneDepFile;
|
|
107
|
+
/**
|
|
108
|
+
* process require/import of Bit components where the require statement is not a relative path
|
|
109
|
+
* but a module path, such as `require('@bit/bit.envs/compiler/babel');`
|
|
110
|
+
*/
|
|
111
|
+
private processComponents;
|
|
112
|
+
private isPkgInWorkspacePolicies;
|
|
113
|
+
private addImportNonMainIssueIfNeeded;
|
|
114
|
+
private processPackages;
|
|
115
|
+
private processMissing;
|
|
116
|
+
private processErrors;
|
|
117
|
+
/**
|
|
118
|
+
* when a user uses core-extensions these core-extensions should not be dependencies.
|
|
119
|
+
* here, we filter them out from all places they could entered as dependencies.
|
|
120
|
+
* an exception is when running this method on bit-core-extensions themselves (dogfooding), in
|
|
121
|
+
* which case we recognizes that the current originFile is a core-extension and avoid filtering.
|
|
122
|
+
*/
|
|
123
|
+
private processCoreAspects;
|
|
124
|
+
/**
|
|
125
|
+
* ** LEGACY ONLY **
|
|
126
|
+
* This is related to a legacy feature "custom-module-resolution". the code was removed, only the debug is still there, just in case.
|
|
127
|
+
*
|
|
128
|
+
* ** OLD COMMENT **
|
|
129
|
+
* currently the only unidentified packages being process are the ones coming from custom-modules-resolution.
|
|
130
|
+
* assuming the author used custom-resolution, which enable using non-relative import syntax,
|
|
131
|
+
* for example, requiring the file 'src/utils/is-string' from anywhere as require('utils/is-string');
|
|
132
|
+
* now, when the component is imported, the driver recognizes 'utils/is-string' as a package,
|
|
133
|
+
* because it's not relative.
|
|
134
|
+
* the goal here is to use the 'package' the driver found and match it with one of the
|
|
135
|
+
* dependencies from the model. In the example above, we might find in the model, a dependency
|
|
136
|
+
* is-string with importSource of 'utils/is-string'.
|
|
137
|
+
* Once a match is found, copy the relativePaths from the model.
|
|
138
|
+
*
|
|
139
|
+
* keep in mind that this custom-modules-resolution supported on legacy components only.
|
|
140
|
+
* as such, no need to find the packageName to pass to _pushToDependenciesIfNotExist method.
|
|
141
|
+
*/
|
|
142
|
+
private processUnidentifiedPackages;
|
|
143
|
+
private _pushToDependenciesIfNotExist;
|
|
144
|
+
private pushToDependenciesArray;
|
|
145
|
+
private getExistingDependency;
|
|
146
|
+
private getExistingDepRelativePaths;
|
|
147
|
+
private getDiffSpecifiers;
|
|
148
|
+
/**
|
|
149
|
+
* when requiring packages in typescript, sometimes there are the types packages with the same
|
|
150
|
+
* name, which the user probably wants as well. for example, requiring `foo` package, will also
|
|
151
|
+
* add `@types/foo` to the devDependencies if it has been found in the user `package.json` file.
|
|
152
|
+
*
|
|
153
|
+
* ideally this should be in bit-javascript. however, the decision where to put these `@types`
|
|
154
|
+
* packages (dependencies/devDependencies) is done here according to the user `package.json`
|
|
155
|
+
* and can't be done there because the `Tree` we get from bit-javascript doesn't have this
|
|
156
|
+
* distinction.
|
|
157
|
+
*/
|
|
158
|
+
private _addTypesPackagesForTypeScript;
|
|
159
|
+
private _pushToUntrackDependenciesIssues;
|
|
160
|
+
private _pushToRelativeComponentsAuthoredIssues;
|
|
161
|
+
private _pushToMissingDependenciesOnFs;
|
|
162
|
+
private _pushToMissingPackagesDependenciesIssues;
|
|
163
|
+
}
|
|
164
|
+
export declare function getValidVersion(version: string | undefined): string | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IssuesList } from '@teambit/component-issues';
|
|
2
|
+
import { ManuallyChangedDependencies } from '@teambit/legacy/dist/consumer/component/consumer-component';
|
|
3
|
+
import { AllDependencies, AllPackagesDependencies } from './apply-overrides';
|
|
4
|
+
export type OverridesDependenciesData = {
|
|
5
|
+
manuallyRemovedDependencies: ManuallyChangedDependencies;
|
|
6
|
+
manuallyAddedDependencies: ManuallyChangedDependencies;
|
|
7
|
+
missingPackageDependencies: string[];
|
|
8
|
+
};
|
|
9
|
+
export declare class DependenciesData {
|
|
10
|
+
allDependencies: AllDependencies;
|
|
11
|
+
allPackagesDependencies: AllPackagesDependencies;
|
|
12
|
+
issues: IssuesList;
|
|
13
|
+
coreAspects: string[];
|
|
14
|
+
constructor(allDependencies: AllDependencies, allPackagesDependencies: AllPackagesDependencies, issues: IssuesList, coreAspects: string[]);
|
|
15
|
+
serialize(): string;
|
|
16
|
+
static deserialize(data: string): DependenciesData;
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Component from '@teambit/legacy/dist/consumer/component/consumer-component';
|
|
2
|
+
import { DependencyLoaderOpts } from '@teambit/legacy/dist/consumer/component/component-loader';
|
|
3
|
+
import { Workspace } from '@teambit/workspace';
|
|
4
|
+
import { DependencyResolverMain } from '@teambit/dependency-resolver';
|
|
5
|
+
import { DevFilesMain } from '@teambit/dev-files';
|
|
6
|
+
import { AspectLoaderMain } from '@teambit/aspect-loader';
|
|
7
|
+
import { DependenciesData } from './dependencies-data';
|
|
8
|
+
import { DebugDependencies } from './auto-detect-deps';
|
|
9
|
+
import OverridesDependencies from './overrides-dependencies';
|
|
10
|
+
export declare class DependenciesLoader {
|
|
11
|
+
private component;
|
|
12
|
+
private depsResolver;
|
|
13
|
+
private devFiles;
|
|
14
|
+
private aspectLoader;
|
|
15
|
+
private idStr;
|
|
16
|
+
constructor(component: Component, depsResolver: DependencyResolverMain, devFiles: DevFilesMain, aspectLoader: AspectLoaderMain);
|
|
17
|
+
load(workspace: Workspace, opts: DependencyLoaderOpts): Promise<{
|
|
18
|
+
dependenciesData: DependenciesData;
|
|
19
|
+
overridesDependencies: OverridesDependencies;
|
|
20
|
+
debugDependenciesData: DebugDependencies;
|
|
21
|
+
}>;
|
|
22
|
+
loadFromScope(dependenciesData: Partial<DependenciesData>): Promise<void>;
|
|
23
|
+
private getDependenciesData;
|
|
24
|
+
private getDependenciesDataFromCacheIfPossible;
|
|
25
|
+
private shouldSaveInCache;
|
|
26
|
+
private setDependenciesDataOnComponent;
|
|
27
|
+
private pushToDependencyResolverExtension;
|
|
28
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Workspace } from '@teambit/workspace';
|
|
2
|
+
import Component from '@teambit/legacy/dist/consumer/component/consumer-component';
|
|
3
|
+
import { DependencyResolverMain } from '@teambit/dependency-resolver';
|
|
4
|
+
import OverridesDependencies from './overrides-dependencies';
|
|
5
|
+
import { DebugComponentsDependency } from './auto-detect-deps';
|
|
6
|
+
export declare function updateDependenciesVersions(depsResolver: DependencyResolverMain, workspace: Workspace, component: Component, overridesDependencies: OverridesDependencies, autoDetectOverrides?: Record<string, any>, debugDependencies?: DebugComponentsDependency[], updateExtensionsVersions?: boolean): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import Component, { ManuallyChangedDependencies } from '@teambit/legacy/dist/consumer/component/consumer-component';
|
|
2
|
+
import { FileType } from './auto-detect-deps';
|
|
3
|
+
export default class OverridesDependencies {
|
|
4
|
+
component: Component;
|
|
5
|
+
componentFromModel: Component | null | undefined;
|
|
6
|
+
manuallyRemovedDependencies: ManuallyChangedDependencies;
|
|
7
|
+
manuallyAddedDependencies: ManuallyChangedDependencies;
|
|
8
|
+
missingPackageDependencies: string[];
|
|
9
|
+
constructor(component: Component);
|
|
10
|
+
shouldIgnorePackage(packageName: string, fileType: FileType): boolean;
|
|
11
|
+
shouldIgnorePackageByType(packageName: string, field: string): boolean;
|
|
12
|
+
shouldIgnorePeerPackage(packageName: string): boolean;
|
|
13
|
+
getDependenciesToAddManually(): Record<string, any> | undefined;
|
|
14
|
+
_manuallyAddPackage(field: string, dependency: string, dependencyValue: string, packageJson: Record<string, any> | null | undefined): Record<string, any> | null | undefined;
|
|
15
|
+
_addManuallyRemovedDep(field: string, value: string): void;
|
|
16
|
+
_addManuallyAddedDep(field: string, value: string): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function packageToDefinetlyTyped(pkgName: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { CLIMain } from '@teambit/cli';
|
|
2
|
+
import { ComponentID } from '@teambit/component-id';
|
|
3
|
+
import { DependencyResolverMain } from '@teambit/dependency-resolver';
|
|
4
|
+
import { Workspace } from '@teambit/workspace';
|
|
5
|
+
import ConsumerComponent from '@teambit/legacy/dist/consumer/component';
|
|
6
|
+
import { DependencyLoaderOpts } from '@teambit/legacy/dist/consumer/component/component-loader';
|
|
7
|
+
import { DevFilesMain } from '@teambit/dev-files';
|
|
8
|
+
import { ComponentIdGraph, GraphMain } from '@teambit/graph';
|
|
9
|
+
import { AspectLoaderMain } from '@teambit/aspect-loader';
|
|
10
|
+
import { ScopeMain } from '@teambit/scope';
|
|
11
|
+
import { DependenciesData, OverridesDependenciesData } from './dependencies-loader/dependencies-data';
|
|
12
|
+
import { RemoveDependenciesFlags, SetDependenciesFlags } from './dependencies-cmd';
|
|
13
|
+
import { DebugDependencies } from './dependencies-loader/auto-detect-deps';
|
|
14
|
+
export type RemoveDependencyResult = {
|
|
15
|
+
id: ComponentID;
|
|
16
|
+
removedPackages: string[];
|
|
17
|
+
};
|
|
18
|
+
export type SetDependenciesResult = {
|
|
19
|
+
changedComps: string[];
|
|
20
|
+
addedPackages: Record<string, string>;
|
|
21
|
+
};
|
|
22
|
+
export type DependenciesResultsDebug = DebugDependencies & OverridesDependenciesData & {
|
|
23
|
+
coreAspects: string[];
|
|
24
|
+
sources: {
|
|
25
|
+
id: string;
|
|
26
|
+
source: string;
|
|
27
|
+
}[];
|
|
28
|
+
};
|
|
29
|
+
export type DependenciesResults = {
|
|
30
|
+
graph: ComponentIdGraph;
|
|
31
|
+
id: ComponentID;
|
|
32
|
+
};
|
|
33
|
+
export type BlameResult = {
|
|
34
|
+
snap: string;
|
|
35
|
+
tag?: string;
|
|
36
|
+
author: string;
|
|
37
|
+
date: string;
|
|
38
|
+
message: string;
|
|
39
|
+
version: string;
|
|
40
|
+
};
|
|
41
|
+
export declare class DependenciesMain {
|
|
42
|
+
private workspace;
|
|
43
|
+
private scope;
|
|
44
|
+
private dependencyResolver;
|
|
45
|
+
private devFiles;
|
|
46
|
+
private aspectLoader;
|
|
47
|
+
private graph;
|
|
48
|
+
constructor(workspace: Workspace, scope: ScopeMain, dependencyResolver: DependencyResolverMain, devFiles: DevFilesMain, aspectLoader: AspectLoaderMain, graph: GraphMain);
|
|
49
|
+
setPeer(componentId: string, range?: string): Promise<void>;
|
|
50
|
+
setDependency(componentPattern: string, packages: string[], options?: SetDependenciesFlags): Promise<SetDependenciesResult>;
|
|
51
|
+
removeDependency(componentPattern: string, packages: string[], options?: RemoveDependenciesFlags, removeOnlyIfExists?: boolean): Promise<RemoveDependencyResult[]>;
|
|
52
|
+
reset(componentPattern: string): Promise<ComponentID[]>;
|
|
53
|
+
eject(componentPattern: string): Promise<ComponentID[]>;
|
|
54
|
+
getDependencies(id: string, scope?: boolean): Promise<DependenciesResults>;
|
|
55
|
+
loadDependencies(component: ConsumerComponent, opts: DependencyLoaderOpts): Promise<{
|
|
56
|
+
dependenciesData: DependenciesData;
|
|
57
|
+
overridesDependencies: import("./dependencies-loader/overrides-dependencies").default;
|
|
58
|
+
debugDependenciesData: DebugDependencies;
|
|
59
|
+
}>;
|
|
60
|
+
/**
|
|
61
|
+
* load dependencies without the need for the workspace.
|
|
62
|
+
* the "auto-detect" are passed here as "dependenciesData". the "overrides", such as dependencies from the env,
|
|
63
|
+
* are calculated here.
|
|
64
|
+
* eventually all these dependencies are added to the ConsumerComponent object.
|
|
65
|
+
*/
|
|
66
|
+
loadDependenciesFromScope(component: ConsumerComponent, dependenciesData: Partial<DependenciesData>): Promise<void>;
|
|
67
|
+
debugDependencies(id: string): Promise<DependenciesResultsDebug>;
|
|
68
|
+
/**
|
|
69
|
+
* helps determine what snap/tag changed a specific dependency.
|
|
70
|
+
* the results are sorted from the oldest to newest.
|
|
71
|
+
*/
|
|
72
|
+
blame(compName: string, depName: string): Promise<BlameResult[]>;
|
|
73
|
+
usageDeep(depName: string, opts?: {
|
|
74
|
+
depth?: number;
|
|
75
|
+
}): Promise<string | undefined>;
|
|
76
|
+
/**
|
|
77
|
+
* @param depName either component-id-string or package-name (of the component or not component)
|
|
78
|
+
* @returns a map of component-id-string to the version of the dependency
|
|
79
|
+
*/
|
|
80
|
+
usage(depName: string): Promise<{
|
|
81
|
+
[compIdStr: string]: string;
|
|
82
|
+
}>;
|
|
83
|
+
private getPackageNameAndVerResolved;
|
|
84
|
+
private splitPkgToNameAndVer;
|
|
85
|
+
static slots: never[];
|
|
86
|
+
static dependencies: import("@teambit/harmony").Aspect[];
|
|
87
|
+
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
88
|
+
static provider([cli, workspace, depsResolver, devFiles, aspectLoader, scope, graph]: [
|
|
89
|
+
CLIMain,
|
|
90
|
+
Workspace,
|
|
91
|
+
DependencyResolverMain,
|
|
92
|
+
DevFilesMain,
|
|
93
|
+
AspectLoaderMain,
|
|
94
|
+
ScopeMain,
|
|
95
|
+
GraphMain
|
|
96
|
+
]): Promise<DependenciesMain>;
|
|
97
|
+
}
|
|
98
|
+
export default DependenciesMain;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
ADDED