zx-bulk-release 1.1.2 → 1.2.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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/main/js/deps.js +8 -1
- package/src/main/js/publish.js +38 -13
- package/src/main/js/tag.js +16 -5
- package/src/test/js/integration.test.js +1 -1
- package/src/test/js/tag.test.js +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## [1.2.0](https://github.com/semrel-extra/zx-bulk-release/compare/v1.1.2...v1.2.0) (2022-06-21)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
* feat: parse legacy lerna tags ([c130191](https://github.com/semrel-extra/zx-bulk-release/commit/c130191f192b185937286730b8c3505d5674c7c1))
|
|
5
|
+
* feat: introduce meta.json to store release details ([a20c348](https://github.com/semrel-extra/zx-bulk-release/commit/a20c34809e29d772a44f71990fdb11921a49ca9f))
|
|
6
|
+
|
|
1
7
|
## [1.1.2](https://github.com/semrel-extra/zx-bulk-release/compare/v1.1.1...v1.1.2) (2022-06-18)
|
|
2
8
|
|
|
3
9
|
### Fixes & improvements
|
package/package.json
CHANGED
package/src/main/js/deps.js
CHANGED
|
@@ -11,7 +11,14 @@ export const updateDeps = async (pkg, packages) => {
|
|
|
11
11
|
if (!deps) continue
|
|
12
12
|
|
|
13
13
|
for (let [name, version] of Object.entries(deps)) {
|
|
14
|
-
|
|
14
|
+
if (!packages[name]) continue
|
|
15
|
+
|
|
16
|
+
const prev = pkg.latest.meta?.[scope]?.[name]
|
|
17
|
+
const actual = packages[name]?.version
|
|
18
|
+
const next = resolveVersion(version, actual, prev)
|
|
19
|
+
|
|
20
|
+
pkg[scope] = {...pkg[scope], [name]: next || version}
|
|
21
|
+
|
|
15
22
|
if (!next) continue
|
|
16
23
|
|
|
17
24
|
deps[name] = next
|
package/src/main/js/publish.js
CHANGED
|
@@ -3,6 +3,7 @@ import {tempy, ctx, fs, path, $} from 'zx-extra'
|
|
|
3
3
|
import {copydir} from 'git-glob-cp'
|
|
4
4
|
|
|
5
5
|
const branches = {}
|
|
6
|
+
const META_VERSION = '1'
|
|
6
7
|
|
|
7
8
|
export const getOrigin = (cwd) => ctx(async ($) => {
|
|
8
9
|
$.cwd = cwd
|
|
@@ -35,9 +36,14 @@ export const fetch = async ({cwd: _cwd, branch, origin: _origin}) => ctx(async (
|
|
|
35
36
|
return cwd
|
|
36
37
|
})
|
|
37
38
|
|
|
38
|
-
export const push = async ({cwd, from, to, branch, origin, msg, ignoreFiles}) => ctx(async ($) => {
|
|
39
|
+
export const push = async ({cwd, from, to, branch, origin, msg, ignoreFiles, files = []}) => ctx(async ($) => {
|
|
39
40
|
const _cwd = await fetch({cwd, branch, origin})
|
|
40
|
-
|
|
41
|
+
|
|
42
|
+
for (let {relpath, contents} of files) {
|
|
43
|
+
const _contents = typeof contents === 'string' ? contents : JSON.stringify(contents, null, 2)
|
|
44
|
+
await fs.outputFile(path.resolve(_cwd, to, relpath), _contents)
|
|
45
|
+
}
|
|
46
|
+
if (from) await copydir({baseFrom: cwd, from, baseTo: _cwd, to, ignoreFiles})
|
|
41
47
|
|
|
42
48
|
$.cwd = _cwd
|
|
43
49
|
|
|
@@ -49,15 +55,13 @@ export const push = async ({cwd, from, to, branch, origin, msg, ignoreFiles}) =>
|
|
|
49
55
|
})
|
|
50
56
|
|
|
51
57
|
export const publish = async (pkg, env) => ctx(async ($) => {
|
|
52
|
-
const {name, version
|
|
58
|
+
const {name, version} = pkg.manifest
|
|
59
|
+
const tag = formatTag({name, version})
|
|
53
60
|
const cwd = pkg.absPath
|
|
61
|
+
|
|
54
62
|
$.cwd = cwd
|
|
55
63
|
$.env = env
|
|
56
64
|
|
|
57
|
-
const tag = formatTag({name, version})
|
|
58
|
-
const from = files ? [...files, 'package.json'] : ['!node_modules', '*']
|
|
59
|
-
const to = getArtifactPath(tag)
|
|
60
|
-
|
|
61
65
|
console.log(`push release tag ${tag}`)
|
|
62
66
|
await $`git config user.name ${$.env.GIT_COMMITTER_NAME || 'Semrel Extra Bot'}`
|
|
63
67
|
await $`git config user.email ${$.env.GIT_COMMITTER_EMAIL || 'semrel-extra-bot@hotmail.com'}`
|
|
@@ -65,7 +69,7 @@ export const publish = async (pkg, env) => ctx(async ($) => {
|
|
|
65
69
|
await $`git push origin ${tag}`
|
|
66
70
|
|
|
67
71
|
console.log('push artifact to branch `meta`')
|
|
68
|
-
await
|
|
72
|
+
await pushMeta(pkg)
|
|
69
73
|
|
|
70
74
|
const registry = env.NPM_REGISTRY || 'https://registry.npmjs.org'
|
|
71
75
|
const npmrc = path.resolve(cwd, '.npmrc')
|
|
@@ -77,23 +81,44 @@ export const publish = async (pkg, env) => ctx(async ($) => {
|
|
|
77
81
|
|
|
78
82
|
export const getArtifactPath = (tag) => tag.toLowerCase().replace(/[^a-z0-9-]/g, '-')
|
|
79
83
|
|
|
80
|
-
export const
|
|
84
|
+
export const getLatestMeta = async (cwd, tag) => {
|
|
81
85
|
if (!tag) return null
|
|
82
86
|
|
|
83
87
|
try {
|
|
84
|
-
const
|
|
85
|
-
return await fs.readJson(path.resolve(
|
|
88
|
+
const _cwd = await fetch({cwd, branch: 'meta'})
|
|
89
|
+
return await fs.readJson(path.resolve(_cwd, getArtifactPath(tag), 'meta.json'))
|
|
86
90
|
} catch {}
|
|
87
91
|
|
|
88
92
|
return null
|
|
89
93
|
}
|
|
90
94
|
|
|
95
|
+
export const pushMeta = async (pkg) => ctx(async ($) => {
|
|
96
|
+
const cwd = pkg.absPath
|
|
97
|
+
const {name, version} = pkg
|
|
98
|
+
const tag = formatTag({name, version})
|
|
99
|
+
const to = getArtifactPath(tag)
|
|
100
|
+
const branch = 'meta'
|
|
101
|
+
const msg = `chore: release meta ${name} ${version}`
|
|
102
|
+
const meta = {
|
|
103
|
+
META_VERSION,
|
|
104
|
+
name: pkg.name,
|
|
105
|
+
version: pkg.version,
|
|
106
|
+
dependencies: pkg.dependencies,
|
|
107
|
+
devDependencies: pkg.devDependencies,
|
|
108
|
+
peerDependencies: pkg.peerDependencies,
|
|
109
|
+
optionalDependencies: pkg.optionalDependencies,
|
|
110
|
+
}
|
|
111
|
+
const files = [{relpath: 'meta.json', contents: meta}]
|
|
112
|
+
|
|
113
|
+
await push({cwd, to, branch, msg, files})
|
|
114
|
+
})
|
|
115
|
+
|
|
91
116
|
export const getLatest = async (cwd, name) => {
|
|
92
117
|
const tag = await getLatestTag(cwd, name)
|
|
93
|
-
const
|
|
118
|
+
const meta = await getLatestMeta(cwd, tag?.ref)
|
|
94
119
|
|
|
95
120
|
return {
|
|
96
121
|
tag,
|
|
97
|
-
|
|
122
|
+
meta
|
|
98
123
|
}
|
|
99
124
|
}
|
package/src/main/js/tag.js
CHANGED
|
@@ -8,8 +8,8 @@ const f0 = {
|
|
|
8
8
|
if (!tag.endsWith('-f0')) return null
|
|
9
9
|
|
|
10
10
|
const pattern = /^(\d{4}\.(?:[1-9]|1[012])\.(?:0[1-9]|[12]\d|30|31))-((?:[a-z0-9-]+\.)?[a-z0-9-]+)\.(v?\d+\.\d+\.\d+.*)-f0$/
|
|
11
|
-
const matched = pattern.exec(tag)
|
|
12
|
-
const [, _date, _name, version] = matched
|
|
11
|
+
const matched = pattern.exec(tag) || []
|
|
12
|
+
const [, _date, _name, version] = matched
|
|
13
13
|
|
|
14
14
|
if (!semver.valid(version)) return null
|
|
15
15
|
|
|
@@ -33,8 +33,8 @@ const f1 = {
|
|
|
33
33
|
if (!tag.endsWith('-f1')) return null
|
|
34
34
|
|
|
35
35
|
const pattern = /^(\d{4}\.(?:[1-9]|1[012])\.(?:0[1-9]|[12]\d|30|31))-[a-z0-9-]+\.(v?\d+\.\d+\.\d+.*)\.([^.]+)-f1$/
|
|
36
|
-
const matched = pattern.exec(tag)
|
|
37
|
-
const [, _date, version, b64] = matched
|
|
36
|
+
const matched = pattern.exec(tag) || []
|
|
37
|
+
const [, _date, version, b64] = matched
|
|
38
38
|
|
|
39
39
|
if (!semver.valid(version)) return null
|
|
40
40
|
|
|
@@ -54,6 +54,17 @@ const f1 = {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
const lerna = {
|
|
58
|
+
parse(tag) {
|
|
59
|
+
const pattern = /^(@?[a-z0-9-]+(?:\/[a-z0-9-]+)?)@(v?\d+\.\d+\.\d+.*)/
|
|
60
|
+
const [, name, version] = pattern.exec(tag) || []
|
|
61
|
+
|
|
62
|
+
if (!semver.valid(version)) return null
|
|
63
|
+
|
|
64
|
+
return {name, version, format: 'lerna', ref: tag}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
57
68
|
// TODO
|
|
58
69
|
// const variants = [f0, f1]
|
|
59
70
|
// export const parseTag = (tag) => {
|
|
@@ -65,7 +76,7 @@ const f1 = {
|
|
|
65
76
|
// return null
|
|
66
77
|
// }
|
|
67
78
|
|
|
68
|
-
export const parseTag = (tag) => f0.parse(tag) || f1.parse(tag) || null
|
|
79
|
+
export const parseTag = (tag) => f0.parse(tag) || f1.parse(tag) || lerna.parse(tag) || null
|
|
69
80
|
|
|
70
81
|
export const formatTag = (tag) => f0.format(tag) || f1.format(tag) || null
|
|
71
82
|
|
|
@@ -121,7 +121,7 @@ test('run()', async () => {
|
|
|
121
121
|
const meta = tempy.temporaryDirectory()
|
|
122
122
|
|
|
123
123
|
await $`git clone --single-branch --branch meta --depth 1 ${origin} ${meta}`
|
|
124
|
-
assert.is((await fs.readJson(`${meta}/${tag.toLowerCase().replace(/[^a-z0-9-]/g, '-')}/
|
|
124
|
+
assert.is((await fs.readJson(`${meta}/${tag.toLowerCase().replace(/[^a-z0-9-]/g, '-')}/meta.json`)).version, '1.0.1')
|
|
125
125
|
})
|
|
126
126
|
|
|
127
127
|
await registry.stop()
|
package/src/test/js/tag.test.js
CHANGED
|
@@ -143,6 +143,16 @@ test('formatTag() / parseTag()', () => {
|
|
|
143
143
|
format: 'f1',
|
|
144
144
|
ref: '2022.6.13-examplecom.v1.0.0.ZXhhbXBsZS5jb20-f1'
|
|
145
145
|
}
|
|
146
|
+
],
|
|
147
|
+
[
|
|
148
|
+
'@qiwi/pijma-ssr@1.1.12',
|
|
149
|
+
{
|
|
150
|
+
name: '@qiwi/pijma-ssr',
|
|
151
|
+
version: '1.1.12',
|
|
152
|
+
format: 'lerna',
|
|
153
|
+
ref: '@qiwi/pijma-ssr@1.1.12'
|
|
154
|
+
},
|
|
155
|
+
true
|
|
146
156
|
]
|
|
147
157
|
]
|
|
148
158
|
|