vyriy 0.3.8 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/cli/args/args.js +2 -0
- package/cli/args/types.d.ts +1 -1
- package/cli/cli.js +5 -0
- package/commands/publish/index.d.ts +2 -0
- package/commands/publish/index.js +1 -0
- package/commands/publish/publish.d.ts +2 -0
- package/commands/publish/publish.js +274 -0
- package/commands/publish/types.d.ts +31 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +149 -1
- package/presets/base/createBaseFiles.d.ts +3 -0
- package/presets/base/createBaseFiles.js +307 -0
- package/presets/config.d.ts +28 -0
- package/presets/config.js +7 -0
- package/presets/createProjectFiles.js +4 -404
- package/presets/library/createLibraryUiFiles.d.ts +3 -0
- package/presets/library/createLibraryUiFiles.js +127 -0
- package/presets/packages/createPackageFiles.d.ts +3 -0
- package/presets/packages/createPackageFiles.js +39 -0
- package/presets/packages/createPackageManifest.d.ts +7 -0
- package/presets/packages/createPackageManifest.js +13 -0
- package/presets/workspaces/createWorkspaceFiles.d.ts +3 -0
- package/presets/workspaces/createWorkspaceFiles.js +98 -0
- package/prompts/project-plan/project-plan.js +10 -6
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
};
|
|
@@ -169,12 +169,16 @@ export const askProjectPlan = async ({ defaults = {}, input = stdin, output = st
|
|
|
169
169
|
output.write(' 3. github\n');
|
|
170
170
|
const defaultCiProvider = defaults.ciProvider ?? 'none';
|
|
171
171
|
const ciProvider = parseCiProvider(await promptWithDefault(question, 'CI/CD provider number or name', defaultCiProvider), defaultCiProvider);
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
172
|
+
const features = isApiPreset(preset)
|
|
173
|
+
? await (async () => {
|
|
174
|
+
output.write('\nInfrastructure:\n');
|
|
175
|
+
output.write(' 1. Docker\n');
|
|
176
|
+
output.write(' 2. AWS\n');
|
|
177
|
+
const defaultInfrastructure = getDefaultInfrastructureInput(defaults.features);
|
|
178
|
+
const featuresAnswer = await promptWithDefault(question, 'Infrastructure number or name', defaultInfrastructure);
|
|
179
|
+
return parseInfrastructure(featuresAnswer, defaultInfrastructure);
|
|
180
|
+
})()
|
|
181
|
+
: [];
|
|
178
182
|
const plan = createProjectPlanFromPreset({
|
|
179
183
|
projectName,
|
|
180
184
|
targetDirectory,
|