@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.
@@ -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
@@ -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
- if (
155
- !sessionPayload ||
156
- !sessionPayload.rigobot ||
157
- (sessionPayload.token && !(await api.validateToken(sessionPayload.token)))
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: ${contentIndex}` :
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: "Is the auto-grading going to be isolated or incremental?",
373
+ message: "How are you going to grade students or yourself?",
348
374
  choices: [
349
375
  {
350
- title: "Incremental: Build on top of each other like a tutorial",
351
- value: "incremental",
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: "No grading: No feedback or testing whatsoever",
356
- value: null,
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
  },
@@ -1,43 +1,38 @@
1
- // import {Command, flags} from '@oclif/command'
2
- // import { prompt } from "enquirer"
3
- // import fetch from 'node-fetch'
4
- import SessionCommand from "../utils/SessionCommand"
5
- import SessionManager from "../managers/session"
6
- // import Console from '../utils/console'
7
- // import { replace } from 'node-emoji'
8
- // import { validURL } from "../utils/validators"
9
- // const BaseCommand from '../utils/BaseCommand');
10
-
11
- class LogoutCommand extends SessionCommand {
12
- static description = `Describe the command here
13
- ...
14
- Extra documentation goes here
15
- `
16
-
17
- static flags: any = {
18
- // name: flags.string({char: 'n', description: 'name to print'}),
19
- }
20
-
21
- static args = [
22
- {
23
- name: "package", // name of arg to show in help and reference with args[name]
24
- required: false, // make the arg required with `required: true`
25
- description:
26
- "The unique string that identifies this package on learnpack", // help description
27
- hidden: false, // hide this arg from help
28
- },
29
- ]
30
-
31
- async init() {
32
- const { flags } = this.parse(LogoutCommand)
33
- await this.initSession(flags)
34
- }
35
-
36
- async run() {
37
- // const {flags, args} = this.parse(LogoutCommand)
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