bulk-release 2.21.1 → 3.0.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 +22 -0
- package/README.md +98 -26
- package/package.json +1 -1
- package/src/main/js/index.js +1 -1
- package/src/main/js/{processor → post}/api/gh.js +0 -27
- package/src/main/js/{processor → post}/api/git.js +2 -10
- package/src/main/js/{processor → post}/api/npm.js +4 -2
- package/src/main/js/post/courier/channels/changelog.js +29 -0
- package/src/main/js/{processor/publishers → post/courier/channels}/cmd.js +1 -0
- package/src/main/js/post/courier/channels/gh-pages.js +30 -0
- package/src/main/js/post/courier/channels/gh-release.js +35 -0
- package/src/main/js/post/courier/channels/meta.js +34 -0
- package/src/main/js/post/courier/channels/npm.js +26 -0
- package/src/main/js/post/courier/index.js +113 -0
- package/src/main/js/post/courier/parcel.js +77 -0
- package/src/main/js/{processor → post/depot}/exec.js +2 -2
- package/src/main/js/{processor → post/depot}/generators/meta.js +3 -3
- package/src/main/js/{processor → post/depot}/generators/notes.js +1 -1
- package/src/main/js/{processor → post/depot}/steps/analyze.js +2 -2
- package/src/main/js/{processor → post/depot}/steps/build.js +2 -2
- package/src/main/js/{processor → post/depot}/steps/clean.js +2 -2
- package/src/main/js/{processor → post/depot}/steps/contextify.js +3 -3
- package/src/main/js/post/depot/steps/pack.js +59 -0
- package/src/main/js/post/depot/steps/publish.js +29 -0
- package/src/main/js/{processor → post/depot}/steps/test.js +1 -1
- package/src/main/js/{processor → post}/release.js +44 -37
- package/src/main/js/post/tar.js +73 -0
- package/src/test/js/utils/mock.js +1 -1
- package/src/main/js/processor/publishers/changelog.js +0 -26
- package/src/main/js/processor/publishers/gh-pages.js +0 -32
- package/src/main/js/processor/publishers/gh-release.js +0 -41
- package/src/main/js/processor/publishers/meta.js +0 -58
- package/src/main/js/processor/publishers/npm.js +0 -15
- package/src/main/js/processor/steps/publish.js +0 -39
- package/src/main/js/processor/steps/teardown.js +0 -58
- /package/src/main/js/{processor → post/depot}/deps.js +0 -0
- /package/src/main/js/{processor → post/depot}/generators/tag.js +0 -0
- /package/src/main/js/{processor → post}/log.js +0 -0
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import {memoizeBy} from '../../util.js'
|
|
2
|
-
import {exec} from '../exec.js'
|
|
3
|
-
import {log} from '../log.js'
|
|
4
|
-
import {npmPersist} from '../api/npm.js'
|
|
5
|
-
import {pushTag} from '../api/git.js'
|
|
6
|
-
import {formatTag} from '../generators/tag.js'
|
|
7
|
-
import {isNpmPublished} from '../publishers/npm.js'
|
|
8
|
-
import {rollbackRelease} from './teardown.js'
|
|
9
|
-
|
|
10
|
-
const pushReleaseTag = async (pkg, ctx) => {
|
|
11
|
-
const {name, version, tag = formatTag({name, version}), config: {gitCommitterEmail, gitCommitterName}} = pkg
|
|
12
|
-
ctx.git.tag = tag
|
|
13
|
-
log.info(`push release tag ${tag}`)
|
|
14
|
-
await pushTag({cwd: ctx.git.root, tag, gitCommitterEmail, gitCommitterName})
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const publish = memoizeBy(async (pkg, ctx = pkg.ctx) => {
|
|
18
|
-
if (pkg.version !== pkg.manifest.version)
|
|
19
|
-
throw new Error('package.json version not synced')
|
|
20
|
-
|
|
21
|
-
const {run = exec, publishers = [], flags} = ctx
|
|
22
|
-
const snapshot = !!flags.snapshot
|
|
23
|
-
const active = publishers.filter(p => (!snapshot || p.snapshot) && p.when(pkg))
|
|
24
|
-
|
|
25
|
-
await npmPersist(pkg)
|
|
26
|
-
|
|
27
|
-
// Prepare phase: serial pkg mutations (e.g. meta injects into ghAssets) — must finish before any run().
|
|
28
|
-
for (const p of active) await p.prepare?.(pkg)
|
|
29
|
-
|
|
30
|
-
if (!snapshot) await pushReleaseTag(pkg, ctx)
|
|
31
|
-
try {
|
|
32
|
-
await Promise.all(active.map(p => p.run(pkg, run)))
|
|
33
|
-
} catch (e) {
|
|
34
|
-
// Roll back full release for npm-published packages; git-tag-only packages keep their tag — it IS the release.
|
|
35
|
-
if (!snapshot && isNpmPublished(pkg)) await rollbackRelease(pkg, ctx)
|
|
36
|
-
throw e
|
|
37
|
-
}
|
|
38
|
-
pkg.published = true
|
|
39
|
-
})
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// Release teardown: undo a published (or half-published) release.
|
|
2
|
-
//
|
|
3
|
-
// Two entry points share the same core:
|
|
4
|
-
// - rollbackRelease: called inline from publish.js on mid-publish failure (tag known from pkg.ctx).
|
|
5
|
-
// - recover: standalone --recover mode — detect orphan tags (tagged but missing on npm) and tear them down.
|
|
6
|
-
//
|
|
7
|
-
// Teardown walks the publishers registry in reverse and calls undo() on each that applies.
|
|
8
|
-
|
|
9
|
-
import {log} from '../log.js'
|
|
10
|
-
import {deleteRemoteTag} from '../api/git.js'
|
|
11
|
-
import {fetchManifest} from '../api/npm.js'
|
|
12
|
-
import {isNpmPublished} from '../publishers/npm.js'
|
|
13
|
-
|
|
14
|
-
// Tear down a release: undo every applicable publisher, then delete the git tag.
|
|
15
|
-
// Failures in individual undo steps are warned, not thrown — teardown is best-effort.
|
|
16
|
-
const teardownRelease = async (pkg, ctx, {tag, version, reason}) => {
|
|
17
|
-
if (!pkg.config.ghBasicAuth) throw new Error(`${reason} requires git credentials (GH_TOKEN)`)
|
|
18
|
-
|
|
19
|
-
for (const p of [...ctx.publishers].reverse()) {
|
|
20
|
-
if (!p.undo || !p.when(pkg)) continue
|
|
21
|
-
try {
|
|
22
|
-
const result = await p.undo(pkg, {tag, version, reason})
|
|
23
|
-
if (result !== false) log.info(`${reason}: ${p.name} undone for '${tag}'`)
|
|
24
|
-
} catch (e) {
|
|
25
|
-
log.warn(`${reason}: ${p.name} undo failed`, e)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
await deleteRemoteTag({cwd: ctx.git.root, tag})
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Rollback a release that failed mid-publish (called inline from publish.js).
|
|
33
|
-
// Uses the current release tag; skips the npm existence check — we already know it failed.
|
|
34
|
-
export const rollbackRelease = async (pkg, ctx = pkg.ctx) => {
|
|
35
|
-
const tag = ctx.git.tag
|
|
36
|
-
if (!tag) return
|
|
37
|
-
log.info(`rollback: cleaning up failed release for tag '${tag}'`)
|
|
38
|
-
await teardownRelease(pkg, ctx, {tag, version: pkg.version, reason: 'rollback'})
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Standalone recovery: if a tag exists but the package is missing from npm, treat it as an orphan and tear down.
|
|
42
|
-
export const recover = async (pkg, ctx = pkg.ctx) => {
|
|
43
|
-
if (!isNpmPublished(pkg)) return false
|
|
44
|
-
|
|
45
|
-
const {tag} = pkg.latest
|
|
46
|
-
if (!tag) return false
|
|
47
|
-
|
|
48
|
-
const manifest = await fetchManifest({
|
|
49
|
-
name: pkg.name,
|
|
50
|
-
version: tag.version,
|
|
51
|
-
config: pkg.config,
|
|
52
|
-
}, {nothrow: true})
|
|
53
|
-
if (manifest) return false
|
|
54
|
-
|
|
55
|
-
log.info(`recover: tag '${tag.ref}' exists but ${pkg.name}@${tag.version} not found on npm, rolling back failed release`)
|
|
56
|
-
await teardownRelease(pkg, ctx, {tag: tag.ref, version: tag.version, reason: 'recover'})
|
|
57
|
-
return true
|
|
58
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|