@mondaydotcomorg/z2h-cli 0.7.0 → 0.7.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.
@@ -12,7 +12,7 @@ import { createWorkspaceCommand } from './commands/create-workspace.mjs';
12
12
  import { createCommand } from './commands/create.mjs';
13
13
  import { generateZ2HTokenCommand } from './commands/generate-z2h-token.mjs';
14
14
  import { migrateCommand } from './commands/migrate.mjs';
15
- import { errorLog, fail, getOutputMode } from './util/logger.mjs';
15
+ import { fail, errorLog, getOutputMode } from './util/logger.mjs';
16
16
  import { trackDuration } from './util/tracker.mjs';
17
17
 
18
18
  const { version } = createRequire(import.meta.url)('../package.json');
@@ -59,7 +59,7 @@ async function main() {
59
59
  await trackDuration('z2h_app_build_success', () => buildCommand(opts), { app_name: getCwdAppName() });
60
60
  }
61
61
  catch (err) {
62
- fail(`build failed: ${err.message}`, { command: 'build' }, 2);
62
+ await fail(`build failed: ${err.message}`, { command: 'build' }, 2);
63
63
  }
64
64
  });
65
65
  program
@@ -71,7 +71,7 @@ async function main() {
71
71
  await devCommand(opts);
72
72
  }
73
73
  catch (err) {
74
- fail(`dev failed: ${err.message}`, { command: 'dev' }, 2);
74
+ await fail(`dev failed: ${err.message}`, { command: 'dev' }, 2);
75
75
  }
76
76
  });
77
77
  program
@@ -83,7 +83,7 @@ async function main() {
83
83
  await cleanCommand(opts);
84
84
  }
85
85
  catch (err) {
86
- fail(`clean failed: ${err.message}`, { command: 'clean' }, 2);
86
+ await fail(`clean failed: ${err.message}`, { command: 'clean' }, 2);
87
87
  }
88
88
  });
89
89
  program
@@ -98,7 +98,7 @@ async function main() {
98
98
  });
99
99
  }
100
100
  catch (err) {
101
- fail(`deploy failed: ${err.message}`, { command: 'deploy' }, 2);
101
+ await fail(`deploy failed: ${err.message}`, { command: 'deploy' }, 2);
102
102
  }
103
103
  });
104
104
  program
@@ -110,7 +110,7 @@ async function main() {
110
110
  await createWorkspaceCommand(opts);
111
111
  }
112
112
  catch (err) {
113
- fail(`create-workspace failed: ${err.message}`, { command: 'create-workspace' }, 1);
113
+ await fail(`create-workspace failed: ${err.message}`, { command: 'create-workspace' }, 1);
114
114
  }
115
115
  });
116
116
  program
@@ -124,7 +124,7 @@ async function main() {
124
124
  await generateZ2HTokenCommand(opts);
125
125
  }
126
126
  catch (err) {
127
- fail(`generate-z2h-token failed: ${err.message}`, { command: 'generate-z2h-token' }, 1);
127
+ await fail(`generate-z2h-token failed: ${err.message}`, { command: 'generate-z2h-token' }, 1);
128
128
  }
129
129
  });
130
130
  program
@@ -141,7 +141,7 @@ async function main() {
141
141
  });
142
142
  }
143
143
  catch (err) {
144
- fail(`create failed: ${err.message}`, { command: 'create' }, 1);
144
+ await fail(`create failed: ${err.message}`, { command: 'create' }, 1);
145
145
  }
146
146
  });
147
147
  program
@@ -154,7 +154,7 @@ async function main() {
154
154
  await migrateCommand(version, opts);
155
155
  }
156
156
  catch (err) {
157
- fail(`migrate failed: ${err.message}`, { command: 'migrate' }, 1);
157
+ await fail(`migrate failed: ${err.message}`, { command: 'migrate' }, 1);
158
158
  }
159
159
  });
160
160
  await program.parseAsync(process.argv);
