@mondaydotcomorg/z2h-cli 0.3.0 โ†’ 0.4.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.
@@ -37,7 +37,7 @@ async function createWorkspaceCommand(opts) {
37
37
  if (await fsExtra.pathExists(home)) {
38
38
  const entries = await fsExtra.readdir(home);
39
39
  if (entries.length > 0) {
40
- throw new Error(`${home} is non-empty. Wipe it before running create-workspace.`);
40
+ throw new Error(`Workspace already exists at ${home}. Remove it and try again.`);
41
41
  }
42
42
  }
43
43
  else {
@@ -66,12 +66,12 @@ async function createWorkspaceCommand(opts) {
66
66
  fsExtra.copy(path__default.default.join(wsTemplatesDir, 'README.md'), path__default.default.join(home, 'README.md')),
67
67
  fsExtra.copy(path__default.default.join(wsTemplatesDir, 'yarn-releases', 'yarn-4.5.1.cjs'), path__default.default.join(home, '.yarn', 'releases', 'yarn-4.5.1.cjs')),
68
68
  ]);
69
- util_logger.info(`bootstrapping workspace at ${home}`);
69
+ util_logger.info(`setting up your Z2H workspace โ€” this may take a minute...`);
70
70
  await execa.execa('yarn', ['install'], {
71
71
  cwd: home,
72
72
  stdio: 'inherit',
73
73
  });
74
- util_logger.output(`[z2h-cli] workspace ready at ${home}`, {
74
+ util_logger.output(`Your workspace is ready! ๐Ÿš€ Apps will live at ${home}`, {
75
75
  ok: true,
76
76
  workspace: home,
77
77
  z2hCliVersion: cliVersion,
@@ -95,7 +95,7 @@ async function createCommand(appName, opts) {
95
95
  if (template === 'html-embed' && opts.htmlFile) {
96
96
  await fsExtra.copy(opts.htmlFile, path__default.default.join(appDir, 'src', 'page.html'));
97
97
  }
98
- util_logger.info(`installing into workspace at ${workspace}`);
98
+ util_logger.info(`installing dependencies for ${appName}...`);
99
99
  await execa.execa('yarn', ['install'], {
100
100
  cwd: workspace,
101
101
  stdio: 'inherit',
@@ -31,7 +31,7 @@ async function createWorkspaceCommand(opts) {
31
31
  if (await pathExists(home)) {
32
32
  const entries = await readdir(home);
33
33
  if (entries.length > 0) {
34
- throw new Error(`${home} is non-empty. Wipe it before running create-workspace.`);
34
+ throw new Error(`Workspace already exists at ${home}. Remove it and try again.`);
35
35
  }
36
36
  }
37
37
  else {
@@ -60,12 +60,12 @@ async function createWorkspaceCommand(opts) {
60
60
  copy(path.join(wsTemplatesDir, 'README.md'), path.join(home, 'README.md')),
61
61
  copy(path.join(wsTemplatesDir, 'yarn-releases', 'yarn-4.5.1.cjs'), path.join(home, '.yarn', 'releases', 'yarn-4.5.1.cjs')),
62
62
  ]);
63
- info(`bootstrapping workspace at ${home}`);
63
+ info(`setting up your Z2H workspace โ€” this may take a minute...`);
64
64
  await execa('yarn', ['install'], {
65
65
  cwd: home,
66
66
  stdio: 'inherit',
67
67
  });
68
- output(`[z2h-cli] workspace ready at ${home}`, {
68
+ output(`Your workspace is ready! ๐Ÿš€ Apps will live at ${home}`, {
69
69
  ok: true,
70
70
  workspace: home,
71
71
  z2hCliVersion: cliVersion,
@@ -89,7 +89,7 @@ async function createCommand(appName, opts) {
89
89
  if (template === 'html-embed' && opts.htmlFile) {
90
90
  await copy(opts.htmlFile, path.join(appDir, 'src', 'page.html'));
91
91
  }
92
- info(`installing into workspace at ${workspace}`);
92
+ info(`installing dependencies for ${appName}...`);
93
93
  await execa('yarn', ['install'], {
94
94
  cwd: workspace,
95
95
  stdio: 'inherit',
@@ -1,3 +1,4 @@
1
+ import { createRequire } from 'node:module';
1
2
  import { Command } from 'commander';
2
3
  import { devCommand } from './commands/dev.mjs';
3
4
  import { buildCommand } from './commands/build.mjs';
@@ -8,6 +9,7 @@ import { createCommand } from './commands/create.mjs';
8
9
  import { generateZ2HTokenCommand } from './commands/generate-z2h-token.mjs';
9
10
  import { errorLog, fail } from './util/logger.mjs';
10
11
 
12
+ const { version } = createRequire(import.meta.url)('../package.json');
11
13
  async function main() {
12
14
  const program = new Command();
13
15
  program
@@ -24,7 +26,7 @@ async function main() {
24
26
  ' 1 user-resolvable error (bad cwd, invalid package.json, lock held)',
25
27
  ' 2 system error (yarn install or trident build failed)',
26
28
  ].join('\n'))
27
- .version('0.0.0');
29
+ .version(version);
28
30
  program
29
31
  .command('build')
30
32
  .description('Build the consumer into its .zth/ shadow and copy artifacts to ./build/')
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ const node_module = require('node:module');
1
2
  const commander = require('commander');
2
3
  const commands_dev = require('./commands/dev.js');
3
4
  const commands_build = require('./commands/build.js');
@@ -8,6 +9,8 @@ const commands_create = require('./commands/create.js');
8
9
  const commands_generateZ2hToken = require('./commands/generate-z2h-token.js');
9
10
  const util_logger = require('./util/logger.js');
10
11
 
12
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
13
+ const { version } = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)))('../package.json');
11
14
  async function main() {
12
15
  const program = new commander.Command();
13
16
  program
@@ -24,7 +27,7 @@ async function main() {
24
27
  ' 1 user-resolvable error (bad cwd, invalid package.json, lock held)',
25
28
  ' 2 system error (yarn install or trident build failed)',
26
29
  ].join('\n'))
27
- .version('0.0.0');
30
+ .version(version);
28
31
  program
29
32
  .command('build')
30
33
  .description('Build the consumer into its .zth/ shadow and copy artifacts to ./build/')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mondaydotcomorg/z2h-cli",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "bin": "./bin/z2h-cli.js",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -57,7 +57,7 @@ describe('create-workspace', () => {
57
57
  await ensureDir(tmp);
58
58
  await writeJson(path.join(tmp, 'somefile.json'), { hello: 'world' });
59
59
 
60
- await expect(createWorkspaceCommand({})).rejects.toThrow(/non-empty/);
60
+ await expect(createWorkspaceCommand({})).rejects.toThrow(/Workspace already exists/);
61
61
  expect(execa).not.toHaveBeenCalled();
62
62
  });
63
63
 
@@ -77,11 +77,7 @@ describe('create', () => {
77
77
  expect(content).toContain('export default function DemoApp()');
78
78
  expect(content).not.toContain('__APP_COMPONENT__');
79
79
 
80
- expect(execa).toHaveBeenCalledWith(
81
- 'yarn',
82
- expect.arrayContaining(['install']),
83
- expect.objectContaining({ cwd: tmp })
84
- );
80
+ expect(execa).toHaveBeenCalledWith('yarn', ['install'], expect.any(Object));
85
81
  });
86
82
 
87
83
  it('scaffolds an html-embed app and copies the html file', async () => {
@@ -38,7 +38,7 @@ export async function createWorkspaceCommand(opts: CreateWorkspaceOptions): Prom
38
38
  if (await pathExists(home)) {
39
39
  const entries = await readdir(home);
40
40
  if (entries.length > 0) {
41
- throw new Error(`${home} is non-empty. Wipe it before running create-workspace.`);
41
+ throw new Error(`Workspace already exists at ${home}. Remove it and try again.`);
42
42
  }
43
43
  } else {
44
44
  await ensureDir(home);
@@ -72,13 +72,13 @@ export async function createWorkspaceCommand(opts: CreateWorkspaceOptions): Prom
72
72
  ),
73
73
  ]);
74
74
 
75
- info(`bootstrapping workspace at ${home}`);
75
+ info(`setting up your Z2H workspace โ€” this may take a minute...`);
76
76
  await execa('yarn', ['install'], {
77
77
  cwd: home,
78
78
  stdio: 'inherit',
79
79
  });
80
80
 
81
- output(`[z2h-cli] workspace ready at ${home}`, {
81
+ output(`Your workspace is ready! ๐Ÿš€ Apps will live at ${home}`, {
82
82
  ok: true,
83
83
  workspace: home,
84
84
  z2hCliVersion: cliVersion,
@@ -115,7 +115,7 @@ export async function createCommand(appName: string, opts: CreateOptions): Promi
115
115
  await copy(opts.htmlFile, path.join(appDir, 'src', 'page.html'));
116
116
  }
117
117
 
118
- info(`installing into workspace at ${workspace}`);
118
+ info(`installing dependencies for ${appName}...`);
119
119
  await execa('yarn', ['install'], {
120
120
  cwd: workspace,
121
121
  stdio: 'inherit',
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { createRequire } from 'node:module';
1
2
  import { Command } from 'commander';
2
3
  import { devCommand } from './commands/dev';
3
4
  import { buildCommand } from './commands/build';
@@ -8,6 +9,8 @@ import { createCommand } from './commands/create';
8
9
  import { generateZ2HTokenCommand } from './commands/generate-z2h-token';
9
10
  import { errorLog, fail } from './util/logger';
10
11
 
12
+ const { version } = createRequire(import.meta.url)('../package.json') as { version: string };
13
+
11
14
  async function main(): Promise<void> {
12
15
  const program = new Command();
13
16
  program
@@ -26,7 +29,7 @@ async function main(): Promise<void> {
26
29
  ' 2 system error (yarn install or trident build failed)',
27
30
  ].join('\n')
28
31
  )
29
- .version('0.0.0');
32
+ .version(version);
30
33
 
31
34
  program
32
35
  .command('build')
@@ -25,15 +25,9 @@ The orchestrator routes to `z2h:feature-development`, which handles the typechec
25
25
 
26
26
  ---
27
27
 
28
- ## ๐ŸŒŸ Prefer Frontend Over Backend
28
+ ## ๐ŸŒŸ Data-Fetching Hierarchy
29
29
 
30
- If a request *could* be solved in this app using existing backend endpoints โ€” do that. Backend changes go through a slow PR + Harmony pipeline; frontend changes ship in seconds via `z2h-cli deploy`.
31
-
32
- When uncertain, ask:
33
-
34
- > "Can we do this in the app with existing endpoints, or does it need a backend change?"
35
-
36
- Only escalate to `z2h:backend-feature-development` for genuinely new persisted entities, schemas, write paths, or server-side rules.
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 `#zero-to-hero` if the data needs an API key or server-side access. Backend changes to `bigbrain-zth` are not in scope.
37
31
 
38
32
  ---
39
33
 
@@ -12,7 +12,7 @@
12
12
  "react-error-boundary": "^3.1.3"
13
13
  },
14
14
  "devDependencies": {
15
- "@mondaydotcomorg/bigbrain-types": "^0.3.3",
15
+ "@mondaydotcomorg/bigbrain-types": "^0.3.4",
16
16
  "@mondaydotcomorg/mf-api-types": "^0.1.1",
17
17
  "@mondaydotcomorg/trident-toolkit": "^2.9.25",
18
18
  "@mondaydotcomorg/z2h-cli": "__Z2H_CLI_VERSION__",