@teambit/deprecation 0.0.593 → 0.0.597
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/deprecate-cmd.d.ts +4 -1
- package/dist/deprecate-cmd.js +35 -2
- package/dist/deprecate-cmd.js.map +1 -1
- package/dist/deprecation.main.runtime.d.ts +14 -9
- package/dist/deprecation.main.runtime.js +15 -42
- package/dist/deprecation.main.runtime.js.map +1 -1
- package/dist/undeprecate-cmd.d.ts +4 -1
- package/dist/undeprecate-cmd.js +34 -2
- package/dist/undeprecate-cmd.js.map +1 -1
- package/package-tar/teambit-deprecation-0.0.597.tgz +0 -0
- package/package.json +10 -9
- package/package-tar/teambit-deprecation-0.0.593.tgz +0 -0
package/dist/deprecate-cmd.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { Workspace } from '@teambit/workspace';
|
|
1
2
|
import { Command, CommandOptions } from '@teambit/cli';
|
|
2
3
|
import { DeprecationMain } from './deprecation.main.runtime';
|
|
3
4
|
export declare class DeprecateCmd implements Command {
|
|
4
5
|
private deprecation;
|
|
6
|
+
private workspace;
|
|
5
7
|
name: string;
|
|
6
8
|
description: string;
|
|
7
9
|
group: string;
|
|
@@ -11,8 +13,9 @@ export declare class DeprecateCmd implements Command {
|
|
|
11
13
|
loader: boolean;
|
|
12
14
|
migration: boolean;
|
|
13
15
|
remoteOp: boolean;
|
|
14
|
-
constructor(deprecation: DeprecationMain);
|
|
16
|
+
constructor(deprecation: DeprecationMain, workspace: Workspace);
|
|
15
17
|
report([id]: [string], { newId }: {
|
|
16
18
|
newId?: string;
|
|
17
19
|
}): Promise<string>;
|
|
20
|
+
private deprecate;
|
|
18
21
|
}
|
package/dist/deprecate-cmd.js
CHANGED
|
@@ -31,9 +31,30 @@ function _chalk() {
|
|
|
31
31
|
return data;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
function _componentsDeprecation() {
|
|
35
|
+
const data = require("@teambit/legacy/dist/scope/component-ops/components-deprecation");
|
|
36
|
+
|
|
37
|
+
_componentsDeprecation = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function _bitId() {
|
|
45
|
+
const data = require("@teambit/legacy/dist/bit-id");
|
|
46
|
+
|
|
47
|
+
_bitId = function () {
|
|
48
|
+
return data;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
|
|
34
54
|
class DeprecateCmd {
|
|
35
|
-
constructor(deprecation) {
|
|
55
|
+
constructor(deprecation, workspace) {
|
|
36
56
|
this.deprecation = deprecation;
|
|
57
|
+
this.workspace = workspace;
|
|
37
58
|
(0, _defineProperty2().default)(this, "name", 'deprecate <id>');
|
|
38
59
|
(0, _defineProperty2().default)(this, "description", 'deprecate a component');
|
|
39
60
|
(0, _defineProperty2().default)(this, "group", 'collaborate');
|
|
@@ -48,7 +69,7 @@ class DeprecateCmd {
|
|
|
48
69
|
async report([id], {
|
|
49
70
|
newId
|
|
50
71
|
}) {
|
|
51
|
-
const result = await this.
|
|
72
|
+
const result = await this.deprecate(id, newId);
|
|
52
73
|
|
|
53
74
|
if (result) {
|
|
54
75
|
return _chalk().default.green(`the component "${id}" has been deprecated successfully`);
|
|
@@ -57,6 +78,18 @@ class DeprecateCmd {
|
|
|
57
78
|
return _chalk().default.bold(`the component "${id}" is already deprecated. no changes have been made`);
|
|
58
79
|
}
|
|
59
80
|
|
|
81
|
+
async deprecate(id, newId) {
|
|
82
|
+
if (this.workspace.isLegacy) {
|
|
83
|
+
const bitId = this.workspace.consumer.getParsedId(id);
|
|
84
|
+
await (0, _componentsDeprecation().deprecateMany)(this.workspace.consumer.scope, new (_bitId().BitIds)(bitId));
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const componentId = await this.workspace.resolveComponentId(id);
|
|
89
|
+
const newComponentId = newId ? await this.workspace.resolveComponentId(newId) : undefined;
|
|
90
|
+
return this.deprecation.deprecate(componentId, newComponentId);
|
|
91
|
+
}
|
|
92
|
+
|
|
60
93
|
}
|
|
61
94
|
|
|
62
95
|
exports.DeprecateCmd = DeprecateCmd;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["deprecate-cmd.ts"],"names":["DeprecateCmd","constructor","deprecation","report","id","newId","result","deprecate","chalk","green","bold"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;
|
|
1
|
+
{"version":3,"sources":["deprecate-cmd.ts"],"names":["DeprecateCmd","constructor","deprecation","workspace","report","id","newId","result","deprecate","chalk","green","bold","isLegacy","bitId","consumer","getParsedId","scope","BitIds","componentId","resolveComponentId","newComponentId","undefined"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,YAAN,CAAsC;AAW3CC,EAAAA,WAAW,CAASC,WAAT,EAA+CC,SAA/C,EAAqE;AAAA,SAA5DD,WAA4D,GAA5DA,WAA4D;AAAA,SAAtBC,SAAsB,GAAtBA,SAAsB;AAAA,kDAVzE,gBAUyE;AAAA,yDATlE,uBASkE;AAAA,mDARxE,aAQwE;AAAA,2DAPhE,IAOgE;AAAA,mDANxE,GAMwE;AAAA,qDALtE,CAAC,CAAC,EAAD,EAAK,iBAAL,EAAwB,8DAAxB,CAAD,CAKsE;AAAA,oDAJvE,IAIuE;AAAA,uDAHpE,IAGoE;AAAA,sDAFrE,IAEqE;AAAE;;AAEtE,QAANC,MAAM,CAAC,CAACC,EAAD,CAAD,EAAiB;AAAEC,IAAAA;AAAF,GAAjB,EAAiE;AAC3E,UAAMC,MAAM,GAAG,MAAM,KAAKC,SAAL,CAAeH,EAAf,EAAmBC,KAAnB,CAArB;;AACA,QAAIC,MAAJ,EAAY;AACV,aAAOE,iBAAMC,KAAN,CAAa,kBAAiBL,EAAG,oCAAjC,CAAP;AACD;;AACD,WAAOI,iBAAME,IAAN,CAAY,kBAAiBN,EAAG,oDAAhC,CAAP;AACD;;AAEsB,QAATG,SAAS,CAACH,EAAD,EAAaC,KAAb,EAA+C;AACpE,QAAI,KAAKH,SAAL,CAAeS,QAAnB,EAA6B;AAC3B,YAAMC,KAAK,GAAG,KAAKV,SAAL,CAAeW,QAAf,CAAwBC,WAAxB,CAAoCV,EAApC,CAAd;AACA,YAAM,4CAAc,KAAKF,SAAL,CAAeW,QAAf,CAAwBE,KAAtC,EAA6C,KAAIC,eAAJ,EAAWJ,KAAX,CAA7C,CAAN;AACA,aAAO,IAAP;AACD;;AACD,UAAMK,WAAW,GAAG,MAAM,KAAKf,SAAL,CAAegB,kBAAf,CAAkCd,EAAlC,CAA1B;AACA,UAAMe,cAAc,GAAGd,KAAK,GAAG,MAAM,KAAKH,SAAL,CAAegB,kBAAf,CAAkCb,KAAlC,CAAT,GAAoDe,SAAhF;AACA,WAAO,KAAKnB,WAAL,CAAiBM,SAAjB,CAA2BU,WAA3B,EAAwCE,cAAxC,CAAP;AACD;;AA9B0C","sourcesContent":["import chalk from 'chalk';\nimport { Workspace } from '@teambit/workspace';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { deprecateMany } from '@teambit/legacy/dist/scope/component-ops/components-deprecation';\nimport { BitIds } from '@teambit/legacy/dist/bit-id';\nimport { DeprecationMain } from './deprecation.main.runtime';\n\nexport class DeprecateCmd implements Command {\n name = 'deprecate <id>';\n description = 'deprecate a component';\n group = 'collaborate';\n skipWorkspace = true;\n alias = 'd';\n options = [['', 'new-id <string>', 'if replaced by another component, enter the new component id']] as CommandOptions;\n loader = true;\n migration = true;\n remoteOp = true;\n\n constructor(private deprecation: DeprecationMain, private workspace: Workspace) {}\n\n async report([id]: [string], { newId }: { newId?: string }): Promise<string> {\n const result = await this.deprecate(id, newId);\n if (result) {\n return chalk.green(`the component \"${id}\" has been deprecated successfully`);\n }\n return chalk.bold(`the component \"${id}\" is already deprecated. no changes have been made`);\n }\n\n private async deprecate(id: string, newId?: string): Promise<boolean> {\n if (this.workspace.isLegacy) {\n const bitId = this.workspace.consumer.getParsedId(id);\n await deprecateMany(this.workspace.consumer.scope, new BitIds(bitId));\n return true;\n }\n const componentId = await this.workspace.resolveComponentId(id);\n const newComponentId = newId ? await this.workspace.resolveComponentId(newId) : undefined;\n return this.deprecation.deprecate(componentId, newComponentId);\n }\n}\n"]}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { CLIMain } from '@teambit/cli';
|
|
2
|
-
import { ComponentMain, Component } from '@teambit/component';
|
|
2
|
+
import { ComponentMain, Component, ComponentID } from '@teambit/component';
|
|
3
3
|
import { ScopeMain } from '@teambit/scope';
|
|
4
4
|
import { Workspace } from '@teambit/workspace';
|
|
5
5
|
import { GraphqlMain } from '@teambit/graphql';
|
|
6
|
+
import { ComponentIdObj } from '@teambit/component-id';
|
|
6
7
|
export declare type DeprecationInfo = {
|
|
7
8
|
isDeprecate: boolean;
|
|
8
9
|
newId?: string;
|
|
9
10
|
};
|
|
10
11
|
export declare type DeprecationMetadata = {
|
|
11
12
|
deprecate?: boolean;
|
|
12
|
-
newId?:
|
|
13
|
+
newId?: ComponentIdObj;
|
|
13
14
|
};
|
|
14
15
|
export declare class DeprecationMain {
|
|
15
16
|
private scope;
|
|
@@ -18,17 +19,21 @@ export declare class DeprecationMain {
|
|
|
18
19
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
19
20
|
static dependencies: import("@teambit/harmony").Aspect[];
|
|
20
21
|
getDeprecationInfo(component: Component): Promise<DeprecationInfo>;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
/**
|
|
23
|
+
* mark a component as deprecated. after this change, the component will be modified.
|
|
24
|
+
* tag and export the component to have it deprecated on the remote.
|
|
25
|
+
*
|
|
26
|
+
* @param componentId
|
|
27
|
+
* @param newId
|
|
28
|
+
* @returns boolean whether or not the component has been deprecated
|
|
29
|
+
*/
|
|
30
|
+
deprecate(componentId: ComponentID, newId?: ComponentID): Promise<boolean>;
|
|
31
|
+
unDeprecate(componentId: ComponentID): Promise<boolean>;
|
|
27
32
|
static provider([graphql, scope, componentAspect, workspace, cli]: [
|
|
28
33
|
GraphqlMain,
|
|
29
34
|
ScopeMain,
|
|
30
35
|
ComponentMain,
|
|
31
36
|
Workspace,
|
|
32
37
|
CLIMain
|
|
33
|
-
]): Promise<
|
|
38
|
+
]): Promise<DeprecationMain>;
|
|
34
39
|
}
|
|
@@ -71,26 +71,6 @@ function _graphql() {
|
|
|
71
71
|
return data;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
function _componentsDeprecation() {
|
|
75
|
-
const data = require("@teambit/legacy/dist/scope/component-ops/components-deprecation");
|
|
76
|
-
|
|
77
|
-
_componentsDeprecation = function () {
|
|
78
|
-
return data;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
return data;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function _bitId() {
|
|
85
|
-
const data = require("@teambit/legacy/dist/bit-id");
|
|
86
|
-
|
|
87
|
-
_bitId = function () {
|
|
88
|
-
return data;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
return data;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
74
|
function _deprecation() {
|
|
95
75
|
const data = require("./deprecation.aspect");
|
|
96
76
|
|
|
@@ -153,39 +133,31 @@ class DeprecationMain {
|
|
|
153
133
|
const data = (_component$config$ext = component.config.extensions.findExtension(_deprecation().DeprecationAspect.id)) === null || _component$config$ext === void 0 ? void 0 : _component$config$ext.config;
|
|
154
134
|
const deprecatedBackwardCompatibility = component.state._consumer.deprecated;
|
|
155
135
|
const isDeprecate = Boolean((data === null || data === void 0 ? void 0 : data.deprecate) || deprecatedBackwardCompatibility);
|
|
136
|
+
const newId = data !== null && data !== void 0 && data.newId ? _component().ComponentID.fromObject(data === null || data === void 0 ? void 0 : data.newId).toString() : undefined;
|
|
156
137
|
return {
|
|
157
138
|
isDeprecate,
|
|
158
|
-
newId
|
|
139
|
+
newId
|
|
159
140
|
};
|
|
160
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* mark a component as deprecated. after this change, the component will be modified.
|
|
144
|
+
* tag and export the component to have it deprecated on the remote.
|
|
145
|
+
*
|
|
146
|
+
* @param componentId
|
|
147
|
+
* @param newId
|
|
148
|
+
* @returns boolean whether or not the component has been deprecated
|
|
149
|
+
*/
|
|
161
150
|
|
|
162
|
-
async deprecate(id, newId) {
|
|
163
|
-
if (this.workspace.isLegacy) {
|
|
164
|
-
const bitId = this.workspace.consumer.getParsedId(id);
|
|
165
|
-
await (0, _componentsDeprecation().deprecateMany)(this.workspace.consumer.scope, new (_bitId().BitIds)(bitId));
|
|
166
|
-
return {
|
|
167
|
-
deprecate: true
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
151
|
|
|
171
|
-
|
|
152
|
+
async deprecate(componentId, newId) {
|
|
172
153
|
const results = await this.workspace.bitMap.addComponentConfig(_deprecation().DeprecationAspect.id, componentId, {
|
|
173
154
|
deprecate: true,
|
|
174
|
-
newId
|
|
155
|
+
newId: newId === null || newId === void 0 ? void 0 : newId.toObject()
|
|
175
156
|
});
|
|
176
157
|
return results;
|
|
177
158
|
}
|
|
178
159
|
|
|
179
|
-
async unDeprecate(
|
|
180
|
-
if (this.workspace.isLegacy) {
|
|
181
|
-
const bitId = this.workspace.consumer.getParsedId(id);
|
|
182
|
-
await (0, _componentsDeprecation().undeprecateMany)(this.workspace.consumer.scope, new (_bitId().BitIds)(bitId));
|
|
183
|
-
return {
|
|
184
|
-
deprecate: false
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const componentId = await this.workspace.resolveComponentId(id);
|
|
160
|
+
async unDeprecate(componentId) {
|
|
189
161
|
const results = await this.workspace.bitMap.addComponentConfig(_deprecation().DeprecationAspect.id, componentId, {
|
|
190
162
|
deprecate: false,
|
|
191
163
|
newId: ''
|
|
@@ -195,9 +167,10 @@ class DeprecationMain {
|
|
|
195
167
|
|
|
196
168
|
static async provider([graphql, scope, componentAspect, workspace, cli]) {
|
|
197
169
|
const deprecation = new DeprecationMain(scope, workspace);
|
|
198
|
-
cli.register(new (_deprecateCmd().DeprecateCmd)(deprecation), new (_undeprecateCmd().UndeprecateCmd)(deprecation));
|
|
170
|
+
cli.register(new (_deprecateCmd().DeprecateCmd)(deprecation, workspace), new (_undeprecateCmd().UndeprecateCmd)(deprecation, workspace));
|
|
199
171
|
componentAspect.registerShowFragments([new (_deprecation3().DeprecationFragment)(deprecation)]);
|
|
200
172
|
graphql.register((0, _deprecation2().deprecationSchema)(deprecation));
|
|
173
|
+
return deprecation;
|
|
201
174
|
}
|
|
202
175
|
|
|
203
176
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["deprecation.main.runtime.ts"],"names":["DeprecationMain","constructor","scope","workspace","getDeprecationInfo","component","data","config","extensions","findExtension","DeprecationAspect","id","deprecatedBackwardCompatibility","state","_consumer","deprecated","isDeprecate","Boolean","deprecate","newId","
|
|
1
|
+
{"version":3,"sources":["deprecation.main.runtime.ts"],"names":["DeprecationMain","constructor","scope","workspace","getDeprecationInfo","component","data","config","extensions","findExtension","DeprecationAspect","id","deprecatedBackwardCompatibility","state","_consumer","deprecated","isDeprecate","Boolean","deprecate","newId","ComponentID","fromObject","toString","undefined","componentId","results","bitMap","addComponentConfig","toObject","unDeprecate","provider","graphql","componentAspect","cli","deprecation","register","DeprecateCmd","UndeprecateCmd","registerShowFragments","DeprecationFragment","MainRuntime","GraphqlAspect","ScopeAspect","ComponentAspect","WorkspaceAspect","CLIAspect","addRuntime"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAA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kB;gCAFNxC,e,kBAGW,CAACyC,wBAAD,EAAgBC,oBAAhB,EAA6BC,4BAA7B,EAA8CC,oBAA9C,EAA+DC,gBAA/D,C;;AAyDxBnC,iCAAkBoC,UAAlB,CAA6B9C,eAA7B","sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\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';\n\nexport type DeprecationInfo = {\n isDeprecate: boolean;\n newId?: string;\n};\n\nexport type DeprecationMetadata = {\n deprecate?: boolean;\n newId?: ComponentIdObj;\n};\n\nexport class DeprecationMain {\n constructor(private scope: ScopeMain, private workspace: Workspace) {}\n static runtime = MainRuntime;\n static dependencies = [GraphqlAspect, ScopeAspect, ComponentAspect, WorkspaceAspect, CLIAspect];\n\n async getDeprecationInfo(component: Component): Promise<DeprecationInfo> {\n const data = component.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 newId = data?.newId ? ComponentID.fromObject(data?.newId).toString() : undefined;\n return {\n isDeprecate,\n newId,\n };\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): Promise<boolean> {\n const results = await this.workspace.bitMap.addComponentConfig(DeprecationAspect.id, componentId, {\n deprecate: true,\n newId: newId?.toObject(),\n });\n\n return results;\n }\n\n async unDeprecate(componentId: ComponentID) {\n const results = await this.workspace.bitMap.addComponentConfig(DeprecationAspect.id, componentId, {\n deprecate: false,\n newId: '',\n });\n\n return results;\n }\n\n static async provider([graphql, scope, componentAspect, workspace, cli]: [\n GraphqlMain,\n ScopeMain,\n ComponentMain,\n Workspace,\n CLIMain\n ]) {\n const deprecation = new DeprecationMain(scope, workspace);\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"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { Workspace } from '@teambit/workspace';
|
|
1
2
|
import { Command, CommandOptions } from '@teambit/cli';
|
|
2
3
|
import { DeprecationMain } from './deprecation.main.runtime';
|
|
3
4
|
export declare class UndeprecateCmd implements Command {
|
|
4
5
|
private deprecation;
|
|
6
|
+
private workspace;
|
|
5
7
|
name: string;
|
|
6
8
|
group: string;
|
|
7
9
|
description: string;
|
|
@@ -11,6 +13,7 @@ export declare class UndeprecateCmd implements Command {
|
|
|
11
13
|
migration: boolean;
|
|
12
14
|
skipWorkspace: boolean;
|
|
13
15
|
remoteOp: boolean;
|
|
14
|
-
constructor(deprecation: DeprecationMain);
|
|
16
|
+
constructor(deprecation: DeprecationMain, workspace: Workspace);
|
|
15
17
|
report([id]: [string]): Promise<string>;
|
|
18
|
+
private undeprecate;
|
|
16
19
|
}
|
package/dist/undeprecate-cmd.js
CHANGED
|
@@ -31,9 +31,30 @@ function _chalk() {
|
|
|
31
31
|
return data;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
function _componentsDeprecation() {
|
|
35
|
+
const data = require("@teambit/legacy/dist/scope/component-ops/components-deprecation");
|
|
36
|
+
|
|
37
|
+
_componentsDeprecation = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function _bitId() {
|
|
45
|
+
const data = require("@teambit/legacy/dist/bit-id");
|
|
46
|
+
|
|
47
|
+
_bitId = function () {
|
|
48
|
+
return data;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
|
|
34
54
|
class UndeprecateCmd {
|
|
35
|
-
constructor(deprecation) {
|
|
55
|
+
constructor(deprecation, workspace) {
|
|
36
56
|
this.deprecation = deprecation;
|
|
57
|
+
this.workspace = workspace;
|
|
37
58
|
(0, _defineProperty2().default)(this, "name", 'undeprecate <id>');
|
|
38
59
|
(0, _defineProperty2().default)(this, "group", 'collaborate');
|
|
39
60
|
(0, _defineProperty2().default)(this, "description", 'undeprecate a deprecated component (local/remote)');
|
|
@@ -46,7 +67,7 @@ class UndeprecateCmd {
|
|
|
46
67
|
}
|
|
47
68
|
|
|
48
69
|
async report([id]) {
|
|
49
|
-
const result = await this.
|
|
70
|
+
const result = await this.undeprecate(id);
|
|
50
71
|
|
|
51
72
|
if (result) {
|
|
52
73
|
return _chalk().default.green(`the component "${id}" has been undeprecated successfully`);
|
|
@@ -55,6 +76,17 @@ class UndeprecateCmd {
|
|
|
55
76
|
return _chalk().default.bold(`the component "${id}" is already undeprecated. no changes have been made`);
|
|
56
77
|
}
|
|
57
78
|
|
|
79
|
+
async undeprecate(id) {
|
|
80
|
+
if (this.workspace.isLegacy) {
|
|
81
|
+
const bitId = this.workspace.consumer.getParsedId(id);
|
|
82
|
+
await (0, _componentsDeprecation().undeprecateMany)(this.workspace.consumer.scope, new (_bitId().BitIds)(bitId));
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const componentId = await this.workspace.resolveComponentId(id);
|
|
87
|
+
return this.deprecation.unDeprecate(componentId);
|
|
88
|
+
}
|
|
89
|
+
|
|
58
90
|
}
|
|
59
91
|
|
|
60
92
|
exports.UndeprecateCmd = UndeprecateCmd;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["undeprecate-cmd.ts"],"names":["UndeprecateCmd","constructor","deprecation","report","id","result","
|
|
1
|
+
{"version":3,"sources":["undeprecate-cmd.ts"],"names":["UndeprecateCmd","constructor","deprecation","workspace","report","id","result","undeprecate","chalk","green","bold","isLegacy","bitId","consumer","getParsedId","scope","BitIds","componentId","resolveComponentId","unDeprecate"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAKO,MAAMA,cAAN,CAAwC;AAW7CC,EAAAA,WAAW,CAASC,WAAT,EAA+CC,SAA/C,EAAqE;AAAA,SAA5DD,WAA4D,GAA5DA,WAA4D;AAAA,SAAtBC,SAAsB,GAAtBA,SAAsB;AAAA,kDAVzE,kBAUyE;AAAA,mDATxE,aASwE;AAAA,yDARlE,mDAQkE;AAAA,mDAPxE,EAOwE;AAAA,qDANtE,EAMsE;AAAA,oDALvE,IAKuE;AAAA,uDAJpE,IAIoE;AAAA,2DAHhE,IAGgE;AAAA,sDAFrE,IAEqE;AAAE;;AAEtE,QAANC,MAAM,CAAC,CAACC,EAAD,CAAD,EAAkC;AAC5C,UAAMC,MAAM,GAAG,MAAM,KAAKC,WAAL,CAAiBF,EAAjB,CAArB;;AACA,QAAIC,MAAJ,EAAY;AACV,aAAOE,iBAAMC,KAAN,CAAa,kBAAiBJ,EAAG,sCAAjC,CAAP;AACD;;AACD,WAAOG,iBAAME,IAAN,CAAY,kBAAiBL,EAAG,sDAAhC,CAAP;AACD;;AAEwB,QAAXE,WAAW,CAACF,EAAD,EAAa;AACpC,QAAI,KAAKF,SAAL,CAAeQ,QAAnB,EAA6B;AAC3B,YAAMC,KAAK,GAAG,KAAKT,SAAL,CAAeU,QAAf,CAAwBC,WAAxB,CAAoCT,EAApC,CAAd;AACA,YAAM,8CAAgB,KAAKF,SAAL,CAAeU,QAAf,CAAwBE,KAAxC,EAA+C,KAAIC,eAAJ,EAAWJ,KAAX,CAA/C,CAAN;AACA,aAAO,IAAP;AACD;;AACD,UAAMK,WAAW,GAAG,MAAM,KAAKd,SAAL,CAAee,kBAAf,CAAkCb,EAAlC,CAA1B;AACA,WAAO,KAAKH,WAAL,CAAiBiB,WAAjB,CAA6BF,WAA7B,CAAP;AACD;;AA7B4C","sourcesContent":["import chalk from 'chalk';\nimport { undeprecateMany } from '@teambit/legacy/dist/scope/component-ops/components-deprecation';\nimport { BitIds } from '@teambit/legacy/dist/bit-id';\nimport { Workspace } from '@teambit/workspace';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { DeprecationMain } from './deprecation.main.runtime';\n\nexport class UndeprecateCmd implements Command {\n name = 'undeprecate <id>';\n group = 'collaborate';\n description = 'undeprecate a deprecated component (local/remote)';\n alias = '';\n options = [] as CommandOptions;\n loader = true;\n migration = true;\n skipWorkspace = true;\n remoteOp = true;\n\n constructor(private deprecation: DeprecationMain, private workspace: Workspace) {}\n\n async report([id]: [string]): Promise<string> {\n const result = await this.undeprecate(id);\n if (result) {\n return chalk.green(`the component \"${id}\" has been undeprecated successfully`);\n }\n return chalk.bold(`the component \"${id}\" is already undeprecated. no changes have been made`);\n }\n\n private async undeprecate(id: string) {\n if (this.workspace.isLegacy) {\n const bitId = this.workspace.consumer.getParsedId(id);\n await undeprecateMany(this.workspace.consumer.scope, new BitIds(bitId));\n return true;\n }\n const componentId = await this.workspace.resolveComponentId(id);\n return this.deprecation.unDeprecate(componentId);\n }\n}\n"]}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/deprecation",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.597",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/component/deprecation",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.component",
|
|
8
8
|
"name": "deprecation",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.597"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
"graphql-tag": "2.12.1",
|
|
15
15
|
"@babel/runtime": "7.12.18",
|
|
16
16
|
"core-js": "^3.0.0",
|
|
17
|
-
"@teambit/cli": "0.0.
|
|
18
|
-
"@teambit/
|
|
19
|
-
"@teambit/
|
|
20
|
-
"@teambit/
|
|
21
|
-
"@teambit/
|
|
17
|
+
"@teambit/cli": "0.0.410",
|
|
18
|
+
"@teambit/workspace": "0.0.597",
|
|
19
|
+
"@teambit/component": "0.0.597",
|
|
20
|
+
"@teambit/graphql": "0.0.597",
|
|
21
|
+
"@teambit/component-id": "0.0.398",
|
|
22
|
+
"@teambit/scope": "0.0.597"
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
24
25
|
"@types/mocha": "5.2.7",
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
"@types/node": "12.20.4"
|
|
30
31
|
},
|
|
31
32
|
"peerDependencies": {
|
|
32
|
-
"@teambit/legacy": "1.0.
|
|
33
|
+
"@teambit/legacy": "1.0.197",
|
|
33
34
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
34
35
|
"react": "^16.8.0 || ^17.0.0"
|
|
35
36
|
},
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
"react": "-"
|
|
58
59
|
},
|
|
59
60
|
"peerDependencies": {
|
|
60
|
-
"@teambit/legacy": "1.0.
|
|
61
|
+
"@teambit/legacy": "1.0.197",
|
|
61
62
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
62
63
|
"react": "^16.8.0 || ^17.0.0"
|
|
63
64
|
}
|
|
Binary file
|