@vyriy/create 0.5.2 → 0.5.4

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/preset/rest.js CHANGED
@@ -1,18 +1,224 @@
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
- import { base } from './base.js';
3
- import { apiWorkspaceBaseFiles, baseToolingDeps, buildPackageJson, serverDeps, webpackDeps, workspaceScripts, } from './shared.js';
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 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
- }),
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
+ 'workspaces/*',
25
+ ],
26
+ scripts: {
27
+ storybook: 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook dev -p 6006 --disable-telemetry',
28
+ check: 'run-s lint build test',
29
+ fix: "run-s 'fix:*'",
30
+ start: "run-p 'start:*'",
31
+ lint: "run-s 'lint:*'",
32
+ build: "run-s 'build:*'",
33
+ test: "run-s 'test:*'",
34
+ 'fix:prettier': 'prettier . --write',
35
+ 'fix:eslint': 'eslint . --fix',
36
+ 'lint:ts': 'tsc',
37
+ 'lint:prettier': 'prettier . --check',
38
+ 'lint:eslint': 'eslint .',
39
+ 'build:storybook': 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook build --quiet --disable-telemetry',
40
+ 'test:jest': 'jest',
41
+ postinstall: 'husky',
42
+ 'start:api': 'sh workspaces/api/bin/start.sh',
43
+ 'build:api': 'rimraf dist && sh workspaces/api/bin/build.sh',
44
+ },
45
+ dependencies: {
46
+ '@vyriy/typescript-config': `^${packageJson.version}`,
47
+ typescript: packageJson.peerDependencies.typescript,
48
+ '@vyriy/prettier-config': `^${packageJson.version}`,
49
+ prettier: packageJson.peerDependencies.prettier,
50
+ '@vyriy/eslint-config': `^${packageJson.version}`,
51
+ eslint: packageJson.peerDependencies.eslint,
52
+ '@vyriy/jest-config': `^${packageJson.version}`,
53
+ jest: packageJson.peerDependencies.jest,
54
+ '@vyriy/storybook-config': `^${packageJson.version}`,
55
+ storybook: packageJson.peerDependencies.storybook,
56
+ '@vyriy/path': `^${packageJson.version}`,
57
+ husky: packageJson.peerDependencies.husky,
58
+ 'npm-run-all2': packageJson.peerDependencies['npm-run-all2'],
59
+ 'cross-env': packageJson.peerDependencies['cross-env'],
60
+ rimraf: packageJson.peerDependencies.rimraf,
61
+ '@vyriy/webpack-config': `^${packageJson.version}`,
62
+ tsx: packageJson.peerDependencies.tsx,
63
+ 'webpack-cli': packageJson.peerDependencies['webpack-cli'],
64
+ '@vyriy/handler': `^${packageJson.version}`,
65
+ '@vyriy/server': `^${packageJson.version}`,
66
+ '@vyriy/router': `^${packageJson.version}`,
67
+ '@vyriy/html': `^${packageJson.version}`,
68
+ },
69
+ }, null, 2) + '\n',
70
+ 'README.md': `# ${options.name}\n\n${options.description}\n`,
71
+ 'doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
72
+ import ReadMe from './README.md?raw';
73
+
74
+ <Meta title="${options.name}" />
75
+
76
+ <Markdown>{ReadMe}</Markdown>
77
+ `,
78
+ 'AGENTS.md': agentsContent,
79
+ '.editorconfig': `# https://editorconfig.org
80
+ root = true
81
+
82
+ [*]
83
+ charset = utf-8
84
+ end_of_line = lf
85
+ insert_final_newline = true
86
+ trim_trailing_whitespace = true
87
+
88
+ indent_style = space
89
+ indent_size = 2
90
+
91
+ max_line_length = 100
92
+
93
+ # Markdown
94
+ [*.md]
95
+ trim_trailing_whitespace = false
96
+ max_line_length = off
97
+
98
+ # YAML / YML
99
+ [*.{yml,yaml}]
100
+ indent_size = 2
101
+
102
+ # JSON
103
+ [*.json]
104
+ indent_size = 2
105
+
106
+ # TypeScript / JavaScript
107
+ [*.{ts,tsx,js,jsx}]
108
+ indent_size = 2
109
+
110
+ # Shell / Bash
111
+ [*.sh]
112
+ indent_size = 2
113
+ `,
114
+ '.gitignore': `.yarn/*
115
+ !.yarn/cache
116
+ !.yarn/patches
117
+ !.yarn/plugins
118
+ !.yarn/releases
119
+ !.yarn/sdks
120
+ !.yarn/versions
121
+
122
+ .DS_Store
123
+ .idea
124
+ node_modules
125
+ coverage
126
+ dist
127
+ storybook-static
128
+ *storybook.log
129
+ consumer
130
+
131
+ cdk.out
132
+ cdk.context.json
133
+
134
+ !/**/.gitkeep
135
+ `,
136
+ '.npmrc': 'engine-strict=true\n',
137
+ '.nvmrc': 'lts/krypton\n',
138
+ '.yarnrc.yml': 'nodeLinker: node-modules\nnpmMinimalAgeGate: 0\n',
139
+ '.husky/commit-msg': '#!/bin/sh\n',
140
+ '.husky/post-checkout': '#!/bin/sh\n\nyarn\n',
141
+ '.husky/post-merge': '#!/bin/sh\n\nyarn\n',
142
+ '.husky/pre-commit': '#!/bin/sh\n\nyarn check\n',
143
+ '.husky/pre-push': '#!/bin/sh\n\nyarn check\n',
144
+ '.storybook/main.ts': `import config from '@vyriy/storybook-config';
145
+ import { path } from '@vyriy/path';
146
+
147
+ export default {
148
+ ...config,
149
+ stories: [
150
+ path('**/*.mdx'),
151
+ path('**/*.stories.@(js|jsx|mjs|ts|tsx)'),
152
+ ],
153
+ };
154
+ `,
155
+ '.storybook/preview.tsx': "export { default } from '@vyriy/storybook-config/preview';\n",
156
+ 'yarn.lock': '',
157
+ 'tsconfig.json': JSON.stringify({
158
+ extends: '@vyriy/typescript-config/index.json',
159
+ include: [
160
+ '.storybook/**/*.ts',
161
+ '.storybook/**/*.tsx',
162
+ 'packages/**/*.ts',
163
+ 'packages/**/*.tsx',
164
+ 'workspaces/**/*.ts',
165
+ 'workspaces/**/*.tsx',
166
+ '*.ts',
167
+ ],
168
+ }, null, 2) + '\n',
169
+ 'prettier.config.ts': "export { default } from '@vyriy/prettier-config';\n",
170
+ '.prettierignore': 'node_modules\ndist\ncoverage\nstorybook-static\nconsumer\n',
171
+ 'eslint.config.ts': "export { default } from '@vyriy/eslint-config';\n",
172
+ 'jest.config.ts': "export { default } from '@vyriy/jest-config';\n",
173
+ 'workspaces/api/bin/build.sh': `#!/usr/bin/env sh
174
+
175
+ set -e
176
+
177
+ scriptdir="$PWD/workspaces/api";
178
+
179
+ NODE_ENV=production npx webpack --config $scriptdir/webpack.config.ts
180
+
181
+ cp $scriptdir/package.json dist/api/package.json
182
+ npm pkg delete "type" --prefix dist/api
183
+ npm pkg delete "private" --prefix dist/api
184
+ `,
185
+ 'workspaces/api/bin/start.sh': `#!/usr/bin/env sh
186
+
187
+ set -e
188
+
189
+ scriptdir="$PWD/workspaces/api";
190
+
191
+ NODE_ENV=production LOG_LEVEL=info tsx $scriptdir/index.ts
192
+ `,
193
+ 'workspaces/api/doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
194
+ import ReadMe from './README.md?raw';
195
+
196
+ <Meta title="Workspaces/API" />
197
+
198
+ <Markdown>{ReadMe}</Markdown>
199
+ `,
200
+ 'workspaces/api/README.md': `# ${options.name} API\n\n${options.description}\n`,
201
+ 'workspaces/api/webpack.config.ts': `import { path } from '@vyriy/path';
202
+ import { ssr, external } from '@vyriy/webpack-config';
203
+
204
+ export default ssr(
205
+ '@w/api',
206
+ {
207
+ path: path('dist', 'api'),
208
+ filename: 'index.js',
209
+ library: { type: 'commonjs2' },
210
+ },
211
+ (config) => ({
212
+ ...config,
213
+ externals: [external({ allowlist: [/^@p/, /^@w/, /^@vyriy/] })],
214
+ }),
215
+ );
216
+ `,
217
+ 'workspaces/api/package.json': JSON.stringify({
218
+ name: '@w/api',
219
+ type: 'module',
220
+ private: true,
221
+ }, null, 2) + '\n',
16
222
  'workspaces/api/index.ts': `import { server } from '@vyriy/server';
17
223
  import { api } from '@vyriy/handler';
18
224
  import { createRouter } from '@vyriy/router';
package/preset/spa.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 spa: Preset;
package/preset/spa.js CHANGED
@@ -1,23 +1,243 @@
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
- import { base } from './base.js';
3
- import { assetsDeclarationFile, baseToolingDeps, buildPackageJson, reactComponentFiles, reactDeps, reactWorkspaceScripts, stylelintConfigFile, stylelintDeps, webpackDeps, } from './shared.js';
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 spa = (options) => ({
5
- ...base(options),
6
- ...stylelintConfigFile(),
7
- ...assetsDeclarationFile(),
8
- ...reactComponentFiles(),
9
- 'package.json': buildPackageJson(options, [
10
- 'packages/*',
11
- 'workspaces/*',
12
- ], reactWorkspaceScripts('spa'), {
13
- ...baseToolingDeps(),
14
- ...webpackDeps(),
15
- ...reactDeps(),
16
- ...stylelintDeps(),
17
- '@vyriy/cn': `^${packageJson.version}`,
18
- '@vyriy/html': `^${packageJson.version}`,
19
- '@vyriy/browserslist-config': `^${packageJson.version}`,
20
- }),
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:spa': 'sh workspaces/spa/bin/start.sh',
46
+ 'build:spa': 'rimraf dist && sh workspaces/spa/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
+ react: packageJson.peerDependencies.react,
68
+ 'react-dom': packageJson.peerDependencies['react-dom'],
69
+ '@types/react': packageJson.peerDependencies['@types/react'],
70
+ '@types/react-dom': packageJson.peerDependencies['@types/react-dom'],
71
+ '@vyriy/stylelint-config': `^${packageJson.version}`,
72
+ stylelint: packageJson.peerDependencies.stylelint,
73
+ '@vyriy/cn': `^${packageJson.version}`,
74
+ '@vyriy/html': `^${packageJson.version}`,
75
+ '@vyriy/browserslist-config': `^${packageJson.version}`,
76
+ },
77
+ }, null, 2) + '\n',
78
+ 'README.md': `# ${options.name}\n\n${options.description}\n`,
79
+ 'doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
80
+ import ReadMe from './README.md?raw';
81
+
82
+ <Meta title="${options.name}" />
83
+
84
+ <Markdown>{ReadMe}</Markdown>
85
+ `,
86
+ 'AGENTS.md': agentsContent,
87
+ '.editorconfig': `# https://editorconfig.org
88
+ root = true
89
+
90
+ [*]
91
+ charset = utf-8
92
+ end_of_line = lf
93
+ insert_final_newline = true
94
+ trim_trailing_whitespace = true
95
+
96
+ indent_style = space
97
+ indent_size = 2
98
+
99
+ max_line_length = 100
100
+
101
+ # Markdown
102
+ [*.md]
103
+ trim_trailing_whitespace = false
104
+ max_line_length = off
105
+
106
+ # YAML / YML
107
+ [*.{yml,yaml}]
108
+ indent_size = 2
109
+
110
+ # JSON
111
+ [*.json]
112
+ indent_size = 2
113
+
114
+ # TypeScript / JavaScript
115
+ [*.{ts,tsx,js,jsx}]
116
+ indent_size = 2
117
+
118
+ # Shell / Bash
119
+ [*.sh]
120
+ indent_size = 2
121
+ `,
122
+ '.gitignore': `.yarn/*
123
+ !.yarn/cache
124
+ !.yarn/patches
125
+ !.yarn/plugins
126
+ !.yarn/releases
127
+ !.yarn/sdks
128
+ !.yarn/versions
129
+
130
+ .DS_Store
131
+ .idea
132
+ node_modules
133
+ coverage
134
+ dist
135
+ storybook-static
136
+ *storybook.log
137
+ consumer
138
+
139
+ cdk.out
140
+ cdk.context.json
141
+
142
+ !/**/.gitkeep
143
+ `,
144
+ '.npmrc': 'engine-strict=true\n',
145
+ '.nvmrc': 'lts/krypton\n',
146
+ '.yarnrc.yml': 'nodeLinker: node-modules\nnpmMinimalAgeGate: 0\n',
147
+ '.husky/commit-msg': '#!/bin/sh\n',
148
+ '.husky/post-checkout': '#!/bin/sh\n\nyarn\n',
149
+ '.husky/post-merge': '#!/bin/sh\n\nyarn\n',
150
+ '.husky/pre-commit': '#!/bin/sh\n\nyarn check\n',
151
+ '.husky/pre-push': '#!/bin/sh\n\nyarn check\n',
152
+ '.storybook/main.ts': `import config from '@vyriy/storybook-config';
153
+ import { path } from '@vyriy/path';
154
+
155
+ export default {
156
+ ...config,
157
+ stories: [
158
+ path('**/*.mdx'),
159
+ path('**/*.stories.@(js|jsx|mjs|ts|tsx)'),
160
+ ],
161
+ };
162
+ `,
163
+ '.storybook/preview.tsx': "export { default } from '@vyriy/storybook-config/preview';\n",
164
+ 'yarn.lock': '',
165
+ 'tsconfig.json': JSON.stringify({
166
+ extends: '@vyriy/typescript-config/index.json',
167
+ include: [
168
+ '.storybook/**/*.ts',
169
+ '.storybook/**/*.tsx',
170
+ 'packages/**/*.ts',
171
+ 'packages/**/*.tsx',
172
+ 'workspaces/**/*.ts',
173
+ 'workspaces/**/*.tsx',
174
+ '*.ts',
175
+ ],
176
+ }, null, 2) + '\n',
177
+ 'prettier.config.ts': "export { default } from '@vyriy/prettier-config';\n",
178
+ '.prettierignore': 'node_modules\ndist\ncoverage\nstorybook-static\nconsumer\n',
179
+ 'eslint.config.ts': "export { default } from '@vyriy/eslint-config';\n",
180
+ 'jest.config.ts': "export { default } from '@vyriy/jest-config';\n",
181
+ 'stylelint.config.ts': "export { default } from '@vyriy/stylelint-config';\n",
182
+ 'assets.d.ts': "declare module '*.scss';\n",
183
+ 'packages/components/package.json': JSON.stringify({
184
+ name: '@p/components',
185
+ private: true,
186
+ type: 'module',
187
+ }, null, 2) + '\n',
188
+ 'packages/components/index.ts': "export * from './page/index.js';\n",
189
+ 'packages/components/index.test.tsx': `import { describe, expect, it } from '@jest/globals';
190
+
191
+ import { Page } from './index.js';
192
+ import { Page as PageImplementation } from './page/index.js';
193
+
194
+ describe('packages/components/page', () => {
195
+ it('re-exports the page component', () => {
196
+ expect(Page).toBe(PageImplementation);
197
+ });
198
+ });
199
+ `,
200
+ 'packages/components/page/index.ts': `export * from './page.js';
201
+ export type * from './types.js';
202
+ `,
203
+ 'packages/components/page/index.test.ts': `import { describe, expect, it } from '@jest/globals';
204
+
205
+ import { Page } from './index.js';
206
+ import { Page as PageImplementation } from './page.js';
207
+
208
+ describe('packages/components/page', () => {
209
+ it('re-exports the page component', () => {
210
+ expect(Page).toBe(PageImplementation);
211
+ });
212
+ });
213
+ `,
214
+ 'packages/components/page/types.ts': `import { FC } from 'react';
215
+
216
+ export type PageProps = {
217
+ content: string;
218
+ };
219
+
220
+ export type PageType = FC<PageProps>;
221
+ `,
222
+ 'packages/components/page/page.tsx': `import type { PageType } from './types.js';
223
+
224
+ export const Page: PageType = ({ content }) => <div className="content">{content}</div>;
225
+ `,
226
+ 'packages/components/page/styles.scss': `.content {
227
+ display: block;
228
+ }
229
+ `,
230
+ 'packages/components/page/page.test.tsx': `import { renderToStaticMarkup } from 'react-dom/server';
231
+ import { describe, expect, it } from '@jest/globals';
232
+
233
+ import { Page } from './page.js';
234
+
235
+ describe('packages/components/page/page', () => {
236
+ it('renders content inside the page content container', () => {
237
+ expect(renderToStaticMarkup(<Page content="Page body" />)).toBe('<div class="content">Page body</div>');
238
+ });
239
+ });
240
+ `,
21
241
  '.browserslistrc': `[development]
22
242
  extends @vyriy/browserslist-config
23
243
 
package/preset/ssg.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 ssg: Preset;