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
package/presets/config.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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 {};
|
package/presets/config.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { createBaseFiles } from './base/createBaseFiles.js';
|
|
2
|
-
import { createPackageFiles } from './packages/createPackageFiles.js';
|
|
3
|
-
import { createWorkspaceFiles } from './workspaces/createWorkspaceFiles.js';
|
|
4
|
-
export const createProjectFiles = (plan) => [
|
|
5
|
-
...createBaseFiles(plan),
|
|
6
|
-
...plan.packages.flatMap((packagePlan) => createPackageFiles(plan, packagePlan)),
|
|
7
|
-
...plan.workspaces.flatMap((workspacePlan) => createWorkspaceFiles(plan, workspacePlan)),
|
|
8
|
-
];
|
package/presets/index.d.ts
DELETED
package/presets/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './createProjectFiles.js';
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { packageVersion, peerDependencies, publishedPackageJson } from '../config.js';
|
|
2
|
-
import { createPackageManifest } from '../packages/createPackageManifest.js';
|
|
3
|
-
export const createLibraryUiFiles = (plan, packagePlan) => [
|
|
4
|
-
createPackageManifest({
|
|
5
|
-
dependencies: {
|
|
6
|
-
'@vyriy/cn': packageVersion(publishedPackageJson.version),
|
|
7
|
-
},
|
|
8
|
-
packageScope: plan.packageScope,
|
|
9
|
-
peerDependencies: {
|
|
10
|
-
react: peerDependencies.react,
|
|
11
|
-
},
|
|
12
|
-
workspaceName: packagePlan.name,
|
|
13
|
-
}),
|
|
14
|
-
{
|
|
15
|
-
path: `packages/${packagePlan.name}/README.md`,
|
|
16
|
-
content: `# ${plan.packageScope}/${packagePlan.name}\n\n${plan.description}\n`,
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
path: `packages/${packagePlan.name}/index.ts`,
|
|
20
|
-
content: "export * from './button.js';\n",
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
path: `packages/${packagePlan.name}/button.tsx`,
|
|
24
|
-
content: `import type { ComponentProps, FC } from 'react';
|
|
25
|
-
import { cn } from '@vyriy/cn';
|
|
26
|
-
|
|
27
|
-
import './button.scss';
|
|
28
|
-
|
|
29
|
-
export type ButtonProps = ComponentProps<'button'> & {
|
|
30
|
-
readonly variant?: 'primary' | 'secondary';
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export type ButtonType = FC<ButtonProps>;
|
|
34
|
-
|
|
35
|
-
export const Button: ButtonType = ({ className, type = 'button', variant = 'primary', ...props }) => (
|
|
36
|
-
<button className={cn('button', \`button--\${variant}\`, className)} type={type} {...props} />
|
|
37
|
-
);
|
|
38
|
-
`,
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
path: `packages/${packagePlan.name}/button.scss`,
|
|
42
|
-
content: `.button {
|
|
43
|
-
border: 1px solid transparent;
|
|
44
|
-
border-radius: 6px;
|
|
45
|
-
cursor: pointer;
|
|
46
|
-
font: inherit;
|
|
47
|
-
padding: 0.5rem 0.875rem;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.button--primary {
|
|
51
|
-
background: #1f6feb;
|
|
52
|
-
color: #fff;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.button--secondary {
|
|
56
|
-
background: #fff;
|
|
57
|
-
border-color: #d0d7de;
|
|
58
|
-
color: #24292f;
|
|
59
|
-
}
|
|
60
|
-
`,
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
path: `packages/${packagePlan.name}/styles.d.ts`,
|
|
64
|
-
content: "declare module '*.scss';\n",
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
path: `packages/${packagePlan.name}/button.stories.tsx`,
|
|
68
|
-
content: `import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
69
|
-
|
|
70
|
-
import { Button } from './button.js';
|
|
71
|
-
|
|
72
|
-
const meta = {
|
|
73
|
-
title: 'UI/Button',
|
|
74
|
-
component: Button,
|
|
75
|
-
args: {
|
|
76
|
-
children: 'Button',
|
|
77
|
-
},
|
|
78
|
-
} satisfies Meta<typeof Button>;
|
|
79
|
-
|
|
80
|
-
export default meta;
|
|
81
|
-
|
|
82
|
-
type Story = StoryObj<typeof meta>;
|
|
83
|
-
|
|
84
|
-
export const Primary: Story = {};
|
|
85
|
-
|
|
86
|
-
export const Secondary: Story = {
|
|
87
|
-
args: {
|
|
88
|
-
variant: 'secondary',
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
`,
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
path: `packages/${packagePlan.name}/button.test.tsx`,
|
|
95
|
-
content: `import type { ReactElement } from 'react';
|
|
96
|
-
import { describe, expect, it } from '@jest/globals';
|
|
97
|
-
|
|
98
|
-
import { Button } from './button.js';
|
|
99
|
-
|
|
100
|
-
type ButtonElement = ReactElement<{
|
|
101
|
-
readonly className: string;
|
|
102
|
-
readonly type: string;
|
|
103
|
-
}>;
|
|
104
|
-
|
|
105
|
-
describe('Button', () => {
|
|
106
|
-
it('creates a primary button by default', () => {
|
|
107
|
-
const element = Button({ children: 'Save' }) as ButtonElement;
|
|
108
|
-
|
|
109
|
-
expect(element.props.className).toBe('button button--primary');
|
|
110
|
-
expect(element.props.type).toBe('button');
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('composes secondary and custom classes', () => {
|
|
114
|
-
const element = Button({
|
|
115
|
-
children: 'Cancel',
|
|
116
|
-
className: 'wide',
|
|
117
|
-
type: 'submit',
|
|
118
|
-
variant: 'secondary',
|
|
119
|
-
}) as ButtonElement;
|
|
120
|
-
|
|
121
|
-
expect(element.props.className).toBe('button button--secondary wide');
|
|
122
|
-
expect(element.props.type).toBe('submit');
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
`,
|
|
126
|
-
},
|
|
127
|
-
];
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { createLibraryUiFiles } from '../library/createLibraryUiFiles.js';
|
|
2
|
-
import { createPackageManifest } from './createPackageManifest.js';
|
|
3
|
-
const createGenericPackageFiles = (plan, packagePlan) => [
|
|
4
|
-
createPackageManifest({
|
|
5
|
-
packageScope: plan.packageScope,
|
|
6
|
-
workspaceName: packagePlan.name,
|
|
7
|
-
}),
|
|
8
|
-
{
|
|
9
|
-
path: `packages/${packagePlan.name}/README.md`,
|
|
10
|
-
content: `# ${plan.packageScope}/${packagePlan.name}\n\n${plan.description}\n`,
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
path: `packages/${packagePlan.name}/index.ts`,
|
|
14
|
-
content: packagePlan.kind === 'stack' ? "export * from './stack.js';\n" : "export type * from './types.js';\n",
|
|
15
|
-
},
|
|
16
|
-
...(packagePlan.kind === 'stack'
|
|
17
|
-
? [
|
|
18
|
-
{
|
|
19
|
-
path: `packages/${packagePlan.name}/stack.ts`,
|
|
20
|
-
content: 'export type StackName = string;\n',
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
path: `packages/${packagePlan.name}/stack.test.ts`,
|
|
24
|
-
content: "import { describe, expect, it } from '@jest/globals';\n\ndescribe('stack', () => {\n it('has a test harness', () => {\n expect(true).toBe(true);\n });\n});\n",
|
|
25
|
-
},
|
|
26
|
-
]
|
|
27
|
-
: [
|
|
28
|
-
{
|
|
29
|
-
path: `packages/${packagePlan.name}/types.ts`,
|
|
30
|
-
content: 'export type PackageName = string;\n',
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
path: `packages/${packagePlan.name}/${packagePlan.name}.test.ts`,
|
|
34
|
-
content: "import { describe, expect, it } from '@jest/globals';\n\ndescribe('package', () => {\n it('has a test harness', () => {\n expect(true).toBe(true);\n });\n});\n",
|
|
35
|
-
},
|
|
36
|
-
]),
|
|
37
|
-
];
|
|
38
|
-
const createPresetPackageFiles = (plan, packagePlan) => plan.preset === 'library' && packagePlan.kind === 'ui' ? createLibraryUiFiles(plan, packagePlan) : undefined;
|
|
39
|
-
export const createPackageFiles = (plan, packagePlan) => createPresetPackageFiles(plan, packagePlan) ?? createGenericPackageFiles(plan, packagePlan);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ProjectFile } from '../../file-plan/index.js';
|
|
2
|
-
export declare const createPackageManifest: ({ dependencies, packageScope, peerDependencies, workspaceName, }: {
|
|
3
|
-
readonly dependencies?: Record<string, string>;
|
|
4
|
-
readonly packageScope: string;
|
|
5
|
-
readonly peerDependencies?: Record<string, string>;
|
|
6
|
-
readonly workspaceName: string;
|
|
7
|
-
}) => ProjectFile;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { json } from '../config.js';
|
|
2
|
-
export const createPackageManifest = ({ dependencies = {}, packageScope, peerDependencies = {}, workspaceName, }) => ({
|
|
3
|
-
path: `packages/${workspaceName}/package.json`,
|
|
4
|
-
content: json({
|
|
5
|
-
name: `${packageScope}/${workspaceName}`,
|
|
6
|
-
version: '0.0.0',
|
|
7
|
-
private: true,
|
|
8
|
-
type: 'module',
|
|
9
|
-
main: 'index.js',
|
|
10
|
-
...(Object.keys(dependencies).length > 0 ? { dependencies } : {}),
|
|
11
|
-
...(Object.keys(peerDependencies).length > 0 ? { peerDependencies } : {}),
|
|
12
|
-
}),
|
|
13
|
-
});
|
package/presets/types.d.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { json, packageVersion, publishedPackageJson } from '../config.js';
|
|
2
|
-
const getWorkspacePath = (workspacePlan) => workspacePlan.kind === 'lambda' && workspacePlan.name === 'api'
|
|
3
|
-
? `workspaces/lambda/${workspacePlan.name}`
|
|
4
|
-
: `workspaces/${workspacePlan.name}`;
|
|
5
|
-
const getWorkspacePackageName = ({ packageScope, workspacePlan, }) => workspacePlan.kind === 'lambda' && workspacePlan.name === 'api'
|
|
6
|
-
? `${packageScope}/lambda-api-workspace`
|
|
7
|
-
: `${packageScope}/${workspacePlan.name}-workspace`;
|
|
8
|
-
const isApiWorkspace = (workspacePlan) => [
|
|
9
|
-
'api',
|
|
10
|
-
'lambda',
|
|
11
|
-
'fargate',
|
|
12
|
-
].includes(workspacePlan.kind);
|
|
13
|
-
const createApiWorkspaceDependencies = (workspacePlan) => isApiWorkspace(workspacePlan)
|
|
14
|
-
? {
|
|
15
|
-
'@vyriy/handler': packageVersion(publishedPackageJson.version),
|
|
16
|
-
'@vyriy/server': packageVersion(publishedPackageJson.version),
|
|
17
|
-
}
|
|
18
|
-
: {};
|
|
19
|
-
const createApiHandlerFile = (workspacePath) => ({
|
|
20
|
-
path: `${workspacePath}/handler.ts`,
|
|
21
|
-
content: `import { api } from '@vyriy/handler';
|
|
22
|
-
|
|
23
|
-
export const handler = api(async (event) => ({
|
|
24
|
-
statusCode: 200,
|
|
25
|
-
body: JSON.stringify({
|
|
26
|
-
path: event.path,
|
|
27
|
-
}),
|
|
28
|
-
}));
|
|
29
|
-
`,
|
|
30
|
-
});
|
|
31
|
-
const createApiServerFile = ({ entrypoint, workspacePath, }) => ({
|
|
32
|
-
path: `${workspacePath}/${entrypoint}`,
|
|
33
|
-
content: `import { server } from '@vyriy/server';
|
|
34
|
-
|
|
35
|
-
import { handler } from './handler.js';
|
|
36
|
-
|
|
37
|
-
server(handler);
|
|
38
|
-
`,
|
|
39
|
-
});
|
|
40
|
-
const createDockerfile = (workspacePath) => ({
|
|
41
|
-
path: `${workspacePath}/Dockerfile`,
|
|
42
|
-
content: `FROM node:24-alpine
|
|
43
|
-
|
|
44
|
-
WORKDIR /app
|
|
45
|
-
|
|
46
|
-
COPY package.json yarn.lock .yarnrc.yml ./
|
|
47
|
-
COPY .yarn ./.yarn
|
|
48
|
-
COPY packages ./packages
|
|
49
|
-
COPY workspaces ./workspaces
|
|
50
|
-
|
|
51
|
-
RUN corepack enable && yarn install --immutable
|
|
52
|
-
RUN yarn build
|
|
53
|
-
|
|
54
|
-
CMD ["node", "workspaces/api/index.js"]
|
|
55
|
-
`,
|
|
56
|
-
});
|
|
57
|
-
const createApiWorkspaceFiles = (plan, workspacePlan) => {
|
|
58
|
-
const workspacePath = getWorkspacePath(workspacePlan);
|
|
59
|
-
const isLambda = workspacePlan.kind === 'lambda';
|
|
60
|
-
return [
|
|
61
|
-
createApiHandlerFile(workspacePath),
|
|
62
|
-
createApiServerFile({ entrypoint: isLambda ? 'server.ts' : 'index.ts', workspacePath }),
|
|
63
|
-
{
|
|
64
|
-
path: `${workspacePath}/${workspacePlan.name}.test.ts`,
|
|
65
|
-
content: "import { describe, expect, it } from '@jest/globals';\n\nimport { handler } from './handler.js';\n\ndescribe('api workspace', () => {\n it('exports a handler', () => {\n expect(handler).toEqual(expect.any(Function));\n });\n});\n",
|
|
66
|
-
},
|
|
67
|
-
...(plan.features.includes('docker') && !isLambda ? [createDockerfile(workspacePath)] : []),
|
|
68
|
-
];
|
|
69
|
-
};
|
|
70
|
-
export const createWorkspaceFiles = (plan, workspacePlan) => {
|
|
71
|
-
const workspacePath = getWorkspacePath(workspacePlan);
|
|
72
|
-
const dependencies = createApiWorkspaceDependencies(workspacePlan);
|
|
73
|
-
return [
|
|
74
|
-
{
|
|
75
|
-
path: `${workspacePath}/package.json`,
|
|
76
|
-
content: json({
|
|
77
|
-
name: getWorkspacePackageName({ packageScope: plan.packageScope, workspacePlan }),
|
|
78
|
-
version: '0.0.0',
|
|
79
|
-
private: true,
|
|
80
|
-
type: 'module',
|
|
81
|
-
main: workspacePlan.kind === 'lambda' ? 'server.js' : 'index.js',
|
|
82
|
-
...(Object.keys(dependencies).length > 0 ? { dependencies } : {}),
|
|
83
|
-
}),
|
|
84
|
-
},
|
|
85
|
-
...(isApiWorkspace(workspacePlan)
|
|
86
|
-
? createApiWorkspaceFiles(plan, workspacePlan)
|
|
87
|
-
: [
|
|
88
|
-
{
|
|
89
|
-
path: `${workspacePath}/index.ts`,
|
|
90
|
-
content: 'export type WorkspaceName = string;\n',
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
path: `${workspacePath}/${workspacePlan.name}.test.ts`,
|
|
94
|
-
content: "import { describe, expect, it } from '@jest/globals';\n\ndescribe('workspace', () => {\n it('has a test harness', () => {\n expect(true).toBe(true);\n });\n});\n",
|
|
95
|
-
},
|
|
96
|
-
]),
|
|
97
|
-
];
|
|
98
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { CreateApiPlan, GetApiRuntimeFromPreset, GetDefaultApiStyleFromPreset, GetFeaturesFromApiPlan, IsApiPreset } from './types.js';
|
|
2
|
-
export declare const isApiPreset: IsApiPreset;
|
|
3
|
-
export declare const getApiRuntimeFromPreset: GetApiRuntimeFromPreset;
|
|
4
|
-
export declare const getDefaultApiStyleFromPreset: GetDefaultApiStyleFromPreset;
|
|
5
|
-
export declare const getFeaturesFromApiPlan: GetFeaturesFromApiPlan;
|
|
6
|
-
export declare const createApiPlan: CreateApiPlan;
|
package/project-plan/api/api.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
const apiPresets = [
|
|
2
|
-
'api',
|
|
3
|
-
'fullstack',
|
|
4
|
-
'mfe',
|
|
5
|
-
];
|
|
6
|
-
export const isApiPreset = (preset) => apiPresets.includes(preset);
|
|
7
|
-
export const getApiRuntimeFromPreset = () => 'docker';
|
|
8
|
-
export const getDefaultApiStyleFromPreset = () => 'rest';
|
|
9
|
-
export const getFeaturesFromApiPlan = (api) => {
|
|
10
|
-
if (!api) {
|
|
11
|
-
return [];
|
|
12
|
-
}
|
|
13
|
-
return api.style === 'rest' ? ['rest-api'] : ['graphql-api'];
|
|
14
|
-
};
|
|
15
|
-
export const createApiPlan = ({ preset, runtime = getApiRuntimeFromPreset(preset), style = getDefaultApiStyleFromPreset(preset), }) => {
|
|
16
|
-
if (!isApiPreset(preset)) {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
const basePlan = {
|
|
20
|
-
enabled: true,
|
|
21
|
-
style,
|
|
22
|
-
runtime,
|
|
23
|
-
};
|
|
24
|
-
const restPlan = {
|
|
25
|
-
rest: {
|
|
26
|
-
router: 'vyriy-router',
|
|
27
|
-
packageName: '@vyriy/router',
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
const graphqlPlan = {
|
|
31
|
-
graphql: {
|
|
32
|
-
packageName: 'graphql',
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
return style === 'rest'
|
|
36
|
-
? {
|
|
37
|
-
...basePlan,
|
|
38
|
-
...restPlan,
|
|
39
|
-
}
|
|
40
|
-
: {
|
|
41
|
-
...basePlan,
|
|
42
|
-
...graphqlPlan,
|
|
43
|
-
};
|
|
44
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './api.js';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { VyriyApiPlan, VyriyApiRuntime, VyriyApiStyle, VyriyFeature, VyriyPreset } from '../types.js';
|
|
2
|
-
export type CreateApiPlanOptions = {
|
|
3
|
-
readonly preset: VyriyPreset;
|
|
4
|
-
readonly runtime?: VyriyApiRuntime;
|
|
5
|
-
readonly style?: VyriyApiStyle;
|
|
6
|
-
};
|
|
7
|
-
export type CreateApiPlan = (options: CreateApiPlanOptions) => VyriyApiPlan | undefined;
|
|
8
|
-
export type IsApiPreset = (preset: VyriyPreset) => boolean;
|
|
9
|
-
export type GetApiRuntimeFromPreset = (preset: VyriyPreset) => VyriyApiRuntime;
|
|
10
|
-
export type GetDefaultApiStyleFromPreset = (preset: VyriyPreset) => VyriyApiStyle;
|
|
11
|
-
export type GetFeaturesFromApiPlan = (api: VyriyApiPlan | undefined) => VyriyFeature[];
|
package/project-plan/ci/ci.d.ts
DELETED
package/project-plan/ci/ci.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export const defaultValidationPipelines = [
|
|
2
|
-
'install',
|
|
3
|
-
'lint',
|
|
4
|
-
'test',
|
|
5
|
-
'build',
|
|
6
|
-
'deploy',
|
|
7
|
-
'smoke',
|
|
8
|
-
'e2e',
|
|
9
|
-
];
|
|
10
|
-
export const createCiPlan = ({ provider = 'none' } = {}) => provider === 'none'
|
|
11
|
-
? {
|
|
12
|
-
enabled: false,
|
|
13
|
-
providers: [],
|
|
14
|
-
pipelines: [],
|
|
15
|
-
}
|
|
16
|
-
: {
|
|
17
|
-
enabled: true,
|
|
18
|
-
providers: [provider],
|
|
19
|
-
pipelines: [...defaultValidationPipelines],
|
|
20
|
-
};
|
package/project-plan/ci/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './ci.js';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { VyriyCiPlan, VyriyCiProvider } from '../types.js';
|
|
2
|
-
export type VyriyCiPromptProvider = 'none' | VyriyCiProvider;
|
|
3
|
-
export type CreateCiPlanOptions = {
|
|
4
|
-
readonly provider?: VyriyCiPromptProvider;
|
|
5
|
-
};
|
|
6
|
-
export type CreateCiPlan = (options?: CreateCiPlanOptions) => VyriyCiPlan;
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { createApiPlan, getFeaturesFromApiPlan } from '../api/index.js';
|
|
2
|
-
import { createCiPlan } from '../ci/index.js';
|
|
3
|
-
import { getProjectKindFromPreset } from '../kind/index.js';
|
|
4
|
-
const baseFeatures = [
|
|
5
|
-
'typescript',
|
|
6
|
-
'eslint',
|
|
7
|
-
'prettier',
|
|
8
|
-
'jest',
|
|
9
|
-
'storybook',
|
|
10
|
-
];
|
|
11
|
-
const presetFeatures = {
|
|
12
|
-
empty: [],
|
|
13
|
-
library: ['react'],
|
|
14
|
-
api: [],
|
|
15
|
-
csr: ['react', 'webpack'],
|
|
16
|
-
ssr: ['react', 'webpack'],
|
|
17
|
-
ssg: ['react', 'webpack'],
|
|
18
|
-
fullstack: ['react', 'webpack'],
|
|
19
|
-
mfe: ['react', 'webpack', 'openmfe'],
|
|
20
|
-
};
|
|
21
|
-
const packagePlans = {
|
|
22
|
-
empty: [],
|
|
23
|
-
library: [{ name: 'ui', kind: 'ui', publishable: true }],
|
|
24
|
-
api: [{ name: 'api', kind: 'api', publishable: false }],
|
|
25
|
-
csr: [
|
|
26
|
-
{ name: 'app', kind: 'app', publishable: false },
|
|
27
|
-
{ name: 'ui', kind: 'ui', publishable: true },
|
|
28
|
-
],
|
|
29
|
-
ssr: [
|
|
30
|
-
{ name: 'app', kind: 'app', publishable: false },
|
|
31
|
-
{ name: 'ui', kind: 'ui', publishable: true },
|
|
32
|
-
{ name: 'ssr', kind: 'app', publishable: false },
|
|
33
|
-
],
|
|
34
|
-
ssg: [
|
|
35
|
-
{ name: 'app', kind: 'app', publishable: false },
|
|
36
|
-
{ name: 'ui', kind: 'ui', publishable: true },
|
|
37
|
-
{ name: 'ssg', kind: 'app', publishable: false },
|
|
38
|
-
{ name: 'content', kind: 'utils', publishable: false },
|
|
39
|
-
],
|
|
40
|
-
fullstack: [
|
|
41
|
-
{ name: 'app', kind: 'app', publishable: false },
|
|
42
|
-
{ name: 'ui', kind: 'ui', publishable: true },
|
|
43
|
-
{ name: 'api', kind: 'api', publishable: false },
|
|
44
|
-
],
|
|
45
|
-
mfe: [
|
|
46
|
-
{ name: 'mfe', kind: 'app', publishable: false },
|
|
47
|
-
{ name: 'ui', kind: 'ui', publishable: true },
|
|
48
|
-
{ name: 'api', kind: 'api', publishable: false },
|
|
49
|
-
{ name: 'openmfe-contract', kind: 'config', publishable: true },
|
|
50
|
-
],
|
|
51
|
-
};
|
|
52
|
-
const workspacePlans = {
|
|
53
|
-
empty: [],
|
|
54
|
-
library: [],
|
|
55
|
-
api: [{ name: 'api', kind: 'api' }],
|
|
56
|
-
csr: [{ name: 'web', kind: 'ui' }],
|
|
57
|
-
ssr: [
|
|
58
|
-
{ name: 'ssr', kind: 'ui' },
|
|
59
|
-
{ name: 'web', kind: 'ui' },
|
|
60
|
-
],
|
|
61
|
-
ssg: [
|
|
62
|
-
{ name: 'ssg', kind: 'ui' },
|
|
63
|
-
{ name: 'web', kind: 'ui' },
|
|
64
|
-
],
|
|
65
|
-
fullstack: [
|
|
66
|
-
{ name: 'web', kind: 'ui' },
|
|
67
|
-
{ name: 'api', kind: 'api' },
|
|
68
|
-
],
|
|
69
|
-
mfe: [
|
|
70
|
-
{ name: 'mfe', kind: 'ui' },
|
|
71
|
-
{ name: 'api', kind: 'api' },
|
|
72
|
-
],
|
|
73
|
-
};
|
|
74
|
-
const uniqueFeatures = (features) => [...new Set(features)];
|
|
75
|
-
const getApiRuntimeFromFeatures = (features) => features.includes('lambda') ? 'lambda' : 'docker';
|
|
76
|
-
const awsInfrastructureFeatures = [
|
|
77
|
-
'aws-cdk',
|
|
78
|
-
'lambda',
|
|
79
|
-
'fargate',
|
|
80
|
-
's3',
|
|
81
|
-
'cloudfront',
|
|
82
|
-
];
|
|
83
|
-
const getApiWorkspaceKindFromFeatures = (features) => {
|
|
84
|
-
if (features.includes('lambda')) {
|
|
85
|
-
return 'lambda';
|
|
86
|
-
}
|
|
87
|
-
if (features.includes('fargate')) {
|
|
88
|
-
return 'fargate';
|
|
89
|
-
}
|
|
90
|
-
return 'api';
|
|
91
|
-
};
|
|
92
|
-
const createWorkspacePlans = ({ features, preset, }) => {
|
|
93
|
-
const apiWorkspaceKind = getApiWorkspaceKindFromFeatures(features);
|
|
94
|
-
const workspaces = workspacePlans[preset].map((workspacePlan) => workspacePlan.name === 'api'
|
|
95
|
-
? {
|
|
96
|
-
...workspacePlan,
|
|
97
|
-
kind: apiWorkspaceKind,
|
|
98
|
-
}
|
|
99
|
-
: workspacePlan);
|
|
100
|
-
if (features.some((feature) => awsInfrastructureFeatures.includes(feature))) {
|
|
101
|
-
return [
|
|
102
|
-
...workspaces,
|
|
103
|
-
{ name: 'stack', kind: 'stack' },
|
|
104
|
-
];
|
|
105
|
-
}
|
|
106
|
-
return workspaces;
|
|
107
|
-
};
|
|
108
|
-
export const createProjectPlanFromPreset = ({ description, apiStyle, ciProvider, features = [], packageScope, preset, projectName, targetDirectory, }) => {
|
|
109
|
-
const api = createApiPlan({ preset, runtime: getApiRuntimeFromFeatures(features), style: apiStyle });
|
|
110
|
-
const apiFeatures = getFeaturesFromApiPlan(api);
|
|
111
|
-
return {
|
|
112
|
-
projectName,
|
|
113
|
-
targetDirectory,
|
|
114
|
-
packageScope,
|
|
115
|
-
description,
|
|
116
|
-
preset,
|
|
117
|
-
projectKind: getProjectKindFromPreset(preset),
|
|
118
|
-
features: uniqueFeatures([
|
|
119
|
-
...baseFeatures,
|
|
120
|
-
...presetFeatures[preset],
|
|
121
|
-
...apiFeatures,
|
|
122
|
-
...features,
|
|
123
|
-
]),
|
|
124
|
-
packages: [...packagePlans[preset]],
|
|
125
|
-
workspaces: createWorkspacePlans({ features, preset }),
|
|
126
|
-
ci: createCiPlan({ provider: ciProvider }),
|
|
127
|
-
...(api ? { api } : {}),
|
|
128
|
-
};
|
|
129
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './create.js';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { VyriyApiStyle, VyriyFeature, VyriyPreset, VyriyProjectPlan } from '../types.js';
|
|
2
|
-
import { VyriyCiPromptProvider } from '../ci/index.js';
|
|
3
|
-
export type CreateProjectPlanFromPresetOptions = {
|
|
4
|
-
readonly projectName: string;
|
|
5
|
-
readonly targetDirectory: string;
|
|
6
|
-
readonly packageScope: string;
|
|
7
|
-
readonly description: string;
|
|
8
|
-
readonly preset: VyriyPreset;
|
|
9
|
-
readonly features?: readonly VyriyFeature[];
|
|
10
|
-
readonly apiStyle?: VyriyApiStyle;
|
|
11
|
-
readonly ciProvider?: VyriyCiPromptProvider;
|
|
12
|
-
};
|
|
13
|
-
export type CreateProjectPlanFromPreset = (options: CreateProjectPlanFromPresetOptions) => VyriyProjectPlan;
|
package/project-plan/index.d.ts
DELETED
package/project-plan/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './kind.js';
|