@teambit/component-writer 0.0.29 → 0.0.30
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.
- package/dist/component-writer.main.runtime.d.ts +2 -2
- package/dist/component-writer.main.runtime.js +9 -14
- package/dist/component-writer.main.runtime.js.map +1 -1
- package/package-tar/teambit-component-writer-0.0.30.tgz +0 -0
- package/package.json +9 -9
- package/package-tar/teambit-component-writer-0.0.29.tgz +0 -0
- /package/dist/{preview-1677037172474.js → preview-1677123420698.js} +0 -0
|
@@ -3,10 +3,10 @@ import { InstallMain } from '@teambit/install';
|
|
|
3
3
|
import { Logger, LoggerMain } from '@teambit/logger';
|
|
4
4
|
import { Workspace } from '@teambit/workspace';
|
|
5
5
|
import { MoverMain } from '@teambit/mover';
|
|
6
|
-
import
|
|
6
|
+
import ConsumerComponent from '@teambit/legacy/dist/consumer/component';
|
|
7
7
|
import Consumer from '@teambit/legacy/dist/consumer/consumer';
|
|
8
8
|
export interface ManyComponentsWriterParams {
|
|
9
|
-
|
|
9
|
+
components: ConsumerComponent[];
|
|
10
10
|
writeToPath?: string;
|
|
11
11
|
throwForExistingDir?: boolean;
|
|
12
12
|
writeConfig?: boolean;
|
|
@@ -183,10 +183,7 @@ class ComponentWriterMain {
|
|
|
183
183
|
async persistComponentsData(opts) {
|
|
184
184
|
var _this$consumer, _this$consumer$config;
|
|
185
185
|
const dataToPersist = new (_dataToPersist().default)();
|
|
186
|
-
opts.
|
|
187
|
-
const allComponents = [componentWithDeps.component, ...componentWithDeps.allDependencies];
|
|
188
|
-
allComponents.forEach(component => dataToPersist.merge(component.dataToPersist));
|
|
189
|
-
});
|
|
186
|
+
opts.components.forEach(component => dataToPersist.merge(component.dataToPersist));
|
|
190
187
|
const componentsConfig = (_this$consumer = this.consumer) === null || _this$consumer === void 0 ? void 0 : (_this$consumer$config = _this$consumer.config) === null || _this$consumer$config === void 0 ? void 0 : _this$consumer$config.componentsConfig;
|
|
191
188
|
if (componentsConfig !== null && componentsConfig !== void 0 && componentsConfig.hasChanged) {
|
|
192
189
|
var _this$consumer2;
|
|
@@ -199,7 +196,7 @@ class ComponentWriterMain {
|
|
|
199
196
|
await dataToPersist.persistAllToFS();
|
|
200
197
|
}
|
|
201
198
|
async populateComponentsFilesToWrite(opts) {
|
|
202
|
-
const writeComponentsParams = opts.
|
|
199
|
+
const writeComponentsParams = opts.components.map(component => this.getWriteParamsOfOneComponent(component, opts));
|
|
203
200
|
const componentWriterInstances = writeComponentsParams.map(writeParams => new (_componentWriter().default)(writeParams));
|
|
204
201
|
this.fixDirsIfNested(componentWriterInstances);
|
|
205
202
|
// add componentMap entries into .bitmap before starting the process because steps like writing package-json
|
|
@@ -250,14 +247,14 @@ class ComponentWriterMain {
|
|
|
250
247
|
componentWriter.writeToPath = newPath;
|
|
251
248
|
});
|
|
252
249
|
}
|
|
253
|
-
getWriteParamsOfOneComponent(
|
|
254
|
-
const componentRootDir = opts.writeToPath ? (0, _path2().pathNormalizeToLinux)(this.consumer.getPathRelativeToConsumer(path().resolve(opts.writeToPath))) : this.consumer.composeRelativeComponentPath(
|
|
250
|
+
getWriteParamsOfOneComponent(component, opts) {
|
|
251
|
+
const componentRootDir = opts.writeToPath ? (0, _path2().pathNormalizeToLinux)(this.consumer.getPathRelativeToConsumer(path().resolve(opts.writeToPath))) : this.consumer.composeRelativeComponentPath(component.id);
|
|
255
252
|
const getParams = () => {
|
|
256
253
|
if (!this.consumer) {
|
|
257
254
|
return {};
|
|
258
255
|
}
|
|
259
256
|
// components can't be saved with multiple versions, so we can ignore the version to find the component in bit.map
|
|
260
|
-
const componentMap = this.consumer.bitMap.getComponentIfExist(
|
|
257
|
+
const componentMap = this.consumer.bitMap.getComponentIfExist(component.id, {
|
|
261
258
|
ignoreVersion: true
|
|
262
259
|
});
|
|
263
260
|
this.throwErrorWhenDirectoryNotEmpty(this.consumer.toAbsolutePath(componentRootDir), componentMap, opts);
|
|
@@ -268,28 +265,26 @@ class ComponentWriterMain {
|
|
|
268
265
|
return _objectSpread({
|
|
269
266
|
consumer: this.consumer,
|
|
270
267
|
bitMap: this.consumer.bitMap,
|
|
271
|
-
component
|
|
268
|
+
component,
|
|
272
269
|
writeToPath: componentRootDir,
|
|
273
270
|
writeConfig: opts.writeConfig
|
|
274
271
|
}, getParams());
|
|
275
272
|
}
|
|
276
273
|
moveComponentsIfNeeded(opts) {
|
|
277
274
|
if (opts.writeToPath && this.consumer) {
|
|
278
|
-
opts.
|
|
279
|
-
|
|
280
|
-
const componentMap = componentWithDeps.component.componentMap;
|
|
275
|
+
opts.components.forEach(component => {
|
|
276
|
+
const componentMap = component.componentMap;
|
|
281
277
|
if (!componentMap.rootDir) {
|
|
282
278
|
throw new (_generalError().default)(`unable to use "--path" flag.
|
|
283
279
|
to move individual files, use bit move.
|
|
284
280
|
to move all component files to a different directory, run bit remove and then bit import --path`);
|
|
285
281
|
}
|
|
286
|
-
const relativeWrittenPath =
|
|
282
|
+
const relativeWrittenPath = component.writtenPath;
|
|
287
283
|
// @ts-ignore relativeWrittenPath is set at this point
|
|
288
284
|
const absoluteWrittenPath = this.consumer.toAbsolutePath(relativeWrittenPath);
|
|
289
285
|
// @ts-ignore this.writeToPath is set at this point
|
|
290
286
|
const absoluteWriteToPath = path().resolve(opts.writeToPath); // don't use consumer.toAbsolutePath, it might be an inner dir
|
|
291
287
|
if (relativeWrittenPath && absoluteWrittenPath !== absoluteWriteToPath) {
|
|
292
|
-
const component = componentWithDeps.component;
|
|
293
288
|
this.mover.moveExistingComponent(component, absoluteWrittenPath, absoluteWriteToPath);
|
|
294
289
|
}
|
|
295
290
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ComponentWriterMain","constructor","installer","compiler","workspace","logger","mover","consumer","writeMany","opts","debug","populateComponentsFilesToWrite","moveComponentsIfNeeded","persistComponentsData","installationError","compilationError","skipDependencyInstallation","installPackagesGracefully","compileGracefully","writeBitMap","installOpts","dedupe","updateExisting","import","install","undefined","err","consoleFailure","message","error","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","MoverAspect","MainRuntime","addRuntime"],"sources":["component-writer.main.runtime.ts"],"sourcesContent":["import { MainRuntime } from '@teambit/cli';\nimport { CompilerAspect, CompilerMain } from '@teambit/compiler';\nimport InstallAspect, { InstallMain } from '@teambit/install';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport fs from 'fs-extra';\nimport mapSeries from 'p-map-series';\nimport * as path from 'path';\nimport MoverAspect, { MoverMain } from '@teambit/mover';\nimport GeneralError from '@teambit/legacy/dist/error/general-error';\nimport { ComponentWithDependencies } from '@teambit/legacy/dist/scope';\nimport { isDir, isDirEmptySync } from '@teambit/legacy/dist/utils';\nimport { PathLinuxRelative, pathNormalizeToLinux, PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';\nimport ComponentMap from '@teambit/legacy/dist/consumer/bit-map/component-map';\nimport DataToPersist from '@teambit/legacy/dist/consumer/component/sources/data-to-persist';\nimport Consumer from '@teambit/legacy/dist/consumer/consumer';\nimport ComponentWriter, { ComponentWriterProps } from './component-writer';\nimport { ComponentWriterAspect } from './component-writer.aspect';\n\nexport interface ManyComponentsWriterParams {\n componentsWithDependencies: ComponentWithDependencies[];\n writeToPath?: string;\n throwForExistingDir?: boolean;\n writeConfig?: boolean;\n skipDependencyInstallation?: boolean;\n verbose?: boolean;\n resetConfig?: boolean;\n}\n\nexport type ComponentWriterResults = { installationError?: Error; compilationError?: Error };\n\nexport class ComponentWriterMain {\n constructor(\n private installer: InstallMain,\n private compiler: CompilerMain,\n private workspace: Workspace,\n private logger: Logger,\n private mover: MoverMain\n ) {}\n\n get consumer(): Consumer {\n return this.workspace.consumer;\n }\n\n async writeMany(opts: ManyComponentsWriterParams): Promise<ComponentWriterResults> {\n this.logger.debug('writeMany, started');\n await this.populateComponentsFilesToWrite(opts);\n this.moveComponentsIfNeeded(opts);\n await this.persistComponentsData(opts);\n let installationError: Error | undefined;\n let compilationError: Error | undefined;\n if (!opts.skipDependencyInstallation) {\n installationError = await this.installPackagesGracefully();\n // no point to compile if the installation is not running. the environment is not ready.\n compilationError = await this.compileGracefully();\n }\n await this.consumer.writeBitMap();\n this.logger.debug('writeMany, completed!');\n return { installationError, compilationError };\n }\n\n private async installPackagesGracefully(): 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 };\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 const dataToPersist = new DataToPersist();\n opts.componentsWithDependencies.forEach((componentWithDeps) => {\n const allComponents = [componentWithDeps.component, ...componentWithDeps.allDependencies];\n allComponents.forEach((component) => dataToPersist.merge(component.dataToPersist));\n });\n const componentsConfig = this.consumer?.config?.componentsConfig;\n if (componentsConfig?.hasChanged) {\n const jsonFiles = await this.consumer?.config.toVinyl(this.consumer.getPath());\n if (jsonFiles) {\n dataToPersist.addManyFiles(jsonFiles);\n }\n }\n dataToPersist.addBasePath(this.consumer.getPath());\n await dataToPersist.persistAllToFS();\n }\n private async populateComponentsFilesToWrite(opts: ManyComponentsWriterParams) {\n const writeComponentsParams = opts.componentsWithDependencies.map((componentWithDeps: ComponentWithDependencies) =>\n this.getWriteParamsOfOneComponent(componentWithDeps, opts)\n );\n const componentWriterInstances = writeComponentsParams.map((writeParams) => new ComponentWriter(writeParams));\n this.fixDirsIfNested(componentWriterInstances);\n // add componentMap entries into .bitmap before starting the process because steps like writing package-json\n // rely on .bitmap to determine whether a dependency exists and what's its origin\n componentWriterInstances.forEach((componentWriter: ComponentWriter) => {\n componentWriter.existingComponentMap =\n componentWriter.existingComponentMap || componentWriter.addComponentToBitMap(componentWriter.writeToPath);\n });\n if (opts.resetConfig) {\n componentWriterInstances.forEach((componentWriter: ComponentWriter) => {\n delete componentWriter.existingComponentMap?.config;\n });\n }\n await mapSeries(componentWriterInstances, (componentWriter: ComponentWriter) =>\n componentWriter.populateComponentsFilesToWrite()\n );\n }\n /**\n * e.g. [bar, bar/foo] => [bar_1, bar/foo]\n * otherwise, the bar/foo component will be saved inside \"bar\" component.\n * in case bar_1 is taken, increment to bar_2 until the name is available.\n */\n private fixDirsIfNested(componentWriterInstances: ComponentWriter[]) {\n const allDirs = componentWriterInstances.map((c) => c.writeToPath);\n\n // get all components that their root-dir is a parent of other components root-dir.\n const parentsOfOthersComps = componentWriterInstances.filter(({ writeToPath }) =>\n allDirs.find((d) => d.startsWith(`${writeToPath}/`))\n );\n if (!parentsOfOthersComps.length) {\n return;\n }\n const parentsOfOthersCompsDirs = parentsOfOthersComps.map((c) => c.writeToPath);\n\n const incrementPath = (p: string, number: number) => `${p}_${number}`;\n const existingRootDirs = Object.keys(this.consumer.bitMap.getAllTrackDirs());\n const allPaths: PathLinuxRelative[] = [...existingRootDirs, ...parentsOfOthersCompsDirs];\n const incrementRecursively = (p: string) => {\n let num = 1;\n let newPath = incrementPath(p, num);\n while (allPaths.includes(newPath)) {\n newPath = incrementPath(p, (num += 1));\n }\n return newPath;\n };\n\n // change the paths of all these parents root-dir to not collide with the children root-dir\n parentsOfOthersComps.forEach((componentWriter) => {\n if (existingRootDirs.includes(componentWriter.writeToPath)) return; // component already exists.\n const newPath = incrementRecursively(componentWriter.writeToPath);\n componentWriter.writeToPath = newPath;\n });\n }\n\n private getWriteParamsOfOneComponent(\n componentWithDeps: ComponentWithDependencies,\n opts: ManyComponentsWriterParams\n ): ComponentWriterProps {\n const componentRootDir: PathLinuxRelative = opts.writeToPath\n ? pathNormalizeToLinux(this.consumer.getPathRelativeToConsumer(path.resolve(opts.writeToPath)))\n : this.consumer.composeRelativeComponentPath(componentWithDeps.component.id);\n const getParams = () => {\n if (!this.consumer) {\n return {};\n }\n // components can't be saved with multiple versions, so we can ignore the version to find the component in bit.map\n const componentMap = this.consumer.bitMap.getComponentIfExist(componentWithDeps.component.id, {\n ignoreVersion: true,\n });\n this.throwErrorWhenDirectoryNotEmpty(this.consumer.toAbsolutePath(componentRootDir), componentMap, opts);\n return {\n existingComponentMap: componentMap,\n };\n };\n return {\n consumer: this.consumer,\n bitMap: this.consumer.bitMap,\n component: componentWithDeps.component,\n writeToPath: componentRootDir,\n writeConfig: opts.writeConfig,\n ...getParams(),\n };\n }\n private moveComponentsIfNeeded(opts: ManyComponentsWriterParams) {\n if (opts.writeToPath && this.consumer) {\n opts.componentsWithDependencies.forEach((componentWithDeps) => {\n // @ts-ignore componentWithDeps.component.componentMap is set\n const componentMap: ComponentMap = componentWithDeps.component.componentMap;\n if (!componentMap.rootDir) {\n throw new GeneralError(`unable to use \"--path\" flag.\nto move individual files, use bit move.\nto move all component files to a different directory, run bit remove and then bit import --path`);\n }\n const relativeWrittenPath = componentWithDeps.component.writtenPath;\n // @ts-ignore relativeWrittenPath is set at this point\n const absoluteWrittenPath = this.consumer.toAbsolutePath(relativeWrittenPath);\n // @ts-ignore this.writeToPath is set at this point\n const absoluteWriteToPath = path.resolve(opts.writeToPath); // don't use consumer.toAbsolutePath, it might be an inner dir\n if (relativeWrittenPath && absoluteWrittenPath !== absoluteWriteToPath) {\n const component = componentWithDeps.component;\n this.mover.moveExistingComponent(component, absoluteWrittenPath, absoluteWriteToPath);\n }\n });\n }\n }\n private throwErrorWhenDirectoryNotEmpty(\n componentDir: PathOsBasedAbsolute,\n componentMap: ComponentMap | null | undefined,\n opts: ManyComponentsWriterParams\n ) {\n // if not writeToPath specified, it goes to the default directory. When componentMap exists, the\n // component is not new, and it's ok to override the existing directory.\n if (!opts.writeToPath && componentMap) return;\n // if writeToPath specified and that directory is already used for that component, it's ok to override\n if (opts.writeToPath && componentMap && componentMap.rootDir && componentMap.rootDir === opts.writeToPath) return;\n\n if (fs.pathExistsSync(componentDir)) {\n if (!isDir(componentDir)) {\n throw new GeneralError(`unable to import to ${componentDir} because it's a file`);\n }\n if (!isDirEmptySync(componentDir) && opts.throwForExistingDir) {\n throw new GeneralError(\n `unable to import to ${componentDir}, the directory is not empty. use --override flag to delete the directory and then import`\n );\n }\n }\n }\n\n static slots = [];\n static dependencies = [InstallAspect, CompilerAspect, LoggerAspect, WorkspaceAspect, MoverAspect];\n static runtime = MainRuntime;\n static async provider([install, compiler, loggerMain, workspace, mover]: [\n InstallMain,\n CompilerMain,\n LoggerMain,\n Workspace,\n MoverMain\n ]) {\n const logger = loggerMain.createLogger(ComponentWriterAspect.id);\n return new ComponentWriterMain(install, compiler, workspace, logger, mover);\n }\n}\n\nComponentWriterAspect.addRuntime(ComponentWriterMain);\n\nexport default ComponentWriterMain;\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;AAAkE;AAAA;AAAA;AAAA;AAc3D,MAAMA,mBAAmB,CAAC;EAC/BC,WAAW,CACDC,SAAsB,EACtBC,QAAsB,EACtBC,SAAoB,EACpBC,MAAc,EACdC,KAAgB,EACxB;IAAA,KALQJ,SAAsB,GAAtBA,SAAsB;IAAA,KACtBC,QAAsB,GAAtBA,QAAsB;IAAA,KACtBC,SAAoB,GAApBA,SAAoB;IAAA,KACpBC,MAAc,GAAdA,MAAc;IAAA,KACdC,KAAgB,GAAhBA,KAAgB;EACvB;EAEH,IAAIC,QAAQ,GAAa;IACvB,OAAO,IAAI,CAACH,SAAS,CAACG,QAAQ;EAChC;EAEA,MAAMC,SAAS,CAACC,IAAgC,EAAmC;IACjF,IAAI,CAACJ,MAAM,CAACK,K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,0BAAc,EAAEC,sBAAY,EAAEC,oBAAe,EAAEC,gBAAW,CAAC;AAAA,gCA9MtFvH,mBAAmB,aA+MbwH,kBAAW;AAa9BN,yCAAqB,CAACO,UAAU,CAACzH,mBAAmB,CAAC;AAAC,eAEvCA,mBAAmB;AAAA"}
|
|
1
|
+
{"version":3,"names":["ComponentWriterMain","constructor","installer","compiler","workspace","logger","mover","consumer","writeMany","opts","debug","populateComponentsFilesToWrite","moveComponentsIfNeeded","persistComponentsData","installationError","compilationError","skipDependencyInstallation","installPackagesGracefully","compileGracefully","writeBitMap","installOpts","dedupe","updateExisting","import","install","undefined","err","consoleFailure","message","error","compileOnWorkspace","dataToPersist","DataToPersist","components","forEach","component","merge","componentsConfig","config","hasChanged","jsonFiles","toVinyl","getPath","addManyFiles","addBasePath","persistAllToFS","writeComponentsParams","map","getWriteParamsOfOneComponent","componentWriterInstances","writeParams","ComponentWriter","fixDirsIfNested","componentWriter","existingComponentMap","addComponentToBitMap","writeToPath","resetConfig","mapSeries","allDirs","c","parentsOfOthersComps","filter","find","d","startsWith","length","parentsOfOthersCompsDirs","incrementPath","p","number","existingRootDirs","Object","keys","bitMap","getAllTrackDirs","allPaths","incrementRecursively","num","newPath","includes","componentRootDir","pathNormalizeToLinux","getPathRelativeToConsumer","path","resolve","composeRelativeComponentPath","id","getParams","componentMap","getComponentIfExist","ignoreVersion","throwErrorWhenDirectoryNotEmpty","toAbsolutePath","writeConfig","rootDir","GeneralError","relativeWrittenPath","writtenPath","absoluteWrittenPath","absoluteWriteToPath","moveExistingComponent","componentDir","fs","pathExistsSync","isDir","isDirEmptySync","throwForExistingDir","provider","loggerMain","createLogger","ComponentWriterAspect","InstallAspect","CompilerAspect","LoggerAspect","WorkspaceAspect","MoverAspect","MainRuntime","addRuntime"],"sources":["component-writer.main.runtime.ts"],"sourcesContent":["import { MainRuntime } from '@teambit/cli';\nimport { CompilerAspect, CompilerMain } from '@teambit/compiler';\nimport InstallAspect, { InstallMain } from '@teambit/install';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport fs from 'fs-extra';\nimport mapSeries from 'p-map-series';\nimport * as path from 'path';\nimport MoverAspect, { MoverMain } from '@teambit/mover';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport GeneralError from '@teambit/legacy/dist/error/general-error';\nimport { isDir, isDirEmptySync } from '@teambit/legacy/dist/utils';\nimport { PathLinuxRelative, pathNormalizeToLinux, PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';\nimport ComponentMap from '@teambit/legacy/dist/consumer/bit-map/component-map';\nimport DataToPersist from '@teambit/legacy/dist/consumer/component/sources/data-to-persist';\nimport Consumer from '@teambit/legacy/dist/consumer/consumer';\nimport ComponentWriter, { ComponentWriterProps } from './component-writer';\nimport { ComponentWriterAspect } from './component-writer.aspect';\n\nexport interface ManyComponentsWriterParams {\n components: ConsumerComponent[];\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; compilationError?: Error };\n\nexport class ComponentWriterMain {\n constructor(\n private installer: InstallMain,\n private compiler: CompilerMain,\n private workspace: Workspace,\n private logger: Logger,\n private mover: MoverMain\n ) {}\n\n get consumer(): Consumer {\n return this.workspace.consumer;\n }\n\n async writeMany(opts: ManyComponentsWriterParams): Promise<ComponentWriterResults> {\n this.logger.debug('writeMany, started');\n await this.populateComponentsFilesToWrite(opts);\n this.moveComponentsIfNeeded(opts);\n await this.persistComponentsData(opts);\n let installationError: Error | undefined;\n let compilationError: Error | undefined;\n if (!opts.skipDependencyInstallation) {\n installationError = await this.installPackagesGracefully();\n // no point to compile if the installation is not running. the environment is not ready.\n compilationError = await this.compileGracefully();\n }\n await this.consumer.writeBitMap();\n this.logger.debug('writeMany, completed!');\n return { installationError, compilationError };\n }\n\n private async installPackagesGracefully(): 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 };\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 const dataToPersist = new DataToPersist();\n opts.components.forEach((component) => dataToPersist.merge(component.dataToPersist));\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.components.map((component) =>\n this.getWriteParamsOfOneComponent(component, 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 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(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,\n writeToPath: componentRootDir,\n writeConfig: opts.writeConfig,\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 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 = 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 componentDir: PathOsBasedAbsolute,\n componentMap: ComponentMap | null | undefined,\n opts: ManyComponentsWriterParams\n ) {\n // if not writeToPath specified, it goes to the default directory. When componentMap exists, the\n // component is not new, and it's ok to override the existing directory.\n if (!opts.writeToPath && componentMap) return;\n // if writeToPath specified and that directory is already used for that component, it's ok to override\n if (opts.writeToPath && componentMap && componentMap.rootDir && componentMap.rootDir === opts.writeToPath) return;\n\n if (fs.pathExistsSync(componentDir)) {\n if (!isDir(componentDir)) {\n throw new GeneralError(`unable to import to ${componentDir} because it's a file`);\n }\n if (!isDirEmptySync(componentDir) && opts.throwForExistingDir) {\n throw new GeneralError(\n `unable to import to ${componentDir}, the directory is not empty. use --override flag to delete the directory and then import`\n );\n }\n }\n }\n\n static slots = [];\n static dependencies = [InstallAspect, CompilerAspect, LoggerAspect, WorkspaceAspect, MoverAspect];\n static runtime = MainRuntime;\n static async provider([install, compiler, loggerMain, workspace, mover]: [\n InstallMain,\n CompilerMain,\n LoggerMain,\n Workspace,\n MoverMain\n ]) {\n const logger = loggerMain.createLogger(ComponentWriterAspect.id);\n return new ComponentWriterMain(install, compiler, workspace, logger, mover);\n }\n}\n\nComponentWriterAspect.addRuntime(ComponentWriterMain);\n\nexport default ComponentWriterMain;\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;AAEA;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;AAEA;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,EACtBC,SAAoB,EACpBC,MAAc,EACdC,KAAgB,EACxB;IAAA,KALQJ,SAAsB,GAAtBA,SAAsB;IAAA,KACtBC,QAAsB,GAAtBA,QAAsB;IAAA,KACtBC,SAAoB,GAApBA,SAAoB;IAAA,KACpBC,MAAc,GAAdA,MAAc;IAAA,KACdC,KAAgB,GAAhBA,KAAgB;EACvB;EAEH,IAAIC,QAAQ,GAAa;IACvB,OAAO,IAAI,CAACH,S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 -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/component-writer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.30",
|
|
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.
|
|
9
|
+
"version": "0.0.30"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"fs-extra": "10.0.0",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"core-js": "^3.0.0",
|
|
15
15
|
"@babel/runtime": "7.20.0",
|
|
16
16
|
"@teambit/harmony": "0.4.6",
|
|
17
|
-
"@teambit/cli": "0.0.
|
|
18
|
-
"@teambit/compiler": "0.0.
|
|
19
|
-
"@teambit/install": "0.0.
|
|
20
|
-
"@teambit/logger": "0.0.
|
|
21
|
-
"@teambit/mover": "0.0.
|
|
22
|
-
"@teambit/workspace": "0.0.
|
|
17
|
+
"@teambit/cli": "0.0.668",
|
|
18
|
+
"@teambit/compiler": "0.0.994",
|
|
19
|
+
"@teambit/install": "0.0.117",
|
|
20
|
+
"@teambit/logger": "0.0.761",
|
|
21
|
+
"@teambit/mover": "0.0.25",
|
|
22
|
+
"@teambit/workspace": "0.0.994"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/fs-extra": "9.0.7",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@types/testing-library__jest-dom": "5.9.5"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@teambit/legacy": "1.0.
|
|
34
|
+
"@teambit/legacy": "1.0.449",
|
|
35
35
|
"react": "^16.8.0 || ^17.0.0",
|
|
36
36
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
37
37
|
},
|
|
Binary file
|
|
File without changes
|