@teambit/component-writer 1.0.1047 → 1.0.1049

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.
@@ -11,6 +11,7 @@ export interface ManyComponentsWriterParams {
11
11
  components: ConsumerComponent[];
12
12
  writeToPath?: string;
13
13
  throwForExistingDir?: boolean;
14
+ writeToEmptyDir?: boolean;
14
15
  writeConfig?: boolean;
15
16
  skipDependencyInstallation?: boolean;
16
17
  verbose?: boolean;
@@ -68,7 +69,28 @@ export declare class ComponentWriterMain {
68
69
  private fixDirsIfNested;
69
70
  private getWriteParamsOfOneComponent;
70
71
  private moveComponentsIfNeeded;
72
+ /**
73
+ * true when the directory-conflict check can be skipped: either nothing is written to the filesystem, or the
74
+ * target directory already belongs to this exact component (so overriding it in place is safe).
75
+ */
76
+ private shouldSkipDirConflictCheck;
71
77
  private throwErrorWhenDirectoryNotEmpty;
78
+ /**
79
+ * final `writeToPath` resolution for the `--write-to-empty-dir` import flag, mainly for non-interactive clients
80
+ * (such as the IDE) that can't prompt for `--override`. runs after fixDirsIfEqual()/fixDirsIfNested() - which may
81
+ * still move dirs using string-only collision checks - so the flag's guarantee holds against the final paths:
82
+ * every relocated component lands in a directory that is empty (or non-existent) and unclaimed in .bitmap.
83
+ * when a target is occupied (by foreign files, or a dir/rootDir owned by another component), it's relocated by
84
+ * suffixing "_N" (e.g. "renderers/class" => "renderers/class_1"). a dir already owned by this component is left
85
+ * as-is (its files are overridden, same as the default import behavior).
86
+ */
87
+ private relocateOccupiedDirs;
88
+ /**
89
+ * returns a human-readable reason why the given directory can't be used for import, or undefined when it's
90
+ * available. a directory is available when it doesn't exist yet, or it's an empty directory that is not already
91
+ * used by another component in the .bitmap file.
92
+ */
93
+ private getDirUnavailableReason;
72
94
  static slots: never[];
73
95
  static dependencies: import("@teambit/harmony").Aspect[];
74
96
  static runtime: import("@teambit/harmony").RuntimeDefinition;
@@ -126,8 +126,6 @@ function _componentWriter2() {
126
126
  }
127
127
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
128
128
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
129
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
130
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
131
129
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
132
130
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
133
131
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
@@ -235,6 +233,8 @@ class ComponentWriterMain {
235
233
  const componentWriterInstances = writeComponentsParams.map(writeParams => new (_componentWriter().default)(writeParams));
236
234
  this.fixDirsIfEqual(componentWriterInstances);
237
235
  this.fixDirsIfNested(componentWriterInstances);
236
+ // must run after the fixDirs* passes above, which may still move writeToPath onto an occupied dir.
237
+ this.relocateOccupiedDirs(componentWriterInstances, opts);
238
238
  // add componentMap entries into .bitmap before starting the process because steps like writing package-json
239
239
  // rely on .bitmap to determine whether a dependency exists and what's its origin
240
240
  await Promise.all(componentWriterInstances.map(async componentWriter => {
@@ -324,27 +324,24 @@ class ComponentWriterMain {
324
324
  }
325
325
  getWriteParamsOfOneComponent(component, opts) {
326
326
  const componentRootDir = opts.writeToPath ? (0, _legacy().pathNormalizeToLinux)(this.consumer.getPathRelativeToConsumer(path().resolve(opts.writeToPath))) : this.consumer.composeRelativeComponentPath(component.id);
327
- const getParams = () => {
328
- if (!this.consumer) {
329
- return {};
330
- }
331
- // components can't be saved with multiple versions, so we can ignore the version to find the component in bit.map
332
- const componentMap = this.consumer.bitMap.getComponentIfExist(component.id, {
333
- ignoreVersion: true
334
- });
335
- this.throwErrorWhenDirectoryNotEmpty(componentRootDir, componentMap, opts);
336
- return {
337
- existingComponentMap: componentMap
338
- };
339
- };
340
- return _objectSpread({
327
+ // components can't be saved with multiple versions, so we can ignore the version to find the component in bit.map
328
+ const existingComponentMap = this.consumer?.bitMap.getComponentIfExist(component.id, {
329
+ ignoreVersion: true
330
+ });
331
+ // with --write-to-empty-dir, dir-conflict resolution is deferred to relocateOccupiedDirs() so it runs after the
332
+ // fixDirs* passes (which may still adjust writeToPath); otherwise fail here when the target dir is occupied.
333
+ if (this.consumer && !opts.writeToEmptyDir) {
334
+ this.throwErrorWhenDirectoryNotEmpty(componentRootDir, existingComponentMap, opts);
335
+ }
336
+ return {
341
337
  workspace: this.workspace,
342
338
  bitMap: this.consumer.bitMap,
343
339
  component,
344
340
  writeToPath: componentRootDir,
345
341
  writeConfig: opts.writeConfig,
346
- skipUpdatingBitMap: opts.skipUpdatingBitMap
347
- }, getParams());
342
+ skipUpdatingBitMap: opts.skipUpdatingBitMap,
343
+ existingComponentMap: existingComponentMap ?? undefined
344
+ };
348
345
  }
349
346
  moveComponentsIfNeeded(opts) {
350
347
  if (opts.writeToPath && this.consumer) {
@@ -366,13 +363,21 @@ to move all component files to a different directory, run bit remove and then bi
366
363
  });
367
364
  }
368
365
  }
366
+ /**
367
+ * true when the directory-conflict check can be skipped: either nothing is written to the filesystem, or the
368
+ * target directory already belongs to this exact component (so overriding it in place is safe).
369
+ */
370
+ shouldSkipDirConflictCheck(componentDirRelative, componentMap, opts) {
371
+ if (opts.skipWritingToFs) return true;
372
+ if (!componentMap) return false;
373
+ // no writeToPath: it goes to the default directory. an existing componentMap means the component is not new.
374
+ if (!opts.writeToPath) return true;
375
+ // writeToPath specified and that directory is already used for that component. compare against the
376
+ // normalized componentDirRelative (not the raw opts.writeToPath, which may be absolute/OS-specific).
377
+ return componentMap.rootDir === componentDirRelative;
378
+ }
369
379
  throwErrorWhenDirectoryNotEmpty(componentDirRelative, componentMap, opts) {
370
- if (opts.skipWritingToFs) return;
371
- // if not writeToPath specified, it goes to the default directory. When componentMap exists, the
372
- // component is not new, and it's ok to override the existing directory.
373
- if (!opts.writeToPath && componentMap) return;
374
- // if writeToPath specified and that directory is already used for that component, it's ok to override
375
- if (opts.writeToPath && componentMap && componentMap.rootDir && componentMap.rootDir === opts.writeToPath) return;
380
+ if (this.shouldSkipDirConflictCheck(componentDirRelative, componentMap, opts)) return;
376
381
  const componentDir = this.consumer.toAbsolutePath(componentDirRelative);
377
382
  if (!_fsExtra().default.pathExistsSync(componentDir)) return;
378
383
  if (!componentMap) {
@@ -389,6 +394,57 @@ either use --path to specify a different directory or modify "defaultDirectory"
389
394
  throw new (_bitError().BitError)(`unable to import to ${componentDir}, the directory is not empty. use --override flag to delete the directory and then import`);
390
395
  }
391
396
  }
397
+
398
+ /**
399
+ * final `writeToPath` resolution for the `--write-to-empty-dir` import flag, mainly for non-interactive clients
400
+ * (such as the IDE) that can't prompt for `--override`. runs after fixDirsIfEqual()/fixDirsIfNested() - which may
401
+ * still move dirs using string-only collision checks - so the flag's guarantee holds against the final paths:
402
+ * every relocated component lands in a directory that is empty (or non-existent) and unclaimed in .bitmap.
403
+ * when a target is occupied (by foreign files, or a dir/rootDir owned by another component), it's relocated by
404
+ * suffixing "_N" (e.g. "renderers/class" => "renderers/class_1"). a dir already owned by this component is left
405
+ * as-is (its files are overridden, same as the default import behavior).
406
+ */
407
+ relocateOccupiedDirs(componentWriterInstances, opts) {
408
+ if (!opts.writeToEmptyDir) return;
409
+ // track dirs already claimed in .bitmap and by other components in this batch, so two relocations never collide.
410
+ const takenDirs = new Set([...this.workspace.bitMap.getAllRootDirs(), ...componentWriterInstances.map(componentWriter => componentWriter.writeToPath)]);
411
+ componentWriterInstances.forEach(componentWriter => {
412
+ const currentDir = componentWriter.writeToPath;
413
+ const componentMap = componentWriter.existingComponentMap;
414
+ if (this.shouldSkipDirConflictCheck(currentDir, componentMap, opts)) return;
415
+ const unavailableReason = this.getDirUnavailableReason(currentDir, componentMap);
416
+ if (!unavailableReason) return;
417
+ let num = 1;
418
+ let candidate = `${currentDir}_${num}`;
419
+ while (takenDirs.has(candidate) || this.getDirUnavailableReason(candidate, componentMap)) {
420
+ num += 1;
421
+ candidate = `${currentDir}_${num}`;
422
+ }
423
+ this.logger.consoleWarning(`unable to import into "${currentDir}" (${unavailableReason}), importing into "${candidate}" instead`);
424
+ componentWriter.writeToPath = candidate;
425
+ takenDirs.add(candidate);
426
+ });
427
+ }
428
+
429
+ /**
430
+ * returns a human-readable reason why the given directory can't be used for import, or undefined when it's
431
+ * available. a directory is available when it doesn't exist yet, or it's an empty directory that is not already
432
+ * used by another component in the .bitmap file.
433
+ */
434
+ getDirUnavailableReason(componentDirRelative, componentMap) {
435
+ // a rootDir may be claimed in .bitmap even when its directory was deleted from the filesystem, so check
436
+ // .bitmap ownership regardless of whether the directory currently exists on disk. it's only ok to reuse the
437
+ // rootDir when it's claimed by the same component we're importing (comparing without version).
438
+ const usedByComponent = this.consumer.bitMap.getComponentIdByRootPath(componentDirRelative);
439
+ if (usedByComponent && !(componentMap && usedByComponent.isEqualWithoutVersion(componentMap.id))) {
440
+ return `it is already used by ${usedByComponent.toString()}`;
441
+ }
442
+ const componentDir = this.consumer.toAbsolutePath(componentDirRelative);
443
+ if (!_fsExtra().default.pathExistsSync(componentDir)) return undefined;
444
+ if (!(0, _legacy().isDir)(componentDir)) return 'it is a file';
445
+ if (!(0, _legacy().isDirEmptySync)(componentDir)) return 'the directory is not empty';
446
+ return undefined;
447
+ }
392
448
  static async provider([install, compiler, loggerMain, workspace, mover, configMerger]) {
393
449
  const logger = loggerMain.createLogger(_componentWriter2().ComponentWriterAspect.id);
394
450
  return new ComponentWriterMain(install, compiler, workspace, logger, mover, configMerger);
@@ -1 +1 @@
1
- {"version":3,"names":["_cli","data","require","_compiler","_install","_logger","_workspace","_bitError","_fsExtra","_interopRequireDefault","_lodash","_pMapSeries","path","_interopRequireWildcard","_mover","_legacy","_legacy2","_component","_configMerger","_componentWriter","_componentWriter2","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownKeys","keys","getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","_toPropertyKey","value","configurable","writable","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","ComponentWriterMain","constructor","installer","compiler","workspace","logger","mover","configMerge","consumer","writeMany","opts","components","debug","writeComponentsFiles","results","finalizeWrite","populateComponentsFilesToWrite","moveComponentsIfNeeded","persistComponentsData","skipUpdatingBitMap","writeBitMap","reasonForBitmapChange","installationError","compilationError","workspaceConfigUpdateResult","writeDeps","writeDependencies","shouldUpdateWorkspaceConfig","updateDepsInWorkspaceConfig","mergeStrategy","externalPackageManagerIsUsed","writeDependenciesToPackageJson","skipDependencyInstallation","installPackagesGracefully","map","id","skipWriteConfigFiles","compileGracefully","componentIds","installOpts","dedupe","updateExisting","import","writeConfigFiles","dependenciesGraph","scope","getDependenciesGraphByComponentIds","install","undefined","err","consoleFailure","message","error","compileOnWorkspace","skipWritingToFs","dataToPersist","DataToPersist","component","merge","addBasePath","getPath","persistAllToFS","writeComponentsParams","getWriteParamsOfOneComponent","componentWriterInstances","writeParams","ComponentWriter","fixDirsIfEqual","fixDirsIfNested","Promise","all","componentWriter","existingComponentMap","addComponentToBitMap","writeToPath","componentConfigPath","join","rootDir","COMPONENT_CONFIG_FILE_NAME","componentConfigExist","fs","pathExists","writeConfig","resetConfig","config","mapSeries","allDirs","c","duplicatedDirs","dir","d","uniqDuplicates","uniq","compDir","hasDuplication","compWriter","ownerName","includes","split","startsWith","incrementPathRecursively","parentsOfOthersComps","find","existingRootDirs","bitMap","getAllRootDirs","parentsOfOthersCompsDirs","allPaths","newPath","existingParent","existingChildren","replace","componentRootDir","pathNormalizeToLinux","getPathRelativeToConsumer","resolve","composeRelativeComponentPath","getParams","componentMap","getComponentIfExist","ignoreVersion","throwErrorWhenDirectoryNotEmpty","BitError","relativeWrittenPath","writtenPath","absoluteWrittenPath","toAbsolutePath","absoluteWriteToPath","moveExistingComponent","componentDirRelative","componentDir","pathExistsSync","compInTheSameDir","getComponentIdByRootPath","toString","isDir","isDirEmptySync","throwForExistingDir","provider","loggerMain","configMerger","createLogger","ComponentWriterAspect","exports","InstallAspect","CompilerAspect","LoggerAspect","WorkspaceAspect","MoverAspect","ConfigMergerAspect","MainRuntime","addRuntime","_default","p","incrementPath","str","number","num"],"sources":["component-writer.main.runtime.ts"],"sourcesContent":["import { MainRuntime } from '@teambit/cli';\nimport type { ComponentID } from '@teambit/component-id';\nimport type { CompilerMain } from '@teambit/compiler';\nimport { CompilerAspect } from '@teambit/compiler';\nimport type { InstallMain } from '@teambit/install';\nimport { InstallAspect } from '@teambit/install';\nimport type { Logger, LoggerMain } from '@teambit/logger';\nimport { LoggerAspect } from '@teambit/logger';\nimport type { Workspace } from '@teambit/workspace';\nimport { WorkspaceAspect } from '@teambit/workspace';\nimport { BitError } from '@teambit/bit-error';\nimport fs from 'fs-extra';\nimport { uniq } from 'lodash';\nimport mapSeries from 'p-map-series';\nimport * as path from 'path';\nimport type { MoverMain } from '@teambit/mover';\nimport { MoverAspect } from '@teambit/mover';\nimport type { ConsumerComponent } from '@teambit/legacy.consumer-component';\nimport type { PathLinuxRelative, PathOsBasedAbsolute } from '@teambit/legacy.utils';\nimport { isDir, isDirEmptySync, pathNormalizeToLinux } from '@teambit/legacy.utils';\nimport type { ComponentMap } from '@teambit/legacy.bit-map';\nimport { COMPONENT_CONFIG_FILE_NAME } from '@teambit/legacy.constants';\nimport { DataToPersist } from '@teambit/component.sources';\nimport type { ConfigMergerMain, WorkspaceConfigUpdateResult } from '@teambit/config-merger';\nimport { ConfigMergerAspect } from '@teambit/config-merger';\nimport type { MergeStrategy } from '@teambit/component.modules.merge-helper';\nimport type { Consumer } from '@teambit/legacy.consumer';\nimport type { ComponentWriterProps } from './component-writer';\nimport ComponentWriter from './component-writer';\nimport { ComponentWriterAspect } from './component-writer.aspect';\n\nexport interface ManyComponentsWriterParams {\n components: ConsumerComponent[];\n writeToPath?: string;\n throwForExistingDir?: boolean;\n writeConfig?: boolean;\n skipDependencyInstallation?: boolean;\n verbose?: boolean;\n resetConfig?: boolean;\n skipWritingToFs?: boolean;\n skipUpdatingBitMap?: boolean;\n skipWriteConfigFiles?: boolean;\n reasonForBitmapChange?: string; // optional. will be written in the bitmap-history-metadata\n shouldUpdateWorkspaceConfig?: boolean; // whether it should update dependencies policy (or leave conflicts) in workspace.jsonc\n mergeStrategy?: MergeStrategy; // needed for workspace.jsonc conflicts\n writeDeps?: 'package.json' | 'workspace.jsonc';\n}\n\nexport type ComponentWriterResults = {\n installationError?: Error;\n compilationError?: Error;\n workspaceConfigUpdateResult?: WorkspaceConfigUpdateResult;\n};\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 private configMerge: ConfigMergerMain\n ) {}\n\n get consumer(): Consumer {\n return this.workspace.consumer;\n }\n\n async writeMany(opts: ManyComponentsWriterParams): Promise<ComponentWriterResults> {\n if (!opts.components.length) return {};\n this.logger.debug('writeMany, started');\n await this.writeComponentsFiles(opts);\n const results = await this.finalizeWrite(opts);\n this.logger.debug('writeMany, completed!');\n return results;\n }\n\n /**\n * Per-batch half of {@link writeMany}: populate, persist, and update .bitmap.\n * Callers batching very large imports call this per chunk, then {@link finalizeWrite} once.\n */\n async writeComponentsFiles(opts: ManyComponentsWriterParams): Promise<void> {\n if (!opts.components.length) return;\n await this.populateComponentsFilesToWrite(opts);\n this.moveComponentsIfNeeded(opts);\n await this.persistComponentsData(opts);\n if (!opts.skipUpdatingBitMap) await this.consumer.writeBitMap(opts.reasonForBitmapChange);\n }\n\n /**\n * Workspace-wide finalization pair to {@link writeComponentsFiles}: workspace.jsonc update,\n * dep install, compile. Runs once per import, not per batch.\n */\n async finalizeWrite(opts: ManyComponentsWriterParams): Promise<ComponentWriterResults> {\n if (!opts.components.length) return {};\n let installationError: Error | undefined;\n let compilationError: Error | undefined;\n let workspaceConfigUpdateResult: WorkspaceConfigUpdateResult | undefined;\n if (opts.writeDeps) {\n await this.workspace.writeDependencies(opts.writeDeps);\n }\n if (opts.shouldUpdateWorkspaceConfig) {\n workspaceConfigUpdateResult = await this.configMerge.updateDepsInWorkspaceConfig(\n opts.components,\n opts.mergeStrategy\n );\n }\n if (this.workspace.externalPackageManagerIsUsed()) {\n await this.installer.writeDependenciesToPackageJson();\n } else if (!opts.skipDependencyInstallation) {\n installationError = await this.installPackagesGracefully(\n opts.components.map(({ id }) => id),\n opts.skipWriteConfigFiles\n );\n // no point to compile if the installation is not running. the environment is not ready.\n compilationError = await this.compileGracefully();\n }\n return { installationError, compilationError, workspaceConfigUpdateResult };\n }\n\n private async installPackagesGracefully(\n componentIds: ComponentID[],\n skipWriteConfigFiles = false\n ): Promise<Error | undefined> {\n this.logger.debug('installPackagesGracefully, start installing packages');\n try {\n const installOpts = {\n dedupe: true,\n updateExisting: false,\n import: false,\n writeConfigFiles: !skipWriteConfigFiles,\n dependenciesGraph: await this.workspace.scope.getDependenciesGraphByComponentIds(componentIds),\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 compileGracefully(): Promise<Error | undefined> {\n try {\n await this.compiler.compileOnWorkspace();\n return undefined;\n } catch (err: any) {\n this.logger.consoleFailure(`compilation failed with the following error: ${err.message}`);\n this.logger.error('compileGracefully, compiler found an error', err);\n return err;\n }\n }\n private async persistComponentsData(opts: ManyComponentsWriterParams) {\n if (opts.skipWritingToFs) return;\n const dataToPersist = new DataToPersist();\n opts.components.forEach((component) => dataToPersist.merge(component.dataToPersist));\n dataToPersist.addBasePath(this.consumer.getPath());\n await dataToPersist.persistAllToFS();\n }\n private async populateComponentsFilesToWrite(opts: ManyComponentsWriterParams) {\n const writeComponentsParams = opts.components.map((component) =>\n this.getWriteParamsOfOneComponent(component, opts)\n );\n const componentWriterInstances = writeComponentsParams.map((writeParams) => new ComponentWriter(writeParams));\n this.fixDirsIfEqual(componentWriterInstances);\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 await Promise.all(\n componentWriterInstances.map(async (componentWriter: ComponentWriter) => {\n componentWriter.existingComponentMap =\n componentWriter.existingComponentMap ||\n (await componentWriter.addComponentToBitMap(componentWriter.writeToPath));\n const componentConfigPath = path.join(\n this.workspace.path,\n componentWriter.existingComponentMap.rootDir,\n COMPONENT_CONFIG_FILE_NAME\n );\n const componentConfigExist = await fs.pathExists(componentConfigPath);\n componentWriter.writeConfig = componentWriter.writeConfig || componentConfigExist;\n })\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 /**\n * this started to be an issue once same-name different-scope is supported.\n * by default, the component-dir consist of the scope-name part of the scope-id, without the owner part.\n * as a result, it's possible that multiple components have the same name, same scope-name but different owner.\n * e.g. org1.ui/button and org2.ui/button. the component-dir for both is \"ui/button\".\n * in this case, we try to prefix the component-dir with the owner-name and if not possible, just increment it (ui/button_1)\n */\n private fixDirsIfEqual(componentWriterInstances: ComponentWriter[]) {\n const allDirs = componentWriterInstances.map((c) => c.writeToPath);\n const duplicatedDirs = allDirs.filter((dir) => allDirs.filter((d) => d === dir).length > 1);\n if (!duplicatedDirs.length) return;\n const uniqDuplicates = uniq(duplicatedDirs);\n uniqDuplicates.forEach((compDir) => {\n const hasDuplication = componentWriterInstances.filter((compWriter) => compWriter.writeToPath === compDir);\n hasDuplication.forEach((compWriter) => {\n const ownerName = compWriter.component.id.scope?.includes('.')\n ? compWriter.component.id.scope.split('.')[0]\n : undefined;\n if (ownerName && !compDir.startsWith(ownerName) && !allDirs.includes(`${ownerName}/${compDir}`)) {\n compWriter.writeToPath = `${ownerName}/${compDir}`;\n } else {\n compWriter.writeToPath = incrementPathRecursively(compWriter.writeToPath, allDirs);\n }\n allDirs.push(compWriter.writeToPath);\n });\n });\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 const existingRootDirs = this.workspace.bitMap.getAllRootDirs();\n const parentsOfOthersCompsDirs = parentsOfOthersComps.map((c) => c.writeToPath);\n const allPaths: PathLinuxRelative[] = [...existingRootDirs, ...parentsOfOthersCompsDirs];\n\n // this is when writing multiple components and some of them are parents of the others.\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 = incrementPathRecursively(componentWriter.writeToPath, allPaths);\n componentWriter.writeToPath = newPath;\n });\n\n // this part is when a component's rootDir we about to write is a children of an existing rootDir.\n // e.g. we're now writing \"foo\", when an existing component has \"foo/bar\" as the rootDir.\n // in this case, we change \"foo\" to be \"foo_1\".\n componentWriterInstances.forEach((componentWriter) => {\n const existingParent = existingRootDirs.find((d) => d.startsWith(`${componentWriter.writeToPath}/`));\n if (!existingParent) return;\n if (existingRootDirs.includes(componentWriter.writeToPath)) return; // component already exists.\n const newPath = incrementPathRecursively(componentWriter.writeToPath, allPaths);\n componentWriter.writeToPath = newPath;\n });\n\n // this part if when for example an existing rootDir is \"comp1\" and currently written component is \"comp1/foo\".\n // obviously we don't want to change existing dirs. we change the \"comp1/foo\" to be \"comp1_1/foo\".\n componentWriterInstances.forEach((componentWriter) => {\n const existingChildren = existingRootDirs.find((d) => componentWriter.writeToPath.startsWith(`${d}/`));\n if (!existingChildren) return;\n // we increment the existing one, because it is used to replace the base-path of the current component\n const newPath = incrementPathRecursively(existingChildren, allPaths);\n componentWriter.writeToPath = componentWriter.writeToPath.replace(existingChildren, newPath);\n });\n }\n\n private getWriteParamsOfOneComponent(\n component: ConsumerComponent,\n opts: ManyComponentsWriterParams\n ): ComponentWriterProps {\n const componentRootDir: PathLinuxRelative = opts.writeToPath\n ? pathNormalizeToLinux(this.consumer.getPathRelativeToConsumer(path.resolve(opts.writeToPath)))\n : this.consumer.composeRelativeComponentPath(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(component.id, {\n ignoreVersion: true,\n });\n this.throwErrorWhenDirectoryNotEmpty(componentRootDir, componentMap, opts);\n return {\n existingComponentMap: componentMap,\n };\n };\n return {\n workspace: this.workspace,\n bitMap: this.consumer.bitMap,\n component,\n writeToPath: componentRootDir,\n writeConfig: opts.writeConfig,\n skipUpdatingBitMap: opts.skipUpdatingBitMap,\n ...getParams(),\n };\n }\n private moveComponentsIfNeeded(opts: ManyComponentsWriterParams) {\n if (opts.writeToPath && this.consumer) {\n opts.components.forEach((component) => {\n const componentMap = component.componentMap as ComponentMap;\n if (!componentMap.rootDir) {\n throw new BitError(`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 = 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 this.mover.moveExistingComponent(component, absoluteWrittenPath, absoluteWriteToPath);\n }\n });\n }\n }\n private throwErrorWhenDirectoryNotEmpty(\n componentDirRelative: PathOsBasedAbsolute,\n componentMap: ComponentMap | null | undefined,\n opts: ManyComponentsWriterParams\n ) {\n if (opts.skipWritingToFs) return;\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 const componentDir = this.consumer.toAbsolutePath(componentDirRelative);\n if (!fs.pathExistsSync(componentDir)) return;\n if (!componentMap) {\n const compInTheSameDir = this.consumer.bitMap.getComponentIdByRootPath(componentDirRelative);\n if (compInTheSameDir) {\n throw new BitError(\n `unable to import to ${componentDir}, the directory is already used by ${compInTheSameDir.toString()}.\neither use --path to specify a different directory or modify \"defaultDirectory\" prop in the workspace.jsonc file to \"{scopeId}/{name}\"`\n );\n }\n }\n if (!isDir(componentDir)) {\n throw new BitError(`unable to import to ${componentDir} because it's a file`);\n }\n if (!isDirEmptySync(componentDir) && opts.throwForExistingDir) {\n throw new BitError(\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 static slots = [];\n static dependencies = [InstallAspect, CompilerAspect, LoggerAspect, WorkspaceAspect, MoverAspect, ConfigMergerAspect];\n static runtime = MainRuntime;\n static async provider([install, compiler, loggerMain, workspace, mover, configMerger]: [\n InstallMain,\n CompilerMain,\n LoggerMain,\n Workspace,\n MoverMain,\n ConfigMergerMain,\n ]) {\n const logger = loggerMain.createLogger(ComponentWriterAspect.id);\n return new ComponentWriterMain(install, compiler, workspace, logger, mover, configMerger);\n }\n}\n\nComponentWriterAspect.addRuntime(ComponentWriterMain);\n\nexport default ComponentWriterMain;\n\nexport function incrementPathRecursively(p: string, allPaths: string[]) {\n const incrementPath = (str: string, number: number) => `${str}_${number}`;\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"],"mappings":";;;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAE,UAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,SAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,QAAA,YAAAA,CAA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B,kBAwSR,CAACgJ,wBAAa,EAAEC,0BAAc,EAAEC,sBAAY,EAAEC,4BAAe,EAAEC,oBAAW,EAAEC,kCAAkB,CAAC;AAAAlK,eAAA,CAxS1Ga,mBAAmB,aAySbsJ,kBAAW;AAc9BR,yCAAqB,CAACS,UAAU,CAACvJ,mBAAmB,CAAC;AAAC,IAAAwJ,QAAA,GAAAT,OAAA,CAAAhL,OAAA,GAEvCiC,mBAAmB;AAE3B,SAASoG,wBAAwBA,CAACqD,CAAS,EAAE9C,QAAkB,EAAE;EACtE,MAAM+C,aAAa,GAAGA,CAACC,GAAW,EAAEC,MAAc,KAAK,GAAGD,GAAG,IAAIC,MAAM,EAAE;EACzE,IAAIC,GAAG,GAAG,CAAC;EACX,IAAIjD,OAAO,GAAG8C,aAAa,CAACD,CAAC,EAAEI,GAAG,CAAC;EACnC,OAAOlD,QAAQ,CAACV,QAAQ,CAACW,OAAO,CAAC,EAAE;IACjCA,OAAO,GAAG8C,aAAa,CAACD,CAAC,EAAGI,GAAG,IAAI,CAAE,CAAC;EACxC;EACA,OAAOjD,OAAO;AAChB","ignoreList":[]}
1
+ {"version":3,"names":["_cli","data","require","_compiler","_install","_logger","_workspace","_bitError","_fsExtra","_interopRequireDefault","_lodash","_pMapSeries","path","_interopRequireWildcard","_mover","_legacy","_legacy2","_component","_configMerger","_componentWriter","_componentWriter2","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_defineProperty","_toPropertyKey","value","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","ComponentWriterMain","constructor","installer","compiler","workspace","logger","mover","configMerge","consumer","writeMany","opts","components","length","debug","writeComponentsFiles","results","finalizeWrite","populateComponentsFilesToWrite","moveComponentsIfNeeded","persistComponentsData","skipUpdatingBitMap","writeBitMap","reasonForBitmapChange","installationError","compilationError","workspaceConfigUpdateResult","writeDeps","writeDependencies","shouldUpdateWorkspaceConfig","updateDepsInWorkspaceConfig","mergeStrategy","externalPackageManagerIsUsed","writeDependenciesToPackageJson","skipDependencyInstallation","installPackagesGracefully","map","id","skipWriteConfigFiles","compileGracefully","componentIds","installOpts","dedupe","updateExisting","import","writeConfigFiles","dependenciesGraph","scope","getDependenciesGraphByComponentIds","install","undefined","err","consoleFailure","message","error","compileOnWorkspace","skipWritingToFs","dataToPersist","DataToPersist","forEach","component","merge","addBasePath","getPath","persistAllToFS","writeComponentsParams","getWriteParamsOfOneComponent","componentWriterInstances","writeParams","ComponentWriter","fixDirsIfEqual","fixDirsIfNested","relocateOccupiedDirs","Promise","all","componentWriter","existingComponentMap","addComponentToBitMap","writeToPath","componentConfigPath","join","rootDir","COMPONENT_CONFIG_FILE_NAME","componentConfigExist","fs","pathExists","writeConfig","resetConfig","config","mapSeries","allDirs","c","duplicatedDirs","filter","dir","d","uniqDuplicates","uniq","compDir","hasDuplication","compWriter","ownerName","includes","split","startsWith","incrementPathRecursively","push","parentsOfOthersComps","find","existingRootDirs","bitMap","getAllRootDirs","parentsOfOthersCompsDirs","allPaths","newPath","existingParent","existingChildren","replace","componentRootDir","pathNormalizeToLinux","getPathRelativeToConsumer","resolve","composeRelativeComponentPath","getComponentIfExist","ignoreVersion","writeToEmptyDir","throwErrorWhenDirectoryNotEmpty","componentMap","BitError","relativeWrittenPath","writtenPath","absoluteWrittenPath","toAbsolutePath","absoluteWriteToPath","moveExistingComponent","shouldSkipDirConflictCheck","componentDirRelative","componentDir","pathExistsSync","compInTheSameDir","getComponentIdByRootPath","toString","isDir","isDirEmptySync","throwForExistingDir","takenDirs","Set","currentDir","unavailableReason","getDirUnavailableReason","num","candidate","consoleWarning","add","usedByComponent","isEqualWithoutVersion","provider","loggerMain","configMerger","createLogger","ComponentWriterAspect","exports","InstallAspect","CompilerAspect","LoggerAspect","WorkspaceAspect","MoverAspect","ConfigMergerAspect","MainRuntime","addRuntime","_default","p","incrementPath","str","number"],"sources":["component-writer.main.runtime.ts"],"sourcesContent":["import { MainRuntime } from '@teambit/cli';\nimport type { ComponentID } from '@teambit/component-id';\nimport type { CompilerMain } from '@teambit/compiler';\nimport { CompilerAspect } from '@teambit/compiler';\nimport type { InstallMain } from '@teambit/install';\nimport { InstallAspect } from '@teambit/install';\nimport type { Logger, LoggerMain } from '@teambit/logger';\nimport { LoggerAspect } from '@teambit/logger';\nimport type { Workspace } from '@teambit/workspace';\nimport { WorkspaceAspect } from '@teambit/workspace';\nimport { BitError } from '@teambit/bit-error';\nimport fs from 'fs-extra';\nimport { uniq } from 'lodash';\nimport mapSeries from 'p-map-series';\nimport * as path from 'path';\nimport type { MoverMain } from '@teambit/mover';\nimport { MoverAspect } from '@teambit/mover';\nimport type { ConsumerComponent } from '@teambit/legacy.consumer-component';\nimport type { PathLinuxRelative } from '@teambit/legacy.utils';\nimport { isDir, isDirEmptySync, pathNormalizeToLinux } from '@teambit/legacy.utils';\nimport type { ComponentMap } from '@teambit/legacy.bit-map';\nimport { COMPONENT_CONFIG_FILE_NAME } from '@teambit/legacy.constants';\nimport { DataToPersist } from '@teambit/component.sources';\nimport type { ConfigMergerMain, WorkspaceConfigUpdateResult } from '@teambit/config-merger';\nimport { ConfigMergerAspect } from '@teambit/config-merger';\nimport type { MergeStrategy } from '@teambit/component.modules.merge-helper';\nimport type { Consumer } from '@teambit/legacy.consumer';\nimport type { ComponentWriterProps } from './component-writer';\nimport ComponentWriter from './component-writer';\nimport { ComponentWriterAspect } from './component-writer.aspect';\n\nexport interface ManyComponentsWriterParams {\n components: ConsumerComponent[];\n writeToPath?: string;\n throwForExistingDir?: boolean;\n // when the target dir is occupied, import into an available empty dir (e.g. \"foo\" => \"foo_1\") instead of failing.\n writeToEmptyDir?: boolean;\n writeConfig?: boolean;\n skipDependencyInstallation?: boolean;\n verbose?: boolean;\n resetConfig?: boolean;\n skipWritingToFs?: boolean;\n skipUpdatingBitMap?: boolean;\n skipWriteConfigFiles?: boolean;\n reasonForBitmapChange?: string; // optional. will be written in the bitmap-history-metadata\n shouldUpdateWorkspaceConfig?: boolean; // whether it should update dependencies policy (or leave conflicts) in workspace.jsonc\n mergeStrategy?: MergeStrategy; // needed for workspace.jsonc conflicts\n writeDeps?: 'package.json' | 'workspace.jsonc';\n}\n\nexport type ComponentWriterResults = {\n installationError?: Error;\n compilationError?: Error;\n workspaceConfigUpdateResult?: WorkspaceConfigUpdateResult;\n};\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 private configMerge: ConfigMergerMain\n ) {}\n\n get consumer(): Consumer {\n return this.workspace.consumer;\n }\n\n async writeMany(opts: ManyComponentsWriterParams): Promise<ComponentWriterResults> {\n if (!opts.components.length) return {};\n this.logger.debug('writeMany, started');\n await this.writeComponentsFiles(opts);\n const results = await this.finalizeWrite(opts);\n this.logger.debug('writeMany, completed!');\n return results;\n }\n\n /**\n * Per-batch half of {@link writeMany}: populate, persist, and update .bitmap.\n * Callers batching very large imports call this per chunk, then {@link finalizeWrite} once.\n */\n async writeComponentsFiles(opts: ManyComponentsWriterParams): Promise<void> {\n if (!opts.components.length) return;\n await this.populateComponentsFilesToWrite(opts);\n this.moveComponentsIfNeeded(opts);\n await this.persistComponentsData(opts);\n if (!opts.skipUpdatingBitMap) await this.consumer.writeBitMap(opts.reasonForBitmapChange);\n }\n\n /**\n * Workspace-wide finalization pair to {@link writeComponentsFiles}: workspace.jsonc update,\n * dep install, compile. Runs once per import, not per batch.\n */\n async finalizeWrite(opts: ManyComponentsWriterParams): Promise<ComponentWriterResults> {\n if (!opts.components.length) return {};\n let installationError: Error | undefined;\n let compilationError: Error | undefined;\n let workspaceConfigUpdateResult: WorkspaceConfigUpdateResult | undefined;\n if (opts.writeDeps) {\n await this.workspace.writeDependencies(opts.writeDeps);\n }\n if (opts.shouldUpdateWorkspaceConfig) {\n workspaceConfigUpdateResult = await this.configMerge.updateDepsInWorkspaceConfig(\n opts.components,\n opts.mergeStrategy\n );\n }\n if (this.workspace.externalPackageManagerIsUsed()) {\n await this.installer.writeDependenciesToPackageJson();\n } else if (!opts.skipDependencyInstallation) {\n installationError = await this.installPackagesGracefully(\n opts.components.map(({ id }) => id),\n opts.skipWriteConfigFiles\n );\n // no point to compile if the installation is not running. the environment is not ready.\n compilationError = await this.compileGracefully();\n }\n return { installationError, compilationError, workspaceConfigUpdateResult };\n }\n\n private async installPackagesGracefully(\n componentIds: ComponentID[],\n skipWriteConfigFiles = false\n ): Promise<Error | undefined> {\n this.logger.debug('installPackagesGracefully, start installing packages');\n try {\n const installOpts = {\n dedupe: true,\n updateExisting: false,\n import: false,\n writeConfigFiles: !skipWriteConfigFiles,\n dependenciesGraph: await this.workspace.scope.getDependenciesGraphByComponentIds(componentIds),\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 compileGracefully(): Promise<Error | undefined> {\n try {\n await this.compiler.compileOnWorkspace();\n return undefined;\n } catch (err: any) {\n this.logger.consoleFailure(`compilation failed with the following error: ${err.message}`);\n this.logger.error('compileGracefully, compiler found an error', err);\n return err;\n }\n }\n private async persistComponentsData(opts: ManyComponentsWriterParams) {\n if (opts.skipWritingToFs) return;\n const dataToPersist = new DataToPersist();\n opts.components.forEach((component) => dataToPersist.merge(component.dataToPersist));\n dataToPersist.addBasePath(this.consumer.getPath());\n await dataToPersist.persistAllToFS();\n }\n private async populateComponentsFilesToWrite(opts: ManyComponentsWriterParams) {\n const writeComponentsParams = opts.components.map((component) =>\n this.getWriteParamsOfOneComponent(component, opts)\n );\n const componentWriterInstances = writeComponentsParams.map((writeParams) => new ComponentWriter(writeParams));\n this.fixDirsIfEqual(componentWriterInstances);\n this.fixDirsIfNested(componentWriterInstances);\n // must run after the fixDirs* passes above, which may still move writeToPath onto an occupied dir.\n this.relocateOccupiedDirs(componentWriterInstances, opts);\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 await Promise.all(\n componentWriterInstances.map(async (componentWriter: ComponentWriter) => {\n componentWriter.existingComponentMap =\n componentWriter.existingComponentMap ||\n (await componentWriter.addComponentToBitMap(componentWriter.writeToPath));\n const componentConfigPath = path.join(\n this.workspace.path,\n componentWriter.existingComponentMap.rootDir,\n COMPONENT_CONFIG_FILE_NAME\n );\n const componentConfigExist = await fs.pathExists(componentConfigPath);\n componentWriter.writeConfig = componentWriter.writeConfig || componentConfigExist;\n })\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 /**\n * this started to be an issue once same-name different-scope is supported.\n * by default, the component-dir consist of the scope-name part of the scope-id, without the owner part.\n * as a result, it's possible that multiple components have the same name, same scope-name but different owner.\n * e.g. org1.ui/button and org2.ui/button. the component-dir for both is \"ui/button\".\n * in this case, we try to prefix the component-dir with the owner-name and if not possible, just increment it (ui/button_1)\n */\n private fixDirsIfEqual(componentWriterInstances: ComponentWriter[]) {\n const allDirs = componentWriterInstances.map((c) => c.writeToPath);\n const duplicatedDirs = allDirs.filter((dir) => allDirs.filter((d) => d === dir).length > 1);\n if (!duplicatedDirs.length) return;\n const uniqDuplicates = uniq(duplicatedDirs);\n uniqDuplicates.forEach((compDir) => {\n const hasDuplication = componentWriterInstances.filter((compWriter) => compWriter.writeToPath === compDir);\n hasDuplication.forEach((compWriter) => {\n const ownerName = compWriter.component.id.scope?.includes('.')\n ? compWriter.component.id.scope.split('.')[0]\n : undefined;\n if (ownerName && !compDir.startsWith(ownerName) && !allDirs.includes(`${ownerName}/${compDir}`)) {\n compWriter.writeToPath = `${ownerName}/${compDir}`;\n } else {\n compWriter.writeToPath = incrementPathRecursively(compWriter.writeToPath, allDirs);\n }\n allDirs.push(compWriter.writeToPath);\n });\n });\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 const existingRootDirs = this.workspace.bitMap.getAllRootDirs();\n const parentsOfOthersCompsDirs = parentsOfOthersComps.map((c) => c.writeToPath);\n const allPaths: PathLinuxRelative[] = [...existingRootDirs, ...parentsOfOthersCompsDirs];\n\n // this is when writing multiple components and some of them are parents of the others.\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 = incrementPathRecursively(componentWriter.writeToPath, allPaths);\n componentWriter.writeToPath = newPath;\n });\n\n // this part is when a component's rootDir we about to write is a children of an existing rootDir.\n // e.g. we're now writing \"foo\", when an existing component has \"foo/bar\" as the rootDir.\n // in this case, we change \"foo\" to be \"foo_1\".\n componentWriterInstances.forEach((componentWriter) => {\n const existingParent = existingRootDirs.find((d) => d.startsWith(`${componentWriter.writeToPath}/`));\n if (!existingParent) return;\n if (existingRootDirs.includes(componentWriter.writeToPath)) return; // component already exists.\n const newPath = incrementPathRecursively(componentWriter.writeToPath, allPaths);\n componentWriter.writeToPath = newPath;\n });\n\n // this part if when for example an existing rootDir is \"comp1\" and currently written component is \"comp1/foo\".\n // obviously we don't want to change existing dirs. we change the \"comp1/foo\" to be \"comp1_1/foo\".\n componentWriterInstances.forEach((componentWriter) => {\n const existingChildren = existingRootDirs.find((d) => componentWriter.writeToPath.startsWith(`${d}/`));\n if (!existingChildren) return;\n // we increment the existing one, because it is used to replace the base-path of the current component\n const newPath = incrementPathRecursively(existingChildren, allPaths);\n componentWriter.writeToPath = componentWriter.writeToPath.replace(existingChildren, newPath);\n });\n }\n\n private getWriteParamsOfOneComponent(\n component: ConsumerComponent,\n opts: ManyComponentsWriterParams\n ): ComponentWriterProps {\n const componentRootDir: PathLinuxRelative = opts.writeToPath\n ? pathNormalizeToLinux(this.consumer.getPathRelativeToConsumer(path.resolve(opts.writeToPath)))\n : this.consumer.composeRelativeComponentPath(component.id);\n // components can't be saved with multiple versions, so we can ignore the version to find the component in bit.map\n const existingComponentMap = this.consumer?.bitMap.getComponentIfExist(component.id, { ignoreVersion: true });\n // with --write-to-empty-dir, dir-conflict resolution is deferred to relocateOccupiedDirs() so it runs after the\n // fixDirs* passes (which may still adjust writeToPath); otherwise fail here when the target dir is occupied.\n if (this.consumer && !opts.writeToEmptyDir) {\n this.throwErrorWhenDirectoryNotEmpty(componentRootDir, existingComponentMap, opts);\n }\n return {\n workspace: this.workspace,\n bitMap: this.consumer.bitMap,\n component,\n writeToPath: componentRootDir,\n writeConfig: opts.writeConfig,\n skipUpdatingBitMap: opts.skipUpdatingBitMap,\n existingComponentMap: existingComponentMap ?? undefined,\n };\n }\n private moveComponentsIfNeeded(opts: ManyComponentsWriterParams) {\n if (opts.writeToPath && this.consumer) {\n opts.components.forEach((component) => {\n const componentMap = component.componentMap as ComponentMap;\n if (!componentMap.rootDir) {\n throw new BitError(`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 = 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 this.mover.moveExistingComponent(component, absoluteWrittenPath, absoluteWriteToPath);\n }\n });\n }\n }\n /**\n * true when the directory-conflict check can be skipped: either nothing is written to the filesystem, or the\n * target directory already belongs to this exact component (so overriding it in place is safe).\n */\n private shouldSkipDirConflictCheck(\n componentDirRelative: PathLinuxRelative,\n componentMap: ComponentMap | null | undefined,\n opts: ManyComponentsWriterParams\n ): boolean {\n if (opts.skipWritingToFs) return true;\n if (!componentMap) return false;\n // no writeToPath: it goes to the default directory. an existing componentMap means the component is not new.\n if (!opts.writeToPath) return true;\n // writeToPath specified and that directory is already used for that component. compare against the\n // normalized componentDirRelative (not the raw opts.writeToPath, which may be absolute/OS-specific).\n return componentMap.rootDir === componentDirRelative;\n }\n\n private throwErrorWhenDirectoryNotEmpty(\n componentDirRelative: PathLinuxRelative,\n componentMap: ComponentMap | null | undefined,\n opts: ManyComponentsWriterParams\n ) {\n if (this.shouldSkipDirConflictCheck(componentDirRelative, componentMap, opts)) return;\n\n const componentDir = this.consumer.toAbsolutePath(componentDirRelative);\n if (!fs.pathExistsSync(componentDir)) return;\n if (!componentMap) {\n const compInTheSameDir = this.consumer.bitMap.getComponentIdByRootPath(componentDirRelative);\n if (compInTheSameDir) {\n throw new BitError(\n `unable to import to ${componentDir}, the directory is already used by ${compInTheSameDir.toString()}.\neither use --path to specify a different directory or modify \"defaultDirectory\" prop in the workspace.jsonc file to \"{scopeId}/{name}\"`\n );\n }\n }\n if (!isDir(componentDir)) {\n throw new BitError(`unable to import to ${componentDir} because it's a file`);\n }\n if (!isDirEmptySync(componentDir) && opts.throwForExistingDir) {\n throw new BitError(\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 * final `writeToPath` resolution for the `--write-to-empty-dir` import flag, mainly for non-interactive clients\n * (such as the IDE) that can't prompt for `--override`. runs after fixDirsIfEqual()/fixDirsIfNested() - which may\n * still move dirs using string-only collision checks - so the flag's guarantee holds against the final paths:\n * every relocated component lands in a directory that is empty (or non-existent) and unclaimed in .bitmap.\n * when a target is occupied (by foreign files, or a dir/rootDir owned by another component), it's relocated by\n * suffixing \"_N\" (e.g. \"renderers/class\" => \"renderers/class_1\"). a dir already owned by this component is left\n * as-is (its files are overridden, same as the default import behavior).\n */\n private relocateOccupiedDirs(componentWriterInstances: ComponentWriter[], opts: ManyComponentsWriterParams) {\n if (!opts.writeToEmptyDir) return;\n // track dirs already claimed in .bitmap and by other components in this batch, so two relocations never collide.\n const takenDirs = new Set<string>([\n ...this.workspace.bitMap.getAllRootDirs(),\n ...componentWriterInstances.map((componentWriter) => componentWriter.writeToPath),\n ]);\n componentWriterInstances.forEach((componentWriter) => {\n const currentDir = componentWriter.writeToPath;\n const componentMap = componentWriter.existingComponentMap;\n if (this.shouldSkipDirConflictCheck(currentDir, componentMap, opts)) return;\n const unavailableReason = this.getDirUnavailableReason(currentDir, componentMap);\n if (!unavailableReason) return;\n\n let num = 1;\n let candidate = `${currentDir}_${num}`;\n while (takenDirs.has(candidate) || this.getDirUnavailableReason(candidate, componentMap)) {\n num += 1;\n candidate = `${currentDir}_${num}`;\n }\n this.logger.consoleWarning(\n `unable to import into \"${currentDir}\" (${unavailableReason}), importing into \"${candidate}\" instead`\n );\n componentWriter.writeToPath = candidate;\n takenDirs.add(candidate);\n });\n }\n\n /**\n * returns a human-readable reason why the given directory can't be used for import, or undefined when it's\n * available. a directory is available when it doesn't exist yet, or it's an empty directory that is not already\n * used by another component in the .bitmap file.\n */\n private getDirUnavailableReason(\n componentDirRelative: PathLinuxRelative,\n componentMap: ComponentMap | null | undefined\n ): string | undefined {\n // a rootDir may be claimed in .bitmap even when its directory was deleted from the filesystem, so check\n // .bitmap ownership regardless of whether the directory currently exists on disk. it's only ok to reuse the\n // rootDir when it's claimed by the same component we're importing (comparing without version).\n const usedByComponent = this.consumer.bitMap.getComponentIdByRootPath(componentDirRelative);\n if (usedByComponent && !(componentMap && usedByComponent.isEqualWithoutVersion(componentMap.id))) {\n return `it is already used by ${usedByComponent.toString()}`;\n }\n const componentDir = this.consumer.toAbsolutePath(componentDirRelative);\n if (!fs.pathExistsSync(componentDir)) return undefined;\n if (!isDir(componentDir)) return 'it is a file';\n if (!isDirEmptySync(componentDir)) return 'the directory is not empty';\n return undefined;\n }\n\n static slots = [];\n static dependencies = [InstallAspect, CompilerAspect, LoggerAspect, WorkspaceAspect, MoverAspect, ConfigMergerAspect];\n static runtime = MainRuntime;\n static async provider([install, compiler, loggerMain, workspace, mover, configMerger]: [\n InstallMain,\n CompilerMain,\n LoggerMain,\n Workspace,\n MoverMain,\n ConfigMergerMain,\n ]) {\n const logger = loggerMain.createLogger(ComponentWriterAspect.id);\n return new ComponentWriterMain(install, compiler, workspace, logger, mover, configMerger);\n }\n}\n\nComponentWriterAspect.addRuntime(ComponentWriterMain);\n\nexport default ComponentWriterMain;\n\nexport function incrementPathRecursively(p: string, allPaths: string[]) {\n const incrementPath = (str: string, number: number) => `${str}_${number}`;\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"],"mappings":";;;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAE,UAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,SAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA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EC,MAAc,KAAK,GAAGD,GAAG,IAAIC,MAAM,EAAE;EACzE,IAAIxB,GAAG,GAAG,CAAC;EACX,IAAIpC,OAAO,GAAG0D,aAAa,CAACD,CAAC,EAAErB,GAAG,CAAC;EACnC,OAAOrC,QAAQ,CAACX,QAAQ,CAACY,OAAO,CAAC,EAAE;IACjCA,OAAO,GAAG0D,aAAa,CAACD,CAAC,EAAGrB,GAAG,IAAI,CAAE,CAAC;EACxC;EACA,OAAOpC,OAAO;AAChB","ignoreList":[]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/component-writer",
3
- "version": "1.0.1047",
3
+ "version": "1.0.1049",
4
4
  "homepage": "https://bit.cloud/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": "1.0.1047"
9
+ "version": "1.0.1049"
10
10
  },
11
11
  "dependencies": {
12
12
  "fs-extra": "10.0.0",
@@ -15,29 +15,29 @@
15
15
  "@teambit/harmony": "0.4.12",
16
16
  "@teambit/bit-error": "0.0.404",
17
17
  "@teambit/component-id": "1.2.4",
18
- "@teambit/legacy.constants": "0.0.31",
19
- "@teambit/legacy.utils": "0.0.39",
20
18
  "@teambit/component-version": "1.0.4",
21
- "@teambit/cli": "0.0.1347",
22
- "@teambit/compiler": "1.0.1047",
23
- "@teambit/component.modules.merge-helper": "0.0.76",
24
- "@teambit/component.sources": "0.0.185",
25
- "@teambit/config-merger": "0.0.914",
26
- "@teambit/install": "1.0.1047",
27
- "@teambit/legacy.bit-map": "0.0.190",
28
- "@teambit/legacy.consumer-component": "0.0.134",
29
- "@teambit/legacy.consumer": "0.0.133",
30
- "@teambit/logger": "0.0.1440",
31
- "@teambit/mover": "1.0.1047",
32
- "@teambit/workspace": "1.0.1047",
33
- "@teambit/legacy.scope": "0.0.133",
34
- "@teambit/objects": "0.0.554"
19
+ "@teambit/cli": "0.0.1348",
20
+ "@teambit/compiler": "1.0.1049",
21
+ "@teambit/component.modules.merge-helper": "0.0.77",
22
+ "@teambit/component.sources": "0.0.186",
23
+ "@teambit/config-merger": "0.0.916",
24
+ "@teambit/install": "1.0.1049",
25
+ "@teambit/legacy.bit-map": "0.0.191",
26
+ "@teambit/legacy.constants": "0.0.32",
27
+ "@teambit/legacy.consumer-component": "0.0.135",
28
+ "@teambit/legacy.consumer": "0.0.134",
29
+ "@teambit/legacy.utils": "0.0.40",
30
+ "@teambit/logger": "0.0.1441",
31
+ "@teambit/mover": "1.0.1049",
32
+ "@teambit/workspace": "1.0.1049",
33
+ "@teambit/legacy.scope": "0.0.134",
34
+ "@teambit/objects": "0.0.556"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/fs-extra": "9.0.7",
38
38
  "@types/lodash": "4.14.165",
39
39
  "@types/mocha": "9.1.0",
40
- "@teambit/harmony.envs.core-aspect-env": "0.1.7"
40
+ "@teambit/harmony.envs.core-aspect-env": "1.0.0"
41
41
  },
42
42
  "peerDependencies": {},
43
43
  "license": "Apache-2.0",
@@ -45,7 +45,7 @@
45
45
  "peerDependenciesMeta": {},
46
46
  "exports": {
47
47
  ".": {
48
- "types": "./index.ts",
48
+ "types": "./dist/index.d.ts",
49
49
  "node": {
50
50
  "require": "./dist/index.js",
51
51
  "import": "./dist/esm.mjs"
@@ -53,8 +53,7 @@
53
53
  "default": "./dist/index.js"
54
54
  },
55
55
  "./dist/*": "./dist/*",
56
- "./artifacts/*": "./artifacts/*",
57
- "./*": "./*.ts"
56
+ "./artifacts/*": "./artifacts/*"
58
57
  },
59
58
  "private": false,
60
59
  "engines": {
package/types/style.d.ts CHANGED
@@ -40,3 +40,7 @@ declare module '*.mdx' {
40
40
  const component: any;
41
41
  export default component;
42
42
  }
43
+
44
+ // `reset-css` ships only `reset.css` (no `.d.ts`). TS6 refuses bare
45
+ // side-effect imports without declarations, so we declare the module here.
46
+ declare module 'reset-css';