@learnpack/learnpack 4.0.6 → 4.0.8
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 +1 -2
- package/lib/managers/config/defaults.d.ts +6 -0
- package/lib/managers/config/defaults.js +6 -0
- package/lib/managers/config/index.js +173 -11
- package/lib/managers/server/routes.js +2 -1
- package/lib/managers/socket.js +1 -1
- package/lib/models/config.d.ts +11 -2
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/start.ts +3 -5
- package/src/managers/config/defaults.ts +49 -43
- package/src/managers/config/index.ts +211 -13
- package/src/managers/server/routes.ts +327 -330
- package/src/managers/socket.ts +2 -6
- package/src/models/config.ts +72 -68
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/4.0.
|
24
|
+
@learnpack/learnpack/4.0.8 win32-x64 node-v20.16.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/v4.0.
|
77
|
+
_See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.8/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/v4.0.
|
92
|
+
_See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.8/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/v4.0.
|
110
|
+
_See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.8/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/v4.0.
|
141
|
+
_See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.8/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/v4.0.
|
159
|
+
_See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.8/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/v4.0.
|
177
|
+
_See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.8/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/v4.0.
|
312
|
+
_See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.8/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/v4.0.
|
333
|
+
_See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.8/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/v4.0.
|
347
|
+
_See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.8/src\commands\test.ts)_
|
348
348
|
<!-- commandsstop -->
|
349
349
|
|
350
350
|
> > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
|
package/lib/commands/start.js
CHANGED
@@ -25,7 +25,6 @@ class StartCommand extends SessionCommand_1.default {
|
|
25
25
|
var _a, _b, _c, _d, _e, _f;
|
26
26
|
// get configuration object
|
27
27
|
const configObject = (_a = this.configManager) === null || _a === void 0 ? void 0 : _a.get();
|
28
|
-
// TODO: console.log(this.config.platform); get the platfrom from Oclif
|
29
28
|
const hasXDG = await osOperations_1.eventManager.checkXDGInstalled();
|
30
29
|
const installedPlugins = this.config.plugins.map(plugin => {
|
31
30
|
return `${plugin.pjson.name}`;
|
@@ -51,7 +50,7 @@ class StartCommand extends SessionCommand_1.default {
|
|
51
50
|
// listen to socket commands
|
52
51
|
if (config && this.configManager) {
|
53
52
|
const server = await server_1.default(configObject, this.configManager, process.env.NODE_ENV === "test");
|
54
|
-
server.setMaxListeners(
|
53
|
+
server.setMaxListeners(30);
|
55
54
|
// I should call a method to get the EventListener
|
56
55
|
const dispatcher = fileQueue_1.default.dispatcher({
|
57
56
|
create: true,
|
@@ -5,7 +5,6 @@ const fs = require("fs");
|
|
5
5
|
const shell = require("shelljs");
|
6
6
|
const child_process_1 = require("child_process");
|
7
7
|
const util_1 = require("util");
|
8
|
-
const execAsync = util_1.promisify(child_process_1.exec);
|
9
8
|
const console_1 = require("../../utils/console");
|
10
9
|
const watcher_1 = require("../../utils/watcher");
|
11
10
|
const errors_1 = require("../../utils/errors");
|
@@ -13,6 +12,7 @@ const defaults_1 = require("./defaults");
|
|
13
12
|
const exercise_1 = require("./exercise");
|
14
13
|
const file_1 = require("../file");
|
15
14
|
/* exercise folder name standard */
|
15
|
+
const execAsync = util_1.promisify(child_process_1.exec);
|
16
16
|
// eslint-disable-next-line
|
17
17
|
const fetch = require("node-fetch");
|
18
18
|
// eslint-disable-next-line
|
@@ -60,7 +60,7 @@ const getCodespacesNamespace = () => {
|
|
60
60
|
return codespace_name;
|
61
61
|
};
|
62
62
|
exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
63
|
-
var _a, _b, _c, _d;
|
63
|
+
var _a, _b, _c, _d, _e, _f;
|
64
64
|
const confPath = getConfigPath();
|
65
65
|
console_1.default.debug("This is the config path: ", confPath);
|
66
66
|
let configObj = {};
|
@@ -108,11 +108,22 @@ exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
|
108
108
|
// auto detect agent (if possible)
|
109
109
|
const codespaces_workspace = getCodespacesNamespace();
|
110
110
|
console_1.default.debug("This is the codespace namespace: ", codespaces_workspace);
|
111
|
+
if (!configObj.config.editor) {
|
112
|
+
configObj.config.editor = {};
|
113
|
+
}
|
111
114
|
console_1.default.debug("This is the agent, and this should be null an the beginning: ", (_c = (_b = configObj.config) === null || _b === void 0 ? void 0 : _b.editor) === null || _c === void 0 ? void 0 : _c.agent);
|
115
|
+
if ((_e = (_d = configObj.config) === null || _d === void 0 ? void 0 : _d.editor) === null || _e === void 0 ? void 0 : _e.agent) {
|
116
|
+
if (configObj.config.suggestions) {
|
117
|
+
configObj.config.suggestions.agent = configObj.config.editor.agent;
|
118
|
+
}
|
119
|
+
else {
|
120
|
+
configObj.config.suggestions = { agent: configObj.config.editor.agent };
|
121
|
+
}
|
122
|
+
}
|
112
123
|
if (shell.which("gp") && configObj && configObj.config) {
|
113
124
|
console_1.default.debug("Gitpod detected");
|
114
125
|
configObj.address = getGitpodAddress();
|
115
|
-
configObj.config.publicUrl = `https://${configObj.config.port}-${(
|
126
|
+
configObj.config.publicUrl = `https://${configObj.config.port}-${(_f = configObj.address) === null || _f === void 0 ? void 0 : _f.slice(8)}`;
|
116
127
|
configObj.config.editor.agent = "vscode";
|
117
128
|
}
|
118
129
|
else if (configObj.config && Boolean(codespaces_workspace)) {
|
@@ -125,11 +136,33 @@ exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
|
125
136
|
console_1.default.debug("Neither Gitpod nor Codespaces detected, using localhost.");
|
126
137
|
configObj.address = `http://localhost:${configObj.config.port}`;
|
127
138
|
configObj.config.publicUrl = `http://localhost:${configObj.config.port}`;
|
128
|
-
}
|
129
|
-
if (!configObj.config.editor.agent) {
|
130
139
|
configObj.config.editor.agent =
|
131
140
|
process.env.TERM_PROGRAM === "vscode" ? "vscode" : "os";
|
132
141
|
}
|
142
|
+
if (configObj.config.editor.agent === "vscode" && isCodeCommandAvailable()) {
|
143
|
+
const extensionName = "learn-pack.learnpack-vscode";
|
144
|
+
if (!isExtensionInstalled(extensionName)) {
|
145
|
+
console_1.default.info("The LearnPack extension is not installed, trying to install it automatically.");
|
146
|
+
if (!installExtension(extensionName)) {
|
147
|
+
configObj.config.warnings = {
|
148
|
+
extension: EXTENSION_INSTALLATION_STEPS,
|
149
|
+
};
|
150
|
+
console_1.default.warning("The LearnPack extension is not installed and this tutorial is meant to be run inside VSCode. Please install the LearnPack extension.");
|
151
|
+
}
|
152
|
+
}
|
153
|
+
}
|
154
|
+
if (configObj.config.suggestions &&
|
155
|
+
configObj.config.editor &&
|
156
|
+
configObj.config.suggestions.agent !== null &&
|
157
|
+
configObj.config.suggestions.agent !== configObj.config.editor.agent) {
|
158
|
+
console_1.default.warning(`The suggested agent "${configObj.config.suggestions.agent}" is different from the detected agent "${configObj.config.editor.agent}"`);
|
159
|
+
try {
|
160
|
+
configObj.config.warnings = Object.assign(Object.assign({}, configObj.config.warnings), { agent: buildAgentWarning(configObj.config.editor.agent, configObj.config.suggestions.agent) });
|
161
|
+
}
|
162
|
+
catch (_g) {
|
163
|
+
console_1.default.error("IMPOSSIBLE TO SET WARNING");
|
164
|
+
}
|
165
|
+
}
|
133
166
|
if (configObj.config && !configObj.config.publicUrl)
|
134
167
|
configObj.config.publicUrl = `${configObj.address}:${configObj.config.port}`;
|
135
168
|
if (configObj.config && !configObj.config.editor.mode && mode) {
|
@@ -137,7 +170,7 @@ exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
|
137
170
|
}
|
138
171
|
if (!configObj.config.editor.mode) {
|
139
172
|
configObj.config.editor.mode =
|
140
|
-
|
173
|
+
process.env.TERM_PROGRAM === "vscode" ? "extension" : "preview";
|
141
174
|
}
|
142
175
|
if (version)
|
143
176
|
configObj.config.editor.version = version;
|
@@ -145,7 +178,7 @@ exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
|
145
178
|
console_1.default.debug("Config version not found, downloading default.");
|
146
179
|
const resp = await fetch("https://raw.githubusercontent.com/learnpack/ide/master/package.json");
|
147
180
|
const packageJSON = await resp.json();
|
148
|
-
configObj.config.editor.version = packageJSON.version || "4.0.
|
181
|
+
configObj.config.editor.version = packageJSON.version || "4.0.2";
|
149
182
|
}
|
150
183
|
configObj.config.dirPath = "./" + confPath.base;
|
151
184
|
configObj.config.exercisesPath = getExercisesPath(confPath.base) || "./";
|
@@ -188,7 +221,9 @@ exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
|
188
221
|
}
|
189
222
|
return {
|
190
223
|
validLanguages: {},
|
191
|
-
get: () =>
|
224
|
+
get: () => {
|
225
|
+
return configObj;
|
226
|
+
},
|
192
227
|
validateEngine: function (language, server, socket) {
|
193
228
|
// eslint-disable-next-line
|
194
229
|
const alias = (_l) => {
|
@@ -206,13 +241,13 @@ exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
|
206
241
|
console_1.default.debug(`Validating engine for ${language} compilation`);
|
207
242
|
let result = shell.exec("learnpack plugins", { silent: true });
|
208
243
|
if (result.code === 0 &&
|
209
|
-
result.stdout.includes(
|
244
|
+
result.stdout.includes(`@learnpack/${language}`)) {
|
210
245
|
this.validLanguages[language] = true;
|
211
246
|
return true;
|
212
247
|
}
|
213
248
|
console_1.default.info(`Language engine for ${language} not found, installing...`);
|
214
249
|
// Install the compiler in their new versions
|
215
|
-
result = shell.exec(`learnpack plugins:install learnpack
|
250
|
+
result = shell.exec(`learnpack plugins:install @learnpack/${language}`, {
|
216
251
|
silent: true,
|
217
252
|
});
|
218
253
|
if (result.code === 0) {
|
@@ -340,7 +375,7 @@ exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
|
340
375
|
});
|
341
376
|
},
|
342
377
|
save: () => {
|
343
|
-
|
378
|
+
console_1.default.debug("Saving configuration with: ", configObj);
|
344
379
|
// remove the duplicates form the actions array
|
345
380
|
// configObj.config.actions = [...new Set(configObj.config.actions)];
|
346
381
|
if (configObj.config) {
|
@@ -374,3 +409,130 @@ function deepMerge(...sources) {
|
|
374
409
|
}
|
375
410
|
return acc;
|
376
411
|
}
|
412
|
+
const buildAgentWarning = (current, suggested) => {
|
413
|
+
const message = `# Agent mismatch!\n
|
414
|
+
|
415
|
+
In LearnPack, the agent is in charge of running the LearnPack interface.
|
416
|
+
|
417
|
+
You're currently using LearnPack through \`${current}\` but the suggested agent is \`${suggested}\`.
|
418
|
+
|
419
|
+
We recommend strongly recommend changing your agent.
|
420
|
+
|
421
|
+
${stepsToChangeAgent(suggested)}
|
422
|
+
`;
|
423
|
+
return message;
|
424
|
+
};
|
425
|
+
const stepsToChangeAgent = (agent) => {
|
426
|
+
if (agent === "vscode") {
|
427
|
+
return `
|
428
|
+
# Steps to Change Agent to VSCode
|
429
|
+
|
430
|
+
1. **Install VSCode**:
|
431
|
+
- Visit the [VSCode website](https://code.visualstudio.com/Download) and download the latest version.
|
432
|
+
- Follow the installation instructions for your operating system.
|
433
|
+
|
434
|
+
2. **Install LearnPack VSCode Extension**:
|
435
|
+
- Open VSCode.
|
436
|
+
- Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or by pressing \`Ctrl+Shift+X\`.
|
437
|
+
- Search for "LearnPack" and click "Install".
|
438
|
+
- If the extension is already installed but disabled, enable it.
|
439
|
+
|
440
|
+
3. **Run LearnPack in VSCode**:
|
441
|
+
- Open your terminal in VSCode.
|
442
|
+
- Navigate to your LearnPack project directory.
|
443
|
+
- Run the following command:
|
444
|
+
\`\`\`sh
|
445
|
+
learnpack start
|
446
|
+
\`\`\`
|
447
|
+
|
448
|
+
We strongly recommend using VSCode for a better learning experience.
|
449
|
+
`;
|
450
|
+
}
|
451
|
+
if (agent === "os") {
|
452
|
+
return `
|
453
|
+
# Steps to Change Agent to OS
|
454
|
+
|
455
|
+
This learning package was designed to run outside of VSCode. We strongly recommend closing VSCode and running the package independently.
|
456
|
+
|
457
|
+
1. **Close VSCode**:
|
458
|
+
- Save your work and close the VSCode application.
|
459
|
+
|
460
|
+
2. **Open a New Terminal**:
|
461
|
+
- Open a terminal or command prompt on your operating system.
|
462
|
+
|
463
|
+
3. **Navigate to Your LearnPack Project Directory**:
|
464
|
+
- Use the \`cd\` command to navigate to the directory where your LearnPack project is located.
|
465
|
+
|
466
|
+
4. **Run LearnPack**:
|
467
|
+
- Run the following command to start LearnPack:
|
468
|
+
\`\`\`sh
|
469
|
+
learnpack start
|
470
|
+
\`\`\`
|
471
|
+
|
472
|
+
We strongly recommend running the package independently for a better learning experience.
|
473
|
+
`;
|
474
|
+
}
|
475
|
+
return "";
|
476
|
+
};
|
477
|
+
/**
|
478
|
+
* Checks if the 'code' command is available in the terminal.
|
479
|
+
*
|
480
|
+
* @returns {boolean} True if the 'code' command is available, false otherwise.
|
481
|
+
*/
|
482
|
+
const isCodeCommandAvailable = () => {
|
483
|
+
return shell.which("code") !== null;
|
484
|
+
};
|
485
|
+
/**
|
486
|
+
* Checks if a specific VSCode extension is installed.
|
487
|
+
*
|
488
|
+
* @param {string} extensionName - The name of the extension to check.
|
489
|
+
* @returns {boolean} True if the extension is installed, false otherwise.
|
490
|
+
*/
|
491
|
+
const isExtensionInstalled = (extensionName) => {
|
492
|
+
if (!isCodeCommandAvailable()) {
|
493
|
+
throw new Error("The 'code' command is not available in the terminal. Please ensure that VSCode is installed and the 'code' command is added to your PATH.");
|
494
|
+
}
|
495
|
+
const result = shell.exec("code --list-extensions", { silent: true });
|
496
|
+
return result.stdout.split("\n").includes(extensionName);
|
497
|
+
};
|
498
|
+
const EXTENSION_INSTALLATION_STEPS = `
|
499
|
+
# Steps to Install LearnPack VSCode Extension
|
500
|
+
|
501
|
+
1. **Open VSCode**:
|
502
|
+
- Launch the Visual Studio Code application on your computer.
|
503
|
+
|
504
|
+
2. **Go to Extensions View**:
|
505
|
+
- Click on the Extensions icon in the Activity Bar on the side of the window.
|
506
|
+
- Alternatively, you can open the Extensions view by pressing \`Ctrl+Shift+X\`.
|
507
|
+
|
508
|
+
3. **Search for LearnPack**:
|
509
|
+
- In the Extensions view, type "LearnPack" into the search bar.
|
510
|
+
|
511
|
+
4. **Install the Extension**:
|
512
|
+
- Find the "LearnPack" extension in the search results and click the "Install" button.
|
513
|
+
- If the extension is already installed but disabled, click the "Enable" button.
|
514
|
+
|
515
|
+
5. **Verify Installation**:
|
516
|
+
- Once installed, you can verify the installation by running the following command in the terminal:
|
517
|
+
\`\`\`sh
|
518
|
+
code --list-extensions | grep learn-pack.learnpack-vscode
|
519
|
+
\`\`\`
|
520
|
+
- If the extension is listed, it means the installation was successful.
|
521
|
+
|
522
|
+
We strongly recommend using the LearnPack extension in VSCode for a better learning experience.
|
523
|
+
`;
|
524
|
+
/**
|
525
|
+
* Installs the LearnPack VSCode extension if the 'code' command is available.
|
526
|
+
*
|
527
|
+
* @param {string} extensionName - The name of the extension to install.
|
528
|
+
* @returns {boolean} True if the installation was successful, false otherwise.
|
529
|
+
*/
|
530
|
+
const installExtension = (extensionName) => {
|
531
|
+
if (!isCodeCommandAvailable()) {
|
532
|
+
throw new Error("The 'code' command is not available in the terminal. Please ensure that VSCode is installed and the 'code' command is added to your PATH.");
|
533
|
+
}
|
534
|
+
const result = shell.exec(`code --install-extension ${extensionName}`, {
|
535
|
+
silent: true,
|
536
|
+
});
|
537
|
+
return result.code === 0;
|
538
|
+
};
|
@@ -36,7 +36,8 @@ async function default_1(app, configObject, configManager) {
|
|
36
36
|
path: `${config === null || config === void 0 ? void 0 : config.dirPath}/vscode_queue.json`,
|
37
37
|
});
|
38
38
|
app.get("/config", withHandler((_, res) => {
|
39
|
-
|
39
|
+
const confObject = configManager.get();
|
40
|
+
res.json(confObject);
|
40
41
|
}));
|
41
42
|
// Added this line to parse the json body
|
42
43
|
const jsonBodyParser = bodyParser.json();
|
package/lib/managers/socket.js
CHANGED
@@ -102,7 +102,7 @@ const SocketManager = {
|
|
102
102
|
});
|
103
103
|
},
|
104
104
|
reload: function (files = null, exercises = null) {
|
105
|
-
this.emit("reload", (files === null || files === void 0 ? void 0 : files.join("")) || ""
|
105
|
+
this.emit("reload", (files === null || files === void 0 ? void 0 : files.join("")) || "", exercises);
|
106
106
|
},
|
107
107
|
openWindow: function (url = "") {
|
108
108
|
fileQueue_1.default.dispatcher().enqueue(fileQueue_1.default.events.OPEN_WINDOW, url);
|
package/lib/models/config.d.ts
CHANGED
@@ -8,10 +8,9 @@ export declare type TCompiler = "webpack" | "vanillajs" | "react" | "html" | "no
|
|
8
8
|
export interface IConfigPath {
|
9
9
|
base: string;
|
10
10
|
}
|
11
|
-
declare type TAgent = "vscode" | "os";
|
12
11
|
export interface IEditor {
|
13
12
|
mode?: TMode;
|
14
|
-
version
|
13
|
+
version?: string;
|
15
14
|
agent?: TAgent;
|
16
15
|
hideTerminal?: boolean;
|
17
16
|
}
|
@@ -56,9 +55,19 @@ export interface IConfig {
|
|
56
55
|
skills: Array<string>;
|
57
56
|
telemetry?: TTelemetryUrls;
|
58
57
|
variables?: TVariables;
|
58
|
+
suggestions: TSuggestions;
|
59
|
+
warnings: TWarnings;
|
59
60
|
runHook: (...agrs: Array<any>) => void;
|
60
61
|
testingFinishedCallback: (arg: any | undefined) => void;
|
61
62
|
}
|
63
|
+
export declare type TAgent = "os" | "vscode" | null;
|
64
|
+
declare type TSuggestions = {
|
65
|
+
agent: TAgent;
|
66
|
+
};
|
67
|
+
declare type TWarnings = {
|
68
|
+
agent?: string;
|
69
|
+
extension?: string;
|
70
|
+
};
|
62
71
|
declare type TVariable = {
|
63
72
|
type: "command" | "string";
|
64
73
|
source: string;
|
package/oclif.manifest.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":"4.0.
|
1
|
+
{"version":"4.0.8","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
@@ -77,7 +77,6 @@ export default class StartCommand extends SessionCommand {
|
|
77
77
|
// get configuration object
|
78
78
|
const configObject = this.configManager?.get()
|
79
79
|
|
80
|
-
// TODO: console.log(this.config.platform); get the platfrom from Oclif
|
81
80
|
const hasXDG = await eventManager.checkXDGInstalled()
|
82
81
|
|
83
82
|
const installedPlugins = this.config.plugins.map(plugin => {
|
@@ -86,6 +85,7 @@ export default class StartCommand extends SessionCommand {
|
|
86
85
|
|
87
86
|
if (configObject) {
|
88
87
|
const { config } = configObject
|
88
|
+
|
89
89
|
// build exerises
|
90
90
|
this.configManager?.buildIndex()
|
91
91
|
|
@@ -112,9 +112,7 @@ export default class StartCommand extends SessionCommand {
|
|
112
112
|
this.exit(1)
|
113
113
|
}
|
114
114
|
|
115
|
-
const appAlreadyExists = checkIfDirectoryExists(
|
116
|
-
`${config?.dirPath}/_app`
|
117
|
-
)
|
115
|
+
const appAlreadyExists = checkIfDirectoryExists(`${config?.dirPath}/_app`)
|
118
116
|
|
119
117
|
if (!appAlreadyExists) {
|
120
118
|
// download app and decompress
|
@@ -137,7 +135,7 @@ export default class StartCommand extends SessionCommand {
|
|
137
135
|
this.configManager,
|
138
136
|
process.env.NODE_ENV === "test"
|
139
137
|
)
|
140
|
-
server.setMaxListeners(
|
138
|
+
server.setMaxListeners(30)
|
141
139
|
|
142
140
|
// I should call a method to get the EventListener
|
143
141
|
const dispatcher = queue.dispatcher({
|
@@ -1,43 +1,49 @@
|
|
1
|
-
import * as os from "os"
|
2
|
-
export default {
|
3
|
-
config: {
|
4
|
-
port: 3000,
|
5
|
-
os: (function () {
|
6
|
-
return os.platform()
|
7
|
-
})(),
|
8
|
-
editor: {
|
9
|
-
mode: null, // [extension, preview]
|
10
|
-
agent: null, // ["vscode", "os"] ("os" is the agent when running outside a coding editor
|
11
|
-
version: null, // By default downloads the latest version
|
12
|
-
},
|
13
|
-
dirPath: "./.learn",
|
14
|
-
configPath: "./learn.json",
|
15
|
-
outputPath: "./.learn/dist",
|
16
|
-
publicPath: "/preview",
|
17
|
-
publicUrl: null,
|
18
|
-
contact: "https://github.com/learnpack/learnpack/issues/new",
|
19
|
-
language: "auto",
|
20
|
-
autoPlay: true,
|
21
|
-
projectType: "tutorial", // [tutorial, project]
|
22
|
-
grading: "isolated", // [isolated, incremental]
|
23
|
-
exercisesPath: "./", // path to the folder that contains the exercises
|
24
|
-
webpackTemplate: null, // if you want webpack to use an HTML template
|
25
|
-
disableGrading: false,
|
26
|
-
disabledActions: [], // Possible: 'build', 'test' or 'reset'
|
27
|
-
actions: [], // ⚠️ deprecated, leave empty )
|
28
|
-
entries: {
|
29
|
-
html: "index.html",
|
30
|
-
vanillajs: "index.js",
|
31
|
-
react: "app.jsx",
|
32
|
-
node: "app.js",
|
33
|
-
python3: "app.py",
|
34
|
-
java: "app.java",
|
35
|
-
},
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
1
|
+
import * as os from "os"
|
2
|
+
export default {
|
3
|
+
config: {
|
4
|
+
port: 3000,
|
5
|
+
os: (function () {
|
6
|
+
return os.platform()
|
7
|
+
})(),
|
8
|
+
editor: {
|
9
|
+
mode: null, // [extension, preview]
|
10
|
+
agent: null, // ["vscode", "os"] ("os" is the agent when running outside a coding editor
|
11
|
+
version: null, // By default downloads the latest version
|
12
|
+
},
|
13
|
+
dirPath: "./.learn",
|
14
|
+
configPath: "./learn.json",
|
15
|
+
outputPath: "./.learn/dist",
|
16
|
+
publicPath: "/preview",
|
17
|
+
publicUrl: null,
|
18
|
+
contact: "https://github.com/learnpack/learnpack/issues/new",
|
19
|
+
language: "auto",
|
20
|
+
autoPlay: true,
|
21
|
+
projectType: "tutorial", // [tutorial, project]
|
22
|
+
grading: "isolated", // [isolated, incremental]
|
23
|
+
exercisesPath: "./", // path to the folder that contains the exercises
|
24
|
+
webpackTemplate: null, // if you want webpack to use an HTML template
|
25
|
+
disableGrading: false,
|
26
|
+
disabledActions: [], // Possible: 'build', 'test' or 'reset'
|
27
|
+
actions: [], // ⚠️ deprecated, leave empty )
|
28
|
+
entries: {
|
29
|
+
html: "index.html",
|
30
|
+
vanillajs: "index.js",
|
31
|
+
react: "app.jsx",
|
32
|
+
node: "app.js",
|
33
|
+
python3: "app.py",
|
34
|
+
java: "app.java",
|
35
|
+
},
|
36
|
+
suggestions: {
|
37
|
+
agent: null,
|
38
|
+
},
|
39
|
+
warnings: {
|
40
|
+
agent: null,
|
41
|
+
},
|
42
|
+
},
|
43
|
+
address: "http://localhost",
|
44
|
+
currentExercise: null,
|
45
|
+
exercises: [],
|
46
|
+
bugsLink: null,
|
47
|
+
videoSolutions: false,
|
48
|
+
localhostOnly: false, // if true, the exercise should not run on gitpod or codespaces but show an error message encouraging the user to run locally
|
49
|
+
}
|