@learnpack/learnpack 2.1.28 → 2.1.30
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 -6
- package/lib/managers/config/index.js +18 -7
- package/lib/managers/file.js +9 -2
- package/lib/managers/server/routes.js +0 -2
- package/lib/managers/session.js +1 -3
- package/lib/managers/socket.js +0 -2
- package/lib/utils/api.js +0 -2
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/start.ts +4 -9
- package/src/managers/config/index.ts +26 -5
- package/src/managers/file.ts +15 -8
- package/src/managers/server/routes.ts +0 -2
- package/src/managers/session.ts +1 -3
- package/src/managers/socket.ts +1 -3
- package/src/utils/api.ts +1 -2
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.30 darwin-arm64 node-v16.20.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.30/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.30/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.30/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.30/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.30/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.30/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.30/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.30/src/commands/start.ts)_
|
334
334
|
|
335
335
|
## `learnpack test [EXERCISESLUG]`
|
336
336
|
|
@@ -344,5 +344,5 @@ 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.30/src/commands/test.ts)_
|
348
348
|
<!-- commandsstop -->
|
package/lib/commands/start.js
CHANGED
@@ -44,16 +44,13 @@ class StartCommand extends SessionCommand_1.default {
|
|
44
44
|
socket_1.default.start(config, server, false);
|
45
45
|
socket_1.default.on("open", (data) => {
|
46
46
|
console_1.default.debug("Opening these files: ", data);
|
47
|
-
console.log("Opening files", data);
|
48
47
|
const files = misc_1.prioritizeHTMLFile(data.files);
|
49
|
-
// console.log("files",files);
|
50
48
|
dispatcher.enqueue(dispatcher.events.OPEN_FILES, files);
|
51
49
|
socket_1.default.ready("Ready to compile...");
|
52
50
|
});
|
53
51
|
socket_1.default.on("open_window", (data) => {
|
54
52
|
console_1.default.debug("Opening window: ", data);
|
55
53
|
dispatcher.enqueue(dispatcher.events.OPEN_WINDOW, data);
|
56
|
-
console.log(data);
|
57
54
|
socket_1.default.ready("Ready to compile...");
|
58
55
|
});
|
59
56
|
socket_1.default.on("reset", (exercise) => {
|
@@ -96,12 +93,11 @@ class StartCommand extends SessionCommand_1.default {
|
|
96
93
|
});
|
97
94
|
});
|
98
95
|
socket_1.default.on("generate", async (data) => {
|
99
|
-
console.log("
|
96
|
+
console.log("Receving generate event, this shouldn't be happening", data);
|
100
97
|
});
|
101
98
|
socket_1.default.on("test", async (data) => {
|
102
99
|
var _a, _b;
|
103
100
|
const exercise = (_a = this.configManager) === null || _a === void 0 ? void 0 : _a.getExercise(data.exerciseSlug);
|
104
|
-
console.log("data", data);
|
105
101
|
if (!(exercise === null || exercise === void 0 ? void 0 : exercise.language)) {
|
106
102
|
socket_1.default.error("compiler-error", "Impossible to detect engine language for testing for " +
|
107
103
|
data.exerciseSlug +
|
@@ -113,7 +109,6 @@ class StartCommand extends SessionCommand_1.default {
|
|
113
109
|
return true;
|
114
110
|
}
|
115
111
|
socket_1.default.log("testing", "Testing your exercise using the " + exercise.language + " engine.");
|
116
|
-
console.log("About to call runHook");
|
117
112
|
await this.config.runHook("action", {
|
118
113
|
action: "test",
|
119
114
|
socket: socket_1.default,
|
@@ -44,13 +44,15 @@ const getCodespacesNamespace = () => {
|
|
44
44
|
.stdout.replace(/(\r\n|\n|\r)/gm, "");
|
45
45
|
if (!codespace_name ||
|
46
46
|
codespace_name === "" ||
|
47
|
-
codespace_name === undefined
|
47
|
+
codespace_name === undefined ||
|
48
|
+
// ! I added this line
|
49
|
+
codespace_name === "$CODESPACE_NAME") {
|
48
50
|
return null;
|
49
51
|
}
|
50
52
|
return codespace_name;
|
51
53
|
};
|
52
54
|
exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
53
|
-
var _a, _b;
|
55
|
+
var _a, _b, _c, _d, _e;
|
54
56
|
const confPath = getConfigPath();
|
55
57
|
console_1.default.debug("This is the config path: ", confPath);
|
56
58
|
let configObj = {};
|
@@ -79,7 +81,6 @@ exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
|
79
81
|
config: jsonConfig,
|
80
82
|
session: session,
|
81
83
|
});
|
82
|
-
console_1.default.debug("Content from the configuration .json ", configObj);
|
83
84
|
}
|
84
85
|
else {
|
85
86
|
throw errors_1.ValidationError("No learn.json file has been found, make sure you are in the folder");
|
@@ -98,19 +99,29 @@ exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
|
98
99
|
[] }));
|
99
100
|
// auto detect agent (if possible)
|
100
101
|
const codespaces_workspace = getCodespacesNamespace();
|
102
|
+
console_1.default.debug("This is the codespace namespace: ", codespaces_workspace);
|
103
|
+
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);
|
101
104
|
if (shell.which("gp") && configObj && configObj.config) {
|
105
|
+
console_1.default.debug("Gitpod detected");
|
102
106
|
configObj.config.editor.agent = "vscode";
|
103
107
|
configObj.address = getGitpodAddress();
|
104
|
-
configObj.config.publicUrl = `https://${configObj.config.port}-${(
|
108
|
+
configObj.config.publicUrl = `https://${configObj.config.port}-${(_d = configObj.address) === null || _d === void 0 ? void 0 : _d.slice(8)}`;
|
105
109
|
}
|
106
|
-
else if (configObj.config && codespaces_workspace) {
|
110
|
+
else if (configObj.config && Boolean(codespaces_workspace)) {
|
111
|
+
console_1.default.debug("Codespaces detected: ", codespaces_workspace);
|
107
112
|
configObj.config.editor.agent = "vscode";
|
108
113
|
configObj.address = `https://${codespaces_workspace}.github.dev`;
|
109
114
|
configObj.config.publicUrl = `https://${codespaces_workspace}-${configObj.config.port}.app.github.dev`;
|
115
|
+
// TODO: Why is needed to have an agent?
|
116
|
+
// } else if (configObj.config && !configObj.config.editor.agent) {
|
110
117
|
}
|
111
|
-
else if (configObj.config
|
118
|
+
else if (configObj.config) {
|
119
|
+
console_1.default.debug("Localhost detected");
|
112
120
|
configObj.config.editor.agent = "localhost";
|
121
|
+
configObj.address = `http://localhost:${configObj.config.port}`;
|
122
|
+
configObj.config.publicUrl = `http://localhost:${configObj.config.port}`;
|
113
123
|
}
|
124
|
+
console_1.default.debug("This is the agent later", (_e = configObj === null || configObj === void 0 ? void 0 : configObj.config) === null || _e === void 0 ? void 0 : _e.editor.agent);
|
114
125
|
if (configObj.config && !configObj.config.publicUrl)
|
115
126
|
configObj.config.publicUrl = `${configObj.address}:${configObj.config.port}`;
|
116
127
|
// Assign default editor mode if not set already
|
@@ -284,7 +295,7 @@ exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
|
284
295
|
});
|
285
296
|
},
|
286
297
|
save: () => {
|
287
|
-
|
298
|
+
// Console.debug("Saving configuration with: ", configObj)
|
288
299
|
// remove the duplicates form the actions array
|
289
300
|
// configObj.config.actions = [...new Set(configObj.config.actions)];
|
290
301
|
if (configObj.config) {
|
package/lib/managers/file.js
CHANGED
@@ -30,11 +30,18 @@ exports.decompress = (sourcePath, destinationPath) => new Promise((resolve, reje
|
|
30
30
|
exports.downloadEditor = async (version, destination) => {
|
31
31
|
// https://raw.githubusercontent.com/learnpack/coding-ide/master/dist/app.tar.gz
|
32
32
|
// if(versions[version] === undefined) throw new Error(`Invalid editor version ${version}`)
|
33
|
-
|
33
|
+
if (!version)
|
34
|
+
throw errors_1.InternalError("Missing editor version on learn.json");
|
35
|
+
const versionNumber = parseInt(version === null || version === void 0 ? void 0 : version.split(".")[0]);
|
36
|
+
let url = `https://github.com/learnpack/coding-ide/blob/${version}/dist`;
|
37
|
+
if (versionNumber > 2)
|
38
|
+
url = `https://github.com/learnpack/ide/blob/master/bin/learnpack-${version}.tar.gz`;
|
39
|
+
const resp2 = await fetch(url, { method: "HEAD" });
|
34
40
|
if (!resp2.ok)
|
35
41
|
throw errors_1.InternalError(`Coding Editor ${version} was not found on learnpack repository, check the config.editor.version property on learn.json`);
|
36
42
|
console_1.default.info("Downloading the LearnPack coding UI, this may take a minute...");
|
37
|
-
|
43
|
+
url += versionNumber > 2 ? `?raw=true` : `/app.tar.gz?raw=true`;
|
44
|
+
return exports.download(url, destination);
|
38
45
|
};
|
39
46
|
exports.download = (url, dest) => {
|
40
47
|
console_1.default.debug("Downloading " + url);
|
@@ -48,7 +48,6 @@ async function default_1(app, configObject, configManager) {
|
|
48
48
|
}));
|
49
49
|
app.post("/set-openai-token", jsonBodyParser, withHandler(async (req, res) => {
|
50
50
|
const token = req.body.token;
|
51
|
-
console.log("Setting openai token");
|
52
51
|
const tokenSaved = await session_1.default.setOpenAIToken(token);
|
53
52
|
if (tokenSaved) {
|
54
53
|
res.json({ status: "ok" });
|
@@ -60,7 +59,6 @@ async function default_1(app, configObject, configManager) {
|
|
60
59
|
app.get("/check/rigo/status", withHandler(async (_, res) => {
|
61
60
|
const payload = await session_1.default.getPayload();
|
62
61
|
const openaiToken = await session_1.default.getOpenAIToken();
|
63
|
-
// console.log("Looking Rigo creds");
|
64
62
|
if (payload && payload.rigobot && payload.rigobot.key) {
|
65
63
|
res.json({ rigoToken: payload.rigobot.key });
|
66
64
|
}
|
package/lib/managers/session.js
CHANGED
package/lib/managers/socket.js
CHANGED
@@ -86,10 +86,8 @@ const SocketManager = {
|
|
86
86
|
ask: function (questions = []) {
|
87
87
|
return new Promise((resolve, _) => {
|
88
88
|
this.emit("ask", "pending", ["Waiting for input..."], questions);
|
89
|
-
console.log("Setting up listeners");
|
90
89
|
this.on("input", ({ inputs }) => {
|
91
90
|
// Workaround to fix issue because null inputs
|
92
|
-
console.log("inputs", inputs);
|
93
91
|
let isNull = false;
|
94
92
|
// eslint-disable-next-line
|
95
93
|
inputs.forEach((input) => {
|
package/lib/utils/api.js
CHANGED
@@ -58,7 +58,6 @@ const login = async (identification, password) => {
|
|
58
58
|
cli_ux_1.default.action.start(`Looking for credentials with ${identification}`);
|
59
59
|
await cli_ux_1.default.wait(1000);
|
60
60
|
const url = `${HOST}/v1/auth/login/`;
|
61
|
-
// Console.log(url);
|
62
61
|
const data = await fetch(url, {
|
63
62
|
body: JSON.stringify({
|
64
63
|
email: identification,
|
@@ -129,7 +128,6 @@ const publish = async (config) => {
|
|
129
128
|
return data;
|
130
129
|
}
|
131
130
|
catch (error) {
|
132
|
-
console.log("payload", payload);
|
133
131
|
console_1.default.error(error.message);
|
134
132
|
console_1.default.debug(error);
|
135
133
|
throw error;
|
package/oclif.manifest.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":"2.1.
|
1
|
+
{"version":"2.1.30","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":"[standalone, gitpod]","options":["standalone","gitpod"]},"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
@@ -120,10 +120,8 @@ export default class StartCommand extends SessionCommand {
|
|
120
120
|
|
121
121
|
socket.on("open", (data: IGitpodData) => {
|
122
122
|
Console.debug("Opening these files: ", data)
|
123
|
-
console.log("Opening files", data)
|
124
123
|
|
125
124
|
const files = prioritizeHTMLFile(data.files)
|
126
|
-
// console.log("files",files);
|
127
125
|
|
128
126
|
dispatcher.enqueue(dispatcher.events.OPEN_FILES, files)
|
129
127
|
socket.ready("Ready to compile...")
|
@@ -132,8 +130,6 @@ export default class StartCommand extends SessionCommand {
|
|
132
130
|
socket.on("open_window", (data: IGitpodData) => {
|
133
131
|
Console.debug("Opening window: ", data)
|
134
132
|
dispatcher.enqueue(dispatcher.events.OPEN_WINDOW, data)
|
135
|
-
console.log(data)
|
136
|
-
|
137
133
|
socket.ready("Ready to compile...")
|
138
134
|
})
|
139
135
|
|
@@ -190,14 +186,15 @@ export default class StartCommand extends SessionCommand {
|
|
190
186
|
})
|
191
187
|
|
192
188
|
socket.on("generate", async (data: IExerciseData) => {
|
193
|
-
console.log(
|
189
|
+
console.log(
|
190
|
+
"Receving generate event, this shouldn't be happening",
|
191
|
+
data
|
192
|
+
)
|
194
193
|
})
|
195
194
|
|
196
195
|
socket.on("test", async (data: IExerciseData) => {
|
197
196
|
const exercise = this.configManager?.getExercise(data.exerciseSlug)
|
198
197
|
|
199
|
-
console.log("data", data)
|
200
|
-
|
201
198
|
if (!exercise?.language) {
|
202
199
|
socket.error(
|
203
200
|
"compiler-error",
|
@@ -221,8 +218,6 @@ export default class StartCommand extends SessionCommand {
|
|
221
218
|
"Testing your exercise using the " + exercise.language + " engine."
|
222
219
|
)
|
223
220
|
|
224
|
-
console.log("About to call runHook")
|
225
|
-
|
226
221
|
await this.config.runHook("action", {
|
227
222
|
action: "test",
|
228
223
|
socket,
|
@@ -59,6 +59,7 @@ const getGitpodAddress = () => {
|
|
59
59
|
|
60
60
|
const getCodespacesNamespace = () => {
|
61
61
|
// https://orange-rotary-phone-wxpg49q5gcg4rp-3000.app.github.dev
|
62
|
+
|
62
63
|
const codespace_name = shell
|
63
64
|
.exec("echo $CODESPACE_NAME", { silent: true })
|
64
65
|
.stdout.replace(/(\r\n|\n|\r)/gm, "")
|
@@ -66,7 +67,9 @@ const getCodespacesNamespace = () => {
|
|
66
67
|
if (
|
67
68
|
!codespace_name ||
|
68
69
|
codespace_name === "" ||
|
69
|
-
codespace_name === undefined
|
70
|
+
codespace_name === undefined ||
|
71
|
+
// ! I added this line
|
72
|
+
codespace_name === "$CODESPACE_NAME"
|
70
73
|
) {
|
71
74
|
return null
|
72
75
|
}
|
@@ -81,6 +84,7 @@ export default async ({
|
|
81
84
|
version,
|
82
85
|
}: IConfigManagerAttributes): Promise<IConfigManager> => {
|
83
86
|
const confPath = getConfigPath()
|
87
|
+
|
84
88
|
Console.debug("This is the config path: ", confPath)
|
85
89
|
|
86
90
|
let configObj: IConfigObj = {}
|
@@ -115,7 +119,6 @@ export default async ({
|
|
115
119
|
config: jsonConfig,
|
116
120
|
session: session,
|
117
121
|
})
|
118
|
-
Console.debug("Content from the configuration .json ", configObj)
|
119
122
|
} else {
|
120
123
|
throw ValidationError(
|
121
124
|
"No learn.json file has been found, make sure you are in the folder"
|
@@ -142,20 +145,38 @@ export default async ({
|
|
142
145
|
|
143
146
|
// auto detect agent (if possible)
|
144
147
|
const codespaces_workspace = getCodespacesNamespace()
|
148
|
+
|
149
|
+
Console.debug("This is the codespace namespace: ", codespaces_workspace)
|
150
|
+
|
151
|
+
Console.debug(
|
152
|
+
"This is the agent, and this should be null an the beginning: ",
|
153
|
+
configObj.config?.editor?.agent
|
154
|
+
)
|
155
|
+
|
145
156
|
if (shell.which("gp") && configObj && configObj.config) {
|
157
|
+
Console.debug("Gitpod detected")
|
146
158
|
configObj.config.editor.agent = "vscode"
|
147
159
|
configObj.address = getGitpodAddress()
|
148
160
|
configObj.config.publicUrl = `https://${
|
149
161
|
configObj.config.port
|
150
162
|
}-${configObj.address?.slice(8)}`
|
151
|
-
} else if (configObj.config && codespaces_workspace) {
|
163
|
+
} else if (configObj.config && Boolean(codespaces_workspace)) {
|
164
|
+
Console.debug("Codespaces detected: ", codespaces_workspace)
|
152
165
|
configObj.config.editor.agent = "vscode"
|
166
|
+
|
153
167
|
configObj.address = `https://${codespaces_workspace}.github.dev`
|
154
168
|
configObj.config.publicUrl = `https://${codespaces_workspace}-${configObj.config.port}.app.github.dev`
|
155
|
-
|
169
|
+
// TODO: Why is needed to have an agent?
|
170
|
+
// } else if (configObj.config && !configObj.config.editor.agent) {
|
171
|
+
} else if (configObj.config) {
|
172
|
+
Console.debug("Localhost detected")
|
156
173
|
configObj.config.editor.agent = "localhost"
|
174
|
+
configObj.address = `http://localhost:${configObj.config.port}`
|
175
|
+
configObj.config.publicUrl = `http://localhost:${configObj.config.port}`
|
157
176
|
}
|
158
177
|
|
178
|
+
Console.debug("This is the agent later", configObj?.config?.editor.agent)
|
179
|
+
|
159
180
|
if (configObj.config && !configObj.config.publicUrl)
|
160
181
|
configObj.config.publicUrl = `${configObj.address}:${configObj.config.port}`
|
161
182
|
|
@@ -384,7 +405,7 @@ onChange()
|
|
384
405
|
})
|
385
406
|
},
|
386
407
|
save: () => {
|
387
|
-
Console.debug("Saving configuration with: ", configObj)
|
408
|
+
// Console.debug("Saving configuration with: ", configObj)
|
388
409
|
|
389
410
|
// remove the duplicates form the actions array
|
390
411
|
// configObj.config.actions = [...new Set(configObj.config.actions)];
|
package/src/managers/file.ts
CHANGED
@@ -36,10 +36,17 @@ export const downloadEditor = async (
|
|
36
36
|
) => {
|
37
37
|
// https://raw.githubusercontent.com/learnpack/coding-ide/master/dist/app.tar.gz
|
38
38
|
// if(versions[version] === undefined) throw new Error(`Invalid editor version ${version}`)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
)
|
39
|
+
|
40
|
+
if (!version)
|
41
|
+
throw InternalError("Missing editor version on learn.json")
|
42
|
+
const versionNumber = parseInt(version?.split(".")[0])
|
43
|
+
|
44
|
+
let url = `https://github.com/learnpack/coding-ide/blob/${version}/dist`
|
45
|
+
|
46
|
+
if (versionNumber > 2)
|
47
|
+
url = `https://github.com/learnpack/ide/blob/master/bin/learnpack-${version}.tar.gz`
|
48
|
+
|
49
|
+
const resp2 = await fetch(url, { method: "HEAD" })
|
43
50
|
if (!resp2.ok)
|
44
51
|
throw InternalError(
|
45
52
|
`Coding Editor ${version} was not found on learnpack repository, check the config.editor.version property on learn.json`
|
@@ -48,10 +55,10 @@ export const downloadEditor = async (
|
|
48
55
|
Console.info(
|
49
56
|
"Downloading the LearnPack coding UI, this may take a minute..."
|
50
57
|
)
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
)
|
58
|
+
|
59
|
+
url += versionNumber > 2 ? `?raw=true` : `/app.tar.gz?raw=true`
|
60
|
+
|
61
|
+
return download(url, destination)
|
55
62
|
}
|
56
63
|
|
57
64
|
export const download = (url: string, dest: string) => {
|
@@ -73,7 +73,6 @@ export default async function (
|
|
73
73
|
jsonBodyParser,
|
74
74
|
withHandler(async (req: express.Request, res: express.Response) => {
|
75
75
|
const token = req.body.token
|
76
|
-
console.log("Setting openai token")
|
77
76
|
|
78
77
|
const tokenSaved = await SessionManager.setOpenAIToken(token)
|
79
78
|
if (tokenSaved) {
|
@@ -89,7 +88,6 @@ export default async function (
|
|
89
88
|
withHandler(async (_: express.Request, res: express.Response) => {
|
90
89
|
const payload = await SessionManager.getPayload()
|
91
90
|
const openaiToken = await SessionManager.getOpenAIToken()
|
92
|
-
// console.log("Looking Rigo creds");
|
93
91
|
|
94
92
|
if (payload && payload.rigobot && payload.rigobot.key) {
|
95
93
|
res.json({ rigoToken: payload.rigobot.key })
|
package/src/managers/session.ts
CHANGED
package/src/managers/socket.ts
CHANGED
@@ -122,12 +122,10 @@ actions = [actions]
|
|
122
122
|
ask: function (questions = []) {
|
123
123
|
return new Promise((resolve, _) => {
|
124
124
|
this.emit("ask", "pending", ["Waiting for input..."], questions)
|
125
|
-
|
125
|
+
|
126
126
|
this.on("input", ({ inputs }: any) => {
|
127
127
|
// Workaround to fix issue because null inputs
|
128
128
|
|
129
|
-
console.log("inputs", inputs)
|
130
|
-
|
131
129
|
let isNull = false
|
132
130
|
// eslint-disable-next-line
|
133
131
|
inputs.forEach((input: any) => {
|
package/src/utils/api.ts
CHANGED
@@ -69,7 +69,7 @@ const login = async (identification: string, password: string) => {
|
|
69
69
|
cli.action.start(`Looking for credentials with ${identification}`)
|
70
70
|
await cli.wait(1000)
|
71
71
|
const url = `${HOST}/v1/auth/login/`
|
72
|
-
|
72
|
+
|
73
73
|
const data = await fetch(url, {
|
74
74
|
body: JSON.stringify({
|
75
75
|
email: identification,
|
@@ -147,7 +147,6 @@ config[k] ? (payload[k] = config[k]) : null
|
|
147
147
|
cli.action.stop("ready")
|
148
148
|
return data
|
149
149
|
} catch (error) {
|
150
|
-
console.log("payload", payload)
|
151
150
|
Console.error((error as TypeError).message)
|
152
151
|
Console.debug(error)
|
153
152
|
throw error
|