@rankcli/cli 0.0.35 → 0.0.37

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 CHANGED
@@ -1105,6 +1105,8 @@ async function analyze(options) {
1105
1105
  var import_agent_runtime2 = require("@rankcli/agent-runtime");
1106
1106
  var import_ora2 = __toESM(require("ora"));
1107
1107
  var import_chalk4 = __toESM(require("chalk"));
1108
+ var import_inquirer3 = __toESM(require("inquirer"));
1109
+ var import_node_child_process2 = require("child_process");
1108
1110
 
1109
1111
  // src/lib/upsell.ts
1110
1112
  var import_chalk3 = __toESM(require("chalk"));
@@ -2140,12 +2142,66 @@ async function syncToCloud(url, report, mergedIssues, pagesAudited, aiAnalysis,
2140
2142
  console.error(import_chalk4.default.dim("Cloud sync returned an unexpected response"));
2141
2143
  return null;
2142
2144
  }
2143
- return { projectId: data.projectId, auditId: data.auditId };
2145
+ return { projectId: data.projectId, auditId: data.auditId, githubLinked: !!data.githubLinked };
2144
2146
  } catch (error) {
2145
2147
  console.error(import_chalk4.default.dim(`Cloud sync failed: ${error instanceof Error ? error.message : String(error)}`));
2146
2148
  return null;
2147
2149
  }
2148
2150
  }
