@leverege/build-tools 2.52.0-pedro.9 → 2.52.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.52.0-pedro.9",
3
+ "version": "2.52.0",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -47,7 +47,6 @@
47
47
  "pull-git": "src/pull-git.sh",
48
48
  "push-my-chart": "src/push-my-chart.mjs",
49
49
  "refresh-npm-token": "src/refresh-npm-token.mjs",
50
- "refresh-py-idx": "src/refresh-py-idx.mjs",
51
50
  "send-to-slack": "src/send-to-slack.mjs",
52
51
  "tag-release": "src/tag-release.mjs",
53
52
  "unleash": "src/unleash.mjs"
@@ -62,10 +61,10 @@
62
61
  "command-line-usage": "^7.0.3",
63
62
  "deepmerge": "^4.3.1",
64
63
  "enquirer": "^2.4.1",
65
- "execa": "^9.3.1",
64
+ "execa": "^9.4.0",
66
65
  "glob": "^11.0.0",
67
66
  "handlebars": "^4.7.8",
68
- "inquirer": "^10.2.2",
67
+ "inquirer": "^11.0.2",
69
68
  "js-yaml": "^4.1.0",
70
69
  "ms": "^2.1.3",
71
70
  "npm-registry-fetch": "^17.1.0",
@@ -74,11 +73,11 @@
74
73
  "read-pkg": "^9.0.1",
75
74
  "readline-sync": "^1.4.10",
76
75
  "semver": "^7.6.3",
77
- "simple-git": "^3.26.0",
78
- "zx": "^8.1.6"
76
+ "simple-git": "^3.27.0",
77
+ "zx": "^8.1.7"
79
78
  },
80
79
  "devDependencies": {
81
80
  "@leverege/eslint-config-leverege": "^4.2.0",
82
81
  "npm": "^10.8.3"
83
82
  }
84
- }
83
+ }
package/src/Docker.mjs CHANGED
@@ -40,8 +40,12 @@ COPY ./.npmrc /usr/src/app/.npmrc
40
40
  RUN apk --no-cache add openssh-client && \
41
41
  apk --update add --no-cache --virtual build-dep g++ gcc libgcc \\
42
42
  libstdc++ linux-headers make {{apkadds}} && \
