@learnpack/learnpack 5.0.53 → 5.0.57

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.
Files changed (60) hide show
  1. package/README.md +30 -12
  2. package/lib/commands/publish.js +29 -7
  3. package/lib/commands/serve.d.ts +7 -0
  4. package/lib/commands/serve.js +149 -0
  5. package/lib/managers/server/routes.js +2 -0
  6. package/lib/utils/api.d.ts +4 -0
  7. package/lib/utils/api.js +21 -4
  8. package/lib/utils/cloudStorage.d.ts +8 -0
  9. package/lib/utils/cloudStorage.js +17 -0
  10. package/oclif.manifest.json +1 -1
  11. package/package.json +3 -1
  12. package/src/commands/publish.ts +68 -12
  13. package/src/commands/serve.ts +192 -0
  14. package/src/creator/README.md +54 -0
  15. package/src/creator/eslint.config.js +28 -0
  16. package/src/creator/index.html +13 -0
  17. package/src/creator/package-lock.json +4659 -0
  18. package/src/creator/package.json +41 -0
  19. package/src/creator/public/vite.svg +1 -0
  20. package/src/creator/src/App.css +42 -0
  21. package/src/creator/src/App.tsx +221 -0
  22. package/src/creator/src/assets/react.svg +1 -0
  23. package/src/creator/src/assets/svgs.tsx +88 -0
  24. package/src/creator/src/components/Loader.tsx +28 -0
  25. package/src/creator/src/components/Login.tsx +263 -0
  26. package/src/creator/src/components/SelectableCard.tsx +30 -0
  27. package/src/creator/src/components/StepWizard.tsx +77 -0
  28. package/src/creator/src/components/SyllabusEditor.tsx +431 -0
  29. package/src/creator/src/index.css +68 -0
  30. package/src/creator/src/main.tsx +19 -0
  31. package/src/creator/src/utils/configTypes.ts +122 -0
  32. package/src/creator/src/utils/constants.ts +2 -0
  33. package/src/creator/src/utils/lib.ts +36 -0
  34. package/src/creator/src/utils/rigo.ts +391 -0
  35. package/src/creator/src/utils/store.ts +78 -0
  36. package/src/creator/src/vite-env.d.ts +1 -0
  37. package/src/creator/tsconfig.app.json +26 -0
  38. package/src/creator/tsconfig.json +7 -0
  39. package/src/creator/tsconfig.node.json +24 -0
  40. package/src/creator/vite.config.ts +13 -0
  41. package/src/creatorDist/assets/index-D92OoEoU.js +23719 -0
  42. package/src/creatorDist/assets/index-tt9JBVY0.css +987 -0
  43. package/src/creatorDist/index.html +14 -0
  44. package/src/creatorDist/vite.svg +1 -0
  45. package/src/managers/server/routes.ts +3 -0
  46. package/src/ui/_app/app.css +1 -0
  47. package/src/ui/_app/app.js +3025 -0
  48. package/src/ui/_app/favicon.ico +0 -0
  49. package/src/ui/_app/index.html +109 -0
  50. package/src/ui/_app/index.html.backup +91 -0
  51. package/src/ui/_app/learnpack.svg +7 -0
  52. package/src/ui/_app/logo-192.png +0 -0
  53. package/src/ui/_app/logo-512.png +0 -0
  54. package/src/ui/_app/logo.png +0 -0
  55. package/src/ui/_app/manifest.webmanifest +21 -0
  56. package/src/ui/_app/sw.js +30 -0
  57. package/src/ui/app.tar.gz +0 -0
  58. package/src/utils/api.ts +24 -4
  59. package/src/utils/cloudStorage.ts +24 -0
  60. package/src/utils/creds.json +13 -0
package/README.md CHANGED
@@ -21,7 +21,7 @@ $ npm install -g @learnpack/learnpack
21
21
  $ learnpack COMMAND
22
22
  running command...
23
23
  $ learnpack (-v|--version|version)
24
- @learnpack/learnpack/5.0.53 win32-x64 node-v22.14.0
24
+ @learnpack/learnpack/5.0.57 win32-x64 node-v22.14.0
25
25
  $ learnpack --help [COMMAND]
26
26
  USAGE
27
27
  $ learnpack COMMAND
