@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/README.md CHANGED
@@ -18,6 +18,8 @@ vyriy-create app --dry-run
18
18
  vyriy-create . --overwrite
19
19
  vyriy-create app --no-install
20
20
  vyriy-create app --no-verify
21
+ vyriy-create --help
22
+ vyriy-create --version
21
23
  ```
22
24
 
23
25
  ## API
@@ -28,10 +30,10 @@ Install as a project dependency:
28
30
  npm install @vyriy/create
29
31
  ```
30
32
 
31
- Use the creator from code:
33
+ Use the creator and CLI helpers from code:
32
34
 
33
35
  ```ts
34
- import { create } from '@vyriy/create';
36
+ import { create, runCreateCli } from '@vyriy/create';
35
37
 
36
38
  const code = await create({
37
39
  directory: 'app',
@@ -41,6 +43,8 @@ const code = await create({
41
43
  install: true,
42
44
  verify: true,
43
45
  });
46
+
47
+ await runCreateCli(['app', '--dry-run']);
44
48
  ```
45
49
 
46
50
  `create(options)` creates a Vyriy project from the configured starter options and returns a process-style exit code.
package/bin/index.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { runCreateCli } from '../index.js';
3
+ await runCreateCli(process.argv.slice(2));
package/cli.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import type { CreateHelpText, ParseCreateBinArgs, RunCreateCli } from './types.js';
2
+ export declare const createVersion: string;
3
+ export declare const createCreateHelpText: CreateHelpText;
4
+ export declare const parseCreateBinArgs: ParseCreateBinArgs;
5
+ export declare const runCreateCli: RunCreateCli;
package/cli.js ADDED
@@ -0,0 +1,62 @@
1
+ import packageJson from './package.json' with { type: 'json' };
2
+ import { create } from './create.js';
3
+ export const createVersion = packageJson.version;
4
+ export const createCreateHelpText = (command = 'vyriy-create', alias = 'vc') => {
5
+ const aliasText = alias ? ` ${alias} [name] Alias for ${command}\n` : '';
6
+ const aliasExampleText = alias ? `\n ${alias} app` : '';
7
+ return `Vyriy Project Creator
8
+
9
+ Usage:
10
+ ${command} [name] Create a new Vyriy project
11
+ ${command} . Initialize a new Vyriy project in the current directory
12
+ ${aliasText}\
13
+ ${command} --help, -h Show help
14
+ ${command} --version, -v Show version
15
+
16
+ Options:
17
+ --dry-run Print the merged file plan without writing project files
18
+ --overwrite Overwrite existing generated paths
19
+ --skip-existing Leave existing generated paths untouched
20
+ --no-install Create files without installing dependencies
21
+ --no-verify Install dependencies without running checks
22
+
23
+ Examples:
24
+ ${command} app
25
+ ${command} app --dry-run
26
+ ${command} .
27
+ ${command} . --no-verify${aliasExampleText}`;
28
+ };
29
+ export const parseCreateBinArgs = (args) => {
30
+ if (args.includes('--help') || args.includes('-h')) {
31
+ return { type: 'help' };
32
+ }
33
+ if (args.includes('--version') || args.includes('-v')) {
34
+ return { type: 'version' };
35
+ }
36
+ const install = !args.includes('--no-install');
37
+ return {
38
+ type: 'create',
39
+ directory: args.find((arg) => !arg.startsWith('-')) ?? '',
40
+ dryRun: args.includes('--dry-run'),
41
+ overwrite: args.includes('--overwrite'),
42
+ skipExisting: args.includes('--skip-existing'),
43
+ install,
44
+ verify: install && !args.includes('--no-verify'),
45
+ };
46
+ };
47
+ export const runCreateCli = async (args = [], command = 'vyriy-create', alias = 'vc') => {
48
+ const parsed = parseCreateBinArgs(args);
49
+ switch (parsed.type) {
50
+ case 'help':
51
+ console.log(createCreateHelpText(command, alias));
52
+ process.exitCode = 0;
53
+ break;
54
+ case 'version':
55
+ console.log(createVersion);
56
+ process.exitCode = 0;
57
+ break;
58
+ case 'create':
59
+ process.exitCode = await create(parsed);
60
+ break;
61
+ }
62
+ };
package/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
+ export * from './cli.js';
1
2
  export * from './create.js';
2
3
  export type * from './types.js';
package/index.js CHANGED
@@ -1 +1,2 @@
1
+ export * from './cli.js';
1
2
  export * from './create.js';
