vyriy 0.3.8 → 0.3.9

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,408 +1,8 @@
1
- import { agentsTemplate } from './agentsTemplate.js';
2
- import rootPackageJson from '../../../package.json' with { type: 'json' };
3
- const json = (value) => `${JSON.stringify(value, null, 2)}\n`;
4
- const packageVersion = (version) => `^${version}`;
5
- const baseRootDevDependencies = {
6
- '@vyriy/typescript-config': packageVersion(rootPackageJson.version),
7
- typescript: rootPackageJson.dependencies.typescript,
8
- '@vyriy/prettier-config': packageVersion(rootPackageJson.version),
9
- prettier: rootPackageJson.dependencies.prettier,
10
- '@vyriy/eslint-config': packageVersion(rootPackageJson.version),
11
- eslint: rootPackageJson.dependencies.eslint,
12
- '@vyriy/jest-config': packageVersion(rootPackageJson.version),
13
- jest: rootPackageJson.dependencies.jest,
14
- '@vyriy/storybook-config': packageVersion(rootPackageJson.version),
15
- storybook: rootPackageJson.dependencies.storybook,
16
- '@vyriy/path': packageVersion(rootPackageJson.version),
17
- husky: rootPackageJson.dependencies.husky,
18
- 'npm-run-all2': rootPackageJson.dependencies['npm-run-all2'],
19
- 'cross-env': rootPackageJson.dependencies['cross-env'],
20
- };
21
- const stylelintDevDependencies = {
22
- '@vyriy/stylelint-config': packageVersion(rootPackageJson.version),
23
- stylelint: rootPackageJson.dependencies.stylelint,
24
- };
25
- const createRootPackageJson = ({ description, packageScope, projectName, stylelint, }) => ({
26
- path: 'package.json',
27
- content: json({
28
- name: `${packageScope}/${projectName}`,
29
- version: '0.0.0',
30
- description,
31
- private: true,
32
- type: 'module',
33
- packageManager: rootPackageJson.packageManager,
34
- engines: {
35
- node: rootPackageJson.engines.node,
36
- },
37
- workspaces: [
38
- 'packages/*',
39
- 'workspaces/*',
40
- ],
41
- scripts: {
42
- storybook: 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook dev -p 6006 --disable-telemetry',
43
- check: 'run-s lint build test',
44
- fix: "run-s 'fix:*'",
45
- lint: "run-s 'lint:*'",
46
- build: "run-s 'build:*'",
47
- test: "run-s 'test:*'",
48
- 'fix:prettier': 'prettier . --write',
49
- 'fix:eslint': 'eslint . --fix',
50
- 'lint:ts': 'tsc --pretty false',
51
- 'lint:prettier': 'prettier . --check',
52
- 'lint:eslint': 'eslint .',
53
- ...(stylelint ? { 'lint:stylelint': 'stylelint "packages/**/*.{scss,css}"' } : {}),
54
- 'build:dist': 'echo "Build dist is not configured yet."',
55
- 'build:storybook': 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook build --quiet --disable-telemetry',
56
- 'test:jest': 'jest --passWithNoTests',
57
- postinstall: 'husky',
58
- },
59
- devDependencies: {
60
- ...baseRootDevDependencies,
61
- ...(stylelint ? stylelintDevDependencies : {}),
62
- },
63
- }),
64
- });
65
- const createPackageManifest = ({ packageScope, workspaceName, }) => ({
66
- path: `packages/${workspaceName}/package.json`,
67
- content: json({
68
- name: `${packageScope}/${workspaceName}`,
69
- version: '0.0.0',
70
- private: true,
71
- type: 'module',
72
- main: 'index.js',
73
- }),
74
- });
75
- const getWorkspacePath = (workspacePlan) => workspacePlan.kind === 'lambda' && workspacePlan.name === 'api'
76
- ? `workspaces/lambda/${workspacePlan.name}`
77
- : `workspaces/${workspacePlan.name}`;
78
- const getWorkspacePackageName = ({ packageScope, workspacePlan, }) => workspacePlan.kind === 'lambda' && workspacePlan.name === 'api'
79
- ? `${packageScope}/lambda-api-workspace`
80
- : `${packageScope}/${workspacePlan.name}-workspace`;
81
- const isApiWorkspace = (workspacePlan) => [
82
- 'api',
83
- 'lambda',
84
- 'fargate',
85
- ].includes(workspacePlan.kind);
86
- const createApiWorkspaceDependencies = (workspacePlan) => isApiWorkspace(workspacePlan)
87
- ? {
88
- '@vyriy/handler': packageVersion(rootPackageJson.version),
89
- '@vyriy/server': packageVersion(rootPackageJson.version),
90
- }
91
- : {};
92
- const createPackageFiles = (plan, packagePlan) => [
93
- createPackageManifest({
94
- packageScope: plan.packageScope,
95
- workspaceName: packagePlan.name,
96
- }),
97
- {
98
- path: `packages/${packagePlan.name}/README.md`,
99
- content: `# ${plan.packageScope}/${packagePlan.name}\n\n${plan.description}\n`,
100
- },
101
- {
102
- path: `packages/${packagePlan.name}/index.ts`,
103
- content: packagePlan.kind === 'stack' ? "export * from './stack.js';\n" : "export type * from './types.js';\n",
104
- },
105
- ...(packagePlan.kind === 'stack'
106
- ? [
107
- {
108
- path: `packages/${packagePlan.name}/stack.ts`,
109
- content: 'export type StackName = string;\n',
110
- },
111
- {
112
- path: `packages/${packagePlan.name}/stack.test.ts`,
113
- content: "import { describe, expect, it } from '@jest/globals';\n\ndescribe('stack', () => {\n it('has a test harness', () => {\n expect(true).toBe(true);\n });\n});\n",
114
- },
115
- ]
116
- : [
117
- {
118
- path: `packages/${packagePlan.name}/types.ts`,
119
- content: 'export type PackageName = string;\n',
120
- },
121
- {
122
- path: `packages/${packagePlan.name}/${packagePlan.name}.test.ts`,
123
- content: "import { describe, expect, it } from '@jest/globals';\n\ndescribe('package', () => {\n it('has a test harness', () => {\n expect(true).toBe(true);\n });\n});\n",
124
- },
125
- ]),
126
- ];
127
- const createApiHandlerFile = (workspacePath) => ({
128
- path: `${workspacePath}/handler.ts`,
129
- content: `import { api } from '@vyriy/handler';
130
-
131
- export const handler = api(async (event) => ({
132
- statusCode: 200,
133
- body: JSON.stringify({
134
- path: event.path,
135
- }),
136
- }));
137
- `,
138
- });
139
- const createApiServerFile = ({ entrypoint, workspacePath, }) => ({
140
- path: `${workspacePath}/${entrypoint}`,
141
- content: `import { server } from '@vyriy/server';
142
-
143
- import { handler } from './handler.js';
144
-
145
- server(handler);
146
- `,
147
- });
148
- const createDockerfile = (workspacePath) => ({
149
- path: `${workspacePath}/Dockerfile`,
150
- content: `FROM node:24-alpine
151
-
152
- WORKDIR /app
153
-
154
- COPY package.json yarn.lock .yarnrc.yml ./
155
- COPY .yarn ./.yarn
156
- COPY packages ./packages
157
- COPY workspaces ./workspaces
158
-
159
- RUN corepack enable && yarn install --immutable
160
- RUN yarn build
161
-
162
- CMD ["node", "workspaces/api/index.js"]
163
- `,
164
- });
165
- const createApiWorkspaceFiles = (plan, workspacePlan) => {
166
- const workspacePath = getWorkspacePath(workspacePlan);
167
- const isLambda = workspacePlan.kind === 'lambda';
168
- return [
169
- createApiHandlerFile(workspacePath),
170
- createApiServerFile({ entrypoint: isLambda ? 'server.ts' : 'index.ts', workspacePath }),
171
- {
172
- path: `${workspacePath}/${workspacePlan.name}.test.ts`,
173
- content: "import { describe, expect, it } from '@jest/globals';\n\nimport { handler } from './handler.js';\n\ndescribe('api workspace', () => {\n it('exports a handler', () => {\n expect(handler).toEqual(expect.any(Function));\n });\n});\n",
174
- },
175
- ...(plan.features.includes('docker') && !isLambda ? [createDockerfile(workspacePath)] : []),
176
- ];
177
- };
178
- const createWorkspaceFiles = (plan, workspacePlan) => {
179
- const workspacePath = getWorkspacePath(workspacePlan);
180
- const dependencies = createApiWorkspaceDependencies(workspacePlan);
181
- return [
182
- {
183
- path: `${workspacePath}/package.json`,
184
- content: json({
185
- name: getWorkspacePackageName({ packageScope: plan.packageScope, workspacePlan }),
186
- version: '0.0.0',
187
- private: true,
188
- type: 'module',
189
- main: workspacePlan.kind === 'lambda' ? 'server.js' : 'index.js',
190
- ...(Object.keys(dependencies).length > 0 ? { dependencies } : {}),
191
- }),
192
- },
193
- ...(isApiWorkspace(workspacePlan)
194
- ? createApiWorkspaceFiles(plan, workspacePlan)
195
- : [
196
- {
197
- path: `${workspacePath}/index.ts`,
198
- content: 'export type WorkspaceName = string;\n',
199
- },
200
- {
201
- path: `${workspacePath}/${workspacePlan.name}.test.ts`,
202
- content: "import { describe, expect, it } from '@jest/globals';\n\ndescribe('workspace', () => {\n it('has a test harness', () => {\n expect(true).toBe(true);\n });\n});\n",
203
- },
204
- ]),
205
- ];
206
- };
207
- const shouldCreateStylelintConfig = (plan) => plan.features.some((feature) => [
208
- 'react',
209
- 'webpack',
210
- ].includes(feature));
211
- const getStylePackageName = (plan) => plan.packages.find((packagePlan) => packagePlan.kind === 'ui')?.name ?? 'ui';
1
+ import { createBaseFiles } from './base/createBaseFiles.js';
2
+ import { createPackageFiles } from './packages/createPackageFiles.js';
3
+ import { createWorkspaceFiles } from './workspaces/createWorkspaceFiles.js';
212
4
  export const createProjectFiles = (plan) => [
213
- createRootPackageJson({
214
- ...plan,
215
- stylelint: shouldCreateStylelintConfig(plan),
216
- }),
217
- {
218
- path: 'README.md',
219
- content: `# ${plan.projectName}\n\n${plan.description}\n`,
220
- },
221
- {
222
- path: 'doc.mdx',
223
- content: `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
224
- import ReadMe from './README.md?raw';
225
-
226
- <Meta title="${plan.projectName}" />
227
-
228
- <Markdown>{ReadMe}</Markdown>
229
- `,
230
- },
231
- {
232
- path: 'AGENTS.md',
233
- content: agentsTemplate,
234
- },
235
- {
236
- path: '.editorconfig',
237
- content: `# https://editorconfig.org
238
- root = true
239
-
240
- [*]
241
- charset = utf-8
242
- end_of_line = lf
243
- insert_final_newline = true
244
- trim_trailing_whitespace = true
245
-
246
- indent_style = space
247
- indent_size = 2
248
-
249
- max_line_length = 100
250
-
251
- # Markdown
252
- [*.md]
253
- trim_trailing_whitespace = false
254
- max_line_length = off
255
-
256
- # YAML / YML
257
- [*.{yml,yaml}]
258
- indent_size = 2
259
-
260
- # JSON
261
- [*.json]
262
- indent_size = 2
263
-
264
- # TypeScript / JavaScript
265
- [*.{ts,tsx,js,jsx}]
266
- indent_size = 2
267
-
268
- # Shell / Bash
269
- [*.sh]
270
- indent_size = 2`,
271
- },
272
- {
273
- path: '.gitignore',
274
- content: `.yarn/*
275
- !.yarn/cache
276
- !.yarn/patches
277
- !.yarn/plugins
278
- !.yarn/releases
279
- !.yarn/sdks
280
- !.yarn/versions
281
-
282
- .DS_Store
283
- .idea
284
- node_modules
285
- coverage
286
- dist
287
- storybook-static
288
- *storybook.log
289
- consumer
290
-
291
- cdk.out
292
- cdk.context.json
293
-
294
- !/**/.gitkeep`,
295
- },
296
- {
297
- path: '.npmrc',
298
- content: 'engine-strict=true\n',
299
- },
300
- {
301
- path: '.nvmrc',
302
- content: 'lts/krypton',
303
- },
304
- {
305
- path: '.yarnrc.yml',
306
- content: 'nodeLinker: node-modules\n',
307
- },
308
- {
309
- path: '.husky/commit-msg',
310
- content: '#!/bin/sh\n',
311
- },
312
- {
313
- path: '.husky/post-checkout',
314
- content: '#!/bin/sh\n\nyarn\n',
315
- },
316
- {
317
- path: '.husky/post-merge',
318
- content: '#!/bin/sh\n\nyarn\n',
319
- },
320
- {
321
- path: '.husky/pre-commit',
322
- content: '#!/bin/sh\n\nyarn check\n',
323
- },
324
- {
325
- path: '.husky/pre-push',
326
- content: '#!/bin/sh\n\nyarn check\n',
327
- },
328
- {
329
- path: '.storybook/main.ts',
330
- content: `import config from '@vyriy/storybook-config';
331
- import { path } from '@vyriy/path';
332
-
333
- export default {
334
- ...config,
335
- stories: [
336
- path('**/*.mdx'),
337
- path('**/*.stories.@(js|jsx|mjs|ts|tsx)'),
338
- ],
339
- };
340
- `,
341
- },
342
- {
343
- path: '.storybook/preview.tsx',
344
- content: "export { default } from '@vyriy/storybook-config/preview';\n",
345
- },
346
- {
347
- path: 'yarn.lock',
348
- content: '',
349
- },
350
- {
351
- path: 'tsconfig.json',
352
- content: json({
353
- extends: '@vyriy/typescript-config/index.json',
354
- include: [
355
- '.storybook/**/*.ts',
356
- '.storybook/**/*.tsx',
357
- 'packages/**/*.ts',
358
- 'packages/**/*.tsx',
359
- 'workspaces/**/*.ts',
360
- 'workspaces/**/*.tsx',
361
- '*.ts',
362
- ],
363
- }),
364
- },
365
- {
366
- path: 'prettier.config.ts',
367
- content: "export { default } from '@vyriy/prettier-config';\n",
368
- },
369
- {
370
- path: '.prettierignore',
371
- content: 'node_modules\ndist\ncoverage\nstorybook-static\n',
372
- },
373
- {
374
- path: 'eslint.config.ts',
375
- content: "export { default } from '@vyriy/eslint-config';\n",
376
- },
377
- {
378
- path: 'jest.config.ts',
379
- content: "export { default } from '@vyriy/jest-config';\n",
380
- },
381
- ...(shouldCreateStylelintConfig(plan)
382
- ? [
383
- {
384
- path: 'stylelint.config.ts',
385
- content: "export { default } from '@vyriy/stylelint-config';\n",
386
- },
387
- {
388
- path: `packages/${getStylePackageName(plan)}/reset.scss`,
389
- content: `html {
390
- box-sizing: border-box;
391
- }
392
-
393
- *,
394
- *::before,
395
- *::after {
396
- box-sizing: inherit;
397
- }
398
-
399
- body {
400
- margin: 0;
401
- }
402
- `,
403
- },
404
- ]
405
- : []),
5
+ ...createBaseFiles(plan),
406
6
  ...plan.packages.flatMap((packagePlan) => createPackageFiles(plan, packagePlan)),
407
7
  ...plan.workspaces.flatMap((workspacePlan) => createWorkspaceFiles(plan, workspacePlan)),
408
8
  ];
