@react-native-windows/telemetry 0.0.0-canary.9 → 0.0.0-canary.90
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 +28 -0
- package/lib-commonjs/e2etest/telemetry.test.js +497 -0
- package/lib-commonjs/e2etest/telemetry.test.js.map +1 -0
- package/lib-commonjs/index.d.ts +11 -6
- package/lib-commonjs/index.js +26 -11
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/telemetry.d.ts +84 -27
- package/lib-commonjs/telemetry.js +370 -171
- 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 +138 -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 +166 -0
- package/lib-commonjs/test/errorUtils.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 +81 -0
- package/lib-commonjs/utils/basePropUtils.js +174 -0
- package/lib-commonjs/utils/basePropUtils.js.map +1 -0
- package/lib-commonjs/utils/errorUtils.d.ts +87 -0
- package/lib-commonjs/utils/errorUtils.js +179 -0
- package/lib-commonjs/utils/errorUtils.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 +187 -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 +82 -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 +35 -21
- package/CHANGELOG.json +0 -125
- package/CHANGELOG.md +0 -63
- package/lib-commonjs/test/sanitize.test.js +0 -220
- package/lib-commonjs/test/sanitize.test.js.map +0 -1
|
@@ -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,EAAE;QAChB,MAAM,CAAC,gBAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KAC7C;SAAM;QACL,OAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YAC9B,MAAM,WAAW,GAAG,GAAG,EAAE;gBACvB,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAClB,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C1E,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,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
* @format
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Gets a telemetry-safe stable device ID.
|
|
8
|
+
* @returns A telemetry-safe stable device ID.
|
|
9
|
+
*/
|
|
10
|
+
export declare function deviceId(): Promise<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Gets the device architecture, like x86/x64/arm64.
|
|
13
|
+
* @returns The device architecture.
|
|
14
|
+
*/
|
|
15
|
+
export declare function deviceArchitecture(): string;
|
|
16
|
+
/**
|
|
17
|
+
* Gets the node architecture, like x86/x64/arm64.
|
|
18
|
+
* @returns The node architecture.
|
|
19
|
+
*/
|
|
20
|
+
export declare function nodeArchitecture(): string;
|
|
21
|
+
/**
|
|
22
|
+
* Gets the device platform, like darwin/linux/win32.
|
|
23
|
+
* @returns The device platform.
|
|
24
|
+
*/
|
|
25
|
+
export declare function devicePlatform(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Gets the device locale.
|
|
28
|
+
* @returns The device locale.
|
|
29
|
+
*/
|
|
30
|
+
export declare function deviceLocale(): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Gets the device's number of CPUs.
|
|
33
|
+
* @returns The device's number of CPUs.
|
|
34
|
+
*/
|
|
35
|
+
export declare function deviceNumCPUs(): number;
|
|
36
|
+
/**
|
|
37
|
+
* Gets the device's total memory in bytes.
|
|
38
|
+
* @returns The device's total memory in bytes.
|
|
39
|
+
*/
|
|
40
|
+
export declare function deviceTotalMemory(): number;
|
|
41
|
+
/**
|
|
42
|
+
* Gets the free space of the give drive in bytes.
|
|
43
|
+
* @param drivePath A path on the drive to check.
|
|
44
|
+
* @returns The free space of the give drive in bytes.
|
|
45
|
+
*/
|
|
46
|
+
export declare function deviceDiskFreeSpace(drivePath?: string | null): number;
|
|
47
|
+
/**
|
|
48
|
+
* Gets the telemetry sample rate.
|
|
49
|
+
* @returns The telemetry sample rate.
|
|
50
|
+
*/
|
|
51
|
+
export declare function sampleRate(): number;
|
|
52
|
+
/**
|
|
53
|
+
* Gets whether or not telemetry events are captured when running in CI.
|
|
54
|
+
* @returns Whether or not telemetry events are captured when running in CI.
|
|
55
|
+
*/
|
|
56
|
+
export declare function captureCI(): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Gets the whether the process is currently running in CI.
|
|
59
|
+
* @returns Whether the process is currently running in CI.
|
|
60
|
+
*/
|
|
61
|
+
export declare function isCI(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Gets the type of CI the process is running under.
|
|
64
|
+
* @returns The type of CI the process is running under.
|
|
65
|
+
*/
|
|
66
|
+
export declare function ciType(): string;
|
|
67
|
+
/**
|
|
68
|
+
* Gets whether the process is running on a Microsoft owned machine.
|
|
69
|
+
* @returns Whether the process is running on a Microsoft owned machine.
|
|
70
|
+
*/
|
|
71
|
+
export declare function isMsftInternal(): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Gets whether the process is running as part of our CLI tests.
|
|
74
|
+
* @returns Whether the process is running as part of our CLI tests.
|
|
75
|
+
*/
|
|
76
|
+
export declare function isCliTest(): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Gets a stable session ID for correlating telemetry events.
|
|
79
|
+
* @returns A stable session ID for correlating telemetry events.
|
|
80
|
+
*/
|
|
81
|
+
export declare function getSessionId(): string;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.getSessionId = exports.isCliTest = exports.isMsftInternal = exports.ciType = exports.isCI = exports.captureCI = exports.sampleRate = exports.deviceDiskFreeSpace = exports.deviceTotalMemory = exports.deviceNumCPUs = exports.deviceLocale = exports.devicePlatform = exports.nodeArchitecture = exports.deviceArchitecture = exports.deviceId = void 0;
|
|
12
|
+
const child_process_1 = require("child_process");
|
|
13
|
+
const os_1 = require("os");
|
|
14
|
+
const ci_info_1 = __importDefault(require("ci-info"));
|
|
15
|
+
const crypto_1 = require("crypto");
|
|
16
|
+
const os_locale_1 = __importDefault(require("os-locale"));
|
|
17
|
+
const DeviceIdRegPath = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\SQMClient';
|
|
18
|
+
const DeviceIdRegKey = 'MachineId';
|
|
19
|
+
/**
|
|
20
|
+
* Gets a telemetry-safe stable device ID.
|
|
21
|
+
* @returns A telemetry-safe stable device ID.
|
|
22
|
+
*/
|
|
23
|
+
async function deviceId() {
|
|
24
|
+
try {
|
|
25
|
+
let regCommand = `${process.env.windir}\\System32\\reg.exe query ${DeviceIdRegPath} /v ${DeviceIdRegKey}`;
|
|
26
|
+
if (deviceArchitecture() === 'x64') {
|
|
27
|
+
// Ensure we query the correct registry
|
|
28
|
+
regCommand += ' /reg:64';
|
|
29
|
+
}
|
|
30
|
+
const output = (0, child_process_1.execSync)(regCommand).toString();
|
|
31
|
+
const result = output.match(/\{([0-9A-Fa-f-]{36})\}/);
|
|
32
|
+
if (result && result.length > 1) {
|
|
33
|
+
return `s:${result[1]}`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (_a) { }
|
|
37
|
+
return '';
|
|
38
|
+
}
|
|
39
|
+
exports.deviceId = deviceId;
|
|
40
|
+
/**
|
|
41
|
+
* Gets the device architecture, like x86/x64/arm64.
|
|
42
|
+
* @returns The device architecture.
|
|
43
|
+
*/
|
|
44
|
+
function deviceArchitecture() {
|
|
45
|
+
const nodeArch = nodeArchitecture();
|
|
46
|
+
// Check if we're running x86 node on x64 hardware
|
|
47
|
+
if (nodeArch === 'x86' && process.env.PROCESSOR_ARCHITEW6432 === 'AMD64') {
|
|
48
|
+
return 'x64';
|
|
49
|
+
}
|
|
50
|
+
return nodeArch;
|
|
51
|
+
}
|
|
52
|
+
exports.deviceArchitecture = deviceArchitecture;
|
|
53
|
+
/**
|
|
54
|
+
* Gets the node architecture, like x86/x64/arm64.
|
|
55
|
+
* @returns The node architecture.
|
|
56
|
+
*/
|
|
57
|
+
function nodeArchitecture() {
|
|
58
|
+
return process.arch === 'ia32' ? 'x86' : process.arch;
|
|
59
|
+
}
|
|
60
|
+
exports.nodeArchitecture = nodeArchitecture;
|
|
61
|
+
/**
|
|
62
|
+
* Gets the device platform, like darwin/linux/win32.
|
|
63
|
+
* @returns The device platform.
|
|
64
|
+
*/
|
|
65
|
+
function devicePlatform() {
|
|
66
|
+
return (0, os_1.platform)();
|
|
67
|
+
}
|
|
68
|
+
exports.devicePlatform = devicePlatform;
|
|
69
|
+
/**
|
|
70
|
+
* Gets the device locale.
|
|
71
|
+
* @returns The device locale.
|
|
72
|
+
*/
|
|
73
|
+
async function deviceLocale() {
|
|
74
|
+
return await (0, os_locale_1.default)();
|
|
75
|
+
}
|
|
76
|
+
exports.deviceLocale = deviceLocale;
|
|
77
|
+
/**
|
|
78
|
+
* Gets the device's number of CPUs.
|
|
79
|
+
* @returns The device's number of CPUs.
|
|
80
|
+
*/
|
|
81
|
+
function deviceNumCPUs() {
|
|
82
|
+
return (0, os_1.cpus)().length;
|
|
83
|
+
}
|
|
84
|
+
exports.deviceNumCPUs = deviceNumCPUs;
|
|
85
|
+
/**
|
|
86
|
+
* Gets the device's total memory in bytes.
|
|
87
|
+
* @returns The device's total memory in bytes.
|
|
88
|
+
*/
|
|
89
|
+
function deviceTotalMemory() {
|
|
90
|
+
return (0, os_1.totalmem)();
|
|
91
|
+
}
|
|
92
|
+
exports.deviceTotalMemory = deviceTotalMemory;
|
|
93
|
+
/**
|
|
94
|
+
* Gets the free space of the give drive in bytes.
|
|
95
|
+
* @param drivePath A path on the drive to check.
|
|
96
|
+
* @returns The free space of the give drive in bytes.
|
|
97
|
+
*/
|
|
98
|
+
function deviceDiskFreeSpace(drivePath) {
|
|
99
|
+
try {
|
|
100
|
+
const out = (0, child_process_1.execSync)(`dir /-C ${drivePath !== null && drivePath !== void 0 ? drivePath : process.cwd()}`)
|
|
101
|
+
.toString()
|
|
102
|
+
.split('\r\n');
|
|
103
|
+
const line = out[out.length - 2];
|
|
104
|
+
const result = line.match(/(\d+) [^\d]+(\d+) /);
|
|
105
|
+
if (result && result.length > 2) {
|
|
106
|
+
return Number(result[2]);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch (_a) { }
|
|
110
|
+
return -1;
|
|
111
|
+
}
|
|
112
|
+
exports.deviceDiskFreeSpace = deviceDiskFreeSpace;
|
|
113
|
+
/**
|
|
114
|
+
* Gets the telemetry sample rate.
|
|
115
|
+
* @returns The telemetry sample rate.
|
|
116
|
+
*/
|
|
117
|
+
function sampleRate() {
|
|
118
|
+
return 100;
|
|
119
|
+
}
|
|
120
|
+
exports.sampleRate = sampleRate;
|
|
121
|
+
/**
|
|
122
|
+
* Gets whether or not telemetry events are captured when running in CI.
|
|
123
|
+
* @returns Whether or not telemetry events are captured when running in CI.
|
|
124
|
+
*/
|
|
125
|
+
function captureCI() {
|
|
126
|
+
// Only capture events in CI if running tests
|
|
127
|
+
return isCliTest();
|
|
128
|
+
}
|
|
129
|
+
exports.captureCI = captureCI;
|
|
130
|
+
/**
|
|
131
|
+
* Gets the whether the process is currently running in CI.
|
|
132
|
+
* @returns Whether the process is currently running in CI.
|
|
133
|
+
*/
|
|
134
|
+
function isCI() {
|
|
135
|
+
return ci_info_1.default.isCI;
|
|
136
|
+
}
|
|
137
|
+
exports.isCI = isCI;
|
|
138
|
+
/**
|
|
139
|
+
* Gets the type of CI the process is running under.
|
|
140
|
+
* @returns The type of CI the process is running under.
|
|
141
|
+
*/
|
|
142
|
+
function ciType() {
|
|
143
|
+
var _a;
|
|
144
|
+
return ci_info_1.default.isCI ? (_a = ci_info_1.default.name) !== null && _a !== void 0 ? _a : 'Unknown' : 'None';
|
|
145
|
+
}
|
|
146
|
+
exports.ciType = ciType;
|
|
147
|
+
/**
|
|
148
|
+
* Gets whether the process is running on a Microsoft owned machine.
|
|
149
|
+
* @returns Whether the process is running on a Microsoft owned machine.
|
|
150
|
+
*/
|
|
151
|
+
function isMsftInternal() {
|
|
152
|
+
return (process.env.UserDNSDomain !== undefined &&
|
|
153
|
+
process.env.UserDNSDomain.toLowerCase().endsWith('corp.microsoft.com'));
|
|
154
|
+
}
|
|
155
|
+
exports.isMsftInternal = isMsftInternal;
|
|
156
|
+
/**
|
|
157
|
+
* Gets whether the process is running as part of our CLI tests.
|
|
158
|
+
* @returns Whether the process is running as part of our CLI tests.
|
|
159
|
+
*/
|
|
160
|
+
function isCliTest() {
|
|
161
|
+
return (process.env.RNW_CLI_TEST !== undefined &&
|
|
162
|
+
process.env.RNW_CLI_TEST.toLowerCase().trim() === 'true');
|
|
163
|
+
}
|
|
164
|
+
exports.isCliTest = isCliTest;
|
|
165
|
+
let sessionId;
|
|
166
|
+
/**
|
|
167
|
+
* Gets a stable session ID for correlating telemetry events.
|
|
168
|
+
* @returns A stable session ID for correlating telemetry events.
|
|
169
|
+
*/
|
|
170
|
+
function getSessionId() {
|
|
171
|
+
return (sessionId !== null && sessionId !== void 0 ? sessionId : (sessionId = (0, crypto_1.randomBytes)(16).toString('hex').padStart(32, '0')));
|
|
172
|
+
}
|
|
173
|
+
exports.getSessionId = getSessionId;
|
|
174
|
+
//# sourceMappingURL=basePropUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basePropUtils.js","sourceRoot":"","sources":["../../src/utils/basePropUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,iDAAuC;AACvC,2BAA4C;AAE5C,sDAAyB;AACzB,mCAAmC;AACnC,0DAAiC;AAEjC,MAAM,eAAe,GAAG,oDAAoD,CAAC;AAC7E,MAAM,cAAc,GAAG,WAAW,CAAC;AAEnC;;;GAGG;AACI,KAAK,UAAU,Q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AC5B,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,SAAS;QACvC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CACvE,CAAC;AACJ,CAAC;AALD,wCAKC;AAED;;;GAGG;AACH,SAAgB,SAAS;IACvB,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,SAAS;QACtC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,KAAK,MAAM,CACzD,CAAC;AACJ,CAAC;AALD,8BAKC;AAED,IAAI,SAA6B,CAAC;AAElC;;;GAGG;AACH,SAAgB,YAAY;IAC1B,OAAO,CACL,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,CAAC,SAAS,GAAG,IAAA,oBAAW,EAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAC7E,CAAC;AACJ,CAAC;AAJD,oCAIC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {execSync} from 'child_process';\nimport {totalmem, cpus, platform} from 'os';\n\nimport ci from 'ci-info';\nimport {randomBytes} from 'crypto';\nimport osLocale from 'os-locale';\n\nconst DeviceIdRegPath = 'HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\SQMClient';\nconst DeviceIdRegKey = 'MachineId';\n\n/**\n * Gets a telemetry-safe stable device ID.\n * @returns A telemetry-safe stable device ID.\n */\nexport async function deviceId(): Promise<string> {\n try {\n let regCommand = `${process.env.windir}\\\\System32\\\\reg.exe query ${DeviceIdRegPath} /v ${DeviceIdRegKey}`;\n if (deviceArchitecture() === 'x64') {\n // Ensure we query the correct registry\n regCommand += ' /reg:64';\n }\n const output = execSync(regCommand).toString();\n\n const result = output.match(/\\{([0-9A-Fa-f-]{36})\\}/);\n if (result && result.length > 1) {\n return `s:${result[1]}`;\n }\n } catch {}\n return '';\n}\n\n/**\n * Gets the device architecture, like x86/x64/arm64.\n * @returns The device architecture.\n */\nexport function deviceArchitecture(): string {\n const nodeArch = nodeArchitecture();\n\n // Check if we're running x86 node on x64 hardware\n if (nodeArch === 'x86' && process.env.PROCESSOR_ARCHITEW6432 === 'AMD64') {\n return 'x64';\n }\n\n return nodeArch;\n}\n\n/**\n * Gets the node architecture, like x86/x64/arm64.\n * @returns The node architecture.\n */\nexport function nodeArchitecture(): string {\n return process.arch === 'ia32' ? 'x86' : process.arch;\n}\n\n/**\n * Gets the device platform, like darwin/linux/win32.\n * @returns The device platform.\n */\nexport function devicePlatform(): string {\n return platform();\n}\n\n/**\n * Gets the device locale.\n * @returns The device locale.\n */\nexport async function deviceLocale(): Promise<string> {\n return await osLocale();\n}\n\n/**\n * Gets the device's number of CPUs.\n * @returns The device's number of CPUs.\n */\nexport function deviceNumCPUs(): number {\n return cpus().length;\n}\n\n/**\n * Gets the device's total memory in bytes.\n * @returns The device's total memory in bytes.\n */\nexport function deviceTotalMemory(): number {\n return totalmem();\n}\n\n/**\n * Gets the free space of the give drive in bytes.\n * @param drivePath A path on the drive to check.\n * @returns The free space of the give drive in bytes.\n */\nexport function deviceDiskFreeSpace(drivePath?: string | null): number {\n try {\n const out = execSync(`dir /-C ${drivePath ?? process.cwd()}`)\n .toString()\n .split('\\r\\n');\n const line = out[out.length - 2];\n const result = line.match(/(\\d+) [^\\d]+(\\d+) /);\n if (result && result.length > 2) {\n return Number(result[2]);\n }\n } catch {}\n return -1;\n}\n\n/**\n * Gets the telemetry sample rate.\n * @returns The telemetry sample rate.\n */\nexport function sampleRate(): number {\n return 100;\n}\n\n/**\n * Gets whether or not telemetry events are captured when running in CI.\n * @returns Whether or not telemetry events are captured when running in CI.\n */\nexport function captureCI(): boolean {\n // Only capture events in CI if running tests\n return isCliTest();\n}\n\n/**\n * Gets the whether the process is currently running in CI.\n * @returns Whether the process is currently running in CI.\n */\nexport function isCI(): boolean {\n return ci.isCI;\n}\n\n/**\n * Gets the type of CI the process is running under.\n * @returns The type of CI the process is running under.\n */\nexport function ciType(): string {\n return ci.isCI ? ci.name ?? 'Unknown' : 'None';\n}\n\n/**\n * Gets whether the process is running on a Microsoft owned machine.\n * @returns Whether the process is running on a Microsoft owned machine.\n */\nexport function isMsftInternal(): boolean {\n return (\n process.env.UserDNSDomain !== undefined &&\n process.env.UserDNSDomain.toLowerCase().endsWith('corp.microsoft.com')\n );\n}\n\n/**\n * Gets whether the process is running as part of our CLI tests.\n * @returns Whether the process is running as part of our CLI tests.\n */\nexport function isCliTest(): boolean {\n return (\n process.env.RNW_CLI_TEST !== undefined &&\n process.env.RNW_CLI_TEST.toLowerCase().trim() === 'true'\n );\n}\n\nlet sessionId: string | undefined;\n\n/**\n * Gets a stable session ID for correlating telemetry events.\n * @returns A stable session ID for correlating telemetry events.\n */\nexport function getSessionId(): string {\n return (\n sessionId ?? (sessionId = randomBytes(16).toString('hex').padStart(32, '0'))\n );\n}\n"]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
* @format
|
|
5
|
+
*/
|
|
6
|
+
import * as appInsights from 'applicationinsights';
|
|
7
|
+
export declare const CodedErrors: {
|
|
8
|
+
Success: number;
|
|
9
|
+
Unknown: number;
|
|
10
|
+
UnsupportedReactNativeVersion: number;
|
|
11
|
+
UserCancel: number;
|
|
12
|
+
NoReactNativeFound: number;
|
|
13
|
+
NoPackageJson: number;
|
|
14
|
+
NoLatestReactNativeWindows: number;
|
|
15
|
+
NoAutoMatchingReactNativeWindows: number;
|
|
16
|
+
IncompatibleOptions: number;
|
|
17
|
+
NoReactNativeDependencies: number;
|
|
18
|
+
NoMatchingPackageVersion: number;
|
|
19
|
+
NoSolution: number;
|
|
20
|
+
NoPropertyInProject: number;
|
|
21
|
+
CopyProjectTemplateNoSourcePath: number;
|
|
22
|
+
CopyProjectTemplateNoDestPath: number;
|
|
23
|
+
CopyProjectTemplateNoProjectName: number;
|
|
24
|
+
MinSDKVersionNotMet: number;
|
|
25
|
+
BadSDKVersionFormat: number;
|
|
26
|
+
NoSDK: number;
|
|
27
|
+
NoMSBuild: number;
|
|
28
|
+
NoVSWhere: number;
|
|
29
|
+
MSBuildError: number;
|
|
30
|
+
NoAppPackage: number;
|
|
31
|
+
NoAppxManifest: number;
|
|
32
|
+
NoDevice: number;
|
|
33
|
+
AppDidNotDeploy: number;
|
|
34
|
+
InvalidDevicesOutput: number;
|
|
35
|
+
RemoveOldAppVersionFailure: number;
|
|
36
|
+
EnableDevModeFailure: number;
|
|
37
|
+
InstallAppFailure: number;
|
|
38
|
+
InstallAppDependenciesFailure: number;
|
|
39
|
+
CheckNetIsolationFailure: number;
|
|
40
|
+
InstallAppToDeviceFailure: number;
|
|
41
|
+
UninstallAppOnDeviceFailure: number;
|
|
42
|
+
DeployRecipeFailure: number;
|
|
43
|
+
AppStartupFailure: number;
|
|
44
|
+
NoWindowsConfig: number;
|
|
45
|
+
IncompleteConfig: number;
|
|
46
|
+
InvalidConfig: number;
|
|
47
|
+
NeedAutolinking: number;
|
|
48
|
+
AddProjectToSolution: number;
|
|
49
|
+
Autolinking: number;
|
|
50
|
+
NeedCodegen: number;
|
|
51
|
+
InvalidCodegenConfig: number;
|
|
52
|
+
NoTemplatesFound: number;
|
|
53
|
+
NoDefaultTemplate: number;
|
|
54
|
+
InvalidTemplateName: number;
|
|
55
|
+
NoProjectName: number;
|
|
56
|
+
InvalidProjectName: number;
|
|
57
|
+
};
|
|
58
|
+
export type CodedErrorType = keyof typeof CodedErrors;
|
|
59
|
+
/**
|
|
60
|
+
* Represents an error whose message might contain user-originating content,
|
|
61
|
+
* therefore when transmitting telemetry, only the type should be sent.
|
|
62
|
+
* @param type a stable ID identifying the type of error.
|
|
63
|
+
* @param message the error text. This should only be used for display to the user.
|
|
64
|
+
* @param data any additional metadata that is safe to collect for telemetry purposes.
|
|
65
|
+
*/
|
|
66
|
+
export declare class CodedError extends Error {
|
|
67
|
+
readonly type: CodedErrorType;
|
|
68
|
+
readonly data?: Record<string, any> | undefined;
|
|
69
|
+
constructor(type: CodedErrorType, message: string, data?: Record<string, any> | undefined);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Tries to parse an error code out of an error message.
|
|
73
|
+
* @param msg An error message to process.
|
|
74
|
+
* @returns The parsed error code.
|
|
75
|
+
*/
|
|
76
|
+
export declare function tryGetErrorCode(msg: string): string | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Sanitize an error message by anonymizing any paths that appear between quotes (''), brackets ([]), or double quotes ("").
|
|
79
|
+
* @param msg The error message to sanitize.
|
|
80
|
+
* @return The message with any paths anonymized.
|
|
81
|
+
*/
|
|
82
|
+
export declare function sanitizeErrorMessage(msg: string): string;
|
|
83
|
+
/**
|
|
84
|
+
* Sanitizes an error stack frame.
|
|
85
|
+
* @param frame
|
|
86
|
+
*/
|
|
87
|
+
export declare function sanitizeErrorStackFrame(frame: appInsights.Contracts.StackFrame): void;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
24
|
+
if (mod && mod.__esModule) return mod;
|
|
25
|
+
var result = {};
|
|
26
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
27
|
+
__setModuleDefault(result, mod);
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.sanitizeErrorStackFrame = exports.sanitizeErrorMessage = exports.tryGetErrorCode = exports.CodedError = exports.CodedErrors = void 0;
|
|
32
|
+
const sanitizeUtils = __importStar(require("./sanitizeUtils"));
|
|
33
|
+
// Note: All CLI commands will set process.exitCode to the numerical value of
|
|
34
|
+
// a thrown CodedError. However node reserves codes 1-192 as per:
|
|
35
|
+
// https://nodejs.org/api/process.html#process_exit_codes so we shouldn't
|
|
36
|
+
// override those as other tools may be monitoring the error code
|
|
37
|
+
exports.CodedErrors = {
|
|
38
|
+
Success: 0,
|
|
39
|
+
Unknown: -1,
|
|
40
|
+
// react-native-windows-init
|
|
41
|
+
UnsupportedReactNativeVersion: 1000,
|
|
42
|
+
UserCancel: 1001,
|
|
43
|
+
NoReactNativeFound: 1002,
|
|
44
|
+
NoPackageJson: 1003,
|
|
45
|
+
NoLatestReactNativeWindows: 1004,
|
|
46
|
+
NoAutoMatchingReactNativeWindows: 1005,
|
|
47
|
+
IncompatibleOptions: 1006,
|
|
48
|
+
NoReactNativeDependencies: 1007,
|
|
49
|
+
NoMatchingPackageVersion: 1008,
|
|
50
|
+
// run-windows
|
|
51
|
+
NoSolution: 2000,
|
|
52
|
+
// Project generation
|
|
53
|
+
NoPropertyInProject: 2100,
|
|
54
|
+
CopyProjectTemplateNoSourcePath: 2101,
|
|
55
|
+
CopyProjectTemplateNoDestPath: 2102,
|
|
56
|
+
CopyProjectTemplateNoProjectName: 2103,
|
|
57
|
+
// SDK requirements
|
|
58
|
+
MinSDKVersionNotMet: 2200,
|
|
59
|
+
BadSDKVersionFormat: 2201,
|
|
60
|
+
NoSDK: 2202,
|
|
61
|
+
// Build
|
|
62
|
+
NoMSBuild: 2300,
|
|
63
|
+
NoVSWhere: 2301,
|
|
64
|
+
MSBuildError: 2302,
|
|
65
|
+
// Deploy
|
|
66
|
+
NoAppPackage: 2400,
|
|
67
|
+
NoAppxManifest: 2401,
|
|
68
|
+
NoDevice: 2402,
|
|
69
|
+
AppDidNotDeploy: 2403,
|
|
70
|
+
InvalidDevicesOutput: 2404,
|
|
71
|
+
RemoveOldAppVersionFailure: 2405,
|
|
72
|
+
EnableDevModeFailure: 2406,
|
|
73
|
+
InstallAppFailure: 2407,
|
|
74
|
+
InstallAppDependenciesFailure: 2408,
|
|
75
|
+
CheckNetIsolationFailure: 2409,
|
|
76
|
+
InstallAppToDeviceFailure: 2410,
|
|
77
|
+
UninstallAppOnDeviceFailure: 2411,
|
|
78
|
+
DeployRecipeFailure: 2412,
|
|
79
|
+
// Launch
|
|
80
|
+
AppStartupFailure: 2500,
|
|
81
|
+
// autolink-windows
|
|
82
|
+
NoWindowsConfig: 3000,
|
|
83
|
+
IncompleteConfig: 3001,
|
|
84
|
+
InvalidConfig: 3002,
|
|
85
|
+
NeedAutolinking: 3003,
|
|
86
|
+
AddProjectToSolution: 3004,
|
|
87
|
+
Autolinking: 3005,
|
|
88
|
+
// codegen-windows
|
|
89
|
+
NeedCodegen: 4000,
|
|
90
|
+
InvalidCodegenConfig: 4001,
|
|
91
|
+
// init-windows
|
|
92
|
+
NoTemplatesFound: 5000,
|
|
93
|
+
NoDefaultTemplate: 5001,
|
|
94
|
+
InvalidTemplateName: 5002,
|
|
95
|
+
NoProjectName: 5003,
|
|
96
|
+
InvalidProjectName: 5004,
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Represents an error whose message might contain user-originating content,
|
|
100
|
+
* therefore when transmitting telemetry, only the type should be sent.
|
|
101
|
+
* @param type a stable ID identifying the type of error.
|
|
102
|
+
* @param message the error text. This should only be used for display to the user.
|
|
103
|
+
* @param data any additional metadata that is safe to collect for telemetry purposes.
|
|
104
|
+
*/
|
|
105
|
+
class CodedError extends Error {
|
|
106
|
+
constructor(type, message, data) {
|
|
107
|
+
super(message);
|
|
108
|
+
this.type = type;
|
|
109
|
+
this.data = data;
|
|
110
|
+
this.name = type;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.CodedError = CodedError;
|
|
114
|
+
/**
|
|
115
|
+
* Tries to parse an error code out of an error message.
|
|
116
|
+
* @param msg An error message to process.
|
|
117
|
+
* @returns The parsed error code.
|
|
118
|
+
*/
|
|
119
|
+
function tryGetErrorCode(msg) {
|
|
120
|
+
const errorRegEx = /error (\w+\d+):/gi;
|
|
121
|
+
const m = errorRegEx.exec(msg);
|
|
122
|
+
return m ? m[1] : undefined;
|
|
123
|
+
}
|
|
124
|
+
exports.tryGetErrorCode = tryGetErrorCode;
|
|
125
|
+
/**
|
|
126
|
+
* Sanitize an error message by anonymizing any paths that appear between quotes (''), brackets ([]), or double quotes ("").
|
|
127
|
+
* @param msg The error message to sanitize.
|
|
128
|
+
* @return The message with any paths anonymized.
|
|
129
|
+
*/
|
|
130
|
+
function sanitizeErrorMessage(msg) {
|
|
131
|
+
const msBuildErrorMessage = /^\d+:\d+>(.*)(\(\d+,\d+\)): error (\w+\d+): (.*)/g;
|
|
132
|
+
msg = msg.replace(msBuildErrorMessage, '[$1]$2: error $3: $4');
|
|
133
|
+
const cpuThreadId = /^\d+(:\d+)?>/g;
|
|
134
|
+
msg = msg.replace(cpuThreadId, '');
|
|
135
|
+
const parts = msg.split(/['[\]"]/g);
|
|
136
|
+
const clean = [];
|
|
137
|
+
const pathRegEx = /(['["]?)([A-Za-z]:|\\)[\\/]([^<>:;,?"*\t\r\n|/\\]+[\\/])+([^<>:;,?"*\t\r\n|]+\/?(['["]?))/gi;
|
|
138
|
+
for (const part of parts) {
|
|
139
|
+
if (pathRegEx.test(part)) {
|
|
140
|
+
pathRegEx.lastIndex = -1;
|
|
141
|
+
let matches;
|
|
142
|
+
let noPath = '';
|
|
143
|
+
let last = 0;
|
|
144
|
+
while ((matches = pathRegEx.exec(part))) {
|
|
145
|
+
noPath +=
|
|
146
|
+
part.substr(last, matches.index - last) +
|
|
147
|
+
sanitizeUtils.getAnonymizedPath(matches[0]);
|
|
148
|
+
last = matches.index + matches[0].length;
|
|
149
|
+
}
|
|
150
|
+
if (noPath !== '') {
|
|
151
|
+
clean.push(noPath);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else if (part !== '') {
|
|
155
|
+
clean.push(part);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return clean.join('').trim();
|
|
159
|
+
}
|
|
160
|
+
exports.sanitizeErrorMessage = sanitizeErrorMessage;
|
|
161
|
+
/**
|
|
162
|
+
* Sanitizes an error stack frame.
|
|
163
|
+
* @param frame
|
|
164
|
+
*/
|
|
165
|
+
function sanitizeErrorStackFrame(frame) {
|
|
166
|
+
const parens = frame.method.indexOf('(');
|
|
167
|
+
if (parens !== -1) {
|
|
168
|
+
// case 1: method === 'methodName (rootOfThePath'
|
|
169
|
+
frame.method = frame.method.substr(0, parens).trim();
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
// case 2: method === <no_method> or something without '(', fileName is full path
|
|
173
|
+
}
|
|
174
|
+
// anonymize the filename
|
|
175
|
+
frame.fileName = sanitizeUtils.getAnonymizedPath(frame.fileName);
|
|
176
|
+
frame.assembly = '';
|
|
177
|
+
}
|
|
178
|
+
exports.sanitizeErrorStackFrame = sanitizeErrorStackFrame;
|
|
179
|
+
//# sourceMappingURL=errorUtils.js.map
|