@npmcli/template-oss 4.18.1 → 4.20.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.
- package/README.md +15 -11
- package/bin/release-manager.js +6 -0
- package/lib/config.js +112 -136
- package/lib/content/{_job-matrix.yml → _job-matrix-yml.hbs} +1 -1
- package/lib/content/{_job-release-integration.yml → _job-release-integration-yml.hbs} +2 -2
- package/lib/content/{_job.yml → _job-yml.hbs} +1 -1
- package/lib/content/_step-node-yml.hbs +60 -0
- package/lib/content/_steps-setup-yml.hbs +6 -0
- package/lib/content/{audit.yml → audit-yml.hbs} +2 -2
- package/lib/content/{ci-release.yml → ci-release-yml.hbs} +7 -7
- package/lib/content/ci-yml.hbs +13 -0
- package/lib/content/{codeql-analysis.yml → codeql-analysis-yml.hbs} +1 -1
- package/lib/content/{eslintrc.js → eslintrc-js.hbs} +11 -1
- package/lib/content/{gitignore → gitignore.hbs} +2 -0
- package/lib/content/index.js +47 -42
- package/lib/content/{pkg.json → package-json.hbs} +8 -9
- package/lib/content/{post-dependabot.yml → post-dependabot-yml.hbs} +1 -1
- package/lib/content/{pull-request.yml → pull-request-yml.hbs} +1 -1
- package/lib/content/{release.yml → release-yml.hbs} +10 -10
- package/lib/content/tsconfig-json.hbs +17 -0
- package/lib/util/ci-versions.js +80 -0
- package/lib/util/files.js +29 -20
- package/lib/util/get-cmd-path.js +36 -0
- package/lib/util/git.js +6 -11
- package/lib/util/import-or-require.js +29 -0
- package/lib/util/merge.js +0 -1
- package/lib/util/parser.js +6 -1
- package/lib/util/path.js +13 -0
- package/lib/util/template.js +9 -6
- package/package.json +10 -10
- package/lib/content/_step-node.yml +0 -57
- package/lib/content/_steps-setup.yml +0 -6
- package/lib/content/ci.yml +0 -13
- package/lib/util/parse-ci-versions.js +0 -78
- /package/lib/content/{CODEOWNERS → CODEOWNERS.hbs} +0 -0
- /package/lib/content/{CODE_OF_CONDUCT.md → CODE_OF_CONDUCT-md.hbs} +0 -0
- /package/lib/content/{CONTRIBUTING.md → CONTRIBUTING-md.hbs} +0 -0
- /package/lib/content/{LICENSE.md → LICENSE-md.hbs} +0 -0
- /package/lib/content/{SECURITY.md → SECURITY-md.hbs} +0 -0
- /package/lib/content/{_on-ci.yml → _on-ci-yml.hbs} +0 -0
- /package/lib/content/{_step-audit.yml → _step-audit-yml.hbs} +0 -0
- /package/lib/content/{_step-checks.yml → _step-checks-yml.hbs} +0 -0
- /package/lib/content/{_step-deps.yml → _step-deps-yml.hbs} +0 -0
- /package/lib/content/{_step-git.yml → _step-git-yml.hbs} +0 -0
- /package/lib/content/{_step-lint.yml → _step-lint-yml.hbs} +0 -0
- /package/lib/content/{_step-test.yml → _step-test-yml.hbs} +0 -0
- /package/lib/content/{bug.yml → bug-yml.hbs} +0 -0
- /package/lib/content/{commitlintrc.js → commitlintrc-js.hbs} +0 -0
- /package/lib/content/{config.yml → config-yml.hbs} +0 -0
- /package/lib/content/{dependabot.yml → dependabot-yml.hbs} +0 -0
- /package/lib/content/{npmrc → npmrc.hbs} +0 -0
- /package/lib/content/{release-please-config.json → release-please-config-json.hbs} +0 -0
- /package/lib/content/{release-please-manifest.json → release-please-manifest-json.hbs} +0 -0
- /package/lib/content/{settings.yml → settings-yml.hbs} +0 -0
- /package/lib/content/{tap.json → tap-json.hbs} +0 -0
package/lib/util/template.js
CHANGED
|
@@ -31,7 +31,7 @@ const makePartials = (dir, isBase) => {
|
|
|
31
31
|
Handlebars.registerPartial(partials)
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const setupHandlebars = (
|
|
34
|
+
const setupHandlebars = (dirs) => {
|
|
35
35
|
Handlebars.registerHelper('obj', ({ hash }) => Object.fromEntries(safeValues(hash)))
|
|
36
36
|
Handlebars.registerHelper('join', (arr, sep) => arr.join(typeof sep === 'string' ? sep : ', '))
|
|
37
37
|
Handlebars.registerHelper('pluck', (arr, key) => arr.map(a => a[key]))
|
|
@@ -40,14 +40,17 @@ const setupHandlebars = (baseDir, ...otherDirs) => {
|
|
|
40
40
|
Handlebars.registerHelper('json', (c) => JSON.stringify(c))
|
|
41
41
|
Handlebars.registerHelper('del', () => JSON.stringify(DELETE))
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
makePartials(
|
|
43
|
+
if (Array.isArray(dirs)) {
|
|
44
|
+
const [baseDir, ...otherDirs] = dirs
|
|
45
|
+
makePartials(baseDir, true)
|
|
46
|
+
for (const dir of otherDirs) {
|
|
47
|
+
makePartials(dir)
|
|
48
|
+
}
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
|
|
49
|
-
const template = (str, { config, ...options }) => {
|
|
50
|
-
setupHandlebars(
|
|
52
|
+
const template = (str, { config = {}, ...options }) => {
|
|
53
|
+
setupHandlebars(config.__PARTIAL_DIRS__)
|
|
51
54
|
|
|
52
55
|
const t = Handlebars.compile(str, { strict: true })
|
|
53
56
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@npmcli/template-oss",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.20.0",
|
|
4
4
|
"description": "templated files used in npm CLI team oss projects",
|
|
5
5
|
"main": "lib/content/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"template-oss-release-manager": "bin/release-manager.js"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
-
"lint": "eslint \"**/*.js\"",
|
|
13
|
+
"lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
|
|
14
14
|
"lintfix": "npm run lint -- --fix",
|
|
15
15
|
"posttest": "npm run lint",
|
|
16
16
|
"snap": "tap",
|
|
@@ -33,25 +33,25 @@
|
|
|
33
33
|
"license": "ISC",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@actions/core": "^1.9.1",
|
|
36
|
-
"@commitlint/cli": "^
|
|
37
|
-
"@commitlint/config-conventional": "^
|
|
36
|
+
"@commitlint/cli": "^18.2.0",
|
|
37
|
+
"@commitlint/config-conventional": "^18.1.0",
|
|
38
38
|
"@isaacs/string-locale-compare": "^1.1.0",
|
|
39
|
-
"@npmcli/arborist": "^
|
|
40
|
-
"@npmcli/git": "^
|
|
39
|
+
"@npmcli/arborist": "^7.2.1",
|
|
40
|
+
"@npmcli/git": "^5.0.3",
|
|
41
41
|
"@npmcli/map-workspaces": "^3.0.0",
|
|
42
|
-
"@npmcli/package-json": "^
|
|
42
|
+
"@npmcli/package-json": "^5.0.0",
|
|
43
43
|
"@octokit/rest": "^19.0.4",
|
|
44
44
|
"diff": "^5.0.0",
|
|
45
45
|
"glob": "^10.1.0",
|
|
46
46
|
"handlebars": "^4.7.7",
|
|
47
|
-
"hosted-git-info": "^
|
|
47
|
+
"hosted-git-info": "^7.0.1",
|
|
48
48
|
"ini": "^4.0.0",
|
|
49
49
|
"json-parse-even-better-errors": "^3.0.0",
|
|
50
50
|
"just-deep-map-values": "^1.1.1",
|
|
51
51
|
"just-diff": "^6.0.0",
|
|
52
52
|
"lodash": "^4.17.21",
|
|
53
53
|
"minimatch": "^9.0.2",
|
|
54
|
-
"npm-package-arg": "^
|
|
54
|
+
"npm-package-arg": "^11.0.1",
|
|
55
55
|
"proc-log": "^3.0.0",
|
|
56
56
|
"release-please": "npm:@npmcli/release-please@^14.2.6",
|
|
57
57
|
"semver": "^7.3.5",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"publish": true
|
|
82
82
|
},
|
|
83
83
|
"engines": {
|
|
84
|
-
"node": "^
|
|
84
|
+
"node": "^18.17.0 || >=20.5.0"
|
|
85
85
|
},
|
|
86
86
|
"workspaces": [
|
|
87
87
|
"workspace/test-workspace"
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
- name: Setup Node
|
|
2
|
-
uses: actions/setup-node@v3
|
|
3
|
-
id: node
|
|
4
|
-
with:
|
|
5
|
-
node-version: {{#if jobIsMatrix}}$\{{ matrix.node-version }}{{else}}{{ last ciVersions }}{{/if}}
|
|
6
|
-
check-latest: contains({{#if jobIsMatrix}}matrix.node-version{{else}}'{{ last ciVersions }}'{{/if}}, '.x')
|
|
7
|
-
{{#if lockfile}}
|
|
8
|
-
cache: npm
|
|
9
|
-
{{/if}}
|
|
10
|
-
|
|
11
|
-
{{#if updateNpm}}
|
|
12
|
-
# node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows
|
|
13
|
-
- name: Update Windows npm
|
|
14
|
-
if: |
|
|
15
|
-
matrix.platform.os == 'windows-latest' && (
|
|
16
|
-
startsWith(steps.node.outputs.node-version, 'v10.') || startsWith(steps.node.outputs.node-version, 'v12.') || startsWith(steps.node.outputs.node-version, 'v14.')
|
|
17
|
-
)
|
|
18
|
-
run: |
|
|
19
|
-
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
|
|
20
|
-
tar xf npm-7.5.4.tgz
|
|
21
|
-
cd package
|
|
22
|
-
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
|
|
23
|
-
cd ..
|
|
24
|
-
rmdir /s /q package
|
|
25
|
-
|
|
26
|
-
# Start on Node 10 because we dont test on anything lower
|
|
27
|
-
- name: Install npm@7 on Node 10
|
|
28
|
-
shell: bash
|
|
29
|
-
if: startsWith(steps.node.outputs.node-version, 'v10.')
|
|
30
|
-
id: npm-7
|
|
31
|
-
run: |
|
|
32
|
-
npm i --prefer-online --no-fund --no-audit -g npm@7
|
|
33
|
-
echo "updated=true" >> "$GITHUB_OUTPUT"
|
|
34
|
-
|
|
35
|
-
- name: Install npm@8 on Node 12
|
|
36
|
-
shell: bash
|
|
37
|
-
if: startsWith(steps.node.outputs.node-version, 'v12.')
|
|
38
|
-
id: npm-8
|
|
39
|
-
run: |
|
|
40
|
-
npm i --prefer-online --no-fund --no-audit -g npm@8
|
|
41
|
-
echo "updated=true" >> "$GITHUB_OUTPUT"
|
|
42
|
-
|
|
43
|
-
- name: Install npm@9 on Node 14/16/18.0
|
|
44
|
-
shell: bash
|
|
45
|
-
if: startsWith(steps.node.outputs.node-version, 'v14.') || startsWith(steps.node.outputs.node-version, 'v16.') || startsWith(steps.node.outputs.node-version, 'v18.0.')
|
|
46
|
-
id: npm-9
|
|
47
|
-
run: |
|
|
48
|
-
npm i --prefer-online --no-fund --no-audit -g npm@9
|
|
49
|
-
echo "updated=true" >> "$GITHUB_OUTPUT"
|
|
50
|
-
|
|
51
|
-
- name: Install npm@latest on Node
|
|
52
|
-
if: $\{{ !(steps.npm-7.outputs.updated || steps.npm-8.outputs.updated || steps.npm-9.outputs.updated) }}
|
|
53
|
-
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
|
|
54
|
-
|
|
55
|
-
- name: npm Version
|
|
56
|
-
run: npm -v
|
|
57
|
-
{{/if}}
|
package/lib/content/ci.yml
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
const semver = require('semver')
|
|
2
|
-
const { partition, uniq, groupBy } = require('lodash')
|
|
3
|
-
|
|
4
|
-
// try to parse a version. if its invalid then
|
|
5
|
-
// try to parse it as a range instead
|
|
6
|
-
const versionOrRange = (v) => semver.parse(v) || new semver.Range(v)
|
|
7
|
-
|
|
8
|
-
// get the version or the upper bound of the range
|
|
9
|
-
// used for sorting to give the latest ci target
|
|
10
|
-
const getMaxVersion = (v) => v.version || v.set[0][1].semver.version
|
|
11
|
-
|
|
12
|
-
// given an array of versions, returns an object where
|
|
13
|
-
// each key is a major and each value is a sorted list of versions
|
|
14
|
-
const versionsByMajor = (versions) => {
|
|
15
|
-
const majors = groupBy(versions, (v) => semver.major(v))
|
|
16
|
-
for (const [k, vs] of Object.entries(majors)) {
|
|
17
|
-
majors[k] = semver.sort(vs)[0]
|
|
18
|
-
}
|
|
19
|
-
return majors
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// given a list of semver ci targets like:
|
|
23
|
-
// ['12.13.0', '12.x', '14.15.0', '14.x', '16.0.0', '16.x']
|
|
24
|
-
// this will parse into a uniq list of lowest "supported"
|
|
25
|
-
// versions. In our cases so that will return
|
|
26
|
-
// '^12.13.0 || ^14.15.0 || >=16'. This is not super generic but fits
|
|
27
|
-
// our use case for now where we want to test on a bunch of
|
|
28
|
-
// specific versions/ranges and map them to somewhat loose
|
|
29
|
-
// semver range for package.json#engines.node. This only supports
|
|
30
|
-
// returning ^ ranges and makes the last version >= currently.
|
|
31
|
-
//
|
|
32
|
-
// Assumptions:
|
|
33
|
-
// - ranges span a single major version
|
|
34
|
-
// - specific versions are lower then the upper bound of
|
|
35
|
-
// ranges within the same major version
|
|
36
|
-
const parseCITargets = (targets = []) => {
|
|
37
|
-
const [versions, ranges] = partition(
|
|
38
|
-
targets.map((t) => versionOrRange(t)),
|
|
39
|
-
(t) => t.version
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
const sorted = [...versions, ...ranges]
|
|
43
|
-
.sort((a, b) => semver.compareBuild(getMaxVersion(a), getMaxVersion(b)))
|
|
44
|
-
.map((v) => v.version || v.raw)
|
|
45
|
-
|
|
46
|
-
// object of {major: lowestVersion } for all passed in versions
|
|
47
|
-
const minVersions = versionsByMajor(versions)
|
|
48
|
-
|
|
49
|
-
// object of {major: lowestVersionInRange } for all passed in ranges
|
|
50
|
-
const minRanges = versionsByMajor(ranges.map((r) => semver.minVersion(r)))
|
|
51
|
-
|
|
52
|
-
// Given all the uniq major versions in targets...
|
|
53
|
-
const parsedRanges = uniq([...Object.keys(minVersions), ...Object.keys(minRanges)])
|
|
54
|
-
// first sort by major to make it display nicer
|
|
55
|
-
.sort((a, b) => Number(a) - Number(b))
|
|
56
|
-
.map((major) => {
|
|
57
|
-
const minVersion = minVersions[major]
|
|
58
|
-
const minRange = minRanges[major]
|
|
59
|
-
// if we only have one then return that
|
|
60
|
-
if (!minVersion || !minRange) {
|
|
61
|
-
return minVersion || minRange
|
|
62
|
-
}
|
|
63
|
-
// otherwise return min version
|
|
64
|
-
// XXX: this assumes the versions are lower than the upper
|
|
65
|
-
// bound for any range for the same major. This is ok for
|
|
66
|
-
// now but will break with more complex/specific semver ranges
|
|
67
|
-
return minVersion
|
|
68
|
-
})
|
|
69
|
-
// make the last version allow all greater than
|
|
70
|
-
.map((v, index, list) => (index === list.length - 1 ? '>=' : '^') + v)
|
|
71
|
-
|
|
72
|
-
return {
|
|
73
|
-
targets: sorted,
|
|
74
|
-
engines: parsedRanges.join(' || '),
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
module.exports = parseCITargets
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|