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
|
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { FileAccess } from 'vs/base/common/network';
import { globals } from 'vs/base/common/platform';
import { env } from 'vs/base/common/process';
import { IProductConfiguration } from 'vs/base/common/product';
import { dirname, joinPath } from 'vs/base/common/resources';
import { ISandboxConfiguration } from 'vs/base/parts/sandbox/common/sandboxTypes';
/**
* @deprecated You MUST use `IProductService` if possible.
*/
let product: IProductConfiguration;
// Native sandbox environment
if (typeof globals.vscode !== 'undefined' && typeof globals.vscode.context !== 'undefined') {
const configuration: ISandboxConfiguration | undefined = globals.vscode.context.configuration();
if (configuration) {
product = configuration.product;
} else {
throw new Error('Sandbox: unable to resolve product configuration from preload script.');
}
}
// Native node.js environment
else if (typeof require?.__$__nodeRequire === 'function') {
// Obtain values from product.json and package.json
const rootPath = dirname(FileAccess.asFileUri('', require));
product = require.__$__nodeRequire(joinPath(rootPath, 'product.json').fsPath);
const pkg = require.__$__nodeRequire(joinPath(rootPath, 'package.json').fsPath) as { version: string };
// 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
});
}
Object.assign(product, {
version: pkg.version
});
}
// Web environment or unknown
else {
// Built time configuration (do NOT modify)
product = { /*BUILD->INSERT_PRODUCT_CONFIGURATION*/ } as IProductConfiguration;
// Running out of sources
if (Object.keys(product).length === 0) {
Object.assign(product, {
version: '1.66.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'
});
}
}
/**
* @deprecated You MUST use `IProductService` if possible.
*/
export default product;
|