/
product.ts
84 lines (74 loc) · 2.93 KB
/
product.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { env } from 'vs/base/common/process';
import { IProductConfiguration } from 'vs/base/common/product';
import { ISandboxConfiguration } from 'vs/base/parts/sandbox/common/sandboxTypes';
import { loadFromFileSystem } from 'vs/platform/product/common/che/product';
/**
* @deprecated You MUST use `IProductService` if possible.
*/
let product: IProductConfiguration;
// Native sandbox environment
const vscodeGlobal = (globalThis as any).vscode;
if (typeof vscodeGlobal !== 'undefined' && typeof vscodeGlobal.context !== 'undefined') {
const configuration: ISandboxConfiguration | undefined = vscodeGlobal.context.configuration();
if (configuration) {
product = configuration.product;
} else {
throw new Error('Sandbox: unable to resolve product configuration from preload script.');
}
}
// _VSCODE environment
else if (globalThis._VSCODE_PRODUCT_JSON && globalThis._VSCODE_PACKAGE_JSON) {
// Obtain values from product.json and package.json-data
product = globalThis._VSCODE_PRODUCT_JSON as unknown as IProductConfiguration;
// Running out of sources
if (env['VSCODE_DEV']) {
Object.assign(product, {
nameShort: `${product.nameShort} Dev`,
nameLong: `${product.nameLong} Dev`,
dataFolderName: `${product.dataFolderName}-dev`,
serverDataFolderName: product.serverDataFolderName ? `${product.serverDataFolderName}-dev` : undefined
});
}
// Version is added during built time, but we still
// want to have it running out of sources so we
// read it from package.json only when we need it.
if (!product.version) {
const pkg = globalThis._VSCODE_PACKAGE_JSON as { version: string };
Object.assign(product, {
version: pkg.version
});
}
}
// Web environment or unknown
else {
// Built time configuration (do NOT modify)
product = { /*BUILD->INSERT_PRODUCT_CONFIGURATION*/ } as IProductConfiguration;
product = loadFromFileSystem();
// Running out of sources
if (Object.keys(product).length === 0) {
Object.assign(product, {
version: '1.87.0-dev',
nameShort: 'Code - OSS Dev',
nameLong: 'Code - OSS Dev',
applicationName: 'code-oss',
dataFolderName: '.vscode-oss',
urlProtocol: 'code-oss',
reportIssueUrl: 'https://github.com/microsoft/vscode/issues/new',
licenseName: 'MIT',
licenseUrl: 'https://github.com/microsoft/vscode/blob/main/LICENSE.txt',
serverLicenseUrl: 'https://github.com/microsoft/vscode/blob/main/LICENSE.txt',
extensionsGallery: {
serviceUrl: 'https://open-vsx.org/vscode/gallery',
itemUrl: 'https://open-vsx.org/vscode/item',
},
});
}
}
/**
* @deprecated You MUST use `IProductService` if possible.
*/
export default product;