@yoamigo.com/cli 0.1.9 → 0.1.11
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 +100 -30
- package/package.json +1 -1
- package/templates/starter/package.json +1 -1
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
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
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(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
|
|
292
|
-
|
|
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,48 @@ 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
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
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
|
+
templateId,
|
|
359
|
+
path: relativePath,
|
|
360
|
+
content
|
|
361
|
+
})
|
|
362
|
+
});
|
|
363
|
+
if (!uploadResponse.ok) {
|
|
364
|
+
const errorText = await uploadResponse.text();
|
|
365
|
+
if (verbose) {
|
|
366
|
+
spinner.stop();
|
|
367
|
+
console.error(chalk4.yellow(`Failed to upload ${relativePath}: ${uploadResponse.status}`));
|
|
368
|
+
console.error(chalk4.yellow(`Response: ${errorText}`));
|
|
369
|
+
spinner.start();
|
|
370
|
+
} else {
|
|
371
|
+
console.warn(chalk4.yellow(`Warning: Failed to upload ${relativePath}`));
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
} catch (uploadError) {
|
|
375
|
+
if (verbose) {
|
|
376
|
+
spinner.stop();
|
|
377
|
+
console.error(chalk4.yellow(`Network error uploading ${relativePath}:`));
|
|
378
|
+
console.error(chalk4.yellow(uploadError instanceof Error ? uploadError.message : String(uploadError)));
|
|
379
|
+
spinner.start();
|
|
380
|
+
} else {
|
|
381
|
+
console.warn(chalk4.yellow(`Warning: Failed to upload ${relativePath}`));
|
|
382
|
+
}
|
|
317
383
|
}
|
|
318
384
|
}
|
|
319
385
|
spinner.succeed(`Template v${version} deployed successfully!`);
|
|
@@ -325,7 +391,11 @@ var deployCommand = new Command4("deploy").description("Upload template to YoAmi
|
|
|
325
391
|
console.log(chalk4.dim(` ${APP_BASE_URL}/dashboard`));
|
|
326
392
|
} catch (error) {
|
|
327
393
|
spinner.fail("Failed to deploy template");
|
|
328
|
-
|
|
394
|
+
if (verbose && error instanceof Error && error.stack) {
|
|
395
|
+
console.error(chalk4.red(error.stack));
|
|
396
|
+
} else {
|
|
397
|
+
console.error(chalk4.red(error instanceof Error ? error.message : "Unknown error"));
|
|
398
|
+
}
|
|
329
399
|
process.exit(1);
|
|
330
400
|
}
|
|
331
401
|
});
|
package/package.json
CHANGED