cli4ai 0.9.1 → 0.9.2
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 +1 -1
- package/src/commands/update.ts +23 -4
- package/src/lib/cli.ts +1 -1
package/package.json
CHANGED
package/src/commands/update.ts
CHANGED
|
@@ -63,9 +63,27 @@ async function getLatestVersions(packageNames: string[]): Promise<Map<string, st
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
-
* Update a single package (
|
|
66
|
+
* Update a single package using cli4ai add -g (reinstalls to ~/.cli4ai/packages/)
|
|
67
67
|
*/
|
|
68
|
-
async function
|
|
68
|
+
async function updateCli4aiPackage(packageName: string): Promise<boolean> {
|
|
69
|
+
return new Promise((resolve) => {
|
|
70
|
+
// Use cli4ai add -g to reinstall the package (same location as original install)
|
|
71
|
+
const proc = spawn('cli4ai', ['add', '-g', packageName, '-y'], {
|
|
72
|
+
stdio: 'pipe'
|
|
73
|
+
});
|
|
74
|
+
proc.on('close', (code) => {
|
|
75
|
+
resolve(code === 0);
|
|
76
|
+
});
|
|
77
|
+
proc.on('error', () => {
|
|
78
|
+
resolve(false);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Update cli4ai itself via npm
|
|
85
|
+
*/
|
|
86
|
+
async function updateNpmPackage(packageName: string): Promise<boolean> {
|
|
69
87
|
return new Promise((resolve) => {
|
|
70
88
|
const proc = spawn('npm', ['install', '-g', `${packageName}@latest`], {
|
|
71
89
|
stdio: 'pipe'
|
|
@@ -139,7 +157,7 @@ export async function updateCommand(options: UpdateOptions): Promise<void> {
|
|
|
139
157
|
|
|
140
158
|
if (hasUpdate) {
|
|
141
159
|
log(` ${CYAN}↑${RESET} cli4ai ${DIM}${current}${RESET} → ${GREEN}${latest}${RESET}`);
|
|
142
|
-
const success = await
|
|
160
|
+
const success = await updateNpmPackage('cli4ai');
|
|
143
161
|
|
|
144
162
|
if (success) {
|
|
145
163
|
log(` ${GREEN}✓${RESET} cli4ai updated\n`);
|
|
@@ -199,7 +217,8 @@ export async function updateCommand(options: UpdateOptions): Promise<void> {
|
|
|
199
217
|
|
|
200
218
|
const updateResults: Array<(typeof toUpdate)[number] & { success: boolean }> = [];
|
|
201
219
|
for (const pkg of toUpdate) {
|
|
202
|
-
|
|
220
|
+
// Use cli4ai add -g to update packages in ~/.cli4ai/packages/
|
|
221
|
+
const success = await updateCli4aiPackage(pkg.name);
|
|
203
222
|
updateResults.push({ ...pkg, success });
|
|
204
223
|
}
|
|
205
224
|
|
package/src/lib/cli.ts
CHANGED