@learnpack/learnpack 2.1.43 → 2.1.45
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 +12 -43
- package/lib/managers/config/index.js +1 -2
- package/lib/utils/checkNotInstalled.d.ts +7 -1
- package/lib/utils/checkNotInstalled.js +156 -16
- package/lib/utils/console.d.ts +1 -1
- package/lib/utils/console.js +7 -7
- package/oclif.manifest.json +1 -1
- package/package.json +3 -2
- package/src/commands/start.ts +17 -41
- package/src/managers/config/exercise.ts +311 -311
- package/src/managers/config/index.ts +455 -455
- package/src/models/config.ts +91 -91
- package/src/models/socket.ts +59 -59
- package/src/utils/checkNotInstalled.ts +228 -17
- package/src/utils/console.ts +24 -24
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.45 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.45/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.45/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.45/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.45/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.45/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.45/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.45/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.45/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.45/src\commands\test.ts)_
|
348
348
|
<!-- commandsstop -->
|
349
349
|
|
350
350
|
> > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
|
package/lib/commands/start.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const tslib_1 = require("tslib");
|
4
3
|
// import path from "path";
|
5
4
|
const command_1 = require("@oclif/command");
|
6
5
|
const SessionCommand_1 = require("../utils/SessionCommand");
|
@@ -12,7 +11,6 @@ const fileQueue_1 = require("../utils/fileQueue");
|
|
12
11
|
const file_1 = require("../managers/file");
|
13
12
|
const misc_1 = require("../utils/misc");
|
14
13
|
const osOperations_1 = require("../utils/osOperations");
|
15
|
-
const cli_ux_1 = require("cli-ux");
|
16
14
|
const checkNotInstalled_1 = require("../utils/checkNotInstalled");
|
17
15
|
class StartCommand extends SessionCommand_1.default {
|
18
16
|
// 🛑 IMPORTANT
|
@@ -22,54 +20,25 @@ class StartCommand extends SessionCommand_1.default {
|
|
22
20
|
await this.initSession(flags);
|
23
21
|
}
|
24
22
|
async run() {
|
25
|
-
var
|
26
|
-
var _b, _c, _d, _e, _f, _g;
|
23
|
+
var _a, _b, _c, _d, _e, _f;
|
27
24
|
// get configuration object
|
28
|
-
const configObject = (
|
25
|
+
const configObject = (_a = this.configManager) === null || _a === void 0 ? void 0 : _a.get();
|
29
26
|
// TODO: console.log(this.config.platform); get the platfrom from Oclif
|
30
27
|
const hasXDG = await osOperations_1.eventManager.checkXDGInstalled();
|
31
28
|
const installedPlugins = this.config.plugins.map(plugin => {
|
32
29
|
return `${plugin.pjson.name}`;
|
33
30
|
});
|
34
|
-
const neededToInstallPlugins = checkNotInstalled_1.checkNotInstalledPlugins((configObject === null || configObject === void 0 ? void 0 : configObject.exercises) || [], installedPlugins);
|
35
|
-
if (neededToInstallPlugins.length > 0) {
|
36
|
-
console_1.default.error("These plugins are not installed but required: ", neededToInstallPlugins);
|
37
|
-
const confirmInstall = await cli_ux_1.cli.confirm("Do you want to install the needed plugins? (y/n)");
|
38
|
-
if (confirmInstall) {
|
39
|
-
console_1.default.info("Installing the needed plugins...");
|
40
|
-
try {
|
41
|
-
for (var neededToInstallPlugins_1 = tslib_1.__asyncValues(neededToInstallPlugins), neededToInstallPlugins_1_1; neededToInstallPlugins_1_1 = await neededToInstallPlugins_1.next(), !neededToInstallPlugins_1_1.done;) {
|
42
|
-
const p = neededToInstallPlugins_1_1.value;
|
43
|
-
await this.config.runCommand(`plugins:install`, [p]);
|
44
|
-
console_1.default.log(`Plugin ${p} installed`);
|
45
|
-
}
|
46
|
-
}
|
47
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
48
|
-
finally {
|
49
|
-
try {
|
50
|
-
if (neededToInstallPlugins_1_1 && !neededToInstallPlugins_1_1.done && (_a = neededToInstallPlugins_1.return)) await _a.call(neededToInstallPlugins_1);
|
51
|
-
}
|
52
|
-
finally { if (e_1) throw e_1.error; }
|
53
|
-
}
|
54
|
-
console_1.default.log("All needed plugins installed, please restart LearnPack to load them.");
|
55
|
-
console_1.default.info("Run: $ learnpack start");
|
56
|
-
this.exit(0);
|
57
|
-
}
|
58
|
-
else {
|
59
|
-
console_1.default.error("You need to install the plugins to complete this exercise");
|
60
|
-
console_1.default.info("To install the plugins run each of the following commands: ");
|
61
|
-
for (const p of neededToInstallPlugins) {
|
62
|
-
console_1.default.log(`learnpack plugins:install ${p}`);
|
63
|
-
}
|
64
|
-
this.exit(1);
|
65
|
-
}
|
66
|
-
}
|
67
31
|
if (configObject) {
|
68
32
|
const { config } = configObject;
|
69
33
|
// build exerises
|
70
|
-
(
|
71
|
-
console_1.default.debug(`Grading: ${config === null || config === void 0 ? void 0 : config.grading} ${((
|
34
|
+
(_b = this.configManager) === null || _b === void 0 ? void 0 : _b.buildIndex();
|
35
|
+
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) ? configObject === null || configObject === void 0 ? void 0 : configObject.exercises.length :
|
72
36
|
0} exercises found`);
|
37
|
+
const neededPlugins = await checkNotInstalled_1.checkNotInstalledPlugins((configObject === null || configObject === void 0 ? void 0 : configObject.exercises) || [], installedPlugins, this);
|
38
|
+
const allDepsInstalled = await checkNotInstalled_1.checkNotInstalledDependencies(neededPlugins.needed);
|
39
|
+
if (!allDepsInstalled) {
|
40
|
+
this.exit(1);
|
41
|
+
}
|
73
42
|
const appAlreadyExists = file_1.checkIfDirectoryExists(`${config === null || config === void 0 ? void 0 : config.dirPath}/_app`);
|
74
43
|
if (!appAlreadyExists) {
|
75
44
|
// download app and decompress
|
@@ -87,9 +56,9 @@ class StartCommand extends SessionCommand_1.default {
|
|
87
56
|
path: `${config.dirPath}/vscode_queue.json`,
|
88
57
|
});
|
89
58
|
if (configObject.exercises) {
|
90
|
-
const agent = ((
|
91
|
-
const path = ((
|
92
|
-
const tutorialSlug = ((
|
59
|
+
const agent = ((_d = configObject.config) === null || _d === void 0 ? void 0 : _d.editor.agent) || "";
|
60
|
+
const path = ((_e = configObject.config) === null || _e === void 0 ? void 0 : _e.dirPath) || "";
|
61
|
+
const tutorialSlug = ((_f = configObject.config) === null || _f === void 0 ? void 0 : _f.slug) || "";
|
93
62
|
const steps = configObject.exercises.map((e, index) => ({
|
94
63
|
slug: e.slug,
|
95
64
|
position: e.position || index,
|
@@ -51,7 +51,6 @@ const getCodespacesNamespace = () => {
|
|
51
51
|
if (!codespace_name ||
|
52
52
|
codespace_name === "" ||
|
53
53
|
codespace_name === undefined ||
|
54
|
-
// ! I added this line
|
55
54
|
codespace_name === "$CODESPACE_NAME") {
|
56
55
|
return null;
|
57
56
|
}
|
@@ -143,7 +142,7 @@ exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
|
143
142
|
console_1.default.debug("Config version not found, downloading default.");
|
144
143
|
const resp = await fetch("https://raw.githubusercontent.com/learnpack/ide/master/package.json");
|
145
144
|
const packageJSON = await resp.json();
|
146
|
-
configObj.config.editor.version = packageJSON.version || "3.1.
|
145
|
+
configObj.config.editor.version = packageJSON.version || "3.1.23";
|
147
146
|
}
|
148
147
|
configObj.config.dirPath = "./" + confPath.base;
|
149
148
|
configObj.config.exercisesPath = getExercisesPath(confPath.base) || "./";
|
@@ -1,2 +1,8 @@
|
|
1
1
|
import { IExercise } from "../models/exercise-obj";
|
2
|
-
|
2
|
+
declare type TNeededPlugins = {
|
3
|
+
needed: string[];
|
4
|
+
notInstalled: string[];
|
5
|
+
};
|
6
|
+
export declare const checkNotInstalledPlugins: (exercises: IExercise[], installedPlugins: string[], command: any) => Promise<TNeededPlugins>;
|
7
|
+
export declare const checkNotInstalledDependencies: (neededPlugins: string[]) => Promise<boolean | undefined>;
|
8
|
+
export {};
|
@@ -1,34 +1,174 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.checkNotInstalledPlugins = void 0;
|
4
|
-
|
3
|
+
exports.checkNotInstalledDependencies = exports.checkNotInstalledPlugins = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const util_1 = require("util");
|
6
|
+
const child_process_1 = require("child_process");
|
7
|
+
const exec = util_1.promisify(child_process_1.exec);
|
8
|
+
const cli_ux_1 = require("cli-ux");
|
9
|
+
const console_1 = require("./console");
|
10
|
+
exports.checkNotInstalledPlugins = async (exercises, installedPlugins, command) => {
|
11
|
+
var e_1, _a;
|
12
|
+
console_1.default.info("Checking needed plugins...");
|
5
13
|
const usefulExtensions = new Set(["py", "js", "jsx", "html"]);
|
6
14
|
const foundExtensions = [];
|
15
|
+
const testingExtensions = [];
|
16
|
+
const neededPlugins = [];
|
17
|
+
let someExerciseWithOnlyTestFile = false; // I will suppose that there are not exercises with only readme and test files
|
18
|
+
// See the extensions of the files that are not tests files
|
7
19
|
for (const e of exercises) {
|
8
|
-
|
20
|
+
const notReadmeFiles = e.files.filter(f => !f.name.toLowerCase().includes("readme"));
|
21
|
+
if (!someExerciseWithOnlyTestFile) {
|
22
|
+
someExerciseWithOnlyTestFile = notReadmeFiles.every(f => f.name.includes("test"));
|
23
|
+
}
|
24
|
+
for (const f of notReadmeFiles) {
|
25
|
+
// There are some courses with only test files in js and grading: incremental
|
26
|
+
// TODO: We should know in the incremental exercises which compilers are needed
|
9
27
|
const ext = f.name.split(".").pop();
|
28
|
+
if (f.name.includes("test")) {
|
29
|
+
testingExtensions.push(ext);
|
30
|
+
continue;
|
31
|
+
}
|
10
32
|
if (ext && usefulExtensions.has(ext) && !foundExtensions.includes(ext)) {
|
11
33
|
foundExtensions.push(ext);
|
12
34
|
}
|
13
35
|
}
|
14
36
|
}
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
37
|
+
if (foundExtensions.length === 0)
|
38
|
+
return {
|
39
|
+
needed: [],
|
40
|
+
notInstalled: [],
|
41
|
+
};
|
42
|
+
if (foundExtensions.includes("html") && foundExtensions.includes("js")) {
|
43
|
+
neededPlugins.push("@learnpack/dom");
|
44
|
+
}
|
45
|
+
if (foundExtensions.includes("html") && !foundExtensions.includes("js")) {
|
46
|
+
neededPlugins.push("@learnpack/html");
|
47
|
+
}
|
48
|
+
if (foundExtensions.includes("jsx")) {
|
49
|
+
neededPlugins.push("@learnpack/react");
|
50
|
+
}
|
51
|
+
if (foundExtensions.includes("py") || testingExtensions.includes("py")) {
|
52
|
+
neededPlugins.push("@learnpack/python");
|
53
|
+
}
|
54
|
+
if ((foundExtensions.includes("js") && !foundExtensions.includes("html")) ||
|
55
|
+
(testingExtensions.includes("js") && someExerciseWithOnlyTestFile)) {
|
56
|
+
neededPlugins.push("@learnpack/node");
|
57
|
+
}
|
58
|
+
const notInstalled = neededPlugins.filter(item => !installedPlugins.includes(item));
|
59
|
+
if (notInstalled.length > 0) {
|
60
|
+
console_1.default.error("These plugins are not installed but required: ", notInstalled);
|
61
|
+
const confirmInstall = await cli_ux_1.cli.confirm("Do you want to install the needed plugins? (y/n)");
|
62
|
+
if (confirmInstall) {
|
63
|
+
console_1.default.info("Installing the needed plugins...");
|
64
|
+
try {
|
65
|
+
for (var notInstalled_1 = tslib_1.__asyncValues(notInstalled), notInstalled_1_1; notInstalled_1_1 = await notInstalled_1.next(), !notInstalled_1_1.done;) {
|
66
|
+
const p = notInstalled_1_1.value;
|
67
|
+
await command.config.runCommand(`plugins:install`, [p]);
|
68
|
+
console_1.default.log(`Plugin ${p} installed`);
|
69
|
+
}
|
70
|
+
}
|
71
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
72
|
+
finally {
|
73
|
+
try {
|
74
|
+
if (notInstalled_1_1 && !notInstalled_1_1.done && (_a = notInstalled_1.return)) await _a.call(notInstalled_1);
|
75
|
+
}
|
76
|
+
finally { if (e_1) throw e_1.error; }
|
77
|
+
}
|
78
|
+
console_1.default.log("All needed plugins installed, please restart LearnPack to load them.");
|
79
|
+
console_1.default.info("Run: $ learnpack start");
|
80
|
+
command.exit(0);
|
19
81
|
}
|
20
|
-
|
21
|
-
|
82
|
+
else {
|
83
|
+
console_1.default.error("You need to install the plugins to complete this exercise");
|
84
|
+
console_1.default.info("To install the plugins run each of the following commands: ");
|
85
|
+
for (const p of notInstalled) {
|
86
|
+
console_1.default.log(`learnpack plugins:install ${p}`);
|
87
|
+
}
|
88
|
+
command.exit(1);
|
22
89
|
}
|
23
|
-
|
24
|
-
|
90
|
+
}
|
91
|
+
return {
|
92
|
+
needed: neededPlugins,
|
93
|
+
notInstalled,
|
94
|
+
};
|
95
|
+
};
|
96
|
+
function includesAll(baseString, elementsArray) {
|
97
|
+
return elementsArray.every(element => baseString.includes(element));
|
98
|
+
}
|
99
|
+
const installDependencies = async (deps, packageManager) => {
|
100
|
+
let command = "";
|
101
|
+
if (packageManager === "npm") {
|
102
|
+
command = `npm install -g ${deps.join(" ")}`;
|
103
|
+
}
|
104
|
+
else if (packageManager === "pip") {
|
105
|
+
command = `pip install ${deps.join(" ")}`;
|
106
|
+
}
|
107
|
+
const { stdout, stderr } = await exec(command);
|
108
|
+
if (stderr && (stderr.includes("npm ERR!") || stderr.includes("Traceback"))) {
|
109
|
+
console_1.default.error(`Error executing ${command}.`);
|
110
|
+
console_1.default.error(stderr);
|
111
|
+
return;
|
112
|
+
}
|
113
|
+
console_1.default.info(`Dependencies ${deps.join(" ")} installed...`);
|
114
|
+
return true;
|
115
|
+
};
|
116
|
+
exports.checkNotInstalledDependencies = async (neededPlugins) => {
|
117
|
+
console_1.default.info("Checking needed dependencies...");
|
118
|
+
const jsPluginsDependencies = [
|
119
|
+
"jest@29.7.0",
|
120
|
+
"jest-environment-jsdom@29.7.0",
|
121
|
+
];
|
122
|
+
const pyPluginsDependencies = ["pytest==6.2.5", "pytest-testdox", "mock"];
|
123
|
+
const npmLsCommand = "npm ls jest jest-environment-jsdom -g";
|
124
|
+
let pytestNeeded = false;
|
125
|
+
let jestNeeded = false;
|
126
|
+
if (neededPlugins.includes("@learnpack/dom") ||
|
127
|
+
neededPlugins.includes("@learnpack/html") ||
|
128
|
+
neededPlugins.includes("@learnpack/react") ||
|
129
|
+
neededPlugins.includes("@learnpack/node")) {
|
130
|
+
jestNeeded = true;
|
131
|
+
}
|
132
|
+
if ("@learnpack/python" in neededPlugins) {
|
133
|
+
pytestNeeded = true;
|
134
|
+
}
|
135
|
+
if (jestNeeded) {
|
136
|
+
const { stdout, stderr } = await exec("npm ls jest jest-environment-jsdom -g");
|
137
|
+
if (stderr) {
|
138
|
+
console_1.default.error(`Error executing ${npmLsCommand}. Use debug for more info`);
|
139
|
+
console_1.default.debug(stderr);
|
140
|
+
return false;
|
25
141
|
}
|
26
|
-
if (
|
27
|
-
|
142
|
+
if (includesAll(stdout, jsPluginsDependencies))
|
143
|
+
return true;
|
144
|
+
console_1.default.error("The jest dependencies are not installed");
|
145
|
+
const confirmInstall = await cli_ux_1.cli.confirm("Do you want to install the needed dependencies? (y/n)");
|
146
|
+
if (!confirmInstall) {
|
147
|
+
console_1.default.error(`The exercises can't be tested without the following dependencies: ${jsPluginsDependencies.join(", ")}`);
|
148
|
+
console_1.default.info(`Please install them and try again. Run the following command to install them: \nnpm install -g ${jsPluginsDependencies.join(" ")}`);
|
149
|
+
return false;
|
150
|
+
}
|
151
|
+
console_1.default.log("Installing jest dependencies...");
|
152
|
+
await installDependencies(jsPluginsDependencies, "npm");
|
153
|
+
}
|
154
|
+
if (pytestNeeded) {
|
155
|
+
const { stdout, stderr } = await exec("pip list");
|
156
|
+
if (stderr) {
|
157
|
+
console_1.default.error(`Error executing pip list. Use debug for more info`);
|
158
|
+
console_1.default.debug(stderr);
|
159
|
+
return;
|
28
160
|
}
|
29
|
-
if (
|
30
|
-
|
161
|
+
if (includesAll(stdout, pyPluginsDependencies))
|
162
|
+
return true;
|
163
|
+
console_1.default.error("The pytest dependencies are not installed");
|
164
|
+
const confirmInstall = await cli_ux_1.cli.confirm("Do you want to install the needed dependencies? (y/n)");
|
165
|
+
if (!confirmInstall) {
|
166
|
+
console_1.default.error(`The exercises can't be tested without the following dependencies: ${pyPluginsDependencies.join(", ")}`);
|
167
|
+
console_1.default.info(`Please install them and try again. Run the following command to install them: \npip install ${pyPluginsDependencies.join(" ")}`);
|
168
|
+
return false;
|
31
169
|
}
|
170
|
+
console_1.default.log("Installing pytest dependencies...");
|
171
|
+
await installDependencies(pyPluginsDependencies, "pip");
|
32
172
|
}
|
33
|
-
return
|
173
|
+
return true;
|
34
174
|
};
|
package/lib/utils/console.d.ts
CHANGED
@@ -4,7 +4,7 @@ declare const _default: {
|
|
4
4
|
log: (msg: string | Array<string>, ...args: Array<any>) => void;
|
5
5
|
error: (msg: string, ...args: Array<any>) => void;
|
6
6
|
success: (msg: string, ...args: Array<any>) => void;
|
7
|
-
info: (msg:
|
7
|
+
info: (msg: any, ...args: Array<any>) => void;
|
8
8
|
help: (msg: string) => void;
|
9
9
|
debug(...args: Array<any>): void;
|
10
10
|
warning: (msg: string) => void;
|
package/lib/utils/console.js
CHANGED
@@ -3,17 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const chalk = require("chalk");
|
4
4
|
exports.default = {
|
5
5
|
// _debug: true,
|
6
|
-
_debug: process.env.DEBUG ===
|
6
|
+
_debug: process.env.DEBUG === "true",
|
7
7
|
startDebug: function () {
|
8
8
|
this._debug = true;
|
9
9
|
},
|
10
10
|
log: (msg, ...args) => console.log(chalk.gray(msg), ...args),
|
11
|
-
error: (msg, ...args) => console.log(chalk.red(
|
12
|
-
success: (msg, ...args) => console.log(chalk.green(
|
13
|
-
info: (msg, ...args) => console.log(chalk.blue(
|
14
|
-
help: (msg) => console.log(`${chalk.white.bold(
|
11
|
+
error: (msg, ...args) => console.log(chalk.red("⨉ " + msg), ...args),
|
12
|
+
success: (msg, ...args) => console.log(chalk.green("✓ " + msg), ...args),
|
13
|
+
info: (msg, ...args) => console.log(chalk.blue("ⓘ " + msg), ...args),
|
14
|
+
help: (msg) => console.log(`${chalk.white.bold("⚠ help:")} ${chalk.white(msg)}`),
|
15
15
|
debug(...args) {
|
16
|
-
this._debug && console.log(chalk.magentaBright(
|
16
|
+
this._debug && console.log(chalk.magentaBright("⚠ debug: "), args);
|
17
17
|
},
|
18
|
-
warning: (msg) => console.log(`${chalk.yellow(
|
18
|
+
warning: (msg) => console.log(`${chalk.yellow("⚠ warning:")} ${chalk.yellow(msg)}`),
|
19
19
|
};
|
package/oclif.manifest.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":"2.1.
|
1
|
+
{"version":"2.1.45","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.
|
4
|
+
"version": "2.1.45",
|
5
5
|
"author": "Alejandro Sanchez @alesanchezr",
|
6
6
|
"bin": {
|
7
7
|
"learnpack": "bin/run"
|
@@ -100,7 +100,8 @@
|
|
100
100
|
"plugins": [
|
101
101
|
"@oclif/plugin-help",
|
102
102
|
"@oclif/plugin-plugins",
|
103
|
-
"@oclif/plugin-warn-if-update-available"
|
103
|
+
"@oclif/plugin-warn-if-update-available",
|
104
|
+
"@learnpack/react"
|
104
105
|
],
|
105
106
|
"permanent_plugins": [
|
106
107
|
"@oclif/plugin-help",
|
package/src/commands/start.ts
CHANGED
@@ -19,7 +19,10 @@ import { IExercise, IExerciseData } from "../models/exercise-obj"
|
|
19
19
|
import { eventManager } from "../utils/osOperations"
|
20
20
|
import { cli } from "cli-ux"
|
21
21
|
import { TOpenWindowData } from "../models/socket"
|
22
|
-
import {
|
22
|
+
import {
|
23
|
+
checkNotInstalledPlugins,
|
24
|
+
checkNotInstalledDependencies,
|
25
|
+
} from "../utils/checkNotInstalled"
|
23
26
|
|
24
27
|
export default class StartCommand extends SessionCommand {
|
25
28
|
static description = "Runs a small server with all the exercise instructions"
|
@@ -79,48 +82,8 @@ export default class StartCommand extends SessionCommand {
|
|
79
82
|
return `${plugin.pjson.name}`
|
80
83
|
})
|
81
84
|
|
82
|
-
const neededToInstallPlugins = checkNotInstalledPlugins(
|
83
|
-
configObject?.exercises || [],
|
84
|
-
installedPlugins
|
85
|
-
)
|
86
|
-
if (neededToInstallPlugins.length > 0) {
|
87
|
-
Console.error(
|
88
|
-
"These plugins are not installed but required: ",
|
89
|
-
neededToInstallPlugins
|
90
|
-
)
|
91
|
-
const confirmInstall = await cli.confirm(
|
92
|
-
"Do you want to install the needed plugins? (y/n)"
|
93
|
-
)
|
94
|
-
if (confirmInstall) {
|
95
|
-
Console.info("Installing the needed plugins...")
|
96
|
-
for await (const p of neededToInstallPlugins) {
|
97
|
-
await this.config.runCommand(`plugins:install`, [p])
|
98
|
-
Console.log(`Plugin ${p} installed`)
|
99
|
-
}
|
100
|
-
|
101
|
-
Console.log(
|
102
|
-
"All needed plugins installed, please restart LearnPack to load them."
|
103
|
-
)
|
104
|
-
Console.info("Run: $ learnpack start")
|
105
|
-
this.exit(0)
|
106
|
-
} else {
|
107
|
-
Console.error(
|
108
|
-
"You need to install the plugins to complete this exercise"
|
109
|
-
)
|
110
|
-
Console.info(
|
111
|
-
"To install the plugins run each of the following commands: "
|
112
|
-
)
|
113
|
-
for (const p of neededToInstallPlugins) {
|
114
|
-
Console.log(`learnpack plugins:install ${p}`)
|
115
|
-
}
|
116
|
-
|
117
|
-
this.exit(1)
|
118
|
-
}
|
119
|
-
}
|
120
|
-
|
121
85
|
if (configObject) {
|
122
86
|
const { config } = configObject
|
123
|
-
|
124
87
|
// build exerises
|
125
88
|
this.configManager?.buildIndex()
|
126
89
|
|
@@ -134,6 +97,19 @@ export default class StartCommand extends SessionCommand {
|
|
134
97
|
} exercises found`
|
135
98
|
)
|
136
99
|
|
100
|
+
const neededPlugins = await checkNotInstalledPlugins(
|
101
|
+
configObject?.exercises || [],
|
102
|
+
installedPlugins,
|
103
|
+
this
|
104
|
+
)
|
105
|
+
|
106
|
+
const allDepsInstalled = await checkNotInstalledDependencies(
|
107
|
+
neededPlugins.needed
|
108
|
+
)
|
109
|
+
if (!allDepsInstalled) {
|
110
|
+
this.exit(1)
|
111
|
+
}
|
112
|
+
|
137
113
|
const appAlreadyExists = checkIfDirectoryExists(
|
138
114
|
`${config?.dirPath}/_app`
|
139
115
|
)
|