@teambit/tracker 1.0.667 → 1.0.669
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 +4 -4
- package/dist/add-cmd.js.map +1 -1
- package/dist/add-components.d.ts +6 -5
- package/dist/add-components.js.map +1 -1
- package/dist/determine-main-file.d.ts +3 -3
- package/dist/determine-main-file.js.map +1 -1
- package/dist/tracker.main.runtime.d.ts +6 -6
- package/dist/tracker.main.runtime.js.map +1 -1
- package/package.json +9 -9
- /package/dist/{preview-1753809186996.js → preview-1753848836384.js} +0 -0
package/dist/add-cmd.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import { Command, CommandOptions } from '@teambit/cli';
|
2
|
-
import { PathLinux } from '@teambit/legacy.utils';
|
3
|
-
import { Warnings } from './add-components';
|
4
|
-
import { TrackerMain } from './tracker.main.runtime';
|
1
|
+
import type { Command, CommandOptions } from '@teambit/cli';
|
2
|
+
import type { PathLinux } from '@teambit/legacy.utils';
|
3
|
+
import type { Warnings } from './add-components';
|
4
|
+
import type { TrackerMain } from './tracker.main.runtime';
|
5
5
|
type AddFlags = {
|
6
6
|
id: string | null | undefined;
|
7
7
|
main: string | null | undefined;
|
package/dist/add-cmd.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","path","_interopRequireWildcard","_bitError","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","AddCmd","constructor","tracker","report","paths","addFlags","addedComponents","warnings","json","paintWarning","alreadyUsedOutput","alreadyUsedWarning","keys","alreadyUsed","map","key","chalk","yellow","bold","join","filter","x","emptyDirectoryOutput","emptyDirectory","length","green","result","files","underline","red","id","title","file","flat","main","namespace","scope","env","override","BitError","normalizedPaths","p","normalize","addForCLI","componentPaths","undefined","defaultScope","added","toString","relativePath","exports"],"sources":["add-cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport * as path from 'path';\nimport { BitError } from '@teambit/bit-error';\nimport { PathLinux, PathOsBased } from '@teambit/legacy.utils';\nimport { AddActionResults, Warnings } from './add-components';\nimport { TrackerMain } from './tracker.main.runtime';\n\ntype AddFlags = {\n id: string | null | undefined;\n main: string | null | undefined;\n namespace: string | null | undefined;\n scope?: string;\n env?: string;\n override: boolean;\n};\n\ntype AddResults = {\n addedComponents: Array<{ id: string; files: PathLinux[] }>;\n warnings: Warnings;\n};\n\nexport class AddCmd implements Command {\n name = 'add [path...]';\n description = 'track one or more directories as new components';\n group = 'component-development';\n extendedDescription = 'Learn the recommended workflow for tracking directories as components, in the link below.';\n helpUrl = 'reference/workspace/component-directory';\n alias = 'a';\n options = [\n ['i', 'id <name>', 'manually set component id'],\n ['m', 'main <file>', 'define component entry point'],\n ['n', 'namespace <namespace>', 'organize component in a namespace'],\n ['o', 'override <boolean>', 'override existing component if exists (default = false)'],\n [\n 's',\n 'scope <string>',\n `sets the component's scope. if not entered, the default-scope from workspace.jsonc will be used`,\n ],\n ['e', 'env <string>', \"set the component's environment. (overrides the env from variants if exists)\"],\n ['j', 'json', 'output as json format'],\n ] as CommandOptions;\n loader = true;\n\n constructor(private tracker: TrackerMain) {}\n\n async report([paths = []]: [string[]], addFlags: AddFlags) {\n const { addedComponents, warnings }: AddResults = await this.json([paths], addFlags);\n\n const paintWarning = () => {\n const alreadyUsedOutput = () => {\n const alreadyUsedWarning = Object.keys(warnings.alreadyUsed)\n .map((key) =>\n chalk.yellow(\n `warning: files ${chalk.bold(warnings.alreadyUsed[key].join(', '))} already used by component: ${key}`\n )\n )\n .filter((x) => x)\n .join('\\n');\n return alreadyUsedWarning ? `${alreadyUsedWarning}\\n` : '';\n };\n const emptyDirectoryOutput = () => {\n if (!warnings.emptyDirectory.length) return '';\n return chalk.yellow(\n `warning: the following directories are empty or all their files were excluded\\n${chalk.bold(\n warnings.emptyDirectory.join('\\n')\n )}\\n`\n );\n };\n return alreadyUsedOutput() + emptyDirectoryOutput();\n };\n\n if (addedComponents.length > 1) {\n return paintWarning() + chalk.green(`tracking ${addedComponents.length} new components`);\n }\n\n return (\n paintWarning() +\n addedComponents\n .map((result) => {\n if (result.files.length === 0) {\n return chalk.underline.red(`could not track component ${chalk.bold(result.id)}: no files to track`);\n }\n const title = chalk.underline(`tracking component ${chalk.bold(result.id)}:\\n`);\n const files = result.files.map((file) => chalk.green(`added ${file}`));\n return title + files.join('\\n');\n })\n .flat()\n .join('\\n\\n')\n );\n }\n\n async json(\n [paths = []]: [string[]],\n { id, main, namespace, scope, env, override = false }: AddFlags\n ): Promise<AddResults> {\n if (namespace && id) {\n throw new BitError(\n 'please use either [id] or [namespace] to add a particular component - they cannot be used together'\n );\n }\n\n const normalizedPaths: PathOsBased[] = paths.map((p) => path.normalize(p));\n const { addedComponents, warnings }: AddActionResults = await this.tracker.addForCLI({\n componentPaths: normalizedPaths,\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n id,\n main: main ? path.normalize(main) : undefined,\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n namespace,\n defaultScope: scope,\n override,\n env,\n });\n return {\n addedComponents: addedComponents.map((added) => ({\n id: added.id.toString(),\n files: added.files.map((f) => f.relativePath),\n })),\n warnings,\n };\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,KAAA;EAAA,MAAAH,IAAA,GAAAI,uBAAA,CAAAF,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,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,MAAM,IAAI,CAACL,OAAO,CAACyC,SAAS,CAAC;MACnFC,cAAc,EAAEJ,eAAe;MAC/B;MACAV,EAAE;MACFI,IAAI,EAAEA,IAAI,GAAGpE,IAAI,CAAD,CAAC,CAAC4E,SAAS,CAACR,IAAI,CAAC,GAAGW,SAAS;MAC7C;MACAV,SAAS;MACTW,YAAY,EAAEV,KAAK;MACnBE,QAAQ;MACRD;IACF,CAAC,CAAC;IACF,OAAO;MACL/B,eAAe,EAAEA,eAAe,CAACQ,GAAG,CAAEiC,KAAK,KAAM;QAC/CjB,EAAE,EAAEiB,KAAK,CAACjB,EAAE,CAACkB,QAAQ,CAAC,CAAC;QACvBrB,KAAK,EAAEoB,KAAK,CAACpB,KAAK,CAACb,GAAG,CAAErC,CAAC,IAAKA,CAAC,CAACwE,YAAY;MAC9C,CAAC,CAAC,CAAC;MACH1C;IACF,CAAC;EACH;AACF;AAAC2C,OAAA,CAAAlD,MAAA,GAAAA,MAAA","ignoreList":[]}
|
1
|
+
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","path","_interopRequireWildcard","_bitError","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","AddCmd","constructor","tracker","report","paths","addFlags","addedComponents","warnings","json","paintWarning","alreadyUsedOutput","alreadyUsedWarning","keys","alreadyUsed","map","key","chalk","yellow","bold","join","filter","x","emptyDirectoryOutput","emptyDirectory","length","green","result","files","underline","red","id","title","file","flat","main","namespace","scope","env","override","BitError","normalizedPaths","p","normalize","addForCLI","componentPaths","undefined","defaultScope","added","toString","relativePath","exports"],"sources":["add-cmd.ts"],"sourcesContent":["import type { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport * as path from 'path';\nimport { BitError } from '@teambit/bit-error';\nimport type { PathLinux, PathOsBased } from '@teambit/legacy.utils';\nimport type { AddActionResults, Warnings } from './add-components';\nimport type { TrackerMain } from './tracker.main.runtime';\n\ntype AddFlags = {\n id: string | null | undefined;\n main: string | null | undefined;\n namespace: string | null | undefined;\n scope?: string;\n env?: string;\n override: boolean;\n};\n\ntype AddResults = {\n addedComponents: Array<{ id: string; files: PathLinux[] }>;\n warnings: Warnings;\n};\n\nexport class AddCmd implements Command {\n name = 'add [path...]';\n description = 'track one or more directories as new components';\n group = 'component-development';\n extendedDescription = 'Learn the recommended workflow for tracking directories as components, in the link below.';\n helpUrl = 'reference/workspace/component-directory';\n alias = 'a';\n options = [\n ['i', 'id <name>', 'manually set component id'],\n ['m', 'main <file>', 'define component entry point'],\n ['n', 'namespace <namespace>', 'organize component in a namespace'],\n ['o', 'override <boolean>', 'override existing component if exists (default = false)'],\n [\n 's',\n 'scope <string>',\n `sets the component's scope. if not entered, the default-scope from workspace.jsonc will be used`,\n ],\n ['e', 'env <string>', \"set the component's environment. (overrides the env from variants if exists)\"],\n ['j', 'json', 'output as json format'],\n ] as CommandOptions;\n loader = true;\n\n constructor(private tracker: TrackerMain) {}\n\n async report([paths = []]: [string[]], addFlags: AddFlags) {\n const { addedComponents, warnings }: AddResults = await this.json([paths], addFlags);\n\n const paintWarning = () => {\n const alreadyUsedOutput = () => {\n const alreadyUsedWarning = Object.keys(warnings.alreadyUsed)\n .map((key) =>\n chalk.yellow(\n `warning: files ${chalk.bold(warnings.alreadyUsed[key].join(', '))} already used by component: ${key}`\n )\n )\n .filter((x) => x)\n .join('\\n');\n return alreadyUsedWarning ? `${alreadyUsedWarning}\\n` : '';\n };\n const emptyDirectoryOutput = () => {\n if (!warnings.emptyDirectory.length) return '';\n return chalk.yellow(\n `warning: the following directories are empty or all their files were excluded\\n${chalk.bold(\n warnings.emptyDirectory.join('\\n')\n )}\\n`\n );\n };\n return alreadyUsedOutput() + emptyDirectoryOutput();\n };\n\n if (addedComponents.length > 1) {\n return paintWarning() + chalk.green(`tracking ${addedComponents.length} new components`);\n }\n\n return (\n paintWarning() +\n addedComponents\n .map((result) => {\n if (result.files.length === 0) {\n return chalk.underline.red(`could not track component ${chalk.bold(result.id)}: no files to track`);\n }\n const title = chalk.underline(`tracking component ${chalk.bold(result.id)}:\\n`);\n const files = result.files.map((file) => chalk.green(`added ${file}`));\n return title + files.join('\\n');\n })\n .flat()\n .join('\\n\\n')\n );\n }\n\n async json(\n [paths = []]: [string[]],\n { id, main, namespace, scope, env, override = false }: AddFlags\n ): Promise<AddResults> {\n if (namespace && id) {\n throw new BitError(\n 'please use either [id] or [namespace] to add a particular component - they cannot be used together'\n );\n }\n\n const normalizedPaths: PathOsBased[] = paths.map((p) => path.normalize(p));\n const { addedComponents, warnings }: AddActionResults = await this.tracker.addForCLI({\n componentPaths: normalizedPaths,\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n id,\n main: main ? path.normalize(main) : undefined,\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n namespace,\n defaultScope: scope,\n override,\n env,\n });\n return {\n addedComponents: addedComponents.map((added) => ({\n id: added.id.toString(),\n files: added.files.map((f) => f.relativePath),\n })),\n warnings,\n };\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,KAAA;EAAA,MAAAH,IAAA,GAAAI,uBAAA,CAAAF,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,UAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,SAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA8C,SAAAI,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,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AAS;MACTW,YAAY,EAAEV,KAAK;MACnBE,QAAQ;MACRD;IACF,CAAC,CAAC;IACF,OAAO;MACL/B,eAAe,EAAEA,eAAe,CAACQ,GAAG,CAAEiC,KAAK,KAAM;QAC/CjB,EAAE,EAAEiB,KAAK,CAACjB,EAAE,CAACkB,QAAQ,CAAC,CAAC;QACvBrB,KAAK,EAAEoB,KAAK,CAACpB,KAAK,CAACb,GAAG,CAAErC,CAAC,IAAKA,CAAC,CAACwE,YAAY;MAC9C,CAAC,CAAC,CAAC;MACH1C;IACF,CAAC;EACH;AACF;AAAC2C,OAAA,CAAAlD,MAAA,GAAAA,MAAA","ignoreList":[]}
|
package/dist/add-components.d.ts
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
import { ComponentID } from '@teambit/component-id';
|
2
|
-
import { BitMap,
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
2
|
+
import type { BitMap, ComponentMapFile, Config } from '@teambit/legacy.bit-map';
|
3
|
+
import { ComponentMap } from '@teambit/legacy.bit-map';
|
4
|
+
import type { Consumer } from '@teambit/legacy.consumer';
|
5
|
+
import type { PathLinux, PathOsBased } from '@teambit/legacy.utils';
|
6
|
+
import type { Workspace } from '@teambit/workspace';
|
7
|
+
import type { ResolvedTrackData } from './tracker.main.runtime';
|
7
8
|
export type AddResult = {
|
8
9
|
id: ComponentID;
|
9
10
|
files: ComponentMapFile[];
|
@@ -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","_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","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","pathNormalizeToLinux","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","sep","lastDir","idOfTrackDir","bitId","BitId","parse","nameSpaceOrDir","getValidIdChunk","getValidBitId","addedComp","immediateDir","getIgnoreListHarmony","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 { BitIdStr, BitId } from '@teambit/legacy-bit-id';\nimport { PACKAGE_JSON, VERSION_DELIMITER, AUTO_GENERATED_STAMP } from '@teambit/legacy.constants';\nimport {\n BitMap,\n ComponentMap,\n ComponentMapFile,\n Config,\n getIgnoreListHarmony,\n MissingMainFile,\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 { Consumer } from '@teambit/legacy.consumer';\nimport { BitError } from '@teambit/bit-error';\nimport { logger } from '@teambit/legacy.logger';\nimport { glob, isDir, pathNormalizeToLinux, PathLinux, PathLinuxRelative, PathOsBased } from '@teambit/legacy.utils';\nimport { linkToNodeModulesByIds } from '@teambit/workspace.modules.node-modules-linker';\nimport { Workspace } from '@teambit/workspace';\nimport determineMainFile from './determine-main-file';\nimport { 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!\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 // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\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(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 // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\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(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 = path.resolve(componentPath);\n const splitPath = absoluteComponentPath.split(path.sep);\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);\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);\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,Q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,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","_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","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","pathNormalizeToLinux","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","sep","lastDir","idOfTrackDir","bitId","BitId","parse","nameSpaceOrDir","getValidIdChunk","getValidBitId","addedComp","immediateDir","getIgnoreListHarmony","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 { glob, isDir, pathNormalizeToLinux } from '@teambit/legacy.utils';\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!\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 // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\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(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 // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\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(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 = path.resolve(componentPath);\n const splitPath = absoluteComponentPath.split(path.sep);\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);\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);\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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N,QAAQ,CAAC3O,MAAM,EAAE;MACpB,MAAM,KAAIG,qBAAO,EAACc,KAAK,CAAC;IAC1B;IAEA,MAAMoE,cAAc,GAAGsJ,QAAQ,CAACnP,GAAG,CAAE6C,KAAkB,IAAK;MAC1D,OAAO;QAAEsC,YAAY,EAAE,IAAA/B,+BAAoB,EAACP,KAAK,CAAC;QAAEwG,IAAI,EAAEvO,IAAI,CAAD,CAAC,CAACwO,QAAQ,CAACzG,KAAK;MAAE,CAAC;IAClF,CAAC,CAAC;IAEF,MAAMe,YAAY,GAAGpF,MAAM,CAACqI,YAAY,CAAC;MACvCnC,WAAW,EAAEoC,0BAAW,CAACsI,UAAU,CAAC;QAAE/F,IAAI,EAAEO;MAAc,CAAC,EAAExK,YAAY,CAAC;MAC1EqC,KAAK,EAAEoE,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,4 +1,4 @@
|
|
1
|
-
import { PathLinux } from '@teambit/legacy.utils';
|
2
|
-
import { ComponentMap } from '@teambit/legacy.bit-map';
|
3
|
-
import { AddedComponent } from './add-components';
|
1
|
+
import type { PathLinux } from '@teambit/legacy.utils';
|
2
|
+
import type { ComponentMap } from '@teambit/legacy.bit-map';
|
3
|
+
import type { AddedComponent } from './add-components';
|
4
4
|
export default function determineMainFile(addedComponent: AddedComponent, existingComponentMap: ComponentMap | null | undefined): PathLinux;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["path","data","_interopRequireWildcard","require","_legacy","_legacy2","_legacy3","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","determineMainFile","addedComponent","existingComponentMap","mainFile","componentIdStr","componentId","toString","files","rootDir","strategies","getExistingIfNotChanged","getUserSpecifiedMainFile","onlyOneFileEnteredUseIt","searchForFileNameIndex","searchForSameFileNameAsImmediateDir","searchForAngularEntryPoint","strategy","foundMainFile","mainFileString","DEFAULT_INDEX_NAME","DEFAULT_INDEX_EXTS","join","MissingMainFile","map","file","normalize","relativePath","_searchMainFile","pathNormalizeToLinux","length","ext","mainFileNameToSearch","searchResult","immediateDir","entryPoint","ANGULAR_BIT_ENTRY_POINT_FILE","baseMainFile","mainFileFromFiles","find","mainFileUsingRootDir","pathJoinLinux","potentialMainFiles","filter","basename","sortByNumOfDirs","a","b","split","DEFAULT_SEPARATOR","sort"],"sources":["determine-main-file.ts"],"sourcesContent":["import * as path from 'path';\n\nimport {\n ANGULAR_BIT_ENTRY_POINT_FILE,\n DEFAULT_INDEX_EXTS,\n DEFAULT_INDEX_NAME,\n DEFAULT_SEPARATOR,\n} from '@teambit/legacy.constants';\nimport { pathJoinLinux, PathLinux, pathNormalizeToLinux } from '@teambit/legacy.utils';\nimport { ComponentMap, MissingMainFile } from '@teambit/legacy.bit-map';\nimport { AddedComponent } from './add-components';\n\nexport default function determineMainFile(\n addedComponent: AddedComponent,\n existingComponentMap: ComponentMap | null | undefined\n): PathLinux {\n const mainFile = addedComponent.mainFile;\n const componentIdStr = addedComponent.componentId.toString();\n const files = addedComponent.files;\n const rootDir = existingComponentMap && existingComponentMap.rootDir;\n const strategies: Function[] = [\n getExistingIfNotChanged,\n getUserSpecifiedMainFile,\n onlyOneFileEnteredUseIt,\n searchForFileNameIndex,\n searchForSameFileNameAsImmediateDir,\n searchForAngularEntryPoint,\n ];\n\n for (const strategy of strategies) {\n const foundMainFile = strategy();\n if (foundMainFile) {\n return foundMainFile;\n }\n }\n const mainFileString = `${DEFAULT_INDEX_NAME}.[${DEFAULT_INDEX_EXTS.join(', ')}]`;\n throw new MissingMainFile(\n componentIdStr,\n mainFileString,\n files.map((file) => path.normalize(file.relativePath))\n );\n\n /**\n * user didn't enter mainFile but the component already exists with mainFile\n */\n function getExistingIfNotChanged(): PathLinux | null | undefined {\n if (!mainFile && existingComponentMap) {\n return existingComponentMap.mainFile;\n }\n return null;\n }\n /**\n * user entered mainFile => search the mainFile in the files array, throw error if not found\n */\n function getUserSpecifiedMainFile(): PathLinux | null | undefined {\n if (mainFile) {\n const foundMainFile = _searchMainFile(pathNormalizeToLinux(mainFile));\n if (foundMainFile) return foundMainFile;\n throw new MissingMainFile(\n componentIdStr,\n mainFile,\n files.map((file) => path.normalize(file.relativePath))\n );\n }\n return null;\n }\n /**\n * user didn't enter mainFile and the component has only one file, use that file as the main file\n */\n function onlyOneFileEnteredUseIt(): PathLinux | null | undefined {\n if (files.length === 1) {\n return files[0].relativePath;\n }\n return null;\n }\n /**\n * user didn't enter mainFile and the component has multiple files, search for file name \"index\",\n * e.g. `index.js`, `index.css`, etc.\n */\n function searchForFileNameIndex(): PathLinux | null | undefined {\n for (const ext of DEFAULT_INDEX_EXTS) {\n const mainFileNameToSearch = `${DEFAULT_INDEX_NAME}.${ext}`;\n const searchResult = _searchMainFile(mainFileNameToSearch);\n if (searchResult) {\n return searchResult;\n }\n }\n return null;\n }\n /**\n * user didn't enter mainFile and the component has multiple files, search for file with the same\n * name as the directory (see #1714)\n */\n function searchForSameFileNameAsImmediateDir(): PathLinux | null | undefined {\n if (addedComponent.immediateDir) {\n for (const ext of DEFAULT_INDEX_EXTS) {\n const mainFileNameToSearch = `${addedComponent.immediateDir}.${ext}`;\n const searchResult = _searchMainFile(mainFileNameToSearch);\n if (searchResult) {\n return searchResult;\n }\n }\n }\n return null;\n }\n /**\n * The component is an angular component and uses the angular entry point\n */\n function searchForAngularEntryPoint(): PathLinux | null | undefined {\n for (const entryPoint of ANGULAR_BIT_ENTRY_POINT_FILE) {\n const searchResult = _searchMainFile(entryPoint);\n if (searchResult) {\n return searchResult;\n }\n }\n return null;\n }\n\n function _searchMainFile(baseMainFile: PathLinux): PathLinux | null | undefined {\n // search for an exact relative-path\n let mainFileFromFiles = files.find((file) => file.relativePath === baseMainFile);\n if (mainFileFromFiles) return baseMainFile;\n if (rootDir) {\n const mainFileUsingRootDir = files.find((file) => pathJoinLinux(rootDir, file.relativePath) === baseMainFile);\n if (mainFileUsingRootDir) return mainFileUsingRootDir.relativePath;\n }\n // search for a file-name\n const potentialMainFiles = files.filter((file) => path.basename(file.relativePath) === baseMainFile);\n if (!potentialMainFiles.length) return null;\n // when there are several files that met the criteria, choose the closer to the root\n const sortByNumOfDirs = (a, b) =>\n a.relativePath.split(DEFAULT_SEPARATOR).length - b.relativePath.split(DEFAULT_SEPARATOR).length;\n potentialMainFiles.sort(sortByNumOfDirs);\n mainFileFromFiles = potentialMainFiles[0];\n return mainFileFromFiles.relativePath;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,uBAAA,CAAAC,OAAA;EAAAH,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAMA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,SAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,QAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAwE,SAAAC,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAA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ACpE;IACA;IACA,MAAMe,kBAAkB,GAAGlC,KAAK,CAACmC,MAAM,CAAElB,IAAI,IAAKlD,IAAI,CAAD,CAAC,CAACqE,QAAQ,CAACnB,IAAI,CAACE,YAAY,CAAC,KAAKU,YAAY,CAAC;IACpG,IAAI,CAACK,kBAAkB,CAACZ,MAAM,EAAE,OAAO,IAAI;IAC3C;IACA,MAAMe,eAAe,GAAGA,CAACC,CAAC,EAAEC,CAAC,KAC3BD,CAAC,CAACnB,YAAY,CAACqB,KAAK,CAACC,2BAAiB,CAAC,CAACnB,MAAM,GAAGiB,CAAC,CAACpB,YAAY,CAACqB,KAAK,CAACC,2BAAiB,CAAC,CAACnB,MAAM;IACjGY,kBAAkB,CAACQ,IAAI,CAACL,eAAe,CAAC;IACxCP,iBAAiB,GAAGI,kBAAkB,CAAC,CAAC,CAAC;IACzC,OAAOJ,iBAAiB,CAACX,YAAY;EACvC;AACF","ignoreList":[]}
|
1
|
+
{"version":3,"names":["path","data","_interopRequireWildcard","require","_legacy","_legacy2","_legacy3","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","determineMainFile","addedComponent","existingComponentMap","mainFile","componentIdStr","componentId","toString","files","rootDir","strategies","getExistingIfNotChanged","getUserSpecifiedMainFile","onlyOneFileEnteredUseIt","searchForFileNameIndex","searchForSameFileNameAsImmediateDir","searchForAngularEntryPoint","strategy","foundMainFile","mainFileString","DEFAULT_INDEX_NAME","DEFAULT_INDEX_EXTS","join","MissingMainFile","map","file","normalize","relativePath","_searchMainFile","pathNormalizeToLinux","length","ext","mainFileNameToSearch","searchResult","immediateDir","entryPoint","ANGULAR_BIT_ENTRY_POINT_FILE","baseMainFile","mainFileFromFiles","find","mainFileUsingRootDir","pathJoinLinux","potentialMainFiles","filter","basename","sortByNumOfDirs","a","b","split","DEFAULT_SEPARATOR","sort"],"sources":["determine-main-file.ts"],"sourcesContent":["import * as path from 'path';\n\nimport {\n ANGULAR_BIT_ENTRY_POINT_FILE,\n DEFAULT_INDEX_EXTS,\n DEFAULT_INDEX_NAME,\n DEFAULT_SEPARATOR,\n} from '@teambit/legacy.constants';\nimport type { PathLinux } from '@teambit/legacy.utils';\nimport { pathJoinLinux, pathNormalizeToLinux } from '@teambit/legacy.utils';\nimport type { ComponentMap } from '@teambit/legacy.bit-map';\nimport { MissingMainFile } from '@teambit/legacy.bit-map';\nimport type { AddedComponent } from './add-components';\n\nexport default function determineMainFile(\n addedComponent: AddedComponent,\n existingComponentMap: ComponentMap | null | undefined\n): PathLinux {\n const mainFile = addedComponent.mainFile;\n const componentIdStr = addedComponent.componentId.toString();\n const files = addedComponent.files;\n const rootDir = existingComponentMap && existingComponentMap.rootDir;\n const strategies: Function[] = [\n getExistingIfNotChanged,\n getUserSpecifiedMainFile,\n onlyOneFileEnteredUseIt,\n searchForFileNameIndex,\n searchForSameFileNameAsImmediateDir,\n searchForAngularEntryPoint,\n ];\n\n for (const strategy of strategies) {\n const foundMainFile = strategy();\n if (foundMainFile) {\n return foundMainFile;\n }\n }\n const mainFileString = `${DEFAULT_INDEX_NAME}.[${DEFAULT_INDEX_EXTS.join(', ')}]`;\n throw new MissingMainFile(\n componentIdStr,\n mainFileString,\n files.map((file) => path.normalize(file.relativePath))\n );\n\n /**\n * user didn't enter mainFile but the component already exists with mainFile\n */\n function getExistingIfNotChanged(): PathLinux | null | undefined {\n if (!mainFile && existingComponentMap) {\n return existingComponentMap.mainFile;\n }\n return null;\n }\n /**\n * user entered mainFile => search the mainFile in the files array, throw error if not found\n */\n function getUserSpecifiedMainFile(): PathLinux | null | undefined {\n if (mainFile) {\n const foundMainFile = _searchMainFile(pathNormalizeToLinux(mainFile));\n if (foundMainFile) return foundMainFile;\n throw new MissingMainFile(\n componentIdStr,\n mainFile,\n files.map((file) => path.normalize(file.relativePath))\n );\n }\n return null;\n }\n /**\n * user didn't enter mainFile and the component has only one file, use that file as the main file\n */\n function onlyOneFileEnteredUseIt(): PathLinux | null | undefined {\n if (files.length === 1) {\n return files[0].relativePath;\n }\n return null;\n }\n /**\n * user didn't enter mainFile and the component has multiple files, search for file name \"index\",\n * e.g. `index.js`, `index.css`, etc.\n */\n function searchForFileNameIndex(): PathLinux | null | undefined {\n for (const ext of DEFAULT_INDEX_EXTS) {\n const mainFileNameToSearch = `${DEFAULT_INDEX_NAME}.${ext}`;\n const searchResult = _searchMainFile(mainFileNameToSearch);\n if (searchResult) {\n return searchResult;\n }\n }\n return null;\n }\n /**\n * user didn't enter mainFile and the component has multiple files, search for file with the same\n * name as the directory (see #1714)\n */\n function searchForSameFileNameAsImmediateDir(): PathLinux | null | undefined {\n if (addedComponent.immediateDir) {\n for (const ext of DEFAULT_INDEX_EXTS) {\n const mainFileNameToSearch = `${addedComponent.immediateDir}.${ext}`;\n const searchResult = _searchMainFile(mainFileNameToSearch);\n if (searchResult) {\n return searchResult;\n }\n }\n }\n return null;\n }\n /**\n * The component is an angular component and uses the angular entry point\n */\n function searchForAngularEntryPoint(): PathLinux | null | undefined {\n for (const entryPoint of ANGULAR_BIT_ENTRY_POINT_FILE) {\n const searchResult = _searchMainFile(entryPoint);\n if (searchResult) {\n return searchResult;\n }\n }\n return null;\n }\n\n function _searchMainFile(baseMainFile: PathLinux): PathLinux | null | undefined {\n // search for an exact relative-path\n let mainFileFromFiles = files.find((file) => file.relativePath === baseMainFile);\n if (mainFileFromFiles) return baseMainFile;\n if (rootDir) {\n const mainFileUsingRootDir = files.find((file) => pathJoinLinux(rootDir, file.relativePath) === baseMainFile);\n if (mainFileUsingRootDir) return mainFileUsingRootDir.relativePath;\n }\n // search for a file-name\n const potentialMainFiles = files.filter((file) => path.basename(file.relativePath) === baseMainFile);\n if (!potentialMainFiles.length) return null;\n // when there are several files that met the criteria, choose the closer to the root\n const sortByNumOfDirs = (a, b) =>\n a.relativePath.split(DEFAULT_SEPARATOR).length - b.relativePath.split(DEFAULT_SEPARATOR).length;\n potentialMainFiles.sort(sortByNumOfDirs);\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CAAC,CAAC,CAAC;IACzC,OAAOJ,iBAAiB,CAACX,YAAY;EACvC;AACF","ignoreList":[]}
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { CLIMain } from '@teambit/cli';
|
2
|
-
import { ComponentID } from '@teambit/component-id';
|
3
|
-
import { Workspace } from '@teambit/workspace';
|
4
|
-
import { Logger, LoggerMain } from '@teambit/logger';
|
5
|
-
import { PathOsBasedRelative, PathOsBasedAbsolute, PathLinuxRelative } from '@teambit/legacy.utils';
|
6
|
-
import { AddActionResults, AddProps, Warnings } from './add-components';
|
1
|
+
import type { CLIMain } from '@teambit/cli';
|
2
|
+
import type { ComponentID } from '@teambit/component-id';
|
3
|
+
import type { Workspace } from '@teambit/workspace';
|
4
|
+
import type { Logger, LoggerMain } from '@teambit/logger';
|
5
|
+
import type { PathOsBasedRelative, PathOsBasedAbsolute, PathLinuxRelative } from '@teambit/legacy.utils';
|
6
|
+
import type { AddActionResults, AddProps, Warnings } from './add-components';
|
7
7
|
export type TrackResult = {
|
8
8
|
files: string[];
|
9
9
|
warnings: Warnings;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_cli","data","require","_path","_interopRequireDefault","_envs","_workspace","_logger","_addCmd","_addComponents","_interopRequireWildcard","_tracker","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","TrackerMain","constructor","workspace","logger","track","trackData","defaultScope","addOwnerToScopeName","undefined","compPath","path","isAbsolute","rootDir","join","addComponent","AddComponents","componentPaths","id","componentName","main","mainFile","override","config","result","add","addedComponent","addedComponents","files","map","relativePath","warnings","componentId","trackMany","manyTrackData","addMultipleFromResolvedTrackData","addForCLI","addProps","OutsideWorkspaceError","addContext","shouldHandleOutOfSync","env","addEnvToConfig","addComponents","addResults","consumer","onDestroy","userEnvId","resolveComponentId","userEnvIdWithPotentialVersion","resolveEnvIdWithPotentialVersionForConfig","toStringWithoutVersion","EnvsAspect","scopeName","includes","isSelfHosted","isHostedByBit","wsDefaultScope","warn","owner","split","remotes","scope","getRemoteScopes","isHub","provider","cli","loggerMain","createLogger","TrackerAspect","trackerMain","register","AddCmd","exports","CLIAspect","WorkspaceAspect","LoggerAspect","MainRuntime","addRuntime","_default"],"sources":["tracker.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport path from 'path';\nimport { ComponentID } from '@teambit/component-id';\nimport { EnvsAspect } from '@teambit/envs';\nimport { WorkspaceAspect, OutsideWorkspaceError, Workspace } from '@teambit/workspace';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { PathOsBasedRelative, PathOsBasedAbsolute, PathLinuxRelative } from '@teambit/legacy.utils';\nimport { AddCmd } from './add-cmd';\nimport AddComponents, {\n AddActionResults,\n AddContext,\n addMultipleFromResolvedTrackData,\n AddProps,\n Warnings,\n} from './add-components';\nimport { TrackerAspect } from './tracker.aspect';\n\nexport type TrackResult = { files: string[]; warnings: Warnings; componentId: ComponentID };\n\n/**\n * this is for \"bit add\", where some data, such as \"componentName\" are not necessarily known\n */\nexport type TrackData = {\n rootDir: PathOsBasedRelative | PathOsBasedAbsolute; // path relative to the workspace or absolute path\n componentName?: string; // if empty, it'll be generated from the path\n mainFile?: string; // if empty, attempts will be made to guess the best candidate\n defaultScope?: string; // can be entered as part of \"bit create\" command, helpful for out-of-sync logic\n config?: { [aspectName: string]: any }; // config specific to this component, which overrides variants of workspace.jsonc\n};\n\n/**\n * this is for commands where we know all the data to enter into .bitmap, such as defaultScope, componentName and files.\n */\nexport type ResolvedTrackData = {\n rootDir: PathLinuxRelative; // path relative to the workspace\n componentName: string;\n mainFile: string;\n files: string[]; // component files relative to the component rootDir\n defaultScope: string;\n config?: { [aspectName: string]: any }; // config specific to this component, which overrides variants of workspace.jsonc\n};\n\nexport class TrackerMain {\n constructor(\n private workspace: Workspace,\n private logger: Logger\n ) {}\n\n /**\n * add a new component to the .bitmap file.\n * this method only adds the records in memory but doesn't persist to the filesystem.\n * to write the .bitmap file once completed, run \"await this.bitMap.write();\"\n */\n async track(trackData: TrackData): Promise<TrackResult> {\n const defaultScope = trackData.defaultScope ? await this.addOwnerToScopeName(trackData.defaultScope) : undefined;\n const compPath = path.isAbsolute(trackData.rootDir)\n ? trackData.rootDir\n : path.join(this.workspace.path, trackData.rootDir);\n const addComponent = new AddComponents(\n { workspace: this.workspace },\n {\n componentPaths: [compPath],\n id: trackData.componentName,\n main: trackData.mainFile,\n override: false,\n defaultScope,\n config: trackData.config,\n }\n );\n const result = await addComponent.add();\n const addedComponent = result.addedComponents[0];\n const files = addedComponent?.files.map((f) => f.relativePath) || [];\n return { files, warnings: result.warnings, componentId: result.addedComponents[0].id };\n }\n\n async trackMany(manyTrackData: ResolvedTrackData[]): Promise<ComponentID[]> {\n return addMultipleFromResolvedTrackData(this.workspace, manyTrackData);\n }\n\n async addForCLI(addProps: AddProps): Promise<AddActionResults> {\n if (!this.workspace) throw new OutsideWorkspaceError();\n const addContext: AddContext = { workspace: this.workspace };\n addProps.shouldHandleOutOfSync = true;\n if (addProps.env) {\n const config = {};\n await this.addEnvToConfig(addProps.env, config);\n addProps.config = config;\n }\n const addComponents = new AddComponents(addContext, addProps);\n const addResults = await addComponents.add();\n await this.workspace.consumer.onDestroy('add');\n\n return addResults;\n }\n\n async addEnvToConfig(env: string, config: { [aspectName: string]: any }) {\n const userEnvId = await this.workspace.resolveComponentId(env);\n let userEnvIdWithPotentialVersion: string;\n try {\n userEnvIdWithPotentialVersion = await this.workspace.resolveEnvIdWithPotentialVersionForConfig(userEnvId);\n } catch {\n // the env needs to be without version\n userEnvIdWithPotentialVersion = userEnvId.toStringWithoutVersion();\n }\n config[userEnvIdWithPotentialVersion] = {};\n config[EnvsAspect.id] = config[EnvsAspect.id] || {};\n config[EnvsAspect.id].env = userEnvId.toStringWithoutVersion();\n }\n\n /**\n * scopes in bit.dev are \"owner.collection\".\n * we might have the scope-name only without the owner and we need to retrieve it from the defaultScope in the\n * workspace.jsonc file.\n *\n * @param scopeName scopeName that might not have the owner part.\n * @returns full scope name\n */\n private async addOwnerToScopeName(scopeName: string): Promise<string> {\n if (scopeName.includes('.')) return scopeName; // it has owner.\n const isSelfHosted = !(await this.isHostedByBit(scopeName));\n if (isSelfHosted) return scopeName;\n const wsDefaultScope = this.workspace.defaultScope;\n if (!wsDefaultScope.includes('.')) {\n this.logger.warn(`the entered scope ${scopeName} has no owner nor the defaultScope in workspace.jsonc`);\n // it's possible that the user entered a non-exist scope just to test the command and will change it later.\n return scopeName;\n }\n const [owner] = wsDefaultScope.split('.');\n return `${owner}.${scopeName}`;\n }\n\n /**\n * whether a scope is hosted by Bit cloud.\n * otherwise, it is self-hosted\n */\n private async isHostedByBit(scopeName: string): Promise<boolean> {\n const remotes = await this.workspace.scope.getRemoteScopes();\n return remotes.isHub(scopeName);\n }\n\n static slots = [];\n static dependencies = [CLIAspect, WorkspaceAspect, LoggerAspect];\n static runtime = MainRuntime;\n static async provider([cli, workspace, loggerMain]: [CLIMain, Workspace, LoggerMain]) {\n const logger = loggerMain.createLogger(TrackerAspect.id);\n const trackerMain = new TrackerMain(workspace, logger);\n cli.register(new AddCmd(trackerMain));\n return trackerMain;\n }\n}\n\nTrackerAspect.addRuntime(TrackerMain);\n\nexport default TrackerMain;\n"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,MAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,MAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EA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Y,CAACC,wBAAa,CAACnD,EAAE,CAAC;IACxD,MAAMoD,WAAW,GAAG,IAAIrE,WAAW,CAACE,SAAS,EAAEC,MAAM,CAAC;IACtD8D,GAAG,CAACK,QAAQ,CAAC,KAAIC,gBAAM,EAACF,WAAW,CAAC,CAAC;IACrC,OAAOA,WAAW;EACpB;AACF;AAACG,OAAA,CAAAxE,WAAA,GAAAA,WAAA;AAAAZ,eAAA,CA3GYY,WAAW,WAkGP,EAAE;AAAAZ,eAAA,CAlGNY,WAAW,kBAmGA,CAACyE,gBAAS,EAAEC,4BAAe,EAAEC,sBAAY,CAAC;AAAAvF,eAAA,CAnGrDY,WAAW,aAoGL4E,kBAAW;AAS9BR,wBAAa,CAACS,UAAU,CAAC7E,WAAW,CAAC;AAAC,IAAA8E,QAAA,GAAAN,OAAA,CAAA7F,OAAA,GAEvBqB,WAAW","ignoreList":[]}
|
1
|
+
{"version":3,"names":["_cli","data","require","_path","_interopRequireDefault","_envs","_workspace","_logger","_addCmd","_addComponents","_interopRequireWildcard","_tracker","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","TrackerMain","constructor","workspace","logger","track","trackData","defaultScope","addOwnerToScopeName","undefined","compPath","path","isAbsolute","rootDir","join","addComponent","AddComponents","componentPaths","id","componentName","main","mainFile","override","config","result","add","addedComponent","addedComponents","files","map","relativePath","warnings","componentId","trackMany","manyTrackData","addMultipleFromResolvedTrackData","addForCLI","addProps","OutsideWorkspaceError","addContext","shouldHandleOutOfSync","env","addEnvToConfig","addComponents","addResults","consumer","onDestroy","userEnvId","resolveComponentId","userEnvIdWithPotentialVersion","resolveEnvIdWithPotentialVersionForConfig","toStringWithoutVersion","EnvsAspect","scopeName","includes","isSelfHosted","isHostedByBit","wsDefaultScope","warn","owner","split","remotes","scope","getRemoteScopes","isHub","provider","cli","loggerMain","createLogger","TrackerAspect","trackerMain","register","AddCmd","exports","CLIAspect","WorkspaceAspect","LoggerAspect","MainRuntime","addRuntime","_default"],"sources":["tracker.main.runtime.ts"],"sourcesContent":["import type { CLIMain } from '@teambit/cli';\nimport { CLIAspect, MainRuntime } from '@teambit/cli';\nimport path from 'path';\nimport type { ComponentID } from '@teambit/component-id';\nimport { EnvsAspect } from '@teambit/envs';\nimport type { Workspace } from '@teambit/workspace';\nimport { WorkspaceAspect, OutsideWorkspaceError } from '@teambit/workspace';\nimport type { Logger, LoggerMain } from '@teambit/logger';\nimport { LoggerAspect } from '@teambit/logger';\nimport type { PathOsBasedRelative, PathOsBasedAbsolute, PathLinuxRelative } from '@teambit/legacy.utils';\nimport { AddCmd } from './add-cmd';\nimport type { AddActionResults, AddContext, AddProps, Warnings } from './add-components';\nimport AddComponents, { addMultipleFromResolvedTrackData } from './add-components';\nimport { TrackerAspect } from './tracker.aspect';\n\nexport type TrackResult = { files: string[]; warnings: Warnings; componentId: ComponentID };\n\n/**\n * this is for \"bit add\", where some data, such as \"componentName\" are not necessarily known\n */\nexport type TrackData = {\n rootDir: PathOsBasedRelative | PathOsBasedAbsolute; // path relative to the workspace or absolute path\n componentName?: string; // if empty, it'll be generated from the path\n mainFile?: string; // if empty, attempts will be made to guess the best candidate\n defaultScope?: string; // can be entered as part of \"bit create\" command, helpful for out-of-sync logic\n config?: { [aspectName: string]: any }; // config specific to this component, which overrides variants of workspace.jsonc\n};\n\n/**\n * this is for commands where we know all the data to enter into .bitmap, such as defaultScope, componentName and files.\n */\nexport type ResolvedTrackData = {\n rootDir: PathLinuxRelative; // path relative to the workspace\n componentName: string;\n mainFile: string;\n files: string[]; // component files relative to the component rootDir\n defaultScope: string;\n config?: { [aspectName: string]: any }; // config specific to this component, which overrides variants of workspace.jsonc\n};\n\nexport class TrackerMain {\n constructor(\n private workspace: Workspace,\n private logger: Logger\n ) {}\n\n /**\n * add a new component to the .bitmap file.\n * this method only adds the records in memory but doesn't persist to the filesystem.\n * to write the .bitmap file once completed, run \"await this.bitMap.write();\"\n */\n async track(trackData: TrackData): Promise<TrackResult> {\n const defaultScope = trackData.defaultScope ? await this.addOwnerToScopeName(trackData.defaultScope) : undefined;\n const compPath = path.isAbsolute(trackData.rootDir)\n ? trackData.rootDir\n : path.join(this.workspace.path, trackData.rootDir);\n const addComponent = new AddComponents(\n { workspace: this.workspace },\n {\n componentPaths: [compPath],\n id: trackData.componentName,\n main: trackData.mainFile,\n override: false,\n defaultScope,\n config: trackData.config,\n }\n );\n const result = await addComponent.add();\n const addedComponent = result.addedComponents[0];\n const files = addedComponent?.files.map((f) => f.relativePath) || [];\n return { files, warnings: result.warnings, componentId: result.addedComponents[0].id };\n }\n\n async trackMany(manyTrackData: ResolvedTrackData[]): Promise<ComponentID[]> {\n return addMultipleFromResolvedTrackData(this.workspace, manyTrackData);\n }\n\n async addForCLI(addProps: AddProps): Promise<AddActionResults> {\n if (!this.workspace) throw new OutsideWorkspaceError();\n const addContext: AddContext = { workspace: this.workspace };\n addProps.shouldHandleOutOfSync = true;\n if (addProps.env) {\n const config = {};\n await this.addEnvToConfig(addProps.env, config);\n addProps.config = config;\n }\n const addComponents = new AddComponents(addContext, addProps);\n const addResults = await addComponents.add();\n await this.workspace.consumer.onDestroy('add');\n\n return addResults;\n }\n\n async addEnvToConfig(env: string, config: { [aspectName: string]: any }) {\n const userEnvId = await this.workspace.resolveComponentId(env);\n let userEnvIdWithPotentialVersion: string;\n try {\n userEnvIdWithPotentialVersion = await this.workspace.resolveEnvIdWithPotentialVersionForConfig(userEnvId);\n } catch {\n // the env needs to be without version\n userEnvIdWithPotentialVersion = userEnvId.toStringWithoutVersion();\n }\n config[userEnvIdWithPotentialVersion] = {};\n config[EnvsAspect.id] = config[EnvsAspect.id] || {};\n config[EnvsAspect.id].env = userEnvId.toStringWithoutVersion();\n }\n\n /**\n * scopes in bit.dev are \"owner.collection\".\n * we might have the scope-name only without the owner and we need to retrieve it from the defaultScope in the\n * workspace.jsonc file.\n *\n * @param scopeName scopeName that might not have the owner part.\n * @returns full scope name\n */\n private async addOwnerToScopeName(scopeName: string): Promise<string> {\n if (scopeName.includes('.')) return scopeName; // it has owner.\n const isSelfHosted = !(await this.isHostedByBit(scopeName));\n if (isSelfHosted) return scopeName;\n const wsDefaultScope = this.workspace.defaultScope;\n if (!wsDefaultScope.includes('.')) {\n this.logger.warn(`the entered scope ${scopeName} has no owner nor the defaultScope in workspace.jsonc`);\n // it's possible that the user entered a non-exist scope just to test the command and will change it later.\n return scopeName;\n }\n const [owner] = wsDefaultScope.split('.');\n return `${owner}.${scopeName}`;\n }\n\n /**\n * whether a scope is hosted by Bit cloud.\n * otherwise, it is self-hosted\n */\n private async isHostedByBit(scopeName: string): Promise<boolean> {\n const remotes = await this.workspace.scope.getRemoteScopes();\n return remotes.isHub(scopeName);\n }\n\n static slots = [];\n static dependencies = [CLIAspect, WorkspaceAspect, LoggerAspect];\n static runtime = MainRuntime;\n static async provider([cli, workspace, loggerMain]: [CLIMain, Workspace, LoggerMain]) {\n const logger = loggerMain.createLogger(TrackerAspect.id);\n const trackerMain = new TrackerMain(workspace, logger);\n cli.register(new AddCmd(trackerMain));\n return trackerMain;\n }\n}\n\nTrackerAspect.addRuntime(TrackerMain);\n\nexport default TrackerMain;\n"],"mappings":";;;;;;AACA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,MAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,MAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,KAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;A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,CAACE,SAAS,EAAEC,MAAM,CAAC;IACtD8D,GAAG,CAACK,QAAQ,CAAC,KAAIC,gBAAM,EAACF,WAAW,CAAC,CAAC;IACrC,OAAOA,WAAW;EACpB;AACF;AAACG,OAAA,CAAAxE,WAAA,GAAAA,WAAA;AAAAZ,eAAA,CA3GYY,WAAW,WAkGP,EAAE;AAAAZ,eAAA,CAlGNY,WAAW,kBAmGA,CAACyE,gBAAS,EAAEC,4BAAe,EAAEC,sBAAY,CAAC;AAAAvF,eAAA,CAnGrDY,WAAW,aAoGL4E,kBAAW;AAS9BR,wBAAa,CAACS,UAAU,CAAC7E,WAAW,CAAC;AAAC,IAAA8E,QAAA,GAAAN,OAAA,CAAA7F,OAAA,GAEvBqB,WAAW","ignoreList":[]}
|
package/package.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@teambit/tracker",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.669",
|
4
4
|
"homepage": "https://bit.cloud/teambit/component/tracker",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"componentId": {
|
7
7
|
"scope": "teambit.component",
|
8
8
|
"name": "tracker",
|
9
|
-
"version": "1.0.
|
9
|
+
"version": "1.0.669"
|
10
10
|
},
|
11
11
|
"dependencies": {
|
12
12
|
"chalk": "4.1.2",
|
@@ -21,16 +21,16 @@
|
|
21
21
|
"@teambit/component-id": "1.2.4",
|
22
22
|
"@teambit/legacy-bit-id": "1.1.3",
|
23
23
|
"@teambit/legacy.analytics": "0.0.75",
|
24
|
-
"@teambit/legacy.bit-map": "0.0.
|
24
|
+
"@teambit/legacy.bit-map": "0.0.115",
|
25
25
|
"@teambit/legacy.constants": "0.0.13",
|
26
|
-
"@teambit/legacy.consumer": "0.0.
|
26
|
+
"@teambit/legacy.consumer": "0.0.58",
|
27
27
|
"@teambit/legacy.logger": "0.0.22",
|
28
|
-
"@teambit/workspace.modules.node-modules-linker": "0.0.
|
28
|
+
"@teambit/workspace.modules.node-modules-linker": "0.0.286",
|
29
29
|
"@teambit/harmony": "0.4.7",
|
30
|
-
"@teambit/cli": "0.0.
|
31
|
-
"@teambit/workspace": "1.0.
|
32
|
-
"@teambit/envs": "1.0.
|
33
|
-
"@teambit/logger": "0.0.
|
30
|
+
"@teambit/cli": "0.0.1246",
|
31
|
+
"@teambit/workspace": "1.0.669",
|
32
|
+
"@teambit/envs": "1.0.669",
|
33
|
+
"@teambit/logger": "0.0.1339"
|
34
34
|
},
|
35
35
|
"devDependencies": {
|
36
36
|
"@types/fs-extra": "9.0.7",
|
File without changes
|