create-fs-app 3.0.0 → 3.2.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 +40 -30
- package/dist/cli/output.js +3 -2
- package/dist/cli/program.js +3 -1
- package/dist/cli/resolve-config.js +2 -1
- package/dist/cli/ui/layer-log.js +6 -2
- package/dist/cli/wizard.js +9 -3
- package/dist/core/auth/jwt.js +2 -2
- package/dist/core/health-check.js +7 -3
- package/dist/core/registry.fallback.json +314 -72
- package/dist/core/scaffold.js +4 -3
- package/dist/core/template-clone.js +16 -5
- package/dist/core/template-registry.js +23 -0
- package/dist/core/welcome.js +260 -0
- package/dist/index.js +2 -2
- package/dist/types/index.js +1 -0
- package/package.json +24 -12
- package/welcome/dist/OFL-BarlowCondensed.txt +93 -0
- package/welcome/dist/cfa-welcome-display.woff2 +0 -0
- package/welcome/dist/cfa-welcome.js +114 -0
package/dist/core/scaffold.js
CHANGED
|
@@ -14,6 +14,7 @@ import { tarballUrl } from './download.js';
|
|
|
14
14
|
import { getCacheEntry } from './template-cache.js';
|
|
15
15
|
import { cloneTemplate, customizeTemplate, initializeGit, installDependencies, } from './template-clone.js';
|
|
16
16
|
import { CliError } from '../utils/cli-error.js';
|
|
17
|
+
import { supportsWelcome } from './welcome.js';
|
|
17
18
|
/** Thrown when dependency installation fails; the project itself was created. */
|
|
18
19
|
export class InstallError extends CliError {
|
|
19
20
|
constructor(details) {
|
|
@@ -52,8 +53,8 @@ export async function planScaffold(config, options = {}) {
|
|
|
52
53
|
? template.key
|
|
53
54
|
: `${template.url ?? 'unknown'}${template.subfolder ? ` (${template.subfolder})` : ''}`;
|
|
54
55
|
return {
|
|
55
|
-
// A template without Docker files has nothing to keep
|
|
56
|
-
config: template.supports.docker
|
|
56
|
+
// A template without Docker files has nothing to keep; one without welcome data keeps its start page
|
|
57
|
+
config: { ...config, docker: config.docker && template.supports.docker, welcome: config.welcome && supportsWelcome(template) },
|
|
57
58
|
targetDir: path.join(options.cwd ?? process.cwd(), config.name),
|
|
58
59
|
template,
|
|
59
60
|
templateLabel,
|
|
@@ -83,7 +84,7 @@ export async function scaffoldProject(plan, hooks = {}) {
|
|
|
83
84
|
const source = await cloneTemplate(plan.template, targetDir, { noCache: plan.noCache });
|
|
84
85
|
done('copy', source);
|
|
85
86
|
start('customize');
|
|
86
|
-
await customizeTemplate(targetDir, config, { kind: plan.kind });
|
|
87
|
+
await customizeTemplate(targetDir, config, { kind: plan.kind, template: plan.template });
|
|
87
88
|
done('customize');
|
|
88
89
|
}
|
|
89
90
|
catch (error) {
|
|
@@ -8,6 +8,7 @@ import { run } from '../utils/exec.js';
|
|
|
8
8
|
import { downloadTemplate } from './download.js';
|
|
9
9
|
import { getTemplateFromCache } from './template-cache.js';
|
|
10
10
|
import { describeJwtAuth, generateJwtAuth, jwtFiles, supportsAuth } from './auth/jwt.js';
|
|
11
|
+
import { applyWelcome, supportsWelcome, welcomeEntry, welcomeFiles } from './welcome.js';
|
|
11
12
|
/**
|
|
12
13
|
* Copy a template into `targetDir` (which must not exist):
|
|
13
14
|
* local path → copy; otherwise cache (24 h) → tarball download.
|
|
@@ -93,7 +94,11 @@ export async function customizeTemplate(targetDir, config, options) {
|
|
|
93
94
|
}
|
|
94
95
|
await generateJwtAuth(targetDir, backend, config.packageManager);
|
|
95
96
|
}
|
|
96
|
-
// 6.
|
|
97
|
+
// 6. Welcome page (official and contributed only; after auth, so it lists the auth routes)
|
|
98
|
+
if (!custom && config.welcome && options.template) {
|
|
99
|
+
await applyWelcome(targetDir, config, options.template);
|
|
100
|
+
}
|
|
101
|
+
// 7. pnpm needs "workspace:*" for local packages (templates ship npm-style "*")
|
|
97
102
|
if (config.packageManager === 'pnpm') {
|
|
98
103
|
await fixWorkspaceProtocol(targetDir);
|
|
99
104
|
}
|
|
@@ -101,7 +106,7 @@ export async function customizeTemplate(targetDir, config, options) {
|
|
|
101
106
|
/**
|
|
102
107
|
* The changes customizeTemplate will make, for --dry-run.
|
|
103
108
|
*/
|
|
104
|
-
export function describeCustomizations(config, kind) {
|
|
109
|
+
export function describeCustomizations(config, kind, template) {
|
|
105
110
|
const custom = kind === 'custom';
|
|
106
111
|
const actions = [];
|
|
107
112
|
actions.push(custom
|
|
@@ -129,13 +134,16 @@ export function describeCustomizations(config, kind) {
|
|
|
129
134
|
if (!custom && config.auth === 'jwt' && supportsAuth(backend)) {
|
|
130
135
|
actions.push(...describeJwtAuth(backend));
|
|
131
136
|
}
|
|
137
|
+
if (!custom && config.welcome && template && supportsWelcome(template)) {
|
|
138
|
+
actions.push(`Use the welcome page as the start page (${welcomeEntry(template)}), which checks the frontend, backend and database`);
|
|
139
|
+
}
|
|
132
140
|
return actions;
|
|
133
141
|
}
|
|
134
142
|
/**
|
|
135
143
|
* Files customizeTemplate adds and removes (project-relative POSIX paths), for
|
|
136
144
|
* --dry-run. Removed paths are candidates: a template may not have them all.
|
|
137
145
|
*/
|
|
138
|
-
export function plannedFileChanges(config, kind) {
|
|
146
|
+
export function plannedFileChanges(config, kind, template) {
|
|
139
147
|
const custom = kind === 'custom';
|
|
140
148
|
const added = [];
|
|
141
149
|
const removed = [];
|
|
@@ -153,6 +161,8 @@ export function plannedFileChanges(config, kind) {
|
|
|
153
161
|
const backend = config.stack?.backend;
|
|
154
162
|
if (config.auth === 'jwt' && supportsAuth(backend))
|
|
155
163
|
added.push(...jwtFiles(backend));
|
|
164
|
+
if (config.welcome && template && supportsWelcome(template))
|
|
165
|
+
added.push(...welcomeFiles(template));
|
|
156
166
|
}
|
|
157
167
|
return { added, removed };
|
|
158
168
|
}
|
|
@@ -250,7 +260,8 @@ async function updatePackageJson(targetDir, config, custom) {
|
|
|
250
260
|
*
|
|
251
261
|
* All templates → sharp, unrs-resolver, esbuild
|
|
252
262
|
* Prisma templates → @prisma/engines, prisma
|
|
253
|
-
* NestJS templates → @nestjs/core, @scarf/scarf (NestJS telemetry)
|
|
263
|
+
* NestJS templates → @nestjs/core, @scarf/scarf (NestJS telemetry), @swc/core (decorator
|
|
264
|
+
* metadata for the backend tests)
|
|
254
265
|
*/
|
|
255
266
|
export function buildAllowList(config) {
|
|
256
267
|
const list = ['sharp', 'unrs-resolver', 'esbuild'];
|
|
@@ -258,7 +269,7 @@ export function buildAllowList(config) {
|
|
|
258
269
|
list.push('@prisma/engines', 'prisma');
|
|
259
270
|
}
|
|
260
271
|
if (config.stack?.backend === 'nest.js') {
|
|
261
|
-
list.push('@nestjs/core', '@scarf/scarf');
|
|
272
|
+
list.push('@nestjs/core', '@scarf/scarf', '@swc/core');
|
|
262
273
|
}
|
|
263
274
|
return list;
|
|
264
275
|
}
|
|
@@ -47,6 +47,26 @@ export const LayersSchema = z.object({
|
|
|
47
47
|
orm: LayerSchema,
|
|
48
48
|
database: LayerSchema,
|
|
49
49
|
});
|
|
50
|
+
/** What the welcome page (core/welcome.ts) shows beyond the layers; checked against the files by validate-registry. */
|
|
51
|
+
export const WelcomeSchema = z.object({
|
|
52
|
+
health: z.string().min(1),
|
|
53
|
+
/** Route the page calls to see whether the backend reaches the database. */
|
|
54
|
+
probe: z.string().min(1),
|
|
55
|
+
/** API docs path (NestJS Swagger), null when the backend has none. */
|
|
56
|
+
docs: z.string().min(1).nullable(),
|
|
57
|
+
routesFile: z.string().min(1),
|
|
58
|
+
routes: z.array(z.tuple([z.string().min(1), z.string().min(1)])),
|
|
59
|
+
schema: z.string().min(1),
|
|
60
|
+
/** Backend script that creates the tables on first run, null when the backend does it itself. */
|
|
61
|
+
setup: z.string().min(1).nullable(),
|
|
62
|
+
database: z.object({
|
|
63
|
+
service: z.string().min(1).optional(),
|
|
64
|
+
env: z.string().min(1),
|
|
65
|
+
file: z.string().min(1).optional(),
|
|
66
|
+
/** The backend waits for the database before it listens (NestJS + Mongoose). */
|
|
67
|
+
blocksStart: z.boolean().optional(),
|
|
68
|
+
}),
|
|
69
|
+
});
|
|
50
70
|
export const RegistryEntrySchema = z.object({
|
|
51
71
|
id: z.string().optional(),
|
|
52
72
|
description: z.string().min(1),
|
|
@@ -58,6 +78,8 @@ export const RegistryEntrySchema = z.object({
|
|
|
58
78
|
node: z.string().min(1).optional(),
|
|
59
79
|
/** Layer data for the layer log (required for official entries by validate-registry). */
|
|
60
80
|
layers: LayersSchema.optional(),
|
|
81
|
+
/** Welcome page data (required for official entries by validate-registry). */
|
|
82
|
+
welcome: WelcomeSchema.optional(),
|
|
61
83
|
});
|
|
62
84
|
export const ContributedEntrySchema = RegistryEntrySchema.extend({
|
|
63
85
|
contributor: ContributorSchema,
|
|
@@ -93,6 +115,7 @@ export function toTemplates(registry, options = {}) {
|
|
|
93
115
|
stack: entry.stack,
|
|
94
116
|
node: entry.node,
|
|
95
117
|
layers: entry.layers,
|
|
118
|
+
welcome: entry.welcome,
|
|
96
119
|
};
|
|
97
120
|
if (options.localDir) {
|
|
98
121
|
return { ...base, localPath: path.join(options.localDir, relative) };
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The welcome page: <cfa-welcome> as the generated project's start page.
|
|
3
|
+
*
|
|
4
|
+
* The element (welcome/src/cfa-welcome.ts, built into welcome/dist/ by
|
|
5
|
+
* scripts/build-welcome.mjs) ships inside the CLI package, so a project gets
|
|
6
|
+
* the page that matches the CLI version that made it. applyWelcome() copies it
|
|
7
|
+
* into apps/frontend/src/cfa-welcome/, writes stack.ts (what the page shows,
|
|
8
|
+
* from the registry's layers and welcome data plus the chosen options) and
|
|
9
|
+
* replaces the start page and its test. --no-welcome skips all of it and the
|
|
10
|
+
* template's own start page stays.
|
|
11
|
+
*/
|
|
12
|
+
import fs from 'fs/promises';
|
|
13
|
+
import { existsSync } from 'fs';
|
|
14
|
+
import path from 'path';
|
|
15
|
+
import { fileURLToPath } from 'url';
|
|
16
|
+
import { Logger } from '../utils/logger.js';
|
|
17
|
+
/** welcome/dist/ of the CLI package (the same path from src/core/ and dist/core/). */
|
|
18
|
+
export const WELCOME_DIST = fileURLToPath(new URL('../../welcome/dist/', import.meta.url));
|
|
19
|
+
const WELCOME_FILES = ['cfa-welcome.js', 'cfa-welcome-display.woff2', 'OFL-BarlowCondensed.txt'];
|
|
20
|
+
/** Folder inside the frontend that holds the element, its types and stack.ts. */
|
|
21
|
+
const WELCOME_FOLDER = 'src/cfa-welcome';
|
|
22
|
+
const NEXT_PAGE = ({ api }) => `"use client";
|
|
23
|
+
|
|
24
|
+
// The start page create-fs-app made for this project: it checks that the
|
|
25
|
+
// frontend, the backend and the database are connected. To use your own page,
|
|
26
|
+
// replace this file; src/cfa-welcome/ can then be deleted.
|
|
27
|
+
import "../cfa-welcome/cfa-welcome.js";
|
|
28
|
+
import { stack } from "../cfa-welcome/stack";
|
|
29
|
+
|
|
30
|
+
const API = process.env.NEXT_PUBLIC_API_URL ?? "${api}";
|
|
31
|
+
|
|
32
|
+
// <cfa-welcome> is a custom element. Typing it here, instead of in React's JSX
|
|
33
|
+
// namespace, works whichever copy of @types/react the build picks up.
|
|
34
|
+
const CfaWelcome = "cfa-welcome" as unknown as (props: { api: string; stack: string }) => null;
|
|
35
|
+
|
|
36
|
+
export default function Home() {
|
|
37
|
+
return <CfaWelcome api={API} stack={JSON.stringify(stack)} />;
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
const REACT_PAGE = ({ api }) => `// The start page create-fs-app made for this project: it checks that the
|
|
41
|
+
// frontend, the backend and the database are connected. To use your own page,
|
|
42
|
+
// replace this component; src/cfa-welcome/ can then be deleted.
|
|
43
|
+
import './cfa-welcome/cfa-welcome.js';
|
|
44
|
+
import { stack } from './cfa-welcome/stack';
|
|
45
|
+
|
|
46
|
+
const API = import.meta.env.VITE_API_URL ?? '${api}';
|
|
47
|
+
|
|
48
|
+
// <cfa-welcome> is a custom element. Typing it here, instead of in React's JSX
|
|
49
|
+
// namespace, works whichever copy of @types/react the build picks up.
|
|
50
|
+
const CfaWelcome = 'cfa-welcome' as unknown as (props: { api: string; stack: string }) => null;
|
|
51
|
+
|
|
52
|
+
function App() {
|
|
53
|
+
return <CfaWelcome api={API} stack={JSON.stringify(stack)} />;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default App;
|
|
57
|
+
`;
|
|
58
|
+
const VUE_PAGE = ({ api }) => `<script setup lang="ts">
|
|
59
|
+
// The start page create-fs-app made for this project: it checks that the
|
|
60
|
+
// frontend, the backend and the database are connected. To use your own page,
|
|
61
|
+
// replace this component; src/cfa-welcome/ and the isCustomElement option in
|
|
62
|
+
// vite.config.ts and vitest.config.ts can then be deleted.
|
|
63
|
+
import './cfa-welcome/cfa-welcome.js';
|
|
64
|
+
import { stack } from './cfa-welcome/stack';
|
|
65
|
+
|
|
66
|
+
const api = import.meta.env.VITE_API_URL ?? '${api}';
|
|
67
|
+
const stackJson = JSON.stringify(stack);
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<template>
|
|
71
|
+
<cfa-welcome
|
|
72
|
+
:api="api"
|
|
73
|
+
:stack="stackJson"
|
|
74
|
+
/>
|
|
75
|
+
</template>
|
|
76
|
+
`;
|
|
77
|
+
/** Shared body of the start page tests: the element renders the project's stack. */
|
|
78
|
+
const testBody = (q, name, render) => `
|
|
79
|
+
afterEach(() => {
|
|
80
|
+
cleanup();
|
|
81
|
+
vi.unstubAllGlobals();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test(${q}renders the welcome page for this project${q}, async () => {
|
|
85
|
+
// The page checks the backend; answer without one running
|
|
86
|
+
vi.stubGlobal(${q}fetch${q}, vi.fn().mockResolvedValue(new Response(${q}{}${q})));
|
|
87
|
+
const { container } = ${render};
|
|
88
|
+
const page = container.querySelector(${q}cfa-welcome${q});
|
|
89
|
+
expect(page).not.toBeNull();
|
|
90
|
+
await vi.waitFor(() => expect(page!.shadowRoot?.textContent).toContain(${q}${name} is running.${q}));
|
|
91
|
+
});
|
|
92
|
+
`;
|
|
93
|
+
const FRONTENDS = {
|
|
94
|
+
'next.js': {
|
|
95
|
+
entry: 'src/app/page.tsx',
|
|
96
|
+
test: '__tests__/page.test.tsx',
|
|
97
|
+
page: NEXT_PAGE,
|
|
98
|
+
testFile: ({ name }) => `import { cleanup, render } from "@testing-library/react";
|
|
99
|
+
import { afterEach, expect, test, vi } from "vitest";
|
|
100
|
+
import Home from "../src/app/page";
|
|
101
|
+
${testBody('"', name, 'render(<Home />)')}`,
|
|
102
|
+
},
|
|
103
|
+
react: {
|
|
104
|
+
entry: 'src/App.tsx',
|
|
105
|
+
test: 'src/App.test.tsx',
|
|
106
|
+
page: REACT_PAGE,
|
|
107
|
+
testFile: ({ name }) => `import { cleanup, render } from '@testing-library/react';
|
|
108
|
+
import { afterEach, expect, test, vi } from 'vitest';
|
|
109
|
+
import App from './App';
|
|
110
|
+
${testBody("'", name, 'render(<App />)')}`,
|
|
111
|
+
},
|
|
112
|
+
vue: {
|
|
113
|
+
entry: 'src/App.vue',
|
|
114
|
+
test: 'src/App.test.ts',
|
|
115
|
+
page: VUE_PAGE,
|
|
116
|
+
testFile: ({ name }) => `import { cleanup, render } from '@testing-library/vue';
|
|
117
|
+
import { afterEach, expect, test, vi } from 'vitest';
|
|
118
|
+
import App from './App.vue';
|
|
119
|
+
${testBody("'", name, 'render(App)')}`,
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
const PLAIN_TYPES = `// Types for cfa-welcome.js (generated by create-fs-app). The module only registers <cfa-welcome>.
|
|
123
|
+
export {};
|
|
124
|
+
`;
|
|
125
|
+
/** The JWT routes the auth scaffolding adds (core/auth/jwt.ts). */
|
|
126
|
+
const JWT_ROUTES = [
|
|
127
|
+
['POST', '/auth/login', '5 per 15 min'],
|
|
128
|
+
['GET', '/auth/me', 'needs token'],
|
|
129
|
+
];
|
|
130
|
+
/** Whether the welcome page can be added: an official or contributed template with welcome data and a known frontend. */
|
|
131
|
+
export function supportsWelcome(template) {
|
|
132
|
+
const frontend = template.stack?.frontend;
|
|
133
|
+
return Boolean(template.welcome && template.layers && frontend && frontend in FRONTENDS);
|
|
134
|
+
}
|
|
135
|
+
/** The welcome page's start page file, relative to the project (for --dry-run and messages). */
|
|
136
|
+
export function welcomeEntry(template) {
|
|
137
|
+
const kind = FRONTENDS[template.stack?.frontend ?? ''];
|
|
138
|
+
if (!kind || !template.layers)
|
|
139
|
+
return undefined;
|
|
140
|
+
return path.posix.join(template.layers.frontend.path ?? 'apps/frontend', kind.entry);
|
|
141
|
+
}
|
|
142
|
+
/** Files applyWelcome adds or replaces (project-relative POSIX paths), for --dry-run. */
|
|
143
|
+
export function welcomeFiles(template) {
|
|
144
|
+
const kind = FRONTENDS[template.stack?.frontend ?? ''];
|
|
145
|
+
if (!kind || !template.layers)
|
|
146
|
+
return [];
|
|
147
|
+
const fe = template.layers.frontend.path ?? 'apps/frontend';
|
|
148
|
+
const folder = path.posix.join(fe, WELCOME_FOLDER);
|
|
149
|
+
return [
|
|
150
|
+
...WELCOME_FILES.map(f => path.posix.join(folder, f)),
|
|
151
|
+
path.posix.join(folder, 'cfa-welcome.d.ts'),
|
|
152
|
+
path.posix.join(folder, 'stack.ts'),
|
|
153
|
+
];
|
|
154
|
+
}
|
|
155
|
+
/** "^20.19.0 || ^22.12.0 || >=24.0.0" → "20.19+" (the lowest supported version). */
|
|
156
|
+
function nodeLabel(range) {
|
|
157
|
+
const match = range?.match(/(\d+)\.(\d+)/);
|
|
158
|
+
return match ? `${match[1]}.${match[2]}+` : undefined;
|
|
159
|
+
}
|
|
160
|
+
function layer(l) {
|
|
161
|
+
if (!l)
|
|
162
|
+
return {};
|
|
163
|
+
const { name, version, path: p, port, notes } = l;
|
|
164
|
+
return { name, version, path: p, port, notes };
|
|
165
|
+
}
|
|
166
|
+
/** What the page shows: the shape of `Stack` in welcome/src/cfa-welcome.ts. */
|
|
167
|
+
export function buildWelcomeStack(config, template) {
|
|
168
|
+
const { layers, welcome, stack } = template;
|
|
169
|
+
if (!layers || !welcome || !stack)
|
|
170
|
+
throw new Error('This template has no welcome page data');
|
|
171
|
+
const pm = config.packageManager;
|
|
172
|
+
const backendPath = layers.backend.path ?? 'apps/backend';
|
|
173
|
+
const jwt = config.auth === 'jwt';
|
|
174
|
+
const docker = config.docker && template.supports.docker;
|
|
175
|
+
return {
|
|
176
|
+
name: config.name,
|
|
177
|
+
packageManager: pm,
|
|
178
|
+
monorepo: stack.monorepo,
|
|
179
|
+
node: nodeLabel(template.node),
|
|
180
|
+
entry: welcomeEntry(template),
|
|
181
|
+
docker,
|
|
182
|
+
auth: jwt ? 'jwt' : null,
|
|
183
|
+
frontend: layer(layers.frontend),
|
|
184
|
+
backend: {
|
|
185
|
+
...layer(layers.backend),
|
|
186
|
+
health: welcome.health,
|
|
187
|
+
probe: welcome.probe,
|
|
188
|
+
docs: welcome.docs,
|
|
189
|
+
routesFile: welcome.routesFile,
|
|
190
|
+
routes: [...welcome.routes, ...(jwt ? JWT_ROUTES : [])],
|
|
191
|
+
},
|
|
192
|
+
orm: {
|
|
193
|
+
...layer(layers.orm),
|
|
194
|
+
schema: welcome.schema,
|
|
195
|
+
// From the project root; "cd ../.." brings the shell back for the next command
|
|
196
|
+
setup: welcome.setup ? `cd ${backendPath} && ${pm} run ${welcome.setup} && cd ../..` : null,
|
|
197
|
+
},
|
|
198
|
+
database: {
|
|
199
|
+
...layer(layers.database),
|
|
200
|
+
kind: stack.database,
|
|
201
|
+
...welcome.database,
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
/** Let Vue treat <cfa-welcome> as a custom element: vue() → vue({ template: { compilerOptions: ... } }). */
|
|
206
|
+
async function patchVueConfig(file) {
|
|
207
|
+
if (!existsSync(file))
|
|
208
|
+
return;
|
|
209
|
+
const content = await fs.readFile(file, 'utf-8');
|
|
210
|
+
const next = content.replace(/\bvue\(\)/, "vue({ template: { compilerOptions: { isCustomElement: (tag) => tag === 'cfa-welcome' } } })");
|
|
211
|
+
if (next === content) {
|
|
212
|
+
Logger.warn(`Could not find vue() in ${path.basename(file)}; add isCustomElement for cfa-welcome to the Vue plugin yourself.`);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
await fs.writeFile(file, next);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* React (Vite) lints only .ts/.tsx, so the built file's eslint-disable banner is
|
|
219
|
+
* reported as unused; ignore the file instead. Next.js and Vue lint .js files
|
|
220
|
+
* and need the banner.
|
|
221
|
+
*/
|
|
222
|
+
async function ignoreInReactEslint(frontendDir) {
|
|
223
|
+
const file = path.join(frontendDir, 'eslint.config.js');
|
|
224
|
+
if (!existsSync(file))
|
|
225
|
+
return; // --no-eslint
|
|
226
|
+
const content = await fs.readFile(file, 'utf-8');
|
|
227
|
+
const next = content.replace(/ignores: \['dist'\]/, "ignores: ['dist', 'src/cfa-welcome/cfa-welcome.js']");
|
|
228
|
+
if (next !== content)
|
|
229
|
+
await fs.writeFile(file, next);
|
|
230
|
+
}
|
|
231
|
+
/** Add the welcome page to a scaffolded project. Skips templates supportsWelcome() rejects. */
|
|
232
|
+
export async function applyWelcome(targetDir, config, template) {
|
|
233
|
+
if (!supportsWelcome(template))
|
|
234
|
+
return;
|
|
235
|
+
const kind = FRONTENDS[template.stack.frontend];
|
|
236
|
+
const frontendDir = path.join(targetDir, template.layers.frontend.path ?? 'apps/frontend');
|
|
237
|
+
const folder = path.join(frontendDir, WELCOME_FOLDER);
|
|
238
|
+
const missing = WELCOME_FILES.filter(f => !existsSync(path.join(WELCOME_DIST, f)));
|
|
239
|
+
if (missing.length > 0) {
|
|
240
|
+
throw new Error(`The welcome page files are missing from ${WELCOME_DIST} (${missing.join(', ')}); run the CLI build (scripts/build-welcome.mjs).`);
|
|
241
|
+
}
|
|
242
|
+
await fs.mkdir(folder, { recursive: true });
|
|
243
|
+
for (const file of WELCOME_FILES) {
|
|
244
|
+
await fs.copyFile(path.join(WELCOME_DIST, file), path.join(folder, file));
|
|
245
|
+
}
|
|
246
|
+
await fs.writeFile(path.join(folder, 'cfa-welcome.d.ts'), PLAIN_TYPES);
|
|
247
|
+
const stack = buildWelcomeStack(config, template);
|
|
248
|
+
await fs.writeFile(path.join(folder, 'stack.ts'), `// What the start page shows about this project (written by create-fs-app).\nexport const stack = ${JSON.stringify(stack, null, 2)};\n`);
|
|
249
|
+
const port = template.layers.backend.port ?? 3001;
|
|
250
|
+
const input = { name: config.name, api: `http://localhost:${port}` };
|
|
251
|
+
await fs.writeFile(path.join(frontendDir, kind.entry), kind.page(input));
|
|
252
|
+
await fs.mkdir(path.dirname(path.join(frontendDir, kind.test)), { recursive: true });
|
|
253
|
+
await fs.writeFile(path.join(frontendDir, kind.test), kind.testFile(input));
|
|
254
|
+
if (template.stack.frontend === 'react')
|
|
255
|
+
await ignoreInReactEslint(frontendDir);
|
|
256
|
+
if (template.stack.frontend === 'vue') {
|
|
257
|
+
await patchVueConfig(path.join(frontendDir, 'vite.config.ts'));
|
|
258
|
+
await patchVueConfig(path.join(frontendDir, 'vitest.config.ts'));
|
|
259
|
+
}
|
|
260
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Keep this file free of imports: it must run on old Node versions to print the error.
|
|
3
3
|
const [major = 0, minor = 0] = process.versions.node.split('.').map(Number);
|
|
4
|
-
if (major
|
|
4
|
+
if (!((major === 20 && minor >= 19) || (major === 22 && minor >= 12) || major >= 24)) {
|
|
5
5
|
console.error([
|
|
6
|
-
'✗ create-fs-app needs Node.js 20.19 or
|
|
6
|
+
'✗ create-fs-app needs Node.js 20.19+, 22.12+ or 24+',
|
|
7
7
|
` You have ${process.versions.node}.`,
|
|
8
8
|
' Try: install Node.js 22 LTS from https://nodejs.org',
|
|
9
9
|
].join('\n'));
|
package/dist/types/index.js
CHANGED
|
@@ -25,6 +25,7 @@ export const ProjectOptionsSchema = z.object({
|
|
|
25
25
|
prettier: z.boolean().default(true),
|
|
26
26
|
docker: z.boolean().default(true),
|
|
27
27
|
auth: AuthStrategySchema.default('none'),
|
|
28
|
+
welcome: z.boolean().default(true), // <cfa-welcome> start page (core/welcome.ts)
|
|
28
29
|
git: z.boolean().default(true), // git init + first commit
|
|
29
30
|
install: z.boolean().default(false), // install dependencies after scaffolding
|
|
30
31
|
});
|
package/package.json
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-fs-app",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.2.0",
|
|
4
|
+
"description": "Create a full-stack TypeScript monorepo from one command: a frontend, a backend and a database, already connected.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"create-fs-app": "
|
|
7
|
+
"create-fs-app": "dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
10
|
"files": [
|
|
11
11
|
"dist/**/*",
|
|
12
|
+
"welcome/dist/**/*",
|
|
12
13
|
"README.md",
|
|
13
14
|
"LICENSE"
|
|
14
15
|
],
|
|
15
16
|
"scripts": {
|
|
16
|
-
"prebuild": "node scripts/sync-registry.mjs",
|
|
17
|
+
"prebuild": "node scripts/sync-registry.mjs && node scripts/build-welcome.mjs",
|
|
17
18
|
"build": "tsc",
|
|
18
19
|
"dev": "tsc -w",
|
|
19
20
|
"lint": "eslint . --max-warnings 0",
|
|
20
21
|
"lint:fix": "eslint . --fix",
|
|
21
|
-
"typecheck": "tsc --noEmit",
|
|
22
|
+
"typecheck": "tsc --noEmit && tsc -p welcome",
|
|
22
23
|
"test": "vitest run",
|
|
23
24
|
"test:e2e-templates": "node scripts/e2e-templates.mjs",
|
|
24
25
|
"test:e2e-docker": "node scripts/e2e-docker.mjs",
|
|
25
26
|
"sync-registry": "node scripts/sync-registry.mjs",
|
|
27
|
+
"build:welcome": "node scripts/build-welcome.mjs",
|
|
26
28
|
"postbuild": "node -e \"require('fs').chmodSync('dist/index.js', 0o755)\"",
|
|
27
29
|
"prepublishOnly": "npm run build",
|
|
28
30
|
"size": "npm pack --dry-run 2>&1 | grep -E 'package size|Tarball Contents'",
|
|
@@ -35,22 +37,31 @@
|
|
|
35
37
|
},
|
|
36
38
|
"keywords": [
|
|
37
39
|
"full-stack",
|
|
40
|
+
"fullstack",
|
|
38
41
|
"monorepo",
|
|
39
42
|
"turborepo",
|
|
40
|
-
"react",
|
|
41
|
-
"next.js",
|
|
42
|
-
"express",
|
|
43
|
-
"nest.js",
|
|
44
43
|
"typescript",
|
|
45
44
|
"cli",
|
|
46
45
|
"scaffolding",
|
|
47
|
-
"boilerplate"
|
|
46
|
+
"boilerplate",
|
|
47
|
+
"starter",
|
|
48
|
+
"next.js",
|
|
49
|
+
"nest.js",
|
|
50
|
+
"react",
|
|
51
|
+
"vue",
|
|
52
|
+
"express",
|
|
53
|
+
"fastify",
|
|
54
|
+
"hono",
|
|
55
|
+
"prisma",
|
|
56
|
+
"drizzle",
|
|
57
|
+
"mongoose",
|
|
58
|
+
"docker"
|
|
48
59
|
],
|
|
49
60
|
"author": "Om Jannu",
|
|
50
61
|
"license": "ISC",
|
|
51
62
|
"repository": {
|
|
52
63
|
"type": "git",
|
|
53
|
-
"url": "https://github.com/Om-jannu/create-fs-app.git"
|
|
64
|
+
"url": "git+https://github.com/Om-jannu/create-fs-app.git"
|
|
54
65
|
},
|
|
55
66
|
"bugs": {
|
|
56
67
|
"url": "https://github.com/Om-jannu/create-fs-app/issues"
|
|
@@ -68,11 +79,12 @@
|
|
|
68
79
|
"@types/node": "^24.8.1",
|
|
69
80
|
"@typescript-eslint/eslint-plugin": "^8.46.1",
|
|
70
81
|
"@typescript-eslint/parser": "^8.46.1",
|
|
82
|
+
"esbuild": "^0.28.2",
|
|
71
83
|
"eslint": "^9.38.0",
|
|
72
84
|
"typescript": "^5.9.3",
|
|
73
85
|
"vitest": "^4.0.0"
|
|
74
86
|
},
|
|
75
87
|
"engines": {
|
|
76
|
-
"node": "
|
|
88
|
+
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
|
|
77
89
|
}
|
|
78
90
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2017 The Barlow Project Authors (https://github.com/jpt/barlow)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|