@vyriy/create 0.5.4 → 0.5.5
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 -16
- package/plan/plan.d.ts +0 -1
- package/plan/plan.js +1 -3
- package/plan/types.d.ts +0 -1
- package/preset/api.js +118 -5
- package/preset/fullstack.js +393 -12
- package/preset/gql.js +198 -34
- package/preset/library.js +346 -180
- package/preset/mfe.js +450 -15
- package/preset/rest.js +182 -6
- package/preset/spa.js +236 -7
- package/preset/ssg.js +266 -13
- package/preset/ssr.js +256 -10
- package/prompt/index.d.ts +0 -1
- package/prompt/index.js +0 -1
- package/prompt/scope.d.ts +0 -2
- package/prompt/scope.js +0 -2
package/preset/ssg.js
CHANGED
|
@@ -35,15 +35,15 @@ export const ssg = (options) => ({
|
|
|
35
35
|
'fix:prettier': 'prettier . --write',
|
|
36
36
|
'fix:eslint': 'eslint . --fix',
|
|
37
37
|
'fix:stylelint': 'stylelint "**/*.{css,scss}" --fix',
|
|
38
|
+
'start:ssg': 'sh workspaces/ssg/bin/start.sh',
|
|
38
39
|
'lint:ts': 'tsc',
|
|
39
40
|
'lint:prettier': 'prettier . --check',
|
|
40
41
|
'lint:eslint': 'eslint .',
|
|
41
42
|
'lint:stylelint': 'stylelint "**/*.{css,scss}"',
|
|
43
|
+
'build:ssg': 'rimraf dist && sh workspaces/ssg/bin/build.sh',
|
|
42
44
|
'build:storybook': 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook build --quiet --disable-telemetry',
|
|
43
45
|
'test:jest': 'jest',
|
|
44
46
|
postinstall: 'husky',
|
|
45
|
-
'start:ssg': 'sh workspaces/ssg/bin/start.sh',
|
|
46
|
-
'build:ssg': 'rimraf dist && sh workspaces/ssg/bin/build.sh',
|
|
47
47
|
},
|
|
48
48
|
dependencies: {
|
|
49
49
|
'@vyriy/typescript-config': `^${packageJson.version}`,
|
|
@@ -74,13 +74,108 @@ export const ssg = (options) => ({
|
|
|
74
74
|
'@vyriy/cn': `^${packageJson.version}`,
|
|
75
75
|
'@vyriy/html': `^${packageJson.version}`,
|
|
76
76
|
sass: packageJson.peerDependencies.sass,
|
|
77
|
+
'@vyriy/render': `^${packageJson.version}`,
|
|
77
78
|
},
|
|
78
79
|
}, null, 2) + '\n',
|
|
79
|
-
'README.md': `#
|
|
80
|
+
'README.md': `# SSG
|
|
81
|
+
|
|
82
|
+
Calm cloud-ready static site generation application.
|
|
83
|
+
|
|
84
|
+
This repository is a Yarn workspace monorepo with a small SSG application and
|
|
85
|
+
shared packages for reusable UI and service boundaries. The current rendering
|
|
86
|
+
path fetches content from a replaceable CMS adapter, renders it through a
|
|
87
|
+
server-safe React component, and writes a static HTML page.
|
|
88
|
+
|
|
89
|
+
## Workspace Layout
|
|
90
|
+
|
|
91
|
+
\`\`\`text
|
|
92
|
+
packages/
|
|
93
|
+
components/ Shared SSR-friendly React components.
|
|
94
|
+
services/ Replaceable server-safe service adapters.
|
|
95
|
+
workspaces/
|
|
96
|
+
ssg/ Static site generation workspace.
|
|
97
|
+
\`\`\`
|
|
98
|
+
|
|
99
|
+
## Rendering Flow
|
|
100
|
+
|
|
101
|
+
The SSG workspace renders a single static page:
|
|
102
|
+
|
|
103
|
+
1. \`@p/services/cms\` returns page content.
|
|
104
|
+
2. \`@p/components\` renders the content with the \`Page\` component.
|
|
105
|
+
3. \`@w/ssg\` writes the generated document to \`dist/ssg/static/index.html\`.
|
|
106
|
+
|
|
107
|
+
The generated HTML includes compiled component styles from
|
|
108
|
+
\`packages/components/page/styles.scss\`.
|
|
109
|
+
|
|
110
|
+
## Development
|
|
111
|
+
|
|
112
|
+
Install dependencies with Yarn 4 and Node.js 24 or newer:
|
|
113
|
+
|
|
114
|
+
\`\`\`bash
|
|
115
|
+
yarn install
|
|
116
|
+
\`\`\`
|
|
117
|
+
|
|
118
|
+
Start the static generation workspace:
|
|
119
|
+
|
|
120
|
+
\`\`\`bash
|
|
121
|
+
yarn start:ssg
|
|
122
|
+
\`\`\`
|
|
123
|
+
|
|
124
|
+
Build the production SSG artifact:
|
|
125
|
+
|
|
126
|
+
\`\`\`bash
|
|
127
|
+
yarn build:ssg
|
|
128
|
+
\`\`\`
|
|
129
|
+
|
|
130
|
+
Run Storybook documentation:
|
|
131
|
+
|
|
132
|
+
\`\`\`bash
|
|
133
|
+
yarn storybook
|
|
134
|
+
\`\`\`
|
|
135
|
+
|
|
136
|
+
## Validation
|
|
137
|
+
|
|
138
|
+
Run all checks:
|
|
139
|
+
|
|
140
|
+
\`\`\`bash
|
|
141
|
+
yarn check
|
|
142
|
+
\`\`\`
|
|
143
|
+
|
|
144
|
+
Run checks separately:
|
|
145
|
+
|
|
146
|
+
\`\`\`bash
|
|
147
|
+
yarn lint
|
|
148
|
+
yarn build
|
|
149
|
+
yarn test
|
|
150
|
+
\`\`\`
|
|
151
|
+
|
|
152
|
+
Focused Jest validation can target the main packages and workspace:
|
|
153
|
+
|
|
154
|
+
\`\`\`bash
|
|
155
|
+
yarn jest workspaces/ssg packages/components packages/services --runInBand --coverage=false
|
|
156
|
+
\`\`\`
|
|
157
|
+
|
|
158
|
+
## Documentation
|
|
159
|
+
|
|
160
|
+
- \`workspaces/ssg/README.md\` documents the SSG pipeline and output.
|
|
161
|
+
- \`packages/components/README.md\` documents shared React components.
|
|
162
|
+
- \`packages/services/README.md\` documents service adapters.
|
|
163
|
+
|
|
164
|
+
The matching \`doc.mdx\` files render these README files in Storybook.
|
|
165
|
+
|
|
166
|
+
## Project Guidance
|
|
167
|
+
|
|
168
|
+
These articles describe the development approach behind this preset and provide practical guidance for evolving a project on top of it:
|
|
169
|
+
|
|
170
|
+
- [Calm Development Environment: Node.js, Corepack, Yarn and Static Preview](https://vyriy.dev/blog/calm-development-setup/) - how to keep the local development environment predictable and easy to reproduce.
|
|
171
|
+
- [Calm App Structure for the Vyriy Ecosystem](https://vyriy.dev/blog/vyriy-calm-app-structure/) - a practical project structure for Vyriy applications: shared configs, small packages, thin workspaces, Storybook docs, tests, and deployable entry points.
|
|
172
|
+
- [One Handler, Many Runtimes](https://vyriy.dev/examples/one-handler-many-runtimes/) - how @vyriy/handler, @vyriy/router, and @vyriy/server compose a calm Lambda-compatible API that can run locally, in Docker, Fargate-style HTTP runtimes, and AWS Lambda.
|
|
173
|
+
- [Storybook as Project Documentation](https://vyriy.dev/blog/storybook-as-project-documentation/) - how to use Storybook as living project documentation and a component playground.
|
|
174
|
+
`,
|
|
80
175
|
'doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
|
|
81
176
|
import ReadMe from './README.md?raw';
|
|
82
177
|
|
|
83
|
-
<Meta title="
|
|
178
|
+
<Meta title="SSG" />
|
|
84
179
|
|
|
85
180
|
<Markdown>{ReadMe}</Markdown>
|
|
86
181
|
`,
|
|
@@ -181,6 +276,101 @@ export default {
|
|
|
181
276
|
'jest.config.ts': "export { default } from '@vyriy/jest-config';\n",
|
|
182
277
|
'stylelint.config.ts': "export { default } from '@vyriy/stylelint-config';\n",
|
|
183
278
|
'assets.d.ts': "declare module '*.scss';\n",
|
|
279
|
+
'packages/components/doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
|
|
280
|
+
import ReadMe from './README.md?raw';
|
|
281
|
+
|
|
282
|
+
<Meta title="Packages/Components" />
|
|
283
|
+
|
|
284
|
+
<Markdown>{ReadMe}</Markdown>
|
|
285
|
+
`,
|
|
286
|
+
'packages/components/README.md': `# Components
|
|
287
|
+
|
|
288
|
+
Shared React components for SSR-friendly application surfaces.
|
|
289
|
+
|
|
290
|
+
The package keeps reusable UI small and framework-neutral. Components should render without browser globals, accept typed props, and stay easy to compose from server-rendered workspaces.
|
|
291
|
+
|
|
292
|
+
## Exports
|
|
293
|
+
|
|
294
|
+
### \`Page\`
|
|
295
|
+
|
|
296
|
+
Renders page body content inside the standard page content container.
|
|
297
|
+
|
|
298
|
+
\`\`\`tsx
|
|
299
|
+
import { Page, type PageProps } from '@p/components';
|
|
300
|
+
|
|
301
|
+
const props: PageProps = {
|
|
302
|
+
content: 'This is a rendered page.',
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
export const App = () => <Page {...props} />;
|
|
306
|
+
\`\`\`
|
|
307
|
+
|
|
308
|
+
Rendered markup:
|
|
309
|
+
|
|
310
|
+
\`\`\`html
|
|
311
|
+
<div class="content">This is a rendered page.</div>
|
|
312
|
+
\`\`\`
|
|
313
|
+
|
|
314
|
+
## Styling
|
|
315
|
+
|
|
316
|
+
\`Page\` uses the \`content\` class. The host workspace owns the actual CSS so the component can stay reusable across SSR and SSG outputs.
|
|
317
|
+
|
|
318
|
+
## Development
|
|
319
|
+
|
|
320
|
+
Add new public components as focused files with matching tests, then re-export them from the package entry point.
|
|
321
|
+
|
|
322
|
+
Focused validation:
|
|
323
|
+
|
|
324
|
+
\`\`\`bash
|
|
325
|
+
yarn jest packages/components --runInBand --coverage=false
|
|
326
|
+
\`\`\`
|
|
327
|
+
`,
|
|
328
|
+
'packages/services/doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
|
|
329
|
+
import ReadMe from './README.md?raw';
|
|
330
|
+
|
|
331
|
+
<Meta title="Packages/Services" />
|
|
332
|
+
|
|
333
|
+
<Markdown>{ReadMe}</Markdown>
|
|
334
|
+
`,
|
|
335
|
+
'packages/services/README.md': `# Services
|
|
336
|
+
|
|
337
|
+
Shared service adapters for application workspaces.
|
|
338
|
+
|
|
339
|
+
The package is the place for replaceable integrations such as CMS access, API clients, and other server-safe service boundaries. Keep adapters typed, deterministic in tests, and free from direct UI concerns.
|
|
340
|
+
|
|
341
|
+
## Exports
|
|
342
|
+
|
|
343
|
+
### \`cms\`
|
|
344
|
+
|
|
345
|
+
CMS content adapter used by application workspaces before rendering the page.
|
|
346
|
+
|
|
347
|
+
\`\`\`ts
|
|
348
|
+
import { cms } from '@p/services/cms';
|
|
349
|
+
|
|
350
|
+
const content = await cms.getContent();
|
|
351
|
+
\`\`\`
|
|
352
|
+
|
|
353
|
+
\`getContent()\` currently returns sample content:
|
|
354
|
+
|
|
355
|
+
\`\`\`ts
|
|
356
|
+
{
|
|
357
|
+
title: 'Sample Content',
|
|
358
|
+
body: 'This is a sample content fetched from the CMS.',
|
|
359
|
+
}
|
|
360
|
+
\`\`\`
|
|
361
|
+
|
|
362
|
+
The returned shape is intended for server rendering: \`title\` is used for document metadata, and \`body\` is passed to the page component.
|
|
363
|
+
|
|
364
|
+
## Development
|
|
365
|
+
|
|
366
|
+
Keep service modules behind small public methods so real providers can replace placeholders without coupling callers to a specific CMS, network client, or runtime host.
|
|
367
|
+
|
|
368
|
+
Focused validation:
|
|
369
|
+
|
|
370
|
+
\`\`\`bash
|
|
371
|
+
yarn jest packages/services --runInBand --coverage=false
|
|
372
|
+
\`\`\`
|
|
373
|
+
`,
|
|
184
374
|
'packages/components/package.json': JSON.stringify({
|
|
185
375
|
name: '@p/components',
|
|
186
376
|
private: true,
|
|
@@ -300,7 +490,73 @@ import ReadMe from './README.md?raw';
|
|
|
300
490
|
|
|
301
491
|
<Markdown>{ReadMe}</Markdown>
|
|
302
492
|
`,
|
|
303
|
-
'workspaces/ssg/README.md': `#
|
|
493
|
+
'workspaces/ssg/README.md': `# @w/ssg
|
|
494
|
+
|
|
495
|
+
Static site generation workspace for the application.
|
|
496
|
+
|
|
497
|
+
The workspace renders CMS content into a static HTML file using shared service
|
|
498
|
+
and component packages. It is intentionally small: content comes from the
|
|
499
|
+
replaceable \`cms\` service adapter, UI comes from the shared \`Page\` component,
|
|
500
|
+
and page styles are compiled from the component package.
|
|
501
|
+
|
|
502
|
+
## Output
|
|
503
|
+
|
|
504
|
+
Running the workspace creates:
|
|
505
|
+
|
|
506
|
+
\`\`\`text
|
|
507
|
+
dist/ssg/static/index.html
|
|
508
|
+
\`\`\`
|
|
509
|
+
|
|
510
|
+
The generated document includes:
|
|
511
|
+
|
|
512
|
+
- document metadata from \`cms.getContent().title\`
|
|
513
|
+
- inline CSS compiled from \`packages/components/page/styles.scss\`
|
|
514
|
+
- server-rendered page markup from \`@p/components\`
|
|
515
|
+
- page body content from \`cms.getContent().body\`
|
|
516
|
+
|
|
517
|
+
## Rendering Flow
|
|
518
|
+
|
|
519
|
+
\`\`\`tsx
|
|
520
|
+
import { cms } from '@p/services/cms';
|
|
521
|
+
import { Page } from '@p/components';
|
|
522
|
+
|
|
523
|
+
const content = await cms.getContent();
|
|
524
|
+
|
|
525
|
+
renderToString(<Page content={content.body} />);
|
|
526
|
+
\`\`\`
|
|
527
|
+
|
|
528
|
+
\`index.tsx\` reads \`styles.css\` from the workspace runtime directory, creates the
|
|
529
|
+
\`static\` output folder, and writes a minified \`index.html\` file.
|
|
530
|
+
|
|
531
|
+
## Development
|
|
532
|
+
|
|
533
|
+
Start the SSG workspace directly:
|
|
534
|
+
|
|
535
|
+
\`\`\`bash
|
|
536
|
+
yarn start:ssg
|
|
537
|
+
\`\`\`
|
|
538
|
+
|
|
539
|
+
Build the bundled production artifact:
|
|
540
|
+
|
|
541
|
+
\`\`\`bash
|
|
542
|
+
yarn build:ssg
|
|
543
|
+
\`\`\`
|
|
544
|
+
|
|
545
|
+
Run the focused test for this workspace:
|
|
546
|
+
|
|
547
|
+
\`\`\`bash
|
|
548
|
+
yarn jest workspaces/ssg --runInBand --coverage=false
|
|
549
|
+
\`\`\`
|
|
550
|
+
|
|
551
|
+
## Package Boundaries
|
|
552
|
+
|
|
553
|
+
- \`@p/services/cms\` owns content loading and should remain replaceable.
|
|
554
|
+
- \`@p/components\` owns reusable SSR-friendly React components.
|
|
555
|
+
- \`@w/ssg\` owns the static rendering pipeline and output layout.
|
|
556
|
+
|
|
557
|
+
Keep the workspace free from direct CMS, browser, or deployment-host coupling so
|
|
558
|
+
the same rendering path can be reused by different static deployment targets.
|
|
559
|
+
`,
|
|
304
560
|
'workspaces/ssg/webpack.config.ts': `import { path } from '@vyriy/path';
|
|
305
561
|
import { ssr, external } from '@vyriy/webpack-config';
|
|
306
562
|
|
|
@@ -323,32 +579,29 @@ export default ssr(
|
|
|
323
579
|
private: true,
|
|
324
580
|
}, null, 2) + '\n',
|
|
325
581
|
'workspaces/ssg/index.tsx': `import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
326
|
-
import { renderToString } from 'react-dom/server';
|
|
327
582
|
|
|
328
583
|
import { script } from '@vyriy/script';
|
|
329
584
|
import { html, minify } from '@vyriy/html';
|
|
330
585
|
import { path } from '@vyriy/path';
|
|
586
|
+
import { html as renderHtml } from '@vyriy/render/html';
|
|
331
587
|
|
|
332
588
|
import { cms } from '@p/services/cms';
|
|
333
589
|
import { Page } from '@p/components';
|
|
334
590
|
|
|
335
|
-
const dashboardStyles = readFileSync(path('styles.css'), 'utf8');
|
|
336
|
-
const staticPath = path('static');
|
|
337
|
-
|
|
338
591
|
void script(async () => {
|
|
339
592
|
const content = await cms.getContent();
|
|
340
593
|
|
|
341
|
-
mkdirSync(
|
|
594
|
+
mkdirSync(path('static'), { recursive: true });
|
|
342
595
|
|
|
343
596
|
writeFileSync(
|
|
344
|
-
path(
|
|
597
|
+
path('static', 'index.html'),
|
|
345
598
|
minify(
|
|
346
599
|
html({
|
|
347
600
|
htmlAttributes: 'lang="en"',
|
|
348
601
|
title: \`<title>\${content.title}</title>\`,
|
|
349
602
|
meta: '<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />',
|
|
350
|
-
style: \`<style>\${
|
|
351
|
-
body:
|
|
603
|
+
style: \`<style>\${readFileSync(path('styles.css'), 'utf8').trim()}</style>\`,
|
|
604
|
+
body: renderHtml(<Page content={content.body} />),
|
|
352
605
|
}),
|
|
353
606
|
),
|
|
354
607
|
);
|
package/preset/ssr.js
CHANGED
|
@@ -35,15 +35,15 @@ export const ssr = (options) => ({
|
|
|
35
35
|
'fix:prettier': 'prettier . --write',
|
|
36
36
|
'fix:eslint': 'eslint . --fix',
|
|
37
37
|
'fix:stylelint': 'stylelint "**/*.{css,scss}" --fix',
|
|
38
|
+
'start:api': 'sh workspaces/api/bin/start.sh',
|
|
38
39
|
'lint:ts': 'tsc',
|
|
39
40
|
'lint:prettier': 'prettier . --check',
|
|
40
41
|
'lint:eslint': 'eslint .',
|
|
41
42
|
'lint:stylelint': 'stylelint "**/*.{css,scss}"',
|
|
43
|
+
'build:api': 'rimraf dist && sh workspaces/api/bin/build.sh',
|
|
42
44
|
'build:storybook': 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook build --quiet --disable-telemetry',
|
|
43
45
|
'test:jest': 'jest',
|
|
44
46
|
postinstall: 'husky',
|
|
45
|
-
'start:api': 'sh workspaces/api/bin/start.sh',
|
|
46
|
-
'build:api': 'rimraf dist && sh workspaces/api/bin/build.sh',
|
|
47
47
|
},
|
|
48
48
|
dependencies: {
|
|
49
49
|
'@vyriy/typescript-config': `^${packageJson.version}`,
|
|
@@ -75,13 +75,101 @@ export const ssr = (options) => ({
|
|
|
75
75
|
'@vyriy/cn': `^${packageJson.version}`,
|
|
76
76
|
'@vyriy/html': `^${packageJson.version}`,
|
|
77
77
|
sass: packageJson.peerDependencies.sass,
|
|
78
|
+
'@vyriy/render': `^${packageJson.version}`,
|
|
78
79
|
},
|
|
79
80
|
}, null, 2) + '\n',
|
|
80
|
-
'README.md': `#
|
|
81
|
+
'README.md': `# SSR
|
|
82
|
+
|
|
83
|
+
Calm cloud-ready SSR application preset.
|
|
84
|
+
|
|
85
|
+
This repository is a small TypeScript workspace for server-rendered React output. The API workspace fetches content through a service adapter, renders shared React components on the server, and returns complete HTML.
|
|
86
|
+
|
|
87
|
+
## Structure
|
|
88
|
+
|
|
89
|
+
\`\`\`text
|
|
90
|
+
packages/
|
|
91
|
+
components/ Shared SSR-friendly React components.
|
|
92
|
+
services/ Replaceable service adapters, including CMS access.
|
|
93
|
+
workspaces/
|
|
94
|
+
api/ Server entry point that renders the page response.
|
|
95
|
+
\`\`\`
|
|
96
|
+
|
|
97
|
+
Documentation is rendered through Storybook MDX wrappers. The root \`doc.mdx\` displays this README, while package and workspace docs display their own README files.
|
|
98
|
+
|
|
99
|
+
## Application Flow
|
|
100
|
+
|
|
101
|
+
1. \`workspaces/api/index.tsx\` starts the server.
|
|
102
|
+
2. The request handler calls \`cms.getContent()\` from \`@p/services/cms\`.
|
|
103
|
+
3. The returned body is rendered with \`Page\` from \`@p/components\`.
|
|
104
|
+
4. The response is wrapped into a complete HTML document and returned as \`text/html\`.
|
|
105
|
+
|
|
106
|
+
## Requirements
|
|
107
|
+
|
|
108
|
+
- Node.js \`>=24.0.0\`
|
|
109
|
+
- Yarn \`4.16.0\`
|
|
110
|
+
|
|
111
|
+
Install dependencies:
|
|
112
|
+
|
|
113
|
+
\`\`\`bash
|
|
114
|
+
yarn install
|
|
115
|
+
\`\`\`
|
|
116
|
+
|
|
117
|
+
## Commands
|
|
118
|
+
|
|
119
|
+
Start the SSR API:
|
|
120
|
+
|
|
121
|
+
\`\`\`bash
|
|
122
|
+
yarn start
|
|
123
|
+
\`\`\`
|
|
124
|
+
|
|
125
|
+
Build the API bundle and Storybook documentation:
|
|
126
|
+
|
|
127
|
+
\`\`\`bash
|
|
128
|
+
yarn build
|
|
129
|
+
\`\`\`
|
|
130
|
+
|
|
131
|
+
Run validation:
|
|
132
|
+
|
|
133
|
+
\`\`\`bash
|
|
134
|
+
yarn check
|
|
135
|
+
\`\`\`
|
|
136
|
+
|
|
137
|
+
Run individual checks:
|
|
138
|
+
|
|
139
|
+
\`\`\`bash
|
|
140
|
+
yarn lint
|
|
141
|
+
yarn test
|
|
142
|
+
\`\`\`
|
|
143
|
+
|
|
144
|
+
Open Storybook documentation:
|
|
145
|
+
|
|
146
|
+
\`\`\`bash
|
|
147
|
+
yarn storybook
|
|
148
|
+
\`\`\`
|
|
149
|
+
|
|
150
|
+
## Packages
|
|
151
|
+
|
|
152
|
+
- \`@p/components\` exports shared React components for server-rendered surfaces.
|
|
153
|
+
- \`@p/services\` exports service adapters that keep integration details outside UI and workspace code.
|
|
154
|
+
- \`@w/api\` is the SSR server workspace and deployable application entry point.
|
|
155
|
+
|
|
156
|
+
## Development Notes
|
|
157
|
+
|
|
158
|
+
Keep public behavior documented where it is introduced. When adding shared components or services, update the matching package README, public re-exports, and focused tests. Prefer SSR-safe code paths and avoid browser globals during render.
|
|
159
|
+
|
|
160
|
+
## Project Guidance
|
|
161
|
+
|
|
162
|
+
These articles describe the development approach behind this preset and provide practical guidance for evolving a project on top of it:
|
|
163
|
+
|
|
164
|
+
- [Calm Development Environment: Node.js, Corepack, Yarn and Static Preview](https://vyriy.dev/blog/calm-development-setup/) - how to keep the local development environment predictable and easy to reproduce.
|
|
165
|
+
- [Calm App Structure for the Vyriy Ecosystem](https://vyriy.dev/blog/vyriy-calm-app-structure/) - a practical project structure for Vyriy applications: shared configs, small packages, thin workspaces, Storybook docs, tests, and deployable entry points.
|
|
166
|
+
- [One Handler, Many Runtimes](https://vyriy.dev/examples/one-handler-many-runtimes/) - how @vyriy/handler, @vyriy/router, and @vyriy/server compose a calm Lambda-compatible API that can run locally, in Docker, Fargate-style HTTP runtimes, and AWS Lambda.
|
|
167
|
+
- [Storybook as Project Documentation](https://vyriy.dev/blog/storybook-as-project-documentation/) - how to use Storybook as living project documentation and a component playground.
|
|
168
|
+
`,
|
|
81
169
|
'doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
|
|
82
170
|
import ReadMe from './README.md?raw';
|
|
83
171
|
|
|
84
|
-
<Meta title="
|
|
172
|
+
<Meta title="SSR" />
|
|
85
173
|
|
|
86
174
|
<Markdown>{ReadMe}</Markdown>
|
|
87
175
|
`,
|
|
@@ -187,6 +275,97 @@ export default {
|
|
|
187
275
|
private: true,
|
|
188
276
|
type: 'module',
|
|
189
277
|
}, null, 2) + '\n',
|
|
278
|
+
'packages/components/doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
|
|
279
|
+
import ReadMe from './README.md?raw';
|
|
280
|
+
|
|
281
|
+
<Meta title="Packages/Components" />
|
|
282
|
+
|
|
283
|
+
<Markdown>{ReadMe}</Markdown>
|
|
284
|
+
`,
|
|
285
|
+
'packages/components/README.md': `# Components
|
|
286
|
+
|
|
287
|
+
Shared React components for SSR-friendly application surfaces.
|
|
288
|
+
|
|
289
|
+
The package keeps reusable UI small and framework-neutral. Components should render without browser globals, accept typed props, and stay easy to compose from server-rendered workspaces.
|
|
290
|
+
|
|
291
|
+
## Exports
|
|
292
|
+
|
|
293
|
+
### \`Page\`
|
|
294
|
+
|
|
295
|
+
Renders page body content inside the standard page content container.
|
|
296
|
+
|
|
297
|
+
\`\`\`tsx
|
|
298
|
+
import { Page } from '@p/components';
|
|
299
|
+
|
|
300
|
+
export const App = () => <Page content="This is a rendered page." />;
|
|
301
|
+
\`\`\`
|
|
302
|
+
|
|
303
|
+
Rendered markup:
|
|
304
|
+
|
|
305
|
+
\`\`\`html
|
|
306
|
+
<div class="content">This is a rendered page.</div>
|
|
307
|
+
\`\`\`
|
|
308
|
+
|
|
309
|
+
## Styling
|
|
310
|
+
|
|
311
|
+
\`Page\` uses the \`content\` class. The host workspace owns the actual CSS so the component can stay reusable across SSR and SSG outputs.
|
|
312
|
+
|
|
313
|
+
## Development
|
|
314
|
+
|
|
315
|
+
Add new public components as focused files with matching tests, then re-export them from the package entry point.
|
|
316
|
+
|
|
317
|
+
Focused validation:
|
|
318
|
+
|
|
319
|
+
\`\`\`bash
|
|
320
|
+
yarn jest packages/components --runInBand --coverage=false
|
|
321
|
+
\`\`\`
|
|
322
|
+
`,
|
|
323
|
+
'packages/services/doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
|
|
324
|
+
import ReadMe from './README.md?raw';
|
|
325
|
+
|
|
326
|
+
<Meta title="Packages/Services" />
|
|
327
|
+
|
|
328
|
+
<Markdown>{ReadMe}</Markdown>
|
|
329
|
+
`,
|
|
330
|
+
'packages/services/README.md': `# Services
|
|
331
|
+
|
|
332
|
+
Shared service adapters for application workspaces.
|
|
333
|
+
|
|
334
|
+
The package is the place for replaceable integrations such as CMS access, API clients, and other server-safe service boundaries. Keep adapters typed, deterministic in tests, and free from direct UI concerns.
|
|
335
|
+
|
|
336
|
+
## Exports
|
|
337
|
+
|
|
338
|
+
### \`cms\`
|
|
339
|
+
|
|
340
|
+
CMS content adapter used by the API workspace before rendering the page.
|
|
341
|
+
|
|
342
|
+
\`\`\`ts
|
|
343
|
+
import { cms } from '@p/services/cms';
|
|
344
|
+
|
|
345
|
+
const content = await cms.getContent();
|
|
346
|
+
\`\`\`
|
|
347
|
+
|
|
348
|
+
\`getContent()\` currently returns sample content:
|
|
349
|
+
|
|
350
|
+
\`\`\`ts
|
|
351
|
+
{
|
|
352
|
+
title: 'Sample Content',
|
|
353
|
+
body: 'This is a sample content fetched from the CMS.',
|
|
354
|
+
}
|
|
355
|
+
\`\`\`
|
|
356
|
+
|
|
357
|
+
The returned shape is intended for server rendering: \`title\` is used for document metadata, and \`body\` is passed to the page component.
|
|
358
|
+
|
|
359
|
+
## Development
|
|
360
|
+
|
|
361
|
+
Keep service modules behind small public methods so real providers can replace placeholders without coupling callers to a specific CMS, network client, or runtime host.
|
|
362
|
+
|
|
363
|
+
Focused validation:
|
|
364
|
+
|
|
365
|
+
\`\`\`bash
|
|
366
|
+
yarn jest packages/services --runInBand --coverage=false
|
|
367
|
+
\`\`\`
|
|
368
|
+
`,
|
|
190
369
|
'packages/components/index.ts': "export * from './page/index.js';\n",
|
|
191
370
|
'packages/components/index.test.tsx': `import { describe, expect, it } from '@jest/globals';
|
|
192
371
|
|
|
@@ -301,7 +480,76 @@ import ReadMe from './README.md?raw';
|
|
|
301
480
|
|
|
302
481
|
<Markdown>{ReadMe}</Markdown>
|
|
303
482
|
`,
|
|
304
|
-
'workspaces/api/README.md': `#
|
|
483
|
+
'workspaces/api/README.md': `# API
|
|
484
|
+
|
|
485
|
+
SSR server workspace for the \`ssr\` preset.
|
|
486
|
+
|
|
487
|
+
The workspace owns the deployable server entry point. It fetches page content, renders shared React components on the server, wraps the result into a complete HTML document, and returns an HTML response.
|
|
488
|
+
|
|
489
|
+
## Entry Point
|
|
490
|
+
|
|
491
|
+
\`index.tsx\` starts the server with \`@vyriy/server\` and registers an async handler with \`@vyriy/handler\`.
|
|
492
|
+
|
|
493
|
+
Request flow:
|
|
494
|
+
|
|
495
|
+
1. Load content with \`cms.getContent()\` from \`@p/services/cms\`.
|
|
496
|
+
2. Render \`<Page content={content.body} />\` from \`@p/components\`.
|
|
497
|
+
3. Read compiled \`styles.css\` from the project runtime directory.
|
|
498
|
+
4. Build and minify the HTML document with \`@vyriy/html\`.
|
|
499
|
+
5. Return \`200\` with \`content-type: text/html; charset=utf-8\`.
|
|
500
|
+
|
|
501
|
+
## Runtime Output
|
|
502
|
+
|
|
503
|
+
The handler returns a complete HTML response:
|
|
504
|
+
|
|
505
|
+
\`\`\`ts
|
|
506
|
+
{
|
|
507
|
+
statusCode: 200,
|
|
508
|
+
headers: {
|
|
509
|
+
'content-type': 'text/html; charset=utf-8',
|
|
510
|
+
},
|
|
511
|
+
body: '<!doctype html>...',
|
|
512
|
+
}
|
|
513
|
+
\`\`\`
|
|
514
|
+
|
|
515
|
+
The document title comes from \`content.title\`, and the rendered body comes from \`content.body\`.
|
|
516
|
+
|
|
517
|
+
## Scripts
|
|
518
|
+
|
|
519
|
+
Start the API from the repository root:
|
|
520
|
+
|
|
521
|
+
\`\`\`bash
|
|
522
|
+
yarn start:api
|
|
523
|
+
\`\`\`
|
|
524
|
+
|
|
525
|
+
The start script compiles \`packages/components/page/styles.scss\` into \`dist/api/styles.css\`, then runs \`workspaces/api/index.tsx\` with \`tsx\`.
|
|
526
|
+
|
|
527
|
+
Build the deployable API output:
|
|
528
|
+
|
|
529
|
+
\`\`\`bash
|
|
530
|
+
yarn build:api
|
|
531
|
+
\`\`\`
|
|
532
|
+
|
|
533
|
+
The build script writes the server bundle, compiled CSS, and runtime package metadata into \`dist/api\`.
|
|
534
|
+
|
|
535
|
+
## Validation
|
|
536
|
+
|
|
537
|
+
Run the focused API tests:
|
|
538
|
+
|
|
539
|
+
\`\`\`bash
|
|
540
|
+
yarn jest workspaces/api --runInBand --coverage=false
|
|
541
|
+
\`\`\`
|
|
542
|
+
|
|
543
|
+
Run the full project validation:
|
|
544
|
+
|
|
545
|
+
\`\`\`bash
|
|
546
|
+
yarn check
|
|
547
|
+
\`\`\`
|
|
548
|
+
|
|
549
|
+
## Development Notes
|
|
550
|
+
|
|
551
|
+
Keep workspace code focused on orchestration. Shared UI belongs in \`@p/components\`, and integration behavior belongs in \`@p/services\`, so the server entry point stays easy to replace or deploy in a different runtime.
|
|
552
|
+
`,
|
|
305
553
|
'workspaces/api/webpack.config.ts': `import { path } from '@vyriy/path';
|
|
306
554
|
import { ssr, external } from '@vyriy/webpack-config';
|
|
307
555
|
|
|
@@ -324,18 +572,16 @@ export default ssr(
|
|
|
324
572
|
private: true,
|
|
325
573
|
}, null, 2) + '\n',
|
|
326
574
|
'workspaces/api/index.tsx': `import { readFileSync } from 'node:fs';
|
|
327
|
-
import { renderToString } from 'react-dom/server';
|
|
328
575
|
|
|
329
576
|
import { server } from '@vyriy/server';
|
|
330
577
|
import { api } from '@vyriy/handler';
|
|
331
578
|
import { html, minify } from '@vyriy/html';
|
|
332
579
|
import { path } from '@vyriy/path';
|
|
580
|
+
import { html as renderHtml } from '@vyriy/render/html';
|
|
333
581
|
|
|
334
582
|
import { cms } from '@p/services/cms';
|
|
335
583
|
import { Page } from '@p/components';
|
|
336
584
|
|
|
337
|
-
const dashboardStyles = readFileSync(path('styles.css'), 'utf8');
|
|
338
|
-
|
|
339
585
|
server(
|
|
340
586
|
api(async () => {
|
|
341
587
|
const content = await cms.getContent();
|
|
@@ -350,8 +596,8 @@ server(
|
|
|
350
596
|
htmlAttributes: 'lang="en"',
|
|
351
597
|
title: \`<title>\${content.title}</title>\`,
|
|
352
598
|
meta: '<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />',
|
|
353
|
-
style: \`<style>\${
|
|
354
|
-
body:
|
|
599
|
+
style: \`<style>\${readFileSync(path('styles.css'), 'utf8').trim()}</style>\`,
|
|
600
|
+
body: renderHtml(<Page content={content.body} />),
|
|
355
601
|
}),
|
|
356
602
|
),
|
|
357
603
|
};
|
package/prompt/index.d.ts
CHANGED
package/prompt/index.js
CHANGED
package/prompt/scope.d.ts
DELETED
package/prompt/scope.js
DELETED