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.
@@ -0,0 +1,307 @@
1
+ import { agentsTemplate } from '../agentsTemplate.js';
2
+ import { json, packageVersion, peerDependencies, publishedPackageJson } from '../config.js';
3
+ const baseRootDevDependencies = {
4
+ '@vyriy/typescript-config': packageVersion(publishedPackageJson.version),
5
+ typescript: peerDependencies.typescript,
6
+ '@vyriy/prettier-config': packageVersion(publishedPackageJson.version),
7
+ prettier: peerDependencies.prettier,
8
+ '@vyriy/eslint-config': packageVersion(publishedPackageJson.version),
9
+ eslint: peerDependencies.eslint,
10
+ '@vyriy/jest-config': packageVersion(publishedPackageJson.version),
11
+ jest: peerDependencies.jest,
12
+ '@vyriy/storybook-config': packageVersion(publishedPackageJson.version),
13
+ storybook: peerDependencies.storybook,
14
+ '@storybook/react-webpack5': peerDependencies['@storybook/react-webpack5'],
15
+ react: peerDependencies.react,
16
+ 'react-dom': peerDependencies['react-dom'],
17
+ '@types/react': peerDependencies['@types/react'],
18
+ '@types/react-dom': peerDependencies['@types/react-dom'],
19
+ '@vyriy/path': packageVersion(publishedPackageJson.version),
20
+ husky: peerDependencies.husky,
21
+ 'npm-run-all2': peerDependencies['npm-run-all2'],
22
+ 'cross-env': peerDependencies['cross-env'],
23
+ };
24
+ const buildDistDevDependencies = {
25
+ vyriy: packageVersion(publishedPackageJson.version),
26
+ rimraf: peerDependencies.rimraf,
27
+ };
28
+ const stylelintDevDependencies = {
29
+ '@vyriy/stylelint-config': packageVersion(publishedPackageJson.version),
30
+ stylelint: peerDependencies.stylelint,
31
+ };
32
+ const shouldCreateStylelintConfig = (plan) => plan.features.some((feature) => [
33
+ 'react',
34
+ 'webpack',
35
+ ].includes(feature));
36
+ const getStylePackageName = (plan) => plan.packages.find((packagePlan) => packagePlan.kind === 'ui')?.name ?? 'ui';
37
+ const shouldCreateResetStyles = (plan) => shouldCreateStylelintConfig(plan) && plan.preset !== 'library';
38
+ const hasPublishablePackages = (plan) => plan.packages.some((packagePlan) => packagePlan.publishable);
39
+ const createRootPackageJson = (plan) => {
40
+ const publishable = hasPublishablePackages(plan);
41
+ const stylelint = shouldCreateStylelintConfig(plan);
42
+ return {
43
+ path: 'package.json',
44
+ content: json({
45
+ name: `${plan.packageScope}/${plan.projectName}`,
46
+ version: '0.0.0',
47
+ description: plan.description,
48
+ private: true,
49
+ type: 'module',
50
+ packageManager: publishedPackageJson.packageManager,
51
+ engines: {
52
+ node: publishedPackageJson.engines.node,
53
+ },
54
+ workspaces: [
55
+ 'packages/*',
56
+ 'workspaces/*',
57
+ ],
58
+ scripts: {
59
+ storybook: 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook dev -p 6006 --disable-telemetry',
60
+ check: 'run-s lint build test',
61
+ fix: "run-s 'fix:*'",
62
+ lint: "run-s 'lint:*'",
63
+ build: "run-s 'build:*'",
64
+ test: "run-s 'test:*'",
65
+ 'fix:prettier': 'prettier . --write',
66
+ 'fix:eslint': 'eslint . --fix',
67
+ 'lint:ts': 'tsc --pretty false',
68
+ 'lint:prettier': 'prettier . --check',
69
+ 'lint:eslint': 'eslint .',
70
+ ...(stylelint ? { 'lint:stylelint': 'stylelint "packages/**/*.{scss,css}"' } : {}),
71
+ 'build:dist': publishable
72
+ ? 'rimraf dist && tsc -p tsconfig.build.json && vyriy publish'
73
+ : 'echo "Build dist is not configured yet."',
74
+ 'build:storybook': 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook build --quiet --disable-telemetry',
75
+ 'test:jest': 'jest --passWithNoTests',
76
+ postinstall: 'husky',
77
+ },
78
+ devDependencies: {
79
+ ...baseRootDevDependencies,
80
+ ...(publishable ? buildDistDevDependencies : {}),
81
+ ...(stylelint ? stylelintDevDependencies : {}),
82
+ },
83
+ }),
84
+ };
85
+ };
86
+ const createBuildTsConfig = () => ({
87
+ path: 'tsconfig.build.json',
88
+ content: json({
89
+ extends: './tsconfig.json',
90
+ include: [
91
+ 'packages/**/*.ts',
92
+ 'packages/**/*.tsx',
93
+ 'packages/**/*.json',
94
+ ],
95
+ exclude: [
96
+ '**/*.test.ts',
97
+ '**/*.test.tsx',
98
+ '**/*.stories.ts',
99
+ '**/*.stories.tsx',
100
+ ],
101
+ compilerOptions: {
102
+ rootDir: './packages',
103
+ outDir: './dist',
104
+ noEmit: false,
105
+ declaration: true,
106
+ allowImportingTsExtensions: false,
107
+ },
108
+ }),
109
+ });
110
+ const createStyleFiles = (plan) => shouldCreateStylelintConfig(plan)
111
+ ? [
112
+ {
113
+ path: 'stylelint.config.ts',
114
+ content: "export { default } from '@vyriy/stylelint-config';\n",
115
+ },
116
+ ...(shouldCreateResetStyles(plan)
117
+ ? [
118
+ {
119
+ path: `packages/${getStylePackageName(plan)}/reset.scss`,
120
+ content: `html {
121
+ box-sizing: border-box;
122
+ }
123
+
124
+ *,
125
+ *::before,
126
+ *::after {
127
+ box-sizing: inherit;
128
+ }
129
+
130
+ body {
131
+ margin: 0;
132
+ }
133
+ `,
134
+ },
135
+ ]
136
+ : []),
137
+ ]
138
+ : [];
139
+ export const createBaseFiles = (plan) => [
140
+ createRootPackageJson(plan),
141
+ {
142
+ path: 'README.md',
143
+ content: `# ${plan.projectName}\n\n${plan.description}\n`,
144
+ },
145
+ {
146
+ path: 'doc.mdx',
147
+ content: `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
148
+ import ReadMe from './README.md?raw';
149
+
150
+ <Meta title="${plan.projectName}" />
151
+
152
+ <Markdown>{ReadMe}</Markdown>
153
+ `,
154
+ },
155
+ {
156
+ path: 'AGENTS.md',
157
+ content: agentsTemplate,
158
+ },
159
+ {
160
+ path: '.editorconfig',
161
+ content: `# https://editorconfig.org
162
+ root = true
163
+
164
+ [*]
165
+ charset = utf-8
166
+ end_of_line = lf
167
+ insert_final_newline = true
168
+ trim_trailing_whitespace = true
169
+
170
+ indent_style = space
171
+ indent_size = 2
172
+
173
+ max_line_length = 100
174
+
175
+ # Markdown
176
+ [*.md]
177
+ trim_trailing_whitespace = false
178
+ max_line_length = off
179
+
180
+ # YAML / YML
181
+ [*.{yml,yaml}]
182
+ indent_size = 2
183
+
184
+ # JSON
185
+ [*.json]
186
+ indent_size = 2
187
+
188
+ # TypeScript / JavaScript
189
+ [*.{ts,tsx,js,jsx}]
190
+ indent_size = 2
191
+
192
+ # Shell / Bash
193
+ [*.sh]
194
+ indent_size = 2`,
195
+ },
196
+ {
197
+ path: '.gitignore',
198
+ content: `.yarn/*
199
+ !.yarn/cache
200
+ !.yarn/patches
201
+ !.yarn/plugins
202
+ !.yarn/releases
203
+ !.yarn/sdks
204
+ !.yarn/versions
205
+
206
+ .DS_Store
207
+ .idea
208
+ node_modules
209
+ coverage
210
+ dist
211
+ storybook-static
212
+ *storybook.log
213
+ consumer
214
+
215
+ cdk.out
216
+ cdk.context.json
217
+
218
+ !/**/.gitkeep`,
219
+ },
220
+ {
221
+ path: '.npmrc',
222
+ content: 'engine-strict=true\n',
223
+ },
224
+ {
225
+ path: '.nvmrc',
226
+ content: 'lts/krypton',
227
+ },
228
+ {
229
+ path: '.yarnrc.yml',
230
+ content: 'nodeLinker: node-modules\nnpmMinimalAgeGate: 0\n',
231
+ },
232
+ {
233
+ path: '.husky/commit-msg',
234
+ content: '#!/bin/sh\n',
235
+ },
236
+ {
237
+ path: '.husky/post-checkout',
238
+ content: '#!/bin/sh\n\nyarn\n',
239
+ },
240
+ {
241
+ path: '.husky/post-merge',
242
+ content: '#!/bin/sh\n\nyarn\n',
243
+ },
244
+ {
245
+ path: '.husky/pre-commit',
246
+ content: '#!/bin/sh\n\nyarn check\n',
247
+ },
248
+ {
249
+ path: '.husky/pre-push',
250
+ content: '#!/bin/sh\n\nyarn check\n',
251
+ },
252
+ {
253
+ path: '.storybook/main.ts',
254
+ content: `import config from '@vyriy/storybook-config';
255
+ import { path } from '@vyriy/path';
256
+
257
+ export default {
258
+ ...config,
259
+ stories: [
260
+ path('**/*.mdx'),
261
+ path('**/*.stories.@(js|jsx|mjs|ts|tsx)'),
262
+ ],
263
+ };
264
+ `,
265
+ },
266
+ {
267
+ path: '.storybook/preview.tsx',
268
+ content: "export { default } from '@vyriy/storybook-config/preview';\n",
269
+ },
270
+ {
271
+ path: 'yarn.lock',
272
+ content: '',
273
+ },
274
+ {
275
+ path: 'tsconfig.json',
276
+ content: json({
277
+ extends: '@vyriy/typescript-config/index.json',
278
+ include: [
279
+ '.storybook/**/*.ts',
280
+ '.storybook/**/*.tsx',
281
+ 'packages/**/*.ts',
282
+ 'packages/**/*.tsx',
283
+ 'workspaces/**/*.ts',
284
+ 'workspaces/**/*.tsx',
285
+ '*.ts',
286
+ ],
287
+ }),
288
+ },
289
+ ...(hasPublishablePackages(plan) ? [createBuildTsConfig()] : []),
290
+ {
291
+ path: 'prettier.config.ts',
292
+ content: "export { default } from '@vyriy/prettier-config';\n",
293
+ },
294
+ {
295
+ path: '.prettierignore',
296
+ content: 'node_modules\ndist\ncoverage\nstorybook-static\n',
297
+ },
298
+ {
299
+ path: 'eslint.config.ts',
300
+ content: "export { default } from '@vyriy/eslint-config';\n",
301
+ },
302
+ {
303
+ path: 'jest.config.ts',
304
+ content: "export { default } from '@vyriy/jest-config';\n",
305
+ },
306
+ ...createStyleFiles(plan),
307
+ ];
@@ -0,0 +1,28 @@
1
+ import packageJson from '../package.json';
2
+ type PublishedPackageJson = typeof packageJson & {
3
+ readonly engines: {
4
+ readonly node: string;
5
+ };
6
+ readonly packageManager: string;
7
+ };
8
+ export declare const json: (value: unknown) => string;
9
+ export declare const packageVersion: (version: string) => string;
10
+ export declare const publishedPackageJson: PublishedPackageJson;
11
+ export declare const peerDependencies: {
12
+ "@storybook/react-webpack5": string;
13
+ "@types/react": string;
14
+ "@types/react-dom": string;
15
+ "cross-env": string;
16
+ eslint: string;
17
+ husky: string;
18
+ jest: string;
19
+ "npm-run-all2": string;
20
+ prettier: string;
21
+ react: string;
22
+ "react-dom": string;
23
+ rimraf: string;
24
+ storybook: string;
25
+ stylelint: string;
26
+ typescript: string;
27
+ };
28
+ export {};
@@ -0,0 +1,7 @@
1
+ import packageJson from '../package.json' with { type: 'json' };
2
+ export const json = (value) => `${JSON.stringify(value, null, 2)}\n`;
3
+ export const packageVersion = (version) => `^${version}`;
4
+ const assumePublishedPackageJson = () => { };
5
+ assumePublishedPackageJson(packageJson);
6
+ export const publishedPackageJson = packageJson;
7
+ export const peerDependencies = publishedPackageJson.peerDependencies;