neonctl 1.17.0 → 1.17.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/README.md +76 -67
- package/config.js +2 -2
- package/package.json +1 -1
- package/writer.js +3 -2
package/README.md
CHANGED
|
@@ -1,37 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
The Neon CLI supports numerous operations, such as authentication and management of Neon projects, branches, compute endpoints, databases, roles, and more.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
The `neonctl` command can be called from command line. Without any arguments, it displays command usage and help:
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
usage: neonctl <cmd> [args]
|
|
9
|
-
|
|
10
|
-
Commands:
|
|
11
|
-
neonctl auth Authenticate
|
|
12
|
-
neonctl projects [command] Manage projects
|
|
13
|
-
neonctl me Show current user
|
|
14
|
-
neonctl branches Manage branches
|
|
15
|
-
|
|
16
|
-
Options:
|
|
17
|
-
--version Show version number [boolean]
|
|
18
|
-
--help Show help [boolean]
|
|
19
|
-
-o, --output Set output format
|
|
20
|
-
[string] [choices: "json", "yaml", "table"] [default: "table"]
|
|
21
|
-
--api-host The API host [default: "https://console.neon.tech/api/v2"]
|
|
22
|
-
--config-dir Path to config directory
|
|
23
|
-
[string] [default: "/home/eduard/.config/neonctl"]
|
|
24
|
-
--oauth-host URL to Neon OAUTH host [default: "https://oauth2.neon.tech"]
|
|
25
|
-
--client-id OAuth client id [string] [default: "neonctl"]
|
|
26
|
-
--api-key API key [string] [default: ""]
|
|
27
|
-
```
|
|
3
|
+
The Neon CLI command name is `neonctl`. The GitHub repository for the Neon CLI is found [here](https://github.com/neondatabase/neonctl).
|
|
28
4
|
|
|
29
5
|
## Install the Neon CLI
|
|
30
6
|
|
|
31
|
-
This
|
|
7
|
+
This section describes how to install the Neon CLI.
|
|
32
8
|
|
|
33
9
|
### Prerequisites
|
|
34
10
|
|
|
11
|
+
Before installing, ensure that you have met the following prerequisites:
|
|
12
|
+
|
|
35
13
|
- Node.js 16.0 or higher. To check if you already have Node.js, run the following command:
|
|
36
14
|
|
|
37
15
|
```shell
|
|
@@ -44,83 +22,114 @@ This topic describes how to install the `neonctl` command-line interface tool an
|
|
|
44
22
|
npm -v
|
|
45
23
|
```
|
|
46
24
|
|
|
47
|
-
If you need to install
|
|
25
|
+
If you need to install `Node.js` or `npm`, refer to instructions on the [official nodejs page](https://nodejs.org) or use the [Node version manager](https://github.com/nvm-sh/nvm).
|
|
48
26
|
|
|
49
27
|
### Install
|
|
50
28
|
|
|
51
|
-
To
|
|
29
|
+
To install the Neon CLI, run the following command:
|
|
52
30
|
|
|
53
31
|
```shell
|
|
54
32
|
npm i -g neonctl
|
|
55
33
|
```
|
|
56
34
|
|
|
57
|
-
###
|
|
35
|
+
### Upgrade
|
|
58
36
|
|
|
59
|
-
To
|
|
37
|
+
To upgrade to the latest version of the Neon CLI, run the `npm i -g neonctl` command again.
|
|
60
38
|
|
|
61
|
-
|
|
39
|
+
## Connect
|
|
40
|
+
|
|
41
|
+
Run the following command to authenticate a connection to Neon:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
62
44
|
neonctl auth
|
|
63
45
|
```
|
|
64
46
|
|
|
65
|
-
The command launches a browser window where you can authorize the Neon CLI to access your Neon account.
|
|
47
|
+
The `auth` command launches a browser window where you can authorize the Neon CLI to access your Neon account. Running a Neon CLI command without authenticating with [neonctl auth](https://neon.tech/docs/reference/cli-auth) automatically launches the browser authentication process.
|
|
66
48
|
|
|
67
|
-
|
|
49
|
+
Alternatively, you can authenticate a connection with a Neon API key using the `--api-key` option when running a Neon CLI command. For example, an API key is used with the following `neonctl projects list` command:
|
|
68
50
|
|
|
69
|
-
|
|
51
|
+
```bash
|
|
52
|
+
neonctl projects list --api-key <neon_api_key>
|
|
53
|
+
```
|
|
70
54
|
|
|
71
|
-
|
|
55
|
+
For information about obtaining an Neon API key, see [Authentication](https://api-docs.neon.tech/reference/authentication), in the _Neon API Reference_.
|
|
72
56
|
|
|
73
|
-
|
|
57
|
+
## Configure autocompletion
|
|
74
58
|
|
|
75
|
-
|
|
59
|
+
The Neon CLI supports autocompletion, which you can configure in a few easy steps. See [Neon CLI commands — completion](https://neon.tech/docs/reference/cli-completion) for instructions.
|
|
76
60
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
61
|
+
## Commands
|
|
62
|
+
|
|
63
|
+
| Command | Subcommands | Description |
|
|
64
|
+
|---------------------------------------------------------|----------------------------------------|---------------------------|
|
|
65
|
+
| [auth](https://neon.tech/docs/reference/cli-auth) | | Authenticate |
|
|
66
|
+
| [projects](https://neon.tech/docs/reference/cli-projects) | `list`, `create`, `update`, `delete`, `get` | Manage projects |
|
|
67
|
+
| [me](../reference/cli-me) | | Show current user |
|
|
68
|
+
| [branches](https://neon.tech/docs/reference/cli-branches) | `list`, `create`, `rename`, `add-compute`, `set-primary`, `delete`, `get` | Manage branches |
|
|
69
|
+
| [databases](https://neon.tech/docs/reference/cli-databases) | `list`, `create`, `delete` | Manage databases |
|
|
70
|
+
| [roles](https://neon.tech/docs/reference/cli-roles) | `list`, `create`, `delete` | Manage roles |
|
|
71
|
+
| [operations](https://neon.tech/reference/cli-operations) | `list` | Manage operations |
|
|
72
|
+
| [connection-string](https://neon.tech/reference/cli-connection-string) | | Get connection string |
|
|
73
|
+
| [completion](https://neon.tech/reference/cli-completion) | | Generate a completion script |
|
|
74
|
+
|
|
75
|
+
## Global options
|
|
85
76
|
|
|
77
|
+
Global options are supported with any Neon CLI command.
|
|
86
78
|
|
|
87
|
-
|
|
79
|
+
| Option | Description | Type | Default |
|
|
80
|
+
| :--------- | :---------------------------------- | :----- | :-------------------------------- |
|
|
81
|
+
| [-o, --output](#output)| Set the Neon CLI output format (`json`, `yaml`, or `table`) | string | table |
|
|
82
|
+
| [--config-dir](#config-dir)| Path to the Neon CLI configuration directory | string | `/home/<user>/.config/neonctl` |
|
|
83
|
+
| [--api-key](#api-key) | Neon API key | string | "" |
|
|
84
|
+
| [--analytics](#analytics) | Manage analytics | boolean| true |
|
|
85
|
+
| [-v, --version](#version) | Show the Neon CLI version number | boolean| - |
|
|
86
|
+
| [-h, --help](#help) | Show the Neon CLI help | boolean| - |
|
|
88
87
|
|
|
89
|
-
|
|
88
|
+
- <a id="output"></a>`-o, --output`
|
|
90
89
|
|
|
91
|
-
|
|
92
|
-
For creating and managing Neon branches.
|
|
90
|
+
Sets the output format. Supported options are `json`, `yaml`, and `table`. The default is `table`. Table output may be limited. The `json` and `yaml` output formats show all data.
|
|
93
91
|
|
|
94
|
-
|
|
92
|
+
```bash
|
|
93
|
+
neonctl me --output json
|
|
94
|
+
```
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
- <a id="config-dir"></a>`--config-dir`
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
Specifies the path to the `neonctl` configuration directory. To view the default configuration directory containing you `credentials.json` file, run `neonctl --help`. The credentials file is created when you authenticate using the `neonctl auth` command. This option is only necessary if you move your `neonctl` configuration file to a location other than the default.
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
```bash
|
|
101
|
+
neonctl projects list --config-dir /home/dtprice/.config/neonctl
|
|
102
|
+
```
|
|
101
103
|
|
|
102
|
-
|
|
104
|
+
- <a id="api-key"></a>`--api-key`
|
|
103
105
|
|
|
104
|
-
|
|
106
|
+
Specifies your Neon API key. You can authenticate using a Neon API key when running a Neon CLI command instead of using `neonctl auth`. For information about obtaining an Neon API key, see [Authentication](https://api-docs.neon.tech/reference/authentication), in the _Neon API Reference_.
|
|
105
107
|
|
|
106
|
-
|
|
108
|
+
```bash
|
|
109
|
+
neonctl <command> --api-key <neon_api_key>
|
|
110
|
+
```
|
|
107
111
|
|
|
108
|
-
|
|
112
|
+
- <a id="analytics"></a>`--analytics`
|
|
109
113
|
|
|
110
|
-
|
|
114
|
+
Analytics are enabled by default to gather information about the CLI commands and options that are used by our customers. This data collection assists in offering support, and allows for a better understanding of typical usage patterns so that we can improve user experience. Neon does not collect user-defined data, such as project IDs or command payloads. To opt-out of analytics data collection, specify `--no-analytics` or `--analytics false`.
|
|
111
115
|
|
|
112
|
-
|
|
116
|
+
- <a id="version"></a>`-v, --version`
|
|
113
117
|
|
|
114
|
-
|
|
118
|
+
Shows the Neon CLI version number.
|
|
115
119
|
|
|
116
|
-
|
|
120
|
+
```bash
|
|
121
|
+
$ neonctl --version
|
|
122
|
+
1.15.0
|
|
123
|
+
```
|
|
117
124
|
|
|
118
|
-
|
|
125
|
+
- <a id="help"></a>`-h, --help`
|
|
119
126
|
|
|
120
|
-
|
|
127
|
+
Shows the `neonctl` command-line help. You can view help for `neonctl`, a `neonctl` command, or a `neonctl` subcommand, as shown in the following examples:
|
|
121
128
|
|
|
122
|
-
|
|
129
|
+
```bash
|
|
130
|
+
neonctl --help
|
|
123
131
|
|
|
124
|
-
|
|
132
|
+
neonctl branches --help
|
|
125
133
|
|
|
126
|
-
|
|
134
|
+
neonctl branches create --help
|
|
135
|
+
```
|
package/config.js
CHANGED
|
@@ -2,9 +2,9 @@ import { join } from 'node:path';
|
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import { existsSync, mkdirSync } from 'node:fs';
|
|
4
4
|
import { isCi } from './env.js';
|
|
5
|
-
export const defaultDir = join(
|
|
5
|
+
export const defaultDir = join(process.env.XDG_CONFIG_HOME || join(homedir(), '.config'), 'neonctl');
|
|
6
6
|
export const ensureConfigDir = async ({ 'config-dir': configDir, }) => {
|
|
7
7
|
if (!existsSync(configDir) && !isCi()) {
|
|
8
|
-
mkdirSync(configDir);
|
|
8
|
+
mkdirSync(configDir, { recursive: true });
|
|
9
9
|
}
|
|
10
10
|
};
|
package/package.json
CHANGED
package/writer.js
CHANGED
|
@@ -48,17 +48,18 @@ export const writer = (props) => {
|
|
|
48
48
|
}
|
|
49
49
|
chunks.forEach(({ data, config }) => {
|
|
50
50
|
const arrayData = Array.isArray(data) ? data : [data];
|
|
51
|
+
const fields = config.fields.filter((field) => arrayData.some((item) => item[field] !== undefined && item[field] !== ''));
|
|
51
52
|
const table = new Table({
|
|
52
53
|
style: {
|
|
53
54
|
head: ['green'],
|
|
54
55
|
},
|
|
55
|
-
head:
|
|
56
|
+
head: fields.map((field) => field
|
|
56
57
|
.split('_')
|
|
57
58
|
.map((word) => word[0].toUpperCase() + word.slice(1))
|
|
58
59
|
.join(' ')),
|
|
59
60
|
});
|
|
60
61
|
arrayData.forEach((item) => {
|
|
61
|
-
table.push(
|
|
62
|
+
table.push(fields.map((field) => item[field]));
|
|
62
63
|
});
|
|
63
64
|
if (config.title) {
|
|
64
65
|
out.write((isCi() ? config.title : chalk.bold(config.title)) + '\n');
|