@@ -0,0 +1,3 @@
1
+ import { ProjectFile } from '../../file-plan/index.js';
2
+ import type { VyriyPackagePlan, VyriyProjectPlan } from '../../project-plan/index.js';
3
+ export declare const createLibraryUiFiles: (plan: VyriyProjectPlan, packagePlan: VyriyPackagePlan) => ProjectFile[];
@@ -0,0 +1,127 @@
1
+ import { packageVersion, peerDependencies, publishedPackageJson } from '../config.js';
2
+ import { createPackageManifest } from '../packages/createPackageManifest.js';
3
+ export const createLibraryUiFiles = (plan, packagePlan) => [
4
+ createPackageManifest({
5
+ dependencies: {
6
+ '@vyriy/cn': packageVersion(publishedPackageJson.version),
7
+ },
8
+ packageScope: plan.packageScope,
9
+ peerDependencies: {
10
+ react: peerDependencies.react,
11
+ },
12
+ workspaceName: packagePlan.name,
13
+ }),
14
+ {
15
+ path: `packages/${packagePlan.name}/README.md`,
16
+ content: `# ${plan.packageScope}/${packagePlan.name}\n\n${plan.description}\n`,
17
+ },
18
+ {
19
+ path: `packages/${packagePlan.name}/index.ts`,
20
+ content: "export * from './button.js';\n",
21
+ },
22
+ {
23
+ path: `packages/${packagePlan.name}/button.tsx`,
24
+ content: `import type { ComponentProps, FC } from 'react';
25
+ import { cn } from '@vyriy/cn';
26
+
27
+ import './button.scss';
28
+
29
+ export type ButtonProps = ComponentProps<'button'> & {
30
+ readonly variant?: 'primary' | 'secondary';
31
+ };
32
+
33
+ export type ButtonType = FC<ButtonProps>;
34
+
35
+ export const Button: ButtonType = ({ className, type = 'button', variant = 'primary', ...props }) => (
36
+ <button className={cn('button', \`button--\${variant}\`, className)} type={type} {...props} />
37
+ );
38
+ `,
39
+ },
40
+ {
41
+ path: `packages/${packagePlan.name}/button.scss`,
42
+ content: `.button {
43
+ border: 1px solid transparent;
44
+ border-radius: 6px;
45
+ cursor: pointer;
46
+ font: inherit;
47
+ padding: 0.5rem 0.875rem;
48
+ }
49
+
50
+ .button--primary {
51
+ background: #1f6feb;
52
+ color: #fff;
53
+ }
54
+
55
+ .button--secondary {
56
+ background: #fff;
57
+ border-color: #d0d7de;
58
+ color: #24292f;
59
+ }
60
+ `,
61
+ },
62
+ {
63
+ path: `packages/${packagePlan.name}/styles.d.ts`,
64
+ content: "declare module '*.scss';\n",
65
+ },
66
+ {
67
+ path: `packages/${packagePlan.name}/button.stories.tsx`,
68
+ content: `import type { Meta, StoryObj } from '@storybook/react-webpack5';
69
+
70
+ import { Button } from './button.js';
71
+
72
+ const meta = {
73
+ title: 'UI/Button',
74
+ component: Button,
75
+ args: {
76
+ children: 'Button',
77
+ },
78
+ } satisfies Meta<typeof Button>;
79
+
80
+ export default meta;
81
+
82
+ type Story = StoryObj<typeof meta>;
83
+
84
+ export const Primary: Story = {};
85
+
86
+ export const Secondary: Story = {
87
+ args: {
88
+ variant: 'secondary',
89
+ },
90
+ };
91
+ `,
92
+ },
93
+ {
94
+ path: `packages/${packagePlan.name}/button.test.tsx`,
95
+ content: `import type { ReactElement } from 'react';
96
+ import { describe, expect, it } from '@jest/globals';
97
+
98
+ import { Button } from './button.js';
99
+
100
+ type ButtonElement = ReactElement<{
101
+ readonly className: string;
102
+ readonly type: string;
103
+ }>;
104
+
105
+ describe('Button', () => {
106
+ it('creates a primary button by default', () => {
107
+ const element = Button({ children: 'Save' }) as ButtonElement;
108
+
109
+ expect(element.props.className).toBe('button button--primary');
110
+ expect(element.props.type).toBe('button');
111
+ });
112
+
113
+ it('composes secondary and custom classes', () => {
114
+ const element = Button({
115
+ children: 'Cancel',
116
+ className: 'wide',
117
+ type: 'submit',
118
+ variant: 'secondary',
119
+ }) as ButtonElement;
120
+
121
+ expect(element.props.className).toBe('button button--secondary wide');
122
+ expect(element.props.type).toBe('submit');
123
+ });
124
+ });
125
+ `,
126
+ },
127
+ ];
@@ -0,0 +1,3 @@
1
+ import { ProjectFile } from '../../file-plan/index.js';
2
+ import type { VyriyPackagePlan, VyriyProjectPlan } from '../../project-plan/index.js';
3
+ export declare const createPackageFiles: (plan: VyriyProjectPlan, packagePlan: VyriyPackagePlan) => ProjectFile[];
@@ -0,0 +1,39 @@
1
+ import { createLibraryUiFiles } from '../library/createLibraryUiFiles.js';
2
+ import { createPackageManifest } from './createPackageManifest.js';
3
+ const createGenericPackageFiles = (plan, packagePlan) => [
4
+ createPackageManifest({
5
+ packageScope: plan.packageScope,
6
+ workspaceName: packagePlan.name,
7
+ }),
8
+ {
9
+ path: `packages/${packagePlan.name}/README.md`,
10
+ content: `# ${plan.packageScope}/${packagePlan.name}\n\n${plan.description}\n`,
11
+ },
12
+ {
13
+ path: `packages/${packagePlan.name}/index.ts`,
14
+ content: packagePlan.kind === 'stack' ? "export * from './stack.js';\n" : "export type * from './types.js';\n",
15
+ },
16
+ ...(packagePlan.kind === 'stack'
17
+ ? [
18
+ {
19
+ path: `packages/${packagePlan.name}/stack.ts`,
20
+ content: 'export type StackName = string;\n',
21
+ },
22
+ {
23
+ path: `packages/${packagePlan.name}/stack.test.ts`,
24
+ content: "import { describe, expect, it } from '@jest/globals';\n\ndescribe('stack', () => {\n it('has a test harness', () => {\n expect(true).toBe(true);\n });\n});\n",
25
+ },
26
+ ]
27
+ : [
28
+ {
29
+ path: `packages/${packagePlan.name}/types.ts`,
30
+ content: 'export type PackageName = string;\n',
31
+ },
32
+ {
33
+ path: `packages/${packagePlan.name}/${packagePlan.name}.test.ts`,
34
+ content: "import { describe, expect, it } from '@jest/globals';\n\ndescribe('package', () => {\n it('has a test harness', () => {\n expect(true).toBe(true);\n });\n});\n",
35
+ },
36
+ ]),
37
+ ];
38
+ const createPresetPackageFiles = (plan, packagePlan) => plan.preset === 'library' && packagePlan.kind === 'ui' ? createLibraryUiFiles(plan, packagePlan) : undefined;
39
+ export const createPackageFiles = (plan, packagePlan) => createPresetPackageFiles(plan, packagePlan) ?? createGenericPackageFiles(plan, packagePlan);
@@ -0,0 +1,7 @@
1
+ import { ProjectFile } from '../../file-plan/index.js';
2
+ export declare const createPackageManifest: ({ dependencies, packageScope, peerDependencies, workspaceName, }: {
3
+ readonly dependencies?: Record<string, string>;
4
+ readonly packageScope: string;
5
+ readonly peerDependencies?: Record<string, string>;
6
+ readonly workspaceName: string;
7
+ }) => ProjectFile;
@@ -0,0 +1,13 @@
1
+ import { json } from '../config.js';
2
+ export const createPackageManifest = ({ dependencies = {}, packageScope, peerDependencies = {}, workspaceName, }) => ({
3
+ path: `packages/${workspaceName}/package.json`,
4
+ content: json({
5
+ name: `${packageScope}/${workspaceName}`,
6
+ version: '0.0.0',
7
+ private: true,
8
+ type: 'module',
9
+ main: 'index.js',
10
+ ...(Object.keys(dependencies).length > 0 ? { dependencies } : {}),
11
+ ...(Object.keys(peerDependencies).length > 0 ? { peerDependencies } : {}),
12
+ }),
13
+ });
@@ -0,0 +1,3 @@
1
+ import { ProjectFile } from '../../file-plan/index.js';
2
+ import type { VyriyProjectPlan, VyriyWorkspacePlan } from '../../project-plan/index.js';
3
+ export declare const createWorkspaceFiles: (plan: VyriyProjectPlan, workspacePlan: VyriyWorkspacePlan) => ProjectFile[];