@@ -46,6 +46,7 @@ USAGE
46
46
  * [`learnpack plugins:uninstall PLUGIN...`](#learnpack-pluginsuninstall-plugin)
47
47
  * [`learnpack plugins:update`](#learnpack-pluginsupdate)
48
48
  * [`learnpack publish`](#learnpack-publish)
49
+ * [`learnpack serve`](#learnpack-serve)
49
50
  * [`learnpack start`](#learnpack-start)
50
51
  * [`learnpack test [EXERCISESLUG]`](#learnpack-test-exerciseslug)
51
52
  * [`learnpack translate`](#learnpack-translate)
@@ -79,7 +80,7 @@ DESCRIPTION
79
80
  12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)
80
81
  ```
81
82
 
82
- _See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.53/src\commands\audit.ts)_
83
+ _See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.57/src\commands\audit.ts)_
83
84
 
84
85
  ## `learnpack breakToken`
85
86
 
@@ -94,7 +95,7 @@ OPTIONS
94
95
  -y, --yes Skip all prompts and initialize an empty project
95
96
  ```
96
97
 
97
- _See code: [src\commands\breakToken.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.53/src\commands\breakToken.ts)_
98
+ _See code: [src\commands\breakToken.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.57/src\commands\breakToken.ts)_
98
99
 
99
100
  ## `learnpack clean`
100
101
 
@@ -109,7 +110,7 @@ DESCRIPTION
109
110
  Extra documentation goes here
110
111
  ```
111
112
 
112
- _See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.53/src\commands\clean.ts)_
113
+ _See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.57/src\commands\clean.ts)_
113
114
 
114
115
  ## `learnpack download [PACKAGE]`
115
116
 
@@ -127,7 +128,7 @@ DESCRIPTION
127
128
  Extra documentation goes here
128
129
  ```
129
130
 
130
- _See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.53/src\commands\download.ts)_
131
+ _See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.57/src\commands\download.ts)_
131
132
 
132
133
  ## `learnpack help [COMMAND]`
133
134
 
@@ -159,7 +160,7 @@ OPTIONS
159
160
  -y, --yes Skip all prompts and initialize an empty project
160
161
  ```
161
162
 
162
- _See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.53/src\commands\init.ts)_
163
+ _See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.57/src\commands\init.ts)_
163
164
 
164
165
  ## `learnpack login [PACKAGE]`
165
166
 
@@ -177,7 +178,7 @@ DESCRIPTION
177
178
  Extra documentation goes here
178
179
  ```
179
180
 
180
- _See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.53/src\commands\login.ts)_
181
+ _See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.57/src\commands\login.ts)_
181
182
 
182
183
  ## `learnpack logout [PACKAGE]`
183
184
 
@@ -195,7 +196,7 @@ DESCRIPTION
195
196
  Extra documentation goes here
196
197
  ```
197
198
 
198
- _See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.53/src\commands\logout.ts)_
199
+ _See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.57/src\commands\logout.ts)_
199
200
 
200
201
  ## `learnpack plugins`
201
202
 
@@ -327,7 +328,24 @@ OPTIONS
327
328
  -s, --strict strict mode
328
329
  ```
329
330
 
330
- _See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.53/src\commands\publish.ts)_
331
+ _See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.57/src\commands\publish.ts)_
332
+
333
+ ## `learnpack serve`
334
+
335
+ Runs a small server to build tutorials
336
+
337
+ ```
338
+ USAGE
339
+ $ learnpack serve
340
+
341
+ OPTIONS
342
+ -d, --debug debugger mode for more verbage
343
+ -h, --host=host server host
344
+ -p, --port=port server port
345
+ -y, --yes Skip all prompts and initialize an empty project
346
+ ```
347
+
348
+ _See code: [src\commands\serve.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.57/src\commands\serve.ts)_
331
349
 
332
350
  ## `learnpack start`
333
351
 
@@ -349,7 +367,7 @@ OPTIONS
349
367
  -y, --yes Skip all prompts and initialize an empty project
350
368
  ```
351
369
 
352
- _See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.53/src\commands\start.ts)_
370
+ _See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.57/src\commands\start.ts)_
353
371
 
354
372
  ## `learnpack test [EXERCISESLUG]`
355
373
 
@@ -366,7 +384,7 @@ OPTIONS
366
384
  -y, --yes Skip all prompts and initialize an empty project
367
385
  ```
368
386
 
369
- _See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.53/src\commands\test.ts)_
387
+ _See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.57/src\commands\test.ts)_
370
388
 
371
389
  ## `learnpack translate`
372
390
 
@@ -380,7 +398,7 @@ OPTIONS
380
398
  -y, --yes Skip all prompts and initialize an empty project
