custom-gallery.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. diff --git a/src/vs/base/common/product.ts b/src/vs/base/common/product.ts
  2. index 1ae8079..eb56045 100644
  3. --- a/src/vs/base/common/product.ts
  4. +++ b/src/vs/base/common/product.ts
  5. @@ -72,2 +72,3 @@ export interface IProductConfiguration {
  6. readonly serviceUrl: string;
  7. + readonly cacheUrl?: string;
  8. readonly itemUrl: string;
  9. diff --git a/src/vs/platform/product/common/product.ts b/src/vs/platform/product/common/product.ts
  10. index 7e63a16..3bfeab8 100644
  11. --- a/src/vs/platform/product/common/product.ts
  12. +++ b/src/vs/platform/product/common/product.ts
  13. @@ -6,3 +6,3 @@
  14. import { FileAccess } from 'vs/base/common/network';
  15. -import { globals } from 'vs/base/common/platform';
  16. +import { globals, isWindows } from 'vs/base/common/platform';
  17. import { env } from 'vs/base/common/process';
  18. @@ -11,2 +11,3 @@ import { dirname, joinPath } from 'vs/base/common/resources';
  19. import { ISandboxConfiguration } from 'vs/base/parts/sandbox/common/sandboxTypes';
  20. +import { getUserDataPath } from 'vs/platform/environment/node/userDataPath';
  21. @@ -36,2 +37,28 @@ else if (typeof require?.__$__nodeRequire === 'function') {
  22. + // Merge user-customized product.json
  23. + try {
  24. + const merge = (...objects: any[]) =>
  25. + objects.reduce((result, current) => {
  26. + Object.keys(current).forEach((key) => {
  27. + if (Array.isArray(result[key]) && Array.isArray(current[key])) {
  28. + result[key] = current[key];
  29. + } else if (typeof result[key] === 'object' && typeof current[key] === 'object') {
  30. + result[key] = merge(result[key], current[key]);
  31. + } else {
  32. + result[key] = current[key];
  33. + }
  34. + });
  35. +
  36. + return result;
  37. + }, {}) as any;
  38. +
  39. + const userDataPath = getUserDataPath({} as any);
  40. + const userProductPath = isWindows ? `file:///${userDataPath}/product.json` : `file://${userDataPath}/product.json`;
  41. +
  42. + const userProduct = require.__$__nodeRequire(FileAccess.asFileUri(userProductPath, require).fsPath);
  43. +
  44. + product = merge(product, userProduct);
  45. + } catch (ex) {
  46. + }
  47. +
  48. // Running out of sources
  49. @@ -46,2 +73,15 @@ else if (typeof require?.__$__nodeRequire === 'function') {
  50. + // Set user-defined extension gallery
  51. + const { serviceUrl, cacheUrl, itemUrl, controlUrl, recommendationsUrl } = product.extensionsGallery || {}
  52. +
  53. + Object.assign(product, {
  54. + extensionsGallery: {
  55. + serviceUrl: env['VSCODE_GALLERY_SERVICE_URL'] || serviceUrl,
  56. + cacheUrl: env['VSCODE_GALLERY_CACHE_URL'] || cacheUrl,
  57. + itemUrl: env['VSCODE_GALLERY_ITEM_URL'] || itemUrl,
  58. + controlUrl: env['VSCODE_GALLERY_CONTROL_URL'] || controlUrl,
  59. + recommendationsUrl: env['VSCODE_GALLERY_RECOMMENDATIONS_URL'] || recommendationsUrl
  60. + }
  61. + })
  62. +
  63. Object.assign(product, {