@teambit/tracker 1.0.1174 → 1.0.1176
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/add-cmd.d.ts +2 -1
- package/dist/add-cmd.js +5 -3
- package/dist/add-cmd.js.map +1 -1
- package/dist/add-components.d.ts +35 -2
- package/dist/add-components.js +259 -40
- package/dist/add-components.js.map +1 -1
- package/dist/add-components.spec.d.ts +1 -0
- package/dist/add-components.spec.js +205 -0
- package/dist/add-components.spec.js.map +1 -0
- package/dist/determine-main-file.js +10 -1
- package/dist/determine-main-file.js.map +1 -1
- package/dist/determine-main-file.spec.d.ts +1 -0
- package/dist/determine-main-file.spec.js +231 -0
- package/dist/determine-main-file.spec.js.map +1 -0
- package/dist/track-workspace-root.spec.d.ts +1 -0
- package/dist/track-workspace-root.spec.js +377 -0
- package/dist/track-workspace-root.spec.js.map +1 -0
- package/dist/tracker.main.runtime.d.ts +8 -1
- package/dist/tracker.main.runtime.js +2 -1
- package/dist/tracker.main.runtime.js.map +1 -1
- package/package.json +20 -16
- /package/dist/{preview-1789911586102.js → preview-1790183760587.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_arrayDifference","data","_interopRequireDefault","require","_firstline","_fsExtra","_ignore","path","_interopRequireWildcard","_lodash","_stringFormat","_legacy","_componentId","_legacyBitId","_legacy2","_legacy3","_exceptions","_addingIndividualFiles","_missingMainFileMultipleComponents","_parentDirTracked","_pathOutsideConsumer","_versionShouldBeRemoved","_bitError","_legacy4","_legacy5","_glob","_workspaceModules","_determineMainFile","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","REGEX_DSL_PATTERN","AddComponents","constructor","context","addProps","workspace","consumer","bitMap","componentPaths","id","main","namespace","override","trackDirFeature","warnings","alreadyUsed","emptyDirectory","existInScope","addedComponents","defaultScope","config","shouldHandleOutOfSync","add","ignoreList","getIgnoreList","gitIgnore","ignore","componentPathsStats","resolvedComponentPathsWithoutGitIgnore","Promise","all","map","componentPath","glob","pathNormalizeToLinux","flat","resolvedComponentPathsWithGitIgnore","filter","diff","arrayDiff","length","PathsNotExist","validatePaths","NoFiles","keys","forEach","compPath","isDir","AddingIndividualFiles","BitError","isMultipleComponents","addMultipleComponents","logger","debugAndAddBreadCrumb","addedOne","addOneComponent","_removeNamespaceIfNotNeeded","files","addedResult","addOrUpdateComponentInBitMap","push","linkComponents","item","Analytics","setExtraData","getFilesAccordingToDsl","filesWithPotentialDsl","filesListAllMatches","dsl","filesListMatch","file","fileInfo","calculateFileInfo","generatedFile","format","matches","matchesAfterGitIgnore","match","fs","existsSync","filesListFlatten","filesListUnique","uniq","fileNormalized","fileWithCorrectCase","find","toLowerCase","relativeToConsumer","getPathRelativeToConsumer","_isPackageJsonOnRootDir","pathRelativeToConsumerRoot","componentMap","rootDir","Error","join","PACKAGE_JSON","normalize","_isOutsideOfWrapDir","wrapDir","wrapDirRelativeToConsumerRoot","startsWith","component","consumerPath","getPath","parsedBitId","componentId","componentFromScope","scope","getModelComponentIfExist","foundComponentFromBitMap","getComponentIfExist","ignoreVersion","componentFilesP","filePath","relativePath","isAutoGenerated","isAutoGeneratedFile","caseSensitive","existingIdOfFile","getComponentIdByPath","idOfFileIsDifferent","isEqual","newId","toComponentIdWithLatestVersion","componentFiles","_updateFilesAccordingToExistingRootDir","_areFilesArraysEqual","_updateFilesWithCurrentLetterCases","_mergeFilesWithExistingComponentMapFiles","trackDir","mainFile","determineMainFile","getRootDir","fileNotInsideTrackDir","getComponentMap","addFilesToComponent","getDefaultScope","hasScope","undefined","fullName","addComponent","ComponentID","changeRootDirAndUpdateFilesAccordingly","existingRootDir","areFilesInsideExistingRootDir","every","ComponentMap","changeFilesPathAccordingToItsRootDir","currentlyAddedDir","currentlyAddedDirParentOfRootDir","existingComponentMapFile","unionBy","currentComponentMap","newFiles","currentFiles","currentFile","sameFile","newFile","_getIdAccordingToExistingComponent","currentId","idWithScope","existingComponentId","getExistingBitId","includes","VERSION_DELIMITER","hasVersion","version","getVersionFromString","VersionShouldBeRemoved","_getIdAccordingToTrackDir","dir","dirNormalizedToLinux","trackDirs","getAllTrackDirs","_addMainFileToFiles","foundFile","_findMainFileInFiles","shouldIgnore","ignores","ExcludedMainFile","name","basename","mainFileRelativeToConsumer","mainPath","toAbsolutePath","MainFileIsDir","normalizedMainFile","componentName","componentDefaultScopeFromComponentDirAndName","finalBitId","idFromPath","relativeComponentPath","_throwForOutsideConsumer","throwForExistingParentDir","cwd","nodir","EmptyDirectory","filteredMatches","filteredMatchedFiles","test","resolvedMainFile","absoluteComponentPath","resolve","splitPath","split","lastDir","idOfTrackDir","bitId","BitId","parse","nameSpaceOrDir","getValidIdChunk","getValidBitId","addedComp","immediateDir","getIgnoreListHarmony","ignoredFiles","ids","linkToNodeModulesByIds","_removeDirectoriesWhenTheirFilesAreAdded","added","_tryAddingMultiple","validateNoDuplicateIds","_addMultipleToBitMap","allPaths","foundDir","p","dirname","debug","missingMainFiles","addedComponent","err","MissingMainFile","MissingMainFileMultipleComponents","sort","allIds","getAllBitIdsFromAllLanes","componentsWithSameName","a","bitIdFromNameOnly","componentIdFromNameOnly","existingComponentWithSameName","searchWithoutScopeAndVersion","addedP","onePath","compact","relativeToConsumerPath","PathOutsideConsumer","exports","isParentDir","parent","relative","isAbsolute","components","ParentDirTracked","toStringWithoutVersion","fileArray","addComponents","duplicateIds","newGroupedComponents","groupBy","key","isEmpty","DuplicateIds","fullPath","parentDir","PARENT","FILE_NAME","line","firstline","AUTO_GENERATED_STAMP","addMultipleFromResolvedTrackData","trackData","componentMaps","filtered","fromObject","c"],"sources":["add-components.ts"],"sourcesContent":["import arrayDiff from 'array-difference';\nimport firstline from 'firstline';\nimport fs from 'fs-extra';\nimport ignore from 'ignore';\nimport * as path from 'path';\nimport { compact, groupBy, isEmpty, unionBy, uniq } from 'lodash';\nimport format from 'string-format';\nimport { Analytics } from '@teambit/legacy.analytics';\nimport { ComponentID } from '@teambit/component-id';\nimport type { BitIdStr } from '@teambit/legacy-bit-id';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { PACKAGE_JSON, VERSION_DELIMITER, AUTO_GENERATED_STAMP } from '@teambit/legacy.constants';\nimport type { BitMap, ComponentMapFile, Config } from '@teambit/legacy.bit-map';\nimport { ComponentMap, getIgnoreListHarmony, MissingMainFile } from '@teambit/legacy.bit-map';\nimport { DuplicateIds, EmptyDirectory, ExcludedMainFile, MainFileIsDir, NoFiles, PathsNotExist } from './exceptions';\nimport { AddingIndividualFiles } from './exceptions/adding-individual-files';\nimport MissingMainFileMultipleComponents from './exceptions/missing-main-file-multiple-components';\nimport { ParentDirTracked } from './exceptions/parent-dir-tracked';\nimport PathOutsideConsumer from './exceptions/path-outside-consumer';\nimport VersionShouldBeRemoved from './exceptions/version-should-be-removed';\nimport type { Consumer } from '@teambit/legacy.consumer';\nimport { BitError } from '@teambit/bit-error';\nimport { logger } from '@teambit/legacy.logger';\nimport type { PathLinux, PathLinuxRelative, PathOsBased } from '@teambit/legacy.utils';\nimport { isDir, pathNormalizeToLinux } from '@teambit/legacy.utils';\nimport { glob } from 'glob';\nimport { linkToNodeModulesByIds } from '@teambit/workspace.modules.node-modules-linker';\nimport type { Workspace } from '@teambit/workspace';\nimport determineMainFile from './determine-main-file';\nimport type { ResolvedTrackData } from './tracker.main.runtime';\n\nexport type AddResult = { id: ComponentID; files: ComponentMapFile[] };\nexport type Warnings = {\n alreadyUsed: Record<string, any>;\n emptyDirectory: string[];\n existInScope: ComponentID[];\n};\nexport type AddActionResults = { addedComponents: AddResult[]; warnings: Warnings };\nexport type PathOrDSL = PathOsBased | string; // can be a path or a DSL, e.g: tests/{PARENT}/{FILE_NAME}\n// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\ntype PathsStats = { [PathOsBased]: { isDir: boolean } };\nexport type AddedComponent = {\n componentId: ComponentID;\n files: ComponentMapFile[];\n mainFile?: PathOsBased | null | undefined;\n trackDir: PathOsBased;\n idFromPath:\n | {\n name: string;\n namespace: string;\n }\n | null\n | undefined;\n immediateDir?: string;\n};\nconst REGEX_DSL_PATTERN = /{([^}]+)}/g;\n\nexport type AddProps = {\n componentPaths: PathOsBased[];\n id?: string;\n main?: PathOsBased;\n namespace?: string;\n override: boolean;\n trackDirFeature?: boolean;\n defaultScope?: string;\n config?: Config;\n shouldHandleOutOfSync?: boolean;\n env?: string;\n};\n\nexport type AddContext = {\n workspace: Workspace;\n};\n\nexport default class AddComponents {\n workspace: Workspace;\n consumer: Consumer;\n bitMap: BitMap;\n componentPaths: PathOsBased[];\n id: string | null | undefined; // id entered by the user\n main: PathOsBased | null | undefined;\n namespace: string | null | undefined;\n override: boolean; // (default = false) replace the files array or only add files.\n trackDirFeature: boolean | null | undefined;\n warnings: Warnings;\n ignoreList: string[];\n gitIgnore: any;\n addedComponents: AddResult[];\n defaultScope?: string; // helpful for out-of-sync\n config?: Config;\n shouldHandleOutOfSync?: boolean; // only bit-add (not bit-create/new) should handle out-of-sync scenario\n constructor(context: AddContext, addProps: AddProps) {\n this.workspace = context.workspace;\n this.consumer = context.workspace.consumer;\n this.bitMap = this.consumer.bitMap;\n this.componentPaths = addProps.componentPaths;\n this.id = addProps.id;\n this.main = addProps.main;\n this.namespace = addProps.namespace;\n this.override = addProps.override;\n this.trackDirFeature = addProps.trackDirFeature;\n this.warnings = {\n alreadyUsed: {},\n emptyDirectory: [],\n existInScope: [],\n };\n this.addedComponents = [];\n this.defaultScope = addProps.defaultScope;\n this.config = addProps.config;\n this.shouldHandleOutOfSync = addProps.shouldHandleOutOfSync;\n }\n\n async add(): Promise<AddActionResults> {\n this.ignoreList = await this.getIgnoreList();\n this.gitIgnore = ignore().add(this.ignoreList); // add ignore list\n\n let componentPathsStats: PathsStats = {};\n\n const resolvedComponentPathsWithoutGitIgnore = (\n await Promise.all(this.componentPaths.map((componentPath) => glob(pathNormalizeToLinux(componentPath))))\n ).flat();\n\n const resolvedComponentPathsWithGitIgnore = this.gitIgnore.filter(resolvedComponentPathsWithoutGitIgnore);\n // Run diff on both arrays to see what was filtered out because of the gitignore file\n // this is not the same as \"lodash.difference\".\n const diff = arrayDiff(resolvedComponentPathsWithGitIgnore, resolvedComponentPathsWithoutGitIgnore);\n\n if (!resolvedComponentPathsWithoutGitIgnore.length) {\n throw new PathsNotExist(this.componentPaths);\n }\n if (resolvedComponentPathsWithGitIgnore.length) {\n componentPathsStats = validatePaths(resolvedComponentPathsWithGitIgnore);\n } else {\n throw new NoFiles(diff);\n }\n Object.keys(componentPathsStats).forEach((compPath) => {\n if (!componentPathsStats[compPath].isDir) {\n throw new AddingIndividualFiles(compPath);\n }\n });\n if (Object.keys(componentPathsStats).length > 1 && this.id) {\n throw new BitError(\n `the --id flag (${this.id}) is used for a single component only, however, got ${this.componentPaths.length} paths`\n );\n }\n // if a user entered multiple paths and entered an id, he wants all these paths to be one component\n // conversely, if a user entered multiple paths without id, he wants each dir as an individual component\n const isMultipleComponents = Object.keys(componentPathsStats).length > 1;\n if (isMultipleComponents) {\n await this.addMultipleComponents(componentPathsStats);\n } else {\n logger.debugAndAddBreadCrumb('add-components', 'adding one component');\n // when a user enters more than one directory, he would like to keep the directories names\n // so then when a component is imported, it will write the files into the original directories\n const addedOne = await this.addOneComponent(Object.keys(componentPathsStats)[0]);\n await this._removeNamespaceIfNotNeeded([addedOne]);\n if (addedOne.files.length) {\n const addedResult = await this.addOrUpdateComponentInBitMap(addedOne);\n if (addedResult) this.addedComponents.push(addedResult);\n }\n }\n await this.linkComponents(this.addedComponents.map((item) => item.id));\n Analytics.setExtraData('num_components', this.addedComponents.length);\n return { addedComponents: this.addedComponents, warnings: this.warnings };\n }\n\n /**\n * @param {string[]} files - array of file-paths from which it should search for the dsl patterns.\n * @param {*} filesWithPotentialDsl - array of file-path which may have DSL patterns\n *\n * @returns array of file-paths from 'files' parameter that match the patterns from 'filesWithPotentialDsl' parameter\n */\n async getFilesAccordingToDsl(files: PathLinux[], filesWithPotentialDsl: PathOrDSL[]): Promise<PathLinux[]> {\n const filesListAllMatches = filesWithPotentialDsl.map(async (dsl) => {\n const filesListMatch = files.map(async (file) => {\n const fileInfo = calculateFileInfo(file);\n const generatedFile = format(dsl, fileInfo);\n const matches = await glob(generatedFile);\n const matchesAfterGitIgnore = this.gitIgnore.filter(matches);\n return matchesAfterGitIgnore.filter((match) => fs.existsSync(match));\n });\n return Promise.all(filesListMatch);\n });\n\n const filesListFlatten = (await Promise.all(filesListAllMatches)).flat();\n const filesListUnique = uniq(filesListFlatten);\n return filesListUnique.map((file) => {\n // when files array has the test file with different letter case, use the one from the file array\n const fileNormalized = pathNormalizeToLinux(file);\n const fileWithCorrectCase = files.find((f) => f.toLowerCase() === fileNormalized.toLowerCase()) || fileNormalized;\n const relativeToConsumer = this.consumer.getPathRelativeToConsumer(fileWithCorrectCase);\n return pathNormalizeToLinux(relativeToConsumer);\n });\n }\n\n /**\n * for imported component, the package.json in the root directory is a bit-generated file and as\n * such, it should be ignored\n */\n _isPackageJsonOnRootDir(pathRelativeToConsumerRoot: PathLinux, componentMap: ComponentMap) {\n if (!componentMap.rootDir) {\n throw new Error('_isPackageJsonOnRootDir should not get called on non imported components');\n }\n return path.join(componentMap.rootDir, PACKAGE_JSON) === path.normalize(pathRelativeToConsumerRoot);\n }\n\n /**\n * imported components might have wrapDir, when they do, files should not be added outside of\n * that wrapDir\n */\n _isOutsideOfWrapDir(pathRelativeToConsumerRoot: PathLinux, componentMap: ComponentMap) {\n if (!componentMap.rootDir) {\n throw new Error('_isOutsideOfWrapDir should not get called on non imported components');\n }\n if (!componentMap.wrapDir) return false;\n const wrapDirRelativeToConsumerRoot = path.join(componentMap.rootDir, componentMap.wrapDir);\n return !path.normalize(pathRelativeToConsumerRoot).startsWith(wrapDirRelativeToConsumerRoot);\n }\n\n /**\n * Add or update existing (imported and new) component according to bitmap\n * there are 3 options:\n * 1. a user is adding a new component. there is no record for this component in bit.map\n * 2. a user is updating an existing component. there is a record for this component in bit.map\n * 3. some or all the files of this component were previously added as another component-id.\n */\n async addOrUpdateComponentInBitMap(component: AddedComponent): Promise<AddResult | null | undefined> {\n const consumerPath = this.consumer.getPath();\n const parsedBitId = component.componentId;\n const componentFromScope = await this.consumer.scope.getModelComponentIfExist(parsedBitId);\n const files: ComponentMapFile[] = component.files;\n const foundComponentFromBitMap = this.bitMap.getComponentIfExist(component.componentId, {\n ignoreVersion: true,\n });\n const componentFilesP = files.map(async (file: ComponentMapFile) => {\n // $FlowFixMe null is removed later on\n const filePath = path.join(consumerPath, file.relativePath);\n const isAutoGenerated = await isAutoGeneratedFile(filePath);\n if (isAutoGenerated) {\n return null;\n }\n const caseSensitive = false;\n const existingIdOfFile = this.bitMap.getComponentIdByPath(file.relativePath, caseSensitive);\n const idOfFileIsDifferent = existingIdOfFile && !existingIdOfFile.isEqual(parsedBitId);\n if (idOfFileIsDifferent) {\n // not imported component file but exists in bitmap\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n if (this.warnings.alreadyUsed[existingIdOfFile]) {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n this.warnings.alreadyUsed[existingIdOfFile].push(file.relativePath);\n } else {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n this.warnings.alreadyUsed[existingIdOfFile] = [file.relativePath];\n }\n return null;\n }\n if (!foundComponentFromBitMap && componentFromScope && this.shouldHandleOutOfSync) {\n const newId = componentFromScope.toComponentIdWithLatestVersion();\n if (!this.defaultScope || this.defaultScope === newId.scope) {\n // otherwise, if defaultScope !== newId.scope, they're different components,\n // and no need to change the id.\n // for more details about this scenario, see https://github.com/teambit/bit/issues/1543, last case.\n component.componentId = newId;\n this.warnings.existInScope.push(newId);\n }\n }\n return file;\n });\n // @ts-ignore it can't be null due to the filter function\n const componentFiles: ComponentMapFile[] = (await Promise.all(componentFilesP)).filter((file) => file);\n if (!componentFiles.length) return { id: component.componentId, files: [] };\n if (foundComponentFromBitMap) {\n this._updateFilesAccordingToExistingRootDir(foundComponentFromBitMap, componentFiles, component);\n }\n if (this.trackDirFeature) {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n if (this.bitMap._areFilesArraysEqual(foundComponentFromBitMap.files, componentFiles)) {\n return foundComponentFromBitMap;\n }\n }\n if (!this.override && foundComponentFromBitMap) {\n this._updateFilesWithCurrentLetterCases(foundComponentFromBitMap, componentFiles);\n component.files = this._mergeFilesWithExistingComponentMapFiles(componentFiles, foundComponentFromBitMap.files);\n } else {\n component.files = componentFiles;\n }\n\n const { componentId, trackDir } = component;\n const mainFile = determineMainFile(component, foundComponentFromBitMap);\n const getRootDir = (): PathLinuxRelative => {\n if (this.trackDirFeature) throw new Error('track dir should not calculate the rootDir');\n if (foundComponentFromBitMap) return foundComponentFromBitMap.rootDir;\n if (!trackDir) throw new Error(`addOrUpdateComponentInBitMap expect to have trackDir for non-legacy workspace`);\n const fileNotInsideTrackDir = componentFiles.find(\n (file) => !pathNormalizeToLinux(file.relativePath).startsWith(`${pathNormalizeToLinux(trackDir)}/`)\n );\n if (fileNotInsideTrackDir) {\n // we check for this error before. however, it's possible that a user have one trackDir\n // and another dir for the tests.\n throw new AddingIndividualFiles(fileNotInsideTrackDir.relativePath);\n }\n return pathNormalizeToLinux(trackDir);\n };\n const getComponentMap = async (): Promise<ComponentMap> => {\n if (this.trackDirFeature) {\n return this.bitMap.addFilesToComponent({ componentId, files: component.files });\n }\n const rootDir = getRootDir();\n const getDefaultScope = async () => {\n if (componentId.hasScope()) return undefined;\n return this.getDefaultScope(rootDir, componentId.fullName);\n };\n const defaultScope = await getDefaultScope();\n const componentMap = this.bitMap.addComponent({\n componentId: new ComponentID(componentId._legacy, defaultScope),\n files: component.files,\n defaultScope,\n config: this.config,\n mainFile,\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n override: this.override,\n });\n componentMap.changeRootDirAndUpdateFilesAccordingly(rootDir);\n return componentMap;\n };\n const componentMap = await getComponentMap();\n return { id: componentId, files: componentMap.files };\n }\n\n /**\n * current componentFiles are relative to the workspace. we want them relative to the rootDir.\n */\n _updateFilesAccordingToExistingRootDir(\n foundComponentFromBitMap: ComponentMap,\n componentFiles: ComponentMapFile[],\n component: AddedComponent\n ) {\n const existingRootDir = foundComponentFromBitMap.rootDir;\n if (!existingRootDir) return; // nothing to do.\n const areFilesInsideExistingRootDir = componentFiles.every((file) =>\n pathNormalizeToLinux(file.relativePath).startsWith(`${existingRootDir}/`)\n );\n if (areFilesInsideExistingRootDir) {\n ComponentMap.changeFilesPathAccordingToItsRootDir(existingRootDir, componentFiles);\n return;\n }\n // some (or all) added files are outside the existing rootDir, the rootDir needs to be changed\n // if a directory was added and it's a parent of the existing rootDir, change the rootDir to\n // the currently added rootDir.\n const currentlyAddedDir = pathNormalizeToLinux(component.trackDir);\n const currentlyAddedDirParentOfRootDir = currentlyAddedDir && existingRootDir.startsWith(`${currentlyAddedDir}/`);\n if (currentlyAddedDirParentOfRootDir) {\n foundComponentFromBitMap.changeRootDirAndUpdateFilesAccordingly(currentlyAddedDir);\n ComponentMap.changeFilesPathAccordingToItsRootDir(currentlyAddedDir, componentFiles);\n return;\n }\n throw new BitError(`unable to add individual files outside the root dir (${existingRootDir}) of ${component.componentId}.\nyou can add the directory these files are located at and it'll change the root dir of the component accordingly`);\n // we might want to change the behavior here to not throw an error and only change the rootDir to \".\"\n // foundComponentFromBitMap.changeRootDirAndUpdateFilesAccordingly('.');\n }\n\n /**\n * the risk with merging the currently added files with the existing bitMap files is overriding\n * the `test` property. e.g. the component directory is re-added without adding the tests flag to\n * track new files in that directory. in this case, we want to preserve the `test` property.\n */\n _mergeFilesWithExistingComponentMapFiles(\n componentFiles: ComponentMapFile[],\n existingComponentMapFile: ComponentMapFile[]\n ) {\n return unionBy(existingComponentMapFile, componentFiles, 'relativePath');\n }\n\n /**\n * if an existing file is for example uppercase and the new file is lowercase it has different\n * behavior according to the OS. some OS are case sensitive, some are not.\n * it's safer to avoid saving both files and instead, replacing the old file with the new one.\n * in case a file has replaced and it is also a mainFile, replace the mainFile as well\n */\n _updateFilesWithCurrentLetterCases(currentComponentMap: ComponentMap, newFiles: ComponentMapFile[]) {\n const currentFiles = currentComponentMap.files;\n currentFiles.forEach((currentFile) => {\n const sameFile = newFiles.find(\n (newFile) => newFile.relativePath.toLowerCase() === currentFile.relativePath.toLowerCase()\n );\n if (sameFile && currentFile.relativePath !== sameFile.relativePath) {\n if (currentComponentMap.mainFile === currentFile.relativePath) {\n currentComponentMap.mainFile = sameFile.relativePath;\n }\n currentFile.relativePath = sameFile.relativePath;\n }\n });\n }\n\n /**\n * if the id is already saved in bitmap file, it might have more data (such as scope, version)\n * use that id instead.\n */\n private _getIdAccordingToExistingComponent(currentId: BitIdStr): ComponentID | undefined {\n const idWithScope = this.defaultScope ? `${this.defaultScope}/${currentId}` : currentId;\n const existingComponentId = this.bitMap.getExistingBitId(idWithScope, false);\n if (currentId.includes(VERSION_DELIMITER)) {\n if (\n !existingComponentId || // this id is new, it shouldn't have a version\n !existingComponentId.hasVersion() || // this component is new, it shouldn't have a version\n // user shouldn't add files to a an existing component with different version\n existingComponentId.version !== ComponentID.getVersionFromString(currentId)\n ) {\n throw new VersionShouldBeRemoved(currentId);\n }\n }\n return existingComponentId;\n }\n\n _getIdAccordingToTrackDir(dir: PathOsBased): ComponentID | null | undefined {\n const dirNormalizedToLinux = pathNormalizeToLinux(dir);\n const trackDirs = this.bitMap.getAllTrackDirs();\n if (!trackDirs) return null;\n return trackDirs[dirNormalizedToLinux];\n }\n\n /**\n * used for updating main file if exists or doesn't exists\n */\n _addMainFileToFiles(files: ComponentMapFile[]): PathOsBased | null | undefined {\n let mainFile = this.main;\n if (mainFile && mainFile.match(REGEX_DSL_PATTERN)) {\n // it's a DSL\n files.forEach((file) => {\n const fileInfo = calculateFileInfo(file.relativePath);\n const generatedFile = format(mainFile, fileInfo);\n const foundFile = this._findMainFileInFiles(generatedFile, files);\n if (foundFile) {\n mainFile = foundFile.relativePath;\n }\n if (fs.existsSync(generatedFile) && !foundFile) {\n const shouldIgnore = this.gitIgnore.ignores(generatedFile);\n if (shouldIgnore) {\n // check if file is in exclude list\n throw new ExcludedMainFile(generatedFile);\n }\n files.push({\n relativePath: pathNormalizeToLinux(generatedFile),\n name: path.basename(generatedFile),\n });\n mainFile = generatedFile;\n }\n });\n }\n if (!mainFile) return undefined;\n const mainFileRelativeToConsumer = this.consumer.getPathRelativeToConsumer(mainFile);\n const mainPath = this.consumer.toAbsolutePath(mainFileRelativeToConsumer);\n if (fs.existsSync(mainPath)) {\n const shouldIgnore = this.gitIgnore.ignores(mainFileRelativeToConsumer);\n if (shouldIgnore) throw new ExcludedMainFile(mainFileRelativeToConsumer);\n if (isDir(mainPath)) {\n throw new MainFileIsDir(mainPath);\n }\n const foundFile = this._findMainFileInFiles(mainFileRelativeToConsumer, files);\n if (foundFile) {\n return foundFile.relativePath;\n }\n files.push({\n relativePath: pathNormalizeToLinux(mainFileRelativeToConsumer),\n name: path.basename(mainFileRelativeToConsumer),\n });\n return mainFileRelativeToConsumer;\n }\n return mainFile;\n }\n\n _findMainFileInFiles(mainFile: string, files: ComponentMapFile[]) {\n const normalizedMainFile = pathNormalizeToLinux(mainFile).toLowerCase();\n return files.find((file) => file.relativePath.toLowerCase() === normalizedMainFile);\n }\n\n private async getDefaultScope(rootDir: string, componentName: string): Promise<string> {\n return (this.defaultScope ||\n (await this.workspace.componentDefaultScopeFromComponentDirAndName(rootDir, componentName))) as string;\n }\n\n /**\n * given the component paths, prepare the id, mainFile and files to be added later on to bitmap\n * the id of the component is either entered by the user or, if not entered, concluded by the path.\n * e.g. bar/foo.js, the id would be bar/foo.\n * in case bitmap has already the same id, the complete id is taken from bitmap (see _getIdAccordingToExistingComponent)\n */\n async addOneComponent(componentPath: PathOsBased): Promise<AddedComponent> {\n let finalBitId: ComponentID | undefined; // final id to use for bitmap file\n let idFromPath;\n if (this.id) {\n finalBitId = this._getIdAccordingToExistingComponent(this.id);\n }\n const relativeComponentPath = this.consumer.getPathRelativeToConsumer(componentPath);\n this._throwForOutsideConsumer(relativeComponentPath);\n throwForExistingParentDir(this.bitMap, relativeComponentPath);\n const matches = await glob(pathNormalizeToLinux(path.join(relativeComponentPath, '**')), {\n cwd: this.consumer.getPath(),\n nodir: true,\n });\n\n if (!matches.length) throw new EmptyDirectory(componentPath);\n\n const filteredMatches = this.gitIgnore.filter(matches);\n\n if (!filteredMatches.length) {\n throw new NoFiles(matches);\n }\n\n const filteredMatchedFiles = filteredMatches.map((match: PathOsBased) => {\n return { relativePath: pathNormalizeToLinux(match), test: false, name: path.basename(match) };\n });\n const resolvedMainFile = this._addMainFileToFiles(filteredMatchedFiles);\n\n const absoluteComponentPath = pathNormalizeToLinux(path.resolve(componentPath));\n const splitPath = absoluteComponentPath.split('/');\n const lastDir = splitPath[splitPath.length - 1];\n const idOfTrackDir = this._getIdAccordingToTrackDir(componentPath);\n if (!finalBitId) {\n if (this.id) {\n const bitId = BitId.parse(this.id, false);\n const defaultScope = await this.getDefaultScope(relativeComponentPath, bitId.name);\n finalBitId = new ComponentID(bitId, defaultScope);\n } else if (idOfTrackDir) {\n finalBitId = idOfTrackDir;\n } else {\n const nameSpaceOrDir = this.namespace || splitPath[splitPath.length - 2];\n if (!this.namespace) {\n idFromPath = { namespace: BitId.getValidIdChunk(nameSpaceOrDir), name: BitId.getValidIdChunk(lastDir) };\n }\n const bitId = BitId.getValidBitId(nameSpaceOrDir, lastDir);\n const defaultScope = await this.getDefaultScope(relativeComponentPath, bitId.name);\n finalBitId = new ComponentID(bitId, defaultScope);\n }\n }\n const trackDir = relativeComponentPath;\n const addedComp = {\n componentId: finalBitId,\n files: filteredMatchedFiles,\n mainFile: resolvedMainFile,\n trackDir,\n idFromPath,\n immediateDir: lastDir,\n };\n\n return addedComp;\n }\n\n async getIgnoreList(): Promise<string[]> {\n const consumerPath = this.consumer.getPath();\n return getIgnoreListHarmony(consumerPath, this.consumer.config.ignoredFiles);\n }\n\n async linkComponents(ids: ComponentID[]) {\n if (this.trackDirFeature) {\n // if trackDirFeature is set, it happens during the component-load and because we load the\n // components in the next line, it gets into an infinite loop.\n return;\n }\n await linkToNodeModulesByIds(this.workspace, ids);\n }\n\n async addMultipleComponents(componentPathsStats: PathsStats): Promise<void> {\n logger.debugAndAddBreadCrumb('add-components', 'adding multiple components');\n this._removeDirectoriesWhenTheirFilesAreAdded(componentPathsStats);\n const added = await this._tryAddingMultiple(componentPathsStats);\n validateNoDuplicateIds(added);\n await this._removeNamespaceIfNotNeeded(added);\n await this._addMultipleToBitMap(added);\n }\n\n /**\n * some uses of wildcards might add directories and their files at the same time, in such cases\n * only the files are needed and the directories can be ignored.\n * @see https://github.com/teambit/bit/issues/1406 for more details\n */\n _removeDirectoriesWhenTheirFilesAreAdded(componentPathsStats: PathsStats) {\n const allPaths = Object.keys(componentPathsStats);\n allPaths.forEach((componentPath) => {\n const foundDir = allPaths.find((p) => p === path.dirname(componentPath));\n if (foundDir && componentPathsStats[foundDir]) {\n logger.debug(`add-components._removeDirectoriesWhenTheirFilesAreAdded, ignoring ${foundDir}`);\n delete componentPathsStats[foundDir];\n }\n });\n }\n\n async _addMultipleToBitMap(added: AddedComponent[]): Promise<void> {\n const missingMainFiles = [];\n await Promise.all(\n added.map(async (component) => {\n if (component.files.length) {\n try {\n const addedComponent = await this.addOrUpdateComponentInBitMap(component);\n if (addedComponent && addedComponent.files.length) this.addedComponents.push(addedComponent);\n } catch (err: any) {\n if (!(err instanceof MissingMainFile)) throw err;\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n missingMainFiles.push(err);\n }\n }\n })\n );\n if (missingMainFiles.length) {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n throw new MissingMainFileMultipleComponents(missingMainFiles.map((err) => err.componentId).sort());\n }\n }\n\n async _removeNamespaceIfNotNeeded(addedComponents: AddedComponent[]) {\n const allIds = this.bitMap.getAllBitIdsFromAllLanes();\n await Promise.all(\n addedComponents.map(async (addedComponent) => {\n if (!addedComponent.idFromPath) return; // when the id was not generated from the path do nothing.\n const componentsWithSameName = addedComponents.filter(\n (a) => a.idFromPath && a.idFromPath.name === addedComponent.idFromPath?.name\n );\n const bitIdFromNameOnly = new BitId({ name: addedComponent.idFromPath.name });\n const defaultScope = await this.getDefaultScope(addedComponent.trackDir, bitIdFromNameOnly.name);\n const componentIdFromNameOnly = new ComponentID(bitIdFromNameOnly, defaultScope);\n const existingComponentWithSameName = allIds.searchWithoutScopeAndVersion(componentIdFromNameOnly);\n if (componentsWithSameName.length === 1 && !existingComponentWithSameName) {\n addedComponent.componentId = componentIdFromNameOnly;\n }\n })\n );\n }\n\n async _tryAddingMultiple(componentPathsStats: PathsStats): Promise<AddedComponent[]> {\n const addedP = Object.keys(componentPathsStats).map(async (onePath) => {\n try {\n const addedComponent = await this.addOneComponent(onePath);\n return addedComponent;\n } catch (err: any) {\n if (!(err instanceof EmptyDirectory)) throw err;\n this.warnings.emptyDirectory.push(onePath);\n return null;\n }\n });\n const added = await Promise.all(addedP);\n return compact(added);\n }\n\n _throwForOutsideConsumer(relativeToConsumerPath: PathOsBased) {\n if (relativeToConsumerPath.startsWith('..')) {\n throw new PathOutsideConsumer(relativeToConsumerPath);\n }\n }\n}\n\nfunction throwForExistingParentDir(bitMap: BitMap, relativeToConsumerPath: PathOsBased) {\n const isParentDir = (parent: string) => {\n const relative = path.relative(parent, relativeToConsumerPath);\n return relative && !relative.startsWith('..') && !path.isAbsolute(relative);\n };\n bitMap.components.forEach((componentMap) => {\n if (!componentMap.rootDir) return;\n if (isParentDir(componentMap.rootDir)) {\n throw new ParentDirTracked(\n componentMap.rootDir,\n componentMap.id.toStringWithoutVersion(),\n relativeToConsumerPath\n );\n }\n });\n}\n\n/**\n * validatePaths - validate if paths entered by user exist and if not throw an error\n *\n * @param {string[]} fileArray - array of paths\n * @returns {PathsStats} componentPathsStats\n */\nfunction validatePaths(fileArray: string[]): PathsStats {\n const componentPathsStats = {};\n fileArray.forEach((componentPath) => {\n if (!fs.existsSync(componentPath)) {\n throw new PathsNotExist([componentPath]);\n }\n componentPathsStats[componentPath] = {\n isDir: isDir(componentPath),\n };\n });\n return componentPathsStats;\n}\n\n/**\n * validate that no two files where added with the same id in the same bit add command\n */\nfunction validateNoDuplicateIds(addComponents: Record<string, any>[]) {\n const duplicateIds = {};\n const newGroupedComponents = groupBy(addComponents, 'componentId');\n Object.keys(newGroupedComponents).forEach((key) => {\n if (newGroupedComponents[key].length > 1) duplicateIds[key] = newGroupedComponents[key];\n });\n if (!isEmpty(duplicateIds)) throw new DuplicateIds(duplicateIds);\n}\n\n/**\n * get the current working dir name of file and file name.\n * @name fileInfo\n * @param relativePath\n * @returns {object}\n * @example\n * ```js\n * currentDirName() // => 'bit'\n * ```\n */\nfunction calculateFileInfo(relativePath: string): { PARENT: string; FILE_NAME: string } {\n const fileInfo = path.parse(relativePath);\n const fullPath = path.dirname(relativePath);\n const rootDir = path.dirname(fullPath);\n const parentDir = path.relative(rootDir, fullPath);\n return { PARENT: parentDir, FILE_NAME: fileInfo.name };\n}\n\nasync function isAutoGeneratedFile(filePath: PathOsBased): Promise<boolean> {\n const line = await firstline(filePath);\n return line.includes(AUTO_GENERATED_STAMP);\n}\n\nexport async function addMultipleFromResolvedTrackData(\n workspace: Workspace,\n trackData: ResolvedTrackData[]\n): Promise<ComponentID[]> {\n const bitMap = workspace.consumer.bitMap;\n const ignoreList = await getIgnoreListHarmony(workspace.path, workspace.consumer.config.ignoredFiles);\n const gitIgnore = ignore().add(ignoreList);\n const componentMaps = trackData.map((data) => {\n const { rootDir, files, componentName, defaultScope, mainFile, config } = data;\n if (path.isAbsolute(rootDir)) throw new BitError(`path is absolute, got ${rootDir}`);\n throwForExistingParentDir(bitMap, rootDir);\n\n const filtered = gitIgnore.filter(files);\n if (!filtered.length) {\n throw new NoFiles(files);\n }\n\n const componentFiles = filtered.map((match: PathOsBased) => {\n return { relativePath: pathNormalizeToLinux(match), name: path.basename(match) };\n });\n\n const componentMap = bitMap.addComponent({\n componentId: ComponentID.fromObject({ name: componentName }, defaultScope),\n files: componentFiles,\n defaultScope,\n config,\n mainFile,\n rootDir,\n });\n return componentMap;\n });\n\n const allIds = componentMaps.map((c) => c.id);\n await linkToNodeModulesByIds(workspace, allIds);\n\n return allIds;\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,iBAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,gBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,WAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,KAAA;EAAA,MAAAN,IAAA,GAAAO,uBAAA,CAAAL,OAAA;EAAAI,IAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,QAAA;EAAA,MAAAR,IAAA,GAAAE,OAAA;EAAAM,OAAA,YAAAA,CAAA;IAAA,OAAAR,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAS,cAAA;EAAA,MAAAT,IAAA,GA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AAC;MAC1EsC,KAAK,EAAEmE,cAAc;MACrBzG,YAAY;MACZC,MAAM;MACN8G,QAAQ;MACRtC;IACF,CAAC,CAAC;IACF,OAAOD,YAAY;EACrB,CAAC,CAAC;EAEF,MAAMgJ,MAAM,GAAGsC,aAAa,CAAClP,GAAG,CAAEqP,CAAC,IAAKA,CAAC,CAAC3Q,EAAE,CAAC;EAC7C,MAAM,IAAAiN,0CAAsB,EAACrN,SAAS,EAAEsO,MAAM,CAAC;EAE/C,OAAOA,MAAM;AACf","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_arrayDifference","data","_interopRequireDefault","require","_firstline","_fsExtra","_ignore","path","_interopRequireWildcard","_lodash","_stringFormat","_legacy","_componentId","_legacyBitId","_legacy2","_legacy3","_exceptions","_addingIndividualFiles","_missingMainFileMultipleComponents","_parentDirTracked","_pathOutsideConsumer","_versionShouldBeRemoved","_bitError","_legacy4","_legacy5","_glob","_workspaceModules","_determineMainFile","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","REGEX_DSL_PATTERN","AddComponents","constructor","context","addProps","workspace","consumer","bitMap","componentPaths","id","main","namespace","override","trackDirFeature","warnings","alreadyUsed","emptyDirectory","existInScope","addedComponents","defaultScope","config","shouldHandleOutOfSync","root","isWorkspaceRootPath","onePath","pathNormalizeToLinux","getPathRelativeToConsumer","WORKSPACE_ROOT_DIR","throwForWorkspaceRootFlagMismatch","resolvedPaths","tracksRoot","some","getWorkspaceRootMap","BitError","add","ignoreList","getIgnoreList","gitIgnore","ignore","componentPathsStats","resolvedComponentPathsWithoutGitIgnore","Promise","all","map","componentPath","glob","flat","resolvedComponentPathsWithGitIgnore","diff","arrayDiff","PathsNotExist","validatePaths","NoFiles","compPath","isDir","AddingIndividualFiles","isMultipleComponents","addMultipleComponents","logger","debugAndAddBreadCrumb","addedOne","addOneComponent","_removeNamespaceIfNotNeeded","files","addedResult","addOrUpdateComponentInBitMap","linkComponents","item","Analytics","setExtraData","getFilesAccordingToDsl","filesWithPotentialDsl","filesListAllMatches","dsl","filesListMatch","file","fileInfo","calculateFileInfo","generatedFile","format","matches","matchesAfterGitIgnore","match","fs","existsSync","filesListFlatten","filesListUnique","uniq","fileNormalized","fileWithCorrectCase","find","toLowerCase","relativeToConsumer","_isPackageJsonOnRootDir","pathRelativeToConsumerRoot","componentMap","rootDir","Error","join","PACKAGE_JSON","normalize","_isOutsideOfWrapDir","wrapDir","wrapDirRelativeToConsumerRoot","startsWith","component","consumerPath","getPath","parsedBitId","componentId","componentFromScope","scope","getModelComponentIfExist","foundComponentFromBitMap","getComponentIfExist","ignoreVersion","workspaceRootMap","isWorkspaceRoot","trackDir","isEqualWithoutVersion","throwForTakingWorkspaceRootMainFile","componentFilesP","filePath","relativePath","isAutoGenerated","isAutoGeneratedFile","keepAutoGenerated","trackAllFiles","isWorkspaceMapFile","caseSensitive","existingIdOfFile","getComponentIdByPath","idOfFileIsDifferent","isEqual","ownedByWorkspaceRoot","Boolean","newId","toComponentIdWithLatestVersion","componentFiles","_updateFilesAccordingToExistingRootDir","_areFilesArraysEqual","_updateFilesWithCurrentLetterCases","_mergeFilesWithExistingComponentMapFiles","mainFile","determineMainFile","getRootDir","fileNotInsideTrackDir","undefined","getComponentMap","addFilesToComponent","getDefaultScope","hasScope","fullName","addComponent","ComponentID","configForWorkspaceRoot","changeRootDirAndUpdateFilesAccordingly","existingRootDir","areFilesInsideExistingRootDir","every","ComponentMap","changeFilesPathAccordingToItsRootDir","currentlyAddedDir","currentlyAddedDirParentOfRootDir","existingComponentMapFile","unionBy","currentComponentMap","newFiles","currentFiles","currentFile","sameFile","newFile","_getIdAccordingToExistingComponent","currentId","idWithScope","existingComponentId","getExistingBitId","includes","VERSION_DELIMITER","hasVersion","version","getVersionFromString","VersionShouldBeRemoved","_getIdAccordingToTrackDir","dir","dirNormalizedToLinux","trackDirs","getAllTrackDirs","_addMainFileToFiles","foundFile","_findMainFileInFiles","shouldIgnore","ignores","ExcludedMainFile","name","basename","mainFileRelativeToConsumer","mainPath","toAbsolutePath","MainFileIsDir","normalizedMainFile","componentName","componentDefaultScopeFromComponentDirAndName","batchRootDirs","finalBitId","idFromPath","relativeComponentPath","_throwForOutsideConsumer","idOfTrackDir","idToAdd","throwForExistingParentDir","nestedRootDirs","getNestedRootDirs","other","cwd","nodir","dot","getScanIgnorePatterns","EmptyDirectory","generatedAtRoot","Set","IGNORE_ROOT_ONLY_LIST","matchesNotIgnored","filterByIgnoreFiles","relativeToComponent","posix","relative","keptByOwnIgnoreFile","filterByOwnIgnoreFile","isTrackable","filteredMatches","filteredMatchedFiles","test","resolvedMainFile","mainNormalized","inFileSet","excludedFromScan","filterByScanIgnorePatterns","excludedByIgnoreRules","absoluteComponentPath","resolve","splitPath","split","lastDir","bitId","BitId","parse","nameSpaceOrDir","getValidIdChunk","getValidBitId","addedComp","immediateDir","getIgnoreListHarmony","ignoredFiles","ids","linkToNodeModulesByIds","_removeDirectoriesWhenTheirFilesAreAdded","added","_tryAddingMultiple","validateNoDuplicateIds","_addMultipleToBitMap","allPaths","foundDir","p","dirname","debug","missingMainFiles","addedComponent","err","MissingMainFile","MissingMainFileMultipleComponents","sort","allIds","getAllBitIdsFromAllLanes","componentsWithSameName","a","bitIdFromNameOnly","componentIdFromNameOnly","existingComponentWithSameName","searchWithoutScopeAndVersion","addedP","compact","relativeToConsumerPath","PathOutsideConsumer","exports","addedId","currentOwner","getComponentIdByRootPath","toStringWithoutVersion","isParentDir","parent","isAbsolute","components","ParentDirTracked","fileArray","addComponents","duplicateIds","newGroupedComponents","groupBy","key","isEmpty","DuplicateIds","fullPath","parentDir","PARENT","FILE_NAME","line","firstline","AUTO_GENERATED_STAMP","WORKSPACE_ROOT_ENV","existingConfig","addedConfig","configuredEnv","Extensions","envs","env","addMultipleFromResolvedTrackData","trackData","normalizeRootDir","componentMaps","fromObject","existingEntry","idToTrack","WORKSPACE_JSONC","scanWorkspaceRootFiles","filterResolvedFiles","c","toString","getFilesByDir","notGenerated","workspaceRelative","filteredByWorkspaceRules","filtered"],"sources":["add-components.ts"],"sourcesContent":["import arrayDiff from 'array-difference';\nimport firstline from 'firstline';\nimport fs from 'fs-extra';\nimport ignore from 'ignore';\nimport * as path from 'path';\nimport { compact, groupBy, isEmpty, unionBy, uniq } from 'lodash';\nimport format from 'string-format';\nimport { Analytics } from '@teambit/legacy.analytics';\nimport { ComponentID } from '@teambit/component-id';\nimport type { BitIdStr } from '@teambit/legacy-bit-id';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport {\n PACKAGE_JSON,\n VERSION_DELIMITER,\n AUTO_GENERATED_STAMP,\n IGNORE_ROOT_ONLY_LIST,\n Extensions,\n WORKSPACE_JSONC,\n} from '@teambit/legacy.constants';\nimport type { BitMap, ComponentMapFile, Config } from '@teambit/legacy.bit-map';\nimport {\n ComponentMap,\n filterByIgnoreFiles,\n filterByOwnIgnoreFile,\n filterByScanIgnorePatterns,\n getFilesByDir,\n getIgnoreListHarmony,\n getScanIgnorePatterns,\n isWorkspaceMapFile,\n MissingMainFile,\n WORKSPACE_ROOT_DIR,\n} from '@teambit/legacy.bit-map';\nimport { DuplicateIds, EmptyDirectory, ExcludedMainFile, MainFileIsDir, NoFiles, PathsNotExist } from './exceptions';\nimport { AddingIndividualFiles } from './exceptions/adding-individual-files';\nimport MissingMainFileMultipleComponents from './exceptions/missing-main-file-multiple-components';\nimport { ParentDirTracked } from './exceptions/parent-dir-tracked';\nimport PathOutsideConsumer from './exceptions/path-outside-consumer';\nimport VersionShouldBeRemoved from './exceptions/version-should-be-removed';\nimport type { Consumer } from '@teambit/legacy.consumer';\nimport { BitError } from '@teambit/bit-error';\nimport { logger } from '@teambit/legacy.logger';\nimport type { PathLinux, PathLinuxRelative, PathOsBased } from '@teambit/legacy.utils';\nimport { isDir, pathNormalizeToLinux } from '@teambit/legacy.utils';\nimport { glob } from 'glob';\nimport { linkToNodeModulesByIds } from '@teambit/workspace.modules.node-modules-linker';\nimport type { Workspace } from '@teambit/workspace';\nimport determineMainFile from './determine-main-file';\nimport type { ResolvedTrackData } from './tracker.main.runtime';\n\nexport type AddResult = { id: ComponentID; files: ComponentMapFile[] };\nexport type Warnings = {\n alreadyUsed: Record<string, any>;\n emptyDirectory: string[];\n existInScope: ComponentID[];\n};\nexport type AddActionResults = { addedComponents: AddResult[]; warnings: Warnings };\nexport type PathOrDSL = PathOsBased | string; // can be a path or a DSL, e.g: tests/{PARENT}/{FILE_NAME}\n// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\ntype PathsStats = { [PathOsBased]: { isDir: boolean } };\nexport type AddedComponent = {\n componentId: ComponentID;\n files: ComponentMapFile[];\n mainFile?: PathOsBased | null | undefined;\n trackDir: PathOsBased;\n idFromPath:\n | {\n name: string;\n namespace: string;\n }\n | null\n | undefined;\n immediateDir?: string;\n};\nconst REGEX_DSL_PATTERN = /{([^}]+)}/g;\n\nexport type AddProps = {\n componentPaths: PathOsBased[];\n id?: string;\n main?: PathOsBased;\n namespace?: string;\n override: boolean;\n trackDirFeature?: boolean;\n defaultScope?: string;\n config?: Config;\n shouldHandleOutOfSync?: boolean;\n env?: string;\n /**\n * spells out the intent to track the workspace root itself. required for it and only for it, see\n * AddComponents.throwForWorkspaceRootFlagMismatch.\n */\n root?: boolean;\n};\n\nexport type AddContext = {\n workspace: Workspace;\n};\n\nexport default class AddComponents {\n workspace: Workspace;\n consumer: Consumer;\n bitMap: BitMap;\n componentPaths: PathOsBased[];\n id: string | null | undefined; // id entered by the user\n main: PathOsBased | null | undefined;\n namespace: string | null | undefined;\n override: boolean; // (default = false) replace the files array or only add files.\n trackDirFeature: boolean | null | undefined;\n warnings: Warnings;\n ignoreList: string[];\n gitIgnore: any;\n addedComponents: AddResult[];\n defaultScope?: string; // helpful for out-of-sync\n config?: Config;\n shouldHandleOutOfSync?: boolean; // only bit-add (not bit-create/new) should handle out-of-sync scenario\n root?: boolean;\n constructor(context: AddContext, addProps: AddProps) {\n this.workspace = context.workspace;\n this.consumer = context.workspace.consumer;\n this.bitMap = this.consumer.bitMap;\n this.componentPaths = addProps.componentPaths;\n this.id = addProps.id;\n this.main = addProps.main;\n this.namespace = addProps.namespace;\n this.override = addProps.override;\n this.trackDirFeature = addProps.trackDirFeature;\n this.warnings = {\n alreadyUsed: {},\n emptyDirectory: [],\n existInScope: [],\n };\n this.addedComponents = [];\n this.defaultScope = addProps.defaultScope;\n this.config = addProps.config;\n this.shouldHandleOutOfSync = addProps.shouldHandleOutOfSync;\n this.root = addProps.root;\n }\n\n /**\n * tracking the workspace root turns the workspace itself into a component: it owns every file no\n * other component claims, `.bitmap` included, and every other component becomes a member of it.\n * \"bit add .\" is one keystroke away from \"git add .\", which means something else entirely, so the\n * intent is spelled out rather than inferred from the path.\n *\n * only the workspace root needs the flag, and it is the only thing the flag does: \"bit add .\" from\n * a sub-directory names that directory, not the root, and is tracked like any other path.\n *\n * a workspace that already has a root does not ask again. what the flag guards against is creating\n * one by accident, and there is none to create here - the add either refreshes the root that exists\n * or names a second owner for \".\", which has its own message saying who holds it.\n */\n /**\n * the paths reach here as the user typed them - relative to the cwd, or absolute - so the workspace\n * root arrives as \".\", as \"\", or as the workspace path itself, depending on where the command ran.\n */\n private isWorkspaceRootPath(onePath: PathOsBased): boolean {\n return (\n (pathNormalizeToLinux(this.consumer.getPathRelativeToConsumer(onePath)) || WORKSPACE_ROOT_DIR) ===\n WORKSPACE_ROOT_DIR\n );\n }\n\n private throwForWorkspaceRootFlagMismatch(resolvedPaths: PathOsBased[]) {\n const tracksRoot = resolvedPaths.some((onePath) => this.isWorkspaceRootPath(onePath));\n if (tracksRoot && !this.root && !this.bitMap.getWorkspaceRootMap()) {\n throw new BitError(`unable to track the workspace root without the --root flag.\nit makes the workspace itself a component - it owns every file no other component claims, .bitmap included, and every other component becomes a member of it.\nif that is what you want, run \"bit add . --root\". to track a component, pass its directory, e.g. \"bit add my-component\"`);\n }\n if (!tracksRoot && this.root) {\n throw new BitError(`the --root flag tracks the workspace root, but none of the given paths is the workspace root.\nrun \"bit add . --root\" from the workspace root, or drop the flag to track the given paths as ordinary components`);\n }\n }\n\n async add(): Promise<AddActionResults> {\n this.ignoreList = await this.getIgnoreList();\n this.gitIgnore = ignore().add(this.ignoreList); // add ignore list\n\n let componentPathsStats: PathsStats = {};\n\n const resolvedComponentPathsWithoutGitIgnore = (\n await Promise.all(this.componentPaths.map((componentPath) => glob(pathNormalizeToLinux(componentPath))))\n ).flat();\n\n const resolvedComponentPathsWithGitIgnore = this.gitIgnore.filter(resolvedComponentPathsWithoutGitIgnore);\n // Run diff on both arrays to see what was filtered out because of the gitignore file\n // this is not the same as \"lodash.difference\".\n const diff = arrayDiff(resolvedComponentPathsWithGitIgnore, resolvedComponentPathsWithoutGitIgnore);\n\n if (!resolvedComponentPathsWithoutGitIgnore.length) {\n throw new PathsNotExist(this.componentPaths);\n }\n if (resolvedComponentPathsWithGitIgnore.length) {\n componentPathsStats = validatePaths(resolvedComponentPathsWithGitIgnore);\n } else {\n throw new NoFiles(diff);\n }\n Object.keys(componentPathsStats).forEach((compPath) => {\n if (!componentPathsStats[compPath].isDir) {\n throw new AddingIndividualFiles(compPath);\n }\n });\n this.throwForWorkspaceRootFlagMismatch(Object.keys(componentPathsStats));\n if (Object.keys(componentPathsStats).length > 1 && this.id) {\n throw new BitError(\n `the --id flag (${this.id}) is used for a single component only, however, got ${this.componentPaths.length} paths`\n );\n }\n // if a user entered multiple paths and entered an id, he wants all these paths to be one component\n // conversely, if a user entered multiple paths without id, he wants each dir as an individual component\n const isMultipleComponents = Object.keys(componentPathsStats).length > 1;\n if (isMultipleComponents) {\n await this.addMultipleComponents(componentPathsStats);\n } else {\n logger.debugAndAddBreadCrumb('add-components', 'adding one component');\n // when a user enters more than one directory, he would like to keep the directories names\n // so then when a component is imported, it will write the files into the original directories\n const addedOne = await this.addOneComponent(Object.keys(componentPathsStats)[0]);\n await this._removeNamespaceIfNotNeeded([addedOne]);\n if (addedOne.files.length) {\n const addedResult = await this.addOrUpdateComponentInBitMap(addedOne);\n if (addedResult) this.addedComponents.push(addedResult);\n }\n }\n await this.linkComponents(this.addedComponents.map((item) => item.id));\n Analytics.setExtraData('num_components', this.addedComponents.length);\n return { addedComponents: this.addedComponents, warnings: this.warnings };\n }\n\n /**\n * @param {string[]} files - array of file-paths from which it should search for the dsl patterns.\n * @param {*} filesWithPotentialDsl - array of file-path which may have DSL patterns\n *\n * @returns array of file-paths from 'files' parameter that match the patterns from 'filesWithPotentialDsl' parameter\n */\n async getFilesAccordingToDsl(files: PathLinux[], filesWithPotentialDsl: PathOrDSL[]): Promise<PathLinux[]> {\n const filesListAllMatches = filesWithPotentialDsl.map(async (dsl) => {\n const filesListMatch = files.map(async (file) => {\n const fileInfo = calculateFileInfo(file);\n const generatedFile = format(dsl, fileInfo);\n const matches = await glob(generatedFile);\n const matchesAfterGitIgnore = this.gitIgnore.filter(matches);\n return matchesAfterGitIgnore.filter((match) => fs.existsSync(match));\n });\n return Promise.all(filesListMatch);\n });\n\n const filesListFlatten = (await Promise.all(filesListAllMatches)).flat();\n const filesListUnique = uniq(filesListFlatten);\n return filesListUnique.map((file) => {\n // when files array has the test file with different letter case, use the one from the file array\n const fileNormalized = pathNormalizeToLinux(file);\n const fileWithCorrectCase = files.find((f) => f.toLowerCase() === fileNormalized.toLowerCase()) || fileNormalized;\n const relativeToConsumer = this.consumer.getPathRelativeToConsumer(fileWithCorrectCase);\n return pathNormalizeToLinux(relativeToConsumer);\n });\n }\n\n /**\n * for imported component, the package.json in the root directory is a bit-generated file and as\n * such, it should be ignored\n */\n _isPackageJsonOnRootDir(pathRelativeToConsumerRoot: PathLinux, componentMap: ComponentMap) {\n if (!componentMap.rootDir) {\n throw new Error('_isPackageJsonOnRootDir should not get called on non imported components');\n }\n return path.join(componentMap.rootDir, PACKAGE_JSON) === path.normalize(pathRelativeToConsumerRoot);\n }\n\n /**\n * imported components might have wrapDir, when they do, files should not be added outside of\n * that wrapDir\n */\n _isOutsideOfWrapDir(pathRelativeToConsumerRoot: PathLinux, componentMap: ComponentMap) {\n if (!componentMap.rootDir) {\n throw new Error('_isOutsideOfWrapDir should not get called on non imported components');\n }\n if (!componentMap.wrapDir) return false;\n const wrapDirRelativeToConsumerRoot = path.join(componentMap.rootDir, componentMap.wrapDir);\n return !path.normalize(pathRelativeToConsumerRoot).startsWith(wrapDirRelativeToConsumerRoot);\n }\n\n /**\n * Add or update existing (imported and new) component according to bitmap\n * there are 3 options:\n * 1. a user is adding a new component. there is no record for this component in bit.map\n * 2. a user is updating an existing component. there is a record for this component in bit.map\n * 3. some or all the files of this component were previously added as another component-id.\n */\n async addOrUpdateComponentInBitMap(component: AddedComponent): Promise<AddResult | null | undefined> {\n const consumerPath = this.consumer.getPath();\n const parsedBitId = component.componentId;\n const componentFromScope = await this.consumer.scope.getModelComponentIfExist(parsedBitId);\n const files: ComponentMapFile[] = component.files;\n const foundComponentFromBitMap = this.bitMap.getComponentIfExist(component.componentId, {\n ignoreVersion: true,\n });\n // the workspace-root component owns every file no other component claims, so it \"owns\" a file\n // only until a more specific component is added for it: the component being added wins, and the\n // root subtracts the new root-dir from its own file-set on the next scan. the one file it cannot\n // give away is its main file - without it, it fails to load from the next scan on.\n const workspaceRootMap = this.bitMap.getWorkspaceRootMap();\n const isWorkspaceRoot = component.trackDir === WORKSPACE_ROOT_DIR;\n if (workspaceRootMap && !isWorkspaceRoot && !parsedBitId.isEqualWithoutVersion(workspaceRootMap.id)) {\n throwForTakingWorkspaceRootMainFile(workspaceRootMap, parsedBitId, pathNormalizeToLinux(component.trackDir));\n }\n const componentFilesP = files.map(async (file: ComponentMapFile) => {\n // $FlowFixMe null is removed later on\n const filePath = path.join(consumerPath, file.relativePath);\n // the workspace map carries the auto-generated banner, but the root component tracks it on\n // purpose (see isWorkspaceMapFile), and the rescan keeps it. the add-time file-set does too.\n const isAutoGenerated = await isAutoGeneratedFile(filePath);\n // trackAllFiles keeps the files bit generates, and the rescan never looks at the banner at all\n // (see getFilesByDir) - so dropping them here would leave the add-time file-set short of it.\n const keepAutoGenerated =\n this.consumer.config.trackAllFiles || (isWorkspaceRoot && isWorkspaceMapFile(file.relativePath));\n if (isAutoGenerated && !keepAutoGenerated) {\n return null;\n }\n const caseSensitive = false;\n const existingIdOfFile = this.bitMap.getComponentIdByPath(file.relativePath, caseSensitive);\n const idOfFileIsDifferent = existingIdOfFile && !existingIdOfFile.isEqual(parsedBitId);\n const ownedByWorkspaceRoot = Boolean(\n workspaceRootMap && existingIdOfFile?.isEqualWithoutVersion(workspaceRootMap.id)\n );\n if (idOfFileIsDifferent && !ownedByWorkspaceRoot) {\n // not imported component file but exists in bitmap\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n if (this.warnings.alreadyUsed[existingIdOfFile]) {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n this.warnings.alreadyUsed[existingIdOfFile].push(file.relativePath);\n } else {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n this.warnings.alreadyUsed[existingIdOfFile] = [file.relativePath];\n }\n return null;\n }\n if (!foundComponentFromBitMap && componentFromScope && this.shouldHandleOutOfSync) {\n const newId = componentFromScope.toComponentIdWithLatestVersion();\n if (!this.defaultScope || this.defaultScope === newId.scope) {\n // otherwise, if defaultScope !== newId.scope, they're different components,\n // and no need to change the id.\n // for more details about this scenario, see https://github.com/teambit/bit/issues/1543, last case.\n component.componentId = newId;\n this.warnings.existInScope.push(newId);\n }\n }\n return file;\n });\n // @ts-ignore it can't be null due to the filter function\n const componentFiles: ComponentMapFile[] = (await Promise.all(componentFilesP)).filter((file) => file);\n if (!componentFiles.length) return { id: component.componentId, files: [] };\n if (foundComponentFromBitMap) {\n this._updateFilesAccordingToExistingRootDir(foundComponentFromBitMap, componentFiles, component);\n }\n if (this.trackDirFeature) {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n if (this.bitMap._areFilesArraysEqual(foundComponentFromBitMap.files, componentFiles)) {\n return foundComponentFromBitMap;\n }\n }\n // the root's files are whatever the scan says. a component nested since the previous add owns the\n // files the previous entry listed for the root, so they are not merged back.\n if (!this.override && foundComponentFromBitMap && !isWorkspaceRoot) {\n this._updateFilesWithCurrentLetterCases(foundComponentFromBitMap, componentFiles);\n component.files = this._mergeFilesWithExistingComponentMapFiles(componentFiles, foundComponentFromBitMap.files);\n } else {\n component.files = componentFiles;\n }\n\n const { componentId, trackDir } = component;\n const mainFile = determineMainFile(component, foundComponentFromBitMap);\n const getRootDir = (): PathLinuxRelative => {\n if (this.trackDirFeature) throw new Error('track dir should not calculate the rootDir');\n if (foundComponentFromBitMap) return foundComponentFromBitMap.rootDir;\n if (!trackDir) throw new Error(`addOrUpdateComponentInBitMap expect to have trackDir for non-legacy workspace`);\n // every file in the workspace is inside the workspace root, so there is nothing to check.\n const fileNotInsideTrackDir =\n trackDir === WORKSPACE_ROOT_DIR\n ? undefined\n : componentFiles.find(\n (file) => !pathNormalizeToLinux(file.relativePath).startsWith(`${pathNormalizeToLinux(trackDir)}/`)\n );\n if (fileNotInsideTrackDir) {\n // we check for this error before. however, it's possible that a user have one trackDir\n // and another dir for the tests.\n throw new AddingIndividualFiles(fileNotInsideTrackDir.relativePath);\n }\n return pathNormalizeToLinux(trackDir);\n };\n const getComponentMap = async (): Promise<ComponentMap> => {\n if (this.trackDirFeature) {\n return this.bitMap.addFilesToComponent({ componentId, files: component.files });\n }\n const rootDir = getRootDir();\n const getDefaultScope = async () => {\n if (componentId.hasScope()) return undefined;\n return this.getDefaultScope(rootDir, componentId.fullName);\n };\n const defaultScope = await getDefaultScope();\n const componentMap = this.bitMap.addComponent({\n componentId: new ComponentID(componentId._legacy, defaultScope),\n files: component.files,\n defaultScope,\n config:\n rootDir === WORKSPACE_ROOT_DIR\n ? configForWorkspaceRoot(foundComponentFromBitMap?.config, this.config)\n : this.config,\n mainFile,\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n override: this.override,\n });\n componentMap.changeRootDirAndUpdateFilesAccordingly(rootDir);\n return componentMap;\n };\n const componentMap = await getComponentMap();\n return { id: componentId, files: componentMap.files };\n }\n\n /**\n * current componentFiles are relative to the workspace. we want them relative to the rootDir.\n */\n _updateFilesAccordingToExistingRootDir(\n foundComponentFromBitMap: ComponentMap,\n componentFiles: ComponentMapFile[],\n component: AddedComponent\n ) {\n const existingRootDir = foundComponentFromBitMap.rootDir;\n if (!existingRootDir) return; // nothing to do.\n // every file in the workspace is inside the workspace root, and its paths are already relative\n // to it, so there is nothing to check and nothing to rewrite. without this, re-running\n // \"bit add .\" would compare \"README.md\" against a \"./\" prefix, decide the files are outside the\n // root, and throw.\n if (existingRootDir === WORKSPACE_ROOT_DIR) return;\n const areFilesInsideExistingRootDir = componentFiles.every((file) =>\n pathNormalizeToLinux(file.relativePath).startsWith(`${existingRootDir}/`)\n );\n if (areFilesInsideExistingRootDir) {\n ComponentMap.changeFilesPathAccordingToItsRootDir(existingRootDir, componentFiles);\n return;\n }\n // some (or all) added files are outside the existing rootDir, the rootDir needs to be changed\n // if a directory was added and it's a parent of the existing rootDir, change the rootDir to\n // the currently added rootDir.\n const currentlyAddedDir = pathNormalizeToLinux(component.trackDir);\n const currentlyAddedDirParentOfRootDir = currentlyAddedDir && existingRootDir.startsWith(`${currentlyAddedDir}/`);\n if (currentlyAddedDirParentOfRootDir) {\n foundComponentFromBitMap.changeRootDirAndUpdateFilesAccordingly(currentlyAddedDir);\n ComponentMap.changeFilesPathAccordingToItsRootDir(currentlyAddedDir, componentFiles);\n return;\n }\n throw new BitError(`unable to add individual files outside the root dir (${existingRootDir}) of ${component.componentId}.\nyou can add the directory these files are located at and it'll change the root dir of the component accordingly`);\n // we might want to change the behavior here to not throw an error and only change the rootDir to \".\"\n // foundComponentFromBitMap.changeRootDirAndUpdateFilesAccordingly('.');\n }\n\n /**\n * the risk with merging the currently added files with the existing bitMap files is overriding\n * the `test` property. e.g. the component directory is re-added without adding the tests flag to\n * track new files in that directory. in this case, we want to preserve the `test` property.\n */\n _mergeFilesWithExistingComponentMapFiles(\n componentFiles: ComponentMapFile[],\n existingComponentMapFile: ComponentMapFile[]\n ) {\n return unionBy(existingComponentMapFile, componentFiles, 'relativePath');\n }\n\n /**\n * if an existing file is for example uppercase and the new file is lowercase it has different\n * behavior according to the OS. some OS are case sensitive, some are not.\n * it's safer to avoid saving both files and instead, replacing the old file with the new one.\n * in case a file has replaced and it is also a mainFile, replace the mainFile as well\n */\n _updateFilesWithCurrentLetterCases(currentComponentMap: ComponentMap, newFiles: ComponentMapFile[]) {\n const currentFiles = currentComponentMap.files;\n currentFiles.forEach((currentFile) => {\n const sameFile = newFiles.find(\n (newFile) => newFile.relativePath.toLowerCase() === currentFile.relativePath.toLowerCase()\n );\n if (sameFile && currentFile.relativePath !== sameFile.relativePath) {\n if (currentComponentMap.mainFile === currentFile.relativePath) {\n currentComponentMap.mainFile = sameFile.relativePath;\n }\n currentFile.relativePath = sameFile.relativePath;\n }\n });\n }\n\n /**\n * if the id is already saved in bitmap file, it might have more data (such as scope, version)\n * use that id instead.\n */\n private _getIdAccordingToExistingComponent(currentId: BitIdStr): ComponentID | undefined {\n const idWithScope = this.defaultScope ? `${this.defaultScope}/${currentId}` : currentId;\n const existingComponentId = this.bitMap.getExistingBitId(idWithScope, false);\n if (currentId.includes(VERSION_DELIMITER)) {\n if (\n !existingComponentId || // this id is new, it shouldn't have a version\n !existingComponentId.hasVersion() || // this component is new, it shouldn't have a version\n // user shouldn't add files to a an existing component with different version\n existingComponentId.version !== ComponentID.getVersionFromString(currentId)\n ) {\n throw new VersionShouldBeRemoved(currentId);\n }\n }\n return existingComponentId;\n }\n\n _getIdAccordingToTrackDir(dir: PathOsBased): ComponentID | null | undefined {\n const dirNormalizedToLinux = pathNormalizeToLinux(dir);\n const trackDirs = this.bitMap.getAllTrackDirs();\n if (!trackDirs) return null;\n return trackDirs[dirNormalizedToLinux];\n }\n\n /**\n * used for updating main file if exists or doesn't exists\n */\n _addMainFileToFiles(files: ComponentMapFile[]): PathOsBased | null | undefined {\n let mainFile = this.main;\n if (mainFile && mainFile.match(REGEX_DSL_PATTERN)) {\n // it's a DSL\n files.forEach((file) => {\n const fileInfo = calculateFileInfo(file.relativePath);\n const generatedFile = format(mainFile, fileInfo);\n const foundFile = this._findMainFileInFiles(generatedFile, files);\n if (foundFile) {\n mainFile = foundFile.relativePath;\n }\n if (fs.existsSync(generatedFile) && !foundFile) {\n const shouldIgnore = this.gitIgnore.ignores(generatedFile);\n if (shouldIgnore) {\n // check if file is in exclude list\n throw new ExcludedMainFile(generatedFile);\n }\n files.push({\n relativePath: pathNormalizeToLinux(generatedFile),\n name: path.basename(generatedFile),\n });\n mainFile = generatedFile;\n }\n });\n }\n if (!mainFile) return undefined;\n const mainFileRelativeToConsumer = this.consumer.getPathRelativeToConsumer(mainFile);\n const mainPath = this.consumer.toAbsolutePath(mainFileRelativeToConsumer);\n if (fs.existsSync(mainPath)) {\n const shouldIgnore = this.gitIgnore.ignores(mainFileRelativeToConsumer);\n if (shouldIgnore) throw new ExcludedMainFile(mainFileRelativeToConsumer);\n if (isDir(mainPath)) {\n throw new MainFileIsDir(mainPath);\n }\n const foundFile = this._findMainFileInFiles(mainFileRelativeToConsumer, files);\n if (foundFile) {\n return foundFile.relativePath;\n }\n files.push({\n relativePath: pathNormalizeToLinux(mainFileRelativeToConsumer),\n name: path.basename(mainFileRelativeToConsumer),\n });\n return mainFileRelativeToConsumer;\n }\n return mainFile;\n }\n\n _findMainFileInFiles(mainFile: string, files: ComponentMapFile[]) {\n const normalizedMainFile = pathNormalizeToLinux(mainFile).toLowerCase();\n return files.find((file) => file.relativePath.toLowerCase() === normalizedMainFile);\n }\n\n private async getDefaultScope(rootDir: string, componentName: string): Promise<string> {\n return (this.defaultScope ||\n (await this.workspace.componentDefaultScopeFromComponentDirAndName(rootDir, componentName))) as string;\n }\n\n /**\n * given the component paths, prepare the id, mainFile and files to be added later on to bitmap\n * the id of the component is either entered by the user or, if not entered, concluded by the path.\n * e.g. bar/foo.js, the id would be bar/foo.\n * in case bitmap has already the same id, the complete id is taken from bitmap (see _getIdAccordingToExistingComponent)\n */\n async addOneComponent(componentPath: PathOsBased, batchRootDirs: PathLinuxRelative[] = []): Promise<AddedComponent> {\n let finalBitId: ComponentID | undefined; // final id to use for bitmap file\n let idFromPath;\n if (this.id) {\n finalBitId = this._getIdAccordingToExistingComponent(this.id);\n }\n // when the tracked dir is the workspace root itself, the relative path is empty. normalize it\n // to \".\" so it is a real rootDir rather than a falsy one.\n const relativeComponentPath = this.consumer.getPathRelativeToConsumer(componentPath) || WORKSPACE_ROOT_DIR;\n this._throwForOutsideConsumer(relativeComponentPath);\n // the component this add is for: the one the user named, tracked already or not, or else the\n // one already tracking this dir. for the workspace root, this is what tells a re-add from a\n // second owner.\n const idOfTrackDir = this._getIdAccordingToTrackDir(relativeComponentPath);\n const idToAdd = this.id ? finalBitId : idOfTrackDir;\n throwForExistingParentDir(this.bitMap, relativeComponentPath, idToAdd || undefined);\n // files of components nested inside this dir belong to them, not to the component being added -\n // whether they are tracked already or added by the same command.\n const nestedRootDirs = uniq([\n ...this.bitMap.getNestedRootDirs(relativeComponentPath),\n ...batchRootDirs.filter(\n (other) =>\n other !== relativeComponentPath &&\n (relativeComponentPath === WORKSPACE_ROOT_DIR || other.startsWith(`${relativeComponentPath}/`))\n ),\n ]);\n const matches = await glob(pathNormalizeToLinux(path.join(relativeComponentPath, '**')), {\n cwd: this.consumer.getPath(),\n nodir: true,\n // dotfiles are component files like any other (the workspace root is full of them: .gitignore,\n // .github/**). the rescan, getFilesByDir(), scans with dot: true, and the add-time file-set has to\n // agree with it rather than be corrected by the next command.\n dot: true,\n // the same exclusions the rescan applies, see getFilesByDir().\n ignore: getScanIgnorePatterns(relativeComponentPath, nestedRootDirs),\n });\n\n if (!matches.length) throw new EmptyDirectory(componentPath);\n\n // the config files \"bit ws-config write\" generates are not source - the same rule the rescan\n // applies (see getFilesByDir), so the add-time file-set matches the next rescan.\n const generatedAtRoot = new Set(\n IGNORE_ROOT_ONLY_LIST.map((file) => pathNormalizeToLinux(path.join(relativeComponentPath, file)))\n );\n const matchesNotIgnored = await filterByIgnoreFiles(\n relativeComponentPath,\n this.consumer.getPath(),\n this.gitIgnore,\n matches.map(pathNormalizeToLinux),\n this.consumer.config.trackAllFiles\n );\n // and by the component's own ignore file, the rule the rescan applies (see getFilesByDir) - it\n // takes paths relative to the component, the matches are relative to the workspace.\n const relativeToComponent = (match: PathLinux) => path.posix.relative(relativeComponentPath, match);\n const keptByOwnIgnoreFile = new Set(\n await filterByOwnIgnoreFile(\n relativeComponentPath,\n this.consumer.getPath(),\n matchesNotIgnored.map(relativeToComponent)\n )\n );\n // the rules the rescan applies too (see getFilesByDir), so the add-time file-set matches it. the\n // main file is checked against the same predicate below - it is put back after this filtering.\n const isTrackable = (match: PathLinux) =>\n keptByOwnIgnoreFile.has(relativeToComponent(match)) &&\n (this.consumer.config.trackAllFiles || !generatedAtRoot.has(match));\n const filteredMatches = matchesNotIgnored.filter(isTrackable);\n\n if (!filteredMatches.length) {\n throw new NoFiles(matches);\n }\n\n const filteredMatchedFiles = filteredMatches.map((match: PathOsBased) => {\n return { relativePath: pathNormalizeToLinux(match), test: false, name: path.basename(match) };\n });\n const resolvedMainFile = this._addMainFileToFiles(filteredMatchedFiles);\n // that puts the main file back into the list after the filtering above, and checks it against the\n // workspace ignore rules only. without applying the rest of them here, the add fails further down\n // on a main file the rescan already dropped, saying it was removed - the config files bit treats\n // as generated (tsconfig.json and friends) reach it that way, as does a component ignore file.\n if (resolvedMainFile) {\n const mainNormalized = pathNormalizeToLinux(resolvedMainFile);\n // it is in the file-set only if it was found on disk. a missing one is reported further down,\n // where the error says so rather than blaming an ignore rule.\n const inFileSet = filteredMatchedFiles.some((file) => file.relativePath === mainNormalized);\n // some paths the scan never yields at all - bit's own dirs, a nested workspace map, the\n // root-dir of a component nested in this one - so they never reach `matches` and the ignore\n // rules below have nothing to compare them against. either way an explicit main file is put\n // into the file-set without going through the scan, and the next rescan drops it again: the\n // component then fails to load, saying the main file was removed.\n const excludedFromScan = !filterByScanIgnorePatterns(relativeComponentPath, [mainNormalized], nestedRootDirs)\n .length;\n const excludedByIgnoreRules = matchesNotIgnored.includes(mainNormalized) && !isTrackable(mainNormalized);\n if ((inFileSet && excludedFromScan) || excludedByIgnoreRules) {\n throw new ExcludedMainFile(relativeToComponent(mainNormalized));\n }\n }\n\n const absoluteComponentPath = pathNormalizeToLinux(path.resolve(componentPath));\n const splitPath = absoluteComponentPath.split('/');\n const lastDir = splitPath[splitPath.length - 1];\n if (!finalBitId) {\n if (this.id) {\n const bitId = BitId.parse(this.id, false);\n const defaultScope = await this.getDefaultScope(relativeComponentPath, bitId.name);\n finalBitId = new ComponentID(bitId, defaultScope);\n } else if (idOfTrackDir) {\n finalBitId = idOfTrackDir;\n } else {\n const nameSpaceOrDir = this.namespace || splitPath[splitPath.length - 2];\n if (!this.namespace) {\n idFromPath = { namespace: BitId.getValidIdChunk(nameSpaceOrDir), name: BitId.getValidIdChunk(lastDir) };\n }\n const bitId = BitId.getValidBitId(nameSpaceOrDir, lastDir);\n const defaultScope = await this.getDefaultScope(relativeComponentPath, bitId.name);\n finalBitId = new ComponentID(bitId, defaultScope);\n }\n }\n const trackDir = relativeComponentPath;\n const addedComp = {\n componentId: finalBitId,\n files: filteredMatchedFiles,\n mainFile: resolvedMainFile,\n trackDir,\n idFromPath,\n immediateDir: lastDir,\n };\n\n return addedComp;\n }\n\n async getIgnoreList(): Promise<string[]> {\n const consumerPath = this.consumer.getPath();\n return getIgnoreListHarmony(consumerPath, this.consumer.config.ignoredFiles, this.consumer.config.trackAllFiles);\n }\n\n async linkComponents(ids: ComponentID[]) {\n if (this.trackDirFeature) {\n // if trackDirFeature is set, it happens during the component-load and because we load the\n // components in the next line, it gets into an infinite loop.\n return;\n }\n await linkToNodeModulesByIds(this.workspace, ids);\n }\n\n async addMultipleComponents(componentPathsStats: PathsStats): Promise<void> {\n logger.debugAndAddBreadCrumb('add-components', 'adding multiple components');\n this._removeDirectoriesWhenTheirFilesAreAdded(componentPathsStats);\n const added = await this._tryAddingMultiple(componentPathsStats);\n validateNoDuplicateIds(added);\n await this._removeNamespaceIfNotNeeded(added);\n await this._addMultipleToBitMap(added);\n }\n\n /**\n * some uses of wildcards might add directories and their files at the same time, in such cases\n * only the files are needed and the directories can be ignored.\n * @see https://github.com/teambit/bit/issues/1406 for more details\n */\n _removeDirectoriesWhenTheirFilesAreAdded(componentPathsStats: PathsStats) {\n const allPaths = Object.keys(componentPathsStats);\n allPaths.forEach((componentPath) => {\n // the dirname of \".\" is \".\" itself - the workspace root is not a wildcard expansion of itself.\n const foundDir = allPaths.find((p) => p !== componentPath && p === path.dirname(componentPath));\n // nor of what sits directly below it. the workspace root contains every other component by\n // design, so a component inside it is no reason to drop it: it was asked for by name, and the\n // --root flag says so in as many words (see throwForWorkspaceRootFlagMismatch). without this,\n // \"bit add . comp --root\" tracks comp alone and reports success, the root never created.\n if (foundDir && componentPathsStats[foundDir] && !this.isWorkspaceRootPath(foundDir)) {\n logger.debug(`add-components._removeDirectoriesWhenTheirFilesAreAdded, ignoring ${foundDir}`);\n delete componentPathsStats[foundDir];\n }\n });\n }\n\n async _addMultipleToBitMap(added: AddedComponent[]): Promise<void> {\n const missingMainFiles = [];\n await Promise.all(\n added.map(async (component) => {\n if (component.files.length) {\n try {\n const addedComponent = await this.addOrUpdateComponentInBitMap(component);\n if (addedComponent && addedComponent.files.length) this.addedComponents.push(addedComponent);\n } catch (err: any) {\n if (!(err instanceof MissingMainFile)) throw err;\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n missingMainFiles.push(err);\n }\n }\n })\n );\n if (missingMainFiles.length) {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n throw new MissingMainFileMultipleComponents(missingMainFiles.map((err) => err.componentId).sort());\n }\n }\n\n async _removeNamespaceIfNotNeeded(addedComponents: AddedComponent[]) {\n const allIds = this.bitMap.getAllBitIdsFromAllLanes();\n await Promise.all(\n addedComponents.map(async (addedComponent) => {\n if (!addedComponent.idFromPath) return; // when the id was not generated from the path do nothing.\n const componentsWithSameName = addedComponents.filter(\n (a) => a.idFromPath && a.idFromPath.name === addedComponent.idFromPath?.name\n );\n const bitIdFromNameOnly = new BitId({ name: addedComponent.idFromPath.name });\n const defaultScope = await this.getDefaultScope(addedComponent.trackDir, bitIdFromNameOnly.name);\n const componentIdFromNameOnly = new ComponentID(bitIdFromNameOnly, defaultScope);\n const existingComponentWithSameName = allIds.searchWithoutScopeAndVersion(componentIdFromNameOnly);\n if (componentsWithSameName.length === 1 && !existingComponentWithSameName) {\n addedComponent.componentId = componentIdFromNameOnly;\n }\n })\n );\n }\n\n async _tryAddingMultiple(componentPathsStats: PathsStats): Promise<AddedComponent[]> {\n const batchRootDirs = Object.keys(componentPathsStats).map(\n (onePath) => pathNormalizeToLinux(this.consumer.getPathRelativeToConsumer(onePath)) || WORKSPACE_ROOT_DIR\n );\n const addedP = Object.keys(componentPathsStats).map(async (onePath) => {\n try {\n const addedComponent = await this.addOneComponent(onePath, batchRootDirs);\n return addedComponent;\n } catch (err: any) {\n if (!(err instanceof EmptyDirectory)) throw err;\n this.warnings.emptyDirectory.push(onePath);\n return null;\n }\n });\n const added = await Promise.all(addedP);\n return compact(added);\n }\n\n _throwForOutsideConsumer(relativeToConsumerPath: PathOsBased) {\n if (relativeToConsumerPath.startsWith('..')) {\n throw new PathOutsideConsumer(relativeToConsumerPath);\n }\n }\n}\n\nfunction throwForExistingParentDir(bitMap: BitMap, relativeToConsumerPath: PathOsBased, addedId?: ComponentID) {\n if (relativeToConsumerPath === WORKSPACE_ROOT_DIR) {\n // only one component can own the workspace root. rejected before the (expensive) scan of the\n // whole workspace, with a message that says which component already owns it. re-adding the same\n // component is fine. the root component contains every other component by design, so there is no\n // parent-dir conflict to check for it.\n const currentOwner = bitMap.getComponentIdByRootPath(WORKSPACE_ROOT_DIR);\n if (currentOwner && !addedId?.isEqual(currentOwner, { ignoreVersion: true })) {\n throw new BitError(\n `unable to track the workspace root, it is already tracked by \"${currentOwner.toStringWithoutVersion()}\"`\n );\n }\n return;\n }\n const isParentDir = (parent: string) => {\n const relative = path.relative(parent, relativeToConsumerPath);\n return relative && !relative.startsWith('..') && !path.isAbsolute(relative);\n };\n bitMap.components.forEach((componentMap) => {\n // the workspace-root component contains every other component by design, and subtracts their\n // root-dirs from its own file-set.\n if (!componentMap.rootDir || componentMap.rootDir === WORKSPACE_ROOT_DIR) return;\n if (isParentDir(componentMap.rootDir)) {\n throw new ParentDirTracked(\n componentMap.rootDir,\n componentMap.id.toStringWithoutVersion(),\n relativeToConsumerPath\n );\n }\n });\n}\n\n/**\n * validatePaths - validate if paths entered by user exist and if not throw an error\n *\n * @param {string[]} fileArray - array of paths\n * @returns {PathsStats} componentPathsStats\n */\nfunction validatePaths(fileArray: string[]): PathsStats {\n const componentPathsStats = {};\n fileArray.forEach((componentPath) => {\n if (!fs.existsSync(componentPath)) {\n throw new PathsNotExist([componentPath]);\n }\n componentPathsStats[componentPath] = {\n isDir: isDir(componentPath),\n };\n });\n return componentPathsStats;\n}\n\n/**\n * validate that no two files where added with the same id in the same bit add command\n */\nfunction validateNoDuplicateIds(addComponents: Record<string, any>[]) {\n const duplicateIds = {};\n const newGroupedComponents = groupBy(addComponents, 'componentId');\n Object.keys(newGroupedComponents).forEach((key) => {\n if (newGroupedComponents[key].length > 1) duplicateIds[key] = newGroupedComponents[key];\n });\n if (!isEmpty(duplicateIds)) throw new DuplicateIds(duplicateIds);\n}\n\n/**\n * get the current working dir name of file and file name.\n * @name fileInfo\n * @param relativePath\n * @returns {object}\n * @example\n * ```js\n * currentDirName() // => 'bit'\n * ```\n */\nfunction calculateFileInfo(relativePath: string): { PARENT: string; FILE_NAME: string } {\n const fileInfo = path.parse(relativePath);\n const fullPath = path.dirname(relativePath);\n const rootDir = path.dirname(fullPath);\n const parentDir = path.relative(rootDir, fullPath);\n return { PARENT: parentDir, FILE_NAME: fileInfo.name };\n}\n\nasync function isAutoGeneratedFile(filePath: PathOsBased): Promise<boolean> {\n const line = await firstline(filePath);\n return line.includes(AUTO_GENERATED_STAMP);\n}\n\n/**\n * the env the workspace-root component is tracked with. hardcoded, the same way the envs aspect\n * names its default env - the tracker does not depend on the env aspects.\n */\nconst WORKSPACE_ROOT_ENV = 'teambit.harmony/empty-env';\n\n/**\n * the workspace-root component (rootDir \".\") is a bag of config files, not a source component:\n * nothing compiles it, nothing tests it, and nothing imports it as a package. the regular default\n * env would give it a compiler and a dependency policy it can never satisfy, so it is tracked with\n * the empty env - as explicit config, so every path that resolves an env or a dependency policy\n * sees the same answer. an env configured by the caller, or set later with \"bit env set\", wins.\n */\nexport function configForWorkspaceRoot(existingConfig?: Config, addedConfig?: Config): Config {\n const configuredEnv = addedConfig?.[Extensions.envs] ?? existingConfig?.[Extensions.envs];\n if (configuredEnv) return { ...existingConfig, ...addedConfig };\n // the same two entries \"bit env set\" writes: the env aspect itself, and the env selection\n return {\n ...existingConfig,\n ...addedConfig,\n [WORKSPACE_ROOT_ENV]: {},\n [Extensions.envs]: { env: WORKSPACE_ROOT_ENV },\n };\n}\n\nexport async function addMultipleFromResolvedTrackData(\n workspace: Workspace,\n trackData: ResolvedTrackData[]\n): Promise<ComponentID[]> {\n const bitMap = workspace.consumer.bitMap;\n const { ignoredFiles, trackAllFiles } = workspace.consumer.config;\n const ignoreList = await getIgnoreListHarmony(workspace.path, ignoredFiles, trackAllFiles);\n const gitIgnore = ignore().add(ignoreList);\n // normalized once, the way the map stores it, so \"./\" is the workspace root here as well as there\n const normalizeRootDir = (rootDir: string): PathLinuxRelative => pathNormalizeToLinux(path.normalize(rootDir));\n const batchRootDirs = trackData.map((data) => normalizeRootDir(data.rootDir));\n const componentMaps: ComponentMap[] = [];\n for (const data of trackData) {\n const { files, componentName, defaultScope, config } = data;\n if (path.isAbsolute(data.rootDir)) throw new BitError(`path is absolute, got ${data.rootDir}`);\n const rootDir = normalizeRootDir(data.rootDir);\n const componentId = ComponentID.fromObject({ name: componentName }, defaultScope);\n // re-tracking the workspace root with the same id is a no-op, not a second owner\n throwForExistingParentDir(bitMap, rootDir, componentId);\n const isWorkspaceRoot = rootDir === WORKSPACE_ROOT_DIR;\n // re-tracking keeps the entry's id, version included, the way \"bit add\" does: the id built from\n // the name alone would replace it and make a snapped component look newly tracked.\n const existingEntry = bitMap.getComponentIfExist(componentId, { ignoreVersion: true });\n const idToTrack = existingEntry?.id ?? componentId;\n // the workspace root has no entry point of its own, workspace.jsonc stands in for it, the way\n // \"bit add .\" resolves it (see determine-main-file). re-tracking keeps the entry's main file.\n const mainFile = data.mainFile ?? existingEntry?.mainFile ?? (isWorkspaceRoot ? WORKSPACE_JSONC : undefined);\n if (!mainFile) throw new BitError(`unable to track \"${rootDir}\" as \"${componentName}\", no main file was given`);\n const existingConfig = isWorkspaceRoot ? existingEntry?.config : undefined;\n const componentFiles = isWorkspaceRoot\n ? await scanWorkspaceRootFiles(workspace, gitIgnore, batchRootDirs)\n : await filterResolvedFiles(rootDir, workspace.path, files, gitIgnore, trackAllFiles);\n // a nested component may take any file from a tracked workspace root but its main file, the\n // rule \"bit add\" applies. a root tracked later in the same call scans around this component.\n const workspaceRootMap = bitMap.getWorkspaceRootMap();\n if (!isWorkspaceRoot && workspaceRootMap) throwForTakingWorkspaceRootMainFile(workspaceRootMap, idToTrack, rootDir);\n const componentMap = bitMap.addComponent({\n componentId: idToTrack,\n files: componentFiles,\n defaultScope: idToTrack.hasScope() ? undefined : defaultScope,\n config: isWorkspaceRoot ? configForWorkspaceRoot(existingConfig, config) : config,\n mainFile,\n rootDir,\n });\n componentMaps.push(componentMap);\n }\n\n const allIds = componentMaps.map((c) => c.id);\n await linkToNodeModulesByIds(workspace, allIds);\n\n return allIds;\n}\n\n/**\n * the workspace-root component owns every file no other component claims, so it gives a file away to\n * a more specific component - all but its main file: without it, it fails to load from the next scan on.\n */\nfunction throwForTakingWorkspaceRootMainFile(\n workspaceRootMap: ComponentMap,\n componentId: ComponentID,\n rootDir: PathLinux\n) {\n // checked on the directory rather than on the files the component keeps: the root's next scan\n // subtracts the whole directory, whether or not the component itself tracks that file. the\n // ownership lookups are case-insensitive, so this comparison is too.\n if (!workspaceRootMap.mainFile.toLowerCase().startsWith(`${rootDir.toLowerCase()}/`)) return;\n throw new BitError(\n `unable to add \"${rootDir}\" as \"${componentId.toString()}\", it contains \"${workspaceRootMap.mainFile}\", the main file of the workspace-root component \"${workspaceRootMap.id.toStringWithoutVersion()}\". set a different main file for it first: bit add . --main ${WORKSPACE_JSONC}`\n );\n}\n\n/**\n * the workspace-root's file-set is derived by scanning, the way every load derives it, rather than\n * taken from the caller: the scan is what knows the nested components (tracked already, or by the same\n * call), the ignore files below the root and bit's own exclusions. a main file the scan leaves out\n * fails the map validation before the map is written, not on the next load.\n */\nasync function scanWorkspaceRootFiles(\n workspace: Workspace,\n gitIgnore: any,\n batchRootDirs: PathLinuxRelative[]\n): Promise<ComponentMapFile[]> {\n const nestedRootDirs = uniq([\n ...workspace.consumer.bitMap.getNestedRootDirs(WORKSPACE_ROOT_DIR),\n ...batchRootDirs.filter((dir) => dir !== WORKSPACE_ROOT_DIR),\n ]);\n const { trackAllFiles } = workspace.consumer.config;\n return getFilesByDir(WORKSPACE_ROOT_DIR, workspace.path, gitIgnore, nestedRootDirs, trackAllFiles);\n}\n\n/**\n * the files the caller resolved for a component, minus the config files \"bit ws-config write\"\n * generates and the ignored ones - the rules the rescan applies, see getFilesByDir. the workspace\n * ignore rules are written against the workspace root, so a file is matched by its workspace-relative\n * path and mapped back to the component-relative one the map stores; the component's own ignore file\n * is applied to the latter.\n */\nasync function filterResolvedFiles(\n rootDir: PathLinuxRelative,\n consumerPath: string,\n files: string[],\n gitIgnore: any,\n trackAllFiles?: boolean\n): Promise<ComponentMapFile[]> {\n const notGenerated = files\n .map(pathNormalizeToLinux)\n .filter((file) => trackAllFiles || !IGNORE_ROOT_ONLY_LIST.includes(file));\n // what a scan never yields (bit's and git's own dirs, a nested workspace map) is not tracked here either,\n // or the next rescan would drop it\n const workspaceRelative = filterByScanIgnorePatterns(\n rootDir,\n notGenerated.map((file) => path.posix.join(rootDir, file))\n );\n const filteredByWorkspaceRules: string[] = gitIgnore\n .filter(workspaceRelative)\n .map((file) => path.posix.relative(rootDir, file));\n const filtered = await filterByOwnIgnoreFile(rootDir, consumerPath, filteredByWorkspaceRules);\n if (!filtered.length) throw new NoFiles(files);\n return filtered.map((relativePath) => ({ relativePath, name: path.basename(relativePath), test: false }));\n}\n"],"mappings":";;;;;;;;AAAA,SAAAA,iBAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,gBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,WAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,KAAA;EAAA,MAAAN,IAAA,GAAAO,uBAAA,CAAAL,OAAA;EAAAI,IAAA,YAAAA,CAAA;IAAA,OA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AACiS,KAAK,CAACC,QAAQ,CAAClI,OAAO,EAAErB,IAAI,CAAC,CAAC;EACpD,MAAMiQ,QAAQ,GAAG,MAAM,IAAAxG,gCAAqB,EAACpI,OAAO,EAAEU,YAAY,EAAEiO,wBAAwB,CAAC;EAC7F,IAAI,CAACC,QAAQ,CAAC3V,MAAM,EAAE,MAAM,KAAImE,qBAAO,EAACW,KAAK,CAAC;EAC9C,OAAO6Q,QAAQ,CAACjS,GAAG,CAAEgF,YAAY,KAAM;IAAEA,YAAY;IAAEuE,IAAI,EAAElQ,IAAI,CAAD,CAAC,CAACmQ,QAAQ,CAACxE,YAAY,CAAC;IAAE6G,IAAI,EAAE;EAAM,CAAC,CAAC,CAAC;AAC3G","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _chai() {
|
|
4
|
+
const data = require("chai");
|
|
5
|
+
_chai = function () {
|
|
6
|
+
return data;
|
|
7
|
+
};
|
|
8
|
+
return data;
|
|
9
|
+
}
|
|
10
|
+
function _fsExtra() {
|
|
11
|
+
const data = _interopRequireDefault(require("fs-extra"));
|
|
12
|
+
_fsExtra = function () {
|
|
13
|
+
return data;
|
|
14
|
+
};
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
function _path() {
|
|
18
|
+
const data = _interopRequireDefault(require("path"));
|
|
19
|
+
_path = function () {
|
|
20
|
+
return data;
|
|
21
|
+
};
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
function _legacy() {
|
|
25
|
+
const data = require("@teambit/legacy.constants");
|
|
26
|
+
_legacy = function () {
|
|
27
|
+
return data;
|
|
28
|
+
};
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
function _harmonyTesting() {
|
|
32
|
+
const data = require("@teambit/harmony.testing.load-aspect");
|
|
33
|
+
_harmonyTesting = function () {
|
|
34
|
+
return data;
|
|
35
|
+
};
|
|
36
|
+
return data;
|
|
37
|
+
}
|
|
38
|
+
function _workspaceTesting() {
|
|
39
|
+
const data = require("@teambit/workspace.testing.mock-workspace");
|
|
40
|
+
_workspaceTesting = function () {
|
|
41
|
+
return data;
|
|
42
|
+
};
|
|
43
|
+
return data;
|
|
44
|
+
}
|
|
45
|
+
function _workspace() {
|
|
46
|
+
const data = require("@teambit/workspace");
|
|
47
|
+
_workspace = function () {
|
|
48
|
+
return data;
|
|
49
|
+
};
|
|
50
|
+
return data;
|
|
51
|
+
}
|
|
52
|
+
function _tracker() {
|
|
53
|
+
const data = require("./tracker.aspect");
|
|
54
|
+
_tracker = function () {
|
|
55
|
+
return data;
|
|
56
|
+
};
|
|
57
|
+
return data;
|
|
58
|
+
}
|
|
59
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
60
|
+
/**
|
|
61
|
+
* which files `bit add` ends up tracking. one harmony load stands in for a process per command, so
|
|
62
|
+
* the rules that pick the files are covered here rather than as e2e.
|
|
63
|
+
*/
|
|
64
|
+
describe('the files bit add tracks', function () {
|
|
65
|
+
this.timeout(0);
|
|
66
|
+
const workspaces = [];
|
|
67
|
+
|
|
68
|
+
/** a component whose own ignore file hides the .json next to its source */
|
|
69
|
+
const compWithIgnoredJson = {
|
|
70
|
+
'comp1/index.js': 'module.exports = () => "comp1";\n',
|
|
71
|
+
'comp1/.bitignore': '*.json\n',
|
|
72
|
+
'comp1/hello.json': '{ "hello": "world" }\n'
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/** the workspace aspect holds the flag, and workspace.jsonc carries comments that JSON.parse rejects */
|
|
76
|
+
function enableTrackAllFiles(workspacePath) {
|
|
77
|
+
const configPath = _path().default.join(workspacePath, 'workspace.jsonc');
|
|
78
|
+
const content = _fsExtra().default.readFileSync(configPath, 'utf8');
|
|
79
|
+
const workspaceKey = '"teambit.workspace/workspace": {';
|
|
80
|
+
if (!content.includes(workspaceKey)) throw new Error(`"${workspaceKey}" is no longer in the mock workspace.jsonc`);
|
|
81
|
+
_fsExtra().default.writeFileSync(configPath, content.replace(workspaceKey, `${workspaceKey}\n "trackAllFiles": true,`));
|
|
82
|
+
}
|
|
83
|
+
async function setup(files, opts = {}) {
|
|
84
|
+
const workspaceData = (0, _workspaceTesting().mockWorkspace)();
|
|
85
|
+
workspaces.push(workspaceData);
|
|
86
|
+
const {
|
|
87
|
+
workspacePath
|
|
88
|
+
} = workspaceData;
|
|
89
|
+
if (opts.trackAllFiles) enableTrackAllFiles(workspacePath);
|
|
90
|
+
Object.entries(files).forEach(([filePath, content]) => _fsExtra().default.outputFileSync(_path().default.join(workspacePath, filePath), content));
|
|
91
|
+
const harmony = await (0, _harmonyTesting().loadManyAspects)([_workspace().WorkspaceAspect, _tracker().TrackerAspect], workspacePath);
|
|
92
|
+
// addForCLI resolves componentPaths and main against the cwd, so the tests pass absolute paths
|
|
93
|
+
return {
|
|
94
|
+
workspacePath,
|
|
95
|
+
tracker: harmony.get(_tracker().TrackerAspect.id)
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** chai has no async throw assertion that also matches a message */
|
|
100
|
+
async function expectToReject(fn, messagePart) {
|
|
101
|
+
try {
|
|
102
|
+
await fn();
|
|
103
|
+
} catch (err) {
|
|
104
|
+
(0, _chai().expect)(err.message).to.have.string(messagePart);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
throw new Error(`expected to reject with "${messagePart}", but it resolved`);
|
|
108
|
+
}
|
|
109
|
+
after(async () => {
|
|
110
|
+
await Promise.all(workspaces.map(workspaceData => (0, _workspaceTesting().destroyWorkspace)(workspaceData)));
|
|
111
|
+
});
|
|
112
|
+
describe('the ignore file of the component being added', () => {
|
|
113
|
+
let addedFiles;
|
|
114
|
+
before(async () => {
|
|
115
|
+
const {
|
|
116
|
+
workspacePath,
|
|
117
|
+
tracker
|
|
118
|
+
} = await setup(compWithIgnoredJson);
|
|
119
|
+
const results = await tracker.addForCLI({
|
|
120
|
+
componentPaths: [_path().default.join(workspacePath, 'comp1')],
|
|
121
|
+
id: 'comp1',
|
|
122
|
+
override: false
|
|
123
|
+
});
|
|
124
|
+
addedFiles = results.addedComponents[0].files.map(file => file.relativePath);
|
|
125
|
+
});
|
|
126
|
+
it('should apply it at add time, as the rescan does', () => {
|
|
127
|
+
(0, _chai().expect)(addedFiles).to.include('index.js');
|
|
128
|
+
(0, _chai().expect)(addedFiles).to.not.include('hello.json');
|
|
129
|
+
});
|
|
130
|
+
it('should keep the ignore file itself, it is a source of the component', () => {
|
|
131
|
+
(0, _chai().expect)(addedFiles).to.include('.bitignore');
|
|
132
|
+
});
|
|
133
|
+
it('should refuse a main file it excludes, rather than track what the next rescan drops', async () => {
|
|
134
|
+
const {
|
|
135
|
+
workspacePath,
|
|
136
|
+
tracker
|
|
137
|
+
} = await setup(compWithIgnoredJson);
|
|
138
|
+
await expectToReject(() => tracker.addForCLI({
|
|
139
|
+
componentPaths: [_path().default.join(workspacePath, 'comp1')],
|
|
140
|
+
id: 'comp1',
|
|
141
|
+
main: _path().default.join(workspacePath, 'comp1/hello.json'),
|
|
142
|
+
override: false
|
|
143
|
+
}), 'was excluded from file list');
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
describe('a config file bit treats as generated, at the component root', () => {
|
|
147
|
+
const compWithTsconfig = {
|
|
148
|
+
'comp1/index.js': 'module.exports = () => "comp1";\n',
|
|
149
|
+
'comp1/tsconfig.json': '{}\n'
|
|
150
|
+
};
|
|
151
|
+
const addWithTsconfigAsMain = async trackAllFiles => {
|
|
152
|
+
const {
|
|
153
|
+
workspacePath,
|
|
154
|
+
tracker
|
|
155
|
+
} = await setup(compWithTsconfig, {
|
|
156
|
+
trackAllFiles
|
|
157
|
+
});
|
|
158
|
+
return tracker.addForCLI({
|
|
159
|
+
componentPaths: [_path().default.join(workspacePath, 'comp1')],
|
|
160
|
+
id: 'comp1',
|
|
161
|
+
main: _path().default.join(workspacePath, 'comp1/tsconfig.json'),
|
|
162
|
+
override: false
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
it('should refuse it as a main file, rather than track what the next rescan drops', async () => {
|
|
166
|
+
// it used to fail further down with "main file tsconfig.json was removed from <id>", which
|
|
167
|
+
// sends the user to "bit remove" for a component they are adding
|
|
168
|
+
await expectToReject(() => addWithTsconfigAsMain(false), 'was excluded from file list');
|
|
169
|
+
});
|
|
170
|
+
it('should accept it with trackAllFiles on, where the rescan keeps it', async () => {
|
|
171
|
+
const results = await addWithTsconfigAsMain(true);
|
|
172
|
+
(0, _chai().expect)(results.addedComponents[0].files.map(file => file.relativePath)).to.include('tsconfig.json');
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
describe('a file bit generated, which carries its banner', () => {
|
|
176
|
+
const compWithGeneratedFile = {
|
|
177
|
+
'comp1/index.js': 'module.exports = () => "comp1";\n',
|
|
178
|
+
'comp1/package.json': `${_legacy().AUTO_GENERATED_MSG}{ "name": "comp1" }\n`
|
|
179
|
+
};
|
|
180
|
+
const filesOf = async trackAllFiles => {
|
|
181
|
+
const {
|
|
182
|
+
workspacePath,
|
|
183
|
+
tracker
|
|
184
|
+
} = await setup(compWithGeneratedFile, {
|
|
185
|
+
trackAllFiles
|
|
186
|
+
});
|
|
187
|
+
const results = await tracker.addForCLI({
|
|
188
|
+
componentPaths: [_path().default.join(workspacePath, 'comp1')],
|
|
189
|
+
id: 'comp1',
|
|
190
|
+
override: false
|
|
191
|
+
});
|
|
192
|
+
return results.addedComponents[0].files.map(file => file.relativePath);
|
|
193
|
+
};
|
|
194
|
+
it('should drop it by default, it is not source', async () => {
|
|
195
|
+
(0, _chai().expect)(await filesOf(false)).to.not.include('package.json');
|
|
196
|
+
});
|
|
197
|
+
it('should keep it with trackAllFiles on, which is what the rescan does', async () => {
|
|
198
|
+
// the rescan never looks at the banner, so dropping it here would leave the two disagreeing:
|
|
199
|
+
// the file is missing from the add, then turns up as a new file on the next status
|
|
200
|
+
(0, _chai().expect)(await filesOf(true)).to.include('package.json');
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
//# sourceMappingURL=add-components.spec.js.map
|