@rushstack/rush-http-build-cache-plugin 5.97.1-pr3481.18 → 5.98.0

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.
Files changed (60) hide show
  1. package/.heft/build-cache/jest-cache/haste-map-bae913f9b9aa720eb4deeae0a60a4b27-22ae7f4ce9de4306889d8c05e5cc39b9-f6b1af01a3130057bdfe3d86807211f9 +0 -0
  2. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/{42/Import_42731f0220476b7d949a2d8f3a6f3333 → 12/Import_12af6d2ca109ffba883fc5079062e0e8} +157 -14
  3. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/{c7/commons_c77bee95093c1098b4a591f2dadf398d → 2e/commons_2e52897dfe4222d991674613f5b35882} +1007 -2581
  4. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/{26/package_263c59db6933ba9581588638fb19da5c → 2f/package_2f923ac6ad9bbd4966f8472750ef7770} +2 -2
  5. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/34/PrefixProxyTerminalProvider_34b4603b9c4455de1c3cc05820149fdd +65 -0
  6. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/{58/index_58c57a8f2a96bf6fdf5db35a2e44baa7 → 46/index_46761981528d09d1a0e438f06cd2c548} +7 -2
  7. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/{06/ConfigurationFile_06d7f35feb0bd944d9b9a2a4d9e112c8 → 57/ConfigurationFile_57c950e8ef4673e11bff94304a50823c} +10 -4
  8. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/{fa/rushlib_fa830331d24a41292b5cb91040384188 → 69/rushlib_695f6e29167e91482e2906a8d09b3a5a} +17 -28
  9. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/8a/HttpBuildCacheProvidertest_8a1598e1f1b42d6933964acfb7612893 +116 -0
  10. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/8a/HttpBuildCacheProvidertest_8a1598e1f1b42d6933964acfb7612893.map +1 -0
  11. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/a3/RushHttpBuildCachePlugin_a3e8a9bb172ff361907e770dcf3268be +1551 -0
  12. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/a3/RushHttpBuildCachePlugin_a3e8a9bb172ff361907e770dcf3268be.map +1 -0
  13. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/{c2/Async_c2ea5cc2edc0a460dcf394ef8277e88e → b4/Async_b43c9d64ab6a035dbce65b9f1a28e166} +78 -2
  14. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/ba/TerminalWritable_ba71b4b7bfe6a26c85f4fd0245057a0a +54 -0
  15. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/ce/index_ce3464019fb882539ee9a6f3e36e615a +2 -2
  16. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/ce/index_ce3464019fb882539ee9a6f3e36e615a.map +1 -1
  17. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/{5d/Text_5da85b5db9a2f06bbe29cdcd91e6fbca → df/Text_df57ddd200e4237e617fc183dcb5fe67} +7 -1
  18. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/{e5/HttpBuildCacheProvider_e53bd002cf44ae62693f20b8c4682941 → ec/HttpBuildCacheProvider_ecceab34e8340fa24dde11b618ffa8a4} +1210 -909
  19. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/ec/HttpBuildCacheProvider_ecceab34e8340fa24dde11b618ffa8a4.map +1 -0
  20. package/.heft/build-cache/jest-cache/perf-cache-bae913f9b9aa720eb4deeae0a60a4b27-da39a3ee5e6b4b0d3255bfef95601890 +1 -1
  21. package/.rush/temp/operation/_phase_build/state.json +1 -1
  22. package/.rush/temp/operation/_phase_test/all.log +29 -0
  23. package/.rush/temp/operation/_phase_test/state.json +1 -1
  24. package/.rush/temp/package-deps__phase_build.json +5 -5
  25. package/.rush/temp/package-deps__phase_test.json +5 -5
  26. package/.rush/temp/rushstack+rush-http-build-cache-plugin-_phase_build-08118e08afc6d454e5623f20498fd64b5e3e9051.log +10 -0
  27. package/.rush/temp/shrinkwrap-deps.json +10 -10
  28. package/lib/HttpBuildCacheProvider.d.ts +2 -0
  29. package/lib/HttpBuildCacheProvider.d.ts.map +1 -1
  30. package/lib/HttpBuildCacheProvider.js +26 -7
  31. package/lib/HttpBuildCacheProvider.js.map +1 -1
  32. package/lib/RushHttpBuildCachePlugin.d.ts.map +1 -1
  33. package/lib/RushHttpBuildCachePlugin.js +28 -4
  34. package/lib/RushHttpBuildCachePlugin.js.map +1 -1
  35. package/lib/test/HttpBuildCacheProvider.test.d.ts.map +1 -0
  36. package/lib/{HttpBuildCacheProvider.test.js → test/HttpBuildCacheProvider.test.js} +46 -3
  37. package/lib/test/HttpBuildCacheProvider.test.js.map +1 -0
  38. package/package.json +6 -6
  39. package/rush-logs/rush-http-build-cache-plugin._phase_build.log +4 -23
  40. package/rush-logs/rush-http-build-cache-plugin._phase_test.log +16 -16
  41. package/src/HttpBuildCacheProvider.ts +36 -7
  42. package/src/RushHttpBuildCachePlugin.ts +23 -28
  43. package/src/test/HttpBuildCacheProvider.test.ts +115 -0
  44. package/temp/coverage/clover.xml +117 -109
  45. package/temp/coverage/coverage-final.json +2 -2
  46. package/temp/coverage/lcov-report/HttpBuildCacheProvider.ts.html +166 -79
  47. package/temp/coverage/lcov-report/RushHttpBuildCachePlugin.ts.html +29 -44
  48. package/temp/coverage/lcov-report/index.html +24 -24
  49. package/temp/coverage/lcov-report/index.ts.html +1 -1
  50. package/temp/coverage/lcov.info +236 -218
  51. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/e5/HttpBuildCacheProvider_e53bd002cf44ae62693f20b8c4682941.map +0 -1
  52. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/e6/RushHttpBuildCachePlugin_e69b4b7cd4f95aa49455690c88f00247 +0 -362
  53. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/e6/RushHttpBuildCachePlugin_e69b4b7cd4f95aa49455690c88f00247.map +0 -1
  54. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/f7/HttpBuildCacheProvidertest_f710af633835df558cad54cb165c14fa +0 -73
  55. package/.heft/build-cache/jest-cache/jest-transform-cache-bae913f9b9aa720eb4deeae0a60a4b27-474488b31a4a940a3990e9eaf06f1647/f7/HttpBuildCacheProvidertest_f710af633835df558cad54cb165c14fa.map +0 -1
  56. package/.rush/temp/rushstack+rush-http-build-cache-plugin-_phase_build-5e3cfa01506c2ac77af487ee9732b935a5bbe122.log +0 -27
  57. package/lib/HttpBuildCacheProvider.test.d.ts.map +0 -1
  58. package/lib/HttpBuildCacheProvider.test.js.map +0 -1
  59. package/src/HttpBuildCacheProvider.test.ts +0 -58
  60. /package/lib/{HttpBuildCacheProvider.test.d.ts → test/HttpBuildCacheProvider.test.d.ts} +0 -0
