@learnpack/learnpack 4.0.15 → 4.0.16
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +10 -10
- package/lib/managers/server/routes.js +1 -9
- package/lib/managers/socket.js +3 -0
- package/lib/models/action.d.ts +1 -1
- package/lib/models/socket.d.ts +1 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/managers/server/routes.ts +1 -10
- package/src/managers/socket.ts +4 -0
- package/src/models/action.ts +3 -2
- package/src/models/socket.ts +28 -27
package/README.md
CHANGED
@@ -21,7 +21,7 @@ $ npm install -g @learnpack/learnpack
|
|
21
21
|
$ learnpack COMMAND
|
22
22
|
running command...
|
23
23
|
$ learnpack (-v|--version|version)
|
24
|
-
@learnpack/learnpack/4.0.
|
24
|
+
@learnpack/learnpack/4.0.16 win32-x64 node-v20.16.0
|
25
25
|
$ learnpack --help [COMMAND]
|
26
26
|
USAGE
|
27
27
|
$ learnpack COMMAND
|
@@ -74,7 +74,7 @@ DESCRIPTION
|
|
74
74
|
12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)
|
75
75
|
```
|
76
76
|
|
77
|
-
_See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.
|
77
|
+
_See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.16/src\commands\audit.ts)_
|
78
78
|
|
79
79
|
## `learnpack clean`
|
80
80
|
|
@@ -89,7 +89,7 @@ DESCRIPTION
|
|
89
89
|
Extra documentation goes here
|
90
90
|
```
|
91
91
|
|
92
|
-
_See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.
|
92
|
+
_See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.16/src\commands\clean.ts)_
|
93
93
|
|
94
94
|
## `learnpack download [PACKAGE]`
|
95
95
|
|
@@ -107,7 +107,7 @@ DESCRIPTION
|
|
107
107
|
Extra documentation goes here
|
108
108
|
```
|
109
109
|
|
110
|
-
_See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.
|
110
|
+
_See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.16/src\commands\download.ts)_
|
111
111
|
|
112
112
|
## `learnpack help [COMMAND]`
|
113
113
|
|
@@ -138,7 +138,7 @@ OPTIONS
|
|
138
138
|
-h, --grading show CLI help
|
139
139
|
```
|
140
140
|
|
141
|
-
_See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.
|
141
|
+
_See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.16/src\commands\init.ts)_
|
142
142
|
|
143
143
|
## `learnpack login [PACKAGE]`
|
144
144
|
|
@@ -156,7 +156,7 @@ DESCRIPTION
|
|
156
156
|
Extra documentation goes here
|
157
157
|
```
|
158
158
|
|
159
|
-
_See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.
|
159
|
+
_See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.16/src\commands\login.ts)_
|
160
160
|
|
161
161
|
## `learnpack logout [PACKAGE]`
|
162
162
|
|
@@ -174,7 +174,7 @@ DESCRIPTION
|
|
174
174
|
Extra documentation goes here
|
175
175
|
```
|
176
176
|
|
177
|
-
_See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.
|
177
|
+
_See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.16/src\commands\logout.ts)_
|
178
178
|
|
179
179
|
## `learnpack plugins`
|
180
180
|
|
@@ -305,7 +305,7 @@ OPTIONS
|
|
305
305
|
-h, --help show CLI help
|
306
306
|
```
|
307
307
|
|
308
|
-
_See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.
|
308
|
+
_See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.16/src\commands\publish.ts)_
|
309
309
|
|
310
310
|
## `learnpack start`
|
311
311
|
|
@@ -326,7 +326,7 @@ OPTIONS
|
|
326
326
|
-w, --watch Watch for file changes
|
327
327
|
```
|
328
328
|
|
329
|
-
_See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.
|
329
|
+
_See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.16/src\commands\start.ts)_
|
330
330
|
|
331
331
|
## `learnpack test [EXERCISESLUG]`
|
332
332
|
|
@@ -340,7 +340,7 @@ ARGUMENTS
|
|
340
340
|
EXERCISESLUG The name of the exercise to test
|
341
341
|
```
|
342
342
|
|
343
|
-
_See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.
|
343
|
+
_See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.16/src\commands\test.ts)_
|
344
344
|
<!-- commandsstop -->
|
345
345
|
|
346
346
|
> > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
|
@@ -120,6 +120,7 @@ async function default_1(app, configObject, configManager) {
|
|
120
120
|
const payloadSaved = await session_1.default.setPayload(payload);
|
121
121
|
if (payloadSaved) {
|
122
122
|
res.json({ status: "ok" });
|
123
|
+
socket_1.default.sessionRefreshed(payload);
|
123
124
|
}
|
124
125
|
else {
|
125
126
|
res.status(500).json({ error: "Failed to save the token" });
|
@@ -258,15 +259,6 @@ async function default_1(app, configObject, configManager) {
|
|
258
259
|
res.end();
|
259
260
|
}
|
260
261
|
}));
|
261
|
-
/*
|
262
|
-
app.post(
|
263
|
-
"/exercise/:slug/file/:fileName",
|
264
|
-
withHandler((req: express.Request, res: express.Response) => {
|
265
|
-
get tokens but also, add allowed action for 'generate'
|
266
|
-
use the sessionManager to keep compatibility with the cli login command.
|
267
|
-
})
|
268
|
-
);
|
269
|
-
*/
|
270
262
|
const textBodyParser = bodyParser.text();
|
271
263
|
app.put("/exercise/:slug/file/:fileName", textBodyParser, withHandler((req, res) => {
|
272
264
|
const exercise = configManager.getExercise(req.params.slug);
|
package/lib/managers/socket.js
CHANGED
@@ -103,6 +103,9 @@ const SocketManager = {
|
|
103
103
|
});
|
104
104
|
});
|
105
105
|
},
|
106
|
+
sessionRefreshed: function (data) {
|
107
|
+
this.emit("session-refreshed", "", [data]);
|
108
|
+
},
|
106
109
|
reload: function (files = null, exercises = null) {
|
107
110
|
this.emit("reload", (files === null || files === void 0 ? void 0 : files.join("")) || "", exercises);
|
108
111
|
},
|
package/lib/models/action.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export type TAction = "test" | "log" | "reload" | "ready" | "clean" | "ask" | "file_change" | "dialog";
|
1
|
+
export type TAction = "test" | "log" | "reload" | "ready" | "clean" | "ask" | "file_change" | "dialog" | "session-refreshed";
|
2
2
|
export type ICallback = (...agrs: any[]) => any;
|
package/lib/models/socket.d.ts
CHANGED
@@ -20,6 +20,7 @@ export interface ISocket {
|
|
20
20
|
clean: (_: string, logs: Array<any>) => void;
|
21
21
|
complete: () => void;
|
22
22
|
ask: (questions: Array<string>) => void;
|
23
|
+
sessionRefreshed: (data: any) => void;
|
23
24
|
reload: (files: Array<string> | null, exercises: Array<string>) => void;
|
24
25
|
openWindow: (id: string) => void;
|
25
26
|
log: (status: TStatus, messages?: string | Array<string>, report?: Array<string>, data?: any) => void;
|
package/oclif.manifest.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":"4.0.
|
1
|
+
{"version":"4.0.16","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":"Builds the project by copying necessary files and directories into a zip file","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"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":{"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
@@ -160,6 +160,7 @@ export default async function (
|
|
160
160
|
const payloadSaved = await SessionManager.setPayload(payload)
|
161
161
|
if (payloadSaved) {
|
162
162
|
res.json({ status: "ok" })
|
163
|
+
socket.sessionRefreshed(payload)
|
163
164
|
} else {
|
164
165
|
res.status(500).json({ error: "Failed to save the token" })
|
165
166
|
}
|
@@ -370,16 +371,6 @@ throw new Error("File not found: " + filePath)
|
|
370
371
|
})
|
371
372
|
)
|
372
373
|
|
373
|
-
/*
|
374
|
-
app.post(
|
375
|
-
"/exercise/:slug/file/:fileName",
|
376
|
-
withHandler((req: express.Request, res: express.Response) => {
|
377
|
-
get tokens but also, add allowed action for 'generate'
|
378
|
-
use the sessionManager to keep compatibility with the cli login command.
|
379
|
-
})
|
380
|
-
);
|
381
|
-
*/
|
382
|
-
|
383
374
|
const textBodyParser = bodyParser.text()
|
384
375
|
app.put(
|
385
376
|
"/exercise/:slug/file/:fileName",
|
package/src/managers/socket.ts
CHANGED
package/src/models/action.ts
CHANGED
package/src/models/socket.ts
CHANGED
@@ -9,7 +9,7 @@ export type TPossibleActions =
|
|
9
9
|
| "test"
|
10
10
|
| "reset"
|
11
11
|
| "tutorial"
|
12
|
-
| "generate"
|
12
|
+
| "generate"
|
13
13
|
|
14
14
|
export interface ISocket {
|
15
15
|
socket: Server<
|
@@ -17,27 +17,28 @@ export interface ISocket {
|
|
17
17
|
DefaultEventsMap,
|
18
18
|
DefaultEventsMap,
|
19
19
|
any
|
20
|
-
> | null
|
21
|
-
config: IConfig | null
|
22
|
-
allowedActions: Array<TPossibleActions
|
23
|
-
actionCallBacks: { [key: string]: ICallback }
|
24
|
-
possibleActions: Array<TPossibleActions
|
25
|
-
isTestingEnvironment: boolean
|
26
|
-
addAllowed: (actions: any) => void
|
27
|
-
removeAllowed: (actions: any) => void
|
28
|
-
start: (config: IConfig, server: any, isTestingEnvironment: boolean) => void
|
29
|
-
on: (action: any, callBack: any) => void
|
30
|
-
clean: (_: string, logs: Array<any>) => void
|
31
|
-
complete: () => void
|
32
|
-
ask: (questions: Array<string>) => void
|
33
|
-
|
34
|
-
|
20
|
+
> | null
|
21
|
+
config: IConfig | null
|
22
|
+
allowedActions: Array<TPossibleActions>
|
23
|
+
actionCallBacks: { [key: string]: ICallback }
|
24
|
+
possibleActions: Array<TPossibleActions>
|
25
|
+
isTestingEnvironment: boolean
|
26
|
+
addAllowed: (actions: any) => void
|
27
|
+
removeAllowed: (actions: any) => void
|
28
|
+
start: (config: IConfig, server: any, isTestingEnvironment: boolean) => void
|
29
|
+
on: (action: any, callBack: any) => void
|
30
|
+
clean: (_: string, logs: Array<any>) => void
|
31
|
+
complete: () => void
|
32
|
+
ask: (questions: Array<string>) => void
|
33
|
+
sessionRefreshed: (data: any) => void
|
34
|
+
reload: (files: Array<string> | null, exercises: Array<string>) => void
|
35
|
+
openWindow: (id: string) => void
|
35
36
|
log: (
|
36
37
|
status: TStatus,
|
37
38
|
messages?: string | Array<string>,
|
38
39
|
report?: Array<string>,
|
39
40
|
data?: any
|
40
|
-
) => void
|
41
|
+
) => void
|
41
42
|
emit: (
|
42
43
|
action: TAction,
|
43
44
|
status: TStatus | string,
|
@@ -45,16 +46,16 @@ export interface ISocket {
|
|
45
46
|
inputs?: Array<string>,
|
46
47
|
report?: Array<string>,
|
47
48
|
data?: any
|
48
|
-
) => void
|
49
|
-
ready: (message: string) => void
|
50
|
-
error: (type: any, stdout: string) => void
|
51
|
-
fatal: (msg: string) => void
|
52
|
-
dialog: (message: string) => void
|
53
|
-
success: (type: any, stdout: string) => void
|
54
|
-
onTestingFinished: (obj: any) => void
|
49
|
+
) => void
|
50
|
+
ready: (message: string) => void
|
51
|
+
error: (type: any, stdout: string) => void
|
52
|
+
fatal: (msg: string) => void
|
53
|
+
dialog: (message: string) => void
|
54
|
+
success: (type: any, stdout: string) => void
|
55
|
+
onTestingFinished: (obj: any) => void
|
55
56
|
}
|
56
57
|
|
57
58
|
export type TOpenWindowData = {
|
58
|
-
url: string
|
59
|
-
exerciseSlug: string
|
60
|
-
}
|
59
|
+
url: string
|
60
|
+
exerciseSlug: string
|
61
|
+
}
|