43
- npm install -g npm@10 && \
44
- npm ci --only=production --ignore-scripts --no-optional {{npmlogging}} && \
43
+ npm install -g npm@10
44
+
45
+ {{preInstallPluginfile}}
46
+
47
+ # Removed --ignore-scripts from npm ci because it was causing issues with python native build
48
+ RUN npm ci --only=production --no-optional {{npmlogging}} && \
45
49
  rm -f /usr/src/app/.npmrc /root/.ssh/*
46
50
 
47
51
  # --------------------------------------------------------------
@@ -67,7 +71,7 @@ COPY --chown=node:node --from=intermediate /usr/src/app /usr/src/app
67
71
 
68
72
  USER {{runuser}}
69
73
  COPY ./bashrc /home/node/.bashrc
70
- CMD [ "/bin/bash", "-c", "node index.js" ]`
74
+ CMD [ "/bin/bash", "-c", "source /home/node/.bashrc && node index.js" ]`
71
75
 
72
76
  const pluginTemplate = `
73
77
  # Dockerfile.plugin - optionally extend the service Docker image
@@ -132,6 +136,19 @@ dunm() {
132
136
  du -sh /usr/src/app/node_modules/* | sort -sh
133
137
  }
134
138
  `
139
+ const cloudBuildSteps = `
140
+ steps:
141
+ - name: 'gcr.io/cloud-builders/docker'
142
+ args:
143
+ - 'build'
144
+ - '--network=cloudbuild'
145
+ - '-t'
146
+ - '{{imageName}}:{{imageVersion}}'
147
+ - '.'
148
+
149
+ images:
150
+ - '{{imageName}}:{{imageVersion}}'
151
+ `
135
152
 
136
153
  const defaultSettings = {
137
154
  apkadds : '',
@@ -139,6 +156,7 @@ const defaultSettings = {
139
156
  nodeimage : 'iron-alpine',
140
157
  npmlogging : '--silent',
141
158
  pluginfile : '# NO PLUGIN',
159
+ preInstallPluginfile : '# NO PRE-INSTALL PLUGIN',
142
160
  regvers : 'package.version',
143
161
  runuser : 'node',
144
162
  }
@@ -168,8 +186,14 @@ const generateDockerfile = ( settings = defaultSettings ) => {
168
186
 
169
187
  const bashrcFile = './docker/bashrc'
170
188
  if ( !fs.existsSync( bashrcFile ) ) {
189
+ let bf = bashrcTemplate
190
+ const bashrcFilePlugin = './docker/Bashrc.plugin'
191
+ if ( fs.existsSync( bashrcFilePlugin ) ) {
192
+ const bashrcAdditions = fs.readFileSync( bashrcFilePlugin )
193
+ bf = `${bf}\n${bashrcAdditions}`
194
+ }
171
195
  warning( `creating the missing ${bashrcFile} file in the docker directory` )
172
- fs.writeFileSync( bashrcFile, bashrcTemplate )
196
+ fs.writeFileSync( bashrcFile, bf )
173
197
  }
174
198
 
175
199
  const dockerfilePlugin = './docker/Dockerfile.plugin'
@@ -194,7 +218,12 @@ const generateDockerfile = ( settings = defaultSettings ) => {
194
218
  errorExit( `***ERROR: something went wrong with ${dockerfilePlugin} plugin creation` )
195
219
  }
196
220
 
197
- const compiled = handlebars.compile( dockerfileTemplate )
221
+ const dockerfilePrePlugin = './docker/DockerfilePreInstall.plugin'
222
+ if ( fs.existsSync( dockerfilePrePlugin ) ) {
223
+ defaultSettings.preInstallPluginfile = fs.readFileSync( dockerfilePrePlugin )
224
+ }
225
+
226
+ const compiled = handlebars.compile( dockerfileTemplate, { noEscape : true } )
198
227
  const replaced = compiled( settings )
199
228
  // temporarily write the Dockerfile to the docker subdir - the container
200
229
  // image builder will then move it over to the build subdir
@@ -226,8 +255,10 @@ const validateCloudBuildBucket = async ( artifactProject ) => {
226
255
  }
227
256
 
228
257
  const buildContainerImage = async ( {
229
- artifactProject, artifactRegistry, containerName, imageVersion, isNpmWorkspace,
258
+ artifactProject, artifactRegistry, containerName,
259
+ imageVersion, isNpmWorkspace, options
230
260
  } ) => {
261
+ const { useCloudBuildFile } = options || {}
231
262
  const buildWorkspace = './build/workspace' // passed to Cloud Build
232
263
  const imageName = `${artifactRegistry}/images/${containerName}`
233
264
 
@@ -256,14 +287,24 @@ const buildContainerImage = async ( {
256
287
  const { fullName : builderName } = await getGcpAccount()
257
288
  const gcloudBuild = `time gcloud builds submit --project ${artifactProject}`
258
289
  const gcloudLogs = `--gcs-log-dir ${formCloudBuildBucketName( artifactProject )}/log`
259
- const gcloudTags = `--tag ${imageName}:${imageVersion}`
290
+ let gcloudTags = `--tag ${imageName}:${imageVersion}`
291
+
292
+ if ( useCloudBuildFile ) {
293
+ const cloudBuildFile = './docker/cloudbuild.yaml'
294
+ gcloudTags = `--config=${cloudBuildFile}`
295
+ const cbst = handlebars.compile( cloudBuildSteps, { noEscape : true } )
296
+ const cbs = cbst( { artifactProject, artifactRegistry, imageName, imageVersion } )
297
+
298
+ fs.writeFileSync( cloudBuildFile, cbs )
299
+ }
260
300
 
261
301
  log( chalk.green.bold( `
262
302
  *** Submitting Build as ${builderName} ***
263
303
  ${gcloudBuild} \\
264
- ${gcloudLogs} \\
265
- ${gcloudTags}
304
+ ${gcloudLogs} \\
305
+ ${gcloudTags}
266
306
  ` ) )
307
+
267
308
 
268
309
  if ( process.env.DRY_RUN === '1' ) {
269
310
  log( '\n***Exiting from DRY_RUN\n' )
package/src/Utils.mjs CHANGED
@@ -9,7 +9,7 @@ import YAML from 'js-yaml'
9
9
 
10
10
  let debugEnabled = process.env.BUILD_TOOLS_DEBUG === '1'
11
11
 
12
- export const disableDebug = () => debugEnabled = false
12
+ export const disableDebug = () => { debugEnabled = false }
13
13
 
14
14
  /* eslint-disable no-console */
15
15
  export const err = console.error
