@mondaydotcomorg/z2h-cli 0.24.2 → 0.25.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.
@@ -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;AA0G9C;;;GAGG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYvG"}
1
+ {"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../../../src/shadow/scaffold.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;GAGG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYvG"}
@@ -1,104 +1,7 @@
1
1
  import path from 'node:path';
2
2
  import { ensureDir, writeFile, writeJson } from 'fs-extra';
3
+ import { WRAPPER_TEMPLATE, tridentrcTemplate, dtsFileTemplate, TSCONFIG_TEMPLATE } from '@mondaydotcomorg/z2h-shared-utils/mf-scaffold';
3
4
 
4
- const WRAPPER_TEMPLATE = `import '@vibe/core/tokens';
5
- import ConsumerApp from '../../src/index';
6
- import React from 'react';
7
- import * as ReactDOM from 'react-dom/client';
8
- import { ErrorBoundary } from 'react-error-boundary';
9
-
10
- const roots = new Map<HTMLElement, ReactDOM.Root>();
11
-
12
- export function init() {}
13
-
14
- export function render(element: HTMLElement) {
15
- const root = ReactDOM.createRoot(element);
16
- root.render(
17
- <ErrorBoundary fallback={<div style={{ padding: 16 }}>This app crashed.</div>}>
18
- <ConsumerApp />
19
- </ErrorBoundary>,
20
- );
21
- roots.set(element, root);
22
- }
23
-
24
- export function unmount({ element }: { element: HTMLElement }) {
25
- const root = roots.get(element);
26
- if (root) {
27
- root.unmount();
28
- roots.delete(element);
29
- }
30
- }
31
- `;
32
- const tridentrcTemplate = (appName, port) => `/** @type {import("@mondaydotcomorg/trident-user-config").MicroFrontendConfig} */
33
- const config = {
34
- appName: '${appName}',
35
- port: ${port},
36
- };
37
-
38
- module.exports = config;
39
- `;
40
- const dtsFileTemplate = () => `
41
- declare module '*.module.css' {
42
- const classNames: {
43
- [className: string]: string;
44
- };
45
- export = classNames;
46
- }
47
-
48
- declare module '*.module.scss' {
49
- const classNames: {
50
- [className: string]: string;
51
- };
52
- export = classNames;
53
- }
54
-
55
- declare module '*.jpg' {
56
- const e: string;
57
- export default e;
58
- }
59
- declare module '*.jpeg' {
60
- const e: string;
61
- export default e;
62
- }
63
- declare module '*.png' {
64
- const e: string;
65
- export default e;
66
- }
67
- declare module '*.riv' {
68
- const e: string;
69
- export default e;
70
- }
71
-
72
- declare module '*.wasm' {
73
- const e: string;
74
- export default e;
75
- }
76
-
77
- declare module '*.html?url' {
78
- const src: string;
79
- export default src;
80
- }
81
- `;
82
- const TSCONFIG_TEMPLATE = {
83
- compilerOptions: {
84
- target: 'es5',
85
- lib: ['dom', 'dom.iterable', 'esnext'],
86
- allowJs: false,
87
- skipLibCheck: true,
88
- esModuleInterop: true,
89
- allowSyntheticDefaultImports: true,
90
- strict: false,
91
- module: 'esnext',
92
- moduleResolution: 'bundler',
93
- resolveJsonModule: true,
94
- noImplicitAny: false,
95
- isolatedModules: true,
96
- baseUrl: 'src',
97
- noEmit: true,
98
- jsx: 'react-jsx',
99
- },
100
- include: ['src', '../src'],
101
- };
102
5
  /**
103
6
  * Write every generated file under .zth/. Overwrites on every run so the
104
7
  * shadow dir is a deterministic function of the CLI version — no drift.
@@ -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;AA0G9C;;;GAGG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYvG"}
1
+ {"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../../src/shadow/scaffold.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;GAGG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYvG"}
@@ -2,120 +2,23 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const path = require('node:path');
4
4
  const fs = require('fs-extra');
5
+ const mfScaffold = require('@mondaydotcomorg/z2h-shared-utils/mf-scaffold');
5
6
 
6
7
  const _interopDefault = e => e && e.__esModule ? e : { default: e };
7
8
 
8
9
  const path__default = /*#__PURE__*/_interopDefault(path);
9
10
 
