@teambit/importer 1.0.159 → 1.0.161
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 +1 -1
- package/artifacts/preview/teambit_scope_importer-preview.js +1 -1
- package/artifacts/schema.json +87 -87
- package/dist/dependents-getter.d.ts +15 -0
- package/dist/dependents-getter.js +208 -0
- package/dist/dependents-getter.js.map +1 -0
- package/dist/import-components.d.ts +2 -2
- package/dist/import-components.js +11 -29
- package/dist/import-components.js.map +1 -1
- package/dist/import.cmd.d.ts +2 -1
- package/dist/import.cmd.js +10 -9
- package/dist/import.cmd.js.map +1 -1
- package/dist/importer.main.runtime.d.ts +1 -1
- package/dist/importer.main.runtime.js.map +1 -1
- package/dist/{preview-1707239008585.js → preview-1707362166593.js} +2 -2
- package/package.json +16 -15
|
@@ -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(compIds: ComponentID[]): Promise<ComponentID[]>;
|
|
13
|
+
private promptDependents;
|
|
14
|
+
private promptLevelByLevel;
|
|
15
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DependentsGetter = void 0;
|
|
7
|
+
function _yesno() {
|
|
8
|
+
const data = _interopRequireDefault(require("yesno"));
|
|
9
|
+
_yesno = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _enquirer() {
|
|
15
|
+
const data = require("enquirer");
|
|
16
|
+
_enquirer = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _lodash() {
|
|
22
|
+
const data = require("lodash");
|
|
23
|
+
_lodash = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
function _chalk() {
|
|
29
|
+
const data = _interopRequireDefault(require("chalk"));
|
|
30
|
+
_chalk = function () {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
function _componentId() {
|
|
36
|
+
const data = require("@teambit/component-id");
|
|
37
|
+
_componentId = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
function _bitError() {
|
|
43
|
+
const data = require("@teambit/bit-error");
|
|
44
|
+
_bitError = function () {
|
|
45
|
+
return data;
|
|
46
|
+
};
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
50
|
+
// @ts-ignore AutoComplete is actually there, the d.ts is probably outdated
|
|
51
|
+
|
|
52
|
+
const SHOW_ALL_PATHS_LIMIT = 10;
|
|
53
|
+
const SCROLL_LIMIT = 20;
|
|
54
|
+
class DependentsGetter {
|
|
55
|
+
constructor(logger, workspace, graph, options) {
|
|
56
|
+
this.logger = logger;
|
|
57
|
+
this.workspace = workspace;
|
|
58
|
+
this.graph = graph;
|
|
59
|
+
this.options = options;
|
|
60
|
+
}
|
|
61
|
+
async getDependents(compIds) {
|
|
62
|
+
this.logger.setStatusLine('finding dependents');
|
|
63
|
+
const {
|
|
64
|
+
silent
|
|
65
|
+
} = this.options;
|
|
66
|
+
const graph = await this.graph.getGraphIds();
|
|
67
|
+
const targetCompIds = await this.workspace.resolveMultipleComponentIds(compIds);
|
|
68
|
+
const sourceIds = await this.workspace.listIds();
|
|
69
|
+
const getIdsForThrough = () => {
|
|
70
|
+
if (!this.options.dependentsVia) return undefined;
|
|
71
|
+
return this.options.dependentsVia.split(',').map(idStr => idStr.trim()).map(id => _componentId().ComponentID.fromString(id));
|
|
72
|
+
};
|
|
73
|
+
const allPaths = graph.findAllPathsFromSourcesToTargets(sourceIds, targetCompIds, getIdsForThrough());
|
|
74
|
+
const selectedPaths = silent ? allPaths : await this.promptDependents(allPaths);
|
|
75
|
+
const uniqAsStrings = (0, _lodash().uniq)(selectedPaths.flat());
|
|
76
|
+
const ids = [];
|
|
77
|
+
const idsToFilterOut = _componentId().ComponentIdList.fromArray([...sourceIds, ...targetCompIds]);
|
|
78
|
+
uniqAsStrings.forEach(idStr => {
|
|
79
|
+
const id = _componentId().ComponentID.fromString(idStr);
|
|
80
|
+
if (idsToFilterOut.hasWithoutVersion(id)) return;
|
|
81
|
+
const sameIds = uniqAsStrings.filter(idString => idString.startsWith(`${id.toStringWithoutVersion()}@`));
|
|
82
|
+
const idToImport = sameIds.length === 1 ? id : id.changeVersion(undefined);
|
|
83
|
+
ids.push(idToImport);
|
|
84
|
+
idsToFilterOut.push(idToImport);
|
|
85
|
+
});
|
|
86
|
+
const idsStr = ids.map(id => id.toString());
|
|
87
|
+
this.logger.debug(`found ${ids.length} component for --dependents flag`, idsStr);
|
|
88
|
+
if (!this.options.silent) {
|
|
89
|
+
this.logger.clearStatusLine();
|
|
90
|
+
const question = idsStr.length ? `found the following ${ids.length} components for --dependents flag:\n${idsStr.join('\n')}` : 'unable to find dependents for the given component (probably the workspace components using it directly)';
|
|
91
|
+
const ok = await (0, _yesno().default)({
|
|
92
|
+
question: `${question}\nWould you like to continue with the import? [yes(y)/no(n)]`
|
|
93
|
+
});
|
|
94
|
+
if (!ok) {
|
|
95
|
+
throw new (_bitError().BitError)('import was aborted');
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return ids;
|
|
99
|
+
}
|
|
100
|
+
async promptDependents(allPaths) {
|
|
101
|
+
if (!allPaths.length) return [];
|
|
102
|
+
this.logger.clearStatusLine();
|
|
103
|
+
const totalToShow = SHOW_ALL_PATHS_LIMIT;
|
|
104
|
+
if (allPaths.length >= totalToShow) {
|
|
105
|
+
return this.promptLevelByLevel(allPaths);
|
|
106
|
+
}
|
|
107
|
+
const firstItems = allPaths.slice(0, totalToShow);
|
|
108
|
+
const choices = firstItems.map(path => {
|
|
109
|
+
const name = path.join(' -> ');
|
|
110
|
+
return {
|
|
111
|
+
name,
|
|
112
|
+
value: path
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
const tooManyPathsMsg = allPaths.length > totalToShow ? `${_chalk().default.yellow(`\nfound ${allPaths.length} paths, showing the shortest ${totalToShow}. if the desired path is not shown, use the --dependents-via flag`)}` : '';
|
|
116
|
+
const result = await (0, _enquirer().prompt)({
|
|
117
|
+
choices,
|
|
118
|
+
footer: '\nEnter to start importing. Ctrl+C to cancel.',
|
|
119
|
+
indicator: (state, choice) => ` ${choice.enabled ? '●' : '○'}`,
|
|
120
|
+
message: 'Choose which path to include ' + `(Press ${_chalk().default.cyan('<space>')} to select, ` + `${_chalk().default.cyan('<a>')} to toggle all, ` + `${_chalk().default.cyan('<i>')} to invert selection)${tooManyPathsMsg}`,
|
|
121
|
+
name: 'selectDependents',
|
|
122
|
+
pointer: '❯',
|
|
123
|
+
styles: {
|
|
124
|
+
dark: _chalk().default.white,
|
|
125
|
+
em: _chalk().default.bgBlack.whiteBright,
|
|
126
|
+
success: _chalk().default.white
|
|
127
|
+
},
|
|
128
|
+
type: 'multiselect',
|
|
129
|
+
validate(value) {
|
|
130
|
+
if (value.length === 0) {
|
|
131
|
+
return 'You must choose at least one path.';
|
|
132
|
+
}
|
|
133
|
+
return true;
|
|
134
|
+
},
|
|
135
|
+
j() {
|
|
136
|
+
return this.down();
|
|
137
|
+
},
|
|
138
|
+
k() {
|
|
139
|
+
return this.up();
|
|
140
|
+
},
|
|
141
|
+
result(names) {
|
|
142
|
+
// This is needed in order to have the values of the choices in the answer object.
|
|
143
|
+
// Otherwise, only the names of the selected choices would've been included.
|
|
144
|
+
return this.map(names);
|
|
145
|
+
},
|
|
146
|
+
cancel() {
|
|
147
|
+
// By default, canceling the prompt via Ctrl+c throws an empty string.
|
|
148
|
+
// The custom cancel function prevents that behavior.
|
|
149
|
+
// Otherwise, Bit CLI would print an error and confuse users.
|
|
150
|
+
// See related issue: https://github.com/enquirer/enquirer/issues/225
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
return Object.values(result.selectDependents);
|
|
154
|
+
}
|
|
155
|
+
async promptLevelByLevel(allPaths) {
|
|
156
|
+
if (allPaths.length < SHOW_ALL_PATHS_LIMIT) {
|
|
157
|
+
throw new Error(`expected to have at least ${SHOW_ALL_PATHS_LIMIT} paths`);
|
|
158
|
+
}
|
|
159
|
+
const finalPath = [];
|
|
160
|
+
this.logger.console(`found ${allPaths.length} available paths from the workspace components to the target components.
|
|
161
|
+
the following prompts will guide you to choose the desired path to import.`);
|
|
162
|
+
const getPrompt = (choices, level, totalPaths) => {
|
|
163
|
+
return new (_enquirer().AutoComplete)({
|
|
164
|
+
name: 'comp',
|
|
165
|
+
message: `Choose which component to include`,
|
|
166
|
+
limit: SCROLL_LIMIT,
|
|
167
|
+
footer() {
|
|
168
|
+
return choices.length >= SCROLL_LIMIT ? _chalk().default.dim('(Scroll up and down to reveal more choices)') : '';
|
|
169
|
+
},
|
|
170
|
+
header() {
|
|
171
|
+
if (level === 1) return '';
|
|
172
|
+
return `total ${totalPaths} paths left (out of ${allPaths.length})`;
|
|
173
|
+
},
|
|
174
|
+
cancel() {
|
|
175
|
+
// By default, canceling the prompt via Ctrl+c throws an empty string.
|
|
176
|
+
// The custom cancel function prevents that behavior.
|
|
177
|
+
// Otherwise, Bit CLI would print an error and confuse users.
|
|
178
|
+
// See related issue: https://github.com/enquirer/enquirer/issues/225
|
|
179
|
+
},
|
|
180
|
+
choices
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
const getLevel = (level, withinPaths) => {
|
|
184
|
+
return (0, _lodash().compact)((0, _lodash().uniq)(withinPaths.map(path => path[level]))).sort();
|
|
185
|
+
};
|
|
186
|
+
const processLevel = async (level, paths, previousLevel) => {
|
|
187
|
+
const pathsWithinThisLevel = previousLevel ? paths.filter(path => path[level] === previousLevel) : paths;
|
|
188
|
+
const nextLevel = getLevel(level + 1, pathsWithinThisLevel);
|
|
189
|
+
if (!nextLevel.length) {
|
|
190
|
+
return finalPath;
|
|
191
|
+
}
|
|
192
|
+
if (nextLevel.length === 1) {
|
|
193
|
+
finalPath.push(nextLevel[0]);
|
|
194
|
+
this.logger.consoleSuccess(`${nextLevel[0]} (auto-selected)`);
|
|
195
|
+
return processLevel(level + 1, pathsWithinThisLevel, nextLevel[0]);
|
|
196
|
+
}
|
|
197
|
+
const promptNextLevel = getPrompt(nextLevel, level + 1, pathsWithinThisLevel.length);
|
|
198
|
+
const resultNextLevel = await promptNextLevel.run();
|
|
199
|
+
finalPath.push(resultNextLevel);
|
|
200
|
+
return processLevel(level + 1, pathsWithinThisLevel, resultNextLevel);
|
|
201
|
+
};
|
|
202
|
+
const result = await processLevel(0, allPaths);
|
|
203
|
+
return [result];
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
exports.DependentsGetter = DependentsGetter;
|
|
207
|
+
|
|
208
|
+
//# sourceMappingURL=dependents-getter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_yesno","data","_interopRequireDefault","require","_enquirer","_lodash","_chalk","_componentId","_bitError","obj","__esModule","default","SHOW_ALL_PATHS_LIMIT","SCROLL_LIMIT","DependentsGetter","constructor","logger","workspace","graph","options","getDependents","compIds","setStatusLine","silent","getGraphIds","targetCompIds","resolveMultipleComponentIds","sourceIds","listIds","getIdsForThrough","dependentsVia","undefined","split","map","idStr","trim","id","ComponentID","fromString","allPaths","findAllPathsFromSourcesToTargets","selectedPaths","promptDependents","uniqAsStrings","uniq","flat","ids","idsToFilterOut","ComponentIdList","fromArray","forEach","hasWithoutVersion","sameIds","filter","idString","startsWith","toStringWithoutVersion","idToImport","length","changeVersion","push","idsStr","toString","debug","clearStatusLine","question","join","ok","yesno","BitError","totalToShow","promptLevelByLevel","firstItems","slice","choices","path","name","value","tooManyPathsMsg","chalk","yellow","result","prompt","footer","indicator","state","choice","enabled","message","cyan","pointer","styles","dark","white","em","bgBlack","whiteBright","success","type","validate","j","down","k","up","names","cancel","Object","values","selectDependents","Error","finalPath","console","getPrompt","level","totalPaths","AutoComplete","limit","dim","header","getLevel","withinPaths","compact","sort","processLevel","paths","previousLevel","pathsWithinThisLevel","nextLevel","consoleSuccess","promptNextLevel","resultNextLevel","run","exports"],"sources":["dependents-getter.ts"],"sourcesContent":["import yesno from 'yesno';\n// @ts-ignore AutoComplete is actually there, the d.ts is probably outdated\nimport { prompt, AutoComplete } from 'enquirer';\nimport { compact, uniq } from 'lodash';\nimport chalk from 'chalk';\nimport { ComponentID, ComponentIdList } from '@teambit/component-id';\nimport { GraphMain } from '@teambit/graph';\nimport { Logger } from '@teambit/logger';\nimport { Workspace } from '@teambit/workspace';\nimport { BitError } from '@teambit/bit-error';\nimport { ImportOptions } from './import-components';\n\nconst SHOW_ALL_PATHS_LIMIT = 10;\nconst SCROLL_LIMIT = 20;\n\nexport class DependentsGetter {\n constructor(\n private logger: Logger,\n private workspace: Workspace,\n private graph: GraphMain,\n private options: ImportOptions\n ) {}\n\n async getDependents(compIds: ComponentID[]): Promise<ComponentID[]> {\n this.logger.setStatusLine('finding dependents');\n const { silent } = this.options;\n const graph = await this.graph.getGraphIds();\n const targetCompIds = await this.workspace.resolveMultipleComponentIds(compIds);\n const sourceIds = await this.workspace.listIds();\n const getIdsForThrough = () => {\n if (!this.options.dependentsVia) return undefined;\n return this.options.dependentsVia\n .split(',')\n .map((idStr) => idStr.trim())\n .map((id) => ComponentID.fromString(id));\n };\n const allPaths = graph.findAllPathsFromSourcesToTargets(sourceIds, targetCompIds, getIdsForThrough());\n const selectedPaths = silent ? allPaths : await this.promptDependents(allPaths);\n const uniqAsStrings = uniq(selectedPaths.flat());\n\n const ids: ComponentID[] = [];\n const idsToFilterOut = ComponentIdList.fromArray([...sourceIds, ...targetCompIds]);\n uniqAsStrings.forEach((idStr) => {\n const id = ComponentID.fromString(idStr);\n if (idsToFilterOut.hasWithoutVersion(id)) return;\n const sameIds = uniqAsStrings.filter((idString) => idString.startsWith(`${id.toStringWithoutVersion()}@`));\n const idToImport = sameIds.length === 1 ? id : id.changeVersion(undefined);\n ids.push(idToImport);\n idsToFilterOut.push(idToImport);\n });\n\n const idsStr = ids.map((id) => id.toString());\n\n this.logger.debug(`found ${ids.length} component for --dependents flag`, idsStr);\n if (!this.options.silent) {\n this.logger.clearStatusLine();\n const question = idsStr.length\n ? `found the following ${ids.length} components for --dependents flag:\\n${idsStr.join('\\n')}`\n : 'unable to find dependents for the given component (probably the workspace components using it directly)';\n const ok = await yesno({\n question: `${question}\\nWould you like to continue with the import? [yes(y)/no(n)]`,\n });\n if (!ok) {\n throw new BitError('import was aborted');\n }\n }\n\n return ids;\n }\n\n private async promptDependents(allPaths: string[][]): Promise<string[][]> {\n if (!allPaths.length) return [];\n this.logger.clearStatusLine();\n\n const totalToShow = SHOW_ALL_PATHS_LIMIT;\n if (allPaths.length >= totalToShow) {\n return this.promptLevelByLevel(allPaths);\n }\n const firstItems = allPaths.slice(0, totalToShow);\n const choices = firstItems.map((path) => {\n const name = path.join(' -> ');\n return { name, value: path };\n });\n const tooManyPathsMsg =\n allPaths.length > totalToShow\n ? `${chalk.yellow(\n `\\nfound ${allPaths.length} paths, showing the shortest ${totalToShow}. if the desired path is not shown, use the --dependents-via flag`\n )}`\n : '';\n const result = await prompt<{ selectDependents: Record<string, string[]> }>({\n choices,\n footer: '\\nEnter to start importing. Ctrl+C to cancel.',\n indicator: (state: any, choice: any) => ` ${choice.enabled ? '●' : '○'}`,\n message:\n 'Choose which path to include ' +\n `(Press ${chalk.cyan('<space>')} to select, ` +\n `${chalk.cyan('<a>')} to toggle all, ` +\n `${chalk.cyan('<i>')} to invert selection)${tooManyPathsMsg}`,\n name: 'selectDependents',\n pointer: '❯',\n styles: {\n dark: chalk.white,\n em: chalk.bgBlack.whiteBright,\n success: chalk.white,\n },\n type: 'multiselect',\n validate(value: string[]) {\n if (value.length === 0) {\n return 'You must choose at least one path.';\n }\n return true;\n },\n j() {\n return this.down();\n },\n k() {\n return this.up();\n },\n result(names: string[]) {\n // This is needed in order to have the values of the choices in the answer object.\n // Otherwise, only the names of the selected choices would've been included.\n return this.map(names);\n },\n cancel() {\n // By default, canceling the prompt via Ctrl+c throws an empty string.\n // The custom cancel function prevents that behavior.\n // Otherwise, Bit CLI would print an error and confuse users.\n // See related issue: https://github.com/enquirer/enquirer/issues/225\n },\n } as any);\n\n return Object.values(result.selectDependents);\n }\n\n private async promptLevelByLevel(allPaths: string[][]): Promise<string[][]> {\n if (allPaths.length < SHOW_ALL_PATHS_LIMIT) {\n throw new Error(`expected to have at least ${SHOW_ALL_PATHS_LIMIT} paths`);\n }\n const finalPath: string[] = [];\n this.logger\n .console(`found ${allPaths.length} available paths from the workspace components to the target components.\nthe following prompts will guide you to choose the desired path to import.`);\n\n const getPrompt = (choices: string[], level: number, totalPaths: number) => {\n return new AutoComplete({\n name: 'comp',\n message: `Choose which component to include`,\n limit: SCROLL_LIMIT,\n footer() {\n return choices.length >= SCROLL_LIMIT ? chalk.dim('(Scroll up and down to reveal more choices)') : '';\n },\n header() {\n if (level === 1) return '';\n return `total ${totalPaths} paths left (out of ${allPaths.length})`;\n },\n cancel() {\n // By default, canceling the prompt via Ctrl+c throws an empty string.\n // The custom cancel function prevents that behavior.\n // Otherwise, Bit CLI would print an error and confuse users.\n // See related issue: https://github.com/enquirer/enquirer/issues/225\n },\n choices,\n });\n };\n\n const getLevel = (level: number, withinPaths: string[][]): string[] => {\n return compact(uniq(withinPaths.map((path) => path[level]))).sort();\n };\n\n const processLevel = async (level: number, paths: string[][], previousLevel?: string): Promise<string[]> => {\n const pathsWithinThisLevel = previousLevel ? paths.filter((path) => path[level] === previousLevel) : paths;\n const nextLevel = getLevel(level + 1, pathsWithinThisLevel);\n if (!nextLevel.length) {\n return finalPath;\n }\n if (nextLevel.length === 1) {\n finalPath.push(nextLevel[0]);\n this.logger.consoleSuccess(`${nextLevel[0]} (auto-selected)`);\n return processLevel(level + 1, pathsWithinThisLevel, nextLevel[0]);\n }\n const promptNextLevel = getPrompt(nextLevel, level + 1, pathsWithinThisLevel.length);\n const resultNextLevel = await promptNextLevel.run();\n finalPath.push(resultNextLevel);\n return processLevel(level + 1, pathsWithinThisLevel, resultNextLevel);\n };\n\n const result = await processLevel(0, allPaths);\n\n return [result];\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,UAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,OAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,MAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,aAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,YAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAA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GAAGD,aAAa,GAAGD,KAAK,CAACvE,MAAM,CAAEsB,IAAI,IAAKA,IAAI,CAACsC,KAAK,CAAC,KAAKY,aAAa,CAAC,GAAGD,KAAK;MAC1G,MAAMG,SAAS,GAAGR,QAAQ,CAACN,KAAK,GAAG,CAAC,EAAEa,oBAAoB,CAAC;MAC3D,IAAI,CAACC,SAAS,CAACrE,MAAM,EAAE;QACrB,OAAOoD,SAAS;MAClB;MACA,IAAIiB,SAAS,CAACrE,MAAM,KAAK,CAAC,EAAE;QAC1BoD,SAAS,CAAClD,IAAI,CAACmE,SAAS,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,CAAC/G,MAAM,CAACgH,cAAc,CAAE,GAAED,SAAS,CAAC,CAAC,CAAE,kBAAiB,CAAC;QAC7D,OAAOJ,YAAY,CAACV,KAAK,GAAG,CAAC,EAAEa,oBAAoB,EAAEC,SAAS,CAAC,CAAC,CAAC,CAAC;MACpE;MACA,MAAME,eAAe,GAAGjB,SAAS,CAACe,SAAS,EAAEd,KAAK,GAAG,CAAC,EAAEa,oBAAoB,CAACpE,MAAM,CAAC;MACpF,MAAMwE,eAAe,GAAG,MAAMD,eAAe,CAACE,GAAG,CAAC,CAAC;MACnDrB,SAAS,CAAClD,IAAI,CAACsE,eAAe,CAAC;MAC/B,OAAOP,YAAY,CAACV,KAAK,GAAG,CAAC,EAAEa,oBAAoB,EAAEI,eAAe,CAAC;IACvE,CAAC;IAED,MAAMjD,MAAM,GAAG,MAAM0C,YAAY,CAAC,CAAC,EAAEpF,QAAQ,CAAC;IAE9C,OAAO,CAAC0C,MAAM,CAAC;EACjB;AACF;AAACmD,OAAA,CAAAtH,gBAAA,GAAAA,gBAAA"}
|
|
@@ -28,8 +28,8 @@ export type ImportOptions = {
|
|
|
28
28
|
objectsOnly?: boolean;
|
|
29
29
|
importDependenciesDirectly?: boolean;
|
|
30
30
|
importDependents?: boolean;
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
dependentsVia?: string;
|
|
32
|
+
silent?: boolean;
|
|
33
33
|
fromOriginalScope?: boolean;
|
|
34
34
|
saveInLane?: boolean;
|
|
35
35
|
lanes?: {
|
|
@@ -4,13 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
function _yesno() {
|
|
8
|
-
const data = _interopRequireDefault(require("yesno"));
|
|
9
|
-
_yesno = function () {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
7
|
function _bitError() {
|
|
15
8
|
const data = require("@teambit/bit-error");
|
|
16
9
|
_bitError = function () {
|
|
@@ -116,6 +109,13 @@ function _lodash() {
|
|
|
116
109
|
};
|
|
117
110
|
return data;
|
|
118
111
|
}
|
|
112
|
+
function _dependentsGetter() {
|
|
113
|
+
const data = require("./dependents-getter");
|
|
114
|
+
_dependentsGetter = function () {
|
|
115
|
+
return data;
|
|
116
|
+
};
|
|
117
|
+
return data;
|
|
118
|
+
}
|
|
119
119
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
120
120
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
121
121
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
@@ -393,34 +393,16 @@ bit import ${idsFromRemote.map(id => id.toStringWithoutVersion()).join(' ')}`);
|
|
|
393
393
|
}
|
|
394
394
|
async getBitIds() {
|
|
395
395
|
const bitIds = this.options.lanes ? await this.getBitIdsForLanes() : await this.getBitIdsForNonLanes();
|
|
396
|
-
const shouldImportDependents = this.options.importDependents || this.options.
|
|
396
|
+
const shouldImportDependents = this.options.importDependents || this.options.dependentsVia;
|
|
397
397
|
if (this.options.importDependenciesDirectly || shouldImportDependents) {
|
|
398
398
|
if (this.options.importDependenciesDirectly) {
|
|
399
399
|
const dependenciesIds = await this.getFlattenedDepsUnique(bitIds);
|
|
400
400
|
bitIds.push(...dependenciesIds);
|
|
401
401
|
}
|
|
402
402
|
if (shouldImportDependents) {
|
|
403
|
-
this.logger.
|
|
404
|
-
const
|
|
405
|
-
|
|
406
|
-
const sourceIds = await this.workspace.listIds();
|
|
407
|
-
const getIdsForThrough = () => {
|
|
408
|
-
if (!this.options.dependentsThrough) return undefined;
|
|
409
|
-
return this.options.dependentsThrough.split(',').map(idStr => idStr.trim()).map(id => _componentId().ComponentID.fromString(id));
|
|
410
|
-
};
|
|
411
|
-
const ids = graph.findIdsFromSourcesToTargets(sourceIds, targetCompIds, getIdsForThrough());
|
|
412
|
-
const idsStr = ids.map(id => id.toString());
|
|
413
|
-
this.logger.debug(`found ${ids.length} component for --dependents flag`, idsStr);
|
|
414
|
-
if (this.options.dependentsDryRun) {
|
|
415
|
-
this.logger.clearStatusLine();
|
|
416
|
-
const ok = await (0, _yesno().default)({
|
|
417
|
-
question: `found the following ${ids.length} components for --dependents flag:\n${idsStr.join('\n')}\nWould you like to continue with the import?`
|
|
418
|
-
});
|
|
419
|
-
if (!ok) {
|
|
420
|
-
throw new (_bitError().BitError)('import was aborted');
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
bitIds.push(...ids);
|
|
403
|
+
const dependentsGetter = new (_dependentsGetter().DependentsGetter)(this.logger, this.workspace, this.graph, this.options);
|
|
404
|
+
const dependents = await dependentsGetter.getDependents(bitIds);
|
|
405
|
+
bitIds.push(...dependents);
|
|
424
406
|
}
|
|
425
407
|
}
|
|
426
408
|
return _componentId().ComponentIdList.uniqFromArray(bitIds);
|