@teambit/component-writer 0.0.3 → 0.0.4

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.
@@ -13,6 +13,9 @@ export interface ManyComponentsWriterParams {
13
13
  verbose?: boolean;
14
14
  resetConfig?: boolean;
15
15
  }
16
+ export declare type ComponentWriterResults = {
17
+ installationError?: Error;
18
+ };
16
19
  export declare class ComponentWriterMain {
17
20
  private installer;
18
21
  private compiler;
@@ -20,8 +23,8 @@ export declare class ComponentWriterMain {
20
23
  private logger;
21
24
  constructor(installer: InstallMain, compiler: CompilerMain, workspace: Workspace, logger: Logger);
22
25
  get consumer(): Consumer;
23
- writeMany(opts: ManyComponentsWriterParams): Promise<void>;
24
- private installPackages;
26
+ writeMany(opts: ManyComponentsWriterParams): Promise<ComponentWriterResults>;
27
+ private installPackagesGracefully;
25
28
  private compile;
26
29
  private persistComponentsData;
27
30
  private populateComponentsFilesToWrite;
@@ -145,16 +145,20 @@ class ComponentWriterMain {
145
145
  await this.populateComponentsFilesToWrite(opts);
146
146
  this.moveComponentsIfNeeded(opts);
147
147
  await this.persistComponentsData(opts);
148
+ let installationError;
148
149
  if (!opts.skipDependencyInstallation) {
149
- await this.installPackages();
150
+ installationError = await this.installPackagesGracefully();
150
151
  await this.compile(); // no point to compile if the installation is not running. the environment is not ready.
151
152
  }
152
153
 
153
154
  await this.consumer.writeBitMap();
154
155
  this.logger.debug('writeMany, completed!');
156
+ return {
157
+ installationError
158
+ };
155
159
  }
156
- async installPackages() {
157
- this.logger.debug('ManyComponentsWriter, _installPackages');
160
+ async installPackagesGracefully() {
161
+ this.logger.debug('installPackagesGracefully, start installing packages');
158
162
  try {
159
163
  const installOpts = {
160
164
  dedupe: true,
@@ -162,11 +166,12 @@ class ComponentWriterMain {
162
166
  import: false
163
167
  };
164
168
  await this.installer.install(undefined, installOpts);
169
+ this.logger.debug('installPackagesGracefully, completed installing packages successfully');
170
+ return undefined;
165
171
  } catch (err) {
166
- this.logger.error('_installPackagesIfNeeded, package-installer found an error', err);
167
- throw new (_bitError().BitError)(`failed installing the packages, consider running the command with "--skip-dependency-installation" flag.
168
- error from the package-manager: ${err.message}.
169
- please use the '--log=error' flag for the full error.`);
172
+ this.logger.consoleFailure(`installation failed with the following error: ${err.message}`);
173
+ this.logger.error('installPackagesGracefully, package-installer found an error', err);
174
+ return err;
170
175
  }
171
176
  }
172
177
  async compile() {
@@ -1 +1 @@
1
- {"version":3,"names":["ComponentWriterMain","constructor","installer","compiler","workspace","logger","consumer","writeMany","opts","debug","populateComponentsFilesToWrite","moveComponentsIfNeeded","persistComponentsData","skipDependencyInstallation","installPackages","compile","writeBitMap","installOpts","dedupe","updateExisting","import","install","undefined","err","error","BitError","message","compileOnWorkspace","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 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) {\n this.logger.debug('writeMany, started');\n await this.populateComponentsFilesToWrite(opts);\n this.moveComponentsIfNeeded(opts);\n await this.persistComponentsData(opts);\n if (!opts.skipDependencyInstallation) {\n await this.installPackages();\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 }\n\n private async installPackages() {\n this.logger.debug('ManyComponentsWriter, _installPackages');\n try {\n const installOpts = {\n dedupe: true,\n updateExisting: false,\n import: false,\n };\n await this.installer.install(undefined, installOpts);\n } catch (err: any) {\n this.logger.error('_installPackagesIfNeeded, package-installer found an error', err);\n throw new BitError(`failed installing the packages, consider running the command with \"--skip-dependency-installation\" flag.\nerror from the package-manager: ${err.message}.\nplease use the '--log=error' flag for the full error.`);\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;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;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAkE;AAAA;AAAA;AAAA;AAY3D,MAAMA,mBAAmB,CAAC;EAC/BC,WAAW,CACDC,SAAsB,EACtBC,QAAsB,EACtBC,SAAoB,EACpBC,MA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mBAAmB,kBAwMR,CAACgH,kBAAa,EAAEC,0BAAc,EAAEC,sBAAY,EAAEC,oBAAe,CAAC;AAAA,gCAxMzEnH,mBAAmB,aAyMboH,kBAAW;AAY9BL,yCAAqB,CAACM,UAAU,CAACrH,mBAAmB,CAAC;AAAC,eAEvCA,mBAAmB;AAAA"}
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;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;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAkE;AAAA;AAAA;AAAA;AAc3D,MAAMA,mBAAmB,CAAC;EAC/BC,WAAW,CACDC,SAAsB,EACtBC,QAAsB,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,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"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { ComponentWriterAspect } from './component-writer.aspect';
2
- export type { ComponentWriterMain } from './component-writer.main.runtime';
2
+ export type { ComponentWriterMain, ComponentWriterResults } from './component-writer.main.runtime';
3
3
  export default ComponentWriterAspect;
4
4
  export { ComponentWriterAspect };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["ComponentWriterAspect"],"sources":["index.ts"],"sourcesContent":["import { ComponentWriterAspect } from './component-writer.aspect';\n\nexport type { ComponentWriterMain } from './component-writer.main.runtime';\nexport default ComponentWriterAspect;\nexport { ComponentWriterAspect };\n"],"mappings":";;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAkE,eAGnDA,wCAAqB;AAAA"}
1
+ {"version":3,"names":["ComponentWriterAspect"],"sources":["index.ts"],"sourcesContent":["import { ComponentWriterAspect } from './component-writer.aspect';\n\nexport type { ComponentWriterMain, ComponentWriterResults } from './component-writer.main.runtime';\nexport default ComponentWriterAspect;\nexport { ComponentWriterAspect };\n"],"mappings":";;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAkE,eAGnDA,wCAAqB;AAAA"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/component-writer",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
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.3"
9
+ "version": "0.0.4"
10
10
  },
11
11
  "dependencies": {
12
12
  "fs-extra": "10.0.0",
@@ -16,10 +16,10 @@
16
16
  "@teambit/harmony": "0.4.6",
17
17
  "@teambit/bit-error": "0.0.402",
18
18
  "@teambit/cli": "0.0.649",
19
- "@teambit/compiler": "0.0.967",
19
+ "@teambit/compiler": "0.0.968",
20
20
  "@teambit/install": "0.0.96",
21
21
  "@teambit/logger": "0.0.742",
22
- "@teambit/workspace": "0.0.967"
22
+ "@teambit/workspace": "0.0.968"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/fs-extra": "9.0.7",