@react-native-windows/telemetry 0.0.0-canary.3 → 0.0.0-canary.30
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/index.d.ts +4 -1
- package/lib-commonjs/index.js +13 -3
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/telemetry.d.ts +75 -12
- package/lib-commonjs/telemetry.js +317 -108
- package/lib-commonjs/telemetry.js.map +1 -1
- package/lib-commonjs/test/{sanitize.test.d.ts → basePropUtils.test.d.ts} +0 -0
- package/lib-commonjs/test/basePropUtils.test.js +116 -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 +159 -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 +84 -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 +94 -0
- package/lib-commonjs/test/sanitizeUtils.test.js.map +1 -0
- package/lib-commonjs/test/telemetry.test.d.ts +26 -0
- package/lib-commonjs/test/telemetry.test.js +469 -0
- package/lib-commonjs/test/telemetry.test.js.map +1 -0
- package/lib-commonjs/test/versionUtils.test.d.ts +7 -0
- package/lib-commonjs/test/versionUtils.test.js +111 -0
- package/lib-commonjs/test/versionUtils.test.js.map +1 -0
- package/lib-commonjs/utils/basePropUtils.d.ts +66 -0
- package/lib-commonjs/utils/basePropUtils.js +131 -0
- package/lib-commonjs/utils/basePropUtils.js.map +1 -0
- package/lib-commonjs/utils/errorUtils.d.ts +80 -0
- package/lib-commonjs/utils/errorUtils.js +164 -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 -19
- package/CHANGELOG.json +0 -35
- package/CHANGELOG.md +0 -23
- package/lib-commonjs/test/sanitize.test.js +0 -174
- package/lib-commonjs/test/sanitize.test.js.map +0 -1
|
@@ -0,0 +1,116 @@
|
|
|
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
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
const basePropUtils = __importStar(require("../utils/basePropUtils"));
|
|
29
|
+
test('deviceId() is valid', async () => {
|
|
30
|
+
const value = await basePropUtils.deviceId();
|
|
31
|
+
expect(value).toBeDefined();
|
|
32
|
+
expect(value).not.toBe('');
|
|
33
|
+
expect(value).not.toBeNull();
|
|
34
|
+
});
|
|
35
|
+
test('deviceId() does not change', async () => {
|
|
36
|
+
expect(await basePropUtils.deviceId()).toBe(await basePropUtils.deviceId());
|
|
37
|
+
});
|
|
38
|
+
test('deviceLocale() is valid', async () => {
|
|
39
|
+
const value = await basePropUtils.deviceLocale();
|
|
40
|
+
expect(value).toBeDefined();
|
|
41
|
+
expect(value).not.toBe('');
|
|
42
|
+
expect(value).not.toBeNull();
|
|
43
|
+
});
|
|
44
|
+
test('deviceLocale() does not change', async () => {
|
|
45
|
+
expect(await basePropUtils.deviceLocale()).toBe(await basePropUtils.deviceLocale());
|
|
46
|
+
});
|
|
47
|
+
test('deviceNumCPUs() is valid', () => {
|
|
48
|
+
const value = basePropUtils.deviceNumCPUs();
|
|
49
|
+
expect(value).toBeGreaterThan(0);
|
|
50
|
+
});
|
|
51
|
+
test('deviceTotalMemory() is valid', () => {
|
|
52
|
+
const value = basePropUtils.deviceTotalMemory();
|
|
53
|
+
expect(value).toBeGreaterThan(0);
|
|
54
|
+
});
|
|
55
|
+
test('deviceDiskFreeSpace() is valid', () => {
|
|
56
|
+
const value = basePropUtils.deviceDiskFreeSpace();
|
|
57
|
+
expect(value).toBeGreaterThanOrEqual(0);
|
|
58
|
+
});
|
|
59
|
+
test('sampleRate() is within valid range', () => {
|
|
60
|
+
const value = basePropUtils.sampleRate();
|
|
61
|
+
expect(value).toBeGreaterThanOrEqual(0);
|
|
62
|
+
expect(value).toBeLessThanOrEqual(100);
|
|
63
|
+
});
|
|
64
|
+
test('ciType() is valid', () => {
|
|
65
|
+
const value = basePropUtils.ciType();
|
|
66
|
+
expect(value).toBeDefined();
|
|
67
|
+
expect(value).not.toBe('');
|
|
68
|
+
expect(value).not.toBeNull();
|
|
69
|
+
});
|
|
70
|
+
test('ciType() is None when not in CI', () => {
|
|
71
|
+
if (basePropUtils.isCI()) {
|
|
72
|
+
expect(basePropUtils.ciType()).not.toBe('None');
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
expect(basePropUtils.ciType()).toBe('None');
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
test('isMsftInternal() is false with no domain', () => {
|
|
79
|
+
delete process.env.UserDNSDomain;
|
|
80
|
+
expect(basePropUtils.isMsftInternal()).toBe(false);
|
|
81
|
+
});
|
|
82
|
+
test('isMsftInternal() is false with example.com domain', () => {
|
|
83
|
+
process.env.UserDNSDomain = 'example.com';
|
|
84
|
+
expect(basePropUtils.isMsftInternal()).toBe(false);
|
|
85
|
+
});
|
|
86
|
+
test('isMsftInternal() is true with Msft domain', () => {
|
|
87
|
+
process.env.UserDNSDomain = 'test.corp.microsoft.com';
|
|
88
|
+
expect(basePropUtils.isMsftInternal()).toBe(true);
|
|
89
|
+
});
|
|
90
|
+
test('isCliTest() is true if RNW_CLI_TEST env variable is set', () => {
|
|
91
|
+
process.env.RNW_CLI_TEST = 'true';
|
|
92
|
+
expect(basePropUtils.isCliTest()).toBe(true);
|
|
93
|
+
});
|
|
94
|
+
test('isCliTest() is false if no RNW_CLI_TEST variable', () => {
|
|
95
|
+
delete process.env.RNW_CLI_TEST;
|
|
96
|
+
expect(basePropUtils.isCliTest()).toBe(false);
|
|
97
|
+
});
|
|
98
|
+
test('getSessionId() is valid', () => {
|
|
99
|
+
const value = basePropUtils.getSessionId();
|
|
100
|
+
expect(value).toBeDefined();
|
|
101
|
+
expect(value).not.toBe('');
|
|
102
|
+
expect(value).not.toBeNull();
|
|
103
|
+
expect(value).toHaveLength(32);
|
|
104
|
+
});
|
|
105
|
+
test('getSessionId() is a guid', () => {
|
|
106
|
+
const value = basePropUtils.getSessionId();
|
|
107
|
+
expect(value).toHaveLength(32);
|
|
108
|
+
const parseGuid = () => {
|
|
109
|
+
parseInt(value, 16);
|
|
110
|
+
};
|
|
111
|
+
expect(parseGuid).not.toThrow();
|
|
112
|
+
});
|
|
113
|
+
test('getSessionId() does not change', () => {
|
|
114
|
+
expect(basePropUtils.getSessionId()).toBe(basePropUtils.getSessionId());
|
|
115
|
+
});
|
|
116
|
+
//# sourceMappingURL=basePropUtils.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basePropUtils.test.js","sourceRoot":"","sources":["../../src/test/basePropUtils.test.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;AAEH,sEAAwD;AAExD,IAAI,CAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;IACrC,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,QAAQ,EAAE,CAAC;IAC7C,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IAC5B,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3B,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;AAC/B,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;IAC5C,MAAM,CAAC,MAAM,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC9E,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,yBAAyB,EAAE,KAAK,IAAI,EAAE;IACzC,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,YAAY,EAAE,CAAC;IACjD,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EA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aAAa,CAAC,YAAY,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\nimport * as basePropUtils from '../utils/basePropUtils';\n\ntest('deviceId() is valid', async () => {\n const value = await basePropUtils.deviceId();\n expect(value).toBeDefined();\n expect(value).not.toBe('');\n expect(value).not.toBeNull();\n});\n\ntest('deviceId() does not change', async () => {\n expect(await basePropUtils.deviceId()).toBe(await basePropUtils.deviceId());\n});\n\ntest('deviceLocale() is valid', async () => {\n const value = await basePropUtils.deviceLocale();\n expect(value).toBeDefined();\n expect(value).not.toBe('');\n expect(value).not.toBeNull();\n});\n\ntest('deviceLocale() does not change', async () => {\n expect(await basePropUtils.deviceLocale()).toBe(\n await basePropUtils.deviceLocale(),\n );\n});\n\ntest('deviceNumCPUs() is valid', () => {\n const value = basePropUtils.deviceNumCPUs();\n expect(value).toBeGreaterThan(0);\n});\n\ntest('deviceTotalMemory() is valid', () => {\n const value = basePropUtils.deviceTotalMemory();\n expect(value).toBeGreaterThan(0);\n});\n\ntest('deviceDiskFreeSpace() is valid', () => {\n const value = basePropUtils.deviceDiskFreeSpace();\n expect(value).toBeGreaterThanOrEqual(0);\n});\n\ntest('sampleRate() is within valid range', () => {\n const value = basePropUtils.sampleRate();\n expect(value).toBeGreaterThanOrEqual(0);\n expect(value).toBeLessThanOrEqual(100);\n});\n\ntest('ciType() is valid', () => {\n const value = basePropUtils.ciType();\n expect(value).toBeDefined();\n expect(value).not.toBe('');\n expect(value).not.toBeNull();\n});\n\ntest('ciType() is None when not in CI', () => {\n if (basePropUtils.isCI()) {\n expect(basePropUtils.ciType()).not.toBe('None');\n } else {\n expect(basePropUtils.ciType()).toBe('None');\n }\n});\n\ntest('isMsftInternal() is false with no domain', () => {\n delete process.env.UserDNSDomain;\n expect(basePropUtils.isMsftInternal()).toBe(false);\n});\n\ntest('isMsftInternal() is false with example.com domain', () => {\n process.env.UserDNSDomain = 'example.com';\n expect(basePropUtils.isMsftInternal()).toBe(false);\n});\n\ntest('isMsftInternal() is true with Msft domain', () => {\n process.env.UserDNSDomain = 'test.corp.microsoft.com';\n expect(basePropUtils.isMsftInternal()).toBe(true);\n});\n\ntest('isCliTest() is true if RNW_CLI_TEST env variable is set', () => {\n process.env.RNW_CLI_TEST = 'true';\n expect(basePropUtils.isCliTest()).toBe(true);\n});\n\ntest('isCliTest() is false if no RNW_CLI_TEST variable', () => {\n delete process.env.RNW_CLI_TEST;\n expect(basePropUtils.isCliTest()).toBe(false);\n});\n\ntest('getSessionId() is valid', () => {\n const value = basePropUtils.getSessionId();\n expect(value).toBeDefined();\n expect(value).not.toBe('');\n expect(value).not.toBeNull();\n expect(value).toHaveLength(32);\n});\n\ntest('getSessionId() is a guid', () => {\n const value = basePropUtils.getSessionId();\n expect(value).toHaveLength(32);\n\n const parseGuid = () => {\n parseInt(value, 16);\n };\n\n expect(parseGuid).not.toThrow();\n});\n\ntest('getSessionId() does not change', () => {\n expect(basePropUtils.getSessionId()).toBe(basePropUtils.getSessionId());\n});\n"]}
|
|
@@ -0,0 +1,159 @@
|
|
|
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
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
const errorUtils = __importStar(require("../utils/errorUtils"));
|
|
29
|
+
test('tryGetErrorCode() with valid error code', () => {
|
|
30
|
+
expect(errorUtils.tryGetErrorCode('foo bar error FOO2020: the thing')).toBe('FOO2020');
|
|
31
|
+
});
|
|
32
|
+
test('tryGetErrorCode() without valid error code', () => {
|
|
33
|
+
expect(errorUtils.tryGetErrorCode('foo bar the thing')).toBeUndefined();
|
|
34
|
+
});
|
|
35
|
+
test('tryGetErrorCode() with word error but no code', () => {
|
|
36
|
+
expect(errorUtils.tryGetErrorCode('test error')).toBeUndefined();
|
|
37
|
+
});
|
|
38
|
+
test('sanitizeErrorMessage() no-op on empty string', () => {
|
|
39
|
+
expect(errorUtils.sanitizeErrorMessage('')).toBe('');
|
|
40
|
+
});
|
|
41
|
+
test('sanitizeErrorMessage() no-op on test string', () => {
|
|
42
|
+
expect(errorUtils.sanitizeErrorMessage('some text')).toBe('some text');
|
|
43
|
+
});
|
|
44
|
+
test("sanitizeErrorMessage() 'project_dir'", () => {
|
|
45
|
+
expect(errorUtils.sanitizeErrorMessage(`this is the cwd: '${process.cwd()}'`)).toBe(`this is the cwd: [project_dir]`);
|
|
46
|
+
});
|
|
47
|
+
test("sanitizeErrorMessage() 'project_dir' uppercase", () => {
|
|
48
|
+
expect(errorUtils.sanitizeErrorMessage(`uppercase: '${process.cwd().toUpperCase()}'`)).toBe(`uppercase: [project_dir]`);
|
|
49
|
+
});
|
|
50
|
+
test("sanitizeErrorMessage() 'project_dir' lowercase", () => {
|
|
51
|
+
expect(errorUtils.sanitizeErrorMessage(`lowercase: '${process.cwd().toLowerCase()}'`)).toBe(`lowercase: [project_dir]`);
|
|
52
|
+
});
|
|
53
|
+
test("sanitizeErrorMessage() 'project_dir' and something else", () => {
|
|
54
|
+
expect(errorUtils.sanitizeErrorMessage(`this is the cwd: '${process.cwd()}' and something else`)).toBe(`this is the cwd: [project_dir] and something else`);
|
|
55
|
+
});
|
|
56
|
+
test('sanitizeErrorMessage() project_dir and something else', () => {
|
|
57
|
+
expect(errorUtils.sanitizeErrorMessage(`this is the cwd: ${process.cwd()} and something else`)).toBe(`this is the cwd: [project_dir]\\???(${' and something else'.length})`);
|
|
58
|
+
});
|
|
59
|
+
test("sanitizeErrorMessage() 'node_modules'", () => {
|
|
60
|
+
expect(errorUtils.sanitizeErrorMessage(`this is the cwd: '${process.cwd()}\\node_modules'`)).toBe(`this is the cwd: [project_dir]\\???(${'node_modules'.length})`);
|
|
61
|
+
});
|
|
62
|
+
test("sanitizeErrorMessage() 'node_modules\\foo'", () => {
|
|
63
|
+
expect(errorUtils.sanitizeErrorMessage(`this is the cwd: '${process.cwd()}\\node_modules\\foo'`)).toBe(`this is the cwd: [node_modules]\\???(${'foo'.length})`);
|
|
64
|
+
});
|
|
65
|
+
test("sanitizeErrorMessage() 'node_modules\\foo' uppercase", () => {
|
|
66
|
+
expect(errorUtils.sanitizeErrorMessage(`uppercase: '${process.cwd().toUpperCase()}\\NODE_MODULES\\foo'`)).toBe(`uppercase: [node_modules]\\???(${'foo'.length})`);
|
|
67
|
+
});
|
|
68
|
+
test("sanitizeErrorMessage() 'node_modules\\foo' lowercase", () => {
|
|
69
|
+
expect(errorUtils.sanitizeErrorMessage(`lowercase: '${process.cwd().toLowerCase()}\\NODE_MODULES\\foo'`)).toBe(`lowercase: [node_modules]\\???(${'foo'.length})`);
|
|
70
|
+
});
|
|
71
|
+
test("sanitizeErrorMessage() 'node_modules\\' and something else", () => {
|
|
72
|
+
expect(errorUtils.sanitizeErrorMessage(`trailing: '${process.cwd()}\\node_modules\\' and something else`)).toBe(`trailing: [node_modules]\\???(0) and something else`);
|
|
73
|
+
});
|
|
74
|
+
test('sanitizeErrorMessage() node_modules and something else that could be part of the path', () => {
|
|
75
|
+
expect(errorUtils.sanitizeErrorMessage(`this is the cwd: ${process.cwd()}\\node_modules and something else that could be part of the path`)).toBe(`this is the cwd: [project_dir]\\???(${'node_modules and something else that could be part of the path'.length})`);
|
|
76
|
+
});
|
|
77
|
+
test('sanitizeErrorMessage() \\node_modules\\ a file under nm', () => {
|
|
78
|
+
expect(errorUtils.sanitizeErrorMessage(`this is the cwd: ${process.cwd()}\\node_modules\\ a file under nm`)).toBe(`this is the cwd: [node_modules]\\???(${' a file under nm'.length})`);
|
|
79
|
+
});
|
|
80
|
+
test('sanitizeErrorMessage() other path', () => {
|
|
81
|
+
expect(errorUtils.sanitizeErrorMessage(`this is another path: A:\\foo\\bar\\baz`)).toBe(`this is another path: [path]`);
|
|
82
|
+
});
|
|
83
|
+
test("sanitizeErrorMessage() 'other path'", () => {
|
|
84
|
+
expect(errorUtils.sanitizeErrorMessage(`this is another path: 'A:\\foo\\bar\\baz'`)).toBe(`this is another path: [path]`);
|
|
85
|
+
});
|
|
86
|
+
test('sanitizeErrorMessage() tracked packages in the npx cache', () => {
|
|
87
|
+
expect(errorUtils.sanitizeErrorMessage(`Cannot find module 'react-native/package.json'
|
|
88
|
+
Require stack:
|
|
89
|
+
- ${process.env.AppData}\\npm-cache\\_npx\\1384\\node_modules\\react-native-windows-init\\lib-commonjs\\Cli.js
|
|
90
|
+
- ${process.env.AppData}\\npm-cache\\_npx\\1384\\node_modules\\react-native-windows-init\\bin.js`)).toBe(`Cannot find module react-native/package.json
|
|
91
|
+
Require stack:
|
|
92
|
+
- [node_modules]\\react-native-windows-init\\lib-commonjs\\Cli.js
|
|
93
|
+
- [node_modules]\\react-native-windows-init\\bin.js`);
|
|
94
|
+
});
|
|
95
|
+
test('sanitizeErrorMessage() forward slashes', () => {
|
|
96
|
+
expect(errorUtils.sanitizeErrorMessage(`EPERM: operation not permitted, scandir ${process.env.UserProfile.replace(/\\/g, '/')}/source/repos/rn2/wintest/windows/packages/boost.1.76.0.0/lib/native/include`)).toBe(`EPERM: operation not permitted, scandir [UserProfile]\\???(${'/source/repos/rn2/wintest/windows/packages/boost.1.76.0.0/lib/native/include'
|
|
97
|
+
.length})`);
|
|
98
|
+
});
|
|
99
|
+
test('sanitizeErrorMessage() file share path', () => {
|
|
100
|
+
expect(errorUtils.sanitizeErrorMessage(`file here: \\\\server\\share`)).toBe('file here: [path]');
|
|
101
|
+
});
|
|
102
|
+
test('sanitizeErrorMessage() with cpu id', () => {
|
|
103
|
+
expect(errorUtils.sanitizeErrorMessage('5>This is an error')).toBe('This is an error');
|
|
104
|
+
});
|
|
105
|
+
test('sanitizeErrorMessage() with cpu/thread id', () => {
|
|
106
|
+
expect(errorUtils.sanitizeErrorMessage('5:42>This is an error')).toEqual('This is an error');
|
|
107
|
+
});
|
|
108
|
+
test('sanitizeErrorStackFrame() with empty frame', () => {
|
|
109
|
+
const emptyFrame = {
|
|
110
|
+
level: 0,
|
|
111
|
+
method: '',
|
|
112
|
+
fileName: '',
|
|
113
|
+
assembly: 'asdf',
|
|
114
|
+
line: 0,
|
|
115
|
+
};
|
|
116
|
+
errorUtils.sanitizeErrorStackFrame(emptyFrame);
|
|
117
|
+
expect(emptyFrame).toEqual({
|
|
118
|
+
level: 0,
|
|
119
|
+
assembly: '',
|
|
120
|
+
fileName: '[path]',
|
|
121
|
+
method: '',
|
|
122
|
+
line: 0,
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
test('sanitizeErrorStackFrame() with assembly name', () => {
|
|
126
|
+
const frame1 = {
|
|
127
|
+
method: '',
|
|
128
|
+
fileName: `${process.cwd()}\\foo.js`,
|
|
129
|
+
assembly: 'asdf',
|
|
130
|
+
level: 0,
|
|
131
|
+
line: 0,
|
|
132
|
+
};
|
|
133
|
+
errorUtils.sanitizeErrorStackFrame(frame1);
|
|
134
|
+
expect(frame1).toEqual({
|
|
135
|
+
assembly: '',
|
|
136
|
+
fileName: '[project_dir]\\???.js(6)',
|
|
137
|
+
method: '',
|
|
138
|
+
level: 0,
|
|
139
|
+
line: 0,
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
test('sanitizeErrorStackFrame() with method name', () => {
|
|
143
|
+
const frame2 = {
|
|
144
|
+
method: `myMethod (something ${process.cwd()}`,
|
|
145
|
+
fileName: `${process.cwd()}\\telemetry\\foo.js`,
|
|
146
|
+
assembly: 'asdf',
|
|
147
|
+
level: 1,
|
|
148
|
+
line: 42,
|
|
149
|
+
};
|
|
150
|
+
errorUtils.sanitizeErrorStackFrame(frame2);
|
|
151
|
+
expect(frame2).toEqual({
|
|
152
|
+
assembly: '',
|
|
153
|
+
fileName: '[project_dir]\\???.js(16)',
|
|
154
|
+
method: 'myMethod',
|
|
155
|
+
level: 1,
|
|
156
|
+
line: 42,
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
//# sourceMappingURL=errorUtils.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorUtils.test.js","sourceRoot":"","sources":["../../src/test/errorUtils.test.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;AAIH,gEAAkD;AAElD,IAAI,CAAC,yCAAyC,EAAE,GAAG,EAAE;IACnD,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,kCAAkC,CAAC,CAAC,CAAC,IAAI,CACzE,SAAS,CACV,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,4CAA4C,EAAE,GAAG,EAAE;IACtD,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;AAC1E,CAAC,C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AE;QACZ,QAAQ,EAAE,QAAQ;QAClB,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,CAAC;KACR,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,8CAA8C,EAAE,GAAG,EAAE;IACxD,MAAM,MAAM,GAAqC;QAC/C,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,UAAU;QACpC,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,CAAC;QACR,IAAI,EAAE,CAAC;KACR,CAAC;IACF,UAAU,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;QACrB,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,0BAA0B;QACpC,MAAM,EAAE,EAAE;QACV,KAAK,EAAE,CAAC;QACR,IAAI,EAAE,CAAC;KACR,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,4CAA4C,EAAE,GAAG,EAAE;IACtD,MAAM,MAAM,GAAqC;QAC/C,MAAM,EAAE,uBAAuB,OAAO,CAAC,GAAG,EAAE,EAAE;QAC9C,QAAQ,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,qBAAqB;QAC/C,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,CAAC;QACR,IAAI,EAAE,EAAE;KACT,CAAC;IACF,UAAU,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;QACrB,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,2BAA2B;QACrC,MAAM,EAAE,UAAU;QAClB,KAAK,EAAE,CAAC;QACR,IAAI,EAAE,EAAE;KACT,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\nimport * as appInsights from 'applicationinsights';\n\nimport * as errorUtils from '../utils/errorUtils';\n\ntest('tryGetErrorCode() with valid error code', () => {\n expect(errorUtils.tryGetErrorCode('foo bar error FOO2020: the thing')).toBe(\n 'FOO2020',\n );\n});\n\ntest('tryGetErrorCode() without valid error code', () => {\n expect(errorUtils.tryGetErrorCode('foo bar the thing')).toBeUndefined();\n});\n\ntest('tryGetErrorCode() with word error but no code', () => {\n expect(errorUtils.tryGetErrorCode('test error')).toBeUndefined();\n});\n\ntest('sanitizeErrorMessage() no-op on empty string', () => {\n expect(errorUtils.sanitizeErrorMessage('')).toBe('');\n});\n\ntest('sanitizeErrorMessage() no-op on test string', () => {\n expect(errorUtils.sanitizeErrorMessage('some text')).toBe('some text');\n});\n\ntest(\"sanitizeErrorMessage() 'project_dir'\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(`this is the cwd: '${process.cwd()}'`),\n ).toBe(`this is the cwd: [project_dir]`);\n});\n\ntest(\"sanitizeErrorMessage() 'project_dir' uppercase\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `uppercase: '${process.cwd().toUpperCase()}'`,\n ),\n ).toBe(`uppercase: [project_dir]`);\n});\n\ntest(\"sanitizeErrorMessage() 'project_dir' lowercase\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `lowercase: '${process.cwd().toLowerCase()}'`,\n ),\n ).toBe(`lowercase: [project_dir]`);\n});\n\ntest(\"sanitizeErrorMessage() 'project_dir' and something else\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `this is the cwd: '${process.cwd()}' and something else`,\n ),\n ).toBe(`this is the cwd: [project_dir] and something else`);\n});\n\ntest('sanitizeErrorMessage() project_dir and something else', () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `this is the cwd: ${process.cwd()} and something else`,\n ),\n ).toBe(\n `this is the cwd: [project_dir]\\\\???(${' and something else'.length})`,\n );\n});\n\ntest(\"sanitizeErrorMessage() 'node_modules'\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `this is the cwd: '${process.cwd()}\\\\node_modules'`,\n ),\n ).toBe(`this is the cwd: [project_dir]\\\\???(${'node_modules'.length})`);\n});\n\ntest(\"sanitizeErrorMessage() 'node_modules\\\\foo'\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `this is the cwd: '${process.cwd()}\\\\node_modules\\\\foo'`,\n ),\n ).toBe(`this is the cwd: [node_modules]\\\\???(${'foo'.length})`);\n});\n\ntest(\"sanitizeErrorMessage() 'node_modules\\\\foo' uppercase\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `uppercase: '${process.cwd().toUpperCase()}\\\\NODE_MODULES\\\\foo'`,\n ),\n ).toBe(`uppercase: [node_modules]\\\\???(${'foo'.length})`);\n});\n\ntest(\"sanitizeErrorMessage() 'node_modules\\\\foo' lowercase\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `lowercase: '${process.cwd().toLowerCase()}\\\\NODE_MODULES\\\\foo'`,\n ),\n ).toBe(`lowercase: [node_modules]\\\\???(${'foo'.length})`);\n});\n\ntest(\"sanitizeErrorMessage() 'node_modules\\\\' and something else\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `trailing: '${process.cwd()}\\\\node_modules\\\\' and something else`,\n ),\n ).toBe(`trailing: [node_modules]\\\\???(0) and something else`);\n});\n\ntest('sanitizeErrorMessage() node_modules and something else that could be part of the path', () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `this is the cwd: ${process.cwd()}\\\\node_modules and something else that could be part of the path`,\n ),\n ).toBe(\n `this is the cwd: [project_dir]\\\\???(${\n 'node_modules and something else that could be part of the path'.length\n })`,\n );\n});\n\ntest('sanitizeErrorMessage() \\\\node_modules\\\\ a file under nm', () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `this is the cwd: ${process.cwd()}\\\\node_modules\\\\ a file under nm`,\n ),\n ).toBe(`this is the cwd: [node_modules]\\\\???(${' a file under nm'.length})`);\n});\n\ntest('sanitizeErrorMessage() other path', () => {\n expect(\n errorUtils.sanitizeErrorMessage(`this is another path: A:\\\\foo\\\\bar\\\\baz`),\n ).toBe(`this is another path: [path]`);\n});\n\ntest(\"sanitizeErrorMessage() 'other path'\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `this is another path: 'A:\\\\foo\\\\bar\\\\baz'`,\n ),\n ).toBe(`this is another path: [path]`);\n});\n\ntest('sanitizeErrorMessage() tracked packages in the npx cache', () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `Cannot find module 'react-native/package.json'\n Require stack:\n - ${process.env.AppData}\\\\npm-cache\\\\_npx\\\\1384\\\\node_modules\\\\react-native-windows-init\\\\lib-commonjs\\\\Cli.js\n - ${process.env.AppData}\\\\npm-cache\\\\_npx\\\\1384\\\\node_modules\\\\react-native-windows-init\\\\bin.js`,\n ),\n ).toBe(`Cannot find module react-native/package.json\n Require stack:\n - [node_modules]\\\\react-native-windows-init\\\\lib-commonjs\\\\Cli.js\n - [node_modules]\\\\react-native-windows-init\\\\bin.js`);\n});\n\ntest('sanitizeErrorMessage() forward slashes', () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `EPERM: operation not permitted, scandir ${process.env.UserProfile!.replace(\n /\\\\/g,\n '/',\n )}/source/repos/rn2/wintest/windows/packages/boost.1.76.0.0/lib/native/include`,\n ),\n ).toBe(\n `EPERM: operation not permitted, scandir [UserProfile]\\\\???(${\n '/source/repos/rn2/wintest/windows/packages/boost.1.76.0.0/lib/native/include'\n .length\n })`,\n );\n});\n\ntest('sanitizeErrorMessage() file share path', () => {\n expect(errorUtils.sanitizeErrorMessage(`file here: \\\\\\\\server\\\\share`)).toBe(\n 'file here: [path]',\n );\n});\n\ntest('sanitizeErrorMessage() with cpu id', () => {\n expect(errorUtils.sanitizeErrorMessage('5>This is an error')).toBe(\n 'This is an error',\n );\n});\n\ntest('sanitizeErrorMessage() with cpu/thread id', () => {\n expect(errorUtils.sanitizeErrorMessage('5:42>This is an error')).toEqual(\n 'This is an error',\n );\n});\n\ntest('sanitizeErrorStackFrame() with empty frame', () => {\n const emptyFrame: appInsights.Contracts.StackFrame = {\n level: 0,\n method: '',\n fileName: '',\n assembly: 'asdf',\n line: 0,\n };\n errorUtils.sanitizeErrorStackFrame(emptyFrame);\n expect(emptyFrame).toEqual({\n level: 0,\n assembly: '',\n fileName: '[path]',\n method: '',\n line: 0,\n });\n});\n\ntest('sanitizeErrorStackFrame() with assembly name', () => {\n const frame1: appInsights.Contracts.StackFrame = {\n method: '',\n fileName: `${process.cwd()}\\\\foo.js`,\n assembly: 'asdf',\n level: 0,\n line: 0,\n };\n errorUtils.sanitizeErrorStackFrame(frame1);\n expect(frame1).toEqual({\n assembly: '',\n fileName: '[project_dir]\\\\???.js(6)',\n method: '',\n level: 0,\n line: 0,\n });\n});\n\ntest('sanitizeErrorStackFrame() with method name', () => {\n const frame2: appInsights.Contracts.StackFrame = {\n method: `myMethod (something ${process.cwd()}`,\n fileName: `${process.cwd()}\\\\telemetry\\\\foo.js`,\n assembly: 'asdf',\n level: 1,\n line: 42,\n };\n errorUtils.sanitizeErrorStackFrame(frame2);\n expect(frame2).toEqual({\n assembly: '',\n fileName: '[project_dir]\\\\???.js(16)',\n method: 'myMethod',\n level: 1,\n line: 42,\n });\n});\n"]}
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
const path_1 = __importDefault(require("path"));
|
|
32
|
+
const child_process_1 = require("child_process");
|
|
33
|
+
const projectUtils = __importStar(require("../utils/projectUtils"));
|
|
34
|
+
test('getProjectId() does not match project name', () => {
|
|
35
|
+
const projectName = 'test-project';
|
|
36
|
+
expect(projectUtils.getProjectId(projectName)).not.toContain(projectName);
|
|
37
|
+
});
|
|
38
|
+
test('getProjectId() does not change for same project name', () => {
|
|
39
|
+
const projectName = 'test-project';
|
|
40
|
+
expect(projectUtils.getProjectId(projectName)).toBe(projectUtils.getProjectId(projectName));
|
|
41
|
+
});
|
|
42
|
+
test('getProjectId() returns different ids for different project names', () => {
|
|
43
|
+
const projectName1 = 'test-project1';
|
|
44
|
+
const projectName2 = 'test-project2';
|
|
45
|
+
expect(projectUtils.getProjectId(projectName1)).not.toBe(projectUtils.getProjectId(projectName2));
|
|
46
|
+
});
|
|
47
|
+
test('usesReactNativeConfig() is false with no react-native.config.js present', async () => {
|
|
48
|
+
const projectRoot = path_1.default.resolve(__dirname, 'projects/BlankUsesTypeScript');
|
|
49
|
+
const value = await projectUtils.usesReactNativeConfig(projectRoot);
|
|
50
|
+
expect(value).toBe(false);
|
|
51
|
+
});
|
|
52
|
+
test('usesReactNativeConfig() is true with react-native.config.js present', async () => {
|
|
53
|
+
const projectRoot = path_1.default.resolve(__dirname, 'projects/BlankUsesReactNativeConfig');
|
|
54
|
+
const value = await projectUtils.usesReactNativeConfig(projectRoot);
|
|
55
|
+
expect(value).toBe(true);
|
|
56
|
+
});
|
|
57
|
+
test('usesTypeScript() is false with no tsconfig.json present', async () => {
|
|
58
|
+
const projectRoot = path_1.default.resolve(__dirname, 'projects/BlankUsesReactNativeConfig');
|
|
59
|
+
const value = await projectUtils.usesTypeScript(projectRoot);
|
|
60
|
+
expect(value).toBe(false);
|
|
61
|
+
});
|
|
62
|
+
test('usesTypeScript() is true with tsconfig.json present', async () => {
|
|
63
|
+
const projectRoot = path_1.default.resolve(__dirname, 'projects/BlankUsesTypeScript');
|
|
64
|
+
const value = await projectUtils.usesTypeScript(projectRoot);
|
|
65
|
+
expect(value).toBe(true);
|
|
66
|
+
});
|
|
67
|
+
test('configToProjectInfo() works with playground project info', async () => {
|
|
68
|
+
const playgroundRoot = path_1.default.resolve(__dirname, '../../../../playground');
|
|
69
|
+
const config = JSON.parse((0, child_process_1.execSync)('npx react-native config', {
|
|
70
|
+
cwd: playgroundRoot,
|
|
71
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
72
|
+
}).toString());
|
|
73
|
+
const info = await projectUtils.configToProjectInfo(config);
|
|
74
|
+
expect(info).not.toBeNull();
|
|
75
|
+
const projectInfo = info;
|
|
76
|
+
expect(projectInfo.id).toBe(projectUtils.getProjectId('playground'));
|
|
77
|
+
expect(projectInfo.platforms).toStrictEqual(['windows']);
|
|
78
|
+
expect(projectInfo.rnwLang).toBe('cpp');
|
|
79
|
+
expect(projectInfo.usesTS).toBe(true);
|
|
80
|
+
expect(projectInfo.usesRNConfig).toBe(true);
|
|
81
|
+
expect(projectInfo.jsEngine).toBe('Hermes');
|
|
82
|
+
expect(projectInfo.rnwSource).toBe('Source');
|
|
83
|
+
});
|
|
84
|
+
//# 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,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,8BAA8B,CAAC,CAAC;IAC5E,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;IACpE,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,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,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,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 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});\n"]}
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
const path_1 = __importDefault(require("path"));
|
|
32
|
+
const sanitizeUtils = __importStar(require("../utils/sanitizeUtils"));
|
|
33
|
+
const projectDir = process.cwd();
|
|
34
|
+
test('getAnonymizedPath() with project dir is anonymized', () => {
|
|
35
|
+
const originalPath = projectDir;
|
|
36
|
+
const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);
|
|
37
|
+
expect(anonymizedPath).not.toBe(originalPath);
|
|
38
|
+
expect(anonymizedPath.startsWith('[project_dir]')).toBe(true);
|
|
39
|
+
});
|
|
40
|
+
test('getAnonymizedPath() with project/index.js is anonymized', () => {
|
|
41
|
+
const originalPath = path_1.default.join(projectDir, 'index.js');
|
|
42
|
+
const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);
|
|
43
|
+
expect(anonymizedPath).not.toBe(originalPath);
|
|
44
|
+
expect(anonymizedPath.startsWith('[project_dir]\\???.js')).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
test('getAnonymizedPath() with project/windows/test.sln is anonymized', () => {
|
|
47
|
+
const originalPath = path_1.default.normalize(path_1.default.join(projectDir, 'windows/test.sln'));
|
|
48
|
+
const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);
|
|
49
|
+
expect(anonymizedPath).not.toBe(originalPath);
|
|
50
|
+
expect(anonymizedPath.startsWith('[windows]\\???.sln')).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
test('getAnonymizedPath() with project/node_modules for untracked package is anonymized', () => {
|
|
53
|
+
const originalPath = path_1.default.normalize(path_1.default.join(projectDir, 'node_modules/untracked/index.js'));
|
|
54
|
+
const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);
|
|
55
|
+
expect(anonymizedPath).not.toBe(originalPath);
|
|
56
|
+
expect(anonymizedPath.startsWith('[node_modules]\\???.js')).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
test('getAnonymizedPath() with project/node_modules for react-secret-pii package is anonymized', () => {
|
|
59
|
+
const originalPath = path_1.default.normalize(path_1.default.join(projectDir, 'node_modules/react-secret-pii/index.js'));
|
|
60
|
+
const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);
|
|
61
|
+
expect(anonymizedPath).not.toBe(originalPath);
|
|
62
|
+
expect(anonymizedPath.startsWith('[node_modules]\\???.js')).toBe(true);
|
|
63
|
+
});
|
|
64
|
+
test('getAnonymizedPath() with path under react-native-windows is anonymized', () => {
|
|
65
|
+
const originalPath = path_1.default.normalize(path_1.default.join(projectDir, 'node_modules/react-native-windows/index.js'));
|
|
66
|
+
const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);
|
|
67
|
+
expect(anonymizedPath).not.toBe(originalPath);
|
|
68
|
+
expect(anonymizedPath).toBe('[node_modules]\\react-native-windows\\index.js');
|
|
69
|
+
});
|
|
70
|
+
test('getAnonymizedPath() with path under @react-native-windows/cli is anonymized', () => {
|
|
71
|
+
const originalPath = path_1.default.normalize(path_1.default.join(projectDir, 'node_modules/@react-native-windows/cli/index.js'));
|
|
72
|
+
const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);
|
|
73
|
+
expect(anonymizedPath).not.toBe(originalPath);
|
|
74
|
+
expect(anonymizedPath).toBe('[node_modules]\\@react-native-windows\\cli\\index.js');
|
|
75
|
+
});
|
|
76
|
+
test('getAnonymizedPath() with path under %%LocalAppData%% is anonymized', () => {
|
|
77
|
+
const originalPath = path_1.default.normalize(path_1.default.join(process.env.LocalAppData, 'test.sln'));
|
|
78
|
+
const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);
|
|
79
|
+
expect(anonymizedPath).not.toBe(originalPath);
|
|
80
|
+
expect(anonymizedPath.startsWith('[LocalAppData]\\???')).toBe(true);
|
|
81
|
+
});
|
|
82
|
+
test('getAnonymizedPath() with a tracked npm package under %%LocalAppData%% is anonymized', () => {
|
|
83
|
+
const originalPath = path_1.default.normalize(path_1.default.join(process.env.LocalAppData, 'node_modules/@react-native-windows/cli/index.js'));
|
|
84
|
+
const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);
|
|
85
|
+
expect(anonymizedPath).not.toBe(originalPath);
|
|
86
|
+
expect(anonymizedPath).toBe('[node_modules]\\@react-native-windows\\cli\\index.js');
|
|
87
|
+
});
|
|
88
|
+
test('getAnonymizedPath() with arbitrary path not under project dir is anonymized', () => {
|
|
89
|
+
const originalPath = 'test.sln';
|
|
90
|
+
const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);
|
|
91
|
+
expect(anonymizedPath).not.toBe(originalPath);
|
|
92
|
+
expect(anonymizedPath).toBe('[path]');
|
|
93
|
+
});
|
|
94
|
+
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,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,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
import * as appInsights from 'applicationinsights';
|
|
8
|
+
import { Telemetry } from '../telemetry';
|
|
9
|
+
export declare class TelemetryTest extends Telemetry {
|
|
10
|
+
protected static hasTestTelemetryProviders: boolean;
|
|
11
|
+
protected static testTelemetryProvidersRan: boolean;
|
|
12
|
+
/** Run at the beginning of each test. */
|
|
13
|
+
static startTest(): Promise<void>;
|
|
14
|
+
/** Run at the end of each test where telemetry was fired. */
|
|
15
|
+
static endTest(finalCallback: () => void): void;
|
|
16
|
+
/** Sets that the telemetry provider has run. */
|
|
17
|
+
static setTestTelemetryProvidersRan(): void;
|
|
18
|
+
/** Retrieves the value of a common property.*/
|
|
19
|
+
static getCommonProperty(key: string): string | undefined;
|
|
20
|
+
/** Retrieves the version of the specified tool/package. */
|
|
21
|
+
static getVersion(key: string): string | null;
|
|
22
|
+
/** Adds a telemetry processor, usually for verifying the envelope. */
|
|
23
|
+
static addTelemetryProcessor(telemetryProcessor: (envelope: appInsights.Contracts.EnvelopeTelemetry, contextObjects?: {
|
|
24
|
+
[name: string]: any;
|
|
25
|
+
}) => boolean): void;
|
|
26
|
+
}
|