@teambit/deprecation 1.0.107 → 1.0.108

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.
@@ -0,0 +1,40 @@
1
+ import chalk from 'chalk';
2
+ import { Workspace } from '@teambit/workspace';
3
+ import { Command, CommandOptions } from '@teambit/cli';
4
+ import { DeprecationMain } from './deprecation.main.runtime';
5
+
6
+ export class DeprecateCmd implements Command {
7
+ name = 'deprecate <component-name>';
8
+ arguments = [{ name: 'component-name', description: 'component name or component id' }];
9
+ description = 'deprecate a component';
10
+ group = 'collaborate';
11
+ skipWorkspace = true;
12
+ alias = 'd';
13
+ options = [
14
+ [
15
+ '',
16
+ 'new-id <string>',
17
+ 'if replaced by another component, enter the new component id. alternatively use "bit rename" to do this automatically',
18
+ ],
19
+ ] as CommandOptions;
20
+ loader = true;
21
+ migration = true;
22
+ remoteOp = true;
23
+ helpUrl = 'reference/components/removing-components';
24
+
25
+ constructor(private deprecation: DeprecationMain, private workspace: Workspace) {}
26
+
27
+ async report([id]: [string], { newId }: { newId?: string }): Promise<string> {
28
+ const result = await this.deprecate(id, newId);
29
+ if (result) {
30
+ return chalk.green(`the component "${id}" has been deprecated successfully`);
31
+ }
32
+ return chalk.bold(`the component "${id}" is already deprecated. no changes have been made`);
33
+ }
34
+
35
+ private async deprecate(id: string, newId?: string): Promise<boolean> {
36
+ const componentId = await this.workspace.resolveComponentId(id);
37
+ const newComponentId = newId ? await this.workspace.resolveComponentId(newId) : undefined;
38
+ return this.deprecation.deprecate(componentId, newComponentId);
39
+ }
40
+ }
@@ -0,0 +1,9 @@
1
+ import { Aspect } from '@teambit/harmony';
2
+
3
+ export const DeprecationAspect = Aspect.create({
4
+ id: 'teambit.component/deprecation',
5
+ dependencies: [],
6
+ defaultConfig: {},
7
+ });
8
+
9
+ export default DeprecationAspect;
@@ -0,0 +1,27 @@
1
+ import { Component, ShowFragment } from '@teambit/component';
2
+ import { DeprecationMain } from './deprecation.main.runtime';
3
+
4
+ export class DeprecationFragment implements ShowFragment {
5
+ constructor(private deprecation: DeprecationMain) {}
6
+
7
+ title = 'deprecated';
8
+
9
+ async renderRow(component: Component) {
10
+ const deprecationInfo = await this.deprecation.getDeprecationInfo(component);
11
+ const isDeprecate = deprecationInfo.isDeprecate.toString();
12
+ const newId = deprecationInfo.newId ? ` (new-id: ${deprecationInfo.newId})` : '';
13
+ return {
14
+ title: this.title,
15
+ content: isDeprecate + newId,
16
+ };
17
+ }
18
+
19
+ async json(component: Component) {
20
+ return {
21
+ title: this.title,
22
+ json: await this.deprecation.getDeprecationInfo(component),
23
+ };
24
+ }
25
+
26
+ weight = 3;
27
+ }
@@ -0,0 +1,51 @@
1
+ import { Component } from '@teambit/component';
2
+ import { Schema } from '@teambit/graphql';
3
+ import gql from 'graphql-tag';
4
+
5
+ import { DeprecationMain } from './deprecation.main.runtime';
6
+
7
+ export function deprecationSchema(deprecation: DeprecationMain): Schema {
8
+ return {
9
+ typeDefs: gql`
10
+ extend type Component {
11
+ deprecation: DeprecationInfo
12
+ }
13
+
14
+ type DeprecationInfo {
15
+ isDeprecate: Boolean
16
+ newId: String
17
+ }
18
+
19
+ type DeprecationResult {
20
+ bitIds: [String]
21
+ missingComponents: [String]
22
+ }
23
+
24
+ type Mutation {
25
+ # deprecate components
26
+ deprecate(bitIds: [String!]!): DeprecationResult
27
+
28
+ # undo deprecate to components
29
+ undeprecate(bitIds: [String!]!): DeprecationResult
30
+ }
31
+ `,
32
+ resolvers: {
33
+ // Mutation: {
34
+ // deprecate: (req: any, { bitIds }: { bitIds: string[] }, context: { verb: string }) => {
35
+ // if (context.verb !== 'write') throw new Error('You are not authorized');
36
+ // return deprecation.deprecate(bitIds);
37
+ // },
38
+
39
+ // undeprecate: (req: any, { bitIds }: { bitIds: string[] }, context: { verb: string }) => {
40
+ // if (context.verb !== 'write') throw new Error('You are not authorized');
41
+ // return deprecation.unDeprecate(bitIds);
42
+ // },
43
+ // },
44
+ Component: {
45
+ deprecation: (component: Component) => {
46
+ return deprecation.getDeprecationInfo(component);
47
+ },
48
+ },
49
+ },
50
+ };
51
+ }
@@ -0,0 +1,85 @@
1
+ import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';
2
+ import { ComponentMain, ComponentAspect, Component, ComponentID } from '@teambit/component';
3
+ import { ScopeMain, ScopeAspect } from '@teambit/scope';
4
+ import WorkspaceAspect, { Workspace } from '@teambit/workspace';
5
+ import { GraphqlAspect, GraphqlMain } from '@teambit/graphql';
6
+ import { ComponentIdObj } from '@teambit/component-id';
7
+ import { DeprecationAspect } from './deprecation.aspect';
8
+ import { deprecationSchema } from './deprecation.graphql';
9
+ import { DeprecationFragment } from './deprecation.fragment';
10
+ import { DeprecateCmd } from './deprecate-cmd';
11
+ import { UndeprecateCmd } from './undeprecate-cmd';
12
+
13
+ export type DeprecationInfo = {
14
+ isDeprecate: boolean;
15
+ newId?: string;
16
+ };
17
+
18
+ export type DeprecationMetadata = {
19
+ deprecate?: boolean;
20
+ newId?: ComponentIdObj;
21
+ };
22
+
23
+ export class DeprecationMain {
24
+ constructor(private scope: ScopeMain, private workspace: Workspace) {}
25
+ static runtime = MainRuntime;
26
+ static dependencies = [GraphqlAspect, ScopeAspect, ComponentAspect, WorkspaceAspect, CLIAspect];
27
+
28
+ async getDeprecationInfo(component: Component): Promise<DeprecationInfo> {
29
+ const data = component.config.extensions.findExtension(DeprecationAspect.id)?.config as
30
+ | DeprecationMetadata
31
+ | undefined;
32
+ const deprecatedBackwardCompatibility = component.state._consumer.deprecated;
33
+ const isDeprecate = Boolean(data?.deprecate || deprecatedBackwardCompatibility);
34
+ const newId = data?.newId ? ComponentID.fromObject(data?.newId).toString() : undefined;
35
+ return {
36
+ isDeprecate,
37
+ newId,
38
+ };
39
+ }
40
+
41
+ /**
42
+ * mark a component as deprecated. after this change, the component will be modified.
43
+ * tag and export the component to have it deprecated on the remote.
44
+ *
45
+ * @param componentId
46
+ * @param newId
47
+ * @returns boolean whether or not the component has been deprecated
48
+ */
49
+ async deprecate(componentId: ComponentID, newId?: ComponentID): Promise<boolean> {
50
+ const results = this.workspace.bitMap.addComponentConfig(componentId, DeprecationAspect.id, {
51
+ deprecate: true,
52
+ newId: newId?.toObject(),
53
+ });
54
+ await this.workspace.bitMap.write(`deprecate ${componentId.toString()}`);
55
+
56
+ return results;
57
+ }
58
+
59
+ async unDeprecate(componentId: ComponentID) {
60
+ const results = this.workspace.bitMap.addComponentConfig(componentId, DeprecationAspect.id, {
61
+ deprecate: false,
62
+ newId: '',
63
+ });
64
+ await this.workspace.bitMap.write(`undeprecate ${componentId.toString()}`);
65
+
66
+ return results;
67
+ }
68
+
69
+ static async provider([graphql, scope, componentAspect, workspace, cli]: [
70
+ GraphqlMain,
71
+ ScopeMain,
72
+ ComponentMain,
73
+ Workspace,
74
+ CLIMain
75
+ ]) {
76
+ const deprecation = new DeprecationMain(scope, workspace);
77
+ cli.register(new DeprecateCmd(deprecation, workspace), new UndeprecateCmd(deprecation, workspace));
78
+ componentAspect.registerShowFragments([new DeprecationFragment(deprecation)]);
79
+ graphql.register(deprecationSchema(deprecation));
80
+
81
+ return deprecation;
82
+ }
83
+ }
84
+
85
+ DeprecationAspect.addRuntime(DeprecationMain);
@@ -1,2 +1,2 @@
1
- import React from 'react';
2
- export declare const Logo: () => React.JSX.Element;
1
+ /// <reference types="react" />
2
+ export declare const Logo: () => JSX.Element;
@@ -4,11 +4,11 @@ import { ScopeMain } from '@teambit/scope';
4
4
  import { Workspace } from '@teambit/workspace';
