Skip to content

Commit 54ab7ab

Browse files
artus9033Copilot
andauthored
refactor: improve logging in navigation codegen (#271)
* refactor: improve logging in navigation codegen * chore: add changeset * fix: log outro of navigation codegen in dry run Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 5484065 commit 54ab7ab

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

.changeset/small-rings-invite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@callstack/brownfield-cli': patch
3+
---
4+
5+
feat: improved logging in brownfield CLI codegens

packages/cli/src/brownie/commands/codegen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export async function runCodegen({ platform }: RunCodegenOptions) {
134134
}
135135
}
136136

137-
outro('Done!');
137+
outro('Brownie codegen done');
138138
}
139139

140140
export const codegenCommand = new Command('codegen')

packages/cli/src/navigation/runner.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'node:fs';
22
import path from 'node:path';
33

4-
import { logger } from '@rock-js/tools';
4+
import { intro, logger, outro } from '@rock-js/tools';
55
import {
66
DEFAULT_ANDROID_JAVA_PACKAGE,
77
getNavigationPackagePath,
@@ -53,7 +53,11 @@ function getOutputPaths(
5353
const androidPackagePathSegments = androidJavaPackageName.split('.');
5454

5555
return {
56-
turboModuleSpec: path.join(packageRoot, 'src', 'NativeBrownfieldNavigation.ts'),
56+
turboModuleSpec: path.join(
57+
packageRoot,
58+
'src',
59+
'NativeBrownfieldNavigation.ts'
60+
),
5761
navigationTs: path.join(packageRoot, 'src', 'index.ts'),
5862
commonjsIndexJs: path.join(packageRoot, 'lib', 'commonjs', 'index.js'),
5963
moduleIndexJs: path.join(packageRoot, 'lib', 'module', 'index.js'),
@@ -78,7 +82,11 @@ function getOutputPaths(
7882
'ios',
7983
'BrownfieldNavigationDelegate.swift'
8084
),
81-
swiftModels: path.join(packageRoot, 'ios', 'BrownfieldNavigationModels.swift'),
85+
swiftModels: path.join(
86+
packageRoot,
87+
'ios',
88+
'BrownfieldNavigationModels.swift'
89+
),
8290
objcImplementation: path.join(
8391
packageRoot,
8492
'ios',
@@ -207,14 +215,16 @@ export async function runNavigationCodegen({
207215
throw new Error(`Spec file not found: ${resolvedSpecPath}`);
208216
}
209217

218+
intro(`Running Brownfield Navigation codegen`);
219+
210220
logger.info(`Parsing spec file: ${resolvedSpecPath}`);
211221
const methods = parseNavigationSpec(resolvedSpecPath);
212222
if (methods.length === 0) {
213223
throw new Error('No methods found in spec file');
214224
}
215225

216226
logger.info(
217-
`Found ${methods.length} method(s): ${methods.map((method) => method.name).join(', ')}`
227+
`Found ${methods.length} method${methods.length === 1 ? '' : 's'}: ${methods.map((method) => method.name).join(', ')}`
218228
);
219229

220230
const packageRoot = getNavigationPackagePath(projectRoot);
@@ -244,13 +254,21 @@ export async function runNavigationCodegen({
244254
artifacts.swiftModels = models.swiftModels;
245255
artifacts.kotlinModels = models.kotlinModels;
246256
} else {
247-
logger.info('No complex model types found; skipping quicktype model generation');
257+
logger.info(
258+
'No complex model types found; skipping quicktype model generation'
259+
);
248260
}
249261

250262
if (dryRun) {
251263
printDryRun(androidJavaPackageName, artifacts);
264+
outro('Brownfield Navigation codegen done');
252265
return;
253266
}
254267

255-
writeArtifacts(getOutputPaths(packageRoot, androidJavaPackageName), artifacts);
268+
writeArtifacts(
269+
getOutputPaths(packageRoot, androidJavaPackageName),
270+
artifacts
271+
);
272+
273+
outro('Brownfield Navigation codegen done');
256274
}

0 commit comments

Comments
 (0)