@npmcli/template-oss 4.7.1 → 4.8.0
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.
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const semver = require('semver')
|
|
2
|
+
const { relative, join } = require('path')
|
|
3
|
+
const Arborist = require('@npmcli/arborist')
|
|
4
|
+
|
|
5
|
+
const run = async ({ root, path, pkg, config: { omitEngines = [] } }) => {
|
|
6
|
+
const pkgPath = join(relative(root, path), 'package.json')
|
|
7
|
+
const arb = new Arborist({ path })
|
|
8
|
+
const tree = await arb.loadActual({ forceActual: true })
|
|
9
|
+
|
|
10
|
+
const engines = pkg.engines.node
|
|
11
|
+
const deps = await tree.querySelectorAll(`#${pkg.name} > .prod:attr(engines, [node])`)
|
|
12
|
+
|
|
13
|
+
const invalid = []
|
|
14
|
+
for (const dep of deps) {
|
|
15
|
+
if (omitEngines.includes(dep.name)) {
|
|
16
|
+
continue
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const depEngines = dep.target.package.engines.node
|
|
20
|
+
if (!semver.subset(engines, depEngines)) {
|
|
21
|
+
invalid.push({
|
|
22
|
+
name: `${dep.name}@${dep.version}`,
|
|
23
|
+
location: dep.location,
|
|
24
|
+
engines: depEngines,
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (invalid.length) {
|
|
30
|
+
const title = `The following production dependencies are not compatible with ` +
|
|
31
|
+
`\`engines.node: ${engines}\` found in \`${pkgPath}\`:`
|
|
32
|
+
return {
|
|
33
|
+
title,
|
|
34
|
+
body: invalid.map((dep) => [
|
|
35
|
+
`${dep.name}:`,
|
|
36
|
+
` engines.node: ${dep.engines}`,
|
|
37
|
+
` location: ${dep.location}`,
|
|
38
|
+
].join('\n')).join('\n'),
|
|
39
|
+
solution: 'Remove them or move them to devDependencies.',
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = {
|
|
45
|
+
run,
|
|
46
|
+
when: ({ pkg, config: c }) => c.applyModule && pkg.engines?.node,
|
|
47
|
+
name: 'check-engines',
|
|
48
|
+
}
|
package/lib/check/index.js
CHANGED
package/lib/content/ci.yml
CHANGED
|
@@ -4,15 +4,6 @@ on:
|
|
|
4
4
|
{{> onCi }}
|
|
5
5
|
|
|
6
6
|
jobs:
|
|
7
|
-
engines:
|
|
8
|
-
{{> jobMatrix
|
|
9
|
-
jobName="Engines"
|
|
10
|
-
jobDepFlags="--engines-strict"
|
|
11
|
-
macCI=false
|
|
12
|
-
windowsCI=false
|
|
13
|
-
ciVersions=baseCiVersions
|
|
14
|
-
}}
|
|
15
|
-
|
|
16
7
|
lint:
|
|
17
8
|
{{> job jobName="Lint" }}
|
|
18
9
|
{{> stepLint jobRunFlags=pkgFlags }}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@npmcli/template-oss",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0",
|
|
4
4
|
"description": "templated files used in npm CLI team oss projects",
|
|
5
5
|
"main": "lib/content/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"@commitlint/cli": "^17.1.1",
|
|
37
37
|
"@commitlint/config-conventional": "^17.1.0",
|
|
38
38
|
"@isaacs/string-locale-compare": "^1.1.0",
|
|
39
|
+
"@npmcli/arborist": "^6.0.0",
|
|
39
40
|
"@npmcli/git": "^4.0.0",
|
|
40
41
|
"@npmcli/map-workspaces": "^3.0.0",
|
|
41
42
|
"@npmcli/package-json": "^3.0.0",
|