@codebakers/cli 1.1.3 → 1.1.5

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.
Files changed (2) hide show
  1. package/dist/index.js +111 -16
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -91,8 +91,24 @@ async function fetchPatterns(patterns) {
91
91
  body: JSON.stringify({ patterns })
92
92
  });
93
93
  }
94
+ async function checkCliVersion() {
95
+ try {
96
+ const baseUrl = getApiUrl();
97
+ const response = await fetchFn(`${baseUrl}/api/cli/version`);
98
+ if (!response.ok) {
99
+ return null;
100
+ }
101
+ return response.json();
102
+ } catch {
103
+ return null;
104
+ }
105
+ }
94
106
 
95
107
  // src/commands/setup.ts
108
+ import { createRequire } from "module";
109
+ var require2 = createRequire(import.meta.url);
110
+ var packageJson = require2("../../package.json");
111
+ var CURRENT_VERSION = packageJson.version;
96
112
  var CODEBAKERS_MARKER = "# CODEBAKERS SMART ROUTER";
97
113
  var USER_CONTENT_SEPARATOR = `
98
114
 
@@ -194,28 +210,107 @@ Validation failed: ${validation.error || "Unknown error"}`));
194
210
  await configureIDE(ide, options.force);
195
211
  }
196
212
  await installClaudeMd(apiKey, options.force);
213
+ const isExistingProject = detectExistingProject();
197
214
  const firstName = userName?.split(" ")[0];
198
215
  const greeting = firstName ? `${firstName}, you're` : "You're";
199
216
  console.log(chalk.bold.green("\n\u{1F389} Setup complete!\n"));