@@ -168,7 +168,6 @@ void main()
168
168
  }
169
169
  process.exit(0);
170
170
  })
171
- .catch((err) => {
172
- errorLog(`main failed: ${err.message}`);
173
- process.exit(1);
171
+ .catch(async (err) => {
172
+ await fail(`main failed: ${err.message}`, { command: 'cli-main' });
174
173
  });
@@ -18,5 +18,5 @@ export declare function output(human: string, data: unknown): void;
18
18
  * Emit a structured failure payload (JSON mode) or a red error line (human mode),
19
19
  * then exit with the given code.
20
20
  */
21
- export declare function fail(message: string, payload: Record<string, unknown>, exitCode?: number): never;
21
+ export declare function fail(message: string, payload: Record<string, unknown>, exitCode?: number): Promise<never>;
22
22
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/util/logger.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAI1C,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAEpD;AAED,wBAAgB,aAAa,IAAI,UAAU,CAE1C;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAItC;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAItC;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAI1C;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAMzD;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,SAAI,GAAG,KAAK,CAW3F"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/util/logger.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAI1C,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAEpD;AAED,wBAAgB,aAAa,IAAI,UAAU,CAE1C;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAItC;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAItC;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAI1C;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAMzD;AAED;;;GAGG;AACH,wBAAsB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,SAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAW1G"}
@@ -44,7 +44,7 @@ function output(human, data) {
44
44
  * Emit a structured failure payload (JSON mode) or a red error line (human mode),
45
45
  * then exit with the given code.
46
46
  */
47
- function fail(message, payload, exitCode = 1) {
47
+ async function fail(message, payload, exitCode = 1) {
48
48
  if (mode === 'json') {
49
49
  process.stdout.write(`${JSON.stringify({ ok: false, error: message, ...payload })}\n`);
50
50
  }
@@ -54,7 +54,7 @@ function fail(message, payload, exitCode = 1) {
54
54
  process.stderr.write(pc.dim(` → ${payload.suggestedCommand}\n`));
55
55
  }
56
56
  }
57
- trackEvent('z2h_cli_error', { action: payload.command ?? 'unknown', error: message });
57
+ await trackEvent('z2h_cli_error', { action: payload.command ?? 'unknown', error: message });
58
58
  process.exit(exitCode);
59
59
  }
60
60
 
@@ -1,3 +1,3 @@
1
- export declare function trackEvent(name: string, data: Record<string, unknown>): void;
1
+ export declare function trackEvent(name: string, data: Record<string, unknown>): Promise<void>;
2
2
  export declare function trackDuration<T>(eventName: string, fn: () => Promise<T>, data?: Record<string, unknown>): Promise<T>;
3
3
  //# sourceMappingURL=tracker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tracker.d.ts","sourceRoot":"","sources":["../../../src/util/tracker.ts"],"names":[],"mappings":"AAMA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAO5E;AAED,wBAAsB,aAAa,CAAC,CAAC,EACnC,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC,CAAC,CAAC,CAKZ"}
1
+ {"version":3,"file":"tracker.d.ts","sourceRoot":"","sources":["../../../src/util/tracker.ts"],"names":[],"mappings":"AAMA,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAO3F;AAED,wBAAsB,aAAa,CAAC,CAAC,EACnC,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC,CAAC,CAAC,CAKZ"}
@@ -1,19 +1,19 @@
1
1
  import os from 'node:os';
2
2
 
3
- const DOORMAN_URL = 'https://track.bigbrain.me/prod/event';
3
+ const DOORMAN_URL = 'https://track-int.bigbrain.me/prod/event';
4
4
  const username = os.userInfo().username;
5
- function trackEvent(name, data) {
6
- void fetch(DOORMAN_URL, {
5
+ async function trackEvent(name, data) {
6
+ await fetch(DOORMAN_URL, {
7
7
  method: 'POST',
8
8
  headers: { 'Content-Type': 'application/json' },
9
- body: JSON.stringify({ name, source: 'z2h-cli', data: { username, ...data } }),
9
+ body: JSON.stringify({ name, source: 'z2h-cli', data: { user_name: username, ...data } }),
10
10
  signal: AbortSignal.timeout(5000),
11
11
  }).catch(() => { });
12
12
  }
13
13
  async function trackDuration(eventName, fn, data) {
14
14
  const start = Date.now();
15
15
  const result = await fn();
16
- trackEvent(eventName, { ...data, duration_ms: Date.now() - start });
16
+ await trackEvent(eventName, { ...data, duration_ms: Date.now() - start });
17
17
  return result;
18
18
  }
19
19
 
package/dist/index.js CHANGED
@@ -65,7 +65,7 @@ async function main() {
65
65
  await util_tracker.trackDuration('z2h_app_build_success', () => commands_build.buildCommand(opts), { app_name: getCwdAppName() });
66
66
  }
67
67
  catch (err) {
68
- util_logger.fail(`build failed: ${err.message}`, { command: 'build' }, 2);
68
+ await util_logger.fail(`build failed: ${err.message}`, { command: 'build' }, 2);
69
69
  }
70
70
  });
71
71
  program
@@ -77,7 +77,7 @@ async function main() {
77
77
  await commands_dev.devCommand(opts);
78
78
  }
79
79
  catch (err) {
80
- util_logger.fail(`dev failed: ${err.message}`, { command: 'dev' }, 2);
80
+ await util_logger.fail(`dev failed: ${err.message}`, { command: 'dev' }, 2);
81
81
  }
82
82
  });
83
83
  program
@@ -89,7 +89,7 @@ async function main() {
89
89
  await commands_clean.cleanCommand(opts);
90
90
  }
91
91
  catch (err) {
92
- util_logger.fail(`clean failed: ${err.message}`, { command: 'clean' }, 2);
92
+ await util_logger.fail(`clean failed: ${err.message}`, { command: 'clean' }, 2);
93
93
  }
94
94
  });
