Comparing version 1.37.0 to 2.0.0
@@ -498,3 +498,3 @@ import { writer } from '../../writer.js'; | ||
let devConnectionString; | ||
const devBranchName = `dev-${cryptoRandomString({ | ||
const devBranchName = `dev/${cryptoRandomString({ | ||
length: 10, | ||
@@ -501,0 +501,0 @@ type: 'url-safe', |
@@ -15,3 +15,2 @@ import { EndpointType } from '@neondatabase/api-client'; | ||
'name', | ||
'primary', | ||
'default', | ||
@@ -24,3 +23,2 @@ 'created_at', | ||
'name', | ||
'primary', | ||
'default', | ||
@@ -126,3 +124,2 @@ 'created_at', | ||
.command('rename <id|name> <new-name>', 'Rename a branch', (yargs) => yargs, (args) => rename(args)) | ||
.command('set-primary <id|name>', 'DEPRECATED: Use set-default. Set a branch as primary', (yargs) => yargs, (args) => setDefault(args)) | ||
.command('set-default <id|name>', 'Set a branch as default', (yargs) => yargs, (args) => setDefault(args)) | ||
@@ -245,2 +242,3 @@ .command('add-compute <id|name>', 'Add a compute to a branch', (yargs) => yargs.options({ | ||
title: 'branch', | ||
emptyMessage: 'No branches have been found.', | ||
}); | ||
@@ -251,2 +249,3 @@ if (data.endpoints?.length > 0) { | ||
title: 'endpoints', | ||
emptyMessage: 'No endpoints have been found.', | ||
}); | ||
@@ -258,2 +257,3 @@ } | ||
title: 'connection_uris', | ||
emptyMessage: 'No connection uris have been found', | ||
}); | ||
@@ -361,2 +361,3 @@ } | ||
fields: ['id', 'name', 'last_reset_at'], | ||
emptyMessage: 'No branches have been restored.', | ||
}); | ||
@@ -369,2 +370,3 @@ const parentId = data.branch.parent_id; | ||
fields: ['id', 'name'], | ||
emptyMessage: 'Backup branch has not been found.', | ||
}); | ||
@@ -371,0 +373,0 @@ } |
@@ -160,12 +160,2 @@ import { describe } from 'vitest'; | ||
}); | ||
/* set primary */ | ||
test('set primary by id', async ({ testCliCommand }) => { | ||
await testCliCommand([ | ||
'branches', | ||
'set-primary', | ||
'br-sunny-branch-123456', | ||
'--project-id', | ||
'test', | ||
]); | ||
}); | ||
/* set default */ | ||
@@ -172,0 +162,0 @@ test('set default by id', async ({ testCliCommand }) => { |
@@ -39,9 +39,2 @@ import { writer } from '../writer.js'; | ||
}, | ||
}) | ||
.options({ | ||
'primary-only': { | ||
describe: projectUpdateRequest['project.settings.allowed_ips.primary_branch_only'].description, | ||
type: 'boolean', | ||
deprecated: 'See --protected-only', | ||
}, | ||
}), async (args) => { | ||
@@ -87,3 +80,2 @@ await add(args); | ||
ips: [...new Set(props.ips.concat(existingAllowedIps?.ips ?? []))], | ||
primary_branch_only: props.primaryOnly ?? existingAllowedIps?.primary_branch_only ?? false, | ||
protected_branches_only: props.protectedOnly ?? | ||
@@ -111,3 +103,2 @@ existingAllowedIps?.protected_branches_only ?? | ||
ips: existingAllowedIps?.ips?.filter((ip) => !props.ips.includes(ip)) ?? [], | ||
primary_branch_only: existingAllowedIps?.primary_branch_only ?? false, | ||
protected_branches_only: existingAllowedIps?.protected_branches_only ?? false, | ||
@@ -128,3 +119,2 @@ }, | ||
ips: props.ips, | ||
primary_branch_only: false, | ||
protected_branches_only: false, | ||
@@ -149,5 +139,4 @@ }, | ||
IP_addresses: ips, | ||
primary_branch_only: project.settings?.allowed_ips?.primary_branch_only ?? false, | ||
protected_branches_only: project.settings?.allowed_ips?.protected_branches_only ?? false, | ||
}; | ||
}; |
@@ -19,13 +19,2 @@ import { describe } from 'vitest'; | ||
}); | ||
test('Add IP allow - Primary', async ({ testCliCommand }) => { | ||
await testCliCommand([ | ||
'ip-allow', | ||
'add', | ||
'127.0.0.1', | ||
'192.168.10.1-192.168.10.15', | ||
'--primary-only', | ||
'--project-id', | ||
'test', | ||
]); | ||
}); | ||
test('Add IP allow - Protected', async ({ testCliCommand }) => { | ||
@@ -32,0 +21,0 @@ await testCliCommand([ |
@@ -21,4 +21,5 @@ import { writer } from '../writer.js'; | ||
title: 'Organizations', | ||
emptyMessage: 'You are not a member of any organization.', | ||
}); | ||
out.end(); | ||
}; |
import { log } from '../log.js'; | ||
import { projectCreateRequest, projectUpdateRequest, } from '../parameters.gen.js'; | ||
import { projectCreateRequest } from '../parameters.gen.js'; | ||
import { writer } from '../writer.js'; | ||
@@ -80,14 +80,2 @@ import { psql } from '../utils/psql.js'; | ||
}, | ||
'ip-allow': { | ||
describe: projectUpdateRequest['project.settings.allowed_ips.ips'] | ||
.description, | ||
type: 'string', | ||
array: true, | ||
deprecated: "Deprecated. Use 'ip-allow' command", | ||
}, | ||
'ip-primary-only': { | ||
describe: projectUpdateRequest['project.settings.allowed_ips.primary_branch_only'].description, | ||
type: 'boolean', | ||
deprecated: "Deprecated. Use 'ip-allow' command", | ||
}, | ||
cu: { | ||
@@ -130,15 +118,17 @@ 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").', | ||
}; | ||
const ownedProjects = getList(props.apiClient.listProjects); | ||
const ownedProjects = await getList(props.apiClient.listProjects); | ||
const sharedProjects = props.orgId | ||
? undefined | ||
: getList(props.apiClient.listSharedProjects); | ||
? [] | ||
: await getList(props.apiClient.listSharedProjects); | ||
const out = writer(props); | ||
out.write(await ownedProjects, { | ||
out.write(ownedProjects, { | ||
fields: PROJECT_FIELDS, | ||
title: 'Projects', | ||
emptyMessage: "You don't have any projects yet. See how to create a new project:\n> neonctl projects create --help", | ||
}); | ||
if (sharedProjects) { | ||
out.write(await sharedProjects, { | ||
if (!props.orgId) { | ||
out.write(sharedProjects, { | ||
fields: PROJECT_FIELDS, | ||
title: 'Shared with you', | ||
emptyMessage: 'No projects have been shared with you', | ||
}); | ||
@@ -203,14 +193,2 @@ } | ||
} | ||
if (props.ipAllow || props.ipPrimaryOnly != undefined) { | ||
const { data } = await props.apiClient.getProject(props.id); | ||
const existingAllowedIps = data.project.settings?.allowed_ips; | ||
project.settings = { | ||
allowed_ips: { | ||
ips: props.ipAllow ?? existingAllowedIps?.ips ?? [], | ||
primary_branch_only: props.ipPrimaryOnly ?? | ||
existingAllowedIps?.primary_branch_only ?? | ||
false, | ||
}, | ||
}; | ||
} | ||
if (props.cu) { | ||
@@ -217,0 +195,0 @@ project.default_endpoint_settings = props.cu |
@@ -105,25 +105,2 @@ import { describe, expect } from 'vitest'; | ||
}); | ||
test('update ip allow', async ({ testCliCommand }) => { | ||
await testCliCommand([ | ||
'projects', | ||
'update', | ||
'test', | ||
'--ip-allow', | ||
'127.0.0.1', | ||
'192.168.1.2/22', | ||
'--ip-primary-only', | ||
]); | ||
}); | ||
test('update ip allow primary only flag', async ({ testCliCommand }) => { | ||
await testCliCommand([ | ||
'projects', | ||
'update', | ||
'test', | ||
'--ip-primary-only', | ||
'false', | ||
]); | ||
}); | ||
test('update ip allow remove', async ({ testCliCommand }) => { | ||
await testCliCommand(['projects', 'update', 'test', '--ip-allow']); | ||
}); | ||
test('update project with default fixed size CU', async ({ testCliCommand, }) => { | ||
@@ -130,0 +107,0 @@ await testCliCommand([ |
@@ -8,3 +8,3 @@ { | ||
"type": "module", | ||
"version": "1.37.0", | ||
"version": "2.0.0", | ||
"description": "CLI tool for NeonDB Cloud management", | ||
@@ -11,0 +11,0 @@ "main": "index.js", |
@@ -25,2 +25,6 @@ import YAML from 'yaml'; | ||
const arrayData = Array.isArray(data) ? data : [data]; | ||
if (!arrayData.length && config.emptyMessage) { | ||
out.write('\n' + config.emptyMessage + '\n'); | ||
return; | ||
} | ||
const fields = config.fields.filter((field) => arrayData.some((item) => item[field] !== undefined && item[field] !== '')); | ||
@@ -27,0 +31,0 @@ const table = new Table({ |
195045
4944