@learnpack/learnpack 5.0.54 → 5.0.58
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 +30 -12
- package/lib/commands/serve.d.ts +7 -0
- package/lib/commands/serve.js +277 -0
- package/lib/managers/server/routes.js +2 -0
- package/lib/utils/api.js +1 -1
- package/lib/utils/cloudStorage.d.ts +8 -0
- package/lib/utils/cloudStorage.js +17 -0
- package/oclif.manifest.json +1 -1
- package/package.json +4 -1
- package/src/commands/serve.ts +371 -0
- package/src/creator/README.md +54 -0
- package/src/creator/eslint.config.js +28 -0
- package/src/creator/index.html +13 -0
- package/src/creator/package-lock.json +4659 -0
- package/src/creator/package.json +41 -0
- package/src/creator/public/vite.svg +1 -0
- package/src/creator/src/App.css +42 -0
- package/src/creator/src/App.tsx +221 -0
- package/src/creator/src/assets/react.svg +1 -0
- package/src/creator/src/assets/svgs.tsx +88 -0
- package/src/creator/src/components/Loader.tsx +28 -0
- package/src/creator/src/components/Login.tsx +263 -0
- package/src/creator/src/components/SelectableCard.tsx +30 -0
- package/src/creator/src/components/StepWizard.tsx +77 -0
- package/src/creator/src/components/SyllabusEditor.tsx +431 -0
- package/src/creator/src/index.css +68 -0
- package/src/creator/src/main.tsx +19 -0
- package/src/creator/src/utils/configTypes.ts +122 -0
- package/src/creator/src/utils/constants.ts +2 -0
- package/src/creator/src/utils/lib.ts +36 -0
- package/src/creator/src/utils/rigo.ts +391 -0
- package/src/creator/src/utils/store.ts +78 -0
- package/src/creator/src/vite-env.d.ts +1 -0
- package/src/creator/tsconfig.app.json +26 -0
- package/src/creator/tsconfig.json +7 -0
- package/src/creator/tsconfig.node.json +24 -0
- package/src/creator/vite.config.ts +13 -0
- package/src/creatorDist/assets/index-D92OoEoU.js +23719 -0
- package/src/creatorDist/assets/index-tt9JBVY0.css +987 -0
- package/src/creatorDist/index.html +14 -0
- package/src/creatorDist/vite.svg +1 -0
- package/src/managers/server/routes.ts +3 -0
- package/src/ui/_app/app.css +1 -0
- package/src/ui/_app/app.js +3025 -0
- package/src/ui/_app/favicon.ico +0 -0
- package/src/ui/_app/index.html +109 -0
- package/src/ui/_app/index.html.backup +91 -0
- package/src/ui/_app/learnpack.svg +7 -0
- package/src/ui/_app/logo-192.png +0 -0
- package/src/ui/_app/logo-512.png +0 -0
- package/src/ui/_app/logo.png +0 -0
- package/src/ui/_app/manifest.webmanifest +21 -0
- package/src/ui/_app/sw.js +30 -0
- package/src/ui/app.tar.gz +0 -0
- package/src/utils/api.ts +1 -1
- package/src/utils/cloudStorage.ts +24 -0
- package/src/utils/convertCreds.js +30 -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.
|
24
|
+
@learnpack/learnpack/5.0.58 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.
|
83
|
+
_See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.58/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.
|
98
|
+
_See code: [src\commands\breakToken.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.58/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.
|
113
|
+
_See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.58/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.
|
131
|
+
_See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.58/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.
|
163
|
+
_See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.58/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.
|
181
|
+
_See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.58/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.
|
199
|
+
_See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.58/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.
|
331
|
+
_See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.58/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.58/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.
|
370
|
+
_See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.58/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.
|
387
|
+
_See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.58/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.
|
401
|
+
_See code: [src\commands\translate.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.58/src\commands\translate.ts)_
|
384
402
|
<!-- commandsstop -->
|
385
403
|
|
386
404
|
> > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
|
@@ -0,0 +1,277 @@
|
|
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 rigoActions_1 = require("../utils/rigoActions");
|
12
|
+
const dotenv = require("dotenv");
|
13
|
+
dotenv.config();
|
14
|
+
const frontMatter = require("front-matter");
|
15
|
+
const crendsEnv = process.env.GCP_CREDENTIALS_JSON;
|
16
|
+
if (!crendsEnv) {
|
17
|
+
console.log("GCP_CREDENTIALS_JSON is not set");
|
18
|
+
process.exit(1);
|
19
|
+
}
|
20
|
+
const credentials = JSON.parse(crendsEnv);
|
21
|
+
const bucketStorage = new storage_1.Storage({
|
22
|
+
credentials,
|
23
|
+
});
|
24
|
+
const bucket = bucketStorage.bucket("learnpack");
|
25
|
+
async function listFilesWithPrefix(prefix) {
|
26
|
+
const [files] = await bucket.getFiles({ prefix });
|
27
|
+
return files;
|
28
|
+
}
|
29
|
+
class ServeCommand extends SessionCommand_1.default {
|
30
|
+
async init() {
|
31
|
+
const { flags } = this.parse(ServeCommand);
|
32
|
+
console.log("Initializing serve command");
|
33
|
+
}
|
34
|
+
async run() {
|
35
|
+
const app = express();
|
36
|
+
const PORT = 3000;
|
37
|
+
const distPath = path.resolve(__dirname, "../creatorDist");
|
38
|
+
// Servir archivos estáticos
|
39
|
+
// app.use(express.static(distPath))
|
40
|
+
app.use(express.json());
|
41
|
+
app.use(cors());
|
42
|
+
const appPath = path.resolve(__dirname, "../ui/_app");
|
43
|
+
const tarPath = path.resolve(__dirname, "../ui/app.tar.gz");
|
44
|
+
if (fs.existsSync(appPath)) {
|
45
|
+
fs.rmSync(appPath, { recursive: true });
|
46
|
+
}
|
47
|
+
if (fs.existsSync(tarPath)) {
|
48
|
+
fs.rmSync(tarPath);
|
49
|
+
}
|
50
|
+
await (0, file_1.downloadEditor)("5.0.0", `${__dirname}/../ui/app.tar.gz`);
|
51
|
+
await (0, file_1.decompress)(`${__dirname}/../ui/app.tar.gz`, `${__dirname}/../ui/_app/`);
|
52
|
+
const localAppPath = path.resolve(__dirname, "../ui/_app");
|
53
|
+
// app.use(express.static(localAppPath))
|
54
|
+
app.post("/upload", async (req, res) => {
|
55
|
+
const { content, destination } = req.body;
|
56
|
+
// console.log("UPLOAD", content, destination)
|
57
|
+
if (!content || !destination) {
|
58
|
+
return res.status(400).send("Missing content or destination");
|
59
|
+
}
|
60
|
+
if (!bucket) {
|
61
|
+
return res.status(500).send("Upload failed");
|
62
|
+
}
|
63
|
+
const buffer = Buffer.from(content, "utf-8");
|
64
|
+
const file = bucket.file(destination);
|
65
|
+
const stream = file.createWriteStream({
|
66
|
+
resumable: false,
|
67
|
+
contentType: "text/plain",
|
68
|
+
});
|
69
|
+
stream.on("error", err => {
|
70
|
+
console.error("❌ Error uploading:", err);
|
71
|
+
res.status(500).send("Upload failed");
|
72
|
+
});
|
73
|
+
stream.on("finish", () => {
|
74
|
+
console.log(`✅ Uploaded to: ${file.name}`);
|
75
|
+
res.send("File uploaded successfully");
|
76
|
+
});
|
77
|
+
stream.end(buffer);
|
78
|
+
});
|
79
|
+
app.get("/", async (req, res) => {
|
80
|
+
// The the ui/_app/index.html
|
81
|
+
console.log("GET /");
|
82
|
+
const file = path.resolve(__dirname, "../ui/_app/index.html");
|
83
|
+
res.sendFile(file);
|
84
|
+
});
|
85
|
+
app.get("/config", async (req, res) => {
|
86
|
+
const courseSlug = req.query.slug;
|
87
|
+
const files = await listFilesWithPrefix(`courses/${courseSlug}`);
|
88
|
+
const learnJson = files.find(file => file.name.endsWith("learn.json"));
|
89
|
+
const learnJsonContent = await (learnJson === null || learnJson === void 0 ? void 0 : learnJson.download());
|
90
|
+
const learnJsonParsed = JSON.parse((learnJsonContent === null || learnJsonContent === void 0 ? void 0 : learnJsonContent.toString()) || "{}");
|
91
|
+
const exerciseMap = {};
|
92
|
+
// Agrupar archivos por ejercicio
|
93
|
+
for (const file of files) {
|
94
|
+
const pathParts = file.name.split("/");
|
95
|
+
const isExercise = pathParts.includes("exercises");
|
96
|
+
if (!isExercise)
|
97
|
+
continue;
|
98
|
+
const slug = pathParts[pathParts.indexOf("exercises") + 1];
|
99
|
+
if (!exerciseMap[slug]) {
|
100
|
+
exerciseMap[slug] = {
|
101
|
+
title: slug,
|
102
|
+
slug: slug,
|
103
|
+
graded: false,
|
104
|
+
files: [],
|
105
|
+
translations: {},
|
106
|
+
};
|
107
|
+
}
|
108
|
+
const fileName = pathParts.at(-1);
|
109
|
+
// Traducciones
|
110
|
+
const readmeMatch = fileName === null || fileName === void 0 ? void 0 : fileName.match(/^readme(?:\.([a-z]{2}))?\.md$/i);
|
111
|
+
if (readmeMatch) {
|
112
|
+
const lang = readmeMatch[1] || "us";
|
113
|
+
exerciseMap[slug].translations[lang] = fileName || "";
|
114
|
+
}
|
115
|
+
else {
|
116
|
+
exerciseMap[slug].files.push(fileName || "");
|
117
|
+
}
|
118
|
+
}
|
119
|
+
const exercises = Object.values(exerciseMap).map((ex, index) => (Object.assign(Object.assign({}, ex), { position: index })));
|
120
|
+
res.set("X-Creator-Web", "true");
|
121
|
+
res.set("Access-Control-Expose-Headers", "X-Creator-Web");
|
122
|
+
res.send({
|
123
|
+
config: Object.assign(Object.assign({}, learnJsonParsed), { title: { us: courseSlug } }),
|
124
|
+
exercises,
|
125
|
+
});
|
126
|
+
});
|
127
|
+
app.get("/exercise/:slug/readme", async (req, res) => {
|
128
|
+
console.log("GET /exercise/:slug/readme");
|
129
|
+
const { slug } = req.params;
|
130
|
+
const courseSlug = req.query.slug;
|
131
|
+
const lang = req.query.lang || "us";
|
132
|
+
const basePath = `courses/${courseSlug}/exercises/${slug}/`;
|
133
|
+
const filename = lang === "us" ? "README.md" : `README.${lang}.md`;
|
134
|
+
const file = bucket.file(basePath + filename);
|
135
|
+
let contentBuffer;
|
136
|
+
try {
|
137
|
+
contentBuffer = await file.download();
|
138
|
+
}
|
139
|
+
catch (_a) {
|
140
|
+
if (lang !== "us") {
|
141
|
+
console.warn(`No README for lang '${lang}', falling back to 'us'`);
|
142
|
+
const fallbackFile = bucket.file(basePath + "README.md");
|
143
|
+
contentBuffer = await fallbackFile.download();
|
144
|
+
}
|
145
|
+
else {
|
146
|
+
return res.status(404).json({ error: "README not found" });
|
147
|
+
}
|
148
|
+
}
|
149
|
+
const { attributes, body } = frontMatter(contentBuffer[0].toString());
|
150
|
+
res.send({ attributes, body });
|
151
|
+
});
|
152
|
+
app.put("/exercise/:slug/file/:fileName", express.text(), async (req, res) => {
|
153
|
+
const { slug, fileName } = req.params;
|
154
|
+
const query = req.query;
|
155
|
+
console.log(`PUT /exercise/${slug}/file/${fileName}`);
|
156
|
+
const courseSlug = query.slug;
|
157
|
+
console.log("COURSE SLUG", courseSlug);
|
158
|
+
// Update the file in the bucket
|
159
|
+
const file = await bucket.file("courses/" + courseSlug + "/exercises/" + slug + "/" + fileName);
|
160
|
+
await file.save(req.body);
|
161
|
+
const created = await file.exists();
|
162
|
+
console.log("File updated", created);
|
163
|
+
res.send({
|
164
|
+
message: "File updated",
|
165
|
+
created,
|
166
|
+
});
|
167
|
+
});
|
168
|
+
app.post("/exercise/:slug/create", async (req, res) => {
|
169
|
+
console.log("POST /exercise/:slug/create");
|
170
|
+
const query = req.query;
|
171
|
+
const { title, readme, language } = req.body;
|
172
|
+
if (!title || !readme) {
|
173
|
+
return res
|
174
|
+
.status(400)
|
175
|
+
.json({ error: "Missing title or readme content" });
|
176
|
+
}
|
177
|
+
const courseSlug = query.slug;
|
178
|
+
const fileName = `courses/${courseSlug}/exercises/${title}/README${language === "us" || language === "en" ? "" : `.${language}`}.md`;
|
179
|
+
const file = bucket.file(fileName);
|
180
|
+
await file.save(readme);
|
181
|
+
const created = await file.exists();
|
182
|
+
res.send({
|
183
|
+
message: "File updated",
|
184
|
+
created,
|
185
|
+
});
|
186
|
+
});
|
187
|
+
app.put("/actions/rename", async (req, res) => {
|
188
|
+
console.log("PUT /actions/rename");
|
189
|
+
const { slug, newSlug } = req.body;
|
190
|
+
const query = req.query;
|
191
|
+
const courseSlug = query.slug;
|
192
|
+
const filePrefix = `courses/${courseSlug}/exercises/${slug}/`;
|
193
|
+
const [files] = await bucket.getFiles({ prefix: filePrefix });
|
194
|
+
for (const file of files) {
|
195
|
+
const newFileName = file.name.replace(slug, newSlug);
|
196
|
+
// eslint-disable-next-line no-await-in-loop
|
197
|
+
await file.rename(newFileName);
|
198
|
+
}
|
199
|
+
res.send({ message: "Files renamed" });
|
200
|
+
});
|
201
|
+
app.post("/actions/translate", express.json(), async (req, res) => {
|
202
|
+
console.log("POST /actions/translate");
|
203
|
+
const { exerciseSlugs, languages, rigoToken } = req.body;
|
204
|
+
const query = req.query;
|
205
|
+
const courseSlug = query.slug;
|
206
|
+
console.log("EXERCISE SLUGS", exerciseSlugs);
|
207
|
+
console.log("LANGUAGES", languages);
|
208
|
+
console.log("RIGO TOKEN", rigoToken);
|
209
|
+
if (!rigoToken) {
|
210
|
+
return res.status(400).json({ error: "RigoToken not found" });
|
211
|
+
}
|
212
|
+
const languagesToTranslate = languages.split(",");
|
213
|
+
try {
|
214
|
+
await Promise.all(exerciseSlugs.map(async (slug) => {
|
215
|
+
const readmePath = `courses/${courseSlug}/exercises/${slug}/README.md`;
|
216
|
+
const readme = await bucket.file(readmePath).download();
|
217
|
+
await Promise.all(languagesToTranslate.map(async (language) => {
|
218
|
+
const response = await (0, rigoActions_1.translateExercise)(rigoToken, {
|
219
|
+
text_to_translate: readme.toString(),
|
220
|
+
output_language: language,
|
221
|
+
exercise_slug: slug,
|
222
|
+
});
|
223
|
+
const translatedReadme = await bucket.file(`courses/${courseSlug}/exercises/${slug}/README.${response.parsed.output_language_code}.md`);
|
224
|
+
await translatedReadme.save(response.parsed.translation);
|
225
|
+
}));
|
226
|
+
}));
|
227
|
+
return res.status(200).json({ message: "Translated exercises" });
|
228
|
+
}
|
229
|
+
catch (error) {
|
230
|
+
console.log(error, "ERROR");
|
231
|
+
return res.status(400).json({ error: error.message });
|
232
|
+
}
|
233
|
+
});
|
234
|
+
app.delete("/exercise/:slug/delete", async (req, res) => {
|
235
|
+
const { slug } = req.params;
|
236
|
+
const query = req.query;
|
237
|
+
const courseSlug = query.slug;
|
238
|
+
const filePrefix = `courses/${courseSlug}/exercises/${slug}/`;
|
239
|
+
const [files] = await bucket.getFiles({ prefix: filePrefix });
|
240
|
+
for (const file of files) {
|
241
|
+
// eslint-disable-next-line no-await-in-loop
|
242
|
+
await file.delete();
|
243
|
+
}
|
244
|
+
res.send({ message: "Files deleted" });
|
245
|
+
});
|
246
|
+
app.get("/assets/:file", (req, res) => {
|
247
|
+
const file = path.join(localAppPath, req.params.file);
|
248
|
+
res.sendFile(file);
|
249
|
+
});
|
250
|
+
// Enviar index.html para todas las rutas
|
251
|
+
app.get("/creator", (req, res) => {
|
252
|
+
res.sendFile(path.join(distPath, "index.html"));
|
253
|
+
});
|
254
|
+
app.get("/creator/syllabus", (req, res) => {
|
255
|
+
res.sendFile(path.join(distPath, "index.html"));
|
256
|
+
});
|
257
|
+
app.get("/creator/:file", (req, res) => {
|
258
|
+
console.log("GET /creator/:file", req.params.file);
|
259
|
+
const file = path.join(distPath, req.params.file);
|
260
|
+
res.sendFile(file);
|
261
|
+
});
|
262
|
+
app.get("/creator/assets/:file", (req, res) => {
|
263
|
+
const file = path.join(distPath, "assets", req.params.file);
|
264
|
+
res.sendFile(file);
|
265
|
+
});
|
266
|
+
app.listen(PORT, () => {
|
267
|
+
console.log(`🚀 Creator UI server running at http://localhost:${PORT}`);
|
268
|
+
});
|
269
|
+
}
|
270
|
+
}
|
271
|
+
ServeCommand.description = "Runs a small server to build tutorials";
|
272
|
+
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({
|
273
|
+
char: "d",
|
274
|
+
description: "debugger mode for more verbage",
|
275
|
+
default: false,
|
276
|
+
}) });
|
277
|
+
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
|
}
|
package/lib/utils/api.js
CHANGED
@@ -327,7 +327,7 @@ const createAsset = async (token, academyId, asset) => {
|
|
327
327
|
title: asset.title,
|
328
328
|
lang: asset.lang,
|
329
329
|
asset_type: "EXERCISE",
|
330
|
-
visibility: "
|
330
|
+
visibility: "PUBLIC",
|
331
331
|
status: "DRAFT",
|
332
332
|
url: "https://4geeksacademy.com",
|
333
333
|
readme_url: null,
|
@@ -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
|
+
}
|
package/oclif.manifest.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":"5.0.
|
1
|
+
{"version":"5.0.58","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.
|
4
|
+
"version": "5.0.58",
|
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,8 @@
|
|
33
34
|
"chalk": "^4.1.0",
|
34
35
|
"chokidar": "^3.4.0",
|
35
36
|
"cli-ux": "^5.4.6",
|
37
|
+
"clipboardy": "^4.0.0",
|
38
|
+
"cors": "^2.8.5",
|
36
39
|
"debounce": "^1.2.0",
|
37
40
|
"dotenv": "^8.2.0",
|
38
41
|
"enquirer": "^2.3.6",
|