-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
75 lines (66 loc) · 2.23 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import verifyWHMCS from "./lib/verify.js";
import publishWHMCS from "./lib/publish.js";
import deleteVersion from "./lib/delete-marketplace-version.js";
import setCompatibleVersions from "./lib/set-compatible-versions.js";
import githubReleases from "./lib/get-github-releases.js";
import marketplaceVersions from "./lib/scrape-marketplace-versions.js";
let verified;
/**
* Called by semantic-release during the verify step
* @param {*} pluginConfig The semantic-release plugin config
* @param {*} context The context provided by semantic-release
*/
async function verifyConditions(pluginConfig, context) {
if (!verified) {
await verifyWHMCS(pluginConfig, context);
verified = true;
}
}
/**
* Called by semantic-release during the publish step
* @param {*} pluginConfig The semantic-release plugin config
* @param {*} context The context provided by semantic-release
*/
async function publish(pluginConfig, context) {
await verifyConditions(pluginConfig, context);
return publishWHMCS(pluginConfig, context);
}
async function syncVersions(pluginConfig, context) {
await verifyConditions(pluginConfig, context);
const releases = await githubReleases(pluginConfig, context);
if (releases && releases.length) {
const versions = await marketplaceVersions(pluginConfig, context);
for (const release of releases) {
if (!versions.includes(release.name.substring(1))) {
context.nextRelease = {
version: release.name.substring(1),
notes: release.body,
releaseDate: release.published_at,
};
console.log(`Adding missing version ${context.nextRelease.version}`);
await publish(pluginConfig, context);
}
}
}
}
async function delVersion(pluginConfig, context) {
await verifyConditions(pluginConfig, context);
await deleteVersion(pluginConfig, context);
}
async function updateCompatibility(pluginConfig, context) {
await verifyConditions(pluginConfig, context);
await setCompatibleVersions(pluginConfig, context);
}
async function fail(pluginConfig, context) {
await verifyConditions(pluginConfig, context);
}
export default {
verifyConditions,
publish,
fail,
syncVersions,
delVersion,
githubReleases,
marketplaceVersions,
updateCompatibility,
};