vyriy 0.3.9 → 0.4.0
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 +74 -179
- package/bin/vyriy.js +2 -2
- package/cli/args.js +29 -0
- package/cli/cli.d.ts +2 -2
- package/cli/cli.js +18 -69
- package/cli/index.d.ts +1 -1
- package/cli/index.js +1 -1
- package/cli/types.d.ts +12 -3
- package/commands/check-env.d.ts +2 -0
- package/commands/check-env.js +65 -0
- package/commands/create/index.d.ts +2 -0
- package/commands/create/index.js +121 -0
- package/commands/create/plan/index.d.ts +4 -0
- package/commands/create/plan/index.js +3 -0
- package/commands/create/plan/plan.d.ts +9 -0
- package/commands/create/plan/plan.js +34 -0
- package/commands/create/plan/question.d.ts +2 -0
- package/commands/create/plan/question.js +25 -0
- package/commands/create/plan/types.d.ts +14 -0
- package/commands/create/preset/api.d.ts +2 -0
- package/commands/create/preset/api.js +16 -0
- package/commands/create/preset/base.d.ts +2 -0
- package/commands/create/preset/base.js +195 -0
- package/commands/create/preset/gql.d.ts +2 -0
- package/commands/create/preset/gql.js +16 -0
- package/commands/create/preset/index.d.ts +12 -0
- package/commands/create/preset/index.js +14 -0
- package/commands/create/preset/library.d.ts +2 -0
- package/commands/create/preset/library.js +227 -0
- package/commands/create/preset/mfe.d.ts +2 -0
- package/commands/create/preset/mfe.js +16 -0
- package/commands/create/preset/rest.d.ts +2 -0
- package/commands/create/preset/rest.js +16 -0
- package/commands/create/preset/spa.d.ts +2 -0
- package/commands/create/preset/spa.js +16 -0
- package/commands/create/preset/ssg.d.ts +2 -0
- package/commands/create/preset/ssg.js +16 -0
- package/commands/create/preset/ssr.d.ts +2 -0
- package/commands/create/preset/ssr.js +16 -0
- package/commands/create/preset/types.d.ts +15 -0
- package/commands/create/prompt/conflict-strategy.d.ts +5 -0
- package/commands/create/prompt/conflict-strategy.js +22 -0
- package/commands/create/prompt/index.d.ts +7 -0
- package/commands/create/prompt/index.js +6 -0
- package/commands/create/prompt/preset.d.ts +4 -0
- package/commands/create/prompt/preset.js +11 -0
- package/commands/create/prompt/prompt.d.ts +2 -0
- package/commands/create/prompt/prompt.js +4 -0
- package/commands/create/prompt/provider.d.ts +2 -0
- package/commands/create/prompt/provider.js +13 -0
- package/commands/create/prompt/resolve-option.d.ts +6 -0
- package/commands/create/prompt/resolve-option.js +8 -0
- package/commands/create/prompt/scope.d.ts +2 -0
- package/commands/create/prompt/scope.js +2 -0
- package/commands/create/prompt/types.d.ts +4 -0
- package/commands/dist.d.ts +2 -0
- package/commands/{publish/publish.js → dist.js} +8 -8
- package/commands/help.d.ts +3 -0
- package/commands/help.js +24 -0
- package/commands/index.d.ts +5 -0
- package/commands/index.js +5 -0
- package/commands/{publish/types.d.ts → types.d.ts} +18 -4
- package/commands/version.d.ts +2 -0
- package/commands/version.js +6 -0
- package/package.json +280 -551
- package/checks/node/index.d.ts +0 -2
- package/checks/node/index.js +0 -1
- package/checks/node/node.d.ts +0 -2
- package/checks/node/node.js +0 -22
- package/checks/node/types.d.ts +0 -11
- package/checks/yarn/index.d.ts +0 -2
- package/checks/yarn/index.js +0 -1
- package/checks/yarn/types.d.ts +0 -7
- package/checks/yarn/yarn.d.ts +0 -2
- package/checks/yarn/yarn.js +0 -40
- package/cli/args/args.js +0 -40
- package/cli/args/index.d.ts +0 -2
- package/cli/args/index.js +0 -1
- package/cli/args/types.d.ts +0 -24
- package/commands/doctor/doctor.d.ts +0 -2
- package/commands/doctor/doctor.js +0 -9
- package/commands/doctor/index.d.ts +0 -2
- package/commands/doctor/index.js +0 -1
- package/commands/doctor/types.d.ts +0 -8
- package/commands/init/index.d.ts +0 -2
- package/commands/init/index.js +0 -1
- package/commands/init/init.d.ts +0 -2
- package/commands/init/init.js +0 -7
- package/commands/init/types.d.ts +0 -5
- package/commands/new/index.d.ts +0 -2
- package/commands/new/index.js +0 -1
- package/commands/new/new.d.ts +0 -3
- package/commands/new/new.js +0 -189
- package/commands/new/types.d.ts +0 -15
- package/commands/publish/index.d.ts +0 -2
- package/commands/publish/index.js +0 -1
- package/commands/publish/publish.d.ts +0 -2
- package/doctor/checkCorepack.d.ts +0 -2
- package/doctor/checkCorepack.js +0 -24
- package/doctor/checkGit.d.ts +0 -2
- package/doctor/checkGit.js +0 -23
- package/doctor/checkNodeVersion.d.ts +0 -5
- package/doctor/checkNodeVersion.js +0 -24
- package/doctor/checkYarn.d.ts +0 -10
- package/doctor/checkYarn.js +0 -45
- package/doctor/createDoctorReport.d.ts +0 -2
- package/doctor/createDoctorReport.js +0 -17
- package/doctor/index.d.ts +0 -7
- package/doctor/index.js +0 -6
- package/doctor/printDoctorReport.d.ts +0 -2
- package/doctor/printDoctorReport.js +0 -42
- package/doctor/types.d.ts +0 -25
- package/file-plan/createFilePlan.d.ts +0 -4
- package/file-plan/createFilePlan.js +0 -29
- package/file-plan/index.d.ts +0 -4
- package/file-plan/index.js +0 -3
- package/file-plan/printFilePlan.d.ts +0 -2
- package/file-plan/printFilePlan.js +0 -44
- package/file-plan/types.d.ts +0 -12
- package/file-plan/writeFilePlan.d.ts +0 -2
- package/file-plan/writeFilePlan.js +0 -12
- package/index.d.ts +0 -12
- package/index.js +0 -12
- package/presets/agentsTemplate.d.ts +0 -1
- package/presets/agentsTemplate.js +0 -105
- package/presets/base/createBaseFiles.d.ts +0 -3
- package/presets/base/createBaseFiles.js +0 -307
- package/presets/config.d.ts +0 -28
- package/presets/config.js +0 -7
- package/presets/createProjectFiles.d.ts +0 -2
- package/presets/createProjectFiles.js +0 -8
- package/presets/index.d.ts +0 -2
- package/presets/index.js +0 -1
- package/presets/library/createLibraryUiFiles.d.ts +0 -3
- package/presets/library/createLibraryUiFiles.js +0 -127
- package/presets/packages/createPackageFiles.d.ts +0 -3
- package/presets/packages/createPackageFiles.js +0 -39
- package/presets/packages/createPackageManifest.d.ts +0 -7
- package/presets/packages/createPackageManifest.js +0 -13
- package/presets/types.d.ts +0 -3
- package/presets/workspaces/createWorkspaceFiles.d.ts +0 -3
- package/presets/workspaces/createWorkspaceFiles.js +0 -98
- package/project-plan/api/api.d.ts +0 -6
- package/project-plan/api/api.js +0 -44
- package/project-plan/api/index.d.ts +0 -2
- package/project-plan/api/index.js +0 -1
- package/project-plan/api/types.d.ts +0 -11
- package/project-plan/ci/ci.d.ts +0 -3
- package/project-plan/ci/ci.js +0 -20
- package/project-plan/ci/index.d.ts +0 -2
- package/project-plan/ci/index.js +0 -1
- package/project-plan/ci/types.d.ts +0 -6
- package/project-plan/create/create.d.ts +0 -2
- package/project-plan/create/create.js +0 -129
- package/project-plan/create/index.d.ts +0 -2
- package/project-plan/create/index.js +0 -1
- package/project-plan/create/types.d.ts +0 -13
- package/project-plan/index.d.ts +0 -6
- package/project-plan/index.js +0 -5
- package/project-plan/kind/index.d.ts +0 -2
- package/project-plan/kind/index.js +0 -1
- package/project-plan/kind/kind.d.ts +0 -2
- package/project-plan/kind/kind.js +0 -1
- package/project-plan/kind/types.d.ts +0 -2
- package/project-plan/print/index.d.ts +0 -2
- package/project-plan/print/index.js +0 -1
- package/project-plan/print/print.d.ts +0 -2
- package/project-plan/print/print.js +0 -47
- package/project-plan/print/types.d.ts +0 -2
- package/project-plan/types.d.ts +0 -46
- package/prompts/project-plan/index.d.ts +0 -2
- package/prompts/project-plan/index.js +0 -1
- package/prompts/project-plan/project-plan.d.ts +0 -2
- package/prompts/project-plan/project-plan.js +0 -198
- package/prompts/project-plan/types.d.ts +0 -18
- package/shared/commandExists.d.ts +0 -2
- package/shared/commandExists.js +0 -10
- package/shared/execCommand.d.ts +0 -2
- package/shared/execCommand.js +0 -7
- package/shared/fileExists.d.ts +0 -2
- package/shared/fileExists.js +0 -10
- package/shared/index.d.ts +0 -6
- package/shared/index.js +0 -5
- package/shared/runCommand.d.ts +0 -9
- package/shared/runCommand.js +0 -34
- package/shared/semver.d.ts +0 -1
- package/shared/semver.js +0 -4
- package/shared/types.d.ts +0 -12
- /package/cli/{args/args.d.ts → args.d.ts} +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const plan: (dirName: string, appPath: string) => Promise<{
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
target: string;
|
|
5
|
+
preset: "base" | "library";
|
|
6
|
+
scope: string | undefined;
|
|
7
|
+
ci: import("../preset/types.js").CiProvider | undefined;
|
|
8
|
+
deploy: import("../preset/types.js").DeployProvider | undefined;
|
|
9
|
+
} | undefined>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { stdin, stdout } from 'node:process';
|
|
2
|
+
import { createInterface } from 'node:readline';
|
|
3
|
+
import { presets as appPreset } from '../preset/index.js';
|
|
4
|
+
import { prompt, provider as promptProvider, preset as promptPreset, scope as promptScope } from '../prompt/index.js';
|
|
5
|
+
import { question as createQuestion } from './question.js';
|
|
6
|
+
export const plan = async (dirName, appPath) => {
|
|
7
|
+
const readline = createInterface({ input: stdin, output: stdout });
|
|
8
|
+
const question = createQuestion(readline, stdout);
|
|
9
|
+
try {
|
|
10
|
+
stdout.write('\nVyriy Project Master\n\n');
|
|
11
|
+
const name = await prompt(question, 'Project name', dirName);
|
|
12
|
+
const description = await prompt(question, 'Project description', 'Calm cloud-ready application');
|
|
13
|
+
const target = await prompt(question, 'Target directory', appPath);
|
|
14
|
+
const preset = await promptPreset(question, stdout);
|
|
15
|
+
const scope = await promptScope(question, preset, name);
|
|
16
|
+
const ci = await promptProvider(question, stdout, 'CI/CD provider', appPreset[preset].preset.ci);
|
|
17
|
+
const deploy = await promptProvider(question, stdout, 'Deploy provider', appPreset[preset].preset.deploy);
|
|
18
|
+
const confirmation = (await prompt(question, 'Use this project plan?', 'y')).toLowerCase();
|
|
19
|
+
return confirmation === 'y'
|
|
20
|
+
? {
|
|
21
|
+
name,
|
|
22
|
+
description,
|
|
23
|
+
target,
|
|
24
|
+
preset,
|
|
25
|
+
scope,
|
|
26
|
+
ci,
|
|
27
|
+
deploy,
|
|
28
|
+
}
|
|
29
|
+
: undefined;
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
readline.close();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const question = (readline, output) => {
|
|
2
|
+
const queuedLines = [];
|
|
3
|
+
const pendingQuestions = [];
|
|
4
|
+
readline.on('line', (line) => {
|
|
5
|
+
const resolve = pendingQuestions.shift();
|
|
6
|
+
if (resolve) {
|
|
7
|
+
resolve(line);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
queuedLines.push(line);
|
|
11
|
+
});
|
|
12
|
+
readline.on('close', () => {
|
|
13
|
+
for (const resolve of pendingQuestions.splice(0)) {
|
|
14
|
+
resolve('');
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return (query) => {
|
|
18
|
+
output.write(query);
|
|
19
|
+
const queuedLine = queuedLines.shift();
|
|
20
|
+
if (queuedLine !== undefined) {
|
|
21
|
+
return Promise.resolve(queuedLine);
|
|
22
|
+
}
|
|
23
|
+
return new Promise((resolve) => pendingQuestions.push(resolve));
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Interface } from 'node:readline';
|
|
2
|
+
import type { Writable } from 'node:stream';
|
|
3
|
+
export type Question = (readline: Interface, output: Writable) => (query: string) => Promise<string>;
|
|
4
|
+
export type Prompt = (question: (query: string) => Promise<string>, label: string, defaultValue: string) => Promise<string>;
|
|
5
|
+
export type PlanResult = {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
target: string;
|
|
9
|
+
preset: string;
|
|
10
|
+
scope?: string;
|
|
11
|
+
ci?: string;
|
|
12
|
+
deploy?: string;
|
|
13
|
+
};
|
|
14
|
+
export type Plan = (dirName: string, appPath: string) => Promise<PlanResult | undefined>;
|
|
@@ -0,0 +1,195 @@
|
|
|
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') : '';
|
|
11
|
+
export const base = {
|
|
12
|
+
files: ({ name, description }) => ({
|
|
13
|
+
'package.json': JSON.stringify({
|
|
14
|
+
name,
|
|
15
|
+
version: '0.0.0',
|
|
16
|
+
description,
|
|
17
|
+
private: true,
|
|
18
|
+
type: 'module',
|
|
19
|
+
agents: './AGENTS.md',
|
|
20
|
+
packageManager: packageJson.packageManager,
|
|
21
|
+
engines: {
|
|
22
|
+
node: packageJson.engines.node,
|
|
23
|
+
},
|
|
24
|
+
scripts: {
|
|
25
|
+
storybook: 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook dev -p 6006 --disable-telemetry',
|
|
26
|
+
check: 'run-s lint build test',
|
|
27
|
+
fix: "run-s 'fix:*'",
|
|
28
|
+
lint: "run-s 'lint:*'",
|
|
29
|
+
build: "run-s 'build:*'",
|
|
30
|
+
test: "run-s 'test:*'",
|
|
31
|
+
'fix:prettier': 'prettier . --write',
|
|
32
|
+
'fix:eslint': 'eslint . --fix',
|
|
33
|
+
'lint:ts': 'tsc',
|
|
34
|
+
'lint:prettier': 'prettier . --check',
|
|
35
|
+
'lint:eslint': 'eslint .',
|
|
36
|
+
'build:storybook': 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook build --quiet --disable-telemetry',
|
|
37
|
+
'test:jest': 'jest --passWithNoTests',
|
|
38
|
+
postinstall: 'husky',
|
|
39
|
+
},
|
|
40
|
+
dependencies: {
|
|
41
|
+
'@vyriy/typescript-config': `^${packageJson.version}`,
|
|
42
|
+
typescript: packageJson.peerDependencies.typescript,
|
|
43
|
+
'@vyriy/prettier-config': `^${packageJson.version}`,
|
|
44
|
+
prettier: packageJson.peerDependencies.prettier,
|
|
45
|
+
'@vyriy/eslint-config': `^${packageJson.version}`,
|
|
46
|
+
eslint: packageJson.peerDependencies.eslint,
|
|
47
|
+
'@vyriy/jest-config': `^${packageJson.version}`,
|
|
48
|
+
jest: packageJson.peerDependencies.jest,
|
|
49
|
+
'@vyriy/storybook-config': `^${packageJson.version}`,
|
|
50
|
+
storybook: packageJson.peerDependencies.storybook,
|
|
51
|
+
'@vyriy/path': `^${packageJson.version}`,
|
|
52
|
+
husky: packageJson.peerDependencies.husky,
|
|
53
|
+
'npm-run-all2': packageJson.peerDependencies['npm-run-all2'],
|
|
54
|
+
'cross-env': packageJson.peerDependencies['cross-env'],
|
|
55
|
+
},
|
|
56
|
+
}, null, 2),
|
|
57
|
+
'README.md': `# ${name}\n\n${description}`,
|
|
58
|
+
'doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
|
|
59
|
+
import ReadMe from './README.md?raw';
|
|
60
|
+
|
|
61
|
+
<Meta title="${name}" />
|
|
62
|
+
|
|
63
|
+
<Markdown>{ReadMe}</Markdown>
|
|
64
|
+
`,
|
|
65
|
+
'AGENTS.md': agentsContent,
|
|
66
|
+
'.editorconfig': `# https://editorconfig.org
|
|
67
|
+
root = true
|
|
68
|
+
|
|
69
|
+
[*]
|
|
70
|
+
charset = utf-8
|
|
71
|
+
end_of_line = lf
|
|
72
|
+
insert_final_newline = true
|
|
73
|
+
trim_trailing_whitespace = true
|
|
74
|
+
|
|
75
|
+
indent_style = space
|
|
76
|
+
indent_size = 2
|
|
77
|
+
|
|
78
|
+
max_line_length = 100
|
|
79
|
+
|
|
80
|
+
# Markdown
|
|
81
|
+
[*.md]
|
|
82
|
+
trim_trailing_whitespace = false
|
|
83
|
+
max_line_length = off
|
|
84
|
+
|
|
85
|
+
# YAML / YML
|
|
86
|
+
[*.{yml,yaml}]
|
|
87
|
+
indent_size = 2
|
|
88
|
+
|
|
89
|
+
# JSON
|
|
90
|
+
[*.json]
|
|
91
|
+
indent_size = 2
|
|
92
|
+
|
|
93
|
+
# TypeScript / JavaScript
|
|
94
|
+
[*.{ts,tsx,js,jsx}]
|
|
95
|
+
indent_size = 2
|
|
96
|
+
|
|
97
|
+
# Shell / Bash
|
|
98
|
+
[*.sh]
|
|
99
|
+
indent_size = 2
|
|
100
|
+
`,
|
|
101
|
+
'.gitignore': `.yarn/*
|
|
102
|
+
!.yarn/cache
|
|
103
|
+
!.yarn/patches
|
|
104
|
+
!.yarn/plugins
|
|
105
|
+
!.yarn/releases
|
|
106
|
+
!.yarn/sdks
|
|
107
|
+
!.yarn/versions
|
|
108
|
+
|
|
109
|
+
.DS_Store
|
|
110
|
+
.idea
|
|
111
|
+
node_modules
|
|
112
|
+
coverage
|
|
113
|
+
dist
|
|
114
|
+
storybook-static
|
|
115
|
+
*storybook.log
|
|
116
|
+
consumer
|
|
117
|
+
|
|
118
|
+
cdk.out
|
|
119
|
+
cdk.context.json
|
|
120
|
+
|
|
121
|
+
!/**/.gitkeep
|
|
122
|
+
`,
|
|
123
|
+
'.npmrc': 'engine-strict=true\n',
|
|
124
|
+
'.nvmrc': 'lts/krypton\n',
|
|
125
|
+
'.yarnrc.yml': 'nodeLinker: node-modules\nnpmMinimalAgeGate: 0\n',
|
|
126
|
+
'.husky/commit-msg': '#!/bin/sh\n',
|
|
127
|
+
'.husky/post-checkout': '#!/bin/sh\n\nyarn\n',
|
|
128
|
+
'.husky/post-merge': '#!/bin/sh\n\nyarn\n',
|
|
129
|
+
'.husky/pre-commit': '#!/bin/sh\n\nyarn check\n',
|
|
130
|
+
'.husky/pre-push': '#!/bin/sh\n\nyarn check\n',
|
|
131
|
+
'.storybook/main.ts': `import config from '@vyriy/storybook-config';
|
|
132
|
+
import { path } from '@vyriy/path';
|
|
133
|
+
|
|
134
|
+
export default {
|
|
135
|
+
...config,
|
|
136
|
+
stories: [
|
|
137
|
+
path('**/*.mdx'),
|
|
138
|
+
path('**/*.stories.@(js|jsx|mjs|ts|tsx)'),
|
|
139
|
+
],
|
|
140
|
+
};
|
|
141
|
+
`,
|
|
142
|
+
'.storybook/preview.tsx': "export { default } from '@vyriy/storybook-config/preview';\n",
|
|
143
|
+
'yarn.lock': '',
|
|
144
|
+
'tsconfig.json': JSON.stringify({
|
|
145
|
+
extends: '@vyriy/typescript-config/index.json',
|
|
146
|
+
include: [
|
|
147
|
+
'.storybook/**/*.ts',
|
|
148
|
+
'.storybook/**/*.tsx',
|
|
149
|
+
'packages/**/*.ts',
|
|
150
|
+
'packages/**/*.tsx',
|
|
151
|
+
'workspaces/**/*.ts',
|
|
152
|
+
'workspaces/**/*.tsx',
|
|
153
|
+
'*.ts',
|
|
154
|
+
],
|
|
155
|
+
}, null, 2),
|
|
156
|
+
'prettier.config.ts': "export { default } from '@vyriy/prettier-config';\n",
|
|
157
|
+
'.prettierignore': 'node_modules\ndist\ncoverage\nstorybook-static\n',
|
|
158
|
+
'eslint.config.ts': "export { default } from '@vyriy/eslint-config';\n",
|
|
159
|
+
'jest.config.ts': "export { default } from '@vyriy/jest-config';\n",
|
|
160
|
+
}),
|
|
161
|
+
ci: {
|
|
162
|
+
gitlab: {
|
|
163
|
+
'.gitlab-ci.yml': `image: node:24
|
|
164
|
+
|
|
165
|
+
code:
|
|
166
|
+
script:
|
|
167
|
+
- corepack enable
|
|
168
|
+
- yarn install
|
|
169
|
+
- yarn check
|
|
170
|
+
`,
|
|
171
|
+
},
|
|
172
|
+
github: {
|
|
173
|
+
'.github/workflows/code.yml': `name: code
|
|
174
|
+
|
|
175
|
+
on:
|
|
176
|
+
push:
|
|
177
|
+
pull_request:
|
|
178
|
+
|
|
179
|
+
jobs:
|
|
180
|
+
code:
|
|
181
|
+
runs-on: ubuntu-latest
|
|
182
|
+
steps:
|
|
183
|
+
- uses: actions/checkout@v4
|
|
184
|
+
- uses: actions/setup-node@v4
|
|
185
|
+
with:
|
|
186
|
+
node-version: 24
|
|
187
|
+
- run: |
|
|
188
|
+
corepack enable
|
|
189
|
+
yarn install
|
|
190
|
+
yarn check
|
|
191
|
+
`,
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
deploy: {},
|
|
195
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { base } from './base.js';
|
|
2
|
+
import { library } from './library.js';
|
|
3
|
+
export const presets = {
|
|
4
|
+
base: {
|
|
5
|
+
name: 'Base',
|
|
6
|
+
description: 'Only configuration',
|
|
7
|
+
preset: base,
|
|
8
|
+
},
|
|
9
|
+
library: {
|
|
10
|
+
name: 'Library',
|
|
11
|
+
description: 'Preset to generate JS/React library',
|
|
12
|
+
preset: library,
|
|
13
|
+
},
|
|
14
|
+
};
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import packageJson from '../../../package.json' with { type: 'json' };
|
|
2
|
+
import { base } from './base.js';
|
|
3
|
+
export const library = {
|
|
4
|
+
files: (options) => {
|
|
5
|
+
const packageScope = options.scope ?? `@${options.name}`;
|
|
6
|
+
const packageName = `${packageScope}/${options.name}`;
|
|
7
|
+
return {
|
|
8
|
+
...base.files(options),
|
|
9
|
+
'package.json': JSON.stringify({
|
|
10
|
+
name: options.name,
|
|
11
|
+
version: '0.0.0',
|
|
12
|
+
description: options.description,
|
|
13
|
+
private: true,
|
|
14
|
+
type: 'module',
|
|
15
|
+
agents: './AGENTS.md',
|
|
16
|
+
packageManager: packageJson.packageManager,
|
|
17
|
+
engines: {
|
|
18
|
+
node: packageJson.engines.node,
|
|
19
|
+
},
|
|
20
|
+
workspaces: [
|
|
21
|
+
'packages/*',
|
|
22
|
+
],
|
|
23
|
+
license: 'MIT',
|
|
24
|
+
repository: {
|
|
25
|
+
type: 'git',
|
|
26
|
+
url: `https://github.com/${options.name}/${options.name}`,
|
|
27
|
+
},
|
|
28
|
+
scripts: {
|
|
29
|
+
storybook: 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook dev -p 6006 --disable-telemetry',
|
|
30
|
+
check: 'run-s lint build test',
|
|
31
|
+
fix: "run-s 'fix:*'",
|
|
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:dist': 'rimraf dist && tsc -p tsconfig.build.json && vyriy -d',
|
|
43
|
+
'build:storybook': 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook build --quiet --disable-telemetry',
|
|
44
|
+
'test:jest': 'jest',
|
|
45
|
+
postinstall: 'husky',
|
|
46
|
+
},
|
|
47
|
+
devDependencies: {
|
|
48
|
+
'@vyriy/typescript-config': `^${packageJson.version}`,
|
|
49
|
+
typescript: packageJson.peerDependencies.typescript,
|
|
50
|
+
'@vyriy/prettier-config': `^${packageJson.version}`,
|
|
51
|
+
prettier: packageJson.peerDependencies.prettier,
|
|
52
|
+
'@vyriy/eslint-config': `^${packageJson.version}`,
|
|
53
|
+
eslint: packageJson.peerDependencies.eslint,
|
|
54
|
+
'@vyriy/jest-config': `^${packageJson.version}`,
|
|
55
|
+
jest: packageJson.peerDependencies.jest,
|
|
56
|
+
'@vyriy/storybook-config': `^${packageJson.version}`,
|
|
57
|
+
storybook: packageJson.peerDependencies.storybook,
|
|
58
|
+
'@vyriy/path': `^${packageJson.version}`,
|
|
59
|
+
vyriy: `^${packageJson.version}`,
|
|
60
|
+
husky: packageJson.peerDependencies.husky,
|
|
61
|
+
'npm-run-all2': packageJson.peerDependencies['npm-run-all2'],
|
|
62
|
+
'cross-env': packageJson.peerDependencies['cross-env'],
|
|
63
|
+
react: packageJson.peerDependencies.react,
|
|
64
|
+
'react-dom': packageJson.peerDependencies['react-dom'],
|
|
65
|
+
'@types/react': packageJson.peerDependencies['@types/react'],
|
|
66
|
+
'@types/react-dom': packageJson.peerDependencies['@types/react-dom'],
|
|
67
|
+
'@vyriy/stylelint-config': `^${packageJson.version}`,
|
|
68
|
+
stylelint: packageJson.peerDependencies.stylelint,
|
|
69
|
+
rimraf: packageJson.peerDependencies.rimraf,
|
|
70
|
+
},
|
|
71
|
+
}, null, 2),
|
|
72
|
+
'tsconfig.build.json': JSON.stringify({
|
|
73
|
+
extends: './tsconfig.json',
|
|
74
|
+
include: [
|
|
75
|
+
'packages/**/*.ts',
|
|
76
|
+
'packages/**/*.tsx',
|
|
77
|
+
'packages/**/*.json',
|
|
78
|
+
],
|
|
79
|
+
exclude: [
|
|
80
|
+
'**/*.test.ts',
|
|
81
|
+
'**/*.test.tsx',
|
|
82
|
+
'**/*.stories.ts',
|
|
83
|
+
'**/*.stories.tsx',
|
|
84
|
+
],
|
|
85
|
+
compilerOptions: {
|
|
86
|
+
rootDir: './packages',
|
|
87
|
+
outDir: './dist',
|
|
88
|
+
noEmit: false,
|
|
89
|
+
declaration: true,
|
|
90
|
+
allowImportingTsExtensions: false,
|
|
91
|
+
},
|
|
92
|
+
}, null, 2),
|
|
93
|
+
'stylelint.config.ts': "export { default } from '@vyriy/stylelint-config';\n",
|
|
94
|
+
[`packages/${options.name}/package.json`]: JSON.stringify({
|
|
95
|
+
name: packageName,
|
|
96
|
+
version: '0.0.0',
|
|
97
|
+
description: options.description,
|
|
98
|
+
private: true,
|
|
99
|
+
type: 'module',
|
|
100
|
+
main: 'index.js',
|
|
101
|
+
dependencies: {
|
|
102
|
+
'@vyriy/cn': `^${packageJson.version}`,
|
|
103
|
+
},
|
|
104
|
+
peerDependencies: {
|
|
105
|
+
react: packageJson.peerDependencies.react,
|
|
106
|
+
},
|
|
107
|
+
}, null, 2),
|
|
108
|
+
[`packages/${options.name}/README.md`]: `# ${packageName}\n\n${options.description}\n`,
|
|
109
|
+
[`packages/${options.name}/doc.mdx`]: `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
|
|
110
|
+
import ReadMe from './README.md?raw';
|
|
111
|
+
|
|
112
|
+
<Meta title="UI/Button" />
|
|
113
|
+
|
|
114
|
+
<Markdown>{ReadMe}</Markdown>
|
|
115
|
+
`,
|
|
116
|
+
[`packages/${options.name}/index.ts`]: "export * from './button.js';\nexport type * from './types.js';\n",
|
|
117
|
+
[`packages/${options.name}/types.ts`]: `import type { ComponentProps, FC } from 'react';
|
|
118
|
+
|
|
119
|
+
export type ButtonProps = ComponentProps<'button'> & {
|
|
120
|
+
readonly variant?: 'primary' | 'secondary';
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export type ButtonType = FC<ButtonProps>;
|
|
124
|
+
`,
|
|
125
|
+
[`packages/${options.name}/button.tsx`]: `import { cn } from '@vyriy/cn';
|
|
126
|
+
|
|
127
|
+
import type { ButtonType } from './types.js';
|
|
128
|
+
|
|
129
|
+
import './button.scss';
|
|
130
|
+
|
|
131
|
+
export const Button: ButtonType = ({ className, type = 'button', variant = 'primary', ...props }) => (
|
|
132
|
+
<button className={cn('button', \`button--\${variant}\`, className)} type={type} {...props} />
|
|
133
|
+
);
|
|
134
|
+
`,
|
|
135
|
+
[`packages/${options.name}/index.test.ts`]: `import { describe, expect, it } from '@jest/globals';
|
|
136
|
+
|
|
137
|
+
import { Button } from './button.js';
|
|
138
|
+
import { Button as PublicButton } from './index.js';
|
|
139
|
+
|
|
140
|
+
describe('ui entry point', () => {
|
|
141
|
+
it('exports Button', () => {
|
|
142
|
+
expect(PublicButton).toBe(Button);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
`,
|
|
146
|
+
[`packages/${options.name}/button.scss`]: `.button {
|
|
147
|
+
border: 1px solid transparent;
|
|
148
|
+
border-radius: 6px;
|
|
149
|
+
cursor: pointer;
|
|
150
|
+
font: inherit;
|
|
151
|
+
padding: 0.5rem 0.875rem;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.button--primary {
|
|
155
|
+
background: #1f6feb;
|
|
156
|
+
color: #fff;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.button--secondary {
|
|
160
|
+
background: #fff;
|
|
161
|
+
border-color: #d0d7de;
|
|
162
|
+
color: #24292f;
|
|
163
|
+
}
|
|
164
|
+
`,
|
|
165
|
+
[`packages/${options.name}/styles.d.ts`]: "declare module '*.scss';\n",
|
|
166
|
+
[`packages/${options.name}/button.stories.tsx`]: `import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
167
|
+
|
|
168
|
+
import { Button } from './button.js';
|
|
169
|
+
|
|
170
|
+
const meta = {
|
|
171
|
+
title: 'UI/Button',
|
|
172
|
+
component: Button,
|
|
173
|
+
args: {
|
|
174
|
+
children: 'Button',
|
|
175
|
+
},
|
|
176
|
+
} satisfies Meta<typeof Button>;
|
|
177
|
+
|
|
178
|
+
export default meta;
|
|
179
|
+
|
|
180
|
+
type Story = StoryObj<typeof meta>;
|
|
181
|
+
|
|
182
|
+
export const Primary: Story = {};
|
|
183
|
+
|
|
184
|
+
export const Secondary: Story = {
|
|
185
|
+
args: {
|
|
186
|
+
variant: 'secondary',
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
`,
|
|
190
|
+
[`packages/${options.name}/button.test.tsx`]: `import type { ReactElement } from 'react';
|
|
191
|
+
import { describe, expect, it } from '@jest/globals';
|
|
192
|
+
|
|
193
|
+
import { Button } from './button.js';
|
|
194
|
+
|
|
195
|
+
type ButtonElement = ReactElement<{
|
|
196
|
+
readonly className: string;
|
|
197
|
+
readonly type: string;
|
|
198
|
+
}>;
|
|
199
|
+
|
|
200
|
+
describe('Button', () => {
|
|
201
|
+
it('creates a primary button by default', () => {
|
|
202
|
+
const element = Button({ children: 'Save' }) as ButtonElement;
|
|
203
|
+
|
|
204
|
+
expect(element.props.className).toBe('button button--primary');
|
|
205
|
+
expect(element.props.type).toBe('button');
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('composes secondary and custom classes', () => {
|
|
209
|
+
const element = Button({
|
|
210
|
+
children: 'Cancel',
|
|
211
|
+
className: 'wide',
|
|
212
|
+
type: 'submit',
|
|
213
|
+
variant: 'secondary',
|
|
214
|
+
}) as ButtonElement;
|
|
215
|
+
|
|
216
|
+
expect(element.props.className).toBe('button button--secondary wide');
|
|
217
|
+
expect(element.props.type).toBe('submit');
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
`,
|
|
221
|
+
};
|
|
222
|
+
},
|
|
223
|
+
ci: {
|
|
224
|
+
...base.ci,
|
|
225
|
+
},
|
|
226
|
+
deploy: {},
|
|
227
|
+
};
|