@react-native-windows/telemetry 0.73.0 → 0.74.0-preview.1

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.
Files changed (30) hide show
  1. package/lib-commonjs/e2etest/telemetry.test.d.ts +28 -28
  2. package/lib-commonjs/e2etest/telemetry.test.js +496 -496
  3. package/lib-commonjs/index.d.ts +11 -11
  4. package/lib-commonjs/index.js +26 -26
  5. package/lib-commonjs/telemetry.d.ts +84 -84
  6. package/lib-commonjs/telemetry.js +370 -370
  7. package/lib-commonjs/telemetry.js.map +1 -1
  8. package/lib-commonjs/test/basePropUtils.test.d.ts +7 -7
  9. package/lib-commonjs/test/basePropUtils.test.js +137 -137
  10. package/lib-commonjs/test/errorUtils.test.d.ts +7 -7
  11. package/lib-commonjs/test/errorUtils.test.js +159 -159
  12. package/lib-commonjs/test/projectUtils.test.d.ts +7 -7
  13. package/lib-commonjs/test/projectUtils.test.js +87 -87
  14. package/lib-commonjs/test/sanitizeUtils.test.d.ts +7 -7
  15. package/lib-commonjs/test/sanitizeUtils.test.js +97 -97
  16. package/lib-commonjs/test/versionUtils.test.d.ts +7 -7
  17. package/lib-commonjs/test/versionUtils.test.js +114 -114
  18. package/lib-commonjs/utils/basePropUtils.d.ts +81 -81
  19. package/lib-commonjs/utils/basePropUtils.js +173 -173
  20. package/lib-commonjs/utils/errorUtils.d.ts +87 -87
  21. package/lib-commonjs/utils/errorUtils.js +178 -178
  22. package/lib-commonjs/utils/optionUtils.d.ts +45 -45
  23. package/lib-commonjs/utils/optionUtils.js +95 -95
  24. package/lib-commonjs/utils/projectUtils.d.ts +50 -50
  25. package/lib-commonjs/utils/projectUtils.js +186 -186
  26. package/lib-commonjs/utils/sanitizeUtils.d.ts +12 -12
  27. package/lib-commonjs/utils/sanitizeUtils.js +81 -81
  28. package/lib-commonjs/utils/versionUtils.d.ts +38 -38
  29. package/lib-commonjs/utils/versionUtils.js +155 -155
  30. package/package.json +14 -16