95
95
  program
@@ -104,7 +104,7 @@ async function main() {
104
104
  });
105
105
  }
106
106
  catch (err) {
107
- util_logger.fail(`deploy failed: ${err.message}`, { command: 'deploy' }, 2);
107
+ await util_logger.fail(`deploy failed: ${err.message}`, { command: 'deploy' }, 2);
108
108
  }
109
109
  });
110
110
  program
@@ -116,7 +116,7 @@ async function main() {
116
116
  await commands_createWorkspace.createWorkspaceCommand(opts);
117
117
  }
118
118
  catch (err) {
119
- util_logger.fail(`create-workspace failed: ${err.message}`, { command: 'create-workspace' }, 1);
119
+ await util_logger.fail(`create-workspace failed: ${err.message}`, { command: 'create-workspace' }, 1);
120
120
  }
121
121
  });
122
122
  program
@@ -130,7 +130,7 @@ async function main() {
130
130
  await commands_generateZ2hToken.generateZ2HTokenCommand(opts);
131
131
  }
132
132
  catch (err) {
133
- util_logger.fail(`generate-z2h-token failed: ${err.message}`, { command: 'generate-z2h-token' }, 1);
133
+ await util_logger.fail(`generate-z2h-token failed: ${err.message}`, { command: 'generate-z2h-token' }, 1);
134
134
  }
135
135
  });
136
136
  program
@@ -147,7 +147,7 @@ async function main() {
147
147
  });
148
148
  }
149
149
  catch (err) {
150
- util_logger.fail(`create failed: ${err.message}`, { command: 'create' }, 1);
150
+ await util_logger.fail(`create failed: ${err.message}`, { command: 'create' }, 1);
151
151
  }
152
152
  });
153
153
  program
@@ -160,7 +160,7 @@ async function main() {
160
160
  await commands_migrate.migrateCommand(version, opts);
161
161
  }
