neonctl 1.4.0 → 1.6.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.
@@ -1,7 +1,7 @@
1
1
  import { databaseCreateRequest } from '../parameters.gen.js';
2
2
  import { commandFailHandler } from '../utils.js';
3
3
  import { writer } from '../writer.js';
4
- const DATABASE_FIELDS = ['name', 'owner_name'];
4
+ const DATABASE_FIELDS = ['name', 'owner_name', 'created_at'];
5
5
  export const command = 'databases';
6
6
  export const describe = 'Manage databases';
7
7
  export const builder = (argv) => argv
package/commands/index.js CHANGED
@@ -4,4 +4,5 @@ import * as users from './users.js';
4
4
  import * as branches from './branches.js';
5
5
  import * as endpoints from './endpoints.js';
6
6
  import * as databases from './databases.js';
7
- export default [auth, projects, users, branches, endpoints, databases];
7
+ import * as roles from './roles.js';
8
+ export default [auth, projects, users, branches, endpoints, databases, roles];
@@ -0,0 +1,54 @@
1
+ import { roleCreateRequest } from '../parameters.gen.js';
2
+ import { commandFailHandler } from '../utils.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 builder = (argv) => argv
8
+ .demandCommand(1, '')
9
+ .fail(commandFailHandler)
10
+ .usage('usage: $0 databases <cmd> [args]')
11
+ .options({
12
+ 'project.id': {
13
+ describe: 'Project ID',
14
+ type: 'string',
15
+ demandOption: true,
16
+ },
17
+ 'branch.id': {
18
+ describe: 'Branch ID',
19
+ type: 'string',
20
+ demandOption: true,
21
+ },
22
+ })
23
+ .command('list', 'List roles', (yargs) => yargs, async (args) => await list(args))
24
+ .command('create', 'Create a role', (yargs) => yargs.options(roleCreateRequest), async (args) => await create(args))
25
+ .command('delete', 'Delete a role', (yargs) => yargs.options({
26
+ 'role.name': {
27
+ describe: 'Role name',
28
+ type: 'string',
29
+ demandOption: true,
30
+ },
31
+ }), async (args) => await deleteRole(args));
32
+ export const handler = (args) => {
33
+ return args;
34
+ };
35
+ export const list = async (props) => {
36
+ const { data } = await props.apiClient.listProjectBranchRoles(props.project.id, props.branch.id);
37
+ writer(props).end(data.roles, {
38
+ fields: ROLES_FIELDS,
39
+ });
40
+ };
41
+ export const create = async (props) => {
42
+ const { data } = await props.apiClient.createProjectBranchRole(props.project.id, props.branch.id, {
43
+ role: props.role,
44
+ });
45
+ writer(props).end(data.role, {
46
+ fields: ROLES_FIELDS,
47
+ });
48
+ };
49
+ export const deleteRole = async (props) => {
50
+ const { data } = await props.apiClient.deleteProjectBranchRole(props.project.id, props.branch.id, props.role.name);
51
+ writer(props).end(data.role, {
52
+ fields: ROLES_FIELDS,
53
+ });
54
+ };
@@ -0,0 +1,50 @@
1
+ import { describe } from '@jest/globals';
2
+ import { testCliCommand } from '../test_utils.js';
3
+ describe('roles', () => {
4
+ testCliCommand({
5
+ name: 'list',
6
+ args: [
7
+ 'roles',
8
+ 'list',
9
+ '--project.id',
10
+ 'test',
11
+ '--branch.id',
12
+ 'test_branch_id',
13
+ ],
14
+ expected: {
15
+ snapshot: true,
16
+ },
17
+ });
18
+ testCliCommand({
19
+ name: 'create',
20
+ args: [
21
+ 'roles',
22
+ 'create',
23
+ '--project.id',
24
+ 'test',
25
+ '--branch.id',
26
+ 'test_branch_id',
27
+ '--role.name',
28
+ 'test_role',
29
+ ],
30
+ expected: {
31
+ snapshot: true,
32
+ },
33
+ });
34
+ testCliCommand({
35
+ name: 'delete',
36
+ args: [
37
+ 'roles',
38
+ 'delete',
39
+ '--project.id',
40
+ 'test',
41
+ '--branch.id',
42
+ 'test_branch_id',
43
+ '--role.name',
44
+ 'test_role',
45
+ ],
46
+ expected: {
47
+ snapshot: true,
48
+ },
49
+ });
50
+ });
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.4.0",
8
+ "version": "1.6.0",
9
9
  "description": "CLI tool for NeonDB Cloud management",
10
10
  "main": "index.js",
11
11
  "author": "NeonDB",
@@ -19,6 +19,8 @@
19
19
  },
20
20
  "devDependencies": {
21
21
  "@apidevtools/swagger-parser": "^10.1.0",
22
+ "@commitlint/cli": "^17.6.5",
23
+ "@commitlint/config-conventional": "^17.6.5",
22
24
  "@jest/globals": "^29.5.0",
23
25
  "@semantic-release/exec": "^6.0.3",
24
26
  "@semantic-release/git": "^10.0.1",
@@ -32,7 +34,7 @@
32
34
  "emocks": "^3.0.1",
33
35
  "eslint": "^8.22.0",
34
36
  "express": "^4.18.2",
35
- "husky": "^8.0.1",
37
+ "husky": "^8.0.3",
36
38
  "jest": "^29.5.0",
37
39
  "lint-staged": "^13.0.3",
38
40
  "prettier": "^2.7.1",
package/parameters.gen.js CHANGED
@@ -221,3 +221,10 @@ export const databaseCreateRequest = {
221
221
  demandOption: true,
222
222
  },
223
223
  };
224
+ export const roleCreateRequest = {
225
+ 'role.name': {
226
+ type: "string",
227
+ description: "The role name. Cannot exceed 63 bytes in length.\n",
228
+ demandOption: true,
229
+ },
230
+ };