@learnpack/learnpack 5.0.217 → 5.0.234
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 +31 -26
- package/lib/commands/publish.d.ts +1 -1
- package/lib/commands/publish.js +17 -9
- package/lib/commands/serve.js +64 -30
- package/lib/creatorDist/assets/{index-CZrxF_55.js → index-CFK5bQP2.js} +4705 -4667
- package/lib/creatorDist/index.html +1 -1
- package/lib/utils/api.d.ts +7 -0
- package/lib/utils/api.js +54 -1
- package/package.json +3 -3
- package/src/commands/publish.ts +20 -8
- package/src/commands/serve.ts +73 -29
- package/src/creator/src/App.tsx +53 -9
- package/src/creator/src/components/syllabus/SyllabusEditor.tsx +35 -20
- package/src/creator/src/utils/lib.ts +5 -0
- package/src/creator/src/utils/store.ts +10 -0
- package/src/creatorDist/assets/{index-CZrxF_55.js → index-CFK5bQP2.js} +4705 -4667
- package/src/creatorDist/index.html +1 -1
- package/src/ui/_app/app.js +366 -366
- package/src/ui/app.tar.gz +0 -0
- package/src/utils/api.ts +80 -10
- package/oclif.manifest.json +0 -1
package/src/ui/app.tar.gz
CHANGED
Binary file
|
package/src/utils/api.ts
CHANGED
@@ -2,6 +2,10 @@ import Console from "../utils/console"
|
|
2
2
|
import * as storage from "node-persist"
|
3
3
|
import cli from "cli-ux"
|
4
4
|
import axios from "axios"
|
5
|
+
import * as dotenv from "dotenv"
|
6
|
+
|
7
|
+
dotenv.config()
|
8
|
+
|
5
9
|
const HOST = "https://breathecode.herokuapp.com"
|
6
10
|
export const RIGOBOT_HOST = "https://rigobot.herokuapp.com"
|
7
11
|
// export const RIGOBOT_HOST = "https://rigobot-test-cca7d841c9d8.herokuapp.com"
|
@@ -49,8 +53,7 @@ const fetch = async (
|
|
49
53
|
if (resp.status === 401)
|
50
54
|
Console.debug("Invalid authentication credentials", `Code: 401`)
|
51
55
|
// throw APIError("Invalid authentication credentials", 401)
|
52
|
-
else if (resp.status === 404)
|
53
|
-
throw APIError("Package not found", 404)
|
56
|
+
else if (resp.status === 404) throw APIError("Package not found", 404)
|
54
57
|
else if (resp.status >= 500)
|
55
58
|
throw APIError("Impossible to connect with the server", 500)
|
56
59
|
else if (resp.status >= 400) {
|
@@ -67,8 +70,7 @@ throw APIError("Package not found", 404)
|
|
67
70
|
} else {
|
68
71
|
throw APIError("Uknown error")
|
69
72
|
}
|
70
|
-
} else
|
71
|
-
throw APIError("Uknown error")
|
73
|
+
} else throw APIError("Uknown error")
|
72
74
|
} catch (error) {
|
73
75
|
Console.error((error as TypeError).message)
|
74
76
|
throw error
|
@@ -132,8 +134,7 @@ const publish = async (config: any) => {
|
|
132
134
|
]
|
133
135
|
|
134
136
|
const payload: { [key: string]: string } = {}
|
135
|
-
for (const k of keys)
|
136
|
-
config[k] ? (payload[k] = config[k]) : null
|
137
|
+
for (const k of keys) config[k] ? (payload[k] = config[k]) : null
|
137
138
|
try {
|
138
139
|
console.log("Package to publish:", payload)
|
139
140
|
cli.action.start("Updating package information...")
|
@@ -178,8 +179,7 @@ const getPackage = async (slug: string) => {
|
|
178
179
|
} catch (error) {
|
179
180
|
if ((error as any).status === 404)
|
180
181
|
Console.error(`Package ${slug} does not exist`)
|
181
|
-
else
|
182
|
-
Console.error(`Package ${slug} does not exist`)
|
182
|
+
else Console.error(`Package ${slug} does not exist`)
|
183
183
|
Console.debug(error)
|
184
184
|
throw error
|
185
185
|
}
|
@@ -195,8 +195,7 @@ const getLangs = async () => {
|
|
195
195
|
} catch (error) {
|
196
196
|
if ((error as any).status === 404)
|
197
197
|
Console.error("Package slug does not exist")
|
198
|
-
else
|
199
|
-
Console.error("Package slug does not exist")
|
198
|
+
else Console.error("Package slug does not exist")
|
200
199
|
Console.debug(error)
|
201
200
|
throw error
|
202
201
|
}
|
@@ -559,6 +558,76 @@ const createRigoPackage = async (token: string, slug: string, config: any) => {
|
|
559
558
|
}
|
560
559
|
}
|
561
560
|
|
561
|
+
type TTechnology = {
|
562
|
+
slug: string
|
563
|
+
lang: string
|
564
|
+
}
|
565
|
+
|
566
|
+
let technologiesCache: TTechnology[] = []
|
567
|
+
|
568
|
+
export const fetchTechnologies = async () => {
|
569
|
+
const BREATHECODE_PERMANENT_TOKEN = process.env.BREATHECODE_PERMANENT_TOKEN
|
570
|
+
const LANGS = ["en", "es", "us"]
|
571
|
+
|
572
|
+
if (!BREATHECODE_PERMANENT_TOKEN) {
|
573
|
+
throw new Error(
|
574
|
+
"BREATHECODE_PERMANENT_TOKEN is not defined in environment variables"
|
575
|
+
)
|
576
|
+
}
|
577
|
+
|
578
|
+
const headers = {
|
579
|
+
Authorization: `Token ${BREATHECODE_PERMANENT_TOKEN}`,
|
580
|
+
}
|
581
|
+
|
582
|
+
const results = await Promise.all(
|
583
|
+
LANGS.map(lang =>
|
584
|
+
axios
|
585
|
+
.get(`${HOST}/v1/registry/technology?lang=${lang}`, { headers })
|
586
|
+
.then(res => {
|
587
|
+
return res.data
|
588
|
+
})
|
589
|
+
.then(data =>
|
590
|
+
data.map((item: any) => ({
|
591
|
+
slug: item.slug,
|
592
|
+
lang: lang,
|
593
|
+
}))
|
594
|
+
)
|
595
|
+
)
|
596
|
+
)
|
597
|
+
|
598
|
+
const allItems = results.flat()
|
599
|
+
|
600
|
+
// Remove duplicates by slug+lang combination
|
601
|
+
const unique = []
|
602
|
+
const seen = new Set()
|
603
|
+
for (const item of allItems) {
|
604
|
+
const key = `${item.slug}:${item.lang}`
|
605
|
+
if (!seen.has(key)) {
|
606
|
+
seen.add(key)
|
607
|
+
unique.push(item)
|
608
|
+
}
|
609
|
+
}
|
610
|
+
|
611
|
+
return unique
|
612
|
+
}
|
613
|
+
|
614
|
+
// Function to update the cache and schedule the next update
|
615
|
+
async function updateTechnologiesPeriodically() {
|
616
|
+
try {
|
617
|
+
technologiesCache = await fetchTechnologies()
|
618
|
+
// Uncomment for debugging:
|
619
|
+
// console.log('Technologies list updated:', technologiesCache);
|
620
|
+
} catch (error: any) {
|
621
|
+
console.error("Error updating technologies list:", error)
|
622
|
+
} finally {
|
623
|
+
setTimeout(updateTechnologiesPeriodically, 24 * 60 * 60 * 1000)
|
624
|
+
}
|
625
|
+
}
|
626
|
+
|
627
|
+
updateTechnologiesPeriodically()
|
628
|
+
|
629
|
+
export const getCurrentTechnologies = () => technologiesCache
|
630
|
+
|
562
631
|
export default {
|
563
632
|
login,
|
564
633
|
publish,
|
@@ -576,4 +645,5 @@ export default {
|
|
576
645
|
getCategories,
|
577
646
|
updateRigoAssetID,
|
578
647
|
createRigoPackage,
|
648
|
+
getCurrentTechnologies,
|
579
649
|
}
|
package/oclif.manifest.json
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":"5.0.217","commands":{"audit":{"id":"audit","description":"learnpack audit is the command in charge of creating an auditory of the repository\n...\nlearnpack audit checks for the following information in a repository:\n 1. The configuration object has slug, repository and description. (Error)\n 2. The command learnpack clean has been run. (Error)\n 3. If a markdown or test file doesn't have any content. (Error)\n 4. The links are accessing to valid servers. (Error)\n 5. The relative images are working (If they have the shortest path to the image or if the images exists in the assets). (Error)\n 6. The external images are working (If they are pointing to a valid server). (Error)\n 7. The exercises directory names are valid. (Error)\n 8. If an exercise doesn't have a README file. (Error)\n 9. The exercises array (Of the config file) has content. (Error)\n 10. The exercses have the same translations. (Warning)\n 11. The .gitignore file exists. (Warning)\n 12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)\n","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"strict":{"name":"strict","type":"boolean","char":"s","description":"strict mode","allowNo":false}},"args":[]},"breakToken":{"id":"breakToken","description":"Break the token","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"grading":{"name":"grading","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"clean":{"id":"clean","description":"Clean the configuration object\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[]},"download":{"id":"download","description":"Describe the command here\n...\nExtra documentation goes here\n","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"init":{"id":"init","description":"Create a new learning package: Book, Tutorial or Exercise","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"grading":{"name":"grading","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"login":{"id":"login","description":"Describe the command here\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"logout":{"id":"logout","description":"Describe the command here\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"publish":{"id":"publish","description":"Builds the project by copying necessary files and directories into a zip file","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"strict":{"name":"strict","type":"boolean","char":"s","description":"strict mode","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"serve":{"id":"serve","description":"Runs a small server to build tutorials","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"server port"},"host":{"name":"host","type":"option","char":"h","description":"server host"},"debug":{"name":"debug","type":"boolean","char":"d","description":"debugger mode for more verbage","allowNo":false}},"args":[]},"start":{"id":"start","description":"Runs a small server with all the exercise instructions","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"server port"},"host":{"name":"host","type":"option","char":"h","description":"server host"},"disableGrading":{"name":"disableGrading","type":"boolean","char":"D","description":"disble grading functionality","allowNo":false},"watch":{"name":"watch","type":"boolean","char":"w","description":"Watch for file changes","allowNo":false},"editor":{"name":"editor","type":"option","char":"e","description":"[preview, extension]","options":["extension","preview"]},"version":{"name":"version","type":"option","char":"v","description":"E.g: 1.0.1"},"grading":{"name":"grading","type":"option","char":"g","description":"[isolated, incremental]","options":["isolated","incremental"]},"debug":{"name":"debug","type":"boolean","char":"d","description":"debugger mode for more verbage","allowNo":false}},"args":[]},"test":{"id":"test","description":"Test exercises","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[{"name":"exerciseSlug","description":"The name of the exercise to test","required":false,"hidden":false}]},"translate":{"id":"translate","description":"List all the lessons, the user is able of select many of them to translate to the given languages","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[]}}}
|