zx-bulk-release 1.18.0 → 1.19.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.
@@ -7,21 +7,9 @@ env:
7
7
  YARN_ENABLE_IMMUTABLE_INSTALLS: false
8
8
 
9
9
  jobs:
10
- init:
11
- name: init
12
- runs-on: ubuntu-20.04
13
- outputs:
14
- skip: ${{ steps.ci-skip-step.outputs.ci-skip }}
15
- skip-not: ${{ steps.ci-skip-step.outputs.ci-skip-not }}
16
- steps:
17
- - uses: actions/checkout@v3
18
- - id: ci-skip-step
19
- uses: mstachniuk/ci-skip@v1
20
-
21
10
  test_push:
11
+ if: github.event_name == 'push'
22
12
  name: Test on push
23
- needs: init
24
- if: ${{ needs.init.outputs.skip == 'false' && github.event_name == 'push' }}
25
13
  runs-on: ubuntu-20.04
26
14
  steps:
27
15
  - name: Checkout
@@ -30,7 +18,7 @@ jobs:
30
18
  - name: Setup Node.js
31
19
  uses: actions/setup-node@v3
32
20
  with:
33
- node-version: 18
21
+ node-version: 18.5
34
22
 
35
23
  - name: Install deps
36
24
  run: yarn install
@@ -40,8 +28,7 @@ jobs:
40
28
  run: yarn test
41
29
 
42
30
  test_pr:
43
- if: ${{ needs.init.outputs.skip == 'false' && github.event_name == 'pull_request' }}
44
- needs: init
31
+ if: github.event_name == 'pull_request'
45
32
  name: Test PR (Node v${{ matrix.node-version }}, OS ${{ matrix.os }})
46
33
  strategy:
47
34
  matrix:
@@ -86,7 +73,7 @@ jobs:
86
73
  - name: Setup Node.js
87
74
  uses: actions/setup-node@v3
88
75
  with:
89
- node-version: 18
76
+ node-version: 18.5
90
77
 
91
78
  - name: Install deps
92
79
  run: yarn install
