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,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
|
-
|
|
11
|
-
|
|
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 `[](${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
|
|
14
|
-
|
|
15
|
-
|
|
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
|
}
|