@learnpack/learnpack 4.0.14 → 4.0.15
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 +36 -5
- package/lib/managers/session.js +8 -1
- package/lib/models/session.d.ts +1 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/managers/server/routes.ts +43 -6
- package/src/managers/session.ts +11 -1
- package/src/models/session.ts +1 -0
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.15 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.15/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.15/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.15/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.15/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.15/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.15/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.15/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.15/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.15/src\commands\test.ts)_
|
344
344
|
<!-- commandsstop -->
|
345
345
|
|
346
346
|
> > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
|
@@ -77,15 +77,11 @@ async function default_1(app, configObject, configManager) {
|
|
77
77
|
}));
|
78
78
|
app.post("/set-tab-hash", jsonBodyParser, withHandler(async (req, res) => {
|
79
79
|
const hash = req.body.hash;
|
80
|
-
// Ensure token is provided in the request body
|
81
|
-
console_1.default.error("TRYINH YO SET TAB HASH IN CLI");
|
82
|
-
console_1.default.success(hash);
|
83
80
|
if (!hash) {
|
84
81
|
return res.status(400).json({ error: "Token is required" });
|
85
82
|
}
|
86
83
|
try {
|
87
84
|
const hashSaved = await session_1.default.setTabHash(hash);
|
88
|
-
// Check if the token was saved successfully
|
89
85
|
if (hashSaved) {
|
90
86
|
res.json({ status: "ok" });
|
91
87
|
}
|
@@ -94,7 +90,42 @@ async function default_1(app, configObject, configManager) {
|
|
94
90
|
}
|
95
91
|
}
|
96
92
|
catch (_a) {
|
97
|
-
|
93
|
+
res.status(500).json({ error: "Internal server error" });
|
94
|
+
}
|
95
|
+
}));
|
96
|
+
app.post("/set-session-key", jsonBodyParser, withHandler(async (req, res) => {
|
97
|
+
const sessionKey = req.body.sessionKey;
|
98
|
+
if (!sessionKey) {
|
99
|
+
return res.status(400).json({ error: "Token is required" });
|
100
|
+
}
|
101
|
+
try {
|
102
|
+
const sessionSaved = await session_1.default.setSessionKey(sessionKey);
|
103
|
+
if (sessionSaved) {
|
104
|
+
res.json({ status: "ok" });
|
105
|
+
}
|
106
|
+
else {
|
107
|
+
res.status(500).json({ error: "Failed to save the token" });
|
108
|
+
}
|
109
|
+
}
|
110
|
+
catch (_a) {
|
111
|
+
res.status(500).json({ error: "Internal server error" });
|
112
|
+
}
|
113
|
+
}));
|
114
|
+
app.post("/set-session", jsonBodyParser, withHandler(async (req, res) => {
|
115
|
+
const payload = req.body.payload;
|
116
|
+
if (!payload) {
|
117
|
+
return res.status(400).json({ error: "Token is required" });
|
118
|
+
}
|
119
|
+
try {
|
120
|
+
const payloadSaved = await session_1.default.setPayload(payload);
|
121
|
+
if (payloadSaved) {
|
122
|
+
res.json({ status: "ok" });
|
123
|
+
}
|
124
|
+
else {
|
125
|
+
res.status(500).json({ error: "Failed to save the token" });
|
126
|
+
}
|
127
|
+
}
|
128
|
+
catch (_a) {
|
98
129
|
res.status(500).json({ error: "Internal server error" });
|
99
130
|
}
|
100
131
|
}));
|
package/lib/managers/session.js
CHANGED
@@ -37,7 +37,14 @@ const Session = {
|
|
37
37
|
await this.initialize();
|
38
38
|
const payload = await storage.getItem("bc-payload");
|
39
39
|
await storage.setItem("bc-payload", Object.assign(Object.assign({}, payload), { tabHash: hash }));
|
40
|
-
console_1.default.debug("
|
40
|
+
console_1.default.debug("tabHash successfuly set");
|
41
|
+
return true;
|
42
|
+
},
|
43
|
+
setSessionKey: async function (value) {
|
44
|
+
await this.initialize();
|
45
|
+
const payload = await storage.getItem("bc-payload");
|
46
|
+
await storage.setItem("bc-payload", Object.assign(Object.assign({}, payload), { sessionKey: value }));
|
47
|
+
console_1.default.debug("sessionKey successfuly set");
|
41
48
|
return true;
|
42
49
|
},
|
43
50
|
setPayload: async function (value) {
|
package/lib/models/session.d.ts
CHANGED
@@ -19,6 +19,7 @@ export interface ISession {
|
|
19
19
|
initialize: () => Promise<boolean>;
|
20
20
|
setRigoToken: (token: string) => Promise<boolean>;
|
21
21
|
setTabHash: (hash: string) => Promise<boolean>;
|
22
|
+
setSessionKey: (value: string) => Promise<boolean>;
|
22
23
|
setPayload: (value: IPayload) => Promise<boolean>;
|
23
24
|
getPayload: () => Promise<any>;
|
24
25
|
isActive: () => boolean;
|
package/oclif.manifest.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":"4.0.
|
1
|
+
{"version":"4.0.15","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
@@ -110,28 +110,65 @@ export default async function (
|
|
110
110
|
jsonBodyParser,
|
111
111
|
withHandler(async (req: express.Request, res: express.Response) => {
|
112
112
|
const hash = req.body.hash
|
113
|
-
// Ensure token is provided in the request body
|
114
|
-
|
115
|
-
Console.error("TRYINH YO SET TAB HASH IN CLI")
|
116
|
-
Console.success(hash)
|
117
113
|
if (!hash) {
|
118
114
|
return res.status(400).json({ error: "Token is required" })
|
119
115
|
}
|
120
116
|
|
121
117
|
try {
|
122
118
|
const hashSaved = await SessionManager.setTabHash(hash)
|
123
|
-
// Check if the token was saved successfully
|
124
119
|
if (hashSaved) {
|
125
120
|
res.json({ status: "ok" })
|
126
121
|
} else {
|
127
122
|
res.status(500).json({ error: "Failed to save the token" })
|
128
123
|
}
|
129
124
|
} catch {
|
130
|
-
// Handle any unexpected errors during the process
|
131
125
|
res.status(500).json({ error: "Internal server error" })
|
132
126
|
}
|
133
127
|
})
|
134
128
|
)
|
129
|
+
app.post(
|
130
|
+
"/set-session-key",
|
131
|
+
jsonBodyParser,
|
132
|
+
withHandler(async (req: express.Request, res: express.Response) => {
|
133
|
+
const sessionKey = req.body.sessionKey
|
134
|
+
if (!sessionKey) {
|
135
|
+
return res.status(400).json({ error: "Token is required" })
|
136
|
+
}
|
137
|
+
|
138
|
+
try {
|
139
|
+
const sessionSaved = await SessionManager.setSessionKey(sessionKey)
|
140
|
+
if (sessionSaved) {
|
141
|
+
res.json({ status: "ok" })
|
142
|
+
} else {
|
143
|
+
res.status(500).json({ error: "Failed to save the token" })
|
144
|
+
}
|
145
|
+
} catch {
|
146
|
+
res.status(500).json({ error: "Internal server error" })
|
147
|
+
}
|
148
|
+
})
|
149
|
+
)
|
150
|
+
app.post(
|
151
|
+
"/set-session",
|
152
|
+
jsonBodyParser,
|
153
|
+
withHandler(async (req: express.Request, res: express.Response) => {
|
154
|
+
const payload = req.body.payload
|
155
|
+
if (!payload) {
|
156
|
+
return res.status(400).json({ error: "Token is required" })
|
157
|
+
}
|
158
|
+
|
159
|
+
try {
|
160
|
+
const payloadSaved = await SessionManager.setPayload(payload)
|
161
|
+
if (payloadSaved) {
|
162
|
+
res.json({ status: "ok" })
|
163
|
+
} else {
|
164
|
+
res.status(500).json({ error: "Failed to save the token" })
|
165
|
+
}
|
166
|
+
} catch {
|
167
|
+
res.status(500).json({ error: "Internal server error" })
|
168
|
+
}
|
169
|
+
})
|
170
|
+
)
|
171
|
+
|
135
172
|
app.get(
|
136
173
|
"/check/rigo/status",
|
137
174
|
withHandler(async (_: express.Request, res: express.Response) => {
|
package/src/managers/session.ts
CHANGED
@@ -51,7 +51,17 @@ const Session: ISession = {
|
|
51
51
|
...payload,
|
52
52
|
tabHash: hash,
|
53
53
|
})
|
54
|
-
Console.debug("
|
54
|
+
Console.debug("tabHash successfuly set")
|
55
|
+
return true
|
56
|
+
},
|
57
|
+
setSessionKey: async function (value: string) {
|
58
|
+
await this.initialize()
|
59
|
+
const payload = await storage.getItem("bc-payload")
|
60
|
+
await storage.setItem("bc-payload", {
|
61
|
+
...payload,
|
62
|
+
sessionKey: value,
|
63
|
+
})
|
64
|
+
Console.debug("sessionKey successfuly set")
|
55
65
|
return true
|
56
66
|
},
|
57
67
|
setPayload: async function (value: IPayload) {
|
package/src/models/session.ts
CHANGED
@@ -23,6 +23,7 @@ export interface ISession {
|
|
23
23
|
initialize: () => Promise<boolean>
|
24
24
|
setRigoToken: (token: string) => Promise<boolean>
|
25
25
|
setTabHash: (hash: string) => Promise<boolean>
|
26
|
+
setSessionKey: (value: string) => Promise<boolean>
|
26
27
|
setPayload: (value: IPayload) => Promise<boolean>
|
27
28
|
getPayload: () => Promise<any>
|
28
29
|
isActive: () => boolean
|