[codex] Add create-frappe-ui initializer - #826
Conversation
Confidence Score: 4/5This is close, but these issues should be fixed before merging.
packages/create-frappe-ui/bin/create-frappe-ui.js
|
| const contents = fs | ||
| .readFileSync(sourcePath, 'utf8') | ||
| .replaceAll('__PROJECT_NAME__', context.projectName) | ||
| .replaceAll('__BASE_ROUTE__', context.baseRoute) | ||
| .replaceAll('__ROUTER_BASE__', context.routerBase) | ||
| fs.writeFileSync(targetPath, contents) |
There was a problem hiding this comment.
With --force, every matching template file is written unconditionally. Re-running the initializer in an existing app can replace edited files like .gitignore, package.json, or src/main.ts without any per-file warning, causing local project changes to be lost.
Context Used: Guidelines for reviewing Frappe Framework applicat... (source)
| const context = { | ||
| baseRoute: options.route, | ||
| baseRouteCode: JSON.stringify(options.route), | ||
| projectName: toPackageName(path.basename(targetDir)), |
There was a problem hiding this comment.
Validate Route Paths
--route is escaped for TypeScript, but values like /../../foo are still accepted and written to frontendRoute. During a Frappe build, that route is used to derive the generated HTML output path, so traversal segments can write outside the intended www route file; reject .., backslashes, and filesystem separators before generating the config.
| .replaceAll('__BASE_ROUTE_CODE__', context.baseRouteCode) | ||
| .replaceAll('__ROUTER_BASE__', context.routerBase) | ||
| .replaceAll('__ROUTER_BASE_CODE__', context.routerBaseCode) | ||
| fs.writeFileSync(targetPath, contents) |
There was a problem hiding this comment.
Guard Existing Files
--force still writes every matching template path unconditionally. Re-running the initializer in an existing app can replace user-edited files such as package.json, src/router.ts, or vite.config.ts; add per-file confirmation, backup, or skip handling before writing an existing path.
What changed
create-frappe-uipackage underpackages/create-frappe-uisonpm create frappe-uican resolve to a dedicated initializer.--frappe/--no-frappe--route <path>for the frontend base routeapps/<appname>/<folder>Notes
Plain projects still use
frappe-ui/vitewith Frappe backend features disabled so the Frappe UI icon resolver is available without enabling proxy/build/Jinja behavior.Validation
node bin/create-frappe-ui.js /tmp/frappe-ui-plain-ts --no-frappecd /tmp/frappe-ui-plain-ts && npm install && npm run buildnode bin/create-frappe-ui.js /tmp/frappe-bench-test/apps/todo/frontend --frappe --route desk/frontendcd /tmp/frappe-bench-test/apps/todo/frontend && npm install && npm run build/frontendroutenpm pack --dry-run --jsonyarn docs:buildusing the original checkout'snode_modules; it exits 0 with existing VitePress/router warnings during renderingDocs preview: https://ui.frappe.io/pr-preview/pr-826/
Coverage: 68.80% (-0.01% vs
main)