@teambit/deprecation 0.0.586 → 0.0.590
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 +18 -0
- package/dist/deprecate-cmd.js +64 -0
- package/dist/deprecate-cmd.js.map +1 -0
- package/dist/deprecation.fragment.d.ts +1 -1
- package/dist/deprecation.fragment.js +4 -1
- package/dist/deprecation.fragment.js.map +1 -1
- package/dist/deprecation.graphql.js +10 -14
- package/dist/deprecation.graphql.js.map +1 -1
- package/dist/deprecation.main.runtime.d.ts +23 -5
- package/dist/deprecation.main.runtime.js +94 -32
- package/dist/deprecation.main.runtime.js.map +1 -1
- package/dist/undeprecate-cmd.d.ts +16 -0
- package/dist/undeprecate-cmd.js +62 -0
- package/dist/undeprecate-cmd.js.map +1 -0
- package/package-tar/teambit-deprecation-0.0.590.tgz +0 -0
- package/package.json +10 -8
- package/package-tar/teambit-deprecation-0.0.586.tgz +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Command, CommandOptions } from '@teambit/cli';
|
|
2
|
+
import { DeprecationMain } from './deprecation.main.runtime';
|
|
3
|
+
export declare class DeprecateCmd implements Command {
|
|
4
|
+
private deprecation;
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
group: string;
|
|
8
|
+
skipWorkspace: boolean;
|
|
9
|
+
alias: string;
|
|
10
|
+
options: CommandOptions;
|
|
11
|
+
loader: boolean;
|
|
12
|
+
migration: boolean;
|
|
13
|
+
remoteOp: boolean;
|
|
14
|
+
constructor(deprecation: DeprecationMain);
|
|
15
|
+
report([id]: [string], { newId }: {
|
|
16
|
+
newId?: string;
|
|
17
|
+
}): Promise<string>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.array.iterator.js");
|
|
6
|
+
|
|
7
|
+
require("core-js/modules/es.promise.js");
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
|
+
value: true
|
|
11
|
+
});
|
|
12
|
+
exports.DeprecateCmd = void 0;
|
|
13
|
+
|
|
14
|
+
function _defineProperty2() {
|
|
15
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
+
|
|
17
|
+
_defineProperty2 = function () {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function _chalk() {
|
|
25
|
+
const data = _interopRequireDefault(require("chalk"));
|
|
26
|
+
|
|
27
|
+
_chalk = function () {
|
|
28
|
+
return data;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return data;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
class DeprecateCmd {
|
|
35
|
+
constructor(deprecation) {
|
|
36
|
+
this.deprecation = deprecation;
|
|
37
|
+
(0, _defineProperty2().default)(this, "name", 'deprecate <id>');
|
|
38
|
+
(0, _defineProperty2().default)(this, "description", 'deprecate a component');
|
|
39
|
+
(0, _defineProperty2().default)(this, "group", 'collaborate');
|
|
40
|
+
(0, _defineProperty2().default)(this, "skipWorkspace", true);
|
|
41
|
+
(0, _defineProperty2().default)(this, "alias", 'd');
|
|
42
|
+
(0, _defineProperty2().default)(this, "options", [['', 'new-id <string>', 'if replaced by another component, enter the new component id']]);
|
|
43
|
+
(0, _defineProperty2().default)(this, "loader", true);
|
|
44
|
+
(0, _defineProperty2().default)(this, "migration", true);
|
|
45
|
+
(0, _defineProperty2().default)(this, "remoteOp", true);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async report([id], {
|
|
49
|
+
newId
|
|
50
|
+
}) {
|
|
51
|
+
const result = await this.deprecation.deprecate(id, newId);
|
|
52
|
+
|
|
53
|
+
if (result) {
|
|
54
|
+
return _chalk().default.green(`the component "${id}" has been deprecated successfully`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return _chalk().default.bold(`the component "${id}" is already deprecated. no changes have been made`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
exports.DeprecateCmd = DeprecateCmd;
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=deprecate-cmd.js.map
|
|
@@ -0,0 +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;;AAIO,MAAMA,YAAN,CAAsC;AAW3CC,EAAAA,WAAW,CAASC,WAAT,EAAuC;AAAA,SAA9BA,WAA8B,GAA9BA,WAA8B;AAAA,kDAV3C,gBAU2C;AAAA,yDATpC,uBASoC;AAAA,mDAR1C,aAQ0C;AAAA,2DAPlC,IAOkC;AAAA,mDAN1C,GAM0C;AAAA,qDALxC,CAAC,CAAC,EAAD,EAAK,iBAAL,EAAwB,8DAAxB,CAAD,CAKwC;AAAA,oDAJzC,IAIyC;AAAA,uDAHtC,IAGsC;AAAA,sDAFvC,IAEuC;AAAE;;AAExC,QAANC,MAAM,CAAC,CAACC,EAAD,CAAD,EAAiB;AAAEC,IAAAA;AAAF,GAAjB,EAAiE;AAC3E,UAAMC,MAAM,GAAG,MAAM,KAAKJ,WAAL,CAAiBK,SAAjB,CAA2BH,EAA3B,EAA+BC,KAA/B,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;;AAnB0C","sourcesContent":["import chalk from 'chalk';\nimport { Command, CommandOptions } from '@teambit/cli';\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) {}\n\n async report([id]: [string], { newId }: { newId?: string }): Promise<string> {\n const result = await this.deprecation.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"]}
|
|
@@ -10,7 +10,7 @@ export declare class DeprecationFragment implements ShowFragment {
|
|
|
10
10
|
}>;
|
|
11
11
|
json(component: Component): Promise<{
|
|
12
12
|
title: string;
|
|
13
|
-
json: import("./deprecation.main.runtime").DeprecationInfo
|
|
13
|
+
json: Promise<import("./deprecation.main.runtime").DeprecationInfo>;
|
|
14
14
|
}>;
|
|
15
15
|
weight: number;
|
|
16
16
|
}
|
|
@@ -27,9 +27,12 @@ class DeprecationFragment {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
async renderRow(component) {
|
|
30
|
+
const deprecationInfo = await this.deprecation.getDeprecationInfo(component);
|
|
31
|
+
const isDeprecate = deprecationInfo.isDeprecate.toString();
|
|
32
|
+
const newId = deprecationInfo.newId ? ` (new-id: ${deprecationInfo.newId})` : '';
|
|
30
33
|
return {
|
|
31
34
|
title: this.title,
|
|
32
|
-
content:
|
|
35
|
+
content: isDeprecate + newId
|
|
33
36
|
};
|
|
34
37
|
}
|
|
35
38
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["deprecation.fragment.ts"],"names":["DeprecationFragment","constructor","deprecation","renderRow","component","
|
|
1
|
+
{"version":3,"sources":["deprecation.fragment.ts"],"names":["DeprecationFragment","constructor","deprecation","renderRow","component","deprecationInfo","getDeprecationInfo","isDeprecate","toString","newId","title","content","json"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGO,MAAMA,mBAAN,CAAkD;AACvDC,EAAAA,WAAW,CAASC,WAAT,EAAuC;AAAA,SAA9BA,WAA8B,GAA9BA,WAA8B;AAAA,mDAE1C,YAF0C;AAAA,oDAqBzC,CArByC;AAAE;;AAIrC,QAATC,SAAS,CAACC,SAAD,EAAuB;AACpC,UAAMC,eAAe,GAAG,MAAM,KAAKH,WAAL,CAAiBI,kBAAjB,CAAoCF,SAApC,CAA9B;AACA,UAAMG,WAAW,GAAGF,eAAe,CAACE,WAAhB,CAA4BC,QAA5B,EAApB;AACA,UAAMC,KAAK,GAAGJ,eAAe,CAACI,KAAhB,GAAyB,aAAYJ,eAAe,CAACI,KAAM,GAA3D,GAAgE,EAA9E;AACA,WAAO;AACLC,MAAAA,KAAK,EAAE,KAAKA,KADP;AAELC,MAAAA,OAAO,EAAEJ,WAAW,GAAGE;AAFlB,KAAP;AAID;;AAES,QAAJG,IAAI,CAACR,SAAD,EAAuB;AAC/B,WAAO;AACLM,MAAAA,KAAK,EAAE,KAAKA,KADP;AAELE,MAAAA,IAAI,EAAE,KAAKV,WAAL,CAAiBI,kBAAjB,CAAoCF,SAApC;AAFD,KAAP;AAID;;AApBsD","sourcesContent":["import { Component, ShowFragment } from '@teambit/component';\nimport { DeprecationMain } from './deprecation.main.runtime';\n\nexport class DeprecationFragment implements ShowFragment {\n constructor(private deprecation: DeprecationMain) {}\n\n title = 'deprecated';\n\n async renderRow(component: Component) {\n const deprecationInfo = await this.deprecation.getDeprecationInfo(component);\n const isDeprecate = deprecationInfo.isDeprecate.toString();\n const newId = deprecationInfo.newId ? ` (new-id: ${deprecationInfo.newId})` : '';\n return {\n title: this.title,\n content: isDeprecate + newId,\n };\n }\n\n async json(component: Component) {\n return {\n title: this.title,\n json: this.deprecation.getDeprecationInfo(component),\n };\n }\n\n weight = 3;\n}\n"]}
|
|
@@ -42,20 +42,16 @@ function deprecationSchema(deprecation) {
|
|
|
42
42
|
}
|
|
43
43
|
`,
|
|
44
44
|
resolvers: {
|
|
45
|
-
Mutation: {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (context.verb !== 'write') throw new Error('You are not authorized');
|
|
56
|
-
return deprecation.unDeprecate(bitIds);
|
|
57
|
-
}
|
|
58
|
-
},
|
|
45
|
+
// Mutation: {
|
|
46
|
+
// deprecate: (req: any, { bitIds }: { bitIds: string[] }, context: { verb: string }) => {
|
|
47
|
+
// if (context.verb !== 'write') throw new Error('You are not authorized');
|
|
48
|
+
// return deprecation.deprecate(bitIds);
|
|
49
|
+
// },
|
|
50
|
+
// undeprecate: (req: any, { bitIds }: { bitIds: string[] }, context: { verb: string }) => {
|
|
51
|
+
// if (context.verb !== 'write') throw new Error('You are not authorized');
|
|
52
|
+
// return deprecation.unDeprecate(bitIds);
|
|
53
|
+
// },
|
|
54
|
+
// },
|
|
59
55
|
Component: {
|
|
60
56
|
deprecation: component => {
|
|
61
57
|
return deprecation.getDeprecationInfo(component);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["deprecation.graphql.ts"],"names":["deprecationSchema","deprecation","typeDefs","resolvers","
|
|
1
|
+
{"version":3,"sources":["deprecation.graphql.ts"],"names":["deprecationSchema","deprecation","typeDefs","resolvers","Component","component","getDeprecationInfo"],"mappings":";;;;;;;;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIO,SAASA,iBAAT,CAA2BC,WAA3B,EAAiE;AACtE,SAAO;AACLC,IAAAA,QAAQ,EAAE,0BAAI;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAtBS;AAuBLC,IAAAA,SAAS,EAAE;AACT;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACAC,MAAAA,SAAS,EAAE;AACTH,QAAAA,WAAW,EAAGI,SAAD,IAA0B;AACrC,iBAAOJ,WAAW,CAACK,kBAAZ,CAA+BD,SAA/B,CAAP;AACD;AAHQ;AAZF;AAvBN,GAAP;AA0CD","sourcesContent":["import { Component } from '@teambit/component';\nimport { Schema } from '@teambit/graphql';\nimport gql from 'graphql-tag';\n\nimport { DeprecationMain } from './deprecation.main.runtime';\n\nexport function deprecationSchema(deprecation: DeprecationMain): Schema {\n return {\n typeDefs: gql`\n extend type Component {\n deprecation: DeprecationInfo\n }\n\n type DeprecationInfo {\n isDeprecate: Boolean\n }\n\n type DeprecationResult {\n bitIds: [String]\n missingComponents: [String]\n }\n\n type Mutation {\n # deprecate components\n deprecate(bitIds: [String!]!): DeprecationResult\n\n # undo deprecate to components\n undeprecate(bitIds: [String!]!): DeprecationResult\n }\n `,\n resolvers: {\n // Mutation: {\n // deprecate: (req: any, { bitIds }: { bitIds: string[] }, context: { verb: string }) => {\n // if (context.verb !== 'write') throw new Error('You are not authorized');\n // return deprecation.deprecate(bitIds);\n // },\n\n // undeprecate: (req: any, { bitIds }: { bitIds: string[] }, context: { verb: string }) => {\n // if (context.verb !== 'write') throw new Error('You are not authorized');\n // return deprecation.unDeprecate(bitIds);\n // },\n // },\n Component: {\n deprecation: (component: Component) => {\n return deprecation.getDeprecationInfo(component);\n },\n },\n },\n };\n}\n"]}
|
|
@@ -1,16 +1,34 @@
|
|
|
1
|
+
import { CLIMain } from '@teambit/cli';
|
|
1
2
|
import { ComponentMain, Component } from '@teambit/component';
|
|
2
3
|
import { ScopeMain } from '@teambit/scope';
|
|
4
|
+
import { Workspace } from '@teambit/workspace';
|
|
3
5
|
import { GraphqlMain } from '@teambit/graphql';
|
|
4
6
|
export declare type DeprecationInfo = {
|
|
5
7
|
isDeprecate: boolean;
|
|
8
|
+
newId?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare type DeprecationMetadata = {
|
|
11
|
+
deprecate?: boolean;
|
|
12
|
+
newId?: string;
|
|
6
13
|
};
|
|
7
14
|
export declare class DeprecationMain {
|
|
8
15
|
private scope;
|
|
9
|
-
|
|
16
|
+
private workspace;
|
|
17
|
+
constructor(scope: ScopeMain, workspace: Workspace);
|
|
10
18
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
11
19
|
static dependencies: import("@teambit/harmony").Aspect[];
|
|
12
|
-
getDeprecationInfo(component: Component): DeprecationInfo
|
|
13
|
-
deprecate(
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
getDeprecationInfo(component: Component): Promise<DeprecationInfo>;
|
|
21
|
+
deprecate(id: string, newId?: string): Promise<boolean | {
|
|
22
|
+
deprecate: boolean;
|
|
23
|
+
}>;
|
|
24
|
+
unDeprecate(id: string): Promise<boolean | {
|
|
25
|
+
deprecate: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
static provider([graphql, scope, componentAspect, workspace, cli]: [
|
|
28
|
+
GraphqlMain,
|
|
29
|
+
ScopeMain,
|
|
30
|
+
ComponentMain,
|
|
31
|
+
Workspace,
|
|
32
|
+
CLIMain
|
|
33
|
+
]): Promise<void>;
|
|
16
34
|
}
|
|
@@ -21,16 +21,6 @@ function _defineProperty2() {
|
|
|
21
21
|
return data;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
function _scope() {
|
|
25
|
-
const data = require("@teambit/legacy/dist/api/scope");
|
|
26
|
-
|
|
27
|
-
_scope = function () {
|
|
28
|
-
return data;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
return data;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
24
|
function _cli() {
|
|
35
25
|
const data = require("@teambit/cli");
|
|
36
26
|
|
|
@@ -51,10 +41,20 @@ function _component() {
|
|
|
51
41
|
return data;
|
|
52
42
|
}
|
|
53
43
|
|
|
54
|
-
function
|
|
44
|
+
function _scope() {
|
|
55
45
|
const data = require("@teambit/scope");
|
|
56
46
|
|
|
57
|
-
|
|
47
|
+
_scope = function () {
|
|
48
|
+
return data;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function _workspace() {
|
|
55
|
+
const data = _interopRequireDefault(require("@teambit/workspace"));
|
|
56
|
+
|
|
57
|
+
_workspace = function () {
|
|
58
58
|
return data;
|
|
59
59
|
};
|
|
60
60
|
|
|
@@ -71,6 +71,26 @@ 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
|
+
|
|
74
94
|
function _deprecation() {
|
|
75
95
|
const data = require("./deprecation.aspect");
|
|
76
96
|
|
|
@@ -101,39 +121,81 @@ function _deprecation3() {
|
|
|
101
121
|
return data;
|
|
102
122
|
}
|
|
103
123
|
|
|
124
|
+
function _deprecateCmd() {
|
|
125
|
+
const data = require("./deprecate-cmd");
|
|
126
|
+
|
|
127
|
+
_deprecateCmd = function () {
|
|
128
|
+
return data;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
return data;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function _undeprecateCmd() {
|
|
135
|
+
const data = require("./undeprecate-cmd");
|
|
136
|
+
|
|
137
|
+
_undeprecateCmd = function () {
|
|
138
|
+
return data;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
return data;
|
|
142
|
+
}
|
|
143
|
+
|
|
104
144
|
class DeprecationMain {
|
|
105
|
-
constructor(scope) {
|
|
145
|
+
constructor(scope, workspace) {
|
|
106
146
|
this.scope = scope;
|
|
147
|
+
this.workspace = workspace;
|
|
107
148
|
}
|
|
108
149
|
|
|
109
|
-
getDeprecationInfo(component) {
|
|
110
|
-
|
|
111
|
-
|
|
150
|
+
async getDeprecationInfo(component) {
|
|
151
|
+
var _component$config$ext;
|
|
152
|
+
|
|
153
|
+
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
|
+
const deprecatedBackwardCompatibility = component.state._consumer.deprecated;
|
|
155
|
+
const isDeprecate = Boolean((data === null || data === void 0 ? void 0 : data.deprecate) || deprecatedBackwardCompatibility);
|
|
112
156
|
return {
|
|
113
|
-
isDeprecate
|
|
157
|
+
isDeprecate,
|
|
158
|
+
newId: data === null || data === void 0 ? void 0 : data.newId
|
|
114
159
|
};
|
|
115
160
|
}
|
|
116
161
|
|
|
117
|
-
async deprecate(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
+
|
|
171
|
+
const componentId = await this.workspace.resolveComponentId(id);
|
|
172
|
+
const results = await this.workspace.addComponentConfigToBitmap(_deprecation().DeprecationAspect.id, componentId, {
|
|
173
|
+
deprecate: true,
|
|
174
|
+
newId
|
|
175
|
+
});
|
|
123
176
|
return results;
|
|
124
177
|
}
|
|
125
178
|
|
|
126
|
-
async unDeprecate(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
179
|
+
async unDeprecate(id) {
|
|
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);
|
|
189
|
+
const results = await this.workspace.addComponentConfigToBitmap(_deprecation().DeprecationAspect.id, componentId, {
|
|
190
|
+
deprecate: false,
|
|
191
|
+
newId: ''
|
|
192
|
+
});
|
|
132
193
|
return results;
|
|
133
194
|
}
|
|
134
195
|
|
|
135
|
-
static async provider([graphql, scope, componentAspect]) {
|
|
136
|
-
const deprecation = new DeprecationMain(scope);
|
|
196
|
+
static async provider([graphql, scope, componentAspect, workspace, cli]) {
|
|
197
|
+
const deprecation = new DeprecationMain(scope, workspace);
|
|
198
|
+
cli.register(new (_deprecateCmd().DeprecateCmd)(deprecation), new (_undeprecateCmd().UndeprecateCmd)(deprecation));
|
|
137
199
|
componentAspect.registerShowFragments([new (_deprecation3().DeprecationFragment)(deprecation)]);
|
|
138
200
|
graphql.register((0, _deprecation2().deprecationSchema)(deprecation));
|
|
139
201
|
}
|
|
@@ -142,7 +204,7 @@ class DeprecationMain {
|
|
|
142
204
|
|
|
143
205
|
exports.DeprecationMain = DeprecationMain;
|
|
144
206
|
(0, _defineProperty2().default)(DeprecationMain, "runtime", _cli().MainRuntime);
|
|
145
|
-
(0, _defineProperty2().default)(DeprecationMain, "dependencies", [_graphql().GraphqlAspect,
|
|
207
|
+
(0, _defineProperty2().default)(DeprecationMain, "dependencies", [_graphql().GraphqlAspect, _scope().ScopeAspect, _component().ComponentAspect, _workspace().default, _cli().CLIAspect]);
|
|
146
208
|
|
|
147
209
|
_deprecation().DeprecationAspect.addRuntime(DeprecationMain);
|
|
148
210
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["deprecation.main.runtime.ts"],"names":["DeprecationMain","constructor","scope","getDeprecationInfo","component","
|
|
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","isLegacy","bitId","consumer","getParsedId","BitIds","componentId","resolveComponentId","results","addComponentConfigToBitmap","unDeprecate","provider","graphql","componentAspect","cli","deprecation","register","DeprecateCmd","UndeprecateCmd","registerShowFragments","DeprecationFragment","MainRuntime","GraphqlAspect","ScopeAspect","ComponentAspect","WorkspaceAspect","CLIAspect","addRuntime"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAYO,MAAMA,eAAN,CAAsB;AAC3BC,EAAAA,WAAW,CAASC,KAAT,EAAmCC,SAAnC,EAAyD;AAAA,SAAhDD,KAAgD,GAAhDA,KAAgD;AAAA,SAAtBC,SAAsB,GAAtBA,SAAsB;AAAE;;AAI9C,QAAlB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LIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { ComponentMain, ComponentAspect, Component } from '@teambit/component';\nimport { ScopeMain, ScopeAspect } from '@teambit/scope';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport { GraphqlAspect, GraphqlMain } from '@teambit/graphql';\nimport { deprecateMany, undeprecateMany } from '@teambit/legacy/dist/scope/component-ops/components-deprecation';\nimport { BitIds } from '@teambit/legacy/dist/bit-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?: string;\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 return {\n isDeprecate,\n newId: data?.newId,\n };\n }\n\n async deprecate(id: string, newId?: string) {\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 {\n deprecate: true,\n };\n }\n const componentId = await this.workspace.resolveComponentId(id);\n const results = await this.workspace.addComponentConfigToBitmap(DeprecationAspect.id, componentId, {\n deprecate: true,\n newId,\n });\n\n return results;\n }\n\n 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 {\n deprecate: false,\n };\n }\n const componentId = await this.workspace.resolveComponentId(id);\n const results = await this.workspace.addComponentConfigToBitmap(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), new UndeprecateCmd(deprecation));\n componentAspect.registerShowFragments([new DeprecationFragment(deprecation)]);\n graphql.register(deprecationSchema(deprecation));\n }\n}\n\nDeprecationAspect.addRuntime(DeprecationMain);\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Command, CommandOptions } from '@teambit/cli';
|
|
2
|
+
import { DeprecationMain } from './deprecation.main.runtime';
|
|
3
|
+
export declare class UndeprecateCmd implements Command {
|
|
4
|
+
private deprecation;
|
|
5
|
+
name: string;
|
|
6
|
+
group: string;
|
|
7
|
+
description: string;
|
|
8
|
+
alias: string;
|
|
9
|
+
options: CommandOptions;
|
|
10
|
+
loader: boolean;
|
|
11
|
+
migration: boolean;
|
|
12
|
+
skipWorkspace: boolean;
|
|
13
|
+
remoteOp: boolean;
|
|
14
|
+
constructor(deprecation: DeprecationMain);
|
|
15
|
+
report([id]: [string]): Promise<string>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.array.iterator.js");
|
|
6
|
+
|
|
7
|
+
require("core-js/modules/es.promise.js");
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
|
+
value: true
|
|
11
|
+
});
|
|
12
|
+
exports.UndeprecateCmd = void 0;
|
|
13
|
+
|
|
14
|
+
function _defineProperty2() {
|
|
15
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
+
|
|
17
|
+
_defineProperty2 = function () {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function _chalk() {
|
|
25
|
+
const data = _interopRequireDefault(require("chalk"));
|
|
26
|
+
|
|
27
|
+
_chalk = function () {
|
|
28
|
+
return data;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return data;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
class UndeprecateCmd {
|
|
35
|
+
constructor(deprecation) {
|
|
36
|
+
this.deprecation = deprecation;
|
|
37
|
+
(0, _defineProperty2().default)(this, "name", 'undeprecate <id>');
|
|
38
|
+
(0, _defineProperty2().default)(this, "group", 'collaborate');
|
|
39
|
+
(0, _defineProperty2().default)(this, "description", 'undeprecate a deprecated component (local/remote)');
|
|
40
|
+
(0, _defineProperty2().default)(this, "alias", '');
|
|
41
|
+
(0, _defineProperty2().default)(this, "options", []);
|
|
42
|
+
(0, _defineProperty2().default)(this, "loader", true);
|
|
43
|
+
(0, _defineProperty2().default)(this, "migration", true);
|
|
44
|
+
(0, _defineProperty2().default)(this, "skipWorkspace", true);
|
|
45
|
+
(0, _defineProperty2().default)(this, "remoteOp", true);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async report([id]) {
|
|
49
|
+
const result = await this.deprecation.unDeprecate(id);
|
|
50
|
+
|
|
51
|
+
if (result) {
|
|
52
|
+
return _chalk().default.green(`the component "${id}" has been undeprecated successfully`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return _chalk().default.bold(`the component "${id}" is already undeprecated. no changes have been made`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
exports.UndeprecateCmd = UndeprecateCmd;
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=undeprecate-cmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["undeprecate-cmd.ts"],"names":["UndeprecateCmd","constructor","deprecation","report","id","result","unDeprecate","chalk","green","bold"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIO,MAAMA,cAAN,CAAwC;AAW7CC,EAAAA,WAAW,CAASC,WAAT,EAAuC;AAAA,SAA9BA,WAA8B,GAA9BA,WAA8B;AAAA,kDAV3C,kBAU2C;AAAA,mDAT1C,aAS0C;AAAA,yDARpC,mDAQoC;AAAA,mDAP1C,EAO0C;AAAA,qDANxC,EAMwC;AAAA,oDALzC,IAKyC;AAAA,uDAJtC,IAIsC;AAAA,2DAHlC,IAGkC;AAAA,sDAFvC,IAEuC;AAAE;;AAExC,QAANC,MAAM,CAAC,CAACC,EAAD,CAAD,EAAkC;AAC5C,UAAMC,MAAM,GAAG,MAAM,KAAKH,WAAL,CAAiBI,WAAjB,CAA6BF,EAA7B,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;;AAnB4C","sourcesContent":["import chalk from 'chalk';\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) {}\n\n async report([id]: [string]): Promise<string> {\n const result = await this.deprecation.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"]}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/deprecation",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.590",
|
|
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.590"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
+
"chalk": "2.4.2",
|
|
12
13
|
"@teambit/harmony": "0.2.11",
|
|
13
14
|
"graphql-tag": "2.12.1",
|
|
14
15
|
"@babel/runtime": "7.12.18",
|
|
15
16
|
"core-js": "^3.0.0",
|
|
16
|
-
"@teambit/
|
|
17
|
-
"@teambit/
|
|
18
|
-
"@teambit/
|
|
19
|
-
"@teambit/scope": "0.0.
|
|
17
|
+
"@teambit/cli": "0.0.405",
|
|
18
|
+
"@teambit/component": "0.0.590",
|
|
19
|
+
"@teambit/graphql": "0.0.590",
|
|
20
|
+
"@teambit/scope": "0.0.590",
|
|
21
|
+
"@teambit/workspace": "0.0.590"
|
|
20
22
|
},
|
|
21
23
|
"devDependencies": {
|
|
22
24
|
"@types/mocha": "5.2.7",
|
|
@@ -27,7 +29,7 @@
|
|
|
27
29
|
"@types/node": "12.20.4"
|
|
28
30
|
},
|
|
29
31
|
"peerDependencies": {
|
|
30
|
-
"@teambit/legacy": "1.0.
|
|
32
|
+
"@teambit/legacy": "1.0.191",
|
|
31
33
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
32
34
|
"react": "^16.8.0 || ^17.0.0"
|
|
33
35
|
},
|
|
@@ -55,7 +57,7 @@
|
|
|
55
57
|
"react": "-"
|
|
56
58
|
},
|
|
57
59
|
"peerDependencies": {
|
|
58
|
-
"@teambit/legacy": "1.0.
|
|
60
|
+
"@teambit/legacy": "1.0.191",
|
|
59
61
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
60
62
|
"react": "^16.8.0 || ^17.0.0"
|
|
61
63
|
}
|
|
Binary file
|