adapt-authoring-core 2.2.2 → 2.2.4

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,4 +1,4 @@
1
- name: Standard.js formatting check
1
+ name: Lint
2
2
  on: push
3
3
  jobs:
4
4
  default:
@@ -9,4 +9,4 @@ jobs:
9
9
  with:
10
10
  node-version: 'lts/*'
11
11
  - run: npm install
12
- - run: npx standard
12
+ - run: npx standard
@@ -1,20 +1,35 @@
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
+ const badgeUrl = `${url}/badge.svg`
18
+ try {
19
+ const res = await fetch(badgeUrl, { method: 'HEAD' })
20
+ if (res.ok) return `[![${w}](${badgeUrl})](${url})`
21
+ } catch {}
22
+ return null
23
+ }))
24
+ return results.filter(Boolean)
25
+ }
26
+
27
+ async generateMd () {
28
+ const rows = await Promise.all(Object.keys(this.app.dependencies).sort().map(async name => {
12
29
  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| - | :-: | - | :-: |')
30
+ const badges = await this.getWorkflowBadges(homepage)
31
+ return `| ${homepage ? `[${name}](${homepage})` : name} | ${version} | ${description} | ${badges.join('<br>')} |`
32
+ }))
33
+ return `| Name | Version | Description | Status |\n| - | :-: | - | :-: |\n${rows.join('\n')}`
19
34
  }
20
35
  }
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.4",
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",