Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

- run: npm ci

- run: node --test test/cli.test.mjs
- run: npm test

- name: Verify tag matches package.json version
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

- run: npm ci

- run: node --test test/cli.test.mjs
- run: npm test

- name: Smoke test via node bin/cli.mjs --help
run: node bin/cli.mjs --help
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.6.1] - 2026-08-29

### Fixed

- `kcc-inventory --json` now drains its complete stdout payload before the
process exits, so piping a full inventory into `jq` cannot receive a
truncated JSON document.

## [0.6.0] - 2026-08-29

### Added
Expand Down Expand Up @@ -123,6 +131,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
directory is listed in `kustomization.yaml`'s explicit `resources:`
(and vice versa) — catches files Flux silently ignores.

[0.6.1]: https://github.com/nitra/cfr/compare/v0.6.0...v0.6.1
[0.6.0]: https://github.com/nitra/cfr/compare/v0.5.0...v0.6.0
[0.5.0]: https://github.com/nitra/cfr/compare/v0.4.0...v0.5.0
[0.4.0]: https://github.com/nitra/cfr/compare/v0.3.0...v0.4.0
Expand Down
8 changes: 6 additions & 2 deletions bin/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ async function main(argv) {
}

main(process.argv.slice(2)).then(
(code) => process.exit(code),
// Не викликаємо process.exit(): він примусово обриває pending stdout
// writes. Для великого `kcc-inventory --json | jq ...` це давало
// неповний JSON, хоча scan уже завершився. exitCode зберігає статус,
// але дає Node дописати pipe перед природним завершенням процесу.
(code) => { process.exitCode = code; },
(err) => {
console.error(`✗ ${err.message || err}`);
process.exit(1);
process.exitCode = 1;
},
);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nitra/cfr",
"version": "0.6.0",
"version": "0.6.1",
"description": "A handful of small k8s/GitOps CLI utilities: `check` verifies every YAML file in a Kustomize directory is listed in kustomization.yaml's explicit resources: (and vice versa); `kcc-inventory` diffs a GCP Config Connector namespace against the live project to find drift; `get-resources` is that same scan without the diff.",
"keywords": [
"kustomize",
Expand Down
14 changes: 14 additions & 0 deletions test/json-output-contract.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';

const here = dirname(fileURLToPath(import.meta.url));
const cli = readFileSync(join(here, '..', 'bin', 'cli.mjs'), 'utf8');
const executable = cli.split('\n').filter((line) => !line.trimStart().startsWith('//')).join('\n');

test('CLI lets JSON stdout drain instead of force-exiting the process', () => {
assert.doesNotMatch(executable, /process\.exit\s*\(/);
assert.match(executable, /process\.exitCode\s*=\s*code/);
});
Loading