neon 8.10.1 → 8.10.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/README.md CHANGED
@@ -1015,7 +1015,7 @@ neon docs search "create branch" --category api --category docs
1015
1015
  neon docs search "pg_dump" --limit 5 --output json
1016
1016
  ```
1017
1017
 
1018
- `--category` limits results to `docs`, `api`, `postgresql`, `guides`, `faqs`, `blog`, or `changelog`; repeat it for more than one. `--limit` is 1 to 40, default 10. Default table output is one row per page: title, the section that matched, and URL. `--output json` and `--output yaml` print an array of hits with `title`, `url`, `category`, `breadcrumb`, `heading`, and `excerpt`, in rank order. No match prints `No results for "<query>".` and exits 0 (`[]` in JSON).
1018
+ `--category` limits results to `docs`, `api`, `postgresql`, `guides`, `faqs`, `blog`, or `changelog`; repeat it for more than one. `--limit` is 1 to 40, default 10. Default output is one block per result: `Title › Section` on one line, cut to the terminal width, and the full URL under it. `--output json` and `--output yaml` print an array of hits with `title`, `url`, `category`, `breadcrumb`, `heading`, and `excerpt`, in rank order. No match prints `No results for "<query>".` and exits 0 (`[]` in JSON).
1019
1019
 
1020
1020
  ## Install the Neon plugin (`plugins`)
1021
1021
 
@@ -4,12 +4,12 @@ import { isClaimableEnvTarget } from "../claimable/state.js";
4
4
  import { getCliName } from "../utils/cli_name.js";
5
5
  import { defaultDevEnvFiles, readEnvFile, resolveEnvFilePath } from "../env_file.js";
6
6
  import { l as functionBaseUrlKey } from "../_chunks/env-BpP3Dqpe.js";
7
- import { branchIdResolve } from "../utils/enrichers.js";
8
- import { bundleEntry } from "../utils/esbuild.js";
9
7
  import { a as resolveDevEnv } from "../_chunks/env-BNm69Qh8.js";
10
- import { envFlag } from "./config.js";
11
8
  import { findConfigFunctionBySource, resolveFunctionsFromConfig } from "../dev/functions.js";
12
9
  import { resolveWatchInputs } from "../dev/inputs.js";
10
+ import { branchIdResolve } from "../utils/enrichers.js";
11
+ import { bundleEntry } from "../utils/esbuild.js";
12
+ import { envFlag } from "./config.js";
13
13
  import { existsSync, mkdirSync, rmSync, statSync, writeFileSync } from "node:fs";
14
14
  import { basename, dirname, join, relative, resolve } from "node:path";
15
15
  import { fileURLToPath } from "node:url";
@@ -1,9 +1,11 @@
1
1
  import { t as __exportAll } from "../_chunks/rolldown-runtime-8H4AJuhK.js";
2
- import { getCliAgent } from "../env.js";
2
+ import { getCliAgent, isCi } from "../env.js";
3
3
  import pkg_default from "../pkg.js";
4
4
  import { isNetworkError } from "../errors.js";
5
+ import { resolveOutputWidth, stripAnsi, truncateTo } from "../human_table.js";
5
6
  import { writer } from "../writer.js";
6
7
  import { single } from "../utils/flags.js";
8
+ import chalk from "chalk";
7
9
  //#region src/commands/docs.ts
8
10
  var docs_exports = /* @__PURE__ */ __exportAll({
9
11
  DEFAULT_SITE_SEARCH_URL: () => DEFAULT_SITE_SEARCH_URL,
@@ -13,6 +15,7 @@ var docs_exports = /* @__PURE__ */ __exportAll({
13
15
  builder: () => builder,
14
16
  command: () => command,
15
17
  describe: () => describe,
18
+ formatSearchResults: () => formatSearchResults,
16
19
  parseSearchHits: () => parseSearchHits,
17
20
  resolveSiteSearchUrl: () => resolveSiteSearchUrl,
18
21
  siteSearchHeaders: () => siteSearchHeaders
@@ -86,16 +89,36 @@ const search = async (props) => {
86
89
  version: pkg_default.version
87
90
  })
88
91
  });
89
- writer(props).end(hits, {
90
- fields: [
91
- "title",
92
- "heading",
93
- "url"
94
- ],
95
- emptyMessage: `No results for "${query}".`,
96
- renderColumns: { heading: (hit) => sectionOf(hit) }
92
+ const emptyMessage = `No results for "${query}".`;
93
+ if (props.output === "json" || props.output === "yaml") {
94
+ writer(props).end(hits, {
95
+ fields: [
96
+ "title",
97
+ "heading",
98
+ "url"
99
+ ],
100
+ emptyMessage
101
+ });
102
+ return;
103
+ }
104
+ const text = formatSearchResults(hits, {
105
+ emptyMessage,
106
+ width: resolveOutputWidth(process.stdout, void 0, {
107
+ stdout: process.stdout,
108
+ envColumns: process.env.COLUMNS
109
+ })
97
110
  });
111
+ process.stdout.write(process.env.NO_COLOR || isCi() ? stripAnsi(text) : text);
98
112
  };
113
+ function formatSearchResults(hits, opts) {
114
+ if (hits.length === 0) return `\n${opts.emptyMessage}\n`;
115
+ return hits.map((hit) => {
116
+ const section = sectionOf(hit).split(" > ").filter(Boolean);
117
+ const line = [hit.title, ...section].join(" › ");
118
+ const shown = opts.width === void 0 ? line : truncateTo(line, opts.width);
119
+ return `${chalk.bold(shown)}\n ${chalk.cyan(hit.url)}\n`;
120
+ }).join("\n");
121
+ }
99
122
  function sectionOf(hit) {
100
123
  const parts = hit.heading.split(" > ");
101
124
  return (parts[0] === hit.title ? parts.slice(1) : parts).join(" > ");
@@ -171,4 +194,4 @@ function parseSearchHits(raw) {
171
194
  });
172
195
  }
173
196
  //#endregion
174
- export { DEFAULT_SITE_SEARCH_URL, MAX_LIMIT, MAX_QUERY_LENGTH, SITE_SEARCH_CATEGORIES, builder, command, describe, parseSearchHits, resolveSiteSearchUrl, siteSearchHeaders, docs_exports as t };
197
+ export { DEFAULT_SITE_SEARCH_URL, MAX_LIMIT, MAX_QUERY_LENGTH, SITE_SEARCH_CATEGORIES, builder, command, describe, formatSearchResults, parseSearchHits, resolveSiteSearchUrl, siteSearchHeaders, docs_exports as t };
@@ -7,9 +7,9 @@ import { deprecatedServiceMessage, parseServices, servicesFlagValue, servicesOpt
7
7
  import { mergeEnvFile, readEnvFile, resolveEnvFilePath } from "../env_file.js";
8
8
  import { t as NEON_ENV_VAR_KEYS, u as isFunctionBaseUrlKey } from "../_chunks/env-BpP3Dqpe.js";
9
9
  import { ENV_PULL_KEY_HELP, ENV_PULL_SERVICES, envKeysForSelection, envPullFlagValue, ownedEnvServiceKeys, parseEnvPullKeys } from "../env_services.js";
10
+ import { i as dropClaimableUnsupported, o as resolveNeonEnvVars } from "../_chunks/env-BNm69Qh8.js";
10
11
  import { fillSingleProject, resolveBranchRef } from "../utils/enrichers.js";
11
12
  import { warnAiGateway } from "../utils/ai_gateway_notice.js";
12
- import { i as dropClaimableUnsupported, o as resolveNeonEnvVars } from "../_chunks/env-BNm69Qh8.js";
13
13
  import { formatPulledEnv, pulledBranch } from "./env_output.js";
14
14
  import { existsSync } from "node:fs";
15
15
  import chalk from "chalk";
@@ -1,6 +1,6 @@
1
1
  import { writer } from "../writer.js";
2
- import { branchIdFromProps } from "../utils/enrichers.js";
3
2
  import { o as resolveNeonEnvVars } from "../_chunks/env-BNm69Qh8.js";
3
+ import { branchIdFromProps } from "../utils/enrichers.js";
4
4
  import YAML from "yaml";
5
5
  //#region src/commands/subscribe.ts
6
6
  const builder = (argv) => argv.usage("$0 realtime subscribe \"<query>\" [options]").positional("query", {
@@ -226,4 +226,4 @@ function charWidth(code) {
226
226
  return 1;
227
227
  }
228
228
  //#endregion
229
- export { displayWidth, formatHumanChunk, parseColumns, resolveOutputWidth, stripAnsi, titleCaseField };
229
+ export { displayWidth, formatHumanChunk, parseColumns, resolveOutputWidth, stripAnsi, titleCaseField, truncateTo };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neon",
3
- "version": "8.10.1",
3
+ "version": "8.10.2",
4
4
  "description": "CLI tool for Neon, the cloud backend primitives built around Lakebase Postgres",
5
5
  "keywords": [
6
6
  "neon",
@@ -70,8 +70,8 @@
70
70
  "yaml": "^2.9.0",
71
71
  "yargs": "17.7.2",
72
72
  "yoctocolors": "^2.1.2",
73
- "@neon/config": "1.9.3",
74
73
  "@neon/realtime": "0.1.2",
74
+ "@neon/config": "1.9.3",
75
75
  "@neon/sdk": "7.4.0",
76
76
  "@neon/config-runtime": "1.10.2"
77
77
  },