@teambit/component-writer 0.0.5 → 0.0.7

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.
@@ -2,6 +2,7 @@ import { CompilerMain } from '@teambit/compiler';
2
2
  import { InstallMain } from '@teambit/install';
3
3
  import { Logger, LoggerMain } from '@teambit/logger';
4
4
  import { Workspace } from '@teambit/workspace';
5
+ import { MoverMain } from '@teambit/mover';
5
6
  import { ComponentWithDependencies } from '@teambit/legacy/dist/scope';
6
7
  import Consumer from '@teambit/legacy/dist/consumer/consumer';
7
8
  export interface ManyComponentsWriterParams {
@@ -21,7 +22,8 @@ export declare class ComponentWriterMain {
21
22
  private compiler;
22
23
  private workspace;
23
24
  private logger;
24
- constructor(installer: InstallMain, compiler: CompilerMain, workspace: Workspace, logger: Logger);
25
+ private mover;
26
+ constructor(installer: InstallMain, compiler: CompilerMain, workspace: Workspace, logger: Logger, mover: MoverMain);
25
27
  get consumer(): Consumer;
26
28
  writeMany(opts: ManyComponentsWriterParams): Promise<ComponentWriterResults>;
27
29
  private installPackagesGracefully;
@@ -40,11 +42,12 @@ export declare class ComponentWriterMain {
40
42
  static slots: never[];
41
43
  static dependencies: import("@teambit/harmony").Aspect[];
42
44
  static runtime: import("@teambit/harmony").RuntimeDefinition;
43
- static provider([install, compiler, loggerMain, workspace]: [
45
+ static provider([install, compiler, loggerMain, workspace, mover]: [
44
46
  InstallMain,
45
47
  CompilerMain,
46
48
  LoggerMain,
47
- Workspace
49
+ Workspace,
50
+ MoverMain
48
51
  ]): Promise<ComponentWriterMain>;
49
52
  }
50
53
  export default ComponentWriterMain;
@@ -77,6 +77,13 @@ function path() {
77
77
  };
78
78
  return data;
79
79
  }
80
+ function _mover() {
81
+ const data = _interopRequireDefault(require("@teambit/mover"));
82
+ _mover = function () {
83
+ return data;
84
+ };
85
+ return data;
86
+ }
80
87
  function _generalError() {
81
88
  const data = _interopRequireDefault(require("@teambit/legacy/dist/error/general-error"));
82
89
  _generalError = function () {
@@ -105,13 +112,6 @@ function _dataToPersist() {
105
112
  };
106
113
  return data;
107
114
  }
108
- function _moveComponents() {
109
- const data = require("@teambit/legacy/dist/consumer/component-ops/move-components");
110
- _moveComponents = function () {
111
- return data;
112
- };
113
- return data;
114
- }
115
115
  function _componentWriter() {
116
116
  const data = _interopRequireDefault(require("./component-writer"));
117
117
  _componentWriter = function () {
@@ -131,11 +131,12 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
131
131
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
132
132
  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; }
133
133
  class ComponentWriterMain {
134
- constructor(installer, compiler, workspace, logger) {
134
+ constructor(installer, compiler, workspace, logger, mover) {
135
135
  this.installer = installer;
136
136
  this.compiler = compiler;
137
137
  this.workspace = workspace;
138
138
  this.logger = logger;
139
+ this.mover = mover;
139
140
  }
140
141
  get consumer() {
141
142
  return this.workspace.consumer;
@@ -294,7 +295,7 @@ to move all component files to a different directory, run bit remove and then bi
294
295
  const absoluteWriteToPath = path().resolve(opts.writeToPath); // don't use consumer.toAbsolutePath, it might be an inner dir
295
296
  if (relativeWrittenPath && absoluteWrittenPath !== absoluteWriteToPath) {
296
297
  const component = componentWithDeps.component;
297
- (0, _moveComponents().moveExistingComponent)(this.consumer, component, absoluteWrittenPath, absoluteWriteToPath);
298
+ this.mover.moveExistingComponent(component, absoluteWrittenPath, absoluteWriteToPath);
298
299
  }
299
300
  });
300
301
  }
@@ -314,14 +315,14 @@ to move all component files to a different directory, run bit remove and then bi
314
315
  }
315
316
  }
316
317
  }
317
- static async provider([install, compiler, loggerMain, workspace]) {
318
+ static async provider([install, compiler, loggerMain, workspace, mover]) {
318
319
  const logger = loggerMain.createLogger(_componentWriter2().ComponentWriterAspect.id);
319
- return new ComponentWriterMain(install, compiler, workspace, logger);
320
+ return new ComponentWriterMain(install, compiler, workspace, logger, mover);
320
321
  }
321
322
  }
322
323
  exports.ComponentWriterMain = ComponentWriterMain;
323
324
  (0, _defineProperty2().default)(ComponentWriterMain, "slots", []);
324
- (0, _defineProperty2().default)(ComponentWriterMain, "dependencies", [_install().default, _compiler().CompilerAspect, _logger().LoggerAspect, _workspace().default]);
325
+ (0, _defineProperty2().default)(ComponentWriterMain, "dependencies", [_install().default, _compiler().CompilerAspect, _logger().LoggerAspect, _workspace().default, _mover().default]);
325
326
  (0, _defineProperty2().default)(ComponentWriterMain, "runtime", _cli().MainRuntime);
326
327
  _componentWriter2().ComponentWriterAspect.addRuntime(ComponentWriterMain);
327
328
  var _default = ComponentWriterMain;
@@ -1 +1 @@
1
- {"version":3,"names":["ComponentWriterMain","constructor","installer","compiler","workspace","logger","consumer","writeMany","opts","debug","populateComponentsFilesToWrite","moveComponentsIfNeeded","persistComponentsData","installationError","skipDependencyInstallation","installPackagesGracefully","compile","writeBitMap","installOpts","dedupe","updateExisting","import","install","undefined","err","consoleFailure","message","error","compileOnWorkspace","BitError","dataToPersist","DataToPersist","componentsWithDependencies","forEach","componentWithDeps","allComponents","component","allDependencies","merge","componentsConfig","config","hasChanged","jsonFiles","toVinyl","getPath","addManyFiles","addBasePath","persistAllToFS","writeComponentsParams","map","getWriteParamsOfOneComponent","componentWriterInstances","writeParams","ComponentWriter","fixDirsIfNested","componentWriter","existingComponentMap","addComponentToBitMap","writeToPath","resetConfig","mapSeries","allDirs","c","parentsOfOthersComps","filter","find","d","startsWith","length","parentsOfOthersCompsDirs","incrementPath","p","number","existingRootDirs","Object","keys","bitMap","getAllTrackDirs","allPaths","incrementRecursively","num","newPath","includes","componentRootDir","pathNormalizeToLinux","getPathRelativeToConsumer","path","resolve","composeRelativeComponentPath","id","getParams","componentMap","getComponentIfExist","ignoreVersion","throwErrorWhenDirectoryNotEmpty","toAbsolutePath","writeConfig","rootDir","GeneralError","relativeWrittenPath","writtenPath","absoluteWrittenPath","absoluteWriteToPath","moveExistingComponent","componentDir","fs","pathExistsSync","isDir","isDirEmptySync","throwForExistingDir","provider","loggerMain","createLogger","ComponentWriterAspect","InstallAspect","CompilerAspect","LoggerAspect","WorkspaceAspect","MainRuntime","addRuntime"],"sources":["component-writer.main.runtime.ts"],"sourcesContent":["import { MainRuntime } from '@teambit/cli';\nimport { CompilerAspect, CompilerMain } from '@teambit/compiler';\nimport InstallAspect, { InstallMain } from '@teambit/install';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport { BitError } from '@teambit/bit-error';\nimport fs from 'fs-extra';\nimport mapSeries from 'p-map-series';\nimport * as path from 'path';\nimport GeneralError from '@teambit/legacy/dist/error/general-error';\nimport { ComponentWithDependencies } from '@teambit/legacy/dist/scope';\nimport { isDir, isDirEmptySync } from '@teambit/legacy/dist/utils';\nimport { PathLinuxRelative, pathNormalizeToLinux, PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';\nimport ComponentMap from '@teambit/legacy/dist/consumer/bit-map/component-map';\nimport DataToPersist from '@teambit/legacy/dist/consumer/component/sources/data-to-persist';\nimport Consumer from '@teambit/legacy/dist/consumer/consumer';\nimport { moveExistingComponent } from '@teambit/legacy/dist/consumer/component-ops/move-components';\nimport ComponentWriter, { ComponentWriterProps } from './component-writer';\nimport { ComponentWriterAspect } from './component-writer.aspect';\n\nexport interface ManyComponentsWriterParams {\n componentsWithDependencies: ComponentWithDependencies[];\n writeToPath?: string;\n throwForExistingDir?: boolean;\n writeConfig?: boolean;\n skipDependencyInstallation?: boolean;\n verbose?: boolean;\n resetConfig?: boolean;\n}\n\nexport type ComponentWriterResults = { installationError?: Error };\n\nexport class ComponentWriterMain {\n constructor(\n private installer: InstallMain,\n private compiler: CompilerMain,\n private workspace: Workspace,\n private logger: Logger\n ) {}\n\n get consumer(): Consumer {\n return this.workspace.consumer;\n }\n\n async writeMany(opts: ManyComponentsWriterParams): Promise<ComponentWriterResults> {\n this.logger.debug('writeMany, started');\n await this.populateComponentsFilesToWrite(opts);\n this.moveComponentsIfNeeded(opts);\n await this.persistComponentsData(opts);\n let installationError: Error | undefined;\n if (!opts.skipDependencyInstallation) {\n installationError = await this.installPackagesGracefully();\n await this.compile(); // no point to compile if the installation is not running. the environment is not ready.\n }\n await this.consumer.writeBitMap();\n this.logger.debug('writeMany, completed!');\n return { installationError };\n }\n\n private async installPackagesGracefully() {\n this.logger.debug('installPackagesGracefully, start installing packages');\n try {\n const installOpts = {\n dedupe: true,\n updateExisting: false,\n import: false,\n };\n await this.installer.install(undefined, installOpts);\n this.logger.debug('installPackagesGracefully, completed installing packages successfully');\n return undefined;\n } catch (err: any) {\n this.logger.consoleFailure(`installation failed with the following error: ${err.message}`);\n this.logger.error('installPackagesGracefully, package-installer found an error', err);\n return err;\n }\n }\n private async compile() {\n try {\n await this.compiler.compileOnWorkspace();\n } catch (err: any) {\n this.logger.error('compile, compiler found an error', err);\n throw new BitError(`failed compiling the components. please run \"bit compile\" once the issue is fixed\nerror from the compiler: ${err.message}.\nplease use the '--log=error' flag for the full error.`);\n }\n }\n private async persistComponentsData(opts: ManyComponentsWriterParams) {\n const dataToPersist = new DataToPersist();\n opts.componentsWithDependencies.forEach((componentWithDeps) => {\n const allComponents = [componentWithDeps.component, ...componentWithDeps.allDependencies];\n allComponents.forEach((component) => dataToPersist.merge(component.dataToPersist));\n });\n const componentsConfig = this.consumer?.config?.componentsConfig;\n if (componentsConfig?.hasChanged) {\n const jsonFiles = await this.consumer?.config.toVinyl(this.consumer.getPath());\n if (jsonFiles) {\n dataToPersist.addManyFiles(jsonFiles);\n }\n }\n dataToPersist.addBasePath(this.consumer.getPath());\n await dataToPersist.persistAllToFS();\n }\n private async populateComponentsFilesToWrite(opts: ManyComponentsWriterParams) {\n const writeComponentsParams = opts.componentsWithDependencies.map((componentWithDeps: ComponentWithDependencies) =>\n this.getWriteParamsOfOneComponent(componentWithDeps, opts)\n );\n const componentWriterInstances = writeComponentsParams.map((writeParams) => new ComponentWriter(writeParams));\n this.fixDirsIfNested(componentWriterInstances);\n // add componentMap entries into .bitmap before starting the process because steps like writing package-json\n // rely on .bitmap to determine whether a dependency exists and what's its origin\n componentWriterInstances.forEach((componentWriter: ComponentWriter) => {\n componentWriter.existingComponentMap =\n componentWriter.existingComponentMap || componentWriter.addComponentToBitMap(componentWriter.writeToPath);\n });\n if (opts.resetConfig) {\n componentWriterInstances.forEach((componentWriter: ComponentWriter) => {\n delete componentWriter.existingComponentMap?.config;\n });\n }\n await mapSeries(componentWriterInstances, (componentWriter: ComponentWriter) =>\n componentWriter.populateComponentsFilesToWrite()\n );\n }\n /**\n * e.g. [bar, bar/foo] => [bar_1, bar/foo]\n * otherwise, the bar/foo component will be saved inside \"bar\" component.\n * in case bar_1 is taken, increment to bar_2 until the name is available.\n */\n private fixDirsIfNested(componentWriterInstances: ComponentWriter[]) {\n const allDirs = componentWriterInstances.map((c) => c.writeToPath);\n\n // get all components that their root-dir is a parent of other components root-dir.\n const parentsOfOthersComps = componentWriterInstances.filter(({ writeToPath }) =>\n allDirs.find((d) => d.startsWith(`${writeToPath}/`))\n );\n if (!parentsOfOthersComps.length) {\n return;\n }\n const parentsOfOthersCompsDirs = parentsOfOthersComps.map((c) => c.writeToPath);\n\n const incrementPath = (p: string, number: number) => `${p}_${number}`;\n const existingRootDirs = Object.keys(this.consumer.bitMap.getAllTrackDirs());\n const allPaths: PathLinuxRelative[] = [...existingRootDirs, ...parentsOfOthersCompsDirs];\n const incrementRecursively = (p: string) => {\n let num = 1;\n let newPath = incrementPath(p, num);\n while (allPaths.includes(newPath)) {\n newPath = incrementPath(p, (num += 1));\n }\n return newPath;\n };\n\n // change the paths of all these parents root-dir to not collide with the children root-dir\n parentsOfOthersComps.forEach((componentWriter) => {\n if (existingRootDirs.includes(componentWriter.writeToPath)) return; // component already exists.\n const newPath = incrementRecursively(componentWriter.writeToPath);\n componentWriter.writeToPath = newPath;\n });\n }\n\n private getWriteParamsOfOneComponent(\n componentWithDeps: ComponentWithDependencies,\n opts: ManyComponentsWriterParams\n ): ComponentWriterProps {\n const componentRootDir: PathLinuxRelative = opts.writeToPath\n ? pathNormalizeToLinux(this.consumer.getPathRelativeToConsumer(path.resolve(opts.writeToPath)))\n : this.consumer.composeRelativeComponentPath(componentWithDeps.component.id);\n const getParams = () => {\n if (!this.consumer) {\n return {};\n }\n // components can't be saved with multiple versions, so we can ignore the version to find the component in bit.map\n const componentMap = this.consumer.bitMap.getComponentIfExist(componentWithDeps.component.id, {\n ignoreVersion: true,\n });\n this.throwErrorWhenDirectoryNotEmpty(this.consumer.toAbsolutePath(componentRootDir), componentMap, opts);\n return {\n existingComponentMap: componentMap,\n };\n };\n return {\n consumer: this.consumer,\n bitMap: this.consumer.bitMap,\n component: componentWithDeps.component,\n writeToPath: componentRootDir,\n writeConfig: opts.writeConfig,\n ...getParams(),\n };\n }\n private moveComponentsIfNeeded(opts: ManyComponentsWriterParams) {\n if (opts.writeToPath && this.consumer) {\n opts.componentsWithDependencies.forEach((componentWithDeps) => {\n // @ts-ignore componentWithDeps.component.componentMap is set\n const componentMap: ComponentMap = componentWithDeps.component.componentMap;\n if (!componentMap.rootDir) {\n throw new GeneralError(`unable to use \"--path\" flag.\nto move individual files, use bit move.\nto move all component files to a different directory, run bit remove and then bit import --path`);\n }\n const relativeWrittenPath = componentWithDeps.component.writtenPath;\n // @ts-ignore relativeWrittenPath is set at this point\n const absoluteWrittenPath = this.consumer.toAbsolutePath(relativeWrittenPath);\n // @ts-ignore this.writeToPath is set at this point\n const absoluteWriteToPath = path.resolve(opts.writeToPath); // don't use consumer.toAbsolutePath, it might be an inner dir\n if (relativeWrittenPath && absoluteWrittenPath !== absoluteWriteToPath) {\n const component = componentWithDeps.component;\n moveExistingComponent(this.consumer, component, absoluteWrittenPath, absoluteWriteToPath);\n }\n });\n }\n }\n private throwErrorWhenDirectoryNotEmpty(\n componentDir: PathOsBasedAbsolute,\n componentMap: ComponentMap | null | undefined,\n opts: ManyComponentsWriterParams\n ) {\n // if not writeToPath specified, it goes to the default directory. When componentMap exists, the\n // component is not new, and it's ok to override the existing directory.\n if (!opts.writeToPath && componentMap) return;\n // if writeToPath specified and that directory is already used for that component, it's ok to override\n if (opts.writeToPath && componentMap && componentMap.rootDir && componentMap.rootDir === opts.writeToPath) return;\n\n if (fs.pathExistsSync(componentDir)) {\n if (!isDir(componentDir)) {\n throw new GeneralError(`unable to import to ${componentDir} because it's a file`);\n }\n if (!isDirEmptySync(componentDir) && opts.throwForExistingDir) {\n throw new GeneralError(\n `unable to import to ${componentDir}, the directory is not empty. use --override flag to delete the directory and then import`\n );\n }\n }\n }\n\n static slots = [];\n static dependencies = [InstallAspect, CompilerAspect, LoggerAspect, WorkspaceAspect];\n static runtime = MainRuntime;\n static async provider([install, compiler, loggerMain, workspace]: [\n InstallMain,\n CompilerMain,\n LoggerMain,\n Workspace\n ]) {\n const logger = loggerMain.createLogger(ComponentWriterAspect.id);\n return new ComponentWriterMain(install, compiler, workspace, logger);\n }\n}\n\nComponentWriterAspect.addRuntime(ComponentWriterMain);\n\nexport default ComponentWriterMain;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EA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AAO,IAAIN,YAAY,CAACM,OAAO,KAAKzF,IAAI,CAACkD,WAAW,EAAE;IAE3G,IAAI+C,kBAAE,CAACC,cAAc,CAACF,YAAY,CAAC,EAAE;MACnC,IAAI,CAAC,IAAAG,cAAK,EAACH,YAAY,CAAC,EAAE;QACxB,MAAM,KAAIN,uBAAY,EAAE,uBAAsBM,YAAa,sBAAqB,CAAC;MACnF;MACA,IAAI,CAAC,IAAAI,uBAAc,EAACJ,YAAY,CAAC,IAAIhG,IAAI,CAACqG,mBAAmB,EAAE;QAC7D,MAAM,KAAIX,uBAAY,EACnB,uBAAsBM,YAAa,2FAA0F,CAC/H;MACH;IACF;EACF;EAKA,aAAaM,QAAQ,CAAC,CAACxF,OAAO,EAAEnB,QAAQ,EAAE4G,UAAU,EAAE3G,SAAS,CAK9D,EAAE;IACD,MAAMC,MAAM,GAAG0G,UAAU,CAACC,YAAY,CAACC,yCAAqB,CAACxB,EAAE,CAAC;IAChE,OAAO,IAAIzF,mBAAmB,CAACsB,OAAO,EAAEnB,QAAQ,EAAEC,SAAS,EAAEC,MAAM,CAAC;EACtE;AACF;AAAC;AAAA,gCAtNYL,mBAAmB,WA0Mf,EAAE;AAAA,gCA1MNA,mBAAmB,kBA2MR,CAACkH,kBAAa,EAAEC,0BAAc,EAAEC,sBAAY,EAAEC,oBAAe,CAAC;AAAA,gCA3MzErH,mBAAmB,aA4MbsH,kBAAW;AAY9BL,yCAAqB,CAACM,UAAU,CAACvH,mBAAmB,CAAC;AAAC,eAEvCA,mBAAmB;AAAA"}
1
+ {"version":3,"names":["ComponentWriterMain","constructor","installer","compiler","workspace","logger","mover","consumer","writeMany","opts","debug","populateComponentsFilesToWrite","moveComponentsIfNeeded","persistComponentsData","installationError","skipDependencyInstallation","installPackagesGracefully","compile","writeBitMap","installOpts","dedupe","updateExisting","import","install","undefined","err","consoleFailure","message","error","compileOnWorkspace","BitError","dataToPersist","DataToPersist","componentsWithDependencies","forEach","componentWithDeps","allComponents","component","allDependencies","merge","componentsConfig","config","hasChanged","jsonFiles","toVinyl","getPath","addManyFiles","addBasePath","persistAllToFS","writeComponentsParams","map","getWriteParamsOfOneComponent","componentWriterInstances","writeParams","ComponentWriter","fixDirsIfNested","componentWriter","existingComponentMap","addComponentToBitMap","writeToPath","resetConfig","mapSeries","allDirs","c","parentsOfOthersComps","filter","find","d","startsWith","length","parentsOfOthersCompsDirs","incrementPath","p","number","existingRootDirs","Object","keys","bitMap","getAllTrackDirs","allPaths","incrementRecursively","num","newPath","includes","componentRootDir","pathNormalizeToLinux","getPathRelativeToConsumer","path","resolve","composeRelativeComponentPath","id","getParams","componentMap","getComponentIfExist","ignoreVersion","throwErrorWhenDirectoryNotEmpty","toAbsolutePath","writeConfig","rootDir","GeneralError","relativeWrittenPath","writtenPath","absoluteWrittenPath","absoluteWriteToPath","moveExistingComponent","componentDir","fs","pathExistsSync","isDir","isDirEmptySync","throwForExistingDir","provider","loggerMain","createLogger","ComponentWriterAspect","InstallAspect","CompilerAspect","LoggerAspect","WorkspaceAspect","MoverAspect","MainRuntime","addRuntime"],"sources":["component-writer.main.runtime.ts"],"sourcesContent":["import { MainRuntime } from '@teambit/cli';\nimport { CompilerAspect, CompilerMain } from '@teambit/compiler';\nimport InstallAspect, { InstallMain } from '@teambit/install';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport { BitError } from '@teambit/bit-error';\nimport fs from 'fs-extra';\nimport mapSeries from 'p-map-series';\nimport * as path from 'path';\nimport MoverAspect, { MoverMain } from '@teambit/mover';\nimport GeneralError from '@teambit/legacy/dist/error/general-error';\nimport { ComponentWithDependencies } from '@teambit/legacy/dist/scope';\nimport { isDir, isDirEmptySync } from '@teambit/legacy/dist/utils';\nimport { PathLinuxRelative, pathNormalizeToLinux, PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';\nimport ComponentMap from '@teambit/legacy/dist/consumer/bit-map/component-map';\nimport DataToPersist from '@teambit/legacy/dist/consumer/component/sources/data-to-persist';\nimport Consumer from '@teambit/legacy/dist/consumer/consumer';\nimport ComponentWriter, { ComponentWriterProps } from './component-writer';\nimport { ComponentWriterAspect } from './component-writer.aspect';\n\nexport interface ManyComponentsWriterParams {\n componentsWithDependencies: ComponentWithDependencies[];\n writeToPath?: string;\n throwForExistingDir?: boolean;\n writeConfig?: boolean;\n skipDependencyInstallation?: boolean;\n verbose?: boolean;\n resetConfig?: boolean;\n}\n\nexport type ComponentWriterResults = { installationError?: Error };\n\nexport class ComponentWriterMain {\n constructor(\n private installer: InstallMain,\n private compiler: CompilerMain,\n private workspace: Workspace,\n private logger: Logger,\n private mover: MoverMain\n ) {}\n\n get consumer(): Consumer {\n return this.workspace.consumer;\n }\n\n async writeMany(opts: ManyComponentsWriterParams): Promise<ComponentWriterResults> {\n this.logger.debug('writeMany, started');\n await this.populateComponentsFilesToWrite(opts);\n this.moveComponentsIfNeeded(opts);\n await this.persistComponentsData(opts);\n let installationError: Error | undefined;\n if (!opts.skipDependencyInstallation) {\n installationError = await this.installPackagesGracefully();\n await this.compile(); // no point to compile if the installation is not running. the environment is not ready.\n }\n await this.consumer.writeBitMap();\n this.logger.debug('writeMany, completed!');\n return { installationError };\n }\n\n private async installPackagesGracefully() {\n this.logger.debug('installPackagesGracefully, start installing packages');\n try {\n const installOpts = {\n dedupe: true,\n updateExisting: false,\n import: false,\n };\n await this.installer.install(undefined, installOpts);\n this.logger.debug('installPackagesGracefully, completed installing packages successfully');\n return undefined;\n } catch (err: any) {\n this.logger.consoleFailure(`installation failed with the following error: ${err.message}`);\n this.logger.error('installPackagesGracefully, package-installer found an error', err);\n return err;\n }\n }\n private async compile() {\n try {\n await this.compiler.compileOnWorkspace();\n } catch (err: any) {\n this.logger.error('compile, compiler found an error', err);\n throw new BitError(`failed compiling the components. please run \"bit compile\" once the issue is fixed\nerror from the compiler: ${err.message}.\nplease use the '--log=error' flag for the full error.`);\n }\n }\n private async persistComponentsData(opts: ManyComponentsWriterParams) {\n const dataToPersist = new DataToPersist();\n opts.componentsWithDependencies.forEach((componentWithDeps) => {\n const allComponents = [componentWithDeps.component, ...componentWithDeps.allDependencies];\n allComponents.forEach((component) => dataToPersist.merge(component.dataToPersist));\n });\n const componentsConfig = this.consumer?.config?.componentsConfig;\n if (componentsConfig?.hasChanged) {\n const jsonFiles = await this.consumer?.config.toVinyl(this.consumer.getPath());\n if (jsonFiles) {\n dataToPersist.addManyFiles(jsonFiles);\n }\n }\n dataToPersist.addBasePath(this.consumer.getPath());\n await dataToPersist.persistAllToFS();\n }\n private async populateComponentsFilesToWrite(opts: ManyComponentsWriterParams) {\n const writeComponentsParams = opts.componentsWithDependencies.map((componentWithDeps: ComponentWithDependencies) =>\n this.getWriteParamsOfOneComponent(componentWithDeps, opts)\n );\n const componentWriterInstances = writeComponentsParams.map((writeParams) => new ComponentWriter(writeParams));\n this.fixDirsIfNested(componentWriterInstances);\n // add componentMap entries into .bitmap before starting the process because steps like writing package-json\n // rely on .bitmap to determine whether a dependency exists and what's its origin\n componentWriterInstances.forEach((componentWriter: ComponentWriter) => {\n componentWriter.existingComponentMap =\n componentWriter.existingComponentMap || componentWriter.addComponentToBitMap(componentWriter.writeToPath);\n });\n if (opts.resetConfig) {\n componentWriterInstances.forEach((componentWriter: ComponentWriter) => {\n delete componentWriter.existingComponentMap?.config;\n });\n }\n await mapSeries(componentWriterInstances, (componentWriter: ComponentWriter) =>\n componentWriter.populateComponentsFilesToWrite()\n );\n }\n /**\n * e.g. [bar, bar/foo] => [bar_1, bar/foo]\n * otherwise, the bar/foo component will be saved inside \"bar\" component.\n * in case bar_1 is taken, increment to bar_2 until the name is available.\n */\n private fixDirsIfNested(componentWriterInstances: ComponentWriter[]) {\n const allDirs = componentWriterInstances.map((c) => c.writeToPath);\n\n // get all components that their root-dir is a parent of other components root-dir.\n const parentsOfOthersComps = componentWriterInstances.filter(({ writeToPath }) =>\n allDirs.find((d) => d.startsWith(`${writeToPath}/`))\n );\n if (!parentsOfOthersComps.length) {\n return;\n }\n const parentsOfOthersCompsDirs = parentsOfOthersComps.map((c) => c.writeToPath);\n\n const incrementPath = (p: string, number: number) => `${p}_${number}`;\n const existingRootDirs = Object.keys(this.consumer.bitMap.getAllTrackDirs());\n const allPaths: PathLinuxRelative[] = [...existingRootDirs, ...parentsOfOthersCompsDirs];\n const incrementRecursively = (p: string) => {\n let num = 1;\n let newPath = incrementPath(p, num);\n while (allPaths.includes(newPath)) {\n newPath = incrementPath(p, (num += 1));\n }\n return newPath;\n };\n\n // change the paths of all these parents root-dir to not collide with the children root-dir\n parentsOfOthersComps.forEach((componentWriter) => {\n if (existingRootDirs.includes(componentWriter.writeToPath)) return; // component already exists.\n const newPath = incrementRecursively(componentWriter.writeToPath);\n componentWriter.writeToPath = newPath;\n });\n }\n\n private getWriteParamsOfOneComponent(\n componentWithDeps: ComponentWithDependencies,\n opts: ManyComponentsWriterParams\n ): ComponentWriterProps {\n const componentRootDir: PathLinuxRelative = opts.writeToPath\n ? pathNormalizeToLinux(this.consumer.getPathRelativeToConsumer(path.resolve(opts.writeToPath)))\n : this.consumer.composeRelativeComponentPath(componentWithDeps.component.id);\n const getParams = () => {\n if (!this.consumer) {\n return {};\n }\n // components can't be saved with multiple versions, so we can ignore the version to find the component in bit.map\n const componentMap = this.consumer.bitMap.getComponentIfExist(componentWithDeps.component.id, {\n ignoreVersion: true,\n });\n this.throwErrorWhenDirectoryNotEmpty(this.consumer.toAbsolutePath(componentRootDir), componentMap, opts);\n return {\n existingComponentMap: componentMap,\n };\n };\n return {\n consumer: this.consumer,\n bitMap: this.consumer.bitMap,\n component: componentWithDeps.component,\n writeToPath: componentRootDir,\n writeConfig: opts.writeConfig,\n ...getParams(),\n };\n }\n private moveComponentsIfNeeded(opts: ManyComponentsWriterParams) {\n if (opts.writeToPath && this.consumer) {\n opts.componentsWithDependencies.forEach((componentWithDeps) => {\n // @ts-ignore componentWithDeps.component.componentMap is set\n const componentMap: ComponentMap = componentWithDeps.component.componentMap;\n if (!componentMap.rootDir) {\n throw new GeneralError(`unable to use \"--path\" flag.\nto move individual files, use bit move.\nto move all component files to a different directory, run bit remove and then bit import --path`);\n }\n const relativeWrittenPath = componentWithDeps.component.writtenPath;\n // @ts-ignore relativeWrittenPath is set at this point\n const absoluteWrittenPath = this.consumer.toAbsolutePath(relativeWrittenPath);\n // @ts-ignore this.writeToPath is set at this point\n const absoluteWriteToPath = path.resolve(opts.writeToPath); // don't use consumer.toAbsolutePath, it might be an inner dir\n if (relativeWrittenPath && absoluteWrittenPath !== absoluteWriteToPath) {\n const component = componentWithDeps.component;\n this.mover.moveExistingComponent(component, absoluteWrittenPath, absoluteWriteToPath);\n }\n });\n }\n }\n private throwErrorWhenDirectoryNotEmpty(\n componentDir: PathOsBasedAbsolute,\n componentMap: ComponentMap | null | undefined,\n opts: ManyComponentsWriterParams\n ) {\n // if not writeToPath specified, it goes to the default directory. When componentMap exists, the\n // component is not new, and it's ok to override the existing directory.\n if (!opts.writeToPath && componentMap) return;\n // if writeToPath specified and that directory is already used for that component, it's ok to override\n if (opts.writeToPath && componentMap && componentMap.rootDir && componentMap.rootDir === opts.writeToPath) return;\n\n if (fs.pathExistsSync(componentDir)) {\n if (!isDir(componentDir)) {\n throw new GeneralError(`unable to import to ${componentDir} because it's a file`);\n }\n if (!isDirEmptySync(componentDir) && opts.throwForExistingDir) {\n throw new GeneralError(\n `unable to import to ${componentDir}, the directory is not empty. use --override flag to delete the directory and then import`\n );\n }\n }\n }\n\n static slots = [];\n static dependencies = [InstallAspect, CompilerAspect, LoggerAspect, WorkspaceAspect, MoverAspect];\n static runtime = MainRuntime;\n static async provider([install, compiler, loggerMain, workspace, mover]: [\n InstallMain,\n CompilerMain,\n LoggerMain,\n Workspace,\n MoverMain\n ]) {\n const logger = loggerMain.createLogger(ComponentWriterAspect.id);\n return new ComponentWriterMain(install, compiler, workspace, logger, mover);\n }\n}\n\nComponentWriterAspect.addRuntime(ComponentWriterMain);\n\nexport default ComponentWriterMain;\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AAC,eAEvCA,mBAAmB;AAAA"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/component-writer",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "homepage": "https://bit.dev/teambit/component/component-writer",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.component",
8
8
  "name": "component-writer",
9
- "version": "0.0.5"
9
+ "version": "0.0.7"
10
10
  },
11
11
  "dependencies": {
12
12
  "fs-extra": "10.0.0",
@@ -15,11 +15,12 @@
15
15
  "@babel/runtime": "7.20.0",
16
16
  "@teambit/harmony": "0.4.6",
17
17
  "@teambit/bit-error": "0.0.402",
18
- "@teambit/cli": "0.0.649",
19
- "@teambit/compiler": "0.0.969",
20
- "@teambit/install": "0.0.96",
21
- "@teambit/logger": "0.0.742",
22
- "@teambit/workspace": "0.0.969"
18
+ "@teambit/cli": "0.0.651",
19
+ "@teambit/compiler": "0.0.971",
20
+ "@teambit/install": "0.0.98",
21
+ "@teambit/logger": "0.0.744",
22
+ "@teambit/mover": "0.0.2",
23
+ "@teambit/workspace": "0.0.971"
23
24
  },
24
25
  "devDependencies": {
25
26
  "@types/fs-extra": "9.0.7",
@@ -31,7 +32,7 @@
31
32
  "@types/testing-library__jest-dom": "5.9.5"
32
33
  },
33
34
  "peerDependencies": {
34
- "@teambit/legacy": "1.0.430",
35
+ "@teambit/legacy": "1.0.433",
35
36
  "react": "^16.8.0 || ^17.0.0",
36
37
  "react-dom": "^16.8.0 || ^17.0.0"
37
38
  },