@learnpack/learnpack 5.0.27 → 5.0.29
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 +27 -11
- package/lib/commands/breakToken.d.ts +10 -0
- package/lib/commands/breakToken.js +23 -0
- package/lib/commands/init.js +78 -44
- package/lib/commands/publish.js +29 -2
- package/lib/commands/start.js +9 -12
- package/lib/managers/config/index.js +77 -77
- package/lib/managers/server/routes.js +1 -5
- package/lib/managers/session.js +8 -0
- package/lib/models/session.d.ts +1 -0
- package/lib/utils/api.d.ts +11 -1
- package/lib/utils/api.js +49 -11
- package/lib/utils/creatorUtilities.d.ts +7 -2
- package/lib/utils/creatorUtilities.js +88 -6
- package/lib/utils/rigoActions.d.ts +6 -0
- package/lib/utils/rigoActions.js +16 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/breakToken.ts +36 -0
- package/src/commands/init.ts +113 -55
- package/src/commands/publish.ts +34 -2
- package/src/commands/start.ts +10 -14
- package/src/managers/config/index.ts +715 -715
- package/src/managers/server/routes.ts +1 -3
- package/src/managers/session.ts +11 -0
- package/src/models/session.ts +1 -0
- package/src/utils/api.ts +60 -12
- package/src/utils/creatorUtilities.ts +101 -7
- package/src/utils/rigoActions.ts +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.29 win32-x64 node-v20.16.0
|
25
25
|
$ learnpack --help [COMMAND]
|
26
26
|
USAGE
|
27
27
|
$ learnpack COMMAND
|
@@ -33,6 +33,7 @@ USAGE
|
|
33
33
|
|
34
34
|
<!-- commands -->
|
35
35
|
* [`learnpack audit`](#learnpack-audit)
|
36
|
+
* [`learnpack breakToken`](#learnpack-breaktoken)
|
36
37
|
* [`learnpack clean`](#learnpack-clean)
|
37
38
|
* [`learnpack download [PACKAGE]`](#learnpack-download-package)
|
38
39
|
* [`learnpack help [COMMAND]`](#learnpack-help-command)
|
@@ -75,7 +76,22 @@ DESCRIPTION
|
|
75
76
|
12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)
|
76
77
|
```
|
77
78
|
|
78
|
-
_See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
79
|
+
_See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.29/src\commands\audit.ts)_
|
80
|
+
|
81
|
+
## `learnpack breakToken`
|
82
|
+
|
83
|
+
Break the token
|
84
|
+
|
85
|
+
```
|
86
|
+
USAGE
|
87
|
+
$ learnpack breakToken
|
88
|
+
|
89
|
+
OPTIONS
|
90
|
+
-h, --grading show CLI help
|
91
|
+
-y, --yes Skip all prompts and initialize an empty project
|
92
|
+
```
|
93
|
+
|
94
|
+
_See code: [src\commands\breakToken.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.29/src\commands\breakToken.ts)_
|
79
95
|
|
80
96
|
## `learnpack clean`
|
81
97
|
|
@@ -90,7 +106,7 @@ DESCRIPTION
|
|
90
106
|
Extra documentation goes here
|
91
107
|
```
|
92
108
|
|
93
|
-
_See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
109
|
+
_See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.29/src\commands\clean.ts)_
|
94
110
|
|
95
111
|
## `learnpack download [PACKAGE]`
|
96
112
|
|
@@ -108,7 +124,7 @@ DESCRIPTION
|
|
108
124
|
Extra documentation goes here
|
109
125
|
```
|
110
126
|
|
111
|
-
_See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
127
|
+
_See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.29/src\commands\download.ts)_
|
112
128
|
|
113
129
|
## `learnpack help [COMMAND]`
|
114
130
|
|
@@ -140,7 +156,7 @@ OPTIONS
|
|
140
156
|
-y, --yes Skip all prompts and initialize an empty project
|
141
157
|
```
|
142
158
|
|
143
|
-
_See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
159
|
+
_See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.29/src\commands\init.ts)_
|
144
160
|
|
145
161
|
## `learnpack login [PACKAGE]`
|
146
162
|
|
@@ -158,7 +174,7 @@ DESCRIPTION
|
|
158
174
|
Extra documentation goes here
|
159
175
|
```
|
160
176
|
|
161
|
-
_See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
177
|
+
_See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.29/src\commands\login.ts)_
|
162
178
|
|
163
179
|
## `learnpack logout [PACKAGE]`
|
164
180
|
|
@@ -176,7 +192,7 @@ DESCRIPTION
|
|
176
192
|
Extra documentation goes here
|
177
193
|
```
|
178
194
|
|
179
|
-
_See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
195
|
+
_See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.29/src\commands\logout.ts)_
|
180
196
|
|
181
197
|
## `learnpack plugins`
|
182
198
|
|
@@ -307,7 +323,7 @@ OPTIONS
|
|
307
323
|
-h, --help show CLI help
|
308
324
|
```
|
309
325
|
|
310
|
-
_See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
326
|
+
_See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.29/src\commands\publish.ts)_
|
311
327
|
|
312
328
|
## `learnpack start`
|
313
329
|
|
@@ -329,7 +345,7 @@ OPTIONS
|
|
329
345
|
-y, --yes Skip all prompts and initialize an empty project
|
330
346
|
```
|
331
347
|
|
332
|
-
_See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
348
|
+
_See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.29/src\commands\start.ts)_
|
333
349
|
|
334
350
|
## `learnpack test [EXERCISESLUG]`
|
335
351
|
|
@@ -346,7 +362,7 @@ OPTIONS
|
|
346
362
|
-y, --yes Skip all prompts and initialize an empty project
|
347
363
|
```
|
348
364
|
|
349
|
-
_See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
365
|
+
_See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.29/src\commands\test.ts)_
|
350
366
|
|
351
367
|
## `learnpack translate`
|
352
368
|
|
@@ -360,7 +376,7 @@ OPTIONS
|
|
360
376
|
-y, --yes Skip all prompts and initialize an empty project
|
361
377
|
```
|
362
378
|
|
363
|
-
_See code: [src\commands\translate.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
379
|
+
_See code: [src\commands\translate.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.29/src\commands\translate.ts)_
|
364
380
|
<!-- commandsstop -->
|
365
381
|
|
366
382
|
> > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import BaseCommand from "../utils/BaseCommand";
|
2
|
+
declare class BreakTokenCommand extends BaseCommand {
|
3
|
+
static description: string;
|
4
|
+
static flags: {
|
5
|
+
grading: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
6
|
+
yes: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
7
|
+
};
|
8
|
+
run(): Promise<void>;
|
9
|
+
}
|
10
|
+
export default BreakTokenCommand;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const command_1 = require("@oclif/command");
|
4
|
+
const BaseCommand_1 = require("../utils/BaseCommand");
|
5
|
+
const console_1 = require("../utils/console");
|
6
|
+
const creatorUtilities_1 = require("../utils/creatorUtilities");
|
7
|
+
class BreakTokenCommand extends BaseCommand_1.default {
|
8
|
+
async run() {
|
9
|
+
const { flags } = this.parse(BreakTokenCommand);
|
10
|
+
// await SessionManager.breakToken()
|
11
|
+
await (0, creatorUtilities_1.createFileOnDesktop)();
|
12
|
+
console_1.default.info("File created on desktop, please make the necessary changes and continue when ready");
|
13
|
+
// Wait for user to press enter
|
14
|
+
process.stdin.once("data", () => {
|
15
|
+
console_1.default.info("File content:");
|
16
|
+
console_1.default.info((0, creatorUtilities_1.getContentIndex)());
|
17
|
+
process.exit(0);
|
18
|
+
});
|
19
|
+
}
|
20
|
+
}
|
21
|
+
BreakTokenCommand.description = "Break the token";
|
22
|
+
BreakTokenCommand.flags = Object.assign(Object.assign({}, BaseCommand_1.default.flags), { grading: command_1.flags.help({ char: "h" }) });
|
23
|
+
exports.default = BreakTokenCommand;
|
package/lib/commands/init.js
CHANGED
@@ -7,19 +7,26 @@ const fs = require("fs-extra");
|
|
7
7
|
const prompts = require("prompts");
|
8
8
|
const cli_ux_1 = require("cli-ux");
|
9
9
|
const eta = require("eta");
|
10
|
+
const api_1 = require("../utils/api");
|
10
11
|
const console_1 = require("../utils/console");
|
11
12
|
const errors_1 = require("../utils/errors");
|
12
13
|
const path = require("path");
|
13
14
|
const rigoActions_1 = require("../utils/rigoActions");
|
14
|
-
const
|
15
|
+
const api_2 = require("../utils/api");
|
15
16
|
const creatorUtilities_1 = require("../utils/creatorUtilities");
|
16
17
|
const session_1 = require("../managers/session");
|
18
|
+
const durationByKind = {
|
19
|
+
code: 3,
|
20
|
+
quiz: 2,
|
21
|
+
read: 1,
|
22
|
+
};
|
17
23
|
const initializeInteractiveCreation = async (rigoToken, courseInfo) => {
|
18
24
|
let prevInteractions = "";
|
19
25
|
let isReady = false;
|
20
26
|
let currentSteps = [];
|
21
27
|
let currentTitle = "";
|
22
28
|
let currentDescription = "";
|
29
|
+
let currentDifficulty = "";
|
23
30
|
while (!isReady) {
|
24
31
|
let wholeInfo = courseInfo;
|
25
32
|
wholeInfo += `
|
@@ -40,6 +47,9 @@ const initializeInteractiveCreation = async (rigoToken, courseInfo) => {
|
|
40
47
|
currentDescription !== res.parsed.description) {
|
41
48
|
currentDescription = res.parsed.description;
|
42
49
|
}
|
50
|
+
if (res.parsed.difficulty && currentDifficulty !== res.parsed.difficulty) {
|
51
|
+
currentDifficulty = res.parsed.difficulty;
|
52
|
+
}
|
43
53
|
if (!isReady) {
|
44
54
|
console.log(currentSteps);
|
45
55
|
console_1.default.info(`AI: ${res.parsed.aiMessage}`);
|
@@ -55,17 +65,49 @@ const initializeInteractiveCreation = async (rigoToken, courseInfo) => {
|
|
55
65
|
prevInteractions += `\nUser: ${userMessage.userMessage}`;
|
56
66
|
}
|
57
67
|
}
|
68
|
+
const duration = (0, creatorUtilities_1.estimateDuration)(currentSteps);
|
58
69
|
return {
|
59
70
|
steps: currentSteps,
|
60
71
|
title: currentTitle,
|
61
72
|
description: currentDescription,
|
62
73
|
interactions: prevInteractions,
|
74
|
+
difficulty: currentDifficulty,
|
75
|
+
duration,
|
63
76
|
};
|
64
77
|
};
|
78
|
+
const appendContentIndex = async () => {
|
79
|
+
const choices = await prompts([
|
80
|
+
{
|
81
|
+
type: "confirm",
|
82
|
+
name: "contentIndex",
|
83
|
+
message: "Do you have a content index for this tutorial?",
|
84
|
+
},
|
85
|
+
]);
|
86
|
+
if (choices.contentIndex) {
|
87
|
+
await (0, creatorUtilities_1.createFileOnDesktop)();
|
88
|
+
console_1.default.info("Please make the necessary in the recently created file in your desktop, it should automatically open. Edit the file to match your expectations and save it. Keep the same name and structure as the example file. Continue when ready.");
|
89
|
+
const isReady = await prompts([
|
90
|
+
{
|
91
|
+
type: "confirm",
|
92
|
+
name: "isReady",
|
93
|
+
message: "Are you ready to continue?",
|
94
|
+
},
|
95
|
+
]);
|
96
|
+
if (!isReady.isReady) {
|
97
|
+
console_1.default.error("Please make the necessary changes and try again.");
|
98
|
+
process.exit(1);
|
99
|
+
}
|
100
|
+
const contentIndex = (0, creatorUtilities_1.getContentIndex)();
|
101
|
+
return contentIndex;
|
102
|
+
}
|
103
|
+
return null;
|
104
|
+
};
|
65
105
|
const handleAILogic = async (tutorialDir, packageInfo) => {
|
66
106
|
fs.removeSync(path.join(tutorialDir, "exercises", "01-hello-world"));
|
67
107
|
let sessionPayload = await session_1.default.getPayload();
|
68
|
-
if (!sessionPayload ||
|
108
|
+
if (!sessionPayload ||
|
109
|
+
!sessionPayload.rigobot ||
|
110
|
+
(sessionPayload.token && !(await api_1.default.validateToken(sessionPayload.token)))) {
|
69
111
|
console_1.default.info("Almost there! First you need to login with 4Geeks.com to use AI Generation tool for creators. You can create a new account here: https://4geeks.com/creators");
|
70
112
|
try {
|
71
113
|
sessionPayload = await session_1.default.login();
|
@@ -76,10 +118,10 @@ const handleAILogic = async (tutorialDir, packageInfo) => {
|
|
76
118
|
}
|
77
119
|
}
|
78
120
|
const rigoToken = sessionPayload.rigobot.key;
|
79
|
-
const
|
80
|
-
if (
|
81
|
-
console_1.default.error("It seems you cannot generate tutorials with AI. Make sure you creator subscription is up to date here: https://4geeks.com/profile/subscriptions
|
82
|
-
process.exit(1)
|
121
|
+
const consumable = await (0, api_2.getConsumable)(sessionPayload.token, "ai-generation");
|
122
|
+
if (consumable.count === 0) {
|
123
|
+
console_1.default.error("It seems you cannot generate tutorials with AI. Make sure you creator subscription is up to date here: https://4geeks.com/profile/subscriptions. If you believe there is an issue you can always contact support@4geeks.com");
|
124
|
+
// process.exit(1)
|
83
125
|
}
|
84
126
|
const isCreator = await (0, rigoActions_1.hasCreatorPermission)(rigoToken);
|
85
127
|
if (!isCreator) {
|
@@ -87,21 +129,26 @@ const handleAILogic = async (tutorialDir, packageInfo) => {
|
|
87
129
|
process.exit(1);
|
88
130
|
}
|
89
131
|
console_1.default.success("🎉 Let's begin this learning journey!");
|
132
|
+
const contentIndex = await appendContentIndex();
|
90
133
|
let packageContext = `
|
91
134
|
\n
|
92
135
|
Title: ${packageInfo.title.us}
|
93
136
|
Description: ${packageInfo.description.us}
|
94
|
-
|
95
|
-
|
137
|
+
|
138
|
+
${contentIndex ?
|
139
|
+
`Content Index submitted by the user, use this to guide your creation: ${contentIndex}` :
|
140
|
+
""}
|
141
|
+
|
96
142
|
`;
|
97
|
-
const { steps, title, description } = await initializeInteractiveCreation(rigoToken, packageContext);
|
143
|
+
const { steps, title, description, duration, difficulty } = await initializeInteractiveCreation(rigoToken, packageContext);
|
98
144
|
packageInfo.title.us = title;
|
99
145
|
packageInfo.description.us = description;
|
146
|
+
packageInfo.duration = duration;
|
147
|
+
packageInfo.difficulty = difficulty;
|
100
148
|
packageContext = `
|
101
149
|
Title: ${title}
|
102
150
|
Description: ${description}
|
103
|
-
|
104
|
-
Estimated duration: ${packageInfo.duration}
|
151
|
+
|
105
152
|
List of exercises: ${steps.join(", ")}
|
106
153
|
`;
|
107
154
|
const exercisesDir = path.join(tutorialDir, "exercises");
|
@@ -123,13 +170,23 @@ const handleAILogic = async (tutorialDir, packageInfo) => {
|
|
123
170
|
lesson_description: description,
|
124
171
|
kind: kind.toLowerCase(),
|
125
172
|
});
|
126
|
-
const
|
127
|
-
|
128
|
-
|
129
|
-
|
173
|
+
const duration = durationByKind[kind.toLowerCase()];
|
174
|
+
let readingTime = (0, creatorUtilities_1.checkReadingTime)(readme.parsed.content, 200, duration || 1);
|
175
|
+
if (readingTime.exceedsThreshold) {
|
176
|
+
// Console.info(
|
177
|
+
// `The reading time for the lesson ${exTitle} exceeds the threshold, reducing it...`
|
178
|
+
// )
|
179
|
+
const reducedReadme = await (0, rigoActions_1.reduceReadme)(rigoToken, {
|
180
|
+
lesson: readingTime.body,
|
181
|
+
number_of_words: readingTime.minutes.toString(),
|
182
|
+
expected_number_words: "200",
|
183
|
+
});
|
184
|
+
if (reducedReadme) {
|
185
|
+
readingTime = (0, creatorUtilities_1.checkReadingTime)(reducedReadme.parsed.content, 200, duration || 1);
|
186
|
+
}
|
130
187
|
}
|
131
188
|
const readmeFilename = "README.md";
|
132
|
-
fs.writeFileSync(path.join(exerciseDir, readmeFilename), newMarkdown);
|
189
|
+
fs.writeFileSync(path.join(exerciseDir, readmeFilename), readingTime.newMarkdown);
|
133
190
|
if (kind.toLowerCase() === "code") {
|
134
191
|
const codeFile = await (0, rigoActions_1.createCodeFile)(rigoToken, {
|
135
192
|
readme: readme.parsed.content,
|
@@ -137,12 +194,12 @@ const handleAILogic = async (tutorialDir, packageInfo) => {
|
|
137
194
|
});
|
138
195
|
fs.writeFileSync(path.join(exerciseDir, `app.${codeFile.parsed.extension.replace(".", "")}`), codeFile.parsed.content);
|
139
196
|
}
|
140
|
-
return
|
197
|
+
return readingTime.newMarkdown;
|
141
198
|
});
|
142
|
-
let imagesArray = [];
|
143
199
|
const readmeContents = await Promise.all(exercisePromises);
|
144
200
|
console_1.default.success("Lessons created! 🎉");
|
145
201
|
console_1.default.info("Generating images for the lessons...");
|
202
|
+
let imagesArray = [];
|
146
203
|
for (const content of readmeContents) {
|
147
204
|
imagesArray = [...imagesArray, ...(0, creatorUtilities_1.extractImagesFromMarkdown)(content)];
|
148
205
|
}
|
@@ -170,7 +227,7 @@ const getChoices = async (empty) => {
|
|
170
227
|
title: "My Interactive Tutorial",
|
171
228
|
description: "",
|
172
229
|
difficulty: "beginner",
|
173
|
-
duration:
|
230
|
+
duration: 5,
|
174
231
|
useAI: "no",
|
175
232
|
grading: "isolated",
|
176
233
|
};
|
@@ -206,30 +263,6 @@ const getChoices = async (empty) => {
|
|
206
263
|
initial: "",
|
207
264
|
message: "Description for your tutorial? Press enter to leave blank",
|
208
265
|
},
|
209
|
-
{
|
210
|
-
type: "select",
|
211
|
-
name: "difficulty",
|
212
|
-
message: "How difficulty will be to complete the tutorial?",
|
213
|
-
choices: [
|
214
|
-
{ title: "Begginer (no previous experience)", value: "beginner" },
|
215
|
-
{ title: "Easy (just a bit of experience required)", value: "easy" },
|
216
|
-
{
|
217
|
-
title: "Intermediate (you need experience)",
|
218
|
-
value: "intermediate",
|
219
|
-
},
|
220
|
-
{ title: "Hard (master the topic)", value: "hard" },
|
221
|
-
],
|
222
|
-
},
|
223
|
-
{
|
224
|
-
type: "text",
|
225
|
-
name: "duration",
|
226
|
-
initial: "1",
|
227
|
-
message: "How many hours avg it takes to complete (number)?",
|
228
|
-
validate: (value) => {
|
229
|
-
const n = Math.floor(Number(value));
|
230
|
-
return n !== Number.POSITIVE_INFINITY && String(n) === value && n >= 0;
|
231
|
-
},
|
232
|
-
},
|
233
266
|
{
|
234
267
|
type: "select",
|
235
268
|
name: "useAI",
|
@@ -243,7 +276,8 @@ const getChoices = async (empty) => {
|
|
243
276
|
],
|
244
277
|
},
|
245
278
|
]);
|
246
|
-
|
279
|
+
const completeChoices = Object.assign(Object.assign({}, choices), { difficulty: "beginner", duration: 30 });
|
280
|
+
return completeChoices;
|
247
281
|
};
|
248
282
|
class InitComand extends BaseCommand_1.default {
|
249
283
|
async run() {
|
package/lib/commands/publish.js
CHANGED
@@ -13,6 +13,8 @@ const axios_1 = require("axios");
|
|
13
13
|
const FormData = require("form-data");
|
14
14
|
const console_1 = require("../utils/console");
|
15
15
|
const file_1 = require("../managers/file");
|
16
|
+
const api_1 = require("../utils/api");
|
17
|
+
const prompts = require("prompts");
|
16
18
|
const RIGOBOT_HOST = "https://rigobot.herokuapp.com";
|
17
19
|
// const RIGOBOT_HOST =
|
18
20
|
// "https://8000-charlytoc-rigobot-bmwdeam7cev.ws-us116.gitpod.io"
|
@@ -37,6 +39,26 @@ const runAudit = () => {
|
|
37
39
|
// Continuar con el proceso de build solo si `learnpack publish` fue exitoso
|
38
40
|
console_1.default.info("Learnpack publish completed successfully. Proceeding with build...");
|
39
41
|
};
|
42
|
+
const selectAcademy = async (academies) => {
|
43
|
+
if (academies.length === 0) {
|
44
|
+
return null;
|
45
|
+
}
|
46
|
+
if (academies.length === 1) {
|
47
|
+
return academies[0];
|
48
|
+
}
|
49
|
+
// prompts the user to select an academy to upload the assets
|
50
|
+
console_1.default.info("In which academy do you want to publish the asset?");
|
51
|
+
const response = await prompts({
|
52
|
+
type: "select",
|
53
|
+
name: "academy",
|
54
|
+
message: "Select an academy",
|
55
|
+
choices: academies.map((academy) => ({
|
56
|
+
title: academy.name,
|
57
|
+
value: academy,
|
58
|
+
})),
|
59
|
+
});
|
60
|
+
return response.academy;
|
61
|
+
};
|
40
62
|
class BuildCommand extends SessionCommand_1.default {
|
41
63
|
async init() {
|
42
64
|
const { flags } = this.parse(BuildCommand);
|
@@ -48,7 +70,9 @@ class BuildCommand extends SessionCommand_1.default {
|
|
48
70
|
// this.configManager?.clean()
|
49
71
|
const configObject = (_a = this.configManager) === null || _a === void 0 ? void 0 : _a.get();
|
50
72
|
let sessionPayload = await session_1.default.getPayload();
|
51
|
-
if (!sessionPayload ||
|
73
|
+
if (!sessionPayload ||
|
74
|
+
!sessionPayload.rigobot ||
|
75
|
+
(sessionPayload.token && !(await api_1.default.validateToken(sessionPayload.token)))) {
|
52
76
|
console_1.default.error("You must be logged in to upload a LearnPack package");
|
53
77
|
try {
|
54
78
|
sessionPayload = await session_1.default.login();
|
@@ -67,7 +91,10 @@ class BuildCommand extends SessionCommand_1.default {
|
|
67
91
|
console_1.default.debug("Building exercises");
|
68
92
|
(_c = this.configManager) === null || _c === void 0 ? void 0 : _c.buildIndex();
|
69
93
|
}
|
70
|
-
// const
|
94
|
+
// const academies = await api.listUserAcademies(sessionPayload.token)
|
95
|
+
// // console.log(academies, "academies")
|
96
|
+
// const academy = await selectAcademy(academies)
|
97
|
+
// console.log(academy, "academy")
|
71
98
|
// Read learn.json to get the slug
|
72
99
|
const learnJsonPath = path.join(process.cwd(), "learn.json");
|
73
100
|
if (!fs.existsSync(learnJsonPath)) {
|
package/lib/commands/start.js
CHANGED
@@ -82,21 +82,26 @@ class StartCommand extends SessionCommand_1.default {
|
|
82
82
|
socket_1.default.on("open", (data) => {
|
83
83
|
console_1.default.debug("Opening these files: ", data);
|
84
84
|
const files = (0, misc_1.prioritizeHTMLFile)(data.files);
|
85
|
-
if (config.editor.agent
|
85
|
+
if (config.editor.agent !== "os") {
|
86
|
+
// Console.info("Opening files for vscode agent")
|
86
87
|
osOperations_1.eventManager.enqueue(dispatcher.events.OPEN_FILES, files);
|
87
88
|
}
|
88
89
|
else {
|
89
|
-
dispatcher.enqueue(dispatcher.events.OPEN_FILES, files)
|
90
|
+
// dispatcher.enqueue(dispatcher.events.OPEN_FILES, files)
|
91
|
+
console_1.default.debug("Ignoring files for os agent");
|
90
92
|
}
|
91
93
|
socket_1.default.ready("Ready to compile...");
|
92
94
|
});
|
93
95
|
socket_1.default.on("open_window", (data) => {
|
94
96
|
console_1.default.debug("Opening window: ", data);
|
97
|
+
console.log("config.os", config.os);
|
95
98
|
// cli.open(data.url); This uses XDG under the ground
|
96
99
|
if (config.os !== "linux" || (config.os === "linux" && hasXDG)) {
|
100
|
+
console.log("Opening window with XDG");
|
97
101
|
osOperations_1.eventManager.enqueue(dispatcher.events.OPEN_WINDOW, data);
|
98
102
|
}
|
99
103
|
else {
|
104
|
+
console.log("Opening window without XDG");
|
100
105
|
dispatcher.enqueue(dispatcher.events.OPEN_WINDOW, data);
|
101
106
|
}
|
102
107
|
socket_1.default.log("open_window", "", undefined, data.url);
|
@@ -142,14 +147,6 @@ class StartCommand extends SessionCommand_1.default {
|
|
142
147
|
telemetry: telemetry_1.default,
|
143
148
|
});
|
144
149
|
});
|
145
|
-
// socket.on("quiz_submission", (data: any) => {
|
146
|
-
// const { stepPosition, event, eventData } = data
|
147
|
-
// TelemetryManager.registerStepEvent(stepPosition, event, eventData)
|
148
|
-
// })
|
149
|
-
// socket.on("ai_interaction", (data: any) => {
|
150
|
-
// const { stepPosition, event, eventData } = data
|
151
|
-
// TelemetryManager.registerStepEvent(stepPosition, event, eventData)
|
152
|
-
// })
|
153
150
|
socket_1.default.on("telemetry_event", (data) => {
|
154
151
|
const { stepPosition, event, eventData } = data;
|
155
152
|
telemetry_1.default.registerStepEvent(stepPosition, event, eventData);
|
@@ -222,9 +219,9 @@ class StartCommand extends SessionCommand_1.default {
|
|
222
219
|
setTimeout(() => dispatcher.enqueue(dispatcher.events.RUNNING), 1000);
|
223
220
|
// start watching for file changes
|
224
221
|
if (StartCommand.flags.watch)
|
225
|
-
this.configManager.watchIndex(_filename => {
|
222
|
+
this.configManager.watchIndex((_filename, _fileContent) => {
|
226
223
|
// Instead of reloading with socket.reload(), I just notify the frontend for the file change
|
227
|
-
socket_1.default.emit("file_change", "ready", _filename);
|
224
|
+
socket_1.default.emit("file_change", "ready", [_filename, _fileContent]);
|
228
225
|
});
|
229
226
|
}
|
230
227
|
}
|