neonctl 2.28.0 → 2.29.0
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 +2 -2
- package/dist/analytics.js +35 -33
- package/dist/api.js +34 -34
- package/dist/auth.js +50 -44
- package/dist/cli.js +2 -2
- package/dist/commands/auth.js +58 -52
- package/dist/commands/bootstrap.js +115 -157
- package/dist/commands/branches.js +154 -147
- package/dist/commands/bucket.js +124 -118
- package/dist/commands/checkout.js +49 -49
- package/dist/commands/config.js +212 -88
- package/dist/commands/connection_string.js +62 -62
- package/dist/commands/data_api.js +96 -96
- package/dist/commands/databases.js +23 -23
- package/dist/commands/deploy.js +12 -12
- package/dist/commands/dev.js +114 -114
- package/dist/commands/env.js +43 -43
- package/dist/commands/functions.js +97 -98
- package/dist/commands/index.js +26 -26
- package/dist/commands/init.js +23 -22
- package/dist/commands/ip_allow.js +29 -29
- package/dist/commands/link.js +223 -166
- package/dist/commands/neon_auth.js +381 -363
- package/dist/commands/operations.js +11 -11
- package/dist/commands/orgs.js +8 -8
- package/dist/commands/projects.js +101 -99
- package/dist/commands/psql.js +31 -31
- package/dist/commands/roles.js +21 -21
- package/dist/commands/schema_diff.js +23 -23
- package/dist/commands/set_context.js +17 -17
- package/dist/commands/status.js +17 -17
- package/dist/commands/user.js +5 -5
- package/dist/commands/vpc_endpoints.js +50 -50
- package/dist/config.js +7 -7
- package/dist/config_format.js +5 -5
- package/dist/context.js +23 -16
- package/dist/current_branch_fast_path.js +6 -6
- package/dist/dev/env.js +33 -33
- package/dist/dev/functions.js +4 -4
- package/dist/dev/inputs.js +6 -6
- package/dist/dev/runtime.js +25 -25
- package/dist/env.js +14 -14
- package/dist/env_file.js +13 -13
- package/dist/errors.js +19 -19
- package/dist/functions_api.js +10 -10
- package/dist/help.js +15 -15
- package/dist/index.js +94 -92
- package/dist/log.js +2 -2
- package/dist/pkg.js +5 -5
- package/dist/psql/cli.js +4 -2
- package/dist/psql/command/cmd_cond.js +61 -61
- package/dist/psql/command/cmd_connect.js +159 -154
- package/dist/psql/command/cmd_copy.js +107 -97
- package/dist/psql/command/cmd_describe.js +368 -363
- package/dist/psql/command/cmd_format.js +276 -263
- package/dist/psql/command/cmd_io.js +269 -263
- package/dist/psql/command/cmd_lo.js +74 -66
- package/dist/psql/command/cmd_meta.js +148 -148
- package/dist/psql/command/cmd_misc.js +17 -17
- package/dist/psql/command/cmd_pipeline.js +142 -135
- package/dist/psql/command/cmd_restrict.js +25 -25
- package/dist/psql/command/cmd_show.js +183 -168
- package/dist/psql/command/dispatch.js +26 -26
- package/dist/psql/command/shared.js +14 -14
- package/dist/psql/complete/filenames.js +16 -16
- package/dist/psql/complete/index.js +4 -4
- package/dist/psql/complete/matcher.js +33 -32
- package/dist/psql/complete/psqlVars.js +173 -173
- package/dist/psql/complete/queries.js +5 -3
- package/dist/psql/complete/rules.js +900 -863
- package/dist/psql/core/common.js +136 -133
- package/dist/psql/core/help.js +343 -343
- package/dist/psql/core/mainloop.js +160 -153
- package/dist/psql/core/prompt.js +126 -123
- package/dist/psql/core/settings.js +111 -111
- package/dist/psql/core/sqlHelp.js +150 -150
- package/dist/psql/core/startup.js +211 -205
- package/dist/psql/core/syncVars.js +14 -14
- package/dist/psql/core/variables.js +24 -24
- package/dist/psql/describe/formatters.js +302 -289
- package/dist/psql/describe/processNamePattern.js +28 -28
- package/dist/psql/describe/queries.js +656 -651
- package/dist/psql/index.js +436 -411
- package/dist/psql/io/history.js +36 -36
- package/dist/psql/io/input.js +15 -15
- package/dist/psql/io/lineEditor/buffer.js +27 -25
- package/dist/psql/io/lineEditor/complete.js +15 -15
- package/dist/psql/io/lineEditor/filename.js +22 -22
- package/dist/psql/io/lineEditor/index.js +65 -62
- package/dist/psql/io/lineEditor/keymap.js +325 -318
- package/dist/psql/io/lineEditor/vt100.js +60 -60
- package/dist/psql/io/pgpass.js +18 -18
- package/dist/psql/io/pgservice.js +14 -14
- package/dist/psql/io/psqlrc.js +46 -46
- package/dist/psql/print/aligned.js +175 -166
- package/dist/psql/print/asciidoc.js +51 -51
- package/dist/psql/print/crosstab.js +34 -31
- package/dist/psql/print/csv.js +25 -22
- package/dist/psql/print/html.js +54 -54
- package/dist/psql/print/json.js +12 -12
- package/dist/psql/print/latex.js +118 -118
- package/dist/psql/print/pager.js +28 -26
- package/dist/psql/print/troff.js +48 -48
- package/dist/psql/print/unaligned.js +15 -14
- package/dist/psql/print/units.js +17 -17
- package/dist/psql/scanner/slash.js +48 -46
- package/dist/psql/scanner/sql.js +88 -84
- package/dist/psql/scanner/stringutils.js +21 -17
- package/dist/psql/types/index.js +7 -7
- package/dist/psql/types/scanner.js +8 -8
- package/dist/psql/wire/connection.js +341 -327
- package/dist/psql/wire/copy.js +7 -7
- package/dist/psql/wire/pipeline.js +26 -24
- package/dist/psql/wire/protocol.js +102 -102
- package/dist/psql/wire/sasl.js +62 -62
- package/dist/psql/wire/tls.js +79 -73
- package/dist/storage_api.js +15 -15
- package/dist/test_utils/fixtures.js +34 -31
- package/dist/test_utils/oauth_server.js +5 -5
- package/dist/utils/api_enums.js +13 -13
- package/dist/utils/branch_notice.js +5 -5
- package/dist/utils/branch_picker.js +26 -26
- package/dist/utils/compute_units.js +4 -4
- package/dist/utils/enrichers.js +20 -15
- package/dist/utils/esbuild.js +28 -28
- package/dist/utils/formats.js +1 -1
- package/dist/utils/middlewares.js +3 -3
- package/dist/utils/package_manager.js +68 -0
- package/dist/utils/point_in_time.js +12 -12
- package/dist/utils/psql.js +30 -30
- package/dist/utils/string.js +2 -2
- package/dist/utils/ui.js +9 -9
- package/dist/utils/zip.js +1 -1
- package/dist/writer.js +17 -17
- package/package.json +6 -7
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { fillSingleProject } from
|
|
2
|
-
import { writer } from
|
|
3
|
-
const OPERATIONS_FIELDS = [
|
|
4
|
-
export const command =
|
|
5
|
-
export const describe =
|
|
6
|
-
export const aliases = [
|
|
1
|
+
import { fillSingleProject } from "../utils/enrichers.js";
|
|
2
|
+
import { writer } from "../writer.js";
|
|
3
|
+
const OPERATIONS_FIELDS = ["id", "action", "status", "created_at"];
|
|
4
|
+
export const command = "operations";
|
|
5
|
+
export const describe = "Manage operations";
|
|
6
|
+
export const aliases = ["operation"];
|
|
7
7
|
export const builder = (argv) => argv
|
|
8
|
-
.usage(
|
|
8
|
+
.usage("$0 operations <sub-command> [options]")
|
|
9
9
|
.options({
|
|
10
|
-
|
|
11
|
-
describe:
|
|
12
|
-
type:
|
|
10
|
+
"project-id": {
|
|
11
|
+
describe: "Project ID",
|
|
12
|
+
type: "string",
|
|
13
13
|
},
|
|
14
14
|
})
|
|
15
15
|
.middleware(fillSingleProject)
|
|
16
|
-
.command(
|
|
16
|
+
.command("list", "List operations", (yargs) => yargs, (args) => list(args));
|
|
17
17
|
export const handler = (args) => {
|
|
18
18
|
return args;
|
|
19
19
|
};
|
package/dist/commands/orgs.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { writer } from
|
|
2
|
-
const ORG_FIELDS = [
|
|
3
|
-
export const command =
|
|
4
|
-
export const describe =
|
|
5
|
-
export const aliases = [
|
|
1
|
+
import { writer } from "../writer.js";
|
|
2
|
+
const ORG_FIELDS = ["id", "name"];
|
|
3
|
+
export const command = "orgs";
|
|
4
|
+
export const describe = "Manage organizations";
|
|
5
|
+
export const aliases = ["org"];
|
|
6
6
|
export const builder = (argv) => {
|
|
7
|
-
return argv.usage(
|
|
7
|
+
return argv.usage("$0 orgs <sub-command> [options]").command("list", "List organizations", (yargs) => yargs, async (args) => {
|
|
8
8
|
// @ts-expect-error: TODO - Assert `args` is `CommonProps`
|
|
9
9
|
await list(args);
|
|
10
10
|
});
|
|
@@ -17,8 +17,8 @@ const list = async (props) => {
|
|
|
17
17
|
const { data: { organizations }, } = await props.apiClient.getCurrentUserOrganizations();
|
|
18
18
|
out.write(organizations, {
|
|
19
19
|
fields: ORG_FIELDS,
|
|
20
|
-
title:
|
|
21
|
-
emptyMessage:
|
|
20
|
+
title: "Organizations",
|
|
21
|
+
emptyMessage: "You are not a member of any organization.",
|
|
22
22
|
});
|
|
23
23
|
out.end();
|
|
24
24
|
};
|
|
@@ -1,143 +1,143 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
1
|
+
import prompts from "prompts";
|
|
2
|
+
import { isNeonApiError, messageFromBody } from "../api.js";
|
|
3
|
+
import { updateContextFile } from "../context.js";
|
|
4
|
+
import { isCi } from "../env.js";
|
|
5
|
+
import { log } from "../log.js";
|
|
6
|
+
import { projectCreateRequest, projectUpdateRequest, } from "../parameters.gen.js";
|
|
7
|
+
import { getComputeUnits } from "../utils/compute_units.js";
|
|
8
|
+
import { psql } from "../utils/psql.js";
|
|
9
|
+
import { writer } from "../writer.js";
|
|
10
10
|
export const PROJECT_FIELDS = [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
"id",
|
|
12
|
+
"name",
|
|
13
|
+
"region_id",
|
|
14
|
+
"created_at",
|
|
15
15
|
];
|
|
16
16
|
export const REGIONS = [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
"aws-us-west-2",
|
|
18
|
+
"aws-ap-southeast-1",
|
|
19
|
+
"aws-ap-southeast-2",
|
|
20
|
+
"aws-eu-central-1",
|
|
21
|
+
"aws-us-east-2",
|
|
22
|
+
"aws-us-east-1",
|
|
23
|
+
"azure-eastus2",
|
|
24
24
|
];
|
|
25
25
|
const PROJECTS_LIST_LIMIT = 100;
|
|
26
|
-
export const command =
|
|
27
|
-
export const describe =
|
|
28
|
-
export const aliases = [
|
|
26
|
+
export const command = "projects";
|
|
27
|
+
export const describe = "Manage projects";
|
|
28
|
+
export const aliases = ["project"];
|
|
29
29
|
export const builder = (argv) => {
|
|
30
30
|
return argv
|
|
31
|
-
.usage(
|
|
31
|
+
.usage("$0 projects <sub-command> [options]")
|
|
32
32
|
.middleware((args) => {
|
|
33
33
|
// Provide alias for analytics
|
|
34
34
|
args.projectId = args.id;
|
|
35
35
|
})
|
|
36
|
-
.command(
|
|
37
|
-
|
|
38
|
-
describe:
|
|
39
|
-
type:
|
|
36
|
+
.command("list", "List projects", (yargs) => yargs.options({
|
|
37
|
+
"org-id": {
|
|
38
|
+
describe: "List projects of a given organization",
|
|
39
|
+
type: "string",
|
|
40
40
|
},
|
|
41
|
-
|
|
42
|
-
describe:
|
|
43
|
-
type:
|
|
41
|
+
"recoverable-only": {
|
|
42
|
+
describe: "List only deleted projects within their deletion grace period",
|
|
43
|
+
type: "boolean",
|
|
44
44
|
},
|
|
45
45
|
}), async (args) => {
|
|
46
46
|
await handleMissingOrgId(args, list);
|
|
47
47
|
})
|
|
48
|
-
.command(
|
|
49
|
-
|
|
50
|
-
describe: projectCreateRequest[
|
|
51
|
-
|
|
52
|
-
type: 'boolean',
|
|
48
|
+
.command("create", "Create a project", (yargs) => yargs.options({
|
|
49
|
+
"block-public-connections": {
|
|
50
|
+
describe: projectCreateRequest["project.settings.block_public_connections"].description,
|
|
51
|
+
type: "boolean",
|
|
53
52
|
},
|
|
54
|
-
|
|
55
|
-
describe: projectCreateRequest[
|
|
56
|
-
|
|
57
|
-
type: 'boolean',
|
|
53
|
+
"block-vpc-connections": {
|
|
54
|
+
describe: projectCreateRequest["project.settings.block_vpc_connections"].description,
|
|
55
|
+
type: "boolean",
|
|
58
56
|
},
|
|
59
57
|
hipaa: {
|
|
60
|
-
describe: projectCreateRequest[
|
|
61
|
-
|
|
58
|
+
describe: projectCreateRequest["project.settings.hipaa"]
|
|
59
|
+
.description,
|
|
60
|
+
type: "boolean",
|
|
62
61
|
},
|
|
63
62
|
name: {
|
|
64
|
-
describe: projectCreateRequest[
|
|
65
|
-
type:
|
|
63
|
+
describe: projectCreateRequest["project.name"].description,
|
|
64
|
+
type: "string",
|
|
66
65
|
},
|
|
67
|
-
|
|
68
|
-
describe: `The region ID. Possible values: ${REGIONS.join(
|
|
69
|
-
type:
|
|
66
|
+
"region-id": {
|
|
67
|
+
describe: `The region ID. Possible values: ${REGIONS.join(", ")}`,
|
|
68
|
+
type: "string",
|
|
70
69
|
},
|
|
71
|
-
|
|
70
|
+
"org-id": {
|
|
72
71
|
describe: "The project's organization ID",
|
|
73
|
-
type:
|
|
72
|
+
type: "string",
|
|
74
73
|
},
|
|
75
74
|
psql: {
|
|
76
|
-
type:
|
|
77
|
-
describe:
|
|
75
|
+
type: "boolean",
|
|
76
|
+
describe: "Connect to a new project via psql",
|
|
78
77
|
default: false,
|
|
79
78
|
},
|
|
80
79
|
fallback: {
|
|
81
|
-
type:
|
|
82
|
-
describe:
|
|
80
|
+
type: "boolean",
|
|
81
|
+
describe: "Force the embedded TypeScript psql fallback (for testing)",
|
|
83
82
|
default: false,
|
|
84
83
|
hidden: true,
|
|
85
84
|
},
|
|
86
85
|
database: {
|
|
87
|
-
describe: projectCreateRequest[
|
|
88
|
-
|
|
86
|
+
describe: projectCreateRequest["project.branch.database_name"]
|
|
87
|
+
.description,
|
|
88
|
+
type: "string",
|
|
89
89
|
},
|
|
90
90
|
role: {
|
|
91
|
-
describe: projectCreateRequest[
|
|
92
|
-
|
|
91
|
+
describe: projectCreateRequest["project.branch.role_name"]
|
|
92
|
+
.description,
|
|
93
|
+
type: "string",
|
|
93
94
|
},
|
|
94
|
-
|
|
95
|
-
type:
|
|
96
|
-
describe:
|
|
95
|
+
"set-context": {
|
|
96
|
+
type: "boolean",
|
|
97
|
+
describe: "Set the current context to the new project",
|
|
97
98
|
default: false,
|
|
98
99
|
},
|
|
99
100
|
cu: {
|
|
100
101
|
describe: 'The number of Compute Units. Could be a fixed size (e.g. "2") or a range delimited by a dash (e.g. "0.5-3").',
|
|
101
|
-
type:
|
|
102
|
+
type: "string",
|
|
102
103
|
},
|
|
103
104
|
}), async (args) => {
|
|
104
105
|
await handleMissingOrgId(args, create);
|
|
105
106
|
})
|
|
106
|
-
.command(
|
|
107
|
-
|
|
108
|
-
describe: projectUpdateRequest[
|
|
109
|
-
.
|
|
110
|
-
|
|
111
|
-
type: 'boolean',
|
|
107
|
+
.command("update <id>", "Update a project", (yargs) => yargs.options({
|
|
108
|
+
"block-vpc-connections": {
|
|
109
|
+
describe: projectUpdateRequest["project.settings.block_vpc_connections"].description +
|
|
110
|
+
" Use --block-vpc-connections=false to set the value to false.",
|
|
111
|
+
type: "boolean",
|
|
112
112
|
},
|
|
113
|
-
|
|
114
|
-
describe: projectUpdateRequest[
|
|
115
|
-
.
|
|
116
|
-
|
|
117
|
-
type: 'boolean',
|
|
113
|
+
"block-public-connections": {
|
|
114
|
+
describe: projectUpdateRequest["project.settings.block_public_connections"].description +
|
|
115
|
+
" Use --block-public-connections=false to set the value to false.",
|
|
116
|
+
type: "boolean",
|
|
118
117
|
},
|
|
119
118
|
hipaa: {
|
|
120
|
-
describe: projectUpdateRequest[
|
|
121
|
-
|
|
119
|
+
describe: projectUpdateRequest["project.settings.hipaa"]
|
|
120
|
+
.description,
|
|
121
|
+
type: "boolean",
|
|
122
122
|
},
|
|
123
123
|
cu: {
|
|
124
124
|
describe: 'The number of Compute Units. Could be a fixed size (e.g. "2") or a range delimited by a dash (e.g. "0.5-3").',
|
|
125
|
-
type:
|
|
125
|
+
type: "string",
|
|
126
126
|
},
|
|
127
127
|
name: {
|
|
128
|
-
describe: projectUpdateRequest[
|
|
129
|
-
type:
|
|
128
|
+
describe: projectUpdateRequest["project.name"].description,
|
|
129
|
+
type: "string",
|
|
130
130
|
},
|
|
131
131
|
}), async (args) => {
|
|
132
132
|
await update(args);
|
|
133
133
|
})
|
|
134
|
-
.command(
|
|
134
|
+
.command("delete <id>", "Delete a project", (yargs) => yargs, async (args) => {
|
|
135
135
|
await deleteProject(args);
|
|
136
136
|
})
|
|
137
|
-
.command(
|
|
137
|
+
.command("recover <id>", "Recovers a deleted project during the deletion grace period", (yargs) => yargs, async (args) => {
|
|
138
138
|
await recover(args);
|
|
139
139
|
})
|
|
140
|
-
.command(
|
|
140
|
+
.command("get <id>", "Get a project", (yargs) => yargs, async (args) => {
|
|
141
141
|
await get(args);
|
|
142
142
|
});
|
|
143
143
|
};
|
|
@@ -158,7 +158,7 @@ const list = async (props) => {
|
|
|
158
158
|
});
|
|
159
159
|
result.push(...data.projects);
|
|
160
160
|
cursor = data.pagination?.cursor;
|
|
161
|
-
log.debug(
|
|
161
|
+
log.debug("Got %d projects, with cursor: %s", data.projects.length, cursor);
|
|
162
162
|
if (data.projects.length < PROJECTS_LIST_LIMIT) {
|
|
163
163
|
end = true;
|
|
164
164
|
}
|
|
@@ -172,9 +172,9 @@ const list = async (props) => {
|
|
|
172
172
|
const out = writer(props);
|
|
173
173
|
out.write(ownedProjects, {
|
|
174
174
|
fields: props.recoverableOnly
|
|
175
|
-
? [...PROJECT_FIELDS,
|
|
175
|
+
? [...PROJECT_FIELDS, "deleted_at", "recoverable_until"]
|
|
176
176
|
: PROJECT_FIELDS,
|
|
177
|
-
title:
|
|
177
|
+
title: "Projects",
|
|
178
178
|
emptyMessage: props.recoverableOnly
|
|
179
179
|
? "You don't have any recoverable projects."
|
|
180
180
|
: "You don't have any projects yet. See how to create a new project:\n> neon projects create --help",
|
|
@@ -183,8 +183,8 @@ const list = async (props) => {
|
|
|
183
183
|
// We don't list shared projects when listing recoverable projects
|
|
184
184
|
out.write(sharedProjects, {
|
|
185
185
|
fields: PROJECT_FIELDS,
|
|
186
|
-
title:
|
|
187
|
-
emptyMessage:
|
|
186
|
+
title: "Shared with you",
|
|
187
|
+
emptyMessage: "No projects have been shared with you",
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
190
|
out.end();
|
|
@@ -201,7 +201,8 @@ const create = async (props) => {
|
|
|
201
201
|
if (!project.settings) {
|
|
202
202
|
project.settings = {};
|
|
203
203
|
}
|
|
204
|
-
project.settings.block_public_connections =
|
|
204
|
+
project.settings.block_public_connections =
|
|
205
|
+
props.blockPublicConnections;
|
|
205
206
|
}
|
|
206
207
|
if (props.blockVpcConnections !== undefined) {
|
|
207
208
|
if (!project.settings) {
|
|
@@ -239,17 +240,17 @@ const create = async (props) => {
|
|
|
239
240
|
});
|
|
240
241
|
}
|
|
241
242
|
const out = writer(props);
|
|
242
|
-
out.write(data.project, { fields: PROJECT_FIELDS, title:
|
|
243
|
+
out.write(data.project, { fields: PROJECT_FIELDS, title: "Project" });
|
|
243
244
|
out.write(data.connection_uris, {
|
|
244
|
-
fields: [
|
|
245
|
-
title:
|
|
245
|
+
fields: ["connection_uri"],
|
|
246
|
+
title: "Connection URIs",
|
|
246
247
|
});
|
|
247
248
|
out.end();
|
|
248
249
|
if (props.psql) {
|
|
249
250
|
const connection_uri = data.connection_uris[0].connection_uri;
|
|
250
|
-
const psqlArgs = props[
|
|
251
|
+
const psqlArgs = props["--"];
|
|
251
252
|
await psql(connection_uri, psqlArgs, {
|
|
252
|
-
mode: props.fallback ?
|
|
253
|
+
mode: props.fallback ? "ts" : "auto",
|
|
253
254
|
});
|
|
254
255
|
}
|
|
255
256
|
};
|
|
@@ -271,7 +272,8 @@ const update = async (props) => {
|
|
|
271
272
|
if (!project.settings) {
|
|
272
273
|
project.settings = {};
|
|
273
274
|
}
|
|
274
|
-
project.settings.block_public_connections =
|
|
275
|
+
project.settings.block_public_connections =
|
|
276
|
+
props.blockPublicConnections;
|
|
275
277
|
}
|
|
276
278
|
if (props.blockVpcConnections !== undefined) {
|
|
277
279
|
if (!project.settings) {
|
|
@@ -317,7 +319,7 @@ const handleMissingOrgId = async (args, cmd) => {
|
|
|
317
319
|
const isOrgIdError = (err) => {
|
|
318
320
|
return (isNeonApiError(err) &&
|
|
319
321
|
err.status === 400 &&
|
|
320
|
-
messageFromBody(err.data)?.includes(
|
|
322
|
+
messageFromBody(err.data)?.includes("org_id is required"));
|
|
321
323
|
};
|
|
322
324
|
const selectOrg = async (props) => {
|
|
323
325
|
const { data: { organizations }, } = await props.apiClient.getCurrentUserOrganizations();
|
|
@@ -326,8 +328,8 @@ const selectOrg = async (props) => {
|
|
|
326
328
|
}
|
|
327
329
|
const { orgId } = await prompts({
|
|
328
330
|
onState: onPromptState,
|
|
329
|
-
type:
|
|
330
|
-
name:
|
|
331
|
+
type: "select",
|
|
332
|
+
name: "orgId",
|
|
331
333
|
message: `What organization would you like to use?`,
|
|
332
334
|
choices: organizations.map((org) => ({
|
|
333
335
|
title: `${org.name} (${org.id})`,
|
|
@@ -337,8 +339,8 @@ const selectOrg = async (props) => {
|
|
|
337
339
|
});
|
|
338
340
|
const { save } = await prompts({
|
|
339
341
|
onState: onPromptState,
|
|
340
|
-
type:
|
|
341
|
-
name:
|
|
342
|
+
type: "confirm",
|
|
343
|
+
name: "save",
|
|
342
344
|
message: `Would you like to use this organization by default?`,
|
|
343
345
|
initial: true,
|
|
344
346
|
});
|
|
@@ -363,8 +365,8 @@ const onPromptState = (state) => {
|
|
|
363
365
|
if (state.aborted) {
|
|
364
366
|
// If we don't re-enable the terminal cursor before exiting
|
|
365
367
|
// the program, the cursor will remain hidden
|
|
366
|
-
process.stdout.write(
|
|
367
|
-
process.stdout.write(
|
|
368
|
+
process.stdout.write("\x1B[?25h");
|
|
369
|
+
process.stdout.write("\n");
|
|
368
370
|
process.exit(1);
|
|
369
371
|
}
|
|
370
372
|
};
|
package/dist/commands/psql.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { EndpointType } from
|
|
2
|
-
import { fillSingleProject } from
|
|
3
|
-
import { handler as connectionStringHandler, SSL_MODES, } from
|
|
4
|
-
export const command =
|
|
5
|
-
export const describe =
|
|
1
|
+
import { EndpointType } from "../utils/api_enums.js";
|
|
2
|
+
import { fillSingleProject } from "../utils/enrichers.js";
|
|
3
|
+
import { handler as connectionStringHandler, SSL_MODES, } from "./connection_string.js";
|
|
4
|
+
export const command = "psql [branch]";
|
|
5
|
+
export const describe = "Connect to a database via psql";
|
|
6
6
|
export const builder = (argv) => {
|
|
7
7
|
return argv
|
|
8
|
-
.usage(
|
|
9
|
-
.example(
|
|
10
|
-
.example(
|
|
11
|
-
.example('$0 psql main -- -c "SELECT 1"',
|
|
12
|
-
.example(
|
|
13
|
-
.positional(
|
|
8
|
+
.usage("$0 psql [branch] [options] [-- psql-args]")
|
|
9
|
+
.example("$0 psql", "Connect to the default branch via psql")
|
|
10
|
+
.example("$0 psql main", "Connect to the main branch via psql")
|
|
11
|
+
.example('$0 psql main -- -c "SELECT 1"', "Run a single query against the main branch")
|
|
12
|
+
.example("$0 psql main@2024-01-01T00:00:00Z", "Connect to the main branch at a specific point in time")
|
|
13
|
+
.positional("branch", {
|
|
14
14
|
describe: `Branch name or id. Defaults to the default branch if omitted. Can be written in the point-in-time format: "branch@timestamp" or "branch@lsn"`,
|
|
15
|
-
type:
|
|
15
|
+
type: "string",
|
|
16
16
|
})
|
|
17
17
|
.options({
|
|
18
|
-
|
|
19
|
-
type:
|
|
20
|
-
describe:
|
|
18
|
+
"project-id": {
|
|
19
|
+
type: "string",
|
|
20
|
+
describe: "Project ID",
|
|
21
21
|
},
|
|
22
|
-
|
|
23
|
-
type:
|
|
24
|
-
describe:
|
|
22
|
+
"role-name": {
|
|
23
|
+
type: "string",
|
|
24
|
+
describe: "Role name",
|
|
25
25
|
},
|
|
26
|
-
|
|
27
|
-
type:
|
|
28
|
-
describe:
|
|
26
|
+
"database-name": {
|
|
27
|
+
type: "string",
|
|
28
|
+
describe: "Database name",
|
|
29
29
|
},
|
|
30
30
|
pooled: {
|
|
31
|
-
type:
|
|
32
|
-
describe:
|
|
31
|
+
type: "boolean",
|
|
32
|
+
describe: "Use pooled connection",
|
|
33
33
|
default: false,
|
|
34
34
|
},
|
|
35
|
-
|
|
36
|
-
type:
|
|
35
|
+
"endpoint-type": {
|
|
36
|
+
type: "string",
|
|
37
37
|
choices: Object.values(EndpointType),
|
|
38
|
-
describe:
|
|
38
|
+
describe: "Endpoint type",
|
|
39
39
|
},
|
|
40
40
|
ssl: {
|
|
41
|
-
type:
|
|
41
|
+
type: "string",
|
|
42
42
|
choices: SSL_MODES,
|
|
43
|
-
default:
|
|
44
|
-
describe:
|
|
43
|
+
default: "require",
|
|
44
|
+
describe: "SSL mode",
|
|
45
45
|
},
|
|
46
46
|
fallback: {
|
|
47
|
-
type:
|
|
48
|
-
describe:
|
|
47
|
+
type: "boolean",
|
|
48
|
+
describe: "Force the embedded TypeScript psql fallback (for testing)",
|
|
49
49
|
default: false,
|
|
50
50
|
hidden: true,
|
|
51
51
|
},
|
package/dist/commands/roles.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { retryOnLock } from
|
|
2
|
-
import { branchIdFromProps, fillSingleProject } from
|
|
3
|
-
import { writer } from
|
|
4
|
-
const ROLES_FIELDS = [
|
|
5
|
-
export const command =
|
|
6
|
-
export const describe =
|
|
7
|
-
export const aliases = [
|
|
1
|
+
import { retryOnLock } from "../api.js";
|
|
2
|
+
import { branchIdFromProps, fillSingleProject } from "../utils/enrichers.js";
|
|
3
|
+
import { writer } from "../writer.js";
|
|
4
|
+
const ROLES_FIELDS = ["name", "created_at"];
|
|
5
|
+
export const command = "roles";
|
|
6
|
+
export const describe = "Manage roles";
|
|
7
|
+
export const aliases = ["role"];
|
|
8
8
|
export const builder = (argv) => argv
|
|
9
|
-
.usage(
|
|
9
|
+
.usage("$0 roles <sub-command> [options]")
|
|
10
10
|
.options({
|
|
11
|
-
|
|
12
|
-
describe:
|
|
13
|
-
type:
|
|
11
|
+
"project-id": {
|
|
12
|
+
describe: "Project ID",
|
|
13
|
+
type: "string",
|
|
14
14
|
},
|
|
15
15
|
branch: {
|
|
16
|
-
describe:
|
|
17
|
-
type:
|
|
16
|
+
describe: "Branch ID or name",
|
|
17
|
+
type: "string",
|
|
18
18
|
},
|
|
19
19
|
})
|
|
20
20
|
.middleware(fillSingleProject)
|
|
21
|
-
.command(
|
|
22
|
-
.command(
|
|
21
|
+
.command("list", "List roles", (yargs) => yargs, (args) => list(args))
|
|
22
|
+
.command("create", "Create a role", (yargs) => yargs.options({
|
|
23
23
|
name: {
|
|
24
|
-
describe:
|
|
25
|
-
type:
|
|
24
|
+
describe: "Role name",
|
|
25
|
+
type: "string",
|
|
26
26
|
demandOption: true,
|
|
27
27
|
},
|
|
28
|
-
|
|
29
|
-
describe:
|
|
28
|
+
"no-login": {
|
|
29
|
+
describe: "Create a passwordless role that cannot login",
|
|
30
30
|
boolean: true,
|
|
31
31
|
},
|
|
32
32
|
}), (args) => create(args))
|
|
33
|
-
.command(
|
|
33
|
+
.command("delete <role>", "Delete a role", (yargs) => yargs, (args) => deleteRole(args));
|
|
34
34
|
export const handler = (args) => {
|
|
35
35
|
return args;
|
|
36
36
|
};
|
|
@@ -46,7 +46,7 @@ export const create = async (props) => {
|
|
|
46
46
|
const { data } = await retryOnLock(() => props.apiClient.createProjectBranchRole(props.projectId, branchId, {
|
|
47
47
|
role: {
|
|
48
48
|
name: props.name,
|
|
49
|
-
no_login: props[
|
|
49
|
+
no_login: props["no-login"],
|
|
50
50
|
},
|
|
51
51
|
}));
|
|
52
52
|
writer(props).end(data.role, {
|