Skip to content

Commit 949dfc3

Browse files
chore: improve release script (#996)
* chore: improve release script Signed-off-by: Alex Matson <[email protected]> * fix for dependabot PRs commit lint Signed-off-by: Alex Matson <[email protected]> * fix Signed-off-by: Alex Matson <[email protected]> --------- Signed-off-by: Alex Matson <[email protected]>
1 parent 8e10736 commit 949dfc3

File tree

5 files changed

+88
-39
lines changed

5 files changed

+88
-39
lines changed

.commitlintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const proc = require('child_process')
22

3-
const scopes = ['release']
3+
const scopes = ['release', 'deps']
44

55
const getScopes = () => {
66
const projects = JSON.parse(

nx.json

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@
1111
"sharedGlobals": []
1212
},
1313
"release": {
14-
"projects": [
15-
"core/*",
16-
"sdk/*",
17-
"wallet-gateway/remote",
18-
"!core/rpc-generator"
19-
],
20-
"projectsRelationship": "independent",
2114
"version": {
2215
"conventionalCommits": true,
2316
"fallbackCurrentVersionResolver": "disk"
@@ -28,6 +21,27 @@
2821
"createRelease": "github",
2922
"file": false
3023
}
24+
},
25+
"groups": {
26+
"core": {
27+
"projects": ["core/*", "!core/rpc-generator"],
28+
"projectsRelationship": "independent",
29+
"version": {
30+
"updateDependents": "never"
31+
}
32+
},
33+
"dapp-sdk": {
34+
"projects": ["sdk/dapp-sdk"],
35+
"projectsRelationship": "independent"
36+
},
37+
"wallet-sdk": {
38+
"projects": ["sdk/wallet-sdk"],
39+
"projectsRelationship": "independent"
40+
},
41+
"wallet-gateway": {
42+
"projects": ["wallet-gateway/remote"],
43+
"projectsRelationship": "independent"
44+
}
3145
}
3246
},
3347
"targetDefaults": {

scripts/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"@commander-js/extra-typings": "^14.0.0",
2828
"@inquirer/prompts": "^8.0.1",
2929
"commander": "^14.0.2",
30+
"inquirer-select-pro": "^1.0.0-alpha.9",
3031
"jsonc-parser": "^3.3.1",
3132
"pm2": "^6.0.14",
3233
"yoctocolors": "^2.1.2"

scripts/src/release.ts

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import { spawn } from 'child_process'
66
import { program } from '@commander-js/extra-typings'
7-
import { getAllNxDependencies } from './lib/utils.js'
8-
import { confirm, select } from '@inquirer/prompts'
7+
import { confirm } from '@inquirer/prompts'
8+
import { select } from 'inquirer-select-pro'
99

1010
// This helper passes through the underlying command's input/output to console
1111
async function cmd(command: string): Promise<void> {
@@ -24,43 +24,29 @@ async function cmd(command: string): Promise<void> {
2424
})
2525
}
2626

27-
const ALL_OPTION = '(all packages)'
28-
const QUIT_OPTION = '(quit)'
27+
const options = ['wallet-sdk', 'dapp-sdk', 'wallet-gateway']
2928

3029
program
3130
.option('--dry-run', 'Perform a dry run (default: true)')
3231
.option('--no-dry-run', 'Perform a real release')
3332
.action(async ({ dryRun = true }) => {
34-
const project = await select({
35-
message: 'Select project to release',
36-
choices: [
37-
'wallet-sdk',
38-
'dapp-sdk',
39-
'wallet-gateway-remote',
40-
ALL_OPTION,
41-
QUIT_OPTION,
42-
],
33+
const groups = await select({
34+
canToggleAll: true,
35+
message: 'Select groups to release',
36+
options: options.map((opt) => ({ name: opt, value: opt })),
4337
}).catch(() => process.exit(0))
4438

45-
if (project === QUIT_OPTION) {
46-
console.log('Aborting')
39+
if (groups.length === 0) {
40+
console.log('No release groups selected; quitting.')
4741
process.exit(0)
4842
}
4943

50-
let deps = undefined
51-
52-
if (project === ALL_OPTION) {
53-
console.log('Cutting a release for everything.')
54-
} else {
55-
deps = await getAllNxDependencies(`@canton-network/${project}`)
56-
}
57-
58-
await runRelease(dryRun, deps)
44+
await runRelease(dryRun, groups)
5945
process.exit(0)
6046
})
6147
.parseAsync(process.argv)
6248

63-
async function runRelease(dryRun: boolean, projects?: string[]): Promise<void> {
49+
async function runRelease(dryRun: boolean, groups: string[]): Promise<void> {
6450
let releaseCmd = `yarn nx release --skip-publish`
6551

6652
if (dryRun === false) {
@@ -78,10 +64,7 @@ async function runRelease(dryRun: boolean, projects?: string[]): Promise<void> {
7864
releaseCmd += ' --dry-run'
7965
}
8066

81-
if (projects && projects.length > 0) {
82-
console.log('Releasing the following set of packages: ', projects)
83-
releaseCmd += ` --projects='${projects.join(',')}'`
84-
}
67+
releaseCmd += ` --groups='${groups.concat('core').join(',')}'`
8568

8669
if (!dryRun) {
8770
const proceedRelease = await confirm({

yarn.lock

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,6 +2012,7 @@ __metadata:
20122012
colors: "npm:^1.4.0"
20132013
commander: "npm:^14.0.2"
20142014
diff: "npm:^8.0.2"
2015+
inquirer-select-pro: "npm:^1.0.0-alpha.9"
20152016
jsonc-parser: "npm:^3.3.1"
20162017
openapi-typescript: "npm:^7.10.1"
20172018
pm2: "npm:^6.0.14"
@@ -3436,6 +3437,27 @@ __metadata:
34363437
languageName: node
34373438
linkType: hard
34383439

3440+
"@inquirer/core@npm:^8.1.0":
3441+
version: 8.2.4
3442+
resolution: "@inquirer/core@npm:8.2.4"
3443+
dependencies:
3444+
"@inquirer/figures": "npm:^1.0.3"
3445+
"@inquirer/type": "npm:^1.3.3"
3446+
"@types/mute-stream": "npm:^0.0.4"
3447+
"@types/node": "npm:^20.14.9"
3448+
"@types/wrap-ansi": "npm:^3.0.0"
3449+
ansi-escapes: "npm:^4.3.2"
3450+
cli-spinners: "npm:^2.9.2"
3451+
cli-width: "npm:^4.1.0"
3452+
mute-stream: "npm:^1.0.0"
3453+
picocolors: "npm:^1.0.1"
3454+
signal-exit: "npm:^4.1.0"
3455+
strip-ansi: "npm:^6.0.1"
3456+
wrap-ansi: "npm:^6.2.0"
3457+
checksum: 10c0/3328ea52823a59cad4bf6c36b143c7322a2e1430ae040717e63c94680f246c0d628aed3032a2f6890652dd4b7fdb0fec7e324059b74173ffa78ae2a485939f33
3458+
languageName: node
3459+
linkType: hard
3460+
34393461
"@inquirer/editor@npm:^1.2.15":
34403462
version: 1.2.15
34413463
resolution: "@inquirer/editor@npm:1.2.15"
@@ -3553,6 +3575,13 @@ __metadata:
35533575
languageName: node
35543576
linkType: hard
35553577

3578+
"@inquirer/figures@npm:^1.0.1, @inquirer/figures@npm:^1.0.3":
3579+
version: 1.0.15
3580+
resolution: "@inquirer/figures@npm:1.0.15"
3581+
checksum: 10c0/6e39a040d260ae234ae220180b7994ff852673e20be925f8aa95e78c7934d732b018cbb4d0ec39e600a410461bcb93dca771e7de23caa10630d255692e440f69
3582+
languageName: node
3583+
linkType: hard
3584+
35563585
"@inquirer/figures@npm:^1.0.13":
35573586
version: 1.0.13
35583587
resolution: "@inquirer/figures@npm:1.0.13"
@@ -3868,7 +3897,7 @@ __metadata:
38683897
languageName: node
38693898
linkType: hard
38703899

3871-
"@inquirer/type@npm:^1.1.6":
3900+
"@inquirer/type@npm:^1.1.6, @inquirer/type@npm:^1.3.1, @inquirer/type@npm:^1.3.3":
38723901
version: 1.5.5
38733902
resolution: "@inquirer/type@npm:1.5.5"
38743903
dependencies:
@@ -7006,6 +7035,15 @@ __metadata:
70067035
languageName: node
70077036
linkType: hard
70087037

7038+
"@types/node@npm:^20.14.9":
7039+
version: 20.19.25
7040+
resolution: "@types/node@npm:20.19.25"
7041+
dependencies:
7042+
undici-types: "npm:~6.21.0"
7043+
checksum: 10c0/992f18cb03264e8dc2fd3cb64f428ee4997cb6d928dad68bf4b752eacac73062697ce7ce6a0e71a6d15af510814397a20597a72332dfec638e02fb3a382ad014
7044+
languageName: node
7045+
linkType: hard
7046+
70097047
"@types/parse-json@npm:^4.0.0":
70107048
version: 4.0.2
70117049
resolution: "@types/parse-json@npm:4.0.2"
@@ -12347,6 +12385,19 @@ __metadata:
1234712385
languageName: node
1234812386
linkType: hard
1234912387

12388+
"inquirer-select-pro@npm:^1.0.0-alpha.9":
12389+
version: 1.0.0-alpha.9
12390+
resolution: "inquirer-select-pro@npm:1.0.0-alpha.9"
12391+
dependencies:
12392+
"@inquirer/core": "npm:^8.1.0"
12393+
"@inquirer/figures": "npm:^1.0.1"
12394+
"@inquirer/type": "npm:^1.3.1"
12395+
ansi-escapes: "npm:^7.0.0"
12396+
chalk: "npm:^5.3.0"
12397+
checksum: 10c0/5362b6260f067d9a2309c669f6b89660eec7e61150a84ba640bb757e397e58fe856099ce9b4813fa6d96201dc2d716dc9846e9fdd68af3f4cfe0a79e569d8805
12398+
languageName: node
12399+
linkType: hard
12400+
1235012401
"inquirer@npm:^12.4.2":
1235112402
version: 12.9.4
1235212403
resolution: "inquirer@npm:12.9.4"
@@ -15494,7 +15545,7 @@ __metadata:
1549415545
languageName: node
1549515546
linkType: hard
1549615547

15497-
"picocolors@npm:^1.1.0, picocolors@npm:^1.1.1":
15548+
"picocolors@npm:^1.0.1, picocolors@npm:^1.1.0, picocolors@npm:^1.1.1":
1549815549
version: 1.1.1
1549915550
resolution: "picocolors@npm:1.1.1"
1550015551
checksum: 10c0/e2e3e8170ab9d7c7421969adaa7e1b31434f789afb9b3f115f6b96d91945041ac3ceb02e9ec6fe6510ff036bcc0bf91e69a1772edc0b707e12b19c0f2d6bcf58

0 commit comments

Comments
 (0)