@hapico/cli 0.0.26 → 0.0.28

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/bin/index.js CHANGED
@@ -55,6 +55,7 @@ const child_process_1 = require("child_process");
55
55
  const util_1 = require("util");
56
56
  const chalk_1 = __importDefault(require("chalk"));
57
57
  const pako_1 = __importDefault(require("pako"));
58
+ const vibe_1 = require("./tools/vibe");
58
59
  // Promisify exec for async usage
59
60
  const execPromise = (0, util_1.promisify)(child_process_1.exec);
60
61
  // Directory to store the token and project config
@@ -209,8 +210,19 @@ class FileManager {
209
210
  return files;
210
211
  }
211
212
  writeFile(file) {
213
+ if (!file.path || file.path.trim() === "")
214
+ return;
212
215
  try {
213
216
  const fullPath = path.join(this.basePath, file.path);
217
+ if (fs.existsSync(fullPath)) {
218
+ try {
219
+ if (fs.statSync(fullPath).isDirectory())
220
+ return;
221
+ }
222
+ catch (e) {
223
+ // ignore
224
+ }
225
+ }
214
226
  const dir = path.dirname(fullPath);
215
227
  fs.mkdirSync(dir, { recursive: true });
216
228
  let hasChanged = true;
@@ -222,6 +234,8 @@ class FileManager {
222
234
  hasChanged = existingContent !== file.content;
223
235
  }
224
236
  catch (readError) {
237
+ if (readError.code === "EISDIR")
238
+ return;
225
239
  console.warn(chalk_1.default.yellow(`Warning: Could not read existing file ${fullPath}, treating as changed:`), readError);
226
240
  hasChanged = true;
227
241
  }
@@ -231,6 +245,8 @@ class FileManager {
231
245
  }
232
246
  }
233
247
  catch (error) {
248
+ if (error.code === "EISDIR")
249
+ return;
234
250
  console.error(chalk_1.default.red(`Error processing file ${file.path}:`), error);
235
251
  throw error;
236
252
  }
@@ -395,7 +411,7 @@ class RoomState {
395
411
  return this.isConnected;
396
412
  }
397
413
  }
398
- commander_1.program.version("0.0.26").description("Hapico CLI for project management");
414
+ commander_1.program.version("0.0.28").description("Hapico CLI for project management");
399
415
  commander_1.program
400
416
  .command("clone <id>")
401
417
  .description("Clone a project by ID")
@@ -483,6 +499,13 @@ commander_1.program
483
499
  apiSpinner.fail(chalk_1.default.red(`Error cloning project: ${error.message}`));
484
500
  }
485
501
  });
502
+ commander_1.program
503
+ .command("vibe")
504
+ .description("Refactor code using AI")
505
+ .action(async () => {
506
+ const targetPath = process.cwd();
507
+ await (0, vibe_1.vibe)(targetPath);
508
+ });
486
509
  commander_1.program
487
510
  .command("dev")
488
511
  .description("Start the project in development mode")
@@ -571,6 +594,10 @@ commander_1.program
571
594
  room.connect(async () => {
572
595
  devSpinner.succeed(chalk_1.default.green("Project started in development mode!"));
573
596
  room.updateState("view", filteredFiles);
597
+ // Debounce the state update to avoid overwhelming the server while typing/saving
598
+ const debouncedUpdate = (0, lodash_1.debounce)((updatedFiles) => {
599
+ room.updateState("view", updatedFiles);
600
+ }, 200);
574
601
  fileManager.setOnFileChange((filePath, content) => {
575
602
  var _a;
576
603
  const es5 = (_a = (0, exports.compileES5)(content, filePath)) !== null && _a !== void 0 ? _a : "";
@@ -582,7 +609,7 @@ commander_1.program
582
609
  return file;
583
610
  });
584
611
  room.files = updatedFiles;
585
- room.updateState("view", updatedFiles);
612
+ debouncedUpdate(updatedFiles);
586
613
  });
587
614
  // Fetch project info
588
615
  const store = getStoredProjectId(pwd);
@@ -603,8 +630,7 @@ commander_1.program
603
630
  const projectType = project.data.type || "view";
604
631
  const zversion = options.zversion;
605
632
  if (projectType === "expo_app" || projectType === "emg_edu_lesson") {
606
- const BASE_EXPO_LINK = `exp://u.expo.dev/e362c6df-abe8-4503-8723-1362f015d167/group/3ac94fc0-92b1-445e-8d88-9b2f6a4b869a`;
607
- //exp://u.expo.dev/e362c6df-abe8-4503-8723-1362f015d167/group/8cd11ab9-b6db-4924-9f7a-5e449f027bba?sessionKey=eyJpZCI6IjU1NF8xIiwidmlld0lkIjo1NTR9&mode=development
633
+ const BASE_EXPO_LINK = `exp://u.expo.dev/e362c6df-abe8-4503-8723-1362f015d167/group/e5d6b96e-3c78-485a-a170-1d8aa8b2c47e`;
608
634
  const link = `${BASE_EXPO_LINK}?sessionKey=${projectId}&mode=development`;
609
635
  qrcode_terminal_1.default.generate(link, { small: true }, (qrcode) => {
610
636
  console.log(chalk_1.default.cyan("📱 Scan this QR code with Expo Go to connect to the project:"));