bulk-release 2.15.31 → 2.15.33

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 CHANGED
@@ -1,3 +1,13 @@
1
+ ## [2.15.33](https://github.com/semrel-extra/zx-bulk-release/compare/v2.15.32...v2.15.33) (2025-09-17)
2
+
3
+ ### Fixes & improvements
4
+ * fix(deps): update dependency zx-extra to v4.0.15 (#68) ([2844bae](https://github.com/semrel-extra/zx-bulk-release/commit/2844bae128f729c22beaee308069ddf0697ca60a))
5
+
6
+ ## [2.15.32](https://github.com/semrel-extra/zx-bulk-release/compare/v2.15.31...v2.15.32) (2025-09-05)
7
+
8
+ ### Fixes & improvements
9
+ * perf: update zx-extra to v4.0.14 ([913d23d](https://github.com/semrel-extra/zx-bulk-release/commit/913d23df054fa44dcc83b75f578a59a9d8ce03fb))
10
+
1
11
  ## [2.15.31](https://github.com/semrel-extra/zx-bulk-release/compare/v2.15.30...v2.15.31) (2025-02-07)
2
12
 
3
13
  ### Fixes & improvements
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bulk-release",
3
3
  "alias": "bulk-release",
4
- "version": "2.15.31",
4
+ "version": "2.15.33",
5
5
  "description": "zx-based alternative for multi-semantic-release",
6
6
  "type": "module",
7
7
  "exports": {
@@ -18,8 +18,8 @@
18
18
  "README.md"
19
19
  ],
20
20
  "scripts": {
21
- "test": "NPM_REGISTRY='http://localhost:4873' NPM_TOKEN='mRv6eIuiaggXGb9ZDFCtBA==' c8 uvu ./src/test -i fixtures -i utils && c8 report -r lcov",
22
- "test:it": "NPM_REGISTRY='http://localhost:4873' NPM_TOKEN='mRv6eIuiaggXGb9ZDFCtBA==' node ./src/test/js/integration.test.js",
21
+ "test": "c8 uvu ./src/test -i fixtures -i utils && c8 report -r lcov",
22
+ "test:it": "node ./src/test/js/integration.test.js",
23
23
  "docs": "mkdir -p docs && cp ./README.md ./docs/README.md",
24
24
  "publish:beta": "npm publish --tag beta --no-git-tag-version",
25
25
  "build": "esbuild src/main/js/index.js --platform=node --outdir=target --bundle --format=esm --external:typescript"
@@ -29,13 +29,13 @@
29
29
  "cosmiconfig": "^9.0.0",
30
30
  "queuefy": "^1.2.1",
31
31
  "tar-stream": "^3.1.7",
32
- "zx-extra": "3.0.29"
32
+ "zx-extra": "4.0.15"
33
33
  },
34
34
  "devDependencies": {
35
- "c8": "^10.1.2",
36
- "esbuild": "^0.24.0",
35
+ "c8": "^10.1.3",
36
+ "esbuild": "^0.25.9",
37
37
  "uvu": "^0.5.6",
38
- "verdaccio": "^6.0.0"
38
+ "verdaccio": "6.1.6"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
@@ -17,7 +17,7 @@ export const pushChangelog = queuefy(async (pkg) => {
17
17
  const msg = msgJoin(_msg, pkg, 'chore: update changelog ${{name}}')
18
18
  const releaseNotes = await formatReleaseNotes(pkg)
19
19
 
20
- await $.o({cwd: _cwd})`echo ${releaseNotes}"\n$(cat ./${file})" > ./${file}`
20
+ await $({cwd: _cwd})`echo ${releaseNotes}"\n$(cat ./${file})" > ./${file}`
21
21
  await pushCommit({cwd, branch, msg, gitCommitterEmail, gitCommitterName, basicAuth})
22
22
  })
23
23
 
@@ -123,7 +123,7 @@ export const ghUploadAssets = async ({ghToken, ghAssets, uploadUrl, cwd}) => {
123
123
  }
124
124
 
125
125
  export const ghGetAsset = async ({repoName, tag, name}) => {
126
- return (await fetch(`https://github.com/${repoName}/releases/download/${tag}/${name}`, {
126
+ return (await fetch(`https://github.com/${repoName}/releases/download/${tag.ref || tag}/${name}`, {
127
127
  headers: {
128
128
  // Accept: 'application/vnd.github.v3+json'
129
129
  }
@@ -1,27 +1,27 @@
1
- import {$, ctx, fs, path, tempy, copy} from 'zx-extra'
1
+ import {$, fs, path, tempy, copy} from 'zx-extra'
2
2
  import {log} from '../log.js'
3
3
  import {memoizeBy} from '../util.js'
4
4
 
5
- export const fetchRepo = memoizeBy(async ({cwd: _cwd, branch, origin: _origin, basicAuth}) => ctx(async ($) => {
5
+ export const fetchRepo = memoizeBy(async ({cwd: _cwd, branch, origin: _origin, basicAuth}) => {
6
6
  const origin = _origin || (await getRepo(_cwd, {basicAuth})).repoAuthedUrl
7
7
  const cwd = tempy.temporaryDirectory()
8
- $.cwd = cwd
8
+ const _$ = $({cwd})
9
9
  try {
10
- await $`git clone --single-branch --branch ${branch} --depth 1 ${origin} .`
10
+ await _$`git clone --single-branch --branch ${branch} --depth 1 ${origin} .`
11
11
  } catch (e) {
12
12
  log({level: 'warn'})(`ref '${branch}' does not exist in ${origin}`)
13
- await $`git init . &&
13
+ await _$`git init . &&
14
14
  git remote add origin ${origin}`
15
15
  }
16
16
 
17
17
  return cwd
18
- }), async ({cwd, branch}) => `${await getRoot(cwd)}:${branch}`)
18
+ }, async ({cwd, branch}) => `${await getRoot(cwd)}:${branch}`)
19
19
 
20
- export const pushCommit = async ({cwd, from, to, branch, origin, msg, ignoreFiles, files = [], basicAuth, gitCommitterEmail, gitCommitterName}) => ctx(async ($) => {
20
+ export const pushCommit = async ({cwd, from, to, branch, origin, msg, ignoreFiles, files = [], basicAuth, gitCommitterEmail, gitCommitterName}) => {
21
21
  let retries = 3
22
22
 
23
23
  const _cwd = await fetchRepo({cwd, branch, origin, basicAuth})
24
- $.cwd = _cwd
24
+ const _$ = $({cwd: _cwd})
25
25
 
26
26
  for (let {relpath, contents} of files) {
27
27
  const _contents = typeof contents === 'string' ? contents : JSON.stringify(contents, null, 2)
@@ -31,7 +31,7 @@ export const pushCommit = async ({cwd, from, to, branch, origin, msg, ignoreFile
31
31
 
32
32
  try {
33
33
  await setUserConfig(_cwd, gitCommitterName, gitCommitterEmail)
34
- await $`git add . &&
34
+ await _$`git add . &&
35
35
  git commit -m ${msg}`
36
36
  } catch {
37
37
  log({level: 'warn'})(`no changes to commit to ${branch}`)
@@ -40,7 +40,7 @@ export const pushCommit = async ({cwd, from, to, branch, origin, msg, ignoreFile
40
40
 
41
41
  while (retries > 0) {
42
42
  try {
43
- return await $.raw`git push origin HEAD:refs/heads/${branch}`
43
+ return await _$`git push origin HEAD:refs/heads/${branch}`
44
44
  } catch (e) {
45
45
  retries -= 1
46
46
  log({level: 'error'})('git push failed', 'branch', branch, 'retries left', retries, e)
@@ -49,15 +49,15 @@ export const pushCommit = async ({cwd, from, to, branch, origin, msg, ignoreFile
49
49
  throw e
50
50
  }
51
51
 
52
- await $`git fetch origin ${branch} &&
52
+ await _$`git fetch origin ${branch} &&
53
53
  git rebase origin/${branch}`
54
54
  }
55
55
  }
56
- })
56
+ }
57
57
 
58
- export const getSha = async (cwd) => (await $.o({cwd})`git rev-parse HEAD`).toString().trim()
58
+ export const getSha = async (cwd) => (await $({cwd})`git rev-parse HEAD`).toString().trim()
59
59
 
60
- export const getRoot = memoizeBy(async (cwd) => (await $.o({cwd})`git rev-parse --show-toplevel`).toString().trim())
60
+ export const getRoot = memoizeBy(async (cwd) => (await $({cwd})`git rev-parse --show-toplevel`).toString().trim())
61
61
 
62
62
  export const parseOrigin = (originUrl) => {
63
63
  const [, , repoHost, repoName] = originUrl.replace(':', '/').replace(/\.git/, '').match(/.+(@|\/\/)([^/]+)\/(.+)$/) || []
@@ -83,16 +83,16 @@ export const getRepo = memoizeBy(async (cwd, {basicAuth} = {}) => {
83
83
  }, getRoot)
84
84
 
85
85
  export const getOrigin = memoizeBy(async (cwd) =>
86
- $.o({cwd})`git config --get remote.origin.url`.then(r => r.toString().trim())
86
+ $({cwd})`git config --get remote.origin.url`.then(r => r.toString().trim())
87
87
  )
88
88
 
89
- export const getCommits = async (cwd, from, to = 'HEAD') => ctx(async ($) => {
90
- $.cwd = cwd
89
+ export const getCommits = async (cwd, from, to = 'HEAD') => {
90
+ const _$ = $({cwd})
91
91
 
92
- const _from = from || await $`git rev-list --max-parents=0 HEAD`
92
+ const _from = from || await _$`git rev-list --max-parents=0 HEAD`
93
93
  const ref = `${_from}..${to}`
94
94
 
95
- return (await $.raw`git log ${ref} --format=+++%s__%b__%h__%H -- ${cwd}`)
95
+ return (await _$`git log ${ref} --format=+++%s__%b__%h__%H -- ${cwd}`)
96
96
  .toString()
97
97
  .split('+++')
98
98
  .filter(Boolean)
@@ -100,27 +100,27 @@ export const getCommits = async (cwd, from, to = 'HEAD') => ctx(async ($) => {
100
100
  const [subj, body, short, hash] = msg.split('__').map(raw => raw.trim())
101
101
  return {subj, body, short, hash}
102
102
  })
103
- })
103
+ }
104
104
 
105
- export const getTags = async (cwd, ref = '') =>
106
- (await $.o({cwd})`git tag -l ${ref}`)
105
+ export const getTags = async (cwd, ref) =>
106
+ (await $({cwd})`git tag -l ${ref || '*'}`)
107
107
  .toString()
108
108
  .split('\n')
109
109
 
110
110
  export const pushTag = async ({cwd, tag, gitCommitterName, gitCommitterEmail}) => {
111
111
  await setUserConfig(cwd, gitCommitterName, gitCommitterEmail)
112
- await $.o({cwd})`
112
+ await $({cwd})`
113
113
  git tag -m ${tag} ${tag} &&
114
114
  git push origin ${tag}`
115
115
  }
116
116
 
117
117
  // Memoize prevents .git/config lock
118
118
  // https://github.com/qiwi/packasso/actions/runs/4539987310/jobs/8000403413#step:7:282
119
- export const setUserConfig = memoizeBy(async(cwd, gitCommitterName, gitCommitterEmail) => $.o({cwd})`
119
+ export const setUserConfig = memoizeBy(async(cwd, gitCommitterName, gitCommitterEmail) => $({cwd})`
120
120
  git config user.name ${gitCommitterName} &&
121
121
  git config user.email ${gitCommitterEmail}
122
122
  `)
123
123
 
124
- export const unsetUserConfig = async(cwd) => $.o({cwd, nothrow: true})`
124
+ export const unsetUserConfig = async(cwd) => $({cwd, nothrow: true})`
125
125
  git config --unset user.name &&
126
126
  git config --unset user.email`
@@ -73,8 +73,16 @@ export const npmPublish = async (pkg) => {
73
73
 
74
74
  const npmTag = pkg.preversion ? 'snapshot' : 'latest'
75
75
  const npmrc = await getNpmrc({npmConfig, npmToken, npmRegistry})
76
-
77
- await $.o({cwd})`npm publish ${npmProvenance ? '--provenance' : ''} --no-git-tag-version --registry=${npmRegistry} --userconfig ${npmrc} --tag ${npmTag} --no-workspaces`
76
+ const npmFlags = [
77
+ '--no-workspaces',
78
+ '--no-git-tag-version',
79
+ `--userconfig=${npmrc}`,
80
+ `--tag=${npmTag}`,
81
+ npmProvenance && `--provenance`,
82
+ npmRegistry && `--registry=${npmRegistry}`,
83
+ ].filter(Boolean)
84
+
85
+ await $({cwd})`npm publish ${npmFlags}`
78
86
  }
79
87
 
80
88
  export const getNpmrc = async ({npmConfig, npmToken, npmRegistry}) => {
@@ -1,5 +1,5 @@
1
1
  import { cosmiconfig } from 'cosmiconfig'
2
- import { camelize, memoizeBy } from './util.js'
2
+ import { asArray, camelize, memoizeBy } from './util.js'
3
3
 
4
4
  const CONFIG_NAME = 'release'
5
5
  const CONFIG_FILES = [
@@ -24,8 +24,8 @@ export const defaultConfig = {
24
24
  // ghPages: 'gh-pages'
25
25
  }
26
26
 
27
- export const getPkgConfig = async (...cwds) =>
28
- normalizePkgConfig((await Promise.all(cwds.map(readPkgConfig))).find(Boolean) || defaultConfig)
27
+ export const getPkgConfig = async (cwd, env) =>
28
+ normalizePkgConfig((await Promise.all(asArray(cwd).map(readPkgConfig))).find(Boolean) || defaultConfig, env)
29
29
 
30
30
  export const readPkgConfig = memoizeBy(async (cwd) => cosmiconfig(CONFIG_NAME, {
31
31
  searchPlaces: CONFIG_FILES,
@@ -34,17 +34,20 @@ export const readPkgConfig = memoizeBy(async (cwd) => cosmiconfig(CONFIG_NAME, {
34
34
  .search(cwd)
35
35
  .then(r => r?.config))
36
36
 
37
- export const normalizePkgConfig = (config, env) => ({
38
- ...parseEnv(env),
39
- ...config,
40
- releaseRules: config.releaseRules || config.semanticRules,
41
- npmFetch: config.npmFetch || config.fetch || config.fetchPkg,
42
- buildCmd: config.buildCmd || config.cmd,
43
- get ghBasicAuth() {
44
- return this.ghUser && this.ghToken ? `${this.ghUser}:${this.ghToken}` : false
45
- },
46
- meta: normalizeMetaConfig(config.meta)
47
- })
37
+ export const normalizePkgConfig = (config, env) => {
38
+ const envConfig = parseEnv(env)
39
+ return {
40
+ ...envConfig,
41
+ ...config,
42
+ releaseRules: config.releaseRules || config.semanticRules,
43
+ npmFetch: config.npmFetch || config.fetch || config.fetchPkg,
44
+ buildCmd: config.buildCmd || config.cmd,
45
+ get ghBasicAuth() {
46
+ return this.ghUser && this.ghToken ? `${this.ghUser}:${this.ghToken}` : false
47
+ },
48
+ meta: normalizeMetaConfig(config.meta || envConfig.ghMeta)
49
+ }
50
+ }
48
51
 
49
52
  export const normalizeMetaConfig = (meta) =>
50
53
  meta === true
@@ -53,10 +56,11 @@ export const normalizeMetaConfig = (meta) =>
53
56
  ? { type: meta } // 'commit' | 'asset' | 'tag'
54
57
  : { type: 'none' }
55
58
 
56
- export const parseEnv = ({GH_USER, GH_USERNAME, GITHUB_USER, GITHUB_USERNAME, GH_TOKEN, GITHUB_TOKEN, NPM_TOKEN, NPM_REGISTRY, NPMRC, NPM_USERCONFIG, NPM_CONFIG_USERCONFIG, NPM_PROVENANCE, GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL} = process.env) =>
59
+ export const parseEnv = ({GH_USER, GH_USERNAME, GH_META, GITHUB_USER, GITHUB_USERNAME, GH_TOKEN, GITHUB_TOKEN, NPM_TOKEN, NPM_REGISTRY, NPMRC, NPM_USERCONFIG, NPM_CONFIG_USERCONFIG, NPM_PROVENANCE, GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL} = process.env) =>
57
60
  ({
58
61
  ghUser: GH_USER || GH_USERNAME || GITHUB_USER || GITHUB_USERNAME,
59
62
  ghToken: GH_TOKEN || GITHUB_TOKEN,
63
+ ghMeta: GH_META,
60
64
  npmConfig: NPMRC || NPM_USERCONFIG || NPM_CONFIG_USERCONFIG,
61
65
  npmToken: NPM_TOKEN,
62
66
  npmProvenance: NPM_PROVENANCE,
@@ -8,7 +8,7 @@ export const exec = async (pkg, name) => {
8
8
 
9
9
  if (cmd) {
10
10
  log({pkg})(`run ${name} '${cmd}'`)
11
- const result = await $.o({cwd: pkg.absPath, quote: v => v, preferLocal: true})`${cmd}`
11
+ const result = await $({cwd: pkg.absPath, quote: v => v, preferLocal: true})`${cmd}`
12
12
 
13
13
  log({pkg})(`duration ${name}: ${Date.now() - now}`)
14
14
  return result
@@ -81,12 +81,13 @@ export const run = async ({cwd = process.cwd(), env, flags = {}} = {}) => within
81
81
  .log()('Great success!')
82
82
  })
83
83
 
84
- export const createContext = async ({flags, env, cwd}) => {
84
+ export const createContext = async ({flags, env: _env, cwd}) => {
85
85
  const { packages, queue, root, prev, graphs } = await topo({cwd, flags})
86
86
  const report = createReport({packages, queue, flags})
87
+ const env = {...process.env, ..._env}
87
88
 
88
89
  $.report = report
89
- $.env = {...process.env, ...env}
90
+ $.env = env
90
91
  $.verbose = !!(flags.debug || $.env.DEBUG ) || $.verbose
91
92
 
92
93
  return {
@@ -96,6 +97,7 @@ export const createContext = async ({flags, env, cwd}) => {
96
97
  queue,
97
98
  prev,
98
99
  graphs,
99
- flags
100
+ flags,
101
+ env
100
102
  }
101
103
  }
@@ -4,8 +4,8 @@ import {getRoot, getSha} from '../api/git.js'
4
4
  import {$} from 'zx-extra'
5
5
 
6
6
  // Inspired by https://docs.github.com/en/actions/learn-github-actions/contexts
7
- export const contextify = async (pkg, {packages, root, flags}) => {
8
- pkg.config = await getPkgConfig(pkg.absPath, root.absPath)
7
+ export const contextify = async (pkg, {packages, root, flags, env}) => {
8
+ pkg.config = await getPkgConfig([pkg.absPath, root.absPath], env)
9
9
  pkg.latest = await getLatest(pkg)
10
10
  pkg.context = {
11
11
  git: {
@@ -1,4 +1,4 @@
1
- import {ctx, fs, path, tempy, $, sleep} from 'zx-extra'
1
+ import {fs, path, tempy, $, sleep} from 'zx-extra'
2
2
  import {fileURLToPath} from 'node:url'
3
3
 
4
4
  const __dirname = path.dirname(fileURLToPath(import.meta.url))
@@ -8,56 +8,51 @@ export const createNpmRegistry = () => {
8
8
  let p
9
9
 
10
10
  return {
11
- address: $.env.NPM_REGISTRY,
11
+ address: $.env.NPM_REGISTRY || 'http://localhost:4873',
12
12
  async start() {
13
13
  fs.removeSync(path.resolve(__dirname, '../../../storage'))
14
14
  const config = path.resolve(__dirname, '../../../verdaccio.config.yaml')
15
- ctx(($) => {
16
- $.preferLocal = true
17
- p = $`verdaccio --config ${config}`
18
- })
15
+ p = $({preferLocal: true})`verdaccio --config ${config}`
19
16
 
20
17
  return sleep(1000)
21
18
  },
22
19
  async stop() {
23
- p._nothrow = true
24
- return p?.kill()
20
+ p.nothrow().kill()
25
21
  }
26
22
  }
27
23
  }
28
24
 
29
- export const createFakeRepo = async ({cwd = tempy.temporaryDirectory(), commits = []} = {}) =>
30
- ctx(async ($) => {
31
- $.cwd = cwd
32
- await $`git init`
25
+ export const createFakeRepo = async ({cwd = tempy.temporaryDirectory(), commits = []} = {}) => {
26
+ const _$ = $({cwd})
27
+ await _$`git init`
33
28
 
34
- await addCommits({cwd, commits})
29
+ await addCommits({cwd, commits})
35
30
 
36
- const bare = tempy.temporaryDirectory()
37
- await $`git init --bare ${bare}`
38
- await $`git remote add origin ${bare}`
31
+ const bare = tempy.temporaryDirectory()
32
+ await _$`git init --bare ${bare}`
33
+ await _$`git remote add origin ${bare}`
39
34
 
40
- return cwd
41
- })
35
+ return cwd
36
+ }
42
37
 
43
- export const addCommits = async ({cwd, commits = []}) => ctx(async ($) => {
44
- $.cwd = cwd
38
+ export const addCommits = async ({cwd, commits = []}) => {
39
+ const _$ = $({cwd})
45
40
 
46
41
  for (let {msg, files, name = 'Semrel-extra Bot', email = 'semrel-extra-bot@hotmail.com', tags = []} of commits) {
47
- await $`git config user.name ${name}`
48
- await $`git config user.email ${email}`
42
+ await _$`git config user.name ${name}`
43
+ await _$`git config user.email ${email}`
49
44
  for (let {relpath, contents} of files) {
50
45
  const _contents = typeof contents === 'string' ? contents : JSON.stringify(contents, null, 2)
51
46
  const file = path.resolve(cwd, relpath)
52
47
  await fs.outputFile(file, _contents)
53
48
 
54
- await $`git add ${file}`
49
+ await _$`git add ${file}`
55
50
  }
56
51
 
57
- await $`git commit -m ${msg}`
52
+ await _$`git commit -m ${msg}`
58
53
 
59
54
  for (let tag of tags) {
60
- await $`git tag ${tag} -m ${tag}`
55
+ await _$`git tag ${tag} -m ${tag}`
61
56
  }
62
57
  }
63
- })
58
+ }