200
- console.log(chalk.green(`\u2713 ${greeting} ready to build!
217
+ if (isExistingProject) {
218
+ console.log(chalk.green(`\u2713 ${greeting} ready to upgrade this project!
219
+ `));
220
+ console.log(chalk.bold.yellow("\u{1F4CB} Existing Project Detected\n"));
221
+ console.log(chalk.white("We recommend starting with an audit to see how your code"));
222
+ console.log(chalk.white("compares to CodeBakers production standards.\n"));
223
+ console.log(chalk.bold("Recommended First Step:"));
224
+ console.log(chalk.cyan(" /audit\n"));
225
+ console.log(chalk.dim(" This will scan your codebase and generate a report showing:"));
226
+ console.log(chalk.dim(" \u2022 Security issues (SQL injection, XSS, etc.)"));
227
+ console.log(chalk.dim(" \u2022 Missing validation and error handling"));
228
+ console.log(chalk.dim(" \u2022 Performance opportunities"));
229
+ console.log(chalk.dim(" \u2022 Test coverage gaps"));
230
+ console.log(chalk.dim(" \u2022 Overall score out of 100\n"));
231
+ console.log(chalk.dim("After reviewing the report, you decide what to fix."));
232
+ console.log(chalk.dim("The AI will use CodeBakers patterns for any changes.\n"));
233
+ console.log(chalk.bold("Other Commands:\n"));
234
+ console.log(chalk.cyan(" /feature [idea]") + chalk.dim(" - Add new functionality"));
235
+ console.log(chalk.cyan(" /design [path]") + chalk.dim(" - Clone design from mockups"));
236
+ console.log(chalk.cyan(" /status") + chalk.dim(" - View project progress"));
237
+ console.log(chalk.cyan(" /commands") + chalk.dim(" - List all commands\n"));
238
+ } else {
239
+ console.log(chalk.green(`\u2713 ${greeting} ready to build!
201
240
  `));
202
- console.log(chalk.bold("4 Commands to Know:\n"));
203
- console.log(chalk.cyan(" /build [idea]"));
204
- console.log(chalk.dim(" Start a new project. AI asks questions, plans everything,"));
205
- console.log(chalk.dim(" then builds phase by phase with tests.\n"));
206
- console.log(chalk.cyan(" /feature [idea]"));
207
- console.log(chalk.dim(" Add to an existing project. AI analyzes your codebase"));
208
- console.log(chalk.dim(" and integrates the new feature properly.\n"));
209
- console.log(chalk.cyan(" /status"));
210
- console.log(chalk.dim(" See project progress, what's built, what's next.\n"));
211
- console.log(chalk.cyan(" /audit"));
212
- console.log(chalk.dim(" Review code quality, security, and get a score.\n"));
213
- console.log(chalk.bold("Example:"));
214
- console.log(chalk.white(" /build a project management tool for remote teams\n"));
215
- console.log(chalk.dim("The AI will ask discovery questions, create a PRD, and"));
216
- console.log(chalk.dim("build your app with production patterns + tests.\n"));
241
+ console.log(chalk.bold("6 Commands to Know:\n"));
242
+ console.log(chalk.cyan(" /build [idea]"));
243
+ console.log(chalk.dim(" Start a new project. AI asks questions, plans everything,"));
244
+ console.log(chalk.dim(" then builds phase by phase with tests.\n"));
245
+ console.log(chalk.cyan(" /feature [idea]"));
246
+ console.log(chalk.dim(" Add to an existing project. AI analyzes your codebase"));
247
+ console.log(chalk.dim(" and integrates the new feature properly.\n"));
248
+ console.log(chalk.cyan(" /design [path]"));
249
+ console.log(chalk.dim(" Clone a design pixel-perfect from mockups or websites."));
250
+ console.log(chalk.dim(' Example: /design ./mockups or /design "like Linear"\n'));
251
+ console.log(chalk.cyan(" /status"));
252
+ console.log(chalk.dim(" See project progress, what's built, what's next.\n"));
253
+ console.log(chalk.cyan(" /audit"));
254
+ console.log(chalk.dim(" Review code quality, security, and get a score.\n"));
255
+ console.log(chalk.cyan(" /commands"));
256
+ console.log(chalk.dim(" List all available commands.\n"));
257
+ console.log(chalk.bold("Examples:"));
258
+ console.log(chalk.white(" /build a project management tool for remote teams"));
259
+ console.log(chalk.white(" /design ./mockups\n"));
260
+ console.log(chalk.dim("The AI will ask discovery questions, create a PRD, and"));
261
+ console.log(chalk.dim("build your app with production patterns + tests.\n"));
262
+ }
263
+ checkForUpdates();
217
264
  });
218
265
  }
266
+ async function checkForUpdates() {
267
+ try {
268
+ const versionInfo = await checkCliVersion();
269
+ if (!versionInfo) return;
270
+ const currentParts = CURRENT_VERSION.split(".").map(Number);
271
+ const latestParts = versionInfo.latest.split(".").map(Number);
272
+ let needsUpdate = false;
273
+ for (let i = 0; i < 3; i++) {
274
+ if ((latestParts[i] || 0) > (currentParts[i] || 0)) {
275
+ needsUpdate = true;
276
+ break;
277
+ } else if ((latestParts[i] || 0) < (currentParts[i] || 0)) {
278
+ break;
279
+ }
280
+ }
281
+ if (needsUpdate) {
282
+ console.log(chalk.yellow(`
283
+ \u{1F4E6} Update available: ${CURRENT_VERSION} \u2192 ${versionInfo.latest}`));
284
+ console.log(chalk.dim(` Run: ${versionInfo.updateCommand}
285
+ `));
286
+ }
287
+ } catch {
288
+ }
289
+ }
290
+ function detectExistingProject() {
291
+ const cwd = process.cwd();
292
+ const indicators = [
293
+ "package.json",
294
+ "src",
295
+ "app",
296
+ "pages",
297
+ "components",
298
+ "lib",
299
+ "tsconfig.json",
300
+ "next.config.js",
301
+ "next.config.mjs",
302
+ "vite.config.ts",
303
+ "tailwind.config.js",
304
+ "tailwind.config.ts"
305
+ ];
306
+ let score = 0;
307
+ for (const indicator of indicators) {
308
+ if (existsSync(join(cwd, indicator))) {
309
+ score++;
310
+ }
311
+ }
312
+ return score >= 2;
313
+ }
219
314
  async function configureIDE(ide, force = false) {
220
315
  const config = IDE_CONFIGS[ide];
221
316
  const spinner = ora(`Configuring ${config.description}...`).start();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebakers/cli",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "description": "CodeBakers CLI - AI prompt patterns for production-ready code",
5
5
  "main": "dist/index.js",
6
6
  "bin": {