162
162
  catch (err) {
163
- util_logger.fail(`migrate failed: ${err.message}`, { command: 'migrate' }, 1);
163
+ await util_logger.fail(`migrate failed: ${err.message}`, { command: 'migrate' }, 1);
164
164
  }
165
165
  });
166
166
  await program.parseAsync(process.argv);
@@ -174,7 +174,6 @@ void main()
174
174
  }
175
175
  process.exit(0);
176
176
  })
177
- .catch((err) => {
178
- util_logger.errorLog(`main failed: ${err.message}`);
179
- process.exit(1);
177
+ .catch(async (err) => {
178
+ await util_logger.fail(`main failed: ${err.message}`, { command: 'cli-main' });
180
179
  });
@@ -18,5 +18,5 @@ export declare function output(human: string, data: unknown): void;
18
18
  * Emit a structured failure payload (JSON mode) or a red error line (human mode),
19
19
  * then exit with the given code.
20
20
  */
21
- export declare function fail(message: string, payload: Record<string, unknown>, exitCode?: number): never;
21
+ export declare function fail(message: string, payload: Record<string, unknown>, exitCode?: number): Promise<never>;
22
22
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/util/logger.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAI1C,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAEpD;AAED,wBAAgB,aAAa,IAAI,UAAU,CAE1C;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAItC;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAItC;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAI1C;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAMzD;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,SAAI,GAAG,KAAK,CAW3F"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/util/logger.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAI1C,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAEpD;AAED,wBAAgB,aAAa,IAAI,UAAU,CAE1C;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAItC;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAItC;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAI1C;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAMzD;AAED;;;GAGG;AACH,wBAAsB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,SAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAW1G"}
@@ -50,7 +50,7 @@ function output(human, data) {
50
50
  * Emit a structured failure payload (JSON mode) or a red error line (human mode),
51
51
  * then exit with the given code.
52
52
  */
53
- function fail(message, payload, exitCode = 1) {
53
+ async function fail(message, payload, exitCode = 1) {
54
54
  if (mode === 'json') {
55
55
  process.stdout.write(`${JSON.stringify({ ok: false, error: message, ...payload })}\n`);
56
56
  }
@@ -60,7 +60,7 @@ function fail(message, payload, exitCode = 1) {
60
60
  process.stderr.write(pc__default.default.dim(` → ${payload.suggestedCommand}\n`));
61
61
  }
62
62
  }
63
- util_tracker.trackEvent('z2h_cli_error', { action: payload.command ?? 'unknown', error: message });
63
+ await util_tracker.trackEvent('z2h_cli_error', { action: payload.command ?? 'unknown', error: message });
64
64
  process.exit(exitCode);
65
65
  }
66
66
 
@@ -1,3 +1,3 @@
1
- export declare function trackEvent(name: string, data: Record<string, unknown>): void;
1
+ export declare function trackEvent(name: string, data: Record<string, unknown>): Promise<void>;
2
2
  export declare function trackDuration<T>(eventName: string, fn: () => Promise<T>, data?: Record<string, unknown>): Promise<T>;
3
3
  //# sourceMappingURL=tracker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tracker.d.ts","sourceRoot":"","sources":["../../src/util/tracker.ts"],"names":[],"mappings":"AAMA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAO5E;AAED,wBAAsB,aAAa,CAAC,CAAC,EACnC,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC,CAAC,CAAC,CAKZ"}
1
+ {"version":3,"file":"tracker.d.ts","sourceRoot":"","sources":["../../src/util/tracker.ts"],"names":[],"mappings":"AAMA,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAO3F;AAED,wBAAsB,aAAa,CAAC,CAAC,EACnC,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC,CAAC,CAAC,CAKZ"}
@@ -6,20 +6,20 @@ const _interopDefault = e => e && e.__esModule ? e : { default: e };
6
6
 
7
7
  const os__default = /*#__PURE__*/_interopDefault(os);
8
8
 
9
- const DOORMAN_URL = 'https://track.bigbrain.me/prod/event';
9
+ const DOORMAN_URL = 'https://track-int.bigbrain.me/prod/event';
10
10
  const username = os__default.default.userInfo().username;
11
- function trackEvent(name, data) {
12
- void fetch(DOORMAN_URL, {
11
+ async function trackEvent(name, data) {
12
+ await fetch(DOORMAN_URL, {
13
13
  method: 'POST',
14
14
  headers: { 'Content-Type': 'application/json' },
15
- body: JSON.stringify({ name, source: 'z2h-cli', data: { username, ...data } }),
15
+ body: JSON.stringify({ name, source: 'z2h-cli', data: { user_name: username, ...data } }),
16
16
  signal: AbortSignal.timeout(5000),
17
17
  }).catch(() => { });
18
18
  }
19
19
  async function trackDuration(eventName, fn, data) {
20
20
  const start = Date.now();
21
21
  const result = await fn();
22
- trackEvent(eventName, { ...data, duration_ms: Date.now() - start });
22
+ await trackEvent(eventName, { ...data, duration_ms: Date.now() - start });
23
23
  return result;
24
24
  }
25
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mondaydotcomorg/z2h-cli",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "bin": "./bin/z2h-cli.js",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
package/src/index.ts CHANGED
@@ -63,7 +63,7 @@ async function main(): Promise<void> {
63
63
  try {
64
64
  await trackDuration('z2h_app_build_success', () => buildCommand(opts), { app_name: getCwdAppName() });
65
65
  } catch (err) {
66
- fail(`build failed: ${(err as Error).message}`, { command: 'build' }, 2);
66
+ await fail(`build failed: ${(err as Error).message}`, { command: 'build' }, 2);
67
67
  }
68
68
  });
69
69
 
@@ -75,7 +75,7 @@ async function main(): Promise<void> {
75
75
  try {
76
76
  await devCommand(opts);
77
77
  } catch (err) {
78
- fail(`dev failed: ${(err as Error).message}`, { command: 'dev' }, 2);
78
+ await fail(`dev failed: ${(err as Error).message}`, { command: 'dev' }, 2);
79
79
  }
80
80
  });
81
81
 
@@ -87,7 +87,7 @@ async function main(): Promise<void> {
87
87
  try {
88
88
  await cleanCommand(opts);
89
89
  } catch (err) {
90
- fail(`clean failed: ${(err as Error).message}`, { command: 'clean' }, 2);
90
+ await fail(`clean failed: ${(err as Error).message}`, { command: 'clean' }, 2);
91
91
  }
92
92
  });
93
93
 
@@ -102,7 +102,7 @@ async function main(): Promise<void> {
102
102
  app_name: getCwdAppName(),
103
103
  });
104
104
  } catch (err) {
105
- fail(`deploy failed: ${(err as Error).message}`, { command: 'deploy' }, 2);
105
+ await fail(`deploy failed: ${(err as Error).message}`, { command: 'deploy' }, 2);
106
106
  }
