neonctl 1.15.0 → 1.16.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/commands/branches.js +15 -1
- package/commands/branches.test.js +13 -0
- package/package.json +1 -1
package/commands/branches.js
CHANGED
|
@@ -5,7 +5,13 @@ import { commandFailHandler } from '../utils/middlewares.js';
|
|
|
5
5
|
import { retryOnLock } from '../api.js';
|
|
6
6
|
import { branchIdFromProps, fillSingleProject } from '../utils/enrichers.js';
|
|
7
7
|
import { looksLikeBranchId, looksLikeLSN, looksLikeTimestamp, } from '../utils/formats.js';
|
|
8
|
-
const BRANCH_FIELDS = [
|
|
8
|
+
const BRANCH_FIELDS = [
|
|
9
|
+
'id',
|
|
10
|
+
'name',
|
|
11
|
+
'primary',
|
|
12
|
+
'created_at',
|
|
13
|
+
'updated_at',
|
|
14
|
+
];
|
|
9
15
|
export const command = 'branches';
|
|
10
16
|
export const describe = 'Manage branches';
|
|
11
17
|
export const aliases = ['branch'];
|
|
@@ -39,6 +45,7 @@ export const builder = (argv) => argv
|
|
|
39
45
|
},
|
|
40
46
|
}), async (args) => await create(args))
|
|
41
47
|
.command('rename <id|name> <new-name>', 'Rename a branch', (yargs) => yargs, async (args) => await rename(args))
|
|
48
|
+
.command('set-primary <id|name>', 'Set a branch as primary', (yargs) => yargs, async (args) => await setPrimary(args))
|
|
42
49
|
.command('delete <id|name>', 'Delete a branch', (yargs) => yargs, async (args) => await deleteBranch(args))
|
|
43
50
|
.command('get <id|name>', 'Get a branch', (yargs) => yargs, async (args) => await get(args));
|
|
44
51
|
export const handler = (args) => {
|
|
@@ -127,6 +134,13 @@ const rename = async (props) => {
|
|
|
127
134
|
fields: BRANCH_FIELDS,
|
|
128
135
|
});
|
|
129
136
|
};
|
|
137
|
+
const setPrimary = async (props) => {
|
|
138
|
+
const branchId = await branchIdFromProps(props);
|
|
139
|
+
const { data } = await retryOnLock(() => props.apiClient.setPrimaryProjectBranch(props.projectId, branchId));
|
|
140
|
+
writer(props).end(data.branch, {
|
|
141
|
+
fields: BRANCH_FIELDS,
|
|
142
|
+
});
|
|
143
|
+
};
|
|
130
144
|
const deleteBranch = async (props) => {
|
|
131
145
|
const branchId = await branchIdFromProps(props);
|
|
132
146
|
const { data } = await retryOnLock(() => props.apiClient.deleteProjectBranch(props.projectId, branchId));
|
|
@@ -127,6 +127,19 @@ describe('branches', () => {
|
|
|
127
127
|
snapshot: true,
|
|
128
128
|
},
|
|
129
129
|
});
|
|
130
|
+
testCliCommand({
|
|
131
|
+
name: 'set primary by id',
|
|
132
|
+
args: [
|
|
133
|
+
'branches',
|
|
134
|
+
'set-primary',
|
|
135
|
+
'br-sunny-branch-123456',
|
|
136
|
+
'--project-id',
|
|
137
|
+
'test',
|
|
138
|
+
],
|
|
139
|
+
expected: {
|
|
140
|
+
snapshot: true,
|
|
141
|
+
},
|
|
142
|
+
});
|
|
130
143
|
testCliCommand({
|
|
131
144
|
name: 'get by id',
|
|
132
145
|
args: ['branches', 'get', 'br-sunny-branch-123456', '--project-id', 'test'],
|