@learnpack/learnpack 2.1.54 → 2.1.57

Sign up to get free protection for your applications and to get access to all the features.
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/2.1.54 win32-x64 node-v20.10.0
24
+ @learnpack/learnpack/2.1.57 win32-x64 node-v20.10.0
25
25
  $ learnpack --help [COMMAND]
26
26
  USAGE
27
27
  $ learnpack COMMAND
@@ -74,7 +74,7 @@ DESCRIPTION
74
74
  12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)
75
75
  ```
76
76
 
77
- _See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.54/src\commands\audit.ts)_
77
+ _See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.57/src\commands\audit.ts)_
78
78
 
79
79
  ## `learnpack clean`
80
80
 
@@ -89,7 +89,7 @@ DESCRIPTION
89
89
  Extra documentation goes here
90
90
  ```
91
91
 
92
- _See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.54/src\commands\clean.ts)_
92
+ _See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.57/src\commands\clean.ts)_
93
93
 
94
94
  ## `learnpack download [PACKAGE]`
95
95
 
@@ -107,7 +107,7 @@ DESCRIPTION
107
107
  Extra documentation goes here
108
108
  ```
109
109
 
110
- _See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.54/src\commands\download.ts)_
110
+ _See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.57/src\commands\download.ts)_
111
111
 
112
112
  ## `learnpack help [COMMAND]`
113
113
 
@@ -138,7 +138,7 @@ OPTIONS
138
138
  -h, --grading show CLI help
139
139
  ```
140
140
 
141
- _See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.54/src\commands\init.ts)_
141
+ _See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.57/src\commands\init.ts)_
142
142
 
143
143
  ## `learnpack login [PACKAGE]`
144
144
 
@@ -156,7 +156,7 @@ DESCRIPTION
156
156
  Extra documentation goes here
157
157
  ```
158
158
 
159
- _See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.54/src\commands\login.ts)_
159
+ _See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.57/src\commands\login.ts)_
160
160
 
161
161
  ## `learnpack logout [PACKAGE]`
162
162
 
@@ -174,7 +174,7 @@ DESCRIPTION
174
174
  Extra documentation goes here
175
175
  ```
176
176
 
177
- _See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.54/src\commands\logout.ts)_
177
+ _See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.57/src\commands\logout.ts)_
178
178
 
179
179
  ## `learnpack plugins`
180
180
 
@@ -309,7 +309,7 @@ DESCRIPTION
309
309
  Extra documentation goes here
310
310
  ```
311
311
 
312
- _See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.54/src\commands\publish.ts)_
312
+ _See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.57/src\commands\publish.ts)_
313
313
 
314
314
  ## `learnpack start`
315
315
 
@@ -330,7 +330,7 @@ OPTIONS
330
330
  -w, --watch Watch for file changes
331
331
  ```
332
332
 
333
- _See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.54/src\commands\start.ts)_
333
+ _See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.57/src\commands\start.ts)_
334
334
 
335
335
  ## `learnpack test [EXERCISESLUG]`
336
336
 
@@ -344,7 +344,7 @@ ARGUMENTS
344
344
  EXERCISESLUG The name of the exercise to test