107
107
  });
108
108
 
@@ -114,7 +114,7 @@ async function main(): Promise<void> {
114
114
  try {
115
115
  await createWorkspaceCommand(opts);
116
116
  } catch (err) {
117
- fail(`create-workspace failed: ${(err as Error).message}`, { command: 'create-workspace' }, 1);
117
+ await fail(`create-workspace failed: ${(err as Error).message}`, { command: 'create-workspace' }, 1);
118
118
  }
119
119
  });
120
120
 
@@ -130,7 +130,7 @@ async function main(): Promise<void> {
130
130
  try {
131
131
  await generateZ2HTokenCommand(opts);
132
132
  } catch (err) {
133
- fail(`generate-z2h-token failed: ${(err as Error).message}`, { command: 'generate-z2h-token' }, 1);
133
+ await fail(`generate-z2h-token failed: ${(err as Error).message}`, { command: 'generate-z2h-token' }, 1);
134
134
  }
135
135
  });
136
136
 
@@ -147,7 +147,7 @@ async function main(): Promise<void> {
147
147
  template: opts.template ?? 'default',
148
148
  });
149
149
  } catch (err) {
150
- fail(`create failed: ${(err as Error).message}`, { command: 'create' }, 1);
150
+ await fail(`create failed: ${(err as Error).message}`, { command: 'create' }, 1);
151
151
  }
