evalify-cli 0.1.4 → 0.1.5
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/dist/index.js +63 -16
- package/package.json +1 -1
- package/src/commands/publish.ts +73 -15
package/dist/index.js
CHANGED
|
@@ -8394,7 +8394,7 @@ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
|
8394
8394
|
var source_default = chalk;
|
|
8395
8395
|
|
|
8396
8396
|
// src/format.ts
|
|
8397
|
-
var VERSION = "0.1.
|
|
8397
|
+
var VERSION = "0.1.5";
|
|
8398
8398
|
function header() {
|
|
8399
8399
|
console.log(source_default.bold.cyan(`
|
|
8400
8400
|
evalify-cli`) + source_default.dim(` v${VERSION}
|
|
@@ -9062,23 +9062,70 @@ async function publish(targetPath) {
|
|
|
9062
9062
|
error("Session expired \u2014 run: evalify-cli login");
|
|
9063
9063
|
return;
|
|
9064
9064
|
}
|
|
9065
|
-
|
|
9065
|
+
let version = parsed.version ?? "1.0.0";
|
|
9066
|
+
const buildPayload = () => ({
|
|
9067
|
+
slug,
|
|
9068
|
+
displayName,
|
|
9069
|
+
domain: parsed.domain ?? "general",
|
|
9070
|
+
version,
|
|
9071
|
+
tags: parsed.tags ?? [],
|
|
9072
|
+
description: parsed.description ?? "",
|
|
9073
|
+
evals: parsed.evals ?? []
|
|
9074
|
+
});
|
|
9075
|
+
let res = await fetch(REGISTRY_URL2, {
|
|
9066
9076
|
method: "POST",
|
|
9067
|
-
headers: {
|
|
9068
|
-
|
|
9069
|
-
Authorization: `Bearer ${token}`
|
|
9070
|
-
},
|
|
9071
|
-
body: JSON.stringify({
|
|
9072
|
-
slug,
|
|
9073
|
-
displayName,
|
|
9074
|
-
domain: parsed.domain ?? "general",
|
|
9075
|
-
version: parsed.version ?? "1.0.0",
|
|
9076
|
-
tags: parsed.tags ?? [],
|
|
9077
|
-
description: parsed.description ?? "",
|
|
9078
|
-
evals: parsed.evals ?? []
|
|
9079
|
-
})
|
|
9077
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
|
|
9078
|
+
body: JSON.stringify(buildPayload())
|
|
9080
9079
|
});
|
|
9081
|
-
|
|
9080
|
+
let data = await res.json();
|
|
9081
|
+
if (res.status === 409 && data.conflict === "version") {
|
|
9082
|
+
console.log();
|
|
9083
|
+
const parts = version.split(".").map(Number);
|
|
9084
|
+
const nextPatch = `${parts[0]}.${parts[1]}.${(parts[2] ?? 0) + 1}`;
|
|
9085
|
+
const { choice } = await (0, import_prompts2.default)({
|
|
9086
|
+
type: "select",
|
|
9087
|
+
name: "choice",
|
|
9088
|
+
message: `Version ${version} is already published. What do you want to do?`,
|
|
9089
|
+
choices: [
|
|
9090
|
+
{ title: `Bump to ${nextPatch}`, value: "bump" },
|
|
9091
|
+
{ title: "Set manually", value: "manual" },
|
|
9092
|
+
{ title: "Cancel", value: "cancel" }
|
|
9093
|
+
],
|
|
9094
|
+
initial: 0
|
|
9095
|
+
});
|
|
9096
|
+
if (!choice || choice === "cancel") {
|
|
9097
|
+
console.log();
|
|
9098
|
+
dim("Cancelled.");
|
|
9099
|
+
console.log();
|
|
9100
|
+
return;
|
|
9101
|
+
}
|
|
9102
|
+
if (choice === "manual") {
|
|
9103
|
+
const { manualVersion } = await (0, import_prompts2.default)({
|
|
9104
|
+
type: "text",
|
|
9105
|
+
name: "manualVersion",
|
|
9106
|
+
message: "Enter version:",
|
|
9107
|
+
initial: nextPatch
|
|
9108
|
+
});
|
|
9109
|
+
if (!manualVersion) {
|
|
9110
|
+
console.log();
|
|
9111
|
+
dim("Cancelled.");
|
|
9112
|
+
console.log();
|
|
9113
|
+
return;
|
|
9114
|
+
}
|
|
9115
|
+
version = manualVersion.trim();
|
|
9116
|
+
} else {
|
|
9117
|
+
version = nextPatch;
|
|
9118
|
+
}
|
|
9119
|
+
parsed.version = version;
|
|
9120
|
+
await import_promises3.default.writeFile(filePath, JSON.stringify({ ...parsed }, null, 2) + "\n");
|
|
9121
|
+
info(`Uploading v${version}...`);
|
|
9122
|
+
res = await fetch(REGISTRY_URL2, {
|
|
9123
|
+
method: "POST",
|
|
9124
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
|
|
9125
|
+
body: JSON.stringify(buildPayload())
|
|
9126
|
+
});
|
|
9127
|
+
data = await res.json();
|
|
9128
|
+
}
|
|
9082
9129
|
if (!res.ok) {
|
|
9083
9130
|
console.log();
|
|
9084
9131
|
error(data.error ?? `Server error ${res.status}`);
|
package/package.json
CHANGED
package/src/commands/publish.ts
CHANGED
|
@@ -152,24 +152,82 @@ export async function publish(targetPath?: string): Promise<void> {
|
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
|
|
155
|
+
let version = parsed.version ?? "1.0.0";
|
|
156
|
+
|
|
157
|
+
const buildPayload = () => ({
|
|
158
|
+
slug,
|
|
159
|
+
displayName,
|
|
160
|
+
domain: parsed.domain ?? "general",
|
|
161
|
+
version,
|
|
162
|
+
tags: parsed.tags ?? [],
|
|
163
|
+
description: parsed.description ?? "",
|
|
164
|
+
evals: parsed.evals ?? [],
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
let res = await fetch(REGISTRY_URL, {
|
|
156
168
|
method: "POST",
|
|
157
|
-
headers: {
|
|
158
|
-
|
|
159
|
-
Authorization: `Bearer ${token}`,
|
|
160
|
-
},
|
|
161
|
-
body: JSON.stringify({
|
|
162
|
-
slug,
|
|
163
|
-
displayName,
|
|
164
|
-
domain: parsed.domain ?? "general",
|
|
165
|
-
version: parsed.version ?? "1.0.0",
|
|
166
|
-
tags: parsed.tags ?? [],
|
|
167
|
-
description: parsed.description ?? "",
|
|
168
|
-
evals: parsed.evals ?? [],
|
|
169
|
-
}),
|
|
169
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
|
|
170
|
+
body: JSON.stringify(buildPayload()),
|
|
170
171
|
});
|
|
171
172
|
|
|
172
|
-
|
|
173
|
+
let data = await res.json();
|
|
174
|
+
|
|
175
|
+
// Version conflict — offer to bump and retry
|
|
176
|
+
if (res.status === 409 && data.conflict === "version") {
|
|
177
|
+
console.log();
|
|
178
|
+
const parts = version.split(".").map(Number);
|
|
179
|
+
const nextPatch = `${parts[0]}.${parts[1]}.${(parts[2] ?? 0) + 1}`;
|
|
180
|
+
|
|
181
|
+
const { choice } = await prompts({
|
|
182
|
+
type: "select",
|
|
183
|
+
name: "choice",
|
|
184
|
+
message: `Version ${version} is already published. What do you want to do?`,
|
|
185
|
+
choices: [
|
|
186
|
+
{ title: `Bump to ${nextPatch}`, value: "bump" },
|
|
187
|
+
{ title: "Set manually", value: "manual" },
|
|
188
|
+
{ title: "Cancel", value: "cancel" },
|
|
189
|
+
],
|
|
190
|
+
initial: 0,
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
if (!choice || choice === "cancel") {
|
|
194
|
+
console.log();
|
|
195
|
+
dim("Cancelled.");
|
|
196
|
+
console.log();
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (choice === "manual") {
|
|
201
|
+
const { manualVersion } = await prompts({
|
|
202
|
+
type: "text",
|
|
203
|
+
name: "manualVersion",
|
|
204
|
+
message: "Enter version:",
|
|
205
|
+
initial: nextPatch,
|
|
206
|
+
});
|
|
207
|
+
if (!manualVersion) {
|
|
208
|
+
console.log();
|
|
209
|
+
dim("Cancelled.");
|
|
210
|
+
console.log();
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
version = manualVersion.trim();
|
|
214
|
+
} else {
|
|
215
|
+
version = nextPatch;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Write new version back to evals.json
|
|
219
|
+
parsed.version = version;
|
|
220
|
+
await fs.writeFile(filePath, JSON.stringify({ ...parsed }, null, 2) + "\n");
|
|
221
|
+
|
|
222
|
+
info(`Uploading v${version}...`);
|
|
223
|
+
|
|
224
|
+
res = await fetch(REGISTRY_URL, {
|
|
225
|
+
method: "POST",
|
|
226
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
|
|
227
|
+
body: JSON.stringify(buildPayload()),
|
|
228
|
+
});
|
|
229
|
+
data = await res.json();
|
|
230
|
+
}
|
|
173
231
|
|
|
174
232
|
if (!res.ok) {
|
|
175
233
|
console.log();
|