@vyriy/create 0.5.5 → 0.6.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.
- package/package.json +2 -2
- package/preset/library.js +5 -5
- package/preset/mfe.js +98 -3
- package/preset/rest.js +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vyriy/create",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Vyriy project creation CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"vyriy-create": "./bin/index.js"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@vyriy/check": "0.
|
|
15
|
+
"@vyriy/check": "0.6.0"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"@testing-library/dom": "^10.4.1",
|
package/preset/library.js
CHANGED
|
@@ -441,11 +441,11 @@ Custom classes are composed with the component classes.
|
|
|
441
441
|
|
|
442
442
|
\`ButtonProps\` extends \`ComponentProps<'button'>\`.
|
|
443
443
|
|
|
444
|
-
| Prop | Type
|
|
445
|
-
| ----------- |
|
|
446
|
-
| \`variant\` | \`'primary'
|
|
447
|
-
| \`className\` | \`string\`
|
|
448
|
-
| \`children\` | \`ReactNode\`
|
|
444
|
+
| Prop | Type | Default | Description |
|
|
445
|
+
| ----------- | ----------- | ------------ | -------------------------------------------------- | -------------------------- |
|
|
446
|
+
| \`variant\` | \`'primary' | 'secondary'\` | \`'primary'\` | Controls the visual style. |
|
|
447
|
+
| \`className\` | \`string\` | - | Adds custom classes alongside the library classes. |
|
|
448
|
+
| \`children\` | \`ReactNode\` | - | Button content. |
|
|
449
449
|
`,
|
|
450
450
|
'packages/components/button/types.ts': `import type { ComponentProps, FC } from 'react';
|
|
451
451
|
|
package/preset/mfe.js
CHANGED
|
@@ -312,11 +312,106 @@ yarn build:static
|
|
|
312
312
|
'workspaces/ui/bin/build.sh': '#!/usr/bin/env sh\n\nset -e\n\nscriptdir="$PWD/workspaces/ui";\n\n. "$PWD/workspaces/env.sh"\n\nNODE_ENV=production \\\nnpx webpack \\\n--config $scriptdir/webpack.config.ts\n',
|
|
313
313
|
'workspaces/ui/bin/start.sh': '#!/usr/bin/env sh\n\nset -e\n\nscriptdir="$PWD/workspaces/ui";\n\n. "$PWD/workspaces/env.sh"\n\nnpx webpack serve \\\n--open \\\n--config $scriptdir/webpack.config.ts \\\n--port $UI_PORT\n',
|
|
314
314
|
'workspaces/ui/doc.mdx': "import { Meta, Markdown } from '@storybook/addon-docs/blocks';\nimport ReadMe from './README.md?raw';\n\n<Meta title=\"Workspaces/UI\" />\n\n<Markdown>{ReadMe}</Markdown>\n",
|
|
315
|
-
'workspaces/ui/index.test.tsx':
|
|
315
|
+
'workspaces/ui/index.test.tsx': `import { beforeAll, describe, expect, it, jest } from '@jest/globals';
|
|
316
|
+
import type { ReactElement } from 'react';
|
|
317
|
+
|
|
318
|
+
type CustomElementOptions = {
|
|
319
|
+
tag: string;
|
|
320
|
+
elements: () => {
|
|
321
|
+
elements: HTMLElement[];
|
|
322
|
+
root: HTMLElement;
|
|
323
|
+
};
|
|
324
|
+
render: (el: HTMLElement) => ReactElement<{
|
|
325
|
+
onClick: () => void;
|
|
326
|
+
tags?: string[];
|
|
327
|
+
}>;
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
const customElementMock = jest.fn();
|
|
331
|
+
const dispatchProfileCardAnalyticsEventMock = jest.fn();
|
|
332
|
+
const dispatchProfileCardSelectEventMock = jest.fn();
|
|
333
|
+
let options: CustomElementOptions;
|
|
334
|
+
|
|
335
|
+
jest.mock('@vyriy/render/custom-element', () => ({
|
|
336
|
+
customElement: customElementMock,
|
|
337
|
+
}));
|
|
338
|
+
|
|
339
|
+
jest.mock('@p/event', () => ({
|
|
340
|
+
dispatchProfileCardAnalyticsEvent: dispatchProfileCardAnalyticsEventMock,
|
|
341
|
+
dispatchProfileCardSelectEvent: dispatchProfileCardSelectEventMock,
|
|
342
|
+
}));
|
|
343
|
+
|
|
344
|
+
describe('workspaces/ui/index.tsx', () => {
|
|
345
|
+
beforeAll(async () => {
|
|
346
|
+
process.env.UI = 'http://localhost:3002';
|
|
347
|
+
|
|
348
|
+
await import('./index.js');
|
|
349
|
+
|
|
350
|
+
[options] = (customElementMock.mock.calls[0] ?? []) as [CustomElementOptions];
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
it('registers the profile-card custom element with event dispatching', () => {
|
|
354
|
+
const renderElements = options.elements();
|
|
355
|
+
const host = document.createElement('vyriy-profile-card');
|
|
356
|
+
|
|
357
|
+
host.setAttribute('avatarUrl', 'https://example.com/avatar.png');
|
|
358
|
+
host.setAttribute('description', 'Profile description');
|
|
359
|
+
host.setAttribute('name', 'Ada Lovelace');
|
|
360
|
+
host.setAttribute('tags', '["math","computing"]');
|
|
361
|
+
host.setAttribute('title', 'Mathematician');
|
|
362
|
+
|
|
363
|
+
const element = options.render(host);
|
|
364
|
+
|
|
365
|
+
element.props.onClick();
|
|
366
|
+
|
|
367
|
+
expect(options.tag).toBe('vyriy-profile-card');
|
|
368
|
+
expect(renderElements.root).toBeInstanceOf(HTMLDivElement);
|
|
369
|
+
expect(renderElements.elements[0]).toBeInstanceOf(HTMLLinkElement);
|
|
370
|
+
expect((renderElements.elements[0] as HTMLLinkElement).href).toBe('http://localhost:3002/main.css');
|
|
371
|
+
expect(element.props.tags).toEqual(['math', 'computing']);
|
|
372
|
+
expect(dispatchProfileCardSelectEventMock).toHaveBeenCalledWith(host, {
|
|
373
|
+
avatarUrl: 'https://example.com/avatar.png',
|
|
374
|
+
name: 'Ada Lovelace',
|
|
375
|
+
role: 'Mathematician',
|
|
376
|
+
});
|
|
377
|
+
expect(dispatchProfileCardAnalyticsEventMock).toHaveBeenCalledWith(host, {
|
|
378
|
+
avatarUrl: 'https://example.com/avatar.png',
|
|
379
|
+
name: 'Ada Lovelace',
|
|
380
|
+
role: 'Mathematician',
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
it('ignores missing and invalid tags attributes', () => {
|
|
385
|
+
const host = document.createElement('vyriy-profile-card');
|
|
386
|
+
|
|
387
|
+
expect(options.render(host).props.tags).toBeUndefined();
|
|
388
|
+
|
|
389
|
+
host.setAttribute('tags', 'not json');
|
|
390
|
+
|
|
391
|
+
expect(options.render(host).props.tags).toBeUndefined();
|
|
392
|
+
|
|
393
|
+
host.setAttribute('tags', '{"tag":"math"}');
|
|
394
|
+
|
|
395
|
+
expect(options.render(host).props.tags).toBeUndefined();
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
it('falls back to empty profile values when attributes are missing', () => {
|
|
399
|
+
const host = document.createElement('vyriy-profile-card');
|
|
400
|
+
const element = options.render(host);
|
|
401
|
+
|
|
402
|
+
element.props.onClick();
|
|
403
|
+
|
|
404
|
+
expect(dispatchProfileCardSelectEventMock).toHaveBeenLastCalledWith(host, {
|
|
405
|
+
avatarUrl: null,
|
|
406
|
+
name: '',
|
|
407
|
+
role: undefined,
|
|
408
|
+
});
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
`,
|
|
316
412
|
'workspaces/ui/index.tsx': `import { customElement } from '@vyriy/render/custom-element';
|
|
317
413
|
|
|
318
414
|
import { dispatchProfileCardAnalyticsEvent, dispatchProfileCardSelectEvent } from '@p/event';
|
|
319
|
-
import { getUi } from '@p/env';
|
|
320
415
|
|
|
321
416
|
import { ProfileCard } from '@p/components/profile-card';
|
|
322
417
|
import '@p/components/styles.scss';
|
|
@@ -352,7 +447,7 @@ customElement({
|
|
|
352
447
|
const container = document.createElement('div');
|
|
353
448
|
|
|
354
449
|
link.rel = 'stylesheet';
|
|
355
|
-
link.href = \`\${
|
|
450
|
+
link.href = \`\${process.env.UI}/main.css\`;
|
|
356
451
|
|
|
357
452
|
return {
|
|
358
453
|
elements: [link, container],
|
package/preset/rest.js
CHANGED
|
@@ -83,8 +83,8 @@ Storybook, and workspace-level build scripts.
|
|
|
83
83
|
|
|
84
84
|
## Workspaces
|
|
85
85
|
|
|
86
|
-
| Workspace
|
|
87
|
-
|
|
|
86
|
+
| Workspace | Description |
|
|
87
|
+
| -------------------------------------- | ------------------------------------------------------ |
|
|
88
88
|
| [\`@w/api\`](./workspaces/api/README.md) | HTTP API server with OpenAPI and Scalar documentation. |
|
|
89
89
|
|
|
90
90
|
## Local development
|
|
@@ -315,8 +315,8 @@ OpenAPI document rendered by Scalar.
|
|
|
315
315
|
|
|
316
316
|
## Routes
|
|
317
317
|
|
|
318
|
-
| Method
|
|
319
|
-
|
|
|
318
|
+
| Method | Path | Description |
|
|
319
|
+
| ------ | --------------- | ------------------------------------------------- |
|
|
320
320
|
| \`GET\` | \`/\` | Serves the Scalar API reference UI. |
|
|
321
321
|
| \`GET\` | \`/openapi.json\` | Returns the OpenAPI 3.0 document for the API. |
|
|
322
322
|
| \`GET\` | \`/api/test\` | Returns a JSON test response: \`{ "test": "ok" }\`. |
|