@npmcli/template-oss 4.23.5 → 4.24.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/lib/content/package-json.hbs +12 -0
- package/lib/release/node-workspace-format.js +3 -1
- package/lib/release/release-manager.js +2 -1
- package/lib/release/release-please.js +5 -6
- package/lib/release/semver-versioning-strategy.js +71 -0
- package/lib/util/import-or-require.js +10 -1
- package/package.json +14 -12
|
@@ -40,13 +40,24 @@
|
|
|
40
40
|
},
|
|
41
41
|
"templateVersion": {{{ del }}},
|
|
42
42
|
"standard": {{{ del }}},
|
|
43
|
+
"nyc": {{#if tap18}}{
|
|
44
|
+
"exclude": {{{ json workspaceGlobs }}}
|
|
45
|
+
}{{else}}{{{ del }}}{{/if}},
|
|
43
46
|
"tap": {
|
|
47
|
+
{{#if tap18}}
|
|
48
|
+
{{#if workspaceGlobs}}
|
|
49
|
+
"exclude": {{{ json workspaceGlobs }}},
|
|
50
|
+
{{/if}}
|
|
51
|
+
"test-ignore": {{{ del }}},
|
|
52
|
+
{{else}}
|
|
53
|
+
"exclude": {{{ del }}},
|
|
44
54
|
{{#if workspacePaths}}
|
|
45
55
|
"exclude": {{#if tap18}}[
|
|
46
56
|
"{{ join workspaceGlobs "," }}"
|
|
47
57
|
]{{else }}{{{ del }}}{{/if}},
|
|
48
58
|
"test-ignore": {{#if tap18}}{{{ del }}}{{else}}"^({{ join workspacePaths "|" }})/"{{/if}},
|
|
49
59
|
{{/if}}
|
|
60
|
+
{{/if}}
|
|
50
61
|
{{#if typescript}}
|
|
51
62
|
{{#if tap16}}
|
|
52
63
|
"coverage": false,
|
|
@@ -57,6 +68,7 @@
|
|
|
57
68
|
],
|
|
58
69
|
{{/if}}
|
|
59
70
|
{{/if}}
|
|
71
|
+
"show-full-coverage": {{#if tap18}}true{{else}}{{{ del }}}{{/if}},
|
|
60
72
|
"nyc-arg": {{#if tap18}}{{{ del }}}{{else}}[
|
|
61
73
|
{{#each workspaceGlobs}}
|
|
62
74
|
"--exclude",
|
|
@@ -5,7 +5,8 @@ const { TagName } = require('release-please/build/src/util/tag-name.js')
|
|
|
5
5
|
const { ROOT_PROJECT_PATH } = require('release-please/build/src/manifest.js')
|
|
6
6
|
const { DEPS, link, wrapSpecs, list } = require('./util.js')
|
|
7
7
|
|
|
8
|
-
/*
|
|
8
|
+
/* TODO fix flaky tests and enable coverage */
|
|
9
|
+
/* c8 ignore start */
|
|
9
10
|
module.exports = class extends ManifestPlugin {
|
|
10
11
|
static WORKSPACE_MESSAGE = (name, version) => `${DEPS}(workspace): ${name}@${version}`
|
|
11
12
|
|
|
@@ -95,3 +96,4 @@ module.exports = class extends ManifestPlugin {
|
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
}
|
|
99
|
+
/* c8 ignore end */
|
|
@@ -165,13 +165,14 @@ class ReleaseManager {
|
|
|
165
165
|
// If the url fails with anything but a 404 we want the process to blow
|
|
166
166
|
// up because that means something is very wrong. This is a rare edge
|
|
167
167
|
// case that isn't worth testing.
|
|
168
|
-
|
|
168
|
+
|
|
169
169
|
if (r.statusCode === 200) {
|
|
170
170
|
this.#info('Found release process from wiki')
|
|
171
171
|
return r.body.text()
|
|
172
172
|
} else if (r.statusCode === 404) {
|
|
173
173
|
this.#info('No release process found in wiki, falling back to default process')
|
|
174
174
|
return this.#getReleaseSteps()
|
|
175
|
+
/* c8 ignore next 3 */
|
|
175
176
|
} else {
|
|
176
177
|
throw new Error(`Release process fetch failed with status: ${r.statusCode}`)
|
|
177
178
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
const RP = require('release-please')
|
|
2
|
-
const { DefaultVersioningStrategy } = require('release-please/build/src/versioning-strategies/default.js')
|
|
3
|
-
const { PrereleaseVersioningStrategy } = require('release-please/build/src/versioning-strategies/prerelease.js')
|
|
4
2
|
const { ROOT_PROJECT_PATH } = require('release-please/build/src/manifest.js')
|
|
5
3
|
const { CheckpointLogger, logger } = require('release-please/build/src/util/logger.js')
|
|
6
4
|
const assert = require('assert')
|
|
@@ -9,8 +7,10 @@ const omit = require('just-omit')
|
|
|
9
7
|
const ChangelogNotes = require('./changelog.js')
|
|
10
8
|
const NodeWorkspaceFormat = require('./node-workspace-format.js')
|
|
11
9
|
const { getPublishTag, noop } = require('./util.js')
|
|
10
|
+
const { SemverVersioningStrategy } = require('./semver-versioning-strategy.js')
|
|
12
11
|
|
|
13
|
-
/*
|
|
12
|
+
/* TODO fix flaky tests and enable coverage */
|
|
13
|
+
/* c8 ignore start */
|
|
14
14
|
class ReleasePlease {
|
|
15
15
|
#token
|
|
16
16
|
#owner
|
|
@@ -52,9 +52,7 @@ class ReleasePlease {
|
|
|
52
52
|
|
|
53
53
|
async init() {
|
|
54
54
|
RP.registerChangelogNotes('default', ({ github, ...o }) => new ChangelogNotes(github, o))
|
|
55
|
-
RP.registerVersioningStrategy('default', o =>
|
|
56
|
-
o.prerelease ? new PrereleaseVersioningStrategy(o) : new DefaultVersioningStrategy(o),
|
|
57
|
-
)
|
|
55
|
+
RP.registerVersioningStrategy('default', o => new SemverVersioningStrategy(o))
|
|
58
56
|
RP.registerPlugin(
|
|
59
57
|
'node-workspace-format',
|
|
60
58
|
({ github, targetBranch, repositoryConfig, ...o }) =>
|
|
@@ -166,5 +164,6 @@ class ReleasePlease {
|
|
|
166
164
|
return releases.length ? releases : null
|
|
167
165
|
}
|
|
168
166
|
}
|
|
167
|
+
/* c8 ignore end */
|
|
169
168
|
|
|
170
169
|
module.exports = ReleasePlease
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const semver = require('semver')
|
|
2
|
+
const { Version } = require('release-please/build/src/version.js')
|
|
3
|
+
|
|
4
|
+
const inc = (version, release, _preid) => {
|
|
5
|
+
const parsed = new semver.SemVer(version)
|
|
6
|
+
const implicitPreid = parsed.prerelease.length > 1 ? parsed.prerelease[0]?.toString() : undefined
|
|
7
|
+
const preid = _preid || implicitPreid
|
|
8
|
+
const next = new semver.SemVer(version).inc(release, preid)
|
|
9
|
+
if (!parsed.prerelease.length) {
|
|
10
|
+
return next.format()
|
|
11
|
+
}
|
|
12
|
+
const isFreshMajor = parsed.minor === 0 && parsed.patch === 0
|
|
13
|
+
const isFreshMinor = parsed.patch === 0
|
|
14
|
+
const shouldPrerelease =
|
|
15
|
+
(release === 'premajor' && isFreshMajor) || (release === 'preminor' && isFreshMinor) || release === 'prepatch'
|
|
16
|
+
if (shouldPrerelease) {
|
|
17
|
+
return semver.inc(version, 'prerelease', preid)
|
|
18
|
+
}
|
|
19
|
+
return next.format()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const parseCommits = commits => {
|
|
23
|
+
let release = 'patch'
|
|
24
|
+
for (const commit of commits) {
|
|
25
|
+
if (commit.breaking) {
|
|
26
|
+
release = 'major'
|
|
27
|
+
break
|
|
28
|
+
} else if (['feat', 'feature'].includes(commit.type)) {
|
|
29
|
+
release = 'minor'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return release
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
class SemverVersioningStrategyNested {
|
|
36
|
+
constructor(options, version, commits) {
|
|
37
|
+
this.options = options
|
|
38
|
+
this.commits = commits
|
|
39
|
+
this.version = version
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
bump() {
|
|
43
|
+
return new SemverVersioningStrategy(this.options).bump(this.version, this.commits)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
class SemverVersioningStrategy {
|
|
48
|
+
constructor(options) {
|
|
49
|
+
this.options = options
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
determineReleaseType(version, commits) {
|
|
53
|
+
return new SemverVersioningStrategyNested(this.options, version, commits)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
bump(currentVersion, commits) {
|
|
57
|
+
const prerelease = this.options.prerelease
|
|
58
|
+
const tag = this.options.prereleaseType
|
|
59
|
+
const releaseType = parseCommits(commits)
|
|
60
|
+
const addPreIfNeeded = prerelease ? `pre${releaseType}` : releaseType
|
|
61
|
+
const version = inc(currentVersion.toString(), addPreIfNeeded, tag)
|
|
62
|
+
/* c8 ignore start */
|
|
63
|
+
if (!version) {
|
|
64
|
+
throw new Error('Could not bump version')
|
|
65
|
+
}
|
|
66
|
+
/* c8 ignore stop */
|
|
67
|
+
return Version.parse(version)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
module.exports = { SemverVersioningStrategy }
|
|
@@ -14,9 +14,18 @@ const importOrRequire = async path => {
|
|
|
14
14
|
let content = {}
|
|
15
15
|
try {
|
|
16
16
|
content = require(path)
|
|
17
|
+
// this is for node 22+
|
|
18
|
+
/* c8 ignore start */
|
|
19
|
+
if (content.__esModule) {
|
|
20
|
+
return content.default
|
|
21
|
+
}
|
|
22
|
+
/* c8 ignore end */
|
|
17
23
|
} catch {
|
|
18
24
|
try {
|
|
19
|
-
|
|
25
|
+
// this is for node under 20
|
|
26
|
+
const results = await import(pathToFileURL(path))
|
|
27
|
+
// istanbul ignore next
|
|
28
|
+
return results.default
|
|
20
29
|
} catch {
|
|
21
30
|
// its ok if this fails since the content dir might only be to provide
|
|
22
31
|
// other files. the index.js is optional
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@npmcli/template-oss",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.24.0",
|
|
4
4
|
"description": "templated files used in npm CLI team oss projects",
|
|
5
5
|
"main": "lib/content/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -73,20 +73,17 @@
|
|
|
73
73
|
"eslint-config-prettier": "^9.1.0",
|
|
74
74
|
"nock": "^13.3.8",
|
|
75
75
|
"prettier": "^3.2.5",
|
|
76
|
-
"tap": "^
|
|
76
|
+
"tap": "^21.0.1"
|
|
77
77
|
},
|
|
78
78
|
"tap": {
|
|
79
79
|
"timeout": 600,
|
|
80
|
-
"nyc-arg": [
|
|
81
|
-
"--exclude",
|
|
82
|
-
"workspace/test-workspace/**",
|
|
83
|
-
"--exclude",
|
|
84
|
-
"tap-snapshots/**"
|
|
85
|
-
],
|
|
86
|
-
"test-ignore": "^(workspace/test-workspace)/",
|
|
87
80
|
"node-arg": [
|
|
88
81
|
"--no-experimental-fetch"
|
|
89
|
-
]
|
|
82
|
+
],
|
|
83
|
+
"exclude": [
|
|
84
|
+
"workspace/test-workspace/**"
|
|
85
|
+
],
|
|
86
|
+
"show-full-coverage": true
|
|
90
87
|
},
|
|
91
88
|
"templateOSS": {
|
|
92
89
|
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
|
|
@@ -94,9 +91,14 @@
|
|
|
94
91
|
"prettier": true
|
|
95
92
|
},
|
|
96
93
|
"engines": {
|
|
97
|
-
"node": "^
|
|
94
|
+
"node": "^20.17.0 || >=22.9.0"
|
|
98
95
|
},
|
|
99
96
|
"workspaces": [
|
|
100
97
|
"workspace/test-workspace"
|
|
101
|
-
]
|
|
98
|
+
],
|
|
99
|
+
"nyc": {
|
|
100
|
+
"exclude": [
|
|
101
|
+
"workspace/test-workspace/**"
|
|
102
|
+
]
|
|
103
|
+
}
|
|
102
104
|
}
|