neonctl 1.27.6 → 1.29.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/.bump +1 -0
- package/.editorconfig +7 -0
- package/.eslintrc.cjs +15 -0
- package/.github/workflows/commitlint.yml +46 -0
- package/.github/workflows/pr.yml +25 -0
- package/.github/workflows/release.yml +30 -0
- package/.husky/commit-msg +4 -0
- package/.husky/pre-commit +4 -0
- package/.nvmrc +1 -0
- package/.prettierignore +3 -0
- package/.prettierrc.json +3 -0
- package/.releaserc.json +47 -0
- package/LICENSE +202 -0
- package/commitlint.config.cjs +7 -0
- package/generateOptionsFromSpec.ts +68 -0
- package/jest/setup.js +5 -0
- package/jest.config.ts +199 -0
- package/mocks/bin/psql.cjs +9 -0
- package/mocks/main/projects/GET.js +27 -0
- package/mocks/main/projects/POST.js +22 -0
- package/mocks/main/projects/shared/GET.js +16 -0
- package/mocks/main/projects/test/DELETE.json +7 -0
- package/mocks/main/projects/test/GET.json +13 -0
- package/mocks/main/projects/test/PATCH.js +18 -0
- package/mocks/main/projects/test/branches/GET.json +25 -0
- package/mocks/main/projects/test/branches/POST.js +83 -0
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/DELETE.json +7 -0
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/GET.json +9 -0
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/PATCH.js +14 -0
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/databases/GET.json +6 -0
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/databases/POST.js +13 -0
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/databases/test_db/DELETE.json +6 -0
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/endpoints/GET.json +26 -0
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/endpoints/POST.json +6 -0
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/roles/GET.json +3 -0
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/roles/POST.js +14 -0
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/roles/test_role/DELETE.json +6 -0
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/roles/test_role/reveal_password/GET.json +3 -0
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/set_as_primary/POST.json +9 -0
- package/mocks/main/projects/test/branches/br-numbered-branch-123456/GET.json +10 -0
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/DELETE.json +7 -0
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/GET.json +10 -0
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/PATCH.js +14 -0
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/databases/GET.json +6 -0
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/databases/POST.js +13 -0
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/databases/test_db/DELETE.json +6 -0
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/endpoints/GET.json +26 -0
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/endpoints/POST.json +6 -0
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/restore/POST.js +16 -0
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/roles/GET.json +3 -0
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/roles/POST.js +14 -0
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/roles/test_role/DELETE.json +6 -0
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/roles/test_role/reveal_password/GET.json +3 -0
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/set_as_primary/POST.json +9 -0
- package/mocks/main/projects/test/endpoints/GET.json +9 -0
- package/mocks/main/projects/test/endpoints/POST.js +32 -0
- package/mocks/main/projects/test/endpoints/test_endpoint_id/DELETE.json +7 -0
- package/mocks/main/projects/test/endpoints/test_endpoint_id/GET.json +9 -0
- package/mocks/main/projects/test/endpoints/test_endpoint_id/PATCH.js +17 -0
- package/mocks/main/projects/test/operations/GET.json +22 -0
- package/mocks/main/users/me/GET.json +5 -0
- package/mocks/restore/projects/test/branches/GET.json +21 -0
- package/mocks/restore/projects/test/branches/br-another-branch-123456/GET.json +6 -0
- package/mocks/restore/projects/test/branches/br-another-branch-123456/restore/POST.js +13 -0
- package/mocks/restore/projects/test/branches/br-any-branch-123456/GET.json +6 -0
- package/mocks/restore/projects/test/branches/br-parent-tots-123456/GET.json +7 -0
- package/mocks/restore/projects/test/branches/br-parent-tots-123456/restore/POST.js +14 -0
- package/mocks/restore/projects/test/branches/br-self-tolsn-123456/GET.json +6 -0
- package/mocks/restore/projects/test/branches/br-self-tolsn-123456/restore/POST.js +15 -0
- package/mocks/single_project/projects/GET.json +10 -0
- package/mocks/single_project/projects/test-project-123456/GET.json +14 -0
- package/mocks/single_project/projects/test-project-123456/branches/GET.json +11 -0
- package/mocks/single_project/projects/test-project-123456/branches/br-main-branch-123456/databases/GET.json +3 -0
- package/mocks/single_project/projects/test-project-123456/branches/br-main-branch-123456/endpoints/GET.json +10 -0
- package/mocks/single_project/projects/test-project-123456/branches/br-main-branch-123456/roles/GET.json +3 -0
- package/mocks/single_project/projects/test-project-123456/branches/br-main-branch-123456/roles/test_role/reveal_password/GET.json +3 -0
- package/package.json +7 -6
- package/pkg.js +45 -3
- package/rollup.config.js +20 -0
- package/snapshots/commands/branches.test.snap +221 -0
- package/snapshots/commands/connection_string.test.snap +70 -0
- package/snapshots/commands/databases.test.snap +20 -0
- package/snapshots/commands/ip_allow.test.snap +55 -0
- package/snapshots/commands/operations.test.snap +17 -0
- package/snapshots/commands/projects.test.snap +141 -0
- package/snapshots/commands/roles.test.snap +19 -0
- package/snapshots/commands/set_context.test.snap +30 -0
- package/snapshots/writer.test.snap +60 -0
- package/snapshotsResolver.cjs +32 -0
- package/src/analytics.ts +95 -0
- package/src/api.ts +44 -0
- package/src/auth.ts +137 -0
- package/{cli.js → src/cli.ts} +1 -0
- package/src/commands/auth.test.ts +62 -0
- package/src/commands/auth.ts +148 -0
- package/src/commands/branches.test.ts +354 -0
- package/src/commands/branches.ts +451 -0
- package/src/commands/connection_string.test.ts +250 -0
- package/src/commands/connection_string.ts +210 -0
- package/src/commands/databases.test.ts +55 -0
- package/src/commands/databases.ts +129 -0
- package/src/commands/help.test.ts +13 -0
- package/{commands/index.js → src/commands/index.ts} +11 -10
- package/src/commands/ip_allow.test.ts +86 -0
- package/src/commands/ip_allow.ts +202 -0
- package/src/commands/operations.test.ts +13 -0
- package/src/commands/operations.ts +41 -0
- package/src/commands/projects.test.ts +147 -0
- package/src/commands/projects.ts +275 -0
- package/src/commands/roles.test.ts +46 -0
- package/src/commands/roles.ts +100 -0
- package/src/commands/set_context.test.ts +64 -0
- package/src/commands/set_context.ts +27 -0
- package/src/commands/user.ts +21 -0
- package/src/config.ts +22 -0
- package/src/context.ts +61 -0
- package/src/env.ts +7 -0
- package/src/errors.ts +24 -0
- package/src/help.ts +185 -0
- package/src/index.ts +180 -0
- package/src/log.ts +16 -0
- package/src/parameters.gen.ts +332 -0
- package/src/pkg.ts +9 -0
- package/src/test_utils/mock_server.ts +27 -0
- package/src/test_utils/oauth_server.ts +10 -0
- package/src/test_utils/test_cli_command.ts +117 -0
- package/src/types.ts +25 -0
- package/src/utils/enrichers.ts +73 -0
- package/src/utils/formats.test.ts +41 -0
- package/src/utils/formats.ts +11 -0
- package/src/utils/middlewares.ts +23 -0
- package/src/utils/point_in_time.ts +86 -0
- package/src/utils/psql.ts +29 -0
- package/src/utils/string.ts +8 -0
- package/src/utils/ui.ts +64 -0
- package/src/writer.test.ts +98 -0
- package/src/writer.ts +131 -0
- package/tsconfig.json +17 -0
- package/analytics.js +0 -78
- package/api.js +0 -35
- package/auth.js +0 -101
- package/commands/auth.js +0 -102
- package/commands/auth.test.js +0 -42
- package/commands/branches.js +0 -311
- package/commands/branches.test.js +0 -321
- package/commands/connection_string.js +0 -137
- package/commands/connection_string.test.js +0 -204
- package/commands/databases.js +0 -79
- package/commands/databases.test.js +0 -51
- package/commands/help.test.js +0 -11
- package/commands/ip_allow.js +0 -135
- package/commands/ip_allow.test.js +0 -78
- package/commands/operations.js +0 -28
- package/commands/operations.test.js +0 -11
- package/commands/projects.js +0 -156
- package/commands/projects.test.js +0 -116
- package/commands/roles.js +0 -57
- package/commands/roles.test.js +0 -42
- package/commands/set_context.js +0 -22
- package/commands/set_context.test.js +0 -53
- package/commands/user.js +0 -15
- package/config.js +0 -11
- package/context.js +0 -48
- package/env.js +0 -6
- package/errors.js +0 -16
- package/help.js +0 -146
- package/index.js +0 -168
- package/log.js +0 -15
- package/parameters.gen.js +0 -302
- package/test_utils/mock_server.js +0 -16
- package/test_utils/oauth_server.js +0 -9
- package/test_utils/test_cli_command.js +0 -80
- package/types.js +0 -1
- package/utils/enrichers.js +0 -49
- package/utils/formats.js +0 -5
- package/utils/formats.test.js +0 -32
- package/utils/middlewares.js +0 -20
- package/utils/point_in_time.js +0 -44
- package/utils/psql.js +0 -24
- package/utils/string.js +0 -5
- package/utils/ui.js +0 -59
- package/writer.js +0 -87
- package/writer.test.js +0 -86
- /package/{callback.html → src/callback.html} +0 -0
package/help.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import cliui from 'cliui';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { consumeBlockIfMatches, consumeNextMatching, drawPointer, splitColumns, } from './utils/ui.js';
|
|
4
|
-
// target width for the leftmost column
|
|
5
|
-
const SPACE_WIDTH = 20;
|
|
6
|
-
const formatHelp = (help) => {
|
|
7
|
-
const lines = help.split('\n');
|
|
8
|
-
const result = [];
|
|
9
|
-
// full command, like `neonctl projects list`
|
|
10
|
-
const topLevelCommand = consumeNextMatching(lines, /^.*/);
|
|
11
|
-
if (topLevelCommand) {
|
|
12
|
-
result.push(chalk.bold(topLevelCommand.replace('[options]', chalk.reset.green('[options]'))));
|
|
13
|
-
result.push('');
|
|
14
|
-
}
|
|
15
|
-
// commands description block
|
|
16
|
-
// example command to see: neonctl projects
|
|
17
|
-
const commandsBlock = consumeBlockIfMatches(lines, /^Commands:/);
|
|
18
|
-
if (commandsBlock.length > 0) {
|
|
19
|
-
const header = commandsBlock.shift();
|
|
20
|
-
result.push(header);
|
|
21
|
-
const ui = cliui({
|
|
22
|
-
width: 0,
|
|
23
|
-
});
|
|
24
|
-
commandsBlock.forEach((line) => {
|
|
25
|
-
if (line.match(/^\s{3,}/)) {
|
|
26
|
-
ui.div({
|
|
27
|
-
text: '',
|
|
28
|
-
width: SPACE_WIDTH,
|
|
29
|
-
padding: [0, 0, 0, 0],
|
|
30
|
-
}, { text: line.trim(), padding: [0, 0, 0, 0] });
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const [command, description] = splitColumns(line);
|
|
34
|
-
// patch the previous command if it was multiline
|
|
35
|
-
if (!description && ui.rows.length > 1) {
|
|
36
|
-
ui.rows[ui.rows.length - 2][0].text += command;
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
ui.div(chalk.cyan(command));
|
|
40
|
-
ui.div({
|
|
41
|
-
text: chalk.gray(drawPointer(SPACE_WIDTH)),
|
|
42
|
-
width: SPACE_WIDTH,
|
|
43
|
-
padding: [0, 0, 0, 0],
|
|
44
|
-
}, { text: description, padding: [0, 0, 0, 2] });
|
|
45
|
-
});
|
|
46
|
-
result.push(ui.toString());
|
|
47
|
-
result.push('');
|
|
48
|
-
}
|
|
49
|
-
// positional args block
|
|
50
|
-
// example command to see: neonctl branches rename
|
|
51
|
-
const positionalsBlock = consumeBlockIfMatches(lines, /Positionals:/);
|
|
52
|
-
if (positionalsBlock.length > 0) {
|
|
53
|
-
const header = positionalsBlock.shift();
|
|
54
|
-
result.push(header);
|
|
55
|
-
const ui = cliui({
|
|
56
|
-
width: 0,
|
|
57
|
-
});
|
|
58
|
-
positionalsBlock.forEach((line) => {
|
|
59
|
-
const [positional, description] = splitColumns(line);
|
|
60
|
-
ui.div({
|
|
61
|
-
text: positional,
|
|
62
|
-
width: SPACE_WIDTH,
|
|
63
|
-
padding: [0, 2, 0, 0],
|
|
64
|
-
}, {
|
|
65
|
-
text: description,
|
|
66
|
-
padding: [0, 0, 0, 0],
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
result.push(ui.toString());
|
|
70
|
-
result.push('');
|
|
71
|
-
}
|
|
72
|
-
// command description
|
|
73
|
-
// example command to see: neonctl projects list
|
|
74
|
-
const descritpionBlock = consumeBlockIfMatches(lines, /^(?!.*options:)/i);
|
|
75
|
-
if (descritpionBlock.length > 0) {
|
|
76
|
-
result.push(...descritpionBlock);
|
|
77
|
-
result.push('');
|
|
78
|
-
}
|
|
79
|
-
while (true) {
|
|
80
|
-
// there are two options blocks: global and specific
|
|
81
|
-
// example to see both: neonctl projects create
|
|
82
|
-
const optionsBlock = consumeBlockIfMatches(lines, /.*options:/i);
|
|
83
|
-
if (optionsBlock.length === 0) {
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
result.push(optionsBlock.shift());
|
|
87
|
-
optionsBlock.forEach((line) => {
|
|
88
|
-
const [option, description] = splitColumns(line);
|
|
89
|
-
const ui = cliui({
|
|
90
|
-
width: 0,
|
|
91
|
-
});
|
|
92
|
-
if (option.startsWith('-')) {
|
|
93
|
-
ui.div({
|
|
94
|
-
text: chalk.green(option),
|
|
95
|
-
padding: [0, 0, 0, 0],
|
|
96
|
-
});
|
|
97
|
-
ui.div({
|
|
98
|
-
text: chalk.gray(drawPointer(SPACE_WIDTH)),
|
|
99
|
-
width: SPACE_WIDTH,
|
|
100
|
-
padding: [0, 2, 0, 0],
|
|
101
|
-
}, {
|
|
102
|
-
text: chalk.rgb(210, 210, 210)(description ?? ''),
|
|
103
|
-
padding: [0, 0, 0, 0],
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
ui.div({
|
|
108
|
-
padding: [0, 0, 0, 0],
|
|
109
|
-
text: '',
|
|
110
|
-
width: SPACE_WIDTH,
|
|
111
|
-
}, {
|
|
112
|
-
text: chalk.rgb(210, 210, 210)(option),
|
|
113
|
-
padding: [0, 0, 0, 0],
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
result.push(ui.toString());
|
|
117
|
-
});
|
|
118
|
-
result.push('');
|
|
119
|
-
}
|
|
120
|
-
const exampleBlock = consumeBlockIfMatches(lines, /Examples:/);
|
|
121
|
-
if (exampleBlock.length > 0) {
|
|
122
|
-
result.push(exampleBlock.shift());
|
|
123
|
-
const ui = cliui({
|
|
124
|
-
width: 0,
|
|
125
|
-
});
|
|
126
|
-
for (const line of exampleBlock) {
|
|
127
|
-
const [command, description] = splitColumns(line);
|
|
128
|
-
ui.div({
|
|
129
|
-
text: chalk.bold(command),
|
|
130
|
-
padding: [0, 0, 0, 0],
|
|
131
|
-
});
|
|
132
|
-
ui.div({
|
|
133
|
-
text: chalk.reset(description),
|
|
134
|
-
padding: [0, 0, 0, 2],
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
result.push(ui.toString());
|
|
138
|
-
}
|
|
139
|
-
return [...result, ...lines];
|
|
140
|
-
};
|
|
141
|
-
export const showHelp = async (argv) => {
|
|
142
|
-
// add wrap to ensure that there are no line breaks
|
|
143
|
-
const help = await argv.getHelp();
|
|
144
|
-
process.stderr.write(formatHelp(help).join('\n') + '\n');
|
|
145
|
-
process.exit(0);
|
|
146
|
-
};
|
package/index.js
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { basename } from 'node:path';
|
|
2
|
-
import yargs from 'yargs';
|
|
3
|
-
import { hideBin } from 'yargs/helpers';
|
|
4
|
-
import axiosDebug from 'axios-debug-log';
|
|
5
|
-
axiosDebug({
|
|
6
|
-
request(debug, config) {
|
|
7
|
-
debug(`${config.method?.toUpperCase()} ${config.url}`);
|
|
8
|
-
},
|
|
9
|
-
response(debug, response) {
|
|
10
|
-
debug(`${response.status} ${response.statusText}`);
|
|
11
|
-
},
|
|
12
|
-
error(debug, error) {
|
|
13
|
-
debug(error);
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
import { ensureAuth } from './commands/auth.js';
|
|
17
|
-
import { defaultDir, ensureConfigDir } from './config.js';
|
|
18
|
-
import { log } from './log.js';
|
|
19
|
-
import { defaultClientID } from './auth.js';
|
|
20
|
-
import { fillInArgs } from './utils/middlewares.js';
|
|
21
|
-
import pkg from './pkg.js';
|
|
22
|
-
import commands from './commands/index.js';
|
|
23
|
-
import { analyticsMiddleware, sendError } from './analytics.js';
|
|
24
|
-
import { isAxiosError } from 'axios';
|
|
25
|
-
import { matchErrorCode } from './errors.js';
|
|
26
|
-
import { showHelp } from './help.js';
|
|
27
|
-
import { currentContextFile, enrichFromContext } from './context.js';
|
|
28
|
-
const NO_SUBCOMMANDS_VERBS = [
|
|
29
|
-
'auth',
|
|
30
|
-
'me',
|
|
31
|
-
'cs',
|
|
32
|
-
'connection-string',
|
|
33
|
-
'set-context',
|
|
34
|
-
];
|
|
35
|
-
let builder = yargs(hideBin(process.argv));
|
|
36
|
-
builder = builder
|
|
37
|
-
.scriptName(pkg.name)
|
|
38
|
-
.locale('en')
|
|
39
|
-
.usage('$0 <command> [options]')
|
|
40
|
-
.parserConfiguration({
|
|
41
|
-
'populate--': true,
|
|
42
|
-
})
|
|
43
|
-
.help()
|
|
44
|
-
.option('output', {
|
|
45
|
-
alias: 'o',
|
|
46
|
-
group: 'Global options:',
|
|
47
|
-
describe: 'Set output format',
|
|
48
|
-
type: 'string',
|
|
49
|
-
choices: ['json', 'yaml', 'table'],
|
|
50
|
-
default: 'table',
|
|
51
|
-
})
|
|
52
|
-
.option('api-host', {
|
|
53
|
-
describe: 'The API host',
|
|
54
|
-
hidden: true,
|
|
55
|
-
default: process.env.NEON_API_HOST ?? 'https://console.neon.tech/api/v2',
|
|
56
|
-
})
|
|
57
|
-
// Setup config directory
|
|
58
|
-
.option('config-dir', {
|
|
59
|
-
describe: 'Path to config directory',
|
|
60
|
-
group: 'Global options:',
|
|
61
|
-
type: 'string',
|
|
62
|
-
default: defaultDir,
|
|
63
|
-
})
|
|
64
|
-
.option('force-auth', {
|
|
65
|
-
describe: 'Force authentication',
|
|
66
|
-
type: 'boolean',
|
|
67
|
-
hidden: true,
|
|
68
|
-
default: false,
|
|
69
|
-
})
|
|
70
|
-
.middleware(ensureConfigDir)
|
|
71
|
-
.options({
|
|
72
|
-
'oauth-host': {
|
|
73
|
-
description: 'URL to Neon OAuth host',
|
|
74
|
-
hidden: true,
|
|
75
|
-
default: process.env.NEON_OAUTH_HOST ?? 'https://oauth2.neon.tech',
|
|
76
|
-
},
|
|
77
|
-
'client-id': {
|
|
78
|
-
description: 'OAuth client id',
|
|
79
|
-
hidden: true,
|
|
80
|
-
type: 'string',
|
|
81
|
-
default: defaultClientID,
|
|
82
|
-
},
|
|
83
|
-
'api-key': {
|
|
84
|
-
describe: 'API key',
|
|
85
|
-
group: 'Global options:',
|
|
86
|
-
type: 'string',
|
|
87
|
-
default: process.env.NEON_API_KEY ?? '',
|
|
88
|
-
},
|
|
89
|
-
apiClient: {
|
|
90
|
-
hidden: true,
|
|
91
|
-
coerce: (v) => v,
|
|
92
|
-
default: null,
|
|
93
|
-
},
|
|
94
|
-
'context-file': {
|
|
95
|
-
describe: 'Context file',
|
|
96
|
-
type: 'string',
|
|
97
|
-
default: currentContextFile,
|
|
98
|
-
},
|
|
99
|
-
})
|
|
100
|
-
.middleware((args) => fillInArgs(args), true)
|
|
101
|
-
.help(false)
|
|
102
|
-
.group('help', 'Global options:')
|
|
103
|
-
.option('help', {
|
|
104
|
-
describe: 'Show help',
|
|
105
|
-
type: 'boolean',
|
|
106
|
-
default: false,
|
|
107
|
-
})
|
|
108
|
-
.alias('help', 'h')
|
|
109
|
-
.middleware(async (args) => {
|
|
110
|
-
if (args.help ||
|
|
111
|
-
(args._.length === 1 &&
|
|
112
|
-
!NO_SUBCOMMANDS_VERBS.includes(args._[0]))) {
|
|
113
|
-
await showHelp(builder);
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
.middleware(ensureAuth)
|
|
117
|
-
.middleware(enrichFromContext)
|
|
118
|
-
.command(commands)
|
|
119
|
-
.strictCommands()
|
|
120
|
-
.option('analytics', {
|
|
121
|
-
describe: 'Manage analytics. Example: --no-analytics, --analytics false',
|
|
122
|
-
group: 'Global options:',
|
|
123
|
-
type: 'boolean',
|
|
124
|
-
default: true,
|
|
125
|
-
})
|
|
126
|
-
.middleware(analyticsMiddleware, true)
|
|
127
|
-
.group('version', 'Global options:')
|
|
128
|
-
.alias('version', 'v')
|
|
129
|
-
.completion()
|
|
130
|
-
.scriptName(basename(process.argv[1]) === 'neon' ? 'neon' : 'neonctl')
|
|
131
|
-
.epilog('For more information, visit https://neon.tech/docs/reference/neon-cli')
|
|
132
|
-
.wrap(null)
|
|
133
|
-
.fail(async (msg, err) => {
|
|
134
|
-
if (process.argv.some((arg) => arg === '--help' || arg === '-h')) {
|
|
135
|
-
await showHelp(builder);
|
|
136
|
-
process.exit(0);
|
|
137
|
-
}
|
|
138
|
-
if (isAxiosError(err)) {
|
|
139
|
-
if (err.code === 'ECONNABORTED') {
|
|
140
|
-
log.error('Request timed out');
|
|
141
|
-
sendError(err, 'REQUEST_TIMEOUT');
|
|
142
|
-
}
|
|
143
|
-
else if (err.response?.status === 401) {
|
|
144
|
-
sendError(err, 'AUTH_FAILED');
|
|
145
|
-
log.error('Authentication failed, please run `neonctl auth`');
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
if (err.response?.data?.message) {
|
|
149
|
-
log.error(err.response?.data?.message);
|
|
150
|
-
}
|
|
151
|
-
log.debug('status: %d %s | path: %s', err.response?.status, err.response?.statusText, err.request?.path);
|
|
152
|
-
sendError(err, 'API_ERROR');
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
sendError(err || new Error(msg), matchErrorCode(msg || err?.message));
|
|
157
|
-
log.error(msg || err?.message);
|
|
158
|
-
}
|
|
159
|
-
err?.stack && log.debug('Stack: %s', err.stack);
|
|
160
|
-
process.exit(1);
|
|
161
|
-
});
|
|
162
|
-
(async () => {
|
|
163
|
-
const args = await builder.argv;
|
|
164
|
-
if (args._.length === 0 || args.help) {
|
|
165
|
-
await showHelp(builder);
|
|
166
|
-
process.exit(0);
|
|
167
|
-
}
|
|
168
|
-
})();
|
package/log.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { format } from 'node:util';
|
|
2
|
-
import { isDebug } from './env.js';
|
|
3
|
-
export const log = {
|
|
4
|
-
debug: (...args) => {
|
|
5
|
-
if (isDebug()) {
|
|
6
|
-
process.stderr.write(`DEBUG: ${format(...args)}\n`);
|
|
7
|
-
}
|
|
8
|
-
},
|
|
9
|
-
info: (...args) => {
|
|
10
|
-
process.stderr.write(`INFO: ${format(...args)}\n`);
|
|
11
|
-
},
|
|
12
|
-
error: (...args) => {
|
|
13
|
-
process.stderr.write(`ERROR: ${format(...args)}\n`);
|
|
14
|
-
},
|
|
15
|
-
};
|
package/parameters.gen.js
DELETED
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
// FILE IS GENERATED, DO NOT EDIT
|
|
2
|
-
export const projectCreateRequest = {
|
|
3
|
-
'project.settings.quota.active_time_seconds': {
|
|
4
|
-
type: "number",
|
|
5
|
-
description: "The total amount of wall-clock time allowed to be spent by the project's compute endpoints.\n",
|
|
6
|
-
demandOption: false,
|
|
7
|
-
},
|
|
8
|
-
'project.settings.quota.compute_time_seconds': {
|
|
9
|
-
type: "number",
|
|
10
|
-
description: "The total amount of CPU seconds allowed to be spent by the project's compute endpoints.\n",
|
|
11
|
-
demandOption: false,
|
|
12
|
-
},
|
|
13
|
-
'project.settings.quota.written_data_bytes': {
|
|
14
|
-
type: "number",
|
|
15
|
-
description: "Total amount of data written to all of a project's branches.\n",
|
|
16
|
-
demandOption: false,
|
|
17
|
-
},
|
|
18
|
-
'project.settings.quota.data_transfer_bytes': {
|
|
19
|
-
type: "number",
|
|
20
|
-
description: "Total amount of data transferred from all of a project's branches using the proxy.\n",
|
|
21
|
-
demandOption: false,
|
|
22
|
-
},
|
|
23
|
-
'project.settings.quota.logical_size_bytes': {
|
|
24
|
-
type: "number",
|
|
25
|
-
description: "Limit on the logical size of every project's branch.\n",
|
|
26
|
-
demandOption: false,
|
|
27
|
-
},
|
|
28
|
-
'project.settings.allowed_ips.ips': {
|
|
29
|
-
type: "array",
|
|
30
|
-
description: "A list of IP addresses that are allowed to connect to the endpoint.",
|
|
31
|
-
demandOption: true,
|
|
32
|
-
},
|
|
33
|
-
'project.settings.allowed_ips.primary_branch_only': {
|
|
34
|
-
type: "boolean",
|
|
35
|
-
description: "If true, the list will be applied only to the primary branch.",
|
|
36
|
-
demandOption: true,
|
|
37
|
-
},
|
|
38
|
-
'project.name': {
|
|
39
|
-
type: "string",
|
|
40
|
-
description: "The project name",
|
|
41
|
-
demandOption: false,
|
|
42
|
-
},
|
|
43
|
-
'project.branch.name': {
|
|
44
|
-
type: "string",
|
|
45
|
-
description: "The branch name. If not specified, the default branch name will be used.\n",
|
|
46
|
-
demandOption: false,
|
|
47
|
-
},
|
|
48
|
-
'project.branch.role_name': {
|
|
49
|
-
type: "string",
|
|
50
|
-
description: "The role name. If not specified, the default role name will be used.\n",
|
|
51
|
-
demandOption: false,
|
|
52
|
-
},
|
|
53
|
-
'project.branch.database_name': {
|
|
54
|
-
type: "string",
|
|
55
|
-
description: "The database name. If not specified, the default database name will be used.\n",
|
|
56
|
-
demandOption: false,
|
|
57
|
-
},
|
|
58
|
-
'project.provisioner': {
|
|
59
|
-
type: "string",
|
|
60
|
-
description: "The Neon compute provisioner.\nSpecify the `k8s-neonvm` provisioner to create a compute endpoint that supports Autoscaling.\n",
|
|
61
|
-
demandOption: false,
|
|
62
|
-
choices: ["k8s-pod", "k8s-neonvm"],
|
|
63
|
-
},
|
|
64
|
-
'project.region_id': {
|
|
65
|
-
type: "string",
|
|
66
|
-
description: "The region identifier. Refer to our [Regions](https://neon.tech/docs/introduction/regions) documentation for supported regions. Values are specified in this format: `aws-us-east-1`\n",
|
|
67
|
-
demandOption: false,
|
|
68
|
-
},
|
|
69
|
-
'project.default_endpoint_settings.suspend_timeout_seconds': {
|
|
70
|
-
type: "number",
|
|
71
|
-
description: "Duration of inactivity in seconds after which the compute endpoint is\nautomatically suspended. The value `0` means use the global default.\nThe value `-1` means never suspend. The default value is `300` seconds (5 minutes).\nThe maximum value is `604800` seconds (1 week). For more information, see\n[Auto-suspend configuration](https://neon.tech/docs/manage/endpoints#auto-suspend-configuration).\n",
|
|
72
|
-
demandOption: false,
|
|
73
|
-
},
|
|
74
|
-
'project.pg_version': {
|
|
75
|
-
type: "number",
|
|
76
|
-
description: "The major PostgreSQL version number. Currently supported versions are `14`, `15` and `16`.",
|
|
77
|
-
demandOption: false,
|
|
78
|
-
},
|
|
79
|
-
'project.store_passwords': {
|
|
80
|
-
type: "boolean",
|
|
81
|
-
description: "Whether or not passwords are stored for roles in the Neon project. Storing passwords facilitates access to Neon features that require authorization.\n",
|
|
82
|
-
demandOption: false,
|
|
83
|
-
},
|
|
84
|
-
'project.history_retention_seconds': {
|
|
85
|
-
type: "number",
|
|
86
|
-
description: "The number of seconds to retain the point-in-time restore (PITR) backup history for this project.\nThe default is 604800 seconds (7 days).\n",
|
|
87
|
-
demandOption: false,
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
export const projectUpdateRequest = {
|
|
91
|
-
'project.settings.quota.active_time_seconds': {
|
|
92
|
-
type: "number",
|
|
93
|
-
description: "The total amount of wall-clock time allowed to be spent by the project's compute endpoints.\n",
|
|
94
|
-
demandOption: false,
|
|
95
|
-
},
|
|
96
|
-
'project.settings.quota.compute_time_seconds': {
|
|
97
|
-
type: "number",
|
|
98
|
-
description: "The total amount of CPU seconds allowed to be spent by the project's compute endpoints.\n",
|
|
99
|
-
demandOption: false,
|
|
100
|
-
},
|
|
101
|
-
'project.settings.quota.written_data_bytes': {
|
|
102
|
-
type: "number",
|
|
103
|
-
description: "Total amount of data written to all of a project's branches.\n",
|
|
104
|
-
demandOption: false,
|
|
105
|
-
},
|
|
106
|
-
'project.settings.quota.data_transfer_bytes': {
|
|
107
|
-
type: "number",
|
|
108
|
-
description: "Total amount of data transferred from all of a project's branches using the proxy.\n",
|
|
109
|
-
demandOption: false,
|
|
110
|
-
},
|
|
111
|
-
'project.settings.quota.logical_size_bytes': {
|
|
112
|
-
type: "number",
|
|
113
|
-
description: "Limit on the logical size of every project's branch.\n",
|
|
114
|
-
demandOption: false,
|
|
115
|
-
},
|
|
116
|
-
'project.settings.allowed_ips.ips': {
|
|
117
|
-
type: "array",
|
|
118
|
-
description: "A list of IP addresses that are allowed to connect to the endpoint.",
|
|
119
|
-
demandOption: true,
|
|
120
|
-
},
|
|
121
|
-
'project.settings.allowed_ips.primary_branch_only': {
|
|
122
|
-
type: "boolean",
|
|
123
|
-
description: "If true, the list will be applied only to the primary branch.",
|
|
124
|
-
demandOption: true,
|
|
125
|
-
},
|
|
126
|
-
'project.name': {
|
|
127
|
-
type: "string",
|
|
128
|
-
description: "The project name",
|
|
129
|
-
demandOption: false,
|
|
130
|
-
},
|
|
131
|
-
'project.default_endpoint_settings.suspend_timeout_seconds': {
|
|
132
|
-
type: "number",
|
|
133
|
-
description: "Duration of inactivity in seconds after which the compute endpoint is\nautomatically suspended. The value `0` means use the global default.\nThe value `-1` means never suspend. The default value is `300` seconds (5 minutes).\nThe maximum value is `604800` seconds (1 week). For more information, see\n[Auto-suspend configuration](https://neon.tech/docs/manage/endpoints#auto-suspend-configuration).\n",
|
|
134
|
-
demandOption: false,
|
|
135
|
-
},
|
|
136
|
-
'project.history_retention_seconds': {
|
|
137
|
-
type: "number",
|
|
138
|
-
description: "The number of seconds to retain the point-in-time restore (PITR) backup history for this project.\nThe default is 604800 seconds (7 days).\n",
|
|
139
|
-
demandOption: false,
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
export const branchCreateRequest = {
|
|
143
|
-
'endpoints': {
|
|
144
|
-
type: "array",
|
|
145
|
-
description: undefined,
|
|
146
|
-
demandOption: false,
|
|
147
|
-
},
|
|
148
|
-
'branch.parent_id': {
|
|
149
|
-
type: "string",
|
|
150
|
-
description: "The `branch_id` of the parent branch. If omitted or empty, the branch will be created from the project's primary branch.\n",
|
|
151
|
-
demandOption: false,
|
|
152
|
-
},
|
|
153
|
-
'branch.name': {
|
|
154
|
-
type: "string",
|
|
155
|
-
description: "The branch name\n",
|
|
156
|
-
demandOption: false,
|
|
157
|
-
},
|
|
158
|
-
'branch.parent_lsn': {
|
|
159
|
-
type: "string",
|
|
160
|
-
description: "A Log Sequence Number (LSN) on the parent branch. The branch will be created with data from this LSN.\n",
|
|
161
|
-
demandOption: false,
|
|
162
|
-
},
|
|
163
|
-
'branch.parent_timestamp': {
|
|
164
|
-
type: "string",
|
|
165
|
-
description: "A timestamp identifying a point in time on the parent branch. The branch will be created with data starting from this point in time.\n",
|
|
166
|
-
demandOption: false,
|
|
167
|
-
},
|
|
168
|
-
};
|
|
169
|
-
export const branchCreateRequestEndpointOptions = {
|
|
170
|
-
'type': {
|
|
171
|
-
type: "string",
|
|
172
|
-
description: "The compute endpoint type. Either `read_write` or `read_only`.\nThe `read_only` compute endpoint type is not yet supported.\n",
|
|
173
|
-
demandOption: true,
|
|
174
|
-
choices: ["read_only", "read_write"],
|
|
175
|
-
},
|
|
176
|
-
'provisioner': {
|
|
177
|
-
type: "string",
|
|
178
|
-
description: "The Neon compute provisioner.\nSpecify the `k8s-neonvm` provisioner to create a compute endpoint that supports Autoscaling.\n",
|
|
179
|
-
demandOption: false,
|
|
180
|
-
choices: ["k8s-pod", "k8s-neonvm"],
|
|
181
|
-
},
|
|
182
|
-
'suspend_timeout_seconds': {
|
|
183
|
-
type: "number",
|
|
184
|
-
description: "Duration of inactivity in seconds after which the compute endpoint is\nautomatically suspended. The value `0` means use the global default.\nThe value `-1` means never suspend. The default value is `300` seconds (5 minutes).\nThe maximum value is `604800` seconds (1 week). For more information, see\n[Auto-suspend configuration](https://neon.tech/docs/manage/endpoints#auto-suspend-configuration).\n",
|
|
185
|
-
demandOption: false,
|
|
186
|
-
},
|
|
187
|
-
};
|
|
188
|
-
export const branchUpdateRequest = {
|
|
189
|
-
'branch.name': {
|
|
190
|
-
type: "string",
|
|
191
|
-
description: undefined,
|
|
192
|
-
demandOption: false,
|
|
193
|
-
},
|
|
194
|
-
};
|
|
195
|
-
export const endpointCreateRequest = {
|
|
196
|
-
'endpoint.branch_id': {
|
|
197
|
-
type: "string",
|
|
198
|
-
description: "The ID of the branch the compute endpoint will be associated with\n",
|
|
199
|
-
demandOption: true,
|
|
200
|
-
},
|
|
201
|
-
'endpoint.region_id': {
|
|
202
|
-
type: "string",
|
|
203
|
-
description: "The region where the compute endpoint will be created. Only the project's `region_id` is permitted.\n",
|
|
204
|
-
demandOption: false,
|
|
205
|
-
},
|
|
206
|
-
'endpoint.type': {
|
|
207
|
-
type: "string",
|
|
208
|
-
description: "The compute endpoint type. Either `read_write` or `read_only`.\nThe `read_only` compute endpoint type is not yet supported.\n",
|
|
209
|
-
demandOption: true,
|
|
210
|
-
choices: ["read_only", "read_write"],
|
|
211
|
-
},
|
|
212
|
-
'endpoint.provisioner': {
|
|
213
|
-
type: "string",
|
|
214
|
-
description: "The Neon compute provisioner.\nSpecify the `k8s-neonvm` provisioner to create a compute endpoint that supports Autoscaling.\n",
|
|
215
|
-
demandOption: false,
|
|
216
|
-
choices: ["k8s-pod", "k8s-neonvm"],
|
|
217
|
-
},
|
|
218
|
-
'endpoint.pooler_enabled': {
|
|
219
|
-
type: "boolean",
|
|
220
|
-
description: "Whether to enable connection pooling for the compute endpoint\n",
|
|
221
|
-
demandOption: false,
|
|
222
|
-
},
|
|
223
|
-
'endpoint.pooler_mode': {
|
|
224
|
-
type: "string",
|
|
225
|
-
description: "The connection pooler mode. Neon supports PgBouncer in `transaction` mode only.\n",
|
|
226
|
-
demandOption: false,
|
|
227
|
-
choices: ["transaction"],
|
|
228
|
-
},
|
|
229
|
-
'endpoint.disabled': {
|
|
230
|
-
type: "boolean",
|
|
231
|
-
description: "Whether to restrict connections to the compute endpoint.\nEnabling this option schedules a suspend compute operation.\nA disabled compute endpoint cannot be enabled by a connection or\nconsole action. However, the compute endpoint is periodically\nenabled by check_availability operations.\n",
|
|
232
|
-
demandOption: false,
|
|
233
|
-
},
|
|
234
|
-
'endpoint.passwordless_access': {
|
|
235
|
-
type: "boolean",
|
|
236
|
-
description: "NOT YET IMPLEMENTED. Whether to permit passwordless access to the compute endpoint.\n",
|
|
237
|
-
demandOption: false,
|
|
238
|
-
},
|
|
239
|
-
'endpoint.suspend_timeout_seconds': {
|
|
240
|
-
type: "number",
|
|
241
|
-
description: "Duration of inactivity in seconds after which the compute endpoint is\nautomatically suspended. The value `0` means use the global default.\nThe value `-1` means never suspend. The default value is `300` seconds (5 minutes).\nThe maximum value is `604800` seconds (1 week). For more information, see\n[Auto-suspend configuration](https://neon.tech/docs/manage/endpoints#auto-suspend-configuration).\n",
|
|
242
|
-
demandOption: false,
|
|
243
|
-
},
|
|
244
|
-
};
|
|
245
|
-
export const endpointUpdateRequest = {
|
|
246
|
-
'endpoint.branch_id': {
|
|
247
|
-
type: "string",
|
|
248
|
-
description: "The destination branch ID. The destination branch must not have an exsiting read-write endpoint.\n",
|
|
249
|
-
demandOption: false,
|
|
250
|
-
},
|
|
251
|
-
'endpoint.provisioner': {
|
|
252
|
-
type: "string",
|
|
253
|
-
description: "The Neon compute provisioner.\nSpecify the `k8s-neonvm` provisioner to create a compute endpoint that supports Autoscaling.\n",
|
|
254
|
-
demandOption: false,
|
|
255
|
-
choices: ["k8s-pod", "k8s-neonvm"],
|
|
256
|
-
},
|
|
257
|
-
'endpoint.pooler_enabled': {
|
|
258
|
-
type: "boolean",
|
|
259
|
-
description: "Whether to enable connection pooling for the compute endpoint\n",
|
|
260
|
-
demandOption: false,
|
|
261
|
-
},
|
|
262
|
-
'endpoint.pooler_mode': {
|
|
263
|
-
type: "string",
|
|
264
|
-
description: "The connection pooler mode. Neon supports PgBouncer in `transaction` mode only.\n",
|
|
265
|
-
demandOption: false,
|
|
266
|
-
choices: ["transaction"],
|
|
267
|
-
},
|
|
268
|
-
'endpoint.disabled': {
|
|
269
|
-
type: "boolean",
|
|
270
|
-
description: "Whether to restrict connections to the compute endpoint.\nEnabling this option schedules a suspend compute operation.\nA disabled compute endpoint cannot be enabled by a connection or\nconsole action. However, the compute endpoint is periodically\nenabled by check_availability operations.\n",
|
|
271
|
-
demandOption: false,
|
|
272
|
-
},
|
|
273
|
-
'endpoint.passwordless_access': {
|
|
274
|
-
type: "boolean",
|
|
275
|
-
description: "NOT YET IMPLEMENTED. Whether to permit passwordless access to the compute endpoint.\n",
|
|
276
|
-
demandOption: false,
|
|
277
|
-
},
|
|
278
|
-
'endpoint.suspend_timeout_seconds': {
|
|
279
|
-
type: "number",
|
|
280
|
-
description: "Duration of inactivity in seconds after which the compute endpoint is\nautomatically suspended. The value `0` means use the global default.\nThe value `-1` means never suspend. The default value is `300` seconds (5 minutes).\nThe maximum value is `604800` seconds (1 week). For more information, see\n[Auto-suspend configuration](https://neon.tech/docs/manage/endpoints#auto-suspend-configuration).\n",
|
|
281
|
-
demandOption: false,
|
|
282
|
-
},
|
|
283
|
-
};
|
|
284
|
-
export const databaseCreateRequest = {
|
|
285
|
-
'database.name': {
|
|
286
|
-
type: "string",
|
|
287
|
-
description: "The name of the datbase\n",
|
|
288
|
-
demandOption: true,
|
|
289
|
-
},
|
|
290
|
-
'database.owner_name': {
|
|
291
|
-
type: "string",
|
|
292
|
-
description: "The name of the role that owns the database\n",
|
|
293
|
-
demandOption: true,
|
|
294
|
-
},
|
|
295
|
-
};
|
|
296
|
-
export const roleCreateRequest = {
|
|
297
|
-
'role.name': {
|
|
298
|
-
type: "string",
|
|
299
|
-
description: "The role name. Cannot exceed 63 bytes in length.\n",
|
|
300
|
-
demandOption: true,
|
|
301
|
-
},
|
|
302
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import emocks from 'emocks';
|
|
2
|
-
import express from 'express';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { log } from '../log';
|
|
5
|
-
export const runMockServer = async (mockDir) => new Promise((resolve) => {
|
|
6
|
-
const app = express();
|
|
7
|
-
app.use(express.json());
|
|
8
|
-
app.use('/', emocks(join(process.cwd(), 'mocks', mockDir), {
|
|
9
|
-
'404': (req, res) => res.status(404).send({ message: 'Not Found' }),
|
|
10
|
-
}));
|
|
11
|
-
const server = app.listen(0);
|
|
12
|
-
server.on('listening', () => {
|
|
13
|
-
resolve(server);
|
|
14
|
-
log.info('Mock server listening at %d', server.address().port);
|
|
15
|
-
});
|
|
16
|
-
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { log } from '../log';
|
|
2
|
-
import { OAuth2Server } from 'oauth2-mock-server';
|
|
3
|
-
export const startOauthServer = async () => {
|
|
4
|
-
const server = new OAuth2Server();
|
|
5
|
-
await server.issuer.keys.generate('RS256');
|
|
6
|
-
await server.start(0, 'localhost');
|
|
7
|
-
log.info('Started OAuth server');
|
|
8
|
-
return server;
|
|
9
|
-
};
|