345
345
  ```
346
346
 
347
- _See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.54/src\commands\test.ts)_
347
+ _See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.57/src\commands\test.ts)_
348
348
  <!-- commandsstop -->
349
349
 
350
350
  > > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
@@ -166,26 +166,33 @@ class StartCommand extends SessionCommand_1.default {
166
166
  exercise,
167
167
  telemetry: telemetry_1.default,
168
168
  });
169
- // Check if ${configObject.dirPath}/reports/${exercise.slug}/report.md or /reports/${exercise.slug}/report.txt exists
170
- // If it does, then send the content of the file to the frontend
171
- // If it doesn't, then send an empty object
172
- if (!configObject.config) {
173
- return;
174
- }
175
- const markdownReportPath = path.join(configObject.config.dirPath, "reports", `${exercise.slug}`, "report.md");
176
- const textReportPath = path.join(configObject.config.dirPath, "reports", `${exercise.slug}`, "report.txt");
177
- const reportExists = fs.existsSync(markdownReportPath) || fs.existsSync(textReportPath);
178
- if (reportExists) {
179
- try {
180
- const reportContent =
181
- // fs.readFileSync(markdownReportPath, "utf8") ||
182
- fs.readFileSync(textReportPath, "utf8");
169
+ try {
170
+ if (!configObject.config) {
171
+ return;
172
+ }
173
+ const getReportPath = (ext) => {
174
+ var _a;
175
+ if (!((_a = configObject.config) === null || _a === void 0 ? void 0 : _a.dirPath)) {
176
+ throw new Error("No directory path found in config");
177
+ }
178
+ return path.join(configObject.config.dirPath, "reports", `${exercise.slug}`, `report.${ext}`);
179
+ };
180
+ const markdownReportPath = getReportPath("md");
181
+ const textReportPath = getReportPath("txt");
182
+ if (fs.existsSync(markdownReportPath)) {
183
+ let reportContent = "";
184
+ reportContent = fs.readFileSync(markdownReportPath, "utf8");
183
185
  socket_1.default.dialog(reportContent);
184
186
  }
185
- catch (error) {
186
- console.log(error);
187
+ if (fs.existsSync(textReportPath)) {
188
+ let reportContent = "";
189
+ reportContent = fs.readFileSync(textReportPath, "utf8");
190
+ socket_1.default.dialog(reportContent);
187
191
  }
188
192
  }
193
+ catch (error) {
194
+ console_1.default.debug("Error finding report for exercise.slug", error);
195
+ }
189
196
  (_b = this.configManager) === null || _b === void 0 ? void 0 : _b.save();
190
197
  return true;
191
198
  });
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const path = require("path");
4
4
  const fs = require("fs");
5
5
  const shell = require("shelljs");
6
+ const child_process_1 = require("child_process");
7
+ const util_1 = require("util");
8
+ const execAsync = util_1.promisify(child_process_1.exec);
6
9
  const console_1 = require("../../utils/console");
7
10
  const watcher_1 = require("../../utils/watcher");
8
11
  const errors_1 = require("../../utils/errors");
@@ -146,6 +149,43 @@ exports.default = async ({ grading, mode, disableGrading, version, }) => {
146
149
  }
147
150
  configObj.config.dirPath = "./" + confPath.base;
148
151
  configObj.config.exercisesPath = getExercisesPath(confPath.base) || "./";
152
+ const allowedCommands = new Set(["ls", "pwd", "echo", "node", "python"]);
153
+ if (configObj.config.variables) {
154
+ const variableKeys = Object.keys(configObj.config.variables);
155
+ const promises = [];
156
+ for (const v of variableKeys) {
157
+ if (Object.prototype.hasOwnProperty.call(configObj.config.variables, v)) {
158
+ const variable = configObj.config.variables[v];
159
+ if (typeof variable === "string") {
160
+ continue;
161
+ }
162
+ const type = variable.type;
163
+ if (type === "command") {
164
+ const promise = (async () => {
165
+ try {
166
+ // Validate the command
167
+ if (!allowedCommands.has(variable.source.split(" ")[0])) {
168
+ throw new Error("Command not allowed");
169
+ }
170
+ // Execute the code and replace the value
171
+ const { stdout } = await execAsync(variable.source);
172
+ if (!configObj.config || !configObj.config.variables)
173
+ return;
174
+ configObj.config.variables[v] = stdout.trim();
175
+ }
176
+ catch (error) {
177
+ console.error(`Error executing code: ${error}`);
178
+ }
179
+ })();
180
+ promises.push(promise);
181
+ }
182
+ else if (type === "string") {
183
+ configObj.config.variables[v] = variable.source;
184
+ }
185
+ }
186
+ }
187
+ await Promise.all(promises);
188
+ }
149
189
  return {
150
190
  validLanguages: {},
151
191
  get: () => configObj,
@@ -151,7 +151,10 @@ const SocketManager = {
151
151
  this.log((type + "-success"), [stdout]);
152
152
  },
153
153
  error: function (type, stdout) {
154
- fileQueue_1.default.dispatcher().enqueue(fileQueue_1.default.events.OPEN_TERMINAL, "");
154
+ var _a;
155
+ if (!((_a = this.config) === null || _a === void 0 ? void 0 : _a.editor.hideTerminal)) {
156
+ fileQueue_1.default.dispatcher().enqueue(fileQueue_1.default.events.OPEN_TERMINAL, "");
157
+ }
155
158
  this.log(type, [stdout]);
156
159
  if (this.isTestingEnvironment) {
157
160
  this.onTestingFinished({
@@ -13,6 +13,7 @@ export interface IEditor {
13
13
  mode?: TMode;
14
14
  version: string;
15
15
  agent?: TAgent;
16
+ hideTerminal?: boolean;
16
17
  }
17
18
  export interface TEntries {
18
19
  python3?: string;
@@ -54,9 +55,17 @@ export interface IConfig {
54
55
  videoSolutions?: boolean;
55
56
  skills: Array<string>;
56
57
  telemetry?: TTelemetryUrls;
58
+ variables?: TVariables;
57
59
  runHook: (...agrs: Array<any>) => void;
58
60
  testingFinishedCallback: (arg: any | undefined) => void;
59
61
  }
62
+ declare type TVariable = {
63
+ type: "command" | "string";
64
+ source: string;
65
+ };
66
+ declare type TVariables = {
67
+ [key: string]: TVariable | string;
68
+ };
60
69
  export interface IConfigObj {
61
70
  session?: number;
62
71
  currentExercise?: any;
@@ -1 +1 @@
1
- {"version":"2.1.54","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":{},"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":{"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":"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}]},"start":{"id":"start","description":"Runs a small server with all the exercise instructions","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"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":{},"args":[{"name":"exerciseSlug","description":"The name of the exercise to test","required":false,"hidden":false}]}}}
1
+ {"version":"2.1.57","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":{},"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":{"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":"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}]},"start":{"id":"start","description":"Runs a small server with all the exercise instructions","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"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":{},"args":[{"name":"exerciseSlug","description":"The name of the exercise to test","required":false,"hidden":false}]}}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@learnpack/learnpack",
3
3
  "description": "Create, sell or download and take learning amazing learning packages",
4
- "version": "2.1.54",
4
+ "version": "2.1.57",
5
5
  "author": "Alejandro Sanchez @alesanchezr",
6
6
  "contributors": [
7
7
  {
@@ -289,37 +289,40 @@ export default class StartCommand extends SessionCommand {
289
289
  telemetry: TelemetryManager,
290
290
  })
291
291
 
292
- // Check if ${configObject.dirPath}/reports/${exercise.slug}/report.md or /reports/${exercise.slug}/report.txt exists
293
- // If it does, then send the content of the file to the frontend
294
- // If it doesn't, then send an empty object
292
+ try {
293
+ if (!configObject.config) {
294
+ return
295
+ }
295
296
 
296
- if (!configObject.config) {
297
- return
298
- }
297
+ const getReportPath = (ext: string) => {
298
+ if (!configObject.config?.dirPath) {
299
+ throw new Error("No directory path found in config")
300
+ }
301
+
302
+ return path.join(
303
+ configObject.config.dirPath,
304
+ "reports",
305
+ `${exercise.slug}`,
306
+ `report.${ext}`
307
+ )
308
+ }
299
309
 
300
- const markdownReportPath = path.join(
301
- configObject.config.dirPath,
302
- "reports",
303
- `${exercise.slug}`,
304
- "report.md"
305
- )
306
- const textReportPath = path.join(
307
- configObject.config.dirPath,
308
- "reports",
309
- `${exercise.slug}`,
310
- "report.txt"
311
- )
312
- const reportExists =
313
- fs.existsSync(markdownReportPath) || fs.existsSync(textReportPath)
314
- if (reportExists) {
315
- try {
316
- const reportContent =
317
- // fs.readFileSync(markdownReportPath, "utf8") ||
318
- fs.readFileSync(textReportPath, "utf8")
310
+ const markdownReportPath = getReportPath("md")
311
+ const textReportPath = getReportPath("txt")
312
+
313
+ if (fs.existsSync(markdownReportPath)) {
314
+ let reportContent = ""
315
+ reportContent = fs.readFileSync(markdownReportPath, "utf8")
316
+ socket.dialog(reportContent)
317
+ }
318
+
319
+ if (fs.existsSync(textReportPath)) {
320
+ let reportContent = ""
321
+ reportContent = fs.readFileSync(textReportPath, "utf8")
319
322
  socket.dialog(reportContent)
320
- } catch (error) {
321
- console.log(error)
322
323
  }
324
+ } catch (error) {
325
+ Console.debug("Error finding report for exercise.slug", error)
323
326
  }
324
327
 
325
328
  this.configManager?.save()
@@ -1,6 +1,11 @@
1
1
  import * as path from "path"
2
2
  import * as fs from "fs"
3
3
  import * as shell from "shelljs"
4
+ import { exec } from "child_process"
5
+ import { promisify } from "util"
6
+
7
+ const execAsync = promisify(exec)
8
+
4
9
  import Console from "../../utils/console"
5
10
  import watch from "../../utils/watcher"
6
11
  import {
@@ -207,6 +212,50 @@ configObj.config.editor.version = version
207
212
  configObj.config.dirPath = "./" + confPath.base
208
213
  configObj.config.exercisesPath = getExercisesPath(confPath.base) || "./"
209
214
 
215
+ const allowedCommands = new Set(["ls", "pwd", "echo", "node", "python"])
216
+
217
+ if (configObj.config.variables) {
218
+ const variableKeys = Object.keys(configObj.config.variables)
219
+ const promises = []
220
+
221
+ for (const v of variableKeys) {
222
+ if (Object.prototype.hasOwnProperty.call(configObj.config.variables, v)) {
223
+ const variable = configObj.config.variables[v]
224
+
225
+ if (typeof variable === "string") {
226
+ continue
227
+ }
228
+
229
+ const type = variable.type
230
+
231
+ if (type === "command") {
232
+ const promise = (async () => {
233
+ try {
234
+ // Validate the command
235
+ if (!allowedCommands.has(variable.source.split(" ")[0])) {
236
+ throw new Error("Command not allowed")
237
+ }
238
+
239
+ // Execute the code and replace the value
240
+ const { stdout } = await execAsync(variable.source)
241
+ if (!configObj.config || !configObj.config.variables)
242
+ return
243
+
244
+ configObj.config.variables[v] = stdout.trim()
245
+ } catch (error) {
246
+ console.error(`Error executing code: ${error}`)
247
+ }
248
+ })()
249
+ promises.push(promise)
250
+ } else if (type === "string") {
251
+ configObj.config.variables[v] = variable.source
252
+ }
253
+ }
254
+ }
255
+
256
+ await Promise.all(promises)
257
+ }
258
+
210
259
  return {
211
260
  validLanguages: {},
212
261
  get: () => configObj,
@@ -224,7 +224,10 @@ actions = [actions]
224
224
  this.log((type + "-success") as TSuccessType, [stdout])
225
225
  },
226
226
  error: function (type: TStatus, stdout: string) {
227
- queue.dispatcher().enqueue(queue.events.OPEN_TERMINAL, "")
227
+ if (!this.config?.editor.hideTerminal) {
228
+ queue.dispatcher().enqueue(queue.events.OPEN_TERMINAL, "")
229
+ }
230
+
228
231
  this.log(type, [stdout])
229
232
 
230
233
  if (this.isTestingEnvironment) {
@@ -1,91 +1,102 @@
1
- import { IExercise } from "./exercise-obj"
2
- import { TTelemetryUrls } from "../managers/telemetry"
3
-
4
- export type TGrading = "isolated" | "incremental" | "no-grading";
5
-
6
- export type TMode = "preview" | "extension";
7
-
8
- export type TConfigAction =
9
- | "test"
10
- | "build"
11
- | "tutorial"
12
- | "reset"
13
- | "generate";
14
-
15
- export type TConfigObjAttributes = "config" | "exercises" | "grading";
16
-
17
- export type TCompiler =
18
- | "webpack"
19
- | "vanillajs"
20
- | "react"
21
- | "html"
22
- | "node"
23
- | "python"
24
- | "css";
25
-
26
- export interface IConfigPath {
27
- base: string;
28
- }
29
-
30
- type TAgent = "vscode" | "os";
31
-
32
- export interface IEditor {
33
- mode?: TMode;
34
- version: string;
35
- agent?: TAgent;
36
- }
37
-
38
- export interface TEntries {
39
- python3?: string;
40
- html?: string;
41
- node?: string;
42
- react?: string;
43
- java?: string;
44
- }
45
-
46
- export interface IConfig {
47
- os: string;
48
- port?: string;
49
- repository?: string;
50
- description?: string;
51
- slug?: string;
52
- dirPath: string;
53
- preview?: string; // Picture thumbnail
54
- entries: TEntries;
55
- grading: TGrading;
56
- configPath: string;
57
- translations: Array<string>;
58
- outputPath?: string;
59
- editor: IEditor;
60
- language: string;
61
- title: string;
62
- duration: number;
63
- difficulty?: string;
64
- exercisesPath: string;
65
- disableGrading: boolean; // TODO: Deprecate
66
- actions: Array<string>; // TODO: Deprecate
67
- autoPlay: boolean;
68
- projectType?: string;
69
- // TODO: nameExerciseValidation
70
- contact?: string;
71
- disabledActions?: Array<TConfigAction>;
72
- compiler: TCompiler;
73
- compilers: Array<TCompiler>;
74
- publicPath: string;
75
- publicUrl?: string;
76
- bugsLink?: string;
77
- videoSolutions?: boolean;
78
- skills: Array<string>;
79
- telemetry?: TTelemetryUrls;
80
- runHook: (...agrs: Array<any>) => void;
81
- testingFinishedCallback: (arg: any | undefined) => void;
82
- }
83
-
84
- export interface IConfigObj {
85
- session?: number;
86
- currentExercise?: any;
87
- config?: IConfig;
88
- exercises?: Array<IExercise>;
89
- confPath?: IConfigPath;
90
- address?: string; // Maybe
91
- }
1
+ import { IExercise } from "./exercise-obj"
2
+ import { TTelemetryUrls } from "../managers/telemetry"
3
+
4
+ export type TGrading = "isolated" | "incremental" | "no-grading";
5
+
6
+ export type TMode = "preview" | "extension";
7
+
8
+ export type TConfigAction =
9
+ | "test"
10
+ | "build"
11
+ | "tutorial"
12
+ | "reset"
13
+ | "generate";
14
+
15
+ export type TConfigObjAttributes = "config" | "exercises" | "grading";
16
+
17
+ export type TCompiler =
18
+ | "webpack"
19
+ | "vanillajs"
20
+ | "react"
21
+ | "html"
22
+ | "node"
23
+ | "python"
24
+ | "css";
25
+
26
+ export interface IConfigPath {
27
+ base: string;
28
+ }
29
+
30
+ type TAgent = "vscode" | "os";
31
+
32
+ export interface IEditor {
33
+ mode?: TMode;
34
+ version: string;
35
+ agent?: TAgent;
36
+ hideTerminal?: boolean;
37
+ }
38
+
39
+ export interface TEntries {
40
+ python3?: string;
41
+ html?: string;
42
+ node?: string;
43
+ react?: string;
44
+ java?: string;
45
+ }
46
+
47
+ export interface IConfig {
48
+ os: string;
49
+ port?: string;
50
+ repository?: string;
51
+ description?: string;
52
+ slug?: string;
53
+ dirPath: string;
54
+ preview?: string; // Picture thumbnail
55
+ entries: TEntries;
56
+ grading: TGrading;
57
+ configPath: string;
58
+ translations: Array<string>;
59
+ outputPath?: string;
60
+ editor: IEditor;
61
+ language: string;
62
+ title: string;
63
+ duration: number;
64
+ difficulty?: string;
65
+ exercisesPath: string;
66
+ disableGrading: boolean; // TODO: Deprecate
67
+ actions: Array<string>; // TODO: Deprecate
68
+ autoPlay: boolean;
69
+ projectType?: string;
70
+ // TODO: nameExerciseValidation
71
+ contact?: string;
72
+ disabledActions?: Array<TConfigAction>;
73
+ compiler: TCompiler;
74
+ compilers: Array<TCompiler>;
75
+ publicPath: string;
76
+ publicUrl?: string;
77
+ bugsLink?: string;
78
+ videoSolutions?: boolean;
79
+ skills: Array<string>;
80
+ telemetry?: TTelemetryUrls;
81
+ variables?: TVariables;
82
+
83
+ runHook: (...agrs: Array<any>) => void;
84
+ testingFinishedCallback: (arg: any | undefined) => void;
85
+ }
86
+
87
+ type TVariable = {
88
+ type: "command" | "string";
89
+ source: string;
90
+ };
91
+ type TVariables = {
92
+ [key: string]: TVariable | string;
93
+ };
94
+
95
+ export interface IConfigObj {
96
+ session?: number;
97
+ currentExercise?: any;
98
+ config?: IConfig;
99
+ exercises?: Array<IExercise>;
100
+ confPath?: IConfigPath;
101
+ address?: string; // Maybe
102
+ }