@teambit/remove 0.0.214 → 0.0.215
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.
|
@@ -63,6 +63,13 @@ function _logger() {
|
|
|
63
63
|
};
|
|
64
64
|
return data;
|
|
65
65
|
}
|
|
66
|
+
function _http() {
|
|
67
|
+
const data = require("@teambit/legacy/dist/scope/network/http");
|
|
68
|
+
_http = function () {
|
|
69
|
+
return data;
|
|
70
|
+
};
|
|
71
|
+
return data;
|
|
72
|
+
}
|
|
66
73
|
function _remotes() {
|
|
67
74
|
const data = require("@teambit/legacy/dist/remotes");
|
|
68
75
|
_remotes = function () {
|
|
@@ -167,6 +174,14 @@ async function removeComponents({
|
|
|
167
174
|
async function removeRemote(consumer, bitIds, force) {
|
|
168
175
|
const groupedBitsByScope = (0, _groupArray().default)(bitIds, 'scope');
|
|
169
176
|
const remotes = consumer ? await (0, _scopeRemotes().getScopeRemotes)(consumer.scope) : await _remotes().Remotes.getGlobalRemotes();
|
|
177
|
+
const shouldGoToCentralHub = remotes.shouldGoToCentralHub(Object.keys(groupedBitsByScope));
|
|
178
|
+
if (shouldGoToCentralHub) {
|
|
179
|
+
const http = await _http().Http.connect(_constants().CENTRAL_BIT_HUB_URL, _constants().CENTRAL_BIT_HUB_NAME);
|
|
180
|
+
return http.deleteViaCentralHub(bitIds.map(id => id.toString()), {
|
|
181
|
+
force,
|
|
182
|
+
idsAreLanes: false
|
|
183
|
+
});
|
|
184
|
+
}
|
|
170
185
|
const context = {};
|
|
171
186
|
(0, _enrichContextFromGlobal().default)(context);
|
|
172
187
|
const removeP = Object.keys(groupedBitsByScope).map(async key => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["removeComponents","consumer","ids","force","remote","track","deleteFiles","fromLane","logger","debugAndAddBreadCrumb","toString","bitIdsLatest","BitIds","fromArray","map","id","changeVersion","LATEST_BIT_VERSION","localIds","remoteIds","partition","isLocal","length","GeneralError","join","remoteResult","R","isEmpty","removeRemote","localResult","removeLocal","RemovedLocalObjects","bitIds","groupedBitsByScope","groupArray","remotes","getScopeRemotes","scope","Remotes","getGlobalRemotes","context","enrichContextFromGlobal","removeP","Object","keys","key","resolvedRemote","resolve","idsStr","toStringWithoutVersion","deleteMany","Promise","all","modifiedComponents","nonModifiedComponents","pMapSeries","componentStatus","getComponentStatusById","modified","push","err","Component","isComponentInvalidByErrorType","idsToRemove","componentsList","ComponentsList","newComponents","listNewComponents","idsToRemoveFromScope","filter","hasWithoutScopeAndVersion","idsToCleanFromWorkspace","components","componentsToRemove","invalidComponents","loadComponents","removedComponentIds","missingComponents","dependentBits","removedFromLane","removeMany","deleteComponentsFiles","invalidComponentsIds","i","removedComponents","c","hasWithoutVersion","packageJsonUtils","removeComponentsFromWorkspacesAndDependencies","cleanFromBitMap","cleanOrRevertFromBitMapWhenOnLane","uniqFromArray"],"sources":["remove-components.ts"],"sourcesContent":["import groupArray from 'group-array';\nimport partition from 'lodash.partition';\nimport R from 'ramda';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport BitIds from '@teambit/legacy/dist/bit-id/bit-ids';\nimport { LATEST_BIT_VERSION } from '@teambit/legacy/dist/constants';\nimport GeneralError from '@teambit/legacy/dist/error/general-error';\nimport enrichContextFromGlobal from '@teambit/legacy/dist/hooks/utils/enrich-context-from-global';\nimport logger from '@teambit/legacy/dist/logger/logger';\nimport { Remotes } from '@teambit/legacy/dist/remotes';\nimport RemovedLocalObjects from '@teambit/legacy/dist/scope/removed-local-objects';\nimport { getScopeRemotes } from '@teambit/legacy/dist/scope/scope-remotes';\nimport deleteComponentsFiles from '@teambit/legacy/dist/consumer/component-ops/delete-component-files';\nimport ComponentsList from '@teambit/legacy/dist/consumer/component/components-list';\nimport Component from '@teambit/legacy/dist/consumer/component/consumer-component';\nimport * as packageJsonUtils from '@teambit/legacy/dist/consumer/component/package-json-utils';\nimport pMapSeries from 'p-map-series';\n\n/**\n * Remove components local and remote\n * splits array of ids into local and remote and removes according to flags\n * @param {string[]} ids - list of remote component ids to delete\n * @param {boolean} force - delete component that are used by other components.\n * @param {boolean} remote - delete component from a remote scope\n * @param {boolean} track - keep tracking local staged components in bitmap.\n * @param {boolean} deleteFiles - delete local added files from fs.\n */\nexport async function removeComponents({\n consumer,\n ids,\n force,\n remote,\n track,\n deleteFiles,\n fromLane,\n}: {\n consumer: Consumer | null | undefined; // when remote is false, it's always set\n ids: BitIds;\n force: boolean;\n remote: boolean;\n track: boolean;\n deleteFiles: boolean;\n fromLane: boolean;\n}): Promise<{ localResult: RemovedLocalObjects; remoteResult: Record<string, any>[] }> {\n logger.debugAndAddBreadCrumb('removeComponents', `{ids}. force: ${force.toString()}`, { ids: ids.toString() });\n // added this to remove support for remove only one version from a component\n const bitIdsLatest = BitIds.fromArray(\n ids.map((id) => {\n return id.changeVersion(LATEST_BIT_VERSION);\n })\n );\n const [localIds, remoteIds] = partition(bitIdsLatest, (id) => id.isLocal());\n if (remote && localIds.length) {\n throw new GeneralError(\n `unable to remove the remote components: ${localIds.join(',')} as they don't contain a scope-name`\n );\n }\n const remoteResult = remote && !R.isEmpty(remoteIds) ? await removeRemote(consumer, remoteIds, force) : [];\n const localResult = !remote\n ? await removeLocal(consumer as Consumer, bitIdsLatest, force, track, deleteFiles, fromLane)\n : new RemovedLocalObjects();\n\n return { localResult, remoteResult };\n}\n\n/**\n * Remove remote component from ssh server\n * this method groups remote components by remote name and deletes remote components together\n * @param {BitIds} bitIds - list of remote component ids to delete\n * @param {boolean} force - delete component that are used by other components.\n */\nasync function removeRemote(consumer: Consumer | null | undefined, bitIds: BitIds, force: boolean) {\n const groupedBitsByScope = groupArray(bitIds, 'scope');\n const remotes = consumer ? await getScopeRemotes(consumer.scope) : await Remotes.getGlobalRemotes();\n const context = {};\n enrichContextFromGlobal(context);\n const removeP = Object.keys(groupedBitsByScope).map(async (key) => {\n const resolvedRemote = await remotes.resolve(key, consumer?.scope);\n const idsStr = groupedBitsByScope[key].map((id) => id.toStringWithoutVersion());\n return resolvedRemote.deleteMany(idsStr, force, context);\n });\n\n return Promise.all(removeP);\n}\n\n/**\n * removeLocal - remove local (imported, new staged components) from modules and bitmap according to flags\n * @param {BitIds} bitIds - list of component ids to delete\n * @param {boolean} force - delete component that are used by other components.\n * @param {boolean} deleteFiles - delete component that are used by other components.\n */\nasync function removeLocal(\n consumer: Consumer,\n bitIds: BitIds,\n force: boolean,\n track: boolean,\n deleteFiles: boolean,\n fromLane: boolean\n): Promise<RemovedLocalObjects> {\n // local remove in case user wants to delete tagged components\n const modifiedComponents = new BitIds();\n const nonModifiedComponents = new BitIds();\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n if (R.isEmpty(bitIds)) return new RemovedLocalObjects();\n if (!force) {\n await pMapSeries(bitIds, async (id) => {\n try {\n const componentStatus = await consumer.getComponentStatusById(id);\n if (componentStatus.modified) modifiedComponents.push(id);\n else nonModifiedComponents.push(id);\n } catch (err: any) {\n // if a component has an error, such as, missing main file, we do want to allow removing that component\n if (Component.isComponentInvalidByErrorType(err)) {\n nonModifiedComponents.push(id);\n } else {\n throw err;\n }\n }\n });\n }\n const idsToRemove = force ? bitIds : nonModifiedComponents;\n const componentsList = new ComponentsList(consumer);\n const newComponents = (await componentsList.listNewComponents(false)) as BitIds;\n const idsToRemoveFromScope = BitIds.fromArray(\n idsToRemove.filter((id) => !newComponents.hasWithoutScopeAndVersion(id))\n );\n const idsToCleanFromWorkspace = BitIds.fromArray(\n idsToRemove.filter((id) => newComponents.hasWithoutScopeAndVersion(id))\n );\n const { components: componentsToRemove, invalidComponents } = await consumer.loadComponents(idsToRemove, false);\n const { removedComponentIds, missingComponents, dependentBits, removedFromLane } = await consumer.scope.removeMany(\n idsToRemoveFromScope,\n force,\n consumer,\n fromLane\n );\n // otherwise, components should still be in .bitmap file\n idsToCleanFromWorkspace.push(...removedComponentIds);\n if (idsToCleanFromWorkspace.length) {\n if (deleteFiles) await deleteComponentsFiles(consumer, idsToCleanFromWorkspace);\n if (!track) {\n const invalidComponentsIds = invalidComponents.map((i) => i.id);\n const removedComponents = componentsToRemove.filter((c) => idsToCleanFromWorkspace.hasWithoutVersion(c.id));\n await packageJsonUtils.removeComponentsFromWorkspacesAndDependencies(\n consumer,\n removedComponents,\n invalidComponentsIds\n );\n await consumer.cleanFromBitMap(idsToCleanFromWorkspace);\n }\n }\n if (removedFromLane.length && fromLane) {\n await consumer.cleanOrRevertFromBitMapWhenOnLane(removedFromLane);\n }\n return new RemovedLocalObjects(\n BitIds.uniqFromArray([...idsToCleanFromWorkspace, ...removedComponentIds]),\n missingComponents,\n modifiedComponents,\n dependentBits,\n removedFromLane\n );\n}\n"],"mappings":";;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAsC;AAAA;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeA,gBAAgB,CAAC;EACrCC,QAAQ;EACRC,GAAG;EACHC,KAAK;EACLC,MAA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GiB,mBAAmB,CAAC;EACpD,IAAIL,uBAAuB,CAACjD,MAAM,EAAE;IAClC,IAAIhB,WAAW,EAAE,MAAM,IAAA2E,+BAAqB,EAAChF,QAAQ,EAAEsE,uBAAuB,CAAC;IAC/E,IAAI,CAAClE,KAAK,EAAE;MACV,MAAM6E,oBAAoB,GAAGR,iBAAiB,CAAC5D,GAAG,CAAEqE,CAAC,IAAKA,CAAC,CAACpE,EAAE,CAAC;MAC/D,MAAMqE,iBAAiB,GAAGX,kBAAkB,CAACJ,MAAM,CAAEgB,CAAC,IAAKd,uBAAuB,CAACe,iBAAiB,CAACD,CAAC,CAACtE,EAAE,CAAC,CAAC;MAC3G,MAAMwE,gBAAgB,GAACC,6CAA6C,CAClEvF,QAAQ,EACRmF,iBAAiB,EACjBF,oBAAoB,CACrB;MACD,MAAMjF,QAAQ,CAACwF,eAAe,CAAClB,uBAAuB,CAAC;IACzD;EACF;EACA,IAAIQ,eAAe,CAACzD,MAAM,IAAIf,QAAQ,EAAE;IACtC,MAAMN,QAAQ,CAACyF,iCAAiC,CAACX,eAAe,CAAC;EACnE;EACA,OAAO,KAAIhD,8BAAmB,EAC5BnB,iBAAM,CAAC+E,aAAa,CAAC,CAAC,GAAGpB,uBAAuB,EAAE,GAAGK,mBAAmB,CAAC,CAAC,EAC1EC,iBAAiB,EACjBxB,kBAAkB,EAClByB,aAAa,EACbC,eAAe,CAChB;AACH"}
|
|
1
|
+
{"version":3,"names":["removeComponents","consumer","ids","force","remote","track","deleteFiles","fromLane","logger","debugAndAddBreadCrumb","toString","bitIdsLatest","BitIds","fromArray","map","id","changeVersion","LATEST_BIT_VERSION","localIds","remoteIds","partition","isLocal","length","GeneralError","join","remoteResult","R","isEmpty","removeRemote","localResult","removeLocal","RemovedLocalObjects","bitIds","groupedBitsByScope","groupArray","remotes","getScopeRemotes","scope","Remotes","getGlobalRemotes","shouldGoToCentralHub","Object","keys","http","Http","connect","CENTRAL_BIT_HUB_URL","CENTRAL_BIT_HUB_NAME","deleteViaCentralHub","idsAreLanes","context","enrichContextFromGlobal","removeP","key","resolvedRemote","resolve","idsStr","toStringWithoutVersion","deleteMany","Promise","all","modifiedComponents","nonModifiedComponents","pMapSeries","componentStatus","getComponentStatusById","modified","push","err","Component","isComponentInvalidByErrorType","idsToRemove","componentsList","ComponentsList","newComponents","listNewComponents","idsToRemoveFromScope","filter","hasWithoutScopeAndVersion","idsToCleanFromWorkspace","components","componentsToRemove","invalidComponents","loadComponents","removedComponentIds","missingComponents","dependentBits","removedFromLane","removeMany","deleteComponentsFiles","invalidComponentsIds","i","removedComponents","c","hasWithoutVersion","packageJsonUtils","removeComponentsFromWorkspacesAndDependencies","cleanFromBitMap","cleanOrRevertFromBitMapWhenOnLane","uniqFromArray"],"sources":["remove-components.ts"],"sourcesContent":["import groupArray from 'group-array';\nimport partition from 'lodash.partition';\nimport R from 'ramda';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport BitIds from '@teambit/legacy/dist/bit-id/bit-ids';\nimport { CENTRAL_BIT_HUB_NAME, CENTRAL_BIT_HUB_URL, LATEST_BIT_VERSION } from '@teambit/legacy/dist/constants';\nimport GeneralError from '@teambit/legacy/dist/error/general-error';\nimport enrichContextFromGlobal from '@teambit/legacy/dist/hooks/utils/enrich-context-from-global';\nimport logger from '@teambit/legacy/dist/logger/logger';\nimport { Http } from '@teambit/legacy/dist/scope/network/http';\nimport { Remotes } from '@teambit/legacy/dist/remotes';\nimport RemovedLocalObjects from '@teambit/legacy/dist/scope/removed-local-objects';\nimport { getScopeRemotes } from '@teambit/legacy/dist/scope/scope-remotes';\nimport deleteComponentsFiles from '@teambit/legacy/dist/consumer/component-ops/delete-component-files';\nimport ComponentsList from '@teambit/legacy/dist/consumer/component/components-list';\nimport Component from '@teambit/legacy/dist/consumer/component/consumer-component';\nimport * as packageJsonUtils from '@teambit/legacy/dist/consumer/component/package-json-utils';\nimport pMapSeries from 'p-map-series';\n\n/**\n * Remove components local and remote\n * splits array of ids into local and remote and removes according to flags\n * @param {string[]} ids - list of remote component ids to delete\n * @param {boolean} force - delete component that are used by other components.\n * @param {boolean} remote - delete component from a remote scope\n * @param {boolean} track - keep tracking local staged components in bitmap.\n * @param {boolean} deleteFiles - delete local added files from fs.\n */\nexport async function removeComponents({\n consumer,\n ids,\n force,\n remote,\n track,\n deleteFiles,\n fromLane,\n}: {\n consumer: Consumer | null | undefined; // when remote is false, it's always set\n ids: BitIds;\n force: boolean;\n remote: boolean;\n track: boolean;\n deleteFiles: boolean;\n fromLane: boolean;\n}): Promise<{ localResult: RemovedLocalObjects; remoteResult: Record<string, any>[] }> {\n logger.debugAndAddBreadCrumb('removeComponents', `{ids}. force: ${force.toString()}`, { ids: ids.toString() });\n // added this to remove support for remove only one version from a component\n const bitIdsLatest = BitIds.fromArray(\n ids.map((id) => {\n return id.changeVersion(LATEST_BIT_VERSION);\n })\n );\n const [localIds, remoteIds] = partition(bitIdsLatest, (id) => id.isLocal());\n if (remote && localIds.length) {\n throw new GeneralError(\n `unable to remove the remote components: ${localIds.join(',')} as they don't contain a scope-name`\n );\n }\n const remoteResult = remote && !R.isEmpty(remoteIds) ? await removeRemote(consumer, remoteIds, force) : [];\n const localResult = !remote\n ? await removeLocal(consumer as Consumer, bitIdsLatest, force, track, deleteFiles, fromLane)\n : new RemovedLocalObjects();\n\n return { localResult, remoteResult };\n}\n\n/**\n * Remove remote component from ssh server\n * this method groups remote components by remote name and deletes remote components together\n * @param {BitIds} bitIds - list of remote component ids to delete\n * @param {boolean} force - delete component that are used by other components.\n */\nasync function removeRemote(consumer: Consumer | null | undefined, bitIds: BitIds, force: boolean) {\n const groupedBitsByScope = groupArray(bitIds, 'scope');\n const remotes = consumer ? await getScopeRemotes(consumer.scope) : await Remotes.getGlobalRemotes();\n const shouldGoToCentralHub = remotes.shouldGoToCentralHub(Object.keys(groupedBitsByScope));\n if (shouldGoToCentralHub) {\n const http = await Http.connect(CENTRAL_BIT_HUB_URL, CENTRAL_BIT_HUB_NAME);\n return http.deleteViaCentralHub(\n bitIds.map((id) => id.toString()),\n { force, idsAreLanes: false }\n );\n }\n const context = {};\n enrichContextFromGlobal(context);\n const removeP = Object.keys(groupedBitsByScope).map(async (key) => {\n const resolvedRemote = await remotes.resolve(key, consumer?.scope);\n const idsStr = groupedBitsByScope[key].map((id) => id.toStringWithoutVersion());\n return resolvedRemote.deleteMany(idsStr, force, context);\n });\n\n return Promise.all(removeP);\n}\n\n/**\n * removeLocal - remove local (imported, new staged components) from modules and bitmap according to flags\n * @param {BitIds} bitIds - list of component ids to delete\n * @param {boolean} force - delete component that are used by other components.\n * @param {boolean} deleteFiles - delete component that are used by other components.\n */\nasync function removeLocal(\n consumer: Consumer,\n bitIds: BitIds,\n force: boolean,\n track: boolean,\n deleteFiles: boolean,\n fromLane: boolean\n): Promise<RemovedLocalObjects> {\n // local remove in case user wants to delete tagged components\n const modifiedComponents = new BitIds();\n const nonModifiedComponents = new BitIds();\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n if (R.isEmpty(bitIds)) return new RemovedLocalObjects();\n if (!force) {\n await pMapSeries(bitIds, async (id) => {\n try {\n const componentStatus = await consumer.getComponentStatusById(id);\n if (componentStatus.modified) modifiedComponents.push(id);\n else nonModifiedComponents.push(id);\n } catch (err: any) {\n // if a component has an error, such as, missing main file, we do want to allow removing that component\n if (Component.isComponentInvalidByErrorType(err)) {\n nonModifiedComponents.push(id);\n } else {\n throw err;\n }\n }\n });\n }\n const idsToRemove = force ? bitIds : nonModifiedComponents;\n const componentsList = new ComponentsList(consumer);\n const newComponents = (await componentsList.listNewComponents(false)) as BitIds;\n const idsToRemoveFromScope = BitIds.fromArray(\n idsToRemove.filter((id) => !newComponents.hasWithoutScopeAndVersion(id))\n );\n const idsToCleanFromWorkspace = BitIds.fromArray(\n idsToRemove.filter((id) => newComponents.hasWithoutScopeAndVersion(id))\n );\n const { components: componentsToRemove, invalidComponents } = await consumer.loadComponents(idsToRemove, false);\n const { removedComponentIds, missingComponents, dependentBits, removedFromLane } = await consumer.scope.removeMany(\n idsToRemoveFromScope,\n force,\n consumer,\n fromLane\n );\n // otherwise, components should still be in .bitmap file\n idsToCleanFromWorkspace.push(...removedComponentIds);\n if (idsToCleanFromWorkspace.length) {\n if (deleteFiles) await deleteComponentsFiles(consumer, idsToCleanFromWorkspace);\n if (!track) {\n const invalidComponentsIds = invalidComponents.map((i) => i.id);\n const removedComponents = componentsToRemove.filter((c) => idsToCleanFromWorkspace.hasWithoutVersion(c.id));\n await packageJsonUtils.removeComponentsFromWorkspacesAndDependencies(\n consumer,\n removedComponents,\n invalidComponentsIds\n );\n await consumer.cleanFromBitMap(idsToCleanFromWorkspace);\n }\n }\n if (removedFromLane.length && fromLane) {\n await consumer.cleanOrRevertFromBitMapWhenOnLane(removedFromLane);\n }\n return new RemovedLocalObjects(\n BitIds.uniqFromArray([...idsToCleanFromWorkspace, ...removedComponentIds]),\n missingComponents,\n modifiedComponents,\n dependentBits,\n removedFromLane\n );\n}\n"],"mappings":";;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAA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AAM,IAAIf,QAAQ,EAAE;IACtC,MAAMN,QAAQ,CAACiG,iCAAiC,CAACX,eAAe,CAAC;EACnE;EACA,OAAO,KAAIxD,8BAAmB,EAC5BnB,iBAAM,CAACuF,aAAa,CAAC,CAAC,GAAGpB,uBAAuB,EAAE,GAAGK,mBAAmB,CAAC,CAAC,EAC1EC,iBAAiB,EACjBxB,kBAAkB,EAClByB,aAAa,EACbC,eAAe,CAChB;AACH"}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/remove",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.215",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/component/remove",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.component",
|
|
8
8
|
"name": "remove",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.215"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"@teambit/component-id": "0.0.427",
|
|
22
22
|
"@teambit/legacy-bit-id": "0.0.423",
|
|
23
23
|
"@teambit/bit-error": "0.0.402",
|
|
24
|
-
"@teambit/cli": "0.0.
|
|
25
|
-
"@teambit/component": "0.0.
|
|
26
|
-
"@teambit/importer": "0.0.
|
|
27
|
-
"@teambit/logger": "0.0.
|
|
28
|
-
"@teambit/workspace": "0.0.
|
|
24
|
+
"@teambit/cli": "0.0.699",
|
|
25
|
+
"@teambit/component": "0.0.1038",
|
|
26
|
+
"@teambit/importer": "0.0.467",
|
|
27
|
+
"@teambit/logger": "0.0.792",
|
|
28
|
+
"@teambit/workspace": "0.0.1038"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/mocha": "9.1.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@types/testing-library__jest-dom": "5.9.5"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@teambit/legacy": "1.0.
|
|
39
|
+
"@teambit/legacy": "1.0.479",
|
|
40
40
|
"react": "^16.8.0 || ^17.0.0",
|
|
41
41
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
42
42
|
},
|
|
Binary file
|
|
File without changes
|