neonctl 1.16.5 → 1.17.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.
@@ -33,19 +33,29 @@ export const builder = (argv) => argv
33
33
  describe: 'Parent branch name or id or timestamp or LSN. Defaults to the primary branch',
34
34
  type: 'string',
35
35
  },
36
- endpoint: {
37
- describe: 'Create a branch with or without an endpoint. By default branch is created with a read-write endpoint. To create a branch without endpoint use --no-endpoint',
36
+ compute: {
37
+ describe: 'Create a branch with or without a compute. By default branch is created with a read-write compute. To create a branch without compute use --no-compute',
38
38
  type: 'boolean',
39
39
  default: true,
40
40
  },
41
- readonly: {
42
- describe: 'Create a read-only branch',
43
- type: 'boolean',
44
- implies: 'endpoint',
41
+ type: {
42
+ describe: 'Type of compute to add',
43
+ type: 'string',
44
+ implies: 'compute',
45
+ default: EndpointType.ReadWrite,
46
+ choices: Object.values(EndpointType),
45
47
  },
46
48
  }), async (args) => await create(args))
47
49
  .command('rename <id|name> <new-name>', 'Rename a branch', (yargs) => yargs, async (args) => await rename(args))
48
50
  .command('set-primary <id|name>', 'Set a branch as primary', (yargs) => yargs, async (args) => await setPrimary(args))
51
+ .command('add-compute <id|name>', 'Add a compute to a branch', (yargs) => yargs.options({
52
+ type: {
53
+ type: 'string',
54
+ choices: Object.values(EndpointType),
55
+ describe: 'Type of compute to add',
56
+ default: EndpointType.ReadOnly,
57
+ },
58
+ }), async (args) => await addCompute(args))
49
59
  .command('delete <id|name>', 'Delete a branch', (yargs) => yargs, async (args) => await deleteBranch(args))
50
60
  .command('get <id|name>', 'Get a branch', (yargs) => yargs, async (args) => await get(args));
51
61
  export const handler = (args) => {
@@ -94,12 +104,10 @@ const create = async (props) => {
94
104
  name: props.name,
95
105
  ...parentProps,
96
106
  },
97
- endpoints: props.endpoint
107
+ endpoints: props.compute
98
108
  ? [
99
109
  {
100
- type: props.readonly
101
- ? EndpointType.ReadOnly
102
- : EndpointType.ReadWrite,
110
+ type: props.type,
103
111
  },
104
112
  ]
105
113
  : [],
@@ -155,3 +163,15 @@ const get = async (props) => {
155
163
  fields: BRANCH_FIELDS,
156
164
  });
157
165
  };
166
+ const addCompute = async (props) => {
167
+ const branchId = await branchIdFromProps(props);
168
+ const { data } = await retryOnLock(() => props.apiClient.createProjectEndpoint(props.projectId, {
169
+ endpoint: {
170
+ branch_id: branchId,
171
+ type: props.type,
172
+ },
173
+ }));
174
+ writer(props).end(data.endpoint, {
175
+ fields: ['id', 'host'],
176
+ });
177
+ };
@@ -31,7 +31,8 @@ describe('branches', () => {
31
31
  'test',
32
32
  '--name',
33
33
  'test_branch',
34
- '--readonly',
34
+ '--type',
35
+ 'read_only',
35
36
  ],
36
37
  expected: {
37
38
  snapshot: true,
@@ -46,7 +47,7 @@ describe('branches', () => {
46
47
  'test',
47
48
  '--name',
48
49
  'test_branch',
49
- '--no-endpoint',
50
+ '--no-compute',
50
51
  ],
51
52
  expected: {
52
53
  snapshot: true,
@@ -154,4 +155,11 @@ describe('branches', () => {
154
155
  snapshot: true,
155
156
  },
156
157
  });
158
+ testCliCommand({
159
+ name: 'add compute',
160
+ args: ['branches', 'add-compute', 'test_branch', '--project-id', 'test'],
161
+ expected: {
162
+ snapshot: true,
163
+ },
164
+ });
157
165
  });
@@ -63,7 +63,7 @@ export const handler = async (props) => {
63
63
  if (data.roles.length === 1) {
64
64
  return data.roles[0].name;
65
65
  }
66
- throw new Error(`Multiple roles found for the branch, please provide one with the --role.name option: ${data.roles
66
+ throw new Error(`Multiple roles found for the branch, please provide one with the --role-name option: ${data.roles
67
67
  .map((r) => r.name)
68
68
  .join(', ')}`);
69
69
  }));
@@ -77,7 +77,7 @@ export const handler = async (props) => {
77
77
  if (data.databases.length === 1) {
78
78
  return data.databases[0].name;
79
79
  }
80
- throw new Error(`Multiple databases found for the branch, please provide one with the --database.name option: ${data.databases
80
+ throw new Error(`Multiple databases found for the branch, please provide one with the --database-name option: ${data.databases
81
81
  .map((d) => d.name)
82
82
  .join(', ')}`);
83
83
  }));
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "url": "git@github.com:neondatabase/neonctl.git"
6
6
  },
7
7
  "type": "module",
8
- "version": "1.16.5",
8
+ "version": "1.17.0",
9
9
  "description": "CLI tool for NeonDB Cloud management",
10
10
  "main": "index.js",
11
11
  "author": "NeonDB",