adapt-authoring-adaptframework 2.5.1 → 2.5.3
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.
|
@@ -1,32 +1,16 @@
|
|
|
1
1
|
name: Release
|
|
2
|
+
|
|
2
3
|
on:
|
|
3
4
|
push:
|
|
4
5
|
branches:
|
|
5
6
|
- master
|
|
6
7
|
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
issues: write
|
|
11
|
+
pull-requests: write
|
|
12
|
+
id-token: write
|
|
13
|
+
|
|
7
14
|
jobs:
|
|
8
15
|
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
|
|
16
|
-
steps:
|
|
17
|
-
- name: Checkout
|
|
18
|
-
uses: actions/checkout@master
|
|
19
|
-
with:
|
|
20
|
-
fetch-depth: 0
|
|
21
|
-
- name: Setup Node.js
|
|
22
|
-
uses: actions/setup-node@master
|
|
23
|
-
with:
|
|
24
|
-
node-version: 'lts/*'
|
|
25
|
-
- name: Update npm
|
|
26
|
-
run: npm install -g npm@latest
|
|
27
|
-
- name: Install dependencies
|
|
28
|
-
run: npm install
|
|
29
|
-
- name: Release
|
|
30
|
-
env:
|
|
31
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
32
|
-
run: npx semantic-release
|
|
16
|
+
uses: adaptlearning/semantic-release-config/.github/workflows/release.yml@master
|
|
@@ -211,6 +211,7 @@ class AdaptFrameworkBuild {
|
|
|
211
211
|
|
|
212
212
|
await this.preBuildHook.invoke(this)
|
|
213
213
|
|
|
214
|
+
await this.applySchemaDefaults()
|
|
214
215
|
await this.writeContentJson()
|
|
215
216
|
|
|
216
217
|
logDir('courseDir', this.courseDir)
|
|
@@ -425,6 +426,60 @@ class AdaptFrameworkBuild {
|
|
|
425
426
|
}))
|
|
426
427
|
}
|
|
427
428
|
|
|
429
|
+
/**
|
|
430
|
+
* Applies schema defaults to the in-memory course and config data using
|
|
431
|
+
* the jsonschema module. Replicates what grunt's schema-defaults task does.
|
|
432
|
+
*
|
|
433
|
+
* TODO: replace validateWithDefaults workaround with schema.validate(data, { ignoreErrors: true })
|
|
434
|
+
* once migrated to adapt-schemas v3.x (see #184)
|
|
435
|
+
* @return {Promise}
|
|
436
|
+
*/
|
|
437
|
+
async applySchemaDefaults () {
|
|
438
|
+
const [jsonschema, contentplugin] = await App.instance.waitForModule('jsonschema', 'contentplugin')
|
|
439
|
+
|
|
440
|
+
const enabledPluginSchemas = this.enabledPlugins
|
|
441
|
+
.reduce((m, p) => [...m, ...contentplugin.getPluginSchemas(p.name)], [])
|
|
442
|
+
const extensionFilter = s => contentplugin.isPluginSchema(s) ? enabledPluginSchemas.includes(s) : true
|
|
443
|
+
const getSchema = name => jsonschema.getSchema(name, { useCache: false, extensionFilter })
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Applies defaults via validate(), catching and ignoring validation errors.
|
|
447
|
+
* The validated+defaulted data is returned from validate() on success, or
|
|
448
|
+
* extracted from the error on failure (validate clones internally).
|
|
449
|
+
*/
|
|
450
|
+
const validateWithDefaults = (schema, data) => {
|
|
451
|
+
try {
|
|
452
|
+
return schema.validate(data, { useDefaults: true, ignoreRequired: true })
|
|
453
|
+
} catch (e) {
|
|
454
|
+
return e.data.data
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
const [courseSchema, configSchema] = await Promise.all([
|
|
459
|
+
getSchema('course'),
|
|
460
|
+
getSchema('config')
|
|
461
|
+
])
|
|
462
|
+
Object.assign(this.courseData.course.data, validateWithDefaults(courseSchema, this.courseData.course.data))
|
|
463
|
+
Object.assign(this.courseData.config.data, validateWithDefaults(configSchema, this.courseData.config.data))
|
|
464
|
+
|
|
465
|
+
for (const type of ['contentObject', 'article', 'block']) {
|
|
466
|
+
const schemaName = type === 'contentObject' ? 'contentobject' : type
|
|
467
|
+
const schema = await getSchema(schemaName)
|
|
468
|
+
for (const item of this.courseData[type].data) {
|
|
469
|
+
Object.assign(item, validateWithDefaults(schema, item))
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
const componentSchemas = {}
|
|
474
|
+
for (const item of this.courseData.component.data) {
|
|
475
|
+
const schemaName = `${item._component}-component`
|
|
476
|
+
if (!componentSchemas[schemaName]) {
|
|
477
|
+
componentSchemas[schemaName] = await getSchema(schemaName)
|
|
478
|
+
}
|
|
479
|
+
Object.assign(item, validateWithDefaults(componentSchemas[schemaName], item))
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
428
483
|
/**
|
|
429
484
|
* Outputs all course data to the required JSON files
|
|
430
485
|
* @return {Promise}
|
|
@@ -881,7 +881,7 @@ class AdaptFrameworkImport {
|
|
|
881
881
|
// Uninstall newly installed plugins
|
|
882
882
|
if (this.contentplugin) {
|
|
883
883
|
tasks.push(...Object.values(this.newContentPlugins).map(p =>
|
|
884
|
-
this.contentplugin.
|
|
884
|
+
this.contentplugin.delete({ _id: p._id })
|
|
885
885
|
.catch(e => log('warn', `failed to uninstall plugin '${p.name}'`, e))
|
|
886
886
|
))
|
|
887
887
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adapt-authoring-adaptframework",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.3",
|
|
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",
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
"adapt-authoring-content": "^2.0.0",
|
|
15
15
|
"adapt-authoring-contentplugin": "^1.0.3",
|
|
16
16
|
"adapt-authoring-core": "^2.0.0",
|
|
17
|
-
"adapt-authoring-courseassets": "^1.0.3",
|
|
18
17
|
"adapt-authoring-coursetheme": "^1.0.2",
|
|
19
18
|
"adapt-authoring-mongodb": "^3.0.0",
|
|
20
19
|
"adapt-authoring-spoortracking": "^1.0.2",
|
|
21
20
|
"adapt-cli": "^3.3.3",
|
|
21
|
+
"adapt-migrations": "^1.4.0",
|
|
22
22
|
"adapt-octopus": "^0.1.2",
|
|
23
23
|
"bytes": "^3.1.2",
|
|
24
24
|
"fs-extra": "11.3.3",
|
|
@@ -37,35 +37,10 @@
|
|
|
37
37
|
"adapt-authoring-tags": "^1.0.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@semantic-release
|
|
41
|
-
"conventional-changelog-eslint": "^6.0.0",
|
|
42
|
-
"semantic-release": "^25.0.2",
|
|
40
|
+
"@adaptlearning/semantic-release-config": "^1.0.0",
|
|
43
41
|
"standard": "^17.1.0"
|
|
44
42
|
},
|
|
45
43
|
"release": {
|
|
46
|
-
"
|
|
47
|
-
[
|
|
48
|
-
"@semantic-release/commit-analyzer",
|
|
49
|
-
{
|
|
50
|
-
"preset": "eslint"
|
|
51
|
-
}
|
|
52
|
-
],
|
|
53
|
-
[
|
|
54
|
-
"@semantic-release/release-notes-generator",
|
|
55
|
-
{
|
|
56
|
-
"preset": "eslint"
|
|
57
|
-
}
|
|
58
|
-
],
|
|
59
|
-
"@semantic-release/npm",
|
|
60
|
-
"@semantic-release/github",
|
|
61
|
-
[
|
|
62
|
-
"@semantic-release/git",
|
|
63
|
-
{
|
|
64
|
-
"assets": [
|
|
65
|
-
"package.json"
|
|
66
|
-
]
|
|
67
|
-
}
|
|
68
|
-
]
|
|
69
|
-
]
|
|
44
|
+
"extends": "@adaptlearning/semantic-release-config"
|
|
70
45
|
}
|
|
71
46
|
}
|
|
@@ -416,7 +416,7 @@ describe('AdaptFrameworkImport', () => {
|
|
|
416
416
|
const uninstalled = []
|
|
417
417
|
const ctx = makeRollbackCtx({
|
|
418
418
|
contentplugin: {
|
|
419
|
-
|
|
419
|
+
delete: async ({ _id }) => uninstalled.push(_id)
|
|
420
420
|
},
|
|
421
421
|
newContentPlugins: {
|
|
422
422
|
'adapt-contrib-text': { _id: 'p1', name: 'adapt-contrib-text' },
|
|
@@ -515,9 +515,9 @@ describe('AdaptFrameworkImport', () => {
|
|
|
515
515
|
const uninstalled = []
|
|
516
516
|
const ctx = makeRollbackCtx({
|
|
517
517
|
contentplugin: {
|
|
518
|
-
|
|
519
|
-
if (
|
|
520
|
-
uninstalled.push(
|
|
518
|
+
delete: async ({ _id }) => {
|
|
519
|
+
if (_id === 'p1') throw new Error('uninstall failed')
|
|
520
|
+
uninstalled.push(_id)
|
|
521
521
|
}
|
|
522
522
|
},
|
|
523
523
|
newContentPlugins: {
|