@kandiforge/kandi-cli 0.45.7
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/bin/.gitkeep +0 -0
- package/package.json +41 -0
- package/scripts/CLAUDE.md +7 -0
- package/scripts/install.js +170 -0
package/bin/.gitkeep
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kandiforge/kandi-cli",
|
|
3
|
+
"version": "0.45.7",
|
|
4
|
+
"description": "Kandi CLI - AI-powered code generation and development tool",
|
|
5
|
+
"author": "Abstract Class Consulting Inc.",
|
|
6
|
+
"license": "PROPRIETARY",
|
|
7
|
+
"homepage": "https://github.com/KandiForge/apps",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/KandiForge/apps.git",
|
|
11
|
+
"directory": "spectacle/crates/forge"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/KandiForge/apps/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"kandi",
|
|
18
|
+
"cli",
|
|
19
|
+
"ai",
|
|
20
|
+
"code-generation",
|
|
21
|
+
"kandiforge",
|
|
22
|
+
"development"
|
|
23
|
+
],
|
|
24
|
+
"bin": {
|
|
25
|
+
"kandi-forge": "bin/kandi-forge",
|
|
26
|
+
"kandi-supersmall": "bin/kandi-supersmall"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"postinstall": "node scripts/install.js",
|
|
30
|
+
"test": "echo \"No tests configured\""
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"bin/",
|
|
34
|
+
"scripts/",
|
|
35
|
+
"README.md",
|
|
36
|
+
"LICENSE"
|
|
37
|
+
],
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=14.0.0"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
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
|
+
// This version MUST match package.json
|
|
9
|
+
const RELEASE_VERSION = '0.45.7';
|
|
10
|
+
const GITHUB_REPO = 'KandiForge/distribution';
|
|
11
|
+
|
|
12
|
+
function downloadFile(url, destPath) {
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
console.log(`Downloading from: ${url}`);
|
|
15
|
+
|
|
16
|
+
https.get(url, (response) => {
|
|
17
|
+
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
18
|
+
// Follow redirect
|
|
19
|
+
return downloadFile(response.headers.location, destPath)
|
|
20
|
+
.then(resolve)
|
|
21
|
+
.catch(reject);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (response.statusCode !== 200) {
|
|
25
|
+
reject(new Error(`Failed to download: ${response.statusCode} ${response.statusMessage}`));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const file = fs.createWriteStream(destPath);
|
|
30
|
+
response.pipe(file);
|
|
31
|
+
|
|
32
|
+
file.on('finish', () => {
|
|
33
|
+
file.close();
|
|
34
|
+
resolve();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
file.on('error', (err) => {
|
|
38
|
+
fs.unlink(destPath, () => {});
|
|
39
|
+
reject(err);
|
|
40
|
+
});
|
|
41
|
+
}).on('error', reject);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Extract ZIP file using PowerShell on Windows
|
|
47
|
+
*/
|
|
48
|
+
function extractZip(zipPath, destDir) {
|
|
49
|
+
try {
|
|
50
|
+
const psCommand = `powershell -Command "Expand-Archive -Path '${zipPath}' -DestinationPath '${destDir}' -Force"`;
|
|
51
|
+
execSync(psCommand, { stdio: 'inherit' });
|
|
52
|
+
} catch (error) {
|
|
53
|
+
throw new Error(`Failed to extract ZIP file: ${error.message}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function install() {
|
|
58
|
+
try {
|
|
59
|
+
const platform = process.platform;
|
|
60
|
+
|
|
61
|
+
// Determine archive name and binary extension based on platform
|
|
62
|
+
let fileName, isZip, ext;
|
|
63
|
+
|
|
64
|
+
if (platform === 'darwin') {
|
|
65
|
+
fileName = `kandi-cli-v${RELEASE_VERSION}-macos-arm64.tar.gz`;
|
|
66
|
+
isZip = false;
|
|
67
|
+
ext = '';
|
|
68
|
+
} else if (platform === 'linux') {
|
|
69
|
+
fileName = `kandi-cli-v${RELEASE_VERSION}-linux-x64.tar.gz`;
|
|
70
|
+
isZip = false;
|
|
71
|
+
ext = '';
|
|
72
|
+
} else if (platform === 'win32') {
|
|
73
|
+
fileName = `kandi-cli-v${RELEASE_VERSION}-windows-x64.zip`;
|
|
74
|
+
isZip = true;
|
|
75
|
+
ext = '.exe';
|
|
76
|
+
} else {
|
|
77
|
+
throw new Error(`Platform ${platform} is not supported. Supported: macOS, Linux, Windows`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Binary names included in kandi-cli package
|
|
81
|
+
const binaryNames = ['kandi-forge', 'kandi-supersmall'];
|
|
82
|
+
|
|
83
|
+
// Download URL from GitHub release assets
|
|
84
|
+
const downloadUrl = `https://github.com/${GITHUB_REPO}/releases/download/kandi-cli-v${RELEASE_VERSION}/${fileName}`;
|
|
85
|
+
|
|
86
|
+
const binDir = path.join(__dirname, '..', 'bin');
|
|
87
|
+
const tempFile = path.join(binDir, fileName);
|
|
88
|
+
|
|
89
|
+
// Create bin directory if it doesn't exist
|
|
90
|
+
if (!fs.existsSync(binDir)) {
|
|
91
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Clean bin directory - remove any existing binaries to avoid mixing platforms
|
|
95
|
+
console.log('Cleaning bin directory...');
|
|
96
|
+
const existingFiles = fs.readdirSync(binDir);
|
|
97
|
+
for (const file of existingFiles) {
|
|
98
|
+
// Skip .gitkeep or other dotfiles
|
|
99
|
+
if (file.startsWith('.')) continue;
|
|
100
|
+
const filePath = path.join(binDir, file);
|
|
101
|
+
try {
|
|
102
|
+
fs.unlinkSync(filePath);
|
|
103
|
+
} catch (e) {
|
|
104
|
+
console.warn(`Warning: Could not remove ${file}: ${e.message}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Download the release archive
|
|
109
|
+
console.log(`Installing kandi-cli v${RELEASE_VERSION} for ${platform}...`);
|
|
110
|
+
await downloadFile(downloadUrl, tempFile);
|
|
111
|
+
|
|
112
|
+
// Extract the archive
|
|
113
|
+
console.log('Extracting binaries...');
|
|
114
|
+
if (isZip) {
|
|
115
|
+
extractZip(tempFile, binDir);
|
|
116
|
+
} else {
|
|
117
|
+
execSync(`tar -xzf "${tempFile}" -C "${binDir}"`, { stdio: 'inherit' });
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Clean up archive
|
|
121
|
+
fs.unlinkSync(tempFile);
|
|
122
|
+
|
|
123
|
+
// The archive extracts to kandi-cli-v{version}/
|
|
124
|
+
const extractedDir = path.join(binDir, `kandi-cli-v${RELEASE_VERSION}`);
|
|
125
|
+
|
|
126
|
+
// Move binaries to bin directory
|
|
127
|
+
const installedBinaries = [];
|
|
128
|
+
for (const baseName of binaryNames) {
|
|
129
|
+
const binaryName = `${baseName}${ext}`;
|
|
130
|
+
const extractedPath = path.join(extractedDir, binaryName);
|
|
131
|
+
const destPath = path.join(binDir, binaryName);
|
|
132
|
+
|
|
133
|
+
if (fs.existsSync(extractedPath)) {
|
|
134
|
+
fs.renameSync(extractedPath, destPath);
|
|
135
|
+
|
|
136
|
+
// Make binary executable (Unix only)
|
|
137
|
+
if (platform !== 'win32') {
|
|
138
|
+
fs.chmodSync(destPath, 0o755);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
installedBinaries.push(binaryName);
|
|
142
|
+
} else {
|
|
143
|
+
console.warn(`Warning: ${binaryName} not found in archive`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Clean up the extracted directory
|
|
148
|
+
if (fs.existsSync(extractedDir)) {
|
|
149
|
+
fs.rmSync(extractedDir, { recursive: true });
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (installedBinaries.length === 0) {
|
|
153
|
+
throw new Error('No binaries were found in the archive');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
console.log('kandi-cli installed successfully!');
|
|
157
|
+
console.log(`Installed ${installedBinaries.length} binaries:`);
|
|
158
|
+
for (const binary of installedBinaries) {
|
|
159
|
+
console.log(` - ${binary}`);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
} catch (error) {
|
|
163
|
+
console.error('Installation failed:', error.message);
|
|
164
|
+
console.error('\nPlease report this issue at: https://github.com/KandiForge/apps/issues');
|
|
165
|
+
process.exit(1);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Run installation
|
|
170
|
+
install();
|