10
- const WRAPPER_TEMPLATE = `import '@vibe/core/tokens';
11
- import ConsumerApp from '../../src/index';
12
- import React from 'react';
13
- import * as ReactDOM from 'react-dom/client';
14
- import { ErrorBoundary } from 'react-error-boundary';
15
-
16
- const roots = new Map<HTMLElement, ReactDOM.Root>();
17
-
18
- export function init() {}
19
-
20
- export function render(element: HTMLElement) {
21
- const root = ReactDOM.createRoot(element);
22
- root.render(
23
- <ErrorBoundary fallback={<div style={{ padding: 16 }}>This app crashed.</div>}>
24
- <ConsumerApp />
25
- </ErrorBoundary>,
26
- );
27
- roots.set(element, root);
28
- }
29
-
30
- export function unmount({ element }: { element: HTMLElement }) {
31
- const root = roots.get(element);
32
- if (root) {
33
- root.unmount();
34
- roots.delete(element);
35
- }
36
- }
37
- `;
38
- const tridentrcTemplate = (appName, port) => `/** @type {import("@mondaydotcomorg/trident-user-config").MicroFrontendConfig} */
39
- const config = {
40
- appName: '${appName}',
41
- port: ${port},
42
- };
43
-
44
- module.exports = config;
45
- `;
46
- const dtsFileTemplate = () => `
47
- declare module '*.module.css' {
48
- const classNames: {
49
- [className: string]: string;
50
- };
51
- export = classNames;
52
- }
53
-
54
- declare module '*.module.scss' {
55
- const classNames: {
56
- [className: string]: string;
57
- };
58
- export = classNames;
59
- }
60
-
61
- declare module '*.jpg' {
62
- const e: string;
63
- export default e;
64
- }
65
- declare module '*.jpeg' {
66
- const e: string;
67
- export default e;
68
- }
69
- declare module '*.png' {
70
- const e: string;
71
- export default e;
72
- }
73
- declare module '*.riv' {
74
- const e: string;
75
- export default e;
76
- }
77
-
78
- declare module '*.wasm' {
79
- const e: string;
80
- export default e;
81
- }
82
-
83
- declare module '*.html?url' {
84
- const src: string;
85
- export default src;
86
- }
87
- `;
88
- const TSCONFIG_TEMPLATE = {
89
- compilerOptions: {
90
- target: 'es5',
91
- lib: ['dom', 'dom.iterable', 'esnext'],
92
- allowJs: false,
93
- skipLibCheck: true,
94
- esModuleInterop: true,
95
- allowSyntheticDefaultImports: true,
96
- strict: false,
97
- module: 'esnext',
98
- moduleResolution: 'bundler',
99
- resolveJsonModule: true,
100
- noImplicitAny: false,
101
- isolatedModules: true,
102
- baseUrl: 'src',
103
- noEmit: true,
104
- jsx: 'react-jsx',
105
- },
106
- include: ['src', '../src'],
107
- };
108
11
  /**
109
12
  * Write every generated file under .zth/. Overwrites on every run so the
110
13
  * shadow dir is a deterministic function of the CLI version — no drift.
111
14
  */
112
15
  async function scaffoldShadow(paths, appName, port) {
113
16
  await fs.ensureDir(paths.shadowSrc);
114
- await fs.writeFile(paths.shadowWrapper, WRAPPER_TEMPLATE);
115
- await fs.writeFile(paths.shadowTridentrc, tridentrcTemplate(appName, port));
17
+ await fs.writeFile(paths.shadowWrapper, mfScaffold.WRAPPER_TEMPLATE);
18
+ await fs.writeFile(paths.shadowTridentrc, mfScaffold.tridentrcTemplate(appName, port));
116
19
  await fs.writeFile(paths.shadowNvmrc, `${process.version}\n`);
117
- await fs.writeFile(paths.shadowDts, dtsFileTemplate());
118
- await fs.writeJson(paths.shadowTsconfig, TSCONFIG_TEMPLATE, { spaces: 2 });
20
+ await fs.writeFile(paths.shadowDts, mfScaffold.dtsFileTemplate());
21
+ await fs.writeJson(paths.shadowTsconfig, mfScaffold.TSCONFIG_TEMPLATE, { spaces: 2 });
119
22
  // Drop a stub README so contributors who open .zth/ know what they're looking at.
120
23
  await fs.writeFile(path__default.default.join(paths.shadowDir, 'README.md'), '# .zth/\nGenerated by z2h-cli. Do not edit — run `z2h-cli build` or `z2h-cli dev` to refresh.\n');
121
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mondaydotcomorg/z2h-cli",
3
- "version": "0.24.2",
3
+ "version": "0.25.0",
4
4
  "bin": "./bin/z2h-cli.js",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -51,6 +51,7 @@
51
51
  ],
