@learnpack/learnpack 2.1.52 → 2.1.54
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 +22 -0
- package/lib/managers/socket.js +7 -0
- package/lib/managers/telemetry.d.ts +1 -1
- package/lib/managers/telemetry.js +10 -2
- package/lib/models/action.d.ts +1 -1
- package/lib/models/socket.d.ts +1 -0
- package/lib/utils/checkNotInstalled.js +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/start.ts +355 -320
- package/src/managers/socket.ts +9 -0
- package/src/managers/telemetry.ts +353 -346
- package/src/models/action.ts +11 -10
- package/src/models/socket.ts +60 -59
- package/src/models/status.ts +16 -16
- package/src/utils/checkNotInstalled.ts +3 -4
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.54 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.54/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.54/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.54/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.54/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.54/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.54/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.54/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.54/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.54/src\commands\test.ts)_
|
348
348
|
<!-- commandsstop -->
|
349
349
|
|
350
350
|
> > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
|
package/lib/commands/start.js
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
// import path from "path";
|
4
4
|
const command_1 = require("@oclif/command");
|
5
|
+
const fs = require("fs");
|
6
|
+
const path = require("path");
|
5
7
|
const SessionCommand_1 = require("../utils/SessionCommand");
|
6
8
|
const console_1 = require("../utils/console");
|
7
9
|
const socket_1 = require("../managers/socket");
|
@@ -164,6 +166,26 @@ class StartCommand extends SessionCommand_1.default {
|
|
164
166
|
exercise,
|
165
167
|
telemetry: telemetry_1.default,
|
166
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");
|
183
|
+
socket_1.default.dialog(reportContent);
|
184
|
+
}
|
185
|
+
catch (error) {
|
186
|
+
console.log(error);
|
187
|
+
}
|
188
|
+
}
|
167
189
|
(_b = this.configManager) === null || _b === void 0 ? void 0 : _b.save();
|
168
190
|
return true;
|
169
191
|
});
|
package/lib/managers/socket.js
CHANGED
@@ -162,6 +162,13 @@ const SocketManager = {
|
|
162
162
|
complete: function () {
|
163
163
|
console.log("complete");
|
164
164
|
},
|
165
|
+
dialog: function (message, format = "md") {
|
166
|
+
if (!this.socket) {
|
167
|
+
this.fatal("Socket is not initialized");
|
168
|
+
return;
|
169
|
+
}
|
170
|
+
this.emit("dialog", "talk", [], undefined, undefined, { message, format });
|
171
|
+
},
|
165
172
|
fatal: function (msg) {
|
166
173
|
this.log("internal-error", [msg]);
|
167
174
|
throw msg;
|
@@ -68,7 +68,7 @@ interface ITelemetryManager {
|
|
68
68
|
finishWorkoutSession: () => void;
|
69
69
|
setStudent: (student: TStudent) => void;
|
70
70
|
save: () => void;
|
71
|
-
retrieve: (
|
71
|
+
retrieve: () => Promise<ITelemetryJSONSchema | null>;
|
72
72
|
}
|
73
73
|
declare const TelemetryManager: ITelemetryManager;
|
74
74
|
export default TelemetryManager;
|
@@ -20,7 +20,7 @@ const TelemetryManager = {
|
|
20
20
|
start: function (agent, steps, path, tutorialSlug) {
|
21
21
|
this.configPath = path;
|
22
22
|
if (!this.current) {
|
23
|
-
this.retrieve(
|
23
|
+
this.retrieve()
|
24
24
|
.then(data => {
|
25
25
|
const prevTelemetry = data;
|
26
26
|
if (prevTelemetry) {
|
@@ -46,6 +46,9 @@ const TelemetryManager = {
|
|
46
46
|
})
|
47
47
|
.catch(error => {
|
48
48
|
console_1.default.debug(error);
|
49
|
+
// Delete the telemetry.json if it exists
|
50
|
+
fs.unlinkSync(`${this.configPath}/telemetry.json`);
|
51
|
+
throw new Error("There was a problem starting, reload LearnPack\nRun\n$ learnpack start");
|
49
52
|
});
|
50
53
|
}
|
51
54
|
},
|
@@ -162,7 +165,12 @@ const TelemetryManager = {
|
|
162
165
|
}
|
163
166
|
}
|
164
167
|
else {
|
165
|
-
|
168
|
+
try {
|
169
|
+
resolve(JSON.parse(data));
|
170
|
+
}
|
171
|
+
catch (error) {
|
172
|
+
reject(error);
|
173
|
+
}
|
166
174
|
}
|
167
175
|
});
|
168
176
|
});
|
package/lib/models/action.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare type TAction = "test" | "log" | "reload" | "ready" | "clean" | "ask" | "file_change";
|
1
|
+
export declare type TAction = "test" | "log" | "reload" | "ready" | "clean" | "ask" | "file_change" | "dialog";
|
2
2
|
export declare type ICallback = (...agrs: any[]) => any;
|
package/lib/models/socket.d.ts
CHANGED
@@ -27,6 +27,7 @@ export interface ISocket {
|
|
27
27
|
ready: (message: string) => void;
|
28
28
|
error: (type: any, stdout: string) => void;
|
29
29
|
fatal: (msg: string) => void;
|
30
|
+
dialog: (message: string) => void;
|
30
31
|
success: (type: any, stdout: string) => void;
|
31
32
|
onTestingFinished: (obj: any) => void;
|
32
33
|
}
|
@@ -140,7 +140,7 @@ exports.checkNotInstalledDependencies = async (neededPlugins) => {
|
|
140
140
|
pytestNeeded = true;
|
141
141
|
}
|
142
142
|
if (jestNeeded) {
|
143
|
-
const { stdout, stderr } = await exec("npm ls
|
143
|
+
const { stdout, stderr } = await exec("npm ls -g");
|
144
144
|
if (stderr) {
|
145
145
|
console_1.default.error(`Error executing ${npmLsCommand}. Use debug for more info`);
|
146
146
|
console_1.default.debug(stderr);
|
package/oclif.manifest.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":"2.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}]}}}
|
package/package.json
CHANGED