2
0

custom-gallery.patch 3.2 KB

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