adapt-authoring-core 2.2.0 → 2.2.2
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/docs/contributing-code.md +18 -18
- package/docs/folder-structure.md +1 -1
- package/docs/hooks.md +3 -3
- package/docs/plugins/licensing.js +20 -11
- package/docs/writing-a-module.md +8 -10
- package/docs/writing-tests.md +1 -1
- package/package.json +1 -1
|
@@ -88,51 +88,51 @@ We use [semantic-release](https://semantic-release.gitbook.io/) to automate rele
|
|
|
88
88
|
| Prefix | Release type | Use for |
|
|
89
89
|
|--------|--------------|---------|
|
|
90
90
|
| `Fix:` | Patch (0.0.x) | Bug fixes |
|
|
91
|
-
| `Update:` | Minor (0.x.0) |
|
|
91
|
+
| `Update:` | Minor (0.x.0) | Backwards-compatible enhancements to existing features |
|
|
92
|
+
| `New:` | Minor (0.x.0) | New features |
|
|
92
93
|
| `Breaking:` | Major (x.0.0) | Breaking changes |
|
|
93
94
|
| `Docs:` | No release | Documentation only |
|
|
94
|
-
| `
|
|
95
|
+
| `Build:` | No release | Build process changes |
|
|
96
|
+
| `Upgrade:` | Varies | Dependency upgrades |
|
|
97
|
+
| `Chore:` | No release | Maintenance, refactoring, tests |
|
|
95
98
|
|
|
96
99
|
### Format
|
|
97
100
|
|
|
98
101
|
```
|
|
99
|
-
Prefix: Short description
|
|
102
|
+
Prefix: Short description (fixes #1234)
|
|
103
|
+
```
|
|
100
104
|
|
|
101
|
-
|
|
105
|
+
Use `(fixes #1234)` when the commit fully resolves an issue, or `(refs #1234)` for partial progress. Keep the first line under 72 characters.
|
|
102
106
|
|
|
103
|
-
|
|
104
|
-
```
|
|
107
|
+
Add a longer explanation on subsequent lines if needed:
|
|
105
108
|
|
|
106
|
-
|
|
109
|
+
```
|
|
110
|
+
Prefix: Short description (fixes #1234)
|
|
107
111
|
|
|
112
|
+
Longer explanation if needed. Wrap at 72 characters.
|
|
108
113
|
```
|
|
109
|
-
Fix: Prevent crash when uploading empty file
|
|
110
114
|
|
|
111
|
-
|
|
112
|
-
returning a 400 error for empty files.
|
|
115
|
+
### Examples
|
|
113
116
|
|
|
114
|
-
Closes #1234
|
|
115
117
|
```
|
|
116
|
-
|
|
118
|
+
Fix: Prevent crash when uploading empty file (fixes #1234)
|
|
117
119
|
```
|
|
118
|
-
Update: Add bulk delete endpoint for assets
|
|
119
120
|
|
|
120
|
-
|
|
121
|
+
```
|
|
122
|
+
Update: Add bulk delete endpoint for assets (fixes #5678)
|
|
121
123
|
```
|
|
122
124
|
|
|
123
125
|
```
|
|
124
|
-
Breaking: Remove deprecated /api/v1 endpoints
|
|
126
|
+
Breaking: Remove deprecated /api/v1 endpoints (fixes #9012)
|
|
125
127
|
|
|
126
128
|
The v1 API has been removed. All clients should migrate to /api.
|
|
127
|
-
|
|
128
|
-
Closes #9012
|
|
129
129
|
```
|
|
130
130
|
|
|
131
131
|
### Tips
|
|
132
132
|
|
|
133
133
|
- Use the imperative mood ("Add feature" not "Added feature")
|
|
134
134
|
- Keep the first line under 72 characters
|
|
135
|
-
- Reference the issue
|
|
135
|
+
- Reference the issue in the first line with `(fixes #N)` or `(refs #N)`
|
|
136
136
|
- For breaking changes, explain what users need to do to migrate
|
|
137
137
|
|
|
138
138
|
## Submitting a pull request
|
package/docs/folder-structure.md
CHANGED
|
@@ -80,7 +80,7 @@ Command-line tools are found in the `bin` folder. Modules can also provide their
|
|
|
80
80
|
|
|
81
81
|
## `docs`
|
|
82
82
|
|
|
83
|
-
The `
|
|
83
|
+
The `docs` folder contains documentation pages. These are picked up and compiled by the documentation generation tools when running `at-docgen`. See the [Building the docs](building-docs) for details.
|
|
84
84
|
|
|
85
85
|
## `conf`
|
|
86
86
|
|
package/docs/hooks.md
CHANGED
|
@@ -12,7 +12,7 @@ All hook observers must complete before the operation continues. For example, a
|
|
|
12
12
|
|
|
13
13
|
Hooks can be either **mutable** or **immutable**:
|
|
14
14
|
|
|
15
|
-
- **Immutable**: the _default_ behaviour
|
|
15
|
+
- **Immutable**: the _default_ behaviour. Observers are run in parallel (at the same time). When running in series, observers receive a deep copy of arguments to prevent unintended modifications.
|
|
16
16
|
- **Mutable**: hooks allow modification of param data, and run observers in series (one after another) to ensure modifications are applied in order.
|
|
17
17
|
|
|
18
18
|
## Basic usage
|
|
@@ -119,8 +119,8 @@ Below are some commonly used hooks, which you may find useful.
|
|
|
119
119
|
| AbstractApiModule | `accessCheckHook` | Check document access | `(req, doc)` | No |
|
|
120
120
|
| AdaptFrameworkBuild | `preBuildHook` | Before course build starts | | Yes |
|
|
121
121
|
| AdaptFrameworkBuild | `postBuildHook` | After course build completes | | Yes |
|
|
122
|
-
|
|
|
123
|
-
|
|
|
122
|
+
| AdaptFrameworkModule | `preImportHook` | Before course import starts | | Yes |
|
|
123
|
+
| AdaptFrameworkModule | `postImportHook` | After course import completes | | No |
|
|
124
124
|
|
|
125
125
|
## Practical examples
|
|
126
126
|
|
|
@@ -40,6 +40,10 @@ export default class Licensing {
|
|
|
40
40
|
|
|
41
41
|
async storeLicenseData (pkg) {
|
|
42
42
|
if (!pkg.license) {
|
|
43
|
+
const l = 'Undefined'
|
|
44
|
+
if (!this.licenses[l]) this.licenses[l] = { count: 0, packages: [] }
|
|
45
|
+
this.licenses[l].count++
|
|
46
|
+
this.licenses[l].packages.push(pkg.name)
|
|
43
47
|
return
|
|
44
48
|
}
|
|
45
49
|
if (typeof pkg.license === 'object') {
|
|
@@ -49,14 +53,17 @@ export default class Licensing {
|
|
|
49
53
|
for (let l of licenses) {
|
|
50
54
|
l = this.licenseNameMap(l)
|
|
51
55
|
if (this.licenses[l]) {
|
|
52
|
-
|
|
56
|
+
this.licenses[l].count++
|
|
57
|
+
this.licenses[l].packages.push(pkg.name)
|
|
58
|
+
return
|
|
53
59
|
}
|
|
54
|
-
this.licenses[l] = { count: 1 }
|
|
60
|
+
this.licenses[l] = { count: 1, packages: [pkg.name] }
|
|
55
61
|
try {
|
|
56
62
|
const { GITHUB_USER, GITHUB_TOKEN } = process.env
|
|
57
63
|
const res = await fetch(`https://api.github.com/licenses/${l.toLowerCase()}`, { headers: { Authorization: `Basic ${Buffer.from(`${GITHUB_USER}:${GITHUB_TOKEN}`).toString('base64')}` } })
|
|
58
|
-
|
|
59
|
-
if (res.
|
|
64
|
+
const body = await res.json()
|
|
65
|
+
if (res.ok) Object.assign(this.licenses[l], body)
|
|
66
|
+
else console.log(`Could not fetch '${l}' license from GitHub API (${res.status}), will list as unknown`)
|
|
60
67
|
} catch (e) {
|
|
61
68
|
console.error(e)
|
|
62
69
|
}
|
|
@@ -92,10 +99,10 @@ export default class Licensing {
|
|
|
92
99
|
|
|
93
100
|
async generateLicenseDetailsMd () {
|
|
94
101
|
let md = ''
|
|
95
|
-
Object.entries(this.licenses).forEach(([key, { name, spdxId, description, body, permissions }]) => {
|
|
102
|
+
Object.entries(this.licenses).forEach(([key, { name, spdx_id: spdxId, description, body, permissions }]) => {
|
|
96
103
|
if (!name) return
|
|
97
104
|
md += '<details>\n'
|
|
98
|
-
md += `<summary>${name} (${spdxId})</summary>\n`
|
|
105
|
+
md += `<summary>${name}${spdxId ? ` (${spdxId})` : ''}</summary>\n`
|
|
99
106
|
md += `<p>${description}</p>\n`
|
|
100
107
|
md += `<p>This license allows the following:\n<ul>${permissions.map(p => `<li>${this.permissionsMap(p)}</li>`).join('\n')}</ul></p>\n`
|
|
101
108
|
md += '<p>The original license text is as follows:</p>\n'
|
|
@@ -106,11 +113,13 @@ export default class Licensing {
|
|
|
106
113
|
}
|
|
107
114
|
|
|
108
115
|
generateUnknownLicenseMd () {
|
|
109
|
-
const unknowns = []
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
116
|
+
const unknowns = Object.entries(this.licenses).filter(([, { name }]) => !name)
|
|
117
|
+
if (!unknowns.length) return ''
|
|
118
|
+
let md = 'No information is held on the following licenses, please do your own research to determine their suitability.\n\n'
|
|
119
|
+
unknowns.forEach(([key, { packages }]) => {
|
|
120
|
+
md += `- **${key}**: ${packages.join(', ')}\n`
|
|
121
|
+
})
|
|
122
|
+
return md
|
|
114
123
|
}
|
|
115
124
|
|
|
116
125
|
async generateMd () {
|
package/docs/writing-a-module.md
CHANGED
|
@@ -23,21 +23,19 @@ The below is what we recommend, and is the approach taken by the the core dev te
|
|
|
23
23
|
| `conf` | Folder | All config files go here (in `.schema.json` format) |
|
|
24
24
|
| `docs` | Folder | Documentation files go here (in `.md` format) |
|
|
25
25
|
| `lib` | Folder | All `.js` code should go here |
|
|
26
|
-
| `
|
|
26
|
+
| `tests` | Folder | Test scripts go here (in `*.spec.js`) |
|
|
27
27
|
| `index.js` | File | Contains all of the exports for your module |
|
|
28
28
|
| `adapt-authoring.json` | File | Adapt-specific metadata file used when initialising the app |
|
|
29
29
|
| `package.json` | File | npm configuration file |
|
|
30
|
+
| `routes.json` | File | _(Optional)_ Declarative route definitions for modules that expose HTTP endpoints. See [Handling server requests](server-requests.md) and [Authentication and permissions](auth-permissions.md) for details. |
|
|
30
31
|
|
|
31
32
|
##### A note on exports:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
```
|
|
35
|
-
export default {
|
|
36
|
-
Module: MyModuleClass,
|
|
37
|
-
utils: MyUtilsClass,
|
|
38
|
-
// ...other exports
|
|
39
|
-
};
|
|
33
|
+
Your module class must be the **default export** — this is what `DependencyLoader` imports. For additional exports, use named exports:
|
|
40
34
|
|
|
35
|
+
```javascript
|
|
36
|
+
// index.js
|
|
37
|
+
export { default } from './lib/MyModule.js'
|
|
38
|
+
export { MyUtilsClass } from './lib/utils.js'
|
|
41
39
|
```
|
|
42
40
|
|
|
43
41
|
## 2. Set up your package.json
|
|
@@ -81,7 +79,7 @@ If you need to wait for another module to initialise before you can continue, th
|
|
|
81
79
|
See below for an example:
|
|
82
80
|
|
|
83
81
|
```javascript
|
|
84
|
-
|
|
82
|
+
import { AbstractModule } from 'adapt-authoring-core'
|
|
85
83
|
|
|
86
84
|
export default class MyModule extends AbstractModule {
|
|
87
85
|
/** @override */
|
package/docs/writing-tests.md
CHANGED