@teambit/importer 1.0.228 → 1.0.229

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ import { ComponentID } from '@teambit/component-id';
2
+ import { GraphMain } from '@teambit/graph';
3
+ import { Logger } from '@teambit/logger';
4
+ import { Workspace } from '@teambit/workspace';
5
+ import { ImportOptions } from './import-components';
6
+ export declare class DependentsGetter {
7
+ private logger;
8
+ private workspace;
9
+ private graph;
10
+ private options;
11
+ constructor(logger: Logger, workspace: Workspace, graph: GraphMain, options: ImportOptions);
12
+ getDependents(targetCompIds: ComponentID[]): Promise<ComponentID[]>;
13
+ private promptDependents;
14
+ private promptLevelByLevel;
15
+ }
@@ -0,0 +1,20 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import type { ImporterMain } from './importer.main.runtime';
3
+ export declare class FetchCmd implements Command {
4
+ private importer;
5
+ name: string;
6
+ description: string;
7
+ extendedDescription: string;
8
+ alias: string;
9
+ private: boolean;
10
+ options: CommandOptions;
11
+ loader: boolean;
12
+ constructor(importer: ImporterMain);
13
+ report([ids]: [string[]], { lanes, components, json, fromOriginalScope, allHistory, }: {
14
+ lanes?: boolean;
15
+ components?: boolean;
16
+ json?: boolean;
17
+ fromOriginalScope?: boolean;
18
+ allHistory?: boolean;
19
+ }): Promise<string>;
20
+ }
@@ -0,0 +1,153 @@
1
+ import { LaneId } from '@teambit/lane-id';
2
+ import { ComponentID, ComponentIdList } from '@teambit/component-id';
3
+ import { Consumer } from '@teambit/legacy/dist/consumer';
4
+ import { Scope } from '@teambit/legacy/dist/scope';
5
+ import { Lane } from '@teambit/legacy/dist/scope/models';
6
+ import Component from '@teambit/legacy/dist/consumer/component';
7
+ import { MergeStrategy } from '@teambit/legacy/dist/consumer/versions-ops/merge-version/merge-version';
8
+ import { MergeResultsThreeWay } from '@teambit/legacy/dist/consumer/versions-ops/merge-version/three-way-merge';
9
+ import VersionDependencies from '@teambit/legacy/dist/scope/version-dependencies';
10
+ import { GraphMain } from '@teambit/graph';
11
+ import { Workspace } from '@teambit/workspace';
12
+ import { ComponentWriterMain, ComponentWriterResults } from '@teambit/component-writer';
13
+ import { EnvsMain } from '@teambit/envs';
14
+ import { FilesStatus } from '@teambit/merging';
15
+ import { WorkspaceConfigUpdateResult } from '@teambit/config-merger';
16
+ import { Logger } from '@teambit/logger';
17
+ export type ImportOptions = {
18
+ ids: string[];
19
+ verbose?: boolean;
20
+ merge?: boolean;
21
+ mergeStrategy?: MergeStrategy;
22
+ filterEnvs?: string[];
23
+ writeToPath?: string;
24
+ writeConfig?: boolean;
25
+ override?: boolean;
26
+ installNpmPackages: boolean;
27
+ writeConfigFiles: boolean;
28
+ objectsOnly?: boolean;
29
+ importDependenciesDirectly?: boolean;
30
+ importDependents?: boolean;
31
+ dependentsVia?: string;
32
+ dependentsAll?: boolean;
33
+ silent?: boolean;
34
+ fromOriginalScope?: boolean;
35
+ saveInLane?: boolean;
36
+ lanes?: {
37
+ laneId: LaneId;
38
+ remoteLane?: Lane;
39
+ };
40
+ allHistory?: boolean;
41
+ fetchDeps?: boolean;
42
+ trackOnly?: boolean;
43
+ includeDeprecated?: boolean;
44
+ isLaneFromRemote?: boolean;
45
+ };
46
+ type ComponentMergeStatus = {
47
+ component: Component;
48
+ mergeResults: MergeResultsThreeWay | null | undefined;
49
+ };
50
+ type ImportedVersions = {
51
+ [id: string]: string[];
52
+ };
53
+ export type ImportStatus = 'added' | 'updated' | 'up to date';
54
+ export type ImportDetails = {
55
+ id: string;
56
+ versions: string[];
57
+ latestVersion: string | null;
58
+ status: ImportStatus;
59
+ filesStatus: FilesStatus | null | undefined;
60
+ missingDeps: ComponentID[];
61
+ deprecated: boolean;
62
+ removed?: boolean;
63
+ };
64
+ export type ImportResult = {
65
+ importedIds: ComponentID[];
66
+ importedDeps: ComponentID[];
67
+ writtenComponents?: Component[];
68
+ importDetails: ImportDetails[];
69
+ cancellationMessage?: string;
70
+ installationError?: Error;
71
+ compilationError?: Error;
72
+ workspaceConfigUpdateResult?: WorkspaceConfigUpdateResult;
73
+ missingIds?: string[];
74
+ lane?: Lane;
75
+ };
76
+ export default class ImportComponents {
77
+ private workspace;
78
+ private graph;
79
+ private componentWriter;
80
+ private envs;
81
+ private logger;
82
+ options: ImportOptions;
83
+ consumer: Consumer;
84
+ scope: Scope;
85
+ mergeStatus: {
86
+ [id: string]: FilesStatus;
87
+ };
88
+ private remoteLane;
89
+ private divergeData;
90
+ constructor(workspace: Workspace, graph: GraphMain, componentWriter: ComponentWriterMain, envs: EnvsMain, logger: Logger, options: ImportOptions);
91
+ importComponents(): Promise<ImportResult>;
92
+ importObjectsOnLane(): Promise<ImportResult>;
93
+ private returnCompleteResults;
94
+ importSpecificComponents(): Promise<ImportResult>;
95
+ private mergeAndSaveLaneObject;
96
+ private _filterComponentsByFilters;
97
+ _fetchDivergeData(components: Component[]): Promise<void>;
98
+ _throwForDivergedHistory(): void;
99
+ private throwForComponentsFromAnotherLane;
100
+ private _importComponentsObjects;
101
+ /**
102
+ * consider the following use cases:
103
+ * 1) no ids were provided. it should import all the lanes components objects AND main components objects
104
+ * (otherwise, if main components are not imported and are missing, then bit-status complains about it)
105
+ * 2) ids are provided with wildcards. we assume the user wants only the ids that are available on the lane.
106
+ * because a user may entered "bit import scope/*" and this scope has many component on the lane and many not on the lane.
107
+ * we want to bring only the components on the lane.
108
+ * 3) ids are provided without wildcards. here, the user knows exactly what's needed and it's ok to get the ids from
109
+ * main if not found on the lane.
110
+ */
111
+ private getBitIdsForLanes;
112
+ private getIdFromStr;
113
+ private getBitIdsForNonLanes;
114
+ private getBitIds;
115
+ private getFlattenedDepsUnique;
116
+ private removeMultipleVersionsKeepLatest;
117
+ importAccordingToBitMap(): Promise<ImportResult>;
118
+ private getIdsToImportFromBitmap;
119
+ _getCurrentVersions(ids: ComponentIdList): Promise<ImportedVersions>;
120
+ /**
121
+ * get import details, includes the diff between the versions array before import and after import
122
+ */
123
+ _getImportDetails(currentVersions: ImportedVersions, components: VersionDependencies[]): Promise<ImportDetails[]>;
124
+ _throwForPotentialIssues(ids: ComponentIdList): Promise<void>;
125
+ _throwForModifiedOrNewComponents(ids: ComponentIdList): Promise<void>;
126
+ /**
127
+ * Model Component id() calculation uses id.toString() for the hash.
128
+ * If an imported component has scopereadonly name equals to a local name, both will have the exact same
129
+ * hash and they'll override each other.
130
+ */
131
+ _throwForDifferentComponentWithSameName(ids: ComponentIdList): void;
132
+ _getMergeStatus(component: Component): Promise<ComponentMergeStatus>;
133
+ /**
134
+ * 1) when there are conflicts and the strategy is "ours", don't write the imported component to
135
+ * the filesystem, only update bitmap.
136
+ *
137
+ * 2) when there are conflicts and the strategy is "theirs", override the local changes by the
138
+ * imported component. (similar to --override)
139
+ *
140
+ * 3) when there is no conflict or there are conflicts and the strategy is manual, write the files
141
+ * according to the merge result. (done by applyModifiedVersion())
142
+ */
143
+ _updateComponentFilesPerMergeStrategy(componentMergeStatus: ComponentMergeStatus): FilesStatus | null | undefined;
144
+ /**
145
+ * update the component files if they are modified and there is a merge strategy.
146
+ * returns only the components that need to be written to the filesystem
147
+ */
148
+ updateAllComponentsAccordingToMergeStrategy(components: Component[]): Promise<Component[]>;
149
+ _shouldSaveLaneData(): boolean;
150
+ _saveLaneDataIfNeeded(components: Component[]): Promise<void>;
151
+ _writeToFileSystem(components: Component[]): Promise<ComponentWriterResults>;
152
+ }
153
+ export {};
@@ -0,0 +1,54 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import { MergeStrategy } from '@teambit/legacy/dist/consumer/versions-ops/merge-version/merge-version';
3
+ import { ImporterMain } from './importer.main.runtime';
4
+ import { ImportDetails } from './import-components';
5
+ type ImportFlags = {
6
+ path?: string;
7
+ objects?: boolean;
8
+ displayDependencies?: boolean;
9
+ override?: boolean;
10
+ verbose?: boolean;
11
+ json?: boolean;
12
+ conf?: string;
13
+ skipDependencyInstallation?: boolean;
14
+ skipWriteConfigFiles?: boolean;
15
+ merge?: MergeStrategy;
16
+ filterEnvs?: string;
17
+ saveInLane?: boolean;
18
+ dependencies?: boolean;
19
+ dependents?: boolean;
20
+ dependentsDryRun?: boolean;
21
+ dependentsVia?: string;
22
+ dependentsAll?: boolean;
23
+ silent?: boolean;
24
+ allHistory?: boolean;
25
+ fetchDeps?: boolean;
26
+ trackOnly?: boolean;
27
+ includeDeprecated?: boolean;
28
+ };
29
+ export declare class ImportCmd implements Command {
30
+ private importer;
31
+ name: string;
32
+ description: string;
33
+ helpUrl: string;
34
+ arguments: {
35
+ name: string;
36
+ description: string;
37
+ }[];
38
+ extendedDescription: string;
39
+ group: string;
40
+ alias: string;
41
+ options: CommandOptions;
42
+ loader: boolean;
43
+ remoteOp: boolean;
44
+ _packageManagerArgs: string[];
45
+ constructor(importer: ImporterMain);
46
+ report([ids]: [string[]], importFlags: ImportFlags): Promise<any>;
47
+ json([ids]: [string[]], importFlags: ImportFlags): Promise<{
48
+ importDetails: ImportDetails[];
49
+ installationError: Error | undefined;
50
+ missingIds: string[] | undefined;
51
+ }>;
52
+ private getImportResults;
53
+ }
54
+ export {};
@@ -0,0 +1,2 @@
1
+ import { Aspect } from '@teambit/harmony';
2
+ export declare const ImporterAspect: Aspect;
@@ -0,0 +1 @@
1
+ export declare const Logo: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,75 @@
1
+ import { CLIMain } from '@teambit/cli';
2
+ import { DependencyResolverMain } from '@teambit/dependency-resolver';
3
+ import { Workspace } from '@teambit/workspace';
4
+ import { EnvsMain } from '@teambit/envs';
5
+ import { ComponentWriterMain } from '@teambit/component-writer';
6
+ import { Logger, LoggerMain } from '@teambit/logger';
7
+ import { ScopeMain } from '@teambit/scope';
8
+ import { LaneId } from '@teambit/lane-id';
9
+ import { InstallMain } from '@teambit/install';
10
+ import { ComponentID } from '@teambit/component-id';
11
+ import { Lane } from '@teambit/legacy/dist/scope/models';
12
+ import { GraphMain } from '@teambit/graph';
13
+ import { ImportOptions, ImportResult } from './import-components';
14
+ export declare class ImporterMain {
15
+ private workspace;
16
+ private depResolver;
17
+ private graph;
18
+ private scope;
19
+ private componentWriter;
20
+ private envs;
21
+ readonly logger: Logger;
22
+ constructor(workspace: Workspace, depResolver: DependencyResolverMain, graph: GraphMain, scope: ScopeMain, componentWriter: ComponentWriterMain, envs: EnvsMain, logger: Logger);
23
+ import(importOptions: ImportOptions, packageManagerArgs?: string[]): Promise<ImportResult>;
24
+ /**
25
+ * fetch objects according to the criteria set by `options` param.
26
+ * to fetch current objects according to the current lane or main, use `this.importCurrentObjects()`.
27
+ */
28
+ importObjects(options?: Partial<ImportOptions>): Promise<ImportResult>;
29
+ /**
30
+ * given a lane object, load all components by their head on the lane, find the artifacts refs and import them from
31
+ * the lane scope
32
+ */
33
+ importHeadArtifactsFromLane(lane: Lane, ids?: ComponentID[], throwIfMissing?: boolean): Promise<void>;
34
+ /**
35
+ * if on main, fetch main objects, if on lane, fetch lane objects.
36
+ */
37
+ importCurrentObjects(): Promise<ImportResult>;
38
+ importObjectsFromMainIfExist(ids: ComponentID[]): Promise<void>;
39
+ /**
40
+ * fetch lane's components and save them in the local scope.
41
+ * once done, merge the lane object and save it as well.
42
+ */
43
+ fetchLaneComponents(lane: Lane): Promise<void>;
44
+ fetch(ids: string[], lanes: boolean, components: boolean, fromOriginalScope: boolean, allHistory?: boolean): Promise<ImportResult | {
45
+ importedIds: ComponentID[];
46
+ importDetails: import("./import-components").ImportDetails[];
47
+ }>;
48
+ private createImportComponents;
49
+ fetchLanes(lanes: Lane[], shouldFetchFromMain?: boolean, options?: Partial<ImportOptions>): Promise<ImportResult>;
50
+ /**
51
+ * get a Lane object from the remote.
52
+ * `persistIfNotExists` saves the object in the local scope only if the lane is not there yet.
53
+ * otherwise, it needs some merging mechanism, which is done differently whether it's export or import.
54
+ * see `sources.mergeLane()` for export and `import-components._saveLaneDataIfNeeded()` for import.
55
+ * in this case, because we only bring the lane object and not the components, it's not easy to do the merge.
56
+ */
57
+ importLaneObject(laneId: LaneId, persistIfNotExists?: boolean, includeLaneHistory?: boolean): Promise<Lane>;
58
+ importObjectsByHashes(hashes: string[], scope: string, reason?: string): Promise<void>;
59
+ private removeFromWorkspaceConfig;
60
+ private getImportedPackagesNames;
61
+ static slots: never[];
62
+ static dependencies: import("@teambit/harmony").Aspect[];
63
+ static runtime: import("@teambit/harmony").RuntimeDefinition;
64
+ static provider([cli, workspace, depResolver, graph, scope, componentWriter, install, envs, loggerMain]: [
65
+ CLIMain,
66
+ Workspace,
67
+ DependencyResolverMain,
68
+ GraphMain,
69
+ ScopeMain,
70
+ ComponentWriterMain,
71
+ InstallMain,
72
+ EnvsMain,
73
+ LoggerMain
74
+ ]): Promise<ImporterMain>;
75
+ }
@@ -0,0 +1,6 @@
1
+ import { ImporterAspect } from './importer.aspect';
2
+ export { FetchCmd } from './fetch-cmd';
3
+ export type { ImportOptions } from './import-components';
4
+ export type { ImporterMain } from './importer.main.runtime';
5
+ export default ImporterAspect;
6
+ export { ImporterAspect };
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.scope_importer@1.0.228/dist/importer.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.scope_importer@1.0.228/dist/importer.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.scope_importer@1.0.229/dist/importer.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.scope_importer@1.0.229/dist/importer.docs.mdx';
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/importer",
3
- "version": "1.0.228",
3
+ "version": "1.0.229",
4
4
  "homepage": "https://bit.cloud/teambit/scope/importer",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.scope",
