bulk-release 2.11.4 → 2.11.5

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,8 @@
1
+ ## [2.11.5](https://github.com/semrel-extra/zx-bulk-release/compare/v2.11.4...v2.11.5) (2023-07-07)
2
+
3
+ ### Fixes & improvements
4
+ * fix(assets): handle `commonPath` corner case ([1e9ac5e](https://github.com/semrel-extra/zx-bulk-release/commit/1e9ac5e64ac1c26a049f28b35c7c98db5bea7d34))
5
+
1
6
  ## [2.11.4](https://github.com/semrel-extra/zx-bulk-release/compare/v2.11.3...v2.11.4) (2023-06-29)
2
7
 
3
8
  ### 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.11.4",
4
+ "version": "2.11.5",
5
5
  "description": "zx-based alternative for multi-semantic-release",
6
6
  "type": "module",
7
7
  "exports": {
package/src/main/js/gh.js CHANGED
@@ -4,7 +4,7 @@ import {log} from './log.js'
4
4
  import {getRepo, pushCommit} from './git.js'
5
5
  import {formatTag} from './meta.js'
6
6
  import {formatReleaseNotes} from './changelog.js'
7
- import {asArray, msgJoin} from './util.js'
7
+ import {asArray, getCommonPath, msgJoin} from './util.js'
8
8
 
9
9
  // https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#create-a-release
10
10
  export const ghRelease = async (pkg) => {
@@ -74,13 +74,9 @@ export const ghPrepareAssets = async (assets, _cwd) => {
74
74
  await fs.copy(path.join(cwd, files[0]), target)
75
75
  return
76
76
  }
77
+ const prefix = getCommonPath(files)
77
78
 
78
- const common = files.length === 1
79
- ? files[0].lastIndexOf('/') + 1
80
- : [...(files[0])].findIndex((c, i) => files.some(f => f.charAt(i) !== c))
81
- const prefix = files[0].slice(0, common)
82
-
83
- return $.raw`tar -C ${common ? path.join(cwd, prefix) : cwd} -cv${zip ? 'z' : ''}f ${target} ${files.map(f => common ? f.slice(common) : f).join(' ')}`
79
+ return $.raw`tar -C ${path.join(cwd, prefix)} -cv${zip ? 'z' : ''}f ${target} ${files.map(f => f.slice(prefix.length)).join(' ')}`
84
80
  }))
85
81
 
86
82
  return temp
@@ -46,3 +46,17 @@ export const memoizeBy = (fn, getKey = v => v, memo = new Map()) => async (...ar
46
46
  export const camelize = s => s.replace(/-./g, x => x[1].toUpperCase())
47
47
 
48
48
  export const asArray = v => Array.isArray(v) ? v : [v]
49
+
50
+ export const getCommonPath = files => {
51
+ const f0 = files[0]
52
+ const common = files.length === 1
53
+ ? f0.lastIndexOf('/') + 1
54
+ : [...(f0)].findIndex((c, i) => files.some(f => f.charAt(i) !== c))
55
+
56
+ const p = f0.slice(0, common)
57
+ if (p.endsWith('/')) {
58
+ return p
59
+ }
60
+
61
+ return p.slice(0, p.lastIndexOf('/') + 1)
62
+ }