@teambit/watcher 0.0.149 → 0.0.151
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/watch.cmd.js +3 -2
- package/dist/watch.cmd.js.map +1 -1
- package/dist/watcher.js +6 -0
- package/dist/watcher.js.map +1 -1
- package/dist/watcher.main.runtime.d.ts +6 -3
- package/dist/watcher.main.runtime.js +12 -4
- package/dist/watcher.main.runtime.js.map +1 -1
- package/package.json +12 -11
- package/.bit-capsule-ready +0 -0
- package/package-tar/teambit-watcher-0.0.149.tgz +0 -0
- /package/dist/{preview-1692674301863.js → preview-1692847103766.js} +0 -0
package/dist/watch.cmd.js
CHANGED
|
@@ -71,8 +71,9 @@ class WatchCommand {
|
|
|
71
71
|
(0, _defineProperty2().default)(this, "name", 'watch');
|
|
72
72
|
(0, _defineProperty2().default)(this, "description", 'automatically recompile modified components (on save)');
|
|
73
73
|
(0, _defineProperty2().default)(this, "extendedDescription", `by default, the watcher doesn't use polling, to keep the CPU idle.
|
|
74
|
-
in some rare cases, this could result in missing file events
|
|
75
|
-
|
|
74
|
+
in some rare cases, this could result in missing file events (files are not watched).
|
|
75
|
+
to fix it, try to stop other watchers on the same machine.
|
|
76
|
+
alternatively, to use polling, run "bit config set watch_use_polling true".`);
|
|
76
77
|
(0, _defineProperty2().default)(this, "helpUrl", 'reference/compiling/compiler-overview');
|
|
77
78
|
(0, _defineProperty2().default)(this, "alias", '');
|
|
78
79
|
(0, _defineProperty2().default)(this, "group", 'development');
|
package/dist/watch.cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_moment","_compiler","_outputFormatter","_checkTypes","WatchCommand","constructor","pubsub","logger","watcher","_defineProperty2","default","event","type","CompilerErrorEvent","TYPE","console","error","registerToEvents","sub","CompilerAspect","id","eventsListener","report","cliArgs","watchCmdOpts","verbose","checkTypes","getCheckTypesEnum","undefined","CheckTypes","None","EntireProject","ChangedFile","Error","watchOpts","msgs","getMessages","preCompile","skipPreCompilation","spawnTSServer","Boolean","watch","exports","onAll","path","onStart","onReady","workspace","watchPathsSortByComponent","clearOutdatedData","formatWatchPathsSortByComponent","chalk","yellow","config","name","moment","format","onChange","args","printOnFileEvent","onAdd","onUnlink","onError","err","eventMsgPlaceholder","filePaths","buildResults","duration","failureMsg","files","join","length","formatCompileResults","process","stdout","write"],"sources":["watch.cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport moment from 'moment';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport type { Logger } from '@teambit/logger';\nimport type { BitBaseEvent, PubsubMain } from '@teambit/pubsub';\nimport { OnComponentEventResult } from '@teambit/workspace';\n\n// import IDs and events\nimport { CompilerAspect, CompilerErrorEvent } from '@teambit/compiler';\n\nimport { EventMessages, WatchOptions } from './watcher';\nimport { formatCompileResults, formatWatchPathsSortByComponent } from './output-formatter';\nimport { CheckTypes } from './check-types';\nimport { WatcherMain } from './watcher.main.runtime';\n\nexport type WatchCmdOpts = {\n verbose?: boolean;\n skipPreCompilation?: boolean;\n checkTypes?: string | boolean;\n};\n\nexport class WatchCommand implements Command {\n name = 'watch';\n description = 'automatically recompile modified components (on save)';\n extendedDescription = `by default, the watcher doesn't use polling, to keep the CPU idle.\nin some rare cases, this could result in missing file events. to fix it, try to prefix this command with CHOKIDAR_USEPOLLING=true\nalternatively, restarting the computer could also help.`;\n helpUrl = 'reference/compiling/compiler-overview';\n alias = '';\n group = 'development';\n options = [\n ['v', 'verbose', 'show all watch events and compiler verbose output'],\n ['', 'skip-pre-compilation', 'skip compilation step before starting to watch'],\n [\n 't',\n 'check-types [string]',\n 'EXPERIMENTAL. show errors/warnings for types. options are [file, project] to investigate only changed file or entire project. defaults to project',\n ],\n ] as CommandOptions;\n\n constructor(\n /**\n * logger extension.\n */\n private pubsub: PubsubMain,\n\n /**\n * logger extension.\n */\n private logger: Logger,\n\n /**\n * watcher extension.\n */\n private watcher: WatcherMain\n ) {\n this.registerToEvents();\n }\n\n private registerToEvents() {\n this.pubsub.sub(CompilerAspect.id, this.eventsListener);\n }\n\n private eventsListener = (event: BitBaseEvent<any>) => {\n switch (event.type) {\n case CompilerErrorEvent.TYPE:\n this.logger.console(`Watcher error ${event.data.error}, 'error'`);\n break;\n default:\n }\n };\n\n async report(cliArgs: [], watchCmdOpts: WatchCmdOpts) {\n const { verbose, checkTypes } = watchCmdOpts;\n const getCheckTypesEnum = () => {\n switch (checkTypes) {\n case undefined:\n case false:\n return CheckTypes.None;\n case 'project':\n case true: // project is the default\n return CheckTypes.EntireProject;\n case 'file':\n return CheckTypes.ChangedFile;\n default:\n throw new Error(`check-types can be either \"file\" or \"project\". got \"${checkTypes}\"`);\n }\n };\n const watchOpts: WatchOptions = {\n msgs: getMessages(this.logger),\n verbose,\n preCompile: !watchCmdOpts.skipPreCompilation,\n spawnTSServer: Boolean(checkTypes), // if check-types is enabled, it must spawn the tsserver.\n checkTypes: getCheckTypesEnum(),\n };\n await this.watcher.watch(watchOpts);\n return 'watcher terminated';\n }\n}\n\nfunction getMessages(logger: Logger): EventMessages {\n return {\n onAll: (event: string, path: string) => logger.console(`Event: \"${event}\". Path: ${path}`),\n onStart: () => {},\n onReady: (workspace, watchPathsSortByComponent, verbose?: boolean) => {\n clearOutdatedData();\n if (verbose) {\n logger.console(formatWatchPathsSortByComponent(watchPathsSortByComponent));\n }\n logger.console(\n chalk.yellow(\n `Watching for component changes in workspace ${workspace.config.name} (${moment().format('HH:mm:ss')})...\\n`\n )\n );\n },\n onChange: (...args) => {\n printOnFileEvent(logger, 'changed', ...args);\n },\n onAdd: (...args) => {\n printOnFileEvent(logger, 'added', ...args);\n },\n onUnlink: (...args) => {\n printOnFileEvent(logger, 'removed', ...args);\n },\n onError: (err) => {\n logger.console(`Watcher error ${err}`);\n },\n };\n}\n\nfunction printOnFileEvent(\n logger: Logger,\n eventMsgPlaceholder: 'changed' | 'added' | 'removed',\n filePaths: string[],\n buildResults: OnComponentEventResult[],\n verbose: boolean,\n duration: number,\n failureMsg?: string\n) {\n const files = filePaths.join(', ');\n if (!buildResults.length) {\n failureMsg = failureMsg || `The files ${files} have been ${eventMsgPlaceholder}, but nothing to compile`;\n logger.console(`${failureMsg}\\n\\n`);\n return;\n }\n logger.console(`The file(s) ${files} have been ${eventMsgPlaceholder}.\\n\\n`);\n logger.console(formatCompileResults(buildResults, verbose));\n logger.console(`Finished. (${duration}ms)`);\n logger.console(chalk.yellow(`Watching for component changes (${moment().format('HH:mm:ss')})...`));\n}\n\n/**\n * with console.clear() all history is deleted from the console. this function preserver the history.\n */\nfunction clearOutdatedData() {\n process.stdout.write('\\x1Bc');\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAOA,SAAAI,UAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,SAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAK,iBAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,gBAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,YAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,WAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AALA;;AAcO,MAAMO,YAAY,CAAoB;EAmB3CC,WAAWA;EACT;AACJ;AACA;EACYC,MAAkB;EAE1B;AACJ;AACA;EACYC,MAAc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CAAC,CAACC,MAAM,CAAC,UAAU,CAAE,MAAK,CAAC,CAAC;AACpG;;AAEA;AACA;AACA;AACA,SAASP,iBAAiBA,CAAA,EAAG;EAC3BwB,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC,OAAO,CAAC;AAC/B"}
|
|
1
|
+
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_moment","_compiler","_outputFormatter","_checkTypes","WatchCommand","constructor","pubsub","logger","watcher","_defineProperty2","default","event","type","CompilerErrorEvent","TYPE","console","error","registerToEvents","sub","CompilerAspect","id","eventsListener","report","cliArgs","watchCmdOpts","verbose","checkTypes","getCheckTypesEnum","undefined","CheckTypes","None","EntireProject","ChangedFile","Error","watchOpts","msgs","getMessages","preCompile","skipPreCompilation","spawnTSServer","Boolean","watch","exports","onAll","path","onStart","onReady","workspace","watchPathsSortByComponent","clearOutdatedData","formatWatchPathsSortByComponent","chalk","yellow","config","name","moment","format","onChange","args","printOnFileEvent","onAdd","onUnlink","onError","err","eventMsgPlaceholder","filePaths","buildResults","duration","failureMsg","files","join","length","formatCompileResults","process","stdout","write"],"sources":["watch.cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport moment from 'moment';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport type { Logger } from '@teambit/logger';\nimport type { BitBaseEvent, PubsubMain } from '@teambit/pubsub';\nimport { OnComponentEventResult } from '@teambit/workspace';\n\n// import IDs and events\nimport { CompilerAspect, CompilerErrorEvent } from '@teambit/compiler';\n\nimport { EventMessages, WatchOptions } from './watcher';\nimport { formatCompileResults, formatWatchPathsSortByComponent } from './output-formatter';\nimport { CheckTypes } from './check-types';\nimport { WatcherMain } from './watcher.main.runtime';\n\nexport type WatchCmdOpts = {\n verbose?: boolean;\n skipPreCompilation?: boolean;\n checkTypes?: string | boolean;\n};\n\nexport class WatchCommand implements Command {\n name = 'watch';\n description = 'automatically recompile modified components (on save)';\n extendedDescription = `by default, the watcher doesn't use polling, to keep the CPU idle.\nin some rare cases, this could result in missing file events (files are not watched).\nto fix it, try to stop other watchers on the same machine.\nalternatively, to use polling, run \"bit config set watch_use_polling true\".`;\n helpUrl = 'reference/compiling/compiler-overview';\n alias = '';\n group = 'development';\n options = [\n ['v', 'verbose', 'show all watch events and compiler verbose output'],\n ['', 'skip-pre-compilation', 'skip compilation step before starting to watch'],\n [\n 't',\n 'check-types [string]',\n 'EXPERIMENTAL. show errors/warnings for types. options are [file, project] to investigate only changed file or entire project. defaults to project',\n ],\n ] as CommandOptions;\n\n constructor(\n /**\n * logger extension.\n */\n private pubsub: PubsubMain,\n\n /**\n * logger extension.\n */\n private logger: Logger,\n\n /**\n * watcher extension.\n */\n private watcher: WatcherMain\n ) {\n this.registerToEvents();\n }\n\n private registerToEvents() {\n this.pubsub.sub(CompilerAspect.id, this.eventsListener);\n }\n\n private eventsListener = (event: BitBaseEvent<any>) => {\n switch (event.type) {\n case CompilerErrorEvent.TYPE:\n this.logger.console(`Watcher error ${event.data.error}, 'error'`);\n break;\n default:\n }\n };\n\n async report(cliArgs: [], watchCmdOpts: WatchCmdOpts) {\n const { verbose, checkTypes } = watchCmdOpts;\n const getCheckTypesEnum = () => {\n switch (checkTypes) {\n case undefined:\n case false:\n return CheckTypes.None;\n case 'project':\n case true: // project is the default\n return CheckTypes.EntireProject;\n case 'file':\n return CheckTypes.ChangedFile;\n default:\n throw new Error(`check-types can be either \"file\" or \"project\". got \"${checkTypes}\"`);\n }\n };\n const watchOpts: WatchOptions = {\n msgs: getMessages(this.logger),\n verbose,\n preCompile: !watchCmdOpts.skipPreCompilation,\n spawnTSServer: Boolean(checkTypes), // if check-types is enabled, it must spawn the tsserver.\n checkTypes: getCheckTypesEnum(),\n };\n await this.watcher.watch(watchOpts);\n return 'watcher terminated';\n }\n}\n\nfunction getMessages(logger: Logger): EventMessages {\n return {\n onAll: (event: string, path: string) => logger.console(`Event: \"${event}\". Path: ${path}`),\n onStart: () => {},\n onReady: (workspace, watchPathsSortByComponent, verbose?: boolean) => {\n clearOutdatedData();\n if (verbose) {\n logger.console(formatWatchPathsSortByComponent(watchPathsSortByComponent));\n }\n logger.console(\n chalk.yellow(\n `Watching for component changes in workspace ${workspace.config.name} (${moment().format('HH:mm:ss')})...\\n`\n )\n );\n },\n onChange: (...args) => {\n printOnFileEvent(logger, 'changed', ...args);\n },\n onAdd: (...args) => {\n printOnFileEvent(logger, 'added', ...args);\n },\n onUnlink: (...args) => {\n printOnFileEvent(logger, 'removed', ...args);\n },\n onError: (err) => {\n logger.console(`Watcher error ${err}`);\n },\n };\n}\n\nfunction printOnFileEvent(\n logger: Logger,\n eventMsgPlaceholder: 'changed' | 'added' | 'removed',\n filePaths: string[],\n buildResults: OnComponentEventResult[],\n verbose: boolean,\n duration: number,\n failureMsg?: string\n) {\n const files = filePaths.join(', ');\n if (!buildResults.length) {\n failureMsg = failureMsg || `The files ${files} have been ${eventMsgPlaceholder}, but nothing to compile`;\n logger.console(`${failureMsg}\\n\\n`);\n return;\n }\n logger.console(`The file(s) ${files} have been ${eventMsgPlaceholder}.\\n\\n`);\n logger.console(formatCompileResults(buildResults, verbose));\n logger.console(`Finished. (${duration}ms)`);\n logger.console(chalk.yellow(`Watching for component changes (${moment().format('HH:mm:ss')})...`));\n}\n\n/**\n * with console.clear() all history is deleted from the console. this function preserver the history.\n */\nfunction clearOutdatedData() {\n process.stdout.write('\\x1Bc');\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAOA,SAAAI,UAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,SAAA,YAAAA,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K,aAAYC,KAAM,cAAaL,mBAAoB,0BAAyB;IACxGzD,MAAM,CAACQ,OAAO,CAAE,GAAEqD,UAAW,MAAK,CAAC;IACnC;EACF;EACA7D,MAAM,CAACQ,OAAO,CAAE,eAAcsD,KAAM,cAAaL,mBAAoB,OAAM,CAAC;EAC5EzD,MAAM,CAACQ,OAAO,CAAC,IAAAyD,uCAAoB,EAACN,YAAY,EAAEzC,OAAO,CAAC,CAAC;EAC3DlB,MAAM,CAACQ,OAAO,CAAE,cAAaoD,QAAS,KAAI,CAAC;EAC3C5D,MAAM,CAACQ,OAAO,CAACoC,gBAAK,CAACC,MAAM,CAAE,mCAAkC,IAAAG,iBAAM,EAAC,CAAC,CAACC,MAAM,CAAC,UAAU,CAAE,MAAK,CAAC,CAAC;AACpG;;AAEA;AACA;AACA;AACA,SAASP,iBAAiBA,CAAA,EAAG;EAC3BwB,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC,OAAO,CAAC;AAC/B"}
|
package/dist/watcher.js
CHANGED
|
@@ -428,13 +428,19 @@ class Watcher {
|
|
|
428
428
|
return this.findTrackDirByFilePathRecursively(parentDir);
|
|
429
429
|
}
|
|
430
430
|
async createWatcher(pathsToWatch) {
|
|
431
|
+
const usePollingConf = await this.watcherMain.globalConfig.get(_constants().CFG_WATCH_USE_POLLING);
|
|
432
|
+
const usePolling = usePollingConf === 'true';
|
|
431
433
|
this.fsWatcher = _chokidar().default.watch(pathsToWatch, {
|
|
432
434
|
ignoreInitial: true,
|
|
433
435
|
// `chokidar` matchers have Bash-parity, so Windows-style backslackes are not supported as separators.
|
|
434
436
|
// (windows-style backslashes are converted to forward slashes)
|
|
435
437
|
ignored: ['**/node_modules/**', '**/package.json'],
|
|
438
|
+
usePolling,
|
|
436
439
|
persistent: true
|
|
437
440
|
});
|
|
441
|
+
if (this.verbose) {
|
|
442
|
+
_logger().default.console(`chokidar.options ${JSON.stringify(this.fsWatcher.options, undefined, 2)}`);
|
|
443
|
+
}
|
|
438
444
|
}
|
|
439
445
|
async setTrackDirs() {
|
|
440
446
|
this.trackDirs = {};
|
package/dist/watcher.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_fsExtra","data","_interopRequireDefault","require","_path","_lodash","_loader","_constants","_logger","_utils","_pMapSeries","_chalk","_chokidar","_workspace","_watchQueue","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","DEBOUNCE_WAIT_MS","Watcher","constructor","workspace","pubsub","watcherMain","WatchQueue","ipcEventsDir","ipcEvents","eventsDir","consumer","watchAll","opts","msgs","watchOpts","_objectWithoutProperties2","verbose","pathsToWatch","getPathsToWatch","componentIds","values","trackDirs","triggerOnPreWatch","createWatcher","watcher","fsWatcher","onStart","scope","watchScopeInternalFiles","Promise","resolve","reject","onAll","on","onReady","loader","stop","filePath","startTime","Date","getTime","files","results","debounced","failureMsg","handleChange","initiator","duration","onChange","onAdd","onUnlink","err","onError","endsWith","BIT_MAP","bitMapChangesInProgress","buildResults","watchQueue","add","handleBitmapChanges","onIdle","dirname","eventName","basename","logger","warn","triggerGotEvent","componentId","getComponentIdByPath","debug","compIdStr","toString","changedFilesPerComponent","sleep","triggerCompChanges","undefined","join","msg","error","console","message","ms","setTimeout","updatedComponentId","hasId","ids","listIds","find","id","isEqual","ignoreVersion","clearComponentCache","component","get","componentMap","state","_consumer","Error","compFilesRelativeToWorkspace","getFilesRelativeToConsumer","compFiles","nonCompFiles","partition","relativeFile","getRelativePathLinux","Boolean","p","removedFiles","compact","all","map","fs","pathExists","toStringWithoutVersion","executeWatchOperationsOnComponent","previewsTrackDirs","_reloadConsumer","setTrackDirs","triggerOnBitmapChange","newDirs","difference","removedDirs","dir","toAbsolutePath","addResults","mapSeries","flat","unwatch","executeWatchOperationsOnRemove","chalk","bold","pub","WorkspaceAspect","creatOnComponentRemovedEvent","triggerOnComponentRemove","isChange","isComponentWatchedExternally","idStr","creatOnComponentChangeEvent","creatOnComponentAddEvent","triggerOnComponentChange","triggerOnComponentAdd","OnComponentRemovedEvent","now","hook","OnComponentChangeEvent","OnComponentAddEvent","watcherData","multipleWatchers","m","_legacy","compilerId","trackDir","findTrackDirByFilePathRecursively","pathNormalizeToLinux","getPathRelativeToConsumer","parentDir","chokidar","watch","ignoreInitial","ignored","persistent","componentsFromBitMap","bitMap","getAllComponents","bitId","rootDir","getRootDir","resolveComponentId","paths","pathsAbsolute","ensureDir","exports"],"sources":["watcher.ts"],"sourcesContent":["import { PubsubMain } from '@teambit/pubsub';\nimport fs from 'fs-extra';\nimport { dirname, basename } from 'path';\nimport { compact, difference, partition } 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 {\n WorkspaceAspect,\n Workspace,\n OnComponentEventResult,\n OnComponentChangeEvent,\n OnComponentAddEvent,\n OnComponentRemovedEvent,\n} from '@teambit/workspace';\nimport { CheckTypes } from './check-types';\nimport { WatcherMain } from './watcher.main.runtime';\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: OnFileEventFunc;\n onAdd: OnFileEventFunc;\n onUnlink: OnFileEventFunc;\n onError: Function;\n};\n\nexport type OnFileEventFunc = (\n filePaths: string[],\n buildResults: OnComponentEventResult[],\n verbose: boolean,\n duration: number,\n failureMsg?: string\n) => void;\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 private ipcEventsDir: string;\n private trackDirs: { [dir: PathLinux]: ComponentID } = {};\n private verbose = false;\n private multipleWatchers: WatcherProcessData[] = [];\n constructor(private workspace: Workspace, private pubsub: PubsubMain, private watcherMain: WatcherMain) {\n this.ipcEventsDir = this.watcherMain.ipcEvents.eventsDir;\n }\n\n get consumer(): Consumer {\n return this.workspace.consumer;\n }\n\n async watchAll(opts: WatchOptions) {\n const { msgs, ...watchOpts } = opts;\n this.verbose = opts.verbose || false;\n const pathsToWatch = await this.getPathsToWatch();\n const componentIds = Object.values(this.trackDirs);\n await this.watcherMain.triggerOnPreWatch(componentIds, watchOpts);\n await this.createWatcher(pathsToWatch);\n const watcher = this.fsWatcher;\n msgs?.onStart(this.workspace);\n\n await this.workspace.scope.watchScopeInternalFiles();\n\n return new Promise((resolve, reject) => {\n if (this.verbose) {\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 loader.stop();\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 (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?.onUnlink(files, results, this.verbose, duration, failureMsg);\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 if (dirname(filePath) === this.ipcEventsDir) {\n const eventName = basename(filePath);\n if (eventName !== 'onPostInstall') {\n this.watcherMain.logger.warn(`eventName ${eventName} is not recognized, please handle it`);\n }\n await this.watcherMain.ipcEvents.triggerGotEvent(eventName as 'onPostInstall');\n return { results: [], files: [filePath] };\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: [], files: [], 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 private async triggerCompChanges(\n componentId: ComponentID,\n files: PathOsBasedAbsolute[],\n initiator?: CompilationInitiator\n ): Promise<OnComponentEventResult[]> {\n let updatedComponentId: ComponentID | undefined = componentId;\n if (!(await this.workspace.hasId(componentId))) {\n // bitmap has changed meanwhile, which triggered `handleBitmapChanges`, which re-loaded consumer and updated versions\n // so the original componentId might not be in the workspace now, and we need to find the updated one\n const ids = await this.workspace.listIds();\n updatedComponentId = ids.find((id) => id.isEqual(componentId, { ignoreVersion: true }));\n if (!updatedComponentId) {\n logger.debug(`triggerCompChanges, the component ${componentId.toString()} was probably removed from .bitmap`);\n return [];\n }\n }\n this.workspace.clearComponentCache(updatedComponentId);\n const component = await this.workspace.get(updatedComponentId);\n const componentMap: ComponentMap = component.state._consumer.componentMap;\n if (!componentMap) {\n throw new Error(\n `unable to find componentMap for ${updatedComponentId.toString()}, make sure this component is in .bitmap`\n );\n }\n const compFilesRelativeToWorkspace = componentMap.getFilesRelativeToConsumer();\n const [compFiles, nonCompFiles] = partition(files, (filePath) => {\n const relativeFile = this.getRelativePathLinux(filePath);\n return Boolean(compFilesRelativeToWorkspace.find((p) => p === relativeFile));\n });\n // nonCompFiles are either, files that were removed from the filesystem or existing files that are ignored.\n // the compiler takes care of removedFiles differently, e.g. removes dists dir and old symlinks.\n const removedFiles = compact(\n await Promise.all(nonCompFiles.map(async (filePath) => ((await fs.pathExists(filePath)) ? null : filePath)))\n );\n\n if (!compFiles.length && !removedFiles.length) {\n logger.debug(\n `the following files are part of the component ${componentId.toStringWithoutVersion()} but configured to be ignored:\\n${files.join(\n '\\n'\n )}'`\n );\n return [];\n }\n const buildResults = await this.executeWatchOperationsOnComponent(\n updatedComponentId,\n compFiles,\n removedFiles,\n true,\n initiator\n );\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 await this.workspace.triggerOnBitmapChange();\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.map((dir) => this.consumer.toAbsolutePath(dir)));\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\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 removedFiles: 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 const buildResults = isChange\n ? await this.workspace.triggerOnComponentChange(componentId, files, removedFiles, initiator)\n : await this.workspace.triggerOnComponentAdd(componentId);\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 // `chokidar` matchers have Bash-parity, so Windows-style backslackes are not supported as separators.\n // (windows-style backslashes are converted to forward slashes)\n ignored: ['**/node_modules/**', '**/package.json'],\n persistent: true,\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 // otherwise, if the dir is not there, chokidar triggers 'onReady' event twice for some unclear reason.\n await fs.ensureDir(this.ipcEventsDir);\n pathsAbsolute.push(this.ipcEventsDir);\n return pathsAbsolute;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,OAAA,YAAAA,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AC/C,MAAMuE,KAAK,GAAGvE,YAAY,CAACN,EAAE;MAC7B,MAAM8E,OAAO,GAAGxE,YAAY,CAACyE,UAAU,CAAC,CAAC;MACzC,IAAI,CAACD,OAAO,EAAE,MAAM,IAAIrE,KAAK,CAAE,GAAEoE,KAAK,CAAC9F,QAAQ,CAAC,CAAE,8CAA6C,CAAC;MAChG,MAAMJ,WAAW,GAAG,MAAM,IAAI,CAAChE,SAAS,CAACqK,kBAAkB,CAACH,KAAK,CAAC;MAClE,IAAI,CAAChJ,SAAS,CAACiJ,OAAO,CAAC,GAAGnG,WAAW;IACvC,CAAC,CACH,CAAC;EACH;EAEA,MAAcjD,eAAeA,CAAA,EAAmC;IAC9D,MAAM,IAAI,CAACmG,YAAY,CAAC,CAAC;IACzB,MAAMoD,KAAK,GAAG,CAAC,GAAG/L,MAAM,CAACD,IAAI,CAAC,IAAI,CAAC4C,SAAS,CAAC,EAAEiC,oBAAO,CAAC;IACvD,MAAMoH,aAAa,GAAGD,KAAK,CAAC3D,GAAG,CAAEY,GAAG,IAAK,IAAI,CAAChH,QAAQ,CAACiH,cAAc,CAACD,GAAG,CAAC,CAAC;IAC3E;IACA,MAAMX,kBAAE,CAAC4D,SAAS,CAAC,IAAI,CAACpK,YAAY,CAAC;IACrCmK,aAAa,CAACzL,IAAI,CAAC,IAAI,CAACsB,YAAY,CAAC;IACrC,OAAOmK,aAAa;EACtB;AACF;AAACE,OAAA,CAAA3K,OAAA,GAAAA,OAAA"}
|
|
1
|
+
{"version":3,"names":["_fsExtra","data","_interopRequireDefault","require","_path","_lodash","_loader","_constants","_logger","_utils","_pMapSeries","_chalk","_chokidar","_workspace","_watchQueue","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","DEBOUNCE_WAIT_MS","Watcher","constructor","workspace","pubsub","watcherMain","WatchQueue","ipcEventsDir","ipcEvents","eventsDir","consumer","watchAll","opts","msgs","watchOpts","_objectWithoutProperties2","verbose","pathsToWatch","getPathsToWatch","componentIds","values","trackDirs","triggerOnPreWatch","createWatcher","watcher","fsWatcher","onStart","scope","watchScopeInternalFiles","Promise","resolve","reject","onAll","on","onReady","loader","stop","filePath","startTime","Date","getTime","files","results","debounced","failureMsg","handleChange","initiator","duration","onChange","onAdd","onUnlink","err","onError","endsWith","BIT_MAP","bitMapChangesInProgress","buildResults","watchQueue","add","handleBitmapChanges","onIdle","dirname","eventName","basename","logger","warn","triggerGotEvent","componentId","getComponentIdByPath","debug","compIdStr","toString","changedFilesPerComponent","sleep","triggerCompChanges","undefined","join","msg","error","console","message","ms","setTimeout","updatedComponentId","hasId","ids","listIds","find","id","isEqual","ignoreVersion","clearComponentCache","component","get","componentMap","state","_consumer","Error","compFilesRelativeToWorkspace","getFilesRelativeToConsumer","compFiles","nonCompFiles","partition","relativeFile","getRelativePathLinux","Boolean","p","removedFiles","compact","all","map","fs","pathExists","toStringWithoutVersion","executeWatchOperationsOnComponent","previewsTrackDirs","_reloadConsumer","setTrackDirs","triggerOnBitmapChange","newDirs","difference","removedDirs","dir","toAbsolutePath","addResults","mapSeries","flat","unwatch","executeWatchOperationsOnRemove","chalk","bold","pub","WorkspaceAspect","creatOnComponentRemovedEvent","triggerOnComponentRemove","isChange","isComponentWatchedExternally","idStr","creatOnComponentChangeEvent","creatOnComponentAddEvent","triggerOnComponentChange","triggerOnComponentAdd","OnComponentRemovedEvent","now","hook","OnComponentChangeEvent","OnComponentAddEvent","watcherData","multipleWatchers","m","_legacy","compilerId","trackDir","findTrackDirByFilePathRecursively","pathNormalizeToLinux","getPathRelativeToConsumer","parentDir","usePollingConf","globalConfig","CFG_WATCH_USE_POLLING","usePolling","chokidar","watch","ignoreInitial","ignored","persistent","JSON","stringify","options","componentsFromBitMap","bitMap","getAllComponents","bitId","rootDir","getRootDir","resolveComponentId","paths","pathsAbsolute","ensureDir","exports"],"sources":["watcher.ts"],"sourcesContent":["import { PubsubMain } from '@teambit/pubsub';\nimport fs from 'fs-extra';\nimport { dirname, basename } from 'path';\nimport { compact, difference, partition } 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, CFG_WATCH_USE_POLLING } 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 {\n WorkspaceAspect,\n Workspace,\n OnComponentEventResult,\n OnComponentChangeEvent,\n OnComponentAddEvent,\n OnComponentRemovedEvent,\n} from '@teambit/workspace';\nimport { CheckTypes } from './check-types';\nimport { WatcherMain } from './watcher.main.runtime';\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: OnFileEventFunc;\n onAdd: OnFileEventFunc;\n onUnlink: OnFileEventFunc;\n onError: Function;\n};\n\nexport type OnFileEventFunc = (\n filePaths: string[],\n buildResults: OnComponentEventResult[],\n verbose: boolean,\n duration: number,\n failureMsg?: string\n) => void;\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 private ipcEventsDir: string;\n private trackDirs: { [dir: PathLinux]: ComponentID } = {};\n private verbose = false;\n private multipleWatchers: WatcherProcessData[] = [];\n constructor(private workspace: Workspace, private pubsub: PubsubMain, private watcherMain: WatcherMain) {\n this.ipcEventsDir = this.watcherMain.ipcEvents.eventsDir;\n }\n\n get consumer(): Consumer {\n return this.workspace.consumer;\n }\n\n async watchAll(opts: WatchOptions) {\n const { msgs, ...watchOpts } = opts;\n this.verbose = opts.verbose || false;\n const pathsToWatch = await this.getPathsToWatch();\n const componentIds = Object.values(this.trackDirs);\n await this.watcherMain.triggerOnPreWatch(componentIds, watchOpts);\n await this.createWatcher(pathsToWatch);\n const watcher = this.fsWatcher;\n msgs?.onStart(this.workspace);\n\n await this.workspace.scope.watchScopeInternalFiles();\n\n return new Promise((resolve, reject) => {\n if (this.verbose) {\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 loader.stop();\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 (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?.onUnlink(files, results, this.verbose, duration, failureMsg);\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 if (dirname(filePath) === this.ipcEventsDir) {\n const eventName = basename(filePath);\n if (eventName !== 'onPostInstall') {\n this.watcherMain.logger.warn(`eventName ${eventName} is not recognized, please handle it`);\n }\n await this.watcherMain.ipcEvents.triggerGotEvent(eventName as 'onPostInstall');\n return { results: [], files: [filePath] };\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: [], files: [], 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 private async triggerCompChanges(\n componentId: ComponentID,\n files: PathOsBasedAbsolute[],\n initiator?: CompilationInitiator\n ): Promise<OnComponentEventResult[]> {\n let updatedComponentId: ComponentID | undefined = componentId;\n if (!(await this.workspace.hasId(componentId))) {\n // bitmap has changed meanwhile, which triggered `handleBitmapChanges`, which re-loaded consumer and updated versions\n // so the original componentId might not be in the workspace now, and we need to find the updated one\n const ids = await this.workspace.listIds();\n updatedComponentId = ids.find((id) => id.isEqual(componentId, { ignoreVersion: true }));\n if (!updatedComponentId) {\n logger.debug(`triggerCompChanges, the component ${componentId.toString()} was probably removed from .bitmap`);\n return [];\n }\n }\n this.workspace.clearComponentCache(updatedComponentId);\n const component = await this.workspace.get(updatedComponentId);\n const componentMap: ComponentMap = component.state._consumer.componentMap;\n if (!componentMap) {\n throw new Error(\n `unable to find componentMap for ${updatedComponentId.toString()}, make sure this component is in .bitmap`\n );\n }\n const compFilesRelativeToWorkspace = componentMap.getFilesRelativeToConsumer();\n const [compFiles, nonCompFiles] = partition(files, (filePath) => {\n const relativeFile = this.getRelativePathLinux(filePath);\n return Boolean(compFilesRelativeToWorkspace.find((p) => p === relativeFile));\n });\n // nonCompFiles are either, files that were removed from the filesystem or existing files that are ignored.\n // the compiler takes care of removedFiles differently, e.g. removes dists dir and old symlinks.\n const removedFiles = compact(\n await Promise.all(nonCompFiles.map(async (filePath) => ((await fs.pathExists(filePath)) ? null : filePath)))\n );\n\n if (!compFiles.length && !removedFiles.length) {\n logger.debug(\n `the following files are part of the component ${componentId.toStringWithoutVersion()} but configured to be ignored:\\n${files.join(\n '\\n'\n )}'`\n );\n return [];\n }\n const buildResults = await this.executeWatchOperationsOnComponent(\n updatedComponentId,\n compFiles,\n removedFiles,\n true,\n initiator\n );\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 await this.workspace.triggerOnBitmapChange();\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.map((dir) => this.consumer.toAbsolutePath(dir)));\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\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 removedFiles: 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 const buildResults = isChange\n ? await this.workspace.triggerOnComponentChange(componentId, files, removedFiles, initiator)\n : await this.workspace.triggerOnComponentAdd(componentId);\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 const usePollingConf = await this.watcherMain.globalConfig.get(CFG_WATCH_USE_POLLING);\n const usePolling = usePollingConf === 'true';\n this.fsWatcher = chokidar.watch(pathsToWatch, {\n ignoreInitial: true,\n // `chokidar` matchers have Bash-parity, so Windows-style backslackes are not supported as separators.\n // (windows-style backslashes are converted to forward slashes)\n ignored: ['**/node_modules/**', '**/package.json'],\n usePolling,\n persistent: true,\n });\n if (this.verbose) {\n logger.console(`chokidar.options ${JSON.stringify(this.fsWatcher.options, undefined, 2)}`);\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 // otherwise, if the dir is not there, chokidar triggers 'onReady' event twice for some unclear reason.\n await fs.ensureDir(this.ipcEventsDir);\n pathsAbsolute.push(this.ipcEventsDir);\n return pathsAbsolute;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,WAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,UAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AA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AMoJ,oBAAoB,GAAG,IAAI,CAAC/J,QAAQ,CAACgK,MAAM,CAACC,gBAAgB,CAAC,CAAC;IACpE,MAAM9I,OAAO,CAACgF,GAAG,CACf4D,oBAAoB,CAAC3D,GAAG,CAAC,MAAOhB,YAAY,IAAK;MAC/C,MAAM8E,KAAK,GAAG9E,YAAY,CAACN,EAAE;MAC7B,MAAMqF,OAAO,GAAG/E,YAAY,CAACgF,UAAU,CAAC,CAAC;MACzC,IAAI,CAACD,OAAO,EAAE,MAAM,IAAI5E,KAAK,CAAE,GAAE2E,KAAK,CAACrG,QAAQ,CAAC,CAAE,8CAA6C,CAAC;MAChG,MAAMJ,WAAW,GAAG,MAAM,IAAI,CAAChE,SAAS,CAAC4K,kBAAkB,CAACH,KAAK,CAAC;MAClE,IAAI,CAACvJ,SAAS,CAACwJ,OAAO,CAAC,GAAG1G,WAAW;IACvC,CAAC,CACH,CAAC;EACH;EAEA,MAAcjD,eAAeA,CAAA,EAAmC;IAC9D,MAAM,IAAI,CAACmG,YAAY,CAAC,CAAC;IACzB,MAAM2D,KAAK,GAAG,CAAC,GAAGtM,MAAM,CAACD,IAAI,CAAC,IAAI,CAAC4C,SAAS,CAAC,EAAEiC,oBAAO,CAAC;IACvD,MAAM2H,aAAa,GAAGD,KAAK,CAAClE,GAAG,CAAEY,GAAG,IAAK,IAAI,CAAChH,QAAQ,CAACiH,cAAc,CAACD,GAAG,CAAC,CAAC;IAC3E;IACA,MAAMX,kBAAE,CAACmE,SAAS,CAAC,IAAI,CAAC3K,YAAY,CAAC;IACrC0K,aAAa,CAAChM,IAAI,CAAC,IAAI,CAACsB,YAAY,CAAC;IACrC,OAAO0K,aAAa;EACtB;AACF;AAACE,OAAA,CAAAlL,OAAA,GAAAA,OAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CLIMain } from '@teambit/cli';
|
|
2
2
|
import { SlotRegistry } from '@teambit/harmony';
|
|
3
|
+
import { GlobalConfigMain } from '@teambit/global-config';
|
|
3
4
|
import { ScopeMain } from '@teambit/scope';
|
|
4
5
|
import { ComponentID } from '@teambit/component-id';
|
|
5
6
|
import { IpcEventsMain } from '@teambit/ipc-events';
|
|
@@ -16,7 +17,8 @@ export declare class WatcherMain {
|
|
|
16
17
|
private onPreWatchSlot;
|
|
17
18
|
readonly ipcEvents: IpcEventsMain;
|
|
18
19
|
readonly logger: Logger;
|
|
19
|
-
|
|
20
|
+
readonly globalConfig: GlobalConfigMain;
|
|
21
|
+
constructor(workspace: Workspace, scope: ScopeMain, pubsub: PubsubMain, onPreWatchSlot: OnPreWatchSlot, ipcEvents: IpcEventsMain, logger: Logger, globalConfig: GlobalConfigMain);
|
|
20
22
|
watch(opts: WatchOptions): Promise<void>;
|
|
21
23
|
watchScopeInternalFiles(): Promise<void>;
|
|
22
24
|
triggerOnPreWatch(componentIds: ComponentID[], watchOpts: WatchOptions): Promise<void>;
|
|
@@ -24,13 +26,14 @@ export declare class WatcherMain {
|
|
|
24
26
|
static slots: ((registerFn: () => string) => SlotRegistry<OnPreWatch>)[];
|
|
25
27
|
static dependencies: import("@teambit/harmony").Aspect[];
|
|
26
28
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
27
|
-
static provider([cli, workspace, scope, pubsub, loggerMain, ipcEvents]: [
|
|
29
|
+
static provider([cli, workspace, scope, pubsub, loggerMain, ipcEvents, globalConfig]: [
|
|
28
30
|
CLIMain,
|
|
29
31
|
Workspace,
|
|
30
32
|
ScopeMain,
|
|
31
33
|
PubsubMain,
|
|
32
34
|
LoggerMain,
|
|
33
|
-
IpcEventsMain
|
|
35
|
+
IpcEventsMain,
|
|
36
|
+
GlobalConfigMain
|
|
34
37
|
], _: any, [onPreWatchSlot]: [OnPreWatchSlot]): Promise<WatcherMain>;
|
|
35
38
|
}
|
|
36
39
|
export default WatcherMain;
|
|
@@ -28,6 +28,13 @@ function _harmony() {
|
|
|
28
28
|
};
|
|
29
29
|
return data;
|
|
30
30
|
}
|
|
31
|
+
function _globalConfig() {
|
|
32
|
+
const data = _interopRequireDefault(require("@teambit/global-config"));
|
|
33
|
+
_globalConfig = function () {
|
|
34
|
+
return data;
|
|
35
|
+
};
|
|
36
|
+
return data;
|
|
37
|
+
}
|
|
31
38
|
function _scope() {
|
|
32
39
|
const data = _interopRequireDefault(require("@teambit/scope"));
|
|
33
40
|
_scope = function () {
|
|
@@ -92,13 +99,14 @@ function _watcher2() {
|
|
|
92
99
|
return data;
|
|
93
100
|
}
|
|
94
101
|
class WatcherMain {
|
|
95
|
-
constructor(workspace, scope, pubsub, onPreWatchSlot, ipcEvents, logger) {
|
|
102
|
+
constructor(workspace, scope, pubsub, onPreWatchSlot, ipcEvents, logger, globalConfig) {
|
|
96
103
|
this.workspace = workspace;
|
|
97
104
|
this.scope = scope;
|
|
98
105
|
this.pubsub = pubsub;
|
|
99
106
|
this.onPreWatchSlot = onPreWatchSlot;
|
|
100
107
|
this.ipcEvents = ipcEvents;
|
|
101
108
|
this.logger = logger;
|
|
109
|
+
this.globalConfig = globalConfig;
|
|
102
110
|
}
|
|
103
111
|
async watch(opts) {
|
|
104
112
|
const watcher = new (_watcher().Watcher)(this.workspace, this.pubsub, this);
|
|
@@ -117,9 +125,9 @@ class WatcherMain {
|
|
|
117
125
|
this.onPreWatchSlot.register(onPreWatchFunc);
|
|
118
126
|
return this;
|
|
119
127
|
}
|
|
120
|
-
static async provider([cli, workspace, scope, pubsub, loggerMain, ipcEvents], _, [onPreWatchSlot]) {
|
|
128
|
+
static async provider([cli, workspace, scope, pubsub, loggerMain, ipcEvents, globalConfig], _, [onPreWatchSlot]) {
|
|
121
129
|
const logger = loggerMain.createLogger(_watcher2().WatcherAspect.id);
|
|
122
|
-
const watcherMain = new WatcherMain(workspace, scope, pubsub, onPreWatchSlot, ipcEvents, logger);
|
|
130
|
+
const watcherMain = new WatcherMain(workspace, scope, pubsub, onPreWatchSlot, ipcEvents, logger, globalConfig);
|
|
123
131
|
const watchCmd = new (_watch().WatchCommand)(pubsub, logger, watcherMain);
|
|
124
132
|
cli.register(watchCmd);
|
|
125
133
|
return watcherMain;
|
|
@@ -127,7 +135,7 @@ class WatcherMain {
|
|
|
127
135
|
}
|
|
128
136
|
exports.WatcherMain = WatcherMain;
|
|
129
137
|
(0, _defineProperty2().default)(WatcherMain, "slots", [_harmony().Slot.withType()]);
|
|
130
|
-
(0, _defineProperty2().default)(WatcherMain, "dependencies", [_cli().CLIAspect, _workspace().default, _scope().default, _pubsub().PubsubAspect, _logger().LoggerAspect, _ipcEvents().default]);
|
|
138
|
+
(0, _defineProperty2().default)(WatcherMain, "dependencies", [_cli().CLIAspect, _workspace().default, _scope().default, _pubsub().PubsubAspect, _logger().LoggerAspect, _ipcEvents().default, _globalConfig().default]);
|
|
131
139
|
(0, _defineProperty2().default)(WatcherMain, "runtime", _cli().MainRuntime);
|
|
132
140
|
_watcher2().WatcherAspect.addRuntime(WatcherMain);
|
|
133
141
|
var _default = WatcherMain;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_cli","data","require","_harmony","
|
|
1
|
+
{"version":3,"names":["_cli","data","require","_harmony","_globalConfig","_interopRequireDefault","_scope","_ipcEvents","_logger","_pubsub","_workspace","_pMapSeries","_watch","_watcher","_watcher2","WatcherMain","constructor","workspace","scope","pubsub","onPreWatchSlot","ipcEvents","logger","globalConfig","watch","opts","watcher","Watcher","watchAll","watchScopeInternalFiles","triggerOnPreWatch","componentIds","watchOpts","preWatchFunctions","values","pMapSeries","func","registerOnPreWatch","onPreWatchFunc","register","provider","cli","loggerMain","_","createLogger","WatcherAspect","id","watcherMain","watchCmd","WatchCommand","exports","_defineProperty2","default","Slot","withType","CLIAspect","WorkspaceAspect","ScopeAspect","PubsubAspect","LoggerAspect","IpcEventsAspect","GlobalConfigAspect","MainRuntime","addRuntime","_default"],"sources":["watcher.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { SlotRegistry, Slot } from '@teambit/harmony';\nimport GlobalConfigAspect, { GlobalConfigMain } from '@teambit/global-config';\nimport ScopeAspect, { ScopeMain } from '@teambit/scope';\nimport { ComponentID } from '@teambit/component-id';\nimport IpcEventsAspect, { IpcEventsMain } from '@teambit/ipc-events';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { PubsubAspect, PubsubMain } from '@teambit/pubsub';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport pMapSeries from 'p-map-series';\nimport { WatchCommand } from './watch.cmd';\nimport { Watcher, WatchOptions } from './watcher';\nimport { WatcherAspect } from './watcher.aspect';\n\nexport type OnPreWatch = (componentIds: ComponentID[], watchOpts: WatchOptions) => Promise<void>;\nexport type OnPreWatchSlot = SlotRegistry<OnPreWatch>;\n\nexport class WatcherMain {\n constructor(\n private workspace: Workspace,\n private scope: ScopeMain,\n private pubsub: PubsubMain,\n private onPreWatchSlot: OnPreWatchSlot,\n readonly ipcEvents: IpcEventsMain,\n readonly logger: Logger,\n readonly globalConfig: GlobalConfigMain\n ) {}\n\n async watch(opts: WatchOptions) {\n const watcher = new Watcher(this.workspace, this.pubsub, this);\n await watcher.watchAll(opts);\n }\n\n async watchScopeInternalFiles() {\n await this.scope.watchScopeInternalFiles();\n }\n\n async triggerOnPreWatch(componentIds: ComponentID[], watchOpts: WatchOptions) {\n const preWatchFunctions = this.onPreWatchSlot.values();\n await pMapSeries(preWatchFunctions, async (func) => {\n await func(componentIds, watchOpts);\n });\n }\n\n registerOnPreWatch(onPreWatchFunc: OnPreWatch) {\n this.onPreWatchSlot.register(onPreWatchFunc);\n return this;\n }\n\n static slots = [Slot.withType<OnPreWatch>()];\n static dependencies = [\n CLIAspect,\n WorkspaceAspect,\n ScopeAspect,\n PubsubAspect,\n LoggerAspect,\n IpcEventsAspect,\n GlobalConfigAspect,\n ];\n static runtime = MainRuntime;\n\n static async provider(\n [cli, workspace, scope, pubsub, loggerMain, ipcEvents, globalConfig]: [\n CLIMain,\n Workspace,\n ScopeMain,\n PubsubMain,\n LoggerMain,\n IpcEventsMain,\n GlobalConfigMain\n ],\n _,\n [onPreWatchSlot]: [OnPreWatchSlot]\n ) {\n const logger = loggerMain.createLogger(WatcherAspect.id);\n const watcherMain = new WatcherMain(workspace, scope, pubsub, onPreWatchSlot, ipcEvents, logger, globalConfig);\n const watchCmd = new WatchCommand(pubsub, logger, watcherMain);\n cli.register(watchCmd);\n return watcherMain;\n }\n}\n\nWatcherAspect.addRuntime(WatcherMain);\n\nexport default WatcherMain;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,cAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAE,aAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,OAAA;EAAA,MAAAL,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAI,MAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,WAAA;EAAA,MAAAN,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAK,UAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,QAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,OAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,QAAA;EAAA,MAAAR,IAAA,GAAAC,OAAA;EAAAO,OAAA,YAAAA,CAAA;IAAA,OAA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CAACC,QAAQ,CAAa,CAAC,CAAC;AAAA,IAAAH,gBAAA,GAAAC,OAAA,EAhCjCrC,WAAW,kBAiCA,CACpBwC,gBAAS,EACTC,oBAAe,EACfC,gBAAW,EACXC,sBAAY,EACZC,sBAAY,EACZC,oBAAe,EACfC,uBAAkB,CACnB;AAAA,IAAAV,gBAAA,GAAAC,OAAA,EAzCUrC,WAAW,aA0CL+C,kBAAW;AAuB9BjB,yBAAa,CAACkB,UAAU,CAAChD,WAAW,CAAC;AAAC,IAAAiD,QAAA,GAEvBjD,WAAW;AAAAmC,OAAA,CAAAE,OAAA,GAAAY,QAAA"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/watcher",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.151",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/workspace/watcher",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.workspace",
|
|
8
8
|
"name": "watcher",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.151"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
@@ -21,14 +21,15 @@
|
|
|
21
21
|
"@teambit/harmony": "0.4.6",
|
|
22
22
|
"@teambit/component-id": "0.0.427",
|
|
23
23
|
"@teambit/legacy-bit-id": "1.0.0",
|
|
24
|
-
"@teambit/workspace": "0.0.
|
|
25
|
-
"@teambit/cli": "0.0.
|
|
26
|
-
"@teambit/compiler": "0.0.
|
|
27
|
-
"@teambit/logger": "0.0.
|
|
28
|
-
"@teambit/pubsub": "0.0.
|
|
29
|
-
"@teambit/
|
|
30
|
-
"@teambit/
|
|
31
|
-
"@teambit/
|
|
24
|
+
"@teambit/workspace": "0.0.1139",
|
|
25
|
+
"@teambit/cli": "0.0.763",
|
|
26
|
+
"@teambit/compiler": "0.0.1139",
|
|
27
|
+
"@teambit/logger": "0.0.856",
|
|
28
|
+
"@teambit/pubsub": "0.0.1139",
|
|
29
|
+
"@teambit/global-config": "0.0.765",
|
|
30
|
+
"@teambit/ipc-events": "0.0.29",
|
|
31
|
+
"@teambit/scope": "0.0.1139",
|
|
32
|
+
"@teambit/component": "0.0.1139"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@types/fs-extra": "9.0.7",
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
"@types/testing-library__jest-dom": "5.9.5"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
|
-
"@teambit/legacy": "1.0.
|
|
45
|
+
"@teambit/legacy": "1.0.547",
|
|
45
46
|
"react": "^16.8.0 || ^17.0.0",
|
|
46
47
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
47
48
|
},
|
package/.bit-capsule-ready
DELETED
|
File without changes
|
|
Binary file
|
|
File without changes
|