neon 4.2.0 → 4.2.1
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/commands/branches.js +2 -2
- package/dist/commands/projects.js +11 -6
- package/dist/commands/snapshots.js +2 -2
- package/dist/human_table.js +18 -51
- package/package.json +3 -3
|
@@ -12,6 +12,7 @@ import prompts from "prompts";
|
|
|
12
12
|
//#region src/commands/projects.ts
|
|
13
13
|
var projects_exports = /* @__PURE__ */ __exportAll({
|
|
14
14
|
PROJECT_FIELDS: () => PROJECT_FIELDS,
|
|
15
|
+
RECOVERABLE_PROJECT_FIELDS: () => RECOVERABLE_PROJECT_FIELDS,
|
|
15
16
|
REGIONS: () => REGIONS,
|
|
16
17
|
aliases: () => aliases,
|
|
17
18
|
builder: () => builder,
|
|
@@ -25,6 +26,14 @@ const PROJECT_FIELDS = [
|
|
|
25
26
|
"region_id",
|
|
26
27
|
"created_at"
|
|
27
28
|
];
|
|
29
|
+
const RECOVERABLE_PROJECT_FIELDS = [
|
|
30
|
+
"id",
|
|
31
|
+
"name",
|
|
32
|
+
"recoverable_until",
|
|
33
|
+
"deleted_at",
|
|
34
|
+
"region_id",
|
|
35
|
+
"created_at"
|
|
36
|
+
];
|
|
28
37
|
const REGIONS = [
|
|
29
38
|
"aws-us-west-2",
|
|
30
39
|
"aws-ap-southeast-1",
|
|
@@ -185,11 +194,7 @@ const list = async (props) => {
|
|
|
185
194
|
const sharedProjects = props.orgId || props.recoverableOnly ? [] : await getList(props.apiClient.listSharedProjects);
|
|
186
195
|
const out = writer(props);
|
|
187
196
|
out.write(ownedProjects, {
|
|
188
|
-
fields: props.recoverableOnly ?
|
|
189
|
-
...PROJECT_FIELDS,
|
|
190
|
-
"deleted_at",
|
|
191
|
-
"recoverable_until"
|
|
192
|
-
] : PROJECT_FIELDS,
|
|
197
|
+
fields: props.recoverableOnly ? RECOVERABLE_PROJECT_FIELDS : PROJECT_FIELDS,
|
|
193
198
|
title: "Projects",
|
|
194
199
|
emptyMessage: props.recoverableOnly ? "You don't have any recoverable projects." : "You don't have any projects yet. See how to create a new project:\n> neon projects create --help"
|
|
195
200
|
});
|
|
@@ -351,4 +356,4 @@ const onPromptState = (state) => {
|
|
|
351
356
|
}
|
|
352
357
|
};
|
|
353
358
|
//#endregion
|
|
354
|
-
export { PROJECT_FIELDS, REGIONS, aliases, builder, command, describe, handler, projects_exports as t };
|
|
359
|
+
export { PROJECT_FIELDS, RECOVERABLE_PROJECT_FIELDS, REGIONS, aliases, builder, command, describe, handler, projects_exports as t };
|
package/dist/human_table.js
CHANGED
|
@@ -32,6 +32,12 @@ function displayWidth(s) {
|
|
|
32
32
|
}
|
|
33
33
|
return width;
|
|
34
34
|
}
|
|
35
|
+
function presentFields(data, fields) {
|
|
36
|
+
return fields.filter((field) => data.some((item) => {
|
|
37
|
+
const value = fieldValue(item, field);
|
|
38
|
+
return value !== void 0 && value !== "";
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
35
41
|
function formatHumanChunk(chunk) {
|
|
36
42
|
const arrayData = Array.isArray(chunk.data) ? chunk.data : [chunk.data];
|
|
37
43
|
const isList = Array.isArray(chunk.data);
|
|
@@ -42,48 +48,28 @@ function formatHumanChunk(chunk) {
|
|
|
42
48
|
out += formatTitle(chunk.title, chunk.colorTitle) + "\n";
|
|
43
49
|
}
|
|
44
50
|
if (!arrayData.length) return out;
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
if (isList) {
|
|
52
|
+
const fields = presentFields(arrayData, chunk.fields);
|
|
53
|
+
if (fields.length) {
|
|
54
|
+
const headers = fields.map(titleCaseField);
|
|
55
|
+
const rows = arrayData.map((item) => fields.map((field) => cellText(item, field, chunk.renderColumns)));
|
|
56
|
+
out += formatColumns(headers, rows, naturalWidths(headers, rows)) + "\n";
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
const fields = presentFields(arrayData, chunk.fields);
|
|
49
61
|
if (!fields.length) return out;
|
|
50
|
-
const
|
|
51
|
-
const rows = arrayData.map((item) => fields.map((field) => cellText(item, field, chunk.renderColumns)));
|
|
52
|
-
const body = isList ? formatList(headers, rows, chunk.width) : formatStacked(headers, rows, chunk.width);
|
|
62
|
+
const body = formatStacked(fields.map(titleCaseField), arrayData.map((item) => fields.map((field) => cellText(item, field, chunk.renderColumns))), chunk.width);
|
|
53
63
|
if (body) out += body + "\n";
|
|
54
64
|
return out;
|
|
55
65
|
}
|
|
56
66
|
function formatTitle(title, colorTitle) {
|
|
57
67
|
return colorTitle ? chalk.bold(title) : title;
|
|
58
68
|
}
|
|
59
|
-
function formatList(headers, rows, width) {
|
|
60
|
-
if (headers.length === 1) return formatOneColumn(headers[0] ?? "", rows.map((row) => row[0] ?? ""));
|
|
61
|
-
if (width === void 0) return formatColumns(headers, rows, naturalWidths(headers, rows));
|
|
62
|
-
for (let n = headers.length; n >= 2; n--) {
|
|
63
|
-
const subsetHeaders = headers.slice(0, n);
|
|
64
|
-
const subsetRows = rows.map((row) => row.slice(0, n));
|
|
65
|
-
const natural = naturalWidths(subsetHeaders, subsetRows);
|
|
66
|
-
if (rowWidth(natural) <= width) return formatColumns(subsetHeaders, subsetRows, natural);
|
|
67
|
-
const fitted = tryFit(subsetHeaders, subsetRows, width);
|
|
68
|
-
if (fitted === void 0) continue;
|
|
69
|
-
if (!natural.slice(0, n - 1).every((col, i) => fitted[i] === col)) continue;
|
|
70
|
-
return formatColumns(subsetHeaders.map((cell, i) => truncateTo(cell, fitted[i] ?? 0)), subsetRows.map((row) => row.map((cell, i) => truncateTo(cell, fitted[i] ?? 0))), fitted);
|
|
71
|
-
}
|
|
72
|
-
return formatStacked(headers, rows, width);
|
|
73
|
-
}
|
|
74
|
-
function rowWidth(widths) {
|
|
75
|
-
if (widths.length === 0) return 0;
|
|
76
|
-
return widths.reduce((sum, col) => sum + col, 0) + (widths.length - 1) * GUTTER;
|
|
77
|
-
}
|
|
78
|
-
function formatOneColumn(header, values) {
|
|
79
|
-
const lines = [chalk.green(header)];
|
|
80
|
-
for (const value of values) lines.push(value);
|
|
81
|
-
return lines.join("\n");
|
|
82
|
-
}
|
|
83
69
|
function formatColumns(headers, rows, widths) {
|
|
84
70
|
const joinRow = (cells) => cells.map((cell, i) => {
|
|
85
71
|
const width = widths[i] ?? 0;
|
|
86
|
-
return i === cells.length - 1 ?
|
|
72
|
+
return i === cells.length - 1 ? cell : padEndWidth(cell, width);
|
|
87
73
|
}).join(" ".repeat(GUTTER)).trimEnd();
|
|
88
74
|
const lines = [chalk.green(joinRow(headers))];
|
|
89
75
|
for (const row of rows) lines.push(joinRow(row));
|
|
@@ -101,25 +87,6 @@ function formatStacked(headers, rows, width) {
|
|
|
101
87
|
function stackedLine(header, value, labelWidth) {
|
|
102
88
|
return `${padEndWidth(header, labelWidth)}${" ".repeat(GUTTER)}${value}`;
|
|
103
89
|
}
|
|
104
|
-
function tryFit(headers, rows, width) {
|
|
105
|
-
const n = headers.length;
|
|
106
|
-
if (n === 0) return [];
|
|
107
|
-
const gutters = (n - 1) * GUTTER;
|
|
108
|
-
if (width <= gutters) return;
|
|
109
|
-
const budget = width - gutters;
|
|
110
|
-
if (budget < n * MIN_COL) return;
|
|
111
|
-
const widths = naturalWidths(headers, rows);
|
|
112
|
-
let overflow = widths.reduce((sum, col) => sum + col, 0) - budget;
|
|
113
|
-
if (overflow <= 0) return widths;
|
|
114
|
-
for (let i = n - 1; i >= 0 && overflow > 0; i--) {
|
|
115
|
-
const current = widths[i] ?? 0;
|
|
116
|
-
const take = Math.min(Math.max(current - MIN_COL, 0), overflow);
|
|
117
|
-
widths[i] = current - take;
|
|
118
|
-
overflow -= take;
|
|
119
|
-
}
|
|
120
|
-
if (overflow > 0) return;
|
|
121
|
-
return widths;
|
|
122
|
-
}
|
|
123
90
|
function naturalWidths(headers, rows) {
|
|
124
91
|
return headers.map((header, i) => Math.max(displayWidth(header), ...rows.map((row) => displayWidth(row[i] ?? ""))));
|
|
125
92
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neon",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"description": "CLI tool for Neon, the cloud backend primitives built around Lakebase Postgres",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"neon",
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
"yaml": "^2.9.0",
|
|
64
64
|
"yargs": "17.7.2",
|
|
65
65
|
"yoctocolors": "^2.1.2",
|
|
66
|
+
"@neon/sdk": "2.2.0",
|
|
66
67
|
"@neon/config": "1.0.2",
|
|
67
|
-
"@neon/config-runtime": "1.0.2"
|
|
68
|
-
"@neon/sdk": "2.2.0"
|
|
68
|
+
"@neon/config-runtime": "1.0.2"
|
|
69
69
|
},
|
|
70
70
|
"optionalDependencies": {
|
|
71
71
|
"@napi-rs/keyring": "1.3.0",
|