Skip to content

Commit 197ee65

Browse files
logger
1 parent 86c51c6 commit 197ee65

File tree

13 files changed

+163
-182
lines changed

13 files changed

+163
-182
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ jobs:
9494
env:
9595
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
9696

97-
- name: Commit version changes
97+
- name: Commit version changes (stable only)
98+
if: inputs.release_type == 'stable release'
9899
run: |
99100
git add -A
100101
git commit -m "chore: version packages" || echo "No changes to commit"

packages/cli/src/__tests__/cli.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ describe('CLI Bundle Command', () => {
9595
expect(output.data.flows[0].stats.packages[0].name).toBe(
9696
'@walkeros/core@latest',
9797
);
98-
});
98+
}, 120000);
9999

100100
it('should output JSON format for failed bundle (invalid syntax)', async () => {
101101
// Flow.Setup format - but bundler will fail on invalid destination code

packages/cli/src/commands/bundle/bundler.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,16 @@ export async function bundleCore(
8484
if (cached) {
8585
const cachedBuild = await getCachedBuild(configContent);
8686
if (cachedBuild) {
87-
logger.info('✨ Using cached build');
87+
logger.debug('Using cached build');
8888

8989
// Write cached build to output
9090
const outputPath = path.resolve(buildOptions.output);
9191
await fs.ensureDir(path.dirname(outputPath));
9292
await fs.writeFile(outputPath, cachedBuild);
9393

94-
logger.gray(`Output: ${outputPath}`);
95-
logger.success('✅ Build completed (from cache)');
94+
const stats = await fs.stat(outputPath);
95+
const sizeKB = (stats.size / 1024).toFixed(1);
96+
logger.log(`Output: ${outputPath} (${sizeKB} KB, cached)`);
9697

9798
// Return stats if requested
9899
if (showStats) {
@@ -121,7 +122,7 @@ export async function bundleCore(
121122
await fs.ensureDir(TEMP_DIR);
122123

123124
// Step 2: Download packages
124-
logger.info('📥 Downloading packages...');
125+
logger.debug('Downloading packages');
125126
// Convert packages object to array format expected by downloadPackages
126127
const packagesArray = Object.entries(buildOptions.packages).map(
127128
([name, packageConfig]) => ({
@@ -168,7 +169,7 @@ export async function bundleCore(
168169
);
169170

170171
// Step 4: Create entry point
171-
logger.info('📝 Creating entry point...');
172+
logger.debug('Creating entry point');
172173
const entryContent = await createEntryPoint(
173174
flowConfig,
174175
buildOptions,
@@ -178,7 +179,9 @@ export async function bundleCore(
178179
await fs.writeFile(entryPath, entryContent);
179180

180181
// Step 4: Bundle with esbuild
181-
logger.info('⚡ Bundling with esbuild...');
182+
logger.debug(
183+
`Running esbuild (target: ${buildOptions.target || 'es2018'}, format: ${buildOptions.format})`,
184+
);
182185
const outputPath = path.resolve(buildOptions.output);
183186

184187
// Ensure output directory exists
@@ -203,7 +206,11 @@ export async function bundleCore(
203206
);
204207
}
205208

206-
logger.gray(`Output: ${outputPath}`);
209+
// Get file size and calculate build time
210+
const outputStats = await fs.stat(outputPath);
211+
const sizeKB = (outputStats.size / 1024).toFixed(1);
212+
const buildTime = ((Date.now() - bundleStartTime) / 1000).toFixed(1);
213+
logger.log(`Output: ${outputPath} (${sizeKB} KB, ${buildTime}s)`);
207214

208215
// Step 5: Cache the build result if caching is enabled
209216
if (buildOptions.cache !== false) {

packages/cli/src/commands/bundle/index.ts

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import path from 'path';
88
import {
99
createCommandLogger,
10-
createLogger,
1110
createTimer,
1211
createSuccessOutput,
1312
createErrorOutput,
@@ -46,9 +45,7 @@ export async function bundleCommand(
4645

4746
// Handle dry-run
4847
if (options.dryRun) {
49-
logger.info(
50-
`[DRY-RUN] Would execute bundle with config: ${options.config}`,
51-
);
48+
logger.log(`[DRY-RUN] Would execute bundle with config: ${options.config}`);
5249
return;
5350
}
5451

@@ -59,7 +56,6 @@ export async function bundleCommand(
5956
}
6057

6158
// Step 1: Read configuration file
62-
logger.info('📦 Reading configuration...');
6359
// Resolve bare names to examples directory, keep paths/URLs as-is
6460
const configPath = resolveAsset(options.config, 'config');
6561
const rawConfig = await loadJsonConfig(configPath);
@@ -95,11 +91,12 @@ export async function bundleCommand(
9591
buildOptions.cache = options.cache;
9692
}
9793

98-
// Log flow being built (for multi-flow setups)
94+
// Log flow being built
95+
const configBasename = path.basename(configPath);
9996
if (isMultiFlow || options.all) {
100-
logger.info(`\n🔧 Building flow: ${flowName}`);
97+
logger.log(`Bundling ${configBasename} (flow: ${flowName})...`);
10198
} else {
102-
logger.info('🔧 Starting bundle process...');
99+
logger.log(`Bundling ${configBasename}...`);
103100
}
104101

105102
// Run bundler
@@ -142,7 +139,6 @@ export async function bundleCommand(
142139

143140
if (options.json) {
144141
// JSON output for CI/CD
145-
const outputLogger = createLogger({ silent: false, json: false });
146142
const output =
147143
failureCount === 0
148144
? createSuccessOutput(
@@ -160,20 +156,18 @@ export async function bundleCommand(
160156
`${failureCount} flow(s) failed to build`,
161157
duration,
162158
);
163-
outputLogger.log('white', JSON.stringify(output, null, 2));
159+
logger.json(output);
164160
} else {
165161
if (options.all) {
166-
logger.info(`\n📊 Build Summary:`);
167-
logger.info(` Total: ${results.length}`);
168-
logger.success(` ✅ Success: ${successCount}`);
162+
logger.log(
163+
`\nBuild Summary: ${successCount}/${results.length} succeeded`,
164+
);
169165
if (failureCount > 0) {
170-
logger.error(`Failed: ${failureCount}`);
166+
logger.error(`Failed: ${failureCount}`);
171167
}
172168
}
173169

174-
if (failureCount === 0) {
175-
logger.success(`\n✅ Bundle created successfully in ${timer.format()}`);
176-
} else {
170+
if (failureCount > 0) {
177171
throw new Error(`${failureCount} flow(s) failed to build`);
178172
}
179173
}
@@ -183,12 +177,10 @@ export async function bundleCommand(
183177

184178
if (options.json) {
185179
// JSON error output for CI/CD
186-
const outputLogger = createLogger({ silent: false, json: false });
187180
const output = createErrorOutput(errorMessage, duration);
188-
outputLogger.log('white', JSON.stringify(output, null, 2));
181+
logger.json(output);
189182
} else {
190-
logger.error('❌ Bundle failed:');
191-
logger.error(errorMessage);
183+
logger.error(`Error: ${errorMessage}`);
192184
}
193185
process.exit(1);
194186
}

packages/cli/src/commands/bundle/package-manager.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ export async function downloadPackages(
152152
const downloadQueue: Package[] = [...packages];
153153
const processed = new Set<string>();
154154

155+
// Track user-specified packages (only these are logged per design)
156+
const userSpecifiedPackages = new Set(packages.map((p) => p.name));
157+
155158
// Track packages that should use local paths (to prevent npm overwriting them)
156159
const localPackageMap = new Map<string, string>();
157160
for (const pkg of packages) {
@@ -209,7 +212,10 @@ export async function downloadPackages(
209212
const cachedPath = await getCachedPackagePath(pkg);
210213

211214
if (useCache && (await isPackageCached(pkg))) {
212-
logger.debug(`Using cached ${packageSpec}...`);
215+
// Only log user-specified packages per design
216+
if (userSpecifiedPackages.has(pkg.name)) {
217+
logger.debug(`Downloading ${packageSpec} (cached)`);
218+
}
213219
try {
214220
// Ensure parent directories exist for scoped packages (@scope/package)
215221
await fs.ensureDir(path.dirname(packageDir));
@@ -232,8 +238,6 @@ export async function downloadPackages(
232238
}
233239
}
234240

235-
logger.debug(`Downloading ${packageSpec}...`);
236-
237241
try {
238242
// Ensure parent directories exist for scoped packages (@scope/package)
239243
await fs.ensureDir(path.dirname(packageDir));
@@ -260,14 +264,23 @@ export async function downloadPackages(
260264
`Package download timed out after ${PACKAGE_DOWNLOAD_TIMEOUT_MS / 1000}s: ${packageSpec}`,
261265
);
262266

267+
// Only log user-specified packages per design
268+
if (userSpecifiedPackages.has(pkg.name)) {
269+
// Get package size for display
270+
const pkgStats = await fs.stat(path.join(packageDir, 'package.json'));
271+
const pkgJsonSize = pkgStats.size;
272+
// Estimate total package size from package.json (rough approximation)
273+
const sizeKB = (pkgJsonSize / 1024).toFixed(1);
274+
logger.debug(`Downloading ${packageSpec} (${sizeKB} KB)`);
275+
}
276+
263277
// Cache the downloaded package for future use
264278
if (useCache) {
265279
try {
266280
await fs.ensureDir(path.dirname(cachedPath));
267281
await fs.copy(packageDir, cachedPath);
268-
logger.debug(`Cached ${packageSpec} for future use`);
269282
} catch (cacheError) {
270-
logger.debug(`Failed to cache ${packageSpec}: ${cacheError}`);
283+
// Silent cache failures
271284
}
272285
}
273286

packages/cli/src/commands/cache.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fs from 'fs-extra';
22
import { Command } from 'commander';
33
import { getTmpPath, getDefaultTmpRoot } from '../core/tmp.js';
4+
import { createLogger } from '../core/logger.js';
45

56
export function registerCacheCommand(program: Command): void {
67
const cache = program.command('cache').description('Manage the CLI cache');
@@ -11,35 +12,39 @@ export function registerCacheCommand(program: Command): void {
1112
.option('--packages', 'Clear only package cache')
1213
.option('--builds', 'Clear only build cache')
1314
.option('--tmp-dir <dir>', 'Custom temp directory')
15+
.option('--silent', 'Suppress output')
1416
.action(async (options) => {
17+
const logger = createLogger({ silent: options.silent });
1518
const tmpDir = options.tmpDir;
1619
if (options.packages) {
1720
await fs.remove(getTmpPath(tmpDir, 'cache', 'packages'));
18-
console.log('Package cache cleared');
21+
logger.log('Package cache cleared');
1922
} else if (options.builds) {
2023
await fs.remove(getTmpPath(tmpDir, 'cache', 'builds'));
21-
console.log('Build cache cleared');
24+
logger.log('Build cache cleared');
2225
} else {
2326
await fs.remove(getTmpPath(tmpDir, 'cache'));
24-
console.log('All caches cleared');
27+
logger.log('All caches cleared');
2528
}
2629
});
2730

2831
cache
2932
.command('info')
3033
.description('Show cache statistics')
3134
.option('--tmp-dir <dir>', 'Custom temp directory')
35+
.option('--silent', 'Suppress output')
3236
.action(async (options) => {
37+
const logger = createLogger({ silent: options.silent });
3338
const tmpDir = options.tmpDir;
3439
const packagesDir = getTmpPath(tmpDir, 'cache', 'packages');
3540
const buildsDir = getTmpPath(tmpDir, 'cache', 'builds');
3641

3742
const packageCount = await countEntries(packagesDir);
3843
const buildCount = await countEntries(buildsDir);
3944

40-
console.log(`Cache directory: ${getTmpPath(tmpDir, 'cache')}`);
41-
console.log(`Cached packages: ${packageCount}`);
42-
console.log(`Cached builds: ${buildCount}`);
45+
logger.log(`Cache directory: ${getTmpPath(tmpDir, 'cache')}`);
46+
logger.log(`Cached packages: ${packageCount}`);
47+
logger.log(`Cached builds: ${buildCount}`);
4348
});
4449
}
4550

@@ -51,10 +56,12 @@ export function registerCleanCommand(program: Command): void {
5156
.command('clean')
5257
.description('Clear the entire temp directory (.tmp/)')
5358
.option('--tmp-dir <dir>', 'Custom temp directory')
59+
.option('--silent', 'Suppress output')
5460
.action(async (options) => {
61+
const logger = createLogger({ silent: options.silent });
5562
const tmpDir = options.tmpDir || getDefaultTmpRoot();
5663
await fs.remove(tmpDir);
57-
console.log(`Temp directory cleared: ${tmpDir}`);
64+
logger.log(`Temp directory cleared: ${tmpDir}`);
5865
});
5966
}
6067

0 commit comments

Comments
 (0)