381
399
  ```
382
400
 
383
- _See code: [src\commands\translate.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.53/src\commands\translate.ts)_
401
+ _See code: [src\commands\translate.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.57/src\commands\translate.ts)_
384
402
  <!-- commandsstop -->
385
403
 
386
404
  > > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
@@ -18,7 +18,7 @@ const prompts = require("prompts");
18
18
  const rigoActions_1 = require("../utils/rigoActions");
19
19
  const misc_1 = require("../utils/misc");
20
20
  const uploadZipEndpont = api_1.RIGOBOT_HOST + "/v1/learnpack/upload";
21
- const handleAssetCreation = async (sessionPayload, academy, learnJson, learnpackDeployUrl) => {
21
+ const handleAssetCreation = async (sessionPayload, academy, learnJson, learnpackDeployUrl, category) => {
22
22
  try {
23
23
  const { exists, academyId } = await api_1.default.doesAssetExists(sessionPayload.token, learnJson.slug);
24
24
  if (!exists) {
@@ -31,6 +31,9 @@ const handleAssetCreation = async (sessionPayload, academy, learnJson, learnpack
31
31
  learnpack_deploy_url: learnpackDeployUrl,
32
32
  technologies: ["node", "bash"],
33
33
  url: "https://4geeksacademy.com",
34
+ category: category,
35
+ owner: sessionPayload.id,
36
+ author: sessionPayload.id,
34
37
  });
35
38
  console_1.default.info("Asset created with id", asset.id);
36
39
  }
@@ -70,12 +73,15 @@ const runAudit = (strict) => {
70
73
  // Continuar con el proceso de build solo si `learnpack publish` fue exitoso
71
74
  console_1.default.info("Learnpack publish completed successfully. Proceeding with build...");
72
75
  };
73
- const selectAcademy = async (academies) => {
76
+ function getCategoriesByAcademy(categories, academy) {
77
+ return categories.filter((cat) => cat.academy.id === academy.id);
78
+ }
79
+ const selectAcademy = async (academies, bcToken) => {
74
80
  if (academies.length === 0) {
75
- return null;
81
+ return { academy: null, category: 0 };
76
82
  }
77
83
  if (academies.length === 1) {
78
- return academies[0];
84
+ return { academy: academies[0], category: 0 };
79
85
  }
80
86
  // prompts the user to select an academy to upload the assets
81
87
  console_1.default.info("In which academy do you want to publish the asset?");
@@ -88,7 +94,21 @@ const selectAcademy = async (academies) => {
88
94
  value: academy,
89
95
  })),
90
96
  });
91
- return response.academy;
97
+ const categories = await api_1.default.getCategories(bcToken);
98
+ const categoriesByAcademy = getCategoriesByAcademy(categories, response.academy);
99
+ const categoriesPrompt = await prompts({
100
+ type: "select",
101
+ name: "category",
102
+ message: "Select a category",
103
+ choices: categoriesByAcademy.map((category) => ({
104
+ title: category.title,
105
+ value: category.id,
106
+ })),
107
+ });
108
+ return {
109
+ academy: response.academy,
110
+ category: categoriesPrompt.category,
111
+ };
92
112
  };
93
113
  class BuildCommand extends SessionCommand_1.default {
94
114
  async init() {
@@ -137,7 +157,7 @@ class BuildCommand extends SessionCommand_1.default {
137
157
  }
138
158
  const academies = await api_1.default.listUserAcademies(sessionPayload.token);
139
159
  // // console.log(academies, "academies")
140
- const academy = await selectAcademy(academies);
160
+ const { academy, category } = await selectAcademy(academies, sessionPayload.token);
141
161
  // Read learn.json to get the slug
142
162
  const learnJsonPath = path.join(process.cwd(), "learn.json");
143
163
  if (!fs.existsSync(learnJsonPath)) {
@@ -258,7 +278,9 @@ class BuildCommand extends SessionCommand_1.default {
258
278
  console.log(res.data);
259
279
  fs.unlinkSync(zipFilePath);
260
280
  this.removeDirectory(buildDir);
261
- await handleAssetCreation(sessionPayload, academy, learnJson, res.data.url);
281
+ if (academy) {
282
+ await handleAssetCreation(sessionPayload, academy, learnJson, res.data.url, category);
283
+ }
262
284
  }
263
285
  catch (error) {
264
286
  if (axios_1.default.isAxiosError(error)) {
@@ -0,0 +1,7 @@
1
+ import SessionCommand from "../utils/SessionCommand";
2
+ export default class ServeCommand extends SessionCommand {
3
+ static description: string;
4
+ static flags: any;
5
+ init(): Promise<void>;
6
+ run(): Promise<void>;
7
+ }
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const command_1 = require("@oclif/command");
4
+ const express = require("express");
5
+ const cors = require("cors");
6
+ const path = require("path");
7
+ const SessionCommand_1 = require("../utils/SessionCommand");
8
+ const storage_1 = require("@google-cloud/storage");
9
+ const file_1 = require("../managers/file");
10
+ const fs = require("fs");
11
+ const frontMatter = require("front-matter");
12
+ function getSlugFromPath(path) {
13
+ const parts = path.split("/").filter(Boolean);
14
+ if (parts.length < 2)
15
+ return null;
16
+ return parts[parts.length - 2];
17
+ }
18
+ const bucketStorage = new storage_1.Storage({
19
+ keyFilename: path.resolve(__dirname, "../utils/creds.json"),
20
+ });
21
+ const bucket = bucketStorage.bucket("learnpack");
22
+ async function listFilesWithPrefix(prefix) {
23
+ const [files] = await bucket.getFiles({ prefix });
24
+ return files;
25
+ }
26
+ class ServeCommand extends SessionCommand_1.default {
27
+ async init() {
28
+ const { flags } = this.parse(ServeCommand);
29
+ console.log("Initializing serve command");
30
+ }
31
+ async run() {
32
+ const app = express();
33
+ const PORT = 3000;
34
+ const distPath = path.resolve(__dirname, "../creatorDist");
35
+ // Servir archivos estáticos
36
+ // app.use(express.static(distPath))
37
+ app.use(express.json());
38
+ app.use(cors());
39
+ const appPath = path.resolve(__dirname, "../ui/_app");
40
+ const tarPath = path.resolve(__dirname, "../ui/app.tar.gz");
41
+ if (fs.existsSync(appPath)) {
42
+ fs.rmSync(appPath, { recursive: true });
43
+ }
44
+ if (fs.existsSync(tarPath)) {
45
+ fs.rmSync(tarPath);
46
+ }
47
+ await (0, file_1.downloadEditor)("5.0.0", `${__dirname}/../ui/app.tar.gz`);
48
+ await (0, file_1.decompress)(`${__dirname}/../ui/app.tar.gz`, `${__dirname}/../ui/_app/`);
49
+ const localAppPath = path.resolve(__dirname, "../ui/_app");
50
+ // app.use(express.static(localAppPath))
51
+ app.post("/upload", async (req, res) => {
52
+ const { content, destination } = req.body;
53
+ // console.log("UPLOAD", content, destination)
54
+ if (!content || !destination) {
55
+ return res.status(400).send("Missing content or destination");
56
+ }
57
+ if (!bucket) {
58
+ return res.status(500).send("Upload failed");
59
+ }
60
+ const buffer = Buffer.from(content, "utf-8");
61
+ const file = bucket.file(destination);
62
+ const stream = file.createWriteStream({
63
+ resumable: false,
64
+ contentType: "text/plain",
65
+ });
66
+ stream.on("error", err => {
67
+ console.error("❌ Error uploading:", err);
68
+ res.status(500).send("Upload failed");
69
+ });
70
+ stream.on("finish", () => {
71
+ console.log(`✅ Uploaded to: ${file.name}`);
72
+ res.send("File uploaded successfully");
73
+ });
74
+ stream.end(buffer);
75
+ });
76
+ app.get("/", async (req, res) => {
77
+ // The the ui/_app/index.html
78
+ console.log("GET /");
79
+ const file = path.resolve(__dirname, "../ui/_app/index.html");
80
+ res.sendFile(file);
81
+ });
82
+ app.get("/config", async (req, res) => {
83
+ console.log("GET /config");
84
+ console.log(req.query.slug, "QUERY");
85
+ const files = await listFilesWithPrefix("courses/" + req.query.slug);
86
+ const learnJson = files.find(file => file.name.endsWith("learn.json"));
87
+ const learnJsonContent = await (learnJson === null || learnJson === void 0 ? void 0 : learnJson.download());
88
+ const learnJsonParsed = JSON.parse((learnJsonContent === null || learnJsonContent === void 0 ? void 0 : learnJsonContent.toString()) || "{}");
89
+ const allExercises = files.filter(file => file.name.includes("exercises/"));
90
+ const exercises = allExercises.map(exercise => {
91
+ const slug = getSlugFromPath(exercise.name);
92
+ return {
93
+ title: slug,
94
+ slug,
95
+ graded: false,
96
+ };
97
+ });
98
+ // console.log(learnJsonParsed, "LEARN JSON PARSED")
99
+ res.send({
100
+ config: Object.assign({}, learnJsonParsed),
101
+ exercises,
102
+ });
103
+ });
104
+ app.get("/exercise/:slug/readme", async (req, res) => {
105
+ console.log("GET /exercise/:slug/readme");
106
+ const { slug } = req.params;
107
+ const query = req.query;
108
+ console.log(query, "QUERY");
109
+ const courseSlug = query.slug;
110
+ const file = await bucket.file("courses/" + courseSlug + "/exercises/" + slug + "/README.md");
111
+ const content = await file.download();
112
+ const { attributes, body } = frontMatter(content[0].toString());
113
+ res.send({
114
+ attributes,
115
+ body,
116
+ });
117
+ });
118
+ app.get("/assets/:file", (req, res) => {
119
+ const file = path.join(localAppPath, req.params.file);
120
+ res.sendFile(file);
121
+ });
122
+ // Enviar index.html para todas las rutas
123
+ app.get("/creator", (req, res) => {
124
+ res.sendFile(path.join(distPath, "index.html"));
125
+ });
126
+ app.get("/creator/syllabus", (req, res) => {
127
+ res.sendFile(path.join(distPath, "index.html"));
128
+ });
129
+ app.get("/creator/:file", (req, res) => {
130
+ console.log("GET /creator/:file", req.params.file);
131
+ const file = path.join(distPath, req.params.file);
132
+ res.sendFile(file);
133
+ });
134
+ app.get("/creator/assets/:file", (req, res) => {
135
+ const file = path.join(distPath, "assets", req.params.file);
136
+ res.sendFile(file);
137
+ });
138
+ app.listen(PORT, () => {
139
+ console.log(`🚀 Creator UI server running at http://localhost:${PORT}`);
140
+ });
141
+ }
142
+ }
143
+ ServeCommand.description = "Runs a small server to build tutorials";
144
+ ServeCommand.flags = Object.assign(Object.assign({}, SessionCommand_1.default.flags), { port: command_1.flags.string({ char: "p", description: "server port" }), host: command_1.flags.string({ char: "h", description: "server host" }), debug: command_1.flags.boolean({
145
+ char: "d",
146
+ description: "debugger mode for more verbage",
147
+ default: false,
148
+ }) });
149
+ exports.default = ServeCommand;
@@ -14,6 +14,7 @@ const telemetry_1 = require("../telemetry");
14
14
  const creatorUtilities_1 = require("../../utils/creatorUtilities");
