vyriy 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/README.md +23 -12
- package/args.js +40 -0
- package/bin/vyriy.js +1 -1
- package/cli.js +67 -0
- package/package.json +51 -6
- package/{cli/types.d.ts → types.d.ts} +7 -1
- package/cli/args.js +0 -29
- package/cli/cli.js +0 -28
- package/commands/check-env.d.ts +0 -2
- package/commands/check-env.js +0 -120
- package/commands/create/index.d.ts +0 -2
- package/commands/create/index.js +0 -130
- package/commands/create/plan/index.d.ts +0 -4
- package/commands/create/plan/index.js +0 -3
- package/commands/create/plan/plan.d.ts +0 -7
- package/commands/create/plan/plan.js +0 -35
- package/commands/create/plan/question.d.ts +0 -2
- package/commands/create/plan/question.js +0 -25
- package/commands/create/plan/types.d.ts +0 -12
- package/commands/create/preset/api.d.ts +0 -2
- package/commands/create/preset/api.js +0 -63
- package/commands/create/preset/base.d.ts +0 -2
- package/commands/create/preset/base.js +0 -159
- package/commands/create/preset/fullstack.d.ts +0 -2
- package/commands/create/preset/fullstack.js +0 -158
- package/commands/create/preset/gql.d.ts +0 -2
- package/commands/create/preset/gql.js +0 -744
- package/commands/create/preset/index.d.ts +0 -52
- package/commands/create/preset/index.js +0 -62
- package/commands/create/preset/library.d.ts +0 -2
- package/commands/create/preset/library.js +0 -247
- package/commands/create/preset/mfe.d.ts +0 -2
- package/commands/create/preset/mfe.js +0 -326
- package/commands/create/preset/rest.d.ts +0 -2
- package/commands/create/preset/rest.js +0 -242
- package/commands/create/preset/shared.d.ts +0 -116
- package/commands/create/preset/shared.js +0 -245
- package/commands/create/preset/spa.d.ts +0 -2
- package/commands/create/preset/spa.js +0 -132
- package/commands/create/preset/ssg.d.ts +0 -2
- package/commands/create/preset/ssg.js +0 -171
- package/commands/create/preset/ssr.d.ts +0 -2
- package/commands/create/preset/ssr.js +0 -179
- package/commands/create/preset/types.d.ts +0 -9
- package/commands/create/prompt/conflict-strategy.d.ts +0 -5
- package/commands/create/prompt/conflict-strategy.js +0 -22
- package/commands/create/prompt/index.d.ts +0 -6
- package/commands/create/prompt/index.js +0 -5
- package/commands/create/prompt/preset.d.ts +0 -4
- package/commands/create/prompt/preset.js +0 -11
- package/commands/create/prompt/prompt.d.ts +0 -2
- package/commands/create/prompt/prompt.js +0 -4
- package/commands/create/prompt/resolve-option.d.ts +0 -6
- package/commands/create/prompt/resolve-option.js +0 -8
- package/commands/create/prompt/scope.d.ts +0 -2
- package/commands/create/prompt/scope.js +0 -2
- package/commands/create/prompt/types.d.ts +0 -4
- package/commands/dist.d.ts +0 -2
- package/commands/dist.js +0 -287
- package/commands/help.d.ts +0 -3
- package/commands/help.js +0 -24
- package/commands/index.d.ts +0 -5
- package/commands/index.js +0 -5
- package/commands/types.d.ts +0 -44
- package/commands/version.d.ts +0 -2
- package/commands/version.js +0 -6
- /package/{cli/args.d.ts → args.d.ts} +0 -0
- /package/{cli/cli.d.ts → cli.d.ts} +0 -0
- /package/{cli/index.d.ts → index.d.ts} +0 -0
- /package/{cli/index.js → index.js} +0 -0
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
import packageJson from '../../../package.json' with { type: 'json' };
|
|
2
|
-
import { base } from './base.js';
|
|
3
|
-
import { apiWorkspaceBaseFiles, baseToolingDeps, buildPackageJson, serverDeps, webpackDeps, workspaceScripts, } from './shared.js';
|
|
4
|
-
export const rest = (options) => ({
|
|
5
|
-
...base(options),
|
|
6
|
-
...apiWorkspaceBaseFiles(options.name, options.description),
|
|
7
|
-
'package.json': buildPackageJson(options, [
|
|
8
|
-
'workspaces/*',
|
|
9
|
-
], workspaceScripts('api'), {
|
|
10
|
-
...baseToolingDeps(),
|
|
11
|
-
...webpackDeps(),
|
|
12
|
-
...serverDeps(),
|
|
13
|
-
'@vyriy/router': `^${packageJson.version}`,
|
|
14
|
-
'@vyriy/html': `^${packageJson.version}`,
|
|
15
|
-
}),
|
|
16
|
-
'workspaces/api/index.ts': `import { server } from '@vyriy/server';
|
|
17
|
-
import { api } from '@vyriy/handler';
|
|
18
|
-
import { createRouter } from '@vyriy/router';
|
|
19
|
-
import { html, minify } from '@vyriy/html';
|
|
20
|
-
|
|
21
|
-
const router = createRouter();
|
|
22
|
-
|
|
23
|
-
router.get('/api/test', async () => {
|
|
24
|
-
return Promise.resolve({
|
|
25
|
-
headers: {
|
|
26
|
-
'content-type': 'application/json',
|
|
27
|
-
},
|
|
28
|
-
body: JSON.stringify({ test: 'ok' }),
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
router.get('/openapi.json', async () => {
|
|
33
|
-
return Promise.resolve({
|
|
34
|
-
headers: {
|
|
35
|
-
'content-type': 'application/json',
|
|
36
|
-
},
|
|
37
|
-
body: JSON.stringify({
|
|
38
|
-
openapi: '3.0.0',
|
|
39
|
-
info: {
|
|
40
|
-
title: 'REST API',
|
|
41
|
-
description: 'A minimal example of an OpenAPI definition in JSON format.',
|
|
42
|
-
version: '1.0.0',
|
|
43
|
-
},
|
|
44
|
-
servers: [
|
|
45
|
-
{
|
|
46
|
-
url: 'http://localhost:3000',
|
|
47
|
-
description: 'Local server',
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
paths: {
|
|
51
|
-
'/api/test': {
|
|
52
|
-
get: {
|
|
53
|
-
summary: 'Test endpoint',
|
|
54
|
-
operationId: 'getTest',
|
|
55
|
-
responses: {
|
|
56
|
-
'200': {
|
|
57
|
-
description: 'A successful test response',
|
|
58
|
-
content: {
|
|
59
|
-
'application/json': {
|
|
60
|
-
schema: {
|
|
61
|
-
$ref: '#/components/schemas/TestResponse',
|
|
62
|
-
},
|
|
63
|
-
example: {
|
|
64
|
-
test: 'ok',
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
components: {
|
|
74
|
-
schemas: {
|
|
75
|
-
TestResponse: {
|
|
76
|
-
type: 'object',
|
|
77
|
-
required: ['test'],
|
|
78
|
-
properties: {
|
|
79
|
-
test: {
|
|
80
|
-
type: 'string',
|
|
81
|
-
example: 'ok',
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
}),
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
router.get('/', async () => {
|
|
92
|
-
return Promise.resolve({
|
|
93
|
-
headers: {
|
|
94
|
-
'content-type': 'text/html; charset=utf-8',
|
|
95
|
-
},
|
|
96
|
-
body: minify(
|
|
97
|
-
html({
|
|
98
|
-
title: '<title>REST API</title>',
|
|
99
|
-
meta: '<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />',
|
|
100
|
-
body: [
|
|
101
|
-
'<div id="app"></div>',
|
|
102
|
-
'<script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>',
|
|
103
|
-
"<script>Scalar.createApiReference('#app', { url: '/openapi.json' })</script>",
|
|
104
|
-
].join(''),
|
|
105
|
-
}),
|
|
106
|
-
),
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
server(api(async (event) => router.route(event)));
|
|
111
|
-
`,
|
|
112
|
-
'workspaces/api/index.test.ts': `import { describe, expect, it, jest } from '@jest/globals';
|
|
113
|
-
import type { APIGatewayProxyEvent } from '@vyriy/router';
|
|
114
|
-
|
|
115
|
-
const apiMock = jest.fn((handler) => ({
|
|
116
|
-
handler,
|
|
117
|
-
}));
|
|
118
|
-
const serverMock = jest.fn();
|
|
119
|
-
|
|
120
|
-
jest.mock('@vyriy/handler', () => ({
|
|
121
|
-
api: apiMock,
|
|
122
|
-
}));
|
|
123
|
-
|
|
124
|
-
jest.mock('@vyriy/server', () => ({
|
|
125
|
-
server: serverMock,
|
|
126
|
-
}));
|
|
127
|
-
|
|
128
|
-
describe('workspaces/api/index.ts', () => {
|
|
129
|
-
const getEvent = (path: string): APIGatewayProxyEvent =>
|
|
130
|
-
({
|
|
131
|
-
body: null,
|
|
132
|
-
headers: {},
|
|
133
|
-
httpMethod: 'GET',
|
|
134
|
-
path,
|
|
135
|
-
pathParameters: null,
|
|
136
|
-
queryStringParameters: null,
|
|
137
|
-
}) as APIGatewayProxyEvent;
|
|
138
|
-
|
|
139
|
-
it('starts the server with the API router handler', async () => {
|
|
140
|
-
await import('./index.js');
|
|
141
|
-
|
|
142
|
-
expect(apiMock).toHaveBeenCalledTimes(1);
|
|
143
|
-
expect(serverMock).toHaveBeenCalledTimes(1);
|
|
144
|
-
expect(serverMock).toHaveBeenCalledWith(apiMock.mock.results[0]?.value);
|
|
145
|
-
|
|
146
|
-
const handler = apiMock.mock.calls[0]?.[0] as (event: APIGatewayProxyEvent) => Promise<{
|
|
147
|
-
body: string;
|
|
148
|
-
headers?: Record<string, string>;
|
|
149
|
-
statusCode: number;
|
|
150
|
-
}>;
|
|
151
|
-
|
|
152
|
-
await expect(handler(getEvent('/api/test'))).resolves.toEqual({
|
|
153
|
-
body: JSON.stringify({
|
|
154
|
-
test: 'ok',
|
|
155
|
-
}),
|
|
156
|
-
headers: {
|
|
157
|
-
'content-type': 'application/json',
|
|
158
|
-
},
|
|
159
|
-
statusCode: 200,
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
const openApiResponse = await handler(getEvent('/openapi.json'));
|
|
163
|
-
|
|
164
|
-
expect(openApiResponse).toEqual({
|
|
165
|
-
body: expect.any(String),
|
|
166
|
-
headers: {
|
|
167
|
-
'content-type': 'application/json',
|
|
168
|
-
},
|
|
169
|
-
statusCode: 200,
|
|
170
|
-
});
|
|
171
|
-
expect(JSON.parse(openApiResponse.body)).toEqual({
|
|
172
|
-
components: {
|
|
173
|
-
schemas: {
|
|
174
|
-
TestResponse: {
|
|
175
|
-
properties: {
|
|
176
|
-
test: {
|
|
177
|
-
example: 'ok',
|
|
178
|
-
type: 'string',
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
required: ['test'],
|
|
182
|
-
type: 'object',
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
info: {
|
|
187
|
-
description: 'A minimal example of an OpenAPI definition in JSON format.',
|
|
188
|
-
title: 'REST API',
|
|
189
|
-
version: '1.0.0',
|
|
190
|
-
},
|
|
191
|
-
openapi: '3.0.0',
|
|
192
|
-
paths: {
|
|
193
|
-
'/api/test': {
|
|
194
|
-
get: {
|
|
195
|
-
operationId: 'getTest',
|
|
196
|
-
responses: {
|
|
197
|
-
'200': {
|
|
198
|
-
content: {
|
|
199
|
-
'application/json': {
|
|
200
|
-
example: {
|
|
201
|
-
test: 'ok',
|
|
202
|
-
},
|
|
203
|
-
schema: {
|
|
204
|
-
$ref: '#/components/schemas/TestResponse',
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
},
|
|
208
|
-
description: 'A successful test response',
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
summary: 'Test endpoint',
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
},
|
|
215
|
-
servers: [
|
|
216
|
-
{
|
|
217
|
-
description: 'Local server',
|
|
218
|
-
url: 'http://localhost:3000',
|
|
219
|
-
},
|
|
220
|
-
],
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
const docsResponse = await handler(getEvent('/'));
|
|
224
|
-
|
|
225
|
-
expect(docsResponse).toEqual({
|
|
226
|
-
body: expect.stringContaining("Scalar.createApiReference('#app', { url: '/openapi.json' })"),
|
|
227
|
-
headers: {
|
|
228
|
-
'content-type': 'text/html; charset=utf-8',
|
|
229
|
-
},
|
|
230
|
-
statusCode: 200,
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
await expect(handler(getEvent('/healthcheck'))).resolves.toEqual({
|
|
234
|
-
body: JSON.stringify({
|
|
235
|
-
message: 'Not Found',
|
|
236
|
-
}),
|
|
237
|
-
statusCode: 404,
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
`,
|
|
242
|
-
});
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import type { PlanResult } from '../plan/types.js';
|
|
2
|
-
import type { FileMap } from './types.js';
|
|
3
|
-
export declare const baseToolingDeps: () => {
|
|
4
|
-
'@vyriy/typescript-config': string;
|
|
5
|
-
typescript: string;
|
|
6
|
-
'@vyriy/prettier-config': string;
|
|
7
|
-
prettier: string;
|
|
8
|
-
'@vyriy/eslint-config': string;
|
|
9
|
-
eslint: string;
|
|
10
|
-
'@vyriy/jest-config': string;
|
|
11
|
-
jest: string;
|
|
12
|
-
'@vyriy/storybook-config': string;
|
|
13
|
-
storybook: string;
|
|
14
|
-
'@vyriy/path': string;
|
|
15
|
-
husky: string;
|
|
16
|
-
'npm-run-all2': string;
|
|
17
|
-
'cross-env': string;
|
|
18
|
-
};
|
|
19
|
-
export declare const webpackDeps: () => {
|
|
20
|
-
rimraf: string;
|
|
21
|
-
'@vyriy/webpack-config': string;
|
|
22
|
-
tsx: string;
|
|
23
|
-
'webpack-cli': string;
|
|
24
|
-
};
|
|
25
|
-
export declare const reactDeps: () => {
|
|
26
|
-
react: string;
|
|
27
|
-
'react-dom': string;
|
|
28
|
-
'@types/react': string;
|
|
29
|
-
'@types/react-dom': string;
|
|
30
|
-
};
|
|
31
|
-
export declare const stylelintDeps: () => {
|
|
32
|
-
'@vyriy/stylelint-config': string;
|
|
33
|
-
stylelint: string;
|
|
34
|
-
};
|
|
35
|
-
export declare const serverDeps: () => {
|
|
36
|
-
'@vyriy/handler': string;
|
|
37
|
-
'@vyriy/server': string;
|
|
38
|
-
};
|
|
39
|
-
export declare const buildPackageJson: (options: Pick<PlanResult, "name" | "description">, workspaces: string[], scripts: Record<string, string>, dependencies: Record<string, string>) => string;
|
|
40
|
-
export declare const reactWorkspaceBaseScripts: () => {
|
|
41
|
-
storybook: string;
|
|
42
|
-
check: string;
|
|
43
|
-
fix: string;
|
|
44
|
-
start: string;
|
|
45
|
-
lint: string;
|
|
46
|
-
build: string;
|
|
47
|
-
test: string;
|
|
48
|
-
'fix:prettier': string;
|
|
49
|
-
'fix:eslint': string;
|
|
50
|
-
'fix:stylelint': string;
|
|
51
|
-
'lint:ts': string;
|
|
52
|
-
'lint:prettier': string;
|
|
53
|
-
'lint:eslint': string;
|
|
54
|
-
'lint:stylelint': string;
|
|
55
|
-
'build:storybook': string;
|
|
56
|
-
'test:jest': string;
|
|
57
|
-
postinstall: string;
|
|
58
|
-
};
|
|
59
|
-
export declare const workspaceBaseScripts: () => {
|
|
60
|
-
storybook: string;
|
|
61
|
-
check: string;
|
|
62
|
-
fix: string;
|
|
63
|
-
start: string;
|
|
64
|
-
lint: string;
|
|
65
|
-
build: string;
|
|
66
|
-
test: string;
|
|
67
|
-
'fix:prettier': string;
|
|
68
|
-
'fix:eslint': string;
|
|
69
|
-
'lint:ts': string;
|
|
70
|
-
'lint:prettier': string;
|
|
71
|
-
'lint:eslint': string;
|
|
72
|
-
'build:storybook': string;
|
|
73
|
-
'test:jest': string;
|
|
74
|
-
postinstall: string;
|
|
75
|
-
};
|
|
76
|
-
export declare const reactWorkspaceScripts: (workspaceName: string) => {
|
|
77
|
-
storybook: string;
|
|
78
|
-
check: string;
|
|
79
|
-
fix: string;
|
|
80
|
-
start: string;
|
|
81
|
-
lint: string;
|
|
82
|
-
build: string;
|
|
83
|
-
test: string;
|
|
84
|
-
'fix:prettier': string;
|
|
85
|
-
'fix:eslint': string;
|
|
86
|
-
'fix:stylelint': string;
|
|
87
|
-
'lint:ts': string;
|
|
88
|
-
'lint:prettier': string;
|
|
89
|
-
'lint:eslint': string;
|
|
90
|
-
'lint:stylelint': string;
|
|
91
|
-
'build:storybook': string;
|
|
92
|
-
'test:jest': string;
|
|
93
|
-
postinstall: string;
|
|
94
|
-
};
|
|
95
|
-
export declare const workspaceScripts: (workspaceName: string) => {
|
|
96
|
-
storybook: string;
|
|
97
|
-
check: string;
|
|
98
|
-
fix: string;
|
|
99
|
-
start: string;
|
|
100
|
-
lint: string;
|
|
101
|
-
build: string;
|
|
102
|
-
test: string;
|
|
103
|
-
'fix:prettier': string;
|
|
104
|
-
'fix:eslint': string;
|
|
105
|
-
'lint:ts': string;
|
|
106
|
-
'lint:prettier': string;
|
|
107
|
-
'lint:eslint': string;
|
|
108
|
-
'build:storybook': string;
|
|
109
|
-
'test:jest': string;
|
|
110
|
-
postinstall: string;
|
|
111
|
-
};
|
|
112
|
-
export declare const stylelintConfigFile: () => FileMap;
|
|
113
|
-
export declare const assetsDeclarationFile: () => FileMap;
|
|
114
|
-
export declare const reactComponentFiles: () => FileMap;
|
|
115
|
-
export declare const reactServiceFiles: () => FileMap;
|
|
116
|
-
export declare const apiWorkspaceBaseFiles: (name: string, description: string) => FileMap;
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import packageJson from '../../../package.json' with { type: 'json' };
|
|
2
|
-
export const baseToolingDeps = () => ({
|
|
3
|
-
'@vyriy/typescript-config': `^${packageJson.version}`,
|
|
4
|
-
typescript: packageJson.peerDependencies.typescript,
|
|
5
|
-
'@vyriy/prettier-config': `^${packageJson.version}`,
|
|
6
|
-
prettier: packageJson.peerDependencies.prettier,
|
|
7
|
-
'@vyriy/eslint-config': `^${packageJson.version}`,
|
|
8
|
-
eslint: packageJson.peerDependencies.eslint,
|
|
9
|
-
'@vyriy/jest-config': `^${packageJson.version}`,
|
|
10
|
-
jest: packageJson.peerDependencies.jest,
|
|
11
|
-
'@vyriy/storybook-config': `^${packageJson.version}`,
|
|
12
|
-
storybook: packageJson.peerDependencies.storybook,
|
|
13
|
-
'@vyriy/path': `^${packageJson.version}`,
|
|
14
|
-
husky: packageJson.peerDependencies.husky,
|
|
15
|
-
'npm-run-all2': packageJson.peerDependencies['npm-run-all2'],
|
|
16
|
-
'cross-env': packageJson.peerDependencies['cross-env'],
|
|
17
|
-
});
|
|
18
|
-
export const webpackDeps = () => ({
|
|
19
|
-
rimraf: packageJson.peerDependencies.rimraf,
|
|
20
|
-
'@vyriy/webpack-config': `^${packageJson.version}`,
|
|
21
|
-
tsx: packageJson.peerDependencies.tsx,
|
|
22
|
-
'webpack-cli': packageJson.peerDependencies['webpack-cli'],
|
|
23
|
-
});
|
|
24
|
-
export const reactDeps = () => ({
|
|
25
|
-
react: packageJson.peerDependencies.react,
|
|
26
|
-
'react-dom': packageJson.peerDependencies['react-dom'],
|
|
27
|
-
'@types/react': packageJson.peerDependencies['@types/react'],
|
|
28
|
-
'@types/react-dom': packageJson.peerDependencies['@types/react-dom'],
|
|
29
|
-
});
|
|
30
|
-
export const stylelintDeps = () => ({
|
|
31
|
-
'@vyriy/stylelint-config': `^${packageJson.version}`,
|
|
32
|
-
stylelint: packageJson.peerDependencies.stylelint,
|
|
33
|
-
});
|
|
34
|
-
export const serverDeps = () => ({
|
|
35
|
-
'@vyriy/handler': `^${packageJson.version}`,
|
|
36
|
-
'@vyriy/server': `^${packageJson.version}`,
|
|
37
|
-
});
|
|
38
|
-
export const buildPackageJson = (options, workspaces, scripts, dependencies) => JSON.stringify({
|
|
39
|
-
name: options.name,
|
|
40
|
-
version: '0.0.0',
|
|
41
|
-
description: options.description,
|
|
42
|
-
private: true,
|
|
43
|
-
type: 'module',
|
|
44
|
-
agents: './AGENTS.md',
|
|
45
|
-
packageManager: packageJson.packageManager,
|
|
46
|
-
engines: {
|
|
47
|
-
node: packageJson.engines.node,
|
|
48
|
-
},
|
|
49
|
-
workspaces,
|
|
50
|
-
scripts,
|
|
51
|
-
dependencies,
|
|
52
|
-
}, null, 2) + '\n';
|
|
53
|
-
export const reactWorkspaceBaseScripts = () => ({
|
|
54
|
-
storybook: 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook dev -p 6006 --disable-telemetry',
|
|
55
|
-
check: 'run-s lint build test',
|
|
56
|
-
fix: "run-s 'fix:*'",
|
|
57
|
-
start: "run-p 'start:*'",
|
|
58
|
-
lint: "run-s 'lint:*'",
|
|
59
|
-
build: "run-s 'build:*'",
|
|
60
|
-
test: "run-s 'test:*'",
|
|
61
|
-
'fix:prettier': 'prettier . --write',
|
|
62
|
-
'fix:eslint': 'eslint . --fix',
|
|
63
|
-
'fix:stylelint': 'stylelint "**/*.{css,scss}" --fix',
|
|
64
|
-
'lint:ts': 'tsc',
|
|
65
|
-
'lint:prettier': 'prettier . --check',
|
|
66
|
-
'lint:eslint': 'eslint .',
|
|
67
|
-
'lint:stylelint': 'stylelint "**/*.{css,scss}"',
|
|
68
|
-
'build:storybook': 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook build --quiet --disable-telemetry',
|
|
69
|
-
'test:jest': 'jest',
|
|
70
|
-
postinstall: 'husky',
|
|
71
|
-
});
|
|
72
|
-
export const workspaceBaseScripts = () => ({
|
|
73
|
-
storybook: 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook dev -p 6006 --disable-telemetry',
|
|
74
|
-
check: 'run-s lint build test',
|
|
75
|
-
fix: "run-s 'fix:*'",
|
|
76
|
-
start: "run-p 'start:*'",
|
|
77
|
-
lint: "run-s 'lint:*'",
|
|
78
|
-
build: "run-s 'build:*'",
|
|
79
|
-
test: "run-s 'test:*'",
|
|
80
|
-
'fix:prettier': 'prettier . --write',
|
|
81
|
-
'fix:eslint': 'eslint . --fix',
|
|
82
|
-
'lint:ts': 'tsc',
|
|
83
|
-
'lint:prettier': 'prettier . --check',
|
|
84
|
-
'lint:eslint': 'eslint .',
|
|
85
|
-
'build:storybook': 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook build --quiet --disable-telemetry',
|
|
86
|
-
'test:jest': 'jest',
|
|
87
|
-
postinstall: 'husky',
|
|
88
|
-
});
|
|
89
|
-
export const reactWorkspaceScripts = (workspaceName) => ({
|
|
90
|
-
...reactWorkspaceBaseScripts(),
|
|
91
|
-
[`start:${workspaceName}`]: `sh workspaces/${workspaceName}/bin/start.sh`,
|
|
92
|
-
[`build:${workspaceName}`]: `rimraf dist && sh workspaces/${workspaceName}/bin/build.sh`,
|
|
93
|
-
});
|
|
94
|
-
export const workspaceScripts = (workspaceName) => ({
|
|
95
|
-
...workspaceBaseScripts(),
|
|
96
|
-
[`start:${workspaceName}`]: `sh workspaces/${workspaceName}/bin/start.sh`,
|
|
97
|
-
[`build:${workspaceName}`]: `rimraf dist && sh workspaces/${workspaceName}/bin/build.sh`,
|
|
98
|
-
});
|
|
99
|
-
export const stylelintConfigFile = () => ({
|
|
100
|
-
'stylelint.config.ts': "export { default } from '@vyriy/stylelint-config';\n",
|
|
101
|
-
});
|
|
102
|
-
export const assetsDeclarationFile = () => ({
|
|
103
|
-
'assets.d.ts': "declare module '*.scss';\n",
|
|
104
|
-
});
|
|
105
|
-
export const reactComponentFiles = () => ({
|
|
106
|
-
'packages/components/package.json': JSON.stringify({
|
|
107
|
-
name: '@p/components',
|
|
108
|
-
private: true,
|
|
109
|
-
type: 'module',
|
|
110
|
-
}, null, 2) + '\n',
|
|
111
|
-
'packages/components/index.ts': "export * from './page/index.js';\n",
|
|
112
|
-
'packages/components/index.test.tsx': `import { describe, expect, it } from '@jest/globals';
|
|
113
|
-
|
|
114
|
-
import { Page } from './index.js';
|
|
115
|
-
import { Page as PageImplementation } from './page/index.js';
|
|
116
|
-
|
|
117
|
-
describe('packages/components/page', () => {
|
|
118
|
-
it('re-exports the page component', () => {
|
|
119
|
-
expect(Page).toBe(PageImplementation);
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
`,
|
|
123
|
-
'packages/components/page/index.ts': `export * from './page.js';
|
|
124
|
-
export type * from './types.js';
|
|
125
|
-
`,
|
|
126
|
-
'packages/components/page/index.test.ts': `import { describe, expect, it } from '@jest/globals';
|
|
127
|
-
|
|
128
|
-
import { Page } from './index.js';
|
|
129
|
-
import { Page as PageImplementation } from './page.js';
|
|
130
|
-
|
|
131
|
-
describe('packages/components/page', () => {
|
|
132
|
-
it('re-exports the page component', () => {
|
|
133
|
-
expect(Page).toBe(PageImplementation);
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
`,
|
|
137
|
-
'packages/components/page/types.ts': `import { FC } from 'react';
|
|
138
|
-
|
|
139
|
-
export type PageProps = {
|
|
140
|
-
content: string;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
export type PageType = FC<PageProps>;
|
|
144
|
-
`,
|
|
145
|
-
'packages/components/page/page.tsx': `import type { PageType } from './types.js';
|
|
146
|
-
|
|
147
|
-
export const Page: PageType = ({ content }) => <div className="content">{content}</div>;
|
|
148
|
-
`,
|
|
149
|
-
'packages/components/page/styles.scss': `.content {
|
|
150
|
-
display: block;
|
|
151
|
-
}
|
|
152
|
-
`,
|
|
153
|
-
'packages/components/page/page.test.tsx': `import { renderToStaticMarkup } from 'react-dom/server';
|
|
154
|
-
import { describe, expect, it } from '@jest/globals';
|
|
155
|
-
|
|
156
|
-
import { Page } from './page.js';
|
|
157
|
-
|
|
158
|
-
describe('packages/components/page/page', () => {
|
|
159
|
-
it('renders content inside the page content container', () => {
|
|
160
|
-
expect(renderToStaticMarkup(<Page content="Page body" />)).toBe('<div class="content">Page body</div>');
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
`,
|
|
164
|
-
});
|
|
165
|
-
export const reactServiceFiles = () => ({
|
|
166
|
-
'packages/services/package.json': JSON.stringify({
|
|
167
|
-
name: '@p/services',
|
|
168
|
-
private: true,
|
|
169
|
-
type: 'module',
|
|
170
|
-
}, null, 2) + '\n',
|
|
171
|
-
'packages/services/cms/index.ts': `export const cms = {
|
|
172
|
-
getContent: async () => {
|
|
173
|
-
// Placeholder for fetching content from a CMS
|
|
174
|
-
return Promise.resolve({
|
|
175
|
-
title: 'Sample Content',
|
|
176
|
-
body: 'This is a sample content fetched from the CMS.',
|
|
177
|
-
});
|
|
178
|
-
},
|
|
179
|
-
};
|
|
180
|
-
`,
|
|
181
|
-
'packages/services/cms/index.test.ts': `import { describe, expect, it } from '@jest/globals';
|
|
182
|
-
|
|
183
|
-
import { cms } from './index.js';
|
|
184
|
-
|
|
185
|
-
describe('packages/services/cms', () => {
|
|
186
|
-
it('returns content for rendering a page', async () => {
|
|
187
|
-
await expect(cms.getContent()).resolves.toEqual({
|
|
188
|
-
title: 'Sample Content',
|
|
189
|
-
body: 'This is a sample content fetched from the CMS.',
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
`,
|
|
194
|
-
});
|
|
195
|
-
export const apiWorkspaceBaseFiles = (name, description) => ({
|
|
196
|
-
'workspaces/api/bin/build.sh': `#!/usr/bin/env sh
|
|
197
|
-
|
|
198
|
-
set -e
|
|
199
|
-
|
|
200
|
-
scriptdir="$PWD/workspaces/api";
|
|
201
|
-
|
|
202
|
-
NODE_ENV=production npx webpack --config $scriptdir/webpack.config.ts
|
|
203
|
-
|
|
204
|
-
cp $scriptdir/package.json dist/api/package.json
|
|
205
|
-
npm pkg delete "type" --prefix dist/api
|
|
206
|
-
npm pkg delete "private" --prefix dist/api
|
|
207
|
-
`,
|
|
208
|
-
'workspaces/api/bin/start.sh': `#!/usr/bin/env sh
|
|
209
|
-
|
|
210
|
-
set -e
|
|
211
|
-
|
|
212
|
-
scriptdir="$PWD/workspaces/api";
|
|
213
|
-
|
|
214
|
-
NODE_ENV=production LOG_LEVEL=info tsx $scriptdir/index.ts
|
|
215
|
-
`,
|
|
216
|
-
'workspaces/api/doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
|
|
217
|
-
import ReadMe from './README.md?raw';
|
|
218
|
-
|
|
219
|
-
<Meta title="Workspaces/API" />
|
|
220
|
-
|
|
221
|
-
<Markdown>{ReadMe}</Markdown>
|
|
222
|
-
`,
|
|
223
|
-
'workspaces/api/README.md': `# ${name} API\n\n${description}\n`,
|
|
224
|
-
'workspaces/api/webpack.config.ts': `import { path } from '@vyriy/path';
|
|
225
|
-
import { ssr, external } from '@vyriy/webpack-config';
|
|
226
|
-
|
|
227
|
-
export default ssr(
|
|
228
|
-
'@w/api',
|
|
229
|
-
{
|
|
230
|
-
path: path('dist', 'api'),
|
|
231
|
-
filename: 'index.js',
|
|
232
|
-
library: { type: 'commonjs2' },
|
|
233
|
-
},
|
|
234
|
-
(config) => ({
|
|
235
|
-
...config,
|
|
236
|
-
externals: [external({ allowlist: [/^@p/, /^@w/, /^@vyriy/] })],
|
|
237
|
-
}),
|
|
238
|
-
);
|
|
239
|
-
`,
|
|
240
|
-
'workspaces/api/package.json': JSON.stringify({
|
|
241
|
-
name: '@w/api',
|
|
242
|
-
type: 'module',
|
|
243
|
-
private: true,
|
|
244
|
-
}, null, 2) + '\n',
|
|
245
|
-
});
|