@teambit/snapping 1.0.102 → 1.0.104
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/generate-comp-from-scope.d.ts +26 -0
- package/dist/generate-comp-from-scope.js +169 -0
- package/dist/generate-comp-from-scope.js.map +1 -0
- package/dist/snap-cmd.d.ts +1 -1
- package/dist/snap-cmd.js +3 -1
- package/dist/snap-cmd.js.map +1 -1
- package/dist/snap-from-scope.cmd.d.ts +9 -1
- package/dist/snap-from-scope.cmd.js +14 -4
- package/dist/snap-from-scope.cmd.js.map +1 -1
- package/dist/snapping.main.runtime.d.ts +26 -7
- package/dist/snapping.main.runtime.js +70 -21
- package/dist/snapping.main.runtime.js.map +1 -1
- package/dist/tag-cmd.d.ts +1 -1
- package/dist/tag-cmd.js +3 -1
- package/dist/tag-cmd.js.map +1 -1
- package/dist/tag-from-scope.cmd.d.ts +1 -1
- package/dist/tag-from-scope.cmd.js +3 -1
- package/dist/tag-from-scope.cmd.js.map +1 -1
- package/dist/tag-model-component.d.ts +2 -1
- package/dist/tag-model-component.js +10 -4
- package/dist/tag-model-component.js.map +1 -1
- package/package.json +22 -21
- /package/dist/{preview-1703214934003.js → preview-1703387662836.js} +0 -0
|
@@ -256,6 +256,13 @@ function _exceptions() {
|
|
|
256
256
|
};
|
|
257
257
|
return data;
|
|
258
258
|
}
|
|
259
|
+
function _dependencies() {
|
|
260
|
+
const data = _interopRequireDefault(require("@teambit/dependencies"));
|
|
261
|
+
_dependencies = function () {
|
|
262
|
+
return data;
|
|
263
|
+
};
|
|
264
|
+
return data;
|
|
265
|
+
}
|
|
259
266
|
function _sources() {
|
|
260
267
|
const data = require("@teambit/legacy/dist/consumer/component/sources");
|
|
261
268
|
_sources = function () {
|
|
@@ -319,6 +326,13 @@ function _snapFromScope() {
|
|
|
319
326
|
};
|
|
320
327
|
return data;
|
|
321
328
|
}
|
|
329
|
+
function _generateCompFromScope() {
|
|
330
|
+
const data = require("./generate-comp-from-scope");
|
|
331
|
+
_generateCompFromScope = function () {
|
|
332
|
+
return data;
|
|
333
|
+
};
|
|
334
|
+
return data;
|
|
335
|
+
}
|
|
322
336
|
function _flattenedEdges() {
|
|
323
337
|
const data = require("./flattened-edges");
|
|
324
338
|
_flattenedEdges = function () {
|
|
@@ -336,7 +350,7 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
|
|
|
336
350
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
337
351
|
const HooksManagerInstance = _hooks().default.getInstance();
|
|
338
352
|
class SnappingMain {
|
|
339
|
-
constructor(workspace, logger, issues, insights, dependencyResolver, scope, exporter, builder, importer) {
|
|
353
|
+
constructor(workspace, logger, issues, insights, dependencyResolver, scope, exporter, builder, importer, deps) {
|
|
340
354
|
var _this$scope;
|
|
341
355
|
this.workspace = workspace;
|
|
342
356
|
this.logger = logger;
|
|
@@ -347,6 +361,7 @@ class SnappingMain {
|
|
|
347
361
|
this.exporter = exporter;
|
|
348
362
|
this.builder = builder;
|
|
349
363
|
this.importer = importer;
|
|
364
|
+
this.deps = deps;
|
|
350
365
|
_defineProperty(this, "objectsRepo", void 0);
|
|
351
366
|
this.objectsRepo = (_this$scope = this.scope) === null || _this$scope === void 0 || (_this$scope = _this$scope.legacyScope) === null || _this$scope === void 0 ? void 0 : _this$scope.objects;
|
|
352
367
|
}
|
|
@@ -376,6 +391,7 @@ class SnappingMain {
|
|
|
376
391
|
soft = false,
|
|
377
392
|
persist = false,
|
|
378
393
|
ignoreBuildErrors = false,
|
|
394
|
+
rebuildDepsGraph,
|
|
379
395
|
incrementBy = 1,
|
|
380
396
|
disableTagAndSnapPipelines = false,
|
|
381
397
|
failFast = false
|
|
@@ -432,6 +448,7 @@ class SnappingMain {
|
|
|
432
448
|
persist,
|
|
433
449
|
disableTagAndSnapPipelines,
|
|
434
450
|
ignoreBuildErrors,
|
|
451
|
+
rebuildDepsGraph,
|
|
435
452
|
incrementBy,
|
|
436
453
|
packageManagerConfigRootDir: this.workspace.path,
|
|
437
454
|
dependencyResolver: this.dependencyResolver,
|
|
@@ -564,11 +581,22 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
564
581
|
dependencies: snapData.dependencies ? await this.scope.resolveMultipleComponentIds(snapData.dependencies) : [],
|
|
565
582
|
aspects: snapData.aspects,
|
|
566
583
|
message: snapData.message,
|
|
567
|
-
files: snapData.files
|
|
584
|
+
files: snapData.files,
|
|
585
|
+
isNew: snapData.isNew,
|
|
586
|
+
mainFile: snapData.mainFile,
|
|
587
|
+
newDependencies: (snapData.newDependencies || []).map(dep => ({
|
|
588
|
+
id: dep.id,
|
|
589
|
+
version: dep.version,
|
|
590
|
+
isComponent: dep.isComponent ?? true,
|
|
591
|
+
type: dep.type ?? 'runtime'
|
|
592
|
+
}))
|
|
568
593
|
};
|
|
569
594
|
}));
|
|
570
|
-
const componentIds = snapDataPerComp.map(t => t.componentId);
|
|
595
|
+
const componentIds = (0, _lodash().compact)(snapDataPerComp.map(t => t.isNew ? null : t.componentId));
|
|
596
|
+
const allCompIds = snapDataPerComp.map(s => s.componentId);
|
|
571
597
|
const componentIdsLatest = componentIds.map(id => id.changeVersion(_constants().LATEST));
|
|
598
|
+
const newCompsData = (0, _lodash().compact)(snapDataPerComp.map(t => t.isNew ? t : null));
|
|
599
|
+
const newComponents = await Promise.all(newCompsData.map(newComp => (0, _generateCompFromScope().generateCompFromScope)(this.scope, newComp)));
|
|
572
600
|
let lane;
|
|
573
601
|
const laneIdStr = params.lane;
|
|
574
602
|
if (laneIdStr) {
|
|
@@ -584,15 +612,22 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
584
612
|
lane,
|
|
585
613
|
reason: `seeders to snap`
|
|
586
614
|
});
|
|
587
|
-
const
|
|
588
|
-
await Promise.all(components.map(async comp => {
|
|
589
|
-
var _snapData$files;
|
|
615
|
+
const getSnapData = id => {
|
|
590
616
|
const snapData = snapDataPerComp.find(t => {
|
|
591
|
-
return t.componentId.isEqual(
|
|
617
|
+
return t.componentId.isEqual(id, {
|
|
592
618
|
ignoreVersion: true
|
|
593
619
|
});
|
|
594
620
|
});
|
|
595
|
-
if (!snapData) throw new Error(`unable to find ${
|
|
621
|
+
if (!snapData) throw new Error(`unable to find ${id.toString()} in snapDataPerComp`);
|
|
622
|
+
return snapData;
|
|
623
|
+
};
|
|
624
|
+
const existingComponents = await this.scope.getMany(componentIdsLatest);
|
|
625
|
+
const components = [...existingComponents, ...newComponents];
|
|
626
|
+
// for new components these are not needed. coz when generating them we already add the aspects and the files.
|
|
627
|
+
// the dependencies are calculated later and they're provided by "newDependencies" prop (not "dependencies").
|
|
628
|
+
await Promise.all(existingComponents.map(async comp => {
|
|
629
|
+
var _snapData$files;
|
|
630
|
+
const snapData = getSnapData(comp.id);
|
|
596
631
|
if (snapData.aspects) await this.scope.addAspectsFromConfigObject(comp, snapData.aspects);
|
|
597
632
|
if (snapData.dependencies.length) {
|
|
598
633
|
await this.updateDependenciesVersionsOfComponent(comp, snapData.dependencies, componentIds);
|
|
@@ -601,8 +636,18 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
601
636
|
await this.updateSourceFiles(comp, snapData.files);
|
|
602
637
|
}
|
|
603
638
|
}));
|
|
639
|
+
await (0, _pMapSeries().default)(components, async comp => this.scope.executeOnCompAspectReCalcSlot(comp));
|
|
640
|
+
|
|
641
|
+
// run this for new components only.
|
|
642
|
+
// otherwise, running this for existing components, will override the existing dependencies unexpectedly.
|
|
643
|
+
// if this is needed for existing components, see how to merge the model data.
|
|
644
|
+
await (0, _pMapSeries().default)(newComponents, async component => {
|
|
645
|
+
const snapData = getSnapData(component.id);
|
|
646
|
+
// adds explicitly defined dependencies and dependencies from envs/aspects (overrides)
|
|
647
|
+
await (0, _generateCompFromScope().addDeps)(component, snapData, this.scope, this.deps, this.dependencyResolver);
|
|
648
|
+
});
|
|
604
649
|
const consumerComponents = components.map(c => c.state._consumer);
|
|
605
|
-
const
|
|
650
|
+
const ids = _componentId().ComponentIdList.fromArray(allCompIds);
|
|
606
651
|
const results = await (0, _tagModelComponent().tagModelComponent)(_objectSpread(_objectSpread({}, params), {}, {
|
|
607
652
|
scope: this.scope,
|
|
608
653
|
consumerComponents,
|
|
@@ -613,7 +658,7 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
613
658
|
skipAutoTag: true,
|
|
614
659
|
persist: true,
|
|
615
660
|
isSnap: true,
|
|
616
|
-
ids
|
|
661
|
+
ids,
|
|
617
662
|
message: params.message
|
|
618
663
|
}));
|
|
619
664
|
const {
|
|
@@ -626,8 +671,8 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
626
671
|
exported
|
|
627
672
|
} = await this.exporter.exportMany({
|
|
628
673
|
scope: this.scope.legacyScope,
|
|
629
|
-
ids
|
|
630
|
-
idsWithFutureScope:
|
|
674
|
+
ids,
|
|
675
|
+
idsWithFutureScope: ids,
|
|
631
676
|
allVersions: false,
|
|
632
677
|
laneObject: updatedLane || undefined,
|
|
633
678
|
// no need other snaps. only the latest one. without this option, when snapping on lane from another-scope, it
|
|
@@ -660,6 +705,7 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
660
705
|
build,
|
|
661
706
|
disableTagAndSnapPipelines = false,
|
|
662
707
|
ignoreBuildErrors = false,
|
|
708
|
+
rebuildDepsGraph,
|
|
663
709
|
unmodified = false,
|
|
664
710
|
exitOnFirstFailedTask = false
|
|
665
711
|
}) {
|
|
@@ -697,6 +743,7 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
697
743
|
isSnap: true,
|
|
698
744
|
disableTagAndSnapPipelines,
|
|
699
745
|
ignoreBuildErrors,
|
|
746
|
+
rebuildDepsGraph,
|
|
700
747
|
packageManagerConfigRootDir: this.workspace.path,
|
|
701
748
|
dependencyResolver: this.dependencyResolver,
|
|
702
749
|
exitOnFirstFailedTask
|
|
@@ -807,7 +854,7 @@ there are matching among unmodified components thought. consider using --unmodif
|
|
|
807
854
|
await this.workspace.bitMap.write(`reset (never-exported)`);
|
|
808
855
|
return notExported;
|
|
809
856
|
}
|
|
810
|
-
async _addFlattenedDependenciesToComponents(components) {
|
|
857
|
+
async _addFlattenedDependenciesToComponents(components, rebuildDepsGraph = false) {
|
|
811
858
|
_loader().default.start('importing missing dependencies...');
|
|
812
859
|
const getLane = async () => {
|
|
813
860
|
const lane = await this.scope.legacyScope.getCurrentLaneObject();
|
|
@@ -824,8 +871,7 @@ there are matching among unmodified components thought. consider using --unmodif
|
|
|
824
871
|
await flattenedDependenciesGetter.populateFlattenedDependencies();
|
|
825
872
|
_loader().default.stop();
|
|
826
873
|
await this._addFlattenedDepsGraphToComponents(components);
|
|
827
|
-
|
|
828
|
-
if (!buildGraphFromHistoricFlattenedEdges) return;
|
|
874
|
+
if (rebuildDepsGraph) return;
|
|
829
875
|
components.forEach(component => {
|
|
830
876
|
const graphFromIds = graphIds.successorsSubgraph(component.id.toString());
|
|
831
877
|
const edgesFromGraph = graphFromIds.edges.map(edge => {
|
|
@@ -861,7 +907,10 @@ there are matching among unmodified components thought. consider using --unmodif
|
|
|
861
907
|
msg += `the following flattened deps exist in the fetched deps but not in the graph:\n${flattenedOnlyInFetched.join(', ')}\n`;
|
|
862
908
|
}
|
|
863
909
|
if (msg) {
|
|
864
|
-
throw new Error(`edges mismatch for ${component.id.toString()}
|
|
910
|
+
throw new Error(`edges mismatch for ${component.id.toString()}:
|
|
911
|
+
${msg}
|
|
912
|
+
please report this error to the support team.
|
|
913
|
+
to be able to continue without this error, re-run the command with "--rebuild-deps-graph" flag.`);
|
|
865
914
|
}
|
|
866
915
|
});
|
|
867
916
|
}
|
|
@@ -1242,14 +1291,14 @@ another option, in case this dependency is not in main yet is to remove all refe
|
|
|
1242
1291
|
const data = {
|
|
1243
1292
|
dependencies: dependenciesListSerialized
|
|
1244
1293
|
};
|
|
1245
|
-
const existingExtension = component.
|
|
1294
|
+
const existingExtension = component.config.extensions.findExtension(extId);
|
|
1246
1295
|
if (existingExtension) {
|
|
1247
1296
|
// Only merge top level of extension data
|
|
1248
1297
|
Object.assign(existingExtension.data, data);
|
|
1249
1298
|
return;
|
|
1250
1299
|
}
|
|
1251
1300
|
const extension = new (_config().ExtensionDataEntry)(undefined, undefined, extId, undefined, data);
|
|
1252
|
-
component.
|
|
1301
|
+
component.config.extensions.push(extension);
|
|
1253
1302
|
}
|
|
1254
1303
|
async getComponentsToTag(includeUnmodified, exactVersion, persist, ids, snapped, unmerged) {
|
|
1255
1304
|
const warnings = [];
|
|
@@ -1310,9 +1359,9 @@ another option, in case this dependency is not in main yet is to remove all refe
|
|
|
1310
1359
|
warnings
|
|
1311
1360
|
};
|
|
1312
1361
|
}
|
|
1313
|
-
static async provider([workspace, cli, loggerMain, issues, insights, dependencyResolver, scope, exporter, builder, importer, globalConfig]) {
|
|
1362
|
+
static async provider([workspace, cli, loggerMain, issues, insights, dependencyResolver, scope, exporter, builder, importer, globalConfig, deps]) {
|
|
1314
1363
|
const logger = loggerMain.createLogger(_snapping().SnappingAspect.id);
|
|
1315
|
-
const snapping = new SnappingMain(workspace, logger, issues, insights, dependencyResolver, scope, exporter, builder, importer);
|
|
1364
|
+
const snapping = new SnappingMain(workspace, logger, issues, insights, dependencyResolver, scope, exporter, builder, importer, deps);
|
|
1316
1365
|
const snapCmd = new (_snapCmd().SnapCmd)(snapping, logger, globalConfig);
|
|
1317
1366
|
const tagCmd = new (_tagCmd().TagCmd)(snapping, logger, globalConfig);
|
|
1318
1367
|
const tagFromScopeCmd = new (_tagFromScope().TagFromScopeCmd)(snapping, logger);
|
|
@@ -1324,7 +1373,7 @@ another option, in case this dependency is not in main yet is to remove all refe
|
|
|
1324
1373
|
}
|
|
1325
1374
|
exports.SnappingMain = SnappingMain;
|
|
1326
1375
|
_defineProperty(SnappingMain, "slots", []);
|
|
1327
|
-
_defineProperty(SnappingMain, "dependencies", [_workspace().default, _cli().CLIAspect, _logger().LoggerAspect, _issues().default, _insights().InsightsAspect, _dependencyResolver().DependencyResolverAspect, _scope().ScopeAspect, _export().ExportAspect, _builder().BuilderAspect, _importer().default, _globalConfig().default]);
|
|
1376
|
+
_defineProperty(SnappingMain, "dependencies", [_workspace().default, _cli().CLIAspect, _logger().LoggerAspect, _issues().default, _insights().InsightsAspect, _dependencyResolver().DependencyResolverAspect, _scope().ScopeAspect, _export().ExportAspect, _builder().BuilderAspect, _importer().default, _globalConfig().default, _dependencies().default]);
|
|
1328
1377
|
_defineProperty(SnappingMain, "runtime", _cli().MainRuntime);
|
|
1329
1378
|
_snapping().SnappingAspect.addRuntime(SnappingMain);
|
|
1330
1379
|
var _default = exports.default = SnappingMain;
|