2151
+ function githubRemoteUrl() {
2152
+ try {
2153
+ const remote = (0, import_node_child_process2.execSync)("git remote get-url origin", {
2154
+ cwd: process.cwd(),
2155
+ encoding: "utf8",
2156
+ stdio: ["ignore", "pipe", "ignore"]
2157
+ }).trim();
2158
+ const match = remote.match(/github\.com[:/]([A-Za-z0-9._-]+)\/([A-Za-z0-9._-]+?)(?:\.git)?$/);
2159
+ return match ? `https://github.com/${match[1]}/${match[2]}` : null;
2160
+ } catch {
2161
+ return null;
2162
+ }
2163
+ }
2164
+ async function offerRepoLink(projectId) {
2165
+ const repoUrl = githubRemoteUrl();
2166
+ if (!repoUrl) return;
2167
+ console.error("");
2168
+ const { link } = await import_inquirer3.default.prompt([
2169
+ {
2170
+ type: "confirm",
2171
+ name: "link",
2172
+ message: `Link ${repoUrl} to this project? RankCLI can then open SEO fix PRs against it.`,
2173
+ default: true
2174
+ }
2175
+ ]);
2176
+ if (!link) {
2177
+ console.error(import_chalk4.default.dim(" Skipped. Link it any time from the project page."));
2178
+ return;
2179
+ }
2180
+ const headers = { "Content-Type": "application/json" };
2181
+ if (isApiKeyAuth()) {
2182
+ const apiKey = getApiKey();
2183
+ if (apiKey) headers["X-API-Key"] = apiKey;
2184
+ } else {
2185
+ const session = await getSession();
2186
+ if (session) headers.Authorization = `Bearer ${session.access_token}`;
2187
+ }
2188
+ const spinner = (0, import_ora2.default)("Linking repository...").start();
2189
+ try {
2190
+ const response = await fetch(`${getApiUrl()}/functions/v1/connect-github-repo`, {
2191
+ method: "POST",
2192
+ headers,
2193
+ body: JSON.stringify({ projectId, repoUrl })
2194
+ });
2195
+ const result = await response.json();
2196
+ if (result.linked) {
2197
+ spinner.succeed("Repository linked - auto-fix PRs are available for this project.");
2198
+ } else {
2199
+ spinner.warn(result.reason || result.error || "Could not link this repository.");
2200
+ }
2201
+ } catch (error) {
2202
+ spinner.warn(`Could not link this repository: ${error instanceof Error ? error.message : error}`);
2203
+ }
2204
+ }
2149
2205
  function printUsage(loggedIn) {
2150
2206
  console.error("\n\u26A0\uFE0F Please provide a URL to audit:");
2151
2207
  console.error(" rankcli audit --url https://your-site.com");
@@ -2418,6 +2474,10 @@ async function audit(options) {
2418
2474
  View and manage issues in the web dashboard:`));
2419
2475
  console.log(import_chalk4.default.bold(` ${WEB_APP_URL}/dashboard/projects/${syncResult.projectId}
2420
2476
  `));
2477
+ const interactive = process.stdout.isTTY && !process.env.CI;
2478
+ if (!syncResult.githubLinked && interactive) {
2479
+ await offerRepoLink(syncResult.projectId);
2480
+ }
2421
2481
  } else {
2422
2482
  syncSpinner.warn("Could not sync to cloud");
2423
2483
  }
@@ -4239,7 +4299,7 @@ async function testWebhook(channel, webhookUrl) {
4239
4299
  }
4240
4300
 
4241
4301
  // src/version.ts
4242
- var VERSION = "0.0.35";
4302
+ var VERSION = "0.0.37";
4243
4303
 
4244
4304
  // src/index.ts
4245
4305
  var program = new import_commander.Command();
package/dist/index.mjs CHANGED
@@ -1092,6 +1092,8 @@ async function analyze(options) {
1092
1092
  import { runFullAudit, discoverPagesFromLinks, frameworks } from "@rankcli/agent-runtime";
1093
1093
  import ora2 from "ora";
1094
1094
  import chalk4 from "chalk";
1095
+ import inquirer3 from "inquirer";
1096
+ import { execSync as execSync2 } from "child_process";
1095
1097
 
1096
1098
  // src/lib/upsell.ts
1097
1099
  import chalk3 from "chalk";
@@ -1961,12 +1963,66 @@ async function syncToCloud(url, report, mergedIssues, pagesAudited, aiAnalysis,
1961
1963
  console.error(chalk4.dim("Cloud sync returned an unexpected response"));
1962
1964
  return null;
1963
1965
  }
1964
- return { projectId: data.projectId, auditId: data.auditId };
1966
+ return { projectId: data.projectId, auditId: data.auditId, githubLinked: !!data.githubLinked };
1965
1967
  } catch (error) {
1966
1968
  console.error(chalk4.dim(`Cloud sync failed: ${error instanceof Error ? error.message : String(error)}`));
1967
1969
  return null;
1968
1970
  }
1969
1971
  }
1972
+ function githubRemoteUrl() {
1973
+ try {
1974
+ const remote = execSync2("git remote get-url origin", {
1975
+ cwd: process.cwd(),
1976
+ encoding: "utf8",
1977
+ stdio: ["ignore", "pipe", "ignore"]
1978
+ }).trim();
1979
+ const match = remote.match(/github\.com[:/]([A-Za-z0-9._-]+)\/([A-Za-z0-9._-]+?)(?:\.git)?$/);
1980
+ return match ? `https://github.com/${match[1]}/${match[2]}` : null;
1981
+ } catch {
1982
+ return null;
1983
+ }
1984
+ }
1985
+ async function offerRepoLink(projectId) {
1986
+ const repoUrl = githubRemoteUrl();
1987
+ if (!repoUrl) return;
1988
+ console.error("");
1989
+ const { link } = await inquirer3.prompt([
1990
+ {
1991
+ type: "confirm",
1992
+ name: "link",
1993
+ message: `Link ${repoUrl} to this project? RankCLI can then open SEO fix PRs against it.`,
1994
+ default: true
1995
+ }
1996
+ ]);
1997
+ if (!link) {
1998
+ console.error(chalk4.dim(" Skipped. Link it any time from the project page."));
1999
+ return;
2000
+ }
2001
+ const headers = { "Content-Type": "application/json" };
2002
+ if (isApiKeyAuth()) {
2003
+ const apiKey = getApiKey();
2004
+ if (apiKey) headers["X-API-Key"] = apiKey;
2005
+ } else {
2006
+ const session = await getSession();
2007
+ if (session) headers.Authorization = `Bearer ${session.access_token}`;
2008
+ }
2009
+ const spinner = ora2("Linking repository...").start();
2010
+ try {
2011
+ const response = await fetch(`${getApiUrl()}/functions/v1/connect-github-repo`, {
2012
+ method: "POST",
2013
+ headers,
2014
+ body: JSON.stringify({ projectId, repoUrl })
2015
+ });
2016
+ const result = await response.json();
2017
+ if (result.linked) {
2018
+ spinner.succeed("Repository linked - auto-fix PRs are available for this project.");
2019
+ } else {
2020
+ spinner.warn(result.reason || result.error || "Could not link this repository.");
2021
+ }
2022
+ } catch (error) {
2023
+ spinner.warn(`Could not link this repository: ${error instanceof Error ? error.message : error}`);
2024
+ }
2025
+ }
1970
2026
  function printUsage(loggedIn) {
1971
2027
  console.error("\n\u26A0\uFE0F Please provide a URL to audit:");
1972
2028
  console.error(" rankcli audit --url https://your-site.com");
@@ -2239,6 +2295,10 @@ async function audit(options) {
2239
2295
  View and manage issues in the web dashboard:`));
2240
2296
  console.log(chalk4.bold(` ${WEB_APP_URL}/dashboard/projects/${syncResult.projectId}
2241
2297
  `));
2298
+ const interactive = process.stdout.isTTY && !process.env.CI;
2299
+ if (!syncResult.githubLinked && interactive) {
2300
+ await offerRepoLink(syncResult.projectId);
2301
+ }
2242
2302
  } else {
2243
2303
  syncSpinner.warn("Could not sync to cloud");
2244
2304
  }
@@ -4095,7 +4155,7 @@ async function testWebhook(channel, webhookUrl) {
4095
4155
  }
4096
4156
 
4097
4157
  // src/version.ts
4098
- var VERSION = "0.0.35";
4158
+ var VERSION = "0.0.37";
4099
4159
 
4100
4160
  // src/index.ts
4101
4161
  var program = new Command();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rankcli/cli",
3
- "version": "0.0.35",
3
+ "version": "0.0.37",
4
4
  "description": "RankCLI - Ship code, get ranked. SEO meets CI/CD.",
5
5
  "homepage": "https://rankcli.dev",
6
6
  "main": "dist/index.js",
@@ -45,7 +45,7 @@
45
45
  "update-version": "node scripts/update-version.js"
46
46
  },
47
47
  "dependencies": {
48
- "@rankcli/agent-runtime": "^0.0.25",
48
+ "@rankcli/agent-runtime": "^0.0.26",
49
49
  "@supabase/supabase-js": "^2.98.0",
50
50
  "chalk": "^5.3.0",
51
51
  "commander": "^12.0.0",
Binary file