Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Add setup-module-windows command with cpp-app template support",
"packageName": "@react-native-windows/cli",
"email": "copilot@github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Add setup-module-windows command with cpp-app template support",
"packageName": "@react-native-windows/telemetry",
"email": "54227869+anupriya13@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -260,58 +260,73 @@ export async function codegenWindowsInternal(
args: string[],
config: Config,
options: CodeGenOptions,
existingSpinner?: Ora,
) {
const startTime = performance.now();
const spinner = newSpinner(
options.check
? 'Checking codegen-windows files...'
: 'Running codegen-windows...',
);
const spinner =
existingSpinner ||
newSpinner(
options.check
? 'Checking codegen-windows files...'
: 'Running codegen-windows...',
);
const shouldLog = !existingSpinner; // Only log completion messages if we created our own spinner

try {
const codegen = new CodeGenWindows(config.root, options);
await codegen.run(spinner);
const endTime = performance.now();

if (!codegen.areChangesNeeded()) {
console.log(
`${chalk.green(
'Success:',
)} No codegen-windows changes necessary. (${Math.round(
endTime - startTime,
)}ms)`,
);
if (shouldLog) {
console.log(
`${chalk.green(
'Success:',
)} No codegen-windows changes necessary. (${Math.round(
endTime - startTime,
)}ms)`,
);
}
} else if (options.check) {
const codegenCommand = 'npx @react-native-community/cli codegen-windows';
console.log(
`${chalk.yellow(
'Warning:',
)} Codegen-windows changes were necessary but ${chalk.bold(
'--check',
)} specified. Run '${chalk.bold(
`${codegenCommand}`,
)}' to apply the changes. (${Math.round(endTime - startTime)}ms)`,
);
if (shouldLog) {
console.log(
`${chalk.yellow(
'Warning:',
)} Codegen-windows changes were necessary but ${chalk.bold(
'--check',
)} specified. Run '${chalk.bold(
`${codegenCommand}`,
)}' to apply the changes. (${Math.round(endTime - startTime)}ms)`,
);
}
throw new CodedError(
'NeedCodegen',
`Codegen-windows changes were necessary but --check was specified. Run '${codegenCommand}' to apply the changes`,
);
} else {
if (shouldLog) {
console.log(
`${chalk.green(
'Success:',
)} Codegen-windows changes completed. (${Math.round(
endTime - startTime,
)}ms)`,
);
}
}
} catch (e) {
if (!existingSpinner) {
spinner.fail();
}
const endTime = performance.now();
if (shouldLog) {
console.log(
`${chalk.green(
'Success:',
)} Codegen-windows changes completed. (${Math.round(
`${chalk.red('Error:')} ${(e as any).toString()}. (${Math.round(
endTime - startTime,
)}ms)`,
);
}
} catch (e) {
spinner.fail();
const endTime = performance.now();
console.log(
`${chalk.red('Error:')} ${(e as any).toString()}. (${Math.round(
endTime - startTime,
)}ms)`,
);
throw e;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,32 +372,42 @@ async function initWindows(
* @param args Unprocessed args passed from react-native CLI.
* @param config Config passed from react-native CLI.
* @param options Options passed from react-native CLI.
* @param existingSpinner Optional existing spinner to use instead of creating a new one.
*/
export async function initWindowsInternal(
args: string[],
config: Config,
options: InitOptions,
existingSpinner?: Ora,
) {
const startTime = performance.now();
const spinner = newSpinner('Running init-windows...');
const spinner = existingSpinner || newSpinner('Running init-windows...');
const shouldLog = !existingSpinner; // Only log completion messages if we created our own spinner

try {
const codegen = new InitWindows(config, options);
await codegen.run(spinner);
const endTime = performance.now();

console.log(
`${chalk.green('Success:')} init-windows completed. (${Math.round(
endTime - startTime,
)}ms)`,
);
if (shouldLog) {
console.log(
`${chalk.green('Success:')} init-windows completed. (${Math.round(
endTime - startTime,
)}ms)`,
);
}
} catch (e) {
spinner.fail();
if (!existingSpinner) {
spinner.fail();
}
const endTime = performance.now();
console.log(
`${chalk.red('Error:')} ${(e as any).toString()}. (${Math.round(
endTime - startTime,
)}ms)`,
);
if (shouldLog) {
console.log(
`${chalk.red('Error:')} ${(e as any).toString()}. (${Math.round(
endTime - startTime,
)}ms)`,
);
}
throw e;
}
}
Expand Down
Loading
Loading