@learnpack/learnpack 5.0.158 → 5.0.162
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/README.md +13 -13
- package/lib/commands/publish.d.ts +4 -2
- package/lib/commands/publish.js +13 -11
- package/lib/commands/serve.js +40 -8
- package/lib/utils/api.d.ts +5 -3
- package/lib/utils/api.js +24 -13
- package/lib/utils/rigoActions.d.ts +4 -0
- package/lib/utils/rigoActions.js +18 -1
- package/oclif.manifest.json +1 -1
- package/package.json +2 -1
- package/src/commands/publish.ts +497 -495
- package/src/commands/serve.ts +57 -8
- package/src/ui/_app/app.css +1 -1
- package/src/ui/_app/app.js +476 -455
- package/src/ui/app.tar.gz +0 -0
- package/src/utils/api.ts +29 -17
- package/src/utils/rigoActions.ts +401 -381
package/src/ui/app.tar.gz
CHANGED
Binary file
|
package/src/utils/api.ts
CHANGED
@@ -425,13 +425,10 @@ type TAssetMissing = {
|
|
425
425
|
category: number
|
426
426
|
owner: number
|
427
427
|
author: number
|
428
|
+
preview: string
|
428
429
|
}
|
429
430
|
|
430
|
-
export const createAsset = async (
|
431
|
-
token: string,
|
432
|
-
academyId: number,
|
433
|
-
asset: TAssetMissing
|
434
|
-
) => {
|
431
|
+
export const createAsset = async (token: string, asset: TAssetMissing) => {
|
435
432
|
const body = {
|
436
433
|
slug: asset.slug,
|
437
434
|
title: asset.title,
|
@@ -439,7 +436,7 @@ export const createAsset = async (
|
|
439
436
|
asset_type: "EXERCISE",
|
440
437
|
visibility: "PUBLIC",
|
441
438
|
status: "DRAFT",
|
442
|
-
url:
|
439
|
+
url: asset.url,
|
443
440
|
readme_url: null,
|
444
441
|
difficulty: null,
|
445
442
|
duration: null,
|
@@ -448,7 +445,7 @@ export const createAsset = async (
|
|
448
445
|
category: asset.category,
|
449
446
|
owner: asset.owner,
|
450
447
|
author: asset.author,
|
451
|
-
preview:
|
448
|
+
preview: asset.preview,
|
452
449
|
description: asset.description,
|
453
450
|
external: false,
|
454
451
|
interactive: true,
|
@@ -458,17 +455,16 @@ export const createAsset = async (
|
|
458
455
|
learnpack_deploy_url: asset.learnpack_deploy_url,
|
459
456
|
technologies: asset.technologies,
|
460
457
|
}
|
461
|
-
const url = `https://breathecode.herokuapp.com/v1/registry/
|
458
|
+
const url = `https://breathecode.herokuapp.com/v1/registry/asset/me`
|
462
459
|
const headers = {
|
463
460
|
Authorization: `Token ${token}`,
|
464
|
-
Academy: academyId,
|
465
461
|
}
|
466
462
|
|
467
463
|
try {
|
468
464
|
const response = await axios.post(url, body, { headers })
|
469
465
|
return response.data
|
470
466
|
} catch (error: any) {
|
471
|
-
|
467
|
+
console.error("Failed to create asset:", error)
|
472
468
|
throw error.response.data
|
473
469
|
}
|
474
470
|
}
|
@@ -478,6 +474,7 @@ export const doesAssetExists = async (
|
|
478
474
|
assetSlug: string
|
479
475
|
): Promise<{ exists: boolean; academyId?: number }> => {
|
480
476
|
const url = `https://breathecode.herokuapp.com/v1/registry/asset/${assetSlug}`
|
477
|
+
|
481
478
|
const headers = {
|
482
479
|
Authorization: `Token ${token}`,
|
483
480
|
}
|
@@ -485,9 +482,7 @@ export const doesAssetExists = async (
|
|
485
482
|
try {
|
486
483
|
const response = await axios.get(url, { headers })
|
487
484
|
if (response.status === 200) {
|
488
|
-
|
489
|
-
const academy = data.academy.id
|
490
|
-
return { exists: true, academyId: academy }
|
485
|
+
return { exists: true }
|
491
486
|
}
|
492
487
|
|
493
488
|
return { exists: false }
|
@@ -499,20 +494,18 @@ export const doesAssetExists = async (
|
|
499
494
|
|
500
495
|
const updateAsset = async (
|
501
496
|
token: string,
|
502
|
-
academyId: number,
|
503
497
|
assetSlug: string,
|
504
498
|
asset: Partial<TAssetMissing>
|
505
499
|
) => {
|
506
|
-
const url = `https://breathecode.herokuapp.com/v1/registry/
|
500
|
+
const url = `https://breathecode.herokuapp.com/v1/registry/asset/me/${assetSlug}`
|
507
501
|
const headers = {
|
508
502
|
Authorization: `Token ${token}`,
|
509
|
-
Academy: academyId,
|
510
503
|
}
|
511
504
|
try {
|
512
505
|
const response = await axios.put(url, asset, { headers })
|
513
506
|
return response.data
|
514
507
|
} catch (error: any) {
|
515
|
-
|
508
|
+
console.error("Failed to update asset:", error)
|
516
509
|
// Try to print the data
|
517
510
|
// console.log(error.response.data)
|
518
511
|
throw error.response.data
|
@@ -533,6 +526,24 @@ const getCategories = async (token: string) => {
|
|
533
526
|
}
|
534
527
|
}
|
535
528
|
|
529
|
+
const updateRigoAssetID = async (
|
530
|
+
token: string,
|
531
|
+
slug: string,
|
532
|
+
asset_id: number
|
533
|
+
) => {
|
534
|
+
const url = `${RIGOBOT_HOST}/v1/learnpack/package/${slug}/`
|
535
|
+
const headers = {
|
536
|
+
Authorization: `Token ${token}`,
|
537
|
+
}
|
538
|
+
try {
|
539
|
+
const response = await axios.put(url, { asset_id }, { headers })
|
540
|
+
return response.data
|
541
|
+
} catch (error) {
|
542
|
+
console.error("Failed to update Rigo package:", error)
|
543
|
+
throw error
|
544
|
+
}
|
545
|
+
}
|
546
|
+
|
536
547
|
export default {
|
537
548
|
login,
|
538
549
|
publish,
|
@@ -548,4 +559,5 @@ export default {
|
|
548
559
|
doesAssetExists,
|
549
560
|
updateAsset,
|
550
561
|
getCategories,
|
562
|
+
updateRigoAssetID,
|
551
563
|
}
|