Skip to content

Commit b2c6dc2

Browse files
Copilothotlong
andcommitted
refactor: address code review feedback
- Simplify count() redundant Array.isArray check - Improve normalization comments in validate.ts and compile.ts Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 8c6f650 commit b2c6dc2

5 files changed

Lines changed: 5 additions & 5 deletions

File tree

packages/cli/src/commands/compile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const compileCommand = new Command('compile')
4141
printKV('Load time', `${duration}ms`);
4242
}
4343

44-
// 2. Normalize map-formatted collections and validate against Protocol
44+
// 2. Normalize map-formatted stack definition and validate against Protocol
4545
if (!options.json) printStep('Validating protocol compliance...');
4646
const normalized = normalizeStackInput(config as Record<string, unknown>);
4747
const result = ObjectStackDefinitionSchema.safeParse(normalized);

packages/cli/src/commands/doctor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ export const doctorCommand = new Command('doctor')
478478
printStep('Loading configuration for analysis...');
479479
try {
480480
const { config: rawConfig } = await loadConfig();
481-
const config = normalizeStackInput(rawConfig as Record<string, unknown>);
481+
const config: any = normalizeStackInput(rawConfig as Record<string, unknown>);
482482

483483
// Circular dependency detection
484484
if (Array.isArray(config.objects) && config.objects.length > 0) {

packages/cli/src/commands/info.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const infoCommand = new Command('info')
2828

2929
try {
3030
const { config: rawConfig, absolutePath, duration } = await loadConfig(configPath);
31-
const config = normalizeStackInput(rawConfig as Record<string, unknown>);
31+
const config: any = normalizeStackInput(rawConfig as Record<string, unknown>);
3232
const stats = collectMetadataStats(config);
3333

3434
if (options.json) {

packages/cli/src/commands/validate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const validateCommand = new Command('validate')
3939
printKV('Load time', `${duration}ms`);
4040
}
4141

42-
// 2. Normalize map-formatted collections and validate against schema
42+
// 2. Normalize map-formatted stack definition and validate against schema
4343
if (!options.json) printStep('Validating against ObjectStack Protocol...');
4444
const normalized = normalizeStackInput(config as Record<string, unknown>);
4545
const result = ObjectStackDefinitionSchema.safeParse(normalized);

packages/cli/src/utils/format.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export interface MetadataStats {
136136
export function collectMetadataStats(config: any): MetadataStats {
137137
const count = (val: any) => {
138138
if (Array.isArray(val)) return val.length;
139-
if (val && typeof val === 'object' && !Array.isArray(val)) return Object.keys(val).length;
139+
if (val && typeof val === 'object') return Object.keys(val).length;
140140
return 0;
141141
};
142142

0 commit comments

Comments
 (0)