create-surf-app 0.1.0 → 0.1.1
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/dist/index.js +32 -13
- package/package.json +7 -3
package/dist/index.js
CHANGED
|
@@ -5,18 +5,18 @@ import fs from "fs";
|
|
|
5
5
|
import path from "path";
|
|
6
6
|
var args = process.argv.slice(2);
|
|
7
7
|
var projectName = args.find((a) => !a.startsWith("--")) || ".";
|
|
8
|
-
var frontendPort = getFlag("--port"
|
|
9
|
-
var backendPort = getFlag("--backend-port"
|
|
10
|
-
function getFlag(name2
|
|
8
|
+
var frontendPort = getFlag("--port") || process.env.VITE_PORT || "5173";
|
|
9
|
+
var backendPort = getFlag("--backend-port") || process.env.VITE_BACKEND_PORT || "3001";
|
|
10
|
+
function getFlag(name2) {
|
|
11
11
|
const idx = args.indexOf(name2);
|
|
12
|
-
return idx >= 0 && args[idx + 1] ? args[idx + 1] :
|
|
12
|
+
return idx >= 0 && args[idx + 1] ? args[idx + 1] : void 0;
|
|
13
13
|
}
|
|
14
14
|
var frontendPkg = {
|
|
15
15
|
name: "frontend",
|
|
16
16
|
private: true,
|
|
17
17
|
type: "module",
|
|
18
18
|
scripts: {
|
|
19
|
-
dev:
|
|
19
|
+
dev: "vite",
|
|
20
20
|
build: "vite build",
|
|
21
21
|
preview: "vite preview",
|
|
22
22
|
lint: "eslint ."
|
|
@@ -61,6 +61,7 @@ var frontendPkg = {
|
|
|
61
61
|
"next-themes": "0.4.6",
|
|
62
62
|
"react": "19.2.4",
|
|
63
63
|
"react-dom": "19.2.4",
|
|
64
|
+
"react-router-dom": "7.6.1",
|
|
64
65
|
"sonner": "1.7.4",
|
|
65
66
|
"tailwind-merge": "2.6.1",
|
|
66
67
|
"vaul": "1.1.2",
|
|
@@ -99,7 +100,7 @@ var templates = {
|
|
|
99
100
|
}
|
|
100
101
|
}, null, 2),
|
|
101
102
|
"backend/server.js": `const { createServer } = require('@surf-ai/sdk/server')
|
|
102
|
-
createServer(
|
|
103
|
+
createServer().start()
|
|
103
104
|
`,
|
|
104
105
|
"backend/routes/.gitkeep": "",
|
|
105
106
|
"backend/db/schema.js": `// Define your Drizzle ORM tables here.
|
|
@@ -113,14 +114,32 @@ createServer({ port: ${backendPort} }).start()
|
|
|
113
114
|
`,
|
|
114
115
|
// ── Frontend ─────────────────────────────────────────────────────────────
|
|
115
116
|
"frontend/package.json": JSON.stringify(frontendPkg, null, 2),
|
|
117
|
+
"frontend/.env": `VITE_PORT=${frontendPort}
|
|
118
|
+
VITE_BACKEND_PORT=${backendPort}
|
|
119
|
+
`,
|
|
116
120
|
"frontend/vite.config.ts": `import { defineConfig, loadEnv } from 'vite'
|
|
117
121
|
import react from '@vitejs/plugin-react'
|
|
118
122
|
import tailwindcss from '@tailwindcss/vite'
|
|
119
123
|
import path from 'path'
|
|
120
124
|
|
|
121
125
|
const env = loadEnv('', process.cwd(), '')
|
|
122
|
-
|
|
123
|
-
|
|
126
|
+
|
|
127
|
+
function requiredPort(name: string) {
|
|
128
|
+
const value = env[name]
|
|
129
|
+
if (!value) {
|
|
130
|
+
throw new Error(\`Missing \${name}. Set it in frontend/.env or your shell environment.\`)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const port = Number.parseInt(value, 10)
|
|
134
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
135
|
+
throw new Error(\`Invalid \${name}: \${value}\`)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return port
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const FRONTEND_PORT = requiredPort('VITE_PORT')
|
|
142
|
+
const BACKEND_PORT = requiredPort('VITE_BACKEND_PORT')
|
|
124
143
|
|
|
125
144
|
export default defineConfig({
|
|
126
145
|
plugins: [react(), tailwindcss()],
|
|
@@ -294,7 +313,7 @@ The agent can also call \`POST /api/__sync-schema\` explicitly after editing.
|
|
|
294
313
|
|
|
295
314
|
- Use \`@surf-ai/sdk/react\` hooks in frontend, \`@surf-ai/sdk/server\` dataApi in backend
|
|
296
315
|
- Use Tailwind CSS classes for styling (Surf Design System theme via \`@surf-ai/theme\`)
|
|
297
|
-
- Use shadcn/ui components \u2014 install with \`
|
|
316
|
+
- Use shadcn/ui components \u2014 install with \`npx shadcn@latest add button\`
|
|
298
317
|
- Use \`cn()\` from \`@surf-ai/sdk/react\` to merge Tailwind classes
|
|
299
318
|
- Frontend packages are pre-installed \u2014 check \`package.json\` before installing
|
|
300
319
|
- Dark theme is the default (configured in entry-client.tsx)
|
|
@@ -333,14 +352,14 @@ console.log(`
|
|
|
333
352
|
Done! Next steps:
|
|
334
353
|
|
|
335
354
|
cd ${name}
|
|
336
|
-
cd backend &&
|
|
337
|
-
cd frontend &&
|
|
355
|
+
cd backend && npm install && cd ..
|
|
356
|
+
cd frontend && npm install && cd ..
|
|
338
357
|
|
|
339
358
|
# Start backend
|
|
340
|
-
cd backend &&
|
|
359
|
+
cd backend && npm run dev &
|
|
341
360
|
|
|
342
361
|
# Start frontend
|
|
343
|
-
cd frontend &&
|
|
362
|
+
cd frontend && npm run dev
|
|
344
363
|
|
|
345
364
|
Open http://localhost:${frontendPort}
|
|
346
365
|
`);
|
package/package.json
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-surf-app",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Scaffold a Surf app — Vite + React + Express + @surf-ai/sdk",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"create-surf-app": "./dist/index.js"
|
|
8
8
|
},
|
|
9
|
-
"files": [
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"templates"
|
|
12
|
+
],
|
|
10
13
|
"scripts": {
|
|
11
14
|
"build": "tsup src/index.ts --format esm --clean && rm -rf dist/templates && cp -r templates dist/templates",
|
|
12
|
-
"dev": "tsup src/index.ts --format esm --watch"
|
|
15
|
+
"dev": "tsup src/index.ts --format esm --watch",
|
|
16
|
+
"test": "bun test"
|
|
13
17
|
},
|
|
14
18
|
"devDependencies": {
|
|
15
19
|
"tsup": "^8.0.0",
|