@pnpm/releasing.commands 1100.6.4 → 1100.7.1
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/CHANGELOG.md +80 -0
- package/lib/change/index.d.ts +42 -0
- package/lib/change/index.js +248 -0
- package/lib/deploy/createDeployFiles.d.ts +26 -0
- package/lib/deploy/createDeployFiles.js +255 -0
- package/lib/deploy/deploy.d.ts +12 -0
- package/lib/deploy/deploy.js +398 -0
- package/lib/deploy/deployHook.d.ts +2 -0
- package/lib/deploy/deployHook.js +15 -0
- package/lib/deploy/index.d.ts +2 -0
- package/lib/deploy/index.js +3 -0
- package/lib/index.d.ts +7 -0
- package/lib/lane/index.d.ts +24 -0
- package/lib/lane/index.js +157 -0
- package/lib/pack-app/index.d.ts +2 -0
- package/lib/pack-app/index.js +3 -0
- package/lib/pack-app/packApp.d.ts +22 -0
- package/lib/pack-app/packApp.js +558 -0
- package/lib/publish/FailedToPublishError.d.ts +22 -0
- package/lib/publish/FailedToPublishError.js +40 -0
- package/lib/publish/batchPublish.d.ts +20 -0
- package/lib/publish/batchPublish.js +201 -0
- package/lib/publish/displayError.d.ts +1 -0
- package/lib/publish/displayError.js +23 -0
- package/lib/publish/executeTokenHelper.d.ts +4 -0
- package/lib/publish/executeTokenHelper.js +17 -0
- package/lib/publish/extractManifestFromPacked.d.ts +19 -0
- package/lib/publish/extractManifestFromPacked.js +110 -0
- package/lib/publish/index.d.ts +3 -0
- package/lib/publish/index.js +4 -0
- package/lib/publish/oidc/authToken.d.ts +73 -0
- package/lib/publish/oidc/authToken.js +97 -0
- package/lib/publish/oidc/idToken.d.ts +76 -0
- package/lib/publish/oidc/idToken.js +90 -0
- package/lib/publish/oidc/provenance.d.ts +73 -0
- package/lib/publish/oidc/provenance.js +91 -0
- package/lib/publish/otp.d.ts +38 -0
- package/lib/publish/otp.js +41 -0
- package/lib/publish/otpEnv.d.ts +7 -0
- package/lib/publish/otpEnv.js +5 -0
- package/lib/publish/pack.d.ts +34 -0
- package/lib/publish/pack.js +408 -0
- package/lib/publish/previousChangelog.d.ts +25 -0
- package/lib/publish/previousChangelog.js +194 -0
- package/lib/publish/publish.d.ts +40 -0
- package/lib/publish/publish.js +256 -0
- package/lib/publish/publishPackedPkg.d.ts +79 -0
- package/lib/publish/publishPackedPkg.js +298 -0
- package/lib/publish/recursivePublish.d.ts +18 -0
- package/lib/publish/recursivePublish.js +132 -0
- package/lib/publish/registryConfigKeys.d.ts +30 -0
- package/lib/publish/registryConfigKeys.js +50 -0
- package/lib/publish/utils/shared-context.d.ts +7 -0
- package/lib/publish/utils/shared-context.js +20 -0
- package/lib/resolveUnpublishedDirs.d.ts +10 -0
- package/lib/resolveUnpublishedDirs.js +14 -0
- package/lib/stage/approve.d.ts +2 -0
- package/lib/stage/approve.js +14 -0
- package/lib/stage/context.d.ts +14 -0
- package/lib/stage/context.js +25 -0
- package/lib/stage/download.d.ts +2 -0
- package/lib/stage/download.js +32 -0
- package/lib/stage/errors.d.ts +15 -0
- package/lib/stage/errors.js +17 -0
- package/lib/stage/help.d.ts +1 -0
- package/lib/stage/help.js +84 -0
- package/lib/stage/index.d.ts +13 -0
- package/lib/stage/index.js +57 -0
- package/lib/stage/list.d.ts +2 -0
- package/lib/stage/list.js +49 -0
- package/lib/stage/parsing.d.ts +6 -0
- package/lib/stage/parsing.js +27 -0
- package/lib/stage/publish.d.ts +7 -0
- package/lib/stage/publish.js +38 -0
- package/lib/stage/reject.d.ts +2 -0
- package/lib/stage/reject.js +16 -0
- package/lib/stage/rendering.d.ts +11 -0
- package/lib/stage/rendering.js +50 -0
- package/lib/stage/request.d.ts +29 -0
- package/lib/stage/request.js +110 -0
- package/lib/stage/types.d.ts +38 -0
- package/lib/stage/types.js +3 -0
- package/lib/stage/view.d.ts +2 -0
- package/lib/stage/view.js +14 -0
- package/lib/tarball/index.d.ts +2 -0
- package/lib/tarball/index.js +3 -0
- package/lib/tarball/publishSummary.d.ts +47 -0
- package/lib/tarball/publishSummary.js +36 -0
- package/lib/tarball/safeTarballFilename.d.ts +8 -0
- package/lib/tarball/safeTarballFilename.js +21 -0
- package/lib/tarball/summarizeTarball.d.ts +12 -0
- package/lib/tarball/summarizeTarball.js +84 -0
- package/lib/version/index.d.ts +35 -0
- package/lib/version/index.js +360 -0
- package/package.json +44 -44
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { readProjectManifest } from '@pnpm/cli.utils';
|
|
3
|
+
import { types as allTypes } from '@pnpm/config.reader';
|
|
4
|
+
import { PnpmError } from '@pnpm/error';
|
|
5
|
+
import { runLifecycleHook } from '@pnpm/exec.lifecycle';
|
|
6
|
+
import { isGitRepo, isWorkingTreeClean } from '@pnpm/network.git-utils';
|
|
7
|
+
import { applyReleasePlan, assembleReleasePlan, changelogStorage, readChangeIntents, readLedger, toProjectDir, } from '@pnpm/releasing.versioning';
|
|
8
|
+
import { safeExeca as execa } from 'execa';
|
|
9
|
+
import { pick } from 'ramda';
|
|
10
|
+
import { renderHelp } from 'render-help';
|
|
11
|
+
import { inc, valid } from 'semver';
|
|
12
|
+
import { renderReleasePlan, toWorkspaceProjects } from '../change/index.js';
|
|
13
|
+
import { changelogHasSection, fetchPublishedChangelog } from '../publish/previousChangelog.js';
|
|
14
|
+
import { resolveUnpublishedDirs } from '../resolveUnpublishedDirs.js';
|
|
15
|
+
export function rcOptionsTypes() {
|
|
16
|
+
return pick([
|
|
17
|
+
'allow-same-version',
|
|
18
|
+
'commit-hooks',
|
|
19
|
+
'git-checks',
|
|
20
|
+
'git-tag-version',
|
|
21
|
+
'message',
|
|
22
|
+
'sign-git-tag',
|
|
23
|
+
'tag-version-prefix',
|
|
24
|
+
], allTypes);
|
|
25
|
+
}
|
|
26
|
+
export function cliOptionsTypes() {
|
|
27
|
+
return {
|
|
28
|
+
...rcOptionsTypes(),
|
|
29
|
+
'dry-run': Boolean,
|
|
30
|
+
json: Boolean,
|
|
31
|
+
preid: String,
|
|
32
|
+
recursive: Boolean,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export const commandNames = ['version'];
|
|
36
|
+
const BUMP_TYPES = ['major', 'minor', 'patch', 'premajor', 'preminor', 'prepatch', 'prerelease'];
|
|
37
|
+
function isBumpType(value) {
|
|
38
|
+
return BUMP_TYPES.includes(value);
|
|
39
|
+
}
|
|
40
|
+
export function help() {
|
|
41
|
+
return renderHelp({
|
|
42
|
+
description: 'Bumps the version of a package.',
|
|
43
|
+
usages: [
|
|
44
|
+
'pnpm version <newversion>',
|
|
45
|
+
'pnpm version <major|minor|patch|premajor|preminor|prepatch|prerelease|from-git>',
|
|
46
|
+
'pnpm version -r [--dry-run]',
|
|
47
|
+
],
|
|
48
|
+
descriptionLists: [
|
|
49
|
+
{
|
|
50
|
+
title: 'Options',
|
|
51
|
+
list: [
|
|
52
|
+
{
|
|
53
|
+
description: "Don't check if working tree is clean",
|
|
54
|
+
name: '--no-git-checks',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
description: 'Sets the prerelease identifier (e.g. alpha, beta, rc)',
|
|
58
|
+
name: '--preid <preid>',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
description: 'Sets the tag prefix. Default is "v". Set to empty string to remove the prefix.',
|
|
62
|
+
name: '--tag-version-prefix <prefix>',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
description: 'Allow bumping to the same version',
|
|
66
|
+
name: '--allow-same-version',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
description: 'Commit message. "%s" is replaced with the new version. Default is "%s".',
|
|
70
|
+
name: '--message <message>',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
description: "Don't create a commit or tag for the version bump. Git commits and tags are always skipped in recursive mode.",
|
|
74
|
+
name: '--no-git-tag-version',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
description: 'Skip running git commit hooks when committing the version bump',
|
|
78
|
+
name: '--no-commit-hooks',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
description: 'Sign the generated git tag with GPG',
|
|
82
|
+
name: '--sign-git-tag',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
description: 'Filter packages by name (glob pattern)',
|
|
86
|
+
name: '--filter <pattern>',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
description: 'Show information in JSON format',
|
|
90
|
+
name: '--json',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
description: 'Apply command to all packages in workspace. Without a version argument, consumes the pending change intents from .changeset/ and applies the resulting release plan',
|
|
94
|
+
name: '--recursive',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
description: 'Print the release plan the pending change intents produce without applying it',
|
|
98
|
+
name: '--dry-run',
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
export async function handler(opts, params) {
|
|
106
|
+
const rawBump = params[0];
|
|
107
|
+
if (!rawBump) {
|
|
108
|
+
if (opts.recursive) {
|
|
109
|
+
return releaseFromIntents(opts);
|
|
110
|
+
}
|
|
111
|
+
throw new PnpmError('INVALID_VERSION_BUMP', 'A version argument is required. Must be a valid semver version (e.g. 1.2.3) or one of: major, minor, patch, premajor, preminor, prepatch, prerelease, from-git');
|
|
112
|
+
}
|
|
113
|
+
const gitCwd = opts.workspaceDir ?? opts.dir;
|
|
114
|
+
const explicitVersion = rawBump === 'from-git'
|
|
115
|
+
? await versionFromGit(gitCwd, opts.tagVersionPrefix)
|
|
116
|
+
: valid(rawBump);
|
|
117
|
+
if (!explicitVersion && !isBumpType(rawBump)) {
|
|
118
|
+
throw new PnpmError('INVALID_VERSION_BUMP', `Invalid version argument: ${rawBump}. Must be a valid semver version (e.g. 1.2.3) or one of: major, minor, patch, premajor, preminor, prepatch, prerelease, from-git`);
|
|
119
|
+
}
|
|
120
|
+
if (opts.gitChecks !== false && await isGitRepo({ cwd: gitCwd })) {
|
|
121
|
+
if (!await isWorkingTreeClean({ cwd: gitCwd })) {
|
|
122
|
+
throw new PnpmError('UNCLEAN_WORKING_TREE', 'Working tree is not clean. Commit or stash your changes.');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const changes = [];
|
|
126
|
+
if (opts.recursive) {
|
|
127
|
+
const pkgDirs = Object.keys(opts.selectedProjectsGraph ?? {});
|
|
128
|
+
const bumpResults = await Promise.all(pkgDirs.map(pkgDir => bumpPackageVersion(pkgDir, rawBump, explicitVersion, opts)));
|
|
129
|
+
for (const change of bumpResults) {
|
|
130
|
+
if (change) {
|
|
131
|
+
changes.push(change);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
const change = await bumpPackageVersion(opts.dir, rawBump, explicitVersion, opts);
|
|
137
|
+
if (change) {
|
|
138
|
+
changes.push(change);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (changes.length === 0) {
|
|
142
|
+
throw new PnpmError('NO_PACKAGES_TO_VERSION', 'No packages to version');
|
|
143
|
+
}
|
|
144
|
+
// In recursive mode, multiple packages can be bumped to different versions
|
|
145
|
+
// in a single run, and there is no obvious single version to tag the commit
|
|
146
|
+
// with. Skip the git commit and tag entirely in that case.
|
|
147
|
+
if (!opts.recursive && opts.gitTagVersion !== false && await isGitRepo({ cwd: gitCwd })) {
|
|
148
|
+
await commitAndTag(changes, { ...opts, cwd: gitCwd });
|
|
149
|
+
}
|
|
150
|
+
await Promise.all(changes.map(change => runVersionLifecycleHook('postversion', change, opts)));
|
|
151
|
+
if (opts.json) {
|
|
152
|
+
return JSON.stringify(changes.map(({ manifestPath: _manifestPath, ...change }) => change), null, 2);
|
|
153
|
+
}
|
|
154
|
+
let output = 'Version bumped successfully:\n';
|
|
155
|
+
for (const change of changes) {
|
|
156
|
+
output += `${change.name}: ${change.currentVersion} → ${change.newVersion}\n`;
|
|
157
|
+
}
|
|
158
|
+
return output;
|
|
159
|
+
}
|
|
160
|
+
async function releaseFromIntents(opts) {
|
|
161
|
+
const workspaceDir = opts.workspaceDir;
|
|
162
|
+
if (!workspaceDir) {
|
|
163
|
+
throw new PnpmError('WORKSPACE_ONLY', 'The bare "pnpm version -r" form consumes change intents and is only supported in a workspace');
|
|
164
|
+
}
|
|
165
|
+
if (!opts.dryRun && opts.gitChecks !== false && await isGitRepo({ cwd: workspaceDir })) {
|
|
166
|
+
if (!await isWorkingTreeClean({ cwd: workspaceDir })) {
|
|
167
|
+
throw new PnpmError('UNCLEAN_WORKING_TREE', 'Working tree is not clean. Commit or stash your changes.');
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const intents = await readChangeIntents(workspaceDir);
|
|
171
|
+
const ledger = await readLedger(workspaceDir);
|
|
172
|
+
const projects = toWorkspaceProjects(opts.allProjects ?? []);
|
|
173
|
+
const filter = (opts.filter ?? []).length > 0
|
|
174
|
+
? new Set(Object.keys(opts.selectedProjectsGraph ?? {}).map((rootDir) => toProjectDir(workspaceDir, rootDir)))
|
|
175
|
+
: undefined;
|
|
176
|
+
const baseArgs = {
|
|
177
|
+
workspaceDir,
|
|
178
|
+
projects,
|
|
179
|
+
intents,
|
|
180
|
+
ledger,
|
|
181
|
+
versioning: opts.versioning,
|
|
182
|
+
filter,
|
|
183
|
+
enforceWorkspaceProtocol: true,
|
|
184
|
+
};
|
|
185
|
+
const unpublishedDirs = await resolveUnpublishedDirs(assembleReleasePlan(baseArgs), opts);
|
|
186
|
+
const plan = assembleReleasePlan({ ...baseArgs, unpublishedDirs });
|
|
187
|
+
const applyOpts = {
|
|
188
|
+
workspaceDir,
|
|
189
|
+
projects,
|
|
190
|
+
allIntents: intents,
|
|
191
|
+
versioning: opts.versioning,
|
|
192
|
+
verifyPublished: buildVerifyPublished(opts),
|
|
193
|
+
};
|
|
194
|
+
if (plan.releases.length === 0) {
|
|
195
|
+
// A full (unfiltered) run garbage-collects the intent files an empty plan
|
|
196
|
+
// leaves behind: declined ("none"-only) intents and files a merge
|
|
197
|
+
// resurrected after every named package had already consumed them. A
|
|
198
|
+
// filtered run must not — "nothing pending in this scope" is no reason to
|
|
199
|
+
// delete prose belonging to packages outside the filter.
|
|
200
|
+
if (!opts.dryRun && filter == null) {
|
|
201
|
+
await applyReleasePlan(plan, applyOpts);
|
|
202
|
+
}
|
|
203
|
+
return 'No pending changes. Record one with "pnpm change".';
|
|
204
|
+
}
|
|
205
|
+
if (opts.dryRun) {
|
|
206
|
+
return renderReleasePlan(plan);
|
|
207
|
+
}
|
|
208
|
+
const applied = await applyReleasePlan(plan, applyOpts);
|
|
209
|
+
if (opts.json) {
|
|
210
|
+
return JSON.stringify(applied, null, 2);
|
|
211
|
+
}
|
|
212
|
+
let output = 'Versions applied:\n';
|
|
213
|
+
for (const release of applied) {
|
|
214
|
+
output += `${release.name}: ${release.currentVersion} → ${release.newVersion}\n`;
|
|
215
|
+
}
|
|
216
|
+
return output;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* In `registry` storage, the gate that lets consumed intents be collected:
|
|
220
|
+
* the release must be published and its tarball's CHANGELOG.md must already
|
|
221
|
+
* carry the composed section. Any error resolving that (offline, transient
|
|
222
|
+
* failure) counts as "not confirmed" so the intent — still the only prose —
|
|
223
|
+
* is kept. `undefined` in `repository` storage, where the committed changelog
|
|
224
|
+
* makes the ledger alone sufficient.
|
|
225
|
+
*/
|
|
226
|
+
function buildVerifyPublished(opts) {
|
|
227
|
+
if (changelogStorage(opts.versioning) !== 'registry')
|
|
228
|
+
return undefined;
|
|
229
|
+
return async (name, version, section) => {
|
|
230
|
+
try {
|
|
231
|
+
const changelog = await fetchPublishedChangelog(opts, name, version);
|
|
232
|
+
return changelog != null && changelogHasSection(changelog, section);
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function invalidVersionFromGitError(cwd, tagVersionPrefix, reason) {
|
|
240
|
+
return new PnpmError('INVALID_VERSION_FROM_GIT', `Could not determine a valid version from Git in ${JSON.stringify(cwd)} using tag prefix ${JSON.stringify(tagVersionPrefix)}: ${reason}`);
|
|
241
|
+
}
|
|
242
|
+
async function versionFromGit(cwd, tagVersionPrefix = 'v') {
|
|
243
|
+
const { stdout } = await execa('git', ['describe', '--tags', '--abbrev=0', '--always', '--match=' + tagVersionPrefix + '*.*.*'], { cwd });
|
|
244
|
+
const tag = typeof stdout === 'string' ? stdout.trim() : '';
|
|
245
|
+
const { stdout: matchingTag } = await execa('git', ['tag', '--list', '--', tag], { cwd });
|
|
246
|
+
if (typeof matchingTag !== 'string' || matchingTag.trim() !== tag) {
|
|
247
|
+
throw invalidVersionFromGitError(cwd, tagVersionPrefix, 'no matching Git tag found');
|
|
248
|
+
}
|
|
249
|
+
const version = tag.startsWith(tagVersionPrefix)
|
|
250
|
+
? valid(tag.slice(tagVersionPrefix.length))
|
|
251
|
+
: null;
|
|
252
|
+
if (!version) {
|
|
253
|
+
throw invalidVersionFromGitError(cwd, tagVersionPrefix, 'tag is not a valid version: ' + JSON.stringify(tag));
|
|
254
|
+
}
|
|
255
|
+
return version;
|
|
256
|
+
}
|
|
257
|
+
async function bumpPackageVersion(pkgDir, rawBump, explicitVersion, opts) {
|
|
258
|
+
const { manifest, writeProjectManifest, fileName } = await readProjectManifest(pkgDir);
|
|
259
|
+
if (!manifest.name || !manifest.version) {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
const currentVersion = manifest.version;
|
|
263
|
+
if (!valid(currentVersion)) {
|
|
264
|
+
throw new PnpmError('INVALID_VERSION', `Invalid version in ${pkgDir}: ${currentVersion}`);
|
|
265
|
+
}
|
|
266
|
+
const preVersionChange = {
|
|
267
|
+
name: manifest.name,
|
|
268
|
+
currentVersion,
|
|
269
|
+
newVersion: currentVersion,
|
|
270
|
+
path: pkgDir,
|
|
271
|
+
manifestPath: path.join(pkgDir, fileName),
|
|
272
|
+
};
|
|
273
|
+
await runVersionLifecycleHook('preversion', preVersionChange, opts);
|
|
274
|
+
const newVersion = explicitVersion ?? inc(currentVersion, rawBump, false, opts.preid);
|
|
275
|
+
if (!newVersion) {
|
|
276
|
+
throw new PnpmError('VERSION_BUMP_FAILED', `Failed to bump version from ${currentVersion} using ${rawBump}`);
|
|
277
|
+
}
|
|
278
|
+
if (newVersion === currentVersion && !opts.allowSameVersion) {
|
|
279
|
+
throw new PnpmError('VERSION_NOT_CHANGED', `Version was not changed: ${currentVersion}`);
|
|
280
|
+
}
|
|
281
|
+
manifest.version = newVersion;
|
|
282
|
+
await writeProjectManifest(manifest);
|
|
283
|
+
const change = {
|
|
284
|
+
name: manifest.name,
|
|
285
|
+
currentVersion,
|
|
286
|
+
newVersion,
|
|
287
|
+
path: pkgDir,
|
|
288
|
+
manifestPath: path.join(pkgDir, fileName),
|
|
289
|
+
};
|
|
290
|
+
await runVersionLifecycleHook('version', change, opts);
|
|
291
|
+
return change;
|
|
292
|
+
}
|
|
293
|
+
async function runVersionLifecycleHook(stage, change, opts) {
|
|
294
|
+
if (opts.ignoreScripts === true)
|
|
295
|
+
return;
|
|
296
|
+
const { manifest } = await readProjectManifest(change.path);
|
|
297
|
+
const lifecycleOpts = {
|
|
298
|
+
depPath: change.name,
|
|
299
|
+
extraBinPaths: opts.extraBinPaths,
|
|
300
|
+
extraEnv: opts.extraEnv,
|
|
301
|
+
initCwd: opts.dir,
|
|
302
|
+
pkgRoot: change.path,
|
|
303
|
+
rootModulesDir: path.join(change.path, opts.modulesDir ?? 'node_modules'),
|
|
304
|
+
scriptShell: opts.scriptShell,
|
|
305
|
+
scriptsPrependNodePath: opts.scriptsPrependNodePath,
|
|
306
|
+
shellEmulator: opts.shellEmulator,
|
|
307
|
+
stdio: 'inherit',
|
|
308
|
+
unsafePerm: opts.unsafePerm ?? false,
|
|
309
|
+
userAgent: opts.userAgent,
|
|
310
|
+
};
|
|
311
|
+
await runLifecycleHook(stage, manifest, lifecycleOpts);
|
|
312
|
+
}
|
|
313
|
+
async function commitAndTag(changes, opts) {
|
|
314
|
+
const resolvedCwd = path.resolve(opts.cwd);
|
|
315
|
+
const [change] = changes;
|
|
316
|
+
const rawMessage = opts.message ?? '%s';
|
|
317
|
+
const message = rawMessage.replace(/%s/g, change.newVersion);
|
|
318
|
+
const tagPrefix = opts.tagVersionPrefix ?? 'v';
|
|
319
|
+
const tagName = `${tagPrefix}${change.newVersion}`;
|
|
320
|
+
const execOpts = { cwd: opts.cwd };
|
|
321
|
+
const resolvedManifestPath = path.resolve(change.manifestPath);
|
|
322
|
+
const relativeManifestPath = path.relative(resolvedCwd, resolvedManifestPath);
|
|
323
|
+
if (relativeManifestPath === '' ||
|
|
324
|
+
path.isAbsolute(relativeManifestPath) ||
|
|
325
|
+
relativeManifestPath.startsWith(`..${path.sep}`) ||
|
|
326
|
+
relativeManifestPath === '..') {
|
|
327
|
+
throw new PnpmError('INVALID_MANIFEST_PATH', `Cannot stage manifest outside of git cwd: ${change.manifestPath}`);
|
|
328
|
+
}
|
|
329
|
+
const manifestPath = relativeManifestPath.split(path.sep).join('/');
|
|
330
|
+
await execa('git', ['add', manifestPath], execOpts);
|
|
331
|
+
const commitArgs = ['commit', '-m', message];
|
|
332
|
+
if (opts.commitHooks === false) {
|
|
333
|
+
commitArgs.push('--no-verify');
|
|
334
|
+
}
|
|
335
|
+
// writeProjectManifest skips writing when the new content matches the existing
|
|
336
|
+
// file, so an --allow-same-version run can leave nothing staged and fail the
|
|
337
|
+
// commit. Pass --allow-empty in that case to let the tag point at the current
|
|
338
|
+
// HEAD as a deliberate marker.
|
|
339
|
+
if (opts.allowSameVersion) {
|
|
340
|
+
commitArgs.push('--allow-empty');
|
|
341
|
+
}
|
|
342
|
+
await execa('git', commitArgs, execOpts);
|
|
343
|
+
const tagArgs = ['tag'];
|
|
344
|
+
if (opts.signGitTag) {
|
|
345
|
+
tagArgs.push('-s');
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
tagArgs.push('-a');
|
|
349
|
+
}
|
|
350
|
+
tagArgs.push(tagName, '-m', message);
|
|
351
|
+
await execa('git', tagArgs, execOpts);
|
|
352
|
+
}
|
|
353
|
+
export const version = {
|
|
354
|
+
handler,
|
|
355
|
+
help,
|
|
356
|
+
commandNames,
|
|
357
|
+
cliOptionsTypes,
|
|
358
|
+
rcOptionsTypes,
|
|
359
|
+
};
|
|
360
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/releasing.commands",
|
|
3
|
-
"version": "1100.
|
|
3
|
+
"version": "1100.7.1",
|
|
4
4
|
"description": "Commands for deploy, pack, and publish",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -28,42 +28,42 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@inquirer/prompts": "^8.4.3",
|
|
31
|
-
"@pnpm/bins.resolver": "1100.0.
|
|
32
|
-
"@pnpm/catalogs.types": "1100.0.
|
|
33
|
-
"@pnpm/cli.common-cli-options-help": "1100.0.
|
|
34
|
-
"@pnpm/cli.utils": "1101.0.
|
|
35
|
-
"@pnpm/config.pick-registry-for-package": "1100.0.
|
|
36
|
-
"@pnpm/config.reader": "1101.
|
|
37
|
-
"@pnpm/constants": "1100.0.
|
|
38
|
-
"@pnpm/deps.path": "1100.0.
|
|
39
|
-
"@pnpm/engine.runtime.commands": "1100.1.
|
|
40
|
-
"@pnpm/engine.runtime.node-resolver": "1101.1.
|
|
41
|
-
"@pnpm/error": "1100.0
|
|
42
|
-
"@pnpm/exec.lifecycle": "1100.1.
|
|
43
|
-
"@pnpm/exec.pnpm-cli-runner": "1100.0.
|
|
44
|
-
"@pnpm/fetching.directory-fetcher": "1100.0.
|
|
45
|
-
"@pnpm/fetching.types": "1100.0.
|
|
46
|
-
"@pnpm/fs.indexed-pkg-importer": "1100.0.
|
|
47
|
-
"@pnpm/fs.is-empty-dir-or-nothing": "1100.0.
|
|
48
|
-
"@pnpm/fs.packlist": "1100.0.
|
|
49
|
-
"@pnpm/installing.client": "1100.2.
|
|
50
|
-
"@pnpm/installing.commands": "1100.
|
|
51
|
-
"@pnpm/lockfile.fs": "1100.1.
|
|
52
|
-
"@pnpm/lockfile.types": "1100.0.
|
|
53
|
-
"@pnpm/network.auth-header": "1101.1.
|
|
54
|
-
"@pnpm/network.fetch": "1100.1.
|
|
55
|
-
"@pnpm/network.git-utils": "1100.0.
|
|
56
|
-
"@pnpm/network.web-auth": "1101.
|
|
31
|
+
"@pnpm/bins.resolver": "1100.0.11",
|
|
32
|
+
"@pnpm/catalogs.types": "1100.0.1",
|
|
33
|
+
"@pnpm/cli.common-cli-options-help": "1100.0.3",
|
|
34
|
+
"@pnpm/cli.utils": "1101.0.19",
|
|
35
|
+
"@pnpm/config.pick-registry-for-package": "1100.0.12",
|
|
36
|
+
"@pnpm/config.reader": "1101.14.0",
|
|
37
|
+
"@pnpm/constants": "1100.0.1",
|
|
38
|
+
"@pnpm/deps.path": "1100.0.11",
|
|
39
|
+
"@pnpm/engine.runtime.commands": "1100.1.16",
|
|
40
|
+
"@pnpm/engine.runtime.node-resolver": "1101.1.18",
|
|
41
|
+
"@pnpm/error": "1100.1.0",
|
|
42
|
+
"@pnpm/exec.lifecycle": "1100.1.8",
|
|
43
|
+
"@pnpm/exec.pnpm-cli-runner": "1100.0.2",
|
|
44
|
+
"@pnpm/fetching.directory-fetcher": "1100.0.25",
|
|
45
|
+
"@pnpm/fetching.types": "1100.0.3",
|
|
46
|
+
"@pnpm/fs.indexed-pkg-importer": "1100.0.21",
|
|
47
|
+
"@pnpm/fs.is-empty-dir-or-nothing": "1100.0.1",
|
|
48
|
+
"@pnpm/fs.packlist": "1100.0.4",
|
|
49
|
+
"@pnpm/installing.client": "1100.2.20",
|
|
50
|
+
"@pnpm/installing.commands": "1100.12.0",
|
|
51
|
+
"@pnpm/lockfile.fs": "1100.1.14",
|
|
52
|
+
"@pnpm/lockfile.types": "1100.0.16",
|
|
53
|
+
"@pnpm/network.auth-header": "1101.1.6",
|
|
54
|
+
"@pnpm/network.fetch": "1100.1.8",
|
|
55
|
+
"@pnpm/network.git-utils": "1100.0.3",
|
|
56
|
+
"@pnpm/network.web-auth": "1101.3.0",
|
|
57
57
|
"@pnpm/npm-package-arg": "^2.0.0",
|
|
58
|
-
"@pnpm/releasing.exportable-manifest": "1100.1.
|
|
59
|
-
"@pnpm/releasing.versioning": "1100.1
|
|
60
|
-
"@pnpm/resolving.npm-resolver": "1102.1.
|
|
61
|
-
"@pnpm/resolving.registry.types": "1100.1.
|
|
62
|
-
"@pnpm/resolving.resolver-base": "1100.5.
|
|
63
|
-
"@pnpm/types": "1101.
|
|
64
|
-
"@pnpm/workspace.projects-filter": "1100.0.
|
|
65
|
-
"@pnpm/workspace.projects-sorter": "1100.0.
|
|
66
|
-
"@pnpm/workspace.workspace-manifest-writer": "1100.0.
|
|
58
|
+
"@pnpm/releasing.exportable-manifest": "1100.1.15",
|
|
59
|
+
"@pnpm/releasing.versioning": "1100.2.1",
|
|
60
|
+
"@pnpm/resolving.npm-resolver": "1102.1.8",
|
|
61
|
+
"@pnpm/resolving.registry.types": "1100.1.6",
|
|
62
|
+
"@pnpm/resolving.resolver-base": "1100.5.4",
|
|
63
|
+
"@pnpm/types": "1101.6.0",
|
|
64
|
+
"@pnpm/workspace.projects-filter": "1100.0.32",
|
|
65
|
+
"@pnpm/workspace.projects-sorter": "1100.0.11",
|
|
66
|
+
"@pnpm/workspace.workspace-manifest-writer": "1100.0.18",
|
|
67
67
|
"@types/normalize-path": "^3.0.2",
|
|
68
68
|
"@zkochan/rimraf": "^4.0.0",
|
|
69
69
|
"chalk": "^5.6.2",
|
|
@@ -93,16 +93,16 @@
|
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
95
|
"@jest/globals": "30.4.1",
|
|
96
|
-
"@pnpm/assert-project": "1100.0.
|
|
97
|
-
"@pnpm/catalogs.config": "1100.0.
|
|
98
|
-
"@pnpm/hooks.pnpmfile": "1100.0.
|
|
96
|
+
"@pnpm/assert-project": "1100.0.22",
|
|
97
|
+
"@pnpm/catalogs.config": "1100.0.3",
|
|
98
|
+
"@pnpm/hooks.pnpmfile": "1100.0.22",
|
|
99
99
|
"@pnpm/logger": "1100.0.0",
|
|
100
|
-
"@pnpm/prepare": "1100.0.
|
|
101
|
-
"@pnpm/releasing.commands": "1100.
|
|
102
|
-
"@pnpm/test-fixtures": "1100.0.
|
|
100
|
+
"@pnpm/prepare": "1100.0.22",
|
|
101
|
+
"@pnpm/releasing.commands": "1100.7.1",
|
|
102
|
+
"@pnpm/test-fixtures": "1100.0.1",
|
|
103
103
|
"@pnpm/test-ipc-server": "1100.0.0",
|
|
104
|
-
"@pnpm/testing.command-defaults": "1100.0.
|
|
105
|
-
"@pnpm/testing.registry-mock": "1100.0.
|
|
104
|
+
"@pnpm/testing.command-defaults": "1100.0.11",
|
|
105
|
+
"@pnpm/testing.registry-mock": "1100.0.11",
|
|
106
106
|
"@types/cross-spawn": "^6.0.6",
|
|
107
107
|
"@types/is-windows": "^1.0.2",
|
|
108
108
|
"@types/libnpmpublish": "^11.2.0",
|