package/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## [1.19.0](https://github.com/semrel-extra/zx-bulk-release/compare/v1.18.0...v1.19.0) (2022-07-18)
2
+
3
+ ### Features
4
+ * feat: add optional `publishCmd` directive ([e3cb37c](https://github.com/semrel-extra/zx-bulk-release/commit/e3cb37c1c7eff7e16fab5ac57a5ae28d7e2e1f57))
5
+
1
6
  ## [1.18.0](https://github.com/semrel-extra/zx-bulk-release/compare/v1.17.7...v1.18.0) (2022-07-09)
2
7
 
3
8
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zx-bulk-release",
3
- "version": "1.18.0",
3
+ "version": "1.19.0",
4
4
  "description": "zx-based alternative for multi-semantic-release",
5
5
  "type": "module",
6
6
  "exports": "./src/main/js/index.js",
@@ -13,12 +13,12 @@
13
13
  "dependencies": {
14
14
  "@semrel-extra/topo": "^1.4.2",
15
15
  "cosmiconfig": "^7.0.1",
16
- "zx-extra": "^2.4.0"
16
+ "zx-extra": "^2.5.0"
17
17
  },
18
18
  "devDependencies": {
19
19
  "c8": "^7.11.3",
20
20
  "uvu": "^0.5.6",
21
- "verdaccio": "^5.13.1"
21
+ "verdaccio": "^5.13.3"
22
22
  },
23
23
  "publishConfig": {
24
24
  "access": "public"
@@ -1,6 +1,6 @@
1
- import {$} from 'zx-extra'
2
1
  import {traverseDeps} from './deps.js'
3
2
  import {fetchPkg} from './npm.js'
3
+ import {runHook} from './util.js'
4
4
 
5
5
  export const build = async (pkg, packages) => {
6
6
  if (pkg.built) return true
@@ -11,9 +11,8 @@ export const build = async (pkg, packages) => {
11
11
 
12
12
  if (pkg.changes.length === 0 && config.npmFetch) await fetchPkg(pkg)
13
13
 
14
- if (!pkg.fetched && config.cmd) {
15
- console.log(`[${pkg.name}] run cmd '${config.cmd}'`)
16
- await $.o({cwd: pkg.absPath, quote: v => v})`${config.cmd}`
14
+ if (!pkg.fetched && config.buildCmd) {
15
+ await await runHook(pkg, 'buildCmd')
17
16
  }
18
17
 
19
18
  pkg.built = true
@@ -29,8 +29,8 @@ export const getConfig = async (...cwds) =>
29
29
 
30
30
  export const normalizeConfig = config => ({
31
31
  ...config,
32
- npmFetch: config.npmFetch || config.fetch || config.fetchPkg,
33
- cmd: config.cmd || (config.buildCmd ? `${config.buildCmd}${config.testCmd ? ` && ${config.testCmd}` : ''}` : '')
32
+ npmFetch: config.npmFetch || config.fetch || config.fetchPkg,
33
+ buildCmd: config.cmd || (config.buildCmd ? `${config.buildCmd}${config.testCmd ? ` && ${config.testCmd}` : ''}` : '')
34
34
  })
35
35
 
36
36
  export const parseEnv = (env = process.env) => {
@@ -1,8 +1,9 @@
1
1
  import {formatTag, getLatestTag, pushTag} from './tag.js'
2
- import {ctx, fs, path, $} from 'zx-extra'
2
+ import {fs, path, $} from 'zx-extra'
3
3
  import {push, fetch, parseRepo} from './repo.js'
4
4
  import {parseEnv} from './config.js'
5
5
  import {fetchManifest, npmPublish} from './npm.js'
6
+ import {runHook, tpl} from './util.js'
6
7
 
7
8
  export const publish = async (pkg) => {
8
9
  await fs.writeJson(pkg.manifestPath, pkg.manifest, {spaces: 2})
@@ -12,6 +13,7 @@ export const publish = async (pkg) => {
12
13
  await npmPublish(pkg)
13
14
  await ghRelease(pkg)
14
15
  await ghPages(pkg)
16
+ await runHook(pkg, 'publishCmd')
15
17
  }
16
18
 
17
19
  export const pushMeta = async (pkg) => {
@@ -0,0 +1,24 @@
1
+ import {$} from 'zx-extra'
2
+
3
+ export const tpl = (str, context) =>
4
+ str?.replace(/\$\{\{\s*([.a-z0-9]+)\s*}}/gi, (matched, key) => get(context, key) ?? '')
5
+
6
+ export const get = (obj, path = '.') => {
7
+ const chunks = path.split('.').filter(Boolean)
8
+ let result = obj
9
+
10
+ for (let i = 0, len = chunks.length; i < len && result !== undefined && result !== null; i++) {
11
+ result = obj[chunks[i]]
12
+ }
13
+
14
+ return result
15
+ }
16
+
17
+ export const runHook = async (pkg, name) => {
18
+ const cmd = tpl(pkg.config[name], pkg)
19
+
20
+ if (cmd) {
21
+ console.log(`[${pkg.name}] run ${name} '${cmd}'`)
22
+ await $.o({cwd: pkg.absPath, quote: v => v})`${cmd}`
23
+ }
24
+ }
@@ -113,6 +113,7 @@ const cwd = await createFakeRepo({
113
113
  },
114
114
  release: {
115
115
  buildCmd: 'yarn && yarn build',
116
+ publishCmd: 'echo "custom publish: ${{name}} ${{version}}"',
116
117
  testCmd: 'yarn test',
117
118
  fetch: true,
118
119
  ghPages: 'gh-pages docs b'
@@ -0,0 +1,19 @@
1
+ import {suite} from 'uvu'
2
+ import * as assert from 'uvu/assert'
3
+ import {tpl} from '../../main/js/util.js'
4
+
5
+ const test = suite('util')
6
+
7
+ test('tpl()', () => {
8
+ const cases = [
9
+ ['echo "custom publish: ${{name}} ${{ version }}"', {name: 'foo', version: '1.0.0'}, 'echo "custom publish: foo 1.0.0"'],
10
+ ['echo "custom publish: ${{name}} ${{version}}"', {}, 'echo "custom publish: "'],
11
+ ]
12
+
13
+ cases.forEach(([template, ctx, result]) => {
14
+ assert.equal(tpl(template, ctx), result)
15
+ })
16
+ })
17
+
18
+ test.run()
19
+