@teambit/deprecation 1.0.108 → 1.0.109

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 @@
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["teambit.component/deprecation-preview"]=t():e["teambit.component/deprecation-preview"]=t()}(self,(()=>(()=>{"use strict";var e={39304:(e,t,o)=>{var n={id:"teambit.component/deprecation@1.0.109",homepage:"https://bit.cloud/teambit/component/deprecation",exported:!0};function r(){const e=i(o(87363));return r=function(){return e},e}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.Logo=void 0,r.__bit_component=n,i.__bit_component=n;const p=()=>r().default.createElement("div",{style:{height:"100%",display:"flex",justifyContent:"center"}},r().default.createElement("img",{style:{width:70},src:"https://static.bit.dev/extensions-icons/deprecation.svg"}));p.__bit_component=n,t.Logo=p},87363:e=>{e.exports=React}},t={};function o(n){var r=t[n];if(void 0!==r)return r.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{o.r(n),o.d(n,{compositions:()=>u,compositions_metadata:()=>l,overview:()=>f});var e={};o.r(e),o.d(e,{default:()=>d});var t=o(39304);o(87363);const r=MdxJsReact,i=TeambitMdxUiMdxScopeContext;var p=["components"];function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},c.apply(this,arguments)}var a={},s="wrapper";function d(e){var t=e.components,o=function(e,t){if(null==e)return{};var o,n,r=function(e,t){if(null==e)return{};var o,n,r={},i=Object.keys(e);for(n=0;n<i.length;n++)o=i[n],t.indexOf(o)>=0||(r[o]=e[o]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)o=i[n],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(r[o]=e[o])}return r}(e,p);return(0,r.mdx)(s,c({},a,o,{components:t,mdxType:"MDXLayout"}),(0,r.mdx)(i.MDXScopeProvider,{components:{},mdxType:"MDXScopeProvider"}))}d.isMDXComponent=!0;const u=[t],f=[e],l={compositions:[{displayName:"Logo",identifier:"Logo"}]}})(),n})()));
@@ -1,5 +1,5 @@
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';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_deprecation@1.0.109/dist/deprecation.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_deprecation@1.0.109/dist/deprecation.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/deprecation",
3
- "version": "1.0.108",
3
+ "version": "1.0.109",
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.108"
9
+ "version": "1.0.109"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
@@ -14,19 +14,19 @@
14
14
  "@teambit/harmony": "0.4.6",
15
15
  "@teambit/component-id": "1.2.0",
16
16
  "@teambit/component.ui.component-deprecated": "0.0.39",
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"
17
+ "@teambit/cli": "0.0.841",
18
+ "@teambit/workspace": "1.0.109",
19
+ "@teambit/component": "1.0.109",
20
+ "@teambit/graphql": "1.0.109",
21
+ "@teambit/scope": "1.0.109",
22
+ "@teambit/docs": "1.0.109",
23
+ "@teambit/ui": "1.0.109"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/mocha": "9.1.0",
27
27
  "@types/jest": "^29.2.2",
28
28
  "@types/testing-library__jest-dom": "^5.9.5",
29
- "@teambit/harmony.envs.core-aspect-env": "0.0.13"
29
+ "@teambit/harmony.envs.core-aspect-env": "0.0.14"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "react": "^17.0.0 || ^18.0.0",
package/deprecate-cmd.ts DELETED
@@ -1,40 +0,0 @@
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
- }
@@ -1,9 +0,0 @@
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;
@@ -1,27 +0,0 @@
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
- }
@@ -1,51 +0,0 @@
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
- }
@@ -1,85 +0,0 @@
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);
package/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export type { DeprecationMain, DeprecationInfo, DeprecationMetadata } from './deprecation.main.runtime';
2
- export { DeprecationAspect, DeprecationAspect as default } from './deprecation.aspect';
@@ -1,31 +0,0 @@
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
- }