@leverege/build-tools 2.47.3 → 2.47.5

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.47.3",
3
+ "version": "2.47.5",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -16,6 +16,7 @@
16
16
  "build-tools": "src/build-tools.mjs",
17
17
  "chart-to-registry": "src/chart-to-registry.mjs",
18
18
  "circleate": "src/circleate.sh",
19
+ "cnpg-snapshot": "src/cnpg-snapshot.mjs",
19
20
  "decrypt-secrets": "src/decrypt-secrets.sh",
20
21
  "dirty-git": "src/dirty-git.sh",
21
22
  "dockreate": "src/dockreate.sh",
@@ -71,10 +72,11 @@
71
72
  "readline-sync": "^1.4.10",
72
73
  "semver": "^7.6.0",
73
74
  "simple-git": "^3.22.0",
75
+ "tempy": "^3.1.0",
74
76
  "zx": "^7.2.3"
75
77
  },
76
78
  "devDependencies": {
77
79
  "@leverege/eslint-config-leverege": "^4.2.0",
78
- "npm": "^10.4.0"
80
+ "npm": "^10.5.0"
79
81
  }
80
82
  }
package/src/Docker.mjs CHANGED
@@ -85,8 +85,7 @@ const pluginTemplate = `
85
85
  # a best practice.
86
86
  `
87
87
 
88
- const bashrcTemplate = `
89
- #!/bin/bash
88
+ const bashrcTemplate = `#!/bin/bash
90
89
  #
91
90
  alias h=history
92
91
 
@@ -117,12 +116,16 @@ cmetrics()
117
116
 
118
117
  cmstat()
119
118
  {
120
- wget -qO- localhost:5111${1}
119
+ wget -qO- localhost:5111
121
120
  }
122
121
 
123
122
  cmclear()
124
123
  {
125
- cmstat /status/clear
124
+ # Future me - thinking this should call cmstat and pass in the endpoint as
125
+ # a parameter? Well don't do it - without escaping the dollar 1 in cmstat
126
+ # the port will end up being 51111, and escaping causes linting to complain
127
+ # about unnecessary escaping.
128
+ wget -qO- localhost:5111/status/clear
126
129
  }
127
130
 
128
131
  dunm() {
@@ -283,6 +286,7 @@ const repoCleanup = async () => {
283
286
  'docker/.keep',
284
287
  'docker/.npmrc',
285
288
  'docker/.gitignore',
289
+ 'docker/.previous',
286
290
  'docker/Dockerfile',
287
291
  'docker/workspace',
288
292
  ]
package/src/Utils.mjs CHANGED
@@ -334,7 +334,7 @@ export const parseHelmChart = async ( helmroot = './helm' ) => {
334
334
  } )
335
335
  }
336
336
 
