adapt-authoring-core 2.2.2 → 2.2.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,20 +1,34 @@
1
+ import fetch from 'node-fetch'
2
+
1
3
  export default class CoreModules {
2
4
  async run () {
3
5
  this.manualFile = 'coremodules.md'
4
6
  this.replace = {
5
7
  VERSION: this.app.pkg.version,
6
- MODULES: this.generateMd()
8
+ MODULES: await this.generateMd()
7
9
  }
8
10
  }
9
11
 
10
- generateMd () {
11
- return Object.keys(this.app.dependencies).sort().reduce((s, name) => {
12
+ async getWorkflowBadges (homepage) {
13
+ if (!homepage) return []
14
+ const workflows = ['tests', 'standardjs']
15
+ const results = await Promise.all(workflows.map(async w => {
16
+ const url = `${homepage}/actions/workflows/${w}.yml`
17
+ try {
18
+ const res = await fetch(url, { method: 'HEAD', redirect: 'follow' })
19
+ if (res.ok) return `[![${w}](${url}/badge.svg)](${url})`
20
+ } catch {}
21
+ return null
22
+ }))
23
+ return results.filter(Boolean)
24
+ }
25
+
26
+ async generateMd () {
27
+ const rows = await Promise.all(Object.keys(this.app.dependencies).sort().map(async name => {
12
28
  const { version, description, homepage } = this.app.dependencies[name]
13
- const workflows = ['tests', 'standardjs']
14
- const badges = homepage
15
- ? workflows.map(w => `[![${w}](${homepage}/actions/workflows/${w}.yml/badge.svg)](${homepage}/actions/workflows/${w}.yml)`).join('<br>')
16
- : ''
17
- return `${s}\n| ${homepage ? `[${name}](${homepage})` : name} | ${version} | ${description} | ${badges} |`
18
- }, '| Name | Version | Description | Status |\n| - | :-: | - | :-: |')
29
+ const badges = await this.getWorkflowBadges(homepage)
30
+ return `| ${homepage ? `[${name}](${homepage})` : name} | ${version} | ${description} | ${badges.join('<br>')} |`
31
+ }))
32
+ return `| Name | Version | Description | Status |\n| - | :-: | - | :-: |\n${rows.join('\n')}`
19
33
  }
20
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-core",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "description": "A bundle of reusable 'core' functionality",
5
5
  "homepage": "https://github.com/adapt-security/adapt-authoring-core",
6
6
  "license": "GPL-3.0",