@@ -135,11 +135,10 @@ const checkAndAnnounce = () => {
135
135
  checkForLatest()
136
136
  .then( ( latestVersion ) => {
137
137
  if ( semverLt( thisVersion, latestVersion ) ) {
138
- console.log( chalk.white`
139
- Update available ${chalk.grey( thisVersion )} \u2b62 ${chalk.green( latestVersion )}
140
- Run ${chalk.cyan( 'npm i -g @leverege/build-tools' )} to update
141
- `
142
- )
138
+ console.log( chalk.white( '\n' +
139
+ ` Update available ${chalk.yellow( thisVersion )} \u2b62 ${chalk.green( latestVersion )}\n` +
140
+ ` Run ${chalk.cyan( 'npm i -g @leverege/build-tools' )} to update\n`
141
+ ) )
143
142
  process.exit( 1 )
144
143
  } else {
145
144
  process.exit( 0 )
@@ -26,8 +26,22 @@ if ( refreshErr && !process.env.BUILD_TOOLS_DEBUG ) {
26
26
  log( refreshErr ) // most likely the token refreshed message
27
27
  }
28
28
 
29
+ const options = {}
30
+ let imageVersion = null
29
31
  // Expected to be invoked like docker-to-registry v1.2.3
30
- const imageVersion = process.argv[2]
32
+ for ( let n = 2; n < process.argv.length; n++ ) {
33
+ if ( process.argv[n].startsWith( '-' ) ) {
34
+ const str = process.argv[n].slice( 1 )
35
+ if ( str.indexOf( '=' ) > 0 ) {
36
+ const [key, value] = str.split( '=' )
37
+ options[key] = value
38
+ } else {
39
+ options[str] = true
40
+ }
41
+ } else {
42
+ imageVersion = process.argv[n]
43
+ }
44
+ }
31
45
  if ( !imageVersion ) {
32
46
  errorExit( '***Error: docker-to-registry requires an image version' )
33
47
  }
@@ -151,12 +165,13 @@ if ( giveGuidance ) {
151
165
  }
152
166
 
153
167
  // do chart checks too
154
- const chart = helmChart?.yaml['Chart.yaml']
155
- const values = helmChart?.yaml['values.yaml']
156
- const expectedChartRegistry = `${artifactRegistry}/images`
168
+ if ( options?.helmChecks !== 'false' ) {
169
+ const chart = helmChart?.yaml['Chart.yaml']
170
+ const values = helmChart?.yaml['values.yaml']
171
+ const expectedChartRegistry = `${artifactRegistry}/images`
157
172
 
158
- if ( expectedChartRegistry !== values.image?.registry ) {
159
- log( `
173
+ if ( expectedChartRegistry !== values.image?.registry ) {
174
+ log( `
160
175
  ${chalk.red.bold( '***Error: mismatched package.json registry and helm/values.yaml' )}
161
176
 
162
177
  The registry specified in the package.json leverege stanza does not line up
@@ -172,8 +187,8 @@ if ( expectedChartRegistry !== values.image?.registry ) {
172
187
  values.yaml registry => ${chalk.green.bold( expectedChartRegistry )}
173
188
  ` )
174
189
 
175
- if ( !values.image ) {
176
- log( `
190
+ if ( !values.image ) {
191
+ log( `
177
192
  ${chalk.yellow.bold( '***DEPRECATED: legacy helm charts detected' )}
178
193
 
179
194
  The helm chart structure appears to be based on the pre-ignition helm chart
@@ -181,9 +196,10 @@ if ( expectedChartRegistry !== values.image?.registry ) {
181
196
  its job.
182
197
 
183
198
  ` )
184
- }
199
+ }
185
200
 
186
- process.exit( 1 )
201
+ process.exit( 1 )
202
+ }
187
203
  }
188
204
 
189
205
  // Give the summary and the user a chance to proceed or not
@@ -256,7 +272,7 @@ if ( isNpmWorkspace ) {
256
272
  await shellCmd( 'npm install --package-lock-only --workspaces false', { stdio : 'inherit' } )
257
273
  }
258
274
 
259
- await docker.buildContainerImage( { artifactProject, artifactRegistry, containerName, imageVersion, isNpmWorkspace } )
275
+ await docker.buildContainerImage( { ...repoDescr, options, imageVersion } )
260
276
 
261
277
  if ( willGitTag ) {
262
278
  const tagDescription = `docker_${imageVersion}`
@@ -213,7 +213,6 @@ try {
213
213
  const hostingPrefix = CHANNEL ? '' : 'hosting:'
214
214
 
215
215
  await $( { ac } )`npm run clean && DOTENV_CONFIG_PATH=${path.join( process.cwd(), '.env.temp' )} DEPLOYMENT_TARGET=${TARGET.siteId} npm run build && firebase use ${TARGET.projectId} && firebase ${deployType} --only ${hostingPrefix}${TARGET.siteId}`
216
- .pipe( process.stdout )
217
216
  } catch ( err ) {
218
217
  console.error( err )
219
218
  }
@@ -130,8 +130,9 @@ const ac = new AbortController()
130
130
 
131
131
  EXIT_EVENTS
132
132
  .forEach( ( event ) => {
133
- process.on( event, () => {
133
+ process.on( event, ( d ) => {
134
134
  if ( !exited ) {
135
+ console.error( d )
135
136
  exited = true
136
137
  fs.removeSync( path.join( process.cwd(), '.env.temp' ) )
137
138
  ac.abort()
@@ -142,7 +143,7 @@ EXIT_EVENTS
142
143
  await fs.writeFile( path.join( process.cwd(), '.env.temp' ), envFileContent )
143
144
 
144
145
  try {
145
- await $( { ac } )`DOTENV_CONFIG_PATH=${path.join( process.cwd(), '.env.temp' )} DEPLOYMENT_TARGET=${TARGET.siteId} npm run serve --colors`.pipe( process.stdout )
146
+ await $( { ac } )`DOTENV_CONFIG_PATH=${path.join( process.cwd(), '.env.temp' )} DEPLOYMENT_TARGET=${TARGET.siteId} npm run serve --colors`
146
147
  } catch ( err ) {
147
148
  console.error( err )
148
149
  }
@@ -17,6 +17,17 @@ config:
17
17
  # # timescale
18
18
  # PG_HOST: "cnpg-db-tsdb-basic-r.cnpg-operands"
19
19
 
20
+ # The settings on the left are for the "standard" legacy chart settings which
21
+ # specifiy the old k8s secrets setups and are the defaults values from the
22
+ # api-server helm chart.
23
+ psqlSecurity: # v----- these are for CNPG -----v
24
+ PSQL_SECRET_NAME: "authz-postgres" # "cnpg-db-psql-stack-postgres-pw"
25
+ PSQL_SECRET_KEY: "postgresql-password" # "password"
26
+ TSDB_SECRET_NAME: "postgresql-password" # "cnpg-db-tsdb-basic-postgres-pw"
27
+ TSDB_SECRET_KEY: "postgresql-password" # "password"
28
+ TSDB_DENSE_SECRET_NAME: "postgresql-password" # "cnpg-db-tsdb-dense-postgres-pw"
29
+ TSDB_DENSE_SECRET_KEY: "postgresql-password" # "password"
30
+
20
31
  autoscaling:
21
32
  minReplicas: 3
22
33
  maxReplicas: 12
@@ -1,3 +1,6 @@
1
1
  #!/bin/bash
2
2
 
3
+ # ensures the PG_PASSWORD secret exists and correct
4
+ ensureCnpgSecret PG_PASSWORD $SERVICE-postgres-pw
5
+
3
6
  kubectl apply -f cnpg-db-psql-stack/cluster.yaml $K8S_WHAT
@@ -1,3 +1,6 @@
1
1
  #!/bin/bash
2
- #
2
+
3
+ # ensures the TSDB_PASSWORD secret exists and correct
4
+ ensureCnpgSecret TSDB_PASSWORD $SERVICE-postgres-pw
5
+
3
6
  kubectl apply -f cnpg-db-tsdb-basic/cluster.yaml $K8S_WHAT
@@ -1,3 +1,6 @@
1
1
  #!/bin/bash
2
- #
2
+
3
+ # ensures the TSDB_DENSE_PASSWORD secret exists and correct
4
+ ensureCnpgSecret TSDB_DENSE_PASSWORD $SERVICE-postgres-pw
5
+
3
6
  kubectl apply -f cnpg-db-tsdb-dense/cluster.yaml $K8S_WHAT
@@ -2,7 +2,7 @@
2
2
  #
3
3
  showInstalling "Elastic Search 8"
4
4
 
5
- [ -z "$ELASTIC_CHART_VERSION" ] && ELASTIC_CHART_VERSION="21.3.10"
5
+ [ -z "$ELASTIC_CHART_VERSION" ] && ELASTIC_CHART_VERSION="21.3.17"
6
6
 
7
7
  OCI_CHART="oci://registry-1.docker.io/bitnamicharts/elasticsearch"
8
8
 
@@ -4,7 +4,7 @@ showInstalling "Redis"
4
4
 
5
5
  OCI_CHART="oci://registry-1.docker.io/bitnamicharts/redis"
6
6
 
7
- [ -z "$REDIS_CHART_VERSION" ] && REDIS_CHART_VERSION="20.0.5"
7
+ [ -z "$REDIS_CHART_VERSION" ] && REDIS_CHART_VERSION="20.1.3"
8
8
 
9
9
  helm upgrade --install redis $OCI_CHART \
10
10
  --values redis/redis-local.yaml \
package/src/helmdn.sh CHANGED
@@ -38,7 +38,6 @@ PLATFORM=(
38
38
  )
39
39
 
40
40
  SYSTEM=(
41
- cert-manager
42
41
  elastic
43
42
  preemptible-killer
44
43
  redis
package/src/helmup.sh CHANGED
@@ -543,14 +543,15 @@ function initializeCnpgOperand() {
543
543
  local IMAGINE_PW_NAME="$CNPG_SERVICE-imagine-pw"
544
544
  local POSTGRES_PW_NAME="$CNPG_SERVICE-postgres-pw"
545
545
 
546
- printf "\nCreating imagine db password for `color g $CNPG_SERVICE`\n"
547
- kubectl create secret generic -n $CNPG_NAMESPACE "$IMAGINE_PW_NAME" \
548
- --from-literal=username="imagine" \
549
- --from-literal=password="$(generatePassword)" &> $DEVNULL
550
- warnOnError $? "the `color y $IMAGINE_PW_NAME` secret may already exist"
546
+ # TODO: we use postgres root password for access - that is bad - fix it?
547
+ # printf "\nCreating imagine db password for `color g $CNPG_SERVICE`\n"
548
+ # kubectl create secret generic -n $CNPG_NAMESPACE "$IMAGINE_PW_NAME" \
549
+ # --from-literal=username="imagine" \
550
+ # --from-literal=password="$(generatePassword)" &> $DEVNULL
551
+ # warnOnError $? "the `color y $IMAGINE_PW_NAME` secret may already exist"
551
552
 
552
- # reflect the secret to default namespace
553
- reflectSecretIntoNamespaces $IMAGINE_PW_NAME $CNPG_NAMESPACE "default"
553
+ # # reflect the secret to default namespace
554
+ # reflectSecretIntoNamespaces $IMAGINE_PW_NAME $CNPG_NAMESPACE "default"
554
555
 
555
556
  printf "\nCreating postgres db password for `color g $CNPG_SERVICE`\n"
556
557
  kubectl create secret generic -n $CNPG_NAMESPACE "$POSTGRES_PW_NAME" \
@@ -670,6 +671,23 @@ EOSNAPSC
670
671
  sleep 2 # hold up processing for a moment to allow IAM mods to propagate
671
672
  }
672
673
 
674
+ function ensureCnpgSecret() {
675
+ local mgrSecret=$1
676
+ local k8sSecret=$2
677
+
678
+ service-man --from-helmup --sync-secrets ${mgrSecret}=${k8sSecret}
679
+
680
+ if [ $? -ne 0 ];
681
+ then
682
+ cat<<BAD_SECRETS
683
+ `color r "There appears to be a problem with one, or both of the secrets. Please
684
+ rectify the situation and try again."`
685
+
686
+ BAD_SECRETS
687
+ exit 1
688
+ fi
689
+ }
690
+
673
691
  function installVeleroEnvironment() {
674
692
  # Follows instructions => https://github.com/vmware-tanzu/velero-plugin-for-gcp
675
693
  showInstalling "Velero Backup Management"
@@ -1,124 +0,0 @@
1
- #!/usr/bin/env node
2
- /* eslint-disable max-len */
3
- /* eslint-disable security/detect-non-literal-fs-filename */
4
- /* eslint-disable no-console */
5
-
6
- import { execSync } from 'child_process';
7
- import fs from 'fs';
8
- import os from 'os';
9
- import path from 'path';
10
-
11
- // Execute gcloud command to get the token
12
- const TOKEN = execSync( 'gcloud auth print-access-token' ).toString().trim();
13
-
14
- // Write to pip.conf
15
- const pipConfigDir = path.join( os.homedir(), '.config', 'pip' );
16
- fs.mkdirSync( pipConfigDir, { recursive : true } );
17
- const pipConfigContent = `
18
- [global]
19
- extra-index-url = https://oauth2accesstoken:${TOKEN}@us-python.pkg.dev/leverege-registry/leverege-python-packages/simple/
20
- `;
21
- fs.writeFileSync( path.join( pipConfigDir, 'pip.conf' ), pipConfigContent );
22
- console.log( 'Updated ~/.config/pip/pip.conf' );
23
-
24
- // Write to pypirc
25
- const pypircContent = `
26
- [distutils]
27
- index-servers =
28
- leverege-python-packages
29
-
30
- [leverege-python-packages]
31
- repository: https://us-python.pkg.dev/leverege-registry/leverege-python-packages/
32
- username: oauth2accesstoken
33
- password: ${TOKEN}
34
- `;
35
- fs.writeFileSync( path.join( os.homedir(), '.pypirc' ), pypircContent );
36
- console.log( 'Updated ~/.pypirc\n' );
37
-
38
- // Escape for sed
39
-
40
- const UV_EXTRA_INDEX_URL = `https://foo:${TOKEN}@us-python.pkg.dev/leverege-registry/leverege-python-packages/simple`;
41
-
42
- const SHELLS = [ 'bash', 'dash', 'zsh', 'fish' ];
43
-
44
- SHELLS.forEach( ( shell ) => {
45
- try {
46
- execSync( `command -v ${shell}` );
47
- let configFile;
48
- switch ( shell ) {
49
- case 'bash':
50
- configFile = path.join( os.homedir(), '.bashrc' );
51
- break;
52
- case 'dash':
53
- configFile = path.join( os.homedir(), '.profile' );
54
- break;
55
- case 'zsh':
56
- configFile = path.join( os.homedir(), '.zshrc' );
57
- break;
58
- case 'fish':
59
- configFile = path.join( os.homedir(), '.config', 'fish', 'config.fish' );
60
- break;
61
- default:
62
- console.log( `Shell ${shell} is not supported.` );
63
- return;
64
- }
65
-
66
- console.log( `Updating shell configuration in ${configFile}` );
67
-
68
- let configContent = fs.readFileSync( configFile, 'utf8' );
69
- const regex = /export UV_EXTRA_INDEX_URL=.*/;
70
- const newLine = `export UV_EXTRA_INDEX_URL=${UV_EXTRA_INDEX_URL}`;
71
-
72
- if ( regex.test( configContent ) ) {
73
- configContent = configContent.replace( regex, newLine );
74
- } else {
75
- configContent += `\n${newLine}\n`;
76
- }
77
-
78
- fs.writeFileSync( configFile, configContent );
79
- } catch ( error ) {
80
- console.log( `Shell ${shell} is not installed.` );
81
- }
82
- } );
83
-
84
- function getParentShell() {
85
- let ppid = execSync( 'ps -p $$ -o ppid=' ).toString().trim();
86
- let shell = execSync( `ps -p ${ppid} -o comm=` ).toString().trim();
87
-
88
- while ( ppid !== '1' ) {
89
- ppid = execSync( `ps -p ${ppid} -o ppid=` ).toString().trim();
90
- shell = execSync( `ps -p ${ppid} -o comm=` ).toString().trim();
91
-
92
- const shellMatch = shell.match( /bash|dash|zsh|fish/ );
93
- if ( shellMatch ) {
94
- return shellMatch[0];
95
- }
96
- }
97
-
98
- return null
99
- }
100
-
101
- const shell = getParentShell();
102
-
103
- if ( !shell ) {
104
- console.log( '\nCould not determine parent shell. Please source your shell configuration to apply the changes.\n' );
105
- console.log( 'Example (bash): source ~/.bashrc' );
106
- console.log( 'Example (dash): source ~/.profile' );
107
- console.log( 'Example (zsh): source ~/.zshrc' );
108
- console.log( 'Example (fish): source ~/.config/fish/config.fish' );
109
- process.exit( 1 );
110
- }
111
-
112
- console.log( `\nSourcing shell configuration for ${shell}` );
113
-
114
- switch ( shell ) {
115
- case 'bash':
116
- case 'dash':
117
- case 'zsh':
118
- case 'fish':
119
- execSync( shell, { stdio : 'inherit' } );
120
- console.log( `Sourced shell configuration for ${shell}` );
121
- break;
122
- default:
123
- console.log( `Shell ${shell} is not supported.` );
124
- }