@teambit/merging 0.0.1
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/dist/index.d.ts +5 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/merge-cmd.d.ts +25 -0
- package/dist/merge-cmd.js +185 -0
- package/dist/merge-cmd.js.map +1 -0
- package/dist/merging.aspect.d.ts +2 -0
- package/dist/merging.aspect.js +24 -0
- package/dist/merging.aspect.js.map +1 -0
- package/dist/merging.main.runtime.d.ts +67 -0
- package/dist/merging.main.runtime.js +776 -0
- package/dist/merging.main.runtime.js.map +1 -0
- package/package-tar/teambit-merging-0.0.1.tgz +0 -0
- package/package.json +88 -0
- package/preview-1648092203429.js +1 -0
- package/tsconfig.json +34 -0
- package/types/asset.d.ts +29 -0
- package/types/style.d.ts +42 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "MergingAspect", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _merging().MergingAspect;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.default = void 0;
|
|
13
|
+
Object.defineProperty(exports, "mergeReport", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _mergeCmd().mergeReport;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
function _merging() {
|
|
21
|
+
const data = require("./merging.aspect");
|
|
22
|
+
|
|
23
|
+
_merging = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function _mergeCmd() {
|
|
31
|
+
const data = require("./merge-cmd");
|
|
32
|
+
|
|
33
|
+
_mergeCmd = function () {
|
|
34
|
+
return data;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return data;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
var _default = _merging().MergingAspect;
|
|
41
|
+
|
|
42
|
+
exports.default = _default;
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["MergingAspect"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;eAEeA,wB","sourcesContent":["import { MergingAspect } from './merging.aspect';\n\nexport { mergeReport } from './merge-cmd';\nexport type { MergingMain } from './merging.main.runtime';\nexport default MergingAspect;\nexport { MergingAspect };\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Command, CommandOptions } from '@teambit/cli';
|
|
2
|
+
import { ApplyVersionResults } from '@teambit/legacy/dist/consumer/versions-ops/merge-version';
|
|
3
|
+
import { MergingMain } from './merging.main.runtime';
|
|
4
|
+
export declare class MergeCmd implements Command {
|
|
5
|
+
private merging;
|
|
6
|
+
name: string;
|
|
7
|
+
shortDescription: string;
|
|
8
|
+
group: string;
|
|
9
|
+
description: string;
|
|
10
|
+
alias: string;
|
|
11
|
+
options: CommandOptions;
|
|
12
|
+
loader: boolean;
|
|
13
|
+
constructor(merging: MergingMain);
|
|
14
|
+
report([values]: [string[]], { ours, theirs, manual, abort, resolve, build, noSnap, message, }: {
|
|
15
|
+
ours?: boolean;
|
|
16
|
+
theirs?: boolean;
|
|
17
|
+
manual?: boolean;
|
|
18
|
+
abort?: boolean;
|
|
19
|
+
resolve?: boolean;
|
|
20
|
+
build?: boolean;
|
|
21
|
+
noSnap?: boolean;
|
|
22
|
+
message: string;
|
|
23
|
+
}): Promise<string>;
|
|
24
|
+
}
|
|
25
|
+
export declare function mergeReport({ components, failedComponents, version, mergeSnapResults }: ApplyVersionResults): string;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.array.iterator.js");
|
|
6
|
+
|
|
7
|
+
require("core-js/modules/es.promise.js");
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
|
+
value: true
|
|
11
|
+
});
|
|
12
|
+
exports.MergeCmd = void 0;
|
|
13
|
+
exports.mergeReport = mergeReport;
|
|
14
|
+
|
|
15
|
+
function _defineProperty2() {
|
|
16
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
+
|
|
18
|
+
_defineProperty2 = function () {
|
|
19
|
+
return data;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function _chalk() {
|
|
26
|
+
const data = _interopRequireDefault(require("chalk"));
|
|
27
|
+
|
|
28
|
+
_chalk = function () {
|
|
29
|
+
return data;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return data;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function _constants() {
|
|
36
|
+
const data = require("@teambit/legacy/dist/constants");
|
|
37
|
+
|
|
38
|
+
_constants = function () {
|
|
39
|
+
return data;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return data;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function _mergeVersion() {
|
|
46
|
+
const data = require("@teambit/legacy/dist/consumer/versions-ops/merge-version");
|
|
47
|
+
|
|
48
|
+
_mergeVersion = function () {
|
|
49
|
+
return data;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return data;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function _featureToggle() {
|
|
56
|
+
const data = require("@teambit/legacy/dist/api/consumer/lib/feature-toggle");
|
|
57
|
+
|
|
58
|
+
_featureToggle = function () {
|
|
59
|
+
return data;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return data;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function _bitError() {
|
|
66
|
+
const data = require("@teambit/bit-error");
|
|
67
|
+
|
|
68
|
+
_bitError = function () {
|
|
69
|
+
return data;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return data;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
class MergeCmd {
|
|
76
|
+
constructor(merging) {
|
|
77
|
+
this.merging = merging;
|
|
78
|
+
(0, _defineProperty2().default)(this, "name", 'merge [values...]');
|
|
79
|
+
(0, _defineProperty2().default)(this, "shortDescription", 'merge changes of different component versions');
|
|
80
|
+
(0, _defineProperty2().default)(this, "group", 'development');
|
|
81
|
+
(0, _defineProperty2().default)(this, "description", `merge changes of different component versions
|
|
82
|
+
\`bit merge <version> [ids...]\` => merge changes of the given version into the checked out version
|
|
83
|
+
\`bit merge [ids...]\` => EXPERIMENTAL. merge changes of the remote head into local, optionally use '--abort' or '--resolve'
|
|
84
|
+
${(0, _constants().WILDCARD_HELP)('merge 0.0.1')}`);
|
|
85
|
+
(0, _defineProperty2().default)(this, "alias", '');
|
|
86
|
+
(0, _defineProperty2().default)(this, "options", [['', 'ours', 'in case of a conflict, override the used version with the current modification'], ['', 'theirs', 'in case of a conflict, override the current modification with the specified version'], ['', 'manual', 'in case of a conflict, leave the files with a conflict state to resolve them manually later'], ['', 'abort', 'EXPERIMENTAL. in case of an unresolved merge, revert to the state before the merge began'], ['', 'resolve', 'EXPERIMENTAL. mark an unresolved merge as resolved and create a new snap with the changes'], ['', 'no-snap', 'EXPERIMENTAL. do not auto snap in case the merge completed without conflicts'], ['', 'build', 'in case of snap during the merge, run the build-pipeline (similar to bit snap --build)'], ['m', 'message <message>', 'EXPERIMENTAL. override the default message for the auto snap']]);
|
|
87
|
+
(0, _defineProperty2().default)(this, "loader", true);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async report([values = []], {
|
|
91
|
+
ours = false,
|
|
92
|
+
theirs = false,
|
|
93
|
+
manual = false,
|
|
94
|
+
abort = false,
|
|
95
|
+
resolve = false,
|
|
96
|
+
build = false,
|
|
97
|
+
noSnap = false,
|
|
98
|
+
message
|
|
99
|
+
}) {
|
|
100
|
+
build = (0, _featureToggle().isFeatureEnabled)(_featureToggle().BUILD_ON_CI) ? Boolean(build) : true;
|
|
101
|
+
const mergeStrategy = (0, _mergeVersion().getMergeStrategy)(ours, theirs, manual);
|
|
102
|
+
if (abort && resolve) throw new (_bitError().BitError)('unable to use "abort" and "resolve" flags together');
|
|
103
|
+
if (noSnap && message) throw new (_bitError().BitError)('unable to use "noSnap" and "message" flags together');
|
|
104
|
+
const {
|
|
105
|
+
components,
|
|
106
|
+
failedComponents,
|
|
107
|
+
version,
|
|
108
|
+
resolvedComponents,
|
|
109
|
+
abortedComponents,
|
|
110
|
+
mergeSnapResults
|
|
111
|
+
} = await this.merging.merge(values, mergeStrategy, abort, resolve, noSnap, message, build);
|
|
112
|
+
|
|
113
|
+
if (resolvedComponents) {
|
|
114
|
+
const title = 'successfully resolved component(s)\n';
|
|
115
|
+
const componentsStr = resolvedComponents.map(c => c.id.toStringWithoutVersion()).join('\n');
|
|
116
|
+
return _chalk().default.underline(title) + _chalk().default.green(componentsStr);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (abortedComponents) {
|
|
120
|
+
const title = 'successfully aborted the merge of the following component(s)\n';
|
|
121
|
+
const componentsStr = abortedComponents.map(c => c.id.toStringWithoutVersion()).join('\n');
|
|
122
|
+
return _chalk().default.underline(title) + _chalk().default.green(componentsStr);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return mergeReport({
|
|
126
|
+
components,
|
|
127
|
+
failedComponents,
|
|
128
|
+
version,
|
|
129
|
+
mergeSnapResults
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
exports.MergeCmd = MergeCmd;
|
|
136
|
+
|
|
137
|
+
function mergeReport({
|
|
138
|
+
components,
|
|
139
|
+
failedComponents,
|
|
140
|
+
version,
|
|
141
|
+
mergeSnapResults
|
|
142
|
+
}) {
|
|
143
|
+
const getSuccessOutput = () => {
|
|
144
|
+
if (!components || !components.length) return ''; // @ts-ignore version is set in case of merge command
|
|
145
|
+
|
|
146
|
+
const title = `successfully merged components${version ? `from version ${_chalk().default.bold(version)}` : ''}\n`; // @ts-ignore components is set in case of merge command
|
|
147
|
+
|
|
148
|
+
return _chalk().default.underline(title) + _chalk().default.green((0, _mergeVersion().applyVersionReport)(components));
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const getSnapsOutput = () => {
|
|
152
|
+
if (!mergeSnapResults || !mergeSnapResults.snappedComponents) return '';
|
|
153
|
+
const {
|
|
154
|
+
snappedComponents,
|
|
155
|
+
autoSnappedResults
|
|
156
|
+
} = mergeSnapResults;
|
|
157
|
+
|
|
158
|
+
const outputComponents = comps => {
|
|
159
|
+
return comps.map(component => {
|
|
160
|
+
let componentOutput = ` > ${component.id.toString()}`;
|
|
161
|
+
const autoTag = autoSnappedResults.filter(result => result.triggeredBy.searchWithoutScopeAndVersion(component.id));
|
|
162
|
+
|
|
163
|
+
if (autoTag.length) {
|
|
164
|
+
const autoTagComp = autoTag.map(a => a.component.id.toString());
|
|
165
|
+
componentOutput += `\n ${_constants().AUTO_SNAPPED_MSG}: ${autoTagComp.join(', ')}`;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return componentOutput;
|
|
169
|
+
}).join('\n');
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
return `\n${_chalk().default.underline('merge-snapped components')}\n(${'components that snapped as a result of the merge'})\n${outputComponents(snappedComponents)}\n`;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const getFailureOutput = () => {
|
|
176
|
+
if (!failedComponents || !failedComponents.length) return '';
|
|
177
|
+
const title = 'the merge has been canceled on the following component(s)';
|
|
178
|
+
const body = failedComponents.map(failedComponent => `${_chalk().default.bold(failedComponent.id.toString())} - ${_chalk().default.red(failedComponent.failureMessage)}`).join('\n');
|
|
179
|
+
return `${_chalk().default.underline(title)}\n${body}\n\n`;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
return getSuccessOutput() + getFailureOutput() + getSnapsOutput();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
//# sourceMappingURL=merge-cmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["merge-cmd.ts"],"names":["MergeCmd","constructor","merging","report","values","ours","theirs","manual","abort","resolve","build","noSnap","message","BUILD_ON_CI","Boolean","mergeStrategy","BitError","components","failedComponents","version","resolvedComponents","abortedComponents","mergeSnapResults","merge","title","componentsStr","map","c","id","toStringWithoutVersion","join","chalk","underline","green","mergeReport","getSuccessOutput","length","bold","getSnapsOutput","snappedComponents","autoSnappedResults","outputComponents","comps","component","componentOutput","toString","autoTag","filter","result","triggeredBy","searchWithoutScopeAndVersion","autoTagComp","a","AUTO_SNAPPED_MSG","getFailureOutput","body","failedComponent","red","failureMessage"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAKA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,QAAN,CAAkC;AAqBvCC,EAAAA,WAAW,CAASC,OAAT,EAA+B;AAAA,SAAtBA,OAAsB,GAAtBA,OAAsB;AAAA,kDApBnC,mBAoBmC;AAAA,8DAnBvB,+CAmBuB;AAAA,mDAlBlC,aAkBkC;AAAA,yDAjB3B;AACjB;AACA;AACA,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B,GAAG,MAAM;AAC7B,QAAI,CAACpC,gBAAD,IAAqB,CAACA,gBAAgB,CAACkB,MAA3C,EAAmD,OAAO,EAAP;AACnD,UAAMZ,KAAK,GAAG,2DAAd;AACA,UAAM+B,IAAI,GAAGrC,gBAAgB,CAC1BQ,GADU,CAER8B,eAAD,IACG,GAAEzB,iBAAMM,IAAN,CAAWmB,eAAe,CAAC5B,EAAhB,CAAmBiB,QAAnB,EAAX,CAA0C,MAAKd,iBAAM0B,GAAN,CAAUD,eAAe,CAACE,cAA1B,CAA0C,EAHrF,EAKV5B,IALU,CAKL,IALK,CAAb;AAMA,WAAQ,GAAEC,iBAAMC,SAAN,CAAgBR,KAAhB,CAAuB,KAAI+B,IAAK,MAA1C;AACD,GAVD;;AAYA,SAAOpB,gBAAgB,KAAKmB,gBAAgB,EAArC,GAA0ChB,cAAc,EAA/D;AACD","sourcesContent":["import chalk from 'chalk';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { WILDCARD_HELP, AUTO_SNAPPED_MSG } from '@teambit/legacy/dist/constants';\nimport {\n ApplyVersionResults,\n getMergeStrategy,\n applyVersionReport,\n} from '@teambit/legacy/dist/consumer/versions-ops/merge-version';\nimport { isFeatureEnabled, BUILD_ON_CI } from '@teambit/legacy/dist/api/consumer/lib/feature-toggle';\nimport { BitError } from '@teambit/bit-error';\nimport { MergingMain } from './merging.main.runtime';\n\nexport class MergeCmd implements Command {\n name = 'merge [values...]';\n shortDescription = 'merge changes of different component versions';\n group = 'development';\n description = `merge changes of different component versions\n \\`bit merge <version> [ids...]\\` => merge changes of the given version into the checked out version\n \\`bit merge [ids...]\\` => EXPERIMENTAL. merge changes of the remote head into local, optionally use '--abort' or '--resolve'\n ${WILDCARD_HELP('merge 0.0.1')}`;\n alias = '';\n options = [\n ['', 'ours', 'in case of a conflict, override the used version with the current modification'],\n ['', 'theirs', 'in case of a conflict, override the current modification with the specified version'],\n ['', 'manual', 'in case of a conflict, leave the files with a conflict state to resolve them manually later'],\n ['', 'abort', 'EXPERIMENTAL. in case of an unresolved merge, revert to the state before the merge began'],\n ['', 'resolve', 'EXPERIMENTAL. mark an unresolved merge as resolved and create a new snap with the changes'],\n ['', 'no-snap', 'EXPERIMENTAL. do not auto snap in case the merge completed without conflicts'],\n ['', 'build', 'in case of snap during the merge, run the build-pipeline (similar to bit snap --build)'],\n ['m', 'message <message>', 'EXPERIMENTAL. override the default message for the auto snap'],\n ] as CommandOptions;\n loader = true;\n\n constructor(private merging: MergingMain) {}\n\n async report(\n [values = []]: [string[]],\n {\n ours = false,\n theirs = false,\n manual = false,\n abort = false,\n resolve = false,\n build = false,\n noSnap = false,\n message,\n }: {\n ours?: boolean;\n theirs?: boolean;\n manual?: boolean;\n abort?: boolean;\n resolve?: boolean;\n build?: boolean;\n noSnap?: boolean;\n message: string;\n }\n ) {\n build = isFeatureEnabled(BUILD_ON_CI) ? Boolean(build) : true;\n const mergeStrategy = getMergeStrategy(ours, theirs, manual);\n if (abort && resolve) throw new BitError('unable to use \"abort\" and \"resolve\" flags together');\n if (noSnap && message) throw new BitError('unable to use \"noSnap\" and \"message\" flags together');\n const {\n components,\n failedComponents,\n version,\n resolvedComponents,\n abortedComponents,\n mergeSnapResults,\n }: ApplyVersionResults = await this.merging.merge(\n values,\n mergeStrategy as any,\n abort,\n resolve,\n noSnap,\n message,\n build\n );\n if (resolvedComponents) {\n const title = 'successfully resolved component(s)\\n';\n const componentsStr = resolvedComponents.map((c) => c.id.toStringWithoutVersion()).join('\\n');\n return chalk.underline(title) + chalk.green(componentsStr);\n }\n if (abortedComponents) {\n const title = 'successfully aborted the merge of the following component(s)\\n';\n const componentsStr = abortedComponents.map((c) => c.id.toStringWithoutVersion()).join('\\n');\n return chalk.underline(title) + chalk.green(componentsStr);\n }\n return mergeReport({\n components,\n failedComponents,\n version,\n mergeSnapResults,\n });\n }\n}\n\nexport function mergeReport({ components, failedComponents, version, mergeSnapResults }: ApplyVersionResults): string {\n const getSuccessOutput = () => {\n if (!components || !components.length) return '';\n // @ts-ignore version is set in case of merge command\n const title = `successfully merged components${version ? `from version ${chalk.bold(version)}` : ''}\\n`;\n // @ts-ignore components is set in case of merge command\n return chalk.underline(title) + chalk.green(applyVersionReport(components));\n };\n\n const getSnapsOutput = () => {\n if (!mergeSnapResults || !mergeSnapResults.snappedComponents) return '';\n const { snappedComponents, autoSnappedResults } = mergeSnapResults;\n const outputComponents = (comps) => {\n return comps\n .map((component) => {\n let componentOutput = ` > ${component.id.toString()}`;\n const autoTag = autoSnappedResults.filter((result) =>\n result.triggeredBy.searchWithoutScopeAndVersion(component.id)\n );\n if (autoTag.length) {\n const autoTagComp = autoTag.map((a) => a.component.id.toString());\n componentOutput += `\\n ${AUTO_SNAPPED_MSG}: ${autoTagComp.join(', ')}`;\n }\n return componentOutput;\n })\n .join('\\n');\n };\n\n return `\\n${chalk.underline(\n 'merge-snapped components'\n )}\\n(${'components that snapped as a result of the merge'})\\n${outputComponents(snappedComponents)}\\n`;\n };\n\n const getFailureOutput = () => {\n if (!failedComponents || !failedComponents.length) return '';\n const title = 'the merge has been canceled on the following component(s)';\n const body = failedComponents\n .map(\n (failedComponent) =>\n `${chalk.bold(failedComponent.id.toString())} - ${chalk.red(failedComponent.failureMessage)}`\n )\n .join('\\n');\n return `${chalk.underline(title)}\\n${body}\\n\\n`;\n };\n\n return getSuccessOutput() + getFailureOutput() + getSnapsOutput();\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MergingAspect = void 0;
|
|
7
|
+
|
|
8
|
+
function _harmony() {
|
|
9
|
+
const data = require("@teambit/harmony");
|
|
10
|
+
|
|
11
|
+
_harmony = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const MergingAspect = _harmony().Aspect.create({
|
|
19
|
+
id: 'teambit.component/merging'
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
exports.MergingAspect = MergingAspect;
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=merging.aspect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["merging.aspect.ts"],"names":["MergingAspect","Aspect","create","id"],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,aAAa,GAAGC,kBAAOC,MAAP,CAAc;AACzCC,EAAAA,EAAE,EAAE;AADqC,CAAd,CAAtB","sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const MergingAspect = Aspect.create({\n id: 'teambit.component/merging',\n});\n"]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { CLIMain } from '@teambit/cli';
|
|
2
|
+
import { Workspace } from '@teambit/workspace';
|
|
3
|
+
import { Consumer } from '@teambit/legacy/dist/consumer';
|
|
4
|
+
import { ApplyVersionResults, MergeStrategy, ApplyVersionResult, FailedComponents } from '@teambit/legacy/dist/consumer/versions-ops/merge-version';
|
|
5
|
+
import { SnappingMain } from '@teambit/snapping';
|
|
6
|
+
import { BitId } from '@teambit/legacy/dist/bit-id';
|
|
7
|
+
import LaneId from '@teambit/legacy/dist/lane-id/lane-id';
|
|
8
|
+
import { AutoTagResult } from '@teambit/legacy/dist/scope/component-ops/auto-tag';
|
|
9
|
+
import { Lane, Version } from '@teambit/legacy/dist/scope/models';
|
|
10
|
+
import Component from '@teambit/legacy/dist/consumer/component/consumer-component';
|
|
11
|
+
import { MergeResultsThreeWay } from '@teambit/legacy/dist/consumer/versions-ops/merge-version/three-way-merge';
|
|
12
|
+
export declare type ComponentStatus = {
|
|
13
|
+
componentFromFS?: Component | null;
|
|
14
|
+
componentFromModel?: Version;
|
|
15
|
+
id: BitId;
|
|
16
|
+
failureMessage?: string;
|
|
17
|
+
mergeResults?: MergeResultsThreeWay | null;
|
|
18
|
+
};
|
|
19
|
+
export declare class MergingMain {
|
|
20
|
+
private workspace;
|
|
21
|
+
private snapping;
|
|
22
|
+
private consumer;
|
|
23
|
+
constructor(workspace: Workspace, snapping: SnappingMain);
|
|
24
|
+
/**
|
|
25
|
+
* merge components according to the "values" param.
|
|
26
|
+
* if the first param is a version, then merge the component ids to that version.
|
|
27
|
+
* otherwise, merge from the remote head to the local.
|
|
28
|
+
*/
|
|
29
|
+
merge(values: string[], mergeStrategy: MergeStrategy, abort: boolean, resolve: boolean, noSnap: boolean, message: string, build: boolean): Promise<ApplyVersionResults>;
|
|
30
|
+
/**
|
|
31
|
+
* when user is on main, it merges the remote main components into local.
|
|
32
|
+
* when user is on a lane, it merges the remote lane components into the local lane.
|
|
33
|
+
*/
|
|
34
|
+
mergeComponentsFromRemote(consumer: Consumer, bitIds: BitId[], mergeStrategy: MergeStrategy, noSnap: boolean, snapMessage: string, build: boolean): Promise<ApplyVersionResults>;
|
|
35
|
+
/**
|
|
36
|
+
* merge multiple components according to the "allComponentsStatus".
|
|
37
|
+
*/
|
|
38
|
+
mergeSnaps({ mergeStrategy, allComponentsStatus, remoteName, laneId, localLane, noSnap, snapMessage, build, }: {
|
|
39
|
+
mergeStrategy: MergeStrategy;
|
|
40
|
+
allComponentsStatus: ComponentStatus[];
|
|
41
|
+
remoteName: string | null;
|
|
42
|
+
laneId: LaneId;
|
|
43
|
+
localLane: Lane | null;
|
|
44
|
+
noSnap: boolean;
|
|
45
|
+
snapMessage: string;
|
|
46
|
+
build: boolean;
|
|
47
|
+
}): Promise<{
|
|
48
|
+
components: ApplyVersionResult[];
|
|
49
|
+
failedComponents: FailedComponents[];
|
|
50
|
+
mergeSnapResults: {
|
|
51
|
+
snappedComponents: Component[];
|
|
52
|
+
autoSnappedResults: AutoTagResult[];
|
|
53
|
+
} | null;
|
|
54
|
+
}>;
|
|
55
|
+
getComponentMergeStatus(id: BitId, localLane: Lane | null, otherLaneName: string, existingOnWorkspaceOnly?: boolean): Promise<ComponentStatus>;
|
|
56
|
+
private applyVersion;
|
|
57
|
+
private abortMerge;
|
|
58
|
+
private resolveMerge;
|
|
59
|
+
private getAllComponentsStatus;
|
|
60
|
+
private snapResolvedComponents;
|
|
61
|
+
private getIdsForUnresolved;
|
|
62
|
+
private getComponentsToMerge;
|
|
63
|
+
static slots: never[];
|
|
64
|
+
static dependencies: import("@teambit/harmony").Aspect[];
|
|
65
|
+
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
66
|
+
static provider([cli, workspace, snapping]: [CLIMain, Workspace, SnappingMain]): Promise<MergingMain>;
|
|
67
|
+
}
|