15
15
  const rigoActions_1 = require("../../utils/rigoActions");
16
16
  const sidebarGenerator_1 = require("../../utils/sidebarGenerator");
17
+ const path = require("path");
17
18
  // import { eventManager } from "../../utils/osOperations"
18
19
  const withHandler = (func) => (req, res) => {
19
20
  try {
@@ -373,4 +374,5 @@ async function default_1(app, configObject, configManager) {
373
374
  app.use("/preview", express.static(config.outputPath));
374
375
  }
375
376
  app.use("/", express.static(`${config === null || config === void 0 ? void 0 : config.dirPath}/_app`));
377
+ app.use("/creator", express.static(path.join(__dirname, "..", "creatorDist")));
376
378
  }
@@ -18,6 +18,9 @@ type TAssetMissing = {
18
18
  description: string;
19
19
  learnpack_deploy_url: string;
20
20
  technologies: string[];
21
+ category: number;
22
+ owner: number;
23
+ author: number;
21
24
  };
22
25
  export declare const createAsset: (token: string, academyId: number, asset: TAssetMissing) => Promise<any>;
23
26
  export declare const doesAssetExists: (token: string, assetSlug: string) => Promise<{
@@ -44,5 +47,6 @@ declare const _default: {
44
47
  academyId?: number;
45
48
  }>;
46
49
  updateAsset: (token: string, academyId: number, assetSlug: string, asset: Partial<TAssetMissing>) => Promise<any>;
50
+ getCategories: (token: string) => Promise<any>;
47
51
  };
48
52
  export default _default;
package/lib/utils/api.js CHANGED
@@ -328,21 +328,23 @@ const createAsset = async (token, academyId, asset) => {
328
328
  lang: asset.lang,
329
329
  asset_type: "EXERCISE",
330
330
  visibility: "PUBLIC",
331
- status: "PUBLISHED",
331
+ status: "DRAFT",
332
332
  url: "https://4geeksacademy.com",
333
333
  readme_url: null,
334
334
  difficulty: null,
335
335
  duration: null,
336
336
  graded: false,
337
337
  gitpod: true,
338
- category: 7,
338
+ category: asset.category,
339
+ owner: asset.owner,
340
+ author: asset.author,
339
341
  preview: null,
340
342
  description: asset.description,
341
- external: true,
343
+ external: false,
342
344
  interactive: true,
343
345
  solution_video_url: null,
344
346
  intro_video_url: null,
345
- translations: ["us"],
347
+ translations: [asset.lang],
346
348
  learnpack_deploy_url: asset.learnpack_deploy_url,
347
349
  technologies: asset.technologies,
348
350
  };
@@ -398,6 +400,20 @@ const updateAsset = async (token, academyId, assetSlug, asset) => {
398
400
  throw error.response.data;
399
401
  }
400
402
  };
