@codebakers/cli 3.8.2 → 3.8.3

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/src/index.ts CHANGED
@@ -165,180 +165,6 @@ async function autoUpdateCli(): Promise<void> {
165
165
  }
166
166
  }
167
167
 
168
- // ============================================
169
- // Automatic Pattern Updates
170
- // ============================================
171
-
172
- interface PatternVersionInfo {
173
- version: string;
174
- moduleCount: number;
175
- updatedAt: string;
176
- cliVersion: string;
177
- }
178
-
179
- interface ContentResponse {
180
- version: string;
181
- router: string;
182
- modules: Record<string, string>;
183
- }
184
-
185
- function getLocalPatternVersion(): string | null {
186
- const cwd = process.cwd();
187
- const versionFile = join(cwd, '.claude', '.version.json');
188
-
189
- if (!existsSync(versionFile)) return null;
190
-
191
- try {
192
- const content = readFileSync(versionFile, 'utf-8');
193
- const info: PatternVersionInfo = JSON.parse(content);
194
- return info.version;
195
- } catch {
196
- return null;
197
- }
198
- }
199
-
200
- function isCodeBakersProject(): boolean {
201
- const cwd = process.cwd();
202
- return existsSync(join(cwd, 'CLAUDE.md')) || existsSync(join(cwd, '.claude'));
203
- }
204
-
205
- async function autoUpdatePatterns(): Promise<void> {
206
- // Only auto-update if this is a CodeBakers project
207
- if (!isCodeBakersProject()) return;
208
-
209
- // Only auto-update if user has valid access
210
- if (!hasValidAccess()) return;
211
-
212
- const localVersion = getLocalPatternVersion();
213
-
214
- // Check if we have a valid cached result first (fast path)
215
- const cached = getCachedPatternInfo();
216
- if (cached) {
217
- // If local matches latest, nothing to do
218
- if (localVersion === cached.latestVersion) return;
219
- // If we know there's an update but haven't updated yet, do it now
220
- if (localVersion !== cached.latestVersion) {
221
- await performPatternUpdate(cached.latestVersion);
222
- }
223
- return;
224
- }
225
-
226
- // Fetch from server to check for updates (with timeout)
227
- try {
228
- const controller = new AbortController();
229
- const timeout = setTimeout(() => controller.abort(), 5000);
230
-
231
- const apiUrl = getApiUrl();
232
- const apiKey = getApiKey();
233
- const trial = getTrialState();
234
-
235
- // Build authorization header
236
- let authHeader = '';
237
- if (apiKey) {
238
- authHeader = `Bearer ${apiKey}`;
239
- } else if (trial?.trialId) {
240
- authHeader = `Trial ${trial.trialId}`;
241
- }
242
-
243
- if (!authHeader) return;
244
-
245
- // First, check the version endpoint (lightweight)
246
- const versionResponse = await fetch(`${apiUrl}/api/content/version`, {
247
- method: 'GET',
248
- headers: {
249
- 'Authorization': authHeader,
250
- },
251
- signal: controller.signal,
252
- });
253
-
254
- clearTimeout(timeout);
255
-
256
- if (versionResponse.ok) {
257
- const versionData = await versionResponse.json();
258
- const serverVersion = versionData.version;
259
-
260
- // Cache the version info
261
- setCachedPatternInfo(serverVersion);
262
-
263
- // If local version is different, update
264
- if (localVersion !== serverVersion) {
265
- await performPatternUpdate(serverVersion);
266
- }
267
- }
268
- } catch {
269
- // Silently fail - don't block CLI for pattern check
270
- }
271
- }
272
-
273
- async function performPatternUpdate(targetVersion: string): Promise<void> {
274
- const cwd = process.cwd();
275
- const claudeMdPath = join(cwd, 'CLAUDE.md');
276
- const claudeDir = join(cwd, '.claude');
277
-
278
- try {
279
- const apiUrl = getApiUrl();
280
- const apiKey = getApiKey();
281
- const trial = getTrialState();
282
-
283
- let authHeader = '';
284
- if (apiKey) {
285
- authHeader = `Bearer ${apiKey}`;
286
- } else if (trial?.trialId) {
287
- authHeader = `Trial ${trial.trialId}`;
288
- }
289
-
290
- if (!authHeader) return;
291
-
292
- const controller = new AbortController();
293
- const timeout = setTimeout(() => controller.abort(), 10000);
294
-
295
- const response = await fetch(`${apiUrl}/api/content`, {
296
- method: 'GET',
297
- headers: {
298
- 'Authorization': authHeader,
299
- },
300
- signal: controller.signal,
301
- });
302
-
303
- clearTimeout(timeout);
304
-
305
- if (!response.ok) return;
306
-
307
- const content: ContentResponse = await response.json();
308
-
309
- // Update CLAUDE.md
310
- if (content.router) {
311
- writeFileSync(claudeMdPath, content.router);
312
- }
313
-
314
- // Update pattern modules
315
- if (content.modules && Object.keys(content.modules).length > 0) {
316
- if (!existsSync(claudeDir)) {
317
- mkdirSync(claudeDir, { recursive: true });
318
- }
319
-
320
- for (const [name, data] of Object.entries(content.modules)) {
321
- writeFileSync(join(claudeDir, name), data);
322
- }
323
- }
324
-
325
- // Write version file
326
- const moduleCount = Object.keys(content.modules || {}).length;
327
- const versionInfo: PatternVersionInfo = {
328
- version: content.version,
329
- moduleCount,
330
- updatedAt: new Date().toISOString(),
331
- cliVersion: getCliVersion(),
332
- };
333
- writeFileSync(join(claudeDir, '.version.json'), JSON.stringify(versionInfo, null, 2));
334
-
335
- // Show subtle notification
336
- console.log(chalk.green(` ✓ Patterns auto-updated to v${content.version} (${moduleCount} modules)\n`));
337
-
338
- } catch {
339
- // Silently fail - don't block the user
340
- }
341
- }
342
168
 
