@vyriy/create 0.5.2 → 0.5.3
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/bin/vyriy-create.js +8 -4
- package/package.json +2 -12
- package/preset/api.d.ts +1 -1
- package/preset/api.js +218 -11
- package/preset/base.d.ts +1 -1
- package/preset/fullstack.js +233 -12
- package/preset/gql.d.ts +1 -1
- package/preset/gql.js +112 -2
- package/preset/library.d.ts +1 -1
- package/preset/library.js +113 -4
- package/preset/mfe.d.ts +1 -1
- package/preset/mfe.js +163 -62
- package/preset/rest.d.ts +1 -1
- package/preset/rest.js +219 -13
- package/preset/spa.d.ts +1 -1
- package/preset/spa.js +238 -18
- package/preset/ssg.d.ts +1 -1
- package/preset/ssg.js +267 -20
- package/preset/ssr.d.ts +1 -1
- package/preset/ssr.js +268 -20
- package/prompt/preset.js +5 -1
- package/preset/shared.d.ts +0 -116
- package/preset/shared.js +0 -245
package/preset/ssg.js
CHANGED
|
@@ -1,25 +1,272 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
1
4
|
import packageJson from '../package.json' with { type: 'json' };
|
|
2
|
-
|
|
3
|
-
|
|
5
|
+
const presetDir = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
const agentsPath = [
|
|
7
|
+
resolve(presetDir, '../../../AGENTS.md'),
|
|
8
|
+
resolve(presetDir, '../../../../AGENTS.md'),
|
|
9
|
+
].find(existsSync) ?? '';
|
|
10
|
+
const agentsContent = agentsPath ? readFileSync(agentsPath, 'utf8') : '';
|
|
4
11
|
export const ssg = (options) => ({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
'package.json': JSON.stringify({
|
|
13
|
+
name: options.name,
|
|
14
|
+
version: '0.0.0',
|
|
15
|
+
description: options.description,
|
|
16
|
+
private: true,
|
|
17
|
+
type: 'module',
|
|
18
|
+
agents: './AGENTS.md',
|
|
19
|
+
packageManager: packageJson.packageManager,
|
|
20
|
+
engines: {
|
|
21
|
+
node: packageJson.engines.node,
|
|
22
|
+
},
|
|
23
|
+
workspaces: [
|
|
24
|
+
'packages/*',
|
|
25
|
+
'workspaces/*',
|
|
26
|
+
],
|
|
27
|
+
scripts: {
|
|
28
|
+
storybook: 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook dev -p 6006 --disable-telemetry',
|
|
29
|
+
check: 'run-s lint build test',
|
|
30
|
+
fix: "run-s 'fix:*'",
|
|
31
|
+
start: "run-p 'start:*'",
|
|
32
|
+
lint: "run-s 'lint:*'",
|
|
33
|
+
build: "run-s 'build:*'",
|
|
34
|
+
test: "run-s 'test:*'",
|
|
35
|
+
'fix:prettier': 'prettier . --write',
|
|
36
|
+
'fix:eslint': 'eslint . --fix',
|
|
37
|
+
'fix:stylelint': 'stylelint "**/*.{css,scss}" --fix',
|
|
38
|
+
'lint:ts': 'tsc',
|
|
39
|
+
'lint:prettier': 'prettier . --check',
|
|
40
|
+
'lint:eslint': 'eslint .',
|
|
41
|
+
'lint:stylelint': 'stylelint "**/*.{css,scss}"',
|
|
42
|
+
'build:storybook': 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook build --quiet --disable-telemetry',
|
|
43
|
+
'test:jest': 'jest',
|
|
44
|
+
postinstall: 'husky',
|
|
45
|
+
'start:ssg': 'sh workspaces/ssg/bin/start.sh',
|
|
46
|
+
'build:ssg': 'rimraf dist && sh workspaces/ssg/bin/build.sh',
|
|
47
|
+
},
|
|
48
|
+
dependencies: {
|
|
49
|
+
'@vyriy/typescript-config': `^${packageJson.version}`,
|
|
50
|
+
typescript: packageJson.peerDependencies.typescript,
|
|
51
|
+
'@vyriy/prettier-config': `^${packageJson.version}`,
|
|
52
|
+
prettier: packageJson.peerDependencies.prettier,
|
|
53
|
+
'@vyriy/eslint-config': `^${packageJson.version}`,
|
|
54
|
+
eslint: packageJson.peerDependencies.eslint,
|
|
55
|
+
'@vyriy/jest-config': `^${packageJson.version}`,
|
|
56
|
+
jest: packageJson.peerDependencies.jest,
|
|
57
|
+
'@vyriy/storybook-config': `^${packageJson.version}`,
|
|
58
|
+
storybook: packageJson.peerDependencies.storybook,
|
|
59
|
+
'@vyriy/path': `^${packageJson.version}`,
|
|
60
|
+
husky: packageJson.peerDependencies.husky,
|
|
61
|
+
'npm-run-all2': packageJson.peerDependencies['npm-run-all2'],
|
|
62
|
+
'cross-env': packageJson.peerDependencies['cross-env'],
|
|
63
|
+
rimraf: packageJson.peerDependencies.rimraf,
|
|
64
|
+
'@vyriy/webpack-config': `^${packageJson.version}`,
|
|
65
|
+
tsx: packageJson.peerDependencies.tsx,
|
|
66
|
+
'webpack-cli': packageJson.peerDependencies['webpack-cli'],
|
|
67
|
+
'@vyriy/script': `^${packageJson.version}`,
|
|
68
|
+
react: packageJson.peerDependencies.react,
|
|
69
|
+
'react-dom': packageJson.peerDependencies['react-dom'],
|
|
70
|
+
'@types/react': packageJson.peerDependencies['@types/react'],
|
|
71
|
+
'@types/react-dom': packageJson.peerDependencies['@types/react-dom'],
|
|
72
|
+
'@vyriy/stylelint-config': `^${packageJson.version}`,
|
|
73
|
+
stylelint: packageJson.peerDependencies.stylelint,
|
|
74
|
+
'@vyriy/cn': `^${packageJson.version}`,
|
|
75
|
+
'@vyriy/html': `^${packageJson.version}`,
|
|
76
|
+
sass: packageJson.peerDependencies.sass,
|
|
77
|
+
},
|
|
78
|
+
}, null, 2) + '\n',
|
|
79
|
+
'README.md': `# ${options.name}\n\n${options.description}\n`,
|
|
80
|
+
'doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
|
|
81
|
+
import ReadMe from './README.md?raw';
|
|
82
|
+
|
|
83
|
+
<Meta title="${options.name}" />
|
|
84
|
+
|
|
85
|
+
<Markdown>{ReadMe}</Markdown>
|
|
86
|
+
`,
|
|
87
|
+
'AGENTS.md': agentsContent,
|
|
88
|
+
'.editorconfig': `# https://editorconfig.org
|
|
89
|
+
root = true
|
|
90
|
+
|
|
91
|
+
[*]
|
|
92
|
+
charset = utf-8
|
|
93
|
+
end_of_line = lf
|
|
94
|
+
insert_final_newline = true
|
|
95
|
+
trim_trailing_whitespace = true
|
|
96
|
+
|
|
97
|
+
indent_style = space
|
|
98
|
+
indent_size = 2
|
|
99
|
+
|
|
100
|
+
max_line_length = 100
|
|
101
|
+
|
|
102
|
+
# Markdown
|
|
103
|
+
[*.md]
|
|
104
|
+
trim_trailing_whitespace = false
|
|
105
|
+
max_line_length = off
|
|
106
|
+
|
|
107
|
+
# YAML / YML
|
|
108
|
+
[*.{yml,yaml}]
|
|
109
|
+
indent_size = 2
|
|
110
|
+
|
|
111
|
+
# JSON
|
|
112
|
+
[*.json]
|
|
113
|
+
indent_size = 2
|
|
114
|
+
|
|
115
|
+
# TypeScript / JavaScript
|
|
116
|
+
[*.{ts,tsx,js,jsx}]
|
|
117
|
+
indent_size = 2
|
|
118
|
+
|
|
119
|
+
# Shell / Bash
|
|
120
|
+
[*.sh]
|
|
121
|
+
indent_size = 2
|
|
122
|
+
`,
|
|
123
|
+
'.gitignore': `.yarn/*
|
|
124
|
+
!.yarn/cache
|
|
125
|
+
!.yarn/patches
|
|
126
|
+
!.yarn/plugins
|
|
127
|
+
!.yarn/releases
|
|
128
|
+
!.yarn/sdks
|
|
129
|
+
!.yarn/versions
|
|
130
|
+
|
|
131
|
+
.DS_Store
|
|
132
|
+
.idea
|
|
133
|
+
node_modules
|
|
134
|
+
coverage
|
|
135
|
+
dist
|
|
136
|
+
storybook-static
|
|
137
|
+
*storybook.log
|
|
138
|
+
consumer
|
|
139
|
+
|
|
140
|
+
cdk.out
|
|
141
|
+
cdk.context.json
|
|
142
|
+
|
|
143
|
+
!/**/.gitkeep
|
|
144
|
+
`,
|
|
145
|
+
'.npmrc': 'engine-strict=true\n',
|
|
146
|
+
'.nvmrc': 'lts/krypton\n',
|
|
147
|
+
'.yarnrc.yml': 'nodeLinker: node-modules\nnpmMinimalAgeGate: 0\n',
|
|
148
|
+
'.husky/commit-msg': '#!/bin/sh\n',
|
|
149
|
+
'.husky/post-checkout': '#!/bin/sh\n\nyarn\n',
|
|
150
|
+
'.husky/post-merge': '#!/bin/sh\n\nyarn\n',
|
|
151
|
+
'.husky/pre-commit': '#!/bin/sh\n\nyarn check\n',
|
|
152
|
+
'.husky/pre-push': '#!/bin/sh\n\nyarn check\n',
|
|
153
|
+
'.storybook/main.ts': `import config from '@vyriy/storybook-config';
|
|
154
|
+
import { path } from '@vyriy/path';
|
|
155
|
+
|
|
156
|
+
export default {
|
|
157
|
+
...config,
|
|
158
|
+
stories: [
|
|
159
|
+
path('**/*.mdx'),
|
|
160
|
+
path('**/*.stories.@(js|jsx|mjs|ts|tsx)'),
|
|
161
|
+
],
|
|
162
|
+
};
|
|
163
|
+
`,
|
|
164
|
+
'.storybook/preview.tsx': "export { default } from '@vyriy/storybook-config/preview';\n",
|
|
165
|
+
'yarn.lock': '',
|
|
166
|
+
'tsconfig.json': JSON.stringify({
|
|
167
|
+
extends: '@vyriy/typescript-config/index.json',
|
|
168
|
+
include: [
|
|
169
|
+
'.storybook/**/*.ts',
|
|
170
|
+
'.storybook/**/*.tsx',
|
|
171
|
+
'packages/**/*.ts',
|
|
172
|
+
'packages/**/*.tsx',
|
|
173
|
+
'workspaces/**/*.ts',
|
|
174
|
+
'workspaces/**/*.tsx',
|
|
175
|
+
'*.ts',
|
|
176
|
+
],
|
|
177
|
+
}, null, 2) + '\n',
|
|
178
|
+
'prettier.config.ts': "export { default } from '@vyriy/prettier-config';\n",
|
|
179
|
+
'.prettierignore': 'node_modules\ndist\ncoverage\nstorybook-static\nconsumer\n',
|
|
180
|
+
'eslint.config.ts': "export { default } from '@vyriy/eslint-config';\n",
|
|
181
|
+
'jest.config.ts': "export { default } from '@vyriy/jest-config';\n",
|
|
182
|
+
'stylelint.config.ts': "export { default } from '@vyriy/stylelint-config';\n",
|
|
183
|
+
'assets.d.ts': "declare module '*.scss';\n",
|
|
184
|
+
'packages/components/package.json': JSON.stringify({
|
|
185
|
+
name: '@p/components',
|
|
186
|
+
private: true,
|
|
187
|
+
type: 'module',
|
|
188
|
+
}, null, 2) + '\n',
|
|
189
|
+
'packages/components/index.ts': "export * from './page/index.js';\n",
|
|
190
|
+
'packages/components/index.test.tsx': `import { describe, expect, it } from '@jest/globals';
|
|
191
|
+
|
|
192
|
+
import { Page } from './index.js';
|
|
193
|
+
import { Page as PageImplementation } from './page/index.js';
|
|
194
|
+
|
|
195
|
+
describe('packages/components/page', () => {
|
|
196
|
+
it('re-exports the page component', () => {
|
|
197
|
+
expect(Page).toBe(PageImplementation);
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
`,
|
|
201
|
+
'packages/components/page/index.ts': `export * from './page.js';
|
|
202
|
+
export type * from './types.js';
|
|
203
|
+
`,
|
|
204
|
+
'packages/components/page/index.test.ts': `import { describe, expect, it } from '@jest/globals';
|
|
205
|
+
|
|
206
|
+
import { Page } from './index.js';
|
|
207
|
+
import { Page as PageImplementation } from './page.js';
|
|
208
|
+
|
|
209
|
+
describe('packages/components/page', () => {
|
|
210
|
+
it('re-exports the page component', () => {
|
|
211
|
+
expect(Page).toBe(PageImplementation);
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
`,
|
|
215
|
+
'packages/components/page/types.ts': `import { FC } from 'react';
|
|
216
|
+
|
|
217
|
+
export type PageProps = {
|
|
218
|
+
content: string;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
export type PageType = FC<PageProps>;
|
|
222
|
+
`,
|
|
223
|
+
'packages/components/page/page.tsx': `import type { PageType } from './types.js';
|
|
224
|
+
|
|
225
|
+
export const Page: PageType = ({ content }) => <div className="content">{content}</div>;
|
|
226
|
+
`,
|
|
227
|
+
'packages/components/page/styles.scss': `.content {
|
|
228
|
+
display: block;
|
|
229
|
+
}
|
|
230
|
+
`,
|
|
231
|
+
'packages/components/page/page.test.tsx': `import { renderToStaticMarkup } from 'react-dom/server';
|
|
232
|
+
import { describe, expect, it } from '@jest/globals';
|
|
233
|
+
|
|
234
|
+
import { Page } from './page.js';
|
|
235
|
+
|
|
236
|
+
describe('packages/components/page/page', () => {
|
|
237
|
+
it('renders content inside the page content container', () => {
|
|
238
|
+
expect(renderToStaticMarkup(<Page content="Page body" />)).toBe('<div class="content">Page body</div>');
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
`,
|
|
242
|
+
'packages/services/package.json': JSON.stringify({
|
|
243
|
+
name: '@p/services',
|
|
244
|
+
private: true,
|
|
245
|
+
type: 'module',
|
|
246
|
+
}, null, 2) + '\n',
|
|
247
|
+
'packages/services/cms/index.ts': `export const cms = {
|
|
248
|
+
getContent: async () => {
|
|
249
|
+
// Placeholder for fetching content from a CMS
|
|
250
|
+
return Promise.resolve({
|
|
251
|
+
title: 'Sample Content',
|
|
252
|
+
body: 'This is a sample content fetched from the CMS.',
|
|
253
|
+
});
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
`,
|
|
257
|
+
'packages/services/cms/index.test.ts': `import { describe, expect, it } from '@jest/globals';
|
|
258
|
+
|
|
259
|
+
import { cms } from './index.js';
|
|
260
|
+
|
|
261
|
+
describe('packages/services/cms', () => {
|
|
262
|
+
it('returns content for rendering a page', async () => {
|
|
263
|
+
await expect(cms.getContent()).resolves.toEqual({
|
|
264
|
+
title: 'Sample Content',
|
|
265
|
+
body: 'This is a sample content fetched from the CMS.',
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
`,
|
|
23
270
|
'workspaces/ssg/bin/build.sh': `#!/usr/bin/env sh
|
|
24
271
|
|
|
25
272
|
set -e
|
package/preset/ssr.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Preset } from './types.js';
|
|
1
|
+
import type { Preset } from './types.js';
|
|
2
2
|
export declare const ssr: Preset;
|
package/preset/ssr.js
CHANGED
|
@@ -1,25 +1,273 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
1
4
|
import packageJson from '../package.json' with { type: 'json' };
|
|
2
|
-
|
|
3
|
-
|
|
5
|
+
const presetDir = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
const agentsPath = [
|
|
7
|
+
resolve(presetDir, '../../../AGENTS.md'),
|
|
8
|
+
resolve(presetDir, '../../../../AGENTS.md'),
|
|
9
|
+
].find(existsSync) ?? '';
|
|
10
|
+
const agentsContent = agentsPath ? readFileSync(agentsPath, 'utf8') : '';
|
|
4
11
|
export const ssr = (options) => ({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
'package.json': JSON.stringify({
|
|
13
|
+
name: options.name,
|
|
14
|
+
version: '0.0.0',
|
|
15
|
+
description: options.description,
|
|
16
|
+
private: true,
|
|
17
|
+
type: 'module',
|
|
18
|
+
agents: './AGENTS.md',
|
|
19
|
+
packageManager: packageJson.packageManager,
|
|
20
|
+
engines: {
|
|
21
|
+
node: packageJson.engines.node,
|
|
22
|
+
},
|
|
23
|
+
workspaces: [
|
|
24
|
+
'packages/*',
|
|
25
|
+
'workspaces/*',
|
|
26
|
+
],
|
|
27
|
+
scripts: {
|
|
28
|
+
storybook: 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook dev -p 6006 --disable-telemetry',
|
|
29
|
+
check: 'run-s lint build test',
|
|
30
|
+
fix: "run-s 'fix:*'",
|
|
31
|
+
start: "run-p 'start:*'",
|
|
32
|
+
lint: "run-s 'lint:*'",
|
|
33
|
+
build: "run-s 'build:*'",
|
|
34
|
+
test: "run-s 'test:*'",
|
|
35
|
+
'fix:prettier': 'prettier . --write',
|
|
36
|
+
'fix:eslint': 'eslint . --fix',
|
|
37
|
+
'fix:stylelint': 'stylelint "**/*.{css,scss}" --fix',
|
|
38
|
+
'lint:ts': 'tsc',
|
|
39
|
+
'lint:prettier': 'prettier . --check',
|
|
40
|
+
'lint:eslint': 'eslint .',
|
|
41
|
+
'lint:stylelint': 'stylelint "**/*.{css,scss}"',
|
|
42
|
+
'build:storybook': 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook build --quiet --disable-telemetry',
|
|
43
|
+
'test:jest': 'jest',
|
|
44
|
+
postinstall: 'husky',
|
|
45
|
+
'start:api': 'sh workspaces/api/bin/start.sh',
|
|
46
|
+
'build:api': 'rimraf dist && sh workspaces/api/bin/build.sh',
|
|
47
|
+
},
|
|
48
|
+
dependencies: {
|
|
49
|
+
'@vyriy/typescript-config': `^${packageJson.version}`,
|
|
50
|
+
typescript: packageJson.peerDependencies.typescript,
|
|
51
|
+
'@vyriy/prettier-config': `^${packageJson.version}`,
|
|
52
|
+
prettier: packageJson.peerDependencies.prettier,
|
|
53
|
+
'@vyriy/eslint-config': `^${packageJson.version}`,
|
|
54
|
+
eslint: packageJson.peerDependencies.eslint,
|
|
55
|
+
'@vyriy/jest-config': `^${packageJson.version}`,
|
|
56
|
+
jest: packageJson.peerDependencies.jest,
|
|
57
|
+
'@vyriy/storybook-config': `^${packageJson.version}`,
|
|
58
|
+
storybook: packageJson.peerDependencies.storybook,
|
|
59
|
+
'@vyriy/path': `^${packageJson.version}`,
|
|
60
|
+
husky: packageJson.peerDependencies.husky,
|
|
61
|
+
'npm-run-all2': packageJson.peerDependencies['npm-run-all2'],
|
|
62
|
+
'cross-env': packageJson.peerDependencies['cross-env'],
|
|
63
|
+
rimraf: packageJson.peerDependencies.rimraf,
|
|
64
|
+
'@vyriy/webpack-config': `^${packageJson.version}`,
|
|
65
|
+
tsx: packageJson.peerDependencies.tsx,
|
|
66
|
+
'webpack-cli': packageJson.peerDependencies['webpack-cli'],
|
|
67
|
+
'@vyriy/handler': `^${packageJson.version}`,
|
|
68
|
+
'@vyriy/server': `^${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
|
+
'@vyriy/stylelint-config': `^${packageJson.version}`,
|
|
74
|
+
stylelint: packageJson.peerDependencies.stylelint,
|
|
75
|
+
'@vyriy/cn': `^${packageJson.version}`,
|
|
76
|
+
'@vyriy/html': `^${packageJson.version}`,
|
|
77
|
+
sass: packageJson.peerDependencies.sass,
|
|
78
|
+
},
|
|
79
|
+
}, null, 2) + '\n',
|
|
80
|
+
'README.md': `# ${options.name}\n\n${options.description}\n`,
|
|
81
|
+
'doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
|
|
82
|
+
import ReadMe from './README.md?raw';
|
|
83
|
+
|
|
84
|
+
<Meta title="${options.name}" />
|
|
85
|
+
|
|
86
|
+
<Markdown>{ReadMe}</Markdown>
|
|
87
|
+
`,
|
|
88
|
+
'AGENTS.md': agentsContent,
|
|
89
|
+
'.editorconfig': `# https://editorconfig.org
|
|
90
|
+
root = true
|
|
91
|
+
|
|
92
|
+
[*]
|
|
93
|
+
charset = utf-8
|
|
94
|
+
end_of_line = lf
|
|
95
|
+
insert_final_newline = true
|
|
96
|
+
trim_trailing_whitespace = true
|
|
97
|
+
|
|
98
|
+
indent_style = space
|
|
99
|
+
indent_size = 2
|
|
100
|
+
|
|
101
|
+
max_line_length = 100
|
|
102
|
+
|
|
103
|
+
# Markdown
|
|
104
|
+
[*.md]
|
|
105
|
+
trim_trailing_whitespace = false
|
|
106
|
+
max_line_length = off
|
|
107
|
+
|
|
108
|
+
# YAML / YML
|
|
109
|
+
[*.{yml,yaml}]
|
|
110
|
+
indent_size = 2
|
|
111
|
+
|
|
112
|
+
# JSON
|
|
113
|
+
[*.json]
|
|
114
|
+
indent_size = 2
|
|
115
|
+
|
|
116
|
+
# TypeScript / JavaScript
|
|
117
|
+
[*.{ts,tsx,js,jsx}]
|
|
118
|
+
indent_size = 2
|
|
119
|
+
|
|
120
|
+
# Shell / Bash
|
|
121
|
+
[*.sh]
|
|
122
|
+
indent_size = 2
|
|
123
|
+
`,
|
|
124
|
+
'.gitignore': `.yarn/*
|
|
125
|
+
!.yarn/cache
|
|
126
|
+
!.yarn/patches
|
|
127
|
+
!.yarn/plugins
|
|
128
|
+
!.yarn/releases
|
|
129
|
+
!.yarn/sdks
|
|
130
|
+
!.yarn/versions
|
|
131
|
+
|
|
132
|
+
.DS_Store
|
|
133
|
+
.idea
|
|
134
|
+
node_modules
|
|
135
|
+
coverage
|
|
136
|
+
dist
|
|
137
|
+
storybook-static
|
|
138
|
+
*storybook.log
|
|
139
|
+
consumer
|
|
140
|
+
|
|
141
|
+
cdk.out
|
|
142
|
+
cdk.context.json
|
|
143
|
+
|
|
144
|
+
!/**/.gitkeep
|
|
145
|
+
`,
|
|
146
|
+
'.npmrc': 'engine-strict=true\n',
|
|
147
|
+
'.nvmrc': 'lts/krypton\n',
|
|
148
|
+
'.yarnrc.yml': 'nodeLinker: node-modules\nnpmMinimalAgeGate: 0\n',
|
|
149
|
+
'.husky/commit-msg': '#!/bin/sh\n',
|
|
150
|
+
'.husky/post-checkout': '#!/bin/sh\n\nyarn\n',
|
|
151
|
+
'.husky/post-merge': '#!/bin/sh\n\nyarn\n',
|
|
152
|
+
'.husky/pre-commit': '#!/bin/sh\n\nyarn check\n',
|
|
153
|
+
'.husky/pre-push': '#!/bin/sh\n\nyarn check\n',
|
|
154
|
+
'.storybook/main.ts': `import config from '@vyriy/storybook-config';
|
|
155
|
+
import { path } from '@vyriy/path';
|
|
156
|
+
|
|
157
|
+
export default {
|
|
158
|
+
...config,
|
|
159
|
+
stories: [
|
|
160
|
+
path('**/*.mdx'),
|
|
161
|
+
path('**/*.stories.@(js|jsx|mjs|ts|tsx)'),
|
|
162
|
+
],
|
|
163
|
+
};
|
|
164
|
+
`,
|
|
165
|
+
'.storybook/preview.tsx': "export { default } from '@vyriy/storybook-config/preview';\n",
|
|
166
|
+
'yarn.lock': '',
|
|
167
|
+
'tsconfig.json': JSON.stringify({
|
|
168
|
+
extends: '@vyriy/typescript-config/index.json',
|
|
169
|
+
include: [
|
|
170
|
+
'.storybook/**/*.ts',
|
|
171
|
+
'.storybook/**/*.tsx',
|
|
172
|
+
'packages/**/*.ts',
|
|
173
|
+
'packages/**/*.tsx',
|
|
174
|
+
'workspaces/**/*.ts',
|
|
175
|
+
'workspaces/**/*.tsx',
|
|
176
|
+
'*.ts',
|
|
177
|
+
],
|
|
178
|
+
}, null, 2) + '\n',
|
|
179
|
+
'prettier.config.ts': "export { default } from '@vyriy/prettier-config';\n",
|
|
180
|
+
'.prettierignore': 'node_modules\ndist\ncoverage\nstorybook-static\nconsumer\n',
|
|
181
|
+
'eslint.config.ts': "export { default } from '@vyriy/eslint-config';\n",
|
|
182
|
+
'jest.config.ts': "export { default } from '@vyriy/jest-config';\n",
|
|
183
|
+
'stylelint.config.ts': "export { default } from '@vyriy/stylelint-config';\n",
|
|
184
|
+
'assets.d.ts': "declare module '*.scss';\n",
|
|
185
|
+
'packages/components/package.json': JSON.stringify({
|
|
186
|
+
name: '@p/components',
|
|
187
|
+
private: true,
|
|
188
|
+
type: 'module',
|
|
189
|
+
}, null, 2) + '\n',
|
|
190
|
+
'packages/components/index.ts': "export * from './page/index.js';\n",
|
|
191
|
+
'packages/components/index.test.tsx': `import { describe, expect, it } from '@jest/globals';
|
|
192
|
+
|
|
193
|
+
import { Page } from './index.js';
|
|
194
|
+
import { Page as PageImplementation } from './page/index.js';
|
|
195
|
+
|
|
196
|
+
describe('packages/components/page', () => {
|
|
197
|
+
it('re-exports the page component', () => {
|
|
198
|
+
expect(Page).toBe(PageImplementation);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
`,
|
|
202
|
+
'packages/components/page/index.ts': `export * from './page.js';
|
|
203
|
+
export type * from './types.js';
|
|
204
|
+
`,
|
|
205
|
+
'packages/components/page/index.test.ts': `import { describe, expect, it } from '@jest/globals';
|
|
206
|
+
|
|
207
|
+
import { Page } from './index.js';
|
|
208
|
+
import { Page as PageImplementation } from './page.js';
|
|
209
|
+
|
|
210
|
+
describe('packages/components/page', () => {
|
|
211
|
+
it('re-exports the page component', () => {
|
|
212
|
+
expect(Page).toBe(PageImplementation);
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
`,
|
|
216
|
+
'packages/components/page/types.ts': `import { FC } from 'react';
|
|
217
|
+
|
|
218
|
+
export type PageProps = {
|
|
219
|
+
content: string;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export type PageType = FC<PageProps>;
|
|
223
|
+
`,
|
|
224
|
+
'packages/components/page/page.tsx': `import type { PageType } from './types.js';
|
|
225
|
+
|
|
226
|
+
export const Page: PageType = ({ content }) => <div className="content">{content}</div>;
|
|
227
|
+
`,
|
|
228
|
+
'packages/components/page/styles.scss': `.content {
|
|
229
|
+
display: block;
|
|
230
|
+
}
|
|
231
|
+
`,
|
|
232
|
+
'packages/components/page/page.test.tsx': `import { renderToStaticMarkup } from 'react-dom/server';
|
|
233
|
+
import { describe, expect, it } from '@jest/globals';
|
|
234
|
+
|
|
235
|
+
import { Page } from './page.js';
|
|
236
|
+
|
|
237
|
+
describe('packages/components/page/page', () => {
|
|
238
|
+
it('renders content inside the page content container', () => {
|
|
239
|
+
expect(renderToStaticMarkup(<Page content="Page body" />)).toBe('<div class="content">Page body</div>');
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
`,
|
|
243
|
+
'packages/services/package.json': JSON.stringify({
|
|
244
|
+
name: '@p/services',
|
|
245
|
+
private: true,
|
|
246
|
+
type: 'module',
|
|
247
|
+
}, null, 2) + '\n',
|
|
248
|
+
'packages/services/cms/index.ts': `export const cms = {
|
|
249
|
+
getContent: async () => {
|
|
250
|
+
// Placeholder for fetching content from a CMS
|
|
251
|
+
return Promise.resolve({
|
|
252
|
+
title: 'Sample Content',
|
|
253
|
+
body: 'This is a sample content fetched from the CMS.',
|
|
254
|
+
});
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
`,
|
|
258
|
+
'packages/services/cms/index.test.ts': `import { describe, expect, it } from '@jest/globals';
|
|
259
|
+
|
|
260
|
+
import { cms } from './index.js';
|
|
261
|
+
|
|
262
|
+
describe('packages/services/cms', () => {
|
|
263
|
+
it('returns content for rendering a page', async () => {
|
|
264
|
+
await expect(cms.getContent()).resolves.toEqual({
|
|
265
|
+
title: 'Sample Content',
|
|
266
|
+
body: 'This is a sample content fetched from the CMS.',
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
`,
|
|
23
271
|
'workspaces/api/bin/build.sh': `#!/usr/bin/env sh
|
|
24
272
|
|
|
25
273
|
set -e
|
package/prompt/preset.js
CHANGED
|
@@ -5,7 +5,11 @@ export const preset = async (question, output) => {
|
|
|
5
5
|
const defaultPreset = 'base';
|
|
6
6
|
const presetNames = Object.keys(appPreset);
|
|
7
7
|
output.write('\nProject preset:\n\n');
|
|
8
|
-
presetNames.
|
|
8
|
+
const maxWidth = Math.max(...presetNames.map((n, i) => `${i + 1}. ${appPreset[n].name}`.length));
|
|
9
|
+
presetNames.forEach((presetName, index) => {
|
|
10
|
+
const label = `${index + 1}. ${appPreset[presetName].name}`;
|
|
11
|
+
output.write(` ${label.padEnd(maxWidth)} - ${appPreset[presetName].description}\n`);
|
|
12
|
+
});
|
|
9
13
|
const presetValue = await prompt(question, '\nPreset number or name', defaultPreset);
|
|
10
14
|
return resolveOption(presetValue, presetNames, defaultPreset);
|
|
11
15
|
};
|