@codebakers/cli 3.8.2 → 3.8.4

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/dist/index.js CHANGED
@@ -31,8 +31,6 @@ const build_js_1 = require("./commands/build.js");
31
31
  const config_js_2 = require("./config.js");
32
32
  const child_process_1 = require("child_process");
33
33
  const api_js_1 = require("./lib/api.js");
34
- const fs_1 = require("fs");
35
- const path_1 = require("path");
36
34
  // ============================================
37
35
  // Automatic Update Notification
38
36
  // ============================================
@@ -155,144 +153,6 @@ async function autoUpdateCli() {
155
153
  // Silently fail - don't block CLI for update check
156
154
  }
157
155
  }
158
- function getLocalPatternVersion() {
159
- const cwd = process.cwd();
160
- const versionFile = (0, path_1.join)(cwd, '.claude', '.version.json');
161
- if (!(0, fs_1.existsSync)(versionFile))
162
- return null;
163
- try {
164
- const content = (0, fs_1.readFileSync)(versionFile, 'utf-8');
165
- const info = JSON.parse(content);
166
- return info.version;
167
- }
168
- catch {
169
- return null;
170
- }
171
- }
172
- function isCodeBakersProject() {
173
- const cwd = process.cwd();
174
- return (0, fs_1.existsSync)((0, path_1.join)(cwd, 'CLAUDE.md')) || (0, fs_1.existsSync)((0, path_1.join)(cwd, '.claude'));
175
- }
176
- async function autoUpdatePatterns() {
177
- // Only auto-update if this is a CodeBakers project
178
- if (!isCodeBakersProject())
179
- return;
180
- // Only auto-update if user has valid access
181
- if (!(0, config_js_2.hasValidAccess)())
182
- return;
183
- const localVersion = getLocalPatternVersion();
184
- // Check if we have a valid cached result first (fast path)
185
- const cached = (0, config_js_2.getCachedPatternInfo)();
186
- if (cached) {
187
- // If local matches latest, nothing to do
188
- if (localVersion === cached.latestVersion)
189
- return;
190
- // If we know there's an update but haven't updated yet, do it now
191
- if (localVersion !== cached.latestVersion) {
192
- await performPatternUpdate(cached.latestVersion);
193
- }
194
- return;
195
- }
196
- // Fetch from server to check for updates (with timeout)
197
- try {
198
- const controller = new AbortController();
199
- const timeout = setTimeout(() => controller.abort(), 5000);
200
- const apiUrl = (0, config_js_2.getApiUrl)();
201
- const apiKey = (0, config_js_2.getApiKey)();
202
- const trial = (0, config_js_2.getTrialState)();
203
- // Build authorization header
204
- let authHeader = '';
205
- if (apiKey) {
206
- authHeader = `Bearer ${apiKey}`;
207
- }
208
- else if (trial?.trialId) {
209
- authHeader = `Trial ${trial.trialId}`;
210
- }
211
- if (!authHeader)
212
- return;
213
- // First, check the version endpoint (lightweight)
214
- const versionResponse = await fetch(`${apiUrl}/api/content/version`, {
215
- method: 'GET',
216
- headers: {
217
- 'Authorization': authHeader,
218
- },
219
- signal: controller.signal,
220
- });
221
- clearTimeout(timeout);
222
- if (versionResponse.ok) {
223
- const versionData = await versionResponse.json();
224
- const serverVersion = versionData.version;
225
- // Cache the version info
226
- (0, config_js_2.setCachedPatternInfo)(serverVersion);
227
- // If local version is different, update
228
- if (localVersion !== serverVersion) {
229
- await performPatternUpdate(serverVersion);
230
- }
231
- }
232
- }
233
- catch {
234
- // Silently fail - don't block CLI for pattern check
235
- }
236
- }
237
- async function performPatternUpdate(targetVersion) {
238
- const cwd = process.cwd();
239
- const claudeMdPath = (0, path_1.join)(cwd, 'CLAUDE.md');
240
- const claudeDir = (0, path_1.join)(cwd, '.claude');
241
- try {
242
- const apiUrl = (0, config_js_2.getApiUrl)();
243
- const apiKey = (0, config_js_2.getApiKey)();
244
- const trial = (0, config_js_2.getTrialState)();
245
- let authHeader = '';
246
- if (apiKey) {
247
- authHeader = `Bearer ${apiKey}`;
248
- }
249
- else if (trial?.trialId) {
250
- authHeader = `Trial ${trial.trialId}`;
251
- }
252
- if (!authHeader)
253
- return;
254
- const controller = new AbortController();
255
- const timeout = setTimeout(() => controller.abort(), 10000);
256
- const response = await fetch(`${apiUrl}/api/content`, {
257
- method: 'GET',
258
- headers: {
259
- 'Authorization': authHeader,
260
- },
261
- signal: controller.signal,
262
- });
263
- clearTimeout(timeout);
264
- if (!response.ok)
265
- return;
266
- const content = await response.json();
267
- // Update CLAUDE.md
268
- if (content.router) {
269
- (0, fs_1.writeFileSync)(claudeMdPath, content.router);
270
- }
271
- // Update pattern modules
272
- if (content.modules && Object.keys(content.modules).length > 0) {
273
- if (!(0, fs_1.existsSync)(claudeDir)) {
274
- (0, fs_1.mkdirSync)(claudeDir, { recursive: true });
275
- }
276
- for (const [name, data] of Object.entries(content.modules)) {
277
- (0, fs_1.writeFileSync)((0, path_1.join)(claudeDir, name), data);
278
- }
279
- }
280
- // Write version file
281
- const moduleCount = Object.keys(content.modules || {}).length;
282
- const versionInfo = {
283
- version: content.version,
284
- moduleCount,
285
- updatedAt: new Date().toISOString(),
286
- cliVersion: (0, config_js_2.getCliVersion)(),
287
- };
288
- (0, fs_1.writeFileSync)((0, path_1.join)(claudeDir, '.version.json'), JSON.stringify(versionInfo, null, 2));
289
- // Show subtle notification
290
- console.log(chalk_1.default.green(` ✓ Patterns auto-updated to v${content.version} (${moduleCount} modules)\n`));
291
- }
292
- catch {
293
- // Silently fail - don't block the user
294
- }
295
- }
296
156
  // Show welcome message when no command is provided
