@ccdevkit/ccaudit 0.1.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.
Files changed (3) hide show
  1. package/bin/ccaudit +28 -0
  2. package/install.js +104 -0
  3. package/package.json +41 -0
package/bin/ccaudit ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const path = require('path');
5
+
6
+ const binaryName = process.platform === 'win32' ? 'ccaudit.exe' : 'ccaudit';
7
+ const binaryPath = path.join(__dirname, binaryName);
8
+
9
+ const child = spawn(binaryPath, process.argv.slice(2), {
10
+ stdio: 'inherit',
11
+ env: process.env,
12
+ });
13
+
14
+ child.on('error', (err) => {
15
+ if (err.code === 'ENOENT') {
16
+ console.error('ccaudit binary not found. Try reinstalling: npm install -g @ccdevkit/ccaudit');
17
+ } else {
18
+ console.error(`Failed to run ccaudit: ${err.message}`);
19
+ }
20
+ process.exit(1);
21
+ });
22
+
23
+ child.on('exit', (code, signal) => {
24
+ if (signal) {
25
+ process.exit(1);
26
+ }
27
+ process.exit(code ?? 0);
28
+ });
package/install.js ADDED
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const https = require('https');
6
+ const { execSync } = require('child_process');
7
+
8
+ const PACKAGE_VERSION = require('./package.json').version;
9
+
10
+ // Map Node.js platform/arch to Go GOOS/GOARCH
11
+ const PLATFORM_MAP = {
12
+ 'darwin-x64': { goos: 'darwin', goarch: 'amd64' },
13
+ 'darwin-arm64': { goos: 'darwin', goarch: 'arm64' },
14
+ 'linux-x64': { goos: 'linux', goarch: 'amd64' },
15
+ 'linux-arm64': { goos: 'linux', goarch: 'arm64' },
16
+ 'win32-x64': { goos: 'windows', goarch: 'amd64' },
17
+ 'win32-arm64': { goos: 'windows', goarch: 'arm64' },
18
+ };
19
+
20
+ const platformKey = `${process.platform}-${process.arch}`;
21
+ const platformInfo = PLATFORM_MAP[platformKey];
22
+
23
+ if (!platformInfo) {
24
+ console.error(`Unsupported platform: ${platformKey}`);
25
+ console.error(`Supported platforms: ${Object.keys(PLATFORM_MAP).join(', ')}`);
26
+ process.exit(1);
27
+ }
28
+
29
+ const { goos, goarch } = platformInfo;
30
+ const binaryName = process.platform === 'win32' ? 'ccaudit.exe' : 'ccaudit';
31
+ const assetName = `ccaudit-${goos}-${goarch}.tar.gz`;
32
+ const downloadUrl = `https://github.com/ccdevkit/ccaudit/releases/download/v${PACKAGE_VERSION}/${assetName}`;
33
+ const binDir = path.join(__dirname, 'bin');
34
+ const binaryPath = path.join(binDir, binaryName);
35
+
36
+ function makeRequest(url) {
37
+ return new Promise((resolve, reject) => {
38
+ const request = https.get(url, (response) => {
39
+ // Handle redirects (GitHub releases redirect to S3)
40
+ if (response.statusCode >= 300 && response.statusCode < 400 && response.headers.location) {
41
+ makeRequest(response.headers.location).then(resolve, reject);
42
+ return;
43
+ }
44
+
45
+ if (response.statusCode < 200 || response.statusCode >= 300) {
46
+ reject(new Error(`Failed to download: HTTP ${response.statusCode}`));
47
+ return;
48
+ }
49
+
50
+ const chunks = [];
51
+ response.on('data', (chunk) => chunks.push(chunk));
52
+ response.on('end', () => resolve(Buffer.concat(chunks)));
53
+ response.on('error', reject);
54
+ });
55
+
56
+ request.on('error', reject);
57
+ });
58
+ }
59
+
60
+ function extractTarGz(buffer, destDir) {
61
+ // Use tar command for extraction
62
+ // Windows 10+ includes tar.exe, and Git Bash/WSL also provide it
63
+ const tarball = path.join(destDir, 'temp.tar.gz');
64
+ fs.writeFileSync(tarball, buffer);
65
+
66
+ try {
67
+ // Use tar command - available on Windows 10+, macOS, and Linux
68
+ execSync(`tar -xzf "${tarball}" -C "${destDir}"`, { stdio: 'pipe' });
69
+ } finally {
70
+ fs.unlinkSync(tarball);
71
+ }
72
+ }
73
+
74
+ async function install() {
75
+ console.warn(`Downloading ccaudit for ${goos}/${goarch}...`);
76
+ console.warn(`URL: ${downloadUrl}`);
77
+
78
+ try {
79
+ // Ensure bin directory exists
80
+ if (!fs.existsSync(binDir)) {
81
+ fs.mkdirSync(binDir, { recursive: true });
82
+ }
83
+
84
+ const buffer = await makeRequest(downloadUrl);
85
+ console.warn(`Downloaded ${buffer.length} bytes`);
86
+
87
+ extractTarGz(buffer, binDir);
88
+
89
+ // Make binary executable (not needed on Windows)
90
+ if (process.platform !== 'win32') {
91
+ fs.chmodSync(binaryPath, 0o755);
92
+ }
93
+
94
+ console.warn(`Installed ccaudit to ${binaryPath}`);
95
+ } catch (error) {
96
+ console.error(`Failed to install ccaudit: ${error.message}`);
97
+ console.error('');
98
+ console.error('You can manually download the binary from:');
99
+ console.error(`https://github.com/ccdevkit/ccaudit/releases/tag/v${PACKAGE_VERSION}`);
100
+ process.exit(1);
101
+ }
102
+ }
103
+
104
+ install();
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@ccdevkit/ccaudit",
3
+ "version": "0.1.0",
4
+ "description": "Audit tool for Claude Code projects - runs compliance checks on code and agent actions",
5
+ "bin": {
6
+ "ccaudit": "bin/ccaudit"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node install.js"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/ccdevkit/ccaudit.git"
14
+ },
15
+ "keywords": [
16
+ "claude",
17
+ "claude-code",
18
+ "audit",
19
+ "compliance",
20
+ "ai",
21
+ "cli"
22
+ ],
23
+ "author": "Sullivan Digital",
24
+ "license": "MIT",
25
+ "bugs": {
26
+ "url": "https://github.com/ccdevkit/ccaudit/issues"
27
+ },
28
+ "homepage": "https://github.com/ccdevkit/ccaudit#readme",
29
+ "engines": {
30
+ "node": ">=18"
31
+ },
32
+ "os": [
33
+ "darwin",
34
+ "linux",
35
+ "win32"
36
+ ],
37
+ "cpu": [
38
+ "x64",
39
+ "arm64"
40
+ ]
41
+ }