403
+ const getCategories = async (token) => {
404
+ const url = `${HOST}/v1/registry/category`;
405
+ const headers = {
406
+ Authorization: `Token ${token}`,
407
+ };
408
+ try {
409
+ const response = await axios_1.default.get(url, { headers });
410
+ return response.data;
411
+ }
412
+ catch (error) {
413
+ console.error("Failed to get categories:", error);
414
+ throw error;
415
+ }
416
+ };
401
417
  exports.default = {
402
418
  login,
403
419
  publish,
@@ -412,4 +428,5 @@ exports.default = {
412
428
  createAsset: exports.createAsset,
413
429
  doesAssetExists: exports.doesAssetExists,
414
430
  updateAsset,
431
+ getCategories,
415
432
  };
@@ -0,0 +1,8 @@
1
+ import { Bucket } from "@google-cloud/storage";
2
+ /**
3
+ * Sube contenido de texto directamente a un bucket de GCS.
4
+ * @param bucket Instancia de Bucket
5
+ * @param destination Ruta destino dentro del bucket (incluye carpeta/nombre)
6
+ * @param textContent Contenido textual a subir
7
+ */
8
+ export declare function uploadTextToBucket(bucket: Bucket, destination: string, textContent: string): Promise<void>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uploadTextToBucket = uploadTextToBucket;
4
+ /**
5
+ * Sube contenido de texto directamente a un bucket de GCS.
6
+ * @param bucket Instancia de Bucket
7
+ * @param destination Ruta destino dentro del bucket (incluye carpeta/nombre)
8
+ * @param textContent Contenido textual a subir
9
+ */
10
+ async function uploadTextToBucket(bucket, destination, textContent) {
11
+ const file = bucket.file(destination);
12
+ await file.save(textContent, {
13
+ resumable: false,
14
+ contentType: "text/plain",
15
+ });
16
+ console.log(`✅ Texto subido a gs://${bucket.name}/${destination}`);
17
+ }
@@ -1 +1 @@
1
- {"version":"5.0.53","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":[]},"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":[]}}}
1
+ {"version":"5.0.57","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":[]}}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@learnpack/learnpack",
3
3
  "description": "Seamlessly build, sell and/or take interactive & auto-graded tutorials, start learning now or build a new tutorial to your audience.",
4
- "version": "5.0.53",
4
+ "version": "5.0.57",
5
5
  "author": "Alejandro Sanchez @alesanchezr",
6
6
  "contributors": [
7
7
  {
@@ -21,6 +21,7 @@
21
21
  "url": "https://github.com/learnpack/learnpack-cli/issues"
22
22
  },
23
23
  "dependencies": {
24
+ "@google-cloud/storage": "^7.16.0",
24
25
  "@oclif/command": "^1.6.1",
25
26
  "@oclif/config": "^1.15.1",
26
27
  "@oclif/plugin-help": "^3.1.0",
@@ -33,6 +34,7 @@
33
34
  "chalk": "^4.1.0",
34
35
  "chokidar": "^3.4.0",
35
36
  "cli-ux": "^5.4.6",
37
+ "cors": "^2.8.5",
36
38
  "debounce": "^1.2.0",
37
39
  "dotenv": "^8.2.0",
38
40
  "enquirer": "^2.3.6",