-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathplatform-checker.js
More file actions
57 lines (45 loc) · 1.55 KB
/
platform-checker.js
File metadata and controls
57 lines (45 loc) · 1.55 KB
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
'use strict';
const semver = require('semver');
const logger = require('heimdalljs-logger')('ember-cli:platform-checker:');
const loadConfig = require('./load-config');
const ci = loadConfig('.github/workflows/ci.yml');
const nodeVersions = new Set();
for (let jobName in ci.jobs) {
let job = ci.jobs[jobName];
job.steps.forEach(step => {
let isSetupNode = step.uses === 'actions/setup-node@v1';
if (isSetupNode && step.with['node-version'].includes('${{') === false) {
nodeVersions.add(step.with['node-version']);
}
});
if (job.strategy && job.strategy.matrix && job.strategy.matrix['node-version']) {
job.strategy.matrix['node-version'].forEach(version => nodeVersions.add(version));
}
}
const testedEngines = Array.from(nodeVersions).join(' || ');
let supportedEngines = loadConfig('package.json').engines.node;
module.exports = class PlatformChecker {
constructor(version) {
this.version = version;
this.isValid = this.checkIsValid();
this.isTested = this.checkIsTested();
this.isDeprecated = this.checkIsDeprecated();
logger.info('%o', {
version: this.version,
isValid: this.isValid,
isTested: this.isTested,
isDeprecated: this.isDeprecated,
});
}
checkIsValid(range) {
range = range || supportedEngines;
return semver.satisfies(this.version, range) || semver.gtr(this.version, range);
}
checkIsDeprecated(range) {
return !this.checkIsValid(range);
}
checkIsTested(range) {
range = range || testedEngines;
return semver.satisfies(this.version, range);
}
};