@teambit/workspace 0.0.909 → 0.0.913
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/on-component-events.d.ts +1 -0
- package/dist/on-component-events.js.map +1 -1
- package/dist/watch/watcher.js +1 -0
- package/dist/watch/watcher.js.map +1 -1
- package/dist/workspace.d.ts +13 -4
- package/dist/workspace.js +41 -26
- package/dist/workspace.js.map +1 -1
- package/dist/workspace.main.runtime.js +1 -1
- package/dist/workspace.main.runtime.js.map +1 -1
- package/dist/workspace.provider.d.ts +4 -2
- package/dist/workspace.provider.js +2 -2
- package/dist/workspace.provider.js.map +1 -1
- package/package-tar/teambit-workspace-0.0.913.tgz +0 -0
- package/package.json +33 -33
- package/{preview-1669087658340.js → preview-1669260309159.js} +2 -2
- package/watch/watcher.ts +1 -0
- package/package-tar/teambit-workspace-0.0.909.tgz +0 -0
|
@@ -12,4 +12,5 @@ export declare type OnComponentEventResult = {
|
|
|
12
12
|
extensionId: string;
|
|
13
13
|
results: SerializableResults;
|
|
14
14
|
};
|
|
15
|
+
export declare type OnMultipleComponentsAdd = () => Promise<void>;
|
|
15
16
|
export declare type OnComponentLoad = (component: Component, loadOpts?: ComponentLoadOptions) => Promise<AspectData | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["on-component-events.ts"],"sourcesContent":["import { Component, ComponentID, AspectData } from '@teambit/component';\nimport { CompilationInitiator } from '@teambit/compiler';\nimport { ComponentLoadOptions } from '@teambit/legacy/dist/consumer/component/component-loader';\n\nexport type SerializableResults = { results: any; toString: () => string };\nexport type OnComponentChange = (\n component: Component,\n files: string[],\n initiator?: CompilationInitiator\n) => Promise<SerializableResults>;\nexport type OnComponentAdd = (component: Component, files: string[]) => Promise<SerializableResults>;\nexport type OnComponentRemove = (componentId: ComponentID) => Promise<SerializableResults>;\nexport type OnComponentEventResult = { extensionId: string; results: SerializableResults };\n\nexport type OnComponentLoad = (\n component: Component,\n loadOpts?: ComponentLoadOptions\n) => Promise<AspectData | undefined>;\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["on-component-events.ts"],"sourcesContent":["import { Component, ComponentID, AspectData } from '@teambit/component';\nimport { CompilationInitiator } from '@teambit/compiler';\nimport { ComponentLoadOptions } from '@teambit/legacy/dist/consumer/component/component-loader';\n\nexport type SerializableResults = { results: any; toString: () => string };\nexport type OnComponentChange = (\n component: Component,\n files: string[],\n initiator?: CompilationInitiator\n) => Promise<SerializableResults>;\nexport type OnComponentAdd = (component: Component, files: string[]) => Promise<SerializableResults>;\nexport type OnComponentRemove = (componentId: ComponentID) => Promise<SerializableResults>;\nexport type OnComponentEventResult = { extensionId: string; results: SerializableResults };\nexport type OnMultipleComponentsAdd = () => Promise<void>;\n\nexport type OnComponentLoad = (\n component: Component,\n loadOpts?: ComponentLoadOptions\n) => Promise<AspectData | undefined>;\n"],"mappings":""}
|
package/dist/watch/watcher.js
CHANGED
|
@@ -325,6 +325,7 @@ class Watcher {
|
|
|
325
325
|
this.fsWatcher.add(newDirs);
|
|
326
326
|
const addResults = await (0, _pMapSeries().default)(newDirs, async dir => this.executeWatchOperationsOnComponent(this.trackDirs[dir], [], false));
|
|
327
327
|
results.push(...addResults.flat());
|
|
328
|
+
await this.workspace.triggerOnMultipleComponentsAdd();
|
|
328
329
|
}
|
|
329
330
|
if (removedDirs.length) {
|
|
330
331
|
await this.fsWatcher.unwatch(removedDirs);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DEBOUNCE_WAIT_MS","Watcher","constructor","workspace","pubsub","trackDirs","verbose","multipleWatchers","WatchQueue","consumer","watchAll","opts","msgs","watchOpts","pathsToWatch","getPathsToWatch","componentIds","Object","values","triggerOnPreWatch","createWatcher","watcher","fsWatcher","onStart","Promise","resolve","reject","process","env","BIT_LOG","onAll","on","onReady","filePath","startTime","Date","getTime","files","results","debounced","failureMsg","handleChange","initiator","duration","onChange","onAdd","p","onUnlink","err","onError","endsWith","BIT_MAP","bitMapChangesInProgress","buildResults","watchQueue","add","handleBitmapChanges","loader","stop","onIdle","componentId","getComponentIdByPath","logger","debug","compIdStr","toString","changedFilesPerComponent","push","sleep","triggerCompChanges","length","undefined","join","msg","error","console","message","ms","setTimeout","clearComponentCache","component","get","componentMap","state","_consumer","compFiles","filter","relativeFile","getRelativePathLinux","isCompFile","Boolean","getFilesRelativeToConsumer","find","executeWatchOperationsOnComponent","previewsTrackDirs","_reloadConsumer","setTrackDirs","newDirs","difference","keys","removedDirs","addResults","mapSeries","dir","flat","unwatch","executeWatchOperationsOnRemove","chalk","bold","pub","WorkspaceAspect","id","creatOnComponentRemovedEvent","triggerOnComponentRemove","isChange","isComponentWatchedExternally","idStr","creatOnComponentChangeEvent","creatOnComponentAddEvent","triggerOnComponentChange","triggerOnComponentAdd","OnComponentRemovedEvent","now","hook","OnComponentChangeEvent","OnComponentAddEvent","watcherData","m","isEqual","_legacy","compilerId","trackDir","findTrackDirByFilePathRecursively","pathNormalizeToLinux","getPathRelativeToConsumer","parentDir","dirname","chokidar","watch","ignoreInitial","ignored","path","includes","sep","persistent","useFsEvents","componentsFromBitMap","bitMap","getAllComponents","all","map","bitId","rootDir","getRootDir","Error","resolveComponentId","paths","pathsAbsolute","toAbsolutePath"],"sources":["watcher.ts"],"sourcesContent":["import { PubsubMain } from '@teambit/pubsub';\nimport { dirname, sep } from 'path';\nimport { difference } from 'lodash';\nimport { ComponentID } from '@teambit/component';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport loader from '@teambit/legacy/dist/cli/loader';\nimport { BIT_MAP } from '@teambit/legacy/dist/constants';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport logger from '@teambit/legacy/dist/logger/logger';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport mapSeries from 'p-map-series';\nimport chalk from 'chalk';\nimport { ChildProcess } from 'child_process';\nimport chokidar, { FSWatcher } from 'chokidar';\nimport ComponentMap from '@teambit/legacy/dist/consumer/bit-map/component-map';\nimport { PathLinux, PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';\nimport { CompilationInitiator } from '@teambit/compiler';\nimport { WorkspaceAspect } from '../';\nimport { OnComponentChangeEvent, OnComponentAddEvent, OnComponentRemovedEvent } from '../events';\nimport { Workspace } from '../workspace';\nimport { OnComponentEventResult } from '../on-component-events';\nimport { CheckTypes } from './check-types';\nimport { WatchQueue } from './watch-queue';\n\nexport type WatcherProcessData = { watchProcess: ChildProcess; compilerId: BitId; componentIds: BitId[] };\n\nexport type EventMessages = {\n onAll: Function;\n onStart: Function;\n onReady: Function;\n onChange: Function;\n onAdd: Function;\n onUnlink: Function;\n onError: Function;\n};\n\nexport type WatchOptions = {\n msgs?: EventMessages;\n initiator?: CompilationInitiator;\n verbose?: boolean; // print watch events to the console. (also ts-server events if spawnTSServer is true)\n spawnTSServer?: boolean; // needed for check types and extract API/docs.\n checkTypes?: CheckTypes; // if enabled, the spawnTSServer becomes true.\n preCompile?: boolean; // whether compile all components before start watching\n};\n\nconst DEBOUNCE_WAIT_MS = 100;\n\nexport class Watcher {\n private fsWatcher: FSWatcher;\n private changedFilesPerComponent: { [componentId: string]: string[] } = {};\n private watchQueue = new WatchQueue();\n private bitMapChangesInProgress = false;\n constructor(\n private workspace: Workspace,\n private pubsub: PubsubMain,\n private trackDirs: { [dir: PathLinux]: ComponentID } = {},\n private verbose = false,\n private multipleWatchers: WatcherProcessData[] = []\n ) {}\n\n get consumer(): Consumer {\n return this.workspace.consumer;\n }\n\n async watchAll(opts: WatchOptions) {\n const { msgs, ...watchOpts } = opts;\n // TODO: run build in the beginning of process (it's work like this in other envs)\n const pathsToWatch = await this.getPathsToWatch();\n const componentIds = Object.values(this.trackDirs);\n await this.workspace.triggerOnPreWatch(componentIds, watchOpts);\n await this.createWatcher(pathsToWatch);\n const watcher = this.fsWatcher;\n msgs?.onStart(this.workspace);\n\n return new Promise((resolve, reject) => {\n // prefix your command with \"BIT_LOG=*\" to see all watch events\n if (process.env.BIT_LOG) {\n // @ts-ignore\n if (msgs?.onAll) watcher.on('all', msgs?.onAll);\n }\n watcher.on('ready', () => {\n msgs?.onReady(this.workspace, this.trackDirs, this.verbose);\n });\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n watcher.on('change', async (filePath) => {\n const startTime = new Date().getTime();\n const { files, results, debounced, failureMsg } = await this.handleChange(filePath, opts?.initiator);\n if (debounced) {\n return;\n }\n const duration = new Date().getTime() - startTime;\n msgs?.onChange(files, results, this.verbose, duration, failureMsg);\n });\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n watcher.on('add', async (filePath) => {\n const startTime = new Date().getTime();\n const { files, results, debounced, failureMsg } = await this.handleChange(filePath, opts?.initiator);\n if (debounced) {\n return;\n }\n const duration = new Date().getTime() - startTime;\n msgs?.onAdd(files, results, this.verbose, duration, failureMsg);\n });\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n watcher.on('unlink', async (p) => {\n msgs?.onUnlink(p);\n await this.handleChange(p);\n });\n watcher.on('error', (err) => {\n msgs?.onError(err);\n reject(err);\n });\n });\n }\n\n /**\n * *** DEBOUNCING ***\n * some actions trigger multiple files changes at (almost) the same time. e.g. \"git pull\".\n * this causes some performance and instability issues. a debouncing mechanism was implemented to help with this.\n * the way how it works is that the first file of the same component starts the execution with a delay (e.g. 200ms).\n * if, in the meanwhile, another file of the same component was changed, it won't start a new execution, instead,\n * it'll only add the file to `this.changedFilesPerComponent` prop.\n * once the execution starts, it'll delete this component-id from the `this.changedFilesPerComponent` array,\n * indicating the next file-change to start a new execution.\n *\n * implementation wise, `lodash.debounce` doesn't help here, because:\n * A) it doesn't return the results, unless \"leading\" option is true. here, it must be false, otherwise, it'll start\n * the execution immediately.\n * B) it debounces the method regardless the param passes to it. so it'll disregard the component-id and will delay\n * other components undesirably.\n *\n * *** QUEUE ***\n * the debouncing helps to not execute the same component multiple times concurrently. however, multiple components\n * and .bitmap changes execution can still be processed concurrently.\n * the following example explains why this is an issue.\n * compA is changed in the .bitmap file from version 0.0.1 to 0.0.2. its files were changed as well.\n * all these changes get pulled at the same time by \"git pull\", as a result, the execution of compA and the .bitmap\n * happen at the same time.\n * during the execution of compA, the component id is parsed as compA@0.0.1, later, it asks for the Workspace for this\n * id. while the workspace is looking for this id, the .bitmap execution reloaded the consumer and changed all versions.\n * after this change, the workspace doesn't have this id anymore, which will trigger an error.\n * to ensure this won't happen, we keep a flag to indicate whether the .bitmap execution is running, and if so, all\n * other executions are paused until the queue is empty (this is done by awaiting for queue.onIdle).\n * once the queue is empty, we know the .bitmap process was done and the workspace has all new ids.\n * in the example above, at this stage, the id will be resolved to compA@0.0.2.\n * one more thing, the queue is configured to have concurrency of 1. to make sure two components are not processed at\n * the same time. (the same way is done when loading all components from the filesystem/scope).\n * this way we can also ensure that if compA was started before the .bitmap execution, it will complete before the\n * .bitmap execution starts.\n */\n private async handleChange(\n filePath: string,\n initiator?: CompilationInitiator\n ): Promise<{\n results: OnComponentEventResult[];\n files?: string[];\n failureMsg?: string;\n debounced?: boolean;\n }> {\n try {\n if (filePath.endsWith(BIT_MAP)) {\n this.bitMapChangesInProgress = true;\n const buildResults = await this.watchQueue.add(() => this.handleBitmapChanges());\n this.bitMapChangesInProgress = false;\n loader.stop();\n return { results: buildResults, files: [filePath] };\n }\n if (this.bitMapChangesInProgress) {\n await this.watchQueue.onIdle();\n }\n const componentId = this.getComponentIdByPath(filePath);\n if (!componentId) {\n const failureMsg = `file ${filePath} is not part of any component, ignoring it`;\n logger.debug(failureMsg);\n loader.stop();\n return { results: [], files: [filePath], failureMsg };\n }\n const compIdStr = componentId.toString();\n if (this.changedFilesPerComponent[compIdStr]) {\n this.changedFilesPerComponent[compIdStr].push(filePath);\n loader.stop();\n return { results: [], debounced: true };\n }\n this.changedFilesPerComponent[compIdStr] = [filePath];\n await this.sleep(DEBOUNCE_WAIT_MS);\n const files = this.changedFilesPerComponent[compIdStr];\n delete this.changedFilesPerComponent[compIdStr];\n\n const buildResults = await this.watchQueue.add(() => this.triggerCompChanges(componentId, files, initiator));\n const failureMsg = buildResults.length\n ? undefined\n : `files ${files.join(', ')} are inside the component ${compIdStr} but configured to be ignored`;\n loader.stop();\n return { results: buildResults, files, failureMsg };\n } catch (err: any) {\n const msg = `watcher found an error while handling ${filePath}`;\n logger.error(msg, err);\n logger.console(`${msg}, ${err.message}`);\n loader.stop();\n return { results: [], files: [filePath], failureMsg: err.message };\n }\n }\n\n private async sleep(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n /**\n * if a file was added/remove, once the component is loaded, it changes .bitmap, and then the\n * entire cache is invalidated and the consumer is reloaded.\n * when a file just changed, no need to reload the consumer, it is enough to just delete the\n * component from the cache (both, workspace and consumer)\n */\n private async triggerCompChanges(\n componentId: ComponentID,\n files: string[],\n initiator?: CompilationInitiator\n ): Promise<OnComponentEventResult[]> {\n this.workspace.clearComponentCache(componentId);\n const component = await this.workspace.get(componentId);\n const componentMap: ComponentMap = component.state._consumer.componentMap;\n const compFiles = files.filter((filePath) => {\n const relativeFile = this.getRelativePathLinux(filePath);\n const isCompFile = Boolean(componentMap.getFilesRelativeToConsumer().find((p) => p === relativeFile));\n if (!isCompFile) {\n logger.debug(`file ${filePath} is inside the component ${componentId.toString()} but configured to be ignored`);\n }\n return isCompFile;\n });\n if (!compFiles.length) {\n return [];\n }\n const buildResults = await this.executeWatchOperationsOnComponent(componentId, compFiles, true, initiator);\n return buildResults;\n }\n\n /**\n * if .bitmap changed, it's possible that a new component has been added. trigger onComponentAdd.\n */\n private async handleBitmapChanges(): Promise<OnComponentEventResult[]> {\n const previewsTrackDirs = { ...this.trackDirs };\n await this.workspace._reloadConsumer();\n await this.setTrackDirs();\n const newDirs: string[] = difference(Object.keys(this.trackDirs), Object.keys(previewsTrackDirs));\n const removedDirs: string[] = difference(Object.keys(previewsTrackDirs), Object.keys(this.trackDirs));\n const results: OnComponentEventResult[] = [];\n if (newDirs.length) {\n this.fsWatcher.add(newDirs);\n const addResults = await mapSeries(newDirs, async (dir) =>\n this.executeWatchOperationsOnComponent(this.trackDirs[dir], [], false)\n );\n results.push(...addResults.flat());\n }\n if (removedDirs.length) {\n await this.fsWatcher.unwatch(removedDirs);\n await mapSeries(removedDirs, (dir) => this.executeWatchOperationsOnRemove(previewsTrackDirs[dir]));\n }\n return results;\n }\n\n private async executeWatchOperationsOnRemove(componentId: ComponentID) {\n logger.debug(`running OnComponentRemove hook for ${chalk.bold(componentId.toString())}`);\n this.pubsub.pub(WorkspaceAspect.id, this.creatOnComponentRemovedEvent(componentId.toString()));\n await this.workspace.triggerOnComponentRemove(componentId);\n }\n\n private async executeWatchOperationsOnComponent(\n componentId: ComponentID,\n files: string[],\n isChange = true,\n initiator?: CompilationInitiator\n ): Promise<OnComponentEventResult[]> {\n if (this.isComponentWatchedExternally(componentId)) {\n // update capsule, once done, it automatically triggers the external watcher\n await this.workspace.get(componentId);\n return [];\n }\n const idStr = componentId.toString();\n\n if (isChange) {\n logger.debug(`running OnComponentChange hook for ${chalk.bold(idStr)}`);\n this.pubsub.pub(WorkspaceAspect.id, this.creatOnComponentChangeEvent(idStr, 'OnComponentChange'));\n } else {\n logger.debug(`running OnComponentAdd hook for ${chalk.bold(idStr)}`);\n this.pubsub.pub(WorkspaceAspect.id, this.creatOnComponentAddEvent(idStr, 'OnComponentAdd'));\n }\n\n let buildResults: OnComponentEventResult[];\n try {\n buildResults = isChange\n ? await this.workspace.triggerOnComponentChange(componentId, files, initiator)\n : await this.workspace.triggerOnComponentAdd(componentId);\n } catch (err: any) {\n // do not exit the watch process on errors, just print them\n const msg = `found an issue during onComponentChange or onComponentAdd hooks`;\n logger.error(msg, err);\n logger.console(`\\n${msg}: ${err.message || err}`);\n return [];\n }\n return buildResults;\n }\n\n private creatOnComponentRemovedEvent(idStr) {\n return new OnComponentRemovedEvent(Date.now(), idStr);\n }\n\n private creatOnComponentChangeEvent(idStr, hook) {\n return new OnComponentChangeEvent(Date.now(), idStr, hook);\n }\n\n private creatOnComponentAddEvent(idStr, hook) {\n return new OnComponentAddEvent(Date.now(), idStr, hook);\n }\n\n private isComponentWatchedExternally(componentId: ComponentID) {\n const watcherData = this.multipleWatchers.find((m) => m.componentIds.find((id) => id.isEqual(componentId._legacy)));\n if (watcherData) {\n logger.debug(`${componentId.toString()} is watched by ${watcherData.compilerId.toString()}`);\n return true;\n }\n return false;\n }\n\n private getComponentIdByPath(filePath: string): ComponentID | null {\n const relativeFile = this.getRelativePathLinux(filePath);\n const trackDir = this.findTrackDirByFilePathRecursively(relativeFile);\n if (!trackDir) {\n // the file is not part of any component. If it was a new component, or a new file of\n // existing component, then, handleBitmapChanges() should deal with it.\n return null;\n }\n return this.trackDirs[trackDir];\n }\n\n private getRelativePathLinux(filePath: string) {\n return pathNormalizeToLinux(this.consumer.getPathRelativeToConsumer(filePath));\n }\n\n private findTrackDirByFilePathRecursively(filePath: string): string | null {\n if (this.trackDirs[filePath]) return filePath;\n const parentDir = dirname(filePath);\n if (parentDir === filePath) return null;\n return this.findTrackDirByFilePathRecursively(parentDir);\n }\n\n private async createWatcher(pathsToWatch: string[]) {\n this.fsWatcher = chokidar.watch(pathsToWatch, {\n ignoreInitial: true,\n // Using the function way since the regular way not working as expected\n // It might be solved when upgrading to chokidar > 3.0.0\n // See:\n // https://github.com/paulmillr/chokidar/issues/773\n // https://github.com/paulmillr/chokidar/issues/492\n // https://github.com/paulmillr/chokidar/issues/724\n ignored: (path) => {\n // Ignore package.json temporarily since it cerates endless loop since it's re-written after each build\n if (path.includes(`${sep}node_modules${sep}`) || path.includes(`${sep}package.json`)) {\n return true;\n }\n return false;\n },\n persistent: true,\n useFsEvents: false,\n });\n }\n\n async setTrackDirs() {\n this.trackDirs = {};\n const componentsFromBitMap = this.consumer.bitMap.getAllComponents();\n await Promise.all(\n componentsFromBitMap.map(async (componentMap) => {\n const bitId = componentMap.id;\n const rootDir = componentMap.getRootDir();\n if (!rootDir) throw new Error(`${bitId.toString()} has no rootDir, which is invalid in Harmony`);\n const componentId = await this.workspace.resolveComponentId(bitId);\n this.trackDirs[rootDir] = componentId;\n })\n );\n }\n\n private async getPathsToWatch(): Promise<PathOsBasedAbsolute[]> {\n await this.setTrackDirs();\n const paths = [...Object.keys(this.trackDirs), BIT_MAP];\n const pathsAbsolute = paths.map((dir) => this.consumer.toAbsolutePath(dir));\n return pathsAbsolute;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA2C;AAAA;AAuB3C,MAAMA,gBAAgB,GAAG,GAAG;AAErB,MAAMC,OAAO,CAAC;EAKnBC,WAAW,CACDC,SAAoB,EACpBC,MAAkB,EAClBC,SAA4C,GAAG,CAAC,CAAC,EACjDC,OAAO,GAAG,KAAK,EACfC,gBAAsC,GAAG,EAAE,EACnD;IAAA,KALQJ,SAAoB,GAApBA,SAAoB;IAAA,KACpBC,MAAkB,GAAlBA,MAAkB;IAAA,KAClBC,SAA4C,GAA5CA,SAA4C;IAAA,KAC5CC,OAAO,GAAPA,OAAO;IAAA,KACPC,gBAAsC,GAAtCA,gBAAsC;IAAA;IAAA,kEARwB,CAAC,CAAC;IAAA,oDACrD,KAAIC,wBAAU,GAAE;IAAA,iEACH,KA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CAAC;IACnB,MAAM6I,oBAAoB,GAAG,IAAI,CAACzI,QAAQ,CAAC0I,MAAM,CAACC,gBAAgB,EAAE;IACpE,MAAM5H,OAAO,CAAC6H,GAAG,CACfH,oBAAoB,CAACI,GAAG,CAAC,MAAOpE,YAAY,IAAK;MAC/C,MAAMqE,KAAK,GAAGrE,YAAY,CAAC6B,EAAE;MAC7B,MAAMyC,OAAO,GAAGtE,YAAY,CAACuE,UAAU,EAAE;MACzC,IAAI,CAACD,OAAO,EAAE,MAAM,IAAIE,KAAK,CAAE,GAAEH,KAAK,CAACtF,QAAQ,EAAG,8CAA6C,CAAC;MAChG,MAAML,WAAW,GAAG,MAAM,IAAI,CAACzD,SAAS,CAACwJ,kBAAkB,CAACJ,KAAK,CAAC;MAClE,IAAI,CAAClJ,SAAS,CAACmJ,OAAO,CAAC,GAAG5F,WAAW;IACvC,CAAC,CAAC,CACH;EACH;EAEA,MAAc7C,eAAe,GAAmC;IAC9D,MAAM,IAAI,CAACiF,YAAY,EAAE;IACzB,MAAM4D,KAAK,GAAG,CAAC,GAAG3I,MAAM,CAACkF,IAAI,CAAC,IAAI,CAAC9F,SAAS,CAAC,EAAE8C,oBAAO,CAAC;IACvD,MAAM0G,aAAa,GAAGD,KAAK,CAACN,GAAG,CAAE/C,GAAG,IAAK,IAAI,CAAC9F,QAAQ,CAACqJ,cAAc,CAACvD,GAAG,CAAC,CAAC;IAC3E,OAAOsD,aAAa;EACtB;AACF;AAAC"}
|
|
1
|
+
{"version":3,"names":["DEBOUNCE_WAIT_MS","Watcher","constructor","workspace","pubsub","trackDirs","verbose","multipleWatchers","WatchQueue","consumer","watchAll","opts","msgs","watchOpts","pathsToWatch","getPathsToWatch","componentIds","Object","values","triggerOnPreWatch","createWatcher","watcher","fsWatcher","onStart","Promise","resolve","reject","process","env","BIT_LOG","onAll","on","onReady","filePath","startTime","Date","getTime","files","results","debounced","failureMsg","handleChange","initiator","duration","onChange","onAdd","p","onUnlink","err","onError","endsWith","BIT_MAP","bitMapChangesInProgress","buildResults","watchQueue","add","handleBitmapChanges","loader","stop","onIdle","componentId","getComponentIdByPath","logger","debug","compIdStr","toString","changedFilesPerComponent","push","sleep","triggerCompChanges","length","undefined","join","msg","error","console","message","ms","setTimeout","clearComponentCache","component","get","componentMap","state","_consumer","compFiles","filter","relativeFile","getRelativePathLinux","isCompFile","Boolean","getFilesRelativeToConsumer","find","executeWatchOperationsOnComponent","previewsTrackDirs","_reloadConsumer","setTrackDirs","newDirs","difference","keys","removedDirs","addResults","mapSeries","dir","flat","triggerOnMultipleComponentsAdd","unwatch","executeWatchOperationsOnRemove","chalk","bold","pub","WorkspaceAspect","id","creatOnComponentRemovedEvent","triggerOnComponentRemove","isChange","isComponentWatchedExternally","idStr","creatOnComponentChangeEvent","creatOnComponentAddEvent","triggerOnComponentChange","triggerOnComponentAdd","OnComponentRemovedEvent","now","hook","OnComponentChangeEvent","OnComponentAddEvent","watcherData","m","isEqual","_legacy","compilerId","trackDir","findTrackDirByFilePathRecursively","pathNormalizeToLinux","getPathRelativeToConsumer","parentDir","dirname","chokidar","watch","ignoreInitial","ignored","path","includes","sep","persistent","useFsEvents","componentsFromBitMap","bitMap","getAllComponents","all","map","bitId","rootDir","getRootDir","Error","resolveComponentId","paths","pathsAbsolute","toAbsolutePath"],"sources":["watcher.ts"],"sourcesContent":["import { PubsubMain } from '@teambit/pubsub';\nimport { dirname, sep } from 'path';\nimport { difference } from 'lodash';\nimport { ComponentID } from '@teambit/component';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport loader from '@teambit/legacy/dist/cli/loader';\nimport { BIT_MAP } from '@teambit/legacy/dist/constants';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport logger from '@teambit/legacy/dist/logger/logger';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport mapSeries from 'p-map-series';\nimport chalk from 'chalk';\nimport { ChildProcess } from 'child_process';\nimport chokidar, { FSWatcher } from 'chokidar';\nimport ComponentMap from '@teambit/legacy/dist/consumer/bit-map/component-map';\nimport { PathLinux, PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';\nimport { CompilationInitiator } from '@teambit/compiler';\nimport { WorkspaceAspect } from '../';\nimport { OnComponentChangeEvent, OnComponentAddEvent, OnComponentRemovedEvent } from '../events';\nimport { Workspace } from '../workspace';\nimport { OnComponentEventResult } from '../on-component-events';\nimport { CheckTypes } from './check-types';\nimport { WatchQueue } from './watch-queue';\n\nexport type WatcherProcessData = { watchProcess: ChildProcess; compilerId: BitId; componentIds: BitId[] };\n\nexport type EventMessages = {\n onAll: Function;\n onStart: Function;\n onReady: Function;\n onChange: Function;\n onAdd: Function;\n onUnlink: Function;\n onError: Function;\n};\n\nexport type WatchOptions = {\n msgs?: EventMessages;\n initiator?: CompilationInitiator;\n verbose?: boolean; // print watch events to the console. (also ts-server events if spawnTSServer is true)\n spawnTSServer?: boolean; // needed for check types and extract API/docs.\n checkTypes?: CheckTypes; // if enabled, the spawnTSServer becomes true.\n preCompile?: boolean; // whether compile all components before start watching\n};\n\nconst DEBOUNCE_WAIT_MS = 100;\n\nexport class Watcher {\n private fsWatcher: FSWatcher;\n private changedFilesPerComponent: { [componentId: string]: string[] } = {};\n private watchQueue = new WatchQueue();\n private bitMapChangesInProgress = false;\n constructor(\n private workspace: Workspace,\n private pubsub: PubsubMain,\n private trackDirs: { [dir: PathLinux]: ComponentID } = {},\n private verbose = false,\n private multipleWatchers: WatcherProcessData[] = []\n ) {}\n\n get consumer(): Consumer {\n return this.workspace.consumer;\n }\n\n async watchAll(opts: WatchOptions) {\n const { msgs, ...watchOpts } = opts;\n // TODO: run build in the beginning of process (it's work like this in other envs)\n const pathsToWatch = await this.getPathsToWatch();\n const componentIds = Object.values(this.trackDirs);\n await this.workspace.triggerOnPreWatch(componentIds, watchOpts);\n await this.createWatcher(pathsToWatch);\n const watcher = this.fsWatcher;\n msgs?.onStart(this.workspace);\n\n return new Promise((resolve, reject) => {\n // prefix your command with \"BIT_LOG=*\" to see all watch events\n if (process.env.BIT_LOG) {\n // @ts-ignore\n if (msgs?.onAll) watcher.on('all', msgs?.onAll);\n }\n watcher.on('ready', () => {\n msgs?.onReady(this.workspace, this.trackDirs, this.verbose);\n });\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n watcher.on('change', async (filePath) => {\n const startTime = new Date().getTime();\n const { files, results, debounced, failureMsg } = await this.handleChange(filePath, opts?.initiator);\n if (debounced) {\n return;\n }\n const duration = new Date().getTime() - startTime;\n msgs?.onChange(files, results, this.verbose, duration, failureMsg);\n });\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n watcher.on('add', async (filePath) => {\n const startTime = new Date().getTime();\n const { files, results, debounced, failureMsg } = await this.handleChange(filePath, opts?.initiator);\n if (debounced) {\n return;\n }\n const duration = new Date().getTime() - startTime;\n msgs?.onAdd(files, results, this.verbose, duration, failureMsg);\n });\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n watcher.on('unlink', async (p) => {\n msgs?.onUnlink(p);\n await this.handleChange(p);\n });\n watcher.on('error', (err) => {\n msgs?.onError(err);\n reject(err);\n });\n });\n }\n\n /**\n * *** DEBOUNCING ***\n * some actions trigger multiple files changes at (almost) the same time. e.g. \"git pull\".\n * this causes some performance and instability issues. a debouncing mechanism was implemented to help with this.\n * the way how it works is that the first file of the same component starts the execution with a delay (e.g. 200ms).\n * if, in the meanwhile, another file of the same component was changed, it won't start a new execution, instead,\n * it'll only add the file to `this.changedFilesPerComponent` prop.\n * once the execution starts, it'll delete this component-id from the `this.changedFilesPerComponent` array,\n * indicating the next file-change to start a new execution.\n *\n * implementation wise, `lodash.debounce` doesn't help here, because:\n * A) it doesn't return the results, unless \"leading\" option is true. here, it must be false, otherwise, it'll start\n * the execution immediately.\n * B) it debounces the method regardless the param passes to it. so it'll disregard the component-id and will delay\n * other components undesirably.\n *\n * *** QUEUE ***\n * the debouncing helps to not execute the same component multiple times concurrently. however, multiple components\n * and .bitmap changes execution can still be processed concurrently.\n * the following example explains why this is an issue.\n * compA is changed in the .bitmap file from version 0.0.1 to 0.0.2. its files were changed as well.\n * all these changes get pulled at the same time by \"git pull\", as a result, the execution of compA and the .bitmap\n * happen at the same time.\n * during the execution of compA, the component id is parsed as compA@0.0.1, later, it asks for the Workspace for this\n * id. while the workspace is looking for this id, the .bitmap execution reloaded the consumer and changed all versions.\n * after this change, the workspace doesn't have this id anymore, which will trigger an error.\n * to ensure this won't happen, we keep a flag to indicate whether the .bitmap execution is running, and if so, all\n * other executions are paused until the queue is empty (this is done by awaiting for queue.onIdle).\n * once the queue is empty, we know the .bitmap process was done and the workspace has all new ids.\n * in the example above, at this stage, the id will be resolved to compA@0.0.2.\n * one more thing, the queue is configured to have concurrency of 1. to make sure two components are not processed at\n * the same time. (the same way is done when loading all components from the filesystem/scope).\n * this way we can also ensure that if compA was started before the .bitmap execution, it will complete before the\n * .bitmap execution starts.\n */\n private async handleChange(\n filePath: string,\n initiator?: CompilationInitiator\n ): Promise<{\n results: OnComponentEventResult[];\n files?: string[];\n failureMsg?: string;\n debounced?: boolean;\n }> {\n try {\n if (filePath.endsWith(BIT_MAP)) {\n this.bitMapChangesInProgress = true;\n const buildResults = await this.watchQueue.add(() => this.handleBitmapChanges());\n this.bitMapChangesInProgress = false;\n loader.stop();\n return { results: buildResults, files: [filePath] };\n }\n if (this.bitMapChangesInProgress) {\n await this.watchQueue.onIdle();\n }\n const componentId = this.getComponentIdByPath(filePath);\n if (!componentId) {\n const failureMsg = `file ${filePath} is not part of any component, ignoring it`;\n logger.debug(failureMsg);\n loader.stop();\n return { results: [], files: [filePath], failureMsg };\n }\n const compIdStr = componentId.toString();\n if (this.changedFilesPerComponent[compIdStr]) {\n this.changedFilesPerComponent[compIdStr].push(filePath);\n loader.stop();\n return { results: [], debounced: true };\n }\n this.changedFilesPerComponent[compIdStr] = [filePath];\n await this.sleep(DEBOUNCE_WAIT_MS);\n const files = this.changedFilesPerComponent[compIdStr];\n delete this.changedFilesPerComponent[compIdStr];\n\n const buildResults = await this.watchQueue.add(() => this.triggerCompChanges(componentId, files, initiator));\n const failureMsg = buildResults.length\n ? undefined\n : `files ${files.join(', ')} are inside the component ${compIdStr} but configured to be ignored`;\n loader.stop();\n return { results: buildResults, files, failureMsg };\n } catch (err: any) {\n const msg = `watcher found an error while handling ${filePath}`;\n logger.error(msg, err);\n logger.console(`${msg}, ${err.message}`);\n loader.stop();\n return { results: [], files: [filePath], failureMsg: err.message };\n }\n }\n\n private async sleep(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n /**\n * if a file was added/remove, once the component is loaded, it changes .bitmap, and then the\n * entire cache is invalidated and the consumer is reloaded.\n * when a file just changed, no need to reload the consumer, it is enough to just delete the\n * component from the cache (both, workspace and consumer)\n */\n private async triggerCompChanges(\n componentId: ComponentID,\n files: string[],\n initiator?: CompilationInitiator\n ): Promise<OnComponentEventResult[]> {\n this.workspace.clearComponentCache(componentId);\n const component = await this.workspace.get(componentId);\n const componentMap: ComponentMap = component.state._consumer.componentMap;\n const compFiles = files.filter((filePath) => {\n const relativeFile = this.getRelativePathLinux(filePath);\n const isCompFile = Boolean(componentMap.getFilesRelativeToConsumer().find((p) => p === relativeFile));\n if (!isCompFile) {\n logger.debug(`file ${filePath} is inside the component ${componentId.toString()} but configured to be ignored`);\n }\n return isCompFile;\n });\n if (!compFiles.length) {\n return [];\n }\n const buildResults = await this.executeWatchOperationsOnComponent(componentId, compFiles, true, initiator);\n return buildResults;\n }\n\n /**\n * if .bitmap changed, it's possible that a new component has been added. trigger onComponentAdd.\n */\n private async handleBitmapChanges(): Promise<OnComponentEventResult[]> {\n const previewsTrackDirs = { ...this.trackDirs };\n await this.workspace._reloadConsumer();\n await this.setTrackDirs();\n const newDirs: string[] = difference(Object.keys(this.trackDirs), Object.keys(previewsTrackDirs));\n const removedDirs: string[] = difference(Object.keys(previewsTrackDirs), Object.keys(this.trackDirs));\n const results: OnComponentEventResult[] = [];\n if (newDirs.length) {\n this.fsWatcher.add(newDirs);\n const addResults = await mapSeries(newDirs, async (dir) =>\n this.executeWatchOperationsOnComponent(this.trackDirs[dir], [], false)\n );\n results.push(...addResults.flat());\n await this.workspace.triggerOnMultipleComponentsAdd();\n }\n if (removedDirs.length) {\n await this.fsWatcher.unwatch(removedDirs);\n await mapSeries(removedDirs, (dir) => this.executeWatchOperationsOnRemove(previewsTrackDirs[dir]));\n }\n return results;\n }\n\n private async executeWatchOperationsOnRemove(componentId: ComponentID) {\n logger.debug(`running OnComponentRemove hook for ${chalk.bold(componentId.toString())}`);\n this.pubsub.pub(WorkspaceAspect.id, this.creatOnComponentRemovedEvent(componentId.toString()));\n await this.workspace.triggerOnComponentRemove(componentId);\n }\n\n private async executeWatchOperationsOnComponent(\n componentId: ComponentID,\n files: string[],\n isChange = true,\n initiator?: CompilationInitiator\n ): Promise<OnComponentEventResult[]> {\n if (this.isComponentWatchedExternally(componentId)) {\n // update capsule, once done, it automatically triggers the external watcher\n await this.workspace.get(componentId);\n return [];\n }\n const idStr = componentId.toString();\n\n if (isChange) {\n logger.debug(`running OnComponentChange hook for ${chalk.bold(idStr)}`);\n this.pubsub.pub(WorkspaceAspect.id, this.creatOnComponentChangeEvent(idStr, 'OnComponentChange'));\n } else {\n logger.debug(`running OnComponentAdd hook for ${chalk.bold(idStr)}`);\n this.pubsub.pub(WorkspaceAspect.id, this.creatOnComponentAddEvent(idStr, 'OnComponentAdd'));\n }\n\n let buildResults: OnComponentEventResult[];\n try {\n buildResults = isChange\n ? await this.workspace.triggerOnComponentChange(componentId, files, initiator)\n : await this.workspace.triggerOnComponentAdd(componentId);\n } catch (err: any) {\n // do not exit the watch process on errors, just print them\n const msg = `found an issue during onComponentChange or onComponentAdd hooks`;\n logger.error(msg, err);\n logger.console(`\\n${msg}: ${err.message || err}`);\n return [];\n }\n return buildResults;\n }\n\n private creatOnComponentRemovedEvent(idStr) {\n return new OnComponentRemovedEvent(Date.now(), idStr);\n }\n\n private creatOnComponentChangeEvent(idStr, hook) {\n return new OnComponentChangeEvent(Date.now(), idStr, hook);\n }\n\n private creatOnComponentAddEvent(idStr, hook) {\n return new OnComponentAddEvent(Date.now(), idStr, hook);\n }\n\n private isComponentWatchedExternally(componentId: ComponentID) {\n const watcherData = this.multipleWatchers.find((m) => m.componentIds.find((id) => id.isEqual(componentId._legacy)));\n if (watcherData) {\n logger.debug(`${componentId.toString()} is watched by ${watcherData.compilerId.toString()}`);\n return true;\n }\n return false;\n }\n\n private getComponentIdByPath(filePath: string): ComponentID | null {\n const relativeFile = this.getRelativePathLinux(filePath);\n const trackDir = this.findTrackDirByFilePathRecursively(relativeFile);\n if (!trackDir) {\n // the file is not part of any component. If it was a new component, or a new file of\n // existing component, then, handleBitmapChanges() should deal with it.\n return null;\n }\n return this.trackDirs[trackDir];\n }\n\n private getRelativePathLinux(filePath: string) {\n return pathNormalizeToLinux(this.consumer.getPathRelativeToConsumer(filePath));\n }\n\n private findTrackDirByFilePathRecursively(filePath: string): string | null {\n if (this.trackDirs[filePath]) return filePath;\n const parentDir = dirname(filePath);\n if (parentDir === filePath) return null;\n return this.findTrackDirByFilePathRecursively(parentDir);\n }\n\n private async createWatcher(pathsToWatch: string[]) {\n this.fsWatcher = chokidar.watch(pathsToWatch, {\n ignoreInitial: true,\n // Using the function way since the regular way not working as expected\n // It might be solved when upgrading to chokidar > 3.0.0\n // See:\n // https://github.com/paulmillr/chokidar/issues/773\n // https://github.com/paulmillr/chokidar/issues/492\n // https://github.com/paulmillr/chokidar/issues/724\n ignored: (path) => {\n // Ignore package.json temporarily since it cerates endless loop since it's re-written after each build\n if (path.includes(`${sep}node_modules${sep}`) || path.includes(`${sep}package.json`)) {\n return true;\n }\n return false;\n },\n persistent: true,\n useFsEvents: false,\n });\n }\n\n async setTrackDirs() {\n this.trackDirs = {};\n const componentsFromBitMap = this.consumer.bitMap.getAllComponents();\n await Promise.all(\n componentsFromBitMap.map(async (componentMap) => {\n const bitId = componentMap.id;\n const rootDir = componentMap.getRootDir();\n if (!rootDir) throw new Error(`${bitId.toString()} has no rootDir, which is invalid in Harmony`);\n const componentId = await this.workspace.resolveComponentId(bitId);\n this.trackDirs[rootDir] = componentId;\n })\n );\n }\n\n private async getPathsToWatch(): Promise<PathOsBasedAbsolute[]> {\n await this.setTrackDirs();\n const paths = [...Object.keys(this.trackDirs), BIT_MAP];\n const pathsAbsolute = paths.map((dir) => this.consumer.toAbsolutePath(dir));\n return pathsAbsolute;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA2C;AAAA;AAuB3C,MAAMA,gBAAgB,GAAG,GAAG;AAErB,MAAMC,OAAO,CAAC;EAKnBC,WAAW,CACDC,SAAoB,EACpBC,MAAkB,EAClBC,SAA4C,GAAG,CAAC,CAAC,EACjDC,OAAO,GAAG,KAAK,EACfC,gBAAsC,GAAG,EAAE,EACnD;IAAA,KALQJ,SAAoB,GAApBA,SAAoB;IAAA,KACpBC,MAAkB,GAAlBA,MAAkB;IAAA,KAClBC,SAA4C,GAA5CA,SAA4C;IAAA,KAC5CC,OAAO,GAAPA,OAAO;IAAA,KACPC,gBAAsC,GAAtCA,gBAAsC;IAAA;IAAA,kEARwB,CAAC,CAAC;IAAA,oDACrD,KAAI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,CAAC,CAAC;EACJ;EAEA,MAAMlD,YAAY,GAAG;IACnB,IAAI,CAAC3F,SAAS,GAAG,CAAC,CAAC;IACnB,MAAM8I,oBAAoB,GAAG,IAAI,CAAC1I,QAAQ,CAAC2I,MAAM,CAACC,gBAAgB,EAAE;IACpE,MAAM7H,OAAO,CAAC8H,GAAG,CACfH,oBAAoB,CAACI,GAAG,CAAC,MAAOrE,YAAY,IAAK;MAC/C,MAAMsE,KAAK,GAAGtE,YAAY,CAAC8B,EAAE;MAC7B,MAAMyC,OAAO,GAAGvE,YAAY,CAACwE,UAAU,EAAE;MACzC,IAAI,CAACD,OAAO,EAAE,MAAM,IAAIE,KAAK,CAAE,GAAEH,KAAK,CAACvF,QAAQ,EAAG,8CAA6C,CAAC;MAChG,MAAML,WAAW,GAAG,MAAM,IAAI,CAACzD,SAAS,CAACyJ,kBAAkB,CAACJ,KAAK,CAAC;MAClE,IAAI,CAACnJ,SAAS,CAACoJ,OAAO,CAAC,GAAG7F,WAAW;IACvC,CAAC,CAAC,CACH;EACH;EAEA,MAAc7C,eAAe,GAAmC;IAC9D,MAAM,IAAI,CAACiF,YAAY,EAAE;IACzB,MAAM6D,KAAK,GAAG,CAAC,GAAG5I,MAAM,CAACkF,IAAI,CAAC,IAAI,CAAC9F,SAAS,CAAC,EAAE8C,oBAAO,CAAC;IACvD,MAAM2G,aAAa,GAAGD,KAAK,CAACN,GAAG,CAAEhD,GAAG,IAAK,IAAI,CAAC9F,QAAQ,CAACsJ,cAAc,CAACxD,GAAG,CAAC,CAAC;IAC3E,OAAOuD,aAAa;EACtB;AACF;AAAC"}
|
package/dist/workspace.d.ts
CHANGED
|
@@ -26,11 +26,11 @@ import { CompilationInitiator } from '@teambit/compiler';
|
|
|
26
26
|
import { Lane } from '@teambit/legacy/dist/scope/models';
|
|
27
27
|
import { ComponentLoadOptions } from '@teambit/legacy/dist/consumer/component/component-loader';
|
|
28
28
|
import { ComponentConfigFile } from './component-config-file';
|
|
29
|
-
import { OnComponentAdd, OnComponentChange, OnComponentEventResult, OnComponentLoad, OnComponentRemove } from './on-component-events';
|
|
29
|
+
import { OnComponentAdd, OnComponentChange, OnComponentEventResult, OnComponentLoad, OnComponentRemove, OnMultipleComponentsAdd } from './on-component-events';
|
|
30
30
|
import { WorkspaceExtConfig } from './types';
|
|
31
31
|
import { Watcher, WatchOptions } from './watch/watcher';
|
|
32
32
|
import { ComponentStatus } from './workspace-component/component-status';
|
|
33
|
-
import { OnComponentAddSlot, OnComponentChangeSlot, OnComponentLoadSlot, OnComponentRemoveSlot, OnPreWatch, OnPreWatchSlot } from './workspace.provider';
|
|
33
|
+
import { OnComponentAddSlot, OnComponentChangeSlot, OnComponentLoadSlot, OnComponentRemoveSlot, OnMultipleComponentsAddSlot, OnPreWatch, OnPreWatchSlot } from './workspace.provider';
|
|
34
34
|
import { WorkspaceComponentLoader } from './workspace-component/workspace-component-loader';
|
|
35
35
|
import { ShouldLoadFunc } from './build-graph-from-fs';
|
|
36
36
|
import { BitMap } from './bit-map';
|
|
@@ -104,6 +104,7 @@ export declare class Workspace implements ComponentFactory {
|
|
|
104
104
|
*/
|
|
105
105
|
private onComponentAddSlot;
|
|
106
106
|
private onComponentRemoveSlot;
|
|
107
|
+
private onMultipleComponentsAddSlot;
|
|
107
108
|
private onPreWatchSlot;
|
|
108
109
|
private graphql;
|
|
109
110
|
priority: boolean;
|
|
@@ -146,7 +147,7 @@ export declare class Workspace implements ComponentFactory {
|
|
|
146
147
|
/**
|
|
147
148
|
* on component add slot.
|
|
148
149
|
*/
|
|
149
|
-
onComponentAddSlot: OnComponentAddSlot, onComponentRemoveSlot: OnComponentRemoveSlot, onPreWatchSlot: OnPreWatchSlot, graphql: GraphqlMain);
|
|
150
|
+
onComponentAddSlot: OnComponentAddSlot, onComponentRemoveSlot: OnComponentRemoveSlot, onMultipleComponentsAddSlot: OnMultipleComponentsAddSlot, onPreWatchSlot: OnPreWatchSlot, graphql: GraphqlMain);
|
|
150
151
|
private validateConfig;
|
|
151
152
|
/**
|
|
152
153
|
* watcher api.
|
|
@@ -162,6 +163,7 @@ export declare class Workspace implements ComponentFactory {
|
|
|
162
163
|
onComponentLoad(loadFn: OnComponentLoad): this;
|
|
163
164
|
registerOnComponentChange(onComponentChangeFunc: OnComponentChange): this;
|
|
164
165
|
registerOnComponentAdd(onComponentAddFunc: OnComponentAdd): this;
|
|
166
|
+
registerOnMultipleComponentsAdd(onMultipleComponentsAddFunc: OnMultipleComponentsAdd): this;
|
|
165
167
|
registerOnComponentRemove(onComponentRemoveFunc: OnComponentRemove): this;
|
|
166
168
|
registerOnPreWatch(onPreWatchFunc: OnPreWatch): this;
|
|
167
169
|
/**
|
|
@@ -243,6 +245,7 @@ export declare class Workspace implements ComponentFactory {
|
|
|
243
245
|
triggerOnComponentChange(id: ComponentID, files: string[], initiator?: CompilationInitiator): Promise<OnComponentEventResult[]>;
|
|
244
246
|
triggerOnComponentAdd(id: ComponentID): Promise<OnComponentEventResult[]>;
|
|
245
247
|
triggerOnComponentRemove(id: ComponentID): Promise<OnComponentEventResult[]>;
|
|
248
|
+
triggerOnMultipleComponentsAdd(): Promise<void>;
|
|
246
249
|
getState(id: ComponentID, hash: string): Promise<import("@teambit/component").State>;
|
|
247
250
|
getSnap(id: ComponentID, hash: string): Promise<import("@teambit/component").Snap>;
|
|
248
251
|
getCurrentLaneId(): LaneId;
|
|
@@ -254,6 +257,7 @@ export declare class Workspace implements ComponentFactory {
|
|
|
254
257
|
getDefaultExtensions(): ExtensionDataList;
|
|
255
258
|
ejectMultipleConfigs(ids: ComponentID[], options: EjectConfOptions): Promise<EjectConfResult[]>;
|
|
256
259
|
ejectConfig(id: ComponentID, options: EjectConfOptions): Promise<EjectConfResult>;
|
|
260
|
+
private getSpecificExtensionsFromScope;
|
|
257
261
|
/**
|
|
258
262
|
* see component-aspect, createAspectListFromLegacy() method for a context why this is needed.
|
|
259
263
|
*/
|
|
@@ -376,7 +380,12 @@ export declare class Workspace implements ComponentFactory {
|
|
|
376
380
|
*/
|
|
377
381
|
setDefaultScopeToComponents(componentIds: ComponentID[], scopeName: string): Promise<ComponentID[]>;
|
|
378
382
|
setDefaultScope(scopeName: string): Promise<void>;
|
|
379
|
-
addSpecificComponentConfig(id: ComponentID, aspectId: string, config?: Record<string, any>, shouldMergeWithExisting?: boolean
|
|
383
|
+
addSpecificComponentConfig(id: ComponentID, aspectId: string, config?: Record<string, any>, shouldMergeWithExisting?: boolean,
|
|
384
|
+
/**
|
|
385
|
+
* relevant only when writing to .bitmap.
|
|
386
|
+
* eject config of the given aspect-id, so then it won't override previous config. (see "adding prod dep, tagging then adding devDep" e2e-test)
|
|
387
|
+
*/
|
|
388
|
+
shouldMergeWithPrevious?: boolean): Promise<void>;
|
|
380
389
|
removeSpecificComponentConfig(id: ComponentID, aspectId: string, markWithMinusIfNotExist: boolean): Promise<void>;
|
|
381
390
|
getAspectIdFromConfig(componentId: ComponentID, aspectIdStr: string, ignoreAspectVersion?: boolean): Promise<string | undefined>;
|
|
382
391
|
getSpecificComponentConfig(id: ComponentID, aspectId: string): Promise<any>;
|
package/dist/workspace.js
CHANGED
|
@@ -277,13 +277,6 @@ function _workspaceComponentLoader() {
|
|
|
277
277
|
};
|
|
278
278
|
return data;
|
|
279
279
|
}
|
|
280
|
-
function _incorrectEnvAspect() {
|
|
281
|
-
const data = require("./exceptions/incorrect-env-aspect");
|
|
282
|
-
_incorrectEnvAspect = function () {
|
|
283
|
-
return data;
|
|
284
|
-
};
|
|
285
|
-
return data;
|
|
286
|
-
}
|
|
287
280
|
function _buildGraphFromFs() {
|
|
288
281
|
const data = require("./build-graph-from-fs");
|
|
289
282
|
_buildGraphFromFs = function () {
|
|
@@ -355,7 +348,7 @@ class Workspace {
|
|
|
355
348
|
/**
|
|
356
349
|
* on component add slot.
|
|
357
350
|
*/
|
|
358
|
-
onComponentAddSlot, onComponentRemoveSlot, onPreWatchSlot, graphql) {
|
|
351
|
+
onComponentAddSlot, onComponentRemoveSlot, onMultipleComponentsAddSlot, onPreWatchSlot, graphql) {
|
|
359
352
|
var _this$config;
|
|
360
353
|
this.pubsub = pubsub;
|
|
361
354
|
this.config = config;
|
|
@@ -373,6 +366,7 @@ class Workspace {
|
|
|
373
366
|
this.envs = envs;
|
|
374
367
|
this.onComponentAddSlot = onComponentAddSlot;
|
|
375
368
|
this.onComponentRemoveSlot = onComponentRemoveSlot;
|
|
369
|
+
this.onMultipleComponentsAddSlot = onMultipleComponentsAddSlot;
|
|
376
370
|
this.onPreWatchSlot = onPreWatchSlot;
|
|
377
371
|
this.graphql = graphql;
|
|
378
372
|
(0, _defineProperty2().default)(this, "priority", true);
|
|
@@ -439,6 +433,10 @@ class Workspace {
|
|
|
439
433
|
this.onComponentAddSlot.register(onComponentAddFunc);
|
|
440
434
|
return this;
|
|
441
435
|
}
|
|
436
|
+
registerOnMultipleComponentsAdd(onMultipleComponentsAddFunc) {
|
|
437
|
+
this.onMultipleComponentsAddSlot.register(onMultipleComponentsAddFunc);
|
|
438
|
+
return this;
|
|
439
|
+
}
|
|
442
440
|
registerOnComponentRemove(onComponentRemoveFunc) {
|
|
443
441
|
this.onComponentRemoveSlot.register(onComponentRemoveFunc);
|
|
444
442
|
return this;
|
|
@@ -743,6 +741,10 @@ class Workspace {
|
|
|
743
741
|
});
|
|
744
742
|
return results;
|
|
745
743
|
}
|
|
744
|
+
async triggerOnMultipleComponentsAdd() {
|
|
745
|
+
const onAddEntries = this.onMultipleComponentsAddSlot.toArray();
|
|
746
|
+
await (0, _pMapSeries().default)(onAddEntries, async ([, onAddFunc]) => onAddFunc());
|
|
747
|
+
}
|
|
746
748
|
getState(id, hash) {
|
|
747
749
|
return this.scope.getState(id, hash);
|
|
748
750
|
}
|
|
@@ -791,11 +793,7 @@ class Workspace {
|
|
|
791
793
|
}
|
|
792
794
|
async ejectConfig(id, options) {
|
|
793
795
|
const componentId = await this.resolveComponentId(id);
|
|
794
|
-
const
|
|
795
|
-
const componentFromScope = await this.scope.get(id);
|
|
796
|
-
const {
|
|
797
|
-
extensions
|
|
798
|
-
} = await this.componentExtensions(component.id, componentFromScope, ['WorkspaceDefault', 'WorkspaceVariants']);
|
|
796
|
+
const extensions = await this.getSpecificExtensionsFromScope(id);
|
|
799
797
|
const aspects = await this.createAspectList(extensions);
|
|
800
798
|
const componentDir = this.componentDir(id, {
|
|
801
799
|
ignoreVersion: true
|
|
@@ -811,6 +809,13 @@ class Workspace {
|
|
|
811
809
|
configPath: _componentConfigFile().ComponentConfigFile.composePath(componentDir)
|
|
812
810
|
};
|
|
813
811
|
}
|
|
812
|
+
async getSpecificExtensionsFromScope(id) {
|
|
813
|
+
const componentFromScope = await this.scope.get(id);
|
|
814
|
+
const {
|
|
815
|
+
extensions
|
|
816
|
+
} = await this.componentExtensions(id, componentFromScope, ['WorkspaceDefault', 'WorkspaceVariants']);
|
|
817
|
+
return extensions;
|
|
818
|
+
}
|
|
814
819
|
|
|
815
820
|
/**
|
|
816
821
|
* see component-aspect, createAspectListFromLegacy() method for a context why this is needed.
|
|
@@ -1392,7 +1397,12 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
|
|
|
1392
1397
|
dir: _path2().default.dirname(config.workspaceConfig.path)
|
|
1393
1398
|
}));
|
|
1394
1399
|
}
|
|
1395
|
-
async addSpecificComponentConfig(id, aspectId, config = {}, shouldMergeWithExisting = false
|
|
1400
|
+
async addSpecificComponentConfig(id, aspectId, config = {}, shouldMergeWithExisting = false,
|
|
1401
|
+
/**
|
|
1402
|
+
* relevant only when writing to .bitmap.
|
|
1403
|
+
* eject config of the given aspect-id, so then it won't override previous config. (see "adding prod dep, tagging then adding devDep" e2e-test)
|
|
1404
|
+
*/
|
|
1405
|
+
shouldMergeWithPrevious = false) {
|
|
1396
1406
|
const componentConfigFile = await this.componentConfigFile(id);
|
|
1397
1407
|
if (componentConfigFile) {
|
|
1398
1408
|
await componentConfigFile.addAspect(aspectId, config, this.resolveComponentId.bind(this), shouldMergeWithExisting);
|
|
@@ -1400,6 +1410,11 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
|
|
|
1400
1410
|
override: true
|
|
1401
1411
|
});
|
|
1402
1412
|
} else {
|
|
1413
|
+
if (shouldMergeWithPrevious) {
|
|
1414
|
+
const extensions = await this.getSpecificExtensionsFromScope(id);
|
|
1415
|
+
const obj = extensions.toConfigObject();
|
|
1416
|
+
config = obj[aspectId] ? (0, _lodash().merge)(obj[aspectId], config) : config;
|
|
1417
|
+
}
|
|
1403
1418
|
this.bitMap.addComponentConfig(id, aspectId, config, shouldMergeWithExisting);
|
|
1404
1419
|
}
|
|
1405
1420
|
}
|
|
@@ -1538,21 +1553,21 @@ needed-for: ${neededFor || '<unknown>'}`);
|
|
|
1538
1553
|
const components = await this.importAndGetAspects(componentIds);
|
|
1539
1554
|
const isAspect = async id => {
|
|
1540
1555
|
const component = await this.get(id);
|
|
1541
|
-
const data = this.envs.getEnvData(component);
|
|
1542
1556
|
const isUsingAspectEnv = this.envs.isUsingAspectEnv(component);
|
|
1543
1557
|
const isUsingEnvEnv = this.envs.isUsingEnvEnv(component);
|
|
1544
1558
|
const isValidAspect = isUsingAspectEnv || isUsingEnvEnv;
|
|
1545
|
-
if (!isValidAspect && idsWithoutCore.includes(component.id.toString())) {
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
}
|
|
1559
|
+
// if (!isValidAspect && idsWithoutCore.includes(component.id.toString())) {
|
|
1560
|
+
// const data = this.envs.getEnvData(component);
|
|
1561
|
+
// const err = new IncorrectEnvAspect(component.id.toString(), data.type, data.id);
|
|
1562
|
+
// if (data.id === DEFAULT_ENV) {
|
|
1563
|
+
// // when cloning a project, or when the node-modules dir is deleted, nothing works and all
|
|
1564
|
+
// // components are default to the DEFAULT_ENV, which is node-env. we must allow "bit
|
|
1565
|
+
// // install" to prepare the workspace and let the proper the envs to be loaded
|
|
1566
|
+
// this.logger.error(err.message);
|
|
1567
|
+
// } else {
|
|
1568
|
+
// throw err;
|
|
1569
|
+
// }
|
|
1570
|
+
// }
|
|
1556
1571
|
return isValidAspect;
|
|
1557
1572
|
};
|
|
1558
1573
|
const graph = await this.getAspectsGraphWithoutCore(components, isAspect);
|