docker run --rm -it \ -v /share/Container/dms/frontend:/app \ -w /app \ -e CI=1 \ node:20-alpine sh -lc ' set -eu echo "1) ตรวจและแก้ package.json → next/react/react-dom ต้องอยู่ใน dependencies + scripts ครบ" test -f package.json || { echo "❌ ไม่พบ package.json ที่ /app"; exit 1; } node -e " const fs=require(\"fs\"); const p=JSON.parse(fs.readFileSync(\"package.json\",\"utf8\")); p.dependencies=p.dependencies||{}; p.devDependencies=p.devDependencies||{}; p.scripts=p.scripts||{}; let changed=false; for(const k of [\"next\",\"react\",\"react-dom\"]){ if(p.devDependencies[k]){ p.dependencies[k]=p.devDependencies[k]; delete p.devDependencies[k]; changed=true; } if(!p.dependencies[k]){ p.dependencies[k]=\"latest\"; changed=true; } } if(!p.scripts.dev){ p.scripts.dev=\"next dev\"; changed=true; } if(!p.scripts.build){ p.scripts.build=\"next build\"; changed=true; } if(!p.scripts.start){ p.scripts.start=\"next start\"; changed=true; } if(changed){ fs.writeFileSync(\"package.json\",JSON.stringify(p,null,2)); console.log(\"package.json patched\"); } " npm i echo "2) โครง Next.js: app/ หรือ src/app/ + layout.jsx + globals.css" APPDIR="app"; [ -d src/app ] && APPDIR="src/app" mkdir -p "$APPDIR" [ -f "$APPDIR/globals.css" ] || printf "%s\n%s\n%s\n" "@tailwind base;" "@tailwind components;" "@tailwind utilities;" > "$APPDIR/globals.css" if [ ! -f "$APPDIR/layout.jsx" ] && [ ! -f "$APPDIR/layout.tsx" ]; then cat > "$APPDIR/layout.jsx" <{children}); } EOF fi grep -q "import \"./globals.css\"" "$APPDIR/layout.jsx" 2>/dev/null || sed -i "1i import \"./globals.css\";" "$APPDIR/layout.jsx" 2>/dev/null || true [ -f "$APPDIR/page.jsx" ] || [ -f "$APPDIR/page.tsx" ] || echo '\''export default function Page(){return
OK
}'\'' > "$APPDIR/page.jsx" echo "3) สร้าง/อัปเดตไฟล์ config ที่ CLI ต้องมี: jsconfig, postcss, tailwind, next.config" [ -f jsconfig.json ] || cat > jsconfig.json < postcss.config.cjs [ -f tailwind.config.js ] || npx tailwindcss init -p grep -q "content:" tailwind.config.js || \ sed -i "s|module.exports = {|module.exports = {\n content: [\"./$APPDIR/**/*.{js,jsx,ts,tsx,mdx}\", \"./components/**/*.{js,jsx,ts,tsx,mdx}\", \"./pages/**/*.{js,jsx,ts,tsx,mdx}\", \"./src/**/*.{js,jsx,ts,tsx,mdx}\"],|g" tailwind.config.js grep -q "tailwindcss-animate" tailwind.config.js || \ sed -i '\''s|plugins: \[|plugins: [require("tailwindcss-animate"), |; s|plugins: \[\]|plugins: [require("tailwindcss-animate")]|'\'' tailwind.config.js # next.config (บางเวอร์ชัน CLI เช็คไฟล์นี้ด้วย) if [ ! -f next.config.js ] && [ ! -f next.config.mjs ]; then cat > next.config.js < components.json </dev/null 2>&1 || true echo "6) init (force) — ตอนนี้ควรผ่านการตรวจจับแล้ว" npx shadcn@latest init -y -f --no-src-dir echo "✅ เสร็จ — ถ้าต้องการเพิ่มคอมโพเนนต์ต่อ:" echo "npx shadcn@latest add -y dialog alert-dialog dropdown-menu checkbox scroll-area tabs tooltip switch button label input card badge progress tabs" '