@teambit/importer 1.0.108 → 1.0.110

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/import.cmd.ts DELETED
@@ -1,286 +0,0 @@
1
- import { Command, CommandOptions } from '@teambit/cli';
2
- import chalk from 'chalk';
3
- import { compact } from 'lodash';
4
- import R from 'ramda';
5
- import { installationErrorOutput, compilationErrorOutput } from '@teambit/merging';
6
- import {
7
- FileStatus,
8
- MergeOptions,
9
- MergeStrategy,
10
- } from '@teambit/legacy/dist/consumer/versions-ops/merge-version/merge-version';
11
- import { ComponentIdList, ComponentID } from '@teambit/component-id';
12
- import GeneralError from '@teambit/legacy/dist/error/general-error';
13
- import { immutableUnshift } from '@teambit/legacy/dist/utils';
14
- import { formatPlainComponentItem } from '@teambit/legacy/dist/cli/chalk-box';
15
- import { ImporterMain } from './importer.main.runtime';
16
- import { ImportOptions, ImportDetails, ImportStatus, ImportResult } from './import-components';
17
-
18
- type ImportFlags = {
19
- path?: string;
20
- objects?: boolean;
21
- displayDependencies?: boolean;
22
- override?: boolean;
23
- verbose?: boolean;
24
- json?: boolean;
25
- conf?: string;
26
- skipDependencyInstallation?: boolean;
27
- skipWriteConfigFiles?: boolean;
28
- merge?: MergeStrategy;
29
- filterEnvs?: string;
30
- saveInLane?: boolean;
31
- dependencies?: boolean;
32
- dependents?: boolean;
33
- allHistory?: boolean;
34
- fetchDeps?: boolean;
35
- trackOnly?: boolean;
36
- includeDeprecated?: boolean;
37
- };
38
-
39
- export class ImportCmd implements Command {
40
- name = 'import [component-patterns...]';
41
- description = 'import components from their remote scopes to the local workspace';
42
- helpUrl = 'reference/components/importing-components';
43
- arguments = [
44
- {
45
- name: 'component-patterns...',
46
- description:
47
- 'component IDs or component patterns (separated by space). Use patterns to import groups of components using a common scope or namespace. E.g., "utils/*" (wrap with double quotes)',
48
- },
49
- ];
50
- extendedDescription: string;
51
- group = 'collaborate';
52
- alias = '';
53
- options = [
54
- ['p', 'path <path>', 'import components into a specific directory (a relative path in the workspace)'],
55
- [
56
- 'o',
57
- 'objects',
58
- 'import components objects to the local scope without checkout (without writing them to the file system). This is the default behavior for import with no id argument',
59
- ],
60
- ['O', 'override', 'override local changes'],
61
- ['v', 'verbose', 'show verbose output for inspection'],
62
- ['j', 'json', 'return the output as JSON'],
63
- // ['', 'conf', 'write the configuration file (component.json) of the component'], // not working. need to fix once ComponentWriter is moved to Harmony
64
- ['x', 'skip-dependency-installation', 'do not auto-install dependencies of the imported components'],
65
- ['', 'skip-write-config-files', 'do not write config files (such as eslint, tsconfig, prettier, etc...)'],
66
- [
67
- 'm',
68
- 'merge [strategy]',
69
- 'merge local changes with the imported version. strategy should be "theirs", "ours" or "manual"',
70
- ],
71
- [
72
- '',
73
- 'dependencies',
74
- 'import all dependencies (bit components only) of imported components and write them to the workspace',
75
- ],
76
- [
77
- '',
78
- 'dependents',
79
- 'import components found while traversing from the imported components upwards to the workspace components',
80
- ],
81
- [
82
- '',
83
- 'filter-envs <envs>',
84
- 'only import components that have the specified environment (e.g., "teambit.react/react-env")',
85
- ],
86
- [
87
- '',
88
- 'save-in-lane',
89
- 'when checked out to a lane and the component is not on the remote-lane, save it in the lane (defaults to save on main)',
90
- ],
91
- [
92
- '',
93
- 'all-history',
94
- 'relevant for fetching all components objects. avoid optimizations, fetch all history versions, always',
95
- ],
96
- [
97
- '',
98
- 'fetch-deps',
99
- 'fetch dependencies (bit components) objects to the local scope, but dont add to the workspace. Useful to resolve errors about missing dependency data',
100
- ],
101
- [
102
- '',
103
- 'track-only',
104
- 'do not write any component files, just create .bitmap entries of the imported components. Useful when the files already exist and just want to re-add the component to the bitmap',
105
- ],
106
- ['', 'include-deprecated', 'when importing with patterns, include deprecated components (default to exclude them)'],
107
- ] as CommandOptions;
108
- loader = true;
109
- migration = true;
110
- remoteOp = true;
111
- _packageManagerArgs: string[]; // gets populated by yargs-adapter.handler().
112
-
113
- constructor(private importer: ImporterMain) {}
114
-
115
- async report([ids = []]: [string[]], importFlags: ImportFlags): Promise<any> {
116
- const {
117
- importDetails,
118
- importedIds,
119
- importedDeps,
120
- installationError,
121
- compilationError,
122
- missingIds,
123
- cancellationMessage,
124
- } = await this.getImportResults(ids, importFlags);
125
- if (!importedIds.length && !missingIds?.length) {
126
- return chalk.yellow(cancellationMessage || 'nothing to import');
127
- }
128
- const importedIdsUniqNoVersion = ComponentIdList.fromArray(importedIds).toVersionLatest();
129
- const summaryPrefix =
130
- importedIdsUniqNoVersion.length === 1
131
- ? 'successfully imported one component'
132
- : `successfully imported ${importedIdsUniqNoVersion.length} components`;
133
-
134
- let upToDateCount = 0;
135
- const importedComponents = importedIds.map((bitId) => {
136
- const details = importDetails.find((c) => c.id === bitId.toStringWithoutVersion());
137
- if (!details) throw new Error(`missing details for component ${bitId.toString()}`);
138
- if (details.status === 'up to date') {
139
- upToDateCount += 1;
140
- }
141
- return formatPlainComponentItemWithVersions(bitId, details);
142
- });
143
- const upToDateStr = upToDateCount === 0 ? '' : `, ${upToDateCount} components are up to date`;
144
- const summary = `${summaryPrefix}${upToDateStr}`;
145
- const importOutput = [...compact(importedComponents), chalk.green(summary)].join('\n');
146
- const importedDepsOutput =
147
- importFlags.displayDependencies && importedDeps.length
148
- ? immutableUnshift(
149
- R.uniq(importedDeps.map(formatPlainComponentItem)),
150
- chalk.green(`\n\nsuccessfully imported ${importedDeps.length} component dependencies`)
151
- ).join('\n')
152
- : '';
153
-
154
- const output =
155
- importOutput +
156
- importedDepsOutput +
157
- formatMissingComponents(missingIds) +
158
- installationErrorOutput(installationError) +
159
- compilationErrorOutput(compilationError);
160
-
161
- return output;
162
- }
163
-
164
- async json([ids]: [string[]], importFlags: ImportFlags) {
165
- const { importDetails, installationError, missingIds } = await this.getImportResults(ids, importFlags);
166
-
167
- return { importDetails, installationError, missingIds };
168
- }
169
-
170
- private async getImportResults(
171
- ids: string[],
172
- {
173
- path,
174
- objects = false,
175
- override = false,
176
- verbose = false,
177
- conf,
178
- skipDependencyInstallation = false,
179
- skipWriteConfigFiles = false,
180
- merge,
181
- filterEnvs,
182
- saveInLane = false,
183
- dependencies = false,
184
- dependents = false,
185
- allHistory = false,
186
- fetchDeps = false,
187
- trackOnly = false,
188
- includeDeprecated = false,
189
- }: ImportFlags
190
- ): Promise<ImportResult> {
191
- if (objects && merge) {
192
- throw new GeneralError(' --objects and --merge flags cannot be used together');
193
- }
194
- if (override && merge) {
195
- throw new GeneralError('--override and --merge cannot be used together');
196
- }
197
- if (!ids.length && dependencies) {
198
- throw new GeneralError('you have to specify ids to use "--dependencies" flag');
199
- }
200
- if (!ids.length && dependents) {
201
- throw new GeneralError('you have to specify ids to use "--dependents" flag');
202
- }
203
- if (!ids.length && trackOnly) {
204
- throw new GeneralError('you have to specify ids to use "--track-only" flag');
205
- }
206
- let mergeStrategy;
207
- if (merge && R.is(String, merge)) {
208
- const options = Object.keys(MergeOptions);
209
- if (!options.includes(merge)) {
210
- throw new GeneralError(`merge must be one of the following: ${options.join(', ')}`);
211
- }
212
- mergeStrategy = merge;
213
- }
214
-
215
- const envsToFilter = filterEnvs ? filterEnvs.split(',').map((p) => p.trim()) : undefined;
216
-
217
- const importOptions: ImportOptions = {
218
- ids,
219
- verbose,
220
- merge: Boolean(merge),
221
- filterEnvs: envsToFilter,
222
- mergeStrategy,
223
- writeToPath: path,
224
- objectsOnly: objects,
225
- override,
226
- writeConfig: Boolean(conf),
227
- installNpmPackages: !skipDependencyInstallation,
228
- writeConfigFiles: !skipWriteConfigFiles,
229
- saveInLane,
230
- importDependenciesDirectly: dependencies,
231
- importDependents: dependents,
232
- allHistory,
233
- fetchDeps,
234
- trackOnly,
235
- includeDeprecated,
236
- };
237
- return this.importer.import(importOptions, this._packageManagerArgs);
238
- }
239
- }
240
-
241
- function formatMissingComponents(missing?: string[]) {
242
- if (!missing?.length) return '';
243
- const title = chalk.underline('Missing Components');
244
- const subTitle = `The following components are missing from the remote in the requested version, try running "bit status" to re-sync your .bitmap file
245
- Also, check that the requested version exists on main or the checked out lane`;
246
- const body = chalk.red(missing.join('\n'));
247
- return `\n\n${title}\n${subTitle}\n${body}`;
248
- }
249
-
250
- function formatPlainComponentItemWithVersions(bitId: ComponentID, importDetails: ImportDetails) {
251
- const status: ImportStatus = importDetails.status;
252
- const id = bitId.toStringWithoutVersion();
253
- const getVersionsOutput = () => {
254
- if (!importDetails.versions.length) return '';
255
- if (importDetails.latestVersion) {
256
- return `${importDetails.versions.length} new version(s) available, latest ${importDetails.latestVersion}`;
257
- }
258
- return `new versions: ${importDetails.versions.join(', ')}`;
259
- };
260
- const versions = getVersionsOutput();
261
- const usedVersion = status === 'added' ? `, currently used version ${bitId.version}` : '';
262
- const getConflictMessage = () => {
263
- if (!importDetails.filesStatus) return '';
264
- const conflictedFiles = Object.keys(importDetails.filesStatus)
265
- // @ts-ignore file is set
266
- .filter((file) => importDetails.filesStatus[file] === FileStatus.manual);
267
- if (!conflictedFiles.length) return '';
268
- return `(the following files were saved with conflicts ${conflictedFiles
269
- .map((file) => chalk.bold(file))
270
- .join(', ')}) `;
271
- };
272
- const conflictMessage = getConflictMessage();
273
- const deprecated = importDetails.deprecated && !importDetails.removed ? chalk.yellow('deprecated') : '';
274
- const removed = importDetails.removed ? chalk.red('removed') : '';
275
- const missingDeps = importDetails.missingDeps.length
276
- ? chalk.red(`missing dependencies: ${importDetails.missingDeps.map((d) => d.toString()).join(', ')}`)
277
- : '';
278
- if (status === 'up to date' && !missingDeps && !deprecated && !conflictMessage && !removed) {
279
- return undefined;
280
- }
281
- return chalk.dim(
282
- `- ${chalk.green(status)} ${chalk.cyan(
283
- id
284
- )} ${versions}${usedVersion} ${conflictMessage}${deprecated}${removed} ${missingDeps}`
285
- );
286
- }
@@ -1,5 +0,0 @@
1
- import { Aspect } from '@teambit/harmony';
2
-
3
- export const ImporterAspect = Aspect.create({
4
- id: 'teambit.scope/importer',
5
- });
@@ -1,332 +0,0 @@
1
- import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';
2
- import { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';
3
- import WorkspaceAspect, { OutsideWorkspaceError, Workspace } from '@teambit/workspace';
4
- import { Analytics } from '@teambit/legacy/dist/analytics/analytics';
5
- import ConsumerComponent from '@teambit/legacy/dist/consumer/component';
6
- import componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';
7
- import { InvalidScopeName, InvalidScopeNameFromRemote } from '@teambit/legacy-bit-id';
8
- import pMapSeries from 'p-map-series';
9
- import EnvsAspect, { EnvsMain } from '@teambit/envs';
10
- import ComponentWriterAspect, { ComponentWriterMain } from '@teambit/component-writer';
11
- import { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';
12
- import ScopeAspect, { ScopeMain } from '@teambit/scope';
13
- import { DEFAULT_LANE, LaneId } from '@teambit/lane-id';
14
- import ScopeComponentsImporter from '@teambit/legacy/dist/scope/component-ops/scope-components-importer';
15
- import { importAllArtifacts } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';
16
- import InstallAspect, { InstallMain } from '@teambit/install';
17
- import loader from '@teambit/legacy/dist/cli/loader';
18
- import { ComponentIdList, ComponentID } from '@teambit/component-id';
19
- import { Lane } from '@teambit/legacy/dist/scope/models';
20
- import { ScopeNotFoundOrDenied } from '@teambit/legacy/dist/remotes/exceptions/scope-not-found-or-denied';
21
- import GraphAspect, { GraphMain } from '@teambit/graph';
22
- import { LaneNotFound } from '@teambit/legacy/dist/api/scope/lib/exceptions/lane-not-found';
23
- import { BitError } from '@teambit/bit-error';
24
- import { ImportCmd } from './import.cmd';
25
- import { ImporterAspect } from './importer.aspect';
26
- import { FetchCmd } from './fetch-cmd';
27
- import ImportComponents, { ImportOptions, ImportResult } from './import-components';
28
-
29
- export class ImporterMain {
30
- constructor(
31
- private workspace: Workspace,
32
- private depResolver: DependencyResolverMain,
33
- private graph: GraphMain,
34
- private scope: ScopeMain,
35
- private componentWriter: ComponentWriterMain,
36
- private envs: EnvsMain,
37
- private logger: Logger
38
- ) {}
39
-
40
- async import(importOptions: ImportOptions, packageManagerArgs: string[] = []): Promise<ImportResult> {
41
- if (!this.workspace) throw new OutsideWorkspaceError();
42
- const consumer = this.workspace.consumer;
43
- consumer.packageManagerArgs = packageManagerArgs;
44
- if (!importOptions.ids.length) {
45
- importOptions.objectsOnly = true;
46
- }
47
- if (this.workspace.consumer.isOnLane()) {
48
- const currentRemoteLane = await this.workspace.getCurrentRemoteLane();
49
- if (currentRemoteLane) {
50
- importOptions.lanes = { laneIds: [currentRemoteLane.toLaneId()], lanes: [currentRemoteLane] };
51
- } else if (!importOptions.ids.length) {
52
- // this is probably a local lane that was never exported.
53
- // although no need to fetch from the lane, still, the import is needed for main (which are available on this
54
- // local lane)
55
- const currentLaneId = this.workspace.getCurrentLaneId();
56
- importOptions.lanes = { laneIds: [currentLaneId], lanes: [] };
57
- }
58
- }
59
- const importComponents = new ImportComponents(
60
- this.workspace,
61
- this.graph,
62
- this.componentWriter,
63
- this.envs,
64
- importOptions
65
- );
66
- const results = await importComponents.importComponents();
67
- Analytics.setExtraData('num_components', results.importedIds.length);
68
- if (results.writtenComponents && results.writtenComponents.length) {
69
- await this.removeFromWorkspaceConfig(results.writtenComponents);
70
- }
71
- await consumer.onDestroy('import');
72
- return results;
73
- }
74
-
75
- /**
76
- * fetch objects according to the criteria set by `options` param.
77
- * to fetch current objects according to the current lane or main, use `this.importCurrentObjects()`.
78
- */
79
- async importObjects(options: Partial<ImportOptions> = {}): Promise<ImportResult> {
80
- const importOptions: ImportOptions = {
81
- ...options,
82
- objectsOnly: true,
83
- ids: options.ids || [],
84
- installNpmPackages: false,
85
- writeConfigFiles: false,
86
- };
87
- const importComponents = new ImportComponents(
88
- this.workspace,
89
- this.graph,
90
- this.componentWriter,
91
- this.envs,
92
- importOptions
93
- );
94
- return importComponents.importComponents();
95
- }
96
-
97
- /**
98
- * given a lane object, load all components by their head on the lane, find the artifacts refs and import them from
99
- * the lane scope
100
- */
101
- async importHeadArtifactsFromLane(lane: Lane, ids: ComponentID[] = lane.toBitIds(), throwIfMissing = false) {
102
- const laneComps = await this.scope.legacyScope.getManyConsumerComponents(ids);
103
- try {
104
- await importAllArtifacts(this.scope.legacyScope, laneComps, lane);
105
- } catch (err) {
106
- this.logger.error(`failed fetching artifacts for lane ${lane.id.toString()}`, err);
107
- if (throwIfMissing) throw err;
108
- }
109
- }
110
-
111
- /**
112
- * if on main, fetch main objects, if on lane, fetch lane objects.
113
- */
114
- async importCurrentObjects(): Promise<ImportResult> {
115
- if (!this.workspace) throw new OutsideWorkspaceError();
116
- const importOptions: ImportOptions = {
117
- ids: [],
118
- objectsOnly: true,
119
- installNpmPackages: false,
120
- writeConfigFiles: false,
121
- };
122
- const currentRemoteLane = await this.workspace.getCurrentRemoteLane();
123
- if (currentRemoteLane) {
124
- importOptions.lanes = { laneIds: [currentRemoteLane.toLaneId()], lanes: [currentRemoteLane] };
125
- }
126
- const importComponents = new ImportComponents(
127
- this.workspace,
128
- this.graph,
129
- this.componentWriter,
130
- this.envs,
131
- importOptions
132
- );
133
- return importComponents.importComponents();
134
- }
135
-
136
- async importObjectsFromMainIfExist(ids: ComponentID[]) {
137
- await this.scope.legacyScope.scopeImporter.importWithoutDeps(ComponentIdList.fromArray(ids), {
138
- cache: false,
139
- includeVersionHistory: true,
140
- ignoreMissingHead: true,
141
- });
142
- }
143
-
144
- /**
145
- * fetch lane's components and save them in the local scope.
146
- * once done, merge the lane object and save it as well.
147
- */
148
- async fetchLaneComponents(lane: Lane) {
149
- const ids = lane.toBitIds();
150
- await this.scope.legacyScope.scopeImporter.importMany({
151
- ids,
152
- lane,
153
- reason: `for fetching lane ${lane.id()}`,
154
- });
155
- const { mergeLane } = await this.scope.legacyScope.sources.mergeLane(lane, true);
156
- await this.scope.legacyScope.lanes.saveLane(mergeLane);
157
- }
158
-
159
- async fetch(ids: string[], lanes: boolean, components: boolean, fromOriginalScope: boolean, allHistory = false) {
160
- if (!lanes && !components) {
161
- throw new BitError(
162
- `please provide the type of objects you would like to pull, the options are --components and --lanes`
163
- );
164
- }
165
- loader.start('fetching objects...');
166
- if (!this.workspace) throw new OutsideWorkspaceError();
167
- const consumer = this.workspace.consumer;
168
-
169
- if (lanes) {
170
- const lanesToFetch = await getLanes(this.logger);
171
- const shouldFetchFromMain = !ids.length || ids.includes(DEFAULT_LANE);
172
- return this.fetchLanes(lanesToFetch, shouldFetchFromMain, { allHistory });
173
- }
174
-
175
- const importOptions: ImportOptions = {
176
- ids,
177
- objectsOnly: true,
178
- allHistory,
179
- verbose: false,
180
- writeConfig: false,
181
- override: false,
182
- installNpmPackages: false,
183
- writeConfigFiles: false,
184
- fromOriginalScope,
185
- };
186
-
187
- const importComponents = new ImportComponents(
188
- this.workspace,
189
- this.graph,
190
- this.componentWriter,
191
- this.envs,
192
- importOptions
193
- );
194
- const { importedIds, importDetails } = await importComponents.importComponents();
195
- Analytics.setExtraData('num_components', importedIds.length);
196
- await consumer.onDestroy('import');
197
- return { importedIds, importDetails };
198
-
199
- async function getLanes(logger: Logger): Promise<Lane[]> {
200
- let remoteLaneIds: LaneId[] = [];
201
- if (ids.length) {
202
- remoteLaneIds = ids
203
- .filter((id) => id !== DEFAULT_LANE)
204
- .map((id) => {
205
- const trackLane = consumer.scope.lanes.getRemoteTrackedDataByLocalLane(id);
206
- if (trackLane) return LaneId.from(trackLane.remoteLane, trackLane.remoteScope);
207
- return LaneId.parse(id);
208
- });
209
- } else {
210
- remoteLaneIds = await consumer.scope.objects.remoteLanes.getAllRemoteLaneIds();
211
- }
212
- const scopeComponentImporter = ScopeComponentsImporter.getInstance(consumer.scope);
213
- try {
214
- return await scopeComponentImporter.importLanes(remoteLaneIds);
215
- } catch (err: any) {
216
- if (
217
- err instanceof InvalidScopeName ||
218
- err instanceof ScopeNotFoundOrDenied ||
219
- err instanceof LaneNotFound ||
220
- err instanceof InvalidScopeNameFromRemote
221
- ) {
222
- // the lane could be a local lane so no need to throw an error in such case
223
- loader.stop();
224
- logger.console(`unable to get lane's data from a remote due to an error:\n${err.message}`, 'warn', 'yellow');
225
- } else {
226
- throw err;
227
- }
228
- }
229
-
230
- return [];
231
- }
232
- }
233
-
234
- async fetchLanes(
235
- lanes: Lane[],
236
- shouldFetchFromMain?: boolean,
237
- options: Partial<ImportOptions> = {}
238
- ): Promise<ImportResult> {
239
- const resultFromMain = shouldFetchFromMain
240
- ? await this.importObjects(options)
241
- : { importedIds: [], importDetails: [], importedDeps: [] };
242
- const resultsPerLane = await pMapSeries(lanes, async (lane) => {
243
- this.logger.setStatusLine(`fetching lane ${lane.name}`);
244
- options.lanes = { laneIds: [lane.toLaneId()], lanes: [lane] };
245
- options.isLaneFromRemote = true;
246
- const results = await this.importObjects(options);
247
- this.logger.consoleSuccess();
248
- return results;
249
- });
250
- resultsPerLane.push(resultFromMain);
251
- const results = resultsPerLane.reduce((acc, curr) => {
252
- acc.importedIds.push(...curr.importedIds);
253
- acc.importDetails.push(...curr.importDetails);
254
- return acc;
255
- });
256
- return results;
257
- }
258
-
259
- /**
260
- * get a Lane object from the remote.
261
- * `persistIfNotExists` saves the object in the local scope only if the lane is not there yet.
262
- * otherwise, it needs some merging mechanism, which is done differently whether it's export or import.
263
- * see `sources.mergeLane()` for export and `import-components._saveLaneDataIfNeeded()` for import.
264
- * in this case, because we only bring the lane object and not the components, it's not easy to do the merge.
265
- */
266
- async importLaneObject(laneId: LaneId, persistIfNotExists = true): Promise<Lane> {
267
- const legacyScope = this.scope.legacyScope;
268
- const results = await legacyScope.scopeImporter.importLanes([laneId]);
269
- const laneObject = results[0];
270
- if (!laneObject) throw new LaneNotFound(laneId.scope, laneId.name);
271
-
272
- if (persistIfNotExists) {
273
- const exists = await legacyScope.loadLane(laneId);
274
- if (!exists) {
275
- await legacyScope.lanes.saveLane(laneObject);
276
- }
277
- }
278
-
279
- return laneObject;
280
- }
281
-
282
- private async removeFromWorkspaceConfig(component: ConsumerComponent[]) {
283
- const importedPackageNames = this.getImportedPackagesNames(component);
284
- this.depResolver.removeFromRootPolicy(importedPackageNames);
285
- await this.depResolver.persistConfig(this.workspace.path);
286
- }
287
-
288
- private getImportedPackagesNames(components: ConsumerComponent[]): string[] {
289
- return components.map((component) => componentIdToPackageName(component));
290
- }
291
-
292
- static slots = [];
293
- static dependencies = [
294
- CLIAspect,
295
- WorkspaceAspect,
296
- DependencyResolverAspect,
297
- GraphAspect,
298
- ScopeAspect,
299
- ComponentWriterAspect,
300
- InstallAspect,
301
- EnvsAspect,
302
- LoggerAspect,
303
- ];
304
- static runtime = MainRuntime;
305
- static async provider([cli, workspace, depResolver, graph, scope, componentWriter, install, envs, loggerMain]: [
306
- CLIMain,
307
- Workspace,
308
- DependencyResolverMain,
309
- GraphMain,
310
- ScopeMain,
311
- ComponentWriterMain,
312
- InstallMain,
313
- EnvsMain,
314
- LoggerMain
315
- ]) {
316
- const logger = loggerMain.createLogger(ImporterAspect.id);
317
- const importerMain = new ImporterMain(workspace, depResolver, graph, scope, componentWriter, envs, logger);
318
- install.registerPreInstall(async (opts) => {
319
- if (!opts?.import) return;
320
- logger.setStatusLine('importing missing objects');
321
- await importerMain.importCurrentObjects();
322
- // logger.consoleSuccess();
323
- });
324
- install.registerPreLink(async (opts) => {
325
- if (opts?.fetchObject) await importerMain.importCurrentObjects();
326
- });
327
- cli.register(new ImportCmd(importerMain), new FetchCmd(importerMain));
328
- return importerMain;
329
- }
330
- }
331
-
332
- ImporterAspect.addRuntime(ImporterMain);
package/index.ts DELETED
@@ -1,6 +0,0 @@
1
- import { ImporterAspect } from './importer.aspect';
2
-
3
- export type { ImportOptions } from './import-components';
4
- export type { ImporterMain } from './importer.main.runtime';
5
- export default ImporterAspect;
6
- export { ImporterAspect };