cli4ai 0.9.0 → 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 +45 -10
- 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'
|
|
@@ -99,14 +117,30 @@ export async function checkForUpdates(): Promise<{ hasUpdate: boolean; current:
|
|
|
99
117
|
*/
|
|
100
118
|
function getUpdateablePackages(): Array<{ name: string; npmName: string; version: string }> {
|
|
101
119
|
const packages: Array<{ name: string; npmName: string; version: string }> = [];
|
|
120
|
+
const seen = new Set<string>();
|
|
121
|
+
|
|
122
|
+
// Get packages from ~/.cli4ai/packages/ (where cli4ai add -g installs)
|
|
123
|
+
for (const pkg of getGlobalPackages()) {
|
|
124
|
+
if (!seen.has(pkg.name)) {
|
|
125
|
+
seen.add(pkg.name);
|
|
126
|
+
packages.push({
|
|
127
|
+
name: pkg.name,
|
|
128
|
+
npmName: `@cli4ai/${pkg.name}`,
|
|
129
|
+
version: pkg.version
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
102
133
|
|
|
103
|
-
//
|
|
134
|
+
// Also check npm global @cli4ai packages (for packages installed via npm directly)
|
|
104
135
|
for (const pkg of getNpmGlobalPackages()) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
136
|
+
if (!seen.has(pkg.name)) {
|
|
137
|
+
seen.add(pkg.name);
|
|
138
|
+
packages.push({
|
|
139
|
+
name: pkg.name,
|
|
140
|
+
npmName: `@cli4ai/${pkg.name}`,
|
|
141
|
+
version: pkg.version
|
|
142
|
+
});
|
|
143
|
+
}
|
|
110
144
|
}
|
|
111
145
|
|
|
112
146
|
return packages;
|
|
@@ -123,7 +157,7 @@ export async function updateCommand(options: UpdateOptions): Promise<void> {
|
|
|
123
157
|
|
|
124
158
|
if (hasUpdate) {
|
|
125
159
|
log(` ${CYAN}↑${RESET} cli4ai ${DIM}${current}${RESET} → ${GREEN}${latest}${RESET}`);
|
|
126
|
-
const success = await
|
|
160
|
+
const success = await updateNpmPackage('cli4ai');
|
|
127
161
|
|
|
128
162
|
if (success) {
|
|
129
163
|
log(` ${GREEN}✓${RESET} cli4ai updated\n`);
|
|
@@ -183,7 +217,8 @@ export async function updateCommand(options: UpdateOptions): Promise<void> {
|
|
|
183
217
|
|
|
184
218
|
const updateResults: Array<(typeof toUpdate)[number] & { success: boolean }> = [];
|
|
185
219
|
for (const pkg of toUpdate) {
|
|
186
|
-
|
|
220
|
+
// Use cli4ai add -g to update packages in ~/.cli4ai/packages/
|
|
221
|
+
const success = await updateCli4aiPackage(pkg.name);
|
|
187
222
|
updateResults.push({ ...pkg, success });
|
|
188
223
|
}
|
|
189
224
|
|
package/src/lib/cli.ts
CHANGED