@teambit/workspace 0.0.829 → 0.0.832
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/__snapshots__/pick-outdated-pkgs.spec.ts.snap +95 -12
- package/dist/__snapshots__/pick-outdated-pkgs.spec.js.snap +83 -6
- package/dist/__snapshots__/pick-outdated-pkgs.spec.ts.snap +95 -12
- package/dist/bit-map.d.ts +1 -0
- package/dist/bit-map.js +4 -0
- package/dist/bit-map.js.map +1 -1
- package/dist/build-graph-from-fs.js +1 -1
- package/dist/build-graph-from-fs.js.map +1 -1
- package/dist/pick-outdated-pkgs.d.ts +5 -1
- package/dist/pick-outdated-pkgs.js +98 -4
- package/dist/pick-outdated-pkgs.js.map +1 -1
- package/dist/pick-outdated-pkgs.spec.js +57 -0
- package/dist/pick-outdated-pkgs.spec.js.map +1 -1
- package/dist/watch/watcher.js +1 -1
- package/dist/watch/watcher.js.map +1 -1
- package/dist/workspace.js +4 -2
- package/dist/workspace.js.map +1 -1
- package/dist/workspace.provider.js +1 -8
- package/dist/workspace.provider.js.map +1 -1
- package/package-tar/teambit-workspace-0.0.832.tgz +0 -0
- package/package.json +59 -59
- package/{preview-1661609046303.js → preview-1661916601653.js} +2 -2
- package/watch/watcher.ts +2 -5
- package/package-tar/teambit-workspace-0.0.829.tgz +0 -0
|
@@ -16,6 +16,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
exports.makeOutdatedPkgChoices = makeOutdatedPkgChoices;
|
|
17
17
|
exports.pickOutdatedPkgs = pickOutdatedPkgs;
|
|
18
18
|
|
|
19
|
+
function _defineProperty2() {
|
|
20
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
+
|
|
22
|
+
_defineProperty2 = function () {
|
|
23
|
+
return data;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
|
|
19
29
|
function _colorizeSemverDiff() {
|
|
20
30
|
const data = _interopRequireDefault(require("@pnpm/colorize-semver-diff"));
|
|
21
31
|
|
|
@@ -36,6 +46,16 @@ function _semverDiff() {
|
|
|
36
46
|
return data;
|
|
37
47
|
}
|
|
38
48
|
|
|
49
|
+
function _lodash() {
|
|
50
|
+
const data = require("lodash");
|
|
51
|
+
|
|
52
|
+
_lodash = function () {
|
|
53
|
+
return data;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return data;
|
|
57
|
+
}
|
|
58
|
+
|
|
39
59
|
function _table() {
|
|
40
60
|
const data = require("table");
|
|
41
61
|
|
|
@@ -66,6 +86,20 @@ function _enquirer() {
|
|
|
66
86
|
return data;
|
|
67
87
|
}
|
|
68
88
|
|
|
89
|
+
function _semver() {
|
|
90
|
+
const data = _interopRequireDefault(require("semver"));
|
|
91
|
+
|
|
92
|
+
_semver = function () {
|
|
93
|
+
return data;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
return data;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
100
|
+
|
|
101
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
102
|
+
|
|
69
103
|
/**
|
|
70
104
|
* Lets the user pick the packages that should be updated.
|
|
71
105
|
*/
|
|
@@ -130,13 +164,14 @@ const DEP_TYPE_PRIORITY = {
|
|
|
130
164
|
*/
|
|
131
165
|
|
|
132
166
|
function makeOutdatedPkgChoices(outdatedPkgs) {
|
|
133
|
-
|
|
167
|
+
const mergedOutdatedPkgs = mergeOutdatedPkgs(outdatedPkgs);
|
|
168
|
+
mergedOutdatedPkgs.sort((pkg1, pkg2) => {
|
|
134
169
|
if (pkg1.targetField === pkg2.targetField) return pkg1.name.localeCompare(pkg2.name);
|
|
135
170
|
return DEP_TYPE_PRIORITY[pkg1.targetField] - DEP_TYPE_PRIORITY[pkg2.targetField];
|
|
136
171
|
});
|
|
137
|
-
const renderedTable = alignColumns(outdatedPkgsRows(
|
|
172
|
+
const renderedTable = alignColumns(outdatedPkgsRows(mergedOutdatedPkgs));
|
|
138
173
|
const groupedChoices = {};
|
|
139
|
-
|
|
174
|
+
mergedOutdatedPkgs.forEach((outdatedPkg, index) => {
|
|
140
175
|
const context = renderContext(outdatedPkg);
|
|
141
176
|
|
|
142
177
|
if (!groupedChoices[context]) {
|
|
@@ -156,6 +191,55 @@ function makeOutdatedPkgChoices(outdatedPkgs) {
|
|
|
156
191
|
return choices;
|
|
157
192
|
}
|
|
158
193
|
|
|
194
|
+
function mergeOutdatedPkgs(outdatedPkgs) {
|
|
195
|
+
const mergedOutdatedPkgs = {};
|
|
196
|
+
const outdatedPkgsNotFromComponentModel = [];
|
|
197
|
+
|
|
198
|
+
for (const outdatedPkg of outdatedPkgs) {
|
|
199
|
+
if (outdatedPkg.source === 'component-model' && outdatedPkg.componentId) {
|
|
200
|
+
if (!mergedOutdatedPkgs[outdatedPkg.name]) {
|
|
201
|
+
mergedOutdatedPkgs[outdatedPkg.name] = _objectSpread(_objectSpread({}, (0, _lodash().omit)(outdatedPkg, ['componentId'])), {}, {
|
|
202
|
+
source: 'rootPolicy',
|
|
203
|
+
dependentComponents: [outdatedPkg.componentId]
|
|
204
|
+
});
|
|
205
|
+
} else {
|
|
206
|
+
if (mergedOutdatedPkgs[outdatedPkg.name].currentRange !== outdatedPkg.currentRange) {
|
|
207
|
+
mergedOutdatedPkgs[outdatedPkg.name].hasDifferentRanges = true;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
mergedOutdatedPkgs[outdatedPkg.name].currentRange = tryPickLowestRange(mergedOutdatedPkgs[outdatedPkg.name].currentRange, outdatedPkg.currentRange);
|
|
211
|
+
mergedOutdatedPkgs[outdatedPkg.name].dependentComponents.push(outdatedPkg.componentId);
|
|
212
|
+
|
|
213
|
+
if (outdatedPkg.targetField === 'dependencies') {
|
|
214
|
+
mergedOutdatedPkgs[outdatedPkg.name].targetField = outdatedPkg.targetField;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
} else {
|
|
218
|
+
outdatedPkgsNotFromComponentModel.push(outdatedPkg);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return [...Object.values(mergedOutdatedPkgs), ...outdatedPkgsNotFromComponentModel];
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function tryPickLowestRange(range1, range2) {
|
|
226
|
+
if (range1 === '*' || range2 === '*') return '*';
|
|
227
|
+
|
|
228
|
+
try {
|
|
229
|
+
return _semver().default.lt(rangeToVersion(range1), rangeToVersion(range2)) ? range1 : range2;
|
|
230
|
+
} catch (_unused) {
|
|
231
|
+
return '*';
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function rangeToVersion(range) {
|
|
236
|
+
if (range.startsWith('~') || range.startsWith('^')) {
|
|
237
|
+
return range.substring(1);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return range;
|
|
241
|
+
}
|
|
242
|
+
|
|
159
243
|
function renderContext(outdatedPkg) {
|
|
160
244
|
if (outdatedPkg.variantPattern) {
|
|
161
245
|
return `${outdatedPkg.variantPattern} (variant)`;
|
|
@@ -190,10 +274,20 @@ function outdatedPkgsRows(outdatedPkgs) {
|
|
|
190
274
|
change: colorizeChange,
|
|
191
275
|
diff
|
|
192
276
|
});
|
|
193
|
-
return [outdatedPkg.name, _chalk().default.grey(`(${TARGET_FIELD_TO_DEP_TYPE[outdatedPkg.targetField]})`), outdatedPkg.currentRange, '❯', latest];
|
|
277
|
+
return [outdatedPkg.name, _chalk().default.grey(`(${TARGET_FIELD_TO_DEP_TYPE[outdatedPkg.targetField]})`), outdatedPkg.hasDifferentRanges ? '*' : outdatedPkg.currentRange, '❯', latest, outdatedPkg.dependentComponents ? renderDependents(outdatedPkg.dependentComponents) : ' '];
|
|
194
278
|
});
|
|
195
279
|
}
|
|
196
280
|
|
|
281
|
+
function renderDependents(dependentComponents) {
|
|
282
|
+
let result = `because of ${dependentComponents[0]}`;
|
|
283
|
+
|
|
284
|
+
if (dependentComponents.length > 1) {
|
|
285
|
+
result += ` and ${dependentComponents.length - 1} other components`;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return result;
|
|
289
|
+
}
|
|
290
|
+
|
|
197
291
|
function alignColumns(rows) {
|
|
198
292
|
return (0, _table().table)(rows, {
|
|
199
293
|
border: (0, _table().getBorderCharacters)('void'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["pickOutdatedPkgs","outdatedPkgs","updateDependencies","prompt","choices","makeOutdatedPkgChoices","footer","indicator","state","choice","enabled","message","chalk","cyan","green","red","name","pointer","styles","dark","white","em","bgBlack","whiteBright","success","type","validate","value","length","j","down","k","up","result","names","map","cancel","Object","values","filter","updateDependency","DEP_TYPE_PRIORITY","dependencies","devDependencies","peerDependencies","sort","pkg1","pkg2","targetField","localeCompare","renderedTable","alignColumns","outdatedPkgsRows","groupedChoices","forEach","outdatedPkg","index","context","renderContext","push","entries","subChoices","variantPattern","componentId","TARGET_FIELD_TO_DEP_TYPE","change","diff","semverDiff","currentRange","latestRange","colorizeChange","latest","colorizeSemverDiff","grey","rows","table","border","getBorderCharacters","columnDefault","paddingLeft","paddingRight","columns","alignment","drawHorizontalLine","split"],"sources":["pick-outdated-pkgs.ts"],"sourcesContent":["import colorizeSemverDiff from '@pnpm/colorize-semver-diff';\nimport semverDiff from '@pnpm/semver-diff';\nimport { OutdatedPkg } from '@teambit/dependency-resolver';\nimport { getBorderCharacters, table } from 'table';\nimport chalk from 'chalk';\nimport { prompt } from 'enquirer';\n\n/**\n * Lets the user pick the packages that should be updated.\n */\nexport async function pickOutdatedPkgs(outdatedPkgs: OutdatedPkg[]): Promise<OutdatedPkg[]> {\n const { updateDependencies } = (await prompt({\n choices: makeOutdatedPkgChoices(outdatedPkgs),\n footer: '\\nEnter to start updating. Ctrl-c to cancel.',\n indicator: (state: any, choice: any) => ` ${choice.enabled ? '●' : '○'}`,\n message:\n 'Choose which packages to update ' +\n `(Press ${chalk.cyan('<space>')} to select, ` +\n `${chalk.cyan('<a>')} to toggle all, ` +\n `${chalk.cyan('<i>')} to invert selection)\n${chalk.green('Green')} - indicates a semantically safe update\n${chalk.red('Red')} - indicates a semantically breaking change`,\n name: 'updateDependencies',\n pointer: '❯',\n styles: {\n dark: chalk.white,\n em: chalk.bgBlack.whiteBright,\n success: chalk.white,\n },\n type: 'multiselect',\n validate(value: string[]) {\n if (value.length === 0) {\n return 'You must choose at least one package.';\n }\n return true;\n },\n j() {\n return this.down();\n },\n k() {\n return this.up();\n },\n result(names: string[]) {\n // This is needed in order to have the values of the choices in the answer object.\n // Otherwise, only the names of the selected choices would've been included.\n return this.map(names);\n },\n cancel() {\n // By default, canceling the prompt via Ctrl+c throws an empty string.\n // The custom cancel function prevents that behavior.\n // Otherwise, Bit CLI would print an error and confuse users.\n // See related issue: https://github.com/enquirer/enquirer/issues/225\n },\n } as any)) as { updateDependencies: Record<string, string | OutdatedPkg> };\n return Object.values(updateDependencies ?? {}).filter(\n (updateDependency) => typeof updateDependency !== 'string'\n ) as OutdatedPkg[];\n}\n\nconst DEP_TYPE_PRIORITY = {\n dependencies: 0,\n devDependencies: 1,\n peerDependencies: 2,\n};\n\n/**\n * Groups the outdated packages and makes choices for enquirer's prompt.\n */\nexport function makeOutdatedPkgChoices(outdatedPkgs: OutdatedPkg[]) {\n outdatedPkgs.sort((pkg1, pkg2) => {\n if (pkg1.targetField === pkg2.targetField) return pkg1.name.localeCompare(pkg2.name);\n return DEP_TYPE_PRIORITY[pkg1.targetField] - DEP_TYPE_PRIORITY[pkg2.targetField];\n });\n const renderedTable = alignColumns(outdatedPkgsRows(outdatedPkgs));\n const groupedChoices = {};\n outdatedPkgs.forEach((outdatedPkg, index) => {\n const context = renderContext(outdatedPkg);\n if (!groupedChoices[context]) {\n groupedChoices[context] = [];\n }\n groupedChoices[context].push({\n message: renderedTable[index],\n name: outdatedPkg.name,\n value: outdatedPkg,\n });\n });\n const choices = Object.entries(groupedChoices).map(([context, subChoices]) => ({\n message: chalk.cyan(context),\n choices: subChoices,\n }));\n return choices;\n}\n\nfunction renderContext(outdatedPkg: OutdatedPkg) {\n if (outdatedPkg.variantPattern) {\n return `${outdatedPkg.variantPattern} (variant)`;\n }\n if (outdatedPkg.componentId) {\n return `${outdatedPkg.componentId} (component)`;\n }\n return 'Root policies';\n}\n\nconst TARGET_FIELD_TO_DEP_TYPE = {\n devDependencies: 'dev',\n dependencies: 'runtime',\n peerDependencies: 'peer',\n};\n\nfunction outdatedPkgsRows(outdatedPkgs: OutdatedPkg[]) {\n return outdatedPkgs.map((outdatedPkg) => {\n const { change, diff } = semverDiff(outdatedPkg.currentRange, outdatedPkg.latestRange);\n let colorizeChange = change ?? 'breaking';\n if (change === 'feature') {\n colorizeChange = 'fix';\n }\n const latest = colorizeSemverDiff({\n change: colorizeChange,\n diff,\n });\n return [\n outdatedPkg.name,\n chalk.grey(`(${TARGET_FIELD_TO_DEP_TYPE[outdatedPkg.targetField]})`),\n outdatedPkg.currentRange,\n '❯',\n latest,\n ];\n });\n}\n\nfunction alignColumns(rows: string[][]) {\n return table(rows, {\n border: getBorderCharacters('void'),\n columnDefault: {\n paddingLeft: 0,\n paddingRight: 1,\n },\n columns: {\n // This is the current range column\n 2: { alignment: 'right' },\n },\n drawHorizontalLine: () => false,\n }).split('\\n');\n}\n"],"mappings":";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M,KAAK,SAAf,EAA0B;MACxBK,cAAc,GAAG,KAAjB;IACD;;IACD,MAAMC,MAAM,GAAG,IAAAC,6BAAA,EAAmB;MAChCP,MAAM,EAAEK,cADwB;MAEhCJ;IAFgC,CAAnB,CAAf;IAIA,OAAO,CACLX,WAAW,CAACvC,IADP,EAELJ,gBAAA,CAAM6D,IAAN,CAAY,IAAGT,wBAAwB,CAACT,WAAW,CAACP,WAAb,CAA0B,GAAjE,CAFK,EAGLO,WAAW,CAACa,YAHP,EAIL,GAJK,EAKLG,MALK,CAAP;EAOD,CAjBM,CAAP;AAkBD;;AAED,SAASpB,YAAT,CAAsBuB,IAAtB,EAAwC;EACtC,OAAO,IAAAC,cAAA,EAAMD,IAAN,EAAY;IACjBE,MAAM,EAAE,IAAAC,4BAAA,EAAoB,MAApB,CADS;IAEjBC,aAAa,EAAE;MACbC,WAAW,EAAE,CADA;MAEbC,YAAY,EAAE;IAFD,CAFE;IAMjBC,OAAO,EAAE;MACP;MACA,GAAG;QAAEC,SAAS,EAAE;MAAb;IAFI,CANQ;IAUjBC,kBAAkB,EAAE,MAAM;EAVT,CAAZ,EAWJC,KAXI,CAWE,IAXF,CAAP;AAYD"}
|
|
1
|
+
{"version":3,"names":["pickOutdatedPkgs","outdatedPkgs","updateDependencies","prompt","choices","makeOutdatedPkgChoices","footer","indicator","state","choice","enabled","message","chalk","cyan","green","red","name","pointer","styles","dark","white","em","bgBlack","whiteBright","success","type","validate","value","length","j","down","k","up","result","names","map","cancel","Object","values","filter","updateDependency","DEP_TYPE_PRIORITY","dependencies","devDependencies","peerDependencies","mergedOutdatedPkgs","mergeOutdatedPkgs","sort","pkg1","pkg2","targetField","localeCompare","renderedTable","alignColumns","outdatedPkgsRows","groupedChoices","forEach","outdatedPkg","index","context","renderContext","push","entries","subChoices","outdatedPkgsNotFromComponentModel","source","componentId","omit","dependentComponents","currentRange","hasDifferentRanges","tryPickLowestRange","range1","range2","semver","lt","rangeToVersion","range","startsWith","substring","variantPattern","TARGET_FIELD_TO_DEP_TYPE","change","diff","semverDiff","latestRange","colorizeChange","latest","colorizeSemverDiff","grey","renderDependents","rows","table","border","getBorderCharacters","columnDefault","paddingLeft","paddingRight","columns","alignment","drawHorizontalLine","split"],"sources":["pick-outdated-pkgs.ts"],"sourcesContent":["import colorizeSemverDiff from '@pnpm/colorize-semver-diff';\nimport semverDiff from '@pnpm/semver-diff';\nimport { OutdatedPkg } from '@teambit/dependency-resolver';\nimport { omit } from 'lodash';\nimport { getBorderCharacters, table } from 'table';\nimport chalk from 'chalk';\nimport { prompt } from 'enquirer';\nimport semver from 'semver';\n\n/**\n * Lets the user pick the packages that should be updated.\n */\nexport async function pickOutdatedPkgs(outdatedPkgs: OutdatedPkg[]): Promise<MergedOutdatedPkg[]> {\n const { updateDependencies } = (await prompt({\n choices: makeOutdatedPkgChoices(outdatedPkgs),\n footer: '\\nEnter to start updating. Ctrl-c to cancel.',\n indicator: (state: any, choice: any) => ` ${choice.enabled ? '●' : '○'}`,\n message:\n 'Choose which packages to update ' +\n `(Press ${chalk.cyan('<space>')} to select, ` +\n `${chalk.cyan('<a>')} to toggle all, ` +\n `${chalk.cyan('<i>')} to invert selection)\n${chalk.green('Green')} - indicates a semantically safe update\n${chalk.red('Red')} - indicates a semantically breaking change`,\n name: 'updateDependencies',\n pointer: '❯',\n styles: {\n dark: chalk.white,\n em: chalk.bgBlack.whiteBright,\n success: chalk.white,\n },\n type: 'multiselect',\n validate(value: string[]) {\n if (value.length === 0) {\n return 'You must choose at least one package.';\n }\n return true;\n },\n j() {\n return this.down();\n },\n k() {\n return this.up();\n },\n result(names: string[]) {\n // This is needed in order to have the values of the choices in the answer object.\n // Otherwise, only the names of the selected choices would've been included.\n return this.map(names);\n },\n cancel() {\n // By default, canceling the prompt via Ctrl+c throws an empty string.\n // The custom cancel function prevents that behavior.\n // Otherwise, Bit CLI would print an error and confuse users.\n // See related issue: https://github.com/enquirer/enquirer/issues/225\n },\n } as any)) as { updateDependencies: Record<string, string | MergedOutdatedPkg> };\n return Object.values(updateDependencies ?? {}).filter(\n (updateDependency) => typeof updateDependency !== 'string'\n ) as OutdatedPkg[];\n}\n\nconst DEP_TYPE_PRIORITY = {\n dependencies: 0,\n devDependencies: 1,\n peerDependencies: 2,\n};\n\n/**\n * Groups the outdated packages and makes choices for enquirer's prompt.\n */\nexport function makeOutdatedPkgChoices(outdatedPkgs: OutdatedPkg[]) {\n const mergedOutdatedPkgs = mergeOutdatedPkgs(outdatedPkgs);\n mergedOutdatedPkgs.sort((pkg1, pkg2) => {\n if (pkg1.targetField === pkg2.targetField) return pkg1.name.localeCompare(pkg2.name);\n return DEP_TYPE_PRIORITY[pkg1.targetField] - DEP_TYPE_PRIORITY[pkg2.targetField];\n });\n const renderedTable = alignColumns(outdatedPkgsRows(mergedOutdatedPkgs));\n const groupedChoices = {};\n mergedOutdatedPkgs.forEach((outdatedPkg, index) => {\n const context = renderContext(outdatedPkg);\n if (!groupedChoices[context]) {\n groupedChoices[context] = [];\n }\n groupedChoices[context].push({\n message: renderedTable[index],\n name: outdatedPkg.name,\n value: outdatedPkg,\n });\n });\n const choices = Object.entries(groupedChoices).map(([context, subChoices]) => ({\n message: chalk.cyan(context),\n choices: subChoices,\n }));\n return choices;\n}\n\nexport interface MergedOutdatedPkg extends OutdatedPkg {\n dependentComponents?: string[];\n hasDifferentRanges?: boolean;\n}\n\nfunction mergeOutdatedPkgs(outdatedPkgs: OutdatedPkg[]): MergedOutdatedPkg[] {\n const mergedOutdatedPkgs: Record<\n string,\n MergedOutdatedPkg & Required<Pick<MergedOutdatedPkg, 'dependentComponents'>>\n > = {};\n const outdatedPkgsNotFromComponentModel: OutdatedPkg[] = [];\n for (const outdatedPkg of outdatedPkgs) {\n if (outdatedPkg.source === 'component-model' && outdatedPkg.componentId) {\n if (!mergedOutdatedPkgs[outdatedPkg.name]) {\n mergedOutdatedPkgs[outdatedPkg.name] = {\n ...omit(outdatedPkg, ['componentId']),\n source: 'rootPolicy',\n dependentComponents: [outdatedPkg.componentId],\n };\n } else {\n if (mergedOutdatedPkgs[outdatedPkg.name].currentRange !== outdatedPkg.currentRange) {\n mergedOutdatedPkgs[outdatedPkg.name].hasDifferentRanges = true;\n }\n mergedOutdatedPkgs[outdatedPkg.name].currentRange = tryPickLowestRange(\n mergedOutdatedPkgs[outdatedPkg.name].currentRange,\n outdatedPkg.currentRange\n );\n mergedOutdatedPkgs[outdatedPkg.name].dependentComponents.push(outdatedPkg.componentId);\n if (outdatedPkg.targetField === 'dependencies') {\n mergedOutdatedPkgs[outdatedPkg.name].targetField = outdatedPkg.targetField;\n }\n }\n } else {\n outdatedPkgsNotFromComponentModel.push(outdatedPkg);\n }\n }\n return [...Object.values(mergedOutdatedPkgs), ...outdatedPkgsNotFromComponentModel];\n}\n\nfunction tryPickLowestRange(range1: string, range2: string) {\n if (range1 === '*' || range2 === '*') return '*';\n try {\n return semver.lt(rangeToVersion(range1), rangeToVersion(range2)) ? range1 : range2;\n } catch {\n return '*';\n }\n}\n\nfunction rangeToVersion(range: string) {\n if (range.startsWith('~') || range.startsWith('^')) {\n return range.substring(1);\n }\n return range;\n}\n\nfunction renderContext(outdatedPkg: MergedOutdatedPkg) {\n if (outdatedPkg.variantPattern) {\n return `${outdatedPkg.variantPattern} (variant)`;\n }\n if (outdatedPkg.componentId) {\n return `${outdatedPkg.componentId} (component)`;\n }\n return 'Root policies';\n}\n\nconst TARGET_FIELD_TO_DEP_TYPE = {\n devDependencies: 'dev',\n dependencies: 'runtime',\n peerDependencies: 'peer',\n};\n\nfunction outdatedPkgsRows(outdatedPkgs: MergedOutdatedPkg[]) {\n return outdatedPkgs.map((outdatedPkg) => {\n const { change, diff } = semverDiff(outdatedPkg.currentRange, outdatedPkg.latestRange);\n let colorizeChange = change ?? 'breaking';\n if (change === 'feature') {\n colorizeChange = 'fix';\n }\n const latest = colorizeSemverDiff({\n change: colorizeChange,\n diff,\n });\n return [\n outdatedPkg.name,\n chalk.grey(`(${TARGET_FIELD_TO_DEP_TYPE[outdatedPkg.targetField]})`),\n outdatedPkg.hasDifferentRanges ? '*' : outdatedPkg.currentRange,\n '❯',\n latest,\n outdatedPkg.dependentComponents ? renderDependents(outdatedPkg.dependentComponents) : ' ',\n ];\n });\n}\n\nfunction renderDependents(dependentComponents: string[]): string {\n let result = `because of ${dependentComponents[0]}`;\n if (dependentComponents.length > 1) {\n result += ` and ${dependentComponents.length - 1} other components`;\n }\n return result;\n}\n\nfunction alignColumns(rows: string[][]) {\n return table(rows, {\n border: getBorderCharacters('void'),\n columnDefault: {\n paddingLeft: 0,\n paddingRight: 1,\n },\n columns: {\n // This is the current range column\n 2: { alignment: 'right' },\n },\n drawHorizontalLine: () => false,\n }).split('\\n');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;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;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AAEA;AACA;AACA;AACO,eAAeA,gBAAf,CAAgCC,YAAhC,EAA2F;EAChG,MAAM;IAAEC;EAAF,IAA0B,MAAM,IAAAC,kBAAA,EAAO;IAC3CC,OAAO,EAAEC,sBAAsB,CAACJ,YAAD,CADY;IAE3CK,MAAM,EAAE,8CAFmC;IAG3CC,SAAS,EAAE,CAACC,KAAD,EAAaC,MAAb,KAA8B,IAAGA,MAAM,CAACC,OAAP,GAAiB,GAAjB,GAAuB,GAAI,EAH5B;IAI3CC,OAAO,EACL,qCACC,UAASC,gBAAA,CAAMC,IAAN,CAAW,SAAX,CAAsB,cADhC,GAEC,GAAED,gBAAA,CAAMC,IAAN,CAAW,KAAX,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 describe('makeOutdatedPkgChoices', () => {
|
|
|
57
57
|
targetField: 'peerDependencies'
|
|
58
58
|
}]); // @ts-ignore
|
|
59
59
|
|
|
60
|
+
expect(choices).toMatchSnapshot();
|
|
61
|
+
});
|
|
62
|
+
it('should group component model updates of the same dependency', () => {
|
|
63
|
+
const choices = (0, _pickOutdatedPkgs().makeOutdatedPkgChoices)([{
|
|
64
|
+
name: 'foo',
|
|
65
|
+
currentRange: '1.0.0',
|
|
66
|
+
latestRange: '2.0.0',
|
|
67
|
+
source: 'component-model',
|
|
68
|
+
componentId: 'comp1',
|
|
69
|
+
targetField: 'devDependencies'
|
|
70
|
+
}, {
|
|
71
|
+
name: 'foo',
|
|
72
|
+
currentRange: '1.1.0',
|
|
73
|
+
latestRange: '2.0.0',
|
|
74
|
+
source: 'component-model',
|
|
75
|
+
componentId: 'comp2',
|
|
76
|
+
targetField: 'dependencies'
|
|
77
|
+
}]); // @ts-ignore
|
|
78
|
+
|
|
79
|
+
expect(choices).toMatchSnapshot();
|
|
80
|
+
});
|
|
81
|
+
it("should group component model updates of the same dependency and use * as current range when can't compare ranges", () => {
|
|
82
|
+
const choices = (0, _pickOutdatedPkgs().makeOutdatedPkgChoices)([{
|
|
83
|
+
name: 'foo',
|
|
84
|
+
currentRange: '<=10.0.0',
|
|
85
|
+
latestRange: '2.0.0',
|
|
86
|
+
source: 'component-model',
|
|
87
|
+
componentId: 'comp1',
|
|
88
|
+
targetField: 'dependencies'
|
|
89
|
+
}, {
|
|
90
|
+
name: 'foo',
|
|
91
|
+
currentRange: '1.1.0',
|
|
92
|
+
latestRange: '2.0.0',
|
|
93
|
+
source: 'component-model',
|
|
94
|
+
componentId: 'comp2',
|
|
95
|
+
targetField: 'dependencies'
|
|
96
|
+
}]); // @ts-ignore
|
|
97
|
+
|
|
98
|
+
expect(choices).toMatchSnapshot();
|
|
99
|
+
});
|
|
100
|
+
it('should group component model updates of the same dependency and display the current range when all components use the same range', () => {
|
|
101
|
+
const choices = (0, _pickOutdatedPkgs().makeOutdatedPkgChoices)([{
|
|
102
|
+
name: 'foo',
|
|
103
|
+
currentRange: '^1.2.3',
|
|
104
|
+
latestRange: '2.0.0',
|
|
105
|
+
source: 'component-model',
|
|
106
|
+
componentId: 'comp1',
|
|
107
|
+
targetField: 'dependencies'
|
|
108
|
+
}, {
|
|
109
|
+
name: 'foo',
|
|
110
|
+
currentRange: '^1.2.3',
|
|
111
|
+
latestRange: '2.0.0',
|
|
112
|
+
source: 'component-model',
|
|
113
|
+
componentId: 'comp2',
|
|
114
|
+
targetField: 'dependencies'
|
|
115
|
+
}]); // @ts-ignore
|
|
116
|
+
|
|
60
117
|
expect(choices).toMatchSnapshot();
|
|
61
118
|
});
|
|
62
119
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["describe","it","choices","makeOutdatedPkgChoices","name","currentRange","latestRange","source","targetField","expect","toMatchSnapshot","componentId","variantPattern"],"sources":["pick-outdated-pkgs.spec.ts"],"sourcesContent":["import { makeOutdatedPkgChoices } from './pick-outdated-pkgs';\n\ndescribe('makeOutdatedPkgChoices', () => {\n it('should render choices in correct order', () => {\n const choices = makeOutdatedPkgChoices([\n {\n name: 'zoo',\n currentRange: '1.0.0',\n latestRange: '1.1.0',\n source: 'rootPolicy',\n targetField: 'devDependencies',\n },\n {\n name: 'qar',\n currentRange: '1.0.0',\n latestRange: '1.1.0',\n source: 'rootPolicy',\n targetField: 'dependencies',\n },\n {\n name: 'foo',\n currentRange: '1.0.0',\n latestRange: '2.0.0',\n source: 'rootPolicy',\n targetField: 'dependencies',\n },\n {\n name: 'bar',\n currentRange: '1.0.0',\n latestRange: '1.1.0',\n source: 'rootPolicy',\n targetField: 'peerDependencies',\n },\n ]);\n // @ts-ignore\n expect(choices).toMatchSnapshot();\n });\n it('should render choices with context information', () => {\n const choices = makeOutdatedPkgChoices([\n {\n name: 'foo',\n currentRange: '1.0.0',\n latestRange: '2.0.0',\n source: 'component',\n componentId: 'comp1',\n targetField: 'dependencies',\n },\n {\n name: 'bar',\n currentRange: '1.0.0',\n latestRange: '1.1.0',\n source: 'variants',\n variantPattern: '{comp2}',\n targetField: 'peerDependencies',\n },\n ]);\n // @ts-ignore\n expect(choices).toMatchSnapshot();\n });\n});\n"],"mappings":";;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEAA,QAAQ,CAAC,wBAAD,EAA2B,MAAM;EACvCC,EAAE,CAAC,wCAAD,EAA2C,MAAM;IACjD,MAAMC,OAAO,GAAG,IAAAC,0CAAA,EAAuB,CACrC;MACEC,IAAI,EAAE,KADR;MAEEC,YAAY,EAAE,OAFhB;MAGEC,WAAW,EAAE,OAHf;MAIEC,MAAM,EAAE,YAJV;MAKEC,WAAW,EAAE;IALf,CADqC,EAQrC;MACEJ,IAAI,EAAE,KADR;MAEEC,YAAY,EAAE,OAFhB;MAGEC,WAAW,EAAE,OAHf;MAIEC,MAAM,EAAE,YAJV;MAKEC,WAAW,EAAE;IALf,CARqC,EAerC;MACEJ,IAAI,EAAE,KADR;MAEEC,YAAY,EAAE,OAFhB;MAGEC,WAAW,EAAE,OAHf;MAIEC,MAAM,EAAE,YAJV;MAKEC,WAAW,EAAE;IALf,CAfqC,EAsBrC;MACEJ,IAAI,EAAE,KADR;MAEEC,YAAY,EAAE,OAFhB;MAGEC,WAAW,EAAE,OAHf;MAIEC,MAAM,EAAE,YAJV;MAKEC,WAAW,EAAE;IALf,CAtBqC,CAAvB,CAAhB,CADiD,CA+BjD;;IACAC,MAAM,CAACP,OAAD,CAAN,CAAgBQ,eAAhB;EACD,CAjCC,CAAF;EAkCAT,EAAE,CAAC,gDAAD,EAAmD,MAAM;IACzD,MAAMC,OAAO,GAAG,IAAAC,0CAAA,EAAuB,CACrC;MACEC,IAAI,EAAE,KADR;MAEEC,YAAY,EAAE,OAFhB;MAGEC,WAAW,EAAE,OAHf;MAIEC,MAAM,EAAE,WAJV;MAKEI,WAAW,EAAE,OALf;MAMEH,WAAW,EAAE;IANf,CADqC,EASrC;MACEJ,IAAI,EAAE,KADR;MAEEC,YAAY,EAAE,OAFhB;MAGEC,WAAW,EAAE,OAHf;MAIEC,MAAM,EAAE,UAJV;MAKEK,cAAc,EAAE,SALlB;MAMEJ,WAAW,EAAE;IANf,CATqC,CAAvB,CAAhB,CADyD,CAmBzD;;IACAC,MAAM,CAACP,OAAD,CAAN,CAAgBQ,eAAhB;EACD,CArBC,CAAF;AAsBD,
|
|
1
|
+
{"version":3,"names":["describe","it","choices","makeOutdatedPkgChoices","name","currentRange","latestRange","source","targetField","expect","toMatchSnapshot","componentId","variantPattern"],"sources":["pick-outdated-pkgs.spec.ts"],"sourcesContent":["import { makeOutdatedPkgChoices } from './pick-outdated-pkgs';\n\ndescribe('makeOutdatedPkgChoices', () => {\n it('should render choices in correct order', () => {\n const choices = makeOutdatedPkgChoices([\n {\n name: 'zoo',\n currentRange: '1.0.0',\n latestRange: '1.1.0',\n source: 'rootPolicy',\n targetField: 'devDependencies',\n },\n {\n name: 'qar',\n currentRange: '1.0.0',\n latestRange: '1.1.0',\n source: 'rootPolicy',\n targetField: 'dependencies',\n },\n {\n name: 'foo',\n currentRange: '1.0.0',\n latestRange: '2.0.0',\n source: 'rootPolicy',\n targetField: 'dependencies',\n },\n {\n name: 'bar',\n currentRange: '1.0.0',\n latestRange: '1.1.0',\n source: 'rootPolicy',\n targetField: 'peerDependencies',\n },\n ]);\n // @ts-ignore\n expect(choices).toMatchSnapshot();\n });\n it('should render choices with context information', () => {\n const choices = makeOutdatedPkgChoices([\n {\n name: 'foo',\n currentRange: '1.0.0',\n latestRange: '2.0.0',\n source: 'component',\n componentId: 'comp1',\n targetField: 'dependencies',\n },\n {\n name: 'bar',\n currentRange: '1.0.0',\n latestRange: '1.1.0',\n source: 'variants',\n variantPattern: '{comp2}',\n targetField: 'peerDependencies',\n },\n ]);\n // @ts-ignore\n expect(choices).toMatchSnapshot();\n });\n it('should group component model updates of the same dependency', () => {\n const choices = makeOutdatedPkgChoices([\n {\n name: 'foo',\n currentRange: '1.0.0',\n latestRange: '2.0.0',\n source: 'component-model',\n componentId: 'comp1',\n targetField: 'devDependencies',\n },\n {\n name: 'foo',\n currentRange: '1.1.0',\n latestRange: '2.0.0',\n source: 'component-model',\n componentId: 'comp2',\n targetField: 'dependencies',\n },\n ]);\n // @ts-ignore\n expect(choices).toMatchSnapshot();\n });\n it(\"should group component model updates of the same dependency and use * as current range when can't compare ranges\", () => {\n const choices = makeOutdatedPkgChoices([\n {\n name: 'foo',\n currentRange: '<=10.0.0',\n latestRange: '2.0.0',\n source: 'component-model',\n componentId: 'comp1',\n targetField: 'dependencies',\n },\n {\n name: 'foo',\n currentRange: '1.1.0',\n latestRange: '2.0.0',\n source: 'component-model',\n componentId: 'comp2',\n targetField: 'dependencies',\n },\n ]);\n // @ts-ignore\n expect(choices).toMatchSnapshot();\n });\n it('should group component model updates of the same dependency and display the current range when all components use the same range', () => {\n const choices = makeOutdatedPkgChoices([\n {\n name: 'foo',\n currentRange: '^1.2.3',\n latestRange: '2.0.0',\n source: 'component-model',\n componentId: 'comp1',\n targetField: 'dependencies',\n },\n {\n name: 'foo',\n currentRange: '^1.2.3',\n latestRange: '2.0.0',\n source: 'component-model',\n componentId: 'comp2',\n targetField: 'dependencies',\n },\n ]);\n // @ts-ignore\n expect(choices).toMatchSnapshot();\n });\n});\n"],"mappings":";;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEAA,QAAQ,CAAC,wBAAD,EAA2B,MAAM;EACvCC,EAAE,CAAC,wCAAD,EAA2C,MAAM;IACjD,MAAMC,OAAO,GAAG,IAAAC,0CAAA,EAAuB,CACrC;MACEC,IAAI,EAAE,KADR;MAEEC,YAAY,EAAE,OAFhB;MAGEC,WAAW,EAAE,OAHf;MAIEC,MAAM,EAAE,YAJV;MAKEC,WAAW,EAAE;IALf,CADqC,EAQrC;MACEJ,IAAI,EAAE,KADR;MAEEC,YAAY,EAAE,OAFhB;MAGEC,WAAW,EAAE,OAH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D,CA3HO,CAAR"}
|
package/dist/watch/watcher.js
CHANGED
|
@@ -538,7 +538,7 @@ class Watcher {
|
|
|
538
538
|
|
|
539
539
|
async setTrackDirs() {
|
|
540
540
|
this.trackDirs = {};
|
|
541
|
-
const componentsFromBitMap = this.consumer.bitMap.getAllComponents(
|
|
541
|
+
const componentsFromBitMap = this.consumer.bitMap.getAllComponents();
|
|
542
542
|
await Promise.all(componentsFromBitMap.map(async componentMap => {
|
|
543
543
|
const bitId = componentMap.id;
|
|
544
544
|
const rootDir = componentMap.getRootDir();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DEBOUNCE_WAIT_MS","Watcher","constructor","workspace","pubsub","trackDirs","verbose","multipleWatchers","WatchQueue","consumer","watchAll","opts","msgs","watchOpts","pathsToWatch","getPathsToWatch","componentIds","Object","values","triggerOnPreWatch","createWatcher","watcher","fsWatcher","onStart","Promise","resolve","reject","process","env","BIT_LOG","onAll","on","onReady","filePath","startTime","Date","getTime","files","results","debounced","failureMsg","handleChange","initiator","duration","onChange","onAdd","p","onUnlink","err","onError","endsWith","BIT_MAP","bitMapChangesInProgress","buildResults","watchQueue","add","handleBitmapChanges","loader","stop","onIdle","componentId","getComponentIdByPath","logger","debug","compIdStr","toString","changedFilesPerComponent","push","sleep","triggerCompChanges","length","undefined","join","msg","error","console","message","ms","setTimeout","clearComponentCache","component","get","componentMap","state","_consumer","compFiles","filter","relativeFile","getRelativePathLinux","isCompFile","Boolean","getFilesRelativeToConsumer","find","executeWatchOperationsOnComponent","previewsTrackDirs","_reloadConsumer","setTrackDirs","newDirs","difference","keys","removedDirs","addResults","mapSeries","dir","flat","unwatch","executeWatchOperationsOnRemove","chalk","bold","pub","WorkspaceAspect","id","creatOnComponentRemovedEvent","triggerOnComponentRemove","isChange","isComponentWatchedExternally","idStr","creatOnComponentChangeEvent","creatOnComponentAddEvent","triggerOnComponentChange","triggerOnComponentAdd","OnComponentRemovedEvent","now","hook","OnComponentChangeEvent","OnComponentAddEvent","watcherData","m","isEqual","_legacy","compilerId","trackDir","findTrackDirByFilePathRecursively","pathNormalizeToLinux","getPathRelativeToConsumer","parentDir","dirname","chokidar","watch","ignoreInitial","ignored","path","includes","sep","persistent","useFsEvents","componentsFromBitMap","bitMap","getAllComponents","COMPONENT_ORIGINS","AUTHORED","IMPORTED","all","map","bitId","rootDir","getRootDir","Error","resolveComponentId","paths","pathsAbsolute","toAbsolutePath"],"sources":["watcher.ts"],"sourcesContent":["import { PubsubMain } from '@teambit/pubsub';\nimport { dirname, sep } from 'path';\nimport { difference } from 'lodash';\nimport { ComponentID } from '@teambit/component';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport loader from '@teambit/legacy/dist/cli/loader';\nimport { BIT_MAP, COMPONENT_ORIGINS } from '@teambit/legacy/dist/constants';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport logger from '@teambit/legacy/dist/logger/logger';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport mapSeries from 'p-map-series';\nimport chalk from 'chalk';\nimport { ChildProcess } from 'child_process';\nimport chokidar, { FSWatcher } from 'chokidar';\nimport ComponentMap from '@teambit/legacy/dist/consumer/bit-map/component-map';\nimport { PathLinux, PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';\nimport { CompilationInitiator } from '@teambit/compiler';\nimport { WorkspaceAspect } from '../';\nimport { OnComponentChangeEvent, OnComponentAddEvent, OnComponentRemovedEvent } from '../events';\nimport { Workspace } from '../workspace';\nimport { OnComponentEventResult } from '../on-component-events';\nimport { CheckTypes } from './check-types';\nimport { WatchQueue } from './watch-queue';\n\nexport type WatcherProcessData = { watchProcess: ChildProcess; compilerId: BitId; componentIds: BitId[] };\n\nexport type EventMessages = {\n onAll: Function;\n onStart: Function;\n onReady: Function;\n onChange: Function;\n onAdd: Function;\n onUnlink: Function;\n onError: Function;\n};\n\nexport type WatchOptions = {\n msgs?: EventMessages;\n initiator?: CompilationInitiator;\n verbose?: boolean; // print watch events to the console. (also ts-server events if spawnTSServer is true)\n spawnTSServer?: boolean; // needed for check types and extract API/docs.\n checkTypes?: CheckTypes; // if enabled, the spawnTSServer becomes true.\n preCompile?: boolean; // whether compile all components before start watching\n};\n\nconst DEBOUNCE_WAIT_MS = 100;\n\nexport class Watcher {\n private fsWatcher: FSWatcher;\n private changedFilesPerComponent: { [componentId: string]: string[] } = {};\n private watchQueue = new WatchQueue();\n private bitMapChangesInProgress = false;\n constructor(\n private workspace: Workspace,\n private pubsub: PubsubMain,\n private trackDirs: { [dir: PathLinux]: ComponentID } = {},\n private verbose = false,\n private multipleWatchers: WatcherProcessData[] = []\n ) {}\n\n get consumer(): Consumer {\n return this.workspace.consumer;\n }\n\n async watchAll(opts: WatchOptions) {\n const { msgs, ...watchOpts } = opts;\n // TODO: run build in the beginning of process (it's work like this in other envs)\n const pathsToWatch = await this.getPathsToWatch();\n const componentIds = Object.values(this.trackDirs);\n await this.workspace.triggerOnPreWatch(componentIds, watchOpts);\n await this.createWatcher(pathsToWatch);\n const watcher = this.fsWatcher;\n msgs?.onStart(this.workspace);\n\n return new Promise((resolve, reject) => {\n // prefix your command with \"BIT_LOG=*\" to see all watch events\n if (process.env.BIT_LOG) {\n // @ts-ignore\n if (msgs?.onAll) watcher.on('all', msgs?.onAll);\n }\n watcher.on('ready', () => {\n msgs?.onReady(this.workspace, this.trackDirs, this.verbose);\n });\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n watcher.on('change', async (filePath) => {\n const startTime = new Date().getTime();\n const { files, results, debounced, failureMsg } = await this.handleChange(filePath, opts?.initiator);\n if (debounced) {\n return;\n }\n const duration = new Date().getTime() - startTime;\n msgs?.onChange(files, results, this.verbose, duration, failureMsg);\n });\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n watcher.on('add', async (filePath) => {\n const startTime = new Date().getTime();\n const { files, results, debounced, failureMsg } = await this.handleChange(filePath, opts?.initiator);\n if (debounced) {\n return;\n }\n const duration = new Date().getTime() - startTime;\n msgs?.onAdd(files, results, this.verbose, duration, failureMsg);\n });\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n watcher.on('unlink', async (p) => {\n msgs?.onUnlink(p);\n await this.handleChange(p);\n });\n watcher.on('error', (err) => {\n msgs?.onError(err);\n reject(err);\n });\n });\n }\n\n /**\n * *** DEBOUNCING ***\n * some actions trigger multiple files changes at (almost) the same time. e.g. \"git pull\".\n * this causes some performance and instability issues. a debouncing mechanism was implemented to help with this.\n * the way how it works is that the first file of the same component starts the execution with a delay (e.g. 200ms).\n * if, in the meanwhile, another file of the same component was changed, it won't start a new execution, instead,\n * it'll only add the file to `this.changedFilesPerComponent` prop.\n * once the execution starts, it'll delete this component-id from the `this.changedFilesPerComponent` array,\n * indicating the next file-change to start a new execution.\n *\n * implementation wise, `lodash.debounce` doesn't help here, because:\n * A) it doesn't return the results, unless \"leading\" option is true. here, it must be false, otherwise, it'll start\n * the execution immediately.\n * B) it debounces the method regardless the param passes to it. so it'll disregard the component-id and will delay\n * other components undesirably.\n *\n * *** QUEUE ***\n * the debouncing helps to not execute the same component multiple times concurrently. however, multiple components\n * and .bitmap changes execution can still be processed concurrently.\n * the following example explains why this is an issue.\n * compA is changed in the .bitmap file from version 0.0.1 to 0.0.2. its files were changed as well.\n * all these changes get pulled at the same time by \"git pull\", as a result, the execution of compA and the .bitmap\n * happen at the same time.\n * during the execution of compA, the component id is parsed as compA@0.0.1, later, it asks for the Workspace for this\n * id. while the workspace is looking for this id, the .bitmap execution reloaded the consumer and changed all versions.\n * after this change, the workspace doesn't have this id anymore, which will trigger an error.\n * to ensure this won't happen, we keep a flag to indicate whether the .bitmap execution is running, and if so, all\n * other executions are paused until the queue is empty (this is done by awaiting for queue.onIdle).\n * once the queue is empty, we know the .bitmap process was done and the workspace has all new ids.\n * in the example above, at this stage, the id will be resolved to compA@0.0.2.\n * one more thing, the queue is configured to have concurrency of 1. to make sure two components are not processed at\n * the same time. (the same way is done when loading all components from the filesystem/scope).\n * this way we can also ensure that if compA was started before the .bitmap execution, it will complete before the\n * .bitmap execution starts.\n */\n private async handleChange(\n filePath: string,\n initiator?: CompilationInitiator\n ): Promise<{\n results: OnComponentEventResult[];\n files?: string[];\n failureMsg?: string;\n debounced?: boolean;\n }> {\n try {\n if (filePath.endsWith(BIT_MAP)) {\n this.bitMapChangesInProgress = true;\n const buildResults = await this.watchQueue.add(() => this.handleBitmapChanges());\n this.bitMapChangesInProgress = false;\n loader.stop();\n return { results: buildResults, files: [filePath] };\n }\n if (this.bitMapChangesInProgress) {\n await this.watchQueue.onIdle();\n }\n const componentId = this.getComponentIdByPath(filePath);\n if (!componentId) {\n const failureMsg = `file ${filePath} is not part of any component, ignoring it`;\n logger.debug(failureMsg);\n loader.stop();\n return { results: [], files: [filePath], failureMsg };\n }\n const compIdStr = componentId.toString();\n if (this.changedFilesPerComponent[compIdStr]) {\n this.changedFilesPerComponent[compIdStr].push(filePath);\n loader.stop();\n return { results: [], debounced: true };\n }\n this.changedFilesPerComponent[compIdStr] = [filePath];\n await this.sleep(DEBOUNCE_WAIT_MS);\n const files = this.changedFilesPerComponent[compIdStr];\n delete this.changedFilesPerComponent[compIdStr];\n\n const buildResults = await this.watchQueue.add(() => this.triggerCompChanges(componentId, files, initiator));\n const failureMsg = buildResults.length\n ? undefined\n : `files ${files.join(', ')} are inside the component ${compIdStr} but configured to be ignored`;\n loader.stop();\n return { results: buildResults, files, failureMsg };\n } catch (err: any) {\n const msg = `watcher found an error while handling ${filePath}`;\n logger.error(msg, err);\n logger.console(`${msg}, ${err.message}`);\n loader.stop();\n return { results: [], files: [filePath], failureMsg: err.message };\n }\n }\n\n private async sleep(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n /**\n * if a file was added/remove, once the component is loaded, it changes .bitmap, and then the\n * entire cache is invalidated and the consumer is reloaded.\n * when a file just changed, no need to reload the consumer, it is enough to just delete the\n * component from the cache (both, workspace and consumer)\n */\n private async triggerCompChanges(\n componentId: ComponentID,\n files: string[],\n initiator?: CompilationInitiator\n ): Promise<OnComponentEventResult[]> {\n this.workspace.clearComponentCache(componentId);\n const component = await this.workspace.get(componentId);\n const componentMap: ComponentMap = component.state._consumer.componentMap;\n const compFiles = files.filter((filePath) => {\n const relativeFile = this.getRelativePathLinux(filePath);\n const isCompFile = Boolean(componentMap.getFilesRelativeToConsumer().find((p) => p === relativeFile));\n if (!isCompFile) {\n logger.debug(`file ${filePath} is inside the component ${componentId.toString()} but configured to be ignored`);\n }\n return isCompFile;\n });\n if (!compFiles.length) {\n return [];\n }\n const buildResults = await this.executeWatchOperationsOnComponent(componentId, compFiles, true, initiator);\n return buildResults;\n }\n\n /**\n * if .bitmap changed, it's possible that a new component has been added. trigger onComponentAdd.\n */\n private async handleBitmapChanges(): Promise<OnComponentEventResult[]> {\n const previewsTrackDirs = { ...this.trackDirs };\n await this.workspace._reloadConsumer();\n await this.setTrackDirs();\n const newDirs: string[] = difference(Object.keys(this.trackDirs), Object.keys(previewsTrackDirs));\n const removedDirs: string[] = difference(Object.keys(previewsTrackDirs), Object.keys(this.trackDirs));\n const results: OnComponentEventResult[] = [];\n if (newDirs.length) {\n this.fsWatcher.add(newDirs);\n const addResults = await mapSeries(newDirs, async (dir) =>\n this.executeWatchOperationsOnComponent(this.trackDirs[dir], [], false)\n );\n results.push(...addResults.flat());\n }\n if (removedDirs.length) {\n await this.fsWatcher.unwatch(removedDirs);\n await mapSeries(removedDirs, (dir) => this.executeWatchOperationsOnRemove(previewsTrackDirs[dir]));\n }\n return results;\n }\n\n private async executeWatchOperationsOnRemove(componentId: ComponentID) {\n logger.debug(`running OnComponentRemove hook for ${chalk.bold(componentId.toString())}`);\n this.pubsub.pub(WorkspaceAspect.id, this.creatOnComponentRemovedEvent(componentId.toString()));\n await this.workspace.triggerOnComponentRemove(componentId);\n }\n\n private async executeWatchOperationsOnComponent(\n componentId: ComponentID,\n files: string[],\n isChange = true,\n initiator?: CompilationInitiator\n ): Promise<OnComponentEventResult[]> {\n if (this.isComponentWatchedExternally(componentId)) {\n // update capsule, once done, it automatically triggers the external watcher\n await this.workspace.get(componentId);\n return [];\n }\n const idStr = componentId.toString();\n\n if (isChange) {\n logger.debug(`running OnComponentChange hook for ${chalk.bold(idStr)}`);\n this.pubsub.pub(WorkspaceAspect.id, this.creatOnComponentChangeEvent(idStr, 'OnComponentChange'));\n } else {\n logger.debug(`running OnComponentAdd hook for ${chalk.bold(idStr)}`);\n this.pubsub.pub(WorkspaceAspect.id, this.creatOnComponentAddEvent(idStr, 'OnComponentAdd'));\n }\n\n let buildResults: OnComponentEventResult[];\n try {\n buildResults = isChange\n ? await this.workspace.triggerOnComponentChange(componentId, files, initiator)\n : await this.workspace.triggerOnComponentAdd(componentId);\n } catch (err: any) {\n // do not exit the watch process on errors, just print them\n const msg = `found an issue during onComponentChange or onComponentAdd hooks`;\n logger.error(msg, err);\n logger.console(`\\n${msg}: ${err.message || err}`);\n return [];\n }\n return buildResults;\n }\n\n private creatOnComponentRemovedEvent(idStr) {\n return new OnComponentRemovedEvent(Date.now(), idStr);\n }\n\n private creatOnComponentChangeEvent(idStr, hook) {\n return new OnComponentChangeEvent(Date.now(), idStr, hook);\n }\n\n private creatOnComponentAddEvent(idStr, hook) {\n return new OnComponentAddEvent(Date.now(), idStr, hook);\n }\n\n private isComponentWatchedExternally(componentId: ComponentID) {\n const watcherData = this.multipleWatchers.find((m) => m.componentIds.find((id) => id.isEqual(componentId._legacy)));\n if (watcherData) {\n logger.debug(`${componentId.toString()} is watched by ${watcherData.compilerId.toString()}`);\n return true;\n }\n return false;\n }\n\n private getComponentIdByPath(filePath: string): ComponentID | null {\n const relativeFile = this.getRelativePathLinux(filePath);\n const trackDir = this.findTrackDirByFilePathRecursively(relativeFile);\n if (!trackDir) {\n // the file is not part of any component. If it was a new component, or a new file of\n // existing component, then, handleBitmapChanges() should deal with it.\n return null;\n }\n return this.trackDirs[trackDir];\n }\n\n private getRelativePathLinux(filePath: string) {\n return pathNormalizeToLinux(this.consumer.getPathRelativeToConsumer(filePath));\n }\n\n private findTrackDirByFilePathRecursively(filePath: string): string | null {\n if (this.trackDirs[filePath]) return filePath;\n const parentDir = dirname(filePath);\n if (parentDir === filePath) return null;\n return this.findTrackDirByFilePathRecursively(parentDir);\n }\n\n private async createWatcher(pathsToWatch: string[]) {\n this.fsWatcher = chokidar.watch(pathsToWatch, {\n ignoreInitial: true,\n // Using the function way since the regular way not working as expected\n // It might be solved when upgrading to chokidar > 3.0.0\n // See:\n // https://github.com/paulmillr/chokidar/issues/773\n // https://github.com/paulmillr/chokidar/issues/492\n // https://github.com/paulmillr/chokidar/issues/724\n ignored: (path) => {\n // Ignore package.json temporarily since it cerates endless loop since it's re-written after each build\n if (path.includes(`${sep}node_modules${sep}`) || path.includes(`${sep}package.json`)) {\n return true;\n }\n return false;\n },\n persistent: true,\n useFsEvents: false,\n });\n }\n\n async setTrackDirs() {\n this.trackDirs = {};\n const componentsFromBitMap = this.consumer.bitMap.getAllComponents([\n COMPONENT_ORIGINS.AUTHORED,\n COMPONENT_ORIGINS.IMPORTED,\n ]);\n await Promise.all(\n componentsFromBitMap.map(async (componentMap) => {\n const bitId = componentMap.id;\n const rootDir = componentMap.getRootDir();\n if (!rootDir) throw new Error(`${bitId.toString()} has no rootDir, which is invalid in Harmony`);\n const componentId = await this.workspace.resolveComponentId(bitId);\n this.trackDirs[rootDir] = componentId;\n })\n );\n }\n\n private async getPathsToWatch(): Promise<PathOsBasedAbsolute[]> {\n await this.setTrackDirs();\n const paths = [...Object.keys(this.trackDirs), BIT_MAP];\n const pathsAbsolute = paths.map((dir) => this.consumer.toAbsolutePath(dir));\n return pathsAbsolute;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;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kBAAf,CAAkCJ,KAAlC,CAA1B;MACA,KAAKrJ,SAAL,CAAesJ,OAAf,IAA0B/F,WAA1B;IACD,CAND,CADI,CAAN;EASD;;EAE4B,MAAf7C,eAAe,GAAmC;IAC9D,MAAM,KAAKiF,YAAL,EAAN;IACA,MAAM+D,KAAK,GAAG,CAAC,GAAG9I,MAAM,CAACkF,IAAP,CAAY,KAAK9F,SAAjB,CAAJ,EAAiC8C,oBAAjC,CAAd;IACA,MAAM6G,aAAa,GAAGD,KAAK,CAACN,GAAN,CAAWlD,GAAD,IAAS,KAAK9F,QAAL,CAAcwJ,cAAd,CAA6B1D,GAA7B,CAAnB,CAAtB;IACA,OAAOyD,aAAP;EACD;;AArVkB"}
|
|
1
|
+
{"version":3,"names":["DEBOUNCE_WAIT_MS","Watcher","constructor","workspace","pubsub","trackDirs","verbose","multipleWatchers","WatchQueue","consumer","watchAll","opts","msgs","watchOpts","pathsToWatch","getPathsToWatch","componentIds","Object","values","triggerOnPreWatch","createWatcher","watcher","fsWatcher","onStart","Promise","resolve","reject","process","env","BIT_LOG","onAll","on","onReady","filePath","startTime","Date","getTime","files","results","debounced","failureMsg","handleChange","initiator","duration","onChange","onAdd","p","onUnlink","err","onError","endsWith","BIT_MAP","bitMapChangesInProgress","buildResults","watchQueue","add","handleBitmapChanges","loader","stop","onIdle","componentId","getComponentIdByPath","logger","debug","compIdStr","toString","changedFilesPerComponent","push","sleep","triggerCompChanges","length","undefined","join","msg","error","console","message","ms","setTimeout","clearComponentCache","component","get","componentMap","state","_consumer","compFiles","filter","relativeFile","getRelativePathLinux","isCompFile","Boolean","getFilesRelativeToConsumer","find","executeWatchOperationsOnComponent","previewsTrackDirs","_reloadConsumer","setTrackDirs","newDirs","difference","keys","removedDirs","addResults","mapSeries","dir","flat","unwatch","executeWatchOperationsOnRemove","chalk","bold","pub","WorkspaceAspect","id","creatOnComponentRemovedEvent","triggerOnComponentRemove","isChange","isComponentWatchedExternally","idStr","creatOnComponentChangeEvent","creatOnComponentAddEvent","triggerOnComponentChange","triggerOnComponentAdd","OnComponentRemovedEvent","now","hook","OnComponentChangeEvent","OnComponentAddEvent","watcherData","m","isEqual","_legacy","compilerId","trackDir","findTrackDirByFilePathRecursively","pathNormalizeToLinux","getPathRelativeToConsumer","parentDir","dirname","chokidar","watch","ignoreInitial","ignored","path","includes","sep","persistent","useFsEvents","componentsFromBitMap","bitMap","getAllComponents","all","map","bitId","rootDir","getRootDir","Error","resolveComponentId","paths","pathsAbsolute","toAbsolutePath"],"sources":["watcher.ts"],"sourcesContent":["import { PubsubMain } from '@teambit/pubsub';\nimport { dirname, sep } from 'path';\nimport { difference } from 'lodash';\nimport { ComponentID } from '@teambit/component';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport loader from '@teambit/legacy/dist/cli/loader';\nimport { BIT_MAP } from '@teambit/legacy/dist/constants';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport logger from '@teambit/legacy/dist/logger/logger';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport mapSeries from 'p-map-series';\nimport chalk from 'chalk';\nimport { ChildProcess } from 'child_process';\nimport chokidar, { FSWatcher } from 'chokidar';\nimport ComponentMap from '@teambit/legacy/dist/consumer/bit-map/component-map';\nimport { PathLinux, PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';\nimport { CompilationInitiator } from '@teambit/compiler';\nimport { WorkspaceAspect } from '../';\nimport { OnComponentChangeEvent, OnComponentAddEvent, OnComponentRemovedEvent } from '../events';\nimport { Workspace } from '../workspace';\nimport { OnComponentEventResult } from '../on-component-events';\nimport { CheckTypes } from './check-types';\nimport { WatchQueue } from './watch-queue';\n\nexport type WatcherProcessData = { watchProcess: ChildProcess; compilerId: BitId; componentIds: BitId[] };\n\nexport type EventMessages = {\n onAll: Function;\n onStart: Function;\n onReady: Function;\n onChange: Function;\n onAdd: Function;\n onUnlink: Function;\n onError: Function;\n};\n\nexport type WatchOptions = {\n msgs?: EventMessages;\n initiator?: CompilationInitiator;\n verbose?: boolean; // print watch events to the console. (also ts-server events if spawnTSServer is true)\n spawnTSServer?: boolean; // needed for check types and extract API/docs.\n checkTypes?: CheckTypes; // if enabled, the spawnTSServer becomes true.\n preCompile?: boolean; // whether compile all components before start watching\n};\n\nconst DEBOUNCE_WAIT_MS = 100;\n\nexport class Watcher {\n private fsWatcher: FSWatcher;\n private changedFilesPerComponent: { [componentId: string]: string[] } = {};\n private watchQueue = new WatchQueue();\n private bitMapChangesInProgress = false;\n constructor(\n private workspace: Workspace,\n private pubsub: PubsubMain,\n private trackDirs: { [dir: PathLinux]: ComponentID } = {},\n private verbose = false,\n private multipleWatchers: WatcherProcessData[] = []\n ) {}\n\n get consumer(): Consumer {\n return this.workspace.consumer;\n }\n\n async watchAll(opts: WatchOptions) {\n const { msgs, ...watchOpts } = opts;\n // TODO: run build in the beginning of process (it's work like this in other envs)\n const pathsToWatch = await this.getPathsToWatch();\n const componentIds = Object.values(this.trackDirs);\n await this.workspace.triggerOnPreWatch(componentIds, watchOpts);\n await this.createWatcher(pathsToWatch);\n const watcher = this.fsWatcher;\n msgs?.onStart(this.workspace);\n\n return new Promise((resolve, reject) => {\n // prefix your command with \"BIT_LOG=*\" to see all watch events\n if (process.env.BIT_LOG) {\n // @ts-ignore\n if (msgs?.onAll) watcher.on('all', msgs?.onAll);\n }\n watcher.on('ready', () => {\n msgs?.onReady(this.workspace, this.trackDirs, this.verbose);\n });\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n watcher.on('change', async (filePath) => {\n const startTime = new Date().getTime();\n const { files, results, debounced, failureMsg } = await this.handleChange(filePath, opts?.initiator);\n if (debounced) {\n return;\n }\n const duration = new Date().getTime() - startTime;\n msgs?.onChange(files, results, this.verbose, duration, failureMsg);\n });\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n watcher.on('add', async (filePath) => {\n const startTime = new Date().getTime();\n const { files, results, debounced, failureMsg } = await this.handleChange(filePath, opts?.initiator);\n if (debounced) {\n return;\n }\n const duration = new Date().getTime() - startTime;\n msgs?.onAdd(files, results, this.verbose, duration, failureMsg);\n });\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n watcher.on('unlink', async (p) => {\n msgs?.onUnlink(p);\n await this.handleChange(p);\n });\n watcher.on('error', (err) => {\n msgs?.onError(err);\n reject(err);\n });\n });\n }\n\n /**\n * *** DEBOUNCING ***\n * some actions trigger multiple files changes at (almost) the same time. e.g. \"git pull\".\n * this causes some performance and instability issues. a debouncing mechanism was implemented to help with this.\n * the way how it works is that the first file of the same component starts the execution with a delay (e.g. 200ms).\n * if, in the meanwhile, another file of the same component was changed, it won't start a new execution, instead,\n * it'll only add the file to `this.changedFilesPerComponent` prop.\n * once the execution starts, it'll delete this component-id from the `this.changedFilesPerComponent` array,\n * indicating the next file-change to start a new execution.\n *\n * implementation wise, `lodash.debounce` doesn't help here, because:\n * A) it doesn't return the results, unless \"leading\" option is true. here, it must be false, otherwise, it'll start\n * the execution immediately.\n * B) it debounces the method regardless the param passes to it. so it'll disregard the component-id and will delay\n * other components undesirably.\n *\n * *** QUEUE ***\n * the debouncing helps to not execute the same component multiple times concurrently. however, multiple components\n * and .bitmap changes execution can still be processed concurrently.\n * the following example explains why this is an issue.\n * compA is changed in the .bitmap file from version 0.0.1 to 0.0.2. its files were changed as well.\n * all these changes get pulled at the same time by \"git pull\", as a result, the execution of compA and the .bitmap\n * happen at the same time.\n * during the execution of compA, the component id is parsed as compA@0.0.1, later, it asks for the Workspace for this\n * id. while the workspace is looking for this id, the .bitmap execution reloaded the consumer and changed all versions.\n * after this change, the workspace doesn't have this id anymore, which will trigger an error.\n * to ensure this won't happen, we keep a flag to indicate whether the .bitmap execution is running, and if so, all\n * other executions are paused until the queue is empty (this is done by awaiting for queue.onIdle).\n * once the queue is empty, we know the .bitmap process was done and the workspace has all new ids.\n * in the example above, at this stage, the id will be resolved to compA@0.0.2.\n * one more thing, the queue is configured to have concurrency of 1. to make sure two components are not processed at\n * the same time. (the same way is done when loading all components from the filesystem/scope).\n * this way we can also ensure that if compA was started before the .bitmap execution, it will complete before the\n * .bitmap execution starts.\n */\n private async handleChange(\n filePath: string,\n initiator?: CompilationInitiator\n ): Promise<{\n results: OnComponentEventResult[];\n files?: string[];\n failureMsg?: string;\n debounced?: boolean;\n }> {\n try {\n if (filePath.endsWith(BIT_MAP)) {\n this.bitMapChangesInProgress = true;\n const buildResults = await this.watchQueue.add(() => this.handleBitmapChanges());\n this.bitMapChangesInProgress = false;\n loader.stop();\n return { results: buildResults, files: [filePath] };\n }\n if (this.bitMapChangesInProgress) {\n await this.watchQueue.onIdle();\n }\n const componentId = this.getComponentIdByPath(filePath);\n if (!componentId) {\n const failureMsg = `file ${filePath} is not part of any component, ignoring it`;\n logger.debug(failureMsg);\n loader.stop();\n return { results: [], files: [filePath], failureMsg };\n }\n const compIdStr = componentId.toString();\n if (this.changedFilesPerComponent[compIdStr]) {\n this.changedFilesPerComponent[compIdStr].push(filePath);\n loader.stop();\n return { results: [], debounced: true };\n }\n this.changedFilesPerComponent[compIdStr] = [filePath];\n await this.sleep(DEBOUNCE_WAIT_MS);\n const files = this.changedFilesPerComponent[compIdStr];\n delete this.changedFilesPerComponent[compIdStr];\n\n const buildResults = await this.watchQueue.add(() => this.triggerCompChanges(componentId, files, initiator));\n const failureMsg = buildResults.length\n ? undefined\n : `files ${files.join(', ')} are inside the component ${compIdStr} but configured to be ignored`;\n loader.stop();\n return { results: buildResults, files, failureMsg };\n } catch (err: any) {\n const msg = `watcher found an error while handling ${filePath}`;\n logger.error(msg, err);\n logger.console(`${msg}, ${err.message}`);\n loader.stop();\n return { results: [], files: [filePath], failureMsg: err.message };\n }\n }\n\n private async sleep(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n /**\n * if a file was added/remove, once the component is loaded, it changes .bitmap, and then the\n * entire cache is invalidated and the consumer is reloaded.\n * when a file just changed, no need to reload the consumer, it is enough to just delete the\n * component from the cache (both, workspace and consumer)\n */\n private async triggerCompChanges(\n componentId: ComponentID,\n files: string[],\n initiator?: CompilationInitiator\n ): Promise<OnComponentEventResult[]> {\n this.workspace.clearComponentCache(componentId);\n const component = await this.workspace.get(componentId);\n const componentMap: ComponentMap = component.state._consumer.componentMap;\n const compFiles = files.filter((filePath) => {\n const relativeFile = this.getRelativePathLinux(filePath);\n const isCompFile = Boolean(componentMap.getFilesRelativeToConsumer().find((p) => p === relativeFile));\n if (!isCompFile) {\n logger.debug(`file ${filePath} is inside the component ${componentId.toString()} but configured to be ignored`);\n }\n return isCompFile;\n });\n if (!compFiles.length) {\n return [];\n }\n const buildResults = await this.executeWatchOperationsOnComponent(componentId, compFiles, true, initiator);\n return buildResults;\n }\n\n /**\n * if .bitmap changed, it's possible that a new component has been added. trigger onComponentAdd.\n */\n private async handleBitmapChanges(): Promise<OnComponentEventResult[]> {\n const previewsTrackDirs = { ...this.trackDirs };\n await this.workspace._reloadConsumer();\n await this.setTrackDirs();\n const newDirs: string[] = difference(Object.keys(this.trackDirs), Object.keys(previewsTrackDirs));\n const removedDirs: string[] = difference(Object.keys(previewsTrackDirs), Object.keys(this.trackDirs));\n const results: OnComponentEventResult[] = [];\n if (newDirs.length) {\n this.fsWatcher.add(newDirs);\n const addResults = await mapSeries(newDirs, async (dir) =>\n this.executeWatchOperationsOnComponent(this.trackDirs[dir], [], false)\n );\n results.push(...addResults.flat());\n }\n if (removedDirs.length) {\n await this.fsWatcher.unwatch(removedDirs);\n await mapSeries(removedDirs, (dir) => this.executeWatchOperationsOnRemove(previewsTrackDirs[dir]));\n }\n return results;\n }\n\n private async executeWatchOperationsOnRemove(componentId: ComponentID) {\n logger.debug(`running OnComponentRemove hook for ${chalk.bold(componentId.toString())}`);\n this.pubsub.pub(WorkspaceAspect.id, this.creatOnComponentRemovedEvent(componentId.toString()));\n await this.workspace.triggerOnComponentRemove(componentId);\n }\n\n private async executeWatchOperationsOnComponent(\n componentId: ComponentID,\n files: string[],\n isChange = true,\n initiator?: CompilationInitiator\n ): Promise<OnComponentEventResult[]> {\n if (this.isComponentWatchedExternally(componentId)) {\n // update capsule, once done, it automatically triggers the external watcher\n await this.workspace.get(componentId);\n return [];\n }\n const idStr = componentId.toString();\n\n if (isChange) {\n logger.debug(`running OnComponentChange hook for ${chalk.bold(idStr)}`);\n this.pubsub.pub(WorkspaceAspect.id, this.creatOnComponentChangeEvent(idStr, 'OnComponentChange'));\n } else {\n logger.debug(`running OnComponentAdd hook for ${chalk.bold(idStr)}`);\n this.pubsub.pub(WorkspaceAspect.id, this.creatOnComponentAddEvent(idStr, 'OnComponentAdd'));\n }\n\n let buildResults: OnComponentEventResult[];\n try {\n buildResults = isChange\n ? await this.workspace.triggerOnComponentChange(componentId, files, initiator)\n : await this.workspace.triggerOnComponentAdd(componentId);\n } catch (err: any) {\n // do not exit the watch process on errors, just print them\n const msg = `found an issue during onComponentChange or onComponentAdd hooks`;\n logger.error(msg, err);\n logger.console(`\\n${msg}: ${err.message || err}`);\n return [];\n }\n return buildResults;\n }\n\n private creatOnComponentRemovedEvent(idStr) {\n return new OnComponentRemovedEvent(Date.now(), idStr);\n }\n\n private creatOnComponentChangeEvent(idStr, hook) {\n return new OnComponentChangeEvent(Date.now(), idStr, hook);\n }\n\n private creatOnComponentAddEvent(idStr, hook) {\n return new OnComponentAddEvent(Date.now(), idStr, hook);\n }\n\n private isComponentWatchedExternally(componentId: ComponentID) {\n const watcherData = this.multipleWatchers.find((m) => m.componentIds.find((id) => id.isEqual(componentId._legacy)));\n if (watcherData) {\n logger.debug(`${componentId.toString()} is watched by ${watcherData.compilerId.toString()}`);\n return true;\n }\n return false;\n }\n\n private getComponentIdByPath(filePath: string): ComponentID | null {\n const relativeFile = this.getRelativePathLinux(filePath);\n const trackDir = this.findTrackDirByFilePathRecursively(relativeFile);\n if (!trackDir) {\n // the file is not part of any component. If it was a new component, or a new file of\n // existing component, then, handleBitmapChanges() should deal with it.\n return null;\n }\n return this.trackDirs[trackDir];\n }\n\n private getRelativePathLinux(filePath: string) {\n return pathNormalizeToLinux(this.consumer.getPathRelativeToConsumer(filePath));\n }\n\n private findTrackDirByFilePathRecursively(filePath: string): string | null {\n if (this.trackDirs[filePath]) return filePath;\n const parentDir = dirname(filePath);\n if (parentDir === filePath) return null;\n return this.findTrackDirByFilePathRecursively(parentDir);\n }\n\n private async createWatcher(pathsToWatch: string[]) {\n this.fsWatcher = chokidar.watch(pathsToWatch, {\n ignoreInitial: true,\n // Using the function way since the regular way not working as expected\n // It might be solved when upgrading to chokidar > 3.0.0\n // See:\n // https://github.com/paulmillr/chokidar/issues/773\n // https://github.com/paulmillr/chokidar/issues/492\n // https://github.com/paulmillr/chokidar/issues/724\n ignored: (path) => {\n // Ignore package.json temporarily since it cerates endless loop since it's re-written after each build\n if (path.includes(`${sep}node_modules${sep}`) || path.includes(`${sep}package.json`)) {\n return true;\n }\n return false;\n },\n persistent: true,\n useFsEvents: false,\n });\n }\n\n async setTrackDirs() {\n this.trackDirs = {};\n const componentsFromBitMap = this.consumer.bitMap.getAllComponents();\n await Promise.all(\n componentsFromBitMap.map(async (componentMap) => {\n const bitId = componentMap.id;\n const rootDir = componentMap.getRootDir();\n if (!rootDir) throw new Error(`${bitId.toString()} has no rootDir, which is invalid in Harmony`);\n const componentId = await this.workspace.resolveComponentId(bitId);\n this.trackDirs[rootDir] = componentId;\n })\n );\n }\n\n private async getPathsToWatch(): Promise<PathOsBasedAbsolute[]> {\n await this.setTrackDirs();\n const paths = [...Object.keys(this.trackDirs), BIT_MAP];\n const pathsAbsolute = paths.map((dir) => this.consumer.toAbsolutePath(dir));\n return pathsAbsolute;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAA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D;;EAE4B,MAAf7C,eAAe,GAAmC;IAC9D,MAAM,KAAKiF,YAAL,EAAN;IACA,MAAM4D,KAAK,GAAG,CAAC,GAAG3I,MAAM,CAACkF,IAAP,CAAY,KAAK9F,SAAjB,CAAJ,EAAiC8C,oBAAjC,CAAd;IACA,MAAM0G,aAAa,GAAGD,KAAK,CAACN,GAAN,CAAW/C,GAAD,IAAS,KAAK9F,QAAL,CAAcqJ,cAAd,CAA6BvD,GAA7B,CAAnB,CAAtB;IACA,OAAOsD,aAAP;EACD;;AAlVkB"}
|
package/dist/workspace.js
CHANGED
|
@@ -780,7 +780,7 @@ class Workspace {
|
|
|
780
780
|
|
|
781
781
|
|
|
782
782
|
getAllComponentIds() {
|
|
783
|
-
const bitIds = this.consumer.bitMap.
|
|
783
|
+
const bitIds = this.consumer.bitMap.getAllBitIds();
|
|
784
784
|
return this.resolveMultipleComponentIds(bitIds);
|
|
785
785
|
}
|
|
786
786
|
|
|
@@ -2289,10 +2289,12 @@ needed-for: ${neededFor || '<unknown>'}`);
|
|
|
2289
2289
|
|
|
2290
2290
|
const variantPoliciesByPatterns = this._variantPatternsToDepPolicesDict(variantPatterns);
|
|
2291
2291
|
|
|
2292
|
+
const components = await this.list();
|
|
2292
2293
|
const outdatedPkgs = await this.dependencyResolver.getOutdatedPkgsFromPolicies({
|
|
2293
2294
|
rootDir: this.path,
|
|
2294
2295
|
variantPoliciesByPatterns,
|
|
2295
|
-
componentPoliciesById
|
|
2296
|
+
componentPoliciesById,
|
|
2297
|
+
components
|
|
2296
2298
|
});
|
|
2297
2299
|
let outdatedPkgsToUpdate;
|
|
2298
2300
|
|