api2cli 0.3.7 → 0.3.9
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 +253 -151
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2154,15 +2154,38 @@ var {
|
|
|
2154
2154
|
} = import__.default;
|
|
2155
2155
|
|
|
2156
2156
|
// src/commands/create.ts
|
|
2157
|
-
var
|
|
2158
|
-
import { existsSync as
|
|
2157
|
+
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
2158
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, renameSync } from "fs";
|
|
2159
2159
|
import { join as join3 } from "path";
|
|
2160
|
+
import { createInterface as createInterface2 } from "readline";
|
|
2160
2161
|
|
|
2161
2162
|
// src/lib/config.ts
|
|
2163
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
2162
2164
|
import { homedir } from "os";
|
|
2163
|
-
import { join } from "path";
|
|
2165
|
+
import { dirname, join } from "path";
|
|
2164
2166
|
var CLI_ROOT = join(homedir(), ".cli");
|
|
2165
2167
|
var TOKENS_DIR = join(homedir(), ".config", "tokens");
|
|
2168
|
+
var API_URL = "https://api2cli.dev";
|
|
2169
|
+
var CONFIG_FILE = join(CLI_ROOT, "config.json");
|
|
2170
|
+
function getConfig() {
|
|
2171
|
+
try {
|
|
2172
|
+
if (existsSync(CONFIG_FILE)) {
|
|
2173
|
+
return JSON.parse(readFileSync(CONFIG_FILE, "utf-8"));
|
|
2174
|
+
}
|
|
2175
|
+
} catch {}
|
|
2176
|
+
return {};
|
|
2177
|
+
}
|
|
2178
|
+
function setConfig(update) {
|
|
2179
|
+
const config = { ...getConfig(), ...update };
|
|
2180
|
+
mkdirSync(dirname(CONFIG_FILE), { recursive: true });
|
|
2181
|
+
writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
2182
|
+
}
|
|
2183
|
+
function getPublishPreference() {
|
|
2184
|
+
return getConfig().publishPreference || "ask";
|
|
2185
|
+
}
|
|
2186
|
+
function setPublishPreference(pref) {
|
|
2187
|
+
setConfig({ publishPreference: pref });
|
|
2188
|
+
}
|
|
2166
2189
|
var TEMPLATE_REPO = "https://github.com/Melvynx/api2cli.git";
|
|
2167
2190
|
var TEMPLATE_REPO_PATH = "packages/template";
|
|
2168
2191
|
function getCliDir(app) {
|
|
@@ -2176,7 +2199,7 @@ function getDistDir(app) {
|
|
|
2176
2199
|
}
|
|
2177
2200
|
|
|
2178
2201
|
// src/lib/template.ts
|
|
2179
|
-
import { existsSync, cpSync, readdirSync, statSync, readFileSync, writeFileSync, rmSync, mkdtempSync } from "fs";
|
|
2202
|
+
import { existsSync as existsSync2, cpSync, readdirSync, statSync, readFileSync as readFileSync2, writeFileSync as writeFileSync2, rmSync, mkdtempSync } from "fs";
|
|
2180
2203
|
import { join as join2 } from "path";
|
|
2181
2204
|
import { tmpdir } from "os";
|
|
2182
2205
|
import { execSync } from "child_process";
|
|
@@ -2190,7 +2213,7 @@ function copyTemplate(targetDir) {
|
|
|
2190
2213
|
stdio: "pipe"
|
|
2191
2214
|
});
|
|
2192
2215
|
const templateSrc = join2(tmp, "repo", TEMPLATE_REPO_PATH);
|
|
2193
|
-
if (!
|
|
2216
|
+
if (!existsSync2(templateSrc)) {
|
|
2194
2217
|
throw new Error(`Template not found in repo at ${TEMPLATE_REPO_PATH}`);
|
|
2195
2218
|
}
|
|
2196
2219
|
cpSync(templateSrc, targetDir, { recursive: true });
|
|
@@ -2212,7 +2235,7 @@ function replacePlaceholders(dir, vars) {
|
|
|
2212
2235
|
const ext = filePath.split(".").pop() ?? "";
|
|
2213
2236
|
if (!["ts", "js", "json", "md", "txt", "template"].includes(ext))
|
|
2214
2237
|
return;
|
|
2215
|
-
let content =
|
|
2238
|
+
let content = readFileSync2(filePath, "utf-8");
|
|
2216
2239
|
let changed = false;
|
|
2217
2240
|
for (const [placeholder, value] of replacements) {
|
|
2218
2241
|
if (content.includes(placeholder)) {
|
|
@@ -2221,7 +2244,7 @@ function replacePlaceholders(dir, vars) {
|
|
|
2221
2244
|
}
|
|
2222
2245
|
}
|
|
2223
2246
|
if (changed) {
|
|
2224
|
-
|
|
2247
|
+
writeFileSync2(filePath, content);
|
|
2225
2248
|
}
|
|
2226
2249
|
});
|
|
2227
2250
|
}
|
|
@@ -2236,25 +2259,119 @@ function walkFiles(dir, callback) {
|
|
|
2236
2259
|
}
|
|
2237
2260
|
}
|
|
2238
2261
|
|
|
2262
|
+
// src/commands/publish.ts
|
|
2263
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
2264
|
+
import { existsSync as existsSync3 } from "fs";
|
|
2265
|
+
import { createInterface } from "readline";
|
|
2266
|
+
function askQuestion(question) {
|
|
2267
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
2268
|
+
return new Promise((resolve2) => {
|
|
2269
|
+
rl.question(question, (answer) => {
|
|
2270
|
+
rl.close();
|
|
2271
|
+
resolve2(answer.trim());
|
|
2272
|
+
});
|
|
2273
|
+
});
|
|
2274
|
+
}
|
|
2275
|
+
async function publishToMarketplace(githubUrl) {
|
|
2276
|
+
try {
|
|
2277
|
+
const res = await fetch(`${API_URL}/api/publish-cli`, {
|
|
2278
|
+
method: "POST",
|
|
2279
|
+
headers: { "Content-Type": "application/json" },
|
|
2280
|
+
body: JSON.stringify({ githubUrl })
|
|
2281
|
+
});
|
|
2282
|
+
const data = await res.json();
|
|
2283
|
+
if (!res.ok) {
|
|
2284
|
+
console.error(` ${import_picocolors.default.red("\u2717")} ${data.error || "Failed to publish"}`);
|
|
2285
|
+
return false;
|
|
2286
|
+
}
|
|
2287
|
+
console.log(` ${import_picocolors.default.green("\u2713")} Published ${import_picocolors.default.bold(data.skill.displayName)} to marketplace`);
|
|
2288
|
+
console.log(` ${import_picocolors.default.dim(`\u2192 ${data.skill.url || `https://api2cli.dev/registry/${data.skill.name}`}`)}`);
|
|
2289
|
+
return true;
|
|
2290
|
+
} catch {
|
|
2291
|
+
console.error(` ${import_picocolors.default.red("\u2717")} Could not reach api2cli.dev`);
|
|
2292
|
+
return false;
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
var publishCommand = new Command("publish").description("Publish a CLI to the api2cli marketplace").argument("<app>", "CLI to publish").option("--github <url>", "GitHub repo URL (e.g. user/repo)").addHelpText("after", `
|
|
2296
|
+
Examples:
|
|
2297
|
+
api2cli publish typefully --github user/typefully-cli
|
|
2298
|
+
api2cli publish dub`).action(async (app, opts) => {
|
|
2299
|
+
const cliDir = getCliDir(app);
|
|
2300
|
+
if (!existsSync3(cliDir)) {
|
|
2301
|
+
console.error(`${import_picocolors.default.red("\u2717")} ${app}-cli not found.`);
|
|
2302
|
+
process.exit(1);
|
|
2303
|
+
}
|
|
2304
|
+
let githubUrl = opts.github;
|
|
2305
|
+
if (!githubUrl) {
|
|
2306
|
+
githubUrl = await askQuestion(` GitHub repo URL ${import_picocolors.default.dim("(e.g. user/repo)")}: `);
|
|
2307
|
+
}
|
|
2308
|
+
if (!githubUrl) {
|
|
2309
|
+
console.log(`${import_picocolors.default.yellow("\u2717")} No GitHub URL provided. Skipped.`);
|
|
2310
|
+
return;
|
|
2311
|
+
}
|
|
2312
|
+
console.log(`
|
|
2313
|
+
Publishing ${import_picocolors.default.bold(`${app}-cli`)} to marketplace...
|
|
2314
|
+
`);
|
|
2315
|
+
await publishToMarketplace(githubUrl);
|
|
2316
|
+
});
|
|
2317
|
+
|
|
2239
2318
|
// src/commands/create.ts
|
|
2319
|
+
function askQuestion2(question) {
|
|
2320
|
+
const rl = createInterface2({ input: process.stdin, output: process.stdout });
|
|
2321
|
+
return new Promise((resolve2) => {
|
|
2322
|
+
rl.question(question, (answer) => {
|
|
2323
|
+
rl.close();
|
|
2324
|
+
resolve2(answer.trim().toLowerCase());
|
|
2325
|
+
});
|
|
2326
|
+
});
|
|
2327
|
+
}
|
|
2328
|
+
async function promptPublish(app) {
|
|
2329
|
+
const pref = getPublishPreference();
|
|
2330
|
+
if (pref === "never")
|
|
2331
|
+
return;
|
|
2332
|
+
console.log(`
|
|
2333
|
+
${import_picocolors2.default.bold("Marketplace")}`);
|
|
2334
|
+
if (pref === "ask") {
|
|
2335
|
+
const answer = await askQuestion2(` Share ${import_picocolors2.default.cyan(`${app}-cli`)} on the marketplace? ${import_picocolors2.default.dim("[y]es / [n]o / [a]lways / n[e]ver")}: `);
|
|
2336
|
+
if (answer === "n" || answer === "no")
|
|
2337
|
+
return;
|
|
2338
|
+
if (answer === "e" || answer === "never") {
|
|
2339
|
+
setPublishPreference("never");
|
|
2340
|
+
console.log(` ${import_picocolors2.default.dim("Saved. Won't ask again. Change with: api2cli publish <app>")}`);
|
|
2341
|
+
return;
|
|
2342
|
+
}
|
|
2343
|
+
if (answer === "a" || answer === "always") {
|
|
2344
|
+
setPublishPreference("always");
|
|
2345
|
+
console.log(` ${import_picocolors2.default.dim("Saved. Will always prompt for publish.")}`);
|
|
2346
|
+
} else if (answer !== "y" && answer !== "yes") {
|
|
2347
|
+
return;
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
const githubUrl = await askQuestion2(` GitHub repo URL ${import_picocolors2.default.dim("(e.g. user/repo)")}: `);
|
|
2351
|
+
if (!githubUrl) {
|
|
2352
|
+
console.log(` ${import_picocolors2.default.dim("Skipped. Publish later with:")} ${import_picocolors2.default.cyan(`api2cli publish ${app}`)}`);
|
|
2353
|
+
return;
|
|
2354
|
+
}
|
|
2355
|
+
await publishToMarketplace(githubUrl);
|
|
2356
|
+
}
|
|
2240
2357
|
var createCommand2 = new Command("create").description("Generate a new CLI from API documentation").argument("<app>", "API/app name (e.g. typefully, dub, mercury)").option("--docs <url>", "URL to API documentation").option("--openapi <url>", "URL to OpenAPI/Swagger spec").option("--base-url <url>", "API base URL", "https://api.example.com").option("--auth-type <type>", "Auth type: bearer, api-key, basic, custom", "bearer").option("--auth-header <name>", "Auth header name", "Authorization").option("--force", "Overwrite existing CLI", false).addHelpText("after", `
|
|
2241
2358
|
Examples:
|
|
2242
2359
|
api2cli create typefully --base-url https://api.typefully.com --auth-type bearer
|
|
2243
2360
|
api2cli create dub --openapi https://api.dub.co/openapi.json
|
|
2244
2361
|
api2cli create my-api --docs https://docs.example.com/api`).action(async (app, opts) => {
|
|
2245
2362
|
const cliDir = getCliDir(app);
|
|
2246
|
-
if (
|
|
2247
|
-
console.error(`${
|
|
2248
|
-
console.error(` Use ${
|
|
2363
|
+
if (existsSync4(cliDir) && !opts.force) {
|
|
2364
|
+
console.error(`${import_picocolors2.default.red("\u2717")} ${app}-cli already exists at ${cliDir}`);
|
|
2365
|
+
console.error(` Use ${import_picocolors2.default.cyan("--force")} to overwrite.`);
|
|
2249
2366
|
process.exit(1);
|
|
2250
2367
|
}
|
|
2251
2368
|
console.log(`
|
|
2252
|
-
${
|
|
2369
|
+
${import_picocolors2.default.bold("Creating")} ${import_picocolors2.default.cyan(`${app}-cli`)}...
|
|
2253
2370
|
`);
|
|
2254
|
-
|
|
2255
|
-
console.log(` ${
|
|
2371
|
+
mkdirSync2(cliDir, { recursive: true });
|
|
2372
|
+
console.log(` ${import_picocolors2.default.green("+")} Created ${import_picocolors2.default.dim(cliDir)}`);
|
|
2256
2373
|
copyTemplate(cliDir);
|
|
2257
|
-
console.log(` ${
|
|
2374
|
+
console.log(` ${import_picocolors2.default.green("+")} Copied template scaffold`);
|
|
2258
2375
|
replacePlaceholders(cliDir, {
|
|
2259
2376
|
appName: app,
|
|
2260
2377
|
appCli: `${app}-cli`,
|
|
@@ -2262,44 +2379,45 @@ ${import_picocolors.default.bold("Creating")} ${import_picocolors.default.cyan(`
|
|
|
2262
2379
|
authType: opts.authType,
|
|
2263
2380
|
authHeader: opts.authHeader
|
|
2264
2381
|
});
|
|
2265
|
-
console.log(` ${
|
|
2266
|
-
console.log(` ${
|
|
2382
|
+
console.log(` ${import_picocolors2.default.green("+")} Configured for ${import_picocolors2.default.bold(app)}`);
|
|
2383
|
+
console.log(` ${import_picocolors2.default.dim("Installing dependencies...")}`);
|
|
2267
2384
|
const install = Bun.spawn(["bun", "install"], {
|
|
2268
2385
|
cwd: cliDir,
|
|
2269
2386
|
stdout: "ignore",
|
|
2270
2387
|
stderr: "pipe"
|
|
2271
2388
|
});
|
|
2272
2389
|
await install.exited;
|
|
2273
|
-
console.log(` ${
|
|
2390
|
+
console.log(` ${import_picocolors2.default.green("+")} Dependencies installed`);
|
|
2274
2391
|
const skillTemplate = join3(cliDir, "skills", "SKILL.md.template");
|
|
2275
|
-
if (
|
|
2392
|
+
if (existsSync4(skillTemplate)) {
|
|
2276
2393
|
const skillDir = join3(cliDir, "skills", `${app}-cli`);
|
|
2277
|
-
|
|
2394
|
+
mkdirSync2(skillDir, { recursive: true });
|
|
2278
2395
|
renameSync(skillTemplate, join3(skillDir, "SKILL.md"));
|
|
2279
2396
|
}
|
|
2280
2397
|
const readmeTemplate = join3(cliDir, "README.md.template");
|
|
2281
|
-
if (
|
|
2398
|
+
if (existsSync4(readmeTemplate)) {
|
|
2282
2399
|
renameSync(readmeTemplate, join3(cliDir, "README.md"));
|
|
2283
2400
|
}
|
|
2284
2401
|
console.log(`
|
|
2285
|
-
${
|
|
2402
|
+
${import_picocolors2.default.green("\u2713")} Created ${import_picocolors2.default.bold(`${app}-cli`)} at ${import_picocolors2.default.dim(cliDir)}`);
|
|
2286
2403
|
console.log(`
|
|
2287
|
-
${
|
|
2288
|
-
console.log(` 1. Edit resources in ${
|
|
2289
|
-
console.log(` 2. Build: ${
|
|
2290
|
-
console.log(` 3. Link: ${
|
|
2291
|
-
console.log(` 4. Auth: ${
|
|
2404
|
+
${import_picocolors2.default.bold("Next steps:")}`);
|
|
2405
|
+
console.log(` 1. Edit resources in ${import_picocolors2.default.dim(`${cliDir}/src/resources/`)}`);
|
|
2406
|
+
console.log(` 2. Build: ${import_picocolors2.default.cyan(`npx api2cli bundle ${app}`)}`);
|
|
2407
|
+
console.log(` 3. Link: ${import_picocolors2.default.cyan(`npx api2cli link ${app}`)}`);
|
|
2408
|
+
console.log(` 4. Auth: ${import_picocolors2.default.cyan(`${app}-cli auth set "your-token"`)}`);
|
|
2409
|
+
await promptPublish(app);
|
|
2292
2410
|
});
|
|
2293
2411
|
|
|
2294
2412
|
// src/commands/install.ts
|
|
2295
|
-
var
|
|
2296
|
-
import { existsSync as
|
|
2413
|
+
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
2414
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync3, symlinkSync as symlinkSync2, unlinkSync as unlinkSync2 } from "fs";
|
|
2297
2415
|
import { join as join5 } from "path";
|
|
2298
2416
|
import { homedir as homedir3 } from "os";
|
|
2299
2417
|
|
|
2300
2418
|
// src/lib/shell.ts
|
|
2301
|
-
var
|
|
2302
|
-
import { existsSync as
|
|
2419
|
+
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
2420
|
+
import { existsSync as existsSync5, readFileSync as readFileSync3, writeFileSync as writeFileSync3, appendFileSync, symlinkSync, unlinkSync, chmodSync } from "fs";
|
|
2303
2421
|
import { homedir as homedir2 } from "os";
|
|
2304
2422
|
import { join as join4 } from "path";
|
|
2305
2423
|
var BIN_DIR = join4(homedir2(), ".local", "bin");
|
|
@@ -2312,20 +2430,20 @@ function getShellRc() {
|
|
|
2312
2430
|
if (shell.includes("fish"))
|
|
2313
2431
|
return join4(homedir2(), ".config", "fish", "config.fish");
|
|
2314
2432
|
const zshrc = join4(homedir2(), ".zshrc");
|
|
2315
|
-
if (
|
|
2433
|
+
if (existsSync5(zshrc))
|
|
2316
2434
|
return zshrc;
|
|
2317
2435
|
return join4(homedir2(), ".bashrc");
|
|
2318
2436
|
}
|
|
2319
2437
|
function ensureBinInPath() {
|
|
2320
2438
|
const rcFile = getShellRc();
|
|
2321
|
-
const content =
|
|
2439
|
+
const content = existsSync5(rcFile) ? readFileSync3(rcFile, "utf-8") : "";
|
|
2322
2440
|
const exportLine = `export PATH="${BIN_DIR}:$PATH"`;
|
|
2323
2441
|
if (content.includes(BIN_DIR))
|
|
2324
2442
|
return;
|
|
2325
2443
|
if (content.includes(MARKER_START)) {
|
|
2326
2444
|
const updated = content.replace(MARKER_END, `${exportLine}
|
|
2327
2445
|
${MARKER_END}`);
|
|
2328
|
-
|
|
2446
|
+
writeFileSync3(rcFile, updated);
|
|
2329
2447
|
} else {
|
|
2330
2448
|
appendFileSync(rcFile, `
|
|
2331
2449
|
${MARKER_START}
|
|
@@ -2335,32 +2453,32 @@ ${MARKER_END}
|
|
|
2335
2453
|
}
|
|
2336
2454
|
}
|
|
2337
2455
|
function addToPath(app, distDir) {
|
|
2338
|
-
const { mkdirSync:
|
|
2339
|
-
|
|
2456
|
+
const { mkdirSync: mkdirSync3 } = __require("fs");
|
|
2457
|
+
mkdirSync3(BIN_DIR, { recursive: true });
|
|
2340
2458
|
const target = join4(distDir, `${app}-cli.js`);
|
|
2341
2459
|
const linkPath = join4(BIN_DIR, `${app}-cli`);
|
|
2342
|
-
if (!
|
|
2343
|
-
console.error(`${
|
|
2344
|
-
console.error(` Run: ${
|
|
2460
|
+
if (!existsSync5(target)) {
|
|
2461
|
+
console.error(`${import_picocolors3.default.red("\u2717")} Built file not found: ${target}`);
|
|
2462
|
+
console.error(` Run: ${import_picocolors3.default.cyan(`npx api2cli bundle ${app}`)}`);
|
|
2345
2463
|
process.exit(1);
|
|
2346
2464
|
}
|
|
2347
2465
|
chmodSync(target, 493);
|
|
2348
|
-
if (
|
|
2466
|
+
if (existsSync5(linkPath)) {
|
|
2349
2467
|
unlinkSync(linkPath);
|
|
2350
2468
|
}
|
|
2351
2469
|
symlinkSync(target, linkPath);
|
|
2352
2470
|
ensureBinInPath();
|
|
2353
|
-
console.log(`${
|
|
2354
|
-
console.log(` ${
|
|
2471
|
+
console.log(`${import_picocolors3.default.green("+")} Linked ${import_picocolors3.default.bold(`${app}-cli`)} -> ${import_picocolors3.default.dim(linkPath)}`);
|
|
2472
|
+
console.log(` ${import_picocolors3.default.dim("PATH updated in")} ${import_picocolors3.default.dim(getShellRc())}`);
|
|
2355
2473
|
}
|
|
2356
2474
|
function removeFromPath(app, _distDir) {
|
|
2357
2475
|
const linkPath = join4(BIN_DIR, `${app}-cli`);
|
|
2358
|
-
if (!
|
|
2359
|
-
console.log(`${
|
|
2476
|
+
if (!existsSync5(linkPath)) {
|
|
2477
|
+
console.log(`${import_picocolors3.default.dim(app)} not linked`);
|
|
2360
2478
|
return;
|
|
2361
2479
|
}
|
|
2362
2480
|
unlinkSync(linkPath);
|
|
2363
|
-
console.log(`${
|
|
2481
|
+
console.log(`${import_picocolors3.default.red("-")} Unlinked ${import_picocolors3.default.bold(`${app}-cli`)}`);
|
|
2364
2482
|
}
|
|
2365
2483
|
|
|
2366
2484
|
// src/commands/install.ts
|
|
@@ -2380,7 +2498,7 @@ function getAppName(repo) {
|
|
|
2380
2498
|
}
|
|
2381
2499
|
function symlinkSkill(cliDir, appCli) {
|
|
2382
2500
|
const skillSource = join5(cliDir, "skills", appCli, "SKILL.md");
|
|
2383
|
-
if (!
|
|
2501
|
+
if (!existsSync6(skillSource))
|
|
2384
2502
|
return;
|
|
2385
2503
|
const agentDirs = [
|
|
2386
2504
|
{ name: "Claude Code", path: join5(homedir3(), ".claude", "skills") },
|
|
@@ -2388,15 +2506,15 @@ function symlinkSkill(cliDir, appCli) {
|
|
|
2388
2506
|
{ name: "OpenClaw", path: join5(homedir3(), ".openclaw", "workspace", "skills") }
|
|
2389
2507
|
];
|
|
2390
2508
|
for (const agent of agentDirs) {
|
|
2391
|
-
if (!
|
|
2509
|
+
if (!existsSync6(join5(agent.path, "..")))
|
|
2392
2510
|
continue;
|
|
2393
2511
|
const skillDir = join5(agent.path, appCli);
|
|
2394
|
-
|
|
2512
|
+
mkdirSync3(skillDir, { recursive: true });
|
|
2395
2513
|
const target = join5(skillDir, "SKILL.md");
|
|
2396
|
-
if (
|
|
2514
|
+
if (existsSync6(target))
|
|
2397
2515
|
unlinkSync2(target);
|
|
2398
2516
|
symlinkSync2(skillSource, target);
|
|
2399
|
-
console.log(` ${
|
|
2517
|
+
console.log(` ${import_picocolors4.default.green("+")} Skill symlinked for ${import_picocolors4.default.dim(agent.name)}`);
|
|
2400
2518
|
}
|
|
2401
2519
|
}
|
|
2402
2520
|
var installCommand = new Command("install").description("Install a CLI from GitHub repo").argument("<source>", "GitHub repo (owner/repo) or app name from registry").option("--force", "Overwrite existing CLI", false).addHelpText("after", `
|
|
@@ -2411,44 +2529,44 @@ Examples:
|
|
|
2411
2529
|
owner = parsed.owner;
|
|
2412
2530
|
repo = parsed.repo;
|
|
2413
2531
|
} else {
|
|
2414
|
-
console.log(`Looking up ${
|
|
2532
|
+
console.log(`Looking up ${import_picocolors4.default.bold(source)} in registry...`);
|
|
2415
2533
|
try {
|
|
2416
2534
|
const res = await fetch(`${REGISTRY_API}/skills/${source}`);
|
|
2417
2535
|
if (!res.ok) {
|
|
2418
|
-
console.error(`${
|
|
2419
|
-
console.error(` Try: ${
|
|
2536
|
+
console.error(`${import_picocolors4.default.red("\u2717")} ${source} not found in registry.`);
|
|
2537
|
+
console.error(` Try: ${import_picocolors4.default.cyan(`api2cli install owner/repo`)}`);
|
|
2420
2538
|
process.exit(1);
|
|
2421
2539
|
}
|
|
2422
2540
|
const data = await res.json();
|
|
2423
2541
|
const githubUrl = data.data?.githubRepo || data.githubRepo;
|
|
2424
2542
|
if (!githubUrl) {
|
|
2425
|
-
console.error(`${
|
|
2543
|
+
console.error(`${import_picocolors4.default.red("\u2717")} No GitHub repo found for ${source}.`);
|
|
2426
2544
|
process.exit(1);
|
|
2427
2545
|
}
|
|
2428
2546
|
const repoParsed = parseGithubInput(githubUrl);
|
|
2429
2547
|
if (!repoParsed) {
|
|
2430
|
-
console.error(`${
|
|
2548
|
+
console.error(`${import_picocolors4.default.red("\u2717")} Invalid repo URL from registry: ${githubUrl}`);
|
|
2431
2549
|
process.exit(1);
|
|
2432
2550
|
}
|
|
2433
2551
|
owner = repoParsed.owner;
|
|
2434
2552
|
repo = repoParsed.repo;
|
|
2435
2553
|
} catch {
|
|
2436
|
-
console.error(`${
|
|
2554
|
+
console.error(`${import_picocolors4.default.red("\u2717")} Could not reach registry. Use ${import_picocolors4.default.cyan("owner/repo")} format instead.`);
|
|
2437
2555
|
process.exit(1);
|
|
2438
2556
|
}
|
|
2439
2557
|
}
|
|
2440
2558
|
const app = getAppName(repo);
|
|
2441
2559
|
const appCli = `${app}-cli`;
|
|
2442
2560
|
const cliDir = getCliDir(app);
|
|
2443
|
-
if (
|
|
2444
|
-
console.error(`${
|
|
2445
|
-
console.error(` Use ${
|
|
2561
|
+
if (existsSync6(cliDir) && !opts.force) {
|
|
2562
|
+
console.error(`${import_picocolors4.default.red("\u2717")} ${appCli} already installed at ${cliDir}`);
|
|
2563
|
+
console.error(` Use ${import_picocolors4.default.cyan("--force")} to reinstall.`);
|
|
2446
2564
|
process.exit(1);
|
|
2447
2565
|
}
|
|
2448
2566
|
console.log(`
|
|
2449
|
-
${
|
|
2567
|
+
${import_picocolors4.default.bold("Installing")} ${import_picocolors4.default.cyan(appCli)} from ${import_picocolors4.default.dim(`${owner}/${repo}`)}...
|
|
2450
2568
|
`);
|
|
2451
|
-
|
|
2569
|
+
mkdirSync3(cliDir, { recursive: true });
|
|
2452
2570
|
const clone = Bun.spawn(["git", "clone", "--depth", "1", `https://github.com/${owner}/${repo}.git`, cliDir], { stdout: "ignore", stderr: "pipe" });
|
|
2453
2571
|
const cloneCode = await clone.exited;
|
|
2454
2572
|
if (cloneCode !== 0) {
|
|
@@ -2460,54 +2578,54 @@ ${import_picocolors3.default.bold("Installing")} ${import_picocolors3.default.cy
|
|
|
2460
2578
|
const retryCode = await retry.exited;
|
|
2461
2579
|
if (retryCode !== 0) {
|
|
2462
2580
|
const retryErr = await new Response(retry.stderr).text();
|
|
2463
|
-
console.error(`${
|
|
2581
|
+
console.error(`${import_picocolors4.default.red("\u2717")} Clone failed: ${retryErr}`);
|
|
2464
2582
|
process.exit(1);
|
|
2465
2583
|
}
|
|
2466
2584
|
} else {
|
|
2467
|
-
console.error(`${
|
|
2585
|
+
console.error(`${import_picocolors4.default.red("\u2717")} Clone failed: ${stderr}`);
|
|
2468
2586
|
process.exit(1);
|
|
2469
2587
|
}
|
|
2470
2588
|
}
|
|
2471
|
-
console.log(` ${
|
|
2472
|
-
console.log(` ${
|
|
2589
|
+
console.log(` ${import_picocolors4.default.green("+")} Cloned ${import_picocolors4.default.dim(`${owner}/${repo}`)}`);
|
|
2590
|
+
console.log(` ${import_picocolors4.default.dim("Installing dependencies...")}`);
|
|
2473
2591
|
const install = Bun.spawn(["bun", "install"], {
|
|
2474
2592
|
cwd: cliDir,
|
|
2475
2593
|
stdout: "ignore",
|
|
2476
2594
|
stderr: "pipe"
|
|
2477
2595
|
});
|
|
2478
2596
|
await install.exited;
|
|
2479
|
-
console.log(` ${
|
|
2597
|
+
console.log(` ${import_picocolors4.default.green("+")} Dependencies installed`);
|
|
2480
2598
|
const entry = join5(cliDir, "src", "index.ts");
|
|
2481
2599
|
const distDir = getDistDir(app);
|
|
2482
|
-
|
|
2600
|
+
mkdirSync3(distDir, { recursive: true });
|
|
2483
2601
|
const outfile = join5(distDir, `${appCli}.js`);
|
|
2484
2602
|
const build = Bun.spawn(["bun", "build", entry, "--outfile", outfile, "--target", "bun"], { cwd: cliDir, stdout: "ignore", stderr: "pipe" });
|
|
2485
2603
|
const buildCode = await build.exited;
|
|
2486
2604
|
if (buildCode !== 0) {
|
|
2487
2605
|
const stderr = await new Response(build.stderr).text();
|
|
2488
|
-
console.error(`${
|
|
2606
|
+
console.error(`${import_picocolors4.default.red("\u2717")} Build failed: ${stderr}`);
|
|
2489
2607
|
process.exit(1);
|
|
2490
2608
|
}
|
|
2491
|
-
console.log(` ${
|
|
2609
|
+
console.log(` ${import_picocolors4.default.green("+")} Built`);
|
|
2492
2610
|
addToPath(app, distDir);
|
|
2493
2611
|
symlinkSkill(cliDir, appCli);
|
|
2494
2612
|
console.log(`
|
|
2495
|
-
${
|
|
2613
|
+
${import_picocolors4.default.green("\u2713")} Installed ${import_picocolors4.default.bold(appCli)}`);
|
|
2496
2614
|
console.log(`
|
|
2497
|
-
${
|
|
2498
|
-
console.log(` ${
|
|
2499
|
-
console.log(` ${
|
|
2615
|
+
${import_picocolors4.default.bold("Next:")}`);
|
|
2616
|
+
console.log(` ${import_picocolors4.default.cyan(`${appCli} auth set "your-token"`)}`);
|
|
2617
|
+
console.log(` ${import_picocolors4.default.cyan(`${appCli} --help`)}`);
|
|
2500
2618
|
});
|
|
2501
2619
|
|
|
2502
2620
|
// src/commands/list.ts
|
|
2503
|
-
var
|
|
2504
|
-
import { existsSync as
|
|
2621
|
+
var import_picocolors5 = __toESM(require_picocolors(), 1);
|
|
2622
|
+
import { existsSync as existsSync7, readdirSync as readdirSync3, statSync as statSync2 } from "fs";
|
|
2505
2623
|
import { join as join6 } from "path";
|
|
2506
2624
|
var listCommand = new Command("list").description("List all installed CLIs").option("--json", "Output as JSON").addHelpText("after", `
|
|
2507
2625
|
Examples:
|
|
2508
2626
|
api2cli list
|
|
2509
2627
|
api2cli list --json`).action((opts) => {
|
|
2510
|
-
if (!
|
|
2628
|
+
if (!existsSync7(CLI_ROOT)) {
|
|
2511
2629
|
console.log("No CLIs installed. Run: api2cli create <app>");
|
|
2512
2630
|
return;
|
|
2513
2631
|
}
|
|
@@ -2523,8 +2641,8 @@ Examples:
|
|
|
2523
2641
|
const name = d.replace(/-cli$/, "");
|
|
2524
2642
|
return {
|
|
2525
2643
|
name,
|
|
2526
|
-
built:
|
|
2527
|
-
hasToken:
|
|
2644
|
+
built: existsSync7(join6(CLI_ROOT, d, "dist")),
|
|
2645
|
+
hasToken: existsSync7(join6(TOKENS_DIR, `${d}.txt`)),
|
|
2528
2646
|
path: join6(CLI_ROOT, d)
|
|
2529
2647
|
};
|
|
2530
2648
|
});
|
|
@@ -2532,24 +2650,24 @@ Examples:
|
|
|
2532
2650
|
return;
|
|
2533
2651
|
}
|
|
2534
2652
|
console.log(`
|
|
2535
|
-
${
|
|
2653
|
+
${import_picocolors5.default.bold("Installed CLIs:")}
|
|
2536
2654
|
`);
|
|
2537
2655
|
for (const d of dirs) {
|
|
2538
2656
|
const name = d.replace(/-cli$/, "");
|
|
2539
|
-
const built =
|
|
2540
|
-
const hasToken =
|
|
2657
|
+
const built = existsSync7(join6(CLI_ROOT, d, "dist"));
|
|
2658
|
+
const hasToken = existsSync7(join6(TOKENS_DIR, `${d}.txt`));
|
|
2541
2659
|
const status = [
|
|
2542
|
-
built ?
|
|
2543
|
-
hasToken ?
|
|
2544
|
-
].join(
|
|
2545
|
-
console.log(` ${
|
|
2660
|
+
built ? import_picocolors5.default.green("built") : import_picocolors5.default.yellow("not built"),
|
|
2661
|
+
hasToken ? import_picocolors5.default.green("auth") : import_picocolors5.default.dim("no auth")
|
|
2662
|
+
].join(import_picocolors5.default.dim(" | "));
|
|
2663
|
+
console.log(` ${import_picocolors5.default.bold(name.padEnd(20))} ${status}`);
|
|
2546
2664
|
}
|
|
2547
2665
|
console.log();
|
|
2548
2666
|
});
|
|
2549
2667
|
|
|
2550
2668
|
// src/commands/bundle.ts
|
|
2551
|
-
var
|
|
2552
|
-
import { existsSync as
|
|
2669
|
+
var import_picocolors6 = __toESM(require_picocolors(), 1);
|
|
2670
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync4 } from "fs";
|
|
2553
2671
|
import { join as join7 } from "path";
|
|
2554
2672
|
import { readdirSync as readdirSync4 } from "fs";
|
|
2555
2673
|
var bundleCommand = new Command("bundle").description("Build/rebuild a CLI from source").argument("[app]", "CLI to build (omit with --all)").option("--compile", "Create standalone binary (~50MB, no runtime needed)").option("--all", "Build all installed CLIs").addHelpText("after", `
|
|
@@ -2558,7 +2676,7 @@ Examples:
|
|
|
2558
2676
|
api2cli bundle typefully --compile
|
|
2559
2677
|
api2cli bundle --all`).action(async (app, opts) => {
|
|
2560
2678
|
if (opts.all) {
|
|
2561
|
-
if (!
|
|
2679
|
+
if (!existsSync8(CLI_ROOT)) {
|
|
2562
2680
|
console.log("No CLIs installed.");
|
|
2563
2681
|
return;
|
|
2564
2682
|
}
|
|
@@ -2576,13 +2694,13 @@ Examples:
|
|
|
2576
2694
|
});
|
|
2577
2695
|
async function buildCli(app, compile) {
|
|
2578
2696
|
const cliDir = getCliDir(app);
|
|
2579
|
-
if (!
|
|
2580
|
-
console.error(`${
|
|
2697
|
+
if (!existsSync8(cliDir)) {
|
|
2698
|
+
console.error(`${import_picocolors6.default.red("\u2717")} ${app}-cli not found. Run: ${import_picocolors6.default.cyan(`api2cli create ${app}`)}`);
|
|
2581
2699
|
return;
|
|
2582
2700
|
}
|
|
2583
2701
|
const distDir = getDistDir(app);
|
|
2584
|
-
|
|
2585
|
-
console.log(`Building ${
|
|
2702
|
+
mkdirSync4(distDir, { recursive: true });
|
|
2703
|
+
console.log(`Building ${import_picocolors6.default.bold(`${app}-cli`)}...`);
|
|
2586
2704
|
const entry = join7(cliDir, "src", "index.ts");
|
|
2587
2705
|
const outfile = join7(distDir, compile ? `${app}-cli` : `${app}-cli.js`);
|
|
2588
2706
|
const args = ["bun", "build", entry, "--outfile", outfile, "--target", "bun"];
|
|
@@ -2593,22 +2711,22 @@ async function buildCli(app, compile) {
|
|
|
2593
2711
|
if (code === 0) {
|
|
2594
2712
|
const size = Bun.file(outfile).size;
|
|
2595
2713
|
const sizeStr = size > 1024 * 1024 ? `${(size / 1024 / 1024).toFixed(1)}MB` : `${(size / 1024).toFixed(1)}KB`;
|
|
2596
|
-
console.log(`${
|
|
2714
|
+
console.log(`${import_picocolors6.default.green("\u2713")} Built ${import_picocolors6.default.bold(`${app}-cli`)} (${sizeStr})`);
|
|
2597
2715
|
} else {
|
|
2598
2716
|
const stderr = await new Response(proc.stderr).text();
|
|
2599
|
-
console.error(`${
|
|
2717
|
+
console.error(`${import_picocolors6.default.red("\u2717")} Build failed: ${stderr}`);
|
|
2600
2718
|
}
|
|
2601
2719
|
}
|
|
2602
2720
|
|
|
2603
2721
|
// src/commands/link.ts
|
|
2604
|
-
var
|
|
2605
|
-
import { existsSync as
|
|
2722
|
+
var import_picocolors7 = __toESM(require_picocolors(), 1);
|
|
2723
|
+
import { existsSync as existsSync9, readdirSync as readdirSync5 } from "fs";
|
|
2606
2724
|
var linkCommand = new Command("link").description("Add a CLI to your PATH").argument("[app]", "CLI to link (omit with --all)").option("--all", "Link all installed CLIs").addHelpText("after", `
|
|
2607
2725
|
Examples:
|
|
2608
2726
|
api2cli link typefully
|
|
2609
2727
|
api2cli link --all`).action((app, opts) => {
|
|
2610
2728
|
if (opts.all || !app) {
|
|
2611
|
-
if (!
|
|
2729
|
+
if (!existsSync9(CLI_ROOT)) {
|
|
2612
2730
|
console.log("No CLIs installed.");
|
|
2613
2731
|
return;
|
|
2614
2732
|
}
|
|
@@ -2619,8 +2737,8 @@ Examples:
|
|
|
2619
2737
|
}
|
|
2620
2738
|
return;
|
|
2621
2739
|
}
|
|
2622
|
-
if (!
|
|
2623
|
-
console.error(`${
|
|
2740
|
+
if (!existsSync9(getCliDir(app))) {
|
|
2741
|
+
console.error(`${import_picocolors7.default.red("\u2717")} ${app}-cli not found. Run: ${import_picocolors7.default.cyan(`api2cli create ${app}`)}`);
|
|
2624
2742
|
process.exit(1);
|
|
2625
2743
|
}
|
|
2626
2744
|
addToPath(app, getDistDir(app));
|
|
@@ -2634,14 +2752,14 @@ Example:
|
|
|
2634
2752
|
});
|
|
2635
2753
|
|
|
2636
2754
|
// src/commands/tokens.ts
|
|
2637
|
-
var
|
|
2638
|
-
import { existsSync as
|
|
2755
|
+
var import_picocolors8 = __toESM(require_picocolors(), 1);
|
|
2756
|
+
import { existsSync as existsSync10, readdirSync as readdirSync6, readFileSync as readFileSync4 } from "fs";
|
|
2639
2757
|
import { join as join8 } from "path";
|
|
2640
2758
|
var tokensCommand = new Command("tokens").description("List all configured API tokens").option("--show", "Show full unmasked tokens").addHelpText("after", `
|
|
2641
2759
|
Examples:
|
|
2642
2760
|
api2cli tokens
|
|
2643
2761
|
api2cli tokens --show`).action((opts) => {
|
|
2644
|
-
if (!
|
|
2762
|
+
if (!existsSync10(TOKENS_DIR)) {
|
|
2645
2763
|
console.log("No tokens configured yet.");
|
|
2646
2764
|
return;
|
|
2647
2765
|
}
|
|
@@ -2651,118 +2769,102 @@ Examples:
|
|
|
2651
2769
|
return;
|
|
2652
2770
|
}
|
|
2653
2771
|
console.log(`
|
|
2654
|
-
${
|
|
2772
|
+
${import_picocolors8.default.bold("Configured tokens:")}
|
|
2655
2773
|
`);
|
|
2656
2774
|
for (const f of files) {
|
|
2657
2775
|
const name = f.replace(".txt", "");
|
|
2658
|
-
const token =
|
|
2659
|
-
const display = opts.show ? token : token.length > 8 ? `${token.slice(0, 4)}${
|
|
2660
|
-
console.log(` ${
|
|
2776
|
+
const token = readFileSync4(join8(TOKENS_DIR, f), "utf-8").trim();
|
|
2777
|
+
const display = opts.show ? token : token.length > 8 ? `${token.slice(0, 4)}${import_picocolors8.default.dim("...")}${token.slice(-4)}` : import_picocolors8.default.dim("****");
|
|
2778
|
+
console.log(` ${import_picocolors8.default.bold(name.padEnd(25))} ${display}`);
|
|
2661
2779
|
}
|
|
2662
2780
|
console.log();
|
|
2663
2781
|
});
|
|
2664
2782
|
|
|
2665
2783
|
// src/commands/remove.ts
|
|
2666
|
-
var
|
|
2667
|
-
import { existsSync as
|
|
2784
|
+
var import_picocolors9 = __toESM(require_picocolors(), 1);
|
|
2785
|
+
import { existsSync as existsSync11, rmSync as rmSync2 } from "fs";
|
|
2668
2786
|
var removeCommand = new Command("remove").description("Remove a CLI entirely").argument("<app>", "CLI to remove").option("--keep-token", "Keep the auth token").addHelpText("after", `
|
|
2669
2787
|
Examples:
|
|
2670
2788
|
api2cli remove typefully
|
|
2671
2789
|
api2cli remove typefully --keep-token`).action((app, opts) => {
|
|
2672
2790
|
const cliDir = getCliDir(app);
|
|
2673
|
-
if (!
|
|
2674
|
-
console.error(`${
|
|
2791
|
+
if (!existsSync11(cliDir)) {
|
|
2792
|
+
console.error(`${import_picocolors9.default.red("\u2717")} ${app}-cli not found.`);
|
|
2675
2793
|
process.exit(1);
|
|
2676
2794
|
}
|
|
2677
2795
|
removeFromPath(app, getDistDir(app));
|
|
2678
2796
|
rmSync2(cliDir, { recursive: true, force: true });
|
|
2679
|
-
console.log(`${
|
|
2797
|
+
console.log(`${import_picocolors9.default.green("\u2713")} Removed ${import_picocolors9.default.bold(`${app}-cli`)}`);
|
|
2680
2798
|
if (!opts.keepToken) {
|
|
2681
2799
|
const tokenFile = getTokenFile(app);
|
|
2682
|
-
if (
|
|
2800
|
+
if (existsSync11(tokenFile)) {
|
|
2683
2801
|
rmSync2(tokenFile);
|
|
2684
|
-
console.log(`${
|
|
2802
|
+
console.log(`${import_picocolors9.default.green("\u2713")} Removed token`);
|
|
2685
2803
|
}
|
|
2686
2804
|
}
|
|
2687
2805
|
});
|
|
2688
2806
|
|
|
2689
2807
|
// src/commands/doctor.ts
|
|
2690
|
-
var
|
|
2691
|
-
import { existsSync as
|
|
2808
|
+
var import_picocolors10 = __toESM(require_picocolors(), 1);
|
|
2809
|
+
import { existsSync as existsSync12 } from "fs";
|
|
2692
2810
|
var doctorCommand = new Command("doctor").description("Check system requirements and configuration").addHelpText("after", `
|
|
2693
2811
|
Example:
|
|
2694
2812
|
api2cli doctor`).action(async () => {
|
|
2695
2813
|
console.log(`
|
|
2696
|
-
${
|
|
2814
|
+
${import_picocolors10.default.bold("api2cli doctor")}
|
|
2697
2815
|
`);
|
|
2698
2816
|
let issues = 0;
|
|
2699
2817
|
try {
|
|
2700
2818
|
const proc = Bun.spawn(["bun", "--version"], { stdout: "pipe", stderr: "pipe" });
|
|
2701
2819
|
const version = (await new Response(proc.stdout).text()).trim();
|
|
2702
|
-
console.log(` ${
|
|
2820
|
+
console.log(` ${import_picocolors10.default.green("\u2713")} Bun ${version}`);
|
|
2703
2821
|
} catch {
|
|
2704
|
-
console.log(` ${
|
|
2822
|
+
console.log(` ${import_picocolors10.default.red("\u2717")} Bun not found. Install: ${import_picocolors10.default.cyan("https://bun.sh")}`);
|
|
2705
2823
|
issues++;
|
|
2706
2824
|
}
|
|
2707
2825
|
try {
|
|
2708
2826
|
const proc = Bun.spawn(["git", "--version"], { stdout: "pipe", stderr: "pipe" });
|
|
2709
2827
|
const version = (await new Response(proc.stdout).text()).trim();
|
|
2710
|
-
console.log(` ${
|
|
2828
|
+
console.log(` ${import_picocolors10.default.green("\u2713")} ${version}`);
|
|
2711
2829
|
} catch {
|
|
2712
|
-
console.log(` ${
|
|
2830
|
+
console.log(` ${import_picocolors10.default.red("\u2717")} Git not found (required to fetch template)`);
|
|
2713
2831
|
issues++;
|
|
2714
2832
|
}
|
|
2715
|
-
if (
|
|
2716
|
-
console.log(` ${
|
|
2833
|
+
if (existsSync12(CLI_ROOT)) {
|
|
2834
|
+
console.log(` ${import_picocolors10.default.green("\u2713")} CLI root: ${import_picocolors10.default.dim(CLI_ROOT)}`);
|
|
2717
2835
|
} else {
|
|
2718
|
-
console.log(` ${
|
|
2836
|
+
console.log(` ${import_picocolors10.default.yellow("~")} CLI root not yet created: ${import_picocolors10.default.dim(CLI_ROOT)}`);
|
|
2719
2837
|
}
|
|
2720
|
-
if (
|
|
2721
|
-
console.log(` ${
|
|
2838
|
+
if (existsSync12(TOKENS_DIR)) {
|
|
2839
|
+
console.log(` ${import_picocolors10.default.green("\u2713")} Tokens dir: ${import_picocolors10.default.dim(TOKENS_DIR)}`);
|
|
2722
2840
|
} else {
|
|
2723
|
-
console.log(` ${
|
|
2841
|
+
console.log(` ${import_picocolors10.default.yellow("~")} Tokens dir not yet created: ${import_picocolors10.default.dim(TOKENS_DIR)}`);
|
|
2724
2842
|
}
|
|
2725
|
-
console.log(` ${
|
|
2843
|
+
console.log(` ${import_picocolors10.default.green("\u2713")} Template: ${import_picocolors10.default.dim(TEMPLATE_REPO)} (fetched on create)`);
|
|
2726
2844
|
console.log(issues === 0 ? `
|
|
2727
|
-
${
|
|
2845
|
+
${import_picocolors10.default.green("All good!")}
|
|
2728
2846
|
` : `
|
|
2729
|
-
${
|
|
2847
|
+
${import_picocolors10.default.red(`${issues} issue(s) found.`)}
|
|
2730
2848
|
`);
|
|
2731
2849
|
});
|
|
2732
2850
|
|
|
2733
2851
|
// src/commands/update.ts
|
|
2734
|
-
var
|
|
2735
|
-
import { existsSync as
|
|
2852
|
+
var import_picocolors11 = __toESM(require_picocolors(), 1);
|
|
2853
|
+
import { existsSync as existsSync13 } from "fs";
|
|
2736
2854
|
var updateCommand = new Command("update").description("Re-sync a CLI when the upstream API changes").argument("<app>", "CLI to update").option("--docs <url>", "Updated API documentation URL").option("--openapi <url>", "Updated OpenAPI spec URL").addHelpText("after", `
|
|
2737
2855
|
Example:
|
|
2738
2856
|
api2cli update typefully --docs https://docs.typefully.com`).action(async (app) => {
|
|
2739
2857
|
const cliDir = getCliDir(app);
|
|
2740
|
-
if (!
|
|
2741
|
-
console.error(`${
|
|
2858
|
+
if (!existsSync13(cliDir)) {
|
|
2859
|
+
console.error(`${import_picocolors11.default.red("\u2717")} ${app}-cli not found. Run: ${import_picocolors11.default.cyan(`api2cli create ${app}`)}`);
|
|
2742
2860
|
process.exit(1);
|
|
2743
2861
|
}
|
|
2744
|
-
console.log(`${
|
|
2862
|
+
console.log(`${import_picocolors11.default.yellow("\uD83D\uDEA7")} Update is agent-driven.`);
|
|
2745
2863
|
console.log(`
|
|
2746
2864
|
Use your AI agent to update resources in:`);
|
|
2747
|
-
console.log(` ${
|
|
2748
|
-
console.log(`
|
|
2749
|
-
Then rebuild: ${import_picocolors10.default.cyan(`api2cli bundle ${app}`)}`);
|
|
2750
|
-
});
|
|
2751
|
-
|
|
2752
|
-
// src/commands/publish.ts
|
|
2753
|
-
var import_picocolors11 = __toESM(require_picocolors(), 1);
|
|
2754
|
-
import { existsSync as existsSync12 } from "fs";
|
|
2755
|
-
var publishCommand = new Command("publish").description("Publish a CLI to the api2cli registry").argument("<app>", "CLI to publish").option("--scope <scope>", "npm scope", "@api2cli").addHelpText("after", `
|
|
2756
|
-
Example:
|
|
2757
|
-
api2cli publish typefully`).action(async (app, opts) => {
|
|
2758
|
-
const cliDir = getCliDir(app);
|
|
2759
|
-
if (!existsSync12(cliDir)) {
|
|
2760
|
-
console.error(`${import_picocolors11.default.red("\u2717")} ${app}-cli not found.`);
|
|
2761
|
-
process.exit(1);
|
|
2762
|
-
}
|
|
2763
|
-
console.log(`Publishing ${import_picocolors11.default.bold(`${app}-cli`)} as ${import_picocolors11.default.cyan(`${opts.scope}/${app}`)}...`);
|
|
2865
|
+
console.log(` ${import_picocolors11.default.dim(`${cliDir}/src/resources/`)}`);
|
|
2764
2866
|
console.log(`
|
|
2765
|
-
${import_picocolors11.default.
|
|
2867
|
+
Then rebuild: ${import_picocolors11.default.cyan(`api2cli bundle ${app}`)}`);
|
|
2766
2868
|
});
|
|
2767
2869
|
|
|
2768
2870
|
// src/index.ts
|