@@ -1,4 +1,4 @@
1
- 209e9cf9090ea89efb6e5d699ef8c518
1
+ 17c8f45b5493500142a3994514f4c6eb
2
2
  "use strict";
3
3
  // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
4
4
  // See LICENSE in the project root for license information.
@@ -145,32 +145,105 @@ class Import {
145
145
  * and a system module is found, then its name is returned without any file path.
146
146
  */
147
147
  static resolveModule(options) {
148
- const { modulePath, baseFolderPath, includeSystemModules, allowSelfReference } = options;
148
+ const { modulePath, baseFolderPath, includeSystemModules, allowSelfReference, getRealPath } = options;
149
149
  if (path.isAbsolute(modulePath)) {
150
150
  return modulePath;
151
151
  }
152
- const normalizedRootPath = FileSystem_1.FileSystem.getRealPath(baseFolderPath);
152
+ const normalizedRootPath = (getRealPath || FileSystem_1.FileSystem.getRealPath)(baseFolderPath);
153
153
  if (modulePath.startsWith('.')) {
154
154
  // This looks like a conventional relative path
155
155
  return path.resolve(normalizedRootPath, modulePath);
156
156
  }
157
- if (includeSystemModules === true && Import._builtInModules.has(modulePath)) {
158
- return modulePath;
157
+ // Built-in modules do not have a scope, so if there is a slash, then we need to check
158
+ // against the first path segment
159
+ const slashIndex = modulePath.indexOf('/');
160
+ const moduleName = slashIndex === -1 ? modulePath : modulePath.slice(0, slashIndex);
161
+ if (!includeSystemModules && Import._builtInModules.has(moduleName)) {
162
+ throw new Error(`Cannot find module "${modulePath}" from "${options.baseFolderPath}".`);
159
163
  }
160
164
  if (allowSelfReference === true) {
161
165
  const ownPackage = Import._getPackageName(baseFolderPath);
162
- if (ownPackage && modulePath.startsWith(ownPackage.packageName)) {
163
- const packagePath = modulePath.substr(ownPackage.packageName.length + 1);
166
+ if (ownPackage &&
167
+ (modulePath === ownPackage.packageName || modulePath.startsWith(`${ownPackage.packageName}/`))) {
168
+ const packagePath = modulePath.slice(ownPackage.packageName.length + 1);
164
169
  return path.resolve(ownPackage.packageRootPath, packagePath);
165
170
  }
166
171
  }
167
172
  try {
168
- return Resolve.sync(
169
- // Append a slash to the package name to ensure `resolve.sync` doesn't attempt to return a system package
170
- includeSystemModules !== true && modulePath.indexOf('/') === -1 ? `${modulePath}/` : modulePath, {
173
+ return Resolve.sync(modulePath, {
171
174
  basedir: normalizedRootPath,
172
- preserveSymlinks: false
175
+ preserveSymlinks: false,
176
+ realpathSync: getRealPath
177
+ });
178
+ }
179
+ catch (e) {
180
+ throw new Error(`Cannot find module "${modulePath}" from "${options.baseFolderPath}".`);
181
+ }
182
+ }
183
+ /**
184
+ * Async version of {@link Import.resolveModule}.
185
+ */
186
+ static async resolveModuleAsync(options) {
187
+ const { modulePath, baseFolderPath, includeSystemModules, allowSelfReference, getRealPath, getRealPathAsync } = options;
188
+ if (path.isAbsolute(modulePath)) {
189
+ return modulePath;
190
+ }
191
+ const normalizedRootPath = await (getRealPathAsync || getRealPath || FileSystem_1.FileSystem.getRealPathAsync)(baseFolderPath);
192
+ if (modulePath.startsWith('.')) {
193
+ // This looks like a conventional relative path
194
+ return path.resolve(normalizedRootPath, modulePath);
195
+ }
196
+ // Built-in modules do not have a scope, so if there is a slash, then we need to check
197
+ // against the first path segment
198
+ const slashIndex = modulePath.indexOf('/');
199
+ const moduleName = slashIndex === -1 ? modulePath : modulePath.slice(0, slashIndex);
200
+ if (!includeSystemModules && Import._builtInModules.has(moduleName)) {
201
+ throw new Error(`Cannot find module "${modulePath}" from "${options.baseFolderPath}".`);
202
+ }
203
+ if (allowSelfReference === true) {
204
+ const ownPackage = Import._getPackageName(baseFolderPath);
205
+ if (ownPackage &&
206
+ (modulePath === ownPackage.packageName || modulePath.startsWith(`${ownPackage.packageName}/`))) {
207
+ const packagePath = modulePath.slice(ownPackage.packageName.length + 1);
208
+ return path.resolve(ownPackage.packageRootPath, packagePath);
209
+ }
210
+ }
211
+ try {
212
+ const resolvePromise = new Promise((resolve, reject) => {
213
+ const realPathFn = getRealPathAsync || getRealPath
214
+ ? (filePath, callback) => {
215
+ if (getRealPathAsync) {
216
+ getRealPathAsync(filePath)
217
+ .then((resolvedPath) => callback(null, resolvedPath))
218
+ .catch((error) => callback(error));
219
+ }
220
+ else {
221
+ try {
222
+ const resolvedPath = getRealPath(filePath);
223
+ callback(null, resolvedPath);
224
+ }
225
+ catch (error) {
226
+ callback(error);
227
+ }
228
+ }
229
+ }
230
+ : undefined;
231
+ Resolve.default(modulePath, {
232
+ basedir: normalizedRootPath,
233
+ preserveSymlinks: false,
234
+ realpath: realPathFn
235
+ }, (error, resolvedPath) => {
236
+ if (error) {
237
+ reject(error);
238
+ }
239
+ else {
240
+ // Resolve docs state that either an error will be returned, or the resolved path.
241
+ // In this case, the resolved path should always be populated.
242
+ resolve(resolvedPath);
243
+ }
244
+ });
173
245
  });
246
+ return await resolvePromise;
174
247
  }
175
248
  catch (e) {
176
249
  throw new Error(`Cannot find module "${modulePath}" from "${options.baseFolderPath}".`);
@@ -197,11 +270,11 @@ class Import {
197
270
  * and a system module is found, then its name is returned without any file path.
198
271
  */
199
272
  static resolvePackage(options) {
200
- const { packageName, includeSystemModules, baseFolderPath, allowSelfReference } = options;
273
+ const { packageName, includeSystemModules, baseFolderPath, allowSelfReference, getRealPath } = options;
201
274
  if (includeSystemModules && Import._builtInModules.has(packageName)) {
202
275
  return packageName;
203
276
  }
204
- const normalizedRootPath = FileSystem_1.FileSystem.getRealPath(baseFolderPath);
277
+ const normalizedRootPath = (getRealPath || FileSystem_1.FileSystem.getRealPath)(baseFolderPath);
205
278
  if (allowSelfReference) {
206
279
  const ownPackage = Import._getPackageName(baseFolderPath);
207
280
  if (ownPackage && ownPackage.packageName === packageName) {
@@ -221,8 +294,78 @@ class Import {
221
294
  // even if the real entry point was in an subfolder with arbitrary nesting.
222
295
  pkg.main = 'package.json';
223
296
  return pkg;
224
- }
297
+ },
298
+ realpathSync: getRealPath
299
+ });
300
+ const packagePath = path.dirname(resolvedPath);
301
+ return packagePath;
302
+ }
303
+ catch (_a) {
304
+ throw new Error(`Cannot find package "${packageName}" from "${baseFolderPath}".`);
305
+ }
306
+ }
307
+ /**
308
+ * Async version of {@link Import.resolvePackage}.
309
+ */
310
+ static async resolvePackageAsync(options) {
311
+ const { packageName, includeSystemModules, baseFolderPath, allowSelfReference, getRealPath, getRealPathAsync } = options;
312
+ if (includeSystemModules && Import._builtInModules.has(packageName)) {
313
+ return packageName;
314
+ }
315
+ const normalizedRootPath = await (getRealPathAsync || getRealPath || FileSystem_1.FileSystem.getRealPathAsync)(baseFolderPath);
316
+ if (allowSelfReference) {
317
+ const ownPackage = Import._getPackageName(baseFolderPath);
318
+ if (ownPackage && ownPackage.packageName === packageName) {
319
+ return ownPackage.packageRootPath;
320
+ }
321
+ }
322
+ PackageName_1.PackageName.parse(packageName); // Ensure the package name is valid and doesn't contain a path
323
+ try {
324
+ const resolvePromise = new Promise((resolve, reject) => {
325
+ const realPathFn = getRealPathAsync || getRealPath
326
+ ? (filePath, callback) => {
327
+ if (getRealPathAsync) {
328
+ getRealPathAsync(filePath)
329
+ .then((resolvedPath) => callback(null, resolvedPath))
330
+ .catch((error) => callback(error));
331
+ }
332
+ else {
333
+ try {
334
+ const resolvedPath = getRealPath(filePath);
335
+ callback(null, resolvedPath);
336
+ }
337
+ catch (error) {
338
+ callback(error);
339
+ }
340
+ }
341
+ }
342
+ : undefined;
343
+ Resolve.default(
344
+ // Append a slash to the package name to ensure `resolve` doesn't attempt to return a system package
345
+ `${packageName}/`, {
346
+ basedir: normalizedRootPath,
347
+ preserveSymlinks: false,
348
+ packageFilter: (pkg, pkgFile, dir) => {
349
+ // Hardwire "main" to point to a file that is guaranteed to exist.
350
+ // This helps resolve packages such as @types/node that have no entry point.
351
+ // And then we can use path.dirname() below to locate the package folder,
352
+ // even if the real entry point was in an subfolder with arbitrary nesting.
353
+ pkg.main = 'package.json';
354
+ return pkg;
355
+ },
356
+ realpath: realPathFn
357
+ }, (error, resolvedPath) => {
358
+ if (error) {
359
+ reject(error);
360
+ }
361
+ else {
362
+ // Resolve docs state that either an error will be returned, or the resolved path.
363
+ // In this case, the resolved path should always be populated.
364
+ resolve(resolvedPath);
365
+ }
366
+ });
225
367
  });
368
+ const resolvedPath = await resolvePromise;
226
369
  const packagePath = path.dirname(resolvedPath);
227
370
  return packagePath;
228
371
  }