@teambit/remove 1.0.1128 → 1.0.1130
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/delete-cmd.js
CHANGED
|
@@ -25,6 +25,13 @@ function _cli() {
|
|
|
25
25
|
};
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
|
+
function _harmonyModules() {
|
|
29
|
+
const data = require("@teambit/harmony.modules.feature-toggle");
|
|
30
|
+
_harmonyModules = function () {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
28
35
|
function _bitError() {
|
|
29
36
|
const data = require("@teambit/bit-error");
|
|
30
37
|
_bitError = function () {
|
|
@@ -67,7 +74,7 @@ to remove components from your local workspace only, use "bit remove" instead.`)
|
|
|
67
74
|
_defineProperty(this, "helpUrl", 'reference/components/removing-components');
|
|
68
75
|
_defineProperty(this, "skipWorkspace", true);
|
|
69
76
|
_defineProperty(this, "alias", '');
|
|
70
|
-
_defineProperty(this, "options", [['', 'lane', 'when on a lane, delete the component from this lane only. this removal will not affect main when the lane is merged'], ['', 'update-main', 'delete component/s on the main lane after merging this lane into main'], ['', 'range <string>', 'EXPERIMENTAL. enter a Semver range to delete specific tags (cannot be used for snaps). see https://www.npmjs.com/package/semver#ranges for the range syntax'], ['s', 'silent', 'skip confirmation'], ['', 'hard', 'NOT-RECOMMENDED. delete a component completely from a remote scope. careful! this is a permanent change that could corrupt dependents.'], ['f', 'force', 'relevant for --hard. allow the deletion even if used as a dependency. WARNING: components that depend on this component will be corrupted'], ['', 'snaps <string>', 'comma-separated list of snap hashes to mark as deleted (e.g. --snaps "hash1,hash2,hash3")']]);
|
|
77
|
+
_defineProperty(this, "options", [['', 'lane', 'when on a lane, delete the component from this lane only. this removal will not affect main when the lane is merged'], ['', 'update-main', 'delete component/s on the main lane after merging this lane into main'], ['', 'range <string>', 'EXPERIMENTAL. enter a Semver range to delete specific tags (cannot be used for snaps). see https://www.npmjs.com/package/semver#ranges for the range syntax'], ['s', 'silent', 'skip confirmation'], ['', 'hard', 'NOT-RECOMMENDED. delete a component completely from a remote scope. careful! this is a permanent change that could corrupt dependents. requires interactive confirmation by a human (--silent does not skip it)'], ['f', 'force', 'relevant for --hard. allow the deletion even if used as a dependency. WARNING: components that depend on this component will be corrupted'], ['', 'snaps <string>', 'comma-separated list of snap hashes to mark as deleted (e.g. --snaps "hash1,hash2,hash3")']]);
|
|
71
78
|
_defineProperty(this, "loader", true);
|
|
72
79
|
_defineProperty(this, "remoteOp", true);
|
|
73
80
|
}
|
|
@@ -88,8 +95,27 @@ to remove components from your local workspace only, use "bit remove" instead.`)
|
|
|
88
95
|
if (this.workspace?.isOnMain() && updateMain) {
|
|
89
96
|
throw new (_bitError().BitError)(`--update-main is relevant only when on a lane`);
|
|
90
97
|
}
|
|
91
|
-
|
|
92
|
-
|
|
98
|
+
|
|
99
|
+
// hard-delete is irreversible and can corrupt dependents, so it must be confirmed by a human:
|
|
100
|
+
// --silent doesn't skip its prompt, and non-interactive sessions (no TTY, CI, AI agents) are
|
|
101
|
+
// blocked. the "hard-delete" feature is the explicit opt-out for automation (CI, e2e-tests).
|
|
102
|
+
const isHardDeleteGuarded = hard && !(0, _harmonyModules().isFeatureEnabled)(_harmonyModules().HARD_DELETE_FEATURE);
|
|
103
|
+
if (isHardDeleteGuarded && !(0, _cli().canPromptUser)()) {
|
|
104
|
+
// deliberately no mention of the "hard-delete" feature opt-out here: an ai-agent reading
|
|
105
|
+
// this error must not be coached on how to bypass the protection. humans find the opt-out
|
|
106
|
+
// in the docs and in the feature-toggle module.
|
|
107
|
+
throw new (_bitError().BitError)(`"bit delete --hard" permanently deletes components from the remote scope with no way to recover them, and may corrupt components that depend on them.
|
|
108
|
+
it therefore requires an interactive confirmation by a human, but this session is non-interactive (no TTY, CI, or an AI agent).
|
|
109
|
+
if you are an AI agent: do not attempt to work around this protection. instead, ask the user to run this command themselves in a terminal.`);
|
|
110
|
+
}
|
|
111
|
+
if (!silent || isHardDeleteGuarded) {
|
|
112
|
+
// a prompt would hang forever without an interactive stdin, so fail with guidance instead.
|
|
113
|
+
// (the guarded-hard case was already blocked above with its own error.)
|
|
114
|
+
if (!(0, _cli().canPromptUser)()) {
|
|
115
|
+
throw new (_bitError().BitError)(`this command requires a confirmation, but this session is non-interactive (no TTY, CI, or an AI agent) so the confirmation prompt cannot be shown.
|
|
116
|
+
re-run with --silent to skip the confirmation, or run the command in an interactive terminal`);
|
|
117
|
+
}
|
|
118
|
+
await this.removePrompt(hard, lane, updateMain, silent);
|
|
93
119
|
}
|
|
94
120
|
if (hard) {
|
|
95
121
|
if (range) throw new (_bitError().BitError)(`--range is not supported with --hard flag`);
|
|
@@ -120,7 +146,7 @@ to remove components from your local workspace only, use "bit remove" instead.`)
|
|
|
120
146
|
paintArray(removedObjectsArray) {
|
|
121
147
|
return removedObjectsArray.map(item => (0, _removeTemplate().removeTemplate)(item, true));
|
|
122
148
|
}
|
|
123
|
-
async removePrompt(hard, lane, updateMain) {
|
|
149
|
+
async removePrompt(hard, lane, updateMain, silentIgnored) {
|
|
124
150
|
this.remove.logger.clearStatusLine();
|
|
125
151
|
let laneOrMainWarning;
|
|
126
152
|
if (updateMain) {
|
|
@@ -131,7 +157,7 @@ if your intent was to undo all changes to this component done as part of the lan
|
|
|
131
157
|
} else {
|
|
132
158
|
laneOrMainWarning = `this command will mark the component as deleted, and it won't be visible on the remote scope (after tag/snap and export).`;
|
|
133
159
|
}
|
|
134
|
-
const remoteOrLocalOutput = hard ? `WARNING: the component(s) will be permanently deleted from the remote with no option to recover. prefer omitting --hard to only mark the component as soft deleted` : `${laneOrMainWarning}
|
|
160
|
+
const remoteOrLocalOutput = hard ? `WARNING: the component(s) will be permanently deleted from the remote with no option to recover. prefer omitting --hard to only mark the component as soft deleted${silentIgnored ? '\nnote: --silent is ignored for --hard deletion, interactive confirmation is required' : ''}` : `${laneOrMainWarning}
|
|
135
161
|
if your intent is to remove the component only from your local workspace, refer to bit remove or bit eject.`;
|
|
136
162
|
const ok = await (0, _yesno().default)({
|
|
137
163
|
question: `${remoteOrLocalOutput}
|
package/dist/delete-cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_yesno","_cli","_bitError","_legacy","_removeTemplate","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","DeleteCmd","constructor","remove","workspace","name","description","COMPONENT_PATTERN_HELP","report","componentsPattern","force","lane","updateMain","hard","silent","range","snaps","isOnLane","BitError","isOnMain","removePrompt","localResult","remoteResult","remote","localMessage","removeTemplate","paintArray","deleteOpts","split","map","s","trim","filter","Boolean","removedComps","deleteComps","items","comp","formatItem","id","toString","joinSections","formatSuccessSummary","join","formatHint","removedObjectsArray","item","logger","clearStatusLine","laneOrMainWarning","remoteOrLocalOutput","ok","yesno","question","chalk","bold","exports"],"sources":["delete-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport yesno from 'yesno';\nimport type { Command, CommandOptions } from '@teambit/cli';\nimport { formatItem, formatSuccessSummary, formatHint, joinSections } from '@teambit/cli';\nimport type { Workspace } from '@teambit/workspace';\nimport { BitError } from '@teambit/bit-error';\nimport type { RemovedObjects } from '@teambit/legacy.scope';\nimport { COMPONENT_PATTERN_HELP } from '@teambit/legacy.constants';\nimport type { RemoveMain } from './remove.main.runtime';\nimport { removeTemplate } from './remove-template';\n\nexport class DeleteCmd implements Command {\n name = 'delete <component-pattern>';\n description = 'soft-delete components from remote scopes';\n extendedDescription = `marks components as deleted so they won't be visible on remote scopes after export.\ncomponents remain recoverable using \"bit recover\" unless --hard is used (permanent deletion, not recommended).\nto remove components from your local workspace only, use \"bit remove\" instead.`;\n arguments = [\n {\n name: 'component-pattern',\n description: COMPONENT_PATTERN_HELP,\n },\n ];\n group = 'collaborate';\n helpUrl = 'reference/components/removing-components';\n skipWorkspace = true;\n alias = '';\n options = [\n [\n '',\n 'lane',\n 'when on a lane, delete the component from this lane only. this removal will not affect main when the lane is merged',\n ],\n ['', 'update-main', 'delete component/s on the main lane after merging this lane into main'],\n [\n '',\n 'range <string>',\n 'EXPERIMENTAL. enter a Semver range to delete specific tags (cannot be used for snaps). see https://www.npmjs.com/package/semver#ranges for the range syntax',\n ],\n ['s', 'silent', 'skip confirmation'],\n [\n '',\n 'hard',\n 'NOT-RECOMMENDED. delete a component completely from a remote scope. careful! this is a permanent change that could corrupt dependents.',\n ],\n [\n 'f',\n 'force',\n 'relevant for --hard. allow the deletion even if used as a dependency. WARNING: components that depend on this component will be corrupted',\n ],\n ['', 'snaps <string>', 'comma-separated list of snap hashes to mark as deleted (e.g. --snaps \"hash1,hash2,hash3\")'],\n ] as CommandOptions;\n loader = true;\n remoteOp = true;\n\n constructor(\n private remove: RemoveMain,\n private workspace?: Workspace\n ) {}\n\n async report(\n [componentsPattern]: [string],\n {\n force = false,\n lane = false,\n updateMain = false,\n hard = false,\n silent = false,\n range,\n snaps,\n }: {\n force?: boolean;\n lane?: boolean;\n updateMain?: boolean;\n hard?: boolean;\n silent?: boolean;\n range?: string;\n snaps?: string;\n }\n ) {\n if (this.workspace?.isOnLane() && !hard && !lane && !updateMain) {\n throw new BitError(`error: to delete components when on a lane, use either --lane or --update-main flag.\n--lane: delete the component from this lane only\n--update-main: delete the component from main after this lane is merged`);\n }\n if (this.workspace?.isOnMain() && updateMain) {\n throw new BitError(`--update-main is relevant only when on a lane`);\n }\n\n if (!silent) {\n await this.removePrompt(hard, lane, updateMain);\n }\n\n if (hard) {\n if (range) throw new BitError(`--range is not supported with --hard flag`);\n const { localResult, remoteResult = [] } = await this.remove.remove({ componentsPattern, remote: true, force });\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n let localMessage = removeTemplate(localResult, false);\n if (localMessage !== '') localMessage += '\\n';\n return `${localMessage}${this.paintArray(remoteResult)}`;\n }\n\n const deleteOpts: any = { updateMain, range };\n if (snaps) {\n deleteOpts.snaps = snaps\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean);\n }\n const removedComps = await this.remove.deleteComps(componentsPattern, deleteOpts);\n const items = removedComps.map((comp) => formatItem(comp.id.toString()));\n return joinSections([\n formatSuccessSummary('successfully deleted the following components'),\n items.join('\\n'),\n formatHint('to update the remote, please tag/snap and then export. to revert, please use \"bit recover\"'),\n ]);\n }\n\n private paintArray(removedObjectsArray: RemovedObjects[]) {\n return removedObjectsArray.map((item) => removeTemplate(item, true));\n }\n\n private async removePrompt(hard?: boolean, lane?: boolean, updateMain?: boolean) {\n this.remove.logger.clearStatusLine();\n\n let laneOrMainWarning: string;\n if (updateMain) {\n laneOrMainWarning = `once this lane is merged, the component will be deleted from main (it won't be visible on the remote scope after tag/snap and export).\nif your intent was to undo all changes to this component done as part of the lane so the component in main will be intact, use --lane instead.`;\n } else if (lane) {\n laneOrMainWarning = `this command will mark the component as removed from this lane, resetting the component to its pre-lane state and content (after tag/snap and export)`;\n } else {\n laneOrMainWarning = `this command will mark the component as deleted, and it won't be visible on the remote scope (after tag/snap and export).`;\n }\n\n const remoteOrLocalOutput = hard\n ? `WARNING: the component(s) will be permanently deleted from the remote with no option to recover. prefer omitting --hard to only mark the component as soft deleted`\n : `${laneOrMainWarning}\nif your intent is to remove the component only from your local workspace, refer to bit remove or bit eject.`;\n\n const ok = await yesno({\n question: `${remoteOrLocalOutput}\n${chalk.bold('Would you like to proceed? [yes(y)/no(n)]')}`,\n });\n if (!ok) {\n throw new BitError('the operation has been canceled');\n }\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,OAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,MAAA,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AAAA,SAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_yesno","_cli","_harmonyModules","_bitError","_legacy","_removeTemplate","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","DeleteCmd","constructor","remove","workspace","name","description","COMPONENT_PATTERN_HELP","report","componentsPattern","force","lane","updateMain","hard","silent","range","snaps","isOnLane","BitError","isOnMain","isHardDeleteGuarded","isFeatureEnabled","HARD_DELETE_FEATURE","canPromptUser","removePrompt","localResult","remoteResult","remote","localMessage","removeTemplate","paintArray","deleteOpts","split","map","s","trim","filter","Boolean","removedComps","deleteComps","items","comp","formatItem","id","toString","joinSections","formatSuccessSummary","join","formatHint","removedObjectsArray","item","silentIgnored","logger","clearStatusLine","laneOrMainWarning","remoteOrLocalOutput","ok","yesno","question","chalk","bold","exports"],"sources":["delete-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport yesno from 'yesno';\nimport type { Command, CommandOptions } from '@teambit/cli';\nimport { canPromptUser, formatItem, formatSuccessSummary, formatHint, joinSections } from '@teambit/cli';\nimport { isFeatureEnabled, HARD_DELETE_FEATURE } from '@teambit/harmony.modules.feature-toggle';\nimport type { Workspace } from '@teambit/workspace';\nimport { BitError } from '@teambit/bit-error';\nimport type { RemovedObjects } from '@teambit/legacy.scope';\nimport { COMPONENT_PATTERN_HELP } from '@teambit/legacy.constants';\nimport type { RemoveMain } from './remove.main.runtime';\nimport { removeTemplate } from './remove-template';\n\nexport class DeleteCmd implements Command {\n name = 'delete <component-pattern>';\n description = 'soft-delete components from remote scopes';\n extendedDescription = `marks components as deleted so they won't be visible on remote scopes after export.\ncomponents remain recoverable using \"bit recover\" unless --hard is used (permanent deletion, not recommended).\nto remove components from your local workspace only, use \"bit remove\" instead.`;\n arguments = [\n {\n name: 'component-pattern',\n description: COMPONENT_PATTERN_HELP,\n },\n ];\n group = 'collaborate';\n helpUrl = 'reference/components/removing-components';\n skipWorkspace = true;\n alias = '';\n options = [\n [\n '',\n 'lane',\n 'when on a lane, delete the component from this lane only. this removal will not affect main when the lane is merged',\n ],\n ['', 'update-main', 'delete component/s on the main lane after merging this lane into main'],\n [\n '',\n 'range <string>',\n 'EXPERIMENTAL. enter a Semver range to delete specific tags (cannot be used for snaps). see https://www.npmjs.com/package/semver#ranges for the range syntax',\n ],\n ['s', 'silent', 'skip confirmation'],\n [\n '',\n 'hard',\n 'NOT-RECOMMENDED. delete a component completely from a remote scope. careful! this is a permanent change that could corrupt dependents. requires interactive confirmation by a human (--silent does not skip it)',\n ],\n [\n 'f',\n 'force',\n 'relevant for --hard. allow the deletion even if used as a dependency. WARNING: components that depend on this component will be corrupted',\n ],\n ['', 'snaps <string>', 'comma-separated list of snap hashes to mark as deleted (e.g. --snaps \"hash1,hash2,hash3\")'],\n ] as CommandOptions;\n loader = true;\n remoteOp = true;\n\n constructor(\n private remove: RemoveMain,\n private workspace?: Workspace\n ) {}\n\n async report(\n [componentsPattern]: [string],\n {\n force = false,\n lane = false,\n updateMain = false,\n hard = false,\n silent = false,\n range,\n snaps,\n }: {\n force?: boolean;\n lane?: boolean;\n updateMain?: boolean;\n hard?: boolean;\n silent?: boolean;\n range?: string;\n snaps?: string;\n }\n ) {\n if (this.workspace?.isOnLane() && !hard && !lane && !updateMain) {\n throw new BitError(`error: to delete components when on a lane, use either --lane or --update-main flag.\n--lane: delete the component from this lane only\n--update-main: delete the component from main after this lane is merged`);\n }\n if (this.workspace?.isOnMain() && updateMain) {\n throw new BitError(`--update-main is relevant only when on a lane`);\n }\n\n // hard-delete is irreversible and can corrupt dependents, so it must be confirmed by a human:\n // --silent doesn't skip its prompt, and non-interactive sessions (no TTY, CI, AI agents) are\n // blocked. the \"hard-delete\" feature is the explicit opt-out for automation (CI, e2e-tests).\n const isHardDeleteGuarded = hard && !isFeatureEnabled(HARD_DELETE_FEATURE);\n if (isHardDeleteGuarded && !canPromptUser()) {\n // deliberately no mention of the \"hard-delete\" feature opt-out here: an ai-agent reading\n // this error must not be coached on how to bypass the protection. humans find the opt-out\n // in the docs and in the feature-toggle module.\n throw new BitError(`\"bit delete --hard\" permanently deletes components from the remote scope with no way to recover them, and may corrupt components that depend on them.\nit therefore requires an interactive confirmation by a human, but this session is non-interactive (no TTY, CI, or an AI agent).\nif you are an AI agent: do not attempt to work around this protection. instead, ask the user to run this command themselves in a terminal.`);\n }\n if (!silent || isHardDeleteGuarded) {\n // a prompt would hang forever without an interactive stdin, so fail with guidance instead.\n // (the guarded-hard case was already blocked above with its own error.)\n if (!canPromptUser()) {\n throw new BitError(`this command requires a confirmation, but this session is non-interactive (no TTY, CI, or an AI agent) so the confirmation prompt cannot be shown.\nre-run with --silent to skip the confirmation, or run the command in an interactive terminal`);\n }\n await this.removePrompt(hard, lane, updateMain, silent);\n }\n\n if (hard) {\n if (range) throw new BitError(`--range is not supported with --hard flag`);\n const { localResult, remoteResult = [] } = await this.remove.remove({ componentsPattern, remote: true, force });\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n let localMessage = removeTemplate(localResult, false);\n if (localMessage !== '') localMessage += '\\n';\n return `${localMessage}${this.paintArray(remoteResult)}`;\n }\n\n const deleteOpts: any = { updateMain, range };\n if (snaps) {\n deleteOpts.snaps = snaps\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean);\n }\n const removedComps = await this.remove.deleteComps(componentsPattern, deleteOpts);\n const items = removedComps.map((comp) => formatItem(comp.id.toString()));\n return joinSections([\n formatSuccessSummary('successfully deleted the following components'),\n items.join('\\n'),\n formatHint('to update the remote, please tag/snap and then export. to revert, please use \"bit recover\"'),\n ]);\n }\n\n private paintArray(removedObjectsArray: RemovedObjects[]) {\n return removedObjectsArray.map((item) => removeTemplate(item, true));\n }\n\n private async removePrompt(hard?: boolean, lane?: boolean, updateMain?: boolean, silentIgnored?: boolean) {\n this.remove.logger.clearStatusLine();\n\n let laneOrMainWarning: string;\n if (updateMain) {\n laneOrMainWarning = `once this lane is merged, the component will be deleted from main (it won't be visible on the remote scope after tag/snap and export).\nif your intent was to undo all changes to this component done as part of the lane so the component in main will be intact, use --lane instead.`;\n } else if (lane) {\n laneOrMainWarning = `this command will mark the component as removed from this lane, resetting the component to its pre-lane state and content (after tag/snap and export)`;\n } else {\n laneOrMainWarning = `this command will mark the component as deleted, and it won't be visible on the remote scope (after tag/snap and export).`;\n }\n\n const remoteOrLocalOutput = hard\n ? `WARNING: the component(s) will be permanently deleted from the remote with no option to recover. prefer omitting --hard to only mark the component as soft deleted${\n silentIgnored ? '\\nnote: --silent is ignored for --hard deletion, interactive confirmation is required' : ''\n }`\n : `${laneOrMainWarning}\nif your intent is to remove the component only from your local workspace, refer to bit remove or bit eject.`;\n\n const ok = await yesno({\n question: `${remoteOrLocalOutput}\n${chalk.bold('Would you like to proceed? [yes(y)/no(n)]')}`,\n });\n if (!ok) {\n throw new BitError('the operation has been canceled');\n }\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,OAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,KAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,IAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,gBAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,eAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,UAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EA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GH,mBAAmB;AACtC,EAAEI,gBAAK,CAACC,IAAI,CAAC,2CAA2C,CAAC;IACrD,CAAC,CAAC;IACF,IAAI,CAACJ,EAAE,EAAE;MACP,MAAM,KAAItC,oBAAQ,EAAC,iCAAiC,CAAC;IACvD;EACF;AACF;AAAC2C,OAAA,CAAA5D,SAAA,GAAAA,SAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/remove",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1130",
|
|
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": "1.0.
|
|
9
|
+
"version": "1.0.1130"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "4.1.2",
|
|
@@ -18,29 +18,30 @@
|
|
|
18
18
|
"p-map-series": "2.1.0",
|
|
19
19
|
"semver": "7.7.1",
|
|
20
20
|
"@teambit/bit-error": "0.0.404",
|
|
21
|
-
"@teambit/cli": "0.0.
|
|
21
|
+
"@teambit/cli": "0.0.1376",
|
|
22
|
+
"@teambit/harmony.modules.feature-toggle": "0.0.54",
|
|
22
23
|
"@teambit/legacy.constants": "0.0.41",
|
|
23
|
-
"@teambit/legacy.scope": "0.0.
|
|
24
|
+
"@teambit/legacy.scope": "0.0.149",
|
|
24
25
|
"@teambit/component-id": "1.2.4",
|
|
25
|
-
"@teambit/component.sources": "0.0.
|
|
26
|
-
"@teambit/legacy.consumer": "0.0.
|
|
26
|
+
"@teambit/component.sources": "0.0.201",
|
|
27
|
+
"@teambit/legacy.consumer": "0.0.149",
|
|
27
28
|
"@teambit/legacy.logger": "0.0.56",
|
|
28
|
-
"@teambit/legacy.component-list": "0.0.
|
|
29
|
-
"@teambit/legacy.consumer-component": "0.0.
|
|
30
|
-
"@teambit/pkg.modules.component-package-name": "0.0.
|
|
31
|
-
"@teambit/scope.network": "0.0.
|
|
32
|
-
"@teambit/scope.remotes": "0.0.
|
|
29
|
+
"@teambit/legacy.component-list": "0.0.203",
|
|
30
|
+
"@teambit/legacy.consumer-component": "0.0.150",
|
|
31
|
+
"@teambit/pkg.modules.component-package-name": "0.0.156",
|
|
32
|
+
"@teambit/scope.network": "0.0.149",
|
|
33
|
+
"@teambit/scope.remotes": "0.0.149",
|
|
33
34
|
"@teambit/harmony": "0.4.12",
|
|
34
35
|
"@teambit/component-issues": "0.0.183",
|
|
35
36
|
"@teambit/legacy.utils": "0.0.48",
|
|
36
|
-
"@teambit/logger": "0.0.
|
|
37
|
-
"@teambit/workspace": "1.0.
|
|
38
|
-
"@teambit/component": "1.0.
|
|
39
|
-
"@teambit/dependency-resolver": "1.0.
|
|
40
|
-
"@teambit/importer": "1.0.
|
|
41
|
-
"@teambit/issues": "1.0.
|
|
42
|
-
"@teambit/lister": "1.0.
|
|
43
|
-
"@teambit/scope": "1.0.
|
|
37
|
+
"@teambit/logger": "0.0.1469",
|
|
38
|
+
"@teambit/workspace": "1.0.1130",
|
|
39
|
+
"@teambit/component": "1.0.1130",
|
|
40
|
+
"@teambit/dependency-resolver": "1.0.1130",
|
|
41
|
+
"@teambit/importer": "1.0.1130",
|
|
42
|
+
"@teambit/issues": "1.0.1130",
|
|
43
|
+
"@teambit/lister": "1.0.1130",
|
|
44
|
+
"@teambit/scope": "1.0.1130"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@types/fs-extra": "9.0.7",
|
|
File without changes
|