zx-bulk-release 1.8.0 → 1.9.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 CHANGED
@@ -1,3 +1,8 @@
1
+ ## [1.9.0](https://github.com/semrel-extra/zx-bulk-release/compare/v1.8.0...v1.9.0) (2022-06-26)
2
+
3
+ ### Features
4
+ * feat: add gh-pages push ([32130b6](https://github.com/semrel-extra/zx-bulk-release/commit/32130b64a2088cc98b1cae678691cd55c18fe0a3))
5
+
1
6
  ## [1.8.0](https://github.com/semrel-extra/zx-bulk-release/compare/v1.7.8...v1.8.0) (2022-06-26)
2
7
 
3
8
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zx-bulk-release",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "zx-based alternative for multi-semantic-release",
5
5
  "type": "module",
6
6
  "exports": "./src/main/js/index.js",
@@ -16,7 +16,6 @@ export const build = (pkg, packages) => ctx(async ($) => {
16
16
  if (pkg.changes?.length === 0 && config.fetch) await fetchPkg(pkg)
17
17
 
18
18
  if (!pkg.fetched) {
19
- // $.quote = v => v
20
19
  await $.raw`${config.buildCmd}`
21
20
  console.log(`built '${pkg.name}'`)
22
21
  }
@@ -12,7 +12,7 @@ export const run = async ({cwd = process.cwd(), env = process.env, flags = {}} =
12
12
 
13
13
  for (let name of queue) {
14
14
  const pkg = packages[name]
15
- pkg.config = await getConfig(cwd, root.absPath)
15
+ pkg.config = await getConfig(pkg.absPath, root.absPath)
16
16
  pkg.latest = await getLatest(cwd, name)
17
17
 
18
18
  const semanticChanges = await getSemanticChanges(pkg.absPath, pkg.latest.tag?.ref)
@@ -7,6 +7,7 @@ export const publish = async (pkg) => {
7
7
  await pushMeta(pkg)
8
8
  await npmPublish(pkg)
9
9
  await createGhRelease(pkg)
10
+ await ghPages(pkg)
10
11
  }
11
12
 
12
13
  export const pushTag = (pkg) => ctx(async ($) => {
@@ -98,6 +99,22 @@ ${commits.join('\n')}`).join('\n')
98
99
  await $`curl -u ${ghUser}:${ghToken} -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${repoName}/releases -d ${releaseData}`
99
100
  })
100
101
 
102
+ const ghPages = async (pkg) => {
103
+ const {config} = pkg
104
+ if (!config.ghPages) return
105
+
106
+ console.log('publish to gh-pages')
107
+ const [from, branch = 'gh-pages', to = '.'] = config.ghPages.split(' ')
108
+
109
+ await push({
110
+ cwd: path.resolve(pkg.absPath, from),
111
+ from: '.',
112
+ to,
113
+ branch,
114
+ msg: 'docs update'
115
+ })
116
+ }
117
+
101
118
  const branches = {}
102
119
  export const fetch = async ({cwd: _cwd, branch, origin: _origin}) => ctx(async ($) => {
103
120
  let cwd = branches[branch]
@@ -127,14 +144,20 @@ export const push = async ({cwd, from, to, branch, origin, msg, ignoreFiles, fil
127
144
  const _contents = typeof contents === 'string' ? contents : JSON.stringify(contents, null, 2)
128
145
  await fs.outputFile(path.resolve(_cwd, to, relpath), _contents)
129
146
  }
130
- if (from) await copydir({baseFrom: cwd, from, baseTo: _cwd, to, ignoreFiles})
147
+ if (from) await copydir({baseFrom: cwd, from, baseTo: _cwd, to, ignoreFiles, cwd})
131
148
 
132
149
  $.cwd = _cwd
133
150
 
134
151
  await $`git config user.name ${gitCommitterEmail}`
135
152
  await $`git config user.email ${gitCommitterName}`
136
153
  await $`git add .`
137
- await $`git commit -m ${msg}`
154
+ try {
155
+ await $`git commit -m ${msg}`
156
+ } catch {
157
+ console.warn('no changes')
158
+ return
159
+ }
160
+
138
161
  await $.raw`git push origin HEAD:refs/heads/${branch}`
139
162
  })
140
163
 
@@ -108,14 +108,15 @@ const cwd = await createFakeRepo({
108
108
  a: 'workspace:^'
109
109
  },
110
110
  scripts: {
111
- build: 'cp index.js bundle.js',
111
+ build: 'cp index.js bundle.js && mkdir -p docs && echo "# docs" > docs/readme.md',
112
112
  test: "node ./index.js"
113
113
  },
114
114
  release: {
115
115
  buildCmd: 'yarn build',
116
116
  postbuildCmd: 'yarn install',
117
117
  testCmd: 'yarn test',
118
- fetch: true
118
+ fetch: true,
119
+ ghPages: 'docs gh-pages b'
119
120
  },
120
121
  exports: {
121
122
  '.': {
@@ -209,9 +210,13 @@ test('run()', async () => {
209
210
 
210
211
  const origin = (await $`git remote get-url origin`).toString().trim()
211
212
  const meta = tempy.temporaryDirectory()
213
+ const ghp = tempy.temporaryDirectory()
212
214
 
213
215
  await $`git clone --single-branch --branch meta --depth 1 ${origin} ${meta}`
214
216
  assert.is((await fs.readJson(`${meta}/${tag.toLowerCase().replace(/[^a-z0-9-]/g, '-')}.json`)).version, '1.1.0')
217
+
218
+ await $`git clone --single-branch --branch gh-pages --depth 1 ${origin} ${ghp}`
219
+ assert.is((await fs.readFile(`${ghp}/b/readme.md`, 'utf-8')).trim(), '# docs')
215
220
  })
216
221
 
217
222
  await registry.stop()