@learnpack/learnpack 5.0.29 → 5.0.30
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/logout.js +6 -11
- package/lib/commands/start.js +0 -3
- package/lib/managers/config/index.js +102 -77
- package/lib/managers/file.js +1 -1
- package/lib/managers/server/routes.js +30 -0
- package/lib/managers/session.js +3 -0
- package/lib/models/config-manager.d.ts +2 -0
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
- package/src/commands/logout.ts +38 -43
- package/src/commands/start.ts +0 -3
- package/src/managers/config/index.ts +741 -715
- package/src/managers/file.ts +1 -1
- package/src/managers/server/routes.ts +42 -0
- package/src/managers/session.ts +4 -0
- package/src/models/config-manager.ts +25 -23
- package/src/utils/templates/incremental/.github/workflows/learnpack-audit.yml +29 -0
- package/src/utils/templates/isolated/.github/workflows/learnpack-audit.yml +29 -0
package/src/managers/file.ts
CHANGED
@@ -123,7 +123,7 @@ export const download = (url: string, dest: string) => {
|
|
123
123
|
})
|
124
124
|
file.on("error", err => {
|
125
125
|
file.close()
|
126
|
-
if (err.
|
126
|
+
if (err.name === "EEXIST") {
|
127
127
|
Console.debug("File already exists")
|
128
128
|
resolve("File already exists")
|
129
129
|
} else {
|
@@ -381,6 +381,48 @@ throw new Error("File not found: " + filePath)
|
|
381
381
|
})
|
382
382
|
)
|
383
383
|
|
384
|
+
app.delete(
|
385
|
+
"/exercise/:slug/delete",
|
386
|
+
withHandler(async (req: express.Request, res: express.Response) => {
|
387
|
+
const exerciseDeleted = configManager.deleteExercise(req.params.slug)
|
388
|
+
if (exerciseDeleted) {
|
389
|
+
configManager.buildIndex()
|
390
|
+
res.json({ status: "ok" })
|
391
|
+
} else {
|
392
|
+
res.status(500).json({ error: "Failed to delete exercise" })
|
393
|
+
}
|
394
|
+
})
|
395
|
+
)
|
396
|
+
|
397
|
+
app.post(
|
398
|
+
"/exercise/:slug/create",
|
399
|
+
jsonBodyParser,
|
400
|
+
withHandler(async (req: express.Request, res: express.Response) => {
|
401
|
+
const { title, readme, language } = req.body
|
402
|
+
const { slug } = req.params
|
403
|
+
|
404
|
+
if (!title || !readme || !language) {
|
405
|
+
return res.status(400).json({ error: "Missing required fields" })
|
406
|
+
}
|
407
|
+
|
408
|
+
try {
|
409
|
+
const exerciseCreated = await configManager.createExercise(
|
410
|
+
slug,
|
411
|
+
readme,
|
412
|
+
language
|
413
|
+
)
|
414
|
+
if (exerciseCreated) {
|
415
|
+
configManager.buildIndex()
|
416
|
+
res.json({ status: "ok" })
|
417
|
+
} else {
|
418
|
+
res.status(500).json({ error: "Failed to create exercise" })
|
419
|
+
}
|
420
|
+
} catch {
|
421
|
+
res.status(500).json({ error: "Failed to create exercise" })
|
422
|
+
}
|
423
|
+
})
|
424
|
+
)
|
425
|
+
|
384
426
|
const textBodyParser = bodyParser.text()
|
385
427
|
app.put(
|
386
428
|
"/exercise/:slug/file/:fileName",
|
package/src/managers/session.ts
CHANGED
@@ -1,23 +1,25 @@
|
|
1
|
-
import { IConfigObj, TGrading } from "./config"
|
2
|
-
import { IExercise } from "./exercise-obj"
|
3
|
-
|
4
|
-
export interface IConfigManagerAttributes {
|
5
|
-
grading: TGrading
|
6
|
-
disableGrading: boolean
|
7
|
-
version: string
|
8
|
-
mode?: string
|
9
|
-
}
|
10
|
-
|
11
|
-
export interface IConfigManager {
|
12
|
-
validLanguages?: any
|
13
|
-
get: () => IConfigObj
|
14
|
-
clean: () => void
|
15
|
-
getExercise: (slug: string | undefined) => IExercise
|
16
|
-
startExercise: (slug: string) => IExercise
|
17
|
-
reset: (slug: string) => void
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
1
|
+
import { IConfigObj, TGrading } from "./config"
|
2
|
+
import { IExercise } from "./exercise-obj"
|
3
|
+
|
4
|
+
export interface IConfigManagerAttributes {
|
5
|
+
grading: TGrading
|
6
|
+
disableGrading: boolean
|
7
|
+
version: string
|
8
|
+
mode?: string
|
9
|
+
}
|
10
|
+
|
11
|
+
export interface IConfigManager {
|
12
|
+
validLanguages?: any
|
13
|
+
get: () => IConfigObj
|
14
|
+
clean: () => void
|
15
|
+
getExercise: (slug: string | undefined) => IExercise
|
16
|
+
startExercise: (slug: string) => IExercise
|
17
|
+
reset: (slug: string) => void
|
18
|
+
createExercise: (slug: string, content: string, language: string) => boolean
|
19
|
+
deleteExercise: (slug: string) => boolean
|
20
|
+
buildIndex: () => boolean | void
|
21
|
+
watchIndex: (onChange: (...args: Array<any>) => void) => void
|
22
|
+
save: () => void
|
23
|
+
noCurrentExercise: () => void
|
24
|
+
getAllExercises: () => IExercise[]
|
25
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
3
|
+
|
4
|
+
name: Learnpack audit
|
5
|
+
|
6
|
+
on:
|
7
|
+
push:
|
8
|
+
branches: [ main ]
|
9
|
+
pull_request:
|
10
|
+
branches: [ main ]
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
build:
|
14
|
+
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
|
17
|
+
strategy:
|
18
|
+
matrix:
|
19
|
+
node-version: [20.x]
|
20
|
+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
21
|
+
|
22
|
+
steps:
|
23
|
+
- uses: actions/checkout@v2
|
24
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
25
|
+
uses: actions/setup-node@v2
|
26
|
+
with:
|
27
|
+
node-version: ${{ matrix.node-version }}
|
28
|
+
- run: npm install @learnpack/learnpack@latest -g
|
29
|
+
- run: learnpack audit
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
3
|
+
|
4
|
+
name: Learnpack audit
|
5
|
+
|
6
|
+
on:
|
7
|
+
push:
|
8
|
+
branches: [ main ]
|
9
|
+
pull_request:
|
10
|
+
branches: [ main ]
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
build:
|
14
|
+
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
|
17
|
+
strategy:
|
18
|
+
matrix:
|
19
|
+
node-version: [20.x]
|
20
|
+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
21
|
+
|
22
|
+
steps:
|
23
|
+
- uses: actions/checkout@v2
|
24
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
25
|
+
uses: actions/setup-node@v2
|
26
|
+
with:
|
27
|
+
node-version: ${{ matrix.node-version }}
|
28
|
+
- run: npm install @learnpack/learnpack@latest -g
|
29
|
+
- run: learnpack audit
|