@yoamigo.com/cli 0.1.9 → 0.1.12

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
@@ -249,7 +249,13 @@ import path4 from "path";
249
249
  var API_BASE_URL2 = getApiBaseUrl();
250
250
  var APP_BASE_URL = getAppBaseUrl();
251
251
  var EXCLUDE_PATTERNS = ["node_modules", "dist", ".git", "vite.config.ts", "tsconfig.json", "*.log"];
252
- var deployCommand = new Command4("deploy").description("Upload template to YoAmigo").argument("<version>", "Template version (e.g., 1.0.0)").action(async (version) => {
252
+ var deployCommand = new Command4("deploy").description("Upload template to YoAmigo").argument("<version>", "Template version (e.g., 1.0.0)").option("-v, --verbose", "Show detailed logging for debugging").action(async (version, options) => {
253
+ const verbose = options.verbose;
254
+ if (verbose) {
255
+ console.log(chalk4.dim(`API URL: ${API_BASE_URL2}`));
256
+ console.log(chalk4.dim(`App URL: ${APP_BASE_URL}`));
257
+ console.log();
258
+ }
253
259
  const credentials = await getCredentials();
254
260
  if (!credentials) {
255
261
  console.error(chalk4.red("Error: Not logged in. Run `yoamigo login` first."));
@@ -275,21 +281,56 @@ var deployCommand = new Command4("deploy").description("Upload template to YoAmi
275
281
  throw new Error("No files found to upload");
276
282
  }
277
283
  spinner.text = `Uploading ${files.length} files...`;
278
- const templateResponse = await fetch(`${API_BASE_URL2}/api/trpc/developer.createOrUpdateTemplate`, {
279
- method: "POST",
280
- headers: {
281
- "Content-Type": "application/json",
282
- "X-API-Key": credentials.apiKey
283
- },
284
- body: JSON.stringify({
285
- name: templateName,
286
- version,
287
- description: packageJson.description || ""
288
- })
289
- });
284
+ const templateUrl = `${API_BASE_URL2}/api/trpc/developer.createOrUpdateTemplate`;
285
+ const templateBody = {
286
+ name: templateName,
287
+ version,
288
+ description: packageJson.description || ""
289
+ };
290
+ if (verbose) {
291
+ spinner.stop();
292
+ console.log(chalk4.dim(`POST ${templateUrl}`));
293
+ console.log(chalk4.dim(`Body: ${JSON.stringify(templateBody)}`));
294
+ spinner.start();
295
+ }
296
+ let templateResponse;
297
+ try {
298
+ templateResponse = await fetch(templateUrl, {
299
+ method: "POST",
300
+ headers: {
301
+ "Content-Type": "application/json",
302
+ "X-API-Key": credentials.apiKey
303
+ },
304
+ body: JSON.stringify({ json: templateBody })
305
+ });
306
+ } catch (fetchError) {
307
+ if (verbose) {
308
+ spinner.stop();
309
+ console.error(chalk4.red(`
310
+ Fetch error for ${templateUrl}:`));
311
+ console.error(chalk4.red(fetchError instanceof Error ? fetchError.stack || fetchError.message : String(fetchError)));
312
+ }
313
+ throw new Error(`Network error: ${fetchError instanceof Error ? fetchError.message : "fetch failed"}`);
314
+ }
315
+ if (verbose) {
316
+ spinner.stop();
317
+ console.log(chalk4.dim(`Response status: ${templateResponse.status}`));
318
+ spinner.start();
319
+ }
290
320
  if (!templateResponse.ok) {
291
- const error = await templateResponse.json();
292
- const errorMessage = error.error?.message || error.message || "Failed to create template";
321
+ const errorText = await templateResponse.text();
322
+ if (verbose) {
323
+ spinner.stop();
324
+ console.error(chalk4.red(`
325
+ Response body: ${errorText}`));
326
+ }
327
+ let errorMessage = "Failed to create template";
328
+ try {
329
+ const error = JSON.parse(errorText);
330
+ errorMessage = error.error?.message || error.message || errorMessage;
331
+ } catch {
332
+ errorMessage = errorText || errorMessage;
333
+ }
293
334
  throw new Error(errorMessage);
294
335
  }
295
336
  const templateData = await templateResponse.json();
@@ -297,23 +338,50 @@ var deployCommand = new Command4("deploy").description("Upload template to YoAmi
297
338
  if (!templateId) {
298
339
  throw new Error("Failed to get template ID");
299
340
  }
341
+ const uploadUrl = `${API_BASE_URL2}/api/trpc/developer.uploadTemplateFile`;
300
342
  for (const file of files) {
301
343
  const relativePath = path4.relative(process.cwd(), file);
302
344
  const content = await fs4.readFile(file, "utf-8");
303
- const uploadResponse = await fetch(`${API_BASE_URL2}/api/trpc/developer.uploadTemplateFile`, {
304
- method: "POST",
305
- headers: {
306
- "Content-Type": "application/json",
307
- "X-API-Key": credentials.apiKey
308
- },
309
- body: JSON.stringify({
310
- templateId,
311
- path: relativePath,
312
- content
313
- })
314
- });
315
- if (!uploadResponse.ok) {
316
- console.warn(chalk4.yellow(`Warning: Failed to upload ${relativePath}`));
345
+ if (verbose) {
346
+ spinner.stop();
347
+ console.log(chalk4.dim(`Uploading: ${relativePath}`));
348
+ spinner.start();
349
+ }
350
+ try {
351
+ const uploadResponse = await fetch(uploadUrl, {
352
+ method: "POST",
353
+ headers: {
354
+ "Content-Type": "application/json",
355
+ "X-API-Key": credentials.apiKey
356
+ },
357
+ body: JSON.stringify({
358
+ json: {
359
+ templateId,
360
+ path: relativePath,
361
+ content
362
+ }
363
+ })
364
+ });
365
+ if (!uploadResponse.ok) {
366
+ const errorText = await uploadResponse.text();
367
+ if (verbose) {
368
+ spinner.stop();
369
+ console.error(chalk4.yellow(`Failed to upload ${relativePath}: ${uploadResponse.status}`));
370
+ console.error(chalk4.yellow(`Response: ${errorText}`));
371
+ spinner.start();
372
+ } else {
373
+ console.warn(chalk4.yellow(`Warning: Failed to upload ${relativePath}`));
374
+ }
375
+ }
376
+ } catch (uploadError) {
377
+ if (verbose) {
378
+ spinner.stop();
379
+ console.error(chalk4.yellow(`Network error uploading ${relativePath}:`));
380
+ console.error(chalk4.yellow(uploadError instanceof Error ? uploadError.message : String(uploadError)));
381
+ spinner.start();
382
+ } else {
383
+ console.warn(chalk4.yellow(`Warning: Failed to upload ${relativePath}`));
384
+ }
317
385
  }
318
386
  }
319
387
  spinner.succeed(`Template v${version} deployed successfully!`);
@@ -325,7 +393,11 @@ var deployCommand = new Command4("deploy").description("Upload template to YoAmi
325
393
  console.log(chalk4.dim(` ${APP_BASE_URL}/dashboard`));
326
394
  } catch (error) {
327
395
  spinner.fail("Failed to deploy template");
328
- console.error(chalk4.red(error instanceof Error ? error.message : "Unknown error"));
396
+ if (verbose && error instanceof Error && error.stack) {
397
+ console.error(chalk4.red(error.stack));
398
+ } else {
399
+ console.error(chalk4.red(error instanceof Error ? error.message : "Unknown error"));
400
+ }
329
401
  process.exit(1);
330
402
  }
331
403
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoamigo.com/cli",
3
- "version": "0.1.9",
3
+ "version": "0.1.12",
4
4
  "description": "CLI for creating and managing YoAmigo templates",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -9,7 +9,7 @@
9
9
  "preview": "vite preview"
10
10
  },
11
11
  "dependencies": {
12
- "@yoamigo.com/core": "^0.1.1",
12
+ "@yoamigo.com/core": "^0.1.2",
13
13
  "react": "^19.2.1",
14
14
  "react-dom": "^19.2.1"
15
15
  },