openadminjs 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/.env.example +9 -0
- package/.github/FUNDING.yml +3 -0
- package/.github/ISSUE_TEMPLATE/bug_report.yml +10 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +10 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +9 -0
- package/.github/dependabot.yml +10 -0
- package/.github/workflows/ci.yml +26 -0
- package/CHANGELOG.md +5 -0
- package/CODE_OF_CONDUCT.md +3 -0
- package/CONTRIBUTING.md +11 -0
- package/LICENSE +21 -0
- package/README.md +175 -0
- package/ROADMAP.md +7 -0
- package/SECURITY.md +11 -0
- package/apps/admin/app/api/auth/login/route.ts +51 -0
- package/apps/admin/app/api/auth/logout/route.ts +11 -0
- package/apps/admin/app/api/auth/refresh/route.ts +46 -0
- package/apps/admin/app/api-tokens/page.tsx +253 -0
- package/apps/admin/app/audit-logs/page.tsx +5 -0
- package/apps/admin/app/dashboard/page.tsx +392 -0
- package/apps/admin/app/files/page.tsx +5 -0
- package/apps/admin/app/globals.css +206 -0
- package/apps/admin/app/jobs/page.tsx +19 -0
- package/apps/admin/app/layout.tsx +57 -0
- package/apps/admin/app/login/page.test.tsx +18 -0
- package/apps/admin/app/login/page.tsx +161 -0
- package/apps/admin/app/login/safe-next-param.ts +4 -0
- package/apps/admin/app/notifications/page.tsx +146 -0
- package/apps/admin/app/page.tsx +5 -0
- package/apps/admin/app/plugins/page.tsx +348 -0
- package/apps/admin/app/profile/page.tsx +116 -0
- package/apps/admin/app/resources/[resource]/[id]/edit/page.tsx +45 -0
- package/apps/admin/app/resources/[resource]/[id]/page.tsx +449 -0
- package/apps/admin/app/resources/[resource]/create/page.tsx +34 -0
- package/apps/admin/app/resources/[resource]/page.tsx +100 -0
- package/apps/admin/app/settings/page.tsx +233 -0
- package/apps/admin/components/ai-assistant-widget.tsx +684 -0
- package/apps/admin/components/app-shell.tsx +305 -0
- package/apps/admin/components/auth-guard.test.tsx +55 -0
- package/apps/admin/components/auth-guard.tsx +39 -0
- package/apps/admin/components/jobs-panel.tsx +103 -0
- package/apps/admin/components/logo.tsx +30 -0
- package/apps/admin/components/resource-form.tsx +349 -0
- package/apps/admin/components/resource-table.tsx +277 -0
- package/apps/admin/lib/ai-events.ts +23 -0
- package/apps/admin/lib/api.test.ts +118 -0
- package/apps/admin/lib/api.ts +135 -0
- package/apps/admin/lib/auth-flow.e2e.test.ts +79 -0
- package/apps/admin/lib/brand.ts +14 -0
- package/apps/admin/lib/locale.ts +49 -0
- package/apps/admin/lib/tokens.ts +93 -0
- package/apps/admin/middleware.ts +58 -0
- package/apps/admin/next-env.d.ts +6 -0
- package/apps/admin/next.config.mjs +7 -0
- package/apps/admin/package.json +44 -0
- package/apps/admin/postcss.config.mjs +6 -0
- package/apps/admin/public/brand/apple-touch-icon.png +0 -0
- package/apps/admin/public/brand/favicon.svg +1 -0
- package/apps/admin/public/brand/og-image.png +0 -0
- package/apps/admin/public/brand/openadminjs-icon-new.png +0 -0
- package/apps/admin/public/brand/openadminjs-logo-monochrome.png +0 -0
- package/apps/admin/public/brand/openadminjs-logo-new.png +0 -0
- package/apps/admin/tailwind.config.ts +37 -0
- package/apps/admin/tsconfig.json +23 -0
- package/apps/admin/vitest.config.ts +7 -0
- package/apps/api/package.json +56 -0
- package/apps/api/plugins.manifest.example.json +22 -0
- package/apps/api/plugins.manifest.json +4 -0
- package/apps/api/src/access/catalog.ts +112 -0
- package/apps/api/src/access/derive-permissions.test.ts +26 -0
- package/apps/api/src/access/derive-permissions.ts +36 -0
- package/apps/api/src/access/public-catalog.ts +28 -0
- package/apps/api/src/admin/admin-ai.controller.ts +125 -0
- package/apps/api/src/admin/admin-ai.events.ts +23 -0
- package/apps/api/src/admin/admin-ai.service.ts +1238 -0
- package/apps/api/src/admin/admin-analytics.service.ts +164 -0
- package/apps/api/src/admin/admin-plugins.controller.ts +32 -0
- package/apps/api/src/admin/admin-plugins.service.ts +253 -0
- package/apps/api/src/admin/admin-resource.service.test.ts +118 -0
- package/apps/api/src/admin/admin-resource.service.ts +375 -0
- package/apps/api/src/admin/admin.controller.ts +72 -0
- package/apps/api/src/admin/admin.module.ts +30 -0
- package/apps/api/src/admin/dto/plugins.dto.ts +37 -0
- package/apps/api/src/admin/validate-resource-payload.test.ts +44 -0
- package/apps/api/src/admin/validate-resource-payload.ts +103 -0
- package/apps/api/src/app.module.ts +37 -0
- package/apps/api/src/auth/auth.controller.ts +70 -0
- package/apps/api/src/auth/auth.dto.ts +49 -0
- package/apps/api/src/auth/auth.module.ts +30 -0
- package/apps/api/src/auth/auth.service.test.ts +75 -0
- package/apps/api/src/auth/auth.service.ts +231 -0
- package/apps/api/src/common/auth-realm.decorator.ts +6 -0
- package/apps/api/src/common/auth.guard.test.ts +61 -0
- package/apps/api/src/common/auth.guard.ts +78 -0
- package/apps/api/src/common/casl-ability.factory.test.ts +33 -0
- package/apps/api/src/common/casl-ability.factory.ts +41 -0
- package/apps/api/src/common/current-user.decorator.ts +6 -0
- package/apps/api/src/common/permission.decorator.ts +7 -0
- package/apps/api/src/common/permissions.guard.ts +31 -0
- package/apps/api/src/common/prisma.service.ts +13 -0
- package/apps/api/src/health/health.controller.ts +25 -0
- package/apps/api/src/mail/mail.module.ts +9 -0
- package/apps/api/src/mail/mail.service.ts +115 -0
- package/apps/api/src/main.ts +37 -0
- package/apps/api/src/plugins/bootstrap.ts +4 -0
- package/apps/api/src/plugins/bundled/hello.plugin.ts +19 -0
- package/apps/api/src/plugins/bundled/registry.ts +7 -0
- package/apps/api/src/plugins/manifest-path.ts +35 -0
- package/apps/api/src/plugins/manifest.schema.test.ts +28 -0
- package/apps/api/src/plugins/manifest.schema.ts +38 -0
- package/apps/api/src/plugins/plugin-loader.ts +109 -0
- package/apps/api/src/queue/queue.controller.ts +28 -0
- package/apps/api/src/queue/queue.module.ts +23 -0
- package/apps/api/src/queue/queue.processor.ts +47 -0
- package/apps/api/src/queue/queue.service.ts +50 -0
- package/apps/api/src/resources/categories.resource.ts +21 -0
- package/apps/api/src/resources/commerce.resource.ts +157 -0
- package/apps/api/src/resources/operations.resource.ts +111 -0
- package/apps/api/src/resources/posts.resource.ts +88 -0
- package/apps/api/src/resources/registry.ts +27 -0
- package/apps/api/src/resources/resource-hooks.install.ts +18 -0
- package/apps/api/src/resources/resource-hooks.registry.test.ts +72 -0
- package/apps/api/src/resources/resource-hooks.registry.ts +66 -0
- package/apps/api/src/resources/resource-hooks.runner.ts +86 -0
- package/apps/api/src/resources/system.resource.ts +51 -0
- package/apps/api/src/resources/users.resource.ts +19 -0
- package/apps/api/src/store/payment/payment.controller.ts +98 -0
- package/apps/api/src/store/payment/payment.module.ts +14 -0
- package/apps/api/src/store/payment/payment.provider.ts +38 -0
- package/apps/api/src/store/payment/payment.service.ts +235 -0
- package/apps/api/src/store/store.controller.ts +26 -0
- package/apps/api/src/store/store.module.ts +12 -0
- package/apps/api/src/test-setup.ts +1 -0
- package/apps/api/tsconfig.json +11 -0
- package/apps/api/vitest.config.ts +21 -0
- package/apps/web/README.md +12 -0
- package/apps/web/app/globals.css +12 -0
- package/apps/web/app/layout.tsx +18 -0
- package/apps/web/app/page.tsx +27 -0
- package/apps/web/app/posts/[slug]/page.tsx +38 -0
- package/apps/web/app/posts/page.tsx +20 -0
- package/apps/web/app/robots.txt/route.ts +9 -0
- package/apps/web/app/sitemap.xml/route.ts +20 -0
- package/apps/web/components/public-fields.tsx +22 -0
- package/apps/web/lib/openadmin-client.ts +82 -0
- package/apps/web/lib/seo.test.ts +41 -0
- package/apps/web/lib/seo.ts +53 -0
- package/apps/web/next-env.d.ts +6 -0
- package/apps/web/next.config.mjs +5 -0
- package/apps/web/package.json +30 -0
- package/apps/web/postcss.config.mjs +6 -0
- package/apps/web/public/brand/apple-touch-icon.png +0 -0
- package/apps/web/public/brand/favicon.svg +1 -0
- package/apps/web/public/brand/og-image.png +0 -0
- package/apps/web/public/brand/openadminjs-icon-new.png +0 -0
- package/apps/web/public/brand/openadminjs-logo-monochrome.png +0 -0
- package/apps/web/public/brand/openadminjs-logo-new.png +0 -0
- package/apps/web/tailwind.config.ts +21 -0
- package/apps/web/test/next-stub.ts +7 -0
- package/apps/web/tsconfig.json +23 -0
- package/apps/web/vitest.config.ts +19 -0
- package/docs/content/security.md +7 -0
- package/eslint.config.mjs +11 -0
- package/examples/README.md +80 -0
- package/examples/basic-admin/README.md +24 -0
- package/examples/basic-admin/package.json +17 -0
- package/examples/basic-admin/prisma/models.fragment.prisma +12 -0
- package/examples/basic-admin/src/index.test.ts +8 -0
- package/examples/basic-admin/src/index.ts +5 -0
- package/examples/basic-admin/src/resources/lead.resource.ts +30 -0
- package/examples/basic-admin/tsconfig.json +7 -0
- package/examples/basic-admin/vitest.config.ts +16 -0
- package/examples/blog-admin/README.md +18 -0
- package/examples/blog-admin/package.json +17 -0
- package/examples/blog-admin/prisma/models.fragment.prisma +30 -0
- package/examples/blog-admin/src/index.test.ts +8 -0
- package/examples/blog-admin/src/index.ts +5 -0
- package/examples/blog-admin/src/resources/authors.resource.ts +21 -0
- package/examples/blog-admin/src/resources/tags.resource.ts +20 -0
- package/examples/blog-admin/tsconfig.json +7 -0
- package/examples/blog-admin/vitest.config.ts +16 -0
- package/examples/crm-admin/README.md +17 -0
- package/examples/crm-admin/package.json +17 -0
- package/examples/crm-admin/prisma/models.fragment.prisma +50 -0
- package/examples/crm-admin/src/index.test.ts +9 -0
- package/examples/crm-admin/src/index.ts +7 -0
- package/examples/crm-admin/src/resources/activities.resource.ts +29 -0
- package/examples/crm-admin/src/resources/companies.resource.ts +21 -0
- package/examples/crm-admin/src/resources/contacts.resource.ts +24 -0
- package/examples/crm-admin/src/resources/deals.resource.ts +30 -0
- package/examples/crm-admin/tsconfig.json +7 -0
- package/examples/crm-admin/vitest.config.ts +16 -0
- package/examples/ecommerce-admin/README.md +17 -0
- package/examples/ecommerce-admin/package.json +17 -0
- package/examples/ecommerce-admin/prisma/models.fragment.prisma +43 -0
- package/examples/ecommerce-admin/src/index.test.ts +8 -0
- package/examples/ecommerce-admin/src/index.ts +7 -0
- package/examples/ecommerce-admin/src/resources/customers.resource.ts +21 -0
- package/examples/ecommerce-admin/src/resources/order-items.resource.ts +22 -0
- package/examples/ecommerce-admin/src/resources/orders.resource.ts +27 -0
- package/examples/ecommerce-admin/src/resources/products.resource.ts +23 -0
- package/examples/ecommerce-admin/tsconfig.json +7 -0
- package/examples/ecommerce-admin/vitest.config.ts +16 -0
- package/examples/marketplace-admin/README.md +17 -0
- package/examples/marketplace-admin/package.json +17 -0
- package/examples/marketplace-admin/prisma/models.fragment.prisma +32 -0
- package/examples/marketplace-admin/src/index.test.ts +8 -0
- package/examples/marketplace-admin/src/index.ts +6 -0
- package/examples/marketplace-admin/src/resources/listings.resource.ts +29 -0
- package/examples/marketplace-admin/src/resources/payouts.resource.ts +28 -0
- package/examples/marketplace-admin/src/resources/sellers.resource.ts +28 -0
- package/examples/marketplace-admin/tsconfig.json +7 -0
- package/examples/marketplace-admin/vitest.config.ts +16 -0
- package/examples/support-admin/README.md +18 -0
- package/examples/support-admin/package.json +17 -0
- package/examples/support-admin/prisma/models.fragment.prisma +20 -0
- package/examples/support-admin/src/index.test.ts +8 -0
- package/examples/support-admin/src/index.ts +5 -0
- package/examples/support-admin/src/resources/ticket-messages.resource.ts +22 -0
- package/examples/support-admin/src/resources/tickets.resource.ts +35 -0
- package/examples/support-admin/tsconfig.json +7 -0
- package/examples/support-admin/vitest.config.ts +16 -0
- package/package.json +33 -0
- package/packages/auth/package.json +17 -0
- package/packages/auth/src/index.test.ts +10 -0
- package/packages/auth/src/index.ts +17 -0
- package/packages/auth/tsconfig.json +8 -0
- package/packages/brand/apps/admin/public/brand/apple-touch-icon.png +0 -0
- package/packages/brand/apps/admin/public/brand/favicon.svg +1 -0
- package/packages/brand/apps/admin/public/brand/og-image.png +0 -0
- package/packages/brand/apps/admin/public/brand/openadminjs-icon-new.png +0 -0
- package/packages/brand/apps/admin/public/brand/openadminjs-logo-monochrome.png +0 -0
- package/packages/brand/apps/admin/public/brand/openadminjs-logo-new.png +0 -0
- package/packages/brand/apps/web/public/brand/apple-touch-icon.png +0 -0
- package/packages/brand/apps/web/public/brand/favicon.svg +1 -0
- package/packages/brand/apps/web/public/brand/og-image.png +0 -0
- package/packages/brand/apps/web/public/brand/openadminjs-icon-new.png +0 -0
- package/packages/brand/apps/web/public/brand/openadminjs-logo-monochrome.png +0 -0
- package/packages/brand/apps/web/public/brand/openadminjs-logo-new.png +0 -0
- package/packages/brand/package.json +19 -0
- package/packages/brand/site/assets/brand/favicon.svg +1 -0
- package/packages/brand/site/assets/brand/og-image.svg +1 -0
- package/packages/brand/site/assets/brand/openadminjs-icon.svg +1 -0
- package/packages/brand/site/assets/brand/openadminjs-logo-dark.svg +1 -0
- package/packages/brand/site/assets/brand/openadminjs-logo-horizontal.svg +1 -0
- package/packages/brand/site/assets/brand/openadminjs-logo-monochrome.svg +1 -0
- package/packages/brand/site/assets/brand/openadminjs-logo.svg +1 -0
- package/packages/brand/src/generate-assets.mjs +182 -0
- package/packages/brand/src/index.test.ts +9 -0
- package/packages/brand/src/index.ts +7 -0
- package/packages/brand/tsconfig.json +7 -0
- package/packages/cli/package.json +44 -0
- package/packages/cli/src/create-project.ts +227 -0
- package/packages/cli/src/index.test.ts +8 -0
- package/packages/cli/src/index.ts +90 -0
- package/packages/cli/src/resource-slug.test.ts +10 -0
- package/packages/cli/src/resource-slug.ts +4 -0
- package/packages/cli/template/.env.example +4 -0
- package/packages/cli/template/README.md +13 -0
- package/packages/cli/template/apps/web/README.md +12 -0
- package/packages/cli/template/apps/web/app/globals.css +12 -0
- package/packages/cli/template/apps/web/app/layout.tsx +18 -0
- package/packages/cli/template/apps/web/app/page.tsx +27 -0
- package/packages/cli/template/apps/web/app/posts/[slug]/page.tsx +38 -0
- package/packages/cli/template/apps/web/app/posts/page.tsx +20 -0
- package/packages/cli/template/apps/web/app/robots.txt/route.ts +9 -0
- package/packages/cli/template/apps/web/app/sitemap.xml/route.ts +20 -0
- package/packages/cli/template/apps/web/components/public-fields.tsx +22 -0
- package/packages/cli/template/apps/web/lib/openadmin-client.ts +71 -0
- package/packages/cli/template/apps/web/lib/seo.ts +42 -0
- package/packages/cli/template/apps/web/next-env.d.ts +2 -0
- package/packages/cli/template/apps/web/next.config.mjs +5 -0
- package/packages/cli/template/apps/web/package.json +29 -0
- package/packages/cli/template/apps/web/postcss.config.mjs +6 -0
- package/packages/cli/template/apps/web/public/brand/apple-touch-icon.png +0 -0
- package/packages/cli/template/apps/web/public/brand/favicon.svg +1 -0
- package/packages/cli/template/apps/web/public/brand/og-image.png +0 -0
- package/packages/cli/template/apps/web/public/brand/openadminjs-icon-new.png +0 -0
- package/packages/cli/template/apps/web/public/brand/openadminjs-logo-monochrome.png +0 -0
- package/packages/cli/template/apps/web/public/brand/openadminjs-logo-new.png +0 -0
- package/packages/cli/template/apps/web/tailwind.config.ts +21 -0
- package/packages/cli/template/apps/web/tsconfig.json +23 -0
- package/packages/cli/template/package.json +19 -0
- package/packages/cli/template/pnpm-workspace.yaml +3 -0
- package/packages/cli/tsconfig.json +10 -0
- package/packages/core/package.json +20 -0
- package/packages/core/src/index.js +1 -0
- package/packages/core/src/index.test.ts +27 -0
- package/packages/core/src/index.ts +61 -0
- package/packages/core/tsconfig.json +8 -0
- package/packages/create-openadminjs/package.json +25 -0
- package/packages/create-openadminjs/src/index.ts +70 -0
- package/packages/create-openadminjs/src/package-name.test.ts +13 -0
- package/packages/create-openadminjs/src/package-name.ts +8 -0
- package/packages/create-openadminjs/src/render-files.test.ts +26 -0
- package/packages/create-openadminjs/src/render-files.ts +21 -0
- package/packages/create-openadminjs/template/.env.example +4 -0
- package/packages/create-openadminjs/template/README.md +13 -0
- package/packages/create-openadminjs/template/apps/web/README.md +12 -0
- package/packages/create-openadminjs/template/apps/web/app/globals.css +12 -0
- package/packages/create-openadminjs/template/apps/web/app/layout.tsx +18 -0
- package/packages/create-openadminjs/template/apps/web/app/page.tsx +27 -0
- package/packages/create-openadminjs/template/apps/web/app/posts/[slug]/page.tsx +38 -0
- package/packages/create-openadminjs/template/apps/web/app/posts/page.tsx +20 -0
- package/packages/create-openadminjs/template/apps/web/app/robots.txt/route.ts +9 -0
- package/packages/create-openadminjs/template/apps/web/app/sitemap.xml/route.ts +20 -0
- package/packages/create-openadminjs/template/apps/web/components/public-fields.tsx +22 -0
- package/packages/create-openadminjs/template/apps/web/lib/openadmin-client.ts +71 -0
- package/packages/create-openadminjs/template/apps/web/lib/seo.ts +42 -0
- package/packages/create-openadminjs/template/apps/web/next-env.d.ts +2 -0
- package/packages/create-openadminjs/template/apps/web/next.config.mjs +5 -0
- package/packages/create-openadminjs/template/apps/web/package.json +29 -0
- package/packages/create-openadminjs/template/apps/web/postcss.config.mjs +6 -0
- package/packages/create-openadminjs/template/apps/web/public/brand/apple-touch-icon.png +0 -0
- package/packages/create-openadminjs/template/apps/web/public/brand/favicon.svg +1 -0
- package/packages/create-openadminjs/template/apps/web/public/brand/og-image.png +0 -0
- package/packages/create-openadminjs/template/apps/web/public/brand/openadminjs-icon-new.png +0 -0
- package/packages/create-openadminjs/template/apps/web/public/brand/openadminjs-logo-monochrome.png +0 -0
- package/packages/create-openadminjs/template/apps/web/public/brand/openadminjs-logo-new.png +0 -0
- package/packages/create-openadminjs/template/apps/web/tailwind.config.ts +21 -0
- package/packages/create-openadminjs/template/apps/web/tsconfig.json +23 -0
- package/packages/create-openadminjs/template/package.json +19 -0
- package/packages/create-openadminjs/template/pnpm-workspace.yaml +3 -0
- package/packages/create-openadminjs/tsconfig.json +10 -0
- package/packages/mail/package.json +18 -0
- package/packages/mail/src/index.test.ts +23 -0
- package/packages/mail/src/index.ts +246 -0
- package/packages/mail/tsconfig.json +5 -0
- package/packages/notifications/package.json +16 -0
- package/packages/notifications/src/index.test.ts +9 -0
- package/packages/notifications/src/index.ts +5 -0
- package/packages/notifications/tsconfig.json +5 -0
- package/packages/payments/package.json +15 -0
- package/packages/payments/src/index.ts +256 -0
- package/packages/payments/tsconfig.json +9 -0
- package/packages/permissions/package.json +17 -0
- package/packages/permissions/src/blueprints.js +57 -0
- package/packages/permissions/src/blueprints.test.ts +62 -0
- package/packages/permissions/src/blueprints.ts +89 -0
- package/packages/permissions/src/index.js +11 -0
- package/packages/permissions/src/index.test.ts +34 -0
- package/packages/permissions/src/index.ts +22 -0
- package/packages/permissions/tsconfig.json +8 -0
- package/packages/plugin-sdk/package.json +26 -0
- package/packages/plugin-sdk/src/hooks.ts +44 -0
- package/packages/plugin-sdk/src/index.ts +37 -0
- package/packages/plugin-sdk/src/sdk.test.ts +13 -0
- package/packages/plugin-sdk/tsconfig.json +8 -0
- package/packages/plugin-sdk/vitest.config.ts +5 -0
- package/packages/queue/package.json +16 -0
- package/packages/queue/src/index.test.ts +12 -0
- package/packages/queue/src/index.ts +6 -0
- package/packages/queue/tsconfig.json +5 -0
- package/packages/resource/package.json +17 -0
- package/packages/resource/src/index.js +177 -0
- package/packages/resource/src/index.test.ts +151 -0
- package/packages/resource/src/index.ts +344 -0
- package/packages/resource/tsconfig.json +8 -0
- package/packages/storage/package.json +16 -0
- package/packages/storage/src/index.test.ts +10 -0
- package/packages/storage/src/index.ts +23 -0
- package/packages/storage/tsconfig.json +5 -0
- package/pnpm-workspace.yaml +4 -0
- package/prisma/migrations/20260505151751_baseline_init_all_tables/migration.sql +371 -0
- package/prisma/migrations/migration_lock.toml +3 -0
- package/prisma/schema.prisma +291 -0
- package/prisma/seed.ts +210 -0
- package/scripts/check-static-site.mjs +17 -0
- package/scripts/e2e-smoke.mjs +17 -0
- package/scripts/make-executable.mjs +4 -0
- package/site/.nojekyll +0 -0
- package/site/assets/brand/apple-touch-icon.png +0 -0
- package/site/assets/brand/favicon.svg +1 -0
- package/site/assets/brand/og-image.png +0 -0
- package/site/assets/brand/openadminjs-icon-new.png +0 -0
- package/site/assets/brand/openadminjs-logo-monochrome.png +0 -0
- package/site/assets/brand/openadminjs-logo-new.png +0 -0
- package/site/assets/css/styles.css +1521 -0
- package/site/assets/js/main.js +193 -0
- package/site/assets/partners/arcbyte.svg +11 -0
- package/site/assets/partners/gridstack.svg +8 -0
- package/site/assets/partners/nebula.svg +12 -0
- package/site/assets/partners/orbitlab.svg +7 -0
- package/site/assets/partners/pulseforge.svg +11 -0
- package/site/assets/partners/vertex.svg +6 -0
- package/site/docs.html +1452 -0
- package/site/index.html +357 -0
- package/tsconfig.base.json +23 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates brand assets from raster masters in `site/assets/brand/`:
|
|
3
|
+
* - openadminjs-logo-new.png (required) — full wordmark / horizontal logo
|
|
4
|
+
* - openadminjs-icon-new.png (optional) — square mark for favicon / app icon; falls back to logo if missing
|
|
5
|
+
*
|
|
6
|
+
* Outputs PNG + thin SVG wrappers (`<image href="…"/>`) for each target directory.
|
|
7
|
+
*/
|
|
8
|
+
import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
9
|
+
import { join, dirname } from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
import sharp from "sharp";
|
|
12
|
+
|
|
13
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
/** `packages/brand/src` → monorepo root */
|
|
15
|
+
const repoRoot = join(__dirname, "../../..");
|
|
16
|
+
|
|
17
|
+
const LOGO_SRC = join(repoRoot, "site/assets/brand/openadminjs-logo-new.png");
|
|
18
|
+
const targets = [
|
|
19
|
+
"apps/admin/public/brand",
|
|
20
|
+
"apps/web/public/brand",
|
|
21
|
+
"packages/cli/template/apps/web/public/brand",
|
|
22
|
+
"packages/create-openadminjs/template/apps/web/public/brand",
|
|
23
|
+
"packages/brand/apps/web/public/brand",
|
|
24
|
+
"packages/brand/apps/admin/public/brand",
|
|
25
|
+
"site/assets/brand"
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
const UNUSED_BRAND_FILES = [
|
|
29
|
+
"openadminjs-logo-horizontal.svg",
|
|
30
|
+
"openadminjs-logo.svg",
|
|
31
|
+
"openadminjs-logo-dark.svg",
|
|
32
|
+
"openadminjs-logo-monochrome.svg",
|
|
33
|
+
"openadminjs-icon.png",
|
|
34
|
+
"openadminjs-icon.svg",
|
|
35
|
+
"og-image.svg",
|
|
36
|
+
"favicon.png"
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
/** SVG shell so browsers can scale; raster lives alongside as `href`. */
|
|
40
|
+
function svgRasterImage(href, w, h, label) {
|
|
41
|
+
const safe = String(label).replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
42
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 ${w} ${h}" role="img" aria-label="${safe}"><image xlink:href="${href}" href="${href}" width="${w}" height="${h}" preserveAspectRatio="xMidYMid meet"/></svg>`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function extractLogoMark(logoBuf) {
|
|
46
|
+
const { data, info } = await sharp(logoBuf).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
|
47
|
+
const { width, height, channels } = info;
|
|
48
|
+
const alphaIndex = channels - 1;
|
|
49
|
+
|
|
50
|
+
const activeCols = new Array(width).fill(false);
|
|
51
|
+
for (let x = 0; x < width; x += 1) {
|
|
52
|
+
for (let y = 0; y < height; y += 1) {
|
|
53
|
+
const idx = (y * width + x) * channels + alphaIndex;
|
|
54
|
+
if (data[idx] > 18) {
|
|
55
|
+
activeCols[x] = true;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
let symbolStart = activeCols.findIndex(Boolean);
|
|
62
|
+
if (symbolStart < 0) symbolStart = 0;
|
|
63
|
+
|
|
64
|
+
let symbolEnd = width - 1;
|
|
65
|
+
let gap = 0;
|
|
66
|
+
for (let x = symbolStart; x < width; x += 1) {
|
|
67
|
+
if (activeCols[x]) {
|
|
68
|
+
gap = 0;
|
|
69
|
+
symbolEnd = x;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
gap += 1;
|
|
73
|
+
if (gap >= 10) break;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const activeRows = new Array(height).fill(false);
|
|
77
|
+
for (let y = 0; y < height; y += 1) {
|
|
78
|
+
for (let x = symbolStart; x <= symbolEnd; x += 1) {
|
|
79
|
+
const idx = (y * width + x) * channels + alphaIndex;
|
|
80
|
+
if (data[idx] > 18) {
|
|
81
|
+
activeRows[y] = true;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
let top = activeRows.findIndex(Boolean);
|
|
88
|
+
if (top < 0) top = 0;
|
|
89
|
+
let bottom = height - 1;
|
|
90
|
+
for (let y = height - 1; y >= 0; y -= 1) {
|
|
91
|
+
if (activeRows[y]) {
|
|
92
|
+
bottom = y;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const markW = Math.max(1, symbolEnd - symbolStart + 1);
|
|
98
|
+
const markH = Math.max(1, bottom - top + 1);
|
|
99
|
+
const side = Math.max(markW, markH);
|
|
100
|
+
const cx = symbolStart + markW / 2;
|
|
101
|
+
const cy = top + markH / 2;
|
|
102
|
+
|
|
103
|
+
let left = Math.floor(cx - side / 2);
|
|
104
|
+
let cropTop = Math.floor(cy - side / 2);
|
|
105
|
+
if (left < 0) left = 0;
|
|
106
|
+
if (cropTop < 0) cropTop = 0;
|
|
107
|
+
if (left + side > width) left = width - side;
|
|
108
|
+
if (cropTop + side > height) cropTop = height - side;
|
|
109
|
+
|
|
110
|
+
return sharp(logoBuf)
|
|
111
|
+
.extract({ left: Math.max(0, left), top: Math.max(0, cropTop), width: Math.min(side, width), height: Math.min(side, height) })
|
|
112
|
+
.resize(512, 512, { fit: "cover" })
|
|
113
|
+
.png()
|
|
114
|
+
.toBuffer();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async function writeBrandToDir(targetDir) {
|
|
118
|
+
mkdirSync(targetDir, { recursive: true });
|
|
119
|
+
|
|
120
|
+
const logoBuf = readFileSync(LOGO_SRC);
|
|
121
|
+
const logoMeta = await sharp(logoBuf).metadata();
|
|
122
|
+
const lw = logoMeta.width ?? 800;
|
|
123
|
+
const lh = logoMeta.height ?? 200;
|
|
124
|
+
|
|
125
|
+
writeFileSync(join(targetDir, "openadminjs-logo-new.png"), logoBuf);
|
|
126
|
+
|
|
127
|
+
const monoPng = await sharp(logoBuf).grayscale().png().toBuffer();
|
|
128
|
+
writeFileSync(join(targetDir, "openadminjs-logo-monochrome.png"), monoPng);
|
|
129
|
+
|
|
130
|
+
const iconBuf = await extractLogoMark(logoBuf);
|
|
131
|
+
writeFileSync(join(targetDir, "openadminjs-icon-new.png"), iconBuf);
|
|
132
|
+
|
|
133
|
+
writeFileSync(join(targetDir, "favicon.svg"), svgRasterImage("openadminjs-icon-new.png", 512, 512, "OpenAdminJS"));
|
|
134
|
+
|
|
135
|
+
const apple = await sharp(iconBuf).resize(180, 180, { fit: "cover" }).png().toBuffer();
|
|
136
|
+
writeFileSync(join(targetDir, "apple-touch-icon.png"), apple);
|
|
137
|
+
|
|
138
|
+
const ogW = 1200;
|
|
139
|
+
const ogH = 630;
|
|
140
|
+
const logoForOg = await sharp(logoBuf).resize(560, null, { fit: "inside" }).png().toBuffer();
|
|
141
|
+
const ogLm = await sharp(logoForOg).metadata();
|
|
142
|
+
const logoH = ogLm.height ?? 0;
|
|
143
|
+
const top = Math.max(0, Math.round((ogH - logoH) / 2));
|
|
144
|
+
const ogPng = await sharp({
|
|
145
|
+
create: { width: ogW, height: ogH, channels: 4, background: { r: 248, g: 251, b: 255, alpha: 1 } }
|
|
146
|
+
})
|
|
147
|
+
.composite([{ input: logoForOg, left: 72, top }])
|
|
148
|
+
.png()
|
|
149
|
+
.toBuffer();
|
|
150
|
+
writeFileSync(join(targetDir, "og-image.png"), ogPng);
|
|
151
|
+
|
|
152
|
+
for (const filename of UNUSED_BRAND_FILES) {
|
|
153
|
+
const full = join(targetDir, filename);
|
|
154
|
+
if (existsSync(full)) unlinkSync(full);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async function main() {
|
|
159
|
+
if (process.argv.includes("--check")) {
|
|
160
|
+
if (!existsSync(LOGO_SRC)) {
|
|
161
|
+
console.error(`Missing required source: ${LOGO_SRC}`);
|
|
162
|
+
process.exit(1);
|
|
163
|
+
}
|
|
164
|
+
process.exit(0);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (!existsSync(LOGO_SRC)) {
|
|
168
|
+
throw new Error(`Missing required source logo: ${LOGO_SRC}`);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
for (const rel of targets) {
|
|
172
|
+
const dir = join(repoRoot, rel);
|
|
173
|
+
await writeBrandToDir(dir);
|
|
174
|
+
console.log("Wrote", rel);
|
|
175
|
+
}
|
|
176
|
+
console.log("Brand assets generated from openadminjs-logo-new.png");
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
main().catch((e) => {
|
|
180
|
+
console.error(e);
|
|
181
|
+
process.exit(1);
|
|
182
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "openadminjs",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"bin": {
|
|
6
|
+
"openadminjs": "dist/index.js"
|
|
7
|
+
},
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./create-project": {
|
|
14
|
+
"types": "./dist/create-project.d.ts",
|
|
15
|
+
"default": "./dist/create-project.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"main": "dist/index.js",
|
|
19
|
+
"types": "dist/index.d.ts",
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"README.md"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc -p tsconfig.json && node ../../scripts/make-executable.mjs dist/index.js",
|
|
29
|
+
"lint": "tsc -p tsconfig.json --noEmit",
|
|
30
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
31
|
+
"test": "vitest run"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@clack/prompts": "^0.8.2",
|
|
35
|
+
"cac": "^6.7.14",
|
|
36
|
+
"fs-extra": "^11.2.0",
|
|
37
|
+
"picocolors": "^1.1.1"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/fs-extra": "^11.0.4",
|
|
41
|
+
"typescript": "^5.7.2",
|
|
42
|
+
"vitest": "^2.1.8"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { cancel, confirm, intro, isCancel, outro, select, text } from "@clack/prompts";
|
|
6
|
+
import fsExtra from "fs-extra";
|
|
7
|
+
import pc from "picocolors";
|
|
8
|
+
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const { copySync, ensureDirSync, readFileSync, writeFileSync } = fsExtra;
|
|
11
|
+
|
|
12
|
+
export type PackageManager = "pnpm" | "npm" | "yarn";
|
|
13
|
+
export type DatabaseDriver = "postgresql";
|
|
14
|
+
|
|
15
|
+
export type CreateProjectOptions = {
|
|
16
|
+
projectName?: string;
|
|
17
|
+
cwd?: string;
|
|
18
|
+
packageManager?: PackageManager;
|
|
19
|
+
database?: DatabaseDriver;
|
|
20
|
+
superadminEmail?: string;
|
|
21
|
+
superadminPassword?: string;
|
|
22
|
+
git?: boolean;
|
|
23
|
+
install?: boolean;
|
|
24
|
+
templateDir?: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type CreateProjectResult = {
|
|
28
|
+
appName: string;
|
|
29
|
+
packageName: string;
|
|
30
|
+
targetDir: string;
|
|
31
|
+
packageManager: PackageManager;
|
|
32
|
+
database: DatabaseDriver;
|
|
33
|
+
superadminEmail: string;
|
|
34
|
+
git: boolean;
|
|
35
|
+
install: boolean;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const placeholderPattern =
|
|
39
|
+
/__APP_NAME__|__PACKAGE_NAME__|__DATABASE_URL__|__DATABASE_PROVIDER__/g;
|
|
40
|
+
|
|
41
|
+
export function toPackageName(input: string): string {
|
|
42
|
+
return input
|
|
43
|
+
.trim()
|
|
44
|
+
.toLowerCase()
|
|
45
|
+
.replace(/[^a-z0-9-]+/g, "-")
|
|
46
|
+
.replace(/^-|-$/g, "");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function defaultTemplateDir(): string {
|
|
50
|
+
return resolve(__dirname, "../template");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function databaseUrl(packageName: string, database: DatabaseDriver): string {
|
|
54
|
+
if (database === "postgresql") {
|
|
55
|
+
return `postgresql://openadminjs:openadminjs@localhost:5432/${packageName}?schema=public`;
|
|
56
|
+
}
|
|
57
|
+
return "";
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function renderFile(file: string, replacements: Record<string, string>): void {
|
|
61
|
+
const content = readFileSync(file, "utf8");
|
|
62
|
+
writeFileSync(file, content.replace(placeholderPattern, (key) => replacements[key] ?? key));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function renderTemplateFiles(targetDir: string, replacements: Record<string, string>): void {
|
|
66
|
+
const stack = [targetDir];
|
|
67
|
+
while (stack.length) {
|
|
68
|
+
const current = stack.pop();
|
|
69
|
+
if (!current) continue;
|
|
70
|
+
for (const entry of readdirSync(current, { withFileTypes: true })) {
|
|
71
|
+
const path = resolve(current, entry.name);
|
|
72
|
+
if (entry.isDirectory()) {
|
|
73
|
+
stack.push(path);
|
|
74
|
+
} else if (entry.isFile()) {
|
|
75
|
+
renderFile(path, replacements);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function createProject(options: Required<CreateProjectOptions>): CreateProjectResult {
|
|
82
|
+
const appName = options.projectName;
|
|
83
|
+
const packageName = toPackageName(appName);
|
|
84
|
+
if (!packageName) throw new Error("Project name must contain at least one letter or number.");
|
|
85
|
+
|
|
86
|
+
const targetDir = resolve(options.cwd, appName);
|
|
87
|
+
if (existsSync(targetDir)) throw new Error(`${targetDir} already exists.`);
|
|
88
|
+
|
|
89
|
+
ensureDirSync(targetDir);
|
|
90
|
+
copySync(options.templateDir, targetDir, {
|
|
91
|
+
overwrite: false,
|
|
92
|
+
errorOnExist: true,
|
|
93
|
+
filter: (source) => !source.includes("node_modules") && !source.includes(".next") && !source.includes("dist")
|
|
94
|
+
});
|
|
95
|
+
renderTemplateFiles(targetDir, {
|
|
96
|
+
__APP_NAME__: appName,
|
|
97
|
+
__PACKAGE_NAME__: packageName,
|
|
98
|
+
__DATABASE_PROVIDER__: options.database,
|
|
99
|
+
__DATABASE_URL__: databaseUrl(packageName, options.database)
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
if (options.git) {
|
|
103
|
+
spawnSync("git", ["init"], { cwd: targetDir, stdio: "ignore" });
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (options.install) {
|
|
107
|
+
const installArgs = options.packageManager === "yarn" ? [] : ["install"];
|
|
108
|
+
spawnSync(options.packageManager, installArgs, { cwd: targetDir, stdio: "inherit" });
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
appName,
|
|
113
|
+
packageName,
|
|
114
|
+
targetDir,
|
|
115
|
+
packageManager: options.packageManager,
|
|
116
|
+
database: options.database,
|
|
117
|
+
superadminEmail: options.superadminEmail,
|
|
118
|
+
git: options.git,
|
|
119
|
+
install: options.install
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function printNextSteps(result: CreateProjectResult): void {
|
|
124
|
+
const pm = result.packageManager;
|
|
125
|
+
outro(
|
|
126
|
+
`${pc.green("Project created.")}\n\nNext steps:\n cd ${result.appName}\n ${pm} install\n docker compose up -d\n ${pm} db:migrate\n ${pm} db:seed\n ${pm} dev\n\nAdmin: http://localhost:3000\nAPI: http://localhost:4000\nDocs: http://localhost:4000/api/docs\n\nSuperadmin: ${result.superadminEmail} / <your password>`
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export async function createProjectInteractive(options: CreateProjectOptions = {}): Promise<CreateProjectResult | undefined> {
|
|
131
|
+
intro(pc.green("Create OpenAdminJS"));
|
|
132
|
+
|
|
133
|
+
const projectName =
|
|
134
|
+
options.projectName ??
|
|
135
|
+
(await text({
|
|
136
|
+
message: "Project name",
|
|
137
|
+
defaultValue: "my-app",
|
|
138
|
+
placeholder: "my-app"
|
|
139
|
+
}));
|
|
140
|
+
if (isCancel(projectName)) {
|
|
141
|
+
cancel("Cancelled");
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const packageManager =
|
|
146
|
+
options.packageManager ??
|
|
147
|
+
(await select<PackageManager>({
|
|
148
|
+
message: "Package manager",
|
|
149
|
+
options: [
|
|
150
|
+
{ value: "pnpm", label: "pnpm" },
|
|
151
|
+
{ value: "npm", label: "npm" },
|
|
152
|
+
{ value: "yarn", label: "yarn" }
|
|
153
|
+
],
|
|
154
|
+
initialValue: "pnpm"
|
|
155
|
+
}));
|
|
156
|
+
if (isCancel(packageManager)) {
|
|
157
|
+
cancel("Cancelled");
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const database =
|
|
162
|
+
options.database ??
|
|
163
|
+
(await select<DatabaseDriver>({
|
|
164
|
+
message: "Database",
|
|
165
|
+
options: [{ value: "postgresql", label: "PostgreSQL" }],
|
|
166
|
+
initialValue: "postgresql"
|
|
167
|
+
}));
|
|
168
|
+
if (isCancel(database)) {
|
|
169
|
+
cancel("Cancelled");
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const superadminEmail =
|
|
174
|
+
options.superadminEmail ??
|
|
175
|
+
(await text({
|
|
176
|
+
message: "Superadmin email",
|
|
177
|
+
defaultValue: "admin@localhost.dev",
|
|
178
|
+
placeholder: "admin@localhost.dev",
|
|
179
|
+
validate(value) {
|
|
180
|
+
return /^\S+@\S+\.\S+$/.test(value) ? undefined : "Enter a valid email address.";
|
|
181
|
+
}
|
|
182
|
+
}));
|
|
183
|
+
if (isCancel(superadminEmail)) {
|
|
184
|
+
cancel("Cancelled");
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const superadminPassword =
|
|
189
|
+
options.superadminPassword ??
|
|
190
|
+
(await text({
|
|
191
|
+
message: "Superadmin password",
|
|
192
|
+
placeholder: "At least 8 characters",
|
|
193
|
+
validate(value) {
|
|
194
|
+
return value.length >= 8 ? undefined : "Password must be at least 8 characters.";
|
|
195
|
+
}
|
|
196
|
+
}));
|
|
197
|
+
if (isCancel(superadminPassword)) {
|
|
198
|
+
cancel("Cancelled");
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const git = options.git ?? (await confirm({ message: "Initialize git?", initialValue: true }));
|
|
203
|
+
if (isCancel(git)) {
|
|
204
|
+
cancel("Cancelled");
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const install = options.install ?? (await confirm({ message: "Install dependencies now?", initialValue: false }));
|
|
209
|
+
if (isCancel(install)) {
|
|
210
|
+
cancel("Cancelled");
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const result = createProject({
|
|
215
|
+
projectName: String(projectName),
|
|
216
|
+
cwd: options.cwd ?? process.cwd(),
|
|
217
|
+
packageManager,
|
|
218
|
+
database,
|
|
219
|
+
superadminEmail: String(superadminEmail),
|
|
220
|
+
superadminPassword: String(superadminPassword),
|
|
221
|
+
git,
|
|
222
|
+
install,
|
|
223
|
+
templateDir: options.templateDir ?? defaultTemplateDir()
|
|
224
|
+
});
|
|
225
|
+
printNextSteps(result);
|
|
226
|
+
return result;
|
|
227
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { modelNameToResourceSlug } from "./resource-slug.js";
|
|
3
|
+
|
|
4
|
+
describe("openadminjs cli", () => {
|
|
5
|
+
it("exposes resource slug helper used by generate resource", () => {
|
|
6
|
+
expect(modelNameToResourceSlug("OrderItem")).toBe("order-item");
|
|
7
|
+
});
|
|
8
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { cac } from "cac";
|
|
5
|
+
import pc from "picocolors";
|
|
6
|
+
import { createProjectInteractive } from "./create-project.js";
|
|
7
|
+
import { modelNameToResourceSlug } from "./resource-slug.js";
|
|
8
|
+
|
|
9
|
+
const cli = cac("openadminjs");
|
|
10
|
+
|
|
11
|
+
function runScript(name: string): void {
|
|
12
|
+
const scripts: Record<string, string> = {
|
|
13
|
+
dev: "pnpm --parallel --filter @openadminjs/api --filter @openadminjs/admin dev",
|
|
14
|
+
build: "pnpm -r build",
|
|
15
|
+
start: "pnpm --parallel --filter @openadminjs/api --filter @openadminjs/admin start"
|
|
16
|
+
};
|
|
17
|
+
console.log(pc.cyan(`Run: ${scripts[name]}`));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function doctor(): void {
|
|
21
|
+
const required = ["package.json", "pnpm-workspace.yaml", ".env.example", "prisma/schema.prisma"];
|
|
22
|
+
const missing = required.filter((file) => !existsSync(join(process.cwd(), file)));
|
|
23
|
+
if (missing.length) {
|
|
24
|
+
console.error(pc.red("OpenAdminJS doctor found missing files:"));
|
|
25
|
+
for (const file of missing) console.error(` - ${file}`);
|
|
26
|
+
process.exitCode = 1;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
console.log(pc.green("OpenAdminJS doctor passed."));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function securityCheck(): void {
|
|
33
|
+
const envExample = existsSync(".env.example") ? readFileSync(".env.example", "utf8") : "";
|
|
34
|
+
const findings: string[] = [];
|
|
35
|
+
if (!envExample.includes("JWT_SECRET")) findings.push("JWT_SECRET is missing from .env.example");
|
|
36
|
+
if (envExample.includes("DATABASE_URL=postgresql://") && !envExample.includes("localhost")) {
|
|
37
|
+
findings.push("DATABASE_URL example should not point to production");
|
|
38
|
+
}
|
|
39
|
+
if (existsSync("apps/admin/app")) {
|
|
40
|
+
const login = existsSync("apps/admin/app/login/page.tsx");
|
|
41
|
+
if (!login) findings.push("Admin login route is missing");
|
|
42
|
+
}
|
|
43
|
+
if (findings.length) {
|
|
44
|
+
console.error(pc.red("Security check failed:"));
|
|
45
|
+
for (const finding of findings) console.error(` - ${finding}`);
|
|
46
|
+
process.exitCode = 1;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
console.log(pc.green("Security check passed."));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function generateResource(modelName: string, options: { force?: boolean }): void {
|
|
53
|
+
const name = modelNameToResourceSlug(modelName);
|
|
54
|
+
const targetDir = join(process.cwd(), "apps/api/src/resources");
|
|
55
|
+
const target = join(targetDir, `${name}.resource.ts`);
|
|
56
|
+
if (existsSync(target) && !options.force) {
|
|
57
|
+
console.error(pc.red(`${target} already exists. Use --force to overwrite.`));
|
|
58
|
+
process.exitCode = 1;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
mkdirSync(targetDir, { recursive: true });
|
|
62
|
+
const plural = `${name}s`;
|
|
63
|
+
writeFileSync(
|
|
64
|
+
target,
|
|
65
|
+
`import { defineResource } from '@openadminjs/core';\n\nexport default defineResource({\n name: '${plural}',\n label: '${modelName}s',\n model: '${modelName}',\n titleField: 'id',\n icon: 'Database',\n permissions: {\n read: '${plural}.read',\n create: '${plural}.create',\n update: '${plural}.update',\n delete: '${plural}.delete',\n },\n fields: {\n id: { type: 'id', label: 'ID', create: false, edit: false },\n },\n});\n`
|
|
66
|
+
);
|
|
67
|
+
console.log(pc.green(`Created ${target}`));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
cli.command("dev", "Start API and admin apps").action(() => runScript("dev"));
|
|
71
|
+
cli.command("create [projectName]", "Create a new OpenAdminJS project").action(async (projectName?: string) => {
|
|
72
|
+
try {
|
|
73
|
+
await createProjectInteractive({ projectName });
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.error(pc.red(error instanceof Error ? error.message : "Failed to create project."));
|
|
76
|
+
process.exitCode = 1;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
cli.command("build", "Build all workspaces").action(() => runScript("build"));
|
|
80
|
+
cli.command("start", "Start production apps").action(() => runScript("start"));
|
|
81
|
+
cli.command("db migrate", "Run Prisma migrations").action(() => console.log("Run: pnpm --filter @openadminjs/api prisma migrate dev"));
|
|
82
|
+
cli.command("db seed", "Seed demo data").action(() => console.log("Run: pnpm --filter @openadminjs/api prisma db seed"));
|
|
83
|
+
cli.command("db studio", "Open Prisma Studio").action(() => console.log("Run: pnpm --filter @openadminjs/api prisma studio"));
|
|
84
|
+
cli.command("generate resource <modelName>", "Generate safe resource config").option("--force", "Overwrite existing file").action(generateResource);
|
|
85
|
+
cli.command("make resource <modelName>", "Alias for generate resource").option("--force", "Overwrite existing file").action(generateResource);
|
|
86
|
+
cli.command("doctor", "Check generated project health").action(doctor);
|
|
87
|
+
cli.command("security", "Run security checklist").action(securityCheck);
|
|
88
|
+
cli.command("security check", "Run security checklist").action(securityCheck);
|
|
89
|
+
cli.help();
|
|
90
|
+
cli.parse();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { modelNameToResourceSlug } from "./resource-slug.js";
|
|
3
|
+
|
|
4
|
+
describe("modelNameToResourceSlug", () => {
|
|
5
|
+
it("converts PascalCase to kebab-case", () => {
|
|
6
|
+
expect(modelNameToResourceSlug("Post")).toBe("post");
|
|
7
|
+
expect(modelNameToResourceSlug("OrderItem")).toBe("order-item");
|
|
8
|
+
expect(modelNameToResourceSlug("BlogCategory")).toBe("blog-category");
|
|
9
|
+
});
|
|
10
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# OpenAdminJS Web Layer
|
|
2
|
+
|
|
3
|
+
This folder is part of the generated application, not the library marketing site.
|
|
4
|
+
|
|
5
|
+
Use it for:
|
|
6
|
+
|
|
7
|
+
- public frontend pages powered by OpenAdminJS API/resource metadata;
|
|
8
|
+
- custom pages for entities created in the admin;
|
|
9
|
+
- SEO metadata, canonical URLs, robots and sitemap generation;
|
|
10
|
+
- field-level public rendering where you choose which resource fields appear on each page.
|
|
11
|
+
|
|
12
|
+
The marketing landing/docs site for GitHub Pages lives in `/site`.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Metadata } from "next";
|
|
2
|
+
import "./globals.css";
|
|
3
|
+
|
|
4
|
+
export const metadata: Metadata = {
|
|
5
|
+
title: {
|
|
6
|
+
default: "OpenAdminJS Web",
|
|
7
|
+
template: "%s | OpenAdminJS Web"
|
|
8
|
+
},
|
|
9
|
+
description: "Public frontend layer powered by OpenAdminJS resources."
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
13
|
+
return (
|
|
14
|
+
<html lang="en">
|
|
15
|
+
<body>{children}</body>
|
|
16
|
+
</html>
|
|
17
|
+
);
|
|
18
|
+
}
|