@@ -30,13 +30,13 @@ function buildTasks(executor: RemoteExecutor, config: ShipnodeConfig) {
3030 task : ( _ctx : object , task : any ) => task . newListr ( [
3131 {
3232 title : 'Update package index' ,
33- task : ( ) => execOrThrow ( executor ,
33+ task : ( ) => executor . execOrThrow (
3434 'SUDO=""; [ "$EUID" -ne 0 ] && SUDO="sudo"; $SUDO apt-get update -qq' ,
3535 ) ,
3636 } ,
3737 {
3838 title : 'Install curl git jq rsync build-essential' ,
39- task : ( ) => execOrThrow ( executor ,
39+ task : ( ) => executor . execOrThrow (
4040 'SUDO=""; [ "$EUID" -ne 0 ] && SUDO="sudo"; ' +
4141 '$SUDO apt-get install -y curl git jq rsync build-essential' ,
4242 ) ,
@@ -46,7 +46,7 @@ function buildTasks(executor: RemoteExecutor, config: ShipnodeConfig) {
4646 {
4747 title : 'Mise (version manager)' ,
4848 task : ( ) =>
49- execOrThrow ( executor ,
49+ executor . execOrThrow (
5050 `if ! command -v mise &>/dev/null; then curl -fsSL https://mise.run | sh; fi` ,
5151 ) ,
5252 } ,
@@ -55,11 +55,11 @@ function buildTasks(executor: RemoteExecutor, config: ShipnodeConfig) {
5555 task : ( _ctx : object , task : any ) => task . newListr ( [
5656 {
5757 title : `Install node@${ nodeVersion } ` ,
58- task : ( ) => execOrThrow ( executor , `${ mise } ; mise install -y "node@${ nodeVersion } "` ) ,
58+ task : ( ) => executor . execOrThrow ( `${ mise } ; mise install -y "node@${ nodeVersion } "` ) ,
5959 } ,
6060 {
6161 title : `Set node@${ nodeVersion } as global default` ,
62- task : ( ) => execOrThrow ( executor , `${ mise } ; mise use -g -y "node@${ nodeVersion } "` ) ,
62+ task : ( ) => executor . execOrThrow ( `${ mise } ; mise use -g -y "node@${ nodeVersion } "` ) ,
6363 } ,
6464 ] , { concurrent : false } ) ,
6565 } ,
@@ -68,7 +68,7 @@ function buildTasks(executor: RemoteExecutor, config: ShipnodeConfig) {
6868 task : ( _ctx : object , task : any ) => task . newListr ( [
6969 {
7070 title : 'Install pm2' ,
71- task : ( ) => execOrThrow ( executor ,
71+ task : ( ) => executor . execOrThrow (
7272 `${ mise } ; ` +
7373 `if ! mise exec "node@${ nodeVersion } " -- pm2 --version &>/dev/null; then ` +
7474 ` mise exec "node@${ nodeVersion } " -- npm install -g pm2; ` +
@@ -77,7 +77,7 @@ function buildTasks(executor: RemoteExecutor, config: ShipnodeConfig) {
7777 } ,
7878 {
7979 title : 'Configure systemd startup' ,
80- task : ( ) => execOrThrow ( executor ,
80+ task : ( ) => executor . execOrThrow (
8181 `${ mise } ; ` +
8282 `mise exec "node@${ nodeVersion } " -- pm2 startup systemd -u $USER --hp $HOME || true; ` +
8383 `mise exec "node@${ nodeVersion } " -- pm2 save --force || true` ,
@@ -88,7 +88,7 @@ function buildTasks(executor: RemoteExecutor, config: ShipnodeConfig) {
8888 {
8989 title : 'Caddy' ,
9090 task : ( ) =>
91- execOrThrow ( executor ,
91+ executor . execOrThrow (
9292 'SUDO=""; [ "$EUID" -ne 0 ] && SUDO="sudo"; ' +
9393 'if ! command -v caddy &>/dev/null; then ' +
9494 ' $SUDO apt-get install -y debian-keyring debian-archive-keyring apt-transport-https; ' +
@@ -107,13 +107,13 @@ function buildTasks(executor: RemoteExecutor, config: ShipnodeConfig) {
107107 return task . newListr ( [
108108 {
109109 title : `Install ${ db . type } ` ,
110- task : ( ) => execOrThrow ( executor , buildDbInstallCommand ( db ) ) ,
110+ task : ( ) => executor . execOrThrow ( buildDbInstallCommand ( db ) ) ,
111111 } ,
112112 {
113113 title : `Create user '${ db . user } ' and database '${ db . name } '` ,
114- task : ( ) => execOrThrow ( executor , buildDbCreateCommand ( db ) ) ,
114+ task : ( ) => executor . execOrThrow ( buildDbCreateCommand ( db ) ) ,
115115 } ,
116- ...( probe ? [ { title : 'Verify connection' , task : ( ) => execOrThrow ( executor , probe ) } ] : [ ] ) ,
116+ ...( probe ? [ { title : 'Verify connection' , task : ( ) => executor . execOrThrow ( probe ) } ] : [ ] ) ,
117117 ] , { concurrent : false } ) ;
118118 } ,
119119 } ]
@@ -127,13 +127,13 @@ function buildTasks(executor: RemoteExecutor, config: ShipnodeConfig) {
127127 return task . newListr ( [
128128 {
129129 title : 'Install redis-server' ,
130- task : ( ) => execOrThrow ( executor , buildRedisInstallCommand ( redis ) ) ,
130+ task : ( ) => executor . execOrThrow ( buildRedisInstallCommand ( redis ) ) ,
131131 } ,
132132 ...( redis . password ? [ {
133133 title : 'Set password' ,
134- task : ( ) => execOrThrow ( executor , buildRedisConfigureCommand ( redis ) ) ,
134+ task : ( ) => executor . execOrThrow ( buildRedisConfigureCommand ( redis ) ) ,
135135 } ] : [ ] ) ,
136- ...( probe ? [ { title : 'Verify connection' , task : ( ) => execOrThrow ( executor , probe ) } ] : [ ] ) ,
136+ ...( probe ? [ { title : 'Verify connection' , task : ( ) => executor . execOrThrow ( probe ) } ] : [ ] ) ,
137137 ] , { concurrent : false } ) ;
138138 } ,
139139 } ]
@@ -143,13 +143,13 @@ function buildTasks(executor: RemoteExecutor, config: ShipnodeConfig) {
143143 task : ( _ctx : object , task : any ) => task . newListr ( [
144144 {
145145 title : `Create release structure at ${ config . remotePath } ` ,
146- task : ( ) => execOrThrow ( executor ,
146+ task : ( ) => executor . execOrThrow (
147147 `mkdir -p "${ config . remotePath } /releases" "${ config . remotePath } /shared" "${ config . remotePath } /.shipnode"` ,
148148 ) ,
149149 } ,
150150 {
151151 title : 'Configure Caddy include' ,
152- task : ( ) => execOrThrow ( executor ,
152+ task : ( ) => executor . execOrThrow (
153153 'SUDO=""; [ "$EUID" -ne 0 ] && SUDO="sudo"; ' +
154154 '$SUDO mkdir -p /etc/caddy/conf.d /var/log/caddy && ' +
155155 'grep -q "import /etc/caddy/conf.d" /etc/caddy/Caddyfile 2>/dev/null || ' +
@@ -164,13 +164,6 @@ function buildTasks(executor: RemoteExecutor, config: ShipnodeConfig) {
164164 ) ;
165165}
166166
167- async function execOrThrow ( executor : RemoteExecutor , cmd : string ) : Promise < void > {
168- const result = await executor . exec ( cmd ) ;
169- if ( result . exitCode !== 0 ) {
170- const detail = ( result . stderr || result . stdout ) . trim ( ) ;
171- throw new Error ( detail || `Command failed with exit code ${ result . exitCode } ` ) ;
172- }
173- }
174167
175168function sh ( s : string ) : string {
176169 return s . replace ( / ' / g, "'\"'\"'" ) ;
0 commit comments