@learnpack/learnpack 2.1.54 → 2.1.56
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +10 -10
- package/lib/commands/start.js +23 -16
- package/lib/managers/socket.js +4 -1
- package/lib/models/config.d.ts +1 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/start.ts +30 -27
- package/src/managers/socket.ts +4 -1
- package/src/models/config.ts +93 -91
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.
|
24
|
+
@learnpack/learnpack/2.1.56 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.
|
77
|
+
_See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.56/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.
|
92
|
+
_See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.56/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.
|
110
|
+
_See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.56/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.
|
141
|
+
_See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.56/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.
|
159
|
+
_See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.56/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.
|
177
|
+
_See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.56/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.
|
312
|
+
_See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.56/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.
|
333
|
+
_See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.56/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.
|
347
|
+
_See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v2.1.56/src\commands\test.ts)_
|
348
348
|
<!-- commandsstop -->
|
349
349
|
|
350
350
|
> > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
|
package/lib/commands/start.js
CHANGED
@@ -166,26 +166,33 @@ class StartCommand extends SessionCommand_1.default {
|
|
166
166
|
exercise,
|
167
167
|
telemetry: telemetry_1.default,
|
168
168
|
});
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
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
|
-
|
186
|
-
|
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
|
});
|
package/lib/managers/socket.js
CHANGED
@@ -151,7 +151,10 @@ const SocketManager = {
|
|
151
151
|
this.log((type + "-success"), [stdout]);
|
152
152
|
},
|
153
153
|
error: function (type, stdout) {
|
154
|
-
|
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({
|
package/lib/models/config.d.ts
CHANGED
package/oclif.manifest.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":"2.1.
|
1
|
+
{"version":"2.1.56","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
package/src/commands/start.ts
CHANGED
@@ -289,37 +289,40 @@ export default class StartCommand extends SessionCommand {
|
|
289
289
|
telemetry: TelemetryManager,
|
290
290
|
})
|
291
291
|
|
292
|
-
|
293
|
-
|
294
|
-
|
292
|
+
try {
|
293
|
+
if (!configObject.config) {
|
294
|
+
return
|
295
|
+
}
|
295
296
|
|
296
|
-
|
297
|
-
|
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
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
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()
|
package/src/managers/socket.ts
CHANGED
@@ -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
|
-
|
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) {
|
package/src/models/config.ts
CHANGED
@@ -1,91 +1,93 @@
|
|
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
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
+
|
82
|
+
runHook: (...agrs: Array<any>) => void;
|
83
|
+
testingFinishedCallback: (arg: any | undefined) => void;
|
84
|
+
}
|
85
|
+
|
86
|
+
export interface IConfigObj {
|
87
|
+
session?: number;
|
88
|
+
currentExercise?: any;
|
89
|
+
config?: IConfig;
|
90
|
+
exercises?: Array<IExercise>;
|
91
|
+
confPath?: IConfigPath;
|
92
|
+
address?: string; // Maybe
|
93
|
+
}
|