custom-gallery.patch 2.8 KB

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