@learnpack/learnpack 2.0.19 → 2.0.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. package/README.md +10 -10
  2. package/lib/commands/audit.d.ts +6 -0
  3. package/lib/commands/audit.js +369 -0
  4. package/lib/commands/clean.d.ts +8 -0
  5. package/lib/commands/clean.js +25 -0
  6. package/lib/commands/download.d.ts +13 -0
  7. package/lib/commands/download.js +55 -0
  8. package/lib/commands/init.d.ts +9 -0
  9. package/lib/commands/init.js +117 -0
  10. package/lib/commands/login.d.ts +14 -0
  11. package/lib/commands/login.js +37 -0
  12. package/lib/commands/logout.d.ts +14 -0
  13. package/lib/commands/logout.js +37 -0
  14. package/lib/commands/publish.d.ts +14 -0
  15. package/lib/commands/publish.js +82 -0
  16. package/lib/commands/start.d.ts +7 -0
  17. package/lib/commands/start.js +165 -0
  18. package/lib/commands/test.d.ts +6 -0
  19. package/lib/commands/test.js +62 -0
  20. package/lib/managers/config/allowed_files.d.ts +5 -0
  21. package/lib/managers/config/allowed_files.js +30 -0
  22. package/lib/managers/config/defaults.d.ts +34 -0
  23. package/lib/managers/config/defaults.js +35 -0
  24. package/lib/managers/config/exercise.d.ts +36 -0
  25. package/lib/managers/config/exercise.js +230 -0
  26. package/lib/managers/config/index.d.ts +3 -0
  27. package/lib/managers/config/index.js +307 -0
  28. package/lib/managers/file.d.ts +13 -0
  29. package/lib/managers/file.js +134 -0
  30. package/lib/managers/gitpod.d.ts +3 -0
  31. package/lib/managers/gitpod.js +67 -0
  32. package/lib/managers/server/index.d.ts +6 -0
  33. package/lib/managers/server/index.js +51 -0
  34. package/lib/managers/server/routes.d.ts +4 -0
  35. package/lib/managers/server/routes.js +160 -0
  36. package/lib/managers/session.d.ts +3 -0
  37. package/lib/managers/session.js +104 -0
  38. package/lib/managers/socket.d.ts +3 -0
  39. package/lib/managers/socket.js +164 -0
  40. package/lib/managers/test.d.ts +0 -0
  41. package/lib/managers/test.js +84 -0
  42. package/lib/models/action.d.ts +2 -0
  43. package/lib/models/action.js +2 -0
  44. package/lib/models/audit-errors.d.ts +4 -0
  45. package/lib/models/audit-errors.js +2 -0
  46. package/lib/models/config-manager.d.ts +21 -0
  47. package/lib/models/config-manager.js +2 -0
  48. package/lib/models/config.d.ts +57 -0
  49. package/lib/models/config.js +2 -0
  50. package/lib/models/counter.d.ts +11 -0
  51. package/lib/models/counter.js +2 -0
  52. package/lib/models/errors.d.ts +15 -0
  53. package/lib/models/errors.js +2 -0
  54. package/lib/models/exercise-obj.d.ts +27 -0
  55. package/lib/models/exercise-obj.js +2 -0
  56. package/lib/models/file.d.ts +5 -0
  57. package/lib/models/file.js +2 -0
  58. package/lib/models/findings.d.ts +17 -0
  59. package/lib/models/findings.js +2 -0
  60. package/lib/models/flags.d.ts +10 -0
  61. package/lib/models/flags.js +2 -0
  62. package/lib/models/front-matter.d.ts +11 -0
  63. package/lib/models/front-matter.js +2 -0
  64. package/lib/models/gitpod-data.d.ts +16 -0
  65. package/lib/models/gitpod-data.js +2 -0
  66. package/lib/models/language.d.ts +4 -0
  67. package/lib/models/language.js +2 -0
  68. package/lib/models/package.d.ts +7 -0
  69. package/lib/models/package.js +2 -0
  70. package/lib/models/plugin-config.d.ts +16 -0
  71. package/lib/models/plugin-config.js +2 -0
  72. package/lib/models/session.d.ts +23 -0
  73. package/lib/models/session.js +2 -0
  74. package/lib/models/socket.d.ts +31 -0
  75. package/lib/models/socket.js +2 -0
  76. package/lib/models/status.d.ts +1 -0
  77. package/lib/models/status.js +2 -0
  78. package/lib/models/success-types.d.ts +1 -0
  79. package/lib/models/success-types.js +2 -0
  80. package/lib/plugin/command/compile.d.ts +6 -0
  81. package/lib/plugin/command/compile.js +18 -0
  82. package/lib/plugin/command/test.d.ts +6 -0
  83. package/lib/plugin/command/test.js +25 -0
  84. package/lib/plugin/index.d.ts +27 -0
  85. package/lib/plugin/index.js +7 -0
  86. package/lib/plugin/plugin.d.ts +8 -0
  87. package/lib/plugin/plugin.js +68 -0
  88. package/lib/plugin/utils.d.ts +16 -0
  89. package/lib/plugin/utils.js +58 -0
  90. package/lib/ui/download.d.ts +5 -0
  91. package/lib/ui/download.js +61 -0
  92. package/lib/utils/BaseCommand.d.ts +8 -0
  93. package/lib/utils/BaseCommand.js +41 -0
  94. package/lib/utils/SessionCommand.d.ts +10 -0
  95. package/lib/utils/SessionCommand.js +47 -0
  96. package/lib/utils/api.d.ts +12 -0
  97. package/lib/utils/api.js +173 -0
  98. package/lib/utils/audit.d.ts +13 -0
  99. package/lib/utils/audit.js +129 -0
  100. package/lib/utils/console.d.ts +12 -0
  101. package/lib/utils/console.js +19 -0
  102. package/lib/utils/errors.d.ts +17 -0
  103. package/lib/utils/errors.js +100 -0
  104. package/lib/utils/exercisesQueue.d.ts +9 -0
  105. package/lib/utils/exercisesQueue.js +38 -0
  106. package/lib/utils/fileQueue.d.ts +40 -0
  107. package/lib/utils/fileQueue.js +168 -0
  108. package/lib/utils/misc.d.ts +1 -0
  109. package/lib/utils/misc.js +23 -0
  110. package/lib/utils/validators.d.ts +5 -0
  111. package/lib/utils/validators.js +17 -0
  112. package/lib/utils/watcher.d.ts +2 -0
  113. package/lib/utils/watcher.js +24 -0
  114. package/oclif.manifest.json +1 -1
  115. package/package.json +1 -1
  116. package/src/commands/init.ts +172 -172
  117. package/src/utils/templates/incremental/.learn/exercises/01-hello-world/README.es.md +24 -24
  118. package/src/utils/templates/incremental/.learn/exercises/01-hello-world/README.md +24 -24
