@mondaydotcomorg/z2h-cli 0.11.6 → 0.12.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.
@@ -1,5 +1,6 @@
1
1
  export interface DevOptions {
2
2
  json?: boolean;
3
+ open?: boolean;
3
4
  }
4
5
  export declare function devCommand(opts?: DevOptions): Promise<void>;
5
6
  //# sourceMappingURL=dev.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAKD,wBAAsB,UAAU,CAAC,IAAI,GAAE,UAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA0ErE"}
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAKD,wBAAsB,UAAU,CAAC,IAAI,GAAE,UAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA6ErE"}
@@ -9,6 +9,7 @@ const util_logger = require('../util/logger.js');
9
9
  const shadow_prepare = require('../shadow/prepare.js');
10
10
  const shadow_consumerPkg = require('../shadow/consumer-pkg.js');
11
11
  const shadow_sync = require('../shadow/sync.js');
12
+ const util_openBrowser = require('../util/open-browser.js');
12
13
 
13
14
  const _interopDefault = e => e && e.__esModule ? e : { default: e };
14
15
 
@@ -68,6 +69,9 @@ async function devCommand(opts = {}) {
68
69
  port,
69
70
  url,
70
71
  });
72
+ if (opts.open) {
73
+ void util_openBrowser.openInBrowser(url);
74
+ }
71
75
  }
72
76
  });
73
77
  // Only watch consumer package.json. Source changes flow through Vite's
