adapt-authoring-adaptframework 1.2.0 → 1.3.0
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.
|
@@ -3,10 +3,16 @@ on:
|
|
|
3
3
|
push:
|
|
4
4
|
branches:
|
|
5
5
|
- master
|
|
6
|
+
|
|
6
7
|
jobs:
|
|
7
8
|
release:
|
|
8
9
|
name: Release
|
|
9
10
|
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
contents: write # to be able to publish a GitHub release
|
|
13
|
+
issues: write # to be able to comment on released issues
|
|
14
|
+
pull-requests: write # to be able to comment on released pull requests
|
|
15
|
+
id-token: write # to enable use of OIDC for trusted publishing and npm provenance
|
|
10
16
|
steps:
|
|
11
17
|
- name: Checkout
|
|
12
18
|
uses: actions/checkout@v3
|
|
@@ -16,10 +22,11 @@ jobs:
|
|
|
16
22
|
uses: actions/setup-node@v3
|
|
17
23
|
with:
|
|
18
24
|
node-version: 'lts/*'
|
|
25
|
+
- name: Update npm
|
|
26
|
+
run: npm install -g npm@latest
|
|
19
27
|
- name: Install dependencies
|
|
20
28
|
run: npm ci
|
|
21
29
|
- name: Release
|
|
22
30
|
env:
|
|
23
31
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
24
|
-
NPM_TOKEN: ${{ secrets.AAT_NPM_TOKEN }}
|
|
25
32
|
run: npx semantic-release
|
|
@@ -71,10 +71,10 @@ class AdaptFrameworkBuild {
|
|
|
71
71
|
*/
|
|
72
72
|
this.isExport = action === 'export'
|
|
73
73
|
/**
|
|
74
|
-
* Whether the final output directory should be compressed
|
|
74
|
+
* Whether the final output directory should be compressed
|
|
75
75
|
* @type {Boolean}
|
|
76
76
|
*/
|
|
77
|
-
this.compress = compress
|
|
77
|
+
this.compress = compress ?? !this.isPreview
|
|
78
78
|
/**
|
|
79
79
|
* The _id of the course being build
|
|
80
80
|
* @type {String}
|
|
@@ -221,8 +221,11 @@ class AdaptFrameworkBuild {
|
|
|
221
221
|
.setData(e)
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
if (this.compress) {
|
|
225
|
+
this.location = await this.prepareZip()
|
|
226
|
+
} else {
|
|
227
|
+
this.location = this.isPreview ? path.join(this.dir, 'build') : this.dir
|
|
228
|
+
}
|
|
226
229
|
await this.postBuildHook.invoke(this)
|
|
227
230
|
await framework.postBuildHook.invoke(this)
|
|
228
231
|
|
|
@@ -235,11 +238,9 @@ class AdaptFrameworkBuild {
|
|
|
235
238
|
*/
|
|
236
239
|
async loadCourseData () {
|
|
237
240
|
const content = await App.instance.waitForModule('content')
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
const langDir = path.join(this.courseDir, 'en')
|
|
241
|
+
const course = await content.findOne({ _id: this.courseId, _type: 'course' })
|
|
242
|
+
const config = await content.findOne({ _courseId: this.courseId, _type: 'config' })
|
|
243
|
+
const langDir = path.join(this.courseDir, course._language ?? config._defaultLanguage ?? 'en')
|
|
243
244
|
this.courseData = {
|
|
244
245
|
course: { dir: langDir, fileName: 'course.json', data: undefined },
|
|
245
246
|
config: { dir: this.courseDir, fileName: 'config.json', data: undefined },
|
|
@@ -460,37 +461,21 @@ class AdaptFrameworkBuild {
|
|
|
460
461
|
await this.ensureDir(dir)
|
|
461
462
|
const filepath = path.join(dir, fileName)
|
|
462
463
|
const returnData = await FWUtils.writeJson(filepath, data)
|
|
463
|
-
FWUtils.log('
|
|
464
|
+
FWUtils.log('verbose', 'WRITE', filepath)
|
|
464
465
|
return returnData
|
|
465
466
|
}))
|
|
466
467
|
}
|
|
467
|
-
|
|
468
|
-
/**
|
|
469
|
-
* Makes sure the output folder is structured to allow the files to be served statically for previewing
|
|
470
|
-
* @return {Promise}
|
|
471
|
-
*/
|
|
472
|
-
async createPreview () {
|
|
473
|
-
const tempName = `${this.dir}_temp`
|
|
474
|
-
await fs.rename(path.join(this.dir, 'build'), tempName)
|
|
475
|
-
await fs.rm(this.dir, { recursive: true })
|
|
476
|
-
await fs.rename(tempName, this.dir)
|
|
477
|
-
this.location = this.dir
|
|
478
|
-
}
|
|
479
|
-
|
|
468
|
+
|
|
480
469
|
/**
|
|
481
470
|
* Creates a zip file containing all files relevant to the type of build being performed
|
|
482
471
|
* @return {Promise}
|
|
483
472
|
*/
|
|
484
|
-
async
|
|
473
|
+
async prepareZip () {
|
|
485
474
|
const zipPath = path.join(this.dir, this.isPublish ? 'build' : '')
|
|
486
|
-
if (this.compress === false) {
|
|
487
|
-
this.location = zipPath
|
|
488
|
-
return
|
|
489
|
-
}
|
|
490
475
|
const outputPath = `${this.dir}.zip`
|
|
491
476
|
await zipper.zip(zipPath, outputPath, { removeSource: true })
|
|
492
477
|
await fs.rm(this.dir, { recursive: true })
|
|
493
|
-
|
|
478
|
+
return outputPath
|
|
494
479
|
}
|
|
495
480
|
|
|
496
481
|
/**
|
|
@@ -2,7 +2,7 @@ import { AbstractModule, Hook } from 'adapt-authoring-core'
|
|
|
2
2
|
import AdaptFrameworkBuild from './AdaptFrameworkBuild.js'
|
|
3
3
|
import AdaptFrameworkImport from './AdaptFrameworkImport.js'
|
|
4
4
|
import ApiDefs from './apidefs.js'
|
|
5
|
-
import fs from 'fs
|
|
5
|
+
import fs from 'fs/promises'
|
|
6
6
|
import FWUtils from './AdaptFrameworkUtils.js'
|
|
7
7
|
import path from 'path'
|
|
8
8
|
import semver from 'semver'
|
|
@@ -65,23 +65,11 @@ class AdaptFrameworkUtils {
|
|
|
65
65
|
static async readJson (filepath) {
|
|
66
66
|
return JSON.parse(await fs.readFile(filepath))
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
|
|
69
69
|
static writeJson (filepath, data) {
|
|
70
70
|
return fs.writeFile(filepath, (JSON.stringify(data, null, 2)))
|
|
71
71
|
}
|
|
72
|
-
|
|
73
|
-
static async exists (filepath) {
|
|
74
|
-
try {
|
|
75
|
-
await fs.stat(filepath)
|
|
76
|
-
return true
|
|
77
|
-
} catch (e) {
|
|
78
|
-
if (e.code === 'ENOENT') {
|
|
79
|
-
return false
|
|
80
|
-
}
|
|
81
|
-
throw e
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
72
|
+
|
|
85
73
|
/**
|
|
86
74
|
* Infers the framework action to be executed from a given request URL
|
|
87
75
|
* @param {external:ExpressRequest} req
|
|
@@ -229,24 +217,17 @@ class AdaptFrameworkUtils {
|
|
|
229
217
|
}
|
|
230
218
|
if (action === 'publish' || action === 'export') {
|
|
231
219
|
res.set('content-disposition', `attachment; filename="${await AdaptFrameworkUtils.slugifyTitle(buildData)}.zip"`)
|
|
232
|
-
|
|
233
|
-
return res.sendFile(path.resolve(buildData.location))
|
|
234
|
-
} catch (e) {
|
|
235
|
-
return next(e)
|
|
236
|
-
}
|
|
220
|
+
return res.sendFile(path.resolve(buildData.location), next)
|
|
237
221
|
}
|
|
238
222
|
if (action === 'preview') {
|
|
239
223
|
if (!req.auth.user) {
|
|
240
224
|
return res.status(App.instance.errors.MISSING_AUTH_HEADER.statusCode).end()
|
|
241
225
|
}
|
|
242
226
|
const filePath = path.resolve(buildData.location, req.path.slice(req.path.indexOf(id) + id.length + 1) || 'index.html')
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
} catch (e) {
|
|
248
|
-
if (e.code === 'ENOENT') return next(e)
|
|
249
|
-
}
|
|
227
|
+
await res.sendFile(filePath, e => {
|
|
228
|
+
if (e.code === 'ENOENT') e = App.instance.errors.NOT_FOUND.setData({ type: 'file', id: filePath })
|
|
229
|
+
next(e)
|
|
230
|
+
})
|
|
250
231
|
}
|
|
251
232
|
}
|
|
252
233
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adapt-authoring-adaptframework",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Adapt framework integration for the Adapt authoring tool",
|
|
5
5
|
"homepage": "https://github.com/adapt-security/adapt-authoring-adaptframework",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
"zipper": "github:adapt-security/zipper#v1.0.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"
|
|
29
|
-
"@semantic-release/commit-analyzer": "^9.0.2",
|
|
28
|
+
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
30
29
|
"@semantic-release/git": "^10.0.1",
|
|
31
|
-
"@semantic-release/github": "^
|
|
32
|
-
"@semantic-release/npm": "^
|
|
33
|
-
"@semantic-release/release-notes-generator": "^
|
|
34
|
-
"conventional-changelog-eslint": "^
|
|
35
|
-
"semantic-release": "^
|
|
36
|
-
"semantic-release-replace-plugin": "^1.2.7"
|
|
30
|
+
"@semantic-release/github": "^12.0.2",
|
|
31
|
+
"@semantic-release/npm": "^13.1.2",
|
|
32
|
+
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
33
|
+
"conventional-changelog-eslint": "^6.0.0",
|
|
34
|
+
"semantic-release": "^25.0.2",
|
|
35
|
+
"semantic-release-replace-plugin": "^1.2.7",
|
|
36
|
+
"standard": "^17.1.0"
|
|
37
37
|
},
|
|
38
38
|
"release": {
|
|
39
39
|
"plugins": [
|