@teambit/watcher 0.0.69 → 0.0.71

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.
@@ -1,7 +1,6 @@
1
1
  import { Command, CommandOptions } from '@teambit/cli';
2
2
  import type { Logger } from '@teambit/logger';
3
3
  import type { PubsubMain } from '@teambit/pubsub';
4
- import { OnComponentEventResult } from '@teambit/workspace';
5
4
  import { WatcherMain } from './watcher.main.runtime';
6
5
  export declare type WatchCmdOpts = {
7
6
  verbose?: boolean;
@@ -21,15 +20,6 @@ export declare class WatchCommand implements Command {
21
20
  * watcher extension.
22
21
  */
23
22
  private watcher;
24
- msgs: {
25
- onAll: (event: string, path: string) => void;
26
- onStart: () => void;
27
- onReady: (workspace: any, watchPathsSortByComponent: any, verbose: any) => void;
28
- onChange: (filePaths: string[], buildResults: OnComponentEventResult[], verbose: boolean, duration: any, failureMsg?: string) => void;
29
- onAdd: (filePaths: string[], buildResults: OnComponentEventResult[], verbose: boolean, duration: any, failureMsg?: string) => void;
30
- onUnlink: (p: any) => void;
31
- onError: (err: any) => void;
32
- };
33
23
  name: string;
34
24
  description: string;
35
25
  helpUrl: string;
package/dist/watch.cmd.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ require("core-js/modules/es.array.iterator.js");
4
5
  require("core-js/modules/es.promise.js");
5
6
  Object.defineProperty(exports, "__esModule", {
6
7
  value: true
@@ -67,49 +68,6 @@ class WatchCommand {
67
68
  this.pubsub = pubsub;
68
69
  this.logger = logger;
69
70
  this.watcher = watcher;
70
- (0, _defineProperty2().default)(this, "msgs", {
71
- onAll: (event, path) => this.logger.console(`Event: "${event}". Path: ${path}`),
72
- onStart: () => {},
73
- onReady: (workspace, watchPathsSortByComponent, verbose) => {
74
- clearOutdatedData();
75
- if (verbose) {
76
- this.logger.console((0, _outputFormatter().formatWatchPathsSortByComponent)(watchPathsSortByComponent));
77
- }
78
- this.logger.console(_chalk().default.yellow(`Watching for component changes in workspace ${workspace.config.name} (${(0, _moment().default)().format('HH:mm:ss')})...\n`));
79
- },
80
- onChange: (filePaths, buildResults, verbose, duration, failureMsg) => {
81
- const files = filePaths.join(', ');
82
- // clearOutdatedData();
83
- if (!buildResults.length) {
84
- failureMsg = failureMsg || `The files ${files} have been changed, but nothing to compile`;
85
- this.logger.console(`${failureMsg}\n\n`);
86
- return;
87
- }
88
- this.logger.console(`The file(s) ${files} have been changed.\n\n`);
89
- this.logger.console((0, _outputFormatter().formatCompileResults)(buildResults, verbose));
90
- this.logger.console(`Finished. (${duration}ms)`);
91
- this.logger.console(_chalk().default.yellow(`Watching for component changes (${(0, _moment().default)().format('HH:mm:ss')})...`));
92
- },
93
- onAdd: (filePaths, buildResults, verbose, duration, failureMsg) => {
94
- const files = filePaths.join(', ');
95
- // clearOutdatedData();
96
- if (!buildResults.length) {
97
- failureMsg = failureMsg || `The files ${files} have been added, but nothing to compile`;
98
- this.logger.console(`${failureMsg}\n\n`);
99
- return;
100
- }
101
- this.logger.console(`The file(s) ${filePaths} have been added.\n\n`);
102
- this.logger.console((0, _outputFormatter().formatCompileResults)(buildResults, verbose));
103
- this.logger.console(`Finished. (${duration}ms)`);
104
- this.logger.console(_chalk().default.yellow(`Watching for component changes (${(0, _moment().default)().format('HH:mm:ss')})...`));
105
- },
106
- onUnlink: p => {
107
- this.logger.console(`file ${p} has been removed`);
108
- },
109
- onError: err => {
110
- this.logger.console(`Watcher error ${err}`);
111
- }
112
- });
113
71
  (0, _defineProperty2().default)(this, "name", 'watch');
114
72
  (0, _defineProperty2().default)(this, "description", 'automatically recompile modified components (on save)');
115
73
  (0, _defineProperty2().default)(this, "helpUrl", 'reference/compiling/compiler-overview');
@@ -150,7 +108,7 @@ class WatchCommand {
150
108
  }
151
109
  };
152
110
  const watchOpts = {
153
- msgs: this.msgs,
111
+ msgs: getMessages(this.logger),
154
112
  verbose,
155
113
  preCompile: !watchCmdOpts.skipPreCompilation,
156
114
  spawnTSServer: Boolean(checkTypes),
@@ -161,11 +119,48 @@ class WatchCommand {
161
119
  return 'watcher terminated';
162
120
  }
163
121
  }
122
+ exports.WatchCommand = WatchCommand;
123
+ function getMessages(logger) {
124
+ return {
125
+ onAll: (event, path) => logger.console(`Event: "${event}". Path: ${path}`),
126
+ onStart: () => {},
127
+ onReady: (workspace, watchPathsSortByComponent, verbose) => {
128
+ clearOutdatedData();
129
+ if (verbose) {
130
+ logger.console((0, _outputFormatter().formatWatchPathsSortByComponent)(watchPathsSortByComponent));
131
+ }
132
+ logger.console(_chalk().default.yellow(`Watching for component changes in workspace ${workspace.config.name} (${(0, _moment().default)().format('HH:mm:ss')})...\n`));
133
+ },
134
+ onChange: (...args) => {
135
+ printOnFileEvent(logger, 'changed', ...args);
136
+ },
137
+ onAdd: (...args) => {
138
+ printOnFileEvent(logger, 'added', ...args);
139
+ },
140
+ onUnlink: (...args) => {
141
+ printOnFileEvent(logger, 'removed', ...args);
142
+ },
143
+ onError: err => {
144
+ logger.console(`Watcher error ${err}`);
145
+ }
146
+ };
147
+ }
148
+ function printOnFileEvent(logger, eventMsgPlaceholder, filePaths, buildResults, verbose, duration, failureMsg) {
149
+ const files = filePaths.join(', ');
150
+ if (!buildResults.length) {
151
+ failureMsg = failureMsg || `The files ${files} have been ${eventMsgPlaceholder}, but nothing to compile`;
152
+ logger.console(`${failureMsg}\n\n`);
153
+ return;
154
+ }
155
+ logger.console(`The file(s) ${files} have been ${eventMsgPlaceholder}.\n\n`);
156
+ logger.console((0, _outputFormatter().formatCompileResults)(buildResults, verbose));
157
+ logger.console(`Finished. (${duration}ms)`);
158
+ logger.console(_chalk().default.yellow(`Watching for component changes (${(0, _moment().default)().format('HH:mm:ss')})...`));
159
+ }
164
160
 
165
161
  /**
166
162
  * with console.clear() all history is deleted from the console. this function preserver the history.
167
163
  */
168
- exports.WatchCommand = WatchCommand;
169
164
  function clearOutdatedData() {
170
165
  process.stdout.write('\x1Bc');
171
166
  }
@@ -1 +1 @@
1
- {"version":3,"names":["WatchCommand","constructor","pubsub","logger","watcher","onAll","event","path","console","onStart","onReady","workspace","watchPathsSortByComponent","verbose","clearOutdatedData","formatWatchPathsSortByComponent","chalk","yellow","config","name","moment","format","onChange","filePaths","buildResults","duration","failureMsg","files","join","length","formatCompileResults","onAdd","onUnlink","p","onError","err","type","CompilerErrorEvent","TYPE","data","error","registerToEvents","sub","CompilerAspect","id","eventsListener","report","cliArgs","watchCmdOpts","checkTypes","getCheckTypesEnum","undefined","CheckTypes","None","EntireProject","ChangedFile","Error","watchOpts","msgs","preCompile","skipPreCompilation","spawnTSServer","Boolean","watch","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 { 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 msgs = {\n onAll: (event: string, path: string) => this.logger.console(`Event: \"${event}\". Path: ${path}`),\n onStart: () => {},\n onReady: (workspace, watchPathsSortByComponent, verbose) => {\n clearOutdatedData();\n if (verbose) {\n this.logger.console(formatWatchPathsSortByComponent(watchPathsSortByComponent));\n }\n this.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: (\n filePaths: string[],\n buildResults: OnComponentEventResult[],\n verbose: boolean,\n duration,\n failureMsg?: string\n ) => {\n const files = filePaths.join(', ');\n // clearOutdatedData();\n if (!buildResults.length) {\n failureMsg = failureMsg || `The files ${files} have been changed, but nothing to compile`;\n this.logger.console(`${failureMsg}\\n\\n`);\n return;\n }\n this.logger.console(`The file(s) ${files} have been changed.\\n\\n`);\n this.logger.console(formatCompileResults(buildResults, verbose));\n this.logger.console(`Finished. (${duration}ms)`);\n this.logger.console(chalk.yellow(`Watching for component changes (${moment().format('HH:mm:ss')})...`));\n },\n onAdd: (\n filePaths: string[],\n buildResults: OnComponentEventResult[],\n verbose: boolean,\n duration,\n failureMsg?: string\n ) => {\n const files = filePaths.join(', ');\n // clearOutdatedData();\n if (!buildResults.length) {\n failureMsg = failureMsg || `The files ${files} have been added, but nothing to compile`;\n this.logger.console(`${failureMsg}\\n\\n`);\n return;\n }\n this.logger.console(`The file(s) ${filePaths} have been added.\\n\\n`);\n this.logger.console(formatCompileResults(buildResults, verbose));\n this.logger.console(`Finished. (${duration}ms)`);\n this.logger.console(chalk.yellow(`Watching for component changes (${moment().format('HH:mm:ss')})...`));\n },\n onUnlink: (p) => {\n this.logger.console(`file ${p} has been removed`);\n },\n onError: (err) => {\n this.logger.console(`Watcher error ${err}`);\n },\n };\n\n name = 'watch';\n description = 'automatically recompile modified components (on save)';\n helpUrl = 'reference/compiling/compiler-overview';\n alias = '';\n group = 'development';\n options = [\n ['v', 'verbose', 'show npm verbose output for inspection and print the stack trace'],\n ['', 'skip-pre-compilation', 'skip the 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: this.msgs,\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\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;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAOA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AALA;;AAcO,MAAMA,YAAY,CAAoB;EA4E3CC,WAAW;EACT;AACJ;AACA;EACYC,MAAkB;EAE1B;AACJ;AACA;EACYC,MAAc;EAEtB;AACJ;AACA;EACYC,OAAoB,EAC5B;IAAA,KAXQF,MAAkB,GAAlBA,MAAkB;IAAA,KAKlBC,MAAc,GAAdA,MAAc;IAAA,KAKdC,OAAoB,GAApBA,OAAoB;IAAA,8CAzFvB;MACLC,KAAK,EAAE,CAACC,KAAa,EAAEC,IAAY,KAAK,IAAI,CAACJ,MAAM,CAACK,OAAO,CA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,CAAC;AAC/B"}
1
+ {"version":3,"names":["WatchCommand","constructor","pubsub","logger","watcher","event","type","CompilerErrorEvent","TYPE","console","data","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","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 helpUrl = 'reference/compiling/compiler-overview';\n alias = '';\n group = 'development';\n options = [\n ['v', 'verbose', 'show npm verbose output for inspection and print the stack trace'],\n ['', 'skip-pre-compilation', 'skip the 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) => {\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;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAOA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AALA;;AAcO,MAAMA,YAAY,CAAoB;EAgB3CC,WAAW;EACT;AACJ;AACA;EACYC,MAAkB;EAE1B;AACJ;AACA;EACYC,MAAc;EAEtB;AACJ;AACA;EACYC,OAAoB,EAC5B;IAAA,KAXQF,MAAkB,GAAlBA,MAAkB;IAAA,KAKlBC,MAAc,GAAdA,MAAc;IAAA,KAKdC,OAAoB,GAApBA,OAAoB;IAAA,8CA7BvB,OAAO;IAAA,qDACA,uDAAuD;IAAA,iDAC3D,uCAAuC;IAAA,+CACzC,EAAE;IAAA,+CACF,aAAa;IAAA,iDACX,CACR,CAAC,GAAG,EAAE,SAAS,EAAE,kEAAkE,CAAC,EACpF,CAAC,EAAE,EAAE,sBAAsB,EAAE,oDAAoD,CAAC,EAClF,CACE,GAAG,EACH,sBAAsB,EACtB,mJAAmJ,CAC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CAACK,MAAM,EAAE;IACxBH,UAAU,GAAGA,UAAU,IAAK,aAAYC,KAAM,cAAaL,mBAAoB,0BAAyB;IACxGvD,MAAM,CAACM,OAAO,CAAE,GAAEqD,UAAW,MAAK,CAAC;IACnC;EACF;EACA3D,MAAM,CAACM,OAAO,CAAE,eAAcsD,KAAM,cAAaL,mBAAoB,OAAM,CAAC;EAC5EvD,MAAM,CAACM,OAAO,CAAC,IAAAyD,uCAAoB,EAACN,YAAY,EAAExC,OAAO,CAAC,CAAC;EAC3DjB,MAAM,CAACM,OAAO,CAAE,cAAaoD,QAAS,KAAI,CAAC;EAC3C1D,MAAM,CAACM,OAAO,CAACoC,gBAAK,CAACC,MAAM,CAAE,mCAAkC,IAAAG,iBAAM,GAAE,CAACC,MAAM,CAAC,UAAU,CAAE,MAAK,CAAC,CAAC;AACpG;;AAEA;AACA;AACA;AACA,SAASP,iBAAiB,GAAG;EAC3BwB,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC,OAAO,CAAC;AAC/B"}
package/dist/watcher.d.ts CHANGED
@@ -6,7 +6,7 @@ import { Consumer } from '@teambit/legacy/dist/consumer';
6
6
  import { ChildProcess } from 'child_process';
7
7
  import { PathLinux } from '@teambit/legacy/dist/utils/path';
8
8
  import { CompilationInitiator } from '@teambit/compiler';
9
- import { Workspace } from '@teambit/workspace';
9
+ import { Workspace, OnComponentEventResult } from '@teambit/workspace';
10
10
  import { CheckTypes } from './check-types';
11
11
  import { WatcherMain } from './watcher.main.runtime';
12
12
  export declare type WatcherProcessData = {
@@ -18,11 +18,12 @@ export declare type EventMessages = {
18
18
  onAll: Function;
19
19
  onStart: Function;
20
20
  onReady: Function;
21
- onChange: Function;
22
- onAdd: Function;
23
- onUnlink: Function;
21
+ onChange: OnFileEventFunc;
22
+ onAdd: OnFileEventFunc;
23
+ onUnlink: OnFileEventFunc;
24
24
  onError: Function;
25
25
  };
26
+ export declare type OnFileEventFunc = (filePaths: string[], buildResults: OnComponentEventResult[], verbose: boolean, duration: number, failureMsg?: string) => void;
26
27
  export declare type WatchOptions = {
27
28
  msgs?: EventMessages;
28
29
  initiator?: CompilationInitiator;
@@ -84,12 +85,6 @@ export declare class Watcher {
84
85
  */
85
86
  private handleChange;
86
87
  private sleep;
87
- /**
88
- * if a file was added/remove, once the component is loaded, it changes .bitmap, and then the
89
- * entire cache is invalidated and the consumer is reloaded.
90
- * when a file just changed, no need to reload the consumer, it is enough to just delete the
91
- * component from the cache (both, workspace and consumer)
92
- */
93
88
  private triggerCompChanges;
94
89
  /**
95
90
  * if .bitmap changed, it's possible that a new component has been added. trigger onComponentAdd.
package/dist/watcher.js CHANGED
@@ -23,6 +23,13 @@ function _defineProperty2() {
23
23
  };
24
24
  return data;
25
25
  }
26
+ function _fsExtra() {
27
+ const data = _interopRequireDefault(require("fs-extra"));
28
+ _fsExtra = function () {
29
+ return data;
30
+ };
31
+ return data;
32
+ }
26
33
  function _path() {
27
34
  const data = require("path");
28
35
  _path = function () {
@@ -173,9 +180,19 @@ class Watcher {
173
180
  msgs === null || msgs === void 0 ? void 0 : msgs.onAdd(files, results, this.verbose, duration, failureMsg);
174
181
  });
175
182
  // eslint-disable-next-line @typescript-eslint/no-misused-promises
176
- watcher.on('unlink', async p => {
177
- msgs === null || msgs === void 0 ? void 0 : msgs.onUnlink(p);
178
- await this.handleChange(p);
183
+ watcher.on('unlink', async filePath => {
184
+ const startTime = new Date().getTime();
185
+ const {
186
+ files,
187
+ results,
188
+ debounced,
189
+ failureMsg
190
+ } = await this.handleChange(filePath, opts === null || opts === void 0 ? void 0 : opts.initiator);
191
+ if (debounced) {
192
+ return;
193
+ }
194
+ const duration = new Date().getTime() - startTime;
195
+ msgs === null || msgs === void 0 ? void 0 : msgs.onUnlink(files, results, this.verbose, duration, failureMsg);
179
196
  });
180
197
  watcher.on('error', err => {
181
198
  msgs === null || msgs === void 0 ? void 0 : msgs.onError(err);
@@ -251,6 +268,7 @@ class Watcher {
251
268
  _loader().default.stop();
252
269
  return {
253
270
  results: [],
271
+ files: [],
254
272
  debounced: true
255
273
  };
256
274
  }
@@ -281,13 +299,6 @@ class Watcher {
281
299
  async sleep(ms) {
282
300
  return new Promise(resolve => setTimeout(resolve, ms));
283
301
  }
284
-
285
- /**
286
- * if a file was added/remove, once the component is loaded, it changes .bitmap, and then the
287
- * entire cache is invalidated and the consumer is reloaded.
288
- * when a file just changed, no need to reload the consumer, it is enough to just delete the
289
- * component from the cache (both, workspace and consumer)
290
- */
291
302
  async triggerCompChanges(componentId, files, initiator) {
292
303
  let updatedComponentId = componentId;
293
304
  if (!(await this.workspace.hasId(componentId))) {
@@ -308,16 +319,19 @@ class Watcher {
308
319
  if (!componentMap) {
309
320
  throw new Error(`unable to find componentMap for ${updatedComponentId.toString()}, make sure this component is in .bitmap`);
310
321
  }
311
- const compFiles = files.filter(filePath => {
322
+ const compFilesRelativeToWorkspace = componentMap.getFilesRelativeToConsumer();
323
+ const [compFiles, nonCompFiles] = (0, _lodash().partition)(files, filePath => {
312
324
  const relativeFile = this.getRelativePathLinux(filePath);
313
- const isCompFile = Boolean(componentMap.getFilesRelativeToConsumer().find(p => p === relativeFile));
314
- return isCompFile;
325
+ return Boolean(compFilesRelativeToWorkspace.find(p => p === relativeFile));
315
326
  });
316
- if (!compFiles.length) {
327
+ // nonCompFiles are either, files that were removed from the filesystem or existing files that are ignored.
328
+ // the compiler takes care of removedFiles differently, e.g. removes dists dir and old symlinks.
329
+ const removedFiles = (0, _lodash().compact)(await Promise.all(nonCompFiles.map(async filePath => (await _fsExtra().default.pathExists(filePath)) ? null : filePath)));
330
+ if (!compFiles.length && !removedFiles.length) {
317
331
  _logger().default.debug(`the following files are part of the component ${componentId.toStringWithoutVersion()} but configured to be ignored:\n${files.join('\n')}'`);
318
332
  return [];
319
333
  }
320
- const buildResults = await this.executeWatchOperationsOnComponent(updatedComponentId, compFiles, true, initiator);
334
+ const buildResults = await this.executeWatchOperationsOnComponent(updatedComponentId, compFiles, removedFiles, true, initiator);
321
335
  return buildResults;
322
336
  }
323
337
 
@@ -333,7 +347,7 @@ class Watcher {
333
347
  const results = [];
334
348
  if (newDirs.length) {
335
349
  this.fsWatcher.add(newDirs);
336
- const addResults = await (0, _pMapSeries().default)(newDirs, async dir => this.executeWatchOperationsOnComponent(this.trackDirs[dir], [], false));
350
+ const addResults = await (0, _pMapSeries().default)(newDirs, async dir => this.executeWatchOperationsOnComponent(this.trackDirs[dir], [], [], false));
337
351
  results.push(...addResults.flat());
338
352
  }
339
353
  if (removedDirs.length) {
@@ -347,7 +361,7 @@ class Watcher {
347
361
  this.pubsub.pub(_workspace().WorkspaceAspect.id, this.creatOnComponentRemovedEvent(componentId.toString()));
348
362
  await this.workspace.triggerOnComponentRemove(componentId);
349
363
  }
350
- async executeWatchOperationsOnComponent(componentId, files, isChange = true, initiator) {
364
+ async executeWatchOperationsOnComponent(componentId, files, removedFiles = [], isChange = true, initiator) {
351
365
  if (this.isComponentWatchedExternally(componentId)) {
352
366
  // update capsule, once done, it automatically triggers the external watcher
353
367
  await this.workspace.get(componentId);
@@ -361,20 +375,7 @@ class Watcher {
361
375
  _logger().default.debug(`running OnComponentAdd hook for ${_chalk().default.bold(idStr)}`);
362
376
  this.pubsub.pub(_workspace().WorkspaceAspect.id, this.creatOnComponentAddEvent(idStr, 'OnComponentAdd'));
363
377
  }
364
-
365
- // the try/catch is probably not needed here because this gets called by `handleChange()` which already has a try/catch
366
- // I left it here commented out for now just in case, but it should be removed as soon as we're more confident
367
-
368
- // let buildResults: OnComponentEventResult[];
369
- // try {
370
- const buildResults = isChange ? await this.workspace.triggerOnComponentChange(componentId, files, initiator) : await this.workspace.triggerOnComponentAdd(componentId);
371
- // } catch (err: any) {
372
- // // do not exit the watch process on errors, just print them
373
- // const msg = `found an issue during onComponentChange or onComponentAdd hooks for ${idStr}`;
374
- // logger.error(msg, err);
375
- // logger.console(`\n${msg}: ${err.message || err}`);
376
- // return [];
377
- // }
378
+ const buildResults = isChange ? await this.workspace.triggerOnComponentChange(componentId, files, removedFiles, initiator) : await this.workspace.triggerOnComponentAdd(componentId);
378
379
  return buildResults;
379
380
  }
380
381
  creatOnComponentRemovedEvent(idStr) {
@@ -1 +1 @@
1
- {"version":3,"names":["DEBOUNCE_WAIT_MS","Watcher","constructor","workspace","pubsub","watcherMain","trackDirs","verbose","multipleWatchers","WatchQueue","consumer","watchAll","opts","msgs","watchOpts","pathsToWatch","getPathsToWatch","componentIds","Object","values","triggerOnPreWatch","createWatcher","watcher","fsWatcher","onStart","scope","watchScopeInternalFiles","Promise","resolve","reject","process","env","BIT_LOG","onAll","on","onReady","loader","stop","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","onIdle","componentId","getComponentIdByPath","logger","debug","compIdStr","toString","changedFilesPerComponent","push","sleep","triggerCompChanges","length","undefined","join","msg","error","console","message","ms","setTimeout","updatedComponentId","hasId","ids","listIds","find","id","isEqual","ignoreVersion","clearComponentCache","component","get","componentMap","state","_consumer","Error","compFiles","filter","relativeFile","getRelativePathLinux","isCompFile","Boolean","getFilesRelativeToConsumer","toStringWithoutVersion","executeWatchOperationsOnComponent","previewsTrackDirs","_reloadConsumer","setTrackDirs","newDirs","difference","keys","removedDirs","addResults","mapSeries","dir","flat","unwatch","executeWatchOperationsOnRemove","chalk","bold","pub","WorkspaceAspect","creatOnComponentRemovedEvent","triggerOnComponentRemove","isChange","isComponentWatchedExternally","idStr","creatOnComponentChangeEvent","creatOnComponentAddEvent","triggerOnComponentChange","triggerOnComponentAdd","OnComponentRemovedEvent","now","hook","OnComponentChangeEvent","OnComponentAddEvent","watcherData","m","_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","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 {\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: 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 watcherMain: WatcherMain,\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.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 // 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 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 (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 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 compFiles = files.filter((filePath) => {\n const relativeFile = this.getRelativePathLinux(filePath);\n const isCompFile = Boolean(componentMap.getFilesRelativeToConsumer().find((p) => p === relativeFile));\n return isCompFile;\n });\n if (!compFiles.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(updatedComponentId, 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 // the try/catch is probably not needed here because this gets called by `handleChange()` which already has a try/catch\n // I left it here commented out for now just in case, but it should be removed as soon as we're more confident\n\n // let buildResults: OnComponentEventResult[];\n // try {\n const 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 for ${idStr}`;\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 pathsAbs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":["DEBOUNCE_WAIT_MS","Watcher","constructor","workspace","pubsub","watcherMain","trackDirs","verbose","multipleWatchers","WatchQueue","consumer","watchAll","opts","msgs","watchOpts","pathsToWatch","getPathsToWatch","componentIds","Object","values","triggerOnPreWatch","createWatcher","watcher","fsWatcher","onStart","scope","watchScopeInternalFiles","Promise","resolve","reject","process","env","BIT_LOG","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","componentId","getComponentIdByPath","logger","debug","compIdStr","toString","changedFilesPerComponent","push","sleep","triggerCompChanges","length","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","newDirs","difference","keys","removedDirs","addResults","mapSeries","dir","flat","unwatch","executeWatchOperationsOnRemove","chalk","bold","pub","WorkspaceAspect","creatOnComponentRemovedEvent","triggerOnComponentRemove","isChange","isComponentWatchedExternally","idStr","creatOnComponentChangeEvent","creatOnComponentAddEvent","triggerOnComponentChange","triggerOnComponentAdd","OnComponentRemovedEvent","now","hook","OnComponentChangeEvent","OnComponentAddEvent","watcherData","m","_legacy","compilerId","trackDir","findTrackDirByFilePathRecursively","pathNormalizeToLinux","getPathRelativeToConsumer","parentDir","dirname","chokidar","watch","ignoreInitial","ignored","path","includes","sep","persistent","useFsEvents","componentsFromBitMap","bitMap","getAllComponents","bitId","rootDir","getRootDir","resolveComponentId","paths","pathsAbsolute","toAbsolutePath"],"sources":["watcher.ts"],"sourcesContent":["import { PubsubMain } from '@teambit/pubsub';\nimport fs from 'fs-extra';\nimport { dirname, sep } 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 constructor(\n private workspace: Workspace,\n private pubsub: PubsubMain,\n private watcherMain: WatcherMain,\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.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 // 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 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 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: string[],\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 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 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 // 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;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;AAUA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA2C;AAAA;AA+B3C,MAAMA,gBAAgB,GAAG,GAAG;AAErB,MAAMC,OAAO,CAAC;EAKnBC,WAAW,CACDC,SAAoB,EACpBC,MAAkB,EAClBC,WAAwB,EACxBC,SAA4C,GAAG,CAAC,CAAC,EACjDC,OAAO,GAAG,KAAK,EACfC,gBAAsC,GAAG,EAAE,EACnD;IAAA,KANQL,SAAoB,GAApBA,SAAoB;IAAA,KACpBC,MAAkB,GAAlBA,MAAkB;IAAA,KAClBC,WAAwB,GAAxBA,WAAwB;IAAA,KACxBC,SAA4C,GAA5CA,SAA4C;IAAA,KAC5CC,OAAO,GAAPA,OAAO;IAAA,KACPC,gBAAsC,GAAtCA,gBAAsC;IAAA;IAAA,kEATwB,CAAC,CAAC;IAAA,oDACrD,KAAIC,wBAAU,GAAE;IAAA,iEACH,KAAK;EAQpC;EAEH,IAAIC,QAAQ,GAAa;IACvB,OAAO,IAAI,CAACP,SAAS,CA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C,MAAOhB,YAAY,IAAK;MAC/C,MAAM0E,KAAK,GAAG1E,YAAY,CAACN,EAAE;MAC7B,MAAMiF,OAAO,GAAG3E,YAAY,CAAC4E,UAAU,EAAE;MACzC,IAAI,CAACD,OAAO,EAAE,MAAM,IAAIxE,KAAK,CAAE,GAAEuE,KAAK,CAACnG,QAAQ,EAAG,8CAA6C,CAAC;MAChG,MAAML,WAAW,GAAG,MAAM,IAAI,CAAC3D,SAAS,CAACsK,kBAAkB,CAACH,KAAK,CAAC;MAClE,IAAI,CAAChK,SAAS,CAACiK,OAAO,CAAC,GAAGzG,WAAW;IACvC,CAAC,CAAC,CACH;EACH;EAEA,MAAc9C,eAAe,GAAmC;IAC9D,MAAM,IAAI,CAACmG,YAAY,EAAE;IACzB,MAAMuD,KAAK,GAAG,CAAC,GAAGxJ,MAAM,CAACoG,IAAI,CAAC,IAAI,CAAChH,SAAS,CAAC,EAAEiD,oBAAO,CAAC;IACvD,MAAMoH,aAAa,GAAGD,KAAK,CAAC9D,GAAG,CAAEc,GAAG,IAAK,IAAI,CAAChH,QAAQ,CAACkK,cAAc,CAAClD,GAAG,CAAC,CAAC;IAC3E,OAAOiD,aAAa;EACtB;AACF;AAAC"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/watcher",
3
- "version": "0.0.69",
3
+ "version": "0.0.71",
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.69"
9
+ "version": "0.0.71"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
@@ -14,20 +14,22 @@
14
14
  "moment": "2.29.4",
15
15
  "p-map-series": "2.1.0",
16
16
  "chokidar": "3.5.1",
17
+ "fs-extra": "10.0.0",
17
18
  "lodash": "4.17.21",
18
19
  "core-js": "^3.0.0",
19
20
  "@babel/runtime": "7.20.0",
20
21
  "@teambit/harmony": "0.4.6",
21
22
  "@teambit/component-id": "0.0.427",
22
23
  "@teambit/legacy-bit-id": "0.0.423",
23
- "@teambit/workspace": "0.0.1057",
24
- "@teambit/cli": "0.0.711",
25
- "@teambit/compiler": "0.0.1057",
26
- "@teambit/logger": "0.0.804",
27
- "@teambit/pubsub": "0.0.1057",
28
- "@teambit/component": "0.0.1057"
24
+ "@teambit/workspace": "0.0.1059",
25
+ "@teambit/cli": "0.0.713",
26
+ "@teambit/compiler": "0.0.1059",
27
+ "@teambit/logger": "0.0.806",
28
+ "@teambit/pubsub": "0.0.1059",
29
+ "@teambit/component": "0.0.1059"
29
30
  },
30
31
  "devDependencies": {
32
+ "@types/fs-extra": "9.0.7",
31
33
  "@types/lodash": "4.14.165",
32
34
  "@types/mocha": "9.1.0",
33
35
  "@types/node": "12.20.4",
@@ -37,7 +39,7 @@
37
39
  "@types/testing-library__jest-dom": "5.9.5"
38
40
  },
39
41
  "peerDependencies": {
40
- "@teambit/legacy": "1.0.491",
42
+ "@teambit/legacy": "1.0.493",
41
43
  "react": "^16.8.0 || ^17.0.0",
42
44
  "react-dom": "^16.8.0 || ^17.0.0"
43
45
  },