custom-gallery.patch 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. diff --git a/src/vs/platform/product/common/product.ts b/src/vs/platform/product/common/product.ts
  2. index 2730ee7..4d46c23 100644
  3. --- a/src/vs/platform/product/common/product.ts
  4. +++ b/src/vs/platform/product/common/product.ts
  5. @@ -8,6 +8,7 @@ import { isWeb } from 'vs/base/common/platform';
  6. import { env } from 'vs/base/common/process';
  7. import { FileAccess } from 'vs/base/common/network';
  8. import { dirname, joinPath } from 'vs/base/common/resources';
  9. +import { getDefaultUserDataPath } from 'vs/base/node/userDataPath';
  10. let product: IProductConfiguration;
  11. @@ -47,6 +48,29 @@ else {
  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(getDefaultUserDataPath(), 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. @@ -56,6 +80,19 @@ else {
  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/platform/product/common/productService.ts b/src/vs/platform/product/common/productService.ts
  60. index 07263ca..0328f58 100644
  61. --- a/src/vs/platform/product/common/productService.ts
  62. +++ b/src/vs/platform/product/common/productService.ts
  63. @@ -67,6 +67,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;