@leverege/build-tools 2.107.0 → 2.108.1

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.107.0",
3
+ "version": "2.108.1",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -47,6 +47,7 @@
47
47
  "helmwhat": "src/helmup.sh",
48
48
  "hook-and-release": "src/hook-and-release.mjs",
49
49
  "init-my-chart": "src/init-my-chart/init-my-chart.mjs",
50
+ "sync-chart-version": "src/sync-chart-version.mjs",
50
51
  "k8scale": "src/k8scale.sh",
51
52
  "k8x": "src/k8x.sh",
52
53
  "klog": "src/klog.sh",
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+ /* eslint-disable */
3
+ /*
4
+ * Keep helm/Chart.yaml in sync with package.json (the "mirror" model):
5
+ * version = <package.json version>
6
+ * appVersion = v<package.json version>
7
+ *
8
+ * package.json's version is the single source of truth. Run automatically from
9
+ * the pre-commit hook (.har/pre-commit) and available manually as `yarn sync:chart`.
10
+ *
11
+ * - Self-stages helm/Chart.yaml so the change lands in the triggering commit.
12
+ * - Idempotent: a no-op (exit 0, no git add) when already in sync.
13
+ * - Line-targeted edits, so no YAML dependency is needed.
14
+ */
15
+
16
+ import { join } from 'node:path'
17
+ import fs from 'node:fs'
18
+ import { execSync } from 'node:child_process'
19
+
20
+ const cdir = process.cwd()
21
+ const pkg = JSON.parse( fs.readFileSync( new URL( join( cdir, 'package.json' ), import.meta.url ), 'utf8' ) )
22
+ const version = pkg.version
23
+ const appVersion = `v${version}`
24
+
25
+ const chartUrl = new URL( join( cdir, join( 'helm', 'Chart.yaml' ) ), import.meta.url )
26
+ let chart
27
+ try {
28
+ chart = fs.readFileSync( chartUrl, 'utf8' )
29
+ } catch {
30
+ process.exit( 0 ) // no chart in this project — nothing to sync
31
+ }
32
+
33
+ // Match the top-level `version:` (not `apiVersion:`) and `appVersion:` lines.
34
+ const updated = chart
35
+ .replace( /^version:.*$/m, `version: ${version}` )
36
+ .replace( /^appVersion:.*$/m, `appVersion: ${appVersion}` )
37
+
38
+ if ( updated === chart ) {
39
+ process.exit( 0 ) // already in sync
40
+ }
41
+
42
+ fs.writeFileSync( chartUrl, updated )
43
+ console.log( `sync-chart-version: helm/Chart.yaml -> version: ${version}, appVersion: ${appVersion}` )
44
+
45
+ try {
46
+ execSync( 'git add helm/Chart.yaml', { stdio : 'ignore' } )
47
+ } catch {
48
+ // Not in a git context (or add failed) — the file is written regardless.
49
+ }