@learnpack/learnpack 5.0.29 → 5.0.31
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 +12 -12
- package/lib/commands/audit.js +15 -15
- package/lib/commands/init.js +39 -15
- package/lib/commands/logout.js +6 -11
- package/lib/commands/start.js +0 -3
- package/lib/commands/translate.js +2 -10
- package/lib/managers/config/index.js +102 -77
- package/lib/managers/file.js +1 -1
- package/lib/managers/server/routes.js +68 -0
- package/lib/managers/session.js +3 -0
- package/lib/models/config-manager.d.ts +2 -0
- package/lib/utils/creatorUtilities.d.ts +2 -0
- package/lib/utils/creatorUtilities.js +48 -7
- package/lib/utils/rigoActions.d.ts +1 -0
- package/lib/utils/rigoActions.js +13 -2
- package/oclif.manifest.json +1 -1
- package/package.json +3 -2
- package/src/commands/audit.ts +449 -449
- package/src/commands/breakToken.ts +36 -36
- package/src/commands/init.ts +48 -17
- package/src/commands/logout.ts +38 -43
- package/src/commands/publish.ts +312 -312
- package/src/commands/start.ts +0 -3
- package/src/commands/translate.ts +1 -20
- package/src/managers/config/index.ts +742 -715
- package/src/managers/file.ts +1 -1
- package/src/managers/server/routes.ts +103 -1
- package/src/managers/session.ts +4 -0
- package/src/models/config-manager.ts +25 -23
- package/src/utils/console.ts +24 -24
- package/src/utils/creatorUtilities.ts +66 -6
- package/src/utils/rigoActions.ts +13 -1
- package/src/utils/templates/incremental/.github/workflows/learnpack-audit.yml +29 -0
- package/src/utils/templates/isolated/.github/workflows/learnpack-audit.yml +29 -0
@@ -1,36 +1,36 @@
|
|
1
|
-
import { flags } from "@oclif/command"
|
2
|
-
import BaseCommand from "../utils/BaseCommand"
|
3
|
-
// eslint-disable-next-line
|
4
|
-
import * as fs from "fs-extra"
|
5
|
-
import Console from "../utils/console"
|
6
|
-
|
7
|
-
import SessionManager from "../managers/session"
|
8
|
-
import { createFileOnDesktop, getContentIndex } from "../utils/creatorUtilities"
|
9
|
-
|
10
|
-
class BreakTokenCommand extends BaseCommand {
|
11
|
-
static description = "Break the token"
|
12
|
-
|
13
|
-
static flags = {
|
14
|
-
...BaseCommand.flags,
|
15
|
-
grading: flags.help({ char: "h" }),
|
16
|
-
}
|
17
|
-
|
18
|
-
async run() {
|
19
|
-
const { flags } = this.parse(BreakTokenCommand)
|
20
|
-
|
21
|
-
// await SessionManager.breakToken()
|
22
|
-
await createFileOnDesktop()
|
23
|
-
Console.info(
|
24
|
-
"File created on desktop, please make the necessary changes and continue when ready"
|
25
|
-
)
|
26
|
-
|
27
|
-
// Wait for user to press enter
|
28
|
-
process.stdin.once("data", () => {
|
29
|
-
Console.info("File content:")
|
30
|
-
Console.info(getContentIndex())
|
31
|
-
process.exit(0)
|
32
|
-
})
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
export default BreakTokenCommand
|
1
|
+
import { flags } from "@oclif/command"
|
2
|
+
import BaseCommand from "../utils/BaseCommand"
|
3
|
+
// eslint-disable-next-line
|
4
|
+
import * as fs from "fs-extra"
|
5
|
+
import Console from "../utils/console"
|
6
|
+
|
7
|
+
import SessionManager from "../managers/session"
|
8
|
+
import { createFileOnDesktop, getContentIndex } from "../utils/creatorUtilities"
|
9
|
+
|
10
|
+
class BreakTokenCommand extends BaseCommand {
|
11
|
+
static description = "Break the token"
|
12
|
+
|
13
|
+
static flags = {
|
14
|
+
...BaseCommand.flags,
|
15
|
+
grading: flags.help({ char: "h" }),
|
16
|
+
}
|
17
|
+
|
18
|
+
async run() {
|
19
|
+
const { flags } = this.parse(BreakTokenCommand)
|
20
|
+
|
21
|
+
// await SessionManager.breakToken()
|
22
|
+
await createFileOnDesktop()
|
23
|
+
Console.info(
|
24
|
+
"File created on desktop, please make the necessary changes and continue when ready"
|
25
|
+
)
|
26
|
+
|
27
|
+
// Wait for user to press enter
|
28
|
+
process.stdin.once("data", () => {
|
29
|
+
Console.info("File content:")
|
30
|
+
Console.info(getContentIndex())
|
31
|
+
process.exit(0)
|
32
|
+
})
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
export default BreakTokenCommand
|
package/src/commands/init.ts
CHANGED
@@ -20,6 +20,7 @@ import {
|
|
20
20
|
readmeCreator,
|
21
21
|
createPreviewReadme,
|
22
22
|
reduceReadme,
|
23
|
+
isValidRigoToken,
|
23
24
|
} from "../utils/rigoActions"
|
24
25
|
import { getConsumable } from "../utils/api"
|
25
26
|
import {
|
@@ -41,6 +42,17 @@ const durationByKind: Record<string, number> = {
|
|
41
42
|
read: 1,
|
42
43
|
}
|
43
44
|
|
45
|
+
const whichTargetAudience = async () => {
|
46
|
+
const res = await prompts([
|
47
|
+
{
|
48
|
+
type: "text",
|
49
|
+
name: "targetAudience",
|
50
|
+
message: "What is the target audience for this tutorial?",
|
51
|
+
},
|
52
|
+
])
|
53
|
+
return res.targetAudience
|
54
|
+
}
|
55
|
+
|
44
56
|
const initializeInteractiveCreation = async (
|
45
57
|
rigoToken: string,
|
46
58
|
courseInfo: string
|
@@ -151,11 +163,19 @@ const handleAILogic = async (tutorialDir: string, packageInfo: PackageInfo) => {
|
|
151
163
|
|
152
164
|
let sessionPayload = await SessionManager.getPayload()
|
153
165
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
166
|
+
const sessionExists = sessionPayload && sessionPayload.rigobot
|
167
|
+
|
168
|
+
const isValidToken =
|
169
|
+
sessionExists && sessionPayload.rigobot.key ?
|
170
|
+
await isValidRigoToken(sessionPayload.rigobot.key) :
|
171
|
+
false
|
172
|
+
|
173
|
+
const isValidBreathecodeToken =
|
174
|
+
sessionExists && sessionPayload.token ?
|
175
|
+
await api.validateToken(sessionPayload.token) :
|
176
|
+
false
|
177
|
+
|
178
|
+
if (!sessionExists || !isValidBreathecodeToken || !isValidToken) {
|
159
179
|
Console.info(
|
160
180
|
"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"
|
161
181
|
)
|
@@ -188,16 +208,22 @@ const handleAILogic = async (tutorialDir: string, packageInfo: PackageInfo) => {
|
|
188
208
|
|
189
209
|
Console.success("🎉 Let's begin this learning journey!")
|
190
210
|
|
211
|
+
const targetAudience = await whichTargetAudience()
|
191
212
|
const contentIndex = await appendContentIndex()
|
192
213
|
|
193
214
|
let packageContext = `
|
194
215
|
\n
|
195
|
-
Title: ${packageInfo.title.us}
|
196
|
-
Description: ${packageInfo.description.us}
|
216
|
+
Title: "${packageInfo.title.us}"
|
217
|
+
Description: "${packageInfo.description.us}"
|
218
|
+
Target Audience: "${targetAudience}"
|
197
219
|
|
198
220
|
${
|
199
221
|
contentIndex ?
|
200
|
-
`Content Index submitted by the user, use this to guide your creation
|
222
|
+
`Content Index submitted by the user, use this to guide your creation. Keep in mind that your tutorial should contain these topics:
|
223
|
+
---
|
224
|
+
${contentIndex}
|
225
|
+
---
|
226
|
+
` :
|
201
227
|
""
|
202
228
|
}
|
203
229
|
|
@@ -211,9 +237,9 @@ const handleAILogic = async (tutorialDir: string, packageInfo: PackageInfo) => {
|
|
211
237
|
packageInfo.difficulty = difficulty
|
212
238
|
|
213
239
|
packageContext = `
|
214
|
-
Title: ${title}
|
215
|
-
Description: ${description}
|
216
|
-
|
240
|
+
Title: "${title}"
|
241
|
+
Description: "${description}"
|
242
|
+
Target Audience: "${targetAudience}"
|
217
243
|
List of exercises: ${steps.join(", ")}
|
218
244
|
`
|
219
245
|
const exercisesDir = path.join(tutorialDir, "exercises")
|
@@ -344,16 +370,21 @@ const getChoices = async (empty: boolean) => {
|
|
344
370
|
{
|
345
371
|
type: "select",
|
346
372
|
name: "grading",
|
347
|
-
message: "
|
373
|
+
message: "How are you going to grade students or yourself?",
|
348
374
|
choices: [
|
349
375
|
{
|
350
|
-
title:
|
351
|
-
|
376
|
+
title:
|
377
|
+
"No grading: No feedback or testing whatsoever, similar to a an interactive book.",
|
378
|
+
value: null,
|
352
379
|
},
|
353
|
-
{ title: "Isolated: Small separated exercises", value: "isolated" },
|
354
380
|
{
|
355
|
-
title: "
|
356
|
-
value:
|
381
|
+
title: "Isolated: Each step is a new separate exercise",
|
382
|
+
value: "isolated",
|
383
|
+
},
|
384
|
+
{
|
385
|
+
title:
|
386
|
+
"Step by step: Each step builds on top of each other like an incremental tutorial",
|
387
|
+
value: "incremental",
|
357
388
|
},
|
358
389
|
],
|
359
390
|
},
|
package/src/commands/logout.ts
CHANGED
@@ -1,43 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
async
|
32
|
-
const {
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
SessionManager.destroy()
|
40
|
-
}
|
41
|
-
}
|
42
|
-
|
43
|
-
export default LogoutCommand
|
1
|
+
import SessionCommand from "../utils/SessionCommand"
|
2
|
+
import SessionManager from "../managers/session"
|
3
|
+
import Console from "../utils/console"
|
4
|
+
|
5
|
+
class LogoutCommand extends SessionCommand {
|
6
|
+
static description = `Describe the command here
|
7
|
+
...
|
8
|
+
Extra documentation goes here
|
9
|
+
`
|
10
|
+
|
11
|
+
static flags: any = {
|
12
|
+
// name: flags.string({char: 'n', description: 'name to print'}),
|
13
|
+
}
|
14
|
+
|
15
|
+
static args = [
|
16
|
+
{
|
17
|
+
name: "package", // name of arg to show in help and reference with args[name]
|
18
|
+
required: false, // make the arg required with `required: true`
|
19
|
+
description:
|
20
|
+
"The unique string that identifies this package on learnpack", // help description
|
21
|
+
hidden: false, // hide this arg from help
|
22
|
+
},
|
23
|
+
]
|
24
|
+
|
25
|
+
async init() {
|
26
|
+
const { flags } = this.parse(LogoutCommand)
|
27
|
+
// await this.initSession(flags)
|
28
|
+
Console.debug("Logout command")
|
29
|
+
}
|
30
|
+
|
31
|
+
async run() {
|
32
|
+
// const {flags, args} = this.parse(LogoutCommand)
|
33
|
+
|
34
|
+
SessionManager.destroy()
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
export default LogoutCommand
|