297
157
  function showWelcome() {
298
158
  console.log(chalk_1.default.blue(`
@@ -308,11 +168,11 @@ function showWelcome() {
308
168
  console.log(chalk_1.default.cyan(' codebakers go') + chalk_1.default.gray(' Start free trial instantly (no signup!)'));
309
169
  console.log(chalk_1.default.cyan(' codebakers build') + chalk_1.default.gray(' Describe your project → Get working code'));
310
170
  console.log(chalk_1.default.cyan(' codebakers scaffold') + chalk_1.default.gray(' Create a new project from scratch'));
311
- console.log(chalk_1.default.cyan(' codebakers init') + chalk_1.default.gray(' Add patterns to existing project\n'));
171
+ console.log(chalk_1.default.cyan(' codebakers init') + chalk_1.default.gray(' Set up CodeBakers in existing project\n'));
312
172
  console.log(chalk_1.default.white(' Development:\n'));
313
173
  console.log(chalk_1.default.cyan(' codebakers generate') + chalk_1.default.gray(' Generate components, APIs, services'));
314
- console.log(chalk_1.default.cyan(' codebakers upgrade') + chalk_1.default.gray(' Update patterns to latest version'));
315
- console.log(chalk_1.default.cyan(' codebakers status') + chalk_1.default.gray(' Check what\'s installed'));
174
+ console.log(chalk_1.default.cyan(' codebakers upgrade') + chalk_1.default.gray(' Check for CLI updates'));
175
+ console.log(chalk_1.default.cyan(' codebakers status') + chalk_1.default.gray(' Check project status'));
316
176
  console.log(chalk_1.default.cyan(' codebakers config') + chalk_1.default.gray(' View or modify configuration\n'));
317
177
  console.log(chalk_1.default.white(' Examples:\n'));
318
178
  console.log(chalk_1.default.gray(' $ ') + chalk_1.default.cyan('codebakers build "SaaS for invoicing"'));
@@ -327,8 +187,8 @@ function showWelcome() {
327
187
  console.log(chalk_1.default.cyan(' codebakers doctor') + chalk_1.default.gray(' Check CodeBakers setup\n'));
328
188
  console.log(chalk_1.default.white(' All Commands:\n'));
329
189
  console.log(chalk_1.default.gray(' go, extend, billing, build, build-status, setup, scaffold, init'));
330
- console.log(chalk_1.default.gray(' generate, upgrade, status, audit, heal, doctor, config'));
331
- console.log(chalk_1.default.gray(' login, install, uninstall, serve, mcp-config, mcp-uninstall\n'));
190
+ console.log(chalk_1.default.gray(' generate, upgrade, status, audit, heal, doctor, config, login'));
191
+ console.log(chalk_1.default.gray(' serve, mcp-config, mcp-uninstall\n'));
332
192
  console.log(chalk_1.default.gray(' Run ') + chalk_1.default.cyan('codebakers <command> --help') + chalk_1.default.gray(' for more info\n'));
333
193
  }
334
194
  const program = new commander_1.Command();
@@ -489,13 +349,9 @@ program
489
349
  // Add update check hook (runs before every command)
490
350
  program.hook('preAction', async () => {
491
351
  // Run CLI auto-update first (if enabled and conditions met)
492
- // Then run pattern auto-update in parallel with update banner check
493
352
  await autoUpdateCli();
494
- // Run pattern auto-update and update banner check in parallel
495
- await Promise.all([
496
- checkForUpdatesInBackground(),
497
- autoUpdatePatterns(),
498
- ]);
353
+ // Check for CLI updates in background
354
+ await checkForUpdatesInBackground();
499
355
  });
500
356
  // Show welcome if no command provided
501
357
  if (process.argv.length <= 2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebakers/cli",
3
- "version": "3.8.2",
3
+ "version": "3.8.4",
4
4
  "description": "CodeBakers CLI - Production patterns for AI-assisted development",
5
5
  "main": "dist/index.js",
6
6
  "bin": {