@@ -1,166 +1,166 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
32
- const errorUtils = __importStar(require("../utils/errorUtils"));
33
- test('tryGetErrorCode() with valid error code', () => {
34
- expect(errorUtils.tryGetErrorCode('foo bar error FOO2020: the thing')).toBe('FOO2020');
35
- });
36
- test('tryGetErrorCode() without valid error code', () => {
37
- expect(errorUtils.tryGetErrorCode('foo bar the thing')).toBeUndefined();
38
- });
39
- test('tryGetErrorCode() with word error but no code', () => {
40
- expect(errorUtils.tryGetErrorCode('test error')).toBeUndefined();
41
- });
42
- test('sanitizeErrorMessage() no-op on empty string', () => {
43
- expect(errorUtils.sanitizeErrorMessage('')).toBe('');
44
- });
45
- test('sanitizeErrorMessage() no-op on test string', () => {
46
- expect(errorUtils.sanitizeErrorMessage('some text')).toBe('some text');
47
- });
48
- test("sanitizeErrorMessage() 'project_dir'", () => {
49
- expect(errorUtils.sanitizeErrorMessage(`this is the cwd: '${process.cwd()}'`)).toBe(`this is the cwd: [project_dir]`);
50
- });
51
- test("sanitizeErrorMessage() 'project_dir' uppercase", () => {
52
- expect(errorUtils.sanitizeErrorMessage(`uppercase: '${process.cwd().toUpperCase()}'`)).toBe(`uppercase: [project_dir]`);
53
- });
54
- test("sanitizeErrorMessage() 'project_dir' lowercase", () => {
55
- expect(errorUtils.sanitizeErrorMessage(`lowercase: '${process.cwd().toLowerCase()}'`)).toBe(`lowercase: [project_dir]`);
56
- });
57
- test("sanitizeErrorMessage() 'project_dir' and something else", () => {
58
- expect(errorUtils.sanitizeErrorMessage(`this is the cwd: '${process.cwd()}' and something else`)).toBe(`this is the cwd: [project_dir] and something else`);
59
- });
60
- test('sanitizeErrorMessage() project_dir and something else', () => {
61
- expect(errorUtils.sanitizeErrorMessage(`this is the cwd: ${process.cwd()} and something else`)).toBe(`this is the cwd: [project_dir]\\???(${' and something else'.length})`);
62
- });
63
- test("sanitizeErrorMessage() 'node_modules'", () => {
64
- expect(errorUtils.sanitizeErrorMessage(`this is the cwd: '${process.cwd()}\\node_modules'`)).toBe(`this is the cwd: [project_dir]\\???(${'node_modules'.length})`);
65
- });
66
- test("sanitizeErrorMessage() 'node_modules\\foo'", () => {
67
- expect(errorUtils.sanitizeErrorMessage(`this is the cwd: '${process.cwd()}\\node_modules\\foo'`)).toBe(`this is the cwd: [node_modules]\\???(${'foo'.length})`);
68
- });
69
- test("sanitizeErrorMessage() 'node_modules\\foo' uppercase", () => {
70
- expect(errorUtils.sanitizeErrorMessage(`uppercase: '${process.cwd().toUpperCase()}\\NODE_MODULES\\foo'`)).toBe(`uppercase: [node_modules]\\???(${'foo'.length})`);
71
- });
72
- test("sanitizeErrorMessage() 'node_modules\\foo' lowercase", () => {
73
- expect(errorUtils.sanitizeErrorMessage(`lowercase: '${process.cwd().toLowerCase()}\\NODE_MODULES\\foo'`)).toBe(`lowercase: [node_modules]\\???(${'foo'.length})`);
74
- });
75
- test("sanitizeErrorMessage() 'node_modules\\' and something else", () => {
76
- expect(errorUtils.sanitizeErrorMessage(`trailing: '${process.cwd()}\\node_modules\\' and something else`)).toBe(`trailing: [node_modules]\\???(0) and something else`);
77
- });
78
- test('sanitizeErrorMessage() node_modules and something else that could be part of the path', () => {
79
- 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})`);
80
- });
81
- test('sanitizeErrorMessage() \\node_modules\\ a file under nm', () => {
82
- 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})`);
83
- });
84
- test('sanitizeErrorMessage() other path', () => {
85
- expect(errorUtils.sanitizeErrorMessage(`this is another path: A:\\foo\\bar\\baz`)).toBe(`this is another path: [path]`);
86
- });
87
- test("sanitizeErrorMessage() 'other path'", () => {
88
- expect(errorUtils.sanitizeErrorMessage(`this is another path: 'A:\\foo\\bar\\baz'`)).toBe(`this is another path: [path]`);
89
- });
90
- test('sanitizeErrorMessage() tracked packages in the npx cache', () => {
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
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ const errorUtils = __importStar(require("../utils/errorUtils"));
33
+ test('tryGetErrorCode() with valid error code', () => {
34
+ expect(errorUtils.tryGetErrorCode('foo bar error FOO2020: the thing')).toBe('FOO2020');
35
+ });
36
+ test('tryGetErrorCode() without valid error code', () => {
37
+ expect(errorUtils.tryGetErrorCode('foo bar the thing')).toBeUndefined();
38
+ });
39
+ test('tryGetErrorCode() with word error but no code', () => {
40
+ expect(errorUtils.tryGetErrorCode('test error')).toBeUndefined();
41
+ });
42
+ test('sanitizeErrorMessage() no-op on empty string', () => {
43
+ expect(errorUtils.sanitizeErrorMessage('')).toBe('');
44
+ });
45
+ test('sanitizeErrorMessage() no-op on test string', () => {
46
+ expect(errorUtils.sanitizeErrorMessage('some text')).toBe('some text');
47
+ });
48
+ test("sanitizeErrorMessage() 'project_dir'", () => {
49
+ expect(errorUtils.sanitizeErrorMessage(`this is the cwd: '${process.cwd()}'`)).toBe(`this is the cwd: [project_dir]`);
50
+ });
51
+ test("sanitizeErrorMessage() 'project_dir' uppercase", () => {
52
+ expect(errorUtils.sanitizeErrorMessage(`uppercase: '${process.cwd().toUpperCase()}'`)).toBe(`uppercase: [project_dir]`);
53
+ });
54
+ test("sanitizeErrorMessage() 'project_dir' lowercase", () => {
55
+ expect(errorUtils.sanitizeErrorMessage(`lowercase: '${process.cwd().toLowerCase()}'`)).toBe(`lowercase: [project_dir]`);
56
+ });
57
+ test("sanitizeErrorMessage() 'project_dir' and something else", () => {
58
+ expect(errorUtils.sanitizeErrorMessage(`this is the cwd: '${process.cwd()}' and something else`)).toBe(`this is the cwd: [project_dir] and something else`);
59
+ });
60
+ test('sanitizeErrorMessage() project_dir and something else', () => {
61
+ expect(errorUtils.sanitizeErrorMessage(`this is the cwd: ${process.cwd()} and something else`)).toBe(`this is the cwd: [project_dir]\\???(${' and something else'.length})`);
62
+ });
63
+ test("sanitizeErrorMessage() 'node_modules'", () => {
64
+ expect(errorUtils.sanitizeErrorMessage(`this is the cwd: '${process.cwd()}\\node_modules'`)).toBe(`this is the cwd: [project_dir]\\???(${'node_modules'.length})`);
65
+ });
66
+ test("sanitizeErrorMessage() 'node_modules\\foo'", () => {
67
+ expect(errorUtils.sanitizeErrorMessage(`this is the cwd: '${process.cwd()}\\node_modules\\foo'`)).toBe(`this is the cwd: [node_modules]\\???(${'foo'.length})`);
68
+ });
69
+ test("sanitizeErrorMessage() 'node_modules\\foo' uppercase", () => {
70
+ expect(errorUtils.sanitizeErrorMessage(`uppercase: '${process.cwd().toUpperCase()}\\NODE_MODULES\\foo'`)).toBe(`uppercase: [node_modules]\\???(${'foo'.length})`);
71
+ });
72
+ test("sanitizeErrorMessage() 'node_modules\\foo' lowercase", () => {
73
+ expect(errorUtils.sanitizeErrorMessage(`lowercase: '${process.cwd().toLowerCase()}\\NODE_MODULES\\foo'`)).toBe(`lowercase: [node_modules]\\???(${'foo'.length})`);
74
+ });
75
+ test("sanitizeErrorMessage() 'node_modules\\' and something else", () => {
76
+ expect(errorUtils.sanitizeErrorMessage(`trailing: '${process.cwd()}\\node_modules\\' and something else`)).toBe(`trailing: [node_modules]\\???(0) and something else`);
77
+ });
78
+ test('sanitizeErrorMessage() node_modules and something else that could be part of the path', () => {
79
+ 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})`);
80
+ });
81
+ test('sanitizeErrorMessage() \\node_modules\\ a file under nm', () => {
82
+ 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})`);
83
+ });
84
+ test('sanitizeErrorMessage() other path', () => {
85
+ expect(errorUtils.sanitizeErrorMessage(`this is another path: A:\\foo\\bar\\baz`)).toBe(`this is another path: [path]`);
86
+ });
87
+ test("sanitizeErrorMessage() 'other path'", () => {
88
+ expect(errorUtils.sanitizeErrorMessage(`this is another path: 'A:\\foo\\bar\\baz'`)).toBe(`this is another path: [path]`);
89
+ });
90
+ test('sanitizeErrorMessage() tracked packages in the npx cache', () => {
91
91
  expect(errorUtils.sanitizeErrorMessage(`Cannot find module 'react-native/package.json'
92
92
  Require stack:
93
93
  - ${process.env.AppData}\\npm-cache\\_npx\\1384\\node_modules\\react-native-windows-init\\lib-commonjs\\Cli.js
94
94
  - ${process.env.AppData}\\npm-cache\\_npx\\1384\\node_modules\\react-native-windows-init\\bin.js`)).toBe(`Cannot find module react-native/package.json
95
95
  Require stack:
96
96
  - [node_modules]\\react-native-windows-init\\lib-commonjs\\Cli.js
97
- - [node_modules]\\react-native-windows-init\\bin.js`);
98
- });
99
- test('sanitizeErrorMessage() forward slashes', () => {
100
- 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'
101
- .length})`);
102
- });
103
- test('sanitizeErrorMessage() file share path', () => {
104
- expect(errorUtils.sanitizeErrorMessage(`file here: \\\\server\\share`)).toBe('file here: [path]');
105
- });
106
- test('sanitizeErrorMessage() with cpu id', () => {
107
- expect(errorUtils.sanitizeErrorMessage('5>This is an error')).toBe('This is an error');
108
- });
109
- test('sanitizeErrorMessage() with cpu/thread id', () => {
110
- expect(errorUtils.sanitizeErrorMessage('5:42>This is an error')).toEqual('This is an error');
111
- });
112
- test('sanitizeErrorMessage() with standard MSBuild error', () => {
113
- expect(errorUtils.sanitizeErrorMessage(`2:6>C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.19041.0\\XamlCompiler\\Microsoft.Windows.UI.Xaml.Common.targets(486,5): error MSB4181: The "CompileXaml" task returned false but did not log an error. [${process.cwd()}\\windows\\teltest68\\teltest68.csproj]`)).toEqual(`[path](486,5): error MSB4181: The CompileXaml task returned false but did not log an error. [windows]\\???.csproj(${'teltest68\\teltest68.csproj'.length})`);
114
- });
115
- test('sanitizeErrorStackFrame() with empty frame', () => {
116
- const emptyFrame = {
117
- level: 0,
118
- method: '',
119
- fileName: '',
120
- assembly: 'asdf',
121
- line: 0,
122
- };
123
- errorUtils.sanitizeErrorStackFrame(emptyFrame);
124
- expect(emptyFrame).toEqual({
125
- level: 0,
126
- assembly: '',
127
- fileName: '[path]',
128
- method: '',
129
- line: 0,
130
- });
131
- });
132
- test('sanitizeErrorStackFrame() with assembly name', () => {
133
- const frame1 = {
134
- method: '',
135
- fileName: `${process.cwd()}\\foo.js`,
136
- assembly: 'asdf',
137
- level: 0,
138
- line: 0,
139
- };
140
- errorUtils.sanitizeErrorStackFrame(frame1);
141
- expect(frame1).toEqual({
142
- assembly: '',
143
- fileName: '[project_dir]\\???.js(6)',
144
- method: '',
145
- level: 0,
146
- line: 0,
147
- });
148
- });
149
- test('sanitizeErrorStackFrame() with method name', () => {
150
- const frame2 = {
151
- method: `myMethod (something ${process.cwd()}`,
152
- fileName: `${process.cwd()}\\telemetry\\foo.js`,
153
- assembly: 'asdf',
154
- level: 1,
155
- line: 42,
156
- };
157
- errorUtils.sanitizeErrorStackFrame(frame2);
158
- expect(frame2).toEqual({
159
- assembly: '',
160
- fileName: '[project_dir]\\???.js(16)',
161
- method: 'myMethod',
162
- level: 1,
163
- line: 42,
164
- });
165
- });
97
+ - [node_modules]\\react-native-windows-init\\bin.js`);
98
+ });
99
+ test('sanitizeErrorMessage() forward slashes', () => {
100
+ 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'
101
+ .length})`);
102
+ });
103
+ test('sanitizeErrorMessage() file share path', () => {
104
+ expect(errorUtils.sanitizeErrorMessage(`file here: \\\\server\\share`)).toBe('file here: [path]');
105
+ });
106
+ test('sanitizeErrorMessage() with cpu id', () => {
107
+ expect(errorUtils.sanitizeErrorMessage('5>This is an error')).toBe('This is an error');
108
+ });
109
+ test('sanitizeErrorMessage() with cpu/thread id', () => {
110
+ expect(errorUtils.sanitizeErrorMessage('5:42>This is an error')).toEqual('This is an error');
111
+ });
112
+ test('sanitizeErrorMessage() with standard MSBuild error', () => {
113
+ expect(errorUtils.sanitizeErrorMessage(`2:6>C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.19041.0\\XamlCompiler\\Microsoft.Windows.UI.Xaml.Common.targets(486,5): error MSB4181: The "CompileXaml" task returned false but did not log an error. [${process.cwd()}\\windows\\teltest68\\teltest68.csproj]`)).toEqual(`[path](486,5): error MSB4181: The CompileXaml task returned false but did not log an error. [windows]\\???.csproj(${'teltest68\\teltest68.csproj'.length})`);
114
+ });
115
+ test('sanitizeErrorStackFrame() with empty frame', () => {
116
+ const emptyFrame = {
117
+ level: 0,
118
+ method: '',
119
+ fileName: '',
120
+ assembly: 'asdf',
121
+ line: 0,
122
+ };
123
+ errorUtils.sanitizeErrorStackFrame(emptyFrame);
124
+ expect(emptyFrame).toEqual({
125
+ level: 0,
126
+ assembly: '',
127
+ fileName: '[path]',
128
+ method: '',
129
+ line: 0,
130
+ });
131
+ });
132
+ test('sanitizeErrorStackFrame() with assembly name', () => {
133
+ const frame1 = {
134
+ method: '',
135
+ fileName: `${process.cwd()}\\foo.js`,
136
+ assembly: 'asdf',
137
+ level: 0,
138
+ line: 0,
139
+ };
140
+ errorUtils.sanitizeErrorStackFrame(frame1);
141
+ expect(frame1).toEqual({
142
+ assembly: '',
143
+ fileName: '[project_dir]\\???.js(6)',
144
+ method: '',
145
+ level: 0,
146
+ line: 0,
147
+ });
148
+ });
149
+ test('sanitizeErrorStackFrame() with method name', () => {
150
+ const frame2 = {
151
+ method: `myMethod (something ${process.cwd()}`,
152
+ fileName: `${process.cwd()}\\telemetry\\foo.js`,
153
+ assembly: 'asdf',
154
+ level: 1,
155
+ line: 42,
156
+ };
157
+ errorUtils.sanitizeErrorStackFrame(frame2);
158
+ expect(frame2).toEqual({
159
+ assembly: '',
160
+ fileName: '[project_dir]\\???.js(16)',
161
+ method: 'myMethod',
162
+ level: 1,
163
+ line: 42,
164
+ });
165
+ });
166
166
  //# sourceMappingURL=errorUtils.test.js.map
@@ -1,7 +1,7 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- *
5
- * @format
6
- */
7
- export {};
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ *
5
+ * @format
6
+ */
7
+ export {};
@@ -1,88 +1,88 @@
1
- "use strict";
2
- /**
3
- * Copyright (c) Microsoft Corporation.
4
- * Licensed under the MIT License.
5
- *
6
- * @format
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
- Object.defineProperty(o, "default", { enumerable: true, value: v });
21
- }) : function(o, v) {
22
- o["default"] = v;
23
- });
24
- var __importStar = (this && this.__importStar) || function (mod) {
25
- if (mod && mod.__esModule) return mod;
26
- var result = {};
27
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
- __setModuleDefault(result, mod);
29
- return result;
30
- };
31
- var __importDefault = (this && this.__importDefault) || function (mod) {
32
- return (mod && mod.__esModule) ? mod : { "default": mod };
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- const path_1 = __importDefault(require("path"));
36
- const child_process_1 = require("child_process");
37
- const projectUtils = __importStar(require("../utils/projectUtils"));
38
- test('getProjectId() does not match project name', () => {
39
- const projectName = 'test-project';
40
- expect(projectUtils.getProjectId(projectName)).not.toContain(projectName);
41
- });
42
- test('getProjectId() does not change for same project name', () => {
43
- const projectName = 'test-project';
44
- expect(projectUtils.getProjectId(projectName)).toBe(projectUtils.getProjectId(projectName));
45
- });
46
- test('getProjectId() returns different ids for different project names', () => {
47
- const projectName1 = 'test-project1';
48
- const projectName2 = 'test-project2';
49
- expect(projectUtils.getProjectId(projectName1)).not.toBe(projectUtils.getProjectId(projectName2));
50
- });
51
- test('usesReactNativeConfig() is false with no react-native.config.js present', async () => {
52
- const projectRoot = path_1.default.resolve(__dirname, 'projects/BlankUsesTypeScript');
53
- const value = await projectUtils.usesReactNativeConfig(projectRoot);
54
- expect(value).toBe(false);
55
- });
56
- test('usesReactNativeConfig() is true with react-native.config.js present', async () => {
57
- const projectRoot = path_1.default.resolve(__dirname, 'projects/BlankUsesReactNativeConfig');
58
- const value = await projectUtils.usesReactNativeConfig(projectRoot);
59
- expect(value).toBe(true);
60
- });
61
- test('usesTypeScript() is false with no tsconfig.json present', async () => {
62
- const projectRoot = path_1.default.resolve(__dirname, 'projects/BlankUsesReactNativeConfig');
63
- const value = await projectUtils.usesTypeScript(projectRoot);
64
- expect(value).toBe(false);
65
- });
66
- test('usesTypeScript() is true with tsconfig.json present', async () => {
67
- const projectRoot = path_1.default.resolve(__dirname, 'projects/BlankUsesTypeScript');
68
- const value = await projectUtils.usesTypeScript(projectRoot);
69
- expect(value).toBe(true);
70
- });
71
- test('configToProjectInfo() works with playground project info', async () => {
72
- const playgroundRoot = path_1.default.resolve(__dirname, '../../../../playground');
73
- const config = JSON.parse((0, child_process_1.execSync)('npx react-native config', {
74
- cwd: playgroundRoot,
75
- stdio: ['ignore', 'pipe', 'ignore'],
76
- }).toString());
77
- const info = await projectUtils.configToProjectInfo(config);
78
- expect(info).not.toBeNull();
79
- const projectInfo = info;
80
- expect(projectInfo.id).toBe(projectUtils.getProjectId('playground'));
81
- expect(projectInfo.platforms).toStrictEqual(['windows']);
82
- expect(projectInfo.rnwLang).toBe('cpp');
83
- expect(projectInfo.usesTS).toBe(true);
84
- expect(projectInfo.usesRNConfig).toBe(true);
85
- expect(projectInfo.jsEngine).toBe('Hermes');
86
- expect(projectInfo.rnwSource).toBe('Source');
87
- }, 200000 /* Increase timeout of this test */);
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ * Licensed under the MIT License.
5
+ *
6
+ * @format
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || function (mod) {
25
+ if (mod && mod.__esModule) return mod;
26
+ var result = {};
27
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
+ __setModuleDefault(result, mod);
29
+ return result;
30
+ };
31
+ var __importDefault = (this && this.__importDefault) || function (mod) {
32
+ return (mod && mod.__esModule) ? mod : { "default": mod };
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ const path_1 = __importDefault(require("path"));
36
+ const child_process_1 = require("child_process");
37
+ const projectUtils = __importStar(require("../utils/projectUtils"));
38
+ test('getProjectId() does not match project name', () => {
39
+ const projectName = 'test-project';
40
+ expect(projectUtils.getProjectId(projectName)).not.toContain(projectName);
41
+ });
42
+ test('getProjectId() does not change for same project name', () => {
43
+ const projectName = 'test-project';
44
+ expect(projectUtils.getProjectId(projectName)).toBe(projectUtils.getProjectId(projectName));
45
+ });
46
+ test('getProjectId() returns different ids for different project names', () => {
47
+ const projectName1 = 'test-project1';
48
+ const projectName2 = 'test-project2';
49
+ expect(projectUtils.getProjectId(projectName1)).not.toBe(projectUtils.getProjectId(projectName2));
50
+ });
51
+ test('usesReactNativeConfig() is false with no react-native.config.js present', async () => {
52
+ const projectRoot = path_1.default.resolve(__dirname, 'projects/BlankUsesTypeScript');
53
+ const value = await projectUtils.usesReactNativeConfig(projectRoot);
54
+ expect(value).toBe(false);
55
+ });
56
+ test('usesReactNativeConfig() is true with react-native.config.js present', async () => {
57
+ const projectRoot = path_1.default.resolve(__dirname, 'projects/BlankUsesReactNativeConfig');
58
+ const value = await projectUtils.usesReactNativeConfig(projectRoot);
59
+ expect(value).toBe(true);
60
+ });
61
+ test('usesTypeScript() is false with no tsconfig.json present', async () => {
62
+ const projectRoot = path_1.default.resolve(__dirname, 'projects/BlankUsesReactNativeConfig');
63
+ const value = await projectUtils.usesTypeScript(projectRoot);
64
+ expect(value).toBe(false);
65
+ });
66
+ test('usesTypeScript() is true with tsconfig.json present', async () => {
67
+ const projectRoot = path_1.default.resolve(__dirname, 'projects/BlankUsesTypeScript');
68
+ const value = await projectUtils.usesTypeScript(projectRoot);
69
+ expect(value).toBe(true);
70
+ });
71
+ test('configToProjectInfo() works with playground project info', async () => {
72
+ const playgroundRoot = path_1.default.resolve(__dirname, '../../../../playground');
73
+ const config = JSON.parse((0, child_process_1.execSync)('npx react-native config', {
74
+ cwd: playgroundRoot,
75
+ stdio: ['ignore', 'pipe', 'ignore'],
76
+ }).toString());
77
+ const info = await projectUtils.configToProjectInfo(config);
78
+ expect(info).not.toBeNull();
79
+ const projectInfo = info;
80
+ expect(projectInfo.id).toBe(projectUtils.getProjectId('playground'));
81
+ expect(projectInfo.platforms).toStrictEqual(['windows']);
82
+ expect(projectInfo.rnwLang).toBe('cpp');
83
+ expect(projectInfo.usesTS).toBe(true);
84
+ expect(projectInfo.usesRNConfig).toBe(true);
85
+ expect(projectInfo.jsEngine).toBe('Hermes');
86
+ expect(projectInfo.rnwSource).toBe('Source');
87
+ }, 200000 /* Increase timeout of this test */);
88
88
  //# sourceMappingURL=projectUtils.test.js.map
@@ -1,7 +1,7 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- *
5
- * @format
6
- */
7
- export {};
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ *
5
+ * @format
6
+ */
7
+ export {};