52
52
  "dependencies": {
53
53
  "@aws-sdk/client-s3": "^3.706.0",
54
+ "@mondaydotcomorg/z2h-shared-utils": "^0.3.0",
54
55
  "chokidar": "^3.6.0",
55
56
  "commander": "^12.1.0",
56
57
  "cors": "^2.8.6",
@@ -1,111 +1,13 @@
1
1
  import path from 'node:path';
2
2
  import { ensureDir, writeFile, writeJson } from 'fs-extra';
3
+ import {
4
+ WRAPPER_TEMPLATE,
5
+ tridentrcTemplate,
6
+ dtsFileTemplate,
7
+ TSCONFIG_TEMPLATE,
8
+ } from '@mondaydotcomorg/z2h-shared-utils/mf-scaffold';
3
9
  import type { ConsumerPaths } from '../types';
4
10
 
5
- const WRAPPER_TEMPLATE = `import '@vibe/core/tokens';
6
- import ConsumerApp from '../../src/index';
7
- import React from 'react';
8
- import * as ReactDOM from 'react-dom/client';
9
- import { ErrorBoundary } from 'react-error-boundary';
10
-
11
- const roots = new Map<HTMLElement, ReactDOM.Root>();
12
-
13
- export function init() {}
14
-
15
- export function render(element: HTMLElement) {
16
- const root = ReactDOM.createRoot(element);
17
- root.render(
18
- <ErrorBoundary fallback={<div style={{ padding: 16 }}>This app crashed.</div>}>
19
- <ConsumerApp />
20
- </ErrorBoundary>,
21
- );
22
- roots.set(element, root);
23
- }
24
-
25
- export function unmount({ element }: { element: HTMLElement }) {
26
- const root = roots.get(element);
27
- if (root) {
28
- root.unmount();
29
- roots.delete(element);
30
- }
31
- }
32
- `;
33
-
34
- const tridentrcTemplate = (appName: string, port: number): string =>
35
- `/** @type {import("@mondaydotcomorg/trident-user-config").MicroFrontendConfig} */
36
- const config = {
37
- appName: '${appName}',
38
- port: ${port},
39
- };
40
-
41
- module.exports = config;
42
- `;
43
-
44
- const dtsFileTemplate = (): string =>
45
- `
46
- declare module '*.module.css' {
47
- const classNames: {
48
- [className: string]: string;
49
- };
50
- export = classNames;
51
- }
52
-
53
- declare module '*.module.scss' {
54
- const classNames: {
55
- [className: string]: string;
56
- };
57
- export = classNames;
58
- }
59
-
60
- declare module '*.jpg' {
61
- const e: string;
62
- export default e;
63
- }
64
- declare module '*.jpeg' {
65
- const e: string;
66
- export default e;
67
- }
68
- declare module '*.png' {
69
- const e: string;
70
- export default e;
71
- }
72
- declare module '*.riv' {
73
- const e: string;
74
- export default e;
75
- }
76
-
77
- declare module '*.wasm' {
78
- const e: string;
79
- export default e;
80
- }
81
-
82
- declare module '*.html?url' {
83
- const src: string;
84
- export default src;
85
- }
86
- `;
87
-
88
- const TSCONFIG_TEMPLATE = {
89
- compilerOptions: {
90
- target: 'es5',
91
- lib: ['dom', 'dom.iterable', 'esnext'],
92
- allowJs: false,
93
- skipLibCheck: true,
94
- esModuleInterop: true,
95
- allowSyntheticDefaultImports: true,
96
- strict: false,
97
- module: 'esnext',
98
- moduleResolution: 'bundler',
99
- resolveJsonModule: true,
100
- noImplicitAny: false,
101
- isolatedModules: true,
102
- baseUrl: 'src',
103
- noEmit: true,
104
- jsx: 'react-jsx',
105
- },
106
- include: ['src', '../src'],
107
- };
108
-
109
11
  /**
110
12
  * Write every generated file under .zth/. Overwrites on every run so the
111
13
  * shadow dir is a deterministic function of the CLI version — no drift.