@react-native-windows/telemetry 0.0.0-canary.8 → 0.0.0-canary.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib-commonjs/e2etest/telemetry.test.d.ts +28 -0
- package/lib-commonjs/e2etest/telemetry.test.js +497 -0
- package/lib-commonjs/e2etest/telemetry.test.js.map +1 -0
- package/lib-commonjs/index.d.ts +6 -1
- package/lib-commonjs/index.js +17 -2
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/telemetry.d.ts +75 -18
- package/lib-commonjs/telemetry.js +340 -141
- package/lib-commonjs/telemetry.js.map +1 -1
- package/lib-commonjs/test/basePropUtils.test.js +138 -0
- package/lib-commonjs/test/basePropUtils.test.js.map +1 -0
- package/lib-commonjs/test/errorUtils.test.d.ts +7 -0
- package/lib-commonjs/test/errorUtils.test.js +166 -0
- package/lib-commonjs/test/errorUtils.test.js.map +1 -0
- package/lib-commonjs/test/projectUtils.test.d.ts +7 -0
- package/lib-commonjs/test/projectUtils.test.js +88 -0
- package/lib-commonjs/test/projectUtils.test.js.map +1 -0
- package/lib-commonjs/test/sanitizeUtils.test.d.ts +7 -0
- package/lib-commonjs/test/sanitizeUtils.test.js +98 -0
- package/lib-commonjs/test/sanitizeUtils.test.js.map +1 -0
- package/lib-commonjs/test/versionUtils.test.d.ts +7 -0
- package/lib-commonjs/test/versionUtils.test.js +115 -0
- package/lib-commonjs/test/versionUtils.test.js.map +1 -0
- package/lib-commonjs/utils/basePropUtils.d.ts +81 -0
- package/lib-commonjs/utils/basePropUtils.js +174 -0
- package/lib-commonjs/utils/basePropUtils.js.map +1 -0
- package/lib-commonjs/utils/errorUtils.d.ts +87 -0
- package/lib-commonjs/utils/errorUtils.js +179 -0
- package/lib-commonjs/utils/errorUtils.js.map +1 -0
- package/lib-commonjs/utils/optionUtils.d.ts +45 -0
- package/lib-commonjs/utils/optionUtils.js +96 -0
- package/lib-commonjs/utils/optionUtils.js.map +1 -0
- package/lib-commonjs/utils/projectUtils.d.ts +50 -0
- package/lib-commonjs/utils/projectUtils.js +187 -0
- package/lib-commonjs/utils/projectUtils.js.map +1 -0
- package/lib-commonjs/utils/sanitizeUtils.d.ts +12 -0
- package/lib-commonjs/utils/sanitizeUtils.js +82 -0
- package/lib-commonjs/utils/sanitizeUtils.js.map +1 -0
- package/lib-commonjs/utils/versionUtils.d.ts +38 -0
- package/lib-commonjs/utils/versionUtils.js +156 -0
- package/lib-commonjs/utils/versionUtils.js.map +1 -0
- package/package.json +37 -21
- package/CHANGELOG.json +0 -110
- package/CHANGELOG.md +0 -63
- package/lib-commonjs/test/sanitize.test.js +0 -220
- package/lib-commonjs/test/sanitize.test.js.map +0 -1
- /package/lib-commonjs/test/{sanitize.test.d.ts → basePropUtils.test.d.ts} +0 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
24
|
+
if (mod && mod.__esModule) return mod;
|
|
25
|
+
var result = {};
|
|
26
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
27
|
+
__setModuleDefault(result, mod);
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.sanitizeErrorStackFrame = exports.sanitizeErrorMessage = exports.tryGetErrorCode = exports.CodedError = exports.CodedErrors = void 0;
|
|
32
|
+
const sanitizeUtils = __importStar(require("./sanitizeUtils"));
|
|
33
|
+
// Note: All CLI commands will set process.exitCode to the numerical value of
|
|
34
|
+
// a thrown CodedError. However node reserves codes 1-192 as per:
|
|
35
|
+
// https://nodejs.org/api/process.html#process_exit_codes so we shouldn't
|
|
36
|
+
// override those as other tools may be monitoring the error code
|
|
37
|
+
exports.CodedErrors = {
|
|
38
|
+
Success: 0,
|
|
39
|
+
Unknown: -1,
|
|
40
|
+
// react-native-windows-init
|
|
41
|
+
UnsupportedReactNativeVersion: 1000,
|
|
42
|
+
UserCancel: 1001,
|
|
43
|
+
NoReactNativeFound: 1002,
|
|
44
|
+
NoPackageJson: 1003,
|
|
45
|
+
NoLatestReactNativeWindows: 1004,
|
|
46
|
+
NoAutoMatchingReactNativeWindows: 1005,
|
|
47
|
+
IncompatibleOptions: 1006,
|
|
48
|
+
NoReactNativeDependencies: 1007,
|
|
49
|
+
NoMatchingPackageVersion: 1008,
|
|
50
|
+
// run-windows
|
|
51
|
+
NoSolution: 2000,
|
|
52
|
+
// Project generation
|
|
53
|
+
NoPropertyInProject: 2100,
|
|
54
|
+
CopyProjectTemplateNoSourcePath: 2101,
|
|
55
|
+
CopyProjectTemplateNoDestPath: 2102,
|
|
56
|
+
CopyProjectTemplateNoProjectName: 2103,
|
|
57
|
+
// SDK requirements
|
|
58
|
+
MinSDKVersionNotMet: 2200,
|
|
59
|
+
BadSDKVersionFormat: 2201,
|
|
60
|
+
NoSDK: 2202,
|
|
61
|
+
// Build
|
|
62
|
+
NoMSBuild: 2300,
|
|
63
|
+
NoVSWhere: 2301,
|
|
64
|
+
MSBuildError: 2302,
|
|
65
|
+
// Deploy
|
|
66
|
+
NoAppPackage: 2400,
|
|
67
|
+
NoAppxManifest: 2401,
|
|
68
|
+
NoDevice: 2402,
|
|
69
|
+
AppDidNotDeploy: 2403,
|
|
70
|
+
InvalidDevicesOutput: 2404,
|
|
71
|
+
RemoveOldAppVersionFailure: 2405,
|
|
72
|
+
EnableDevModeFailure: 2406,
|
|
73
|
+
InstallAppFailure: 2407,
|
|
74
|
+
InstallAppDependenciesFailure: 2408,
|
|
75
|
+
CheckNetIsolationFailure: 2409,
|
|
76
|
+
InstallAppToDeviceFailure: 2410,
|
|
77
|
+
UninstallAppOnDeviceFailure: 2411,
|
|
78
|
+
DeployRecipeFailure: 2412,
|
|
79
|
+
// Launch
|
|
80
|
+
AppStartupFailure: 2500,
|
|
81
|
+
// autolink-windows
|
|
82
|
+
NoWindowsConfig: 3000,
|
|
83
|
+
IncompleteConfig: 3001,
|
|
84
|
+
InvalidConfig: 3002,
|
|
85
|
+
NeedAutolinking: 3003,
|
|
86
|
+
AddProjectToSolution: 3004,
|
|
87
|
+
Autolinking: 3005,
|
|
88
|
+
// codegen-windows
|
|
89
|
+
NeedCodegen: 4000,
|
|
90
|
+
InvalidCodegenConfig: 4001,
|
|
91
|
+
// init-windows
|
|
92
|
+
NoTemplatesFound: 5000,
|
|
93
|
+
NoDefaultTemplate: 5001,
|
|
94
|
+
InvalidTemplateName: 5002,
|
|
95
|
+
NoProjectName: 5003,
|
|
96
|
+
InvalidProjectName: 5004,
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Represents an error whose message might contain user-originating content,
|
|
100
|
+
* therefore when transmitting telemetry, only the type should be sent.
|
|
101
|
+
* @param type a stable ID identifying the type of error.
|
|
102
|
+
* @param message the error text. This should only be used for display to the user.
|
|
103
|
+
* @param data any additional metadata that is safe to collect for telemetry purposes.
|
|
104
|
+
*/
|
|
105
|
+
class CodedError extends Error {
|
|
106
|
+
constructor(type, message, data) {
|
|
107
|
+
super(message);
|
|
108
|
+
this.type = type;
|
|
109
|
+
this.data = data;
|
|
110
|
+
this.name = type;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.CodedError = CodedError;
|
|
114
|
+
/**
|
|
115
|
+
* Tries to parse an error code out of an error message.
|
|
116
|
+
* @param msg An error message to process.
|
|
117
|
+
* @returns The parsed error code.
|
|
118
|
+
*/
|
|
119
|
+
function tryGetErrorCode(msg) {
|
|
120
|
+
const errorRegEx = /error (\w+\d+):/gi;
|
|
121
|
+
const m = errorRegEx.exec(msg);
|
|
122
|
+
return m ? m[1] : undefined;
|
|
123
|
+
}
|
|
124
|
+
exports.tryGetErrorCode = tryGetErrorCode;
|
|
125
|
+
/**
|
|
126
|
+
* Sanitize an error message by anonymizing any paths that appear between quotes (''), brackets ([]), or double quotes ("").
|
|
127
|
+
* @param msg The error message to sanitize.
|
|
128
|
+
* @return The message with any paths anonymized.
|
|
129
|
+
*/
|
|
130
|
+
function sanitizeErrorMessage(msg) {
|
|
131
|
+
const msBuildErrorMessage = /^\d+:\d+>(.*)(\(\d+,\d+\)): error (\w+\d+): (.*)/g;
|
|
132
|
+
msg = msg.replace(msBuildErrorMessage, '[$1]$2: error $3: $4');
|
|
133
|
+
const cpuThreadId = /^\d+(:\d+)?>/g;
|
|
134
|
+
msg = msg.replace(cpuThreadId, '');
|
|
135
|
+
const parts = msg.split(/['[\]"]/g);
|
|
136
|
+
const clean = [];
|
|
137
|
+
const pathRegEx = /(['["]?)([A-Za-z]:|\\)[\\/]([^<>:;,?"*\t\r\n|/\\]+[\\/])+([^<>:;,?"*\t\r\n|]+\/?(['["]?))/gi;
|
|
138
|
+
for (const part of parts) {
|
|
139
|
+
if (pathRegEx.test(part)) {
|
|
140
|
+
pathRegEx.lastIndex = -1;
|
|
141
|
+
let matches;
|
|
142
|
+
let noPath = '';
|
|
143
|
+
let last = 0;
|
|
144
|
+
while ((matches = pathRegEx.exec(part))) {
|
|
145
|
+
noPath +=
|
|
146
|
+
part.substr(last, matches.index - last) +
|
|
147
|
+
sanitizeUtils.getAnonymizedPath(matches[0]);
|
|
148
|
+
last = matches.index + matches[0].length;
|
|
149
|
+
}
|
|
150
|
+
if (noPath !== '') {
|
|
151
|
+
clean.push(noPath);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else if (part !== '') {
|
|
155
|
+
clean.push(part);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return clean.join('').trim();
|
|
159
|
+
}
|
|
160
|
+
exports.sanitizeErrorMessage = sanitizeErrorMessage;
|
|
161
|
+
/**
|
|
162
|
+
* Sanitizes an error stack frame.
|
|
163
|
+
* @param frame
|
|
164
|
+
*/
|
|
165
|
+
function sanitizeErrorStackFrame(frame) {
|
|
166
|
+
const parens = frame.method.indexOf('(');
|
|
167
|
+
if (parens !== -1) {
|
|
168
|
+
// case 1: method === 'methodName (rootOfThePath'
|
|
169
|
+
frame.method = frame.method.substr(0, parens).trim();
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
// case 2: method === <no_method> or something without '(', fileName is full path
|
|
173
|
+
}
|
|
174
|
+
// anonymize the filename
|
|
175
|
+
frame.fileName = sanitizeUtils.getAnonymizedPath(frame.fileName);
|
|
176
|
+
frame.assembly = '';
|
|
177
|
+
}
|
|
178
|
+
exports.sanitizeErrorStackFrame = sanitizeErrorStackFrame;
|
|
179
|
+
//# sourceMappingURL=errorUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorUtils.js","sourceRoot":"","sources":["../../src/utils/errorUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;AAIH,+DAAiD;AAEjD,6EAA6E;AAC7E,iEAAiE;AACjE,yE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AC;IACjE,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC;AACtB,CAAC;AAbD,0DAaC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport * as appInsights from 'applicationinsights';\n\nimport * as sanitizeUtils from './sanitizeUtils';\n\n// Note: All CLI commands will set process.exitCode to the numerical value of\n// a thrown CodedError. However node reserves codes 1-192 as per:\n// https://nodejs.org/api/process.html#process_exit_codes so we shouldn't\n// override those as other tools may be monitoring the error code\n\nexport const CodedErrors = {\n Success: 0,\n Unknown: -1,\n\n // react-native-windows-init\n UnsupportedReactNativeVersion: 1000,\n UserCancel: 1001,\n NoReactNativeFound: 1002,\n NoPackageJson: 1003,\n NoLatestReactNativeWindows: 1004,\n NoAutoMatchingReactNativeWindows: 1005,\n IncompatibleOptions: 1006,\n NoReactNativeDependencies: 1007,\n NoMatchingPackageVersion: 1008,\n\n // run-windows\n NoSolution: 2000,\n // Project generation\n NoPropertyInProject: 2100,\n CopyProjectTemplateNoSourcePath: 2101,\n CopyProjectTemplateNoDestPath: 2102,\n CopyProjectTemplateNoProjectName: 2103,\n // SDK requirements\n MinSDKVersionNotMet: 2200,\n BadSDKVersionFormat: 2201,\n NoSDK: 2202,\n // Build\n NoMSBuild: 2300,\n NoVSWhere: 2301,\n MSBuildError: 2302,\n // Deploy\n NoAppPackage: 2400,\n NoAppxManifest: 2401,\n NoDevice: 2402,\n AppDidNotDeploy: 2403,\n InvalidDevicesOutput: 2404,\n RemoveOldAppVersionFailure: 2405,\n EnableDevModeFailure: 2406,\n InstallAppFailure: 2407,\n InstallAppDependenciesFailure: 2408,\n CheckNetIsolationFailure: 2409,\n InstallAppToDeviceFailure: 2410,\n UninstallAppOnDeviceFailure: 2411,\n DeployRecipeFailure: 2412,\n // Launch\n AppStartupFailure: 2500,\n\n // autolink-windows\n NoWindowsConfig: 3000,\n IncompleteConfig: 3001,\n InvalidConfig: 3002,\n NeedAutolinking: 3003,\n AddProjectToSolution: 3004,\n Autolinking: 3005,\n\n // codegen-windows\n NeedCodegen: 4000,\n InvalidCodegenConfig: 4001,\n\n // init-windows\n NoTemplatesFound: 5000,\n NoDefaultTemplate: 5001,\n InvalidTemplateName: 5002,\n NoProjectName: 5003,\n InvalidProjectName: 5004,\n};\n\nexport type CodedErrorType = keyof typeof CodedErrors;\n\n/**\n * Represents an error whose message might contain user-originating content,\n * therefore when transmitting telemetry, only the type should be sent.\n * @param type a stable ID identifying the type of error.\n * @param message the error text. This should only be used for display to the user.\n * @param data any additional metadata that is safe to collect for telemetry purposes.\n */\nexport class CodedError extends Error {\n constructor(\n public readonly type: CodedErrorType,\n message: string,\n public readonly data?: Record<string, any>,\n ) {\n super(message);\n this.name = type;\n }\n}\n\n/**\n * Tries to parse an error code out of an error message.\n * @param msg An error message to process.\n * @returns The parsed error code.\n */\nexport function tryGetErrorCode(msg: string): string | undefined {\n const errorRegEx = /error (\\w+\\d+):/gi;\n const m = errorRegEx.exec(msg);\n return m ? m[1] : undefined;\n}\n\n/**\n * Sanitize an error message by anonymizing any paths that appear between quotes (''), brackets ([]), or double quotes (\"\").\n * @param msg The error message to sanitize.\n * @return The message with any paths anonymized.\n */\nexport function sanitizeErrorMessage(msg: string): string {\n const msBuildErrorMessage =\n /^\\d+:\\d+>(.*)(\\(\\d+,\\d+\\)): error (\\w+\\d+): (.*)/g;\n msg = msg.replace(msBuildErrorMessage, '[$1]$2: error $3: $4');\n\n const cpuThreadId = /^\\d+(:\\d+)?>/g;\n msg = msg.replace(cpuThreadId, '');\n\n const parts = msg.split(/['[\\]\"]/g);\n const clean = [];\n const pathRegEx =\n /(['[\"]?)([A-Za-z]:|\\\\)[\\\\/]([^<>:;,?\"*\\t\\r\\n|/\\\\]+[\\\\/])+([^<>:;,?\"*\\t\\r\\n|]+\\/?(['[\"]?))/gi;\n for (const part of parts) {\n if (pathRegEx.test(part)) {\n pathRegEx.lastIndex = -1;\n let matches: RegExpExecArray | null;\n let noPath = '';\n let last = 0;\n while ((matches = pathRegEx.exec(part))) {\n noPath +=\n part.substr(last, matches!.index - last) +\n sanitizeUtils.getAnonymizedPath(matches[0]);\n last = matches!.index + matches![0].length;\n }\n if (noPath !== '') {\n clean.push(noPath);\n }\n } else if (part !== '') {\n clean.push(part);\n }\n }\n return clean.join('').trim();\n}\n\n/**\n * Sanitizes an error stack frame.\n * @param frame\n */\nexport function sanitizeErrorStackFrame(\n frame: appInsights.Contracts.StackFrame,\n): void {\n const parens = frame.method.indexOf('(');\n if (parens !== -1) {\n // case 1: method === 'methodName (rootOfThePath'\n frame.method = frame.method.substr(0, parens).trim();\n } else {\n // case 2: method === <no_method> or something without '(', fileName is full path\n }\n // anonymize the filename\n frame.fileName = sanitizeUtils.getAnonymizedPath(frame.fileName);\n frame.assembly = '';\n}\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
* @format
|
|
5
|
+
*/
|
|
6
|
+
export type OptionSanitizer = (key: string, value: any) => any;
|
|
7
|
+
export type YargsOptionsType = Record<string, any>;
|
|
8
|
+
export interface CommanderOptionsType extends Record<string, any> {
|
|
9
|
+
logging?: boolean;
|
|
10
|
+
telemetry?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Converts a raw Commander arg name ('--no-bad-dog') into an options property name ('badDog').
|
|
14
|
+
* @param name The raw Commander arg name.
|
|
15
|
+
* @returns The options name.
|
|
16
|
+
*/
|
|
17
|
+
export declare function commanderNameToOptionName(name: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Converts a yargs-parsed options object into an options object suitable for telemetry.
|
|
20
|
+
* @param options The options object as parsed by yargs.
|
|
21
|
+
* @param sanitizer Function to sanitize the option values for telemetry.
|
|
22
|
+
* @returns An options object suitable for telemetry.
|
|
23
|
+
*/
|
|
24
|
+
export declare function yargsOptionsToOptions(options: YargsOptionsType, sanitizer?: OptionSanitizer): Record<string, any>;
|
|
25
|
+
/**
|
|
26
|
+
* Converts a Commander-parsed options object into an options object suitable for telemetry.
|
|
27
|
+
* @param options The options object as parsed by Commander.
|
|
28
|
+
* @param sanitizer Function to sanitize the option values for telemetry.
|
|
29
|
+
* @returns An options object suitable for telemetry.
|
|
30
|
+
*/
|
|
31
|
+
export declare function commanderOptionsToOptions(options: CommanderOptionsType, sanitizer?: OptionSanitizer): Record<string, any>;
|
|
32
|
+
/**
|
|
33
|
+
* Checks whether the given command-line args contains the given option key.
|
|
34
|
+
* @param key The option key to look for.
|
|
35
|
+
* @param argv The raw command-line args.
|
|
36
|
+
* @returns Whether the given command-line args contains the given option key.
|
|
37
|
+
*/
|
|
38
|
+
export declare function argsContainsOption(key: string, argv: string[]): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Filters down a given set of options to only include those that were present in the command-line args.
|
|
41
|
+
* @param options The full set of options.
|
|
42
|
+
* @param argv The raw command-line args.
|
|
43
|
+
* @returns The filtered set of options.
|
|
44
|
+
*/
|
|
45
|
+
export declare function optionsToArgs(options: Record<string, any>, argv: string[]): Record<string, any>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.optionsToArgs = exports.argsContainsOption = exports.commanderOptionsToOptions = exports.yargsOptionsToOptions = exports.commanderNameToOptionName = void 0;
|
|
9
|
+
const lodash_1 = require("lodash");
|
|
10
|
+
/**
|
|
11
|
+
* Converts a raw Commander arg name ('--no-bad-dog') into an options property name ('badDog').
|
|
12
|
+
* @param name The raw Commander arg name.
|
|
13
|
+
* @returns The options name.
|
|
14
|
+
*/
|
|
15
|
+
function commanderNameToOptionName(name) {
|
|
16
|
+
if (name.startsWith('--')) {
|
|
17
|
+
name = name.slice('--'.length);
|
|
18
|
+
}
|
|
19
|
+
if (name.startsWith('no-')) {
|
|
20
|
+
name = name.slice('no-'.length);
|
|
21
|
+
}
|
|
22
|
+
if (name.endsWith(' [string]')) {
|
|
23
|
+
name = name.slice(0, name.length - ' [string]'.length);
|
|
24
|
+
}
|
|
25
|
+
if (name.endsWith(' [number]')) {
|
|
26
|
+
name = name.slice(0, name.length - ' [number]'.length);
|
|
27
|
+
}
|
|
28
|
+
return (0, lodash_1.camelCase)(name);
|
|
29
|
+
}
|
|
30
|
+
exports.commanderNameToOptionName = commanderNameToOptionName;
|
|
31
|
+
/**
|
|
32
|
+
* Converts a yargs-parsed options object into an options object suitable for telemetry.
|
|
33
|
+
* @param options The options object as parsed by yargs.
|
|
34
|
+
* @param sanitizer Function to sanitize the option values for telemetry.
|
|
35
|
+
* @returns An options object suitable for telemetry.
|
|
36
|
+
*/
|
|
37
|
+
function yargsOptionsToOptions(options, sanitizer) {
|
|
38
|
+
const result = {};
|
|
39
|
+
for (const key of Object.keys(options)) {
|
|
40
|
+
if (!(key in Object.prototype) &&
|
|
41
|
+
key !== '$0' &&
|
|
42
|
+
key !== '_' &&
|
|
43
|
+
key.includes('-') !== (0, lodash_1.camelCase)(key) in options) {
|
|
44
|
+
result[key] = sanitizer ? sanitizer(key, options[key]) : options[key];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
exports.yargsOptionsToOptions = yargsOptionsToOptions;
|
|
50
|
+
/**
|
|
51
|
+
* Converts a Commander-parsed options object into an options object suitable for telemetry.
|
|
52
|
+
* @param options The options object as parsed by Commander.
|
|
53
|
+
* @param sanitizer Function to sanitize the option values for telemetry.
|
|
54
|
+
* @returns An options object suitable for telemetry.
|
|
55
|
+
*/
|
|
56
|
+
function commanderOptionsToOptions(options, sanitizer) {
|
|
57
|
+
const result = {};
|
|
58
|
+
for (const key of Object.keys(options)) {
|
|
59
|
+
if (!(key in Object.prototype)) {
|
|
60
|
+
result[key] = sanitizer ? sanitizer(key, options[key]) : options[key];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
exports.commanderOptionsToOptions = commanderOptionsToOptions;
|
|
66
|
+
/**
|
|
67
|
+
* Checks whether the given command-line args contains the given option key.
|
|
68
|
+
* @param key The option key to look for.
|
|
69
|
+
* @param argv The raw command-line args.
|
|
70
|
+
* @returns Whether the given command-line args contains the given option key.
|
|
71
|
+
*/
|
|
72
|
+
function argsContainsOption(key, argv) {
|
|
73
|
+
const kebabKey = (0, lodash_1.kebabCase)(key);
|
|
74
|
+
return (argv.includes(`--${key}`) ||
|
|
75
|
+
argv.includes(`--no-${key}`) ||
|
|
76
|
+
argv.includes(`--${kebabKey}`) ||
|
|
77
|
+
argv.includes(`--no-${kebabKey}`));
|
|
78
|
+
}
|
|
79
|
+
exports.argsContainsOption = argsContainsOption;
|
|
80
|
+
/**
|
|
81
|
+
* Filters down a given set of options to only include those that were present in the command-line args.
|
|
82
|
+
* @param options The full set of options.
|
|
83
|
+
* @param argv The raw command-line args.
|
|
84
|
+
* @returns The filtered set of options.
|
|
85
|
+
*/
|
|
86
|
+
function optionsToArgs(options, argv) {
|
|
87
|
+
const result = {};
|
|
88
|
+
for (const key of Object.keys(options)) {
|
|
89
|
+
if (!(key in Object.prototype) && argsContainsOption(key, argv)) {
|
|
90
|
+
result[key] = options[key];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
exports.optionsToArgs = optionsToArgs;
|
|
96
|
+
//# sourceMappingURL=optionUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optionUtils.js","sourceRoot":"","sources":["../../src/utils/optionUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,mCAA4C;AAW5C;;;;GAIG;AACH,SAAgB,yBAAyB,CAAC,IAAY;IACpD,IAAI,IAA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CAAC,CAAC;SAC5B;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAXD,sCAWC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {camelCase, kebabCase} from 'lodash';\n\nexport type OptionSanitizer = (key: string, value: any) => any;\n\nexport type YargsOptionsType = Record<string, any>;\n\nexport interface CommanderOptionsType extends Record<string, any> {\n logging?: boolean;\n telemetry?: boolean;\n}\n\n/**\n * Converts a raw Commander arg name ('--no-bad-dog') into an options property name ('badDog').\n * @param name The raw Commander arg name.\n * @returns The options name.\n */\nexport function commanderNameToOptionName(name: string): string {\n if (name.startsWith('--')) {\n name = name.slice('--'.length);\n }\n if (name.startsWith('no-')) {\n name = name.slice('no-'.length);\n }\n if (name.endsWith(' [string]')) {\n name = name.slice(0, name.length - ' [string]'.length);\n }\n if (name.endsWith(' [number]')) {\n name = name.slice(0, name.length - ' [number]'.length);\n }\n return camelCase(name);\n}\n\n/**\n * Converts a yargs-parsed options object into an options object suitable for telemetry.\n * @param options The options object as parsed by yargs.\n * @param sanitizer Function to sanitize the option values for telemetry.\n * @returns An options object suitable for telemetry.\n */\nexport function yargsOptionsToOptions(\n options: YargsOptionsType,\n sanitizer?: OptionSanitizer,\n): Record<string, any> {\n const result: Record<string, any> = {};\n for (const key of Object.keys(options)) {\n if (\n !(key in Object.prototype) &&\n key !== '$0' &&\n key !== '_' &&\n key.includes('-') !== camelCase(key) in options\n ) {\n result[key] = sanitizer ? sanitizer(key, options[key]) : options[key];\n }\n }\n return result;\n}\n\n/**\n * Converts a Commander-parsed options object into an options object suitable for telemetry.\n * @param options The options object as parsed by Commander.\n * @param sanitizer Function to sanitize the option values for telemetry.\n * @returns An options object suitable for telemetry.\n */\nexport function commanderOptionsToOptions(\n options: CommanderOptionsType,\n sanitizer?: OptionSanitizer,\n): Record<string, any> {\n const result: Record<string, any> = {};\n for (const key of Object.keys(options)) {\n if (!(key in Object.prototype)) {\n result[key] = sanitizer ? sanitizer(key, options[key]) : options[key];\n }\n }\n return result;\n}\n\n/**\n * Checks whether the given command-line args contains the given option key.\n * @param key The option key to look for.\n * @param argv The raw command-line args.\n * @returns Whether the given command-line args contains the given option key.\n */\nexport function argsContainsOption(key: string, argv: string[]): boolean {\n const kebabKey = kebabCase(key);\n return (\n argv.includes(`--${key}`) ||\n argv.includes(`--no-${key}`) ||\n argv.includes(`--${kebabKey}`) ||\n argv.includes(`--no-${kebabKey}`)\n );\n}\n\n/**\n * Filters down a given set of options to only include those that were present in the command-line args.\n * @param options The full set of options.\n * @param argv The raw command-line args.\n * @returns The filtered set of options.\n */\nexport function optionsToArgs(\n options: Record<string, any>,\n argv: string[],\n): Record<string, any> {\n const result: Record<string, any> = {};\n for (const key of Object.keys(options)) {\n if (!(key in Object.prototype) && argsContainsOption(key, argv)) {\n result[key] = options[key];\n }\n }\n return result;\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
* @format
|
|
5
|
+
*/
|
|
6
|
+
interface ProjectInfo {
|
|
7
|
+
id: string | null;
|
|
8
|
+
platforms: Array<string>;
|
|
9
|
+
rnwLang: 'cpp' | 'cs' | 'cpp+cs' | null;
|
|
10
|
+
}
|
|
11
|
+
export interface DependencyProjectInfo extends ProjectInfo {
|
|
12
|
+
}
|
|
13
|
+
export interface AppProjectInfo extends ProjectInfo {
|
|
14
|
+
usesTS: boolean;
|
|
15
|
+
usesRNConfig: boolean;
|
|
16
|
+
jsEngine: string;
|
|
17
|
+
rnwSource: string;
|
|
18
|
+
dependencies: Array<DependencyProjectInfo>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Gets a unique, telemetry-safe project ID based on the project name.
|
|
22
|
+
* @param projectName The project name.
|
|
23
|
+
* @returns The telemetry-safe project ID.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getProjectId(projectName: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Gets whether the project at the given path has a react-native.config.js file.
|
|
28
|
+
* @param projectRoot The project root path to look in.
|
|
29
|
+
* @returns Whether the project at the given path has a react-native.config.js file.
|
|
30
|
+
*/
|
|
31
|
+
export declare function usesReactNativeConfig(projectRoot: string): Promise<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* Gets whether the project at the given path is using TypeScript.
|
|
34
|
+
* @param projectRoot The project root path to look in.
|
|
35
|
+
* @returns Whether the project at the given path is using TypeScript.
|
|
36
|
+
*/
|
|
37
|
+
export declare function usesTypeScript(projectRoot: string): Promise<boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* Calculate the project telemetry info from a react-native CLI config.
|
|
40
|
+
* @param config Config passed from react-native CLI.
|
|
41
|
+
* @returns The calculated project info.
|
|
42
|
+
*/
|
|
43
|
+
export declare function configToProjectInfo(config: Record<string, any>): Promise<AppProjectInfo | DependencyProjectInfo | null>;
|
|
44
|
+
/**
|
|
45
|
+
* Gets the full path to the app's native project file from a react-native CLI config.
|
|
46
|
+
* @param config Config passed from react-native CLI.
|
|
47
|
+
* @returns The full path to the app's native project file
|
|
48
|
+
*/
|
|
49
|
+
export declare function getProjectFileFromConfig(config: Record<string, any>): string | null;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,187 @@
|
|
|
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.getProjectFileFromConfig = exports.configToProjectInfo = exports.usesTypeScript = exports.usesReactNativeConfig = exports.getProjectId = void 0;
|
|
12
|
+
const crypto_1 = require("crypto");
|
|
13
|
+
const fs_1 = __importDefault(require("@react-native-windows/fs"));
|
|
14
|
+
const path_1 = __importDefault(require("path"));
|
|
15
|
+
/**
|
|
16
|
+
* Gets a unique, telemetry-safe project ID based on the project name.
|
|
17
|
+
* @param projectName The project name.
|
|
18
|
+
* @returns The telemetry-safe project ID.
|
|
19
|
+
*/
|
|
20
|
+
function getProjectId(projectName) {
|
|
21
|
+
const hash = (0, crypto_1.createHash)('sha256');
|
|
22
|
+
hash.update(projectName);
|
|
23
|
+
return hash.digest('hex');
|
|
24
|
+
}
|
|
25
|
+
exports.getProjectId = getProjectId;
|
|
26
|
+
/**
|
|
27
|
+
* Checks that a given file exits in the path specified.
|
|
28
|
+
* @param fileName The file to check for.
|
|
29
|
+
* @param projectRoot The root path to look in.
|
|
30
|
+
* @returns Whether the file exists.
|
|
31
|
+
*/
|
|
32
|
+
async function fileExists(fileName, projectRoot) {
|
|
33
|
+
try {
|
|
34
|
+
const reactNativeConfigPath = path_1.default.resolve(projectRoot, fileName);
|
|
35
|
+
const stats = await fs_1.default.stat(reactNativeConfigPath);
|
|
36
|
+
return stats.isFile();
|
|
37
|
+
}
|
|
38
|
+
catch (_a) { }
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Gets whether the project at the given path has a react-native.config.js file.
|
|
43
|
+
* @param projectRoot The project root path to look in.
|
|
44
|
+
* @returns Whether the project at the given path has a react-native.config.js file.
|
|
45
|
+
*/
|
|
46
|
+
async function usesReactNativeConfig(projectRoot) {
|
|
47
|
+
return fileExists('./react-native.config.js', projectRoot);
|
|
48
|
+
}
|
|
49
|
+
exports.usesReactNativeConfig = usesReactNativeConfig;
|
|
50
|
+
/**
|
|
51
|
+
* Gets whether the project at the given path is using TypeScript.
|
|
52
|
+
* @param projectRoot The project root path to look in.
|
|
53
|
+
* @returns Whether the project at the given path is using TypeScript.
|
|
54
|
+
*/
|
|
55
|
+
async function usesTypeScript(projectRoot) {
|
|
56
|
+
return fileExists('./tsconfig.json', projectRoot);
|
|
57
|
+
}
|
|
58
|
+
exports.usesTypeScript = usesTypeScript;
|
|
59
|
+
/**
|
|
60
|
+
* Get the list of keys in the object for which the value is defined.
|
|
61
|
+
* @param obj The object to search.
|
|
62
|
+
* @returns The list of keys.
|
|
63
|
+
*/
|
|
64
|
+
function getDefinedKeys(obj) {
|
|
65
|
+
return Object.keys(obj).filter(value => obj[value] !== undefined && obj[value] !== null && value);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Given a react-native CLI config, determine the language of the RNW dependency if possible.
|
|
69
|
+
* @param config Dependency config passed from react-native CLI.
|
|
70
|
+
* @returns The language of the RNW dependency.
|
|
71
|
+
*/
|
|
72
|
+
function getDependencyRnwLang(config) {
|
|
73
|
+
if (config) {
|
|
74
|
+
let cppCount = 0;
|
|
75
|
+
let csCount = 0;
|
|
76
|
+
for (const project of config.projects) {
|
|
77
|
+
switch (project.projectLang) {
|
|
78
|
+
case 'cpp':
|
|
79
|
+
cppCount++;
|
|
80
|
+
break;
|
|
81
|
+
case 'cs':
|
|
82
|
+
csCount++;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (cppCount > 0 && csCount > 0) {
|
|
87
|
+
return 'cpp+cs';
|
|
88
|
+
}
|
|
89
|
+
else if (cppCount > 0) {
|
|
90
|
+
return 'cpp';
|
|
91
|
+
}
|
|
92
|
+
else if (csCount > 0) {
|
|
93
|
+
return 'cs';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Returns true if the item is a boolean with a value of true or a string with a value of 'true'.
|
|
100
|
+
* @param item The item to parse.
|
|
101
|
+
* @returns The boolean value.
|
|
102
|
+
*/
|
|
103
|
+
function parseBoolean(item) {
|
|
104
|
+
if (typeof item === 'boolean') {
|
|
105
|
+
return item;
|
|
106
|
+
}
|
|
107
|
+
else if (typeof item === 'string') {
|
|
108
|
+
return item.toLowerCase() === 'true';
|
|
109
|
+
}
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Calculate the project telemetry info from a react-native CLI config.
|
|
114
|
+
* @param config Config passed from react-native CLI.
|
|
115
|
+
* @returns The calculated project info.
|
|
116
|
+
*/
|
|
117
|
+
async function configToProjectInfo(config) {
|
|
118
|
+
var _a, _b, _c;
|
|
119
|
+
try {
|
|
120
|
+
const id = getProjectId(require(path_1.default.join(config.root, 'package.json')).name);
|
|
121
|
+
const platforms = getDefinedKeys(config.project);
|
|
122
|
+
if ('windows' in config.project && config.project.windows !== null) {
|
|
123
|
+
const rnwLang = (_a = config.project.windows.project) === null || _a === void 0 ? void 0 : _a.projectLang;
|
|
124
|
+
const usesTS = await usesTypeScript(config.project.windows.folder);
|
|
125
|
+
const usesRNConfig = await usesReactNativeConfig(config.project.windows.folder);
|
|
126
|
+
const jsEngine = parseBoolean((_b = config.project.windows.experimentalFeatures) === null || _b === void 0 ? void 0 : _b.UseHermes)
|
|
127
|
+
? 'Hermes'
|
|
128
|
+
: 'Chakra';
|
|
129
|
+
const rnwSource = parseBoolean((_c = config.project.windows.experimentalFeatures) === null || _c === void 0 ? void 0 : _c.UseExperimentalNuget)
|
|
130
|
+
? 'NuGet'
|
|
131
|
+
: 'Source';
|
|
132
|
+
const dependencies = [];
|
|
133
|
+
for (const dependencyName in config.dependencies) {
|
|
134
|
+
if (!Object.prototype.hasOwnProperty(dependencyName)) {
|
|
135
|
+
const dependencyId = getProjectId(dependencyName);
|
|
136
|
+
const dependencyPlatforms = getDefinedKeys(config.dependencies[dependencyName].platforms);
|
|
137
|
+
if (dependencyPlatforms.length > 0) {
|
|
138
|
+
const dependencyRnwLang = getDependencyRnwLang(config.dependencies[dependencyName].platforms.windows);
|
|
139
|
+
const dependencyInfo = {
|
|
140
|
+
id: dependencyId,
|
|
141
|
+
platforms: dependencyPlatforms,
|
|
142
|
+
rnwLang: dependencyRnwLang,
|
|
143
|
+
};
|
|
144
|
+
dependencies.push(dependencyInfo);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const appInfo = {
|
|
149
|
+
id,
|
|
150
|
+
platforms,
|
|
151
|
+
rnwLang,
|
|
152
|
+
usesTS,
|
|
153
|
+
usesRNConfig,
|
|
154
|
+
jsEngine,
|
|
155
|
+
rnwSource,
|
|
156
|
+
dependencies,
|
|
157
|
+
};
|
|
158
|
+
return appInfo;
|
|
159
|
+
}
|
|
160
|
+
// Probably just a dependency project, return minimal info
|
|
161
|
+
const dependencyInfo = {
|
|
162
|
+
id,
|
|
163
|
+
platforms,
|
|
164
|
+
rnwLang: null,
|
|
165
|
+
};
|
|
166
|
+
return dependencyInfo;
|
|
167
|
+
}
|
|
168
|
+
catch (_d) { }
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
exports.configToProjectInfo = configToProjectInfo;
|
|
172
|
+
/**
|
|
173
|
+
* Gets the full path to the app's native project file from a react-native CLI config.
|
|
174
|
+
* @param config Config passed from react-native CLI.
|
|
175
|
+
* @returns The full path to the app's native project file
|
|
176
|
+
*/
|
|
177
|
+
function getProjectFileFromConfig(config) {
|
|
178
|
+
try {
|
|
179
|
+
if ('windows' in config.project && config.project.windows !== null) {
|
|
180
|
+
return path_1.default.join(config.project.windows.folder, config.project.windows.sourceDir, config.project.windows.project.projectFile);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
catch (_a) { }
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
exports.getProjectFileFromConfig = getProjectFileFromConfig;
|
|
187
|
+
//# sourceMappingURL=projectUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projectUtils.js","sourceRoot":"","sources":["../../src/utils/projectUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,mCAAkC;AAClC,kEAA0C;AAC1C,gDAAwB;AAkBxB;;;;GAIG;AACH,SAAgB,YAAY,CAAC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BACR,SAAS;gBACT,YAAY;aACb,CAAC;YAEF,OAAO,OAAO,CAAC;SAChB;QAED,0DAA0D;QAC1D,MAAM,cAAc,GAA0B;YAC5C,EAAE;YACF,SAAS;YACT,OAAO,EAAE,IAAI;SACd,CAAC;QACF,OAAO,cAAc,CAAC;KACvB;IAAC,WAAM,GAAE;IACV,OAAO,IAAI,CAAC;AACd,CAAC;AAvED,kDAuEC;AAED;;;;GAIG;AACH,SAAgB,wBAAwB,CACtC,MAA2B;IAE3B,IAAI;QACF,IAAI,SAAS,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,KAAK,IAAI,EAAE;YAClE,OAAO,cAAI,CAAC,IAAI,CACd,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAC7B,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,EAChC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAC3C,CAAC;SACH;KACF;IAAC,WAAM,GAAE;IACV,OAAO,IAAI,CAAC;AACd,CAAC;AAbD,4DAaC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {createHash} from 'crypto';\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\n\ninterface ProjectInfo {\n id: string | null;\n platforms: Array<string>;\n rnwLang: 'cpp' | 'cs' | 'cpp+cs' | null;\n}\n\nexport interface DependencyProjectInfo extends ProjectInfo {}\n\nexport interface AppProjectInfo extends ProjectInfo {\n usesTS: boolean;\n usesRNConfig: boolean;\n jsEngine: string;\n rnwSource: string;\n dependencies: Array<DependencyProjectInfo>;\n}\n\n/**\n * Gets a unique, telemetry-safe project ID based on the project name.\n * @param projectName The project name.\n * @returns The telemetry-safe project ID.\n */\nexport function getProjectId(projectName: string): string {\n const hash = createHash('sha256');\n hash.update(projectName);\n return hash.digest('hex');\n}\n\n/**\n * Checks that a given file exits in the path specified.\n * @param fileName The file to check for.\n * @param projectRoot The root path to look in.\n * @returns Whether the file exists.\n */\nasync function fileExists(\n fileName: string,\n projectRoot: string,\n): Promise<boolean> {\n try {\n const reactNativeConfigPath = path.resolve(projectRoot, fileName);\n const stats = await fs.stat(reactNativeConfigPath);\n return stats.isFile();\n } catch {}\n return false;\n}\n\n/**\n * Gets whether the project at the given path has a react-native.config.js file.\n * @param projectRoot The project root path to look in.\n * @returns Whether the project at the given path has a react-native.config.js file.\n */\nexport async function usesReactNativeConfig(\n projectRoot: string,\n): Promise<boolean> {\n return fileExists('./react-native.config.js', projectRoot);\n}\n\n/**\n * Gets whether the project at the given path is using TypeScript.\n * @param projectRoot The project root path to look in.\n * @returns Whether the project at the given path is using TypeScript.\n */\nexport async function usesTypeScript(projectRoot: string): Promise<boolean> {\n return fileExists('./tsconfig.json', projectRoot);\n}\n\n/**\n * Get the list of keys in the object for which the value is defined.\n * @param obj The object to search.\n * @returns The list of keys.\n */\nfunction getDefinedKeys(obj: Record<string, any>): string[] {\n return Object.keys(obj).filter(\n value => obj[value] !== undefined && obj[value] !== null && value,\n );\n}\n\n/**\n * Given a react-native CLI config, determine the language of the RNW dependency if possible.\n * @param config Dependency config passed from react-native CLI.\n * @returns The language of the RNW dependency.\n */\nfunction getDependencyRnwLang(\n config: Record<string, any> | null | undefined,\n): 'cpp' | 'cs' | 'cpp+cs' | null {\n if (config) {\n let cppCount = 0;\n let csCount = 0;\n for (const project of config.projects) {\n switch (project.projectLang) {\n case 'cpp':\n cppCount++;\n break;\n case 'cs':\n csCount++;\n break;\n }\n }\n if (cppCount > 0 && csCount > 0) {\n return 'cpp+cs';\n } else if (cppCount > 0) {\n return 'cpp';\n } else if (csCount > 0) {\n return 'cs';\n }\n }\n return null;\n}\n\n/**\n * Returns true if the item is a boolean with a value of true or a string with a value of 'true'.\n * @param item The item to parse.\n * @returns The boolean value.\n */\nfunction parseBoolean(item: any): boolean {\n if (typeof item === 'boolean') {\n return item;\n } else if (typeof item === 'string') {\n return item.toLowerCase() === 'true';\n }\n return false;\n}\n\n/**\n * Calculate the project telemetry info from a react-native CLI config.\n * @param config Config passed from react-native CLI.\n * @returns The calculated project info.\n */\nexport async function configToProjectInfo(\n config: Record<string, any>,\n): Promise<AppProjectInfo | DependencyProjectInfo | null> {\n try {\n const id: string = getProjectId(\n require(path.join(config.root, 'package.json')).name,\n );\n const platforms = getDefinedKeys(config.project);\n\n if ('windows' in config.project && config.project.windows !== null) {\n const rnwLang = config.project.windows.project?.projectLang;\n const usesTS = await usesTypeScript(config.project.windows.folder);\n const usesRNConfig = await usesReactNativeConfig(\n config.project.windows.folder,\n );\n const jsEngine = parseBoolean(\n config.project.windows.experimentalFeatures?.UseHermes,\n )\n ? 'Hermes'\n : 'Chakra';\n const rnwSource = parseBoolean(\n config.project.windows.experimentalFeatures?.UseExperimentalNuget,\n )\n ? 'NuGet'\n : 'Source';\n\n const dependencies: DependencyProjectInfo[] = [];\n for (const dependencyName in config.dependencies) {\n if (!Object.prototype.hasOwnProperty(dependencyName)) {\n const dependencyId = getProjectId(dependencyName);\n const dependencyPlatforms = getDefinedKeys(\n config.dependencies[dependencyName].platforms,\n );\n\n if (dependencyPlatforms.length > 0) {\n const dependencyRnwLang = getDependencyRnwLang(\n config.dependencies[dependencyName].platforms.windows,\n );\n const dependencyInfo: DependencyProjectInfo = {\n id: dependencyId,\n platforms: dependencyPlatforms,\n rnwLang: dependencyRnwLang,\n };\n dependencies.push(dependencyInfo);\n }\n }\n }\n\n const appInfo: AppProjectInfo = {\n id,\n platforms,\n rnwLang,\n usesTS,\n usesRNConfig,\n jsEngine,\n rnwSource,\n dependencies,\n };\n\n return appInfo;\n }\n\n // Probably just a dependency project, return minimal info\n const dependencyInfo: DependencyProjectInfo = {\n id,\n platforms,\n rnwLang: null,\n };\n return dependencyInfo;\n } catch {}\n return null;\n}\n\n/**\n * Gets the full path to the app's native project file from a react-native CLI config.\n * @param config Config passed from react-native CLI.\n * @returns The full path to the app's native project file\n */\nexport function getProjectFileFromConfig(\n config: Record<string, any>,\n): string | null {\n try {\n if ('windows' in config.project && config.project.windows !== null) {\n return path.join(\n config.project.windows.folder,\n config.project.windows.sourceDir,\n config.project.windows.project.projectFile,\n );\n }\n } catch {}\n return null;\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
* @format
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Gets an anonymized version of the given path, suitable for Telemetry.
|
|
8
|
+
* @param filepath The path to anonymize.
|
|
9
|
+
* @param projectRoot Optional root path for the project. Defaults to process.cwd().
|
|
10
|
+
* @returns The anonymized path.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getAnonymizedPath(filepath: string, projectRoot?: string): string;
|