package/package.json CHANGED
@@ -1,15 +1,18 @@
1
1
  {
2
2
  "name": "@vyriy/create",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "Vyriy project creation CLI.",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": ">=24.0.0"
8
8
  },
9
- "packageManager": "yarn@4.15.0",
10
- "bin": "./bin/vyriy-create.js",
9
+ "packageManager": "yarn@4.16.0",
10
+ "bin": {
11
+ "vc": "./bin/index.js",
12
+ "vyriy-create": "./bin/index.js"
13
+ },
11
14
  "dependencies": {
12
- "@vyriy/check": "0.5.2"
15
+ "@vyriy/check": "0.5.4"
13
16
  },
14
17
  "peerDependencies": {
15
18
  "@testing-library/dom": "^10.4.1",
@@ -122,6 +125,16 @@
122
125
  "import": "./index.js",
123
126
  "default": "./index.js"
124
127
  },
128
+ "./cli": {
129
+ "types": "./cli.d.ts",
130
+ "import": "./cli.js",
131
+ "default": "./cli.js"
132
+ },
133
+ "./cli.js": {
134
+ "types": "./cli.d.ts",
135
+ "import": "./cli.js",
136
+ "default": "./cli.js"
137
+ },
125
138
  "./create": {
126
139
  "types": "./create.d.ts",
127
140
  "import": "./create.js",
@@ -252,16 +265,6 @@
252
265
  "import": "./preset/rest.js",
253
266
  "default": "./preset/rest.js"
254
267
  },