8
8
  "name": "importer",
9
- "version": "1.0.228"
9
+ "version": "1.0.229"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
@@ -20,24 +20,24 @@
20
20
  "@teambit/lane-id": "0.0.311",
21
21
  "@teambit/harmony": "0.4.6",
22
22
  "@teambit/legacy-bit-id": "1.1.1",
23
- "@teambit/graph": "1.0.228",
24
- "@teambit/logger": "0.0.954",
25
- "@teambit/workspace": "1.0.228",
26
- "@teambit/cli": "0.0.861",
27
- "@teambit/checkout": "1.0.228",
28
- "@teambit/component-writer": "1.0.228",
29
- "@teambit/config-merger": "0.0.95",
30
- "@teambit/envs": "1.0.228",
31
- "@teambit/merging": "1.0.228",
32
- "@teambit/dependency-resolver": "1.0.228",
33
- "@teambit/install": "1.0.228",
34
- "@teambit/scope": "1.0.228"
23
+ "@teambit/graph": "1.0.229",
24
+ "@teambit/logger": "0.0.955",
25
+ "@teambit/workspace": "1.0.229",
26
+ "@teambit/cli": "0.0.862",
27
+ "@teambit/checkout": "1.0.229",
28
+ "@teambit/component-writer": "1.0.229",
29
+ "@teambit/config-merger": "0.0.96",
30
+ "@teambit/envs": "1.0.229",
31
+ "@teambit/merging": "1.0.229",
32
+ "@teambit/dependency-resolver": "1.0.229",
33
+ "@teambit/install": "1.0.229",
34
+ "@teambit/scope": "1.0.229"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/lodash": "4.14.165",
38
38
  "@types/mocha": "9.1.0",
39
39
  "chai": "4.3.0",
40
- "@teambit/harmony.envs.core-aspect-env": "0.0.30"
40
+ "@teambit/harmony.envs.core-aspect-env": "0.0.33"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "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,40 +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_graph@1.0.228"
43
- },
44
- {
45
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_logger@0.0.954"
46
- },
47
- {
48
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@1.0.228"
49
- },
50
- {
51
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.861"
52
- },
53
- {
54
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_checkout@1.0.228"
55
- },
56
- {
57
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component-writer@1.0.228"
58
- },
59
- {
60
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_config-merger@0.0.95"
61
- },
62
- {
63
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.envs_envs@1.0.228"
64
- },
65
- {
66
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_merging@1.0.228"
67
- },
68
- {
69
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_install@1.0.228"
70
- },
71
- {
72
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.scope_scope@1.0.228"
73
- }
74
38
  ]
75
39
  }