@teambit/deprecation 1.0.270 → 1.0.271
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/__bit_junit.xml +1 -1
- package/artifacts/preview/teambit_component_deprecation-preview.js +1 -1
- package/artifacts/schema.json +32 -32
- package/dist/deprecation.main.runtime.js +3 -0
- package/dist/deprecation.main.runtime.js.map +1 -1
- package/dist/{preview-1715509699621.js → preview-1715656872728.js} +2 -2
- package/package.json +10 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<testsuites tests="0" failures="0" errors="0" skipped="0">
|
|
3
|
-
<testsuite name="teambit.component/deprecation@1.0.
|
|
3
|
+
<testsuite name="teambit.component/deprecation@1.0.271" tests="0" failures="0" errors="0" skipped="0"/>
|
|
4
4
|
</testsuites>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["teambit.component/deprecation-preview"]=t():e["teambit.component/deprecation-preview"]=t()}(self,(()=>(()=>{"use strict";var e={
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["teambit.component/deprecation-preview"]=t():e["teambit.component/deprecation-preview"]=t()}(self,(()=>(()=>{"use strict";var e={89629:(e,t,o)=>{var n={id:"teambit.component/deprecation@1.0.271",homepage:"https://bit.cloud/teambit/component/deprecation",exported:!0};function r(){const e=i(o(41594));return r=function(){return e},e}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.Logo=void 0,r.__bit_component=n,i.__bit_component=n;const p=()=>r().default.createElement("div",{style:{height:"100%",display:"flex",justifyContent:"center"}},r().default.createElement("img",{style:{width:70},src:"https://static.bit.dev/extensions-icons/deprecation.svg"}));p.__bit_component=n,t.Logo=p},41594:e=>{e.exports=React}},t={};function o(n){var r=t[n];if(void 0!==r)return r.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{o.r(n),o.d(n,{compositions:()=>u,compositions_metadata:()=>l,overview:()=>f});var e={};o.r(e),o.d(e,{default:()=>d});var t=o(89629);o(41594);const r=MdxJsReact,i=TeambitMdxUiMdxScopeContext;var p=["components"];function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},c.apply(this,arguments)}var a={},s="wrapper";function d(e){var t=e.components,o=function(e,t){if(null==e)return{};var o,n,r=function(e,t){if(null==e)return{};var o={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;o[n]=e[n]}return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)o=i[n],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(r[o]=e[o])}return r}(e,p);return(0,r.mdx)(s,c({},a,o,{components:t,mdxType:"MDXLayout"}),(0,r.mdx)(i.MDXScopeProvider,{components:{},mdxType:"MDXScopeProvider"}))}d.isMDXComponent=!0;const u=[t],f=[e],l={compositions:[{displayName:"Logo",identifier:"Logo"}]}})(),n})()));
|
package/artifacts/schema.json
CHANGED
|
@@ -437,7 +437,7 @@
|
|
|
437
437
|
"__schema": "VariableLikeSchema",
|
|
438
438
|
"location": {
|
|
439
439
|
"filePath": "deprecation.main.runtime.ts",
|
|
440
|
-
"line":
|
|
440
|
+
"line": 144,
|
|
441
441
|
"character": 3
|
|
442
442
|
},
|
|
443
443
|
"signature": "(property) DeprecationMain.runtime: RuntimeDefinition",
|
|
@@ -446,7 +446,7 @@
|
|
|
446
446
|
"__schema": "InferenceTypeSchema",
|
|
447
447
|
"location": {
|
|
448
448
|
"filePath": "deprecation.main.runtime.ts",
|
|
449
|
-
"line":
|
|
449
|
+
"line": 144,
|
|
450
450
|
"character": 3
|
|
451
451
|
},
|
|
452
452
|
"type": "RuntimeDefinition"
|
|
@@ -458,7 +458,7 @@
|
|
|
458
458
|
"__schema": "VariableLikeSchema",
|
|
459
459
|
"location": {
|
|
460
460
|
"filePath": "deprecation.main.runtime.ts",
|
|
461
|
-
"line":
|
|
461
|
+
"line": 145,
|
|
462
462
|
"character": 3
|
|
463
463
|
},
|
|
464
464
|
"signature": "(property) DeprecationMain.dependencies: Aspect[]",
|
|
@@ -467,7 +467,7 @@
|
|
|
467
467
|
"__schema": "InferenceTypeSchema",
|
|
468
468
|
"location": {
|
|
469
469
|
"filePath": "deprecation.main.runtime.ts",
|
|
470
|
-
"line":
|
|
470
|
+
"line": 145,
|
|
471
471
|
"character": 3
|
|
472
472
|
},
|
|
473
473
|
"type": "Aspect[]"
|
|
@@ -479,7 +479,7 @@
|
|
|
479
479
|
"__schema": "FunctionLikeSchema",
|
|
480
480
|
"location": {
|
|
481
481
|
"filePath": "deprecation.main.runtime.ts",
|
|
482
|
-
"line":
|
|
482
|
+
"line": 154,
|
|
483
483
|
"character": 3
|
|
484
484
|
},
|
|
485
485
|
"signature": "(method) DeprecationMain.provider([graphql, scope, componentAspect, workspace, cli, depsResolver, issues]: [\n GraphqlMain,\n ScopeMain,\n ComponentMain,\n Workspace,\n CLIMain,\n DependencyResolverMain,\n IssuesMain\n]): Promise<DeprecationMain>",
|
|
@@ -489,7 +489,7 @@
|
|
|
489
489
|
"__schema": "ParameterSchema",
|
|
490
490
|
"location": {
|
|
491
491
|
"filePath": "deprecation.main.runtime.ts",
|
|
492
|
-
"line":
|
|
492
|
+
"line": 154,
|
|
493
493
|
"character": 25
|
|
494
494
|
},
|
|
495
495
|
"name": "[ graphql, scope, componentAspect, workspace, cli, depsResolver, issues ]",
|
|
@@ -497,7 +497,7 @@
|
|
|
497
497
|
"__schema": "TupleTypeSchema",
|
|
498
498
|
"location": {
|
|
499
499
|
"filePath": "deprecation.main.runtime.ts",
|
|
500
|
-
"line":
|
|
500
|
+
"line": 154,
|
|
501
501
|
"character": 98
|
|
502
502
|
},
|
|
503
503
|
"elements": [
|
|
@@ -505,7 +505,7 @@
|
|
|
505
505
|
"__schema": "TypeRefSchema",
|
|
506
506
|
"location": {
|
|
507
507
|
"filePath": "deprecation.main.runtime.ts",
|
|
508
|
-
"line":
|
|
508
|
+
"line": 155,
|
|
509
509
|
"character": 5
|
|
510
510
|
},
|
|
511
511
|
"name": "GraphqlMain",
|
|
@@ -518,7 +518,7 @@
|
|
|
518
518
|
"__schema": "TypeRefSchema",
|
|
519
519
|
"location": {
|
|
520
520
|
"filePath": "deprecation.main.runtime.ts",
|
|
521
|
-
"line":
|
|
521
|
+
"line": 156,
|
|
522
522
|
"character": 5
|
|
523
523
|
},
|
|
524
524
|
"name": "ScopeMain",
|
|
@@ -531,7 +531,7 @@
|
|
|
531
531
|
"__schema": "TypeRefSchema",
|
|
532
532
|
"location": {
|
|
533
533
|
"filePath": "deprecation.main.runtime.ts",
|
|
534
|
-
"line":
|
|
534
|
+
"line": 157,
|
|
535
535
|
"character": 5
|
|
536
536
|
},
|
|
537
537
|
"name": "ComponentMain",
|
|
@@ -544,7 +544,7 @@
|
|
|
544
544
|
"__schema": "TypeRefSchema",
|
|
545
545
|
"location": {
|
|
546
546
|
"filePath": "deprecation.main.runtime.ts",
|
|
547
|
-
"line":
|
|
547
|
+
"line": 158,
|
|
548
548
|
"character": 5
|
|
549
549
|
},
|
|
550
550
|
"name": "Workspace",
|
|
@@ -557,7 +557,7 @@
|
|
|
557
557
|
"__schema": "TypeRefSchema",
|
|
558
558
|
"location": {
|
|
559
559
|
"filePath": "deprecation.main.runtime.ts",
|
|
560
|
-
"line":
|
|
560
|
+
"line": 159,
|
|
561
561
|
"character": 5
|
|
562
562
|
},
|
|
563
563
|
"name": "CLIMain",
|
|
@@ -570,7 +570,7 @@
|
|
|
570
570
|
"__schema": "TypeRefSchema",
|
|
571
571
|
"location": {
|
|
572
572
|
"filePath": "deprecation.main.runtime.ts",
|
|
573
|
-
"line":
|
|
573
|
+
"line": 160,
|
|
574
574
|
"character": 5
|
|
575
575
|
},
|
|
576
576
|
"name": "DependencyResolverMain",
|
|
@@ -583,7 +583,7 @@
|
|
|
583
583
|
"__schema": "TypeRefSchema",
|
|
584
584
|
"location": {
|
|
585
585
|
"filePath": "deprecation.main.runtime.ts",
|
|
586
|
-
"line":
|
|
586
|
+
"line": 161,
|
|
587
587
|
"character": 5
|
|
588
588
|
},
|
|
589
589
|
"name": "IssuesMain",
|
|
@@ -602,7 +602,7 @@
|
|
|
602
602
|
"__schema": "InferenceTypeSchema",
|
|
603
603
|
"location": {
|
|
604
604
|
"filePath": "deprecation.main.runtime.ts",
|
|
605
|
-
"line":
|
|
605
|
+
"line": 154,
|
|
606
606
|
"character": 3
|
|
607
607
|
},
|
|
608
608
|
"type": "Promise<DeprecationMain>"
|
|
@@ -1524,7 +1524,7 @@
|
|
|
1524
1524
|
"__schema": "VariableLikeSchema",
|
|
1525
1525
|
"location": {
|
|
1526
1526
|
"filePath": "deprecation.main.runtime.ts",
|
|
1527
|
-
"line":
|
|
1527
|
+
"line": 144,
|
|
1528
1528
|
"character": 3
|
|
1529
1529
|
},
|
|
1530
1530
|
"signature": "(property) DeprecationMain.runtime: RuntimeDefinition",
|
|
@@ -1533,7 +1533,7 @@
|
|
|
1533
1533
|
"__schema": "InferenceTypeSchema",
|
|
1534
1534
|
"location": {
|
|
1535
1535
|
"filePath": "deprecation.main.runtime.ts",
|
|
1536
|
-
"line":
|
|
1536
|
+
"line": 144,
|
|
1537
1537
|
"character": 3
|
|
1538
1538
|
},
|
|
1539
1539
|
"type": "RuntimeDefinition"
|
|
@@ -1545,7 +1545,7 @@
|
|
|
1545
1545
|
"__schema": "VariableLikeSchema",
|
|
1546
1546
|
"location": {
|
|
1547
1547
|
"filePath": "deprecation.main.runtime.ts",
|
|
1548
|
-
"line":
|
|
1548
|
+
"line": 145,
|
|
1549
1549
|
"character": 3
|
|
1550
1550
|
},
|
|
1551
1551
|
"signature": "(property) DeprecationMain.dependencies: Aspect[]",
|
|
@@ -1554,7 +1554,7 @@
|
|
|
1554
1554
|
"__schema": "InferenceTypeSchema",
|
|
1555
1555
|
"location": {
|
|
1556
1556
|
"filePath": "deprecation.main.runtime.ts",
|
|
1557
|
-
"line":
|
|
1557
|
+
"line": 145,
|
|
1558
1558
|
"character": 3
|
|
1559
1559
|
},
|
|
1560
1560
|
"type": "Aspect[]"
|
|
@@ -1566,7 +1566,7 @@
|
|
|
1566
1566
|
"__schema": "FunctionLikeSchema",
|
|
1567
1567
|
"location": {
|
|
1568
1568
|
"filePath": "deprecation.main.runtime.ts",
|
|
1569
|
-
"line":
|
|
1569
|
+
"line": 154,
|
|
1570
1570
|
"character": 3
|
|
1571
1571
|
},
|
|
1572
1572
|
"signature": "(method) DeprecationMain.provider([graphql, scope, componentAspect, workspace, cli, depsResolver, issues]: [\n GraphqlMain,\n ScopeMain,\n ComponentMain,\n Workspace,\n CLIMain,\n DependencyResolverMain,\n IssuesMain\n]): Promise<DeprecationMain>",
|
|
@@ -1576,7 +1576,7 @@
|
|
|
1576
1576
|
"__schema": "ParameterSchema",
|
|
1577
1577
|
"location": {
|
|
1578
1578
|
"filePath": "deprecation.main.runtime.ts",
|
|
1579
|
-
"line":
|
|
1579
|
+
"line": 154,
|
|
1580
1580
|
"character": 25
|
|
1581
1581
|
},
|
|
1582
1582
|
"name": "[ graphql, scope, componentAspect, workspace, cli, depsResolver, issues ]",
|
|
@@ -1584,7 +1584,7 @@
|
|
|
1584
1584
|
"__schema": "TupleTypeSchema",
|
|
1585
1585
|
"location": {
|
|
1586
1586
|
"filePath": "deprecation.main.runtime.ts",
|
|
1587
|
-
"line":
|
|
1587
|
+
"line": 154,
|
|
1588
1588
|
"character": 98
|
|
1589
1589
|
},
|
|
1590
1590
|
"elements": [
|
|
@@ -1592,7 +1592,7 @@
|
|
|
1592
1592
|
"__schema": "TypeRefSchema",
|
|
1593
1593
|
"location": {
|
|
1594
1594
|
"filePath": "deprecation.main.runtime.ts",
|
|
1595
|
-
"line":
|
|
1595
|
+
"line": 155,
|
|
1596
1596
|
"character": 5
|
|
1597
1597
|
},
|
|
1598
1598
|
"name": "GraphqlMain",
|
|
@@ -1605,7 +1605,7 @@
|
|
|
1605
1605
|
"__schema": "TypeRefSchema",
|
|
1606
1606
|
"location": {
|
|
1607
1607
|
"filePath": "deprecation.main.runtime.ts",
|
|
1608
|
-
"line":
|
|
1608
|
+
"line": 156,
|
|
1609
1609
|
"character": 5
|
|
1610
1610
|
},
|
|
1611
1611
|
"name": "ScopeMain",
|
|
@@ -1618,7 +1618,7 @@
|
|
|
1618
1618
|
"__schema": "TypeRefSchema",
|
|
1619
1619
|
"location": {
|
|
1620
1620
|
"filePath": "deprecation.main.runtime.ts",
|
|
1621
|
-
"line":
|
|
1621
|
+
"line": 157,
|
|
1622
1622
|
"character": 5
|
|
1623
1623
|
},
|
|
1624
1624
|
"name": "ComponentMain",
|
|
@@ -1631,7 +1631,7 @@
|
|
|
1631
1631
|
"__schema": "TypeRefSchema",
|
|
1632
1632
|
"location": {
|
|
1633
1633
|
"filePath": "deprecation.main.runtime.ts",
|
|
1634
|
-
"line":
|
|
1634
|
+
"line": 158,
|
|
1635
1635
|
"character": 5
|
|
1636
1636
|
},
|
|
1637
1637
|
"name": "Workspace",
|
|
@@ -1644,7 +1644,7 @@
|
|
|
1644
1644
|
"__schema": "TypeRefSchema",
|
|
1645
1645
|
"location": {
|
|
1646
1646
|
"filePath": "deprecation.main.runtime.ts",
|
|
1647
|
-
"line":
|
|
1647
|
+
"line": 159,
|
|
1648
1648
|
"character": 5
|
|
1649
1649
|
},
|
|
1650
1650
|
"name": "CLIMain",
|
|
@@ -1657,7 +1657,7 @@
|
|
|
1657
1657
|
"__schema": "TypeRefSchema",
|
|
1658
1658
|
"location": {
|
|
1659
1659
|
"filePath": "deprecation.main.runtime.ts",
|
|
1660
|
-
"line":
|
|
1660
|
+
"line": 160,
|
|
1661
1661
|
"character": 5
|
|
1662
1662
|
},
|
|
1663
1663
|
"name": "DependencyResolverMain",
|
|
@@ -1670,7 +1670,7 @@
|
|
|
1670
1670
|
"__schema": "TypeRefSchema",
|
|
1671
1671
|
"location": {
|
|
1672
1672
|
"filePath": "deprecation.main.runtime.ts",
|
|
1673
|
-
"line":
|
|
1673
|
+
"line": 161,
|
|
1674
1674
|
"character": 5
|
|
1675
1675
|
},
|
|
1676
1676
|
"name": "IssuesMain",
|
|
@@ -1689,7 +1689,7 @@
|
|
|
1689
1689
|
"__schema": "InferenceTypeSchema",
|
|
1690
1690
|
"location": {
|
|
1691
1691
|
"filePath": "deprecation.main.runtime.ts",
|
|
1692
|
-
"line":
|
|
1692
|
+
"line": 154,
|
|
1693
1693
|
"character": 3
|
|
1694
1694
|
},
|
|
1695
1695
|
"type": "Promise<DeprecationMain>"
|
|
@@ -1709,7 +1709,7 @@
|
|
|
1709
1709
|
"__schema": "UnImplementedSchema",
|
|
1710
1710
|
"location": {
|
|
1711
1711
|
"filePath": "deprecation.main.runtime.ts",
|
|
1712
|
-
"line":
|
|
1712
|
+
"line": 173,
|
|
1713
1713
|
"character": 1
|
|
1714
1714
|
},
|
|
1715
1715
|
"name": "DeprecationAspect.addRuntime(DeprecationMain);",
|
|
@@ -1768,7 +1768,7 @@
|
|
|
1768
1768
|
"componentId": {
|
|
1769
1769
|
"scope": "teambit.component",
|
|
1770
1770
|
"name": "deprecation",
|
|
1771
|
-
"version": "1.0.
|
|
1771
|
+
"version": "1.0.271"
|
|
1772
1772
|
},
|
|
1773
1773
|
"taggedModuleExports": []
|
|
1774
1774
|
}
|
|
@@ -198,6 +198,9 @@ class DeprecationMain {
|
|
|
198
198
|
*/
|
|
199
199
|
async isDeprecatedByIdWithoutLoadingComponent(componentId) {
|
|
200
200
|
if (!componentId.hasVersion()) return false;
|
|
201
|
+
const bitmapEntry = this.workspace.bitMap.getBitmapEntryIfExist(componentId);
|
|
202
|
+
if (bitmapEntry && bitmapEntry.isDeprecated()) return true;
|
|
203
|
+
if (bitmapEntry && bitmapEntry.isUndeprecated()) return false;
|
|
201
204
|
const modelComp = await this.workspace.scope.getBitObjectModelComponent(componentId);
|
|
202
205
|
if (!modelComp) return false;
|
|
203
206
|
const isDeprecated = await modelComp.isDeprecated(this.workspace.scope.legacyScope.objects, componentId.version);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_cli","data","require","_semver","_interopRequireDefault","_component","_scope","_workspace","_graphql","_deprecation","_deprecation2","_deprecation3","_deprecateCmd","_undeprecateCmd","_issues","_pMapSeries","_dependencyResolver","_lodash","_componentIssues","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","Symbol","toPrimitive","call","TypeError","String","Number","DeprecationMain","constructor","scope","workspace","depsResolver","getDeprecationInfo","component","headComponent","getHeadComponent","config","extensions","findExtension","DeprecationAspect","id","deprecatedBackwardCompatibility","state","_consumer","deprecated","isDeprecate","Boolean","deprecate","currentTag","getTag","isDeprecateByRange","range","semver","satisfies","version","newId","ComponentID","fromObject","toString","undefined","head","hash","headTag","headComp","get","changeVersion","Error","componentId","results","bitMap","addComponentConfig","toObject","write","unDeprecate","addDeprecatedDependenciesIssues","components","pMapSeries","addDeprecatedDepIssue","dependencies","getComponentDependencies","removedWithUndefined","Promise","all","map","dep","isRemoved","isDeprecatedByIdWithoutLoadingComponent","removed","compact","length","issues","getOrCreate","IssuesClasses","DeprecatedDependencies","hasVersion","modelComp","getBitObjectModelComponent","isDeprecated","legacyScope","objects","provider","graphql","componentAspect","cli","deprecation","registerAddComponentsIssues","bind","register","DeprecateCmd","UndeprecateCmd","registerShowFragments","DeprecationFragment","deprecationSchema","exports","MainRuntime","GraphqlAspect","ScopeAspect","ComponentAspect","WorkspaceAspect","CLIAspect","DependencyResolverAspect","IssuesAspect","addRuntime"],"sources":["deprecation.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport semver from 'semver';\nimport { ComponentMain, ComponentAspect, Component, ComponentID } from '@teambit/component';\nimport { ScopeMain, ScopeAspect } from '@teambit/scope';\nimport { WorkspaceAspect, Workspace } from '@teambit/workspace';\nimport { GraphqlAspect, GraphqlMain } from '@teambit/graphql';\nimport { ComponentIdObj } from '@teambit/component-id';\nimport { DeprecationAspect } from './deprecation.aspect';\nimport { deprecationSchema } from './deprecation.graphql';\nimport { DeprecationFragment } from './deprecation.fragment';\nimport { DeprecateCmd } from './deprecate-cmd';\nimport { UndeprecateCmd } from './undeprecate-cmd';\nimport IssuesAspect, { IssuesMain } from '@teambit/issues';\nimport pMapSeries from 'p-map-series';\nimport DependencyResolverAspect, { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { compact } from 'lodash';\nimport { IssuesClasses } from '@teambit/component-issues';\n\nexport type DeprecationInfo = {\n isDeprecate: boolean;\n newId?: string;\n range?: string;\n};\n\nexport type DeprecationMetadata = {\n /**\n * whether the head is deprecated\n */\n deprecate?: boolean;\n /**\n * the new id to use instead of the current one\n */\n newId?: ComponentIdObj;\n /**\n * Semver range to deprecate previous versions\n */\n range?: string;\n};\n\nexport class DeprecationMain {\n constructor(private scope: ScopeMain, private workspace: Workspace, private depsResolver: DependencyResolverMain) {}\n\n async getDeprecationInfo(component: Component): Promise<DeprecationInfo> {\n const headComponent = await this.getHeadComponent(component);\n\n const data = headComponent.config.extensions.findExtension(DeprecationAspect.id)?.config as\n | DeprecationMetadata\n | undefined;\n const deprecatedBackwardCompatibility = component.state._consumer.deprecated;\n const isDeprecate = Boolean(data?.deprecate || deprecatedBackwardCompatibility);\n const currentTag = component.getTag();\n const isDeprecateByRange = Boolean(data?.range && currentTag && semver.satisfies(currentTag.version, data.range));\n const newId = data?.newId ? ComponentID.fromObject(data?.newId).toString() : undefined;\n return {\n isDeprecate: isDeprecate || isDeprecateByRange,\n newId,\n range: data?.range,\n };\n }\n\n private async getHeadComponent(component: Component): Promise<Component> {\n if (\n component.id.version &&\n component.head &&\n component.id.version !== component.head?.hash &&\n component.id.version !== component.headTag?.version.version\n ) {\n const headComp = this.workspace // if workspace exits, prefer using the workspace as it may be modified\n ? await this.workspace.get(component.id.changeVersion(undefined))\n : await this.scope.get(component.id.changeVersion(component.head.hash));\n if (!headComp) throw new Error(`unable to get the head of ${component.id.toString()}`);\n return headComp;\n }\n return component;\n }\n\n /**\n * mark a component as deprecated. after this change, the component will be modified.\n * tag and export the component to have it deprecated on the remote.\n *\n * @param componentId\n * @param newId\n * @returns boolean whether or not the component has been deprecated\n */\n async deprecate(componentId: ComponentID, newId?: ComponentID, range?: string): Promise<boolean> {\n const results = this.workspace.bitMap.addComponentConfig(componentId, DeprecationAspect.id, {\n deprecate: !range,\n newId: newId?.toObject(),\n range,\n });\n await this.workspace.bitMap.write(`deprecate ${componentId.toString()}`);\n\n return results;\n }\n\n async unDeprecate(componentId: ComponentID) {\n const results = this.workspace.bitMap.addComponentConfig(componentId, DeprecationAspect.id, {\n deprecate: false,\n newId: '',\n });\n await this.workspace.bitMap.write(`undeprecate ${componentId.toString()}`);\n\n return results;\n }\n\n async addDeprecatedDependenciesIssues(components: Component[]) {\n await pMapSeries(components, async (component) => {\n await this.addDeprecatedDepIssue(component);\n });\n }\n\n private async addDeprecatedDepIssue(component: Component) {\n const dependencies = this.depsResolver.getComponentDependencies(component);\n const removedWithUndefined = await Promise.all(\n dependencies.map(async (dep) => {\n const isRemoved = await this.isDeprecatedByIdWithoutLoadingComponent(dep.componentId);\n if (isRemoved) return dep.componentId;\n return undefined;\n })\n );\n const removed = compact(removedWithUndefined).map((id) => id.toString());\n if (removed.length) {\n component.state.issues.getOrCreate(IssuesClasses.DeprecatedDependencies).data = removed;\n }\n }\n\n /**\n * performant version of isDeprecated() in case the component object is not available and loading it is expensive.\n */\n private async isDeprecatedByIdWithoutLoadingComponent(componentId: ComponentID): Promise<boolean> {\n if (!componentId.hasVersion()) return false;\n const modelComp = await this.workspace.scope.getBitObjectModelComponent(componentId);\n if (!modelComp) return false;\n const isDeprecated = await modelComp.isDeprecated(\n this.workspace.scope.legacyScope.objects,\n componentId.version as string\n );\n return Boolean(isDeprecated);\n }\n\n static runtime = MainRuntime;\n static dependencies = [\n GraphqlAspect,\n ScopeAspect,\n ComponentAspect,\n WorkspaceAspect,\n CLIAspect,\n DependencyResolverAspect,\n IssuesAspect,\n ];\n static async provider([graphql, scope, componentAspect, workspace, cli, depsResolver, issues]: [\n GraphqlMain,\n ScopeMain,\n ComponentMain,\n Workspace,\n CLIMain,\n DependencyResolverMain,\n IssuesMain\n ]) {\n const deprecation = new DeprecationMain(scope, workspace, depsResolver);\n issues.registerAddComponentsIssues(deprecation.addDeprecatedDependenciesIssues.bind(deprecation));\n cli.register(new DeprecateCmd(deprecation, workspace), new UndeprecateCmd(deprecation, workspace));\n componentAspect.registerShowFragments([new DeprecationFragment(deprecation)]);\n graphql.register(deprecationSchema(deprecation));\n\n return deprecation;\n }\n}\n\nDeprecationAspect.addRuntime(DeprecationMain);\n"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,WAAA;EAAA,MAAAJ,IAAA,GAAAC,O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IYoB,eAAe,aAqGTuF,kBAAW;AAAA3G,eAAA,CArGjBoB,eAAe,kBAsGJ,CACpBwF,wBAAa,EACbC,oBAAW,EACXC,4BAAe,EACfC,4BAAe,EACfC,gBAAS,EACTC,6BAAwB,EACxBC,iBAAY,CACb;AAoBHlF,gCAAiB,CAACmF,UAAU,CAAC/F,eAAe,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_cli","data","require","_semver","_interopRequireDefault","_component","_scope","_workspace","_graphql","_deprecation","_deprecation2","_deprecation3","_deprecateCmd","_undeprecateCmd","_issues","_pMapSeries","_dependencyResolver","_lodash","_componentIssues","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","Symbol","toPrimitive","call","TypeError","String","Number","DeprecationMain","constructor","scope","workspace","depsResolver","getDeprecationInfo","component","headComponent","getHeadComponent","config","extensions","findExtension","DeprecationAspect","id","deprecatedBackwardCompatibility","state","_consumer","deprecated","isDeprecate","Boolean","deprecate","currentTag","getTag","isDeprecateByRange","range","semver","satisfies","version","newId","ComponentID","fromObject","toString","undefined","head","hash","headTag","headComp","get","changeVersion","Error","componentId","results","bitMap","addComponentConfig","toObject","write","unDeprecate","addDeprecatedDependenciesIssues","components","pMapSeries","addDeprecatedDepIssue","dependencies","getComponentDependencies","removedWithUndefined","Promise","all","map","dep","isRemoved","isDeprecatedByIdWithoutLoadingComponent","removed","compact","length","issues","getOrCreate","IssuesClasses","DeprecatedDependencies","hasVersion","bitmapEntry","getBitmapEntryIfExist","isDeprecated","isUndeprecated","modelComp","getBitObjectModelComponent","legacyScope","objects","provider","graphql","componentAspect","cli","deprecation","registerAddComponentsIssues","bind","register","DeprecateCmd","UndeprecateCmd","registerShowFragments","DeprecationFragment","deprecationSchema","exports","MainRuntime","GraphqlAspect","ScopeAspect","ComponentAspect","WorkspaceAspect","CLIAspect","DependencyResolverAspect","IssuesAspect","addRuntime"],"sources":["deprecation.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport semver from 'semver';\nimport { ComponentMain, ComponentAspect, Component, ComponentID } from '@teambit/component';\nimport { ScopeMain, ScopeAspect } from '@teambit/scope';\nimport { WorkspaceAspect, Workspace } from '@teambit/workspace';\nimport { GraphqlAspect, GraphqlMain } from '@teambit/graphql';\nimport { ComponentIdObj } from '@teambit/component-id';\nimport { DeprecationAspect } from './deprecation.aspect';\nimport { deprecationSchema } from './deprecation.graphql';\nimport { DeprecationFragment } from './deprecation.fragment';\nimport { DeprecateCmd } from './deprecate-cmd';\nimport { UndeprecateCmd } from './undeprecate-cmd';\nimport IssuesAspect, { IssuesMain } from '@teambit/issues';\nimport pMapSeries from 'p-map-series';\nimport DependencyResolverAspect, { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { compact } from 'lodash';\nimport { IssuesClasses } from '@teambit/component-issues';\n\nexport type DeprecationInfo = {\n isDeprecate: boolean;\n newId?: string;\n range?: string;\n};\n\nexport type DeprecationMetadata = {\n /**\n * whether the head is deprecated\n */\n deprecate?: boolean;\n /**\n * the new id to use instead of the current one\n */\n newId?: ComponentIdObj;\n /**\n * Semver range to deprecate previous versions\n */\n range?: string;\n};\n\nexport class DeprecationMain {\n constructor(private scope: ScopeMain, private workspace: Workspace, private depsResolver: DependencyResolverMain) {}\n\n async getDeprecationInfo(component: Component): Promise<DeprecationInfo> {\n const headComponent = await this.getHeadComponent(component);\n\n const data = headComponent.config.extensions.findExtension(DeprecationAspect.id)?.config as\n | DeprecationMetadata\n | undefined;\n const deprecatedBackwardCompatibility = component.state._consumer.deprecated;\n const isDeprecate = Boolean(data?.deprecate || deprecatedBackwardCompatibility);\n const currentTag = component.getTag();\n const isDeprecateByRange = Boolean(data?.range && currentTag && semver.satisfies(currentTag.version, data.range));\n const newId = data?.newId ? ComponentID.fromObject(data?.newId).toString() : undefined;\n return {\n isDeprecate: isDeprecate || isDeprecateByRange,\n newId,\n range: data?.range,\n };\n }\n\n private async getHeadComponent(component: Component): Promise<Component> {\n if (\n component.id.version &&\n component.head &&\n component.id.version !== component.head?.hash &&\n component.id.version !== component.headTag?.version.version\n ) {\n const headComp = this.workspace // if workspace exits, prefer using the workspace as it may be modified\n ? await this.workspace.get(component.id.changeVersion(undefined))\n : await this.scope.get(component.id.changeVersion(component.head.hash));\n if (!headComp) throw new Error(`unable to get the head of ${component.id.toString()}`);\n return headComp;\n }\n return component;\n }\n\n /**\n * mark a component as deprecated. after this change, the component will be modified.\n * tag and export the component to have it deprecated on the remote.\n *\n * @param componentId\n * @param newId\n * @returns boolean whether or not the component has been deprecated\n */\n async deprecate(componentId: ComponentID, newId?: ComponentID, range?: string): Promise<boolean> {\n const results = this.workspace.bitMap.addComponentConfig(componentId, DeprecationAspect.id, {\n deprecate: !range,\n newId: newId?.toObject(),\n range,\n });\n await this.workspace.bitMap.write(`deprecate ${componentId.toString()}`);\n\n return results;\n }\n\n async unDeprecate(componentId: ComponentID) {\n const results = this.workspace.bitMap.addComponentConfig(componentId, DeprecationAspect.id, {\n deprecate: false,\n newId: '',\n });\n await this.workspace.bitMap.write(`undeprecate ${componentId.toString()}`);\n\n return results;\n }\n\n async addDeprecatedDependenciesIssues(components: Component[]) {\n await pMapSeries(components, async (component) => {\n await this.addDeprecatedDepIssue(component);\n });\n }\n\n private async addDeprecatedDepIssue(component: Component) {\n const dependencies = this.depsResolver.getComponentDependencies(component);\n const removedWithUndefined = await Promise.all(\n dependencies.map(async (dep) => {\n const isRemoved = await this.isDeprecatedByIdWithoutLoadingComponent(dep.componentId);\n if (isRemoved) return dep.componentId;\n return undefined;\n })\n );\n const removed = compact(removedWithUndefined).map((id) => id.toString());\n if (removed.length) {\n component.state.issues.getOrCreate(IssuesClasses.DeprecatedDependencies).data = removed;\n }\n }\n\n /**\n * performant version of isDeprecated() in case the component object is not available and loading it is expensive.\n */\n private async isDeprecatedByIdWithoutLoadingComponent(componentId: ComponentID): Promise<boolean> {\n if (!componentId.hasVersion()) return false;\n const bitmapEntry = this.workspace.bitMap.getBitmapEntryIfExist(componentId);\n if (bitmapEntry && bitmapEntry.isDeprecated()) return true;\n if (bitmapEntry && bitmapEntry.isUndeprecated()) return false;\n const modelComp = await this.workspace.scope.getBitObjectModelComponent(componentId);\n if (!modelComp) return false;\n const isDeprecated = await modelComp.isDeprecated(\n this.workspace.scope.legacyScope.objects,\n componentId.version as string\n );\n return Boolean(isDeprecated);\n }\n\n static runtime = MainRuntime;\n static dependencies = [\n GraphqlAspect,\n ScopeAspect,\n ComponentAspect,\n WorkspaceAspect,\n CLIAspect,\n DependencyResolverAspect,\n IssuesAspect,\n ];\n static async provider([graphql, scope, componentAspect, workspace, cli, depsResolver, issues]: [\n GraphqlMain,\n ScopeMain,\n ComponentMain,\n Workspace,\n CLIMain,\n DependencyResolverMain,\n IssuesMain\n ]) {\n const deprecation = new DeprecationMain(scope, workspace, depsResolver);\n issues.registerAddComponentsIssues(deprecation.addDeprecatedDependenciesIssues.bind(deprecation));\n cli.register(new DeprecateCmd(deprecation, workspace), new UndeprecateCmd(deprecation, workspace));\n componentAspect.registerShowFragments([new DeprecationFragment(deprecation)]);\n graphql.register(deprecationSchema(deprecation));\n\n return deprecation;\n }\n}\n\nDeprecationAspect.addRuntime(DeprecationMain);\n"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,WAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,UAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,OAAA;EAAA,M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ACM,QAAQ,CAAC,IAAAK,iCAAiB,EAACR,WAAW,CAAC,CAAC;IAEhD,OAAOA,WAAW;EACpB;AACF;AAACS,OAAA,CAAAzF,eAAA,GAAAA,eAAA;AAAApB,eAAA,CAnIYoB,eAAe,aAwGT0F,kBAAW;AAAA9G,eAAA,CAxGjBoB,eAAe,kBAyGJ,CACpB2F,wBAAa,EACbC,oBAAW,EACXC,4BAAe,EACfC,4BAAe,EACfC,gBAAS,EACTC,6BAAwB,EACxBC,iBAAY,CACb;AAoBHrF,gCAAiB,CAACsF,UAAU,CAAClG,eAAe,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.component_deprecation@1.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.component_deprecation@1.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.component_deprecation@1.0.271/dist/deprecation.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.component_deprecation@1.0.271/dist/deprecation.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/deprecation",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.271",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/component/deprecation",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.component",
|
|
8
8
|
"name": "deprecation",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.271"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
"@teambit/component-id": "1.2.0",
|
|
19
19
|
"@teambit/component.ui.component-deprecated": "0.0.39",
|
|
20
20
|
"@teambit/cli": "0.0.865",
|
|
21
|
-
"@teambit/workspace": "1.0.
|
|
22
|
-
"@teambit/component": "1.0.
|
|
23
|
-
"@teambit/graphql": "1.0.
|
|
21
|
+
"@teambit/workspace": "1.0.271",
|
|
22
|
+
"@teambit/component": "1.0.271",
|
|
23
|
+
"@teambit/graphql": "1.0.271",
|
|
24
24
|
"@teambit/component-issues": "0.0.149",
|
|
25
|
-
"@teambit/dependency-resolver": "1.0.
|
|
26
|
-
"@teambit/issues": "1.0.
|
|
27
|
-
"@teambit/scope": "1.0.
|
|
28
|
-
"@teambit/docs": "1.0.
|
|
29
|
-
"@teambit/ui": "1.0.
|
|
25
|
+
"@teambit/dependency-resolver": "1.0.271",
|
|
26
|
+
"@teambit/issues": "1.0.271",
|
|
27
|
+
"@teambit/scope": "1.0.271",
|
|
28
|
+
"@teambit/docs": "1.0.271",
|
|
29
|
+
"@teambit/ui": "1.0.271"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/lodash": "4.14.165",
|