255
- "./preset/shared": {
256
- "types": "./preset/shared.d.ts",
257
- "import": "./preset/shared.js",
258
- "default": "./preset/shared.js"
259
- },
260
- "./preset/shared.js": {
261
- "types": "./preset/shared.d.ts",
262
- "import": "./preset/shared.js",
263
- "default": "./preset/shared.js"
264
- },
265
268
  "./preset/spa": {
266
269
  "types": "./preset/spa.d.ts",
267
270
  "import": "./preset/spa.js",
package/preset/api.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 api: Preset;
package/preset/api.js CHANGED
@@ -1,15 +1,222 @@
1
- import { base } from './base.js';
2
- import { apiWorkspaceBaseFiles, baseToolingDeps, buildPackageJson, serverDeps, webpackDeps, workspaceScripts, } from './shared.js';
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { dirname, resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import packageJson from '../package.json' with { type: 'json' };
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') : '';
3
11
  export const api = (options) => ({
4
- ...base(options),
5
- ...apiWorkspaceBaseFiles(options.name, options.description),
6
- 'package.json': buildPackageJson(options, [
7
- 'workspaces/*',
8
- ], workspaceScripts('api'), {
9
- ...baseToolingDeps(),
10
- ...webpackDeps(),
11
- ...serverDeps(),
12
- }),
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
+ },
67
+ }, null, 2) + '\n',
68
+ 'README.md': `# ${options.name}\n\n${options.description}\n`,
69
+ 'doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
70
+ import ReadMe from './README.md?raw';
71
+
72
+ <Meta title="${options.name}" />
73
+
74
+ <Markdown>{ReadMe}</Markdown>
75
+ `,
76
+ 'AGENTS.md': agentsContent,
77
+ '.editorconfig': `# https://editorconfig.org
78
+ root = true
79
+
80
+ [*]
81
+ charset = utf-8
82
+ end_of_line = lf
83
+ insert_final_newline = true
84
+ trim_trailing_whitespace = true
85
+
86
+ indent_style = space
87
+ indent_size = 2
88
+
89
+ max_line_length = 100
90
+
91
+ # Markdown
92
+ [*.md]
93
+ trim_trailing_whitespace = false
94
+ max_line_length = off
95
+
96
+ # YAML / YML
97
+ [*.{yml,yaml}]
98
+ indent_size = 2
99
+
100
+ # JSON
101
+ [*.json]
102
+ indent_size = 2
103
+
104
+ # TypeScript / JavaScript
105
+ [*.{ts,tsx,js,jsx}]
106
+ indent_size = 2
107
+
108
+ # Shell / Bash
109
+ [*.sh]
110
+ indent_size = 2
111
+ `,
112
+ '.gitignore': `.yarn/*
113
+ !.yarn/cache
114
+ !.yarn/patches
115
+ !.yarn/plugins
116
+ !.yarn/releases
117
+ !.yarn/sdks
118
+ !.yarn/versions
119
+
120
+ .DS_Store
121
+ .idea
122
+ node_modules
123
+ coverage
124
+ dist
125
+ storybook-static
126
+ *storybook.log
127
+ consumer
128
+
129
+ cdk.out
130
+ cdk.context.json
131
+
132
+ !/**/.gitkeep
133
+ `,
134
+ '.npmrc': 'engine-strict=true\n',
135
+ '.nvmrc': 'lts/krypton\n',
136
+ '.yarnrc.yml': 'nodeLinker: node-modules\nnpmMinimalAgeGate: 0\n',
137
+ '.husky/commit-msg': '#!/bin/sh\n',
138
+ '.husky/post-checkout': '#!/bin/sh\n\nyarn\n',
139
+ '.husky/post-merge': '#!/bin/sh\n\nyarn\n',
140
+ '.husky/pre-commit': '#!/bin/sh\n\nyarn check\n',
141
+ '.husky/pre-push': '#!/bin/sh\n\nyarn check\n',
142
+ '.storybook/main.ts': `import config from '@vyriy/storybook-config';
143
+ import { path } from '@vyriy/path';
144
+
145
+ export default {
146
+ ...config,
147
+ stories: [
148
+ path('**/*.mdx'),
149
+ path('**/*.stories.@(js|jsx|mjs|ts|tsx)'),
150
+ ],
151
+ };
152
+ `,
153
+ '.storybook/preview.tsx': "export { default } from '@vyriy/storybook-config/preview';\n",
154
+ 'yarn.lock': '',
155
+ 'tsconfig.json': JSON.stringify({
156
+ extends: '@vyriy/typescript-config/index.json',
157
+ include: [
158
+ '.storybook/**/*.ts',
159
+ '.storybook/**/*.tsx',
160
+ 'packages/**/*.ts',
161
+ 'packages/**/*.tsx',
162
+ 'workspaces/**/*.ts',
163
+ 'workspaces/**/*.tsx',
164
+ '*.ts',
165
+ ],
166
+ }, null, 2) + '\n',
167
+ 'prettier.config.ts': "export { default } from '@vyriy/prettier-config';\n",
168
+ '.prettierignore': 'node_modules\ndist\ncoverage\nstorybook-static\nconsumer\n',
169
+ 'eslint.config.ts': "export { default } from '@vyriy/eslint-config';\n",
170
+ 'jest.config.ts': "export { default } from '@vyriy/jest-config';\n",
171
+ 'workspaces/api/bin/build.sh': `#!/usr/bin/env sh
172
+
173
+ set -e
174
+
175
+ scriptdir="$PWD/workspaces/api";
176
+
177
+ NODE_ENV=production npx webpack --config $scriptdir/webpack.config.ts
178
+
179
+ cp $scriptdir/package.json dist/api/package.json
180
+ npm pkg delete "type" --prefix dist/api
181
+ npm pkg delete "private" --prefix dist/api
182
+ `,
183
+ 'workspaces/api/bin/start.sh': `#!/usr/bin/env sh
184
+
185
+ set -e
186
+
187
+ scriptdir="$PWD/workspaces/api";
188
+
189
+ NODE_ENV=production LOG_LEVEL=info tsx $scriptdir/index.ts
190
+ `,
191
+ 'workspaces/api/doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
192
+ import ReadMe from './README.md?raw';
193
+
194
+ <Meta title="Workspaces/API" />
195
+
196
+ <Markdown>{ReadMe}</Markdown>
197
+ `,
198
+ 'workspaces/api/README.md': `# ${options.name} API\n\n${options.description}\n`,
199
+ 'workspaces/api/webpack.config.ts': `import { path } from '@vyriy/path';
200
+ import { ssr, external } from '@vyriy/webpack-config';
201
+
202
+ export default ssr(
203
+ '@w/api',
204
+ {
205
+ path: path('dist', 'api'),
206
+ filename: 'index.js',
207
+ library: { type: 'commonjs2' },
208
+ },
209
+ (config) => ({
210
+ ...config,
211
+ externals: [external({ allowlist: [/^@p/, /^@w/, /^@vyriy/] })],
212
+ }),
213
+ );
214
+ `,
215
+ 'workspaces/api/package.json': JSON.stringify({
216
+ name: '@w/api',
217
+ type: 'module',
218
+ private: true,
219
+ }, null, 2) + '\n',
13
220
  'workspaces/api/index.ts': `import { server } from '@vyriy/server';
14
221
  import { api } from '@vyriy/handler';
15
222
 
package/preset/base.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 base: Preset;
package/preset/base.js CHANGED
@@ -53,11 +53,118 @@ export const base = ({ name, description }) => ({
53
53
  'cross-env': packageJson.peerDependencies['cross-env'],
54
54
  },
55
55
  }, null, 2) + '\n',
56
- 'README.md': `# ${name}\n\n${description}\n`,
56
+ 'README.md': `# Base
57
+
58
+ Base is a minimal project preset for starting new applications, packages, or workspaces with a calm shared foundation already in place.
59
+
60
+ The repository intentionally contains configuration and workflow glue instead of product code. Its main entry point is Storybook: it works as both living documentation and a playground for future components, UI states, examples, and integration notes.
61
+
62
+ ## Why Storybook
63
+
64
+ Storybook is configured from the start so the project has a visible documentation surface before any application-specific structure exists.
65
+
66
+ Use it to:
67
+
68
+ - document project decisions and package APIs with MDX;
69
+ - develop and review future components in isolation;
70
+ - capture component states, variants, and edge cases as stories;
71
+ - build a static documentation site that can be shared or deployed;
72
+ - keep README-driven documentation visible inside the same developer UI.
73
+
74
+ The root \`doc.mdx\` renders this README in Storybook, so the project overview is available both in the repository and in the local documentation playground.
75
+
76
+ ## Included Foundation
77
+
78
+ - TypeScript configuration from \`@vyriy/typescript-config\`.
79
+ - ESLint configuration from \`@vyriy/eslint-config\`.
80
+ - Prettier configuration from \`@vyriy/prettier-config\`.
81
+ - Jest configuration from \`@vyriy/jest-config\`.
82
+ - Storybook configuration from \`@vyriy/storybook-config\`.
83
+ - Husky hooks for dependency refresh after branch changes or merges and quality checks before commit or push.
84
+
85
+ ## Requirements
86
+
87
+ - Node.js \`>=24.0.0\`.
88
+ - Yarn \`4.16.0\`.
89
+
90
+ ## Install
91
+
92
+ \`\`\`bash
93
+ yarn
94
+ \`\`\`
95
+
96
+ ## Commands
97
+
98
+ \`\`\`bash
99
+ yarn storybook
100
+ \`\`\`
101
+
102
+ Starts the local Storybook playground on port \`6006\`.
103
+
104
+ \`\`\`bash
105
+ yarn build
106
+ \`\`\`
107
+
108
+ Builds the static Storybook output.
109
+
110
+ \`\`\`bash
111
+ yarn check
112
+ \`\`\`
113
+
114
+ Runs the full project validation pipeline: \`lint\`, \`build\`, and \`test\`.
115
+
116
+ \`\`\`bash
117
+ yarn fix
118
+ \`\`\`
119
+
120
+ Formats the project and applies available ESLint fixes.
121
+
122
+ \`\`\`bash
123
+ yarn lint
124
+ \`\`\`
125
+
126
+ Checks TypeScript, formatting, and ESLint rules.
127
+
128
+ \`\`\`bash
129
+ yarn test
130
+ \`\`\`
131
+
132
+ Runs Jest. The command is allowed to pass in an empty preset before tests are added.
133
+
134
+ ## Structure
135
+
136
+ \`\`\`text
137
+ .
138
+ ├── .storybook/
139
+ │ ├── main.ts
140
+ │ └── preview.tsx
141
+ ├── .husky/
142
+ ├── doc.mdx
143
+ ├── eslint.config.ts
144
+ ├── jest.config.ts
145
+ ├── prettier.config.ts
146
+ ├── tsconfig.json
147
+ └── package.json
148
+ \`\`\`
149
+
150
+ ## Adding Project Code
151
+
152
+ Add source code where it fits the final project shape, for example under \`packages/*\` or \`workspaces/*\`. These paths are already included in \`tsconfig.json\`.
153
+
154
+ When adding public components or package APIs, add matching stories or MDX documentation so Storybook remains the first place to inspect behavior, examples, and supported states.
155
+
156
+ ## Project Guidance
157
+
158
+ These articles describe the development approach behind this preset and provide practical guidance for evolving a project on top of it:
159
+
160
+ - [Calm Development Environment: Node.js, Corepack, Yarn and Static Preview](https://vyriy.dev/blog/calm-development-setup/) - how to keep the local development environment predictable and easy to reproduce.
161
+ - [Calm Component Structure](https://vyriy.dev/blog/calm-component-structure/) - how to organize component code, tests, stories, and public exports.
162
+ - [Storybook as Project Documentation](https://vyriy.dev/blog/storybook-as-project-documentation/) - how to use Storybook as living project documentation and a component playground.
163
+ `,
57
164
  'doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
58
165
  import ReadMe from './README.md?raw';
59
166
 
60
- <Meta title="${name}" />
167
+ <Meta title="Base" />
61
168
 
62
169
  <Markdown>{ReadMe}</Markdown>
63
170
  `,