@react-native-windows/cli 0.73.2 → 0.74.0-preview.2
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/commands/autolinkWindows/autolinkWindows.d.ts +87 -87
- package/lib-commonjs/commands/autolinkWindows/autolinkWindows.js +654 -654
- package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.d.ts +14 -14
- package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.js +32 -32
- package/lib-commonjs/commands/codegenWindows/codegenWindows.d.ts +27 -27
- package/lib-commonjs/commands/codegenWindows/codegenWindows.js +205 -205
- package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.d.ts +12 -12
- package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.js +22 -22
- package/lib-commonjs/commands/config/configUtils.d.ts +123 -123
- package/lib-commonjs/commands/config/configUtils.js +380 -380
- package/lib-commonjs/commands/config/dependencyConfig.d.ts +37 -37
- package/lib-commonjs/commands/config/dependencyConfig.js +227 -227
- package/lib-commonjs/commands/config/projectConfig.d.ts +27 -27
- package/lib-commonjs/commands/config/projectConfig.js +180 -180
- package/lib-commonjs/commands/healthCheck/healthCheckList.d.ts +6 -6
- package/lib-commonjs/commands/healthCheck/healthCheckList.js +20 -20
- package/lib-commonjs/commands/healthCheck/healthCheckList.js.map +1 -1
- package/lib-commonjs/commands/healthCheck/healthChecks.d.ts +7 -7
- package/lib-commonjs/commands/healthCheck/healthChecks.js +123 -123
- package/lib-commonjs/commands/initWindows/initWindows.d.ts +46 -46
- package/lib-commonjs/commands/initWindows/initWindows.js +243 -243
- package/lib-commonjs/commands/initWindows/initWindowsOptions.d.ts +15 -15
- package/lib-commonjs/commands/initWindows/initWindowsOptions.js +37 -37
- package/lib-commonjs/commands/runWindows/runWindows.d.ts +10 -10
- package/lib-commonjs/commands/runWindows/runWindows.js +321 -321
- package/lib-commonjs/commands/runWindows/runWindowsOptions.d.ts +56 -56
- package/lib-commonjs/commands/runWindows/runWindowsOptions.js +132 -132
- package/lib-commonjs/e2etest/autolink.test.d.ts +6 -6
- package/lib-commonjs/e2etest/autolink.test.js +366 -366
- package/lib-commonjs/e2etest/dependencyConfig.test.d.ts +6 -6
- package/lib-commonjs/e2etest/dependencyConfig.test.js +129 -129
- package/lib-commonjs/e2etest/healthChecks.test.d.ts +6 -6
- package/lib-commonjs/e2etest/healthChecks.test.js +30 -30
- package/lib-commonjs/e2etest/initWindows.test.d.ts +6 -6
- package/lib-commonjs/e2etest/initWindows.test.js +42 -42
- package/lib-commonjs/e2etest/projectConfig.test.d.ts +6 -6
- package/lib-commonjs/e2etest/projectConfig.test.js +110 -110
- package/lib-commonjs/e2etest/projectConfig.utils.d.ts +8 -8
- package/lib-commonjs/e2etest/projectConfig.utils.js +76 -76
- package/lib-commonjs/e2etest/runWindows.test.d.ts +6 -6
- package/lib-commonjs/e2etest/runWindows.test.js +60 -60
- package/lib-commonjs/e2etest/typesUpToDate.test.d.ts +6 -0
- package/lib-commonjs/e2etest/typesUpToDate.test.js +21 -0
- package/lib-commonjs/e2etest/typesUpToDate.test.js.map +1 -0
- package/lib-commonjs/generator-common/index.d.ts +39 -39
- package/lib-commonjs/generator-common/index.js +242 -242
- package/lib-commonjs/generator-windows/index.d.ts +10 -10
- package/lib-commonjs/generator-windows/index.js +316 -316
- package/lib-commonjs/index.d.ts +50 -50
- package/lib-commonjs/index.js +77 -77
- package/lib-commonjs/utils/build.d.ts +12 -12
- package/lib-commonjs/utils/build.js +84 -84
- package/lib-commonjs/utils/checkRequirements.d.ts +6 -6
- package/lib-commonjs/utils/checkRequirements.js +69 -69
- package/lib-commonjs/utils/commandWithProgress.d.ts +21 -21
- package/lib-commonjs/utils/commandWithProgress.js +149 -149
- package/lib-commonjs/utils/deploy.d.ts +12 -12
- package/lib-commonjs/utils/deploy.js +353 -353
- package/lib-commonjs/utils/info.d.ts +6 -6
- package/lib-commonjs/utils/info.js +28 -28
- package/lib-commonjs/utils/msbuildtools.d.ts +28 -28
- package/lib-commonjs/utils/msbuildtools.js +273 -273
- package/lib-commonjs/utils/msbuildtools.js.map +1 -1
- package/lib-commonjs/utils/pathHelpers.d.ts +9 -9
- package/lib-commonjs/utils/pathHelpers.js +36 -36
- package/lib-commonjs/utils/telemetryHelpers.d.ts +29 -29
- package/lib-commonjs/utils/telemetryHelpers.js +120 -120
- package/lib-commonjs/utils/version.d.ts +19 -19
- package/lib-commonjs/utils/version.js +109 -109
- package/lib-commonjs/utils/vsInstalls.d.ts +34 -34
- package/lib-commonjs/utils/vsInstalls.js +99 -99
- package/lib-commonjs/utils/vstools.d.ts +16 -16
- package/lib-commonjs/utils/vstools.js +189 -189
- package/lib-commonjs/utils/winappdeploytool.d.ts +24 -24
- package/lib-commonjs/utils/winappdeploytool.js +108 -108
- package/package.json +16 -16
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
* @format
|
|
5
|
-
*/
|
|
6
|
-
import { CommandOption } from '@react-native-community/cli-types';
|
|
7
|
-
export interface AutoLinkOptions {
|
|
8
|
-
logging?: boolean;
|
|
9
|
-
check?: boolean;
|
|
10
|
-
sln?: string;
|
|
11
|
-
proj?: string;
|
|
12
|
-
telemetry?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export declare const autolinkOptions: CommandOption[];
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
* @format
|
|
5
|
+
*/
|
|
6
|
+
import { CommandOption } from '@react-native-community/cli-types';
|
|
7
|
+
export interface AutoLinkOptions {
|
|
8
|
+
logging?: boolean;
|
|
9
|
+
check?: boolean;
|
|
10
|
+
sln?: string;
|
|
11
|
+
proj?: string;
|
|
12
|
+
telemetry?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const autolinkOptions: CommandOption[];
|
|
@@ -1,33 +1,33 @@
|
|
|
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.autolinkOptions = void 0;
|
|
9
|
-
exports.autolinkOptions = [
|
|
10
|
-
{
|
|
11
|
-
name: '--logging',
|
|
12
|
-
description: 'Verbose output logging',
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
name: '--check',
|
|
16
|
-
description: 'Only check whether any autolinked files need to change',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
name: '--sln [string]',
|
|
20
|
-
description: "Override the app solution file determined by 'react-native config', e.g. windows\\myApp.sln",
|
|
21
|
-
default: undefined,
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
name: '--proj [string]',
|
|
25
|
-
description: "Override the app project file determined by 'react-native config', e.g. windows\\myApp\\myApp.vcxproj",
|
|
26
|
-
default: undefined,
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
name: '--no-telemetry',
|
|
30
|
-
description: 'Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI',
|
|
31
|
-
},
|
|
32
|
-
];
|
|
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.autolinkOptions = void 0;
|
|
9
|
+
exports.autolinkOptions = [
|
|
10
|
+
{
|
|
11
|
+
name: '--logging',
|
|
12
|
+
description: 'Verbose output logging',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: '--check',
|
|
16
|
+
description: 'Only check whether any autolinked files need to change',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: '--sln [string]',
|
|
20
|
+
description: "Override the app solution file determined by 'react-native config', e.g. windows\\myApp.sln",
|
|
21
|
+
default: undefined,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: '--proj [string]',
|
|
25
|
+
description: "Override the app project file determined by 'react-native config', e.g. windows\\myApp\\myApp.vcxproj",
|
|
26
|
+
default: undefined,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: '--no-telemetry',
|
|
30
|
+
description: 'Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI',
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
33
|
//# sourceMappingURL=autolinkWindowsOptions.js.map
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
* @format
|
|
5
|
-
*/
|
|
6
|
-
import { Ora } from 'ora';
|
|
7
|
-
import { Command, Config } from '@react-native-community/cli-types';
|
|
8
|
-
import { CodeGenOptions } from './codegenWindowsOptions';
|
|
9
|
-
export declare class CodeGenWindows {
|
|
10
|
-
readonly root: string;
|
|
11
|
-
readonly options: CodeGenOptions;
|
|
12
|
-
private changesNecessary;
|
|
13
|
-
areChangesNeeded(): boolean;
|
|
14
|
-
constructor(root: string, options: CodeGenOptions);
|
|
15
|
-
run(spinner: Ora): Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Performs codegen for RNW native modules and apps.
|
|
19
|
-
* @param args Unprocessed args passed from react-native CLI.
|
|
20
|
-
* @param config Config passed from react-native CLI.
|
|
21
|
-
* @param options Options passed from react-native CLI.
|
|
22
|
-
*/
|
|
23
|
-
export declare function codegenWindowsInternal(args: string[], config: Config, options: CodeGenOptions): Promise<void>;
|
|
24
|
-
/**
|
|
25
|
-
* Performs codegen for RNW native modules.
|
|
26
|
-
*/
|
|
27
|
-
export declare const codegenCommand: Command;
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
* @format
|
|
5
|
+
*/
|
|
6
|
+
import { Ora } from 'ora';
|
|
7
|
+
import { Command, Config } from '@react-native-community/cli-types';
|
|
8
|
+
import { CodeGenOptions } from './codegenWindowsOptions';
|
|
9
|
+
export declare class CodeGenWindows {
|
|
10
|
+
readonly root: string;
|
|
11
|
+
readonly options: CodeGenOptions;
|
|
12
|
+
private changesNecessary;
|
|
13
|
+
areChangesNeeded(): boolean;
|
|
14
|
+
constructor(root: string, options: CodeGenOptions);
|
|
15
|
+
run(spinner: Ora): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Performs codegen for RNW native modules and apps.
|
|
19
|
+
* @param args Unprocessed args passed from react-native CLI.
|
|
20
|
+
* @param config Config passed from react-native CLI.
|
|
21
|
+
* @param options Options passed from react-native CLI.
|
|
22
|
+
*/
|
|
23
|
+
export declare function codegenWindowsInternal(args: string[], config: Config, options: CodeGenOptions): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Performs codegen for RNW native modules.
|
|
26
|
+
*/
|
|
27
|
+
export declare const codegenCommand: Command;
|
|
@@ -1,206 +1,206 @@
|
|
|
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.codegenCommand = exports.codegenWindowsInternal = exports.CodeGenWindows = void 0;
|
|
12
|
-
const path_1 = __importDefault(require("path"));
|
|
13
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
14
|
-
const perf_hooks_1 = require("perf_hooks");
|
|
15
|
-
const telemetry_1 = require("@react-native-windows/telemetry");
|
|
16
|
-
const codegen_1 = require("@react-native-windows/codegen");
|
|
17
|
-
const commandWithProgress_1 = require("../../utils/commandWithProgress");
|
|
18
|
-
const telemetryHelpers_1 = require("../../utils/telemetryHelpers");
|
|
19
|
-
const codegenWindowsOptions_1 = require("./codegenWindowsOptions");
|
|
20
|
-
class CodeGenWindows {
|
|
21
|
-
areChangesNeeded() {
|
|
22
|
-
return this.changesNecessary;
|
|
23
|
-
}
|
|
24
|
-
constructor(root, options) {
|
|
25
|
-
this.root = root;
|
|
26
|
-
this.options = options;
|
|
27
|
-
this.changesNecessary = false;
|
|
28
|
-
}
|
|
29
|
-
async run(spinner) {
|
|
30
|
-
var _a, _b;
|
|
31
|
-
const verbose = this.options.logging;
|
|
32
|
-
verboseMessage('', verbose);
|
|
33
|
-
verboseMessage('Loading codegenConfig from package.json');
|
|
34
|
-
const pkgJson = require(path_1.default.join(this.root, 'package.json'));
|
|
35
|
-
if (!pkgJson.codegenConfig) {
|
|
36
|
-
spinner.info(`No ${chalk_1.default.bold('codegenConfig')} specified in package.json - ${chalk_1.default.yellow('Skipping codegen-windows')}`);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const codegenConfigType = pkgJson.codegenConfig.type;
|
|
40
|
-
if (codegenConfigType !== 'modules' && codegenConfigType !== 'all') {
|
|
41
|
-
spinner.info(`${chalk_1.default.bold('codegenConfig.type')} in package.json is not ${chalk_1.default.bold('modules')} or ${chalk_1.default.bold('all')} - ${chalk_1.default.yellow('Skipping codegen-windows')}`);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
if (!pkgJson.codegenConfig.windows) {
|
|
45
|
-
spinner.info(`No ${chalk_1.default.bold('codegenConfig.windows')} specified in package.json - ${chalk_1.default.yellow('Skipping codegen-windows')}`);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (!pkgJson.codegenConfig.windows.namespace) {
|
|
49
|
-
throw new telemetry_1.CodedError('InvalidCodegenConfig', `Missing ${chalk_1.default.bold('codegenConfig.windows.namespace')} value in package.json`);
|
|
50
|
-
}
|
|
51
|
-
let cppStringType = 'std::string';
|
|
52
|
-
if (pkgJson.codegenConfig.windows.cppStringType) {
|
|
53
|
-
switch (pkgJson.codegenConfig.windows.cppStringType) {
|
|
54
|
-
case 'std::string':
|
|
55
|
-
case 'std::wstring':
|
|
56
|
-
cppStringType = pkgJson.codegenConfig.windows.cppStringType;
|
|
57
|
-
break;
|
|
58
|
-
default:
|
|
59
|
-
throw new telemetry_1.CodedError('InvalidCodegenConfig', `Value of ${chalk_1.default.bold('codegenConfig.windows.cppStringType')} in package.json should be either 'std::string' or 'std::wstring'`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
let separateDataTypes = false;
|
|
63
|
-
if (pkgJson.codegenConfig.windows.separateDataTypes !== undefined) {
|
|
64
|
-
switch (pkgJson.codegenConfig.windows.separateDataTypes) {
|
|
65
|
-
case true:
|
|
66
|
-
case false:
|
|
67
|
-
separateDataTypes = pkgJson.codegenConfig.windows.separateDataTypes;
|
|
68
|
-
break;
|
|
69
|
-
default:
|
|
70
|
-
throw new telemetry_1.CodedError('InvalidCodegenConfig', `Value of ${chalk_1.default.bold('codegenConfig.windows.separateDataTypes')} in package.json should be either true or false`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if (!pkgJson.codegenConfig.name) {
|
|
74
|
-
throw new telemetry_1.CodedError('InvalidCodegenConfig', `Missing ${chalk_1.default.bold('codegenConfig.name')} value in package.json`);
|
|
75
|
-
}
|
|
76
|
-
const projectName = pkgJson.codegenConfig.name.replace(/[^a-zA-Z]/g, '');
|
|
77
|
-
const projectNamespace = pkgJson.codegenConfig.windows.namespace;
|
|
78
|
-
const jsRootDir = pkgJson.codegenConfig.jsSrcsDir
|
|
79
|
-
? path_1.default.join(this.root, pkgJson.codegenConfig.jsSrcsDir)
|
|
80
|
-
: this.root;
|
|
81
|
-
const codegenOutputDir = (_a = pkgJson.codegenConfig.windows.outputDirectory) !== null && _a !== void 0 ? _a : 'codegen';
|
|
82
|
-
const generators = (_b = pkgJson.codegenConfig.windows.generators) !== null && _b !== void 0 ? _b : [
|
|
83
|
-
'modulesWindows',
|
|
84
|
-
];
|
|
85
|
-
const jsRootPathRelative = path_1.default.relative(process.cwd(), jsRootDir);
|
|
86
|
-
const options = {
|
|
87
|
-
files: [
|
|
88
|
-
`${jsRootPathRelative}${jsRootPathRelative ? '/' : ''}**/*Native*.[jt]s`,
|
|
89
|
-
],
|
|
90
|
-
cppStringType,
|
|
91
|
-
separateDataTypes,
|
|
92
|
-
libraryName: projectName,
|
|
93
|
-
methodOnly: false,
|
|
94
|
-
modulesCxx: generators.indexOf('modulesCxx') !== -1,
|
|
95
|
-
modulesTypeScriptTypes: generators.indexOf('modulesTypeScriptTypes') !== -1,
|
|
96
|
-
modulesWindows: generators.indexOf('modulesWindows') !== -1,
|
|
97
|
-
namespace: projectNamespace,
|
|
98
|
-
outputDirectory: path_1.default.join(this.root, codegenOutputDir),
|
|
99
|
-
test: !!this.options.check,
|
|
100
|
-
};
|
|
101
|
-
verboseMessage(`Run codegen with options: \n${JSON.stringify(options, null, 2)}`, verbose);
|
|
102
|
-
this.changesNecessary = (0, codegen_1.runCodeGen)(options);
|
|
103
|
-
spinner.succeed();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
exports.CodeGenWindows = CodeGenWindows;
|
|
107
|
-
/**
|
|
108
|
-
* Logs the given message if verbose is True.
|
|
109
|
-
* @param message The message to log.
|
|
110
|
-
* @param verbose Whether or not verbose logging is enabled.
|
|
111
|
-
*/
|
|
112
|
-
function verboseMessage(message, verbose) {
|
|
113
|
-
if (verbose) {
|
|
114
|
-
console.log(message);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Sanitizes the given option for telemetry.
|
|
119
|
-
* @param key The key of the option.
|
|
120
|
-
* @param value The unsanitized value of the option.
|
|
121
|
-
* @returns The sanitized value of the option.
|
|
122
|
-
*/
|
|
123
|
-
function optionSanitizer(key, value) {
|
|
124
|
-
// Do not add a default case here.
|
|
125
|
-
// Strings risking PII should just return true if present, false otherwise.
|
|
126
|
-
// All others should return the value (or false if undefined).
|
|
127
|
-
switch (key) {
|
|
128
|
-
case 'logging':
|
|
129
|
-
case 'check':
|
|
130
|
-
case 'telemetry':
|
|
131
|
-
return value === undefined ? false : value; // Return value
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Get the extra props to add to the `codegen-windows` telemetry event.
|
|
136
|
-
* @returns The extra props.
|
|
137
|
-
*/
|
|
138
|
-
async function getExtraProps() {
|
|
139
|
-
const extraProps = {};
|
|
140
|
-
return extraProps;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* The function run when calling `react-native codegen-windows`.
|
|
144
|
-
* @param args Unprocessed args passed from react-native CLI.
|
|
145
|
-
* @param config Config passed from react-native CLI.
|
|
146
|
-
* @param options Options passed from react-native CLI.
|
|
147
|
-
*/
|
|
148
|
-
async function codegenWindows(args, config, options) {
|
|
149
|
-
await (0, telemetryHelpers_1.startTelemetrySession)('codegen-windows', config, options, (0, telemetryHelpers_1.getDefaultOptions)(config, codegenWindowsOptions_1.codegenOptions), optionSanitizer);
|
|
150
|
-
let codegenWindowsError;
|
|
151
|
-
try {
|
|
152
|
-
await codegenWindowsInternal(args, config, options);
|
|
153
|
-
}
|
|
154
|
-
catch (ex) {
|
|
155
|
-
codegenWindowsError =
|
|
156
|
-
ex instanceof Error ? ex : new Error(String(ex));
|
|
157
|
-
telemetry_1.Telemetry.trackException(codegenWindowsError);
|
|
158
|
-
}
|
|
159
|
-
await (0, telemetryHelpers_1.endTelemetrySession)(codegenWindowsError, getExtraProps);
|
|
160
|
-
(0, commandWithProgress_1.setExitProcessWithError)(options.logging, codegenWindowsError);
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Performs codegen for RNW native modules and apps.
|
|
164
|
-
* @param args Unprocessed args passed from react-native CLI.
|
|
165
|
-
* @param config Config passed from react-native CLI.
|
|
166
|
-
* @param options Options passed from react-native CLI.
|
|
167
|
-
*/
|
|
168
|
-
async function codegenWindowsInternal(args, config, options) {
|
|
169
|
-
const startTime = perf_hooks_1.performance.now();
|
|
170
|
-
const spinner = (0, commandWithProgress_1.newSpinner)(options.check
|
|
171
|
-
? 'Checking codegen-windows files...'
|
|
172
|
-
: 'Running codegen-windows...');
|
|
173
|
-
try {
|
|
174
|
-
const codegen = new CodeGenWindows(config.root, options);
|
|
175
|
-
await codegen.run(spinner);
|
|
176
|
-
const endTime = perf_hooks_1.performance.now();
|
|
177
|
-
if (!codegen.areChangesNeeded()) {
|
|
178
|
-
console.log(`${chalk_1.default.green('Success:')} No codegen-windows changes necessary. (${Math.round(endTime - startTime)}ms)`);
|
|
179
|
-
}
|
|
180
|
-
else if (options.check) {
|
|
181
|
-
const codegenCommand = 'npx react-native codegen-windows';
|
|
182
|
-
console.log(`${chalk_1.default.yellow('Warning:')} Codegen-windows changes were necessary but ${chalk_1.default.bold('--check')} specified. Run '${chalk_1.default.bold(`${codegenCommand}`)}' to apply the changes. (${Math.round(endTime - startTime)}ms)`);
|
|
183
|
-
throw new telemetry_1.CodedError('NeedCodegen', `Codegen-windows changes were necessary but --check was specified. Run '${codegenCommand}' to apply the changes`);
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
console.log(`${chalk_1.default.green('Success:')} Codegen-windows changes completed. (${Math.round(endTime - startTime)}ms)`);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
catch (e) {
|
|
190
|
-
spinner.fail();
|
|
191
|
-
const endTime = perf_hooks_1.performance.now();
|
|
192
|
-
console.log(`${chalk_1.default.red('Error:')} ${e.toString()}. (${Math.round(endTime - startTime)}ms)`);
|
|
193
|
-
throw e;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
exports.codegenWindowsInternal = codegenWindowsInternal;
|
|
197
|
-
/**
|
|
198
|
-
* Performs codegen for RNW native modules.
|
|
199
|
-
*/
|
|
200
|
-
exports.codegenCommand = {
|
|
201
|
-
name: 'codegen-windows',
|
|
202
|
-
description: 'Runs Windows-specific codegen',
|
|
203
|
-
func: codegenWindows,
|
|
204
|
-
options: codegenWindowsOptions_1.codegenOptions,
|
|
205
|
-
};
|
|
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.codegenCommand = exports.codegenWindowsInternal = exports.CodeGenWindows = void 0;
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
14
|
+
const perf_hooks_1 = require("perf_hooks");
|
|
15
|
+
const telemetry_1 = require("@react-native-windows/telemetry");
|
|
16
|
+
const codegen_1 = require("@react-native-windows/codegen");
|
|
17
|
+
const commandWithProgress_1 = require("../../utils/commandWithProgress");
|
|
18
|
+
const telemetryHelpers_1 = require("../../utils/telemetryHelpers");
|
|
19
|
+
const codegenWindowsOptions_1 = require("./codegenWindowsOptions");
|
|
20
|
+
class CodeGenWindows {
|
|
21
|
+
areChangesNeeded() {
|
|
22
|
+
return this.changesNecessary;
|
|
23
|
+
}
|
|
24
|
+
constructor(root, options) {
|
|
25
|
+
this.root = root;
|
|
26
|
+
this.options = options;
|
|
27
|
+
this.changesNecessary = false;
|
|
28
|
+
}
|
|
29
|
+
async run(spinner) {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
const verbose = this.options.logging;
|
|
32
|
+
verboseMessage('', verbose);
|
|
33
|
+
verboseMessage('Loading codegenConfig from package.json');
|
|
34
|
+
const pkgJson = require(path_1.default.join(this.root, 'package.json'));
|
|
35
|
+
if (!pkgJson.codegenConfig) {
|
|
36
|
+
spinner.info(`No ${chalk_1.default.bold('codegenConfig')} specified in package.json - ${chalk_1.default.yellow('Skipping codegen-windows')}`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const codegenConfigType = pkgJson.codegenConfig.type;
|
|
40
|
+
if (codegenConfigType !== 'modules' && codegenConfigType !== 'all') {
|
|
41
|
+
spinner.info(`${chalk_1.default.bold('codegenConfig.type')} in package.json is not ${chalk_1.default.bold('modules')} or ${chalk_1.default.bold('all')} - ${chalk_1.default.yellow('Skipping codegen-windows')}`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (!pkgJson.codegenConfig.windows) {
|
|
45
|
+
spinner.info(`No ${chalk_1.default.bold('codegenConfig.windows')} specified in package.json - ${chalk_1.default.yellow('Skipping codegen-windows')}`);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (!pkgJson.codegenConfig.windows.namespace) {
|
|
49
|
+
throw new telemetry_1.CodedError('InvalidCodegenConfig', `Missing ${chalk_1.default.bold('codegenConfig.windows.namespace')} value in package.json`);
|
|
50
|
+
}
|
|
51
|
+
let cppStringType = 'std::string';
|
|
52
|
+
if (pkgJson.codegenConfig.windows.cppStringType) {
|
|
53
|
+
switch (pkgJson.codegenConfig.windows.cppStringType) {
|
|
54
|
+
case 'std::string':
|
|
55
|
+
case 'std::wstring':
|
|
56
|
+
cppStringType = pkgJson.codegenConfig.windows.cppStringType;
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
throw new telemetry_1.CodedError('InvalidCodegenConfig', `Value of ${chalk_1.default.bold('codegenConfig.windows.cppStringType')} in package.json should be either 'std::string' or 'std::wstring'`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
let separateDataTypes = false;
|
|
63
|
+
if (pkgJson.codegenConfig.windows.separateDataTypes !== undefined) {
|
|
64
|
+
switch (pkgJson.codegenConfig.windows.separateDataTypes) {
|
|
65
|
+
case true:
|
|
66
|
+
case false:
|
|
67
|
+
separateDataTypes = pkgJson.codegenConfig.windows.separateDataTypes;
|
|
68
|
+
break;
|
|
69
|
+
default:
|
|
70
|
+
throw new telemetry_1.CodedError('InvalidCodegenConfig', `Value of ${chalk_1.default.bold('codegenConfig.windows.separateDataTypes')} in package.json should be either true or false`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (!pkgJson.codegenConfig.name) {
|
|
74
|
+
throw new telemetry_1.CodedError('InvalidCodegenConfig', `Missing ${chalk_1.default.bold('codegenConfig.name')} value in package.json`);
|
|
75
|
+
}
|
|
76
|
+
const projectName = pkgJson.codegenConfig.name.replace(/[^a-zA-Z]/g, '');
|
|
77
|
+
const projectNamespace = pkgJson.codegenConfig.windows.namespace;
|
|
78
|
+
const jsRootDir = pkgJson.codegenConfig.jsSrcsDir
|
|
79
|
+
? path_1.default.join(this.root, pkgJson.codegenConfig.jsSrcsDir)
|
|
80
|
+
: this.root;
|
|
81
|
+
const codegenOutputDir = (_a = pkgJson.codegenConfig.windows.outputDirectory) !== null && _a !== void 0 ? _a : 'codegen';
|
|
82
|
+
const generators = (_b = pkgJson.codegenConfig.windows.generators) !== null && _b !== void 0 ? _b : [
|
|
83
|
+
'modulesWindows',
|
|
84
|
+
];
|
|
85
|
+
const jsRootPathRelative = path_1.default.relative(process.cwd(), jsRootDir);
|
|
86
|
+
const options = {
|
|
87
|
+
files: [
|
|
88
|
+
`${jsRootPathRelative}${jsRootPathRelative ? '/' : ''}**/*Native*.[jt]s`,
|
|
89
|
+
],
|
|
90
|
+
cppStringType,
|
|
91
|
+
separateDataTypes,
|
|
92
|
+
libraryName: projectName,
|
|
93
|
+
methodOnly: false,
|
|
94
|
+
modulesCxx: generators.indexOf('modulesCxx') !== -1,
|
|
95
|
+
modulesTypeScriptTypes: generators.indexOf('modulesTypeScriptTypes') !== -1,
|
|
96
|
+
modulesWindows: generators.indexOf('modulesWindows') !== -1,
|
|
97
|
+
namespace: projectNamespace,
|
|
98
|
+
outputDirectory: path_1.default.join(this.root, codegenOutputDir),
|
|
99
|
+
test: !!this.options.check,
|
|
100
|
+
};
|
|
101
|
+
verboseMessage(`Run codegen with options: \n${JSON.stringify(options, null, 2)}`, verbose);
|
|
102
|
+
this.changesNecessary = (0, codegen_1.runCodeGen)(options);
|
|
103
|
+
spinner.succeed();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.CodeGenWindows = CodeGenWindows;
|
|
107
|
+
/**
|
|
108
|
+
* Logs the given message if verbose is True.
|
|
109
|
+
* @param message The message to log.
|
|
110
|
+
* @param verbose Whether or not verbose logging is enabled.
|
|
111
|
+
*/
|
|
112
|
+
function verboseMessage(message, verbose) {
|
|
113
|
+
if (verbose) {
|
|
114
|
+
console.log(message);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Sanitizes the given option for telemetry.
|
|
119
|
+
* @param key The key of the option.
|
|
120
|
+
* @param value The unsanitized value of the option.
|
|
121
|
+
* @returns The sanitized value of the option.
|
|
122
|
+
*/
|
|
123
|
+
function optionSanitizer(key, value) {
|
|
124
|
+
// Do not add a default case here.
|
|
125
|
+
// Strings risking PII should just return true if present, false otherwise.
|
|
126
|
+
// All others should return the value (or false if undefined).
|
|
127
|
+
switch (key) {
|
|
128
|
+
case 'logging':
|
|
129
|
+
case 'check':
|
|
130
|
+
case 'telemetry':
|
|
131
|
+
return value === undefined ? false : value; // Return value
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Get the extra props to add to the `codegen-windows` telemetry event.
|
|
136
|
+
* @returns The extra props.
|
|
137
|
+
*/
|
|
138
|
+
async function getExtraProps() {
|
|
139
|
+
const extraProps = {};
|
|
140
|
+
return extraProps;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The function run when calling `react-native codegen-windows`.
|
|
144
|
+
* @param args Unprocessed args passed from react-native CLI.
|
|
145
|
+
* @param config Config passed from react-native CLI.
|
|
146
|
+
* @param options Options passed from react-native CLI.
|
|
147
|
+
*/
|
|
148
|
+
async function codegenWindows(args, config, options) {
|
|
149
|
+
await (0, telemetryHelpers_1.startTelemetrySession)('codegen-windows', config, options, (0, telemetryHelpers_1.getDefaultOptions)(config, codegenWindowsOptions_1.codegenOptions), optionSanitizer);
|
|
150
|
+
let codegenWindowsError;
|
|
151
|
+
try {
|
|
152
|
+
await codegenWindowsInternal(args, config, options);
|
|
153
|
+
}
|
|
154
|
+
catch (ex) {
|
|
155
|
+
codegenWindowsError =
|
|
156
|
+
ex instanceof Error ? ex : new Error(String(ex));
|
|
157
|
+
telemetry_1.Telemetry.trackException(codegenWindowsError);
|
|
158
|
+
}
|
|
159
|
+
await (0, telemetryHelpers_1.endTelemetrySession)(codegenWindowsError, getExtraProps);
|
|
160
|
+
(0, commandWithProgress_1.setExitProcessWithError)(options.logging, codegenWindowsError);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Performs codegen for RNW native modules and apps.
|
|
164
|
+
* @param args Unprocessed args passed from react-native CLI.
|
|
165
|
+
* @param config Config passed from react-native CLI.
|
|
166
|
+
* @param options Options passed from react-native CLI.
|
|
167
|
+
*/
|
|
168
|
+
async function codegenWindowsInternal(args, config, options) {
|
|
169
|
+
const startTime = perf_hooks_1.performance.now();
|
|
170
|
+
const spinner = (0, commandWithProgress_1.newSpinner)(options.check
|
|
171
|
+
? 'Checking codegen-windows files...'
|
|
172
|
+
: 'Running codegen-windows...');
|
|
173
|
+
try {
|
|
174
|
+
const codegen = new CodeGenWindows(config.root, options);
|
|
175
|
+
await codegen.run(spinner);
|
|
176
|
+
const endTime = perf_hooks_1.performance.now();
|
|
177
|
+
if (!codegen.areChangesNeeded()) {
|
|
178
|
+
console.log(`${chalk_1.default.green('Success:')} No codegen-windows changes necessary. (${Math.round(endTime - startTime)}ms)`);
|
|
179
|
+
}
|
|
180
|
+
else if (options.check) {
|
|
181
|
+
const codegenCommand = 'npx react-native codegen-windows';
|
|
182
|
+
console.log(`${chalk_1.default.yellow('Warning:')} Codegen-windows changes were necessary but ${chalk_1.default.bold('--check')} specified. Run '${chalk_1.default.bold(`${codegenCommand}`)}' to apply the changes. (${Math.round(endTime - startTime)}ms)`);
|
|
183
|
+
throw new telemetry_1.CodedError('NeedCodegen', `Codegen-windows changes were necessary but --check was specified. Run '${codegenCommand}' to apply the changes`);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
console.log(`${chalk_1.default.green('Success:')} Codegen-windows changes completed. (${Math.round(endTime - startTime)}ms)`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
catch (e) {
|
|
190
|
+
spinner.fail();
|
|
191
|
+
const endTime = perf_hooks_1.performance.now();
|
|
192
|
+
console.log(`${chalk_1.default.red('Error:')} ${e.toString()}. (${Math.round(endTime - startTime)}ms)`);
|
|
193
|
+
throw e;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
exports.codegenWindowsInternal = codegenWindowsInternal;
|
|
197
|
+
/**
|
|
198
|
+
* Performs codegen for RNW native modules.
|
|
199
|
+
*/
|
|
200
|
+
exports.codegenCommand = {
|
|
201
|
+
name: 'codegen-windows',
|
|
202
|
+
description: 'Runs Windows-specific codegen',
|
|
203
|
+
func: codegenWindows,
|
|
204
|
+
options: codegenWindowsOptions_1.codegenOptions,
|
|
205
|
+
};
|
|
206
206
|
//# sourceMappingURL=codegenWindows.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
* @format
|
|
5
|
-
*/
|
|
6
|
-
import { CommandOption } from '@react-native-community/cli-types';
|
|
7
|
-
export interface CodeGenOptions {
|
|
8
|
-
logging?: boolean;
|
|
9
|
-
check?: boolean;
|
|
10
|
-
telemetry?: boolean;
|
|
11
|
-
}
|
|
12
|
-
export declare const codegenOptions: CommandOption[];
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
* @format
|
|
5
|
+
*/
|
|
6
|
+
import { CommandOption } from '@react-native-community/cli-types';
|
|
7
|
+
export interface CodeGenOptions {
|
|
8
|
+
logging?: boolean;
|
|
9
|
+
check?: boolean;
|
|
10
|
+
telemetry?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const codegenOptions: CommandOption[];
|
|
@@ -1,23 +1,23 @@
|
|
|
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.codegenOptions = void 0;
|
|
9
|
-
exports.codegenOptions = [
|
|
10
|
-
{
|
|
11
|
-
name: '--logging',
|
|
12
|
-
description: 'Verbose output logging',
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
name: '--check',
|
|
16
|
-
description: 'Only check whether any codegen files need to change',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
name: '--no-telemetry',
|
|
20
|
-
description: 'Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI',
|
|
21
|
-
},
|
|
22
|
-
];
|
|
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.codegenOptions = void 0;
|
|
9
|
+
exports.codegenOptions = [
|
|
10
|
+
{
|
|
11
|
+
name: '--logging',
|
|
12
|
+
description: 'Verbose output logging',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: '--check',
|
|
16
|
+
description: 'Only check whether any codegen files need to change',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: '--no-telemetry',
|
|
20
|
+
description: 'Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI',
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
23
|
//# sourceMappingURL=codegenWindowsOptions.js.map
|