343
169
  // Show welcome message when no command is provided
344
170
  function showWelcome(): void {
@@ -356,12 +182,12 @@ function showWelcome(): void {
356
182
  console.log(chalk.cyan(' codebakers go') + chalk.gray(' Start free trial instantly (no signup!)'));
357
183
  console.log(chalk.cyan(' codebakers build') + chalk.gray(' Describe your project → Get working code'));
358
184
  console.log(chalk.cyan(' codebakers scaffold') + chalk.gray(' Create a new project from scratch'));
359
- console.log(chalk.cyan(' codebakers init') + chalk.gray(' Add patterns to existing project\n'));
185
+ console.log(chalk.cyan(' codebakers init') + chalk.gray(' Set up CodeBakers in existing project\n'));
360
186
 
361
187
  console.log(chalk.white(' Development:\n'));
362
188
  console.log(chalk.cyan(' codebakers generate') + chalk.gray(' Generate components, APIs, services'));
363
- console.log(chalk.cyan(' codebakers upgrade') + chalk.gray(' Update patterns to latest version'));
364
- console.log(chalk.cyan(' codebakers status') + chalk.gray(' Check what\'s installed'));
189
+ console.log(chalk.cyan(' codebakers upgrade') + chalk.gray(' Check for CLI updates'));
190
+ console.log(chalk.cyan(' codebakers status') + chalk.gray(' Check project status'));
365
191
  console.log(chalk.cyan(' codebakers config') + chalk.gray(' View or modify configuration\n'));
366
192
 
367
193
  console.log(chalk.white(' Examples:\n'));
@@ -379,8 +205,8 @@ function showWelcome(): void {
379
205
 
380
206
  console.log(chalk.white(' All Commands:\n'));
381
207
  console.log(chalk.gray(' go, extend, billing, build, build-status, setup, scaffold, init'));
382
- console.log(chalk.gray(' generate, upgrade, status, audit, heal, doctor, config'));
383
- console.log(chalk.gray(' login, install, uninstall, serve, mcp-config, mcp-uninstall\n'));
208
+ console.log(chalk.gray(' generate, upgrade, status, audit, heal, doctor, config, login'));
209
+ console.log(chalk.gray(' serve, mcp-config, mcp-uninstall\n'));
384
210
 
385
211
  console.log(chalk.gray(' Run ') + chalk.cyan('codebakers <command> --help') + chalk.gray(' for more info\n'));
386
212
  }
@@ -568,14 +394,10 @@ program
568
394
  // Add update check hook (runs before every command)
569
395
  program.hook('preAction', async () => {
570
396
  // Run CLI auto-update first (if enabled and conditions met)
571
- // Then run pattern auto-update in parallel with update banner check
572
397
  await autoUpdateCli();
573
398
 
574
- // Run pattern auto-update and update banner check in parallel
575
- await Promise.all([
576
- checkForUpdatesInBackground(),
577
- autoUpdatePatterns(),
578
- ]);
399
+ // Check for CLI updates in background
400
+ await checkForUpdatesInBackground();
579
401
  });
580
402
 
581
403
  // Show welcome if no command provided