neonctl 2.0.0 → 2.2.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/analytics.js CHANGED
@@ -3,7 +3,7 @@ import { join } from 'node:path';
3
3
  import { Analytics } from '@segment/analytics-node';
4
4
  import { isAxiosError } from 'axios';
5
5
  import { CREDENTIALS_FILE } from './config.js';
6
- import { isCi } from './env.js';
6
+ import { getGithubEnvVars, isCi } from './env.js';
7
7
  import { log } from './log.js';
8
8
  import pkg from './pkg.js';
9
9
  import { getApiClient } from './api.js';
@@ -55,6 +55,7 @@ export const analyticsMiddleware = async (args) => {
55
55
  output: args.output,
56
56
  },
57
57
  ci: isCi(),
58
+ githubEnvVars: getGithubEnvVars(process.env),
58
59
  },
59
60
  });
60
61
  };
package/env.js CHANGED
@@ -4,3 +4,33 @@ export const isCi = () => {
4
4
  export const isDebug = () => {
5
5
  return Boolean(process.env.DEBUG);
6
6
  };
7
+ export const getGithubEnvVars = (env) => {
8
+ const vars = [
9
+ // github action info
10
+ 'GITHUB_ACTION_PATH',
11
+ // source github repository
12
+ 'GITHUB_REPOSITORY',
13
+ // environment info
14
+ 'GITHUB_RUN_ID',
15
+ 'GITHUB_RUN_NUMBER',
16
+ 'GITHUB_SERVER_URL',
17
+ 'GITHUB_WORKFLOW_REF',
18
+ 'RUNNER_ARCH',
19
+ 'RUNNER_ENVIRONMENT',
20
+ 'RUNNER_OS',
21
+ ];
22
+ const map = new Map();
23
+ vars.forEach((v) => {
24
+ let value = env[v];
25
+ if (value === undefined || value === '') {
26
+ return;
27
+ }
28
+ if (v === 'GITHUB_ACTION_PATH') {
29
+ value = value.includes('actions/')
30
+ ? value.replace(/^.*actions\/(.+)$/, '$1')
31
+ : value;
32
+ }
33
+ map.set(v, value);
34
+ });
35
+ return Object.fromEntries(map);
36
+ };
package/env.test.js ADDED
@@ -0,0 +1,55 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { getGithubEnvVars } from './env';
3
+ describe('getGithubEnvVars', () => {
4
+ it('success all keys', () => {
5
+ const env = {
6
+ GITHUB_ACTION_PATH: '1',
7
+ GITHUB_REPOSITORY: '2',
8
+ GITHUB_RUN_ID: '3',
9
+ GITHUB_RUN_NUMBER: '4',
10
+ GITHUB_SERVER_URL: '5',
11
+ GITHUB_WORKFLOW_REF: '6',
12
+ RUNNER_ARCH: '7',
13
+ RUNNER_ENVIRONMENT: '8',
14
+ RUNNER_OS: '9',
15
+ unrelated: 'unrelated',
16
+ };
17
+ const ret = {
18
+ GITHUB_ACTION_PATH: '1',
19
+ GITHUB_REPOSITORY: '2',
20
+ GITHUB_RUN_ID: '3',
21
+ GITHUB_RUN_NUMBER: '4',
22
+ GITHUB_SERVER_URL: '5',
23
+ GITHUB_WORKFLOW_REF: '6',
24
+ RUNNER_ARCH: '7',
25
+ RUNNER_ENVIRONMENT: '8',
26
+ RUNNER_OS: '9',
27
+ };
28
+ expect(getGithubEnvVars(env)).toEqual(ret);
29
+ });
30
+ it('empty all keys', () => {
31
+ expect(getGithubEnvVars({})).toEqual({});
32
+ });
33
+ it('action path', () => {
34
+ expect(getGithubEnvVars({
35
+ GITHUB_ACTION_PATH: '/home/runner/work/_actions/neondatabase/create-branch-action/v5',
36
+ })).toEqual({
37
+ GITHUB_ACTION_PATH: 'neondatabase/create-branch-action/v5',
38
+ });
39
+ expect(getGithubEnvVars({
40
+ GITHUB_ACTION_PATH: '/home/runner/actions-runner/_work/actions/neondatabase/create-branch-action/v5',
41
+ })).toEqual({
42
+ GITHUB_ACTION_PATH: 'neondatabase/create-branch-action/v5',
43
+ });
44
+ expect(getGithubEnvVars({
45
+ GITHUB_ACTION_PATH: 'C:\\b\\_actions\\neondatabase\\create-branch-action\\v5',
46
+ })).toEqual({
47
+ GITHUB_ACTION_PATH: 'C:\\b\\_actions\\neondatabase\\create-branch-action\\v5',
48
+ });
49
+ expect(getGithubEnvVars({
50
+ GITHUB_ACTION_PATH: '/home/runner/work/app/app/./.github/actions/custom-action',
51
+ })).toEqual({
52
+ GITHUB_ACTION_PATH: 'custom-action',
53
+ });
54
+ });
55
+ });
package/index.js CHANGED
@@ -28,6 +28,7 @@ import { currentContextFile, enrichFromContext } from './context.js';
28
28
  const NO_SUBCOMMANDS_VERBS = [
29
29
  // aliases
30
30
  'auth',
31
+ 'login',
31
32
  'me',
32
33
  // aliases
33
34
  'cs',
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.0.0",
8
+ "version": "2.2.0",
9
9
  "description": "CLI tool for NeonDB Cloud management",
10
10
  "main": "index.js",
11
11
  "author": "NeonDB",