337
- export const analyzeRepository = async () => {
337
+ export const analyzeRepository = async ( giveGuidance ) => {
338
338
  const gitRoot = await getGitRootDirectory()
339
339
  const subPkgs = await glob( `${gitRoot}/packages/**/package.json`, { ignore : '/**/node_modules/**' } )
340
340
  const helmChart = await parseHelmChart()
@@ -382,6 +382,12 @@ export const analyzeRepository = async () => {
382
382
  } catch ( error ) {
383
383
  errorExit( error )
384
384
  }
385
+
386
+ if ( giveGuidance ) {
387
+ // let npm build run in guidance mode
388
+ await shellCmd( 'npm run build' )
389
+ }
390
+
385
391
  const containerName = closestPackageJson.name
386
392
  const artifactProject = closestPackageJson.artifactRegistry.project
387
393
  const artifactRegistry = closestPackageJson.leverege.registry
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from 'node:fs'
4
+
5
+ import handlebars from 'handlebars'
6
+ import { temporaryFile } from 'tempy'
7
+
8
+ import {
9
+ getDateTimestamp,
10
+ debug,
11
+ shellCmd,
12
+ } from './Utils.mjs'
13
+
14
+ const backup = `
15
+ apiVersion: postgresql.cnpg.io/v1
16
+ kind: Backup
17
+ metadata:
18
+ name: {{clusterName}}-snapshot-{{dateTimestamp}}
19
+ namespace: cnpg-operands
20
+ labels:
21
+ cnpg-backup: manual
22
+ cnpg-operand: {{clusterName}}
23
+ spec:
24
+ method: volumeSnapshot
25
+ cluster:
26
+ name: {{clusterName}}`
27
+
28
+ const dateTimestamp = getDateTimestamp()
29
+ const clusterName = process.argv[2]
30
+ const compiled = handlebars.compile( backup )
31
+ const replaced = compiled( { dateTimestamp, clusterName } )
32
+ const tmpfile = temporaryFile()
33
+
34
+ debug( { replaced, tmpfile }, '<==Apply That' )
35
+
36
+ fs.writeFileSync( tmpfile, replaced ) // eslint-disable-line security/detect-non-literal-fs-filename
37
+ await shellCmd( 'overwhelm' )
38
+ await shellCmd( `kubectl apply -f ${tmpfile}` )
@@ -29,6 +29,9 @@ if ( !imageVersion ) {
29
29
  errorExit( '***Error: docker-to-registry requires an image version' )
30
30
  }
31
31
 
32
+ // may use guide-me or guideme to ask for update guidance
33
+ const giveGuidance = imageVersion.match( /^guide-*me$/ ) !== null
34
+
32
35
  const willGitTag = imageVersion.match( /^v\d+\.\d+\.\d+$/ )
33
36
  const tagInfo = willGitTag ?
34
37
  chalk.yellow.bold( 'will be git tagged' ) :
@@ -67,7 +70,7 @@ if ( !fs.existsSync( './helm' ) ) {
67
70
  process.exit( 1 )
68
71
  }
69
72
 
70
- const repoDescr = await analyzeRepository()
73
+ const repoDescr = await analyzeRepository( giveGuidance )
71
74
  debug( { repoDescr }, '<==The Repo Description' )
72
75
 
73
76
  const dockerInfo = await docker.generateDockerfile()
@@ -82,7 +85,7 @@ const {
82
85
  isNpmWorkspace,
83
86
  } = repoDescr
84
87
 
85
- if ( imageVersion === 'guide-me' ) {
88
+ if ( giveGuidance ) {
86
89
  await docker.validateCloudBuildBucket( artifactProject )
87
90
  }
88
91
 
@@ -92,7 +95,7 @@ const registryFolder = `${artifactRegistry}/images/${containerName}`
92
95
  log( chalk.green.bold( 'Updating dependencies and workspace...' ) )
93
96
  await shellCmd( 'npm install', { stdio : 'inherit' } )
94
97
 
95
- if ( imageVersion === 'guide-me' ) {
98
+ if ( giveGuidance ) {
96
99
  await docker.repoCleanup() // adjusts gitignore files and removes cruft
97
100
  /* eslint-disable max-len */
98
101
  log( `
@@ -1,3 +1,9 @@
1
1
  #!/bin/bash
2
2
 
3
- kubectl delete -f db-timescale-dense/db-timescale-dense.yaml $K8S_WHAT
3
+ printf "\nHibernating the db-timescale-dense cluster...\n"
4
+ kubectl cnpg hibernate on -n cnpg-operands db-timescale-dense
5
+
6
+ # *** DANGER ***
7
+ # kubectl delete will destroy the cluster
8
+ # *** DANGER ***
9
+ # kubectl delete -f db-timescale-dense/db-timescale-dense.yaml $K8S_WHAT
@@ -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="18.12.1"
7
+ [ -z "$REDIS_CHART_VERSION" ] && REDIS_CHART_VERSION="18.16.1"
8
8
 
9
9
  helm upgrade --install redis $OCI_CHART \
10
10
  --values redis/redis-local.yaml \
@@ -13,11 +13,13 @@ deployment:
13
13
  logs:
14
14
  general:
15
15
  format: json
16
- level: WARN # DEBUG
16
+ level: WARN # INFO # DEBUG
17
17
  access:
18
18
  enabled: true
19
19
  format: json
20
- bufferingSize: 10
20
+ # fields:
21
+ # headers:
22
+ # defaultmode: keep
21
23
 
22
24
  # Custom entry points may be added here - the first two are port definitions
23
25
  # for both unsecured and secured MQTT ports used by connect. Note that the