@@ -1,172 +1,172 @@
1
- import { flags } from "@oclif/command";
2
- import BaseCommand from "../utils/BaseCommand";
3
-
4
- // eslint-disable-next-line
5
- import * as fs from "fs-extra";
6
- import * as prompts from "prompts";
7
- import cli from "cli-ux";
8
- import * as eta from "eta";
9
-
10
- import Console from "../utils/console";
11
- import { ValidationError } from "../utils/errors";
12
- import defaults from "../managers/config/defaults";
13
-
14
- import * as path from "path";
15
-
16
- class InitComand extends BaseCommand {
17
- static description =
18
- "Create a new learning package: Book, Tutorial or Exercise";
19
-
20
- static flags = {
21
- ...BaseCommand.flags,
22
- grading: flags.help({ char: "h" }),
23
- };
24
-
25
- async run() {
26
- const { flags } = this.parse(InitComand);
27
-
28
- // if the folder/file .learn or .breathecode aleady exists
29
- await alreadyInitialized();
30
-
31
- const choices = await prompts([
32
- {
33
- type: "select",
34
- name: "grading",
35
- message: "Is the auto-grading going to be isolated or incremental?",
36
- choices: [
37
- {
38
- title: "Incremental: Build on top of each other like a tutorial",
39
- value: "incremental",
40
- },
41
- { title: "Isolated: Small separated exercises", value: "isolated" },
42
- {
43
- title: "No grading: No feedback or testing whatsoever",
44
- value: null,
45
- },
46
- ],
47
- },
48
- {
49
- type: "text",
50
- name: "title",
51
- initial: "My Interactive Tutorial",
52
- message: "Title for your tutorial? Press enter to leave as it is",
53
- },
54
- {
55
- type: "text",
56
- name: "description",
57
- initial: "",
58
- message: "Description for your tutorial? Press enter to leave blank",
59
- },
60
- {
61
- type: "select",
62
- name: "difficulty",
63
- message: "How difficulty will be to complete the tutorial?",
64
- choices: [
65
- { title: "Begginer (no previous experience)", value: "beginner" },
66
- { title: "Easy (just a bit of experience required)", value: "easy" },
67
- {
68
- title: "Intermediate (you need experience)",
69
- value: "intermediate",
70
- },
71
- { title: "Hard (master the topic)", value: "hard" },
72
- ],
73
- },
74
- {
75
- type: "text",
76
- name: "duration",
77
- initial: "1",
78
- message: "How many hours avg it takes to complete (number)?",
79
- validate: (value: string) => {
80
- const n = Math.floor(Number(value));
81
- return (
82
- n !== Number.POSITIVE_INFINITY && String(n) === value && n >= 0
83
- );
84
- },
85
- },
86
- ]);
87
-
88
- const packageInfo = {
89
- ...defaults.config,
90
- grading: choices.grading,
91
- difficulty: choices.difficulty,
92
- duration: parseInt(choices.duration),
93
- description: choices.description,
94
- title: choices.title,
95
- slug: choices.title
96
- .toLowerCase()
97
- .replace(/ /g, "-")
98
- .replace(/[^\w-]+/g, ""),
99
- };
100
-
101
- cli.action.start("Initializing package");
102
-
103
- const languages = ["en", "es"];
104
-
105
- const templatesDir = path.resolve(
106
- __dirname,
107
- "../utils/templates/" + choices.grading || "no-grading"
108
- );
109
- if (!fs.existsSync(templatesDir))
110
- throw ValidationError(`Template ${templatesDir} does not exists`);
111
- await fs.copySync(templatesDir, "./");
112
-
113
- // Creating README files
114
- // eslint-disable-next-line
115
- languages.forEach((language) => {
116
- const readmeFilename = `README${language !== "en" ? `.${language}` : ""}`;
117
- fs.writeFileSync(
118
- `./${readmeFilename}.md`,
119
- eta.render(
120
- fs.readFileSync(
121
- path.resolve(__dirname, `${templatesDir}/${readmeFilename}.ejs`),
122
- "utf-8"
123
- ),
124
- packageInfo
125
- )
126
- );
127
- if (fs.existsSync(`./${readmeFilename}.ejs`))
128
- fs.removeSync(`./${readmeFilename}.ejs`);
129
- });
130
-
131
- if (!fs.existsSync("./.gitignore"))
132
- fs.copyFile(
133
- path.resolve(__dirname, "../utils/templates/gitignore.txt"),
134
- "./.gitignore"
135
- );
136
- fs.writeFileSync("./learn.json", JSON.stringify(packageInfo, null, 2));
137
-
138
- cli.action.stop();
139
- Console.success(`😋 Package initialized successfully`);
140
- Console.help(
141
- `Start the exercises by running the following command on your terminal: $ learnpack start`
142
- );
143
- }
144
- }
145
-
146
- const alreadyInitialized = () =>
147
- new Promise((resolve, reject) => {
148
- fs.readdir("./", function (err: any, files: any) {
149
- files = files.filter((f: any) =>
150
- [".learn", "learn.json", "bc.json", ".breathecode"].includes(f)
151
- );
152
- if (err) {
153
- reject(ValidationError(err.message));
154
- throw ValidationError(err.message);
155
- } else if (files.length > 0) {
156
- reject(
157
- ValidationError(
158
- "It seems the package is already initialized because we've found the following files: " +
159
- files.join(",")
160
- )
161
- );
162
- throw ValidationError(
163
- "It seems the package is already initialized because we've found the following files: " +
164
- files.join(",")
165
- );
166
- }
167
-
168
- resolve(false);
169
- });
170
- });
171
-
172
- export default InitComand;
1
+ import { flags } from "@oclif/command";
2
+ import BaseCommand from "../utils/BaseCommand";
3
+
4
+ // eslint-disable-next-line
5
+ import * as fs from "fs-extra";
6
+ import * as prompts from "prompts";
7
+ import cli from "cli-ux";
8
+ import * as eta from "eta";
9
+
10
+ import Console from "../utils/console";
11
+ import { ValidationError } from "../utils/errors";
12
+ import defaults from "../managers/config/defaults";
13
+
14
+ import * as path from "path";
15
+
16
+ class InitComand extends BaseCommand {
17
+ static description =
18
+ "Create a new learning package: Book, Tutorial or Exercise";
19
+
20
+ static flags = {
21
+ ...BaseCommand.flags,
22
+ grading: flags.help({ char: "h" }),
23
+ };
24
+
25
+ async run() {
26
+ const { flags } = this.parse(InitComand);
27
+
28
+ // if the folder/file .learn or .breathecode aleady exists
29
+ await alreadyInitialized();
30
+
31
+ const choices = await prompts([
32
+ {
33
+ type: "select",
34
+ name: "grading",
35
+ message: "Is the auto-grading going to be isolated or incremental?",
36
+ choices: [
37
+ {
38
+ title: "Incremental: Build on top of each other like a tutorial",
39
+ value: "incremental",
40
+ },
41
+ { title: "Isolated: Small separated exercises", value: "isolated" },
42
+ {
43
+ title: "No grading: No feedback or testing whatsoever",
44
+ value: null,
45
+ },
46
+ ],
47
+ },
48
+ {
49
+ type: "text",
50
+ name: "title",
51
+ initial: "My Interactive Tutorial",
52
+ message: "Title for your tutorial? Press enter to leave as it is",
53
+ },
54
+ {
55
+ type: "text",
56
+ name: "description",
57
+ initial: "",
58
+ message: "Description for your tutorial? Press enter to leave blank",
59
+ },
60
+ {
61
+ type: "select",
62
+ name: "difficulty",
63
+ message: "How difficulty will be to complete the tutorial?",
64
+ choices: [
65
+ { title: "Begginer (no previous experience)", value: "beginner" },
66
+ { title: "Easy (just a bit of experience required)", value: "easy" },
67
+ {
68
+ title: "Intermediate (you need experience)",
69
+ value: "intermediate",
70
+ },
71
+ { title: "Hard (master the topic)", value: "hard" },
72
+ ],
73
+ },
74
+ {
75
+ type: "text",
76
+ name: "duration",
77
+ initial: "1",
78
+ message: "How many hours avg it takes to complete (number)?",
79
+ validate: (value: string) => {
80
+ const n = Math.floor(Number(value));
81
+ return (
82
+ n !== Number.POSITIVE_INFINITY && String(n) === value && n >= 0
83
+ );
84
+ },
85
+ },
86
+ ]);
87
+
88
+ const packageInfo = {
89
+ ...defaults.config,
90
+ grading: choices.grading,
91
+ difficulty: choices.difficulty,
92
+ duration: parseInt(choices.duration),
93
+ description: choices.description,
94
+ title: choices.title,
95
+ slug: choices.title
96
+ .toLowerCase()
97
+ .replace(/ /g, "-")
98
+ .replace(/[^\w-]+/g, ""),
99
+ };
100
+
101
+ cli.action.start("Initializing package");
102
+
103
+ const languages = ["en", "es"];
104
+
105
+ const templatesDir = path.resolve(
106
+ __dirname,
107
+ "../../src/utils/templates/" + choices.grading || "no-grading"
108
+ );
109
+ if (!fs.existsSync(templatesDir))
110
+ throw ValidationError(`Template ${templatesDir} does not exists`);
111
+ await fs.copySync(templatesDir, "./");
112
+
113
+ // Creating README files
114
+ // eslint-disable-next-line
115
+ languages.forEach((language) => {
116
+ const readmeFilename = `README${language !== "en" ? `.${language}` : ""}`;
117
+ fs.writeFileSync(
118
+ `./${readmeFilename}.md`,
119
+ eta.render(
120
+ fs.readFileSync(
121
+ path.resolve(__dirname, `${templatesDir}/${readmeFilename}.ejs`),
122
+ "utf-8"
123
+ ),
124
+ packageInfo
125
+ )
126
+ );
127
+ if (fs.existsSync(`./${readmeFilename}.ejs`))
128
+ fs.removeSync(`./${readmeFilename}.ejs`);
129
+ });
130
+
131
+ if (!fs.existsSync("./.gitignore"))
132
+ fs.copyFile(
133
+ path.resolve(__dirname, "../../src/utils/templates/gitignore.txt"),
134
+ "./.gitignore"
135
+ );
136
+ fs.writeFileSync("./learn.json", JSON.stringify(packageInfo, null, 2));
137
+
138
+ cli.action.stop();
139
+ Console.success(`😋 Package initialized successfully`);
140
+ Console.help(
141
+ `Start the exercises by running the following command on your terminal: $ learnpack start`
142
+ );
143
+ }
144
+ }
145
+
146
+ const alreadyInitialized = () =>
147
+ new Promise((resolve, reject) => {
148
+ fs.readdir("./", function (err: any, files: any) {
149
+ files = files.filter((f: any) =>
150
+ [".learn", "learn.json", "bc.json", ".breathecode"].includes(f)
151
+ );
152
+ if (err) {
153
+ reject(ValidationError(err.message));
154
+ throw ValidationError(err.message);
155
+ } else if (files.length > 0) {
156
+ reject(
157
+ ValidationError(
158
+ "It seems the package is already initialized because we've found the following files: " +
159
+ files.join(",")
160
+ )
161
+ );
162
+ throw ValidationError(
163
+ "It seems the package is already initialized because we've found the following files: " +
164
+ files.join(",")
165
+ );
166
+ }
167
+
168
+ resolve(false);
169
+ });
170
+ });
171
+
172
+ export default InitComand;
@@ -1,24 +1,24 @@
1
- # `01` Hello World
2
-
3
- Puedes tener un archivo README el cual será como una página de un libro, sin archivos de código.
4
-
5
- También puedes agregar un archivo `README.[lenguaje].md` para traducciones, por ejemplo `README.es.md` para español.
6
-
7
- ## Inserta videos
8
-
9
- Si quieres incluir algún video introductorio para cada ejercicio, agrega la propiedad `intro` en el inicio del README.md para ese ejercicio en particular:
10
-
11
- ```markdown
12
- ---
13
- intro: "https://www.youtube.com/watch?v=YkgkThdzX-8"
14
- ---
15
- ```
16
-
17
- Tambien puedes agregar un video explicando la solución para cada ejercicio agregando la propiedad `tutorial` al inicio del markdown del README.md correspondiente:
18
-
19
- ```markdown
20
- ---
21
- intro: "https://www.youtube.com/watch?v=YkgkThdzX-8"
22
- tutorial: "https://www.youtube.com/watch?v=YkgkThdzX-8"
23
- ---
24
- ```
1
+ # `01` Hello World
2
+
3
+ Puedes tener un archivo README el cual será como una página de un libro, sin archivos de código.
4
+
5
+ También puedes agregar un archivo `README.[lenguaje].md` para traducciones, por ejemplo `README.es.md` para español.
6
+
7
+ ## Inserta videos
8
+
9
+ Si quieres incluir algún video introductorio para cada ejercicio, agrega la propiedad `intro` en el inicio del README.md para ese ejercicio en particular:
10
+
11
+ ```markdown
12
+ ---
13
+ intro: "https://www.youtube.com/watch?v=YkgkThdzX-8"
14
+ ---
15
+ ```
16
+
17
+ Tambien puedes agregar un video explicando la solución para cada ejercicio agregando la propiedad `tutorial` al inicio del markdown del README.md correspondiente:
18
+
19
+ ```markdown
20
+ ---
21
+ intro: "https://www.youtube.com/watch?v=YkgkThdzX-8"
22
+ tutorial: "https://www.youtube.com/watch?v=YkgkThdzX-8"
23
+ ---
24
+ ```
@@ -1,24 +1,24 @@
1
- # `01` Hello World
2
-
3
- You can have just a README file and it will be like a page in a book, no code files.
4
-
5
- You can also add a `README.[lang].md` file for translations, for example: `README.es.md` for spanish.
6
-
7
- ## Video compatibility
8
-
9
- If you want to include some video introduction for each exercise, add a `intro` property in the markdown frontmatter of the README.md for that particular exercise:
10
-
11
- ```markdown
12
- ---
13
- intro: "https://www.youtube.com/watch?v=YkgkThdzX-8"
14
- ---
15
- ```
16
-
17
- You can also add a video solution for each exercise by adding a `tutorial` property on the markdown frontmatter of it's README.md:
18
-
19
- ```markdown
20
- ---
21
- intro: "https://www.youtube.com/watch?v=YkgkThdzX-8"
22
- tutorial: "https://www.youtube.com/watch?v=YkgkThdzX-8"
23
- ---
24
- ```
1
+ # `01` Hello World
2
+
3
+ You can have just a README file and it will be like a page in a book, no code files.
4
+
5
+ You can also add a `README.[lang].md` file for translations, for example: `README.es.md` for spanish.
6
+
7
+ ## Video compatibility
8
+
9
+ If you want to include some video introduction for each exercise, add a `intro` property in the markdown frontmatter of the README.md for that particular exercise:
10
+
11
+ ```markdown
12
+ ---
13
+ intro: "https://www.youtube.com/watch?v=YkgkThdzX-8"
14
+ ---
15
+ ```
16
+
17
+ You can also add a video solution for each exercise by adding a `tutorial` property on the markdown frontmatter of it's README.md:
18
+
19
+ ```markdown
20
+ ---
21
+ intro: "https://www.youtube.com/watch?v=YkgkThdzX-8"
22
+ tutorial: "https://www.youtube.com/watch?v=YkgkThdzX-8"
23
+ ---
24
+ ```