@vyriy/create 0.8.8 → 0.8.10
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/AGENTS.md +125 -68
- package/README.md +2 -0
- package/package.json +30 -4
- package/plan/plan.d.ts +1 -1
- package/preset/index.d.ts +5 -0
- package/preset/index.js +6 -0
- package/preset/mcp.d.ts +2 -0
- package/preset/mcp.js +531 -0
- package/preset/mfe.js +12 -3
- package/preset/ssg.js +202 -369
- package/preset/types.d.ts +1 -1
package/preset/ssg.js
CHANGED
|
@@ -29,14 +29,12 @@ export const ssg = (options) => ({
|
|
|
29
29
|
storybook: 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook dev -p 6006 --disable-telemetry',
|
|
30
30
|
check: 'run-s lint build test',
|
|
31
31
|
fix: "run-s 'fix:*'",
|
|
32
|
-
start: "run-p 'start:*'",
|
|
33
32
|
lint: "run-s 'lint:*'",
|
|
34
33
|
build: "run-s 'build:*'",
|
|
35
34
|
test: "run-s 'test:*'",
|
|
36
35
|
'fix:prettier': 'prettier . --write',
|
|
37
36
|
'fix:eslint': 'eslint . --fix',
|
|
38
37
|
'fix:stylelint': 'stylelint "**/*.{css,scss}" --fix',
|
|
39
|
-
'start:ssg': 'sh workspaces/ssg/bin/start.sh',
|
|
40
38
|
'lint:ts': 'tsc',
|
|
41
39
|
'lint:prettier': 'prettier . --check',
|
|
42
40
|
'lint:eslint': 'eslint .',
|
|
@@ -65,104 +63,91 @@ export const ssg = (options) => ({
|
|
|
65
63
|
'@vyriy/webpack-config': `^${packageJson.version}`,
|
|
66
64
|
tsx: packageJson.peerDependencies.tsx,
|
|
67
65
|
'webpack-cli': packageJson.peerDependencies['webpack-cli'],
|
|
68
|
-
'@vyriy/script': `^${packageJson.version}`,
|
|
69
|
-
react: packageJson.peerDependencies.react,
|
|
70
|
-
'react-dom': packageJson.peerDependencies['react-dom'],
|
|
71
|
-
'@types/react': packageJson.peerDependencies['@types/react'],
|
|
72
|
-
'@types/react-dom': packageJson.peerDependencies['@types/react-dom'],
|
|
73
66
|
'@vyriy/stylelint-config': `^${packageJson.version}`,
|
|
74
67
|
stylelint: packageJson.peerDependencies.stylelint,
|
|
75
|
-
'@vyriy/cn': `^${packageJson.version}`,
|
|
76
|
-
'@vyriy/html': `^${packageJson.version}`,
|
|
77
68
|
sass: packageJson.peerDependencies.sass,
|
|
78
|
-
'@vyriy/
|
|
69
|
+
'@vyriy/ssg': `^${packageJson.version}`,
|
|
79
70
|
},
|
|
80
71
|
}, null, 2) + '\n',
|
|
81
72
|
'README.md': `# SSG
|
|
82
73
|
|
|
83
|
-
|
|
74
|
+
Markdown-first static site generated with \`@vyriy/ssg\`.
|
|
84
75
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
server-safe React component, and writes a static HTML page.
|
|
76
|
+
The repository keeps content under \`site/*\`, styling under
|
|
77
|
+
\`packages/components/styles.scss\`, and the build entry point in
|
|
78
|
+
\`workspaces/ssg\`.
|
|
89
79
|
|
|
90
|
-
##
|
|
80
|
+
## Structure
|
|
91
81
|
|
|
92
82
|
\`\`\`text
|
|
93
83
|
packages/
|
|
94
|
-
components/
|
|
95
|
-
|
|
84
|
+
components/ Site stylesheet and style documentation.
|
|
85
|
+
site/
|
|
86
|
+
home/ Home page Markdown.
|
|
87
|
+
consulting/ Standalone consulting page Markdown.
|
|
88
|
+
docs/ Documentation landing page and docs entries.
|
|
89
|
+
blog/ Blog entries.
|
|
90
|
+
examples/ Example entries.
|
|
91
|
+
public/ Static assets copied into dist.
|
|
96
92
|
workspaces/
|
|
97
|
-
ssg/
|
|
93
|
+
ssg/ Thin build workspace around @vyriy/ssg.
|
|
98
94
|
\`\`\`
|
|
99
95
|
|
|
100
|
-
##
|
|
96
|
+
## Build Flow
|
|
101
97
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
3. \`@w/ssg\` writes the generated document to \`dist/ssg/static/index.html\`.
|
|
107
|
-
|
|
108
|
-
The generated HTML includes compiled component styles from
|
|
109
|
-
\`packages/components/page/styles.scss\`.
|
|
98
|
+
1. \`workspaces/ssg\` is bundled into \`dist/index.js\`.
|
|
99
|
+
2. \`packages/components/styles.scss\` is compiled into \`dist/styles.css\`.
|
|
100
|
+
3. \`@vyriy/ssg\` reads Markdown from \`site\` and writes static output to \`dist\`.
|
|
101
|
+
4. The generated site includes HTML pages, search data, sitemap, robots.txt, and copied public assets.
|
|
110
102
|
|
|
111
103
|
## Development
|
|
112
104
|
|
|
113
|
-
Install dependencies
|
|
105
|
+
Install dependencies:
|
|
114
106
|
|
|
115
107
|
\`\`\`bash
|
|
116
108
|
yarn install
|
|
117
109
|
\`\`\`
|
|
118
110
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
\`\`\`bash
|
|
122
|
-
yarn start:ssg
|
|
123
|
-
\`\`\`
|
|
124
|
-
|
|
125
|
-
Build the production SSG artifact:
|
|
111
|
+
Build the static site:
|
|
126
112
|
|
|
127
113
|
\`\`\`bash
|
|
128
114
|
yarn build:ssg
|
|
129
115
|
\`\`\`
|
|
130
116
|
|
|
131
|
-
Run Storybook documentation:
|
|
132
|
-
|
|
133
|
-
\`\`\`bash
|
|
134
|
-
yarn storybook
|
|
135
|
-
\`\`\`
|
|
136
|
-
|
|
137
|
-
## Validation
|
|
138
|
-
|
|
139
117
|
Run all checks:
|
|
140
118
|
|
|
141
119
|
\`\`\`bash
|
|
142
120
|
yarn check
|
|
143
121
|
\`\`\`
|
|
144
122
|
|
|
145
|
-
|
|
123
|
+
Focused validation:
|
|
146
124
|
|
|
147
125
|
\`\`\`bash
|
|
148
|
-
yarn
|
|
149
|
-
yarn
|
|
150
|
-
yarn test
|
|
126
|
+
yarn jest workspaces/ssg --runInBand --coverage=false
|
|
127
|
+
yarn lint:stylelint
|
|
151
128
|
\`\`\`
|
|
152
129
|
|
|
153
|
-
|
|
130
|
+
## Content
|
|
154
131
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
\`\`\`
|
|
132
|
+
Each content page is a \`README.md\` file with optional frontmatter:
|
|
133
|
+
|
|
134
|
+
\`\`\`md
|
|
135
|
+
---
|
|
136
|
+
title: Calm page
|
|
137
|
+
description: A short page description.
|
|
138
|
+
published: true
|
|
139
|
+
tags:
|
|
140
|
+
- ssg
|
|
141
|
+
---
|
|
158
142
|
|
|
159
|
-
|
|
143
|
+
# Calm page
|
|
160
144
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
- \`packages/services/README.md\` documents service adapters.
|
|
145
|
+
Page content.
|
|
146
|
+
\`\`\`
|
|
164
147
|
|
|
165
|
-
|
|
148
|
+
By default \`@vyriy/ssg\` builds \`home\`, \`consulting\`, \`docs\`, \`blog\`,
|
|
149
|
+
\`examples\`, search pages, related content metadata, \`sitemap.xml\`, and
|
|
150
|
+
\`robots.txt\`.
|
|
166
151
|
|
|
167
152
|
## Project Guidance
|
|
168
153
|
|
|
@@ -170,7 +155,6 @@ These articles describe the development approach behind this preset and provide
|
|
|
170
155
|
|
|
171
156
|
- [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.
|
|
172
157
|
- [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.
|
|
173
|
-
- [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.
|
|
174
158
|
- [Storybook as Project Documentation](https://vyriy.dev/blog/storybook-as-project-documentation/) - how to use Storybook as living project documentation and a component playground.
|
|
175
159
|
`,
|
|
176
160
|
'doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
|
|
@@ -253,7 +237,6 @@ cdk.context.json
|
|
|
253
237
|
'yarn.lock': '',
|
|
254
238
|
...styleToolingFiles,
|
|
255
239
|
'.prettierignore': 'node_modules\ndist\ncoverage\nstorybook-static\nconsumer\n',
|
|
256
|
-
'assets.d.ts': "declare module '*.scss';\n",
|
|
257
240
|
'packages/components/doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
|
|
258
241
|
import ReadMe from './README.md?raw';
|
|
259
242
|
|
|
@@ -263,90 +246,20 @@ import ReadMe from './README.md?raw';
|
|
|
263
246
|
`,
|
|
264
247
|
'packages/components/README.md': `# Components
|
|
265
248
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
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.
|
|
249
|
+
Site presentation package.
|
|
269
250
|
|
|
270
|
-
|
|
251
|
+
The starter keeps only shared stylesheet ownership here. \`@vyriy/ssg\` owns the
|
|
252
|
+
default static rendering system, while this package owns project-specific visual
|
|
253
|
+
tokens and small CSS adjustments.
|
|
271
254
|
|
|
272
|
-
|
|
255
|
+
## Files
|
|
273
256
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
\`\`\`tsx
|
|
277
|
-
import { Page, type PageProps } from '@p/components';
|
|
278
|
-
|
|
279
|
-
const props: PageProps = {
|
|
280
|
-
content: 'This is a rendered page.',
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
export const App = () => <Page {...props} />;
|
|
284
|
-
\`\`\`
|
|
285
|
-
|
|
286
|
-
Rendered markup:
|
|
287
|
-
|
|
288
|
-
\`\`\`html
|
|
289
|
-
<div class="content">This is a rendered page.</div>
|
|
290
|
-
\`\`\`
|
|
291
|
-
|
|
292
|
-
## Styling
|
|
293
|
-
|
|
294
|
-
\`Page\` uses the \`content\` class. The host workspace owns the actual CSS so the component can stay reusable across SSR and SSG outputs.
|
|
295
|
-
|
|
296
|
-
## Development
|
|
297
|
-
|
|
298
|
-
Add new public components as focused files with matching tests, then re-export them from the package entry point.
|
|
299
|
-
|
|
300
|
-
Focused validation:
|
|
301
|
-
|
|
302
|
-
\`\`\`bash
|
|
303
|
-
yarn jest packages/components --runInBand --coverage=false
|
|
304
|
-
\`\`\`
|
|
305
|
-
`,
|
|
306
|
-
'packages/services/doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
|
|
307
|
-
import ReadMe from './README.md?raw';
|
|
257
|
+
- \`styles.scss\` - compiled into \`dist/styles.css\` before the static site is generated.
|
|
308
258
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
<Markdown>{ReadMe}</Markdown>
|
|
312
|
-
`,
|
|
313
|
-
'packages/services/README.md': `# Services
|
|
314
|
-
|
|
315
|
-
Shared service adapters for application workspaces.
|
|
316
|
-
|
|
317
|
-
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.
|
|
318
|
-
|
|
319
|
-
## Exports
|
|
320
|
-
|
|
321
|
-
### \`cms\`
|
|
322
|
-
|
|
323
|
-
CMS content adapter used by application workspaces before rendering the page.
|
|
324
|
-
|
|
325
|
-
\`\`\`ts
|
|
326
|
-
import { cms } from '@p/services/cms';
|
|
327
|
-
|
|
328
|
-
const content = await cms.getContent();
|
|
329
|
-
\`\`\`
|
|
330
|
-
|
|
331
|
-
\`getContent()\` currently returns sample content:
|
|
332
|
-
|
|
333
|
-
\`\`\`ts
|
|
334
|
-
{
|
|
335
|
-
title: 'Sample Content',
|
|
336
|
-
body: 'This is a sample content fetched from the CMS.',
|
|
337
|
-
}
|
|
338
|
-
\`\`\`
|
|
339
|
-
|
|
340
|
-
The returned shape is intended for server rendering: \`title\` is used for document metadata, and \`body\` is passed to the page component.
|
|
341
|
-
|
|
342
|
-
## Development
|
|
343
|
-
|
|
344
|
-
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.
|
|
345
|
-
|
|
346
|
-
Focused validation:
|
|
259
|
+
## Validation
|
|
347
260
|
|
|
348
261
|
\`\`\`bash
|
|
349
|
-
yarn
|
|
262
|
+
yarn lint:stylelint
|
|
350
263
|
\`\`\`
|
|
351
264
|
`,
|
|
352
265
|
'packages/components/package.json': JSON.stringify({
|
|
@@ -354,112 +267,40 @@ yarn jest packages/services --runInBand --coverage=false
|
|
|
354
267
|
private: true,
|
|
355
268
|
type: 'module',
|
|
356
269
|
}, null, 2) + '\n',
|
|
357
|
-
'packages/components/
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
it('re-exports the page component', () => {
|
|
365
|
-
expect(Page).toBe(PageImplementation);
|
|
366
|
-
});
|
|
367
|
-
});
|
|
368
|
-
`,
|
|
369
|
-
'packages/components/page/index.ts': `export * from './page.js';
|
|
370
|
-
export type * from './types.js';
|
|
371
|
-
`,
|
|
372
|
-
'packages/components/page/index.test.ts': `import { describe, expect, it } from '@jest/globals';
|
|
373
|
-
|
|
374
|
-
import { Page } from './index.js';
|
|
375
|
-
import { Page as PageImplementation } from './page.js';
|
|
376
|
-
|
|
377
|
-
describe('packages/components/page', () => {
|
|
378
|
-
it('re-exports the page component', () => {
|
|
379
|
-
expect(Page).toBe(PageImplementation);
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
`,
|
|
383
|
-
'packages/components/page/types.ts': `import { FC } from 'react';
|
|
384
|
-
|
|
385
|
-
export type PageProps = {
|
|
386
|
-
content: string;
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
export type PageType = FC<PageProps>;
|
|
390
|
-
`,
|
|
391
|
-
'packages/components/page/page.tsx': `import type { PageType } from './types.js';
|
|
392
|
-
|
|
393
|
-
export const Page: PageType = ({ content }) => <div className="content">{content}</div>;
|
|
394
|
-
`,
|
|
395
|
-
'packages/components/page/styles.scss': `.content {
|
|
396
|
-
display: block;
|
|
270
|
+
'packages/components/styles.scss': `:root {
|
|
271
|
+
--color-bg: #ffffff;
|
|
272
|
+
--color-text: #28323c;
|
|
273
|
+
--color-heading: #3d5165;
|
|
274
|
+
--color-link: #365f8c;
|
|
275
|
+
--color-border: #dbe1e5;
|
|
276
|
+
--font-sans: system-ui, -apple-system, blinkmacsystemfont, 'Segoe UI', sans-serif;
|
|
397
277
|
}
|
|
398
|
-
`,
|
|
399
|
-
'packages/components/page/page.test.tsx': `import { renderToStaticMarkup } from 'react-dom/server';
|
|
400
|
-
import { describe, expect, it } from '@jest/globals';
|
|
401
|
-
|
|
402
|
-
import { Page } from './page.js';
|
|
403
278
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
`,
|
|
410
|
-
'packages/services/package.json': JSON.stringify({
|
|
411
|
-
name: '@p/services',
|
|
412
|
-
private: true,
|
|
413
|
-
type: 'module',
|
|
414
|
-
}, null, 2) + '\n',
|
|
415
|
-
'packages/services/cms/index.ts': `export const cms = {
|
|
416
|
-
getContent: async () => {
|
|
417
|
-
// Placeholder for fetching content from a CMS
|
|
418
|
-
return Promise.resolve({
|
|
419
|
-
title: 'Sample Content',
|
|
420
|
-
body: 'This is a sample content fetched from the CMS.',
|
|
421
|
-
});
|
|
422
|
-
},
|
|
423
|
-
};
|
|
424
|
-
`,
|
|
425
|
-
'packages/services/cms/index.test.ts': `import { describe, expect, it } from '@jest/globals';
|
|
426
|
-
|
|
427
|
-
import { cms } from './index.js';
|
|
279
|
+
body {
|
|
280
|
+
background: var(--color-bg);
|
|
281
|
+
color: var(--color-text);
|
|
282
|
+
font-family: var(--font-sans);
|
|
283
|
+
}
|
|
428
284
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
title: 'Sample Content',
|
|
433
|
-
body: 'This is a sample content fetched from the CMS.',
|
|
434
|
-
});
|
|
435
|
-
});
|
|
436
|
-
});
|
|
285
|
+
a {
|
|
286
|
+
color: var(--color-link);
|
|
287
|
+
}
|
|
437
288
|
`,
|
|
438
289
|
'workspaces/ssg/bin/build.sh': `#!/usr/bin/env sh
|
|
439
290
|
|
|
440
|
-
set -
|
|
441
|
-
|
|
442
|
-
scriptdir="$PWD/workspaces/ssg";
|
|
443
|
-
distdir="$PWD/dist/ssg";
|
|
291
|
+
set -eu
|
|
444
292
|
|
|
445
|
-
NODE_ENV=production npx webpack --config $
|
|
446
|
-
|
|
447
|
-
yarn exec sass packages/components/page/styles.scss "$distdir/styles.css" --no-source-map --style=compressed
|
|
448
|
-
cp $scriptdir/package.json "$distdir/package.json"
|
|
449
|
-
npm pkg delete "type" --prefix "$distdir"
|
|
450
|
-
npm pkg delete "private" --prefix "$distdir"
|
|
451
|
-
`,
|
|
452
|
-
'workspaces/ssg/bin/start.sh': `#!/usr/bin/env sh
|
|
293
|
+
NODE_ENV=production npx webpack --config "$PWD/workspaces/ssg/webpack.config.ts"
|
|
453
294
|
|
|
454
|
-
|
|
295
|
+
yarn exec sass packages/components/styles.scss dist/styles.css --no-source-map --style=compressed
|
|
455
296
|
|
|
456
|
-
|
|
457
|
-
|
|
297
|
+
cp "$PWD/workspaces/ssg/package.json" dist/package.json
|
|
298
|
+
npm pkg delete type --prefix dist
|
|
458
299
|
|
|
459
|
-
|
|
460
|
-
yarn exec sass packages/components/page/styles.scss "$distdir/styles.css" --no-source-map
|
|
300
|
+
node dist/index.js
|
|
461
301
|
|
|
462
|
-
|
|
302
|
+
rm dist/index.js
|
|
303
|
+
rm dist/package.json
|
|
463
304
|
`,
|
|
464
305
|
'workspaces/ssg/doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
|
|
465
306
|
import ReadMe from './README.md?raw';
|
|
@@ -470,84 +311,36 @@ import ReadMe from './README.md?raw';
|
|
|
470
311
|
`,
|
|
471
312
|
'workspaces/ssg/README.md': `# @w/ssg
|
|
472
313
|
|
|
473
|
-
Static site
|
|
314
|
+
Static site build workspace.
|
|
474
315
|
|
|
475
|
-
The workspace
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
and page styles are compiled from the component package.
|
|
479
|
-
|
|
480
|
-
## Output
|
|
481
|
-
|
|
482
|
-
Running the workspace creates:
|
|
483
|
-
|
|
484
|
-
\`\`\`text
|
|
485
|
-
dist/ssg/static/index.html
|
|
486
|
-
\`\`\`
|
|
487
|
-
|
|
488
|
-
The generated document includes:
|
|
489
|
-
|
|
490
|
-
- document metadata from \`cms.getContent().title\`
|
|
491
|
-
- inline CSS compiled from \`packages/components/page/styles.scss\`
|
|
492
|
-
- server-rendered page markup from \`@p/components\`
|
|
493
|
-
- page body content from \`cms.getContent().body\`
|
|
494
|
-
|
|
495
|
-
## Rendering Flow
|
|
496
|
-
|
|
497
|
-
\`\`\`tsx
|
|
498
|
-
import { cms } from '@p/services/cms';
|
|
499
|
-
import { Page } from '@p/components';
|
|
500
|
-
|
|
501
|
-
const content = await cms.getContent();
|
|
502
|
-
|
|
503
|
-
renderToString(<Page content={content.body} />);
|
|
504
|
-
\`\`\`
|
|
505
|
-
|
|
506
|
-
\`index.tsx\` reads \`styles.css\` from the workspace runtime directory, creates the
|
|
507
|
-
\`static\` output folder, and writes a minified \`index.html\` file.
|
|
508
|
-
|
|
509
|
-
## Development
|
|
510
|
-
|
|
511
|
-
Start the SSG workspace directly:
|
|
512
|
-
|
|
513
|
-
\`\`\`bash
|
|
514
|
-
yarn start:ssg
|
|
515
|
-
\`\`\`
|
|
316
|
+
The workspace is intentionally thin. It calls \`buildStaticSite\` from
|
|
317
|
+
\`@vyriy/ssg\`, passes the compiled stylesheet content, and lets the reusable
|
|
318
|
+
generator build the static site from Markdown content under \`site\`.
|
|
516
319
|
|
|
517
|
-
Build
|
|
320
|
+
## Build
|
|
518
321
|
|
|
519
322
|
\`\`\`bash
|
|
520
323
|
yarn build:ssg
|
|
521
324
|
\`\`\`
|
|
522
325
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
\`\`\`bash
|
|
526
|
-
yarn jest workspaces/ssg --runInBand --coverage=false
|
|
527
|
-
\`\`\`
|
|
528
|
-
|
|
529
|
-
## Package Boundaries
|
|
530
|
-
|
|
531
|
-
- \`@p/services/cms\` owns content loading and should remain replaceable.
|
|
532
|
-
- \`@p/components\` owns reusable SSR-friendly React components.
|
|
533
|
-
- \`@w/ssg\` owns the static rendering pipeline and output layout.
|
|
534
|
-
|
|
535
|
-
Keep the workspace free from direct CMS, browser, or deployment-host coupling so
|
|
536
|
-
the same rendering path can be reused by different static deployment targets.
|
|
326
|
+
The build writes output into \`dist\`.
|
|
537
327
|
`,
|
|
538
|
-
'workspaces/ssg/webpack.config.ts': `import
|
|
328
|
+
'workspaces/ssg/webpack.config.ts': `import 'webpack';
|
|
329
|
+
|
|
330
|
+
import { path } from '@vyriy/path';
|
|
539
331
|
import { ssr, external } from '@vyriy/webpack-config';
|
|
540
332
|
|
|
541
333
|
export default ssr(
|
|
542
334
|
'@w/ssg',
|
|
543
335
|
{
|
|
544
|
-
path: path('dist'
|
|
336
|
+
path: path('dist'),
|
|
545
337
|
filename: 'index.js',
|
|
546
338
|
library: { type: 'commonjs2' },
|
|
339
|
+
clean: false,
|
|
547
340
|
},
|
|
548
341
|
(config) => ({
|
|
549
342
|
...config,
|
|
550
|
-
externals: [external({ allowlist: [/^@
|
|
343
|
+
externals: [external({ allowlist: [/^@w/] })],
|
|
551
344
|
}),
|
|
552
345
|
);
|
|
553
346
|
`,
|
|
@@ -556,94 +349,134 @@ export default ssr(
|
|
|
556
349
|
type: 'module',
|
|
557
350
|
private: true,
|
|
558
351
|
}, null, 2) + '\n',
|
|
559
|
-
'workspaces/ssg/index.
|
|
352
|
+
'workspaces/ssg/index.ts': `import { readFile } from 'node:fs/promises';
|
|
353
|
+
import { join } from 'node:path';
|
|
560
354
|
|
|
561
|
-
import {
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
mkdirSync(path('static'), { recursive: true });
|
|
573
|
-
|
|
574
|
-
writeFileSync(
|
|
575
|
-
path('static', 'index.html'),
|
|
576
|
-
minify(
|
|
577
|
-
html({
|
|
578
|
-
htmlAttributes: 'lang="en"',
|
|
579
|
-
title: \`<title>\${content.title}</title>\`,
|
|
580
|
-
meta: '<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />',
|
|
581
|
-
style: \`<style>\${readFileSync(path('styles.css'), 'utf8').trim()}</style>\`,
|
|
582
|
-
body: renderHtml(<Page content={content.body} />),
|
|
583
|
-
}),
|
|
584
|
-
),
|
|
585
|
-
);
|
|
586
|
-
});
|
|
355
|
+
import { buildStaticSite } from '@vyriy/ssg';
|
|
356
|
+
|
|
357
|
+
export const buildWorkspaceStaticSite = async () =>
|
|
358
|
+
buildStaticSite({
|
|
359
|
+
siteName: 'Site',
|
|
360
|
+
siteUrl: process.env.SITE_URL,
|
|
361
|
+
stylesheetContent: await readFile(join(process.cwd(), 'dist/styles.css'), 'utf8'),
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
void buildWorkspaceStaticSite();
|
|
587
365
|
`,
|
|
588
|
-
'workspaces/ssg/index.test.
|
|
366
|
+
'workspaces/ssg/index.test.ts': `import { join } from 'node:path';
|
|
589
367
|
|
|
590
|
-
|
|
591
|
-
Promise.resolve({
|
|
592
|
-
title: 'Sample Content',
|
|
593
|
-
body: 'This is a sample content fetched from the CMS.',
|
|
594
|
-
}),
|
|
595
|
-
);
|
|
596
|
-
let scriptPromise: Promise<void> | undefined;
|
|
597
|
-
const scriptMock = jest.fn((handler: () => Promise<void>) => {
|
|
598
|
-
scriptPromise = handler();
|
|
368
|
+
import { describe, expect, it, jest } from '@jest/globals';
|
|
599
369
|
|
|
600
|
-
|
|
601
|
-
})
|
|
602
|
-
const nodeFs = jest.requireActual<typeof import('node:fs')>('node:fs');
|
|
603
|
-
const mkdirSyncMock = jest.fn();
|
|
604
|
-
const readFileSyncMock = jest.fn<(path: string | URL, encoding: 'utf8') => string>(
|
|
605
|
-
() => '.content { display: block; }',
|
|
370
|
+
const mockReadFile = jest.fn<(path: string, encoding: string) => Promise<string>>(() =>
|
|
371
|
+
Promise.resolve('body { color: #28323c; }'),
|
|
606
372
|
);
|
|
607
|
-
const
|
|
373
|
+
const mockBuildStaticSite = jest.fn<
|
|
374
|
+
(options: { readonly siteName: string; readonly siteUrl?: string; readonly stylesheetContent: string }) => Promise<void>
|
|
375
|
+
>(() => Promise.resolve());
|
|
608
376
|
|
|
609
|
-
jest.mock('node:fs', () => ({
|
|
610
|
-
|
|
611
|
-
mkdirSync: mkdirSyncMock,
|
|
612
|
-
readFileSync: readFileSyncMock,
|
|
613
|
-
writeFileSync: writeFileSyncMock,
|
|
377
|
+
jest.mock('node:fs/promises', () => ({
|
|
378
|
+
readFile: mockReadFile,
|
|
614
379
|
}));
|
|
615
380
|
|
|
616
|
-
jest.mock('@vyriy/
|
|
617
|
-
|
|
381
|
+
jest.mock('@vyriy/ssg', () => ({
|
|
382
|
+
buildStaticSite: mockBuildStaticSite,
|
|
618
383
|
}));
|
|
619
384
|
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
expect(generatedHtml).toContain('<style>.content { display: block; }</style>');
|
|
645
|
-
expect(generatedHtml).toContain('This is a sample content fetched from the CMS.');
|
|
385
|
+
describe('@w/ssg entry point', () => {
|
|
386
|
+
it('builds the static site with the compiled stylesheet content', async () => {
|
|
387
|
+
const cwd = jest.spyOn(process, 'cwd').mockReturnValue('/project');
|
|
388
|
+
const siteUrl = process.env.SITE_URL;
|
|
389
|
+
process.env.SITE_URL = 'https://example.com';
|
|
390
|
+
|
|
391
|
+
try {
|
|
392
|
+
await import('./index.js');
|
|
393
|
+
await Promise.resolve();
|
|
394
|
+
|
|
395
|
+
expect(mockReadFile).toHaveBeenCalledWith(join('/project', 'dist/styles.css'), 'utf8');
|
|
396
|
+
expect(mockBuildStaticSite).toHaveBeenCalledWith({
|
|
397
|
+
siteName: 'Site',
|
|
398
|
+
siteUrl: 'https://example.com',
|
|
399
|
+
stylesheetContent: 'body { color: #28323c; }',
|
|
400
|
+
});
|
|
401
|
+
} finally {
|
|
402
|
+
cwd.mockRestore();
|
|
403
|
+
if (siteUrl === undefined) {
|
|
404
|
+
delete process.env.SITE_URL;
|
|
405
|
+
} else {
|
|
406
|
+
process.env.SITE_URL = siteUrl;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
646
409
|
});
|
|
647
410
|
});
|
|
648
411
|
`,
|
|
412
|
+
'site/home/README.md': `---
|
|
413
|
+
title: Site
|
|
414
|
+
description: A calm static site generated with @vyriy/ssg.
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
# Site
|
|
418
|
+
|
|
419
|
+
This is a Markdown-first static site generated with \`@vyriy/ssg\`.
|
|
420
|
+
|
|
421
|
+
Edit content under \`site/*/README.md\`, then run:
|
|
422
|
+
|
|
423
|
+
\`\`\`bash
|
|
424
|
+
yarn build:ssg
|
|
425
|
+
\`\`\`
|
|
426
|
+
`,
|
|
427
|
+
'site/consulting/README.md': `---
|
|
428
|
+
title: Consulting
|
|
429
|
+
description: A standalone page generated from Markdown.
|
|
430
|
+
published: true
|
|
431
|
+
---
|
|
432
|
+
|
|
433
|
+
# Consulting
|
|
434
|
+
|
|
435
|
+
This standalone page is optional, but it shows how \`@vyriy/ssg\` can generate
|
|
436
|
+
top-level content pages alongside indexed sections.
|
|
437
|
+
`,
|
|
438
|
+
'site/docs/README.md': `---
|
|
439
|
+
title: Documentation
|
|
440
|
+
description: Documentation landing page for the generated static site.
|
|
441
|
+
published: true
|
|
442
|
+
tags:
|
|
443
|
+
- docs
|
|
444
|
+
---
|
|
445
|
+
|
|
446
|
+
# Documentation
|
|
447
|
+
|
|
448
|
+
Add documentation entries under \`site/docs/<slug>/README.md\`.
|
|
449
|
+
`,
|
|
450
|
+
'site/blog/hello-world/README.md': `---
|
|
451
|
+
title: Hello static site
|
|
452
|
+
description: First published blog entry for the generated SSG preset.
|
|
453
|
+
date: 2026-06-19
|
|
454
|
+
published: true
|
|
455
|
+
homePage: true
|
|
456
|
+
homePageOrder: 1
|
|
457
|
+
tags:
|
|
458
|
+
- ssg
|
|
459
|
+
- vyriy
|
|
460
|
+
---
|
|
461
|
+
|
|
462
|
+
# Hello static site
|
|
463
|
+
|
|
464
|
+
This starter blog entry proves that the generated site can build indexed content
|
|
465
|
+
sections from Markdown.
|
|
466
|
+
`,
|
|
467
|
+
'site/examples/hello-world/README.md': `---
|
|
468
|
+
title: Hello example
|
|
469
|
+
description: First example entry for the generated SSG preset.
|
|
470
|
+
date: 2026-06-19
|
|
471
|
+
published: true
|
|
472
|
+
tags:
|
|
473
|
+
- example
|
|
474
|
+
- ssg
|
|
475
|
+
---
|
|
476
|
+
|
|
477
|
+
# Hello example
|
|
478
|
+
|
|
479
|
+
Examples live under \`site/examples/<slug>/README.md\`.
|
|
480
|
+
`,
|
|
481
|
+
'site/public/.gitkeep': '',
|
|
649
482
|
});
|