@teambit/renaming 0.0.107 → 0.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.
@@ -3,6 +3,7 @@ import { RenamingMain } from '.';
3
3
  export declare type RenameOptions = {
4
4
  scope?: string;
5
5
  path?: string;
6
+ refactor?: boolean;
6
7
  };
7
8
  export declare class RenameCmd implements Command {
8
9
  private renaming;
@@ -41,7 +41,7 @@ to assign a default-scope to this component, please use "--scope" flag`);
41
41
  (0, _defineProperty2().default)(this, "group", 'collaborate');
42
42
  (0, _defineProperty2().default)(this, "skipWorkspace", true);
43
43
  (0, _defineProperty2().default)(this, "alias", '');
44
- (0, _defineProperty2().default)(this, "options", [['s', 'scope <string>', 'default scope for the newly created component'], ['p', 'path <string>', 'relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`']]);
44
+ (0, _defineProperty2().default)(this, "options", [['s', 'scope <string>', 'default scope for the newly created component'], ['p', 'path <string>', 'relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`'], ['r', 'refactor', 'change the source code of all components using this component with the new package-name']]);
45
45
  (0, _defineProperty2().default)(this, "loader", true);
46
46
  (0, _defineProperty2().default)(this, "migration", true);
47
47
  (0, _defineProperty2().default)(this, "remoteOp", true);
@@ -1 +1 @@
1
- {"version":3,"sources":["rename.cmd.ts"],"names":["RenameCmd","constructor","renaming","report","sourceId","targetId","options","results","rename","chalk","green","bold","toString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AASO,MAAMA,SAAN,CAAmC;AAiBxCC,EAAAA,WAAW,CAASC,QAAT,EAAiC;AAAA,SAAxBA,QAAwB,GAAxBA,QAAwB;AAAA,kDAhBrC,oCAgBqC;AAAA,yDAd1C,+GAc0C;AAAA,iEAbrB;AACzB,uEAY8C;AAAA,mDAXpC,aAWoC;AAAA,2DAV5B,IAU4B;AAAA,mDATpC,EASoC;AAAA,qDARlC,CACR,CAAC,GAAD,EAAM,gBAAN,EAAwB,+CAAxB,CADQ,EAER,CAAC,GAAD,EAAM,eAAN,EAAuB,qFAAvB,CAFQ,CAQkC;AAAA,oDAJnC,IAImC;AAAA,uDAHhC,IAGgC;AAAA,sDAFjC,IAEiC;AAAE;;AAElC,QAANC,MAAM,CAAC,CAACC,QAAD,EAAWC,QAAX,CAAD,EAAyCC,OAAzC,EAAkF;AAC5F,UAAMC,OAAO,GAAG,MAAM,KAAKL,QAAL,CAAcM,MAAd,CAAqBJ,QAArB,EAA+BC,QAA/B,EAAyCC,OAAzC,CAAtB;AACA,WAAOG,iBAAMC,KAAN,CACJ,wBAAuBD,iBAAME,IAAN,CAAWJ,OAAO,CAACH,QAAR,CAAiBQ,QAAjB,EAAX,CAAwC,OAAMH,iBAAME,IAAN,CAAWJ,OAAO,CAACF,QAAR,CAAiBO,QAAjB,EAAX,CAAwC,EADzG,CAAP;AAGD;;AAxBuC","sourcesContent":["import chalk from 'chalk';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { RenamingMain } from '.';\n\nexport type RenameOptions = {\n scope?: string;\n path?: string;\n};\n\nexport class RenameCmd implements Command {\n name = 'rename <source-name> <target-name>';\n description =\n 'EXPERIMENTAL. rename component. if tagged/exported, create a new component and deprecate the source-component';\n extendedDescription = `the \"<target-name>\" should include the component-name only, without the scope-name.\nto assign a default-scope to this component, please use \"--scope\" flag`;\n group = 'collaborate';\n skipWorkspace = true;\n alias = '';\n options = [\n ['s', 'scope <string>', 'default scope for the newly created component'],\n ['p', 'path <string>', 'relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`'],\n ] as CommandOptions;\n loader = true;\n migration = true;\n remoteOp = true;\n\n constructor(private renaming: RenamingMain) {}\n\n async report([sourceId, targetId]: [string, string], options: RenameOptions): Promise<string> {\n const results = await this.renaming.rename(sourceId, targetId, options);\n return chalk.green(\n `successfully renamed ${chalk.bold(results.sourceId.toString())} to ${chalk.bold(results.targetId.toString())}`\n );\n }\n}\n"]}
1
+ {"version":3,"sources":["rename.cmd.ts"],"names":["RenameCmd","constructor","renaming","report","sourceId","targetId","options","results","rename","chalk","green","bold","toString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAUO,MAAMA,SAAN,CAAmC;AAkBxCC,EAAAA,WAAW,CAASC,QAAT,EAAiC;AAAA,SAAxBA,QAAwB,GAAxBA,QAAwB;AAAA,kDAjBrC,oCAiBqC;AAAA,yDAf1C,+GAe0C;AAAA,iEAdrB;AACzB,uEAa8C;AAAA,mDAZpC,aAYoC;AAAA,2DAX5B,IAW4B;AAAA,mDAVpC,EAUoC;AAAA,qDATlC,CACR,CAAC,GAAD,EAAM,gBAAN,EAAwB,+CAAxB,CADQ,EAER,CAAC,GAAD,EAAM,eAAN,EAAuB,qFAAvB,CAFQ,EAGR,CAAC,GAAD,EAAM,UAAN,EAAkB,yFAAlB,CAHQ,CASkC;AAAA,oDAJnC,IAImC;AAAA,uDAHhC,IAGgC;AAAA,sDAFjC,IAEiC;AAAE;;AAElC,QAANC,MAAM,CAAC,CAACC,QAAD,EAAWC,QAAX,CAAD,EAAyCC,OAAzC,EAAkF;AAC5F,UAAMC,OAAO,GAAG,MAAM,KAAKL,QAAL,CAAcM,MAAd,CAAqBJ,QAArB,EAA+BC,QAA/B,EAAyCC,OAAzC,CAAtB;AACA,WAAOG,iBAAMC,KAAN,CACJ,wBAAuBD,iBAAME,IAAN,CAAWJ,OAAO,CAACH,QAAR,CAAiBQ,QAAjB,EAAX,CAAwC,OAAMH,iBAAME,IAAN,CAAWJ,OAAO,CAACF,QAAR,CAAiBO,QAAjB,EAAX,CAAwC,EADzG,CAAP;AAGD;;AAzBuC","sourcesContent":["import chalk from 'chalk';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { RenamingMain } from '.';\n\nexport type RenameOptions = {\n scope?: string;\n path?: string;\n refactor?: boolean;\n};\n\nexport class RenameCmd implements Command {\n name = 'rename <source-name> <target-name>';\n description =\n 'EXPERIMENTAL. rename component. if tagged/exported, create a new component and deprecate the source-component';\n extendedDescription = `the \"<target-name>\" should include the component-name only, without the scope-name.\nto assign a default-scope to this component, please use \"--scope\" flag`;\n group = 'collaborate';\n skipWorkspace = true;\n alias = '';\n options = [\n ['s', 'scope <string>', 'default scope for the newly created component'],\n ['p', 'path <string>', 'relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`'],\n ['r', 'refactor', 'change the source code of all components using this component with the new package-name'],\n ] as CommandOptions;\n loader = true;\n migration = true;\n remoteOp = true;\n\n constructor(private renaming: RenamingMain) {}\n\n async report([sourceId, targetId]: [string, string], options: RenameOptions): Promise<string> {\n const results = await this.renaming.rename(sourceId, targetId, options);\n return chalk.green(\n `successfully renamed ${chalk.bold(results.sourceId.toString())} to ${chalk.bold(results.targetId.toString())}`\n );\n }\n}\n"]}
@@ -3,26 +3,29 @@ import { Component, ComponentID, ComponentMain } from '@teambit/component';
3
3
  import { DeprecationMain } from '@teambit/deprecation';
4
4
  import { GraphqlMain } from '@teambit/graphql';
5
5
  import { NewComponentHelperMain } from '@teambit/new-component-helper';
6
+ import { RefactoringMain } from '@teambit/refactoring';
6
7
  import { Workspace } from '@teambit/workspace';
7
8
  import { RenameOptions } from './rename.cmd';
8
9
  export declare class RenamingMain {
9
10
  private workspace;
10
11
  private newComponentHelper;
11
12
  private deprecation;
12
- constructor(workspace: Workspace, newComponentHelper: NewComponentHelperMain, deprecation: DeprecationMain);
13
+ private refactoring;
14
+ constructor(workspace: Workspace, newComponentHelper: NewComponentHelperMain, deprecation: DeprecationMain, refactoring: RefactoringMain);
13
15
  rename(sourceIdStr: string, targetIdStr: string, options: RenameOptions): Promise<RenameResult>;
14
16
  getRenamingInfo(component: Component): RenamingInfo | null;
15
17
  private getConfig;
16
18
  static slots: never[];
17
19
  static dependencies: import("@teambit/harmony").Aspect[];
18
20
  static runtime: import("@teambit/harmony").RuntimeDefinition;
19
- static provider([cli, workspace, deprecation, newComponentHelper, componentMain, graphql]: [
21
+ static provider([cli, workspace, deprecation, newComponentHelper, componentMain, graphql, refactoring]: [
20
22
  CLIMain,
21
23
  Workspace,
22
24
  DeprecationMain,
23
25
  NewComponentHelperMain,
24
26
  ComponentMain,
25
- GraphqlMain
27
+ GraphqlMain,
28
+ RefactoringMain
26
29
  ]): Promise<RenamingMain>;
27
30
  }
28
31
  export declare type RenameResult = {
@@ -71,6 +71,16 @@ function _newComponentHelper() {
71
71
  return data;
72
72
  }
73
73
 
74
+ function _refactoring() {
75
+ const data = _interopRequireDefault(require("@teambit/refactoring"));
76
+
77
+ _refactoring = function () {
78
+ return data;
79
+ };
80
+
81
+ return data;
82
+ }
83
+
74
84
  function _workspace() {
75
85
  const data = _interopRequireDefault(require("@teambit/workspace"));
76
86
 
@@ -130,10 +140,11 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
130
140
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
131
141
 
132
142
  class RenamingMain {
133
- constructor(workspace, newComponentHelper, deprecation) {
143
+ constructor(workspace, newComponentHelper, deprecation, refactoring) {
134
144
  this.workspace = workspace;
135
145
  this.newComponentHelper = newComponentHelper;
136
146
  this.deprecation = deprecation;
147
+ this.refactoring = refactoring;
137
148
  }
138
149
 
139
150
  async rename(sourceIdStr, targetIdStr, options) {
@@ -151,6 +162,15 @@ class RenamingMain {
151
162
  await this.workspace.bitMap.write();
152
163
  }
153
164
 
165
+ if (options.refactor) {
166
+ const allComponents = await this.workspace.list();
167
+ const {
168
+ changedComponents
169
+ } = await this.refactoring.refactorDependencyName(allComponents, sourceId, targetId);
170
+ await Promise.all(changedComponents.map(comp => this.workspace.write(comp)));
171
+ }
172
+
173
+ await this.workspace.link();
154
174
  return {
155
175
  sourceId,
156
176
  targetId
@@ -176,8 +196,8 @@ class RenamingMain {
176
196
  });
177
197
  }
178
198
 
179
- static async provider([cli, workspace, deprecation, newComponentHelper, componentMain, graphql]) {
180
- const renaming = new RenamingMain(workspace, newComponentHelper, deprecation);
199
+ static async provider([cli, workspace, deprecation, newComponentHelper, componentMain, graphql, refactoring]) {
200
+ const renaming = new RenamingMain(workspace, newComponentHelper, deprecation, refactoring);
181
201
  cli.register(new (_rename().RenameCmd)(renaming));
182
202
  graphql.register((0, _renaming3().renamingSchema)(renaming));
183
203
  componentMain.registerShowFragments([new (_renaming2().RenamingFragment)(renaming)]);
@@ -188,7 +208,7 @@ class RenamingMain {
188
208
 
189
209
  exports.RenamingMain = RenamingMain;
190
210
  (0, _defineProperty2().default)(RenamingMain, "slots", []);
191
- (0, _defineProperty2().default)(RenamingMain, "dependencies", [_cli().CLIAspect, _workspace().default, _deprecation().DeprecationAspect, _newComponentHelper().default, _component().default, _graphql().default]);
211
+ (0, _defineProperty2().default)(RenamingMain, "dependencies", [_cli().CLIAspect, _workspace().default, _deprecation().DeprecationAspect, _newComponentHelper().default, _component().default, _graphql().default, _refactoring().default]);
192
212
  (0, _defineProperty2().default)(RenamingMain, "runtime", _cli().MainRuntime);
193
213
 
194
214
  _renaming().RenamingAspect.addRuntime(RenamingMain);
@@ -1 +1 @@
1
- {"version":3,"sources":["renaming.main.runtime.ts"],"names":["RenamingMain","constructor","workspace","newComponentHelper","deprecation","rename","sourceIdStr","targetIdStr","options","sourceId","resolveComponentId","isTagged","hasVersion","sourceComp","get","targetId","getNewComponentId","undefined","scope","config","getConfig","writeAndAddNewComp","deprecate","bitMap","renameNewComponent","write","getRenamingInfo","component","renameConfig","state","aspects","RenamingAspect","id","renamedFrom","ComponentID","fromObject","comp","fromExisting","getConfigFromExistingToNewComponent","toObject","provider","cli","componentMain","graphql","renaming","register","RenameCmd","registerShowFragments","RenamingFragment","CLIAspect","WorkspaceAspect","DeprecationAspect","NewComponentHelperAspect","ComponentAspect","GraphqlAspect","MainRuntime","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;;;;;;;;;;AAEO,MAAMA,YAAN,CAAmB;AACxBC,EAAAA,WAAW,CACDC,SADC,EAEDC,kBAFC,EAGDC,WAHC,EAIT;AAAA,SAHQF,SAGR,GAHQA,SAGR;AAAA,SAFQC,kBAER,GAFQA,kBAER;AAAA,SADQC,WACR,GADQA,WACR;AAAE;;AAEQ,QAANC,MAAM,CAACC,WAAD,EAAsBC,WAAtB,EAA2CC,OAA3C,EAA0F;AACpG,UAAMC,QAAQ,GAAG,MAAM,KAAKP,SAAL,CAAeQ,kBAAf,CAAkCJ,WAAlC,CAAvB;AACA,UAAMK,QAAQ,GAAGF,QAAQ,CAACG,UAAT,EAAjB;AACA,UAAMC,UAAU,GAAG,MAAM,KAAKX,SAAL,CAAeY,GAAf,CAAmBL,QAAnB,CAAzB;AACA,UAAMM,QAAQ,GAAG,KAAKZ,kBAAL,CAAwBa,iBAAxB,CAA0CT,WAA1C,EAAuDU,SAAvD,EAAkET,OAAlE,aAAkEA,OAAlE,uBAAkEA,OAAO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EAOlB;AACD,UAAMC,QAAQ,GAAG,IAAI5C,YAAJ,CAAiBE,SAAjB,EAA4BC,kBAA5B,EAAgDC,WAAhD,CAAjB;AACAqC,IAAAA,GAAG,CAACI,QAAJ,CAAa,KAAIC,mBAAJ,EAAcF,QAAd,CAAb;AACAD,IAAAA,OAAO,CAACE,QAAR,CAAiB,iCAAeD,QAAf,CAAjB;AACAF,IAAAA,aAAa,CAACK,qBAAd,CAAoC,CAAC,KAAIC,6BAAJ,EAAqBJ,QAArB,CAAD,CAApC;AACA,WAAOA,QAAP;AACD;;AApEuB;;;gCAAb5C,Y,WA6CI,E;gCA7CJA,Y,kBA8CW,CACpBiD,gBADoB,EAEpBC,oBAFoB,EAGpBC,gCAHoB,EAIpBC,6BAJoB,EAKpBC,oBALoB,EAMpBC,kBANoB,C;gCA9CXtD,Y,aAsDMuD,kB;;AAiBnBxB,2BAAeyB,UAAf,CAA0BxD,YAA1B","sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport ComponentAspect, { Component, ComponentID, ComponentMain } from '@teambit/component';\nimport { DeprecationAspect, DeprecationMain } from '@teambit/deprecation';\nimport GraphqlAspect, { GraphqlMain } from '@teambit/graphql';\nimport NewComponentHelperAspect, { NewComponentHelperMain } from '@teambit/new-component-helper';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport { RenameCmd, RenameOptions } from './rename.cmd';\nimport { RenamingAspect } from './renaming.aspect';\nimport { RenamingFragment } from './renaming.fragment';\nimport { renamingSchema } from './renaming.graphql';\n\nexport class RenamingMain {\n constructor(\n private workspace: Workspace,\n private newComponentHelper: NewComponentHelperMain,\n private deprecation: DeprecationMain\n ) {}\n\n async rename(sourceIdStr: string, targetIdStr: string, options: RenameOptions): Promise<RenameResult> {\n const sourceId = await this.workspace.resolveComponentId(sourceIdStr);\n const isTagged = sourceId.hasVersion();\n const sourceComp = await this.workspace.get(sourceId);\n const targetId = this.newComponentHelper.getNewComponentId(targetIdStr, undefined, options?.scope);\n if (isTagged) {\n const config = await this.getConfig(sourceComp);\n await this.newComponentHelper.writeAndAddNewComp(sourceComp, targetId, options, config);\n await this.deprecation.deprecate(sourceId, targetId);\n } else {\n this.workspace.bitMap.renameNewComponent(sourceId, targetId);\n await this.workspace.bitMap.write();\n }\n\n return {\n sourceId,\n targetId,\n };\n }\n\n getRenamingInfo(component: Component): RenamingInfo | null {\n const renameConfig = component.state.aspects.get(RenamingAspect.id)?.config as RenamingInfo | undefined;\n if (!renameConfig) return null;\n return {\n renamedFrom: ComponentID.fromObject(renameConfig.renamedFrom),\n };\n }\n\n private async getConfig(comp: Component) {\n const fromExisting = await this.newComponentHelper.getConfigFromExistingToNewComponent(comp);\n return {\n ...fromExisting,\n [RenamingAspect.id]: {\n renamedFrom: comp.id.toObject(),\n },\n };\n }\n\n static slots = [];\n static dependencies = [\n CLIAspect,\n WorkspaceAspect,\n DeprecationAspect,\n NewComponentHelperAspect,\n ComponentAspect,\n GraphqlAspect,\n ];\n static runtime = MainRuntime;\n static async provider([cli, workspace, deprecation, newComponentHelper, componentMain, graphql]: [\n CLIMain,\n Workspace,\n DeprecationMain,\n NewComponentHelperMain,\n ComponentMain,\n GraphqlMain\n ]) {\n const renaming = new RenamingMain(workspace, newComponentHelper, deprecation);\n cli.register(new RenameCmd(renaming));\n graphql.register(renamingSchema(renaming));\n componentMain.registerShowFragments([new RenamingFragment(renaming)]);\n return renaming;\n }\n}\n\nRenamingAspect.addRuntime(RenamingMain);\n\nexport type RenameResult = { sourceId: ComponentID; targetId: ComponentID };\n\nexport type RenamingInfo = {\n renamedFrom: ComponentID;\n};\n"]}
1
+ {"version":3,"sources":["renaming.main.runtime.ts"],"names":["RenamingMain","constructor","workspace","newComponentHelper","deprecation","refactoring","rename","sourceIdStr","targetIdStr","options","sourceId","resolveComponentId","isTagged","hasVersion","sourceComp","get","targetId","getNewComponentId","undefined","scope","config","getConfig","writeAndAddNewComp","deprecate","bitMap","renameNewComponent","write","refactor","allComponents","list","changedComponents","refactorDependencyName","Promise","all","map","comp","link","getRenamingInfo","component","renameConfig","state","aspects","RenamingAspect","id","renamedFrom","ComponentID","fromObject","fromExisting","getConfigFromExistingToNewComponent","toObject","provider","cli","componentMain","graphql","renaming","register","RenameCmd","registerShowFragments","RenamingFragment","CLIAspect","WorkspaceAspect","DeprecationAspect","NewComponentHelperAspect","ComponentAspect","GraphqlAspect","RefactoringAspect","MainRuntime","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;;;;;;;;;;AAEO,MAAMA,YAAN,CAAmB;AACxBC,EAAAA,WAAW,CACDC,SADC,EAEDC,kBAFC,EAGDC,WAHC,EAIDC,WAJC,EAKT;AAAA,SAJQH,SAIR,GAJQA,SAIR;AAAA,SAHQC,kBAGR,GAHQA,kBAGR;AAAA,SAFQC,WAER,GAFQA,WAER;AAAA,SADQC,WACR,GADQA,WACR;AAAE;;AAEQ,QAANC,MAAM,CAACC,WAAD,EAAsBC,WAAtB,EAA2CC,OAA3C,EAA0F;AACpG,UAAMC,QAAQ,GAAG,MAAM,KAAKR,SAAL,CAAeS,kBAAf,CAAkCJ,WAAlC,CAAvB;AACA,UAAMK,QAAQ,GAAGF,QAAQ,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Y,aA+DMkE,kB;;AAkBnBxB,2BAAeyB,UAAf,CAA0BnE,YAA1B","sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport ComponentAspect, { Component, ComponentID, ComponentMain } from '@teambit/component';\nimport { DeprecationAspect, DeprecationMain } from '@teambit/deprecation';\nimport GraphqlAspect, { GraphqlMain } from '@teambit/graphql';\nimport NewComponentHelperAspect, { NewComponentHelperMain } from '@teambit/new-component-helper';\nimport RefactoringAspect, { RefactoringMain } from '@teambit/refactoring';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport { RenameCmd, RenameOptions } from './rename.cmd';\nimport { RenamingAspect } from './renaming.aspect';\nimport { RenamingFragment } from './renaming.fragment';\nimport { renamingSchema } from './renaming.graphql';\n\nexport class RenamingMain {\n constructor(\n private workspace: Workspace,\n private newComponentHelper: NewComponentHelperMain,\n private deprecation: DeprecationMain,\n private refactoring: RefactoringMain\n ) {}\n\n async rename(sourceIdStr: string, targetIdStr: string, options: RenameOptions): Promise<RenameResult> {\n const sourceId = await this.workspace.resolveComponentId(sourceIdStr);\n const isTagged = sourceId.hasVersion();\n const sourceComp = await this.workspace.get(sourceId);\n const targetId = this.newComponentHelper.getNewComponentId(targetIdStr, undefined, options?.scope);\n if (isTagged) {\n const config = await this.getConfig(sourceComp);\n await this.newComponentHelper.writeAndAddNewComp(sourceComp, targetId, options, config);\n await this.deprecation.deprecate(sourceId, targetId);\n } else {\n this.workspace.bitMap.renameNewComponent(sourceId, targetId);\n await this.workspace.bitMap.write();\n }\n if (options.refactor) {\n const allComponents = await this.workspace.list();\n const { changedComponents } = await this.refactoring.refactorDependencyName(allComponents, sourceId, targetId);\n await Promise.all(changedComponents.map((comp) => this.workspace.write(comp)));\n }\n\n await this.workspace.link();\n\n return {\n sourceId,\n targetId,\n };\n }\n\n getRenamingInfo(component: Component): RenamingInfo | null {\n const renameConfig = component.state.aspects.get(RenamingAspect.id)?.config as RenamingInfo | undefined;\n if (!renameConfig) return null;\n return {\n renamedFrom: ComponentID.fromObject(renameConfig.renamedFrom),\n };\n }\n\n private async getConfig(comp: Component) {\n const fromExisting = await this.newComponentHelper.getConfigFromExistingToNewComponent(comp);\n return {\n ...fromExisting,\n [RenamingAspect.id]: {\n renamedFrom: comp.id.toObject(),\n },\n };\n }\n\n static slots = [];\n static dependencies = [\n CLIAspect,\n WorkspaceAspect,\n DeprecationAspect,\n NewComponentHelperAspect,\n ComponentAspect,\n GraphqlAspect,\n RefactoringAspect,\n ];\n static runtime = MainRuntime;\n static async provider([cli, workspace, deprecation, newComponentHelper, componentMain, graphql, refactoring]: [\n CLIMain,\n Workspace,\n DeprecationMain,\n NewComponentHelperMain,\n ComponentMain,\n GraphqlMain,\n RefactoringMain\n ]) {\n const renaming = new RenamingMain(workspace, newComponentHelper, deprecation, refactoring);\n cli.register(new RenameCmd(renaming));\n graphql.register(renamingSchema(renaming));\n componentMain.registerShowFragments([new RenamingFragment(renaming)]);\n return renaming;\n }\n}\n\nRenamingAspect.addRuntime(RenamingMain);\n\nexport type RenameResult = { sourceId: ComponentID; targetId: ComponentID };\n\nexport type RenamingInfo = {\n renamedFrom: ComponentID;\n};\n"]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/renaming",
3
- "version": "0.0.107",
3
+ "version": "0.0.108",
4
4
  "homepage": "https://bit.dev/teambit/component/renaming",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.component",
8
8
  "name": "renaming",
9
- "version": "0.0.107"
9
+ "version": "0.0.108"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
@@ -14,12 +14,13 @@
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.467",
18
- "@teambit/component": "0.0.703",
19
- "@teambit/graphql": "0.0.703",
20
- "@teambit/deprecation": "0.0.703",
21
- "@teambit/new-component-helper": "0.0.107",
22
- "@teambit/workspace": "0.0.703"
17
+ "@teambit/cli": "0.0.468",
18
+ "@teambit/component": "0.0.704",
19
+ "@teambit/graphql": "0.0.704",
20
+ "@teambit/deprecation": "0.0.704",
21
+ "@teambit/new-component-helper": "0.0.108",
22
+ "@teambit/refactoring": "0.0.1",
23
+ "@teambit/workspace": "0.0.704"
23
24
  },
24
25
  "devDependencies": {
25
26
  "@types/react": "^17.0.8",
@@ -30,7 +31,7 @@
30
31
  "@types/node": "12.20.4"
31
32
  },
32
33
  "peerDependencies": {
33
- "@teambit/legacy": "1.0.245",
34
+ "@teambit/legacy": "1.0.246",
34
35
  "react-dom": "^16.8.0 || ^17.0.0",
35
36
  "react": "^16.8.0 || ^17.0.0"
36
37
  },
@@ -58,7 +59,7 @@
58
59
  "react": "-"
59
60
  },
60
61
  "peerDependencies": {
61
- "@teambit/legacy": "1.0.245",
62
+ "@teambit/legacy": "1.0.246",
62
63
  "react-dom": "^16.8.0 || ^17.0.0",
63
64
  "react": "^16.8.0 || ^17.0.0"
64
65
  }
@@ -1,2 +1,2 @@
1
- export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_renaming@0.0.107/dist/renaming.composition.js')]
2
- export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_renaming@0.0.107/dist/renaming.docs.mdx')]
1
+ export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_renaming@0.0.108/dist/renaming.composition.js')]
2
+ export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_renaming@0.0.108/dist/renaming.docs.mdx')]