5
5
  import { GraphqlMain } from '@teambit/graphql';
6
6
  import { ComponentIdObj } from '@teambit/component-id';
7
- export declare type DeprecationInfo = {
7
+ export type DeprecationInfo = {
8
8
  isDeprecate: boolean;
9
9
  newId?: string;
10
10
  };
11
- export declare type DeprecationMetadata = {
11
+ export type DeprecationMetadata = {
12
12
  deprecate?: boolean;
13
13
  newId?: ComponentIdObj;
14
14
  };
@@ -84,11 +84,10 @@ class DeprecationMain {
84
84
  this.workspace = workspace;
85
85
  }
86
86
  async getDeprecationInfo(component) {
87
- var _component$config$ext;
88
- const data = (_component$config$ext = component.config.extensions.findExtension(_deprecation().DeprecationAspect.id)) === null || _component$config$ext === void 0 ? void 0 : _component$config$ext.config;
87
+ const data = component.config.extensions.findExtension(_deprecation().DeprecationAspect.id)?.config;
89
88
  const deprecatedBackwardCompatibility = component.state._consumer.deprecated;
90
- const isDeprecate = Boolean((data === null || data === void 0 ? void 0 : data.deprecate) || deprecatedBackwardCompatibility);
91
- const newId = data !== null && data !== void 0 && data.newId ? _component().ComponentID.fromObject(data === null || data === void 0 ? void 0 : data.newId).toString() : undefined;
89
+ const isDeprecate = Boolean(data?.deprecate || deprecatedBackwardCompatibility);
90
+ const newId = data?.newId ? _component().ComponentID.fromObject(data?.newId).toString() : undefined;
92
91
  return {
93
92
  isDeprecate,
94
93
  newId
@@ -106,7 +105,7 @@ class DeprecationMain {
106
105
  async deprecate(componentId, newId) {
107
106
  const results = this.workspace.bitMap.addComponentConfig(componentId, _deprecation().DeprecationAspect.id, {
108
107
  deprecate: true,
109
- newId: newId === null || newId === void 0 ? void 0 : newId.toObject()
108
+ newId: newId?.toObject()
110
109
  });
111
110
  await this.workspace.bitMap.write(`deprecate ${componentId.toString()}`);
112
111
  return results;
@@ -1 +1 @@
1
- {"version":3,"names":["_cli","data","require","_component","_scope","_workspace","_interopRequireDefault","_graphql","_deprecation","_deprecation2","_deprecation3","_deprecateCmd","_undeprecateCmd","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","DeprecationMain","constructor","scope","workspace","getDeprecationInfo","component","_component$config$ext","config","extensions","findExtension","DeprecationAspect","id","deprecatedBackwardCompatibility","state","_consumer","deprecated","isDeprecate","Boolean","deprecate","newId","ComponentID","fromObject","toString","undefined","componentId","results","bitMap","addComponentConfig","toObject","write","unDeprecate","provider","graphql","componentAspect","cli","deprecation","register","DeprecateCmd","UndeprecateCmd","registerShowFragments","DeprecationFragment","deprecationSchema","exports","MainRuntime","GraphqlAspect","ScopeAspect","ComponentAspect","WorkspaceAspect","CLIAspect","addRuntime"],"sources":["deprecation.main.runtime.ts"],"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 = this.workspace.bitMap.addComponentConfig(componentId, DeprecationAspect.id, {\n deprecate: true,\n newId: newId?.toObject(),\n });\n await this.workspace.bitMap.write(`deprecate ${componentId.toString()}`);\n\n return results;\n }\n\n async unDeprecate(componentId: ComponentID) {\n const results = this.workspace.bitMap.addComponentConfig(componentId, DeprecationAspect.id, {\n deprecate: false,\n newId: '',\n });\n await this.workspace.bitMap.write(`undeprecate ${componentId.toString()}`);\n\n return results;\n }\n\n 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"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,WAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,OAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,MAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,WAAA;EAAA,MAAAJ,IAAA,GAAAK,sBAAA,CAAAJ,OAAA;EAAAG,UAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,SAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,QAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAO,aAAA;EAAA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D,eAAA,CAFjBoB,eAAe,kBAGJ,CAAC4C,wBAAa,EAAEC,oBAAW,EAAEC,4BAAe,EAAEC,oBAAe,EAAEC,gBAAS,CAAC;AA2DjGtC,gCAAiB,CAACuC,UAAU,CAACjD,eAAe,CAAC"}
1
+ {"version":3,"names":["_cli","data","require","_component","_scope","_workspace","_interopRequireDefault","_graphql","_deprecation","_deprecation2","_deprecation3","_deprecateCmd","_undeprecateCmd","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","DeprecationMain","constructor","scope","workspace","getDeprecationInfo","component","config","extensions","findExtension","DeprecationAspect","id","deprecatedBackwardCompatibility","state","_consumer","deprecated","isDeprecate","Boolean","deprecate","newId","ComponentID","fromObject","toString","undefined","componentId","results","bitMap","addComponentConfig","toObject","write","unDeprecate","provider","graphql","componentAspect","cli","deprecation","register","DeprecateCmd","UndeprecateCmd","registerShowFragments","DeprecationFragment","deprecationSchema","exports","MainRuntime","GraphqlAspect","ScopeAspect","ComponentAspect","WorkspaceAspect","CLIAspect","addRuntime"],"sources":["deprecation.main.runtime.ts"],"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 = this.workspace.bitMap.addComponentConfig(componentId, DeprecationAspect.id, {\n deprecate: true,\n newId: newId?.toObject(),\n });\n await this.workspace.bitMap.write(`deprecate ${componentId.toString()}`);\n\n return results;\n }\n\n async unDeprecate(componentId: ComponentID) {\n const results = this.workspace.bitMap.addComponentConfig(componentId, DeprecationAspect.id, {\n deprecate: false,\n newId: '',\n });\n await this.workspace.bitMap.write(`undeprecate ${componentId.toString()}`);\n\n return results;\n }\n\n 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"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,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D8B,GAAG,CAACE,QAAQ,CAAC,KAAIC,4BAAY,EAACF,WAAW,EAAE/B,SAAS,CAAC,EAAE,KAAIkC,gCAAc,EAACH,WAAW,EAAE/B,SAAS,CAAC,CAAC;IAClG6B,eAAe,CAACM,qBAAqB,CAAC,CAAC,KAAIC,mCAAmB,EAACL,WAAW,CAAC,CAAC,CAAC;IAC7EH,OAAO,CAACI,QAAQ,CAAC,IAAAK,iCAAiB,EAACN,WAAW,CAAC,CAAC;IAEhD,OAAOA,WAAW;EACpB;AACF;AAACO,OAAA,CAAAzC,eAAA,GAAAA,eAAA;AAAApB,eAAA,CA5DYoB,eAAe,aAET0C,kBAAW;AAAA9D,eAAA,CAFjBoB,eAAe,kBAGJ,CAAC2C,wBAAa,EAAEC,oBAAW,EAAEC,4BAAe,EAAEC,oBAAe,EAAEC,gBAAS,CAAC;AA2DjGtC,gCAAiB,CAACuC,UAAU,CAAChD,eAAe,CAAC"}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_deprecation@1.0.107/dist/deprecation.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_deprecation@1.0.107/dist/deprecation.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_deprecation@1.0.108/dist/deprecation.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_deprecation@1.0.108/dist/deprecation.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
package/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export type { DeprecationMain, DeprecationInfo, DeprecationMetadata } from './deprecation.main.runtime';
2
+ export { DeprecationAspect, DeprecationAspect as default } from './deprecation.aspect';
package/package.json CHANGED
@@ -1,41 +1,37 @@
1
1
  {
2
2
  "name": "@teambit/deprecation",
3
- "version": "1.0.107",
3
+ "version": "1.0.108",
4
4
  "homepage": "https://bit.cloud/teambit/component/deprecation",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.component",
8
8
  "name": "deprecation",
9
- "version": "1.0.107"
9
+ "version": "1.0.108"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
13
13
  "graphql-tag": "2.12.1",
14
- "core-js": "^3.0.0",
15
- "@babel/runtime": "7.20.0",
16
14
  "@teambit/harmony": "0.4.6",
17
15
  "@teambit/component-id": "1.2.0",
18
16
  "@teambit/component.ui.component-deprecated": "0.0.39",
19
- "@teambit/cli": "0.0.839",
20
- "@teambit/workspace": "1.0.107",
21
- "@teambit/component": "1.0.107",
22
- "@teambit/graphql": "1.0.107",
23
- "@teambit/scope": "1.0.107",
24
- "@teambit/docs": "1.0.107",
25
- "@teambit/ui": "1.0.107"
17
+ "@teambit/cli": "0.0.840",
18
+ "@teambit/workspace": "1.0.108",
19
+ "@teambit/component": "1.0.108",
20
+ "@teambit/graphql": "1.0.108",
21
+ "@teambit/scope": "1.0.108",
22
+ "@teambit/docs": "1.0.108",
23
+ "@teambit/ui": "1.0.108"
26
24
  },
27
25
  "devDependencies": {
28
- "@types/react": "^17.0.8",
29
26
  "@types/mocha": "9.1.0",
30
- "@types/node": "12.20.4",
31
- "@types/react-dom": "^17.0.5",
32
- "@types/jest": "^26.0.0",
33
- "@types/testing-library__jest-dom": "5.9.5"
27
+ "@types/jest": "^29.2.2",
28
+ "@types/testing-library__jest-dom": "^5.9.5",
29
+ "@teambit/harmony.envs.core-aspect-env": "0.0.13"
34
30
  },
35
31
  "peerDependencies": {
36
- "@teambit/legacy": "1.0.624",
37
- "react": "^16.8.0 || ^17.0.0",
38
- "react-dom": "^16.8.0 || ^17.0.0"
32
+ "react": "^17.0.0 || ^18.0.0",
33
+ "@types/react": "^18.2.12",
34
+ "@teambit/legacy": "1.0.624"
39
35
  },
40
36
  "license": "Apache-2.0",
41
37
  "optionalDependencies": {},
@@ -49,7 +45,7 @@
49
45
  },
50
46
  "private": false,
51
47
  "engines": {
52
- "node": ">=12.22.0"
48
+ "node": ">=16.0.0"
53
49
  },
54
50
  "repository": {
55
51
  "type": "git",
@@ -58,12 +54,9 @@
58
54
  "keywords": [
59
55
  "bit",
60
56
  "bit-aspect",
57
+ "bit-core-aspect",
61
58
  "components",
62
59
  "collaboration",
63
- "web",
64
- "react",
65
- "react-components",
66
- "angular",
67
- "angular-components"
60
+ "web"
68
61
  ]
69
62
  }
package/tsconfig.json CHANGED
@@ -1,38 +1,33 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "lib": [
4
- "es2019",
5
- "DOM",
6
- "ES6",
7
- "DOM.Iterable",
8
- "ScriptHost"
4
+ "esnext",
5
+ "dom",
6
+ "dom.Iterable"
9
7
  ],
10
- "target": "es2015",
11
- "module": "CommonJS",
12
- "jsx": "react",
13
- "allowJs": true,
14
- "composite": true,
8
+ "target": "es2020",
9
+ "module": "es2020",
10
+ "jsx": "react-jsx",
15
11
  "declaration": true,
16
12
  "sourceMap": true,
17
- "skipLibCheck": true,
18
13
  "experimentalDecorators": true,
19
- "outDir": "dist",
14
+ "skipLibCheck": true,
20
15
  "moduleResolution": "node",
21
16
  "esModuleInterop": true,
22
- "rootDir": ".",
23
17
  "resolveJsonModule": true,
24
- "emitDeclarationOnly": true,
25
- "emitDecoratorMetadata": true,
26
- "allowSyntheticDefaultImports": true,
27
- "strictPropertyInitialization": false,
28
- "strict": true,
29
- "noImplicitAny": false,
30
- "preserveConstEnums": true
18
+ "allowJs": true,
19
+ "outDir": "dist",
20
+ "emitDeclarationOnly": true
31
21
  },
32
22
  "exclude": [
23
+ "artifacts",
24
+ "public",
33
25
  "dist",
26
+ "node_modules",
27
+ "package.json",
34
28
  "esm.mjs",
35
- "package.json"
29
+ "**/*.cjs",
30
+ "./dist"
36
31
  ],
37
32
  "include": [
38
33
  "**/*",
package/types/asset.d.ts CHANGED
@@ -5,12 +5,12 @@ declare module '*.png' {
5
5
  declare module '*.svg' {
6
6
  import type { FunctionComponent, SVGProps } from 'react';
7
7
 
8
- export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
8
+ export const ReactComponent: FunctionComponent<
9
+ SVGProps<SVGSVGElement> & { title?: string }
10
+ >;
9
11
  const src: string;
10
12
  export default src;
11
13
  }
12
-
13
- // @TODO Gilad
14
14
  declare module '*.jpg' {
15
15
  const value: any;
16
16
  export = value;
@@ -27,3 +27,15 @@ declare module '*.bmp' {
27
27
  const value: any;
28
28
  export = value;
29
29
  }
30
+ declare module '*.otf' {
31
+ const value: any;
32
+ export = value;
33
+ }
34
+ declare module '*.woff' {
35
+ const value: any;
36
+ export = value;
37
+ }
38
+ declare module '*.woff2' {
39
+ const value: any;
40
+ export = value;
41
+ }
@@ -0,0 +1,31 @@
1
+ import chalk from 'chalk';
2
+ import { Workspace } from '@teambit/workspace';
3
+ import { Command, CommandOptions } from '@teambit/cli';
4
+ import { DeprecationMain } from './deprecation.main.runtime';
5
+
6
+ export class UndeprecateCmd implements Command {
7
+ name = 'undeprecate <id>';
8
+ group = 'collaborate';
9
+ description = 'undeprecate a deprecated component (local/remote)';
10
+ alias = '';
11
+ options = [] as CommandOptions;
12
+ loader = true;
13
+ migration = true;
14
+ skipWorkspace = true;
15
+ remoteOp = true;
16
+
17
+ constructor(private deprecation: DeprecationMain, private workspace: Workspace) {}
18
+
19
+ async report([id]: [string]): Promise<string> {
20
+ const result = await this.undeprecate(id);
21
+ if (result) {
22
+ return chalk.green(`the component "${id}" has been undeprecated successfully`);
23
+ }
24
+ return chalk.bold(`the component "${id}" is not currently deprecated. no changes have been made`);
25
+ }
26
+
27
+ private async undeprecate(id: string) {
28
+ const componentId = await this.workspace.resolveComponentId(id);
29
+ return this.deprecation.unDeprecate(componentId);
30
+ }
31
+ }