@teambit/snapping 1.0.454 → 1.0.456
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 +8 -8
- package/artifacts/schema.json +6796 -3489
- package/dist/index.d.ts +3 -2
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -1
- package/dist/snap-from-scope.cmd.d.ts +3 -2
- package/dist/snap-from-scope.cmd.js +25 -16
- package/dist/snap-from-scope.cmd.js.map +1 -1
- package/dist/snapping.main.runtime.d.ts +9 -22
- package/dist/snapping.main.runtime.js +17 -202
- package/dist/snapping.main.runtime.js.map +1 -1
- package/dist/tag-model-component.d.ts +2 -8
- package/dist/tag-model-component.js +4 -4
- package/dist/tag-model-component.js.map +1 -1
- package/package.json +28 -30
- /package/dist/{preview-1730949656105.js → preview-1731122628865.js} +0 -0
|
@@ -18,6 +18,13 @@ function _graph() {
|
|
|
18
18
|
};
|
|
19
19
|
return data;
|
|
20
20
|
}
|
|
21
|
+
function _fsExtra() {
|
|
22
|
+
const data = _interopRequireDefault(require("fs-extra"));
|
|
23
|
+
_fsExtra = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
21
28
|
function _getFlattenedDependencies() {
|
|
22
29
|
const data = require("@teambit/legacy/dist/scope/component-ops/get-flattened-dependencies");
|
|
23
30
|
_getFlattenedDependencies = function () {
|
|
@@ -333,20 +340,6 @@ function _lanesModules() {
|
|
|
333
340
|
};
|
|
334
341
|
return data;
|
|
335
342
|
}
|
|
336
|
-
function _forking() {
|
|
337
|
-
const data = require("@teambit/forking");
|
|
338
|
-
_forking = function () {
|
|
339
|
-
return data;
|
|
340
|
-
};
|
|
341
|
-
return data;
|
|
342
|
-
}
|
|
343
|
-
function _install() {
|
|
344
|
-
const data = require("@teambit/install");
|
|
345
|
-
_install = function () {
|
|
346
|
-
return data;
|
|
347
|
-
};
|
|
348
|
-
return data;
|
|
349
|
-
}
|
|
350
343
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
351
344
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
352
345
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -354,7 +347,7 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
|
|
|
354
347
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
355
348
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
356
349
|
class SnappingMain {
|
|
357
|
-
constructor(workspace, logger, issues, insights, dependencyResolver, scope, exporter, builder, importer, deps, application
|
|
350
|
+
constructor(workspace, logger, issues, insights, dependencyResolver, scope, exporter, builder, importer, deps, application) {
|
|
358
351
|
this.workspace = workspace;
|
|
359
352
|
this.logger = logger;
|
|
360
353
|
this.issues = issues;
|
|
@@ -366,8 +359,6 @@ class SnappingMain {
|
|
|
366
359
|
this.importer = importer;
|
|
367
360
|
this.deps = deps;
|
|
368
361
|
this.application = application;
|
|
369
|
-
this.forking = forking;
|
|
370
|
-
this.install = install;
|
|
371
362
|
_defineProperty(this, "objectsRepo", void 0);
|
|
372
363
|
this.objectsRepo = this.scope?.legacyScope?.objects;
|
|
373
364
|
}
|
|
@@ -434,10 +425,7 @@ class SnappingMain {
|
|
|
434
425
|
stagedConfig,
|
|
435
426
|
removedComponents
|
|
436
427
|
} = await (0, _tagModelComponent().tagModelComponent)({
|
|
437
|
-
workspace: this.workspace,
|
|
438
|
-
scope: this.scope,
|
|
439
428
|
snapping: this,
|
|
440
|
-
builder: this.builder,
|
|
441
429
|
consumerComponents,
|
|
442
430
|
ids: compIds,
|
|
443
431
|
message,
|
|
@@ -457,7 +445,6 @@ class SnappingMain {
|
|
|
457
445
|
rebuildDepsGraph,
|
|
458
446
|
incrementBy,
|
|
459
447
|
packageManagerConfigRootDir: this.workspace.path,
|
|
460
|
-
dependencyResolver: this.dependencyResolver,
|
|
461
448
|
exitOnFirstFailedTask: failFast
|
|
462
449
|
});
|
|
463
450
|
const tagResults = {
|
|
@@ -537,15 +524,12 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
537
524
|
return comp.buildStatus === _constants().BuildStatus.Succeed && !params.rebuildArtifacts;
|
|
538
525
|
});
|
|
539
526
|
const results = await (0, _tagModelComponent().tagModelComponent)(_objectSpread(_objectSpread({}, params), {}, {
|
|
540
|
-
scope: this.scope,
|
|
541
527
|
consumerComponents,
|
|
542
528
|
tagDataPerComp,
|
|
543
529
|
populateArtifactsFrom: shouldUsePopulateArtifactsFrom ? components.map(c => c.id) : undefined,
|
|
544
530
|
populateArtifactsIgnorePkgJson: params.ignoreLastPkgJson,
|
|
545
531
|
copyLogFromPreviousSnap: true,
|
|
546
532
|
snapping: this,
|
|
547
|
-
builder: this.builder,
|
|
548
|
-
dependencyResolver: this.dependencyResolver,
|
|
549
533
|
skipAutoTag: true,
|
|
550
534
|
persist: true,
|
|
551
535
|
ids: componentIds,
|
|
@@ -579,174 +563,7 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
579
563
|
newComponents: new (_componentId().ComponentIdList)()
|
|
580
564
|
};
|
|
581
565
|
}
|
|
582
|
-
async forkAndSnap(snapDataPerCompRaw, params) {
|
|
583
|
-
const allAreForkedFrom = snapDataPerCompRaw.every(s => s.forkFrom);
|
|
584
|
-
if (!allAreForkedFrom) {
|
|
585
|
-
throw new (_bitError().BitError)(`when forkedFrom prop is used, all components must have the forkedFrom prop`);
|
|
586
|
-
}
|
|
587
|
-
let lane;
|
|
588
|
-
const laneIdStr = params.lane;
|
|
589
|
-
if (laneIdStr) {
|
|
590
|
-
const laneId = _laneId().LaneId.parse(laneIdStr);
|
|
591
|
-
try {
|
|
592
|
-
lane = await this.importer.importLaneObject(laneId);
|
|
593
|
-
} catch (err) {
|
|
594
|
-
if (err.constructor.name !== _legacy2().LaneNotFound.name) throw err;
|
|
595
|
-
// if the lane is not found, it's probably because it's new. create a new lane.
|
|
596
|
-
lane = await (0, _lanesModules().createLane)(this.workspace, laneId.name, laneId.scope);
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
const snapDataPerComp = snapDataPerCompRaw.map(snapData => {
|
|
600
|
-
return {
|
|
601
|
-
componentId: _componentId().ComponentID.fromString(snapData.componentId),
|
|
602
|
-
dependencies: snapData.dependencies || [],
|
|
603
|
-
aspects: snapData.aspects,
|
|
604
|
-
message: snapData.message,
|
|
605
|
-
files: snapData.files,
|
|
606
|
-
isNew: snapData.isNew,
|
|
607
|
-
mainFile: snapData.mainFile,
|
|
608
|
-
newDependencies: (snapData.newDependencies || []).map(dep => ({
|
|
609
|
-
id: dep.id,
|
|
610
|
-
version: dep.version,
|
|
611
|
-
isComponent: dep.isComponent ?? true,
|
|
612
|
-
type: dep.type ?? 'runtime'
|
|
613
|
-
})),
|
|
614
|
-
removeDependencies: snapData.removeDependencies,
|
|
615
|
-
forkFrom: _componentId().ComponentID.fromString(snapData.forkFrom),
|
|
616
|
-
version: snapData.version
|
|
617
|
-
};
|
|
618
|
-
});
|
|
619
|
-
|
|
620
|
-
// console.log('snapDataPerComp', JSON.stringify(snapDataPerComp, undefined, 2));
|
|
621
|
-
|
|
622
|
-
const allCompIds = snapDataPerComp.map(s => s.componentId);
|
|
623
|
-
const forkedFromData = (0, _lodash().compact)(snapDataPerComp.map(t => t.forkFrom ? t : null));
|
|
624
|
-
const forkMultipleData = forkedFromData.map(f => ({
|
|
625
|
-
sourceId: f.forkFrom.toString(),
|
|
626
|
-
targetId: f.componentId.fullName,
|
|
627
|
-
targetScope: f.componentId.scope
|
|
628
|
-
}));
|
|
629
|
-
const forkResults = await this.forking.forkMultipleFromRemote(forkMultipleData, {
|
|
630
|
-
refactor: true
|
|
631
|
-
});
|
|
632
|
-
const newEnvData = {};
|
|
633
|
-
forkedFromData.forEach(f => {
|
|
634
|
-
const bitmapElem = this.workspace.bitMap.getBitmapEntry(f.componentId);
|
|
635
|
-
// @ts-ignore
|
|
636
|
-
const env = bitmapElem?.config?.['teambit.envs/envs'].env;
|
|
637
|
-
if (!env) return;
|
|
638
|
-
const found = forkedFromData.find(fo => fo.forkFrom?.toStringWithoutVersion() === env);
|
|
639
|
-
if (!found) return;
|
|
640
|
-
const newEnvStr = found.componentId.toString();
|
|
641
|
-
if (!newEnvData[newEnvStr]) newEnvData[newEnvStr] = [];
|
|
642
|
-
newEnvData[newEnvStr].push(f.componentId);
|
|
643
|
-
});
|
|
644
|
-
await (0, _pMapSeries().default)(Object.entries(newEnvData), async ([env, compIds]) => {
|
|
645
|
-
await this.workspace.setEnvToComponents(_componentId().ComponentID.fromString(env), compIds, false);
|
|
646
|
-
});
|
|
647
|
-
const getSnapData = id => {
|
|
648
|
-
const snapData = snapDataPerComp.find(t => {
|
|
649
|
-
return t.componentId.isEqual(id, {
|
|
650
|
-
ignoreVersion: true
|
|
651
|
-
});
|
|
652
|
-
});
|
|
653
|
-
if (!snapData) throw new Error(`unable to find ${id.toString()} in snapDataPerComp`);
|
|
654
|
-
return snapData;
|
|
655
|
-
};
|
|
656
|
-
const newForkedComponents = await this.workspace.getMany(forkResults.map(f => f.targetCompId));
|
|
657
|
-
await Promise.all(newForkedComponents.map(async comp => {
|
|
658
|
-
const snapData = getSnapData(comp.id);
|
|
659
|
-
if (snapData.files?.length) {
|
|
660
|
-
await this.updateSourceFiles(comp, snapData.files);
|
|
661
|
-
await this.workspace.write(comp);
|
|
662
|
-
}
|
|
663
|
-
if (snapData.aspects) {
|
|
664
|
-
const bitmapElem = this.workspace.bitMap.getBitmapEntry(comp.id);
|
|
665
|
-
if (!bitmapElem) throw new Error(`unable to find ${comp.id.toString()} in the bitmap`);
|
|
666
|
-
const currentConfig = bitmapElem.config;
|
|
667
|
-
if (!currentConfig) {
|
|
668
|
-
this.workspace.bitMap.setEntireConfig(comp.id, snapData.aspects);
|
|
669
|
-
return;
|
|
670
|
-
}
|
|
671
|
-
const currentEnvSettings = currentConfig['teambit.envs/envs'];
|
|
672
|
-
const currentEnv = currentEnvSettings !== '-' && currentEnvSettings.env;
|
|
673
|
-
const newEnv = snapData.aspects['teambit.envs/envs']?.env;
|
|
674
|
-
if (!currentEnv || !newEnv) {
|
|
675
|
-
this.workspace.bitMap.setEntireConfig(comp.id, _objectSpread(_objectSpread({}, currentConfig), snapData.aspects));
|
|
676
|
-
return;
|
|
677
|
-
}
|
|
678
|
-
const currentEnvWithPotentialVer = Object.keys(currentConfig).find(c => c === currentEnv || c.startsWith(`${currentEnv}@`));
|
|
679
|
-
if (currentEnvWithPotentialVer) delete currentConfig[currentEnvWithPotentialVer];
|
|
680
|
-
delete currentConfig['teambit.envs/envs'];
|
|
681
|
-
this.workspace.bitMap.setEntireConfig(comp.id, _objectSpread(_objectSpread({}, currentConfig), snapData.aspects));
|
|
682
|
-
}
|
|
683
|
-
}));
|
|
684
|
-
await this.workspace.bitMap.write();
|
|
685
|
-
// if you don't clear the cache here, the installation assumes all components have the old env.
|
|
686
|
-
await this.workspace.clearCache();
|
|
687
|
-
await this.install.install(undefined, {
|
|
688
|
-
dedupe: true,
|
|
689
|
-
import: false,
|
|
690
|
-
copyPeerToRuntimeOnRoot: true,
|
|
691
|
-
copyPeerToRuntimeOnComponents: false,
|
|
692
|
-
updateExisting: false
|
|
693
|
-
});
|
|
694
|
-
// if we don't clear the cache here, the "build" process during tag doesn't install the necessary packages
|
|
695
|
-
// on the capsules.
|
|
696
|
-
await this.workspace.clearCache();
|
|
697
|
-
const components = await this.workspace.getMany(forkedFromData.map(f => f.componentId));
|
|
698
|
-
const consumerComponents = components.map(c => c.state._consumer);
|
|
699
|
-
const ids = _componentId().ComponentIdList.fromArray(allCompIds);
|
|
700
|
-
await this.throwForVariousIssues(components, params.ignoreIssues);
|
|
701
|
-
const shouldTag = Boolean(params.tag);
|
|
702
|
-
const results = await (0, _tagModelComponent().tagModelComponent)(_objectSpread(_objectSpread({}, params), {}, {
|
|
703
|
-
scope: this.scope,
|
|
704
|
-
consumerComponents,
|
|
705
|
-
tagDataPerComp: snapDataPerComp.map(s => ({
|
|
706
|
-
componentId: s.componentId,
|
|
707
|
-
message: s.message,
|
|
708
|
-
dependencies: [],
|
|
709
|
-
versionToTag: shouldTag ? s.version || 'patch' : undefined
|
|
710
|
-
})),
|
|
711
|
-
snapping: this,
|
|
712
|
-
builder: this.builder,
|
|
713
|
-
dependencyResolver: this.dependencyResolver,
|
|
714
|
-
skipAutoTag: true,
|
|
715
|
-
persist: true,
|
|
716
|
-
isSnap: !shouldTag,
|
|
717
|
-
ids,
|
|
718
|
-
message: params.message,
|
|
719
|
-
updateDependentsOnLane: params.updateDependents
|
|
720
|
-
}));
|
|
721
|
-
const {
|
|
722
|
-
taggedComponents
|
|
723
|
-
} = results;
|
|
724
|
-
let exportedIds;
|
|
725
|
-
if (params.push) {
|
|
726
|
-
const updatedLane = lane ? await this.scope.legacyScope.loadLane(lane.toLaneId()) : undefined;
|
|
727
|
-
const {
|
|
728
|
-
exported
|
|
729
|
-
} = await this.exporter.exportMany({
|
|
730
|
-
scope: this.scope.legacyScope,
|
|
731
|
-
ids,
|
|
732
|
-
allVersions: false,
|
|
733
|
-
laneObject: updatedLane,
|
|
734
|
-
// no need other snaps. only the latest one. without this option, when snapping on lane from another-scope, it
|
|
735
|
-
// may throw an error saying the previous snaps don't exist on the filesystem.
|
|
736
|
-
// (see the e2e - "snap on a lane when the component is new to the lane and the scope")
|
|
737
|
-
exportHeadsOnly: true
|
|
738
|
-
});
|
|
739
|
-
exportedIds = exported;
|
|
740
|
-
}
|
|
741
|
-
return {
|
|
742
|
-
snappedComponents: taggedComponents,
|
|
743
|
-
snappedIds: taggedComponents.map(comp => comp.id),
|
|
744
|
-
exportedIds
|
|
745
|
-
};
|
|
746
|
-
}
|
|
747
566
|
async snapFromScope(snapDataPerCompRaw, params) {
|
|
748
|
-
const hasForkedFrom = snapDataPerCompRaw.some(s => s.forkFrom);
|
|
749
|
-
if (hasForkedFrom) return this.forkAndSnap(snapDataPerCompRaw, params);
|
|
750
567
|
if (this.workspace) {
|
|
751
568
|
throw new (_bitError().BitError)(`unable to run this command from a workspace, please create a new bare-scope and run it from there`);
|
|
752
569
|
}
|
|
@@ -857,7 +674,6 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
857
674
|
const ids = _componentId().ComponentIdList.fromArray(allCompIds);
|
|
858
675
|
const shouldTag = Boolean(params.tag);
|
|
859
676
|
const results = await (0, _tagModelComponent().tagModelComponent)(_objectSpread(_objectSpread({}, params), {}, {
|
|
860
|
-
scope: this.scope,
|
|
861
677
|
consumerComponents,
|
|
862
678
|
tagDataPerComp: snapDataPerComp.map(s => ({
|
|
863
679
|
componentId: s.componentId,
|
|
@@ -866,8 +682,6 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
866
682
|
versionToTag: shouldTag ? s.version || 'patch' : undefined
|
|
867
683
|
})),
|
|
868
684
|
snapping: this,
|
|
869
|
-
builder: this.builder,
|
|
870
|
-
dependencyResolver: this.dependencyResolver,
|
|
871
685
|
skipAutoTag: true,
|
|
872
686
|
persist: true,
|
|
873
687
|
isSnap: !shouldTag,
|
|
@@ -943,10 +757,7 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
943
757
|
stagedConfig,
|
|
944
758
|
removedComponents
|
|
945
759
|
} = await (0, _tagModelComponent().tagModelComponent)({
|
|
946
|
-
workspace: this.workspace,
|
|
947
|
-
scope: this.scope,
|
|
948
760
|
snapping: this,
|
|
949
|
-
builder: this.builder,
|
|
950
761
|
editor,
|
|
951
762
|
consumerComponents,
|
|
952
763
|
ids,
|
|
@@ -963,7 +774,6 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
963
774
|
ignoreBuildErrors,
|
|
964
775
|
rebuildDepsGraph,
|
|
965
776
|
packageManagerConfigRootDir: this.workspace.path,
|
|
966
|
-
dependencyResolver: this.dependencyResolver,
|
|
967
777
|
exitOnFirstFailedTask
|
|
968
778
|
});
|
|
969
779
|
const snapResults = {
|
|
@@ -1411,7 +1221,12 @@ another option, in case this dependency is not in main yet is to remove all refe
|
|
|
1411
1221
|
const currentFiles = component.state.filesystem.files;
|
|
1412
1222
|
files.forEach(file => {
|
|
1413
1223
|
if (file.delete) {
|
|
1414
|
-
const
|
|
1224
|
+
const found = currentFiles.find(f => f.relative === file.path);
|
|
1225
|
+
if (!found) return;
|
|
1226
|
+
if (this.workspace) {
|
|
1227
|
+
_fsExtra().default.removeSync(found.path);
|
|
1228
|
+
}
|
|
1229
|
+
const index = currentFiles.findIndex(f => f.relative === file.path);
|
|
1415
1230
|
if (index !== -1) {
|
|
1416
1231
|
currentFiles.splice(index, 1);
|
|
1417
1232
|
}
|
|
@@ -1563,9 +1378,9 @@ another option, in case this dependency is not in main yet is to remove all refe
|
|
|
1563
1378
|
warnings
|
|
1564
1379
|
};
|
|
1565
1380
|
}
|
|
1566
|
-
static async provider([workspace, cli, loggerMain, issues, insights, dependencyResolver, scope, exporter, builder, importer, globalConfig, deps, application
|
|
1381
|
+
static async provider([workspace, cli, loggerMain, issues, insights, dependencyResolver, scope, exporter, builder, importer, globalConfig, deps, application]) {
|
|
1567
1382
|
const logger = loggerMain.createLogger(_snapping().SnappingAspect.id);
|
|
1568
|
-
const snapping = new SnappingMain(workspace, logger, issues, insights, dependencyResolver, scope, exporter, builder, importer, deps, application
|
|
1383
|
+
const snapping = new SnappingMain(workspace, logger, issues, insights, dependencyResolver, scope, exporter, builder, importer, deps, application);
|
|
1569
1384
|
const snapCmd = new (_snapCmd().SnapCmd)(snapping, logger, globalConfig);
|
|
1570
1385
|
const tagCmd = new (_tagCmd().TagCmd)(snapping, logger, globalConfig);
|
|
1571
1386
|
const tagFromScopeCmd = new (_tagFromScope().TagFromScopeCmd)(snapping, logger);
|
|
@@ -1578,7 +1393,7 @@ another option, in case this dependency is not in main yet is to remove all refe
|
|
|
1578
1393
|
}
|
|
1579
1394
|
exports.SnappingMain = SnappingMain;
|
|
1580
1395
|
_defineProperty(SnappingMain, "slots", []);
|
|
1581
|
-
_defineProperty(SnappingMain, "dependencies", [_workspace().WorkspaceAspect, _cli().CLIAspect, _logger().LoggerAspect, _issues().IssuesAspect, _insights().InsightsAspect, _dependencyResolver().DependencyResolverAspect, _scope().ScopeAspect, _export().ExportAspect, _builder().BuilderAspect, _importer().ImporterAspect, _globalConfig().GlobalConfigAspect, _dependencies().DependenciesAspect, _application().ApplicationAspect
|
|
1396
|
+
_defineProperty(SnappingMain, "dependencies", [_workspace().WorkspaceAspect, _cli().CLIAspect, _logger().LoggerAspect, _issues().IssuesAspect, _insights().InsightsAspect, _dependencyResolver().DependencyResolverAspect, _scope().ScopeAspect, _export().ExportAspect, _builder().BuilderAspect, _importer().ImporterAspect, _globalConfig().GlobalConfigAspect, _dependencies().DependenciesAspect, _application().ApplicationAspect]);
|
|
1582
1397
|
_defineProperty(SnappingMain, "runtime", _cli().MainRuntime);
|
|
1583
1398
|
_snapping().SnappingAspect.addRuntime(SnappingMain);
|
|
1584
1399
|
var _default = exports.default = SnappingMain;
|