neonctl 2.15.1 → 2.16.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.
package/commands/index.js CHANGED
@@ -10,6 +10,7 @@ import * as roles from './roles.js';
10
10
  import * as operations from './operations.js';
11
11
  import * as cs from './connection_string.js';
12
12
  import * as setContext from './set_context.js';
13
+ import * as init from './init.js';
13
14
  export default [
14
15
  auth,
15
16
  users,
@@ -23,4 +24,5 @@ export default [
23
24
  operations,
24
25
  cs,
25
26
  setContext,
27
+ init,
26
28
  ];
@@ -0,0 +1,44 @@
1
+ import { execa } from 'execa';
2
+ import { log } from '../log.js';
3
+ import { sendError } from '../analytics.js';
4
+ export const command = 'init';
5
+ export const describe = 'Initialize a new Neon project using your AI coding assistant';
6
+ export const builder = (yargs) => yargs
7
+ .option('context-file', {
8
+ hidden: true,
9
+ })
10
+ .strict(false);
11
+ export const handler = async (args) => {
12
+ const passThruArgs = args['--'] || [];
13
+ await runNeonInit(passThruArgs);
14
+ };
15
+ const runNeonInit = async (args) => {
16
+ try {
17
+ await execa('npx', ['neon-init', ...args], {
18
+ stdio: 'inherit',
19
+ });
20
+ }
21
+ catch (error) {
22
+ // Check if it's an ENOENT error (command not found)
23
+ if (error?.code === 'ENOENT') {
24
+ log.error('npx is not available in the PATH');
25
+ sendError(error, 'NPX_NOT_FOUND');
26
+ process.exit(1);
27
+ }
28
+ // Check if the process was killed by a signal (user cancelled)
29
+ else if (error?.signal) {
30
+ process.exit(1);
31
+ }
32
+ // Handle all other errors
33
+ else {
34
+ const exitError = new Error(`failed to run neon-init`);
35
+ sendError(exitError, 'NEON_INIT_FAILED');
36
+ if (typeof error?.exitCode === 'number') {
37
+ process.exit(error.exitCode);
38
+ }
39
+ else {
40
+ process.exit(1);
41
+ }
42
+ }
43
+ }
44
+ };
@@ -0,0 +1,10 @@
1
+ import { describe } from 'vitest';
2
+ import { test } from '../test_utils/fixtures';
3
+ describe('init', () => {
4
+ test('init should run neon-init', async ({ testCliCommand }) => {
5
+ await testCliCommand(['init']);
6
+ });
7
+ test('init with an argument', async ({ testCliCommand }) => {
8
+ await testCliCommand(['init', '--', '--debug']);
9
+ });
10
+ });
package/index.js CHANGED
@@ -34,6 +34,7 @@ const NO_SUBCOMMANDS_VERBS = [
34
34
  'cs',
35
35
  'connection-string',
36
36
  'set-context',
37
+ 'init',
37
38
  // aliases
38
39
  ];
39
40
  let builder = yargs(hideBin(process.argv));
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "url": "git+ssh://git@github.com/neondatabase/neonctl.git"
6
6
  },
7
7
  "type": "module",
8
- "version": "2.15.1",
8
+ "version": "2.16.0",
9
9
  "description": "CLI tool for NeonDB Cloud management",
10
10
  "main": "index.js",
11
11
  "author": "NeonDB",
@@ -62,6 +62,7 @@
62
62
  "cli-table": "^0.3.11",
63
63
  "crypto-random-string": "^5.0.0",
64
64
  "diff": "^5.2.0",
65
+ "execa": "^9.6.0",
65
66
  "open": "^10.1.0",
66
67
  "openid-client": "^6.8.1",
67
68
  "prompts": "2.4.2",