@learnpack/learnpack 4.0.10 → 4.0.12
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +25 -10
- package/lib/commands/audit.d.ts +6 -6
- package/lib/commands/audit.js +327 -327
- package/lib/commands/build.d.ts +11 -0
- package/lib/commands/build.js +160 -0
- package/lib/commands/clean.d.ts +8 -8
- package/lib/commands/clean.js +22 -22
- package/lib/commands/download.d.ts +13 -13
- package/lib/commands/download.js +52 -52
- package/lib/commands/init.d.ts +9 -9
- package/lib/commands/init.js +127 -127
- package/lib/commands/login.d.ts +14 -14
- package/lib/commands/login.js +34 -34
- package/lib/commands/logout.d.ts +14 -14
- package/lib/commands/logout.js +34 -34
- package/lib/commands/publish.d.ts +14 -14
- package/lib/commands/publish.js +79 -79
- package/lib/commands/start.d.ts +7 -7
- package/lib/commands/start.js +252 -250
- package/lib/commands/test.d.ts +6 -6
- package/lib/commands/test.js +62 -62
- package/lib/index.d.ts +1 -1
- package/lib/index.js +4 -4
- package/lib/managers/config/allowed_files.d.ts +5 -5
- package/lib/managers/config/allowed_files.js +30 -30
- package/lib/managers/config/defaults.d.ts +47 -48
- package/lib/managers/config/defaults.js +51 -51
- package/lib/managers/config/exercise.d.ts +36 -36
- package/lib/managers/config/exercise.js +243 -236
- package/lib/managers/config/index.d.ts +3 -3
- package/lib/managers/config/index.js +464 -459
- package/lib/managers/file.d.ts +14 -14
- package/lib/managers/file.js +190 -184
- package/lib/managers/gitpod.d.ts +3 -3
- package/lib/managers/gitpod.js +67 -67
- package/lib/managers/server/index.d.ts +5 -6
- package/lib/managers/server/index.js +58 -58
- package/lib/managers/server/routes.d.ts +4 -4
- package/lib/managers/server/routes.js +228 -220
- package/lib/managers/session.d.ts +3 -3
- package/lib/managers/session.js +125 -125
- package/lib/managers/socket.d.ts +3 -3
- package/lib/managers/socket.js +188 -186
- package/lib/managers/telemetry.d.ts +74 -74
- package/lib/managers/telemetry.js +215 -214
- package/lib/managers/test.js +84 -84
- package/lib/models/action.d.ts +2 -2
- package/lib/models/action.js +2 -2
- package/lib/models/audit.d.ts +15 -15
- package/lib/models/audit.js +2 -2
- package/lib/models/config-manager.d.ts +21 -21
- package/lib/models/config-manager.js +2 -2
- package/lib/models/config.d.ts +86 -86
- package/lib/models/config.js +2 -2
- package/lib/models/counter.d.ts +11 -11
- package/lib/models/counter.js +2 -2
- package/lib/models/errors.d.ts +15 -15
- package/lib/models/errors.js +2 -2
- package/lib/models/exercise-obj.d.ts +29 -30
- package/lib/models/exercise-obj.js +2 -2
- package/lib/models/file.d.ts +5 -5
- package/lib/models/file.js +2 -2
- package/lib/models/findings.d.ts +17 -17
- package/lib/models/findings.js +2 -2
- package/lib/models/flags.d.ts +10 -10
- package/lib/models/flags.js +2 -2
- package/lib/models/front-matter.d.ts +11 -11
- package/lib/models/front-matter.js +2 -2
- package/lib/models/gitpod-data.d.ts +16 -16
- package/lib/models/gitpod-data.js +2 -2
- package/lib/models/language.d.ts +4 -4
- package/lib/models/language.js +2 -2
- package/lib/models/package.d.ts +7 -7
- package/lib/models/package.js +2 -2
- package/lib/models/plugin-config.d.ts +16 -16
- package/lib/models/plugin-config.js +2 -2
- package/lib/models/session.d.ts +31 -31
- package/lib/models/session.js +2 -2
- package/lib/models/socket.d.ts +37 -37
- package/lib/models/socket.js +2 -2
- package/lib/models/status.d.ts +1 -1
- package/lib/models/status.js +2 -2
- package/lib/models/success-types.d.ts +1 -1
- package/lib/models/success-types.js +2 -2
- package/lib/plugin/command/compile.d.ts +6 -6
- package/lib/plugin/command/compile.js +18 -18
- package/lib/plugin/command/test.d.ts +6 -6
- package/lib/plugin/command/test.js +25 -25
- package/lib/plugin/index.d.ts +27 -27
- package/lib/plugin/index.js +7 -7
- package/lib/plugin/plugin.d.ts +8 -8
- package/lib/plugin/plugin.js +68 -68
- package/lib/plugin/utils.d.ts +16 -16
- package/lib/plugin/utils.js +58 -58
- package/lib/ui/download.d.ts +5 -5
- package/lib/ui/download.js +62 -61
- package/lib/utils/BaseCommand.d.ts +8 -8
- package/lib/utils/BaseCommand.js +41 -41
- package/lib/utils/SessionCommand.d.ts +10 -10
- package/lib/utils/SessionCommand.js +43 -43
- package/lib/utils/api.d.ts +14 -14
- package/lib/utils/api.js +255 -255
- package/lib/utils/audit.d.ts +16 -16
- package/lib/utils/audit.js +303 -303
- package/lib/utils/checkNotInstalled.d.ts +8 -8
- package/lib/utils/checkNotInstalled.js +185 -181
- package/lib/utils/console.d.ts +12 -12
- package/lib/utils/console.js +19 -19
- package/lib/utils/errors.d.ts +17 -17
- package/lib/utils/errors.js +107 -100
- package/lib/utils/exercisesQueue.d.ts +9 -9
- package/lib/utils/exercisesQueue.js +38 -38
- package/lib/utils/fileQueue.d.ts +43 -43
- package/lib/utils/fileQueue.js +169 -169
- package/lib/utils/misc.d.ts +1 -1
- package/lib/utils/misc.js +24 -23
- package/lib/utils/osOperations.d.ts +5 -5
- package/lib/utils/osOperations.js +72 -72
- package/lib/utils/validators.d.ts +5 -5
- package/lib/utils/validators.js +16 -17
- package/lib/utils/watcher.d.ts +2 -2
- package/lib/utils/watcher.js +25 -25
- package/oclif.manifest.json +1 -1
- package/package.json +6 -4
- package/src/commands/build.ts +181 -0
- package/src/managers/config/index.ts +5 -0
- package/src/managers/server/routes.ts +10 -0
- package/src/managers/session.ts +1 -1
package/lib/commands/start.js
CHANGED
@@ -1,250 +1,252 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
// import path from "path";
|
4
|
-
const command_1 = require("@oclif/command");
|
5
|
-
const fs = require("fs");
|
6
|
-
const path = require("path");
|
7
|
-
const SessionCommand_1 = require("../utils/SessionCommand");
|
8
|
-
const console_1 = require("../utils/console");
|
9
|
-
const socket_1 = require("../managers/socket");
|
10
|
-
const telemetry_1 = require("../managers/telemetry");
|
11
|
-
const server_1 = require("../managers/server");
|
12
|
-
const fileQueue_1 = require("../utils/fileQueue");
|
13
|
-
const file_1 = require("../managers/file");
|
14
|
-
const misc_1 = require("../utils/misc");
|
15
|
-
const osOperations_1 = require("../utils/osOperations");
|
16
|
-
const checkNotInstalled_1 = require("../utils/checkNotInstalled");
|
17
|
-
class StartCommand extends SessionCommand_1.default {
|
18
|
-
// 🛑 IMPORTANT
|
19
|
-
// Every command that will use the configManager needs this init method
|
20
|
-
async init() {
|
21
|
-
const { flags } = this.parse(StartCommand);
|
22
|
-
await this.initSession(flags);
|
23
|
-
}
|
24
|
-
async run() {
|
25
|
-
var _a, _b, _c, _d, _e, _f;
|
26
|
-
// get configuration object
|
27
|
-
const configObject = (_a = this.configManager) === null || _a === void 0 ? void 0 : _a.get();
|
28
|
-
const hasXDG = await osOperations_1.eventManager.checkXDGInstalled();
|
29
|
-
const installedPlugins = this.config.plugins.map(plugin => {
|
30
|
-
return `${plugin.pjson.name}`;
|
31
|
-
});
|
32
|
-
if (configObject) {
|
33
|
-
const { config } = configObject;
|
34
|
-
// build exerises
|
35
|
-
(_b = this.configManager) === null || _b === void 0 ? void 0 : _b.buildIndex();
|
36
|
-
console_1.default.debug(`Grading: ${config === null || config === void 0 ? void 0 : config.grading} ${((_c = config === null || config === void 0 ? void 0 : config.disabledActions) === null || _c === void 0 ? void 0 : _c.includes("test")) ? "(disabled)" : ""}, editor: ${config === null || config === void 0 ? void 0 : config.editor.mode} ${config === null || config === void 0 ? void 0 : config.editor.version}, for ${Array.isArray(configObject === null || configObject === void 0 ? void 0 : configObject.exercises) ?
|
37
|
-
0
|
38
|
-
|
39
|
-
const
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
server.
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
const
|
62
|
-
const
|
63
|
-
const
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
socket_1.default.
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
process.on("
|
210
|
-
|
211
|
-
|
212
|
-
//
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
}
|
222
|
-
|
223
|
-
|
224
|
-
StartCommand.
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
// import path from "path";
|
4
|
+
const command_1 = require("@oclif/command");
|
5
|
+
const fs = require("fs");
|
6
|
+
const path = require("path");
|
7
|
+
const SessionCommand_1 = require("../utils/SessionCommand");
|
8
|
+
const console_1 = require("../utils/console");
|
9
|
+
const socket_1 = require("../managers/socket");
|
10
|
+
const telemetry_1 = require("../managers/telemetry");
|
11
|
+
const server_1 = require("../managers/server");
|
12
|
+
const fileQueue_1 = require("../utils/fileQueue");
|
13
|
+
const file_1 = require("../managers/file");
|
14
|
+
const misc_1 = require("../utils/misc");
|
15
|
+
const osOperations_1 = require("../utils/osOperations");
|
16
|
+
const checkNotInstalled_1 = require("../utils/checkNotInstalled");
|
17
|
+
class StartCommand extends SessionCommand_1.default {
|
18
|
+
// 🛑 IMPORTANT
|
19
|
+
// Every command that will use the configManager needs this init method
|
20
|
+
async init() {
|
21
|
+
const { flags } = this.parse(StartCommand);
|
22
|
+
await this.initSession(flags);
|
23
|
+
}
|
24
|
+
async run() {
|
25
|
+
var _a, _b, _c, _d, _e, _f;
|
26
|
+
// get configuration object
|
27
|
+
const configObject = (_a = this.configManager) === null || _a === void 0 ? void 0 : _a.get();
|
28
|
+
const hasXDG = await osOperations_1.eventManager.checkXDGInstalled();
|
29
|
+
const installedPlugins = this.config.plugins.map(plugin => {
|
30
|
+
return `${plugin.pjson.name}`;
|
31
|
+
});
|
32
|
+
if (configObject) {
|
33
|
+
const { config } = configObject;
|
34
|
+
// build exerises
|
35
|
+
(_b = this.configManager) === null || _b === void 0 ? void 0 : _b.buildIndex();
|
36
|
+
console_1.default.debug(`Grading: ${config === null || config === void 0 ? void 0 : config.grading} ${((_c = config === null || config === void 0 ? void 0 : config.disabledActions) === null || _c === void 0 ? void 0 : _c.includes("test")) ? "(disabled)" : ""}, editor: ${config === null || config === void 0 ? void 0 : config.editor.mode} ${config === null || config === void 0 ? void 0 : config.editor.version}, for ${Array.isArray(configObject === null || configObject === void 0 ? void 0 : configObject.exercises) ?
|
37
|
+
configObject === null || configObject === void 0 ? void 0 : configObject.exercises.length :
|
38
|
+
0} exercises found`);
|
39
|
+
const neededPlugins = await (0, checkNotInstalled_1.checkNotInstalledPlugins)((configObject === null || configObject === void 0 ? void 0 : configObject.exercises) || [], installedPlugins, this);
|
40
|
+
const allDepsInstalled = await (0, checkNotInstalled_1.checkNotInstalledDependencies)(neededPlugins.needed);
|
41
|
+
if (!allDepsInstalled) {
|
42
|
+
this.exit(1);
|
43
|
+
}
|
44
|
+
const appAlreadyExists = (0, file_1.checkIfDirectoryExists)(`${config === null || config === void 0 ? void 0 : config.dirPath}/_app`);
|
45
|
+
if (!appAlreadyExists) {
|
46
|
+
// download app and decompress
|
47
|
+
await (0, file_1.downloadEditor)(config === null || config === void 0 ? void 0 : config.editor.version, `${config === null || config === void 0 ? void 0 : config.dirPath}/app.tar.gz`);
|
48
|
+
console_1.default.info("Decompressing LearnPack UI, this may take a minute...");
|
49
|
+
await (0, file_1.decompress)(`${config === null || config === void 0 ? void 0 : config.dirPath}/app.tar.gz`, `${config === null || config === void 0 ? void 0 : config.dirPath}/_app/`);
|
50
|
+
}
|
51
|
+
// listen to socket commands
|
52
|
+
if (config && this.configManager) {
|
53
|
+
const server = await (0, server_1.default)(configObject, this.configManager, process.env.NODE_ENV === "test");
|
54
|
+
server.setMaxListeners(30);
|
55
|
+
// I should call a method to get the EventListener
|
56
|
+
const dispatcher = fileQueue_1.default.dispatcher({
|
57
|
+
create: true,
|
58
|
+
path: `${config.dirPath}/vscode_queue.json`,
|
59
|
+
});
|
60
|
+
if (configObject.exercises) {
|
61
|
+
const agent = ((_d = configObject.config) === null || _d === void 0 ? void 0 : _d.editor.agent) || "";
|
62
|
+
const path = ((_e = configObject.config) === null || _e === void 0 ? void 0 : _e.dirPath) || "";
|
63
|
+
const tutorialSlug = ((_f = configObject.config) === null || _f === void 0 ? void 0 : _f.slug) || "";
|
64
|
+
const steps = configObject.exercises.map((e, index) => ({
|
65
|
+
slug: e.slug,
|
66
|
+
position: e.position || index,
|
67
|
+
files: e.files,
|
68
|
+
ai_interactions: [],
|
69
|
+
compilations: [],
|
70
|
+
tests: [],
|
71
|
+
is_testeable: e.graded || false,
|
72
|
+
}));
|
73
|
+
if (path && steps.length > 0) {
|
74
|
+
telemetry_1.default.start(agent, steps, path, tutorialSlug);
|
75
|
+
}
|
76
|
+
if (config.telemetry) {
|
77
|
+
telemetry_1.default.urls = config.telemetry;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
socket_1.default.start(config, server, false);
|
81
|
+
socket_1.default.on("open", (data) => {
|
82
|
+
console_1.default.debug("Opening these files: ", data);
|
83
|
+
const files = (0, misc_1.prioritizeHTMLFile)(data.files);
|
84
|
+
if (config.editor.agent === "os") {
|
85
|
+
osOperations_1.eventManager.enqueue(dispatcher.events.OPEN_FILES, files);
|
86
|
+
}
|
87
|
+
else {
|
88
|
+
dispatcher.enqueue(dispatcher.events.OPEN_FILES, files);
|
89
|
+
}
|
90
|
+
socket_1.default.ready("Ready to compile...");
|
91
|
+
});
|
92
|
+
socket_1.default.on("open_window", (data) => {
|
93
|
+
console_1.default.debug("Opening window: ", data);
|
94
|
+
// cli.open(data.url); This uses XDG under the ground
|
95
|
+
if (config.os !== "linux" || (config.os === "linux" && hasXDG)) {
|
96
|
+
osOperations_1.eventManager.enqueue(dispatcher.events.OPEN_WINDOW, data);
|
97
|
+
}
|
98
|
+
else {
|
99
|
+
dispatcher.enqueue(dispatcher.events.OPEN_WINDOW, data);
|
100
|
+
}
|
101
|
+
socket_1.default.log("open_window", "", undefined, data.url);
|
102
|
+
});
|
103
|
+
socket_1.default.on("open_terminal", (exercise) => {
|
104
|
+
console_1.default.debug("Opening terminal: ", exercise);
|
105
|
+
// eventManager.enqueue(dispatcher.events.OPEN_TERMINAL, exercise);
|
106
|
+
if (config.editor.agent === "vscode") {
|
107
|
+
dispatcher.enqueue(dispatcher.events.OPEN_TERMINAL, exercise);
|
108
|
+
}
|
109
|
+
});
|
110
|
+
socket_1.default.on("reset", (exercise) => {
|
111
|
+
var _a;
|
112
|
+
try {
|
113
|
+
(_a = this.configManager) === null || _a === void 0 ? void 0 : _a.reset(exercise.exerciseSlug);
|
114
|
+
socket_1.default.ready("Ready to compile...");
|
115
|
+
}
|
116
|
+
catch (error) {
|
117
|
+
socket_1.default.error("compiler-error", error.message ||
|
118
|
+
"There was an error reseting the exercise");
|
119
|
+
setTimeout(() => socket_1.default.ready("Ready to compile..."), 2000);
|
120
|
+
}
|
121
|
+
});
|
122
|
+
socket_1.default.on("build", async (data) => {
|
123
|
+
var _a;
|
124
|
+
const exercise = (_a = this.configManager) === null || _a === void 0 ? void 0 : _a.getExercise(data.exerciseSlug);
|
125
|
+
if (!(exercise === null || exercise === void 0 ? void 0 : exercise.language)) {
|
126
|
+
socket_1.default.error("compiler-error", "Impossible to detect language to build for " +
|
127
|
+
data.exerciseSlug +
|
128
|
+
"...");
|
129
|
+
return;
|
130
|
+
}
|
131
|
+
socket_1.default.log("compiling", "Building exercise " +
|
132
|
+
data.exerciseSlug +
|
133
|
+
" with " +
|
134
|
+
exercise.language +
|
135
|
+
"...");
|
136
|
+
await this.config.runHook("action", {
|
137
|
+
action: "compile",
|
138
|
+
socket: socket_1.default,
|
139
|
+
configuration: config,
|
140
|
+
exercise,
|
141
|
+
telemetry: telemetry_1.default,
|
142
|
+
});
|
143
|
+
});
|
144
|
+
socket_1.default.on("ai_interaction", (data) => {
|
145
|
+
const { stepPosition, event, eventData } = data;
|
146
|
+
telemetry_1.default.registerStepEvent(stepPosition, event, eventData);
|
147
|
+
});
|
148
|
+
socket_1.default.on("test", async (data) => {
|
149
|
+
var _a, _b;
|
150
|
+
const exercise = (_a = this.configManager) === null || _a === void 0 ? void 0 : _a.getExercise(data.exerciseSlug);
|
151
|
+
if (!(exercise === null || exercise === void 0 ? void 0 : exercise.language)) {
|
152
|
+
socket_1.default.error("compiler-error", "Impossible to detect engine language for testing for " +
|
153
|
+
data.exerciseSlug +
|
154
|
+
"...");
|
155
|
+
return;
|
156
|
+
}
|
157
|
+
if ((config === null || config === void 0 ? void 0 : config.disabledActions.includes("test")) ||
|
158
|
+
(config === null || config === void 0 ? void 0 : config.disableGrading)) {
|
159
|
+
socket_1.default.ready("Grading is disabled on configuration");
|
160
|
+
return true;
|
161
|
+
}
|
162
|
+
socket_1.default.log("testing", "Testing your exercise using the " + exercise.language + " engine.");
|
163
|
+
await this.config.runHook("action", {
|
164
|
+
action: "test",
|
165
|
+
socket: socket_1.default,
|
166
|
+
configuration: config,
|
167
|
+
exercise,
|
168
|
+
telemetry: telemetry_1.default,
|
169
|
+
});
|
170
|
+
try {
|
171
|
+
if (!configObject.config) {
|
172
|
+
return;
|
173
|
+
}
|
174
|
+
const getReportPath = (ext) => {
|
175
|
+
var _a;
|
176
|
+
if (!((_a = configObject.config) === null || _a === void 0 ? void 0 : _a.dirPath)) {
|
177
|
+
throw new Error("No directory path found in config");
|
178
|
+
}
|
179
|
+
return path.join(configObject.config.dirPath, "reports", `${exercise.slug}`, `report.${ext}`);
|
180
|
+
};
|
181
|
+
const markdownReportPath = getReportPath("md");
|
182
|
+
const textReportPath = getReportPath("txt");
|
183
|
+
if (fs.existsSync(markdownReportPath)) {
|
184
|
+
let reportContent = "";
|
185
|
+
reportContent = fs.readFileSync(markdownReportPath, "utf8");
|
186
|
+
socket_1.default.dialog(reportContent);
|
187
|
+
}
|
188
|
+
if (fs.existsSync(textReportPath)) {
|
189
|
+
let reportContent = "";
|
190
|
+
reportContent = fs.readFileSync(textReportPath, "utf8");
|
191
|
+
socket_1.default.dialog(reportContent);
|
192
|
+
}
|
193
|
+
}
|
194
|
+
catch (error) {
|
195
|
+
console_1.default.debug("Error finding report for exercise.slug", error);
|
196
|
+
}
|
197
|
+
(_b = this.configManager) === null || _b === void 0 ? void 0 : _b.save();
|
198
|
+
return true;
|
199
|
+
});
|
200
|
+
const terminate = async () => {
|
201
|
+
var _a;
|
202
|
+
console_1.default.error("Terminating Learnpack...");
|
203
|
+
await telemetry_1.default.submit();
|
204
|
+
(_a = this.configManager) === null || _a === void 0 ? void 0 : _a.noCurrentExercise();
|
205
|
+
dispatcher.enqueue(dispatcher.events.END);
|
206
|
+
process.exit();
|
207
|
+
};
|
208
|
+
server.on("close", terminate);
|
209
|
+
process.on("SIGINT", terminate);
|
210
|
+
process.on("SIGTERM", terminate);
|
211
|
+
process.on("SIGHUP", terminate);
|
212
|
+
// finish the server startup
|
213
|
+
setTimeout(() => dispatcher.enqueue(dispatcher.events.RUNNING), 1000);
|
214
|
+
// start watching for file changes
|
215
|
+
if (StartCommand.flags.watch)
|
216
|
+
this.configManager.watchIndex(_filename => {
|
217
|
+
// Instead of reloading with socket.reload(), I just notify the frontend for the file change
|
218
|
+
socket_1.default.emit("file_change", "ready", _filename);
|
219
|
+
});
|
220
|
+
}
|
221
|
+
}
|
222
|
+
}
|
223
|
+
}
|
224
|
+
StartCommand.description = "Runs a small server with all the exercise instructions";
|
225
|
+
StartCommand.flags = Object.assign(Object.assign({}, SessionCommand_1.default.flags), { port: command_1.flags.string({ char: "p", description: "server port" }), host: command_1.flags.string({ char: "h", description: "server host" }), disableGrading: command_1.flags.boolean({
|
226
|
+
char: "D",
|
227
|
+
description: "disble grading functionality",
|
228
|
+
default: false,
|
229
|
+
}),
|
230
|
+
// disableGrading: flags.boolean({char: 'dg', description: 'disble grading functionality', default: false }),
|
231
|
+
watch: command_1.flags.boolean({
|
232
|
+
char: "w",
|
233
|
+
description: "Watch for file changes",
|
234
|
+
default: false,
|
235
|
+
}), editor: command_1.flags.string({
|
236
|
+
char: "e",
|
237
|
+
description: "[preview, extension]",
|
238
|
+
options: ["extension", "preview"],
|
239
|
+
}), version: command_1.flags.string({
|
240
|
+
char: "v",
|
241
|
+
description: "E.g: 1.0.1",
|
242
|
+
default: undefined,
|
243
|
+
}), grading: command_1.flags.string({
|
244
|
+
char: "g",
|
245
|
+
description: "[isolated, incremental]",
|
246
|
+
options: ["isolated", "incremental"],
|
247
|
+
}), debug: command_1.flags.boolean({
|
248
|
+
char: "d",
|
249
|
+
description: "debugger mode for more verbage",
|
250
|
+
default: false,
|
251
|
+
}) });
|
252
|
+
exports.default = StartCommand;
|
package/lib/commands/test.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import SessionCommand from "../utils/SessionCommand";
|
2
|
-
declare class TestCommand extends SessionCommand {
|
3
|
-
init(): Promise<void>;
|
4
|
-
run(): Promise<void>;
|
5
|
-
}
|
6
|
-
export default TestCommand;
|
1
|
+
import SessionCommand from "../utils/SessionCommand";
|
2
|
+
declare class TestCommand extends SessionCommand {
|
3
|
+
init(): Promise<void>;
|
4
|
+
run(): Promise<void>;
|
5
|
+
}
|
6
|
+
export default TestCommand;
|