neonctl 2.5.0 → 2.6.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 +10 -9
- package/commands/branches.js +5 -0
- package/commands/projects.js +4 -0
- package/index.js +6 -1
- package/package.json +1 -1
- package/utils/enrichers.js +6 -2
package/analytics.js
CHANGED
|
@@ -48,15 +48,7 @@ export const analyticsMiddleware = async (args) => {
|
|
|
48
48
|
client.track({
|
|
49
49
|
userId: userId ?? 'anonymous',
|
|
50
50
|
event: 'CLI Started',
|
|
51
|
-
properties:
|
|
52
|
-
version: pkg.version,
|
|
53
|
-
command: args._.join(' '),
|
|
54
|
-
flags: {
|
|
55
|
-
output: args.output,
|
|
56
|
-
},
|
|
57
|
-
ci: isCi(),
|
|
58
|
-
githubEnvVars: getGithubEnvVars(process.env),
|
|
59
|
-
},
|
|
51
|
+
properties: getAnalyticsEventProperties(args),
|
|
60
52
|
context: {
|
|
61
53
|
direct: true,
|
|
62
54
|
},
|
|
@@ -97,3 +89,12 @@ export const trackEvent = (event, properties) => {
|
|
|
97
89
|
});
|
|
98
90
|
log.debug('Sent CLI event: %s', event);
|
|
99
91
|
};
|
|
92
|
+
export const getAnalyticsEventProperties = (args) => ({
|
|
93
|
+
version: pkg.version,
|
|
94
|
+
command: args._.join(' '),
|
|
95
|
+
flags: {
|
|
96
|
+
output: args.output,
|
|
97
|
+
},
|
|
98
|
+
ci: isCi(),
|
|
99
|
+
githubEnvVars: getGithubEnvVars(process.env),
|
|
100
|
+
});
|
package/commands/branches.js
CHANGED
|
@@ -36,6 +36,10 @@ export const builder = (argv) => argv
|
|
|
36
36
|
},
|
|
37
37
|
})
|
|
38
38
|
.middleware(fillSingleProject)
|
|
39
|
+
.middleware((args) => {
|
|
40
|
+
// Provide alias for analytics
|
|
41
|
+
args.branchId ?? (args.branchId = args.id);
|
|
42
|
+
})
|
|
39
43
|
.command('list', 'List branches', (yargs) => yargs, (args) => list(args))
|
|
40
44
|
.command('create', 'Create a branch', (yargs) => yargs.options({
|
|
41
45
|
name: branchCreateRequest['branch.name'],
|
|
@@ -94,6 +98,7 @@ export const builder = (argv) => argv
|
|
|
94
98
|
.middleware((args) => {
|
|
95
99
|
args.id = args.targetId;
|
|
96
100
|
args.pointInTime = args['source@(timestamp'];
|
|
101
|
+
args.branchId = args.id; // for analytics
|
|
97
102
|
})
|
|
98
103
|
.usage('$0 branches restore <target-id|name> <source>[@(timestamp|lsn)]')
|
|
99
104
|
.options({
|
package/commands/projects.js
CHANGED
|
@@ -26,6 +26,10 @@ export const aliases = ['project'];
|
|
|
26
26
|
export const builder = (argv) => {
|
|
27
27
|
return argv
|
|
28
28
|
.usage('$0 projects <sub-command> [options]')
|
|
29
|
+
.middleware((args) => {
|
|
30
|
+
// Provide alias for analytics
|
|
31
|
+
args.projectId = args.id;
|
|
32
|
+
})
|
|
29
33
|
.command('list', 'List projects', (yargs) => yargs.options({
|
|
30
34
|
'org-id': {
|
|
31
35
|
describe: 'List projects of a given organization',
|
package/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import { defaultClientID } from './auth.js';
|
|
|
20
20
|
import { fillInArgs } from './utils/middlewares.js';
|
|
21
21
|
import pkg from './pkg.js';
|
|
22
22
|
import commands from './commands/index.js';
|
|
23
|
-
import { analyticsMiddleware, closeAnalytics, sendError } from './analytics.js';
|
|
23
|
+
import { analyticsMiddleware, closeAnalytics, getAnalyticsEventProperties, sendError, trackEvent, } from './analytics.js';
|
|
24
24
|
import { isAxiosError } from 'axios';
|
|
25
25
|
import { matchErrorCode } from './errors.js';
|
|
26
26
|
import { showHelp } from './help.js';
|
|
@@ -180,6 +180,11 @@ builder = builder
|
|
|
180
180
|
void (async () => {
|
|
181
181
|
try {
|
|
182
182
|
const args = await builder.argv;
|
|
183
|
+
trackEvent('cli_command_success', {
|
|
184
|
+
...getAnalyticsEventProperties(args),
|
|
185
|
+
projectId: args.projectId,
|
|
186
|
+
branchId: args.branchId,
|
|
187
|
+
});
|
|
183
188
|
if (args._.length === 0 || args.help) {
|
|
184
189
|
await showHelp(builder);
|
|
185
190
|
process.exit(0);
|
package/package.json
CHANGED
package/utils/enrichers.js
CHANGED
|
@@ -15,7 +15,7 @@ export const branchIdResolve = async ({ branch, apiClient, projectId, }) => {
|
|
|
15
15
|
}
|
|
16
16
|
return branchData.id;
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
const getBranchIdFromProps = async (props) => {
|
|
19
19
|
const branch = 'branch' in props && typeof props.branch === 'string'
|
|
20
20
|
? props.branch
|
|
21
21
|
: props.id;
|
|
@@ -35,11 +35,15 @@ export const branchIdFromProps = async (props) => {
|
|
|
35
35
|
}
|
|
36
36
|
throw new Error('No default branch found');
|
|
37
37
|
};
|
|
38
|
+
export const branchIdFromProps = async (props) => {
|
|
39
|
+
props.branchId = await getBranchIdFromProps(props);
|
|
40
|
+
return props.branchId;
|
|
41
|
+
};
|
|
38
42
|
export const fillSingleProject = async (props) => {
|
|
39
43
|
if (props.projectId) {
|
|
40
44
|
return props;
|
|
41
45
|
}
|
|
42
|
-
const { data } = await props.apiClient.listProjects({});
|
|
46
|
+
const { data } = await props.apiClient.listProjects({ limit: 2 });
|
|
43
47
|
if (data.projects.length === 0) {
|
|
44
48
|
throw new Error('No projects found');
|
|
45
49
|
}
|