@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,82 +1,82 @@
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.getAnonymizedPath = void 0;
12
- const path_1 = __importDefault(require("path"));
13
- const telemetry_1 = require("../telemetry");
14
- const nodeModules = '\\node_modules\\';
15
- const windows = '\\windows\\';
16
- const knownEnvironmentVariablePaths = [
17
- 'AppData',
18
- 'LocalAppData',
19
- 'UserProfile',
20
- ];
21
- /**
22
- * Gets an anonymized version of the given path, suitable for Telemetry.
23
- * @param filepath The path to anonymize.
24
- * @param projectRoot Optional root path for the project. Defaults to process.cwd().
25
- * @returns The anonymized path.
26
- */
27
- function getAnonymizedPath(filepath, projectRoot) {
28
- projectRoot = (projectRoot !== null && projectRoot !== void 0 ? projectRoot : process.cwd())
29
- .replace(/\//g, '\\')
30
- .toLowerCase();
31
- projectRoot = projectRoot.endsWith('\\')
32
- ? projectRoot.slice(0, -1)
33
- : projectRoot;
34
- filepath = filepath.replace(/\//g, '\\');
35
- const ext = path_1.default.extname(filepath);
36
- // Check if we're under node_modules
37
- const nodeModulesIndex = filepath.toLowerCase().lastIndexOf(nodeModules);
38
- if (nodeModulesIndex >= 0) {
39
- // We are under node_modules
40
- // Check if it's an npm package we're tracking
41
- for (const trackedNpmPackage of telemetry_1.NpmPackagesWeTrack) {
42
- const startIndex = filepath
43
- .toLowerCase()
44
- .lastIndexOf(nodeModules + trackedNpmPackage.replace(/\//g, '\\') + '\\');
45
- if (startIndex >= 0) {
46
- // We are under node_modules within an npm package we're tracking, anonymize by removing root
47
- return ('[node_modules]\\' + filepath.slice(startIndex + nodeModules.length));
48
- }
49
- }
50
- // It's an npm package we're not tracking, anonymize with [node_modules]
51
- return `[node_modules]\\???${ext}(${filepath.slice(nodeModulesIndex).length - nodeModules.length})`;
52
- }
53
- // Check if we're under the projectRoot
54
- if (filepath.toLowerCase().startsWith(projectRoot)) {
55
- // We are under the projectRoot
56
- const rest = filepath.slice(projectRoot.length);
57
- if (rest.toLowerCase().startsWith(windows)) {
58
- // We are under the windows path, anonymize with [windows]
59
- return `[windows]\\???${ext}(${rest.length - windows.length})`;
60
- }
61
- else {
62
- // We are just within the projectRoot, anonymize with [project_dir]
63
- if (rest === '' || rest === '\\') {
64
- return '[project_dir]';
65
- }
66
- else {
67
- return `[project_dir]\\???${ext}(${rest.length - (rest.startsWith('\\') ? 1 : 0)})`;
68
- }
69
- }
70
- }
71
- // Check if we're under a known environmental variable path
72
- for (const knownPath of knownEnvironmentVariablePaths) {
73
- if (process.env[knownPath] &&
74
- filepath.toLowerCase().startsWith(process.env[knownPath].toLowerCase())) {
75
- return `[${knownPath}]\\???(${filepath.length - process.env[knownPath].length})`;
76
- }
77
- }
78
- // We are somewhere else, anonymize with [path]
79
- return '[path]';
80
- }
81
- exports.getAnonymizedPath = getAnonymizedPath;
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.getAnonymizedPath = void 0;
12
+ const path_1 = __importDefault(require("path"));
13
+ const telemetry_1 = require("../telemetry");
14
+ const nodeModules = '\\node_modules\\';
15
+ const windows = '\\windows\\';
16
+ const knownEnvironmentVariablePaths = [
17
+ 'AppData',
18
+ 'LocalAppData',
19
+ 'UserProfile',
20
+ ];
21
+ /**
22
+ * Gets an anonymized version of the given path, suitable for Telemetry.
23
+ * @param filepath The path to anonymize.
24
+ * @param projectRoot Optional root path for the project. Defaults to process.cwd().
25
+ * @returns The anonymized path.
26
+ */
27
+ function getAnonymizedPath(filepath, projectRoot) {
28
+ projectRoot = (projectRoot !== null && projectRoot !== void 0 ? projectRoot : process.cwd())
29
+ .replace(/\//g, '\\')
30
+ .toLowerCase();
31
+ projectRoot = projectRoot.endsWith('\\')
32
+ ? projectRoot.slice(0, -1)
33
+ : projectRoot;
34
+ filepath = filepath.replace(/\//g, '\\');
35
+ const ext = path_1.default.extname(filepath);
36
+ // Check if we're under node_modules
37
+ const nodeModulesIndex = filepath.toLowerCase().lastIndexOf(nodeModules);
38
+ if (nodeModulesIndex >= 0) {
39
+ // We are under node_modules
40
+ // Check if it's an npm package we're tracking
41
+ for (const trackedNpmPackage of telemetry_1.NpmPackagesWeTrack) {
42
+ const startIndex = filepath
43
+ .toLowerCase()
44
+ .lastIndexOf(nodeModules + trackedNpmPackage.replace(/\//g, '\\') + '\\');
45
+ if (startIndex >= 0) {
46
+ // We are under node_modules within an npm package we're tracking, anonymize by removing root
47
+ return ('[node_modules]\\' + filepath.slice(startIndex + nodeModules.length));
48
+ }
49
+ }
50
+ // It's an npm package we're not tracking, anonymize with [node_modules]
51
+ return `[node_modules]\\???${ext}(${filepath.slice(nodeModulesIndex).length - nodeModules.length})`;
52
+ }
53
+ // Check if we're under the projectRoot
54
+ if (filepath.toLowerCase().startsWith(projectRoot)) {
55
+ // We are under the projectRoot
56
+ const rest = filepath.slice(projectRoot.length);
57
+ if (rest.toLowerCase().startsWith(windows)) {
58
+ // We are under the windows path, anonymize with [windows]
59
+ return `[windows]\\???${ext}(${rest.length - windows.length})`;
60
+ }
61
+ else {
62
+ // We are just within the projectRoot, anonymize with [project_dir]
63
+ if (rest === '' || rest === '\\') {
64
+ return '[project_dir]';
65
+ }
66
+ else {
67
+ return `[project_dir]\\???${ext}(${rest.length - (rest.startsWith('\\') ? 1 : 0)})`;
68
+ }
69
+ }
70
+ }
71
+ // Check if we're under a known environmental variable path
72
+ for (const knownPath of knownEnvironmentVariablePaths) {
73
+ if (process.env[knownPath] &&
74
+ filepath.toLowerCase().startsWith(process.env[knownPath].toLowerCase())) {
75
+ return `[${knownPath}]\\???(${filepath.length - process.env[knownPath].length})`;
76
+ }
77
+ }
78
+ // We are somewhere else, anonymize with [path]
79
+ return '[path]';
80
+ }
81
+ exports.getAnonymizedPath = getAnonymizedPath;
82
82
  //# sourceMappingURL=sanitizeUtils.js.map
@@ -1,38 +1,38 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- * @format
5
- */
6
- /**
7
- * Gets the version of node being used.
8
- * @returns The version of node being used.
9
- */
10
- export declare function getNodeVersion(): Promise<string | null>;
11
- /**
12
- * Gets the version of npm installed, if available.
13
- * @returns The version of npm installed, if available.
14
- */
15
- export declare function getNpmVersion(): Promise<string | null>;
16
- /**
17
- * Gets the version of yarn installed, if available.
18
- * @returns The version of yarn installed, if available.
19
- */
20
- export declare function getYarnVersion(): Promise<string | null>;
21
- /**
22
- * Gets the latest version of Visual Studio installed, if available.
23
- * @returns The latest version of Visual Studio installed, if available.
24
- */
25
- export declare function getVisualStudioVersion(): Promise<string | null>;
26
- /**
27
- * Gets the version installed of the specified npm package.
28
- * @param pkgName The npm package name.
29
- * @returns The version installed, if available.
30
- */
31
- export declare function getVersionOfNpmPackage(pkgName: string): Promise<string | null>;
32
- /**
33
- * Gets the versions of the specified NuGet packages referenced in a project file.
34
- * @param projectFile Path to the native project file.
35
- * @param nugetPackages The NuGet package names to look for.
36
- * @returns The mapping of NuGet package names and their versions.
37
- */
38
- export declare function getVersionsOfNuGetPackages(projectFile: string, nugetPackages: string[]): Promise<Record<string, string>>;
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ /**
7
+ * Gets the version of node being used.
8
+ * @returns The version of node being used.
9
+ */
10
+ export declare function getNodeVersion(): Promise<string | null>;
11
+ /**
12
+ * Gets the version of npm installed, if available.
13
+ * @returns The version of npm installed, if available.
14
+ */
15
+ export declare function getNpmVersion(): Promise<string | null>;
16
+ /**
17
+ * Gets the version of yarn installed, if available.
18
+ * @returns The version of yarn installed, if available.
19
+ */
20
+ export declare function getYarnVersion(): Promise<string | null>;
21
+ /**
22
+ * Gets the latest version of Visual Studio installed, if available.
23
+ * @returns The latest version of Visual Studio installed, if available.
24
+ */
25
+ export declare function getVisualStudioVersion(): Promise<string | null>;
26
+ /**
27
+ * Gets the version installed of the specified npm package.
28
+ * @param pkgName The npm package name.
29
+ * @returns The version installed, if available.
30
+ */
31
+ export declare function getVersionOfNpmPackage(pkgName: string): Promise<string | null>;
32
+ /**
33
+ * Gets the versions of the specified NuGet packages referenced in a project file.
34
+ * @param projectFile Path to the native project file.
35
+ * @param nugetPackages The NuGet package names to look for.
36
+ * @returns The mapping of NuGet package names and their versions.
37
+ */
38
+ export declare function getVersionsOfNuGetPackages(projectFile: string, nugetPackages: string[]): Promise<Record<string, string>>;
@@ -1,156 +1,156 @@
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.getVersionsOfNuGetPackages = exports.getVersionOfNpmPackage = exports.getVisualStudioVersion = exports.getYarnVersion = exports.getNpmVersion = exports.getNodeVersion = void 0;
12
- const envinfo_1 = __importDefault(require("envinfo"));
13
- const fs_1 = __importDefault(require("@react-native-windows/fs"));
14
- const path_1 = __importDefault(require("path"));
15
- const xmldom_1 = require("@xmldom/xmldom");
16
- const xpath_1 = __importDefault(require("xpath"));
17
- const msbuildSelect = xpath_1.default.useNamespaces({
18
- msbuild: 'http://schemas.microsoft.com/developer/msbuild/2003',
19
- });
20
- /**
21
- * Gets the version of node being used.
22
- * @returns The version of node being used.
23
- */
24
- async function getNodeVersion() {
25
- return process.version.slice(1);
26
- }
27
- exports.getNodeVersion = getNodeVersion;
28
- /**
29
- * Gets the version of npm installed, if available.
30
- * @returns The version of npm installed, if available.
31
- */
32
- async function getNpmVersion() {
33
- try {
34
- const info = await envinfo_1.default.helpers.getnpmInfo();
35
- return info[1];
36
- }
37
- catch (_a) { }
38
- return null;
39
- }
40
- exports.getNpmVersion = getNpmVersion;
41
- /**
42
- * Gets the version of yarn installed, if available.
43
- * @returns The version of yarn installed, if available.
44
- */
45
- async function getYarnVersion() {
46
- try {
47
- const info = await envinfo_1.default.helpers.getYarnInfo();
48
- return info[1];
49
- }
50
- catch (_a) { }
51
- return null;
52
- }
53
- exports.getYarnVersion = getYarnVersion;
54
- /**
55
- * Gets the latest version of Visual Studio installed, if available.
56
- * @returns The latest version of Visual Studio installed, if available.
57
- */
58
- async function getVisualStudioVersion() {
59
- try {
60
- const info = await envinfo_1.default.helpers.getVisualStudioInfo();
61
- const versions = info[1];
62
- return versions.sort().slice(-1)[0].split(' ')[0];
63
- }
64
- catch (_a) { }
65
- return null;
66
- }
67
- exports.getVisualStudioVersion = getVisualStudioVersion;
68
- /**
69
- * Gets the version installed of the specified npm package.
70
- * @param pkgName The npm package name.
71
- * @returns The version installed, if available.
72
- */
73
- async function getVersionOfNpmPackage(pkgName) {
74
- try {
75
- const pkgJsonPath = require.resolve(`${pkgName.trim()}/package.json`, {
76
- paths: [process.cwd(), __dirname],
77
- });
78
- const pkgJson = await fs_1.default.readJsonFile(pkgJsonPath);
79
- if (pkgJson.name === pkgName) {
80
- return pkgJson.version;
81
- }
82
- }
83
- catch (_a) { }
84
- return null;
85
- }
86
- exports.getVersionOfNpmPackage = getVersionOfNpmPackage;
87
- /**
88
- * Reads and parses an XML file into a Document.
89
- * @param filePath The path to the XML file.
90
- * @returns The parsed Document.
91
- */
92
- async function readXmlFile(filePath) {
93
- const contents = await fs_1.default.readFile(filePath, 'utf-8');
94
- return new xmldom_1.DOMParser().parseFromString(contents);
95
- }
96
- /**
97
- * Gets the versions of the specified NuGet packages referenced in a packages.config file.
98
- * @param projectDoc The XML document of the packages.config file.
99
- * @param nugetPackages The NuGet package names to look for.
100
- * @returns The mapping of NuGet package names and their versions.
101
- */
102
- function getVersionsFromPackagesConfig(packagesConfigDoc, nugetPackages) {
103
- const versions = {};
104
- for (const pkgName of nugetPackages) {
105
- const version = xpath_1.default.select1(`//packages/package[@id='${pkgName}']/@version`, packagesConfigDoc);
106
- if (version) {
107
- const versionValue = version.nodeValue;
108
- if (versionValue !== null) {
109
- versions[pkgName] = versionValue;
110
- }
111
- }
112
- }
113
- return versions;
114
- }
115
- /**
116
- * Gets the versions of the specified NuGet packages referenced in a project file.
117
- * @param projectDoc The XML document of the project file.
118
- * @param nugetPackages The NuGet package names to look for.
119
- * @returns The mapping of NuGet package names and their versions.
120
- */
121
- function getVersionsFromProjectFile(projectDoc, nugetPackages) {
122
- const versions = {};
123
- for (const pkgName of nugetPackages) {
124
- const version = msbuildSelect(`//msbuild:ItemGroup/msbuild:PackageReference[@Include='${pkgName}']/msbuild:Version`, projectDoc, true);
125
- if (version) {
126
- const versionValue = version.textContent;
127
- if (versionValue !== null) {
128
- versions[pkgName] = versionValue;
129
- }
130
- }
131
- }
132
- return versions;
133
- }
134
- /**
135
- * Gets the versions of the specified NuGet packages referenced in a project file.
136
- * @param projectFile Path to the native project file.
137
- * @param nugetPackages The NuGet package names to look for.
138
- * @returns The mapping of NuGet package names and their versions.
139
- */
140
- async function getVersionsOfNuGetPackages(projectFile, nugetPackages) {
141
- try {
142
- // First check for the presence of a packages.config file
143
- const packagesConfigFile = path_1.default.join(path_1.default.dirname(projectFile), 'packages.config');
144
- const packagesConfigDoc = await readXmlFile(packagesConfigFile);
145
- return getVersionsFromPackagesConfig(packagesConfigDoc, nugetPackages);
146
- }
147
- catch (_a) { }
148
- try {
149
- const projectDoc = await readXmlFile(projectFile);
150
- return getVersionsFromProjectFile(projectDoc, nugetPackages);
151
- }
152
- catch (_b) { }
153
- return {};
154
- }
155
- exports.getVersionsOfNuGetPackages = getVersionsOfNuGetPackages;
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.getVersionsOfNuGetPackages = exports.getVersionOfNpmPackage = exports.getVisualStudioVersion = exports.getYarnVersion = exports.getNpmVersion = exports.getNodeVersion = void 0;
12
+ const envinfo_1 = __importDefault(require("envinfo"));
13
+ const fs_1 = __importDefault(require("@react-native-windows/fs"));
14
+ const path_1 = __importDefault(require("path"));
15
+ const xmldom_1 = require("@xmldom/xmldom");
16
+ const xpath_1 = __importDefault(require("xpath"));
17
+ const msbuildSelect = xpath_1.default.useNamespaces({
18
+ msbuild: 'http://schemas.microsoft.com/developer/msbuild/2003',
19
+ });
20
+ /**
21
+ * Gets the version of node being used.
22
+ * @returns The version of node being used.
23
+ */
24
+ async function getNodeVersion() {
25
+ return process.version.slice(1);
26
+ }
27
+ exports.getNodeVersion = getNodeVersion;
28
+ /**
29
+ * Gets the version of npm installed, if available.
30
+ * @returns The version of npm installed, if available.
31
+ */
32
+ async function getNpmVersion() {
33
+ try {
34
+ const info = await envinfo_1.default.helpers.getnpmInfo();
35
+ return info[1];
36
+ }
37
+ catch (_a) { }
38
+ return null;
39
+ }
40
+ exports.getNpmVersion = getNpmVersion;
41
+ /**
42
+ * Gets the version of yarn installed, if available.
43
+ * @returns The version of yarn installed, if available.
44
+ */
45
+ async function getYarnVersion() {
46
+ try {
47
+ const info = await envinfo_1.default.helpers.getYarnInfo();
48
+ return info[1];
49
+ }
50
+ catch (_a) { }
51
+ return null;
52
+ }
53
+ exports.getYarnVersion = getYarnVersion;
54
+ /**
55
+ * Gets the latest version of Visual Studio installed, if available.
56
+ * @returns The latest version of Visual Studio installed, if available.
57
+ */
58
+ async function getVisualStudioVersion() {
59
+ try {
60
+ const info = await envinfo_1.default.helpers.getVisualStudioInfo();
61
+ const versions = info[1];
62
+ return versions.sort().slice(-1)[0].split(' ')[0];
63
+ }
64
+ catch (_a) { }
65
+ return null;
66
+ }
67
+ exports.getVisualStudioVersion = getVisualStudioVersion;
68
+ /**
69
+ * Gets the version installed of the specified npm package.
70
+ * @param pkgName The npm package name.
71
+ * @returns The version installed, if available.
72
+ */
73
+ async function getVersionOfNpmPackage(pkgName) {
74
+ try {
75
+ const pkgJsonPath = require.resolve(`${pkgName.trim()}/package.json`, {
76
+ paths: [process.cwd(), __dirname],
77
+ });
78
+ const pkgJson = await fs_1.default.readJsonFile(pkgJsonPath);
79
+ if (pkgJson.name === pkgName) {
80
+ return pkgJson.version;
81
+ }
82
+ }
83
+ catch (_a) { }
84
+ return null;
85
+ }
86
+ exports.getVersionOfNpmPackage = getVersionOfNpmPackage;
87
+ /**
88
+ * Reads and parses an XML file into a Document.
89
+ * @param filePath The path to the XML file.
90
+ * @returns The parsed Document.
91
+ */
92
+ async function readXmlFile(filePath) {
93
+ const contents = await fs_1.default.readFile(filePath, 'utf-8');
94
+ return new xmldom_1.DOMParser().parseFromString(contents);
95
+ }
96
+ /**
97
+ * Gets the versions of the specified NuGet packages referenced in a packages.config file.
98
+ * @param projectDoc The XML document of the packages.config file.
99
+ * @param nugetPackages The NuGet package names to look for.
100
+ * @returns The mapping of NuGet package names and their versions.
101
+ */
102
+ function getVersionsFromPackagesConfig(packagesConfigDoc, nugetPackages) {
103
+ const versions = {};
104
+ for (const pkgName of nugetPackages) {
105
+ const version = xpath_1.default.select1(`//packages/package[@id='${pkgName}']/@version`, packagesConfigDoc);
106
+ if (version) {
107
+ const versionValue = version.nodeValue;
108
+ if (versionValue !== null) {
109
+ versions[pkgName] = versionValue;
110
+ }
111
+ }
112
+ }
113
+ return versions;
114
+ }
115
+ /**
116
+ * Gets the versions of the specified NuGet packages referenced in a project file.
117
+ * @param projectDoc The XML document of the project file.
118
+ * @param nugetPackages The NuGet package names to look for.
119
+ * @returns The mapping of NuGet package names and their versions.
120
+ */
121
+ function getVersionsFromProjectFile(projectDoc, nugetPackages) {
122
+ const versions = {};
123
+ for (const pkgName of nugetPackages) {
124
+ const version = msbuildSelect(`//msbuild:ItemGroup/msbuild:PackageReference[@Include='${pkgName}']/msbuild:Version`, projectDoc, true);
125
+ if (version) {
126
+ const versionValue = version.textContent;
127
+ if (versionValue !== null) {
128
+ versions[pkgName] = versionValue;
129
+ }
130
+ }
131
+ }
132
+ return versions;
133
+ }
134
+ /**
135
+ * Gets the versions of the specified NuGet packages referenced in a project file.
136
+ * @param projectFile Path to the native project file.
137
+ * @param nugetPackages The NuGet package names to look for.
138
+ * @returns The mapping of NuGet package names and their versions.
139
+ */
140
+ async function getVersionsOfNuGetPackages(projectFile, nugetPackages) {
141
+ try {
142
+ // First check for the presence of a packages.config file
143
+ const packagesConfigFile = path_1.default.join(path_1.default.dirname(projectFile), 'packages.config');
144
+ const packagesConfigDoc = await readXmlFile(packagesConfigFile);
145
+ return getVersionsFromPackagesConfig(packagesConfigDoc, nugetPackages);
146
+ }
147
+ catch (_a) { }
148
+ try {
149
+ const projectDoc = await readXmlFile(projectFile);
150
+ return getVersionsFromProjectFile(projectDoc, nugetPackages);
151
+ }
152
+ catch (_b) { }
153
+ return {};
154
+ }
155
+ exports.getVersionsOfNuGetPackages = getVersionsOfNuGetPackages;
156
156
  //# sourceMappingURL=versionUtils.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-windows/telemetry",
3
- "version": "0.73.0",
3
+ "version": "0.74.0-preview.1",
4
4
  "license": "MIT",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "typings": "lib-commonjs/index.d.ts",
@@ -18,9 +18,10 @@
18
18
  "watch": "rnw-scripts watch"
19
19
  },
20
20
  "dependencies": {
21
- "@react-native-windows/fs": "0.73.0",
21
+ "@azure/core-auth": "1.5.0",
22
+ "@react-native-windows/fs": "0.74.0-preview.1",
22
23
  "@xmldom/xmldom": "^0.7.7",
23
- "applicationinsights": "^2.3.1",
24
+ "applicationinsights": "2.9.1",
24
25
  "ci-info": "^3.2.0",
25
26
  "envinfo": "^7.8.1",
26
27
  "lodash": "^4.17.21",
@@ -28,9 +29,9 @@
28
29
  "xpath": "^0.0.27"
29
30
  },
30
31
  "devDependencies": {
31
- "@rnw-scripts/eslint-config": "1.2.3",
32
- "@rnw-scripts/jest-unittest-config": "1.5.6",
33
- "@rnw-scripts/just-task": "2.3.17",
32
+ "@rnw-scripts/eslint-config": "1.2.9",
33
+ "@rnw-scripts/jest-unittest-config": "1.5.8",
34
+ "@rnw-scripts/just-task": "2.3.25",
34
35
  "@rnw-scripts/ts-config": "2.0.5",
35
36
  "@types/envinfo": "^7.8.1",
36
37
  "@types/jest": "^29.2.2",
@@ -38,28 +39,25 @@
38
39
  "@types/semver": "^7.3.3",
39
40
  "@typescript-eslint/eslint-plugin": "^5.30.5",
40
41
  "@typescript-eslint/parser": "^5.57.1",
41
- "babel-jest": "^29.3.0",
42
+ "babel-jest": "^29.6.3",
42
43
  "eslint": "^8.19.0",
43
- "jest": "^29.2.1",
44
+ "jest": "^29.6.3",
44
45
  "lookpath": "^1.2.1",
45
- "prettier": "^2.4.1",
46
+ "prettier": "2.8.8",
46
47
  "semver": "^7.3.5",
47
- "typescript": "^4.9.5"
48
+ "typescript": "5.0.4"
48
49
  },
49
50
  "files": [
50
51
  "lib-commonjs"
51
52
  ],
52
53
  "beachball": {
53
- "defaultNpmTag": "latest",
54
+ "defaultNpmTag": "preview",
54
55
  "disallowedChangeTypes": [
55
56
  "major",
56
57
  "minor",
57
- "prerelease"
58
+ "patch"
58
59
  ]
59
60
  },
60
61
  "promoteRelease": true,
61
- "windowsOnly": true,
62
- "engines": {
63
- "node": ">= 18"
64
- }
62
+ "windowsOnly": true
65
63
  }