@teambit/renaming 0.0.138 → 0.0.141

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.
@@ -4,7 +4,6 @@ import { DeprecationMain } from '@teambit/deprecation';
4
4
  import { GraphqlMain } from '@teambit/graphql';
5
5
  import { NewComponentHelperMain } from '@teambit/new-component-helper';
6
6
  import { RefactoringMain } from '@teambit/refactoring';
7
- import { ConfigMain } from '@teambit/config';
8
7
  import { Workspace } from '@teambit/workspace';
9
8
  import { RenameOptions } from './rename.cmd';
10
9
  export declare class RenamingMain {
@@ -12,8 +11,7 @@ export declare class RenamingMain {
12
11
  private newComponentHelper;
13
12
  private deprecation;
14
13
  private refactoring;
15
- private config;
16
- constructor(workspace: Workspace, newComponentHelper: NewComponentHelperMain, deprecation: DeprecationMain, refactoring: RefactoringMain, config: ConfigMain);
14
+ constructor(workspace: Workspace, newComponentHelper: NewComponentHelperMain, deprecation: DeprecationMain, refactoring: RefactoringMain);
17
15
  rename(sourceIdStr: string, targetIdStr: string, options: RenameOptions): Promise<RenameDependencyNameResult>;
18
16
  getRenamingInfo(component: Component): RenamingInfo | null;
19
17
  /**
@@ -29,15 +27,14 @@ export declare class RenamingMain {
29
27
  static slots: never[];
30
28
  static dependencies: import("@teambit/harmony").Aspect[];
31
29
  static runtime: import("@teambit/harmony").RuntimeDefinition;
32
- static provider([cli, workspace, deprecation, newComponentHelper, componentMain, graphql, refactoring, config,]: [
30
+ static provider([cli, workspace, deprecation, newComponentHelper, componentMain, graphql, refactoring]: [
33
31
  CLIMain,
34
32
  Workspace,
35
33
  DeprecationMain,
36
34
  NewComponentHelperMain,
37
35
  ComponentMain,
38
36
  GraphqlMain,
39
- RefactoringMain,
40
- ConfigMain
37
+ RefactoringMain
41
38
  ]): Promise<RenamingMain>;
42
39
  }
43
40
  export declare type RenameDependencyNameResult = {
@@ -21,16 +21,6 @@ function _defineProperty2() {
21
21
  return data;
22
22
  }
23
23
 
24
- function _path() {
25
- const data = _interopRequireDefault(require("path"));
26
-
27
- _path = function () {
28
- return data;
29
- };
30
-
31
- return data;
32
- }
33
-
34
24
  function _bitError() {
35
25
  const data = require("@teambit/bit-error");
36
26
 
@@ -121,16 +111,6 @@ function _componentConfig() {
121
111
  return data;
122
112
  }
123
113
 
124
- function _config() {
125
- const data = require("@teambit/config");
126
-
127
- _config = function () {
128
- return data;
129
- };
130
-
131
- return data;
132
- }
133
-
134
114
  function _workspace() {
135
115
  const data = _interopRequireDefault(require("@teambit/workspace"));
136
116
 
@@ -200,12 +180,11 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
200
180
  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; }
201
181
 
202
182
  class RenamingMain {
203
- constructor(workspace, newComponentHelper, deprecation, refactoring, config) {
183
+ constructor(workspace, newComponentHelper, deprecation, refactoring) {
204
184
  this.workspace = workspace;
205
185
  this.newComponentHelper = newComponentHelper;
206
186
  this.deprecation = deprecation;
207
187
  this.refactoring = refactoring;
208
- this.config = config;
209
188
  }
210
189
 
211
190
  async rename(sourceIdStr, targetIdStr, options) {
@@ -284,17 +263,7 @@ to be able to rename the scope, please untag the components first (using "bit un
284
263
  }
285
264
 
286
265
  if (this.workspace.defaultScope === oldScope) {
287
- var _this$config$workspac, _this$config$workspac2;
288
-
289
- (_this$config$workspac = this.config.workspaceConfig) === null || _this$config$workspac === void 0 ? void 0 : _this$config$workspac.setExtension(_workspace().default.id, {
290
- defaultScope: newScope
291
- }, {
292
- mergeIntoExisting: true,
293
- ignoreVersion: true
294
- });
295
- await ((_this$config$workspac2 = this.config.workspaceConfig) === null || _this$config$workspac2 === void 0 ? void 0 : _this$config$workspac2.write({
296
- dir: _path().default.dirname(this.config.workspaceConfig.path)
297
- }));
266
+ await this.workspace.setDefaultScope(newScope);
298
267
  componentsUsingOldScope.forEach(comp => this.workspace.bitMap.removeDefaultScope(comp.id));
299
268
  } else {
300
269
  componentsUsingOldScope.forEach(comp => this.workspace.bitMap.setDefaultScope(comp.id, newScope));
@@ -337,10 +306,10 @@ to be able to rename the scope, please untag the components first (using "bit un
337
306
  });
338
307
  }
339
308
 
340
- static async provider([cli, workspace, deprecation, newComponentHelper, componentMain, graphql, refactoring, config]) {
309
+ static async provider([cli, workspace, deprecation, newComponentHelper, componentMain, graphql, refactoring]) {
341
310
  var _scopeCommand$command;
342
311
 
343
- const renaming = new RenamingMain(workspace, newComponentHelper, deprecation, refactoring, config);
312
+ const renaming = new RenamingMain(workspace, newComponentHelper, deprecation, refactoring);
344
313
  cli.register(new (_rename().RenameCmd)(renaming));
345
314
  const scopeCommand = cli.getCommand('scope');
346
315
  scopeCommand === null || scopeCommand === void 0 ? void 0 : (_scopeCommand$command = scopeCommand.commands) === null || _scopeCommand$command === void 0 ? void 0 : _scopeCommand$command.push(new (_scopeRename().ScopeRenameCmd)(renaming));
@@ -353,7 +322,7 @@ to be able to rename the scope, please untag the components first (using "bit un
353
322
 
354
323
  exports.RenamingMain = RenamingMain;
355
324
  (0, _defineProperty2().default)(RenamingMain, "slots", []);
356
- (0, _defineProperty2().default)(RenamingMain, "dependencies", [_cli().CLIAspect, _workspace().default, _deprecation().DeprecationAspect, _newComponentHelper().default, _component().default, _graphql().default, _refactoring().default, _config().ConfigAspect]);
325
+ (0, _defineProperty2().default)(RenamingMain, "dependencies", [_cli().CLIAspect, _workspace().default, _deprecation().DeprecationAspect, _newComponentHelper().default, _component().default, _graphql().default, _refactoring().default]);
357
326
  (0, _defineProperty2().default)(RenamingMain, "runtime", _cli().MainRuntime);
358
327
 
359
328
  _renaming().RenamingAspect.addRuntime(RenamingMain);
@@ -1 +1 @@
1
- {"version":3,"sources":["renaming.main.runtime.ts"],"names":["RenamingMain","constructor","workspace","newComponentHelper","deprecation","refactoring","config","rename","sourceIdStr","targetIdStr","options","sourceId","resolveComponentId","isTagged","hasVersion","sourceComp","get","targetId","getNewComponentId","undefined","scope","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","renameScope","oldScope","newScope","componentsUsingOldScope","filter","length","defaultScope","BitError","exported","_legacy","hasScope","idsStr","toString","join","tagged","workspaceConfig","setExtension","WorkspaceAspect","mergeIntoExisting","ignoreVersion","dir","path","dirname","forEach","removeDefaultScope","setDefaultScope","refactoredIds","legacyComps","c","_consumer","packagesToReplace","oldStr","newStr","bindingPrefix","replaceMultipleStrings","push","scopeRenamedComponentIds","fromExisting","getConfigFromExistingToNewComponent","toObject","provider","cli","componentMain","graphql","renaming","register","RenameCmd","scopeCommand","getCommand","commands","ScopeRenameCmd","registerShowFragments","RenamingFragment","CLIAspect","DeprecationAspect","NewComponentHelperAspect","ComponentAspect","GraphqlAspect","RefactoringAspect","ConfigAspect","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;;AAC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QAAd,CAAb;AAEA,UAAMG,YAAY,GAAGN,GAAG,CAACO,UAAJ,CAAe,OAAf,CAArB;AACAD,IAAAA,YAAY,SAAZ,IAAAA,YAAY,WAAZ,qCAAAA,YAAY,CAAEE,QAAd,gFAAwBd,IAAxB,CAA6B,KAAIe,6BAAJ,EAAmBN,QAAnB,CAA7B;AAEAD,IAAAA,OAAO,CAACE,QAAR,CAAiB,iCAAeD,QAAf,CAAjB;AACAF,IAAAA,aAAa,CAACS,qBAAd,CAAoC,CAAC,KAAIC,6BAAJ,EAAqBR,QAArB,CAAD,CAApC;AACA,WAAOA,QAAP;AACD;;AA9JuB;;;gCAAb3F,Y,WAsHI,E;gCAtHJA,Y,kBAuHW,CACpBoG,gBADoB,EAEpBpC,oBAFoB,EAGpBqC,gCAHoB,EAIpBC,6BAJoB,EAKpBC,oBALoB,EAMpBC,kBANoB,EAOpBC,sBAPoB,EAQpBC,sBARoB,C;gCAvHX1G,Y,aAiIM2G,kB;;AAgCnBjE,2BAAekE,UAAf,CAA0B5G,YAA1B","sourcesContent":["import path from 'path';\nimport { BitError } from '@teambit/bit-error';\nimport componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';\nimport { 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, { MultipleStringsReplacement, RefactoringMain } from '@teambit/refactoring';\nimport { getBindingPrefixByDefaultScope } from '@teambit/legacy/dist/consumer/config/component-config';\nimport { ConfigAspect, ConfigMain } from '@teambit/config';\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';\nimport { ScopeRenameCmd } from './scope-rename.cmd';\n\nexport class RenamingMain {\n constructor(\n private workspace: Workspace,\n private newComponentHelper: NewComponentHelperMain,\n private deprecation: DeprecationMain,\n private refactoring: RefactoringMain,\n private config: ConfigMain\n ) {}\n\n async rename(sourceIdStr: string, targetIdStr: string, options: RenameOptions): Promise<RenameDependencyNameResult> {\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 /**\n * change the default-scope for new components. optionally (if refactor is true), change the source code to match the\n * new scope-name.\n * keep in mind that this is working for new components only, for tagged/exported it's impossible. See the errors\n * thrown in such cases in this method.\n */\n async renameScope(oldScope: string, newScope: string, options: { refactor?: boolean }): Promise<RenameScopeResult> {\n const allComponents = await this.workspace.list();\n const componentsUsingOldScope = allComponents.filter((comp) => comp.id.scope === oldScope);\n if (!componentsUsingOldScope.length && this.workspace.defaultScope !== oldScope) {\n throw new BitError(\n `none of the components is using \"${oldScope}\". also, the workspace is not configured with \"${oldScope}\"`\n );\n }\n // verify they're all new.\n const exported = componentsUsingOldScope.filter((comp) => comp.id._legacy.hasScope());\n if (exported.length) {\n const idsStr = exported.map((comp) => comp.id.toString()).join(', ');\n throw new BitError(`unable to rename the scope for the following exported components:\\n${idsStr}\nbecause these components were exported already, other components may use them and they'll break upon rename.\ninstead, deprecate the above components (using \"bit deprecate\"), tag, export and then eject them.\nonce they are not in the workspace, you can fork them (\"bit fork\") with the new scope-name`);\n }\n const tagged = componentsUsingOldScope.filter((comp) => comp.id.hasVersion());\n if (tagged.length) {\n const idsStr = tagged.map((comp) => comp.id.toString()).join(', ');\n throw new BitError(`unable to rename the scope for the following tagged components:\\n${idsStr}\nbecause these components were tagged, the objects have the dependencies data of the old-scope.\nto be able to rename the scope, please untag the components first (using \"bit untag\" command)`);\n }\n if (this.workspace.defaultScope === oldScope) {\n this.config.workspaceConfig?.setExtension(\n WorkspaceAspect.id,\n { defaultScope: newScope },\n { mergeIntoExisting: true, ignoreVersion: true }\n );\n await this.config.workspaceConfig?.write({ dir: path.dirname(this.config.workspaceConfig.path) });\n componentsUsingOldScope.forEach((comp) => this.workspace.bitMap.removeDefaultScope(comp.id));\n } else {\n componentsUsingOldScope.forEach((comp) => this.workspace.bitMap.setDefaultScope(comp.id, newScope));\n }\n await this.workspace.bitMap.write();\n const refactoredIds: ComponentID[] = [];\n if (options.refactor) {\n const legacyComps = componentsUsingOldScope.map((c) => c.state._consumer);\n const packagesToReplace: MultipleStringsReplacement = legacyComps.map((comp) => {\n return {\n oldStr: componentIdToPackageName(comp),\n newStr: componentIdToPackageName({\n ...comp,\n bindingPrefix: getBindingPrefixByDefaultScope(newScope),\n id: comp.id,\n defaultScope: newScope,\n }),\n };\n });\n const { changedComponents } = await this.refactoring.replaceMultipleStrings(allComponents, packagesToReplace);\n await Promise.all(changedComponents.map((comp) => this.workspace.write(comp)));\n refactoredIds.push(...changedComponents.map((c) => c.id));\n }\n\n return { scopeRenamedComponentIds: componentsUsingOldScope.map((comp) => comp.id), refactoredIds };\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 ConfigAspect,\n ];\n static runtime = MainRuntime;\n static async provider([\n cli,\n workspace,\n deprecation,\n newComponentHelper,\n componentMain,\n graphql,\n refactoring,\n config,\n ]: [\n CLIMain,\n Workspace,\n DeprecationMain,\n NewComponentHelperMain,\n ComponentMain,\n GraphqlMain,\n RefactoringMain,\n ConfigMain\n ]) {\n const renaming = new RenamingMain(workspace, newComponentHelper, deprecation, refactoring, config);\n cli.register(new RenameCmd(renaming));\n\n const scopeCommand = cli.getCommand('scope');\n scopeCommand?.commands?.push(new ScopeRenameCmd(renaming));\n\n graphql.register(renamingSchema(renaming));\n componentMain.registerShowFragments([new RenamingFragment(renaming)]);\n return renaming;\n }\n}\n\nRenamingAspect.addRuntime(RenamingMain);\n\nexport type RenameDependencyNameResult = { sourceId: ComponentID; targetId: ComponentID };\n\nexport type RenamingInfo = {\n renamedFrom: ComponentID;\n};\n\nexport type RenameScopeResult = { scopeRenamedComponentIds: ComponentID[]; refactoredIds: ComponentID[] };\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","renameScope","oldScope","newScope","componentsUsingOldScope","filter","length","defaultScope","BitError","exported","_legacy","hasScope","idsStr","toString","join","tagged","setDefaultScope","forEach","removeDefaultScope","refactoredIds","legacyComps","c","_consumer","packagesToReplace","oldStr","newStr","bindingPrefix","replaceMultipleStrings","push","scopeRenamedComponentIds","fromExisting","getConfigFromExistingToNewComponent","toObject","provider","cli","componentMain","graphql","renaming","register","RenameCmd","scopeCommand","getCommand","commands","ScopeRenameCmd","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;;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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ACC,GAAD,EAAM9E,SAAN,EAAiBE,WAAjB,EAA8BD,kBAA9B,EAAkD8E,aAAlD,EAAiEC,OAAjE,EAA0E7E,WAA1E,CAAD,EAQlB;AAAA;;AACD,UAAM8E,QAAQ,GAAG,IAAInF,YAAJ,CAAiBE,SAAjB,EAA4BC,kBAA5B,EAAgDC,WAAhD,EAA6DC,WAA7D,CAAjB;AACA2E,IAAAA,GAAG,CAACI,QAAJ,CAAa,KAAIC,mBAAJ,EAAcF,QAAd,CAAb;AAEA,UAAMG,YAAY,GAAGN,GAAG,CAACO,UAAJ,CAAe,OAAf,CAArB;AACAD,IAAAA,YAAY,SAAZ,IAAAA,YAAY,WAAZ,qCAAAA,YAAY,CAAEE,QAAd,gFAAwBd,IAAxB,CAA6B,KAAIe,6BAAJ,EAAmBN,QAAnB,CAA7B;AAEAD,IAAAA,OAAO,CAACE,QAAR,CAAiB,iCAAeD,QAAf,CAAjB;AACAF,IAAAA,aAAa,CAACS,qBAAd,CAAoC,CAAC,KAAIC,6BAAJ,EAAqBR,QAArB,CAAD,CAApC;AACA,WAAOA,QAAP;AACD;;AA7IuB;;;gCAAbnF,Y,WAgHI,E;gCAhHJA,Y,kBAiHW,CACpB4F,gBADoB,EAEpBC,oBAFoB,EAGpBC,gCAHoB,EAIpBC,6BAJoB,EAKpBC,oBALoB,EAMpBC,kBANoB,EAOpBC,sBAPoB,C;gCAjHXlG,Y,aA0HMmG,kB;;AAsBnBzD,2BAAe0D,UAAf,CAA0BpG,YAA1B","sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';\nimport { 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, { MultipleStringsReplacement, RefactoringMain } from '@teambit/refactoring';\nimport { getBindingPrefixByDefaultScope } from '@teambit/legacy/dist/consumer/config/component-config';\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';\nimport { ScopeRenameCmd } from './scope-rename.cmd';\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<RenameDependencyNameResult> {\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 /**\n * change the default-scope for new components. optionally (if refactor is true), change the source code to match the\n * new scope-name.\n * keep in mind that this is working for new components only, for tagged/exported it's impossible. See the errors\n * thrown in such cases in this method.\n */\n async renameScope(oldScope: string, newScope: string, options: { refactor?: boolean }): Promise<RenameScopeResult> {\n const allComponents = await this.workspace.list();\n const componentsUsingOldScope = allComponents.filter((comp) => comp.id.scope === oldScope);\n if (!componentsUsingOldScope.length && this.workspace.defaultScope !== oldScope) {\n throw new BitError(\n `none of the components is using \"${oldScope}\". also, the workspace is not configured with \"${oldScope}\"`\n );\n }\n // verify they're all new.\n const exported = componentsUsingOldScope.filter((comp) => comp.id._legacy.hasScope());\n if (exported.length) {\n const idsStr = exported.map((comp) => comp.id.toString()).join(', ');\n throw new BitError(`unable to rename the scope for the following exported components:\\n${idsStr}\nbecause these components were exported already, other components may use them and they'll break upon rename.\ninstead, deprecate the above components (using \"bit deprecate\"), tag, export and then eject them.\nonce they are not in the workspace, you can fork them (\"bit fork\") with the new scope-name`);\n }\n const tagged = componentsUsingOldScope.filter((comp) => comp.id.hasVersion());\n if (tagged.length) {\n const idsStr = tagged.map((comp) => comp.id.toString()).join(', ');\n throw new BitError(`unable to rename the scope for the following tagged components:\\n${idsStr}\nbecause these components were tagged, the objects have the dependencies data of the old-scope.\nto be able to rename the scope, please untag the components first (using \"bit untag\" command)`);\n }\n if (this.workspace.defaultScope === oldScope) {\n await this.workspace.setDefaultScope(newScope);\n componentsUsingOldScope.forEach((comp) => this.workspace.bitMap.removeDefaultScope(comp.id));\n } else {\n componentsUsingOldScope.forEach((comp) => this.workspace.bitMap.setDefaultScope(comp.id, newScope));\n }\n await this.workspace.bitMap.write();\n const refactoredIds: ComponentID[] = [];\n if (options.refactor) {\n const legacyComps = componentsUsingOldScope.map((c) => c.state._consumer);\n const packagesToReplace: MultipleStringsReplacement = legacyComps.map((comp) => {\n return {\n oldStr: componentIdToPackageName(comp),\n newStr: componentIdToPackageName({\n ...comp,\n bindingPrefix: getBindingPrefixByDefaultScope(newScope),\n id: comp.id,\n defaultScope: newScope,\n }),\n };\n });\n const { changedComponents } = await this.refactoring.replaceMultipleStrings(allComponents, packagesToReplace);\n await Promise.all(changedComponents.map((comp) => this.workspace.write(comp)));\n refactoredIds.push(...changedComponents.map((c) => c.id));\n }\n\n return { scopeRenamedComponentIds: componentsUsingOldScope.map((comp) => comp.id), refactoredIds };\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\n const scopeCommand = cli.getCommand('scope');\n scopeCommand?.commands?.push(new ScopeRenameCmd(renaming));\n\n graphql.register(renamingSchema(renaming));\n componentMain.registerShowFragments([new RenamingFragment(renaming)]);\n return renaming;\n }\n}\n\nRenamingAspect.addRuntime(RenamingMain);\n\nexport type RenameDependencyNameResult = { sourceId: ComponentID; targetId: ComponentID };\n\nexport type RenamingInfo = {\n renamedFrom: ComponentID;\n};\n\nexport type RenameScopeResult = { scopeRenamedComponentIds: ComponentID[]; refactoredIds: ComponentID[] };\n"]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/renaming",
3
- "version": "0.0.138",
3
+ "version": "0.0.141",
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.138"
9
+ "version": "0.0.141"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
@@ -14,15 +14,14 @@
14
14
  "@babel/runtime": "7.12.18",
15
15
  "core-js": "^3.0.0",
16
16
  "@teambit/harmony": "0.3.3",
17
- "@teambit/cli": "0.0.490",
18
- "@teambit/component": "0.0.734",
19
- "@teambit/graphql": "0.0.734",
17
+ "@teambit/cli": "0.0.491",
18
+ "@teambit/component": "0.0.737",
19
+ "@teambit/graphql": "0.0.737",
20
20
  "@teambit/bit-error": "0.0.394",
21
- "@teambit/config": "0.0.503",
22
- "@teambit/deprecation": "0.0.734",
23
- "@teambit/new-component-helper": "0.0.138",
24
- "@teambit/refactoring": "0.0.31",
25
- "@teambit/workspace": "0.0.734"
21
+ "@teambit/deprecation": "0.0.737",
22
+ "@teambit/new-component-helper": "0.0.141",
23
+ "@teambit/refactoring": "0.0.34",
24
+ "@teambit/workspace": "0.0.737"
26
25
  },
27
26
  "devDependencies": {
28
27
  "@types/react": "^17.0.8",
@@ -33,7 +32,7 @@
33
32
  "@types/node": "12.20.4"
34
33
  },
35
34
  "peerDependencies": {
36
- "@teambit/legacy": "1.0.270",
35
+ "@teambit/legacy": "1.0.271",
37
36
  "react-dom": "^16.8.0 || ^17.0.0",
38
37
  "react": "^16.8.0 || ^17.0.0"
39
38
  },
@@ -61,7 +60,7 @@
61
60
  "react": "-"
62
61
  },
63
62
  "peerDependencies": {
64
- "@teambit/legacy": "1.0.270",
63
+ "@teambit/legacy": "1.0.271",
65
64
  "react-dom": "^16.8.0 || ^17.0.0",
66
65
  "react": "^16.8.0 || ^17.0.0"
67
66
  }
@@ -1,2 +1,2 @@
1
- export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_renaming@0.0.138/dist/renaming.composition.js')]
2
- export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_renaming@0.0.138/dist/renaming.docs.mdx')]
1
+ export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_renaming@0.0.141/dist/renaming.composition.js')]
2
+ export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_renaming@0.0.141/dist/renaming.docs.mdx')]
package/tsconfig.json CHANGED
@@ -15,13 +15,13 @@
15
15
  "declaration": true,
16
16
  "sourceMap": true,
17
17
  "skipLibCheck": true,
18
+ "experimentalDecorators": true,
18
19
  "outDir": "dist",
19
20
  "moduleResolution": "node",
20
21
  "esModuleInterop": true,
21
22
  "rootDir": ".",
22
23
  "resolveJsonModule": true,
23
24
  "emitDeclarationOnly": true,
24
- "experimentalDecorators": true,
25
25
  "emitDecoratorMetadata": true,
26
26
  "allowSyntheticDefaultImports": true,
27
27
  "strictPropertyInitialization": false,