@learnpack/learnpack 5.0.40 → 5.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -12
- package/lib/commands/init.js +18 -3
- package/lib/managers/config/index.js +17 -14
- package/lib/models/config.d.ts +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/init.ts +19 -3
- package/src/managers/config/index.ts +17 -15
- package/src/models/config.ts +1 -1
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/5.0.
|
24
|
+
@learnpack/learnpack/5.0.42 win32-x64 node-v22.14.0
|
25
25
|
$ learnpack --help [COMMAND]
|
26
26
|
USAGE
|
27
27
|
$ learnpack COMMAND
|
@@ -79,7 +79,7 @@ DESCRIPTION
|
|
79
79
|
12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)
|
80
80
|
```
|
81
81
|
|
82
|
-
_See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
82
|
+
_See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.42/src\commands\audit.ts)_
|
83
83
|
|
84
84
|
## `learnpack breakToken`
|
85
85
|
|
@@ -94,7 +94,7 @@ OPTIONS
|
|
94
94
|
-y, --yes Skip all prompts and initialize an empty project
|
95
95
|
```
|
96
96
|
|
97
|
-
_See code: [src\commands\breakToken.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
97
|
+
_See code: [src\commands\breakToken.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.42/src\commands\breakToken.ts)_
|
98
98
|
|
99
99
|
## `learnpack clean`
|
100
100
|
|
@@ -109,7 +109,7 @@ DESCRIPTION
|
|
109
109
|
Extra documentation goes here
|
110
110
|
```
|
111
111
|
|
112
|
-
_See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
112
|
+
_See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.42/src\commands\clean.ts)_
|
113
113
|
|
114
114
|
## `learnpack download [PACKAGE]`
|
115
115
|
|
@@ -127,7 +127,7 @@ DESCRIPTION
|
|
127
127
|
Extra documentation goes here
|
128
128
|
```
|
129
129
|
|
130
|
-
_See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
130
|
+
_See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.42/src\commands\download.ts)_
|
131
131
|
|
132
132
|
## `learnpack help [COMMAND]`
|
133
133
|
|
@@ -159,7 +159,7 @@ OPTIONS
|
|
159
159
|
-y, --yes Skip all prompts and initialize an empty project
|
160
160
|
```
|
161
161
|
|
162
|
-
_See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
162
|
+
_See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.42/src\commands\init.ts)_
|
163
163
|
|
164
164
|
## `learnpack login [PACKAGE]`
|
165
165
|
|
@@ -177,7 +177,7 @@ DESCRIPTION
|
|
177
177
|
Extra documentation goes here
|
178
178
|
```
|
179
179
|
|
180
|
-
_See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
180
|
+
_See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.42/src\commands\login.ts)_
|
181
181
|
|
182
182
|
## `learnpack logout [PACKAGE]`
|
183
183
|
|
@@ -195,7 +195,7 @@ DESCRIPTION
|
|
195
195
|
Extra documentation goes here
|
196
196
|
```
|
197
197
|
|
198
|
-
_See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
198
|
+
_See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.42/src\commands\logout.ts)_
|
199
199
|
|
200
200
|
## `learnpack plugins`
|
201
201
|
|
@@ -327,7 +327,7 @@ OPTIONS
|
|
327
327
|
-s, --strict strict mode
|
328
328
|
```
|
329
329
|
|
330
|
-
_See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
330
|
+
_See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.42/src\commands\publish.ts)_
|
331
331
|
|
332
332
|
## `learnpack start`
|
333
333
|
|
@@ -349,7 +349,7 @@ OPTIONS
|
|
349
349
|
-y, --yes Skip all prompts and initialize an empty project
|
350
350
|
```
|
351
351
|
|
352
|
-
_See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
352
|
+
_See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.42/src\commands\start.ts)_
|
353
353
|
|
354
354
|
## `learnpack test [EXERCISESLUG]`
|
355
355
|
|
@@ -366,7 +366,7 @@ OPTIONS
|
|
366
366
|
-y, --yes Skip all prompts and initialize an empty project
|
367
367
|
```
|
368
368
|
|
369
|
-
_See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
369
|
+
_See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.42/src\commands\test.ts)_
|
370
370
|
|
371
371
|
## `learnpack translate`
|
372
372
|
|
@@ -380,7 +380,7 @@ OPTIONS
|
|
380
380
|
-y, --yes Skip all prompts and initialize an empty project
|
381
381
|
```
|
382
382
|
|
383
|
-
_See code: [src\commands\translate.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
383
|
+
_See code: [src\commands\translate.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.42/src\commands\translate.ts)_
|
384
384
|
<!-- commandsstop -->
|
385
385
|
|
386
386
|
> > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
|
package/lib/commands/init.js
CHANGED
@@ -27,15 +27,23 @@ const PARAMS = {
|
|
27
27
|
max_rewrite_attempts: 3,
|
28
28
|
max_title_length: 50,
|
29
29
|
};
|
30
|
-
const
|
30
|
+
const whichTargetAudienceAndEstimatedDuration = async () => {
|
31
31
|
const res = await prompts([
|
32
32
|
{
|
33
33
|
type: "text",
|
34
34
|
name: "targetAudience",
|
35
35
|
message: "What is the target audience for this tutorial?",
|
36
36
|
},
|
37
|
+
{
|
38
|
+
type: "number",
|
39
|
+
name: "estimatedDuration",
|
40
|
+
message: "What is the estimated duration for this tutorial in minutes?",
|
41
|
+
},
|
37
42
|
]);
|
38
|
-
return
|
43
|
+
return {
|
44
|
+
targetAudience: res.targetAudience,
|
45
|
+
estimatedDuration: res.estimatedDuration,
|
46
|
+
};
|
39
47
|
};
|
40
48
|
async function processExercise(rigoToken, steps, packageContext, exercise, exercisesDir) {
|
41
49
|
const { exNumber, exTitle, kind, description } = (0, creatorUtilities_1.getExInfo)(exercise);
|
@@ -196,13 +204,14 @@ const handleAILogic = async (tutorialDir, packageInfo) => {
|
|
196
204
|
process.exit(1);
|
197
205
|
}
|
198
206
|
console_1.default.success("🎉 Let's begin this learning journey!");
|
199
|
-
const targetAudience = await
|
207
|
+
const { targetAudience, estimatedDuration } = await whichTargetAudienceAndEstimatedDuration();
|
200
208
|
const contentIndex = await appendContentIndex();
|
201
209
|
let packageContext = `
|
202
210
|
\n
|
203
211
|
Title: "${packageInfo.title.us}"
|
204
212
|
Description: "${packageInfo.description.us}"
|
205
213
|
Target Audience: "${targetAudience}"
|
214
|
+
Estimated Duration: "${estimatedDuration} minutes"
|
206
215
|
|
207
216
|
${contentIndex ?
|
208
217
|
`Content Index submitted by the user, use this to guide your creation. Keep in mind that your tutorial should contain these topics:
|
@@ -212,6 +221,12 @@ const handleAILogic = async (tutorialDir, packageInfo) => {
|
|
212
221
|
` :
|
213
222
|
""}
|
214
223
|
|
224
|
+
Keep in mind that depending on the type of exercise, the duration will vary.
|
225
|
+
This is the duration for each type of exercise:
|
226
|
+
${Object.entries(durationByKind)
|
227
|
+
.map(([key, value]) => `${key}: ${value} minutes`)
|
228
|
+
.join("\n")}
|
229
|
+
|
215
230
|
`;
|
216
231
|
const { steps, title, description, duration, difficulty } = await initializeInteractiveCreation(rigoToken, packageContext);
|
217
232
|
packageInfo.title.us = title;
|
@@ -60,8 +60,9 @@ const getCodespacesNamespace = () => {
|
|
60
60
|
return codespace_name;
|
61
61
|
};
|
62
62
|
exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
63
|
-
var _a, _b, _c
|
63
|
+
var _a, _b, _c;
|
64
64
|
const confPath = getConfigPath();
|
65
|
+
const suggestions = { agent: null };
|
65
66
|
console_1.default.debug("This is the config path: ", confPath);
|
66
67
|
let configObj = {};
|
67
68
|
if (confPath) {
|
@@ -74,6 +75,9 @@ exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
|
74
75
|
throw new Error(`Invalid ${confPath.base}/config.json syntax: Unable to parse.`);
|
75
76
|
}
|
76
77
|
const jsonConfig = JSON.parse(`${learnJsonContent}`);
|
78
|
+
if ((_a = jsonConfig === null || jsonConfig === void 0 ? void 0 : jsonConfig.editor) === null || _a === void 0 ? void 0 : _a.agent) {
|
79
|
+
suggestions.agent = jsonConfig.editor.agent;
|
80
|
+
}
|
77
81
|
if (!jsonConfig)
|
78
82
|
throw new Error(`Invalid ${confPath.config} syntax: Unable to parse.`);
|
79
83
|
let session;
|
@@ -95,7 +99,7 @@ exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
|
95
99
|
}
|
96
100
|
configObj = deepMerge(defaults_1.default || {}, configObj, {
|
97
101
|
config: {
|
98
|
-
grading: grading || ((
|
102
|
+
grading: grading || ((_b = configObj.config) === null || _b === void 0 ? void 0 : _b.grading),
|
99
103
|
configPath: confPath.config,
|
100
104
|
},
|
101
105
|
});
|
@@ -111,19 +115,11 @@ exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
|
111
115
|
if (!configObj.config.editor) {
|
112
116
|
configObj.config.editor = {};
|
113
117
|
}
|
114
|
-
|
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
|
-
}
|
118
|
+
configObj.config.suggestions = suggestions;
|
123
119
|
if (shell.which("gp") && configObj && configObj.config) {
|
124
120
|
console_1.default.debug("Gitpod detected");
|
125
121
|
configObj.address = getGitpodAddress();
|
126
|
-
configObj.config.publicUrl = `https://${configObj.config.port}-${(
|
122
|
+
configObj.config.publicUrl = `https://${configObj.config.port}-${(_c = configObj.address) === null || _c === void 0 ? void 0 : _c.slice(8)}`;
|
127
123
|
configObj.config.editor.agent = "vscode";
|
128
124
|
}
|
129
125
|
else if (configObj.config && Boolean(codespaces_workspace)) {
|
@@ -159,10 +155,13 @@ exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
|
159
155
|
try {
|
160
156
|
configObj.config.warnings = Object.assign(Object.assign({}, configObj.config.warnings), { agent: buildAgentWarning(configObj.config.editor.agent, configObj.config.suggestions.agent) });
|
161
157
|
}
|
162
|
-
catch (
|
158
|
+
catch (_d) {
|
163
159
|
console_1.default.error("IMPOSSIBLE TO SET WARNING");
|
164
160
|
}
|
165
161
|
}
|
162
|
+
else {
|
163
|
+
configObj.config.warnings.agent = undefined;
|
164
|
+
}
|
166
165
|
if (configObj.config && !configObj.config.publicUrl)
|
167
166
|
configObj.config.publicUrl = `${configObj.address}:${configObj.config.port}`;
|
168
167
|
if (configObj.config && !configObj.config.editor.mode && mode) {
|
@@ -176,7 +175,7 @@ exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
|
176
175
|
console_1.default.debug("Config version not found, downloading default.");
|
177
176
|
const resp = await fetch("https://raw.githubusercontent.com/learnpack/ide/master/package.json");
|
178
177
|
const packageJSON = await resp.json();
|
179
|
-
configObj.config.editor.version = packageJSON.version || "
|
178
|
+
configObj.config.editor.version = packageJSON.version || "5.0.0";
|
180
179
|
}
|
181
180
|
configObj.config.dirPath = "./" + confPath.base;
|
182
181
|
configObj.config.exercisesPath = getExercisesPath(confPath.base) || "./";
|
@@ -370,6 +369,10 @@ exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
|
370
369
|
grupedByDirectory.length > 0 ?
|
371
370
|
grupedByDirectory.map((path, position) => (0, exercise_1.exercise)(path, position, configObj)) :
|
372
371
|
[(0, exercise_1.exercise)(((_b = configObj === null || configObj === void 0 ? void 0 : configObj.config) === null || _b === void 0 ? void 0 : _b.exercisesPath) || "", 0, configObj)];
|
372
|
+
if (configObj.config) {
|
373
|
+
configObj.config.editor.agent =
|
374
|
+
process.env.TERM_PROGRAM === "vscode" ? "vscode" : "os";
|
375
|
+
}
|
373
376
|
this.save();
|
374
377
|
},
|
375
378
|
createExercise: (slug, content, language) => {
|
package/lib/models/config.d.ts
CHANGED
package/oclif.manifest.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":"5.0.
|
1
|
+
{"version":"5.0.42","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":{"strict":{"name":"strict","type":"boolean","char":"s","description":"strict mode","allowNo":false}},"args":[]},"breakToken":{"id":"breakToken","description":"Break the token","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"grading":{"name":"grading","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"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":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"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":"Builds the project by copying necessary files and directories into a zip file","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"strict":{"name":"strict","type":"boolean","char":"s","description":"strict mode","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"start":{"id":"start","description":"Runs a small server with all the exercise instructions","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"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":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[{"name":"exerciseSlug","description":"The name of the exercise to test","required":false,"hidden":false}]},"translate":{"id":"translate","description":"List all the lessons, the user is able of select many of them to translate to the given languages","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[]}}}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@learnpack/learnpack",
|
3
3
|
"description": "Seamlessly build, sell and/or take interactive & auto-graded tutorials, start learning now or build a new tutorial to your audience.",
|
4
|
-
"version": "5.0.
|
4
|
+
"version": "5.0.42",
|
5
5
|
"author": "Alejandro Sanchez @alesanchezr",
|
6
6
|
"contributors": [
|
7
7
|
{
|
package/src/commands/init.ts
CHANGED
@@ -50,15 +50,23 @@ const PARAMS = {
|
|
50
50
|
max_title_length: 50,
|
51
51
|
}
|
52
52
|
|
53
|
-
const
|
53
|
+
const whichTargetAudienceAndEstimatedDuration = async () => {
|
54
54
|
const res = await prompts([
|
55
55
|
{
|
56
56
|
type: "text",
|
57
57
|
name: "targetAudience",
|
58
58
|
message: "What is the target audience for this tutorial?",
|
59
59
|
},
|
60
|
+
{
|
61
|
+
type: "number",
|
62
|
+
name: "estimatedDuration",
|
63
|
+
message: "What is the estimated duration for this tutorial in minutes?",
|
64
|
+
},
|
60
65
|
])
|
61
|
-
return
|
66
|
+
return {
|
67
|
+
targetAudience: res.targetAudience,
|
68
|
+
estimatedDuration: res.estimatedDuration,
|
69
|
+
}
|
62
70
|
}
|
63
71
|
|
64
72
|
async function processExercise(
|
@@ -308,7 +316,8 @@ const handleAILogic = async (tutorialDir: string, packageInfo: PackageInfo) => {
|
|
308
316
|
|
309
317
|
Console.success("🎉 Let's begin this learning journey!")
|
310
318
|
|
311
|
-
const targetAudience
|
319
|
+
const { targetAudience, estimatedDuration } =
|
320
|
+
await whichTargetAudienceAndEstimatedDuration()
|
312
321
|
const contentIndex = await appendContentIndex()
|
313
322
|
|
314
323
|
let packageContext = `
|
@@ -316,6 +325,7 @@ const handleAILogic = async (tutorialDir: string, packageInfo: PackageInfo) => {
|
|
316
325
|
Title: "${packageInfo.title.us}"
|
317
326
|
Description: "${packageInfo.description.us}"
|
318
327
|
Target Audience: "${targetAudience}"
|
328
|
+
Estimated Duration: "${estimatedDuration} minutes"
|
319
329
|
|
320
330
|
${
|
321
331
|
contentIndex ?
|
@@ -327,6 +337,12 @@ const handleAILogic = async (tutorialDir: string, packageInfo: PackageInfo) => {
|
|
327
337
|
""
|
328
338
|
}
|
329
339
|
|
340
|
+
Keep in mind that depending on the type of exercise, the duration will vary.
|
341
|
+
This is the duration for each type of exercise:
|
342
|
+
${Object.entries(durationByKind)
|
343
|
+
.map(([key, value]) => `${key}: ${value} minutes`)
|
344
|
+
.join("\n")}
|
345
|
+
|
330
346
|
`
|
331
347
|
|
332
348
|
const { steps, title, description, duration, difficulty } =
|
@@ -27,7 +27,7 @@ import {
|
|
27
27
|
IConfigManager,
|
28
28
|
} from "../../models/config-manager"
|
29
29
|
import { IFile } from "../../models/file"
|
30
|
-
|
30
|
+
import { TSuggestions } from "../../models/config"
|
31
31
|
/* exercise folder name standard */
|
32
32
|
const execAsync = promisify(exec)
|
33
33
|
|
@@ -98,6 +98,8 @@ export default async ({
|
|
98
98
|
version,
|
99
99
|
}: IConfigManagerAttributes): Promise<IConfigManager> => {
|
100
100
|
const confPath = getConfigPath()
|
101
|
+
|
102
|
+
const suggestions: TSuggestions = { agent: null }
|
101
103
|
Console.debug("This is the config path: ", confPath)
|
102
104
|
|
103
105
|
let configObj: IConfigObj = {}
|
@@ -117,6 +119,10 @@ export default async ({
|
|
117
119
|
|
118
120
|
const jsonConfig = JSON.parse(`${learnJsonContent}`)
|
119
121
|
|
122
|
+
if (jsonConfig?.editor?.agent) {
|
123
|
+
suggestions.agent = jsonConfig.editor.agent
|
124
|
+
}
|
125
|
+
|
120
126
|
if (!jsonConfig)
|
121
127
|
throw new Error(`Invalid ${confPath.config} syntax: Unable to parse.`)
|
122
128
|
|
@@ -166,18 +172,7 @@ throw InternalError("Config object not found")
|
|
166
172
|
configObj.config.editor = {}
|
167
173
|
}
|
168
174
|
|
169
|
-
|
170
|
-
"This is the agent, and this should be null an the beginning: ",
|
171
|
-
configObj.config?.editor?.agent
|
172
|
-
)
|
173
|
-
|
174
|
-
if (configObj.config?.editor?.agent) {
|
175
|
-
if (configObj.config.suggestions) {
|
176
|
-
configObj.config.suggestions.agent = configObj.config.editor.agent
|
177
|
-
} else {
|
178
|
-
configObj.config.suggestions = { agent: configObj.config.editor.agent }
|
179
|
-
}
|
180
|
-
}
|
175
|
+
configObj.config.suggestions = suggestions
|
181
176
|
|
182
177
|
if (shell.which("gp") && configObj && configObj.config) {
|
183
178
|
Console.debug("Gitpod detected")
|
@@ -230,7 +225,7 @@ throw InternalError("Config object not found")
|
|
230
225
|
|
231
226
|
try {
|
232
227
|
configObj.config.warnings = {
|
233
|
-
...configObj.config.warnings,
|
228
|
+
...configObj.config.warnings,
|
234
229
|
agent: buildAgentWarning(
|
235
230
|
configObj.config.editor.agent,
|
236
231
|
configObj.config.suggestions.agent
|
@@ -239,6 +234,8 @@ throw InternalError("Config object not found")
|
|
239
234
|
} catch {
|
240
235
|
Console.error("IMPOSSIBLE TO SET WARNING")
|
241
236
|
}
|
237
|
+
} else {
|
238
|
+
configObj.config.warnings.agent = undefined
|
242
239
|
}
|
243
240
|
|
244
241
|
if (configObj.config && !configObj.config.publicUrl)
|
@@ -259,7 +256,7 @@ configObj.config.editor.version = version
|
|
259
256
|
"https://raw.githubusercontent.com/learnpack/ide/master/package.json"
|
260
257
|
)
|
261
258
|
const packageJSON = await resp.json()
|
262
|
-
configObj.config.editor.version = packageJSON.version || "
|
259
|
+
configObj.config.editor.version = packageJSON.version || "5.0.0"
|
263
260
|
}
|
264
261
|
|
265
262
|
configObj.config.dirPath = "./" + confPath.base
|
@@ -511,6 +508,11 @@ fs.mkdirSync(confPath.base)
|
|
511
508
|
) :
|
512
509
|
[exercise(configObj?.config?.exercisesPath || "", 0, configObj)]
|
513
510
|
|
511
|
+
if (configObj.config) {
|
512
|
+
configObj.config.editor.agent =
|
513
|
+
process.env.TERM_PROGRAM === "vscode" ? "vscode" : "os"
|
514
|
+
}
|
515
|
+
|
514
516
|
this.save()
|
515
517
|
},
|
516
518
|
createExercise: (slug: string, content: string, language: string) => {
|