152
152
  });
153
153
 
@@ -160,7 +160,7 @@ async function main(): Promise<void> {
160
160
  try {
161
161
  await migrateCommand(version, opts);
162
162
  } catch (err) {
163
- fail(`migrate failed: ${(err as Error).message}`, { command: 'migrate' }, 1);
163
+ await fail(`migrate failed: ${(err as Error).message}`, { command: 'migrate' }, 1);
164
164
  }
165
165
  });
166
166
 
@@ -176,7 +176,6 @@ void main()
176
176
  }
177
177
  process.exit(0);
178
178
  })
179
- .catch((err: unknown) => {
180
- errorLog(`main failed: ${(err as Error).message}`);
181
- process.exit(1);
179
+ .catch(async (err: unknown) => {
180
+ await fail(`main failed: ${(err as Error).message}`, { command: 'cli-main' });
182
181
  });
@@ -52,7 +52,7 @@ export function output(human: string, data: unknown): void {
52
52
  * Emit a structured failure payload (JSON mode) or a red error line (human mode),
53
53
  * then exit with the given code.
54
54
  */
55
- export function fail(message: string, payload: Record<string, unknown>, exitCode = 1): never {
55
+ export async function fail(message: string, payload: Record<string, unknown>, exitCode = 1): Promise<never> {
56
56
  if (mode === 'json') {
57
57
  process.stdout.write(`${JSON.stringify({ ok: false, error: message, ...payload })}\n`);
58
58
  } else {
@@ -61,6 +61,6 @@ export function fail(message: string, payload: Record<string, unknown>, exitCode
61
61
  process.stderr.write(pc.dim(` → ${payload.suggestedCommand}\n`));
62
62
  }
63
63
  }
64
- trackEvent('z2h_cli_error', { action: (payload.command as string) ?? 'unknown', error: message });
64
+ await trackEvent('z2h_cli_error', { action: payload.command ?? 'unknown', error: message });
65
65
  process.exit(exitCode);
66
66
  }
@@ -1,14 +1,14 @@
1
1
  import os from 'node:os';
2
2
 
3
- const DOORMAN_URL = 'https://track.bigbrain.me/prod/event';
3
+ const DOORMAN_URL = 'https://track-int.bigbrain.me/prod/event';
4
4
 
5
5
  const username = os.userInfo().username;
6
6
 
7
- export function trackEvent(name: string, data: Record<string, unknown>): void {
8
- void fetch(DOORMAN_URL, {
7
+ export async function trackEvent(name: string, data: Record<string, unknown>): Promise<void> {
8
+ await fetch(DOORMAN_URL, {
9
9
  method: 'POST',
10
10
  headers: { 'Content-Type': 'application/json' },
11
- body: JSON.stringify({ name, source: 'z2h-cli', data: { username, ...data } }),
11
+ body: JSON.stringify({ name, source: 'z2h-cli', data: { user_name: username, ...data } }),
12
12
  signal: AbortSignal.timeout(5000),
13
13
  }).catch(() => {});
14
14
  }
@@ -20,6 +20,6 @@ export async function trackDuration<T>(
20
20
  ): Promise<T> {
21
21
  const start = Date.now();
22
22
  const result = await fn();
23
- trackEvent(eventName, { ...data, duration_ms: Date.now() - start });
23
+ await trackEvent(eventName, { ...data, duration_ms: Date.now() - start });
24
24
  return result;
25
25
  }