@leverege/build-tools 2.107.0 → 2.108.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.107.0",
3
+ "version": "2.108.0",
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,47 @@
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 fs from 'node:fs'
17
+ import { execSync } from 'node:child_process'
18
+
19
+ const pkg = JSON.parse( fs.readFileSync( new URL( '../package.json', import.meta.url ), 'utf8' ) )
20
+ const version = pkg.version
21
+ const appVersion = `v${version}`
22
+
23
+ const chartUrl = new URL( '../helm/Chart.yaml', import.meta.url )
24
+ let chart
25
+ try {
26
+ chart = fs.readFileSync( chartUrl, 'utf8' )
27
+ } catch {
28
+ process.exit( 0 ) // no chart in this project — nothing to sync
29
+ }
30
+
31
+ // Match the top-level `version:` (not `apiVersion:`) and `appVersion:` lines.
32
+ const updated = chart
33
+ .replace( /^version:.*$/m, `version: ${version}` )
34
+ .replace( /^appVersion:.*$/m, `appVersion: ${appVersion}` )
35
+
36
+ if ( updated === chart ) {
37
+ process.exit( 0 ) // already in sync
38
+ }
39
+
40
+ fs.writeFileSync( chartUrl, updated )
41
+ console.log( `sync-chart-version: helm/Chart.yaml -> version: ${version}, appVersion: ${appVersion}` )
42
+
43
+ try {
44
+ execSync( 'git add helm/Chart.yaml', { stdio : 'ignore' } )
45
+ } catch {
46
+ // Not in a git context (or add failed) — the file is written regardless.
47
+ }