neonctl 1.9.4 → 1.11.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/commands/branches.js +2 -1
- package/commands/connection_string.js +9 -1
- package/commands/connection_string.test.js +18 -0
- package/commands/databases.js +2 -1
- package/commands/endpoints.js +2 -1
- package/commands/index.js +1 -1
- package/commands/operations.js +2 -1
- package/commands/projects.js +2 -1
- package/commands/roles.js +2 -1
- package/index.js +2 -1
- package/package.json +1 -1
package/commands/branches.js
CHANGED
|
@@ -4,10 +4,11 @@ import { commandFailHandler } from '../utils.js';
|
|
|
4
4
|
const BRANCH_FIELDS = ['id', 'name', 'created_at'];
|
|
5
5
|
export const command = 'branches';
|
|
6
6
|
export const describe = 'Manage branches';
|
|
7
|
+
export const aliases = ['branch'];
|
|
7
8
|
export const builder = (argv) => argv
|
|
8
9
|
.demandCommand(1, '')
|
|
9
10
|
.fail(commandFailHandler)
|
|
10
|
-
.usage('usage: $0 branches <command> [options]')
|
|
11
|
+
.usage('usage: $0 branches <sub-command> [options]')
|
|
11
12
|
.options({
|
|
12
13
|
'project.id': {
|
|
13
14
|
describe: 'Project ID',
|
|
@@ -23,12 +23,20 @@ export const builder = (argv) => {
|
|
|
23
23
|
describe: 'Database name',
|
|
24
24
|
demandOption: true,
|
|
25
25
|
},
|
|
26
|
+
pooled: {
|
|
27
|
+
type: 'boolean',
|
|
28
|
+
describe: 'Use pooled connection',
|
|
29
|
+
default: false,
|
|
30
|
+
},
|
|
26
31
|
});
|
|
27
32
|
};
|
|
28
33
|
export const handler = async (props) => {
|
|
29
34
|
const { data: { endpoint }, } = await props.apiClient.getProjectEndpoint(props.project.id, props.endpoint.id);
|
|
30
35
|
const { data: password } = await props.apiClient.getProjectBranchRolePassword(props.project.id, endpoint.branch_id, props.role.name);
|
|
31
|
-
const
|
|
36
|
+
const host = props.pooled
|
|
37
|
+
? endpoint.host.replace(endpoint.id, `${endpoint.id}-pooler`)
|
|
38
|
+
: endpoint.host;
|
|
39
|
+
const connectionString = new URL(`postgres://${host}`);
|
|
32
40
|
connectionString.pathname = props.database.name;
|
|
33
41
|
connectionString.username = props.role.name;
|
|
34
42
|
connectionString.password = password.password;
|
|
@@ -18,4 +18,22 @@ describe('connection_string', () => {
|
|
|
18
18
|
snapshot: true,
|
|
19
19
|
},
|
|
20
20
|
});
|
|
21
|
+
testCliCommand({
|
|
22
|
+
name: 'connection_string pooled',
|
|
23
|
+
args: [
|
|
24
|
+
'connection-string',
|
|
25
|
+
'--project.id',
|
|
26
|
+
'test',
|
|
27
|
+
'--endpoint.id',
|
|
28
|
+
'test_endpoint_id',
|
|
29
|
+
'--database.name',
|
|
30
|
+
'test_db',
|
|
31
|
+
'--role.name',
|
|
32
|
+
'test_role',
|
|
33
|
+
'--pooled',
|
|
34
|
+
],
|
|
35
|
+
expected: {
|
|
36
|
+
snapshot: true,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
21
39
|
});
|
package/commands/databases.js
CHANGED
|
@@ -4,10 +4,11 @@ import { writer } from '../writer.js';
|
|
|
4
4
|
const DATABASE_FIELDS = ['name', 'owner_name', 'created_at'];
|
|
5
5
|
export const command = 'databases';
|
|
6
6
|
export const describe = 'Manage databases';
|
|
7
|
+
export const aliases = ['database'];
|
|
7
8
|
export const builder = (argv) => argv
|
|
8
9
|
.demandCommand(1, '')
|
|
9
10
|
.fail(commandFailHandler)
|
|
10
|
-
.usage('usage: $0 databases <command> [options]')
|
|
11
|
+
.usage('usage: $0 databases <sub-command> [options]')
|
|
11
12
|
.options({
|
|
12
13
|
'project.id': {
|
|
13
14
|
describe: 'Project ID',
|
package/commands/endpoints.js
CHANGED
|
@@ -10,10 +10,11 @@ const ENDPOINT_FIELDS = [
|
|
|
10
10
|
];
|
|
11
11
|
export const command = 'endpoints';
|
|
12
12
|
export const describe = 'Manage endpoints';
|
|
13
|
+
export const aliases = ['endpoint'];
|
|
13
14
|
export const builder = (argv) => argv
|
|
14
15
|
.demandCommand(1, '')
|
|
15
16
|
.fail(commandFailHandler)
|
|
16
|
-
.usage('usage: $0 endpoints <command> [options]')
|
|
17
|
+
.usage('usage: $0 endpoints <sub-command> [options]')
|
|
17
18
|
.options({
|
|
18
19
|
'project.id': {
|
|
19
20
|
describe: 'Project ID',
|
package/commands/index.js
CHANGED
package/commands/operations.js
CHANGED
|
@@ -3,10 +3,11 @@ import { writer } from '../writer.js';
|
|
|
3
3
|
const OPERATIONS_FIELDS = ['id', 'action', 'status', 'created_at'];
|
|
4
4
|
export const command = 'operations';
|
|
5
5
|
export const describe = 'Manage operations';
|
|
6
|
+
export const aliases = ['operation'];
|
|
6
7
|
export const builder = (argv) => argv
|
|
7
8
|
.demandCommand(1, '')
|
|
8
9
|
.fail(commandFailHandler)
|
|
9
|
-
.usage('usage: $0 operations <command> [options]')
|
|
10
|
+
.usage('usage: $0 operations <sub-command> [options]')
|
|
10
11
|
.options({
|
|
11
12
|
'project.id': {
|
|
12
13
|
describe: 'Project ID',
|
package/commands/projects.js
CHANGED
|
@@ -4,11 +4,12 @@ import { writer } from '../writer.js';
|
|
|
4
4
|
const PROJECT_FIELDS = ['id', 'name', 'region_id', 'created_at'];
|
|
5
5
|
export const command = 'projects';
|
|
6
6
|
export const describe = 'Manage projects';
|
|
7
|
+
export const aliases = ['project'];
|
|
7
8
|
export const builder = (argv) => {
|
|
8
9
|
return argv
|
|
9
10
|
.demandCommand(1, '')
|
|
10
11
|
.fail(commandFailHandler)
|
|
11
|
-
.usage('usage: $0 projects <command> [options]')
|
|
12
|
+
.usage('usage: $0 projects <sub-command> [options]')
|
|
12
13
|
.command('list', 'List projects', (yargs) => yargs, async (args) => {
|
|
13
14
|
await list(args);
|
|
14
15
|
})
|
package/commands/roles.js
CHANGED
|
@@ -4,10 +4,11 @@ import { writer } from '../writer.js';
|
|
|
4
4
|
const ROLES_FIELDS = ['name', 'created_at'];
|
|
5
5
|
export const command = 'roles';
|
|
6
6
|
export const describe = 'Manage roles';
|
|
7
|
+
export const aliases = ['role'];
|
|
7
8
|
export const builder = (argv) => argv
|
|
8
9
|
.demandCommand(1, '')
|
|
9
10
|
.fail(commandFailHandler)
|
|
10
|
-
.usage('usage: $0 roles <command> [options]')
|
|
11
|
+
.usage('usage: $0 roles <sub-command> [options]')
|
|
11
12
|
.options({
|
|
12
13
|
'project.id': {
|
|
13
14
|
describe: 'Project ID',
|
package/index.js
CHANGED
|
@@ -21,7 +21,8 @@ import { fillInArgs } from './utils.js';
|
|
|
21
21
|
import pkg from './pkg.js';
|
|
22
22
|
import commands from './commands/index.js';
|
|
23
23
|
import { analyticsMiddleware } from './analytics.js';
|
|
24
|
-
|
|
24
|
+
let builder = yargs(hideBin(process.argv));
|
|
25
|
+
builder = builder
|
|
25
26
|
.scriptName(pkg.name)
|
|
26
27
|
.usage('usage: $0 <command> [options]')
|
|
27
28
|
.help()
|