@mondaydotcomorg/z2h-cli 0.7.0 → 0.7.2-feat-arielle-build-after-create-and-improve-setup-script-c31a761
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/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +1 -0
- package/dist/commands/clean.d.ts.map +1 -1
- package/dist/commands/clean.js +1 -0
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +5 -0
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +1 -0
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +3 -0
- package/dist/esm/commands/build.d.ts.map +1 -1
- package/dist/esm/commands/build.mjs +1 -0
- package/dist/esm/commands/clean.d.ts.map +1 -1
- package/dist/esm/commands/clean.mjs +1 -0
- package/dist/esm/commands/create.d.ts.map +1 -1
- package/dist/esm/commands/create.mjs +5 -0
- package/dist/esm/commands/deploy.d.ts.map +1 -1
- package/dist/esm/commands/deploy.mjs +1 -0
- package/dist/esm/commands/dev.d.ts.map +1 -1
- package/dist/esm/commands/dev.mjs +3 -0
- package/dist/esm/index.mjs +15 -13
- package/dist/esm/migrations/auto-migrate.mjs +3 -3
- package/dist/esm/shadow/scaffold.d.ts.map +1 -1
- package/dist/esm/shadow/scaffold.mjs +2 -1
- package/dist/esm/templates/app/claude-settings.mjs +1 -1
- package/dist/esm/util/logger.d.ts +1 -1
- package/dist/esm/util/logger.d.ts.map +1 -1
- package/dist/esm/util/logger.mjs +2 -2
- package/dist/esm/util/tracker.d.ts +1 -1
- package/dist/esm/util/tracker.d.ts.map +1 -1
- package/dist/esm/util/tracker.mjs +5 -5
- package/dist/index.js +14 -12
- package/dist/migrations/auto-migrate.js +3 -3
- package/dist/shadow/scaffold.d.ts.map +1 -1
- package/dist/shadow/scaffold.js +2 -1
- package/dist/templates/app/claude-settings.js +1 -1
- package/dist/util/logger.d.ts +1 -1
- package/dist/util/logger.d.ts.map +1 -1
- package/dist/util/logger.js +2 -2
- package/dist/util/tracker.d.ts +1 -1
- package/dist/util/tracker.d.ts.map +1 -1
- package/dist/util/tracker.js +5 -5
- package/package.json +1 -1
- package/src/commands/__tests__/create.test.ts +7 -0
- package/src/commands/build.ts +1 -0
- package/src/commands/clean.ts +1 -0
- package/src/commands/create.ts +6 -0
- package/src/commands/deploy.ts +1 -0
- package/src/commands/dev.ts +3 -0
- package/src/index.ts +14 -12
- package/src/migrations/auto-migrate.ts +4 -4
- package/src/shadow/scaffold.ts +2 -1
- package/src/templates/app/CLAUDE.md +3 -1
- package/src/templates/app/claude-settings.json +1 -1
- package/src/util/logger.ts +2 -2
- package/src/util/tracker.ts +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAGD,wBAAsB,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAoCpE"}
|
package/dist/commands/build.js
CHANGED
|
@@ -5,6 +5,7 @@ const execa = require('execa');
|
|
|
5
5
|
const util_logger = require('../util/logger.js');
|
|
6
6
|
const shadow_prepare = require('../shadow/prepare.js');
|
|
7
7
|
|
|
8
|
+
// Should be run from the consumer app directory — uses process.cwd() to locate it.
|
|
8
9
|
async function buildCommand(opts) {
|
|
9
10
|
if (opts.json) {
|
|
10
11
|
util_logger.setOutputMode('json');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../src/commands/clean.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;
|
|
1
|
+
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../src/commands/clean.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAGD,wBAAsB,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBpE"}
|
package/dist/commands/clean.js
CHANGED
|
@@ -4,6 +4,7 @@ const fsExtra = require('fs-extra');
|
|
|
4
4
|
const util_logger = require('../util/logger.js');
|
|
5
5
|
const shadow_paths = require('../shadow/paths.js');
|
|
6
6
|
|
|
7
|
+
// Should be run from the consumer app directory — uses process.cwd() to locate it.
|
|
7
8
|
async function cleanCommand(opts) {
|
|
8
9
|
if (opts.json) {
|
|
9
10
|
util_logger.setOutputMode('json');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AA6BD,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAuFvF"}
|
package/dist/commands/create.js
CHANGED
|
@@ -10,6 +10,7 @@ const util_manifest = require('../util/manifest.js');
|
|
|
10
10
|
const util_appName = require('../util/app-name.js');
|
|
11
11
|
const constants = require('../constants.js');
|
|
12
12
|
const util_npm_install = require('../util/npm/install.js');
|
|
13
|
+
const commands_build = require('./build.js');
|
|
13
14
|
|
|
14
15
|
const _interopDefault = e => e && e.__esModule ? e : { default: e };
|
|
15
16
|
|
|
@@ -97,6 +98,10 @@ async function createCommand(appName, opts) {
|
|
|
97
98
|
}
|
|
98
99
|
util_logger.info(`installing dependencies for ${appName}...`);
|
|
99
100
|
await util_npm_install.runYarnInstall({ cwd: workspace });
|
|
101
|
+
// build/dev/deploy all locate the consumer via process.cwd() — chdir before calling them.
|
|
102
|
+
util_logger.info(`pre-building ${appName}`);
|
|
103
|
+
process.chdir(appDir);
|
|
104
|
+
await commands_build.buildCommand({});
|
|
100
105
|
util_logger.output(`[z2h-cli] app ready at ${appDir}`, {
|
|
101
106
|
ok: true,
|
|
102
107
|
appDir,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAoBA,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAoBA,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAGD,wBAAsB,aAAa,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CA+EtE"}
|
package/dist/commands/deploy.js
CHANGED
|
@@ -18,6 +18,7 @@ const _interopDefault = e => e && e.__esModule ? e : { default: e };
|
|
|
18
18
|
const path__default = /*#__PURE__*/_interopDefault(path);
|
|
19
19
|
const os__default = /*#__PURE__*/_interopDefault(os);
|
|
20
20
|
|
|
21
|
+
// Should be run from the consumer app directory — uses process.cwd() to locate it.
|
|
21
22
|
async function deployCommand(opts) {
|
|
22
23
|
if (opts.json) {
|
|
23
24
|
util_logger.setOutputMode('json');
|
|
@@ -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;
|
|
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,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAyEhE"}
|
package/dist/commands/dev.js
CHANGED
|
@@ -16,6 +16,7 @@ const path__default = /*#__PURE__*/_interopDefault(path);
|
|
|
16
16
|
const fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
17
17
|
|
|
18
18
|
const TRIDENT_READY_PATTERN = /Server started at/i;
|
|
19
|
+
// Should be run from the consumer app directory — uses process.cwd() to locate it.
|
|
19
20
|
async function devCommand(opts) {
|
|
20
21
|
if (opts.json) {
|
|
21
22
|
util_logger.setOutputMode('json');
|
|
@@ -30,6 +31,8 @@ async function devCommand(opts) {
|
|
|
30
31
|
const server = execa.execa('yarn', ['start'], {
|
|
31
32
|
cwd: ctx.paths.shadowDir,
|
|
32
33
|
stdio: ['inherit', 'pipe', 'inherit'],
|
|
34
|
+
// Trident requires NPM_TOKEN to be set or it refuses to start; 'FAKE_TOKEN' satisfies the check without real credentials.
|
|
35
|
+
env: { ...process.env, NPM_TOKEN: process.env.NPM_TOKEN ?? 'FAKE_TOKEN' },
|
|
33
36
|
});
|
|
34
37
|
const pidFile = path__default.default.join(ctx.paths.shadowDir, 'dev.pid');
|
|
35
38
|
if (server.pid) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/commands/build.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/commands/build.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAGD,wBAAsB,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAoCpE"}
|
|
@@ -3,6 +3,7 @@ import { execa } from 'execa';
|
|
|
3
3
|
import { setOutputMode, info, output } from '../util/logger.mjs';
|
|
4
4
|
import { prepareShadow } from '../shadow/prepare.mjs';
|
|
5
5
|
|
|
6
|
+
// Should be run from the consumer app directory — uses process.cwd() to locate it.
|
|
6
7
|
async function buildCommand(opts) {
|
|
7
8
|
if (opts.json) {
|
|
8
9
|
setOutputMode('json');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../../src/commands/clean.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;
|
|
1
|
+
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../../src/commands/clean.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAGD,wBAAsB,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBpE"}
|
|
@@ -2,6 +2,7 @@ import { pathExists, remove } from 'fs-extra';
|
|
|
2
2
|
import { setOutputMode, info, output } from '../util/logger.mjs';
|
|
3
3
|
import { resolveConsumerPaths } from '../shadow/paths.mjs';
|
|
4
4
|
|
|
5
|
+
// Should be run from the consumer app directory — uses process.cwd() to locate it.
|
|
5
6
|
async function cleanCommand(opts) {
|
|
6
7
|
if (opts.json) {
|
|
7
8
|
setOutputMode('json');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/create.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AA6BD,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAuFvF"}
|
|
@@ -8,6 +8,7 @@ import { readManifest } from '../util/manifest.mjs';
|
|
|
8
8
|
import { mfAppName } from '../util/app-name.mjs';
|
|
9
9
|
import { APP_NAME_PATTERN } from '../constants.mjs';
|
|
10
10
|
import { runYarnInstall } from '../util/npm/install.mjs';
|
|
11
|
+
import { buildCommand } from './build.mjs';
|
|
11
12
|
|
|
12
13
|
// Names reserved by the host MF (mf-bigbrain-zth) for platform pages under
|
|
13
14
|
// /bigbrain-vibe/<name>. Creating an app with one of these would shadow the
|
|
@@ -91,6 +92,10 @@ async function createCommand(appName, opts) {
|
|
|
91
92
|
}
|
|
92
93
|
info(`installing dependencies for ${appName}...`);
|
|
93
94
|
await runYarnInstall({ cwd: workspace });
|
|
95
|
+
// build/dev/deploy all locate the consumer via process.cwd() — chdir before calling them.
|
|
96
|
+
info(`pre-building ${appName}`);
|
|
97
|
+
process.chdir(appDir);
|
|
98
|
+
await buildCommand({});
|
|
94
99
|
output(`[z2h-cli] app ready at ${appDir}`, {
|
|
95
100
|
ok: true,
|
|
96
101
|
appDir,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy.ts"],"names":[],"mappings":"AAoBA,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy.ts"],"names":[],"mappings":"AAoBA,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAGD,wBAAsB,aAAa,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CA+EtE"}
|
|
@@ -11,6 +11,7 @@ import { readZthAuth } from '../util/auth/auth-store.mjs';
|
|
|
11
11
|
import { mfAppName, cleanAppName } from '../util/app-name.mjs';
|
|
12
12
|
import { buildCommand } from './build.mjs';
|
|
13
13
|
|
|
14
|
+
// Should be run from the consumer app directory — uses process.cwd() to locate it.
|
|
14
15
|
async function deployCommand(opts) {
|
|
15
16
|
if (opts.json) {
|
|
16
17
|
setOutputMode('json');
|
|
@@ -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;
|
|
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,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAyEhE"}
|
|
@@ -9,6 +9,7 @@ import { ensureConsumerPkg } from '../shadow/consumer-pkg.mjs';
|
|
|
9
9
|
import { syncShadow } from '../shadow/sync.mjs';
|
|
10
10
|
|
|
11
11
|
const TRIDENT_READY_PATTERN = /Server started at/i;
|
|
12
|
+
// Should be run from the consumer app directory — uses process.cwd() to locate it.
|
|
12
13
|
async function devCommand(opts) {
|
|
13
14
|
if (opts.json) {
|
|
14
15
|
setOutputMode('json');
|
|
@@ -23,6 +24,8 @@ async function devCommand(opts) {
|
|
|
23
24
|
const server = execa('yarn', ['start'], {
|
|
24
25
|
cwd: ctx.paths.shadowDir,
|
|
25
26
|
stdio: ['inherit', 'pipe', 'inherit'],
|
|
27
|
+
// Trident requires NPM_TOKEN to be set or it refuses to start; 'FAKE_TOKEN' satisfies the check without real credentials.
|
|
28
|
+
env: { ...process.env, NPM_TOKEN: process.env.NPM_TOKEN ?? 'FAKE_TOKEN' },
|
|
26
29
|
});
|
|
27
30
|
const pidFile = path.join(ctx.paths.shadowDir, 'dev.pid');
|
|
28
31
|
if (server.pid) {
|
package/dist/esm/index.mjs
CHANGED
|
@@ -12,14 +12,17 @@ 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 {
|
|
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');
|
|
19
19
|
const UPDATE_SCRIPT = path.join(os.homedir(), 'Development', 'bigbrain-z2h', 'z2h', 'setup', 'update.sh');
|
|
20
20
|
function selfUpdate() {
|
|
21
21
|
try {
|
|
22
|
-
execa('bash', [UPDATE_SCRIPT], {
|
|
22
|
+
execa('bash', [UPDATE_SCRIPT], {
|
|
23
|
+
detached: true,
|
|
24
|
+
stdio: 'ignore',
|
|
25
|
+
}).unref();
|
|
23
26
|
}
|
|
24
27
|
catch (err) {
|
|
25
28
|
errorLog(`Z2H auto-update failed to start: ${err.message}`);
|
|
@@ -59,7 +62,7 @@ async function main() {
|
|
|
59
62
|
await trackDuration('z2h_app_build_success', () => buildCommand(opts), { app_name: getCwdAppName() });
|
|
60
63
|
}
|
|
61
64
|
catch (err) {
|
|
62
|
-
fail(`build failed: ${err.message}`, { command: 'build' }, 2);
|
|
65
|
+
await fail(`build failed: ${err.message}`, { command: 'build' }, 2);
|
|
63
66
|
}
|
|
64
67
|
});
|
|
65
68
|
program
|
|
@@ -71,7 +74,7 @@ async function main() {
|
|
|
71
74
|
await devCommand(opts);
|
|
72
75
|
}
|
|
73
76
|
catch (err) {
|
|
74
|
-
fail(`dev failed: ${err.message}`, { command: 'dev' }, 2);
|
|
77
|
+
await fail(`dev failed: ${err.message}`, { command: 'dev' }, 2);
|
|
75
78
|
}
|
|
76
79
|
});
|
|
77
80
|
program
|
|
@@ -83,7 +86,7 @@ async function main() {
|
|
|
83
86
|
await cleanCommand(opts);
|
|
84
87
|
}
|
|
85
88
|
catch (err) {
|
|
86
|
-
fail(`clean failed: ${err.message}`, { command: 'clean' }, 2);
|
|
89
|
+
await fail(`clean failed: ${err.message}`, { command: 'clean' }, 2);
|
|
87
90
|
}
|
|
88
91
|
});
|
|
89
92
|
program
|
|
@@ -98,7 +101,7 @@ async function main() {
|
|
|
98
101
|
});
|
|
99
102
|
}
|
|
100
103
|
catch (err) {
|
|
101
|
-
fail(`deploy failed: ${err.message}`, { command: 'deploy' }, 2);
|
|
104
|
+
await fail(`deploy failed: ${err.message}`, { command: 'deploy' }, 2);
|
|
102
105
|
}
|
|
103
106
|
});
|
|
104
107
|
program
|
|
@@ -110,7 +113,7 @@ async function main() {
|
|
|
110
113
|
await createWorkspaceCommand(opts);
|
|
111
114
|
}
|
|
112
115
|
catch (err) {
|
|
113
|
-
fail(`create-workspace failed: ${err.message}`, { command: 'create-workspace' }, 1);
|
|
116
|
+
await fail(`create-workspace failed: ${err.message}`, { command: 'create-workspace' }, 1);
|
|
114
117
|
}
|
|
115
118
|
});
|
|
116
119
|
program
|
|
@@ -124,7 +127,7 @@ async function main() {
|
|
|
124
127
|
await generateZ2HTokenCommand(opts);
|
|
125
128
|
}
|
|
126
129
|
catch (err) {
|
|
127
|
-
fail(`generate-z2h-token failed: ${err.message}`, { command: 'generate-z2h-token' }, 1);
|
|
130
|
+
await fail(`generate-z2h-token failed: ${err.message}`, { command: 'generate-z2h-token' }, 1);
|
|
128
131
|
}
|
|
129
132
|
});
|
|
130
133
|
program
|
|
@@ -141,7 +144,7 @@ async function main() {
|
|
|
141
144
|
});
|
|
142
145
|
}
|
|
143
146
|
catch (err) {
|
|
144
|
-
fail(`create failed: ${err.message}`, { command: 'create' }, 1);
|
|
147
|
+
await fail(`create failed: ${err.message}`, { command: 'create' }, 1);
|
|
145
148
|
}
|
|
146
149
|
});
|
|
147
150
|
program
|
|
@@ -154,7 +157,7 @@ async function main() {
|
|
|
154
157
|
await migrateCommand(version, opts);
|
|
155
158
|
}
|
|
156
159
|
catch (err) {
|
|
157
|
-
fail(`migrate failed: ${err.message}`, { command: 'migrate' }, 1);
|
|
160
|
+
await fail(`migrate failed: ${err.message}`, { command: 'migrate' }, 1);
|
|
158
161
|
}
|
|
159
162
|
});
|
|
160
163
|
await program.parseAsync(process.argv);
|
|
@@ -168,7 +171,6 @@ void main()
|
|
|
168
171
|
}
|
|
169
172
|
process.exit(0);
|
|
170
173
|
})
|
|
171
|
-
.catch((err) => {
|
|
172
|
-
|
|
173
|
-
process.exit(1);
|
|
174
|
+
.catch(async (err) => {
|
|
175
|
+
await fail(`main failed: ${err.message}`, { command: 'cli-main' });
|
|
174
176
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { execa } from 'execa';
|
|
2
|
+
import { pathExists, readJson, writeJson, writeFile } from 'fs-extra';
|
|
2
3
|
import { createRequire } from 'node:module';
|
|
4
|
+
import path from 'node:path';
|
|
3
5
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { pathExists, readJson, writeJson, writeFile } from 'fs-extra';
|
|
5
|
-
import { execa } from 'execa';
|
|
6
6
|
import semver from 'semver';
|
|
7
7
|
import { warn, info, errorLog } from '../util/logger.mjs';
|
|
8
8
|
import { getWorkspaceHome, isZ2hWorkspace } from '../util/workspace.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../../../src/shadow/scaffold.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../../../src/shadow/scaffold.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AA0G9C;;;GAGG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYvG"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { ensureDir, writeFile, writeJson } from 'fs-extra';
|
|
3
3
|
|
|
4
|
-
const WRAPPER_TEMPLATE = `import
|
|
4
|
+
const WRAPPER_TEMPLATE = `import '@vibe/core/tokens';
|
|
5
|
+
import ConsumerApp from '../../src/index';
|
|
5
6
|
import React from 'react';
|
|
6
7
|
import * as ReactDOM from 'react-dom/client';
|
|
7
8
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
@@ -9,7 +9,7 @@ var hooks = {
|
|
|
9
9
|
hooks: [
|
|
10
10
|
{
|
|
11
11
|
type: "command",
|
|
12
|
-
command: "if [ -f .zth/dev.pid ]; then
|
|
12
|
+
command: "if [ -f .zth/dev.pid ]; then PGID=$(ps -o pgid= -p $(cat .zth/dev.pid) 2>/dev/null | tr -d ' '); [ -n \"$PGID\" ] && kill -- -$PGID 2>/dev/null; rm -f .zth/dev.pid; fi"
|
|
13
13
|
}
|
|
14
14
|
]
|
|
15
15
|
}
|
|
@@ -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,
|
|
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"}
|
package/dist/esm/util/logger.mjs
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
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
|
@@ -25,7 +25,10 @@ const { version } = node_module.createRequire((typeof document === 'undefined' ?
|
|
|
25
25
|
const UPDATE_SCRIPT = path__default.default.join(os__default.default.homedir(), 'Development', 'bigbrain-z2h', 'z2h', 'setup', 'update.sh');
|
|
26
26
|
function selfUpdate() {
|
|
27
27
|
try {
|
|
28
|
-
execa.execa('bash', [UPDATE_SCRIPT], {
|
|
28
|
+
execa.execa('bash', [UPDATE_SCRIPT], {
|
|
29
|
+
detached: true,
|
|
30
|
+
stdio: 'ignore',
|
|
31
|
+
}).unref();
|
|
29
32
|
}
|
|
30
33
|
catch (err) {
|
|
31
34
|
util_logger.errorLog(`Z2H auto-update failed to start: ${err.message}`);
|
|
@@ -65,7 +68,7 @@ async function main() {
|
|
|
65
68
|
await util_tracker.trackDuration('z2h_app_build_success', () => commands_build.buildCommand(opts), { app_name: getCwdAppName() });
|
|
66
69
|
}
|
|
67
70
|
catch (err) {
|
|
68
|
-
util_logger.fail(`build failed: ${err.message}`, { command: 'build' }, 2);
|
|
71
|
+
await util_logger.fail(`build failed: ${err.message}`, { command: 'build' }, 2);
|
|
69
72
|
}
|
|
70
73
|
});
|
|
71
74
|
program
|
|
@@ -77,7 +80,7 @@ async function main() {
|
|
|
77
80
|
await commands_dev.devCommand(opts);
|
|
78
81
|
}
|
|
79
82
|
catch (err) {
|
|
80
|
-
util_logger.fail(`dev failed: ${err.message}`, { command: 'dev' }, 2);
|
|
83
|
+
await util_logger.fail(`dev failed: ${err.message}`, { command: 'dev' }, 2);
|
|
81
84
|
}
|
|
82
85
|
});
|
|
83
86
|
program
|
|
@@ -89,7 +92,7 @@ async function main() {
|
|
|
89
92
|
await commands_clean.cleanCommand(opts);
|
|
90
93
|
}
|
|
91
94
|
catch (err) {
|
|
92
|
-
util_logger.fail(`clean failed: ${err.message}`, { command: 'clean' }, 2);
|
|
95
|
+
await util_logger.fail(`clean failed: ${err.message}`, { command: 'clean' }, 2);
|
|
93
96
|
}
|
|
94
97
|
});
|
|
95
98
|
program
|
|
@@ -104,7 +107,7 @@ async function main() {
|
|
|
104
107
|
});
|
|
105
108
|
}
|
|
106
109
|
catch (err) {
|
|
107
|
-
util_logger.fail(`deploy failed: ${err.message}`, { command: 'deploy' }, 2);
|
|
110
|
+
await util_logger.fail(`deploy failed: ${err.message}`, { command: 'deploy' }, 2);
|
|
108
111
|
}
|
|
109
112
|
});
|
|
110
113
|
program
|
|
@@ -116,7 +119,7 @@ async function main() {
|
|
|
116
119
|
await commands_createWorkspace.createWorkspaceCommand(opts);
|
|
117
120
|
}
|
|
118
121
|
catch (err) {
|
|
119
|
-
util_logger.fail(`create-workspace failed: ${err.message}`, { command: 'create-workspace' }, 1);
|
|
122
|
+
await util_logger.fail(`create-workspace failed: ${err.message}`, { command: 'create-workspace' }, 1);
|
|
120
123
|
}
|
|
121
124
|
});
|
|
122
125
|
program
|
|
@@ -130,7 +133,7 @@ async function main() {
|
|
|
130
133
|
await commands_generateZ2hToken.generateZ2HTokenCommand(opts);
|
|
131
134
|
}
|
|
132
135
|
catch (err) {
|
|
133
|
-
util_logger.fail(`generate-z2h-token failed: ${err.message}`, { command: 'generate-z2h-token' }, 1);
|
|
136
|
+
await util_logger.fail(`generate-z2h-token failed: ${err.message}`, { command: 'generate-z2h-token' }, 1);
|
|
134
137
|
}
|
|
135
138
|
});
|
|
136
139
|
program
|
|
@@ -147,7 +150,7 @@ async function main() {
|
|
|
147
150
|
});
|
|
148
151
|
}
|
|
149
152
|
catch (err) {
|
|
150
|
-
util_logger.fail(`create failed: ${err.message}`, { command: 'create' }, 1);
|
|
153
|
+
await util_logger.fail(`create failed: ${err.message}`, { command: 'create' }, 1);
|
|
151
154
|
}
|
|
152
155
|
});
|
|
153
156
|
program
|
|
@@ -160,7 +163,7 @@ async function main() {
|
|
|
160
163
|
await commands_migrate.migrateCommand(version, opts);
|
|
161
164
|
}
|
|
162
165
|
catch (err) {
|
|
163
|
-
util_logger.fail(`migrate failed: ${err.message}`, { command: 'migrate' }, 1);
|
|
166
|
+
await util_logger.fail(`migrate failed: ${err.message}`, { command: 'migrate' }, 1);
|
|
164
167
|
}
|
|
165
168
|
});
|
|
166
169
|
await program.parseAsync(process.argv);
|
|
@@ -174,7 +177,6 @@ void main()
|
|
|
174
177
|
}
|
|
175
178
|
process.exit(0);
|
|
176
179
|
})
|
|
177
|
-
.catch((err) => {
|
|
178
|
-
util_logger.
|
|
179
|
-
process.exit(1);
|
|
180
|
+
.catch(async (err) => {
|
|
181
|
+
await util_logger.fail(`main failed: ${err.message}`, { command: 'cli-main' });
|
|
180
182
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const execa = require('execa');
|
|
4
|
+
const fsExtra = require('fs-extra');
|
|
4
5
|
const node_module = require('node:module');
|
|
6
|
+
const path = require('node:path');
|
|
5
7
|
const node_url = require('node:url');
|
|
6
|
-
const fsExtra = require('fs-extra');
|
|
7
|
-
const execa = require('execa');
|
|
8
8
|
const semver = require('semver');
|
|
9
9
|
const util_logger = require('../util/logger.js');
|
|
10
10
|
const util_workspace = require('../util/workspace.js');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../../src/shadow/scaffold.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../../src/shadow/scaffold.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AA0G9C;;;GAGG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYvG"}
|
package/dist/shadow/scaffold.js
CHANGED
|
@@ -7,7 +7,8 @@ const _interopDefault = e => e && e.__esModule ? e : { default: e };
|
|
|
7
7
|
|
|
8
8
|
const path__default = /*#__PURE__*/_interopDefault(path);
|
|
9
9
|
|
|
10
|
-
const WRAPPER_TEMPLATE = `import
|
|
10
|
+
const WRAPPER_TEMPLATE = `import '@vibe/core/tokens';
|
|
11
|
+
import ConsumerApp from '../../src/index';
|
|
11
12
|
import React from 'react';
|
|
12
13
|
import * as ReactDOM from 'react-dom/client';
|
|
13
14
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
@@ -11,7 +11,7 @@ var hooks = {
|
|
|
11
11
|
hooks: [
|
|
12
12
|
{
|
|
13
13
|
type: "command",
|
|
14
|
-
command: "if [ -f .zth/dev.pid ]; then
|
|
14
|
+
command: "if [ -f .zth/dev.pid ]; then PGID=$(ps -o pgid= -p $(cat .zth/dev.pid) 2>/dev/null | tr -d ' '); [ -n \"$PGID\" ] && kill -- -$PGID 2>/dev/null; rm -f .zth/dev.pid; fi"
|
|
15
15
|
}
|
|
16
16
|
]
|
|
17
17
|
}
|
package/dist/util/logger.d.ts
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/util/logger.js
CHANGED
|
@@ -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
|
|
package/dist/util/tracker.d.ts
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/util/tracker.js
CHANGED
|
@@ -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
|
-
|
|
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
|
@@ -4,6 +4,7 @@ import { mkdtemp, rm, writeJson, readJson, ensureDir, pathExists, writeFile } fr
|
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
5
|
|
|
6
6
|
import { runYarnInstall } from '../../util/npm/install';
|
|
7
|
+
import { buildCommand } from '../build';
|
|
7
8
|
import { createCommand } from '../create';
|
|
8
9
|
import * as manifest from '../../util/manifest';
|
|
9
10
|
|
|
@@ -14,6 +15,11 @@ vi.mock('../../util/npm/install', () => ({
|
|
|
14
15
|
runYarnInstall: vi.fn().mockResolvedValue(undefined),
|
|
15
16
|
}));
|
|
16
17
|
|
|
18
|
+
// Mock build so tsc/yarn build don't run in tests.
|
|
19
|
+
vi.mock('../build', () => ({
|
|
20
|
+
buildCommand: vi.fn().mockResolvedValue(undefined),
|
|
21
|
+
}));
|
|
22
|
+
|
|
17
23
|
vi.spyOn(manifest, 'readManifest').mockResolvedValue({});
|
|
18
24
|
|
|
19
25
|
async function makeWorkspace(tmp: string): Promise<void> {
|
|
@@ -33,6 +39,7 @@ describe('create', () => {
|
|
|
33
39
|
tmp = await mkdtemp(path.join(os.tmpdir(), 'z2h-c-'));
|
|
34
40
|
process.env.Z2H_WORKSPACE_HOME = tmp;
|
|
35
41
|
vi.mocked(runYarnInstall).mockClear();
|
|
42
|
+
vi.mocked(buildCommand).mockClear();
|
|
36
43
|
});
|
|
37
44
|
|
|
38
45
|
afterEach(async () => {
|
package/src/commands/build.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface BuildOptions {
|
|
|
8
8
|
publicUrl?: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
// Should be run from the consumer app directory — uses process.cwd() to locate it.
|
|
11
12
|
export async function buildCommand(opts: BuildOptions): Promise<void> {
|
|
12
13
|
if (opts.json) {
|
|
13
14
|
setOutputMode('json');
|
package/src/commands/clean.ts
CHANGED
package/src/commands/create.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { readManifest } from '../util/manifest';
|
|
|
8
8
|
import { mfAppName } from '../util/app-name';
|
|
9
9
|
import { APP_NAME_PATTERN } from '../constants';
|
|
10
10
|
import { runYarnInstall } from '../util/npm/install';
|
|
11
|
+
import { buildCommand } from './build';
|
|
11
12
|
|
|
12
13
|
export interface CreateOptions {
|
|
13
14
|
template?: string;
|
|
@@ -118,6 +119,11 @@ export async function createCommand(appName: string, opts: CreateOptions): Promi
|
|
|
118
119
|
info(`installing dependencies for ${appName}...`);
|
|
119
120
|
await runYarnInstall({ cwd: workspace });
|
|
120
121
|
|
|
122
|
+
// build/dev/deploy all locate the consumer via process.cwd() — chdir before calling them.
|
|
123
|
+
info(`pre-building ${appName}`);
|
|
124
|
+
process.chdir(appDir);
|
|
125
|
+
await buildCommand({});
|
|
126
|
+
|
|
121
127
|
output(`[z2h-cli] app ready at ${appDir}`, {
|
|
122
128
|
ok: true,
|
|
123
129
|
appDir,
|
package/src/commands/deploy.ts
CHANGED
|
@@ -23,6 +23,7 @@ export interface DeployOptions {
|
|
|
23
23
|
json?: boolean;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
// Should be run from the consumer app directory — uses process.cwd() to locate it.
|
|
26
27
|
export async function deployCommand(opts: DeployOptions): Promise<void> {
|
|
27
28
|
if (opts.json) {
|
|
28
29
|
setOutputMode('json');
|
package/src/commands/dev.ts
CHANGED
|
@@ -15,6 +15,7 @@ export interface DevOptions {
|
|
|
15
15
|
|
|
16
16
|
const TRIDENT_READY_PATTERN = /Server started at/i;
|
|
17
17
|
|
|
18
|
+
// Should be run from the consumer app directory — uses process.cwd() to locate it.
|
|
18
19
|
export async function devCommand(opts: DevOptions): Promise<void> {
|
|
19
20
|
if (opts.json) {
|
|
20
21
|
setOutputMode('json');
|
|
@@ -31,6 +32,8 @@ export async function devCommand(opts: DevOptions): Promise<void> {
|
|
|
31
32
|
const server = execa('yarn', ['start'], {
|
|
32
33
|
cwd: ctx.paths.shadowDir,
|
|
33
34
|
stdio: ['inherit', 'pipe', 'inherit'],
|
|
35
|
+
// Trident requires NPM_TOKEN to be set or it refuses to start; 'FAKE_TOKEN' satisfies the check without real credentials.
|
|
36
|
+
env: { ...process.env, NPM_TOKEN: process.env.NPM_TOKEN ?? 'FAKE_TOKEN' },
|
|
34
37
|
});
|
|
35
38
|
|
|
36
39
|
const pidFile = path.join(ctx.paths.shadowDir, 'dev.pid');
|
package/src/index.ts
CHANGED
|
@@ -21,7 +21,10 @@ const UPDATE_SCRIPT = path.join(os.homedir(), 'Development', 'bigbrain-z2h', 'z2
|
|
|
21
21
|
|
|
22
22
|
function selfUpdate(): void {
|
|
23
23
|
try {
|
|
24
|
-
execa('bash', [UPDATE_SCRIPT], {
|
|
24
|
+
execa('bash', [UPDATE_SCRIPT], {
|
|
25
|
+
detached: true,
|
|
26
|
+
stdio: 'ignore',
|
|
27
|
+
}).unref();
|
|
25
28
|
} catch (err) {
|
|
26
29
|
errorLog(`Z2H auto-update failed to start: ${(err as Error).message}`);
|
|
27
30
|
}
|
|
@@ -63,7 +66,7 @@ async function main(): Promise<void> {
|
|
|
63
66
|
try {
|
|
64
67
|
await trackDuration('z2h_app_build_success', () => buildCommand(opts), { app_name: getCwdAppName() });
|
|
65
68
|
} catch (err) {
|
|
66
|
-
fail(`build failed: ${(err as Error).message}`, { command: 'build' }, 2);
|
|
69
|
+
await fail(`build failed: ${(err as Error).message}`, { command: 'build' }, 2);
|
|
67
70
|
}
|
|
68
71
|
});
|
|
69
72
|
|
|
@@ -75,7 +78,7 @@ async function main(): Promise<void> {
|
|
|
75
78
|
try {
|
|
76
79
|
await devCommand(opts);
|
|
77
80
|
} catch (err) {
|
|
78
|
-
fail(`dev failed: ${(err as Error).message}`, { command: 'dev' }, 2);
|
|
81
|
+
await fail(`dev failed: ${(err as Error).message}`, { command: 'dev' }, 2);
|
|
79
82
|
}
|
|
80
83
|
});
|
|
81
84
|
|
|
@@ -87,7 +90,7 @@ async function main(): Promise<void> {
|
|
|
87
90
|
try {
|
|
88
91
|
await cleanCommand(opts);
|
|
89
92
|
} catch (err) {
|
|
90
|
-
fail(`clean failed: ${(err as Error).message}`, { command: 'clean' }, 2);
|
|
93
|
+
await fail(`clean failed: ${(err as Error).message}`, { command: 'clean' }, 2);
|
|
91
94
|
}
|
|
92
95
|
});
|
|
93
96
|
|
|
@@ -102,7 +105,7 @@ async function main(): Promise<void> {
|
|
|
102
105
|
app_name: getCwdAppName(),
|
|
103
106
|
});
|
|
104
107
|
} catch (err) {
|
|
105
|
-
fail(`deploy failed: ${(err as Error).message}`, { command: 'deploy' }, 2);
|
|
108
|
+
await fail(`deploy failed: ${(err as Error).message}`, { command: 'deploy' }, 2);
|
|
106
109
|
}
|
|
107
110
|
});
|
|
108
111
|
|
|
@@ -114,7 +117,7 @@ async function main(): Promise<void> {
|
|
|
114
117
|
try {
|
|
115
118
|
await createWorkspaceCommand(opts);
|
|
116
119
|
} catch (err) {
|
|
117
|
-
fail(`create-workspace failed: ${(err as Error).message}`, { command: 'create-workspace' }, 1);
|
|
120
|
+
await fail(`create-workspace failed: ${(err as Error).message}`, { command: 'create-workspace' }, 1);
|
|
118
121
|
}
|
|
119
122
|
});
|
|
120
123
|
|
|
@@ -130,7 +133,7 @@ async function main(): Promise<void> {
|
|
|
130
133
|
try {
|
|
131
134
|
await generateZ2HTokenCommand(opts);
|
|
132
135
|
} catch (err) {
|
|
133
|
-
fail(`generate-z2h-token failed: ${(err as Error).message}`, { command: 'generate-z2h-token' }, 1);
|
|
136
|
+
await fail(`generate-z2h-token failed: ${(err as Error).message}`, { command: 'generate-z2h-token' }, 1);
|
|
134
137
|
}
|
|
135
138
|
});
|
|
136
139
|
|
|
@@ -147,7 +150,7 @@ async function main(): Promise<void> {
|
|
|
147
150
|
template: opts.template ?? 'default',
|
|
148
151
|
});
|
|
149
152
|
} catch (err) {
|
|
150
|
-
fail(`create failed: ${(err as Error).message}`, { command: 'create' }, 1);
|
|
153
|
+
await fail(`create failed: ${(err as Error).message}`, { command: 'create' }, 1);
|
|
151
154
|
}
|
|
152
155
|
});
|
|
153
156
|
|
|
@@ -160,7 +163,7 @@ async function main(): Promise<void> {
|
|
|
160
163
|
try {
|
|
161
164
|
await migrateCommand(version, opts);
|
|
162
165
|
} catch (err) {
|
|
163
|
-
fail(`migrate failed: ${(err as Error).message}`, { command: 'migrate' }, 1);
|
|
166
|
+
await fail(`migrate failed: ${(err as Error).message}`, { command: 'migrate' }, 1);
|
|
164
167
|
}
|
|
165
168
|
});
|
|
166
169
|
|
|
@@ -176,7 +179,6 @@ void main()
|
|
|
176
179
|
}
|
|
177
180
|
process.exit(0);
|
|
178
181
|
})
|
|
179
|
-
.catch((err: unknown) => {
|
|
180
|
-
|
|
181
|
-
process.exit(1);
|
|
182
|
+
.catch(async (err: unknown) => {
|
|
183
|
+
await fail(`main failed: ${(err as Error).message}`, { command: 'cli-main' });
|
|
182
184
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { execa } from 'execa';
|
|
2
|
+
import { pathExists, readJson, writeFile, writeJson } from 'fs-extra';
|
|
2
3
|
import { createRequire } from 'node:module';
|
|
4
|
+
import path from 'node:path';
|
|
3
5
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { pathExists, readJson, writeJson, writeFile } from 'fs-extra';
|
|
5
|
-
import { execa } from 'execa';
|
|
6
6
|
import semver from 'semver';
|
|
7
|
-
import { info, warn
|
|
7
|
+
import { errorLog, info, warn } from '../util/logger';
|
|
8
8
|
import { getWorkspaceHome, isZ2hWorkspace } from '../util/workspace';
|
|
9
9
|
|
|
10
10
|
const STATE_FILE = '.z2h-migrations-state.json';
|
package/src/shadow/scaffold.ts
CHANGED
|
@@ -2,7 +2,8 @@ import path from 'node:path';
|
|
|
2
2
|
import { ensureDir, writeFile, writeJson } from 'fs-extra';
|
|
3
3
|
import type { ConsumerPaths } from '../types';
|
|
4
4
|
|
|
5
|
-
const WRAPPER_TEMPLATE = `import
|
|
5
|
+
const WRAPPER_TEMPLATE = `import '@vibe/core/tokens';
|
|
6
|
+
import ConsumerApp from '../../src/index';
|
|
6
7
|
import React from 'react';
|
|
7
8
|
import * as ReactDOM from 'react-dom/client';
|
|
8
9
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
@@ -27,7 +27,9 @@ The orchestrator routes to `z2h:feature-development`, which handles the typechec
|
|
|
27
27
|
|
|
28
28
|
## 🌟 Data-Fetching Hierarchy
|
|
29
29
|
|
|
30
|
-
When a request needs data, follow `z2h:coding-standards-mf` §0: write a `runQuery` helper for Snowflake data (TS module using `getBigBrainAPI()` for React apps; vanilla `<script>` using `window.location.origin` for html-embed apps), write a client-side fetch for other browser-accessible sources, or tell the user to reach out at `#ask-zero-to-hero` if the data needs an API key or server-side access. Backend changes to `bigbrain-zth` are not in scope.
|
|
30
|
+
When a request needs data, follow `z2h:coding-standards-mf` §0: write a `runQuery` helper for Snowflake data (TS module using `getBigBrainAPI()` for React apps; vanilla `<script>` using `window.location.origin` for html-embed apps), write a client-side fetch for other browser-accessible sources, or tell the user to reach out at `#ask-zero-to-hero` if the data needs an API key or server-side access. Backend changes to `bigbrain-zth` are not in scope — no modifications, no suggestions, no workarounds.
|
|
31
|
+
|
|
32
|
+
**Query storage:** All SQL query strings go in `src/queries.ts`, not inline in components or hooks. Import from there.
|
|
31
33
|
|
|
32
34
|
---
|
|
33
35
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"hooks": [
|
|
11
11
|
{
|
|
12
12
|
"type": "command",
|
|
13
|
-
"command": "if [ -f .zth/dev.pid ]; then
|
|
13
|
+
"command": "if [ -f .zth/dev.pid ]; then PGID=$(ps -o pgid= -p $(cat .zth/dev.pid) 2>/dev/null | tr -d ' '); [ -n \"$PGID\" ] && kill -- -$PGID 2>/dev/null; rm -f .zth/dev.pid; fi"
|
|
14
14
|
}
|
|
15
15
|
]
|
|
16
16
|
}
|
package/src/util/logger.ts
CHANGED
|
@@ -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:
|
|
64
|
+
await trackEvent('z2h_cli_error', { action: payload.command ?? 'unknown', error: message });
|
|
65
65
|
process.exit(exitCode);
|
|
66
66
|
}
|
package/src/util/tracker.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
}
|