@teambit/lanes 0.0.127 → 0.0.131
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/package.json +25 -10
- package/tsconfig.json +1 -1
- package/index.ts +0 -5
- package/lane.cmd.ts +0 -365
- package/lanes.aspect.ts +0 -5
- package/lanes.graphql.ts +0 -93
- package/lanes.main.runtime.ts +0 -196
- package/package-tar/teambit-lanes-0.0.127.tgz +0 -0
- package/types/asset.d.ts +0 -29
- package/types/style.d.ts +0 -42
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/lanes",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.131",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/lanes/lanes",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.lanes",
|
|
8
8
|
"name": "lanes",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.131"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"graphql-tag": "2.12.1",
|
|
15
15
|
"@babel/runtime": "7.12.18",
|
|
16
16
|
"core-js": "^3.0.0",
|
|
17
|
-
"@teambit/bit-error": "0.0.
|
|
18
|
-
"@teambit/cli": "0.0.
|
|
19
|
-
"@teambit/scope": "0.0.
|
|
20
|
-
"@teambit/workspace": "0.0.
|
|
21
|
-
"@teambit/graphql": "0.0.
|
|
22
|
-
"@teambit/lanes.modules.diff": "0.0.
|
|
17
|
+
"@teambit/bit-error": "0.0.375",
|
|
18
|
+
"@teambit/cli": "0.0.389",
|
|
19
|
+
"@teambit/scope": "0.0.559",
|
|
20
|
+
"@teambit/workspace": "0.0.559",
|
|
21
|
+
"@teambit/graphql": "0.0.559",
|
|
22
|
+
"@teambit/lanes.modules.diff": "0.0.82"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/mocha": "5.2.7",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@types/node": "12.20.4"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@teambit/legacy": "1.0.
|
|
33
|
+
"@teambit/legacy": "1.0.175",
|
|
34
34
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
35
35
|
"react": "^16.8.0 || ^17.0.0"
|
|
36
36
|
},
|
|
@@ -58,12 +58,27 @@
|
|
|
58
58
|
"react": "-"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@teambit/legacy": "1.0.
|
|
61
|
+
"@teambit/legacy": "1.0.175",
|
|
62
62
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
63
63
|
"react": "^16.8.0 || ^17.0.0"
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
|
+
"files": [
|
|
68
|
+
"dist",
|
|
69
|
+
"!dist/tsconfig.tsbuildinfo",
|
|
70
|
+
"**/*.md",
|
|
71
|
+
"**/*.mdx",
|
|
72
|
+
"**/*.js",
|
|
73
|
+
"**/*.json",
|
|
74
|
+
"**/*.sass",
|
|
75
|
+
"**/*.scss",
|
|
76
|
+
"**/*.less",
|
|
77
|
+
"**/*.css",
|
|
78
|
+
"**/*.css",
|
|
79
|
+
"**/*.jpeg",
|
|
80
|
+
"**/*.gif"
|
|
81
|
+
],
|
|
67
82
|
"private": false,
|
|
68
83
|
"engines": {
|
|
69
84
|
"node": ">=12.22.0"
|
package/tsconfig.json
CHANGED
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"skipLibCheck": true,
|
|
16
16
|
"moduleResolution": "node",
|
|
17
17
|
"esModuleInterop": true,
|
|
18
|
-
"outDir": "dist",
|
|
19
18
|
"composite": true,
|
|
20
19
|
"emitDeclarationOnly": true,
|
|
20
|
+
"outDir": "dist",
|
|
21
21
|
"experimentalDecorators": true,
|
|
22
22
|
"emitDecoratorMetadata": true,
|
|
23
23
|
"allowSyntheticDefaultImports": true,
|
package/index.ts
DELETED
package/lane.cmd.ts
DELETED
|
@@ -1,365 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line max-classes-per-file
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { ScopeMain } from '@teambit/scope';
|
|
4
|
-
import { Workspace } from '@teambit/workspace';
|
|
5
|
-
import { Command, CommandOptions } from '@teambit/cli';
|
|
6
|
-
import { BASE_DOCS_DOMAIN } from '@teambit/legacy/dist/constants';
|
|
7
|
-
import { LaneData } from '@teambit/legacy/dist/scope/lanes/lanes';
|
|
8
|
-
import { getMergeStrategy } from '@teambit/legacy/dist/consumer/versions-ops/merge-version';
|
|
9
|
-
import { mergeReport } from '@teambit/legacy/dist/cli/commands/public-cmds/merge-cmd';
|
|
10
|
-
import { BUILD_ON_CI, isFeatureEnabled } from '@teambit/legacy/dist/api/consumer/lib/feature-toggle';
|
|
11
|
-
import { BitError } from '@teambit/bit-error';
|
|
12
|
-
import { removePrompt } from '@teambit/legacy/dist/prompts';
|
|
13
|
-
import { CreateLaneOptions, LanesMain } from './lanes.main.runtime';
|
|
14
|
-
|
|
15
|
-
type LaneOptions = {
|
|
16
|
-
details?: boolean;
|
|
17
|
-
remote?: string;
|
|
18
|
-
merged?: boolean;
|
|
19
|
-
notMerged?: boolean;
|
|
20
|
-
json?: boolean;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export class LaneListCmd implements Command {
|
|
24
|
-
name = 'list';
|
|
25
|
-
description = `list lanes`;
|
|
26
|
-
alias = '';
|
|
27
|
-
options = [
|
|
28
|
-
['d', 'details', 'show more details on the state of each component in each lane'],
|
|
29
|
-
['j', 'json', 'show lanes details in json format'],
|
|
30
|
-
['r', 'remote <string>', 'show remote lanes'],
|
|
31
|
-
['', 'merged', 'show merged lanes'],
|
|
32
|
-
['', 'not-merged', 'show not merged lanes'],
|
|
33
|
-
] as CommandOptions;
|
|
34
|
-
loader = true;
|
|
35
|
-
private = true;
|
|
36
|
-
migration = true;
|
|
37
|
-
remoteOp = true;
|
|
38
|
-
skipWorkspace = true;
|
|
39
|
-
|
|
40
|
-
constructor(private lanes: LanesMain, private workspace: Workspace, private scope: ScopeMain) {}
|
|
41
|
-
|
|
42
|
-
async report(args, laneOptions: LaneOptions): Promise<string> {
|
|
43
|
-
const { details, remote, merged, notMerged } = laneOptions;
|
|
44
|
-
|
|
45
|
-
const lanes = await this.lanes.getLanes({
|
|
46
|
-
remote,
|
|
47
|
-
merged,
|
|
48
|
-
notMerged,
|
|
49
|
-
});
|
|
50
|
-
if (merged) {
|
|
51
|
-
const mergedLanes = lanes.filter((l) => l.isMerged);
|
|
52
|
-
if (!mergedLanes.length) return chalk.green('None of the lanes is merged');
|
|
53
|
-
return chalk.green(mergedLanes.map((m) => m.name).join('\n'));
|
|
54
|
-
}
|
|
55
|
-
if (notMerged) {
|
|
56
|
-
const unmergedLanes = lanes.filter((l) => !l.isMerged);
|
|
57
|
-
if (!unmergedLanes.length) return chalk.green('All lanes are merged');
|
|
58
|
-
return chalk.green(unmergedLanes.map((m) => m.name).join('\n'));
|
|
59
|
-
}
|
|
60
|
-
const currentLane = this.lanes.getCurrentLane();
|
|
61
|
-
let currentLaneStr = currentLane ? `current lane - ${chalk.bold(currentLane as string)}` : '';
|
|
62
|
-
if (details) {
|
|
63
|
-
const laneDataOfCurrentLane = lanes.find((l) => l.name === currentLane);
|
|
64
|
-
const remoteOfCurrentLane = laneDataOfCurrentLane ? laneDataOfCurrentLane.remote : null;
|
|
65
|
-
const currentLaneComponents = laneDataOfCurrentLane ? outputComponents(laneDataOfCurrentLane.components) : '';
|
|
66
|
-
if (currentLaneStr) {
|
|
67
|
-
currentLaneStr += `${outputRemoteLane(remoteOfCurrentLane)}\n${currentLaneComponents}`;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const availableLanes = lanes
|
|
72
|
-
.filter((l) => l.name !== currentLane)
|
|
73
|
-
// @ts-ignore
|
|
74
|
-
.map((laneData) => {
|
|
75
|
-
if (details) {
|
|
76
|
-
const laneTitle = `> ${chalk.green(laneData.name)}${outputRemoteLane(laneData.remote)}\n`;
|
|
77
|
-
const components = outputComponents(laneData.components);
|
|
78
|
-
return laneTitle + components;
|
|
79
|
-
}
|
|
80
|
-
return ` > ${chalk.green(laneData.name)} (${laneData.components.length} components)`;
|
|
81
|
-
})
|
|
82
|
-
.join('\n');
|
|
83
|
-
|
|
84
|
-
const outputFooter = () => {
|
|
85
|
-
let footer = '\n';
|
|
86
|
-
if (details) {
|
|
87
|
-
footer += 'You can use --merged and --not-merged to see which of the lanes is fully merged.';
|
|
88
|
-
} else {
|
|
89
|
-
footer +=
|
|
90
|
-
"to get more info on all lanes in workspace use 'bit lane list --details' or 'bit lane show <lane-name>' for a specific lane.";
|
|
91
|
-
}
|
|
92
|
-
if (!remote && this.workspace) footer += `\nswitch lanes using 'bit switch <name>'.`;
|
|
93
|
-
|
|
94
|
-
return footer;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
return outputCurrentLane() + outputAvailableLanes() + outputFooter();
|
|
98
|
-
|
|
99
|
-
function outputCurrentLane() {
|
|
100
|
-
return currentLaneStr ? `${currentLaneStr}\n` : '';
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function outputAvailableLanes() {
|
|
104
|
-
if (!availableLanes) return '';
|
|
105
|
-
return remote ? `${availableLanes}\n` : `\nAvailable lanes:\n${availableLanes}\n`;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
async json(args, laneOptions: LaneOptions) {
|
|
109
|
-
const { remote, merged = false, notMerged = false } = laneOptions;
|
|
110
|
-
|
|
111
|
-
const lanes = await this.lanes.getLanes({
|
|
112
|
-
remote,
|
|
113
|
-
showDefaultLane: true,
|
|
114
|
-
merged,
|
|
115
|
-
notMerged,
|
|
116
|
-
});
|
|
117
|
-
const currentLane = this.lanes.getCurrentLane();
|
|
118
|
-
return { lanes, currentLane };
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export class LaneShowCmd implements Command {
|
|
123
|
-
name = 'show <name>';
|
|
124
|
-
description = `show lane details`;
|
|
125
|
-
alias = '';
|
|
126
|
-
options = [
|
|
127
|
-
['j', 'json', 'show the lane details in json format'],
|
|
128
|
-
['r', 'remote <string>', 'show remote lanes'],
|
|
129
|
-
] as CommandOptions;
|
|
130
|
-
loader = true;
|
|
131
|
-
private = true;
|
|
132
|
-
migration = true;
|
|
133
|
-
remoteOp = true;
|
|
134
|
-
skipWorkspace = true;
|
|
135
|
-
|
|
136
|
-
constructor(private lanes: LanesMain, private workspace: Workspace, private scope: ScopeMain) {}
|
|
137
|
-
|
|
138
|
-
async report([name]: [string], laneOptions: LaneOptions): Promise<string> {
|
|
139
|
-
const { remote } = laneOptions;
|
|
140
|
-
|
|
141
|
-
const lanes = await this.lanes.getLanes({
|
|
142
|
-
name,
|
|
143
|
-
remote,
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
const onlyLane = lanes[0];
|
|
147
|
-
const title = `showing information for ${chalk.bold(name)}${outputRemoteLane(onlyLane.remote)}\n`;
|
|
148
|
-
return title + outputComponents(onlyLane.components);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
async json([name]: [string], laneOptions: LaneOptions) {
|
|
152
|
-
const { remote } = laneOptions;
|
|
153
|
-
|
|
154
|
-
const lanes = await this.lanes.getLanes({
|
|
155
|
-
name,
|
|
156
|
-
remote,
|
|
157
|
-
});
|
|
158
|
-
return lanes[0];
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export class LaneCreateCmd implements Command {
|
|
163
|
-
name = 'create <name>';
|
|
164
|
-
description = `create and switch to a new lane`;
|
|
165
|
-
alias = '';
|
|
166
|
-
options = [
|
|
167
|
-
[
|
|
168
|
-
'',
|
|
169
|
-
'remote-scope <string>',
|
|
170
|
-
'remote scope where this lane will be exported to (can be changed later with "bit lane track")',
|
|
171
|
-
],
|
|
172
|
-
[
|
|
173
|
-
'',
|
|
174
|
-
'remote-name <string>',
|
|
175
|
-
'lane name on the remote, default to the local name (can be changed later with "bit lane track")',
|
|
176
|
-
],
|
|
177
|
-
] as CommandOptions;
|
|
178
|
-
loader = true;
|
|
179
|
-
private = true;
|
|
180
|
-
migration = true;
|
|
181
|
-
|
|
182
|
-
constructor(private lanes: LanesMain) {}
|
|
183
|
-
|
|
184
|
-
async report([name]: [string], createLaneOptions: CreateLaneOptions): Promise<string> {
|
|
185
|
-
const result = await this.lanes.createLane(name, createLaneOptions);
|
|
186
|
-
const remoteScopeOrDefaultScope = createLaneOptions.remoteScope
|
|
187
|
-
? `the remote scope ${chalk.bold(createLaneOptions.remoteScope)}`
|
|
188
|
-
: `the default-scope ${chalk.bold(result.remoteScope)}. to change it, please run "bit lane track" command`;
|
|
189
|
-
const title = chalk.green(`successfully added a new lane ${chalk.bold(result.localLane)}`);
|
|
190
|
-
const remoteScopeOutput = `this lane will be exported to ${remoteScopeOrDefaultScope}`;
|
|
191
|
-
return `${title}\n${remoteScopeOutput}`;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export class LaneTrackCmd implements Command {
|
|
196
|
-
name = 'track <local-name> <remote-scope> [remote-name]';
|
|
197
|
-
description = `change the remote scope or remote lane of the local lane`;
|
|
198
|
-
alias = '';
|
|
199
|
-
options = [] as CommandOptions;
|
|
200
|
-
loader = true;
|
|
201
|
-
private = true;
|
|
202
|
-
migration = true;
|
|
203
|
-
|
|
204
|
-
constructor(private lanes: LanesMain) {}
|
|
205
|
-
|
|
206
|
-
async report([localName, remoteScope, remoteName]: [string, string, string]): Promise<string> {
|
|
207
|
-
const { beforeTrackData, afterTrackData } = await this.lanes.trackLane(localName, remoteScope, remoteName);
|
|
208
|
-
const remoteScopeChanges =
|
|
209
|
-
afterTrackData.remoteScope === beforeTrackData?.remoteScope
|
|
210
|
-
? `the remote-scope has not been changed`
|
|
211
|
-
: `the remote-scope has been changed from ${chalk.bold(
|
|
212
|
-
beforeTrackData?.remoteScope || '<n/a>'
|
|
213
|
-
)} to ${chalk.bold(afterTrackData.remoteScope)}`;
|
|
214
|
-
const remoteNameChanges =
|
|
215
|
-
afterTrackData.remoteLane === beforeTrackData?.remoteLane
|
|
216
|
-
? `the remote-name has not been changed`
|
|
217
|
-
: `the remote-name has been changed from ${chalk.bold(beforeTrackData?.remoteLane || '<n/a>')} to ${chalk.bold(
|
|
218
|
-
afterTrackData.remoteLane
|
|
219
|
-
)}`;
|
|
220
|
-
|
|
221
|
-
return `${remoteScopeChanges}\n${remoteNameChanges}`;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
export class LaneMergeCmd implements Command {
|
|
226
|
-
name = 'merge <lane>';
|
|
227
|
-
description = `merge a local or a remote lane`;
|
|
228
|
-
alias = '';
|
|
229
|
-
options = [
|
|
230
|
-
['', 'remote <name>', 'remote scope name'],
|
|
231
|
-
['', 'ours', 'in case of a conflict, override the used version with the current modification'],
|
|
232
|
-
['', 'theirs', 'in case of a conflict, override the current modification with the specified version'],
|
|
233
|
-
['', 'manual', 'in case of a conflict, leave the files with a conflict state to resolve them manually later'],
|
|
234
|
-
['', 'existing', 'checkout only components in a lane that exist in the workspace'],
|
|
235
|
-
['', 'no-snap', 'do not auto snap in case the merge completed without conflicts'],
|
|
236
|
-
['', 'build', 'in case of snap during the merge, run the build-pipeline (similar to bit snap --build)'],
|
|
237
|
-
['m', 'message <message>', 'override the default message for the auto snap'],
|
|
238
|
-
] as CommandOptions;
|
|
239
|
-
loader = true;
|
|
240
|
-
private = true;
|
|
241
|
-
migration = true;
|
|
242
|
-
remoteOp = true;
|
|
243
|
-
|
|
244
|
-
constructor(private lanes: LanesMain) {}
|
|
245
|
-
|
|
246
|
-
async report(
|
|
247
|
-
[name]: [string],
|
|
248
|
-
{
|
|
249
|
-
ours = false,
|
|
250
|
-
theirs = false,
|
|
251
|
-
manual = false,
|
|
252
|
-
remote: remoteName,
|
|
253
|
-
build,
|
|
254
|
-
existing: existingOnWorkspaceOnly = false,
|
|
255
|
-
noSnap = false,
|
|
256
|
-
message: snapMessage = '',
|
|
257
|
-
}: {
|
|
258
|
-
ours: boolean;
|
|
259
|
-
theirs: boolean;
|
|
260
|
-
manual: boolean;
|
|
261
|
-
remote?: string;
|
|
262
|
-
existing?: boolean;
|
|
263
|
-
build?: boolean;
|
|
264
|
-
noSnap: boolean;
|
|
265
|
-
message: string;
|
|
266
|
-
}
|
|
267
|
-
): Promise<string> {
|
|
268
|
-
build = isFeatureEnabled(BUILD_ON_CI) ? Boolean(build) : true;
|
|
269
|
-
const mergeStrategy = getMergeStrategy(ours, theirs, manual);
|
|
270
|
-
if (noSnap && snapMessage) throw new BitError('unable to use "noSnap" and "message" flags together');
|
|
271
|
-
|
|
272
|
-
const results = await this.lanes.mergeLane(name, {
|
|
273
|
-
// @ts-ignore
|
|
274
|
-
remoteName,
|
|
275
|
-
build,
|
|
276
|
-
// @ts-ignore
|
|
277
|
-
mergeStrategy,
|
|
278
|
-
existingOnWorkspaceOnly,
|
|
279
|
-
noSnap,
|
|
280
|
-
snapMessage,
|
|
281
|
-
});
|
|
282
|
-
return mergeReport(results);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
export class LaneRemoveCmd implements Command {
|
|
287
|
-
name = 'remove <lane...>';
|
|
288
|
-
description = `remove lanes`;
|
|
289
|
-
alias = '';
|
|
290
|
-
options = [
|
|
291
|
-
['r', 'remote', 'remove a remote lane (in the lane arg, use remote/lane-id syntax)'],
|
|
292
|
-
[
|
|
293
|
-
'f',
|
|
294
|
-
'force',
|
|
295
|
-
'removes the component from the scope, even if used as a dependency. WARNING: components that depend on this component will corrupt',
|
|
296
|
-
],
|
|
297
|
-
['s', 'silent', 'skip confirmation'],
|
|
298
|
-
] as CommandOptions;
|
|
299
|
-
loader = true;
|
|
300
|
-
private = true;
|
|
301
|
-
migration = true;
|
|
302
|
-
|
|
303
|
-
constructor(private lanes: LanesMain) {}
|
|
304
|
-
|
|
305
|
-
async report(
|
|
306
|
-
[names]: [string[]],
|
|
307
|
-
{
|
|
308
|
-
remote = false,
|
|
309
|
-
force = false,
|
|
310
|
-
silent = false,
|
|
311
|
-
}: {
|
|
312
|
-
remote: boolean;
|
|
313
|
-
force: boolean;
|
|
314
|
-
silent: boolean;
|
|
315
|
-
}
|
|
316
|
-
): Promise<string> {
|
|
317
|
-
if (!silent) {
|
|
318
|
-
const removePromptResult = await removePrompt();
|
|
319
|
-
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
320
|
-
if (!yn(removePromptResult.shouldRemove)) {
|
|
321
|
-
throw new BitError('the operation has been canceled');
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
const laneResults = await this.lanes.removeLanes(names, { remote, force });
|
|
325
|
-
return chalk.green(`successfully removed the following lane(s): ${chalk.bold(laneResults.join(', '))}`);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
export class LaneCmd implements Command {
|
|
330
|
-
name = 'lane [name]';
|
|
331
|
-
shortDescription = 'show lanes details';
|
|
332
|
-
description = `show lanes details
|
|
333
|
-
https://${BASE_DOCS_DOMAIN}/docs/lanes`;
|
|
334
|
-
alias = '';
|
|
335
|
-
options = [
|
|
336
|
-
['d', 'details', 'show more details on the state of each component in each lane'],
|
|
337
|
-
['j', 'json', 'show lanes details in json format'],
|
|
338
|
-
['r', 'remote <string>', 'show remote lanes'],
|
|
339
|
-
['', 'merged', 'show merged lanes'],
|
|
340
|
-
['', 'not-merged', 'show not merged lanes'],
|
|
341
|
-
] as CommandOptions;
|
|
342
|
-
loader = true;
|
|
343
|
-
private = true;
|
|
344
|
-
migration = true;
|
|
345
|
-
remoteOp = true;
|
|
346
|
-
skipWorkspace = true;
|
|
347
|
-
commands: Command[] = [];
|
|
348
|
-
|
|
349
|
-
constructor(private lanes: LanesMain, private workspace: Workspace, private scope: ScopeMain) {}
|
|
350
|
-
|
|
351
|
-
async report([name]: [string], laneOptions: LaneOptions): Promise<string> {
|
|
352
|
-
return new LaneListCmd(this.lanes, this.workspace, this.scope).report([name], laneOptions);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
function outputComponents(components: LaneData['components']): string {
|
|
357
|
-
const componentsTitle = `\tcomponents (${components.length})\n`;
|
|
358
|
-
const componentsStr = components.map((c) => `\t ${c.id.toString()} - ${c.head}`).join('\n');
|
|
359
|
-
return componentsTitle + componentsStr;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
function outputRemoteLane(remoteLane: string | null | undefined): string {
|
|
363
|
-
if (!remoteLane) return '';
|
|
364
|
-
return ` - (remote lane - ${remoteLane})`;
|
|
365
|
-
}
|
package/lanes.aspect.ts
DELETED
package/lanes.graphql.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { Schema } from '@teambit/graphql';
|
|
2
|
-
import gql from 'graphql-tag';
|
|
3
|
-
import { LanesMain } from './lanes.main.runtime';
|
|
4
|
-
|
|
5
|
-
export function lanesSchema(lanesMain: LanesMain): Schema {
|
|
6
|
-
return {
|
|
7
|
-
typeDefs: gql`
|
|
8
|
-
type CompLaneData {
|
|
9
|
-
id: String!
|
|
10
|
-
head: String!
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
type LanesData {
|
|
14
|
-
name: String!
|
|
15
|
-
components: [CompLaneData]
|
|
16
|
-
isMerged: Boolean
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
type FileDiff {
|
|
20
|
-
filePath: String!
|
|
21
|
-
diffOutput: String
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
type FieldsDiff {
|
|
25
|
-
fieldName: String!
|
|
26
|
-
diffOutput: String
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
type DiffResults {
|
|
30
|
-
id: String
|
|
31
|
-
hasDiff: Boolean
|
|
32
|
-
filesDiff: [FileDiff]
|
|
33
|
-
fieldsDiff: [FieldsDiff]
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
type GetDiffResult {
|
|
37
|
-
newComps: [String]
|
|
38
|
-
compsWithNoChanges: [String]
|
|
39
|
-
toLaneName: String
|
|
40
|
-
compsWithDiff: [DiffResults]
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
input DiffOptions {
|
|
44
|
-
color: Boolean
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
type Lanes {
|
|
48
|
-
getLanes: [LanesData]
|
|
49
|
-
getLaneByName(name: String): LanesData
|
|
50
|
-
getCurrentLaneName: String
|
|
51
|
-
getDiff(values: [String], options: DiffOptions): GetDiffResult
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
type Query {
|
|
55
|
-
lanes: Lanes
|
|
56
|
-
}
|
|
57
|
-
`,
|
|
58
|
-
resolvers: {
|
|
59
|
-
Lanes: {
|
|
60
|
-
getLanes: async (lanes: LanesMain) => {
|
|
61
|
-
const lanesResults = await lanes.getLanes({});
|
|
62
|
-
return lanesResults.map((lane) => ({
|
|
63
|
-
name: lane.name,
|
|
64
|
-
components: lane.components.map((c) => ({ id: c.id.toString(), head: c.head.toString() })),
|
|
65
|
-
isMerged: Boolean(lane.isMerged),
|
|
66
|
-
}));
|
|
67
|
-
},
|
|
68
|
-
getLaneByName: async (lanes: LanesMain, { name }: { name: string }) => {
|
|
69
|
-
const lanesResults = await lanes.getLanes({ name });
|
|
70
|
-
const laneResult = lanesResults[0];
|
|
71
|
-
return {
|
|
72
|
-
name: laneResult.name,
|
|
73
|
-
components: laneResult.components.map((c) => ({ id: c.id.toString(), head: c.head.toString() })),
|
|
74
|
-
isMerged: Boolean(laneResult.isMerged),
|
|
75
|
-
};
|
|
76
|
-
},
|
|
77
|
-
getCurrentLaneName: (lanes: LanesMain) => {
|
|
78
|
-
return lanes.getCurrentLane();
|
|
79
|
-
},
|
|
80
|
-
getDiff: async (lanes: LanesMain, { values, options }: { values: string[]; options: { color?: boolean } }) => {
|
|
81
|
-
const getDiffResults = await lanes.getDiff(values, options);
|
|
82
|
-
return {
|
|
83
|
-
...getDiffResults,
|
|
84
|
-
compsWithDiff: getDiffResults.compsWithDiff.map((item) => ({ ...item, id: item.id.toString() })),
|
|
85
|
-
};
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
Query: {
|
|
89
|
-
lanes: () => lanesMain,
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
}
|
package/lanes.main.runtime.ts
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';
|
|
2
|
-
import { ScopeMain, ScopeAspect } from '@teambit/scope';
|
|
3
|
-
import { GraphqlAspect, GraphqlMain } from '@teambit/graphql';
|
|
4
|
-
import { Workspace, WorkspaceAspect } from '@teambit/workspace';
|
|
5
|
-
import getRemoteByName from '@teambit/legacy/dist/remotes/get-remote-by-name';
|
|
6
|
-
import { LaneDiffCmd, LaneDiffGenerator } from '@teambit/lanes.modules.diff';
|
|
7
|
-
import { LaneData } from '@teambit/legacy/dist/scope/lanes/lanes';
|
|
8
|
-
import LaneId from '@teambit/legacy/dist/lane-id/lane-id';
|
|
9
|
-
import { BitError } from '@teambit/bit-error';
|
|
10
|
-
import createNewLane from '@teambit/legacy/dist/consumer/lanes/create-lane';
|
|
11
|
-
import { mergeLanes } from '@teambit/legacy/dist/consumer/lanes/merge-lanes';
|
|
12
|
-
import { DEFAULT_LANE } from '@teambit/legacy/dist/constants';
|
|
13
|
-
import { DiffOptions } from '@teambit/legacy/dist/consumer/component-ops/components-diff';
|
|
14
|
-
import { MergeStrategy, ApplyVersionResults } from '@teambit/legacy/dist/consumer/versions-ops/merge-version';
|
|
15
|
-
import { TrackLane } from '@teambit/legacy/dist/scope/scope-json';
|
|
16
|
-
import removeLanes from '@teambit/legacy/dist/consumer/lanes/remove-lanes';
|
|
17
|
-
import { LanesAspect } from './lanes.aspect';
|
|
18
|
-
import {
|
|
19
|
-
LaneCmd,
|
|
20
|
-
LaneCreateCmd,
|
|
21
|
-
LaneListCmd,
|
|
22
|
-
LaneMergeCmd,
|
|
23
|
-
LaneRemoveCmd,
|
|
24
|
-
LaneShowCmd,
|
|
25
|
-
LaneTrackCmd,
|
|
26
|
-
} from './lane.cmd';
|
|
27
|
-
import { lanesSchema } from './lanes.graphql';
|
|
28
|
-
|
|
29
|
-
export type LaneResults = {
|
|
30
|
-
lanes: LaneData[];
|
|
31
|
-
currentLane?: string | null;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export type MergeLaneOptions = {
|
|
35
|
-
remoteName: string | null;
|
|
36
|
-
mergeStrategy: MergeStrategy;
|
|
37
|
-
noSnap: boolean;
|
|
38
|
-
snapMessage: string;
|
|
39
|
-
existingOnWorkspaceOnly: boolean;
|
|
40
|
-
build: boolean;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export type CreateLaneOptions = {
|
|
44
|
-
remoteScope?: string; // default to the defaultScope in workspace.jsonc
|
|
45
|
-
remoteName?: string; // default to the local lane
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export class LanesMain {
|
|
49
|
-
constructor(private workspace: Workspace | undefined, private scope: ScopeMain) {}
|
|
50
|
-
|
|
51
|
-
async getLanes({
|
|
52
|
-
name,
|
|
53
|
-
remote,
|
|
54
|
-
merged,
|
|
55
|
-
showDefaultLane,
|
|
56
|
-
notMerged,
|
|
57
|
-
}: {
|
|
58
|
-
name?: string;
|
|
59
|
-
remote?: string;
|
|
60
|
-
merged?: boolean;
|
|
61
|
-
showDefaultLane?: boolean;
|
|
62
|
-
notMerged?: boolean;
|
|
63
|
-
}): Promise<LaneData[]> {
|
|
64
|
-
const showMergeData = Boolean(merged || notMerged);
|
|
65
|
-
const consumer = this.workspace?.consumer;
|
|
66
|
-
if (remote) {
|
|
67
|
-
const remoteObj = await getRemoteByName(remote, consumer);
|
|
68
|
-
const lanes = await remoteObj.listLanes(name, showMergeData);
|
|
69
|
-
return lanes;
|
|
70
|
-
}
|
|
71
|
-
const lanes = await this.scope.legacyScope.lanes.getLanesData(this.scope.legacyScope, name, showMergeData);
|
|
72
|
-
|
|
73
|
-
if (showDefaultLane) {
|
|
74
|
-
const defaultLane = this.getLaneDataOfDefaultLane();
|
|
75
|
-
if (defaultLane) lanes.push(defaultLane);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return lanes;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
getCurrentLane(): string | null {
|
|
82
|
-
if (!this.workspace?.consumer) return null;
|
|
83
|
-
return this.scope.legacyScope.lanes.getCurrentLaneName();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
async createLane(name: string, { remoteScope, remoteName }: CreateLaneOptions): Promise<TrackLane> {
|
|
87
|
-
if (!this.workspace) {
|
|
88
|
-
throw new BitError(`unable to create a lane outside of Bit workspace`);
|
|
89
|
-
}
|
|
90
|
-
await createNewLane(this.workspace.consumer, name);
|
|
91
|
-
this.scope.legacyScope.lanes.setCurrentLane(name);
|
|
92
|
-
const trackLaneData = {
|
|
93
|
-
localLane: name,
|
|
94
|
-
remoteLane: remoteName || name,
|
|
95
|
-
remoteScope: remoteScope || this.workspace.defaultScope,
|
|
96
|
-
};
|
|
97
|
-
this.scope.legacyScope.lanes.trackLane(trackLaneData);
|
|
98
|
-
await this.workspace.consumer.onDestroy();
|
|
99
|
-
|
|
100
|
-
return trackLaneData;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async trackLane(
|
|
104
|
-
localName: string,
|
|
105
|
-
remoteScope: string,
|
|
106
|
-
remoteName?: string
|
|
107
|
-
): Promise<{ beforeTrackData?: TrackLane; afterTrackData: TrackLane }> {
|
|
108
|
-
if (!this.workspace) {
|
|
109
|
-
throw new BitError(`unable to track a lane outside of Bit workspace`);
|
|
110
|
-
}
|
|
111
|
-
const lane = await this.scope.legacyScope.lanes.loadLane(LaneId.from(localName));
|
|
112
|
-
if (!lane) {
|
|
113
|
-
throw new BitError(`unable to find a local lane "${localName}"`);
|
|
114
|
-
}
|
|
115
|
-
const beforeTrackData = this.scope.legacyScope.lanes.getRemoteTrackedDataByLocalLane(localName);
|
|
116
|
-
const beforeTrackDataCloned = beforeTrackData ? { ...beforeTrackData } : undefined;
|
|
117
|
-
const afterTrackData = {
|
|
118
|
-
localLane: localName,
|
|
119
|
-
remoteLane: remoteName || beforeTrackData?.remoteLane || localName,
|
|
120
|
-
remoteScope,
|
|
121
|
-
};
|
|
122
|
-
this.scope.legacyScope.lanes.trackLane(afterTrackData);
|
|
123
|
-
await this.workspace.consumer.onDestroy();
|
|
124
|
-
|
|
125
|
-
return { beforeTrackData: beforeTrackDataCloned, afterTrackData };
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
async removeLanes(laneNames: string[], { remote, force }: { remote: boolean; force: boolean }): Promise<string[]> {
|
|
129
|
-
const results = await removeLanes(this.workspace?.consumer, laneNames, remote, force);
|
|
130
|
-
if (this.workspace) await this.workspace.consumer.onDestroy();
|
|
131
|
-
|
|
132
|
-
return results.laneResults;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
async mergeLane(laneName: string, options: MergeLaneOptions): Promise<ApplyVersionResults> {
|
|
136
|
-
if (!this.workspace) {
|
|
137
|
-
throw new BitError(`unable to merge a lane outside of Bit workspace`);
|
|
138
|
-
}
|
|
139
|
-
const mergeResults = await mergeLanes({
|
|
140
|
-
consumer: this.workspace.consumer,
|
|
141
|
-
laneName,
|
|
142
|
-
...options,
|
|
143
|
-
});
|
|
144
|
-
await this.workspace.consumer.onDestroy();
|
|
145
|
-
|
|
146
|
-
return mergeResults;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* the values array may include zero to two values and will be processed as following:
|
|
151
|
-
* [] => diff between the current lane and default lane. (only inside workspace).
|
|
152
|
-
* [to] => diff between the current lane (or default-lane when in scope) and "to" lane.
|
|
153
|
-
* [from, to] => diff between "from" lane and "to" lane.
|
|
154
|
-
*/
|
|
155
|
-
public getDiff(values: string[], diffOptions: DiffOptions = {}) {
|
|
156
|
-
const laneDiffGenerator = new LaneDiffGenerator(this.workspace, this.scope);
|
|
157
|
-
return laneDiffGenerator.generate(values, diffOptions);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
private getLaneDataOfDefaultLane(): LaneData | null {
|
|
161
|
-
const consumer = this.workspace?.consumer;
|
|
162
|
-
if (!consumer) return null;
|
|
163
|
-
const bitIds = consumer.bitMap.getAuthoredAndImportedBitIdsOfDefaultLane();
|
|
164
|
-
return {
|
|
165
|
-
name: DEFAULT_LANE,
|
|
166
|
-
remote: null,
|
|
167
|
-
components: bitIds.map((bitId) => ({ id: bitId, head: bitId.version as string })),
|
|
168
|
-
isMerged: null,
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
static slots = [];
|
|
173
|
-
static dependencies = [CLIAspect, ScopeAspect, WorkspaceAspect, GraphqlAspect];
|
|
174
|
-
static runtime = MainRuntime;
|
|
175
|
-
static async provider([cli, scope, workspace, graphql]: [CLIMain, ScopeMain, Workspace, GraphqlMain]) {
|
|
176
|
-
const lanesMain = new LanesMain(workspace, scope);
|
|
177
|
-
const isLegacy = workspace && workspace.consumer.isLegacy;
|
|
178
|
-
if (!isLegacy) {
|
|
179
|
-
const laneCmd = new LaneCmd(lanesMain, workspace, scope);
|
|
180
|
-
laneCmd.commands = [
|
|
181
|
-
new LaneListCmd(lanesMain, workspace, scope),
|
|
182
|
-
new LaneShowCmd(lanesMain, workspace, scope),
|
|
183
|
-
new LaneCreateCmd(lanesMain),
|
|
184
|
-
new LaneMergeCmd(lanesMain),
|
|
185
|
-
new LaneRemoveCmd(lanesMain),
|
|
186
|
-
new LaneTrackCmd(lanesMain),
|
|
187
|
-
new LaneDiffCmd(workspace, scope),
|
|
188
|
-
];
|
|
189
|
-
cli.register(laneCmd);
|
|
190
|
-
graphql.register(lanesSchema(lanesMain));
|
|
191
|
-
}
|
|
192
|
-
return lanesMain;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
LanesAspect.addRuntime(LanesMain);
|
|
Binary file
|
package/types/asset.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
declare module '*.png' {
|
|
2
|
-
const value: any;
|
|
3
|
-
export = value;
|
|
4
|
-
}
|
|
5
|
-
declare module '*.svg' {
|
|
6
|
-
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
-
|
|
8
|
-
export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
|
|
9
|
-
const src: string;
|
|
10
|
-
export default src;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// @TODO Gilad
|
|
14
|
-
declare module '*.jpg' {
|
|
15
|
-
const value: any;
|
|
16
|
-
export = value;
|
|
17
|
-
}
|
|
18
|
-
declare module '*.jpeg' {
|
|
19
|
-
const value: any;
|
|
20
|
-
export = value;
|
|
21
|
-
}
|
|
22
|
-
declare module '*.gif' {
|
|
23
|
-
const value: any;
|
|
24
|
-
export = value;
|
|
25
|
-
}
|
|
26
|
-
declare module '*.bmp' {
|
|
27
|
-
const value: any;
|
|
28
|
-
export = value;
|
|
29
|
-
}
|
package/types/style.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
declare module '*.module.css' {
|
|
2
|
-
const classes: { readonly [key: string]: string };
|
|
3
|
-
export default classes;
|
|
4
|
-
}
|
|
5
|
-
declare module '*.module.scss' {
|
|
6
|
-
const classes: { readonly [key: string]: string };
|
|
7
|
-
export default classes;
|
|
8
|
-
}
|
|
9
|
-
declare module '*.module.sass' {
|
|
10
|
-
const classes: { readonly [key: string]: string };
|
|
11
|
-
export default classes;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
declare module '*.module.less' {
|
|
15
|
-
const classes: { readonly [key: string]: string };
|
|
16
|
-
export default classes;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
declare module '*.less' {
|
|
20
|
-
const classes: { readonly [key: string]: string };
|
|
21
|
-
export default classes;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
declare module '*.css' {
|
|
25
|
-
const classes: { readonly [key: string]: string };
|
|
26
|
-
export default classes;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
declare module '*.sass' {
|
|
30
|
-
const classes: { readonly [key: string]: string };
|
|
31
|
-
export default classes;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
declare module '*.scss' {
|
|
35
|
-
const classes: { readonly [key: string]: string };
|
|
36
|
-
export default classes;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
declare module '*.mdx' {
|
|
40
|
-
const component: any;
|
|
41
|
-
export default component;
|
|
42
|
-
}
|