@learnpack/learnpack 2.1.35 → 2.1.37
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 +0 -1
- package/lib/managers/config/exercise.js +8 -5
- package/lib/managers/config/index.js +2 -0
- package/lib/managers/telemetry.d.ts +1 -1
- package/lib/managers/telemetry.js +13 -4
- package/lib/utils/audit.js +3 -2
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/start.ts +0 -1
- package/src/managers/config/exercise.ts +14 -12
- package/src/managers/config/index.ts +3 -0
- package/src/managers/telemetry.ts +17 -4
- package/src/utils/audit.ts +2 -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/2.1.
|
24
|
+
@learnpack/learnpack/2.1.37 darwin-arm64 node-v16.20.1
|
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.37/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.37/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.37/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.37/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.37/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.37/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.37/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.37/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.37/src/commands/test.ts)_
|
348
348
|
<!-- commandsstop -->
|
349
349
|
|
350
350
|
> > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
|
package/lib/commands/start.js
CHANGED
@@ -46,7 +46,6 @@ class StartCommand extends SessionCommand_1.default {
|
|
46
46
|
const agent = ((_d = configObject.config) === null || _d === void 0 ? void 0 : _d.editor.agent) || "";
|
47
47
|
const path = ((_e = configObject.config) === null || _e === void 0 ? void 0 : _e.dirPath) || "";
|
48
48
|
const tutorialSlug = ((_f = configObject.config) === null || _f === void 0 ? void 0 : _f.slug) || "";
|
49
|
-
console_1.default.info("Starting Telemetry with slug...", tutorialSlug);
|
50
49
|
const steps = configObject.exercises.map((e, index) => ({
|
51
50
|
slug: e.slug,
|
52
51
|
position: e.position || index,
|
@@ -82,11 +82,14 @@ exports.exercise = (path, position, configObject) => {
|
|
82
82
|
fs.mkdirSync(`${config === null || config === void 0 ? void 0 : config.dirPath}/resets`);
|
83
83
|
if (!fs.existsSync(`${config === null || config === void 0 ? void 0 : config.dirPath}/resets/` + this.slug)) {
|
84
84
|
fs.mkdirSync(`${config === null || config === void 0 ? void 0 : config.dirPath}/resets/` + this.slug);
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
85
|
+
}
|
86
|
+
for (const _file of this.files) {
|
87
|
+
const stats = fs.statSync(_file.path);
|
88
|
+
if (stats.isDirectory() || _file.hidden)
|
89
|
+
continue;
|
90
|
+
const fileContent = fs.readFileSync(_file.path);
|
91
|
+
if (!fs.existsSync(`${config === null || config === void 0 ? void 0 : config.dirPath}/resets/${this.slug}/${_file.name}`)) {
|
92
|
+
fs.writeFileSync(`${config === null || config === void 0 ? void 0 : config.dirPath}/resets/${this.slug}/${_file.name}`, fileContent);
|
90
93
|
}
|
91
94
|
}
|
92
95
|
return content;
|
@@ -197,6 +197,8 @@ exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
|
197
197
|
fs.unlinkSync(configObj.config.dirPath + "/app.tar.gz");
|
198
198
|
if (fs.existsSync(configObj.config.dirPath + "/config.json"))
|
199
199
|
fs.unlinkSync(configObj.config.dirPath + "/config.json");
|
200
|
+
if (fs.existsSync(configObj.config.dirPath + "/telemetry.json"))
|
201
|
+
fs.unlinkSync(configObj.config.dirPath + "/telemetry.json");
|
200
202
|
if (fs.existsSync(configObj.config.dirPath + "/vscode_queue.json"))
|
201
203
|
fs.unlinkSync(configObj.config.dirPath + "/vscode_queue.json");
|
202
204
|
}
|
@@ -48,11 +48,18 @@ const TelemetryManager = {
|
|
48
48
|
});
|
49
49
|
}
|
50
50
|
},
|
51
|
+
// verifyStudent: function () {
|
52
|
+
// if (!this.current) {
|
53
|
+
// return;
|
54
|
+
// }
|
55
|
+
// if (!this.current.user_id) {
|
56
|
+
// }
|
57
|
+
// },
|
51
58
|
setStudent: function (student) {
|
52
59
|
if (!this.current) {
|
53
60
|
return;
|
54
61
|
}
|
55
|
-
this.current.
|
62
|
+
this.current.user_id = student.user_id;
|
56
63
|
this.save();
|
57
64
|
this.submit();
|
58
65
|
},
|
@@ -88,6 +95,10 @@ const TelemetryManager = {
|
|
88
95
|
if (data.stderr) {
|
89
96
|
data.stderr = stringToBase64(data.stderr);
|
90
97
|
}
|
98
|
+
if (Object.prototype.hasOwnProperty.call(data, "exitCode")) {
|
99
|
+
data.exit_code = data.exitCode;
|
100
|
+
data.exitCode = undefined;
|
101
|
+
}
|
91
102
|
switch (event) {
|
92
103
|
case "compile":
|
93
104
|
if (!step.compilations) {
|
@@ -172,19 +183,17 @@ const TelemetryManager = {
|
|
172
183
|
});
|
173
184
|
},
|
174
185
|
streamEvent: async function (stepPosition, event, data) {
|
175
|
-
var _a;
|
176
186
|
if (!this.current)
|
177
187
|
return;
|
178
188
|
const url = this.urls.streaming;
|
179
189
|
if (!url) {
|
180
190
|
return;
|
181
|
-
// throw new Error("Streaming URL not specified");
|
182
191
|
}
|
183
192
|
const stepSlug = this.current.steps[stepPosition].slug;
|
184
193
|
const body = {
|
185
194
|
slug: stepSlug,
|
186
195
|
telemetry_id: this.current.telemetry_id,
|
187
|
-
user_id:
|
196
|
+
user_id: this.current.user_id,
|
188
197
|
step_position: stepPosition,
|
189
198
|
event,
|
190
199
|
data,
|
package/lib/utils/audit.js
CHANGED
@@ -39,7 +39,7 @@ const checkForEmptySpaces = (str) => {
|
|
39
39
|
return isEmpty;
|
40
40
|
};
|
41
41
|
const checkLearnpackClean = (configObj, errors) => {
|
42
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
42
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
43
43
|
if ((((_a = configObj.config) === null || _a === void 0 ? void 0 : _a.outputPath) &&
|
44
44
|
fs.existsSync((_b = configObj.config) === null || _b === void 0 ? void 0 : _b.outputPath)) ||
|
45
45
|
fs.existsSync(`${(_c = configObj.config) === null || _c === void 0 ? void 0 : _c.dirPath}/_app`) ||
|
@@ -47,7 +47,8 @@ const checkLearnpackClean = (configObj, errors) => {
|
|
47
47
|
fs.existsSync(`${(_e = configObj.config) === null || _e === void 0 ? void 0 : _e.dirPath}/resets`) ||
|
48
48
|
fs.existsSync(`${(_f = configObj.config) === null || _f === void 0 ? void 0 : _f.dirPath}/app.tar.gz`) ||
|
49
49
|
fs.existsSync(`${(_g = configObj.config) === null || _g === void 0 ? void 0 : _g.dirPath}/config.json`) ||
|
50
|
-
fs.existsSync(`${(_h = configObj.config) === null || _h === void 0 ? void 0 : _h.dirPath}/vscode_queue.json`)
|
50
|
+
fs.existsSync(`${(_h = configObj.config) === null || _h === void 0 ? void 0 : _h.dirPath}/vscode_queue.json`) ||
|
51
|
+
fs.existsSync(`${(_j = configObj.config) === null || _j === void 0 ? void 0 : _j.dirPath}/telemetry.json`)) {
|
51
52
|
errors.push({
|
52
53
|
exercise: undefined,
|
53
54
|
msg: "You have to run learnpack clean command",
|
package/oclif.manifest.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":"2.1.
|
1
|
+
{"version":"2.1.37","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
@@ -121,7 +121,6 @@ export default class StartCommand extends SessionCommand {
|
|
121
121
|
const path = configObject.config?.dirPath || ""
|
122
122
|
const tutorialSlug = configObject.config?.slug || ""
|
123
123
|
|
124
|
-
Console.info("Starting Telemetry with slug...", tutorialSlug)
|
125
124
|
const steps = configObject.exercises.map(
|
126
125
|
(e: IExercise, index): TStep => ({
|
127
126
|
slug: e.slug,
|
@@ -121,18 +121,20 @@ lang = null
|
|
121
121
|
fs.mkdirSync(`${config?.dirPath}/resets`)
|
122
122
|
if (!fs.existsSync(`${config?.dirPath}/resets/` + this.slug)) {
|
123
123
|
fs.mkdirSync(`${config?.dirPath}/resets/` + this.slug)
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
124
|
+
}
|
125
|
+
|
126
|
+
for (const _file of this.files) {
|
127
|
+
const stats = fs.statSync(_file.path)
|
128
|
+
if (stats.isDirectory() || _file.hidden)
|
129
|
+
continue
|
130
|
+
const fileContent = fs.readFileSync(_file.path)
|
131
|
+
if (
|
132
|
+
!fs.existsSync(`${config?.dirPath}/resets/${this.slug}/${_file.name}`)
|
133
|
+
) {
|
134
|
+
fs.writeFileSync(
|
135
|
+
`${config?.dirPath}/resets/${this.slug}/${_file.name}`,
|
136
|
+
fileContent
|
137
|
+
)
|
136
138
|
}
|
137
139
|
}
|
138
140
|
|
@@ -278,6 +278,9 @@ return true
|
|
278
278
|
if (fs.existsSync(configObj.config.dirPath + "/config.json"))
|
279
279
|
fs.unlinkSync(configObj.config.dirPath + "/config.json")
|
280
280
|
|
281
|
+
if (fs.existsSync(configObj.config.dirPath + "/telemetry.json"))
|
282
|
+
fs.unlinkSync(configObj.config.dirPath + "/telemetry.json")
|
283
|
+
|
281
284
|
if (fs.existsSync(configObj.config.dirPath + "/vscode_queue.json"))
|
282
285
|
fs.unlinkSync(configObj.config.dirPath + "/vscode_queue.json")
|
283
286
|
}
|
@@ -62,7 +62,7 @@ type TStudent = {
|
|
62
62
|
|
63
63
|
export interface ITelemetryJSONSchema {
|
64
64
|
telemetry_id?: string;
|
65
|
-
|
65
|
+
user_id?: number | string;
|
66
66
|
slug: string;
|
67
67
|
agent?: string;
|
68
68
|
tutorial_started_at?: number;
|
@@ -147,13 +147,22 @@ const TelemetryManager: ITelemetryManager = {
|
|
147
147
|
})
|
148
148
|
}
|
149
149
|
},
|
150
|
+
// verifyStudent: function () {
|
151
|
+
// if (!this.current) {
|
152
|
+
// return;
|
153
|
+
// }
|
154
|
+
|
155
|
+
// if (!this.current.user_id) {
|
156
|
+
|
157
|
+
// }
|
158
|
+
// },
|
150
159
|
|
151
160
|
setStudent: function (student) {
|
152
161
|
if (!this.current) {
|
153
162
|
return
|
154
163
|
}
|
155
164
|
|
156
|
-
this.current.
|
165
|
+
this.current.user_id = student.user_id
|
157
166
|
this.save()
|
158
167
|
this.submit()
|
159
168
|
},
|
@@ -199,6 +208,11 @@ const TelemetryManager: ITelemetryManager = {
|
|
199
208
|
data.stderr = stringToBase64(data.stderr)
|
200
209
|
}
|
201
210
|
|
211
|
+
if (Object.prototype.hasOwnProperty.call(data, "exitCode")) {
|
212
|
+
data.exit_code = data.exitCode
|
213
|
+
data.exitCode = undefined
|
214
|
+
}
|
215
|
+
|
202
216
|
switch (event) {
|
203
217
|
case "compile":
|
204
218
|
if (!step.compilations) {
|
@@ -308,7 +322,6 @@ return
|
|
308
322
|
const url = this.urls.streaming
|
309
323
|
if (!url) {
|
310
324
|
return
|
311
|
-
// throw new Error("Streaming URL not specified");
|
312
325
|
}
|
313
326
|
|
314
327
|
const stepSlug = this.current.steps[stepPosition].slug
|
@@ -316,7 +329,7 @@ return
|
|
316
329
|
const body = {
|
317
330
|
slug: stepSlug,
|
318
331
|
telemetry_id: this.current.telemetry_id,
|
319
|
-
user_id: this.current.
|
332
|
+
user_id: this.current.user_id,
|
320
333
|
step_position: stepPosition,
|
321
334
|
event,
|
322
335
|
data,
|
package/src/utils/audit.ts
CHANGED
@@ -62,7 +62,8 @@ const checkLearnpackClean = (configObj: IConfigObj, errors: IAuditErrors[]) => {
|
|
62
62
|
fs.existsSync(`${configObj.config?.dirPath}/resets`) ||
|
63
63
|
fs.existsSync(`${configObj.config?.dirPath}/app.tar.gz`) ||
|
64
64
|
fs.existsSync(`${configObj.config?.dirPath}/config.json`) ||
|
65
|
-
fs.existsSync(`${configObj.config?.dirPath}/vscode_queue.json`)
|
65
|
+
fs.existsSync(`${configObj.config?.dirPath}/vscode_queue.json`) ||
|
66
|
+
fs.existsSync(`${configObj.config?.dirPath}/telemetry.json`)
|
66
67
|
) {
|
67
68
|
errors.push({
|
68
69
|
exercise: undefined,
|