@react-native-windows/telemetry 0.0.0-canary.13 → 0.0.0-canary.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib-commonjs/e2etest/telemetry.test.d.ts +26 -0
- package/lib-commonjs/e2etest/telemetry.test.js +574 -0
- package/lib-commonjs/e2etest/telemetry.test.js.map +1 -0
- package/lib-commonjs/index.d.ts +11 -7
- package/lib-commonjs/index.js +26 -14
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/telemetry.d.ts +76 -29
- package/lib-commonjs/telemetry.js +433 -201
- package/lib-commonjs/telemetry.js.map +1 -1
- package/lib-commonjs/test/{sanitize.test.d.ts → basePropUtils.test.d.ts} +7 -7
- package/lib-commonjs/test/basePropUtils.test.js +145 -0
- package/lib-commonjs/test/basePropUtils.test.js.map +1 -0
- package/lib-commonjs/test/errorUtils.test.d.ts +7 -0
- package/lib-commonjs/test/errorUtils.test.js +160 -0
- package/lib-commonjs/test/errorUtils.test.js.map +1 -0
- package/lib-commonjs/test/nameUtils.test.d.ts +7 -0
- package/lib-commonjs/test/nameUtils.test.js +54 -0
- package/lib-commonjs/test/nameUtils.test.js.map +1 -0
- package/lib-commonjs/test/projectUtils.test.d.ts +7 -0
- package/lib-commonjs/test/projectUtils.test.js +88 -0
- package/lib-commonjs/test/projectUtils.test.js.map +1 -0
- package/lib-commonjs/test/sanitizeUtils.test.d.ts +7 -0
- package/lib-commonjs/test/sanitizeUtils.test.js +98 -0
- package/lib-commonjs/test/sanitizeUtils.test.js.map +1 -0
- package/lib-commonjs/test/versionUtils.test.d.ts +7 -0
- package/lib-commonjs/test/versionUtils.test.js +115 -0
- package/lib-commonjs/test/versionUtils.test.js.map +1 -0
- package/lib-commonjs/utils/basePropUtils.d.ts +92 -0
- package/lib-commonjs/utils/basePropUtils.js +217 -0
- package/lib-commonjs/utils/basePropUtils.js.map +1 -0
- package/lib-commonjs/{CodedError.d.ts → utils/errorUtils.d.ts} +93 -61
- package/lib-commonjs/utils/errorUtils.js +183 -0
- package/lib-commonjs/utils/errorUtils.js.map +1 -0
- package/lib-commonjs/utils/nameUtils.d.ts +7 -0
- package/lib-commonjs/utils/nameUtils.js +22 -0
- package/lib-commonjs/utils/nameUtils.js.map +1 -0
- package/lib-commonjs/utils/optionUtils.d.ts +45 -0
- package/lib-commonjs/utils/optionUtils.js +96 -0
- package/lib-commonjs/utils/optionUtils.js.map +1 -0
- package/lib-commonjs/utils/projectUtils.d.ts +50 -0
- package/lib-commonjs/utils/projectUtils.js +185 -0
- package/lib-commonjs/utils/projectUtils.js.map +1 -0
- package/lib-commonjs/utils/sanitizeUtils.d.ts +12 -0
- package/lib-commonjs/utils/sanitizeUtils.js +85 -0
- package/lib-commonjs/utils/sanitizeUtils.js.map +1 -0
- package/lib-commonjs/utils/versionUtils.d.ts +38 -0
- package/lib-commonjs/utils/versionUtils.js +156 -0
- package/lib-commonjs/utils/versionUtils.js.map +1 -0
- package/package.json +40 -22
- package/CHANGELOG.json +0 -200
- package/CHANGELOG.md +0 -95
- package/lib-commonjs/CodedError.js +0 -77
- package/lib-commonjs/CodedError.js.map +0 -1
- package/lib-commonjs/test/sanitize.test.js +0 -258
- package/lib-commonjs/test/sanitize.test.js.map +0 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*
|
|
6
|
+
* @format
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const path_1 = __importDefault(require("path"));
|
|
36
|
+
const child_process_1 = require("child_process");
|
|
37
|
+
const projectUtils = __importStar(require("../utils/projectUtils"));
|
|
38
|
+
test('getProjectId() does not match project name', () => {
|
|
39
|
+
const projectName = 'test-project';
|
|
40
|
+
expect(projectUtils.getProjectId(projectName)).not.toContain(projectName);
|
|
41
|
+
});
|
|
42
|
+
test('getProjectId() does not change for same project name', () => {
|
|
43
|
+
const projectName = 'test-project';
|
|
44
|
+
expect(projectUtils.getProjectId(projectName)).toBe(projectUtils.getProjectId(projectName));
|
|
45
|
+
});
|
|
46
|
+
test('getProjectId() returns different ids for different project names', () => {
|
|
47
|
+
const projectName1 = 'test-project1';
|
|
48
|
+
const projectName2 = 'test-project2';
|
|
49
|
+
expect(projectUtils.getProjectId(projectName1)).not.toBe(projectUtils.getProjectId(projectName2));
|
|
50
|
+
});
|
|
51
|
+
test('usesReactNativeConfig() is false with no react-native.config.js present', async () => {
|
|
52
|
+
const projectRoot = path_1.default.resolve(__dirname, 'projects/BlankUsesTypeScript');
|
|
53
|
+
const value = await projectUtils.usesReactNativeConfig(projectRoot);
|
|
54
|
+
expect(value).toBe(false);
|
|
55
|
+
});
|
|
56
|
+
test('usesReactNativeConfig() is true with react-native.config.js present', async () => {
|
|
57
|
+
const projectRoot = path_1.default.resolve(__dirname, 'projects/BlankUsesReactNativeConfig');
|
|
58
|
+
const value = await projectUtils.usesReactNativeConfig(projectRoot);
|
|
59
|
+
expect(value).toBe(true);
|
|
60
|
+
});
|
|
61
|
+
test('usesTypeScript() is false with no tsconfig.json present', async () => {
|
|
62
|
+
const projectRoot = path_1.default.resolve(__dirname, 'projects/BlankUsesReactNativeConfig');
|
|
63
|
+
const value = await projectUtils.usesTypeScript(projectRoot);
|
|
64
|
+
expect(value).toBe(false);
|
|
65
|
+
});
|
|
66
|
+
test('usesTypeScript() is true with tsconfig.json present', async () => {
|
|
67
|
+
const projectRoot = path_1.default.resolve(__dirname, 'projects/BlankUsesTypeScript');
|
|
68
|
+
const value = await projectUtils.usesTypeScript(projectRoot);
|
|
69
|
+
expect(value).toBe(true);
|
|
70
|
+
});
|
|
71
|
+
test('configToProjectInfo() works with playground project info', async () => {
|
|
72
|
+
const playgroundRoot = path_1.default.resolve(__dirname, '../../../../playground');
|
|
73
|
+
const config = JSON.parse((0, child_process_1.execSync)('npx @react-native-community/cli config', {
|
|
74
|
+
cwd: playgroundRoot,
|
|
75
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
76
|
+
}).toString());
|
|
77
|
+
const info = await projectUtils.configToProjectInfo(config);
|
|
78
|
+
expect(info).not.toBeNull();
|
|
79
|
+
const projectInfo = info;
|
|
80
|
+
expect(projectInfo.id).toBe(projectUtils.getProjectId('playground'));
|
|
81
|
+
expect(projectInfo.platforms).toStrictEqual(['windows']);
|
|
82
|
+
expect(projectInfo.rnwLang).toBe('cpp');
|
|
83
|
+
expect(projectInfo.usesTS).toBe(true);
|
|
84
|
+
expect(projectInfo.usesRNConfig).toBe(true);
|
|
85
|
+
expect(projectInfo.jsEngine).toBe('Hermes');
|
|
86
|
+
expect(projectInfo.rnwSource).toBe('Source');
|
|
87
|
+
}, 200000 /* Increase timeout of this test */);
|
|
88
|
+
//# sourceMappingURL=projectUtils.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projectUtils.test.js","sourceRoot":"","sources":["../../src/test/projectUtils.test.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gDAAwB;AACxB,iDAAuC;AAEvC,oEAAsD;AAEtD,IAAI,CAAC,4CAA4C,EAAE,GAAG,EAAE;IACtD,MAAM,WAAW,GAAG,cAAc,CAAC;IACnC,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;AAC5E,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,sDAAsD,EAAE,GAAG,EAAE;IAChE,MAAM,WAAW,GAAG,cAAc,CAAC;IACnC,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CACjD,YAAY,CAAC,YAAY,CAAC,WAAW,CAAC,CACvC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,kEAAkE,EAAE,GAAG,EAAE;IAC5E,MAAM,YAAY,GAAG,eAAe,CAAC;IACrC,MAAM,YAAY,GAAG,eAAe,CAAC;IACrC,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CACtD,YAAY,CAAC,YAAY,CAAC,YAAY,CAAC,CACxC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,yEAAyE,EAAE,KAAK,IAAI,EAAE;IACzF,MAAM,WAAW,GAAG,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CAAC,CAAC;IACzE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CACvB,IAAA,wBAAQ,EAAC,wCAAwC,EAAE;QACjD,GAAG,EAAE,cAAc;QACnB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;KACpC,CAAC,CAAC,QAAQ,EAAE,CACd,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC5D,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAE5B,MAAM,WAAW,GAAG,IAAmC,CAAC;IAExD,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;IACrE,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IACzD,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC/C,CAAC,EAAE,MAAM,CAAC,mCAAmC,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\nimport path from 'path';\nimport {execSync} from 'child_process';\n\nimport * as projectUtils from '../utils/projectUtils';\n\ntest('getProjectId() does not match project name', () => {\n const projectName = 'test-project';\n expect(projectUtils.getProjectId(projectName)).not.toContain(projectName);\n});\n\ntest('getProjectId() does not change for same project name', () => {\n const projectName = 'test-project';\n expect(projectUtils.getProjectId(projectName)).toBe(\n projectUtils.getProjectId(projectName),\n );\n});\n\ntest('getProjectId() returns different ids for different project names', () => {\n const projectName1 = 'test-project1';\n const projectName2 = 'test-project2';\n expect(projectUtils.getProjectId(projectName1)).not.toBe(\n projectUtils.getProjectId(projectName2),\n );\n});\n\ntest('usesReactNativeConfig() is false with no react-native.config.js present', async () => {\n const projectRoot = path.resolve(__dirname, 'projects/BlankUsesTypeScript');\n const value = await projectUtils.usesReactNativeConfig(projectRoot);\n expect(value).toBe(false);\n});\n\ntest('usesReactNativeConfig() is true with react-native.config.js present', async () => {\n const projectRoot = path.resolve(\n __dirname,\n 'projects/BlankUsesReactNativeConfig',\n );\n const value = await projectUtils.usesReactNativeConfig(projectRoot);\n expect(value).toBe(true);\n});\n\ntest('usesTypeScript() is false with no tsconfig.json present', async () => {\n const projectRoot = path.resolve(\n __dirname,\n 'projects/BlankUsesReactNativeConfig',\n );\n const value = await projectUtils.usesTypeScript(projectRoot);\n expect(value).toBe(false);\n});\n\ntest('usesTypeScript() is true with tsconfig.json present', async () => {\n const projectRoot = path.resolve(__dirname, 'projects/BlankUsesTypeScript');\n const value = await projectUtils.usesTypeScript(projectRoot);\n expect(value).toBe(true);\n});\n\ntest('configToProjectInfo() works with playground project info', async () => {\n const playgroundRoot = path.resolve(__dirname, '../../../../playground');\n const config = JSON.parse(\n execSync('npx @react-native-community/cli config', {\n cwd: playgroundRoot,\n stdio: ['ignore', 'pipe', 'ignore'],\n }).toString(),\n );\n\n const info = await projectUtils.configToProjectInfo(config);\n expect(info).not.toBeNull();\n\n const projectInfo = info as projectUtils.AppProjectInfo;\n\n expect(projectInfo.id).toBe(projectUtils.getProjectId('playground'));\n expect(projectInfo.platforms).toStrictEqual(['windows']);\n expect(projectInfo.rnwLang).toBe('cpp');\n expect(projectInfo.usesTS).toBe(true);\n expect(projectInfo.usesRNConfig).toBe(true);\n expect(projectInfo.jsEngine).toBe('Hermes');\n expect(projectInfo.rnwSource).toBe('Source');\n}, 200000 /* Increase timeout of this test */);\n"]}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*
|
|
6
|
+
* @format
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const path_1 = __importDefault(require("path"));
|
|
36
|
+
const sanitizeUtils = __importStar(require("../utils/sanitizeUtils"));
|
|
37
|
+
const projectDir = process.cwd();
|
|
38
|
+
test('getAnonymizedPath() with project dir is anonymized', () => {
|
|
39
|
+
const originalPath = projectDir;
|
|
40
|
+
const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);
|
|
41
|
+
expect(anonymizedPath).not.toBe(originalPath);
|
|
42
|
+
expect(anonymizedPath.startsWith('[project_dir]')).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
test('getAnonymizedPath() with project/index.js is anonymized', () => {
|
|
45
|
+
const originalPath = path_1.default.join(projectDir, 'index.js');
|
|
46
|
+
const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);
|
|
47
|
+
expect(anonymizedPath).not.toBe(originalPath);
|
|
48
|
+
expect(anonymizedPath.startsWith('[project_dir]\\???.js')).toBe(true);
|
|
49
|
+
});
|
|
50
|
+
test('getAnonymizedPath() with project/windows/test.sln is anonymized', () => {
|
|
51
|
+
const originalPath = path_1.default.normalize(path_1.default.join(projectDir, 'windows/test.sln'));
|
|
52
|
+
const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);
|
|
53
|
+
expect(anonymizedPath).not.toBe(originalPath);
|
|
54
|
+
expect(anonymizedPath.startsWith('[windows]\\???.sln')).toBe(true);
|
|
55
|
+
});
|
|
56
|
+
test('getAnonymizedPath() with project/node_modules for untracked package is anonymized', () => {
|
|
57
|
+
const originalPath = path_1.default.normalize(path_1.default.join(projectDir, 'node_modules/untracked/index.js'));
|
|
58
|
+
const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);
|
|
59
|
+
expect(anonymizedPath).not.toBe(originalPath);
|
|
60
|
+
expect(anonymizedPath.startsWith('[node_modules]\\???.js')).toBe(true);
|
|
61
|
+
});
|
|
62
|
+
test('getAnonymizedPath() with project/node_modules for react-secret-pii package is anonymized', () => {
|
|
63
|
+
const originalPath = path_1.default.normalize(path_1.default.join(projectDir, 'node_modules/react-secret-pii/index.js'));
|
|
64
|
+
const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);
|
|
65
|
+
expect(anonymizedPath).not.toBe(originalPath);
|
|
66
|
+
expect(anonymizedPath.startsWith('[node_modules]\\???.js')).toBe(true);
|
|
67
|
+
});
|
|
68
|
+
test('getAnonymizedPath() with path under react-native-windows is anonymized', () => {
|
|
69
|
+
const originalPath = path_1.default.normalize(path_1.default.join(projectDir, 'node_modules/react-native-windows/index.js'));
|
|
70
|
+
const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);
|
|
71
|
+
expect(anonymizedPath).not.toBe(originalPath);
|
|
72
|
+
expect(anonymizedPath).toBe('[node_modules]\\react-native-windows\\index.js');
|
|
73
|
+
});
|
|
74
|
+
test('getAnonymizedPath() with path under @react-native-windows/cli is anonymized', () => {
|
|
75
|
+
const originalPath = path_1.default.normalize(path_1.default.join(projectDir, 'node_modules/@react-native-windows/cli/index.js'));
|
|
76
|
+
const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);
|
|
77
|
+
expect(anonymizedPath).not.toBe(originalPath);
|
|
78
|
+
expect(anonymizedPath).toBe('[node_modules]\\@react-native-windows\\cli\\index.js');
|
|
79
|
+
});
|
|
80
|
+
test('getAnonymizedPath() with path under %%LocalAppData%% is anonymized', () => {
|
|
81
|
+
const originalPath = path_1.default.normalize(path_1.default.join(process.env.LocalAppData, 'test.sln'));
|
|
82
|
+
const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);
|
|
83
|
+
expect(anonymizedPath).not.toBe(originalPath);
|
|
84
|
+
expect(anonymizedPath.startsWith('[LocalAppData]\\???')).toBe(true);
|
|
85
|
+
});
|
|
86
|
+
test('getAnonymizedPath() with a tracked npm package under %%LocalAppData%% is anonymized', () => {
|
|
87
|
+
const originalPath = path_1.default.normalize(path_1.default.join(process.env.LocalAppData, 'node_modules/@react-native-windows/cli/index.js'));
|
|
88
|
+
const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);
|
|
89
|
+
expect(anonymizedPath).not.toBe(originalPath);
|
|
90
|
+
expect(anonymizedPath).toBe('[node_modules]\\@react-native-windows\\cli\\index.js');
|
|
91
|
+
});
|
|
92
|
+
test('getAnonymizedPath() with arbitrary path not under project dir is anonymized', () => {
|
|
93
|
+
const originalPath = 'test.sln';
|
|
94
|
+
const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);
|
|
95
|
+
expect(anonymizedPath).not.toBe(originalPath);
|
|
96
|
+
expect(anonymizedPath).toBe('[path]');
|
|
97
|
+
});
|
|
98
|
+
//# sourceMappingURL=sanitizeUtils.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitizeUtils.test.js","sourceRoot":"","sources":["../../src/test/sanitizeUtils.test.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gDAAwB;AAExB,sEAAwD;AAExD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAEjC,IAAI,CAAC,oDAAoD,EAAE,GAAG,EAAE;IAC9D,MAAM,YAAY,GAAG,UAAU,CAAC;IAChC,MAAM,cAAc,GAAG,aAAa,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;IACrE,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC9C,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChE,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,yDAAyD,EAAE,GAAG,EAAE;IACnE,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACvD,MAAM,cAAc,GAAG,aAAa,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;IACrE,MAAM,CAAC,cAAc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iB,CAAC,YAAY,CAAC,CAAC;IACrE,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC9C,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACtE,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,qFAAqF,EAAE,GAAG,EAAE;IAC/F,MAAM,YAAY,GAAG,cAAI,CAAC,SAAS,CACjC,cAAI,CAAC,IAAI,CACP,OAAO,CAAC,GAAG,CAAC,YAAa,EACzB,iDAAiD,CAClD,CACF,CAAC;IACF,MAAM,cAAc,GAAG,aAAa,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;IACrE,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC9C,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,CACzB,sDAAsD,CACvD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,6EAA6E,EAAE,GAAG,EAAE;IACvF,MAAM,YAAY,GAAG,UAAU,CAAC;IAChC,MAAM,cAAc,GAAG,aAAa,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;IACrE,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC9C,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACxC,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\nimport path from 'path';\n\nimport * as sanitizeUtils from '../utils/sanitizeUtils';\n\nconst projectDir = process.cwd();\n\ntest('getAnonymizedPath() with project dir is anonymized', () => {\n const originalPath = projectDir;\n const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);\n expect(anonymizedPath).not.toBe(originalPath);\n expect(anonymizedPath.startsWith('[project_dir]')).toBe(true);\n});\n\ntest('getAnonymizedPath() with project/index.js is anonymized', () => {\n const originalPath = path.join(projectDir, 'index.js');\n const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);\n expect(anonymizedPath).not.toBe(originalPath);\n expect(anonymizedPath.startsWith('[project_dir]\\\\???.js')).toBe(true);\n});\n\ntest('getAnonymizedPath() with project/windows/test.sln is anonymized', () => {\n const originalPath = path.normalize(\n path.join(projectDir, 'windows/test.sln'),\n );\n const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);\n expect(anonymizedPath).not.toBe(originalPath);\n expect(anonymizedPath.startsWith('[windows]\\\\???.sln')).toBe(true);\n});\n\ntest('getAnonymizedPath() with project/node_modules for untracked package is anonymized', () => {\n const originalPath = path.normalize(\n path.join(projectDir, 'node_modules/untracked/index.js'),\n );\n const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);\n expect(anonymizedPath).not.toBe(originalPath);\n expect(anonymizedPath.startsWith('[node_modules]\\\\???.js')).toBe(true);\n});\n\ntest('getAnonymizedPath() with project/node_modules for react-secret-pii package is anonymized', () => {\n const originalPath = path.normalize(\n path.join(projectDir, 'node_modules/react-secret-pii/index.js'),\n );\n const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);\n expect(anonymizedPath).not.toBe(originalPath);\n expect(anonymizedPath.startsWith('[node_modules]\\\\???.js')).toBe(true);\n});\n\ntest('getAnonymizedPath() with path under react-native-windows is anonymized', () => {\n const originalPath = path.normalize(\n path.join(projectDir, 'node_modules/react-native-windows/index.js'),\n );\n const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);\n expect(anonymizedPath).not.toBe(originalPath);\n expect(anonymizedPath).toBe('[node_modules]\\\\react-native-windows\\\\index.js');\n});\n\ntest('getAnonymizedPath() with path under @react-native-windows/cli is anonymized', () => {\n const originalPath = path.normalize(\n path.join(projectDir, 'node_modules/@react-native-windows/cli/index.js'),\n );\n const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);\n expect(anonymizedPath).not.toBe(originalPath);\n expect(anonymizedPath).toBe(\n '[node_modules]\\\\@react-native-windows\\\\cli\\\\index.js',\n );\n});\n\ntest('getAnonymizedPath() with path under %%LocalAppData%% is anonymized', () => {\n const originalPath = path.normalize(\n path.join(process.env.LocalAppData!, 'test.sln'),\n );\n const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);\n expect(anonymizedPath).not.toBe(originalPath);\n expect(anonymizedPath.startsWith('[LocalAppData]\\\\???')).toBe(true);\n});\n\ntest('getAnonymizedPath() with a tracked npm package under %%LocalAppData%% is anonymized', () => {\n const originalPath = path.normalize(\n path.join(\n process.env.LocalAppData!,\n 'node_modules/@react-native-windows/cli/index.js',\n ),\n );\n const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);\n expect(anonymizedPath).not.toBe(originalPath);\n expect(anonymizedPath).toBe(\n '[node_modules]\\\\@react-native-windows\\\\cli\\\\index.js',\n );\n});\n\ntest('getAnonymizedPath() with arbitrary path not under project dir is anonymized', () => {\n const originalPath = 'test.sln';\n const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);\n expect(anonymizedPath).not.toBe(originalPath);\n expect(anonymizedPath).toBe('[path]');\n});\n"]}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*
|
|
6
|
+
* @format
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const versionUtils = __importStar(require("../utils/versionUtils"));
|
|
36
|
+
const path_1 = __importDefault(require("path"));
|
|
37
|
+
const semver_1 = __importDefault(require("semver"));
|
|
38
|
+
function expectValidVersion(version, expectSemVer) {
|
|
39
|
+
expect(version).not.toBeNull();
|
|
40
|
+
expect(version).toBeDefined();
|
|
41
|
+
if (expectSemVer) {
|
|
42
|
+
expect(semver_1.default.valid(version)).toBe(version);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
version.split('.').forEach(s => {
|
|
46
|
+
const tryParseInt = () => {
|
|
47
|
+
parseInt(s, 10);
|
|
48
|
+
};
|
|
49
|
+
expect(tryParseInt).not.toThrow();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
test('getNodeVersion() is valid', async () => {
|
|
54
|
+
const version = await versionUtils.getNodeVersion();
|
|
55
|
+
expectValidVersion(version, true);
|
|
56
|
+
});
|
|
57
|
+
test('getNpmVersion() is valid', async () => {
|
|
58
|
+
const version = await versionUtils.getNpmVersion();
|
|
59
|
+
if (version) {
|
|
60
|
+
expectValidVersion(version, true);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
test('getYarnVersion() is valid', async () => {
|
|
64
|
+
const version = await versionUtils.getYarnVersion();
|
|
65
|
+
if (version) {
|
|
66
|
+
expectValidVersion(version, true);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
test('getVisualStudioVersion() is valid', async () => {
|
|
70
|
+
const version = await versionUtils.getVisualStudioVersion();
|
|
71
|
+
expectValidVersion(version, false);
|
|
72
|
+
});
|
|
73
|
+
test('getVersionOfNpmPackage() of empty string is null', async () => {
|
|
74
|
+
const version = await versionUtils.getVersionOfNpmPackage('');
|
|
75
|
+
expect(version).toBeNull();
|
|
76
|
+
});
|
|
77
|
+
test('getVersionOfNpmPackage() of invalid package is null', async () => {
|
|
78
|
+
const version = await versionUtils.getVersionOfNpmPackage('invalidpackage');
|
|
79
|
+
expect(version).toBeNull();
|
|
80
|
+
});
|
|
81
|
+
test('getVersionOfNpmPackage() of valid package is valid', async () => {
|
|
82
|
+
const version = await versionUtils.getVersionOfNpmPackage('jest');
|
|
83
|
+
expectValidVersion(version, true);
|
|
84
|
+
});
|
|
85
|
+
test('getVersionsOfNuGetPackages() of valid package in packages.config is valid', async () => {
|
|
86
|
+
const projectFile = path_1.default.resolve(__dirname, 'projects/UsesPackagesConfig/UsesPackagesConfig.vcxproj');
|
|
87
|
+
const versions = await versionUtils.getVersionsOfNuGetPackages(projectFile, [
|
|
88
|
+
'Microsoft.Windows.CppWinRT',
|
|
89
|
+
]);
|
|
90
|
+
expect(versions).not.toBeNull();
|
|
91
|
+
expectValidVersion(versions['Microsoft.Windows.CppWinRT'], false);
|
|
92
|
+
});
|
|
93
|
+
test('getVersionsOfNuGetPackages() of invalid package in packages.config is invalid', async () => {
|
|
94
|
+
const projectFile = path_1.default.resolve(__dirname, 'projects/UsesPackagesConfig/UsesPackagesConfig.vcxproj');
|
|
95
|
+
const versions = await versionUtils.getVersionsOfNuGetPackages(projectFile, [
|
|
96
|
+
'Invalid.Package',
|
|
97
|
+
]);
|
|
98
|
+
expect(versions).toStrictEqual({});
|
|
99
|
+
});
|
|
100
|
+
test('getVersionsOfNuGetPackages() of valid package in project is valid', async () => {
|
|
101
|
+
const projectFile = path_1.default.resolve(__dirname, 'projects/UsesPackageReference/UsesPackageReference.csproj');
|
|
102
|
+
const versions = await versionUtils.getVersionsOfNuGetPackages(projectFile, [
|
|
103
|
+
'Microsoft.NETCore.UniversalWindowsPlatform',
|
|
104
|
+
]);
|
|
105
|
+
expect(versions).not.toBeNull();
|
|
106
|
+
expectValidVersion(versions['Microsoft.NETCore.UniversalWindowsPlatform'], false);
|
|
107
|
+
});
|
|
108
|
+
test('getVersionsOfNuGetPackages() of invalid package in project is invalid', async () => {
|
|
109
|
+
const projectFile = path_1.default.resolve(__dirname, 'projects/UsesPackageReference/UsesPackageReference.csproj');
|
|
110
|
+
const versions = await versionUtils.getVersionsOfNuGetPackages(projectFile, [
|
|
111
|
+
'Invalid.Package',
|
|
112
|
+
]);
|
|
113
|
+
expect(versions).toStrictEqual({});
|
|
114
|
+
});
|
|
115
|
+
//# sourceMappingURL=versionUtils.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versionUtils.test.js","sourceRoot":"","sources":["../../src/test/versionUtils.test.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oEAAsD;AAEtD,gDAAwB;AACxB,oDAA4B;AAE5B,SAAS,kBAAkB,CAAC,OAAsB,EAAE,YAAqB;IACvE,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC/B,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IAC9B,IAAI,YAAY,EA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AM,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;AACrC,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,mEAAmE,EAAE,KAAK,IAAI,EAAE;IACnF,MAAM,WAAW,GAAG,cAAI,CAAC,OAAO,CAC9B,SAAS,EACT,2DAA2D,CAC5D,CAAC;IACF,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,0BAA0B,CAAC,WAAW,EAAE;QAC1E,4CAA4C;KAC7C,CAAC,CAAC;IACH,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAChC,kBAAkB,CAChB,QAAQ,CAAC,4CAA4C,CAAC,EACtD,KAAK,CACN,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,uEAAuE,EAAE,KAAK,IAAI,EAAE;IACvF,MAAM,WAAW,GAAG,cAAI,CAAC,OAAO,CAC9B,SAAS,EACT,2DAA2D,CAC5D,CAAC;IACF,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,0BAA0B,CAAC,WAAW,EAAE;QAC1E,iBAAiB;KAClB,CAAC,CAAC;IACH,MAAM,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;AACrC,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\nimport * as versionUtils from '../utils/versionUtils';\n\nimport path from 'path';\nimport semver from 'semver';\n\nfunction expectValidVersion(version: string | null, expectSemVer: boolean) {\n expect(version).not.toBeNull();\n expect(version).toBeDefined();\n if (expectSemVer) {\n expect(semver.valid(version)).toBe(version);\n } else {\n version!.split('.').forEach(s => {\n const tryParseInt = () => {\n parseInt(s, 10);\n };\n expect(tryParseInt).not.toThrow();\n });\n }\n}\n\ntest('getNodeVersion() is valid', async () => {\n const version = await versionUtils.getNodeVersion();\n expectValidVersion(version, true);\n});\n\ntest('getNpmVersion() is valid', async () => {\n const version = await versionUtils.getNpmVersion();\n if (version) {\n expectValidVersion(version, true);\n }\n});\n\ntest('getYarnVersion() is valid', async () => {\n const version = await versionUtils.getYarnVersion();\n if (version) {\n expectValidVersion(version, true);\n }\n});\n\ntest('getVisualStudioVersion() is valid', async () => {\n const version = await versionUtils.getVisualStudioVersion();\n expectValidVersion(version, false);\n});\n\ntest('getVersionOfNpmPackage() of empty string is null', async () => {\n const version = await versionUtils.getVersionOfNpmPackage('');\n expect(version).toBeNull();\n});\n\ntest('getVersionOfNpmPackage() of invalid package is null', async () => {\n const version = await versionUtils.getVersionOfNpmPackage('invalidpackage');\n expect(version).toBeNull();\n});\n\ntest('getVersionOfNpmPackage() of valid package is valid', async () => {\n const version = await versionUtils.getVersionOfNpmPackage('jest');\n expectValidVersion(version, true);\n});\n\ntest('getVersionsOfNuGetPackages() of valid package in packages.config is valid', async () => {\n const projectFile = path.resolve(\n __dirname,\n 'projects/UsesPackagesConfig/UsesPackagesConfig.vcxproj',\n );\n const versions = await versionUtils.getVersionsOfNuGetPackages(projectFile, [\n 'Microsoft.Windows.CppWinRT',\n ]);\n expect(versions).not.toBeNull();\n expectValidVersion(versions['Microsoft.Windows.CppWinRT'], false);\n});\n\ntest('getVersionsOfNuGetPackages() of invalid package in packages.config is invalid', async () => {\n const projectFile = path.resolve(\n __dirname,\n 'projects/UsesPackagesConfig/UsesPackagesConfig.vcxproj',\n );\n const versions = await versionUtils.getVersionsOfNuGetPackages(projectFile, [\n 'Invalid.Package',\n ]);\n expect(versions).toStrictEqual({});\n});\n\ntest('getVersionsOfNuGetPackages() of valid package in project is valid', async () => {\n const projectFile = path.resolve(\n __dirname,\n 'projects/UsesPackageReference/UsesPackageReference.csproj',\n );\n const versions = await versionUtils.getVersionsOfNuGetPackages(projectFile, [\n 'Microsoft.NETCore.UniversalWindowsPlatform',\n ]);\n expect(versions).not.toBeNull();\n expectValidVersion(\n versions['Microsoft.NETCore.UniversalWindowsPlatform'],\n false,\n );\n});\n\ntest('getVersionsOfNuGetPackages() of invalid package in project is invalid', async () => {\n const projectFile = path.resolve(\n __dirname,\n 'projects/UsesPackageReference/UsesPackageReference.csproj',\n );\n const versions = await versionUtils.getVersionsOfNuGetPackages(projectFile, [\n 'Invalid.Package',\n ]);\n expect(versions).toStrictEqual({});\n});\n"]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
* @format
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Given a path and a key, retrieves the value from the Registry.
|
|
8
|
+
* @returns If the path and key exist, the requested value from the Registry; empty string otherwise.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getValueFromRegistry(path: string, key: string): Promise<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Gets a telemetry-safe stable device ID.
|
|
13
|
+
* @returns A telemetry-safe stable device ID.
|
|
14
|
+
*/
|
|
15
|
+
export declare function deviceId(): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Gets the Windows build name, number and architecture.
|
|
18
|
+
* @returns A string containing the Windows build name, number and architecture.
|
|
19
|
+
* e.g. 19569.1000.amd64fre.rs_prerelease.200214-1419
|
|
20
|
+
*/
|
|
21
|
+
export declare function fullBuildInfo(): Promise<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Gets the device architecture, like x86/x64/arm64.
|
|
24
|
+
* @returns The device architecture.
|
|
25
|
+
*/
|
|
26
|
+
export declare function deviceArchitecture(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the node architecture, like x86/x64/arm64.
|
|
29
|
+
* @returns The node architecture.
|
|
30
|
+
*/
|
|
31
|
+
export declare function nodeArchitecture(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the node platform, like darwin/linux/win32.
|
|
34
|
+
* @returns The device platform.
|
|
35
|
+
*/
|
|
36
|
+
export declare function nodePlatform(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the OS name, to be filled in the PartA device.deviceClass field.
|
|
39
|
+
* @returns The device class.
|
|
40
|
+
*/
|
|
41
|
+
export declare function deviceClass(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Gets the device locale.
|
|
44
|
+
* @returns The device locale.
|
|
45
|
+
*/
|
|
46
|
+
export declare function deviceLocale(): Promise<string>;
|
|
47
|
+
/**
|
|
48
|
+
* Gets the device's number of CPUs.
|
|
49
|
+
* @returns The device's number of CPUs.
|
|
50
|
+
*/
|
|
51
|
+
export declare function deviceNumCPUs(): number;
|
|
52
|
+
/**
|
|
53
|
+
* Gets the device's total memory in bytes.
|
|
54
|
+
* @returns The device's total memory in bytes.
|
|
55
|
+
*/
|
|
56
|
+
export declare function deviceTotalMemory(): number;
|
|
57
|
+
/**
|
|
58
|
+
* Gets the free space of the give drive in bytes.
|
|
59
|
+
* @param drivePath A path on the drive to check.
|
|
60
|
+
* @returns The free space of the give drive in bytes.
|
|
61
|
+
*/
|
|
62
|
+
export declare function deviceDiskFreeSpace(drivePath?: string | null): number;
|
|
63
|
+
/**
|
|
64
|
+
* Gets whether or not telemetry events are captured when running in CI.
|
|
65
|
+
* @returns Whether or not telemetry events are captured when running in CI.
|
|
66
|
+
*/
|
|
67
|
+
export declare function captureCI(): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Gets the whether the process is currently running in CI.
|
|
70
|
+
* @returns Whether the process is currently running in CI.
|
|
71
|
+
*/
|
|
72
|
+
export declare function isCI(): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Gets the type of CI the process is running under.
|
|
75
|
+
* @returns The type of CI the process is running under.
|
|
76
|
+
*/
|
|
77
|
+
export declare function ciType(): string;
|
|
78
|
+
/**
|
|
79
|
+
* Gets whether the process is running on a Microsoft owned machine.
|
|
80
|
+
* @returns Whether the process is running on a Microsoft owned machine.
|
|
81
|
+
*/
|
|
82
|
+
export declare function isMsftInternal(): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Gets whether the process is running as part of our CLI tests.
|
|
85
|
+
* @returns Whether the process is running as part of our CLI tests.
|
|
86
|
+
*/
|
|
87
|
+
export declare function isCliTest(): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Gets a stable session ID for correlating telemetry events.
|
|
90
|
+
* @returns A stable session ID for correlating telemetry events.
|
|
91
|
+
*/
|
|
92
|
+
export declare function getSessionId(): string;
|