@@ -1 +1 @@
1
- {"version":3,"file":"generate-z2h-token.d.ts","sourceRoot":"","sources":["../../src/commands/generate-z2h-token.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,sBAAsB,yDAAyD,CAAC;AAC7F,eAAO,MAAM,mBAAmB,SAAU,CAAC;AAE3C,MAAM,WAAW,uBAAuB;IACtC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,+DAA+D;IAC/D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAuED,wBAAsB,uBAAuB,CAAC,IAAI,GAAE,uBAA4B,GAAG,OAAO,CAAC,IAAI,CAAC,CA+B/F"}
1
+ {"version":3,"file":"generate-z2h-token.d.ts","sourceRoot":"","sources":["../../src/commands/generate-z2h-token.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,sBAAsB,yDAAyD,CAAC;AAC7F,eAAO,MAAM,mBAAmB,SAAU,CAAC;AAE3C,MAAM,WAAW,uBAAuB;IACtC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,+DAA+D;IAC/D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAwDD,wBAAsB,uBAAuB,CAAC,IAAI,GAAE,uBAA4B,GAAG,OAAO,CAAC,IAAI,CAAC,CA+B/F"}
@@ -2,10 +2,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const readline = require('node:readline/promises');
4
4
  const node_process = require('node:process');
5
- const execa = require('execa');
6
5
  const util_logger = require('../util/logger.js');
7
6
  const util_auth_writeAuth = require('../util/auth/write-auth.js');
8
7
  const util_auth_loopbackServer = require('../util/auth/loopback-server.js');
8
+ const util_openBrowser = require('../util/open-browser.js');
9
9
 
10
10
  const _interopDefault = e => e && e.__esModule ? e : { default: e };
11
11
 
@@ -13,19 +13,6 @@ const readline__default = /*#__PURE__*/_interopDefault(readline);
13
13
 
14
14
  const DEFAULT_TOKEN_PAGE_URL = 'https://bigbrain.me/bigbrain-vibe/generate-z2h-token';
15
15
  const LOOPBACK_TIMEOUT_MS = 120_000;
16
- function browserOpenCommand() {
17
- switch (process.platform) {
18
- case 'darwin':
19
- return 'open';
20
- case 'win32':
21
- return 'start';
22
- default:
23
- return 'xdg-open';
24
- }
25
- }
26
- async function openInBrowser(url) {
27
- await execa.execa(browserOpenCommand(), [url], { stdio: 'ignore' });
28
- }
29
16
  async function promptForToken() {
30
17
  const rl = readline__default.default.createInterface({ input: node_process.stdin, output: node_process.stdout });
31
18
  try {
@@ -58,7 +45,7 @@ async function runLoopbackFlow(pageUrl) {
58
45
  util_logger.info('opening your browser to mint a Z2H deploy token');
59
46
  util_logger.info(` ${fullUrl}`);
60
47
  try {
61
- await openInBrowser(fullUrl);
48
+ await util_openBrowser.openInBrowser(fullUrl);
62
49
  }
63
50
  catch {
64
51
  util_logger.warn('could not auto-open the browser. please visit the URL above manually.');
@@ -1,5 +1,6 @@
1
1
  export interface DevOptions {
2
2
  json?: boolean;
3
+ open?: boolean;
3
4
  }
4
5
  export declare function devCommand(opts?: DevOptions): Promise<void>;
5
6
  //# sourceMappingURL=dev.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/commands/dev.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAKD,wBAAsB,UAAU,CAAC,IAAI,GAAE,UAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA0ErE"}
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/commands/dev.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAKD,wBAAsB,UAAU,CAAC,IAAI,GAAE,UAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA6ErE"}
@@ -7,6 +7,7 @@ import { setOutputMode, info, output, warn, errorLog } from '../util/logger.mjs'
7
7
  import { prepareShadow } from '../shadow/prepare.mjs';
8
8
  import { ensureConsumerPkg } from '../shadow/consumer-pkg.mjs';
9
9
  import { syncShadow } from '../shadow/sync.mjs';
10
+ import { openInBrowser } from '../util/open-browser.mjs';
10
11
 
11
12
  const TRIDENT_READY_PATTERN = /Server started at/i;
12
13
  // Should be run from the consumer app directory — uses process.cwd() to locate it.
@@ -61,6 +62,9 @@ async function devCommand(opts = {}) {
61
62
  port,
62
63
  url,
63
64
  });
65
+ if (opts.open) {
66
+ void openInBrowser(url);
67
+ }
64
68
  }
65
69
  });
66
70
  // Only watch consumer package.json. Source changes flow through Vite's
@@ -1 +1 @@
1
- {"version":3,"file":"generate-z2h-token.d.ts","sourceRoot":"","sources":["../../../src/commands/generate-z2h-token.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,sBAAsB,yDAAyD,CAAC;AAC7F,eAAO,MAAM,mBAAmB,SAAU,CAAC;AAE3C,MAAM,WAAW,uBAAuB;IACtC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,+DAA+D;IAC/D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAuED,wBAAsB,uBAAuB,CAAC,IAAI,GAAE,uBAA4B,GAAG,OAAO,CAAC,IAAI,CAAC,CA+B/F"}
1
+ {"version":3,"file":"generate-z2h-token.d.ts","sourceRoot":"","sources":["../../../src/commands/generate-z2h-token.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,sBAAsB,yDAAyD,CAAC;AAC7F,eAAO,MAAM,mBAAmB,SAAU,CAAC;AAE3C,MAAM,WAAW,uBAAuB;IACtC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,+DAA+D;IAC/D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAwDD,wBAAsB,uBAAuB,CAAC,IAAI,GAAE,uBAA4B,GAAG,OAAO,CAAC,IAAI,CAAC,CA+B/F"}
@@ -1,25 +1,12 @@
1
1
  import readline from 'node:readline/promises';
2
2
  import { stdin, stdout } from 'node:process';
3
- import { execa } from 'execa';
4
3
  import { setOutputMode, warn, output, info } from '../util/logger.mjs';
5
4
  import { validateJwtPattern, writeZthAuth } from '../util/auth/write-auth.mjs';
6
5
  import { startLoopbackServer } from '../util/auth/loopback-server.mjs';
6
+ import { openInBrowser } from '../util/open-browser.mjs';
7
7
 
8
8
  const DEFAULT_TOKEN_PAGE_URL = 'https://bigbrain.me/bigbrain-vibe/generate-z2h-token';
9
9
  const LOOPBACK_TIMEOUT_MS = 120_000;
10
- function browserOpenCommand() {
11
- switch (process.platform) {
12
- case 'darwin':
13
- return 'open';
14
- case 'win32':
15
- return 'start';
16
- default:
17
- return 'xdg-open';
18
- }
19
- }
20
- async function openInBrowser(url) {
21
- await execa(browserOpenCommand(), [url], { stdio: 'ignore' });
22
- }
23
10
  async function promptForToken() {
24
11
  const rl = readline.createInterface({ input: stdin, output: stdout });
25
12
  try {
@@ -70,6 +70,7 @@ async function main() {
70
70
  program
71
71
  .command('dev')
72
72
  .description('Start the Trident dev server against .zth/ with native Vite HMR')
73
+ .option('--open', 'open the browser automatically when the dev server is ready')
73
74
  .option('--json', 'emit structured JSON on stdout')
74
75
  .action(async (opts) => {
75
76
  try {
@@ -0,0 +1,2 @@
1
+ export declare function openInBrowser(url: string): Promise<void>;
2
+ //# sourceMappingURL=open-browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-browser.d.ts","sourceRoot":"","sources":["../../../src/util/open-browser.ts"],"names":[],"mappings":"AAcA,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI9D"}
@@ -0,0 +1,20 @@
1
+ import { execa } from 'execa';
2
+ import { errorLog } from './logger.mjs';
3
+
4
+ function browserOpenCommand() {
5
+ switch (process.platform) {
6
+ case 'darwin':
7
+ return 'open';
8
+ case 'win32':
9
+ return 'start';
10
+ default:
11
+ return 'xdg-open';
12
+ }
13
+ }
14
+ async function openInBrowser(url) {
15
+ await execa(browserOpenCommand(), [url], { stdio: 'ignore' }).catch(() => {
16
+ errorLog(`Failed to open browser for ${url}, open it manually.`);
17
+ });
18
+ }
19
+
20
+ export { openInBrowser };
package/dist/index.js CHANGED
@@ -76,6 +76,7 @@ async function main() {
76
76
  program
77
77
  .command('dev')
78
78
  .description('Start the Trident dev server against .zth/ with native Vite HMR')
79
+ .option('--open', 'open the browser automatically when the dev server is ready')
79
80
  .option('--json', 'emit structured JSON on stdout')
80
81
  .action(async (opts) => {
81
82
  try {
@@ -0,0 +1,2 @@
1
+ export declare function openInBrowser(url: string): Promise<void>;
2
+ //# sourceMappingURL=open-browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-browser.d.ts","sourceRoot":"","sources":["../../src/util/open-browser.ts"],"names":[],"mappings":"AAcA,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI9D"}
@@ -0,0 +1,22 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const execa = require('execa');
4
+ const util_logger = require('./logger.js');
5
+
6
+ function browserOpenCommand() {
7
+ switch (process.platform) {
8
+ case 'darwin':
9
+ return 'open';
10
+ case 'win32':
11
+ return 'start';
12
+ default:
13
+ return 'xdg-open';
14
+ }
15
+ }
16
+ async function openInBrowser(url) {
17
+ await execa.execa(browserOpenCommand(), [url], { stdio: 'ignore' }).catch(() => {
18
+ util_logger.errorLog(`Failed to open browser for ${url}, open it manually.`);
19
+ });
20
+ }
21
+
22
+ exports.openInBrowser = openInBrowser;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mondaydotcomorg/z2h-cli",
3
- "version": "0.11.6",
3
+ "version": "0.12.1",
4
4
  "bin": "./bin/z2h-cli.js",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -7,10 +7,12 @@ import { info, warn, errorLog, output, setOutputMode } from '../util/logger';
7
7
  import { prepareShadow } from '../shadow/prepare';
8
8
  import { ensureConsumerPkg } from '../shadow/consumer-pkg';
9
9
  import { syncShadow } from '../shadow/sync';
10
+ import { openInBrowser } from '../util/open-browser';
10
11
  import type { ConsumerPkg } from '../types';
11
12
 
12
13
  export interface DevOptions {
13
14
  json?: boolean;
15
+ open?: boolean;
14
16
  }
15
17
 
16
18
  const TRIDENT_READY_PATTERN = /Server started at/i;
@@ -71,6 +73,9 @@ export async function devCommand(opts: DevOptions = {}): Promise<void> {
71
73
  port,
72
74
  url,
73
75
  });
76
+ if (opts.open) {
77
+ void openInBrowser(url);
78
+ }
74
79
  }
75
80
  });
76
81
 
@@ -1,9 +1,9 @@
1
1
  import readline from 'node:readline/promises';
2
2
  import { stdin, stdout } from 'node:process';
3
- import { execa } from 'execa';
4
3
  import { info, warn, output, setOutputMode } from '../util/logger';
5
4
  import { writeZthAuth, validateJwtPattern } from '../util/auth/write-auth';
6
5
  import { startLoopbackServer } from '../util/auth/loopback-server';
6
+ import { openInBrowser } from '../util/open-browser';
7
7
 
8
8
  export const DEFAULT_TOKEN_PAGE_URL = 'https://bigbrain.me/bigbrain-vibe/generate-z2h-token';
9
9
  export const LOOPBACK_TIMEOUT_MS = 120_000;
@@ -21,21 +21,6 @@ export interface GenerateZ2HTokenOptions {
21
21
  json?: boolean;
22
22
  }
23
23
 
24
- function browserOpenCommand(): string {
25
- switch (process.platform) {
26
- case 'darwin':
27
- return 'open';
28
- case 'win32':
29
- return 'start';
30
- default:
31
- return 'xdg-open';
32
- }
33
- }
34
-
35
- async function openInBrowser(url: string): Promise<void> {
36
- await execa(browserOpenCommand(), [url], { stdio: 'ignore' });
37
- }
38
-
39
24
  async function promptForToken(): Promise<string> {
40
25
  const rl = readline.createInterface({ input: stdin, output: stdout });
41
26
  try {
package/src/index.ts CHANGED
@@ -78,8 +78,9 @@ async function main(): Promise<void> {
78
78
  program
79
79
  .command('dev')
80
80
  .description('Start the Trident dev server against .zth/ with native Vite HMR')
81
+ .option('--open', 'open the browser automatically when the dev server is ready')
81
82
  .option('--json', 'emit structured JSON on stdout')
82
- .action(async (opts: { json?: boolean }) => {
83
+ .action(async (opts: { open?: boolean; json?: boolean }) => {
83
84
  try {
84
85
  await devCommand(opts);
85
86
  } catch (err) {
@@ -38,9 +38,9 @@ When a request needs data, follow `z2h:coding-standards-mf` §0: write a `runQue
38
38
  - This folder is **standalone** — not part of any monorepo, no git initialized.
39
39
  - `src/index.tsx` default-exports the React component the host MF loads.
40
40
  - `package.json` wires the `z2h-cli` for `build` / `start` / `deploy`.
41
- - `.zth/` is an auto-generated shadow workspace — never edit it by hand; `npx z2h-cli clean` wipes it.
42
- - Local dev: `npx z2h-cli dev` → opens at `https://bigbrain.me/bigbrain-vibe/<app>?zth_local=<port>`.
43
- - Production: `npx z2h-cli deploy` → live at `https://bigbrain.me/bigbrain-vibe/<app>`.
41
+ - `.zth/` is an auto-generated shadow workspace — never edit it by hand; `z2h-cli clean` wipes it.
42
+ - Local dev: `z2h-cli dev` → opens at `https://bigbrain.me/bigbrain-vibe/<app>?zth_local=<port>`.
43
+ - Production: `z2h-cli deploy` → live at `https://bigbrain.me/bigbrain-vibe/<app>`.
44
44
  - There is no git, no PR, no CI. The gate is: lint pass → typecheck pass → user previews and approves.
45
45
 
46
46
  ---
@@ -54,8 +54,8 @@ Apps are **private by default** — only you can view them. After the first depl
54
54
  To change visibility at any time:
55
55
 
56
56
  ```
57
- npx z2h-cli grant --public # open to all monday.com employees
58
- npx z2h-cli revoke --public # back to private
57
+ z2h-cli grant --public # open to all monday.com employees
58
+ z2h-cli revoke --public # back to private
59
59
  ```
60
60
 
61
61
  ---
@@ -0,0 +1,19 @@
1
+ import { execa } from 'execa';
2
+ import { errorLog } from './logger';
3
+
4
+ function browserOpenCommand(): string {
5
+ switch (process.platform) {
6
+ case 'darwin':
7
+ return 'open';
8
+ case 'win32':
9
+ return 'start';
10
+ default:
11
+ return 'xdg-open';
12
+ }
13
+ }
14
+
15
+ export async function openInBrowser(url: string): Promise<void> {
16
+ await execa(browserOpenCommand(), [url], { stdio: 'ignore' }).catch(() => {
17
+ errorLog(`Failed to open browser for ${url}, open it manually.`);
18
+ });
19
+ }