openadminjs 0.1.4 → 0.1.6
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 +16 -113
- package/dist/create-project.d.ts +34 -0
- package/dist/create-project.js +229 -0
- package/dist/create-project.test.d.ts +1 -0
- package/dist/create-project.test.js +46 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +138 -0
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +7 -0
- package/dist/resource-slug.d.ts +2 -0
- package/dist/resource-slug.js +4 -0
- package/dist/resource-slug.test.d.ts +1 -0
- package/dist/resource-slug.test.js +9 -0
- package/package.json +36 -24
- package/{packages/cli/template → template}/.env.example +2 -2
- package/.env.example +0 -9
- package/.github/FUNDING.yml +0 -3
- package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -10
- package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -10
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -9
- package/.github/dependabot.yml +0 -10
- package/.github/workflows/ci.yml +0 -26
- package/CHANGELOG.md +0 -5
- package/CODE_OF_CONDUCT.md +0 -3
- package/CONTRIBUTING.md +0 -11
- package/LICENSE +0 -21
- package/ROADMAP.md +0 -7
- package/SECURITY.md +0 -11
- package/apps/admin/app/api/auth/login/route.ts +0 -51
- package/apps/admin/app/api/auth/logout/route.ts +0 -11
- package/apps/admin/app/api/auth/refresh/route.ts +0 -46
- package/apps/admin/app/api-tokens/page.tsx +0 -253
- package/apps/admin/app/audit-logs/page.tsx +0 -5
- package/apps/admin/app/dashboard/page.tsx +0 -392
- package/apps/admin/app/files/page.tsx +0 -5
- package/apps/admin/app/globals.css +0 -206
- package/apps/admin/app/jobs/page.tsx +0 -19
- package/apps/admin/app/layout.tsx +0 -57
- package/apps/admin/app/login/page.test.tsx +0 -18
- package/apps/admin/app/login/page.tsx +0 -161
- package/apps/admin/app/login/safe-next-param.ts +0 -4
- package/apps/admin/app/notifications/page.tsx +0 -146
- package/apps/admin/app/page.tsx +0 -5
- package/apps/admin/app/plugins/page.tsx +0 -407
- package/apps/admin/app/profile/page.tsx +0 -116
- package/apps/admin/app/resources/[resource]/[id]/edit/page.tsx +0 -45
- package/apps/admin/app/resources/[resource]/[id]/page.tsx +0 -449
- package/apps/admin/app/resources/[resource]/create/page.tsx +0 -34
- package/apps/admin/app/resources/[resource]/page.tsx +0 -100
- package/apps/admin/app/settings/page.tsx +0 -233
- package/apps/admin/components/ai-assistant-widget.tsx +0 -684
- package/apps/admin/components/app-shell.tsx +0 -305
- package/apps/admin/components/auth-guard.test.tsx +0 -55
- package/apps/admin/components/auth-guard.tsx +0 -39
- package/apps/admin/components/jobs-panel.tsx +0 -103
- package/apps/admin/components/logo.tsx +0 -30
- package/apps/admin/components/resource-form.tsx +0 -349
- package/apps/admin/components/resource-table.tsx +0 -277
- package/apps/admin/lib/ai-events.ts +0 -23
- package/apps/admin/lib/api.test.ts +0 -118
- package/apps/admin/lib/api.ts +0 -135
- package/apps/admin/lib/auth-flow.e2e.test.ts +0 -79
- package/apps/admin/lib/brand.ts +0 -14
- package/apps/admin/lib/locale.ts +0 -49
- package/apps/admin/lib/tokens.ts +0 -93
- package/apps/admin/middleware.ts +0 -58
- package/apps/admin/next-env.d.ts +0 -6
- package/apps/admin/next.config.mjs +0 -7
- package/apps/admin/package.json +0 -44
- package/apps/admin/tailwind.config.ts +0 -37
- package/apps/admin/vitest.config.ts +0 -7
- package/apps/api/package.json +0 -56
- package/apps/api/plugins.manifest.example.json +0 -34
- package/apps/api/plugins.manifest.json +0 -4
- package/apps/api/src/access/catalog.ts +0 -112
- package/apps/api/src/access/derive-permissions.test.ts +0 -26
- package/apps/api/src/access/derive-permissions.ts +0 -36
- package/apps/api/src/access/public-catalog.ts +0 -28
- package/apps/api/src/admin/admin-ai.controller.ts +0 -125
- package/apps/api/src/admin/admin-ai.events.ts +0 -23
- package/apps/api/src/admin/admin-ai.service.ts +0 -1271
- package/apps/api/src/admin/admin-analytics.service.ts +0 -164
- package/apps/api/src/admin/admin-plugins.controller.ts +0 -32
- package/apps/api/src/admin/admin-plugins.service.ts +0 -267
- package/apps/api/src/admin/admin-resource.service.test.ts +0 -118
- package/apps/api/src/admin/admin-resource.service.ts +0 -375
- package/apps/api/src/admin/admin.controller.ts +0 -72
- package/apps/api/src/admin/admin.module.ts +0 -30
- package/apps/api/src/admin/dto/plugins.dto.ts +0 -55
- package/apps/api/src/admin/validate-resource-payload.test.ts +0 -44
- package/apps/api/src/admin/validate-resource-payload.ts +0 -103
- package/apps/api/src/app.module.ts +0 -45
- package/apps/api/src/auth/auth.controller.ts +0 -70
- package/apps/api/src/auth/auth.dto.ts +0 -49
- package/apps/api/src/auth/auth.module.ts +0 -30
- package/apps/api/src/auth/auth.service.test.ts +0 -75
- package/apps/api/src/auth/auth.service.ts +0 -231
- package/apps/api/src/common/auth-realm.decorator.ts +0 -6
- package/apps/api/src/common/auth.guard.test.ts +0 -61
- package/apps/api/src/common/auth.guard.ts +0 -78
- package/apps/api/src/common/casl-ability.factory.test.ts +0 -33
- package/apps/api/src/common/casl-ability.factory.ts +0 -41
- package/apps/api/src/common/current-user.decorator.ts +0 -6
- package/apps/api/src/common/permission.decorator.ts +0 -7
- package/apps/api/src/common/permissions.guard.ts +0 -31
- package/apps/api/src/common/prisma.service.ts +0 -13
- package/apps/api/src/health/health.controller.ts +0 -25
- package/apps/api/src/mail/mail.module.ts +0 -9
- package/apps/api/src/mail/mail.service.ts +0 -115
- package/apps/api/src/main.ts +0 -37
- package/apps/api/src/plugins/bootstrap.ts +0 -4
- package/apps/api/src/plugins/bundled/admin-widget.plugin.ts +0 -25
- package/apps/api/src/plugins/bundled/hello.plugin.ts +0 -19
- package/apps/api/src/plugins/bundled/image-optimizer.plugin.ts +0 -22
- package/apps/api/src/plugins/bundled/registry.ts +0 -13
- package/apps/api/src/plugins/bundled/seo.plugin.ts +0 -25
- package/apps/api/src/plugins/manifest-path.ts +0 -35
- package/apps/api/src/plugins/manifest.schema.test.ts +0 -36
- package/apps/api/src/plugins/manifest.schema.ts +0 -58
- package/apps/api/src/plugins/plugin-api.interceptor.ts +0 -47
- package/apps/api/src/plugins/plugin-loader.ts +0 -134
- package/apps/api/src/plugins/plugin-runtime.test.ts +0 -24
- package/apps/api/src/plugins/plugin-runtime.ts +0 -85
- package/apps/api/src/queue/queue.controller.ts +0 -28
- package/apps/api/src/queue/queue.module.ts +0 -23
- package/apps/api/src/queue/queue.processor.ts +0 -47
- package/apps/api/src/queue/queue.service.ts +0 -50
- package/apps/api/src/resources/categories.resource.ts +0 -21
- package/apps/api/src/resources/commerce.resource.ts +0 -157
- package/apps/api/src/resources/operations.resource.ts +0 -111
- package/apps/api/src/resources/posts.resource.ts +0 -88
- package/apps/api/src/resources/registry.ts +0 -27
- package/apps/api/src/resources/resource-hooks.install.ts +0 -18
- package/apps/api/src/resources/resource-hooks.registry.test.ts +0 -72
- package/apps/api/src/resources/resource-hooks.registry.ts +0 -66
- package/apps/api/src/resources/resource-hooks.runner.ts +0 -93
- package/apps/api/src/resources/system.resource.ts +0 -51
- package/apps/api/src/resources/users.resource.ts +0 -19
- package/apps/api/src/store/payment/payment.controller.ts +0 -98
- package/apps/api/src/store/payment/payment.module.ts +0 -14
- package/apps/api/src/store/payment/payment.provider.ts +0 -38
- package/apps/api/src/store/payment/payment.service.ts +0 -235
- package/apps/api/src/store/store.controller.ts +0 -26
- package/apps/api/src/store/store.module.ts +0 -12
- package/apps/api/src/test-setup.ts +0 -1
- package/apps/api/tsconfig.json +0 -11
- package/apps/api/vitest.config.ts +0 -21
- package/apps/web/lib/openadmin-client.ts +0 -82
- package/apps/web/lib/seo.test.ts +0 -41
- package/apps/web/lib/seo.ts +0 -53
- package/apps/web/next-env.d.ts +0 -6
- package/apps/web/package.json +0 -30
- package/apps/web/postcss.config.mjs +0 -6
- package/apps/web/public/brand/apple-touch-icon.png +0 -0
- package/apps/web/public/brand/favicon.svg +0 -1
- 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/test/next-stub.ts +0 -7
- package/apps/web/tsconfig.json +0 -23
- package/apps/web/vitest.config.ts +0 -19
- package/docs/content/security.md +0 -7
- package/eslint.config.mjs +0 -11
- package/examples/README.md +0 -80
- package/examples/basic-admin/README.md +0 -24
- package/examples/basic-admin/package.json +0 -17
- package/examples/basic-admin/prisma/models.fragment.prisma +0 -12
- package/examples/basic-admin/src/index.test.ts +0 -8
- package/examples/basic-admin/src/index.ts +0 -5
- package/examples/basic-admin/src/resources/lead.resource.ts +0 -30
- package/examples/basic-admin/tsconfig.json +0 -7
- package/examples/basic-admin/vitest.config.ts +0 -16
- package/examples/blog-admin/README.md +0 -18
- package/examples/blog-admin/package.json +0 -17
- package/examples/blog-admin/prisma/models.fragment.prisma +0 -30
- package/examples/blog-admin/src/index.test.ts +0 -8
- package/examples/blog-admin/src/index.ts +0 -5
- package/examples/blog-admin/src/resources/authors.resource.ts +0 -21
- package/examples/blog-admin/src/resources/tags.resource.ts +0 -20
- package/examples/blog-admin/tsconfig.json +0 -7
- package/examples/blog-admin/vitest.config.ts +0 -16
- package/examples/crm-admin/README.md +0 -17
- package/examples/crm-admin/package.json +0 -17
- package/examples/crm-admin/prisma/models.fragment.prisma +0 -50
- package/examples/crm-admin/src/index.test.ts +0 -9
- package/examples/crm-admin/src/index.ts +0 -7
- package/examples/crm-admin/src/resources/activities.resource.ts +0 -29
- package/examples/crm-admin/src/resources/companies.resource.ts +0 -21
- package/examples/crm-admin/src/resources/contacts.resource.ts +0 -24
- package/examples/crm-admin/src/resources/deals.resource.ts +0 -30
- package/examples/crm-admin/tsconfig.json +0 -7
- package/examples/crm-admin/vitest.config.ts +0 -16
- package/examples/ecommerce-admin/README.md +0 -17
- package/examples/ecommerce-admin/package.json +0 -17
- package/examples/ecommerce-admin/prisma/models.fragment.prisma +0 -43
- package/examples/ecommerce-admin/src/index.test.ts +0 -8
- package/examples/ecommerce-admin/src/index.ts +0 -7
- package/examples/ecommerce-admin/src/resources/customers.resource.ts +0 -21
- package/examples/ecommerce-admin/src/resources/order-items.resource.ts +0 -22
- package/examples/ecommerce-admin/src/resources/orders.resource.ts +0 -27
- package/examples/ecommerce-admin/src/resources/products.resource.ts +0 -23
- package/examples/ecommerce-admin/tsconfig.json +0 -7
- package/examples/ecommerce-admin/vitest.config.ts +0 -16
- package/examples/marketplace-admin/README.md +0 -17
- package/examples/marketplace-admin/package.json +0 -17
- package/examples/marketplace-admin/prisma/models.fragment.prisma +0 -32
- package/examples/marketplace-admin/src/index.test.ts +0 -8
- package/examples/marketplace-admin/src/index.ts +0 -6
- package/examples/marketplace-admin/src/resources/listings.resource.ts +0 -29
- package/examples/marketplace-admin/src/resources/payouts.resource.ts +0 -28
- package/examples/marketplace-admin/src/resources/sellers.resource.ts +0 -28
- package/examples/marketplace-admin/tsconfig.json +0 -7
- package/examples/marketplace-admin/vitest.config.ts +0 -16
- package/examples/support-admin/README.md +0 -18
- package/examples/support-admin/package.json +0 -17
- package/examples/support-admin/prisma/models.fragment.prisma +0 -20
- package/examples/support-admin/src/index.test.ts +0 -8
- package/examples/support-admin/src/index.ts +0 -5
- package/examples/support-admin/src/resources/ticket-messages.resource.ts +0 -22
- package/examples/support-admin/src/resources/tickets.resource.ts +0 -35
- package/examples/support-admin/tsconfig.json +0 -7
- package/examples/support-admin/vitest.config.ts +0 -16
- package/packages/auth/package.json +0 -17
- package/packages/auth/src/index.test.ts +0 -10
- package/packages/auth/src/index.ts +0 -17
- package/packages/auth/tsconfig.json +0 -8
- package/packages/brand/apps/admin/public/brand/apple-touch-icon.png +0 -0
- package/packages/brand/apps/admin/public/brand/favicon.svg +0 -1
- 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 +0 -1
- 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 +0 -19
- package/packages/brand/site/assets/brand/favicon.svg +0 -1
- package/packages/brand/site/assets/brand/og-image.svg +0 -1
- package/packages/brand/site/assets/brand/openadminjs-icon.svg +0 -1
- package/packages/brand/site/assets/brand/openadminjs-logo-dark.svg +0 -1
- package/packages/brand/site/assets/brand/openadminjs-logo-horizontal.svg +0 -1
- package/packages/brand/site/assets/brand/openadminjs-logo-monochrome.svg +0 -1
- package/packages/brand/site/assets/brand/openadminjs-logo.svg +0 -1
- package/packages/brand/src/generate-assets.mjs +0 -182
- package/packages/brand/src/index.test.ts +0 -9
- package/packages/brand/src/index.ts +0 -7
- package/packages/brand/tsconfig.json +0 -7
- package/packages/cli/package.json +0 -44
- package/packages/cli/src/create-project.ts +0 -316
- package/packages/cli/src/index.test.ts +0 -8
- package/packages/cli/src/index.ts +0 -149
- package/packages/cli/src/resource-slug.test.ts +0 -10
- package/packages/cli/src/resource-slug.ts +0 -4
- package/packages/cli/template/apps/web/README.md +0 -12
- package/packages/cli/template/apps/web/app/globals.css +0 -12
- package/packages/cli/template/apps/web/app/layout.tsx +0 -18
- package/packages/cli/template/apps/web/app/page.tsx +0 -27
- package/packages/cli/template/apps/web/app/posts/[slug]/page.tsx +0 -38
- package/packages/cli/template/apps/web/app/posts/page.tsx +0 -20
- package/packages/cli/template/apps/web/app/robots.txt/route.ts +0 -9
- package/packages/cli/template/apps/web/app/sitemap.xml/route.ts +0 -20
- package/packages/cli/template/apps/web/components/public-fields.tsx +0 -22
- package/packages/cli/template/apps/web/next.config.mjs +0 -5
- package/packages/cli/template/apps/web/postcss.config.mjs +0 -6
- package/packages/cli/template/apps/web/public/brand/apple-touch-icon.png +0 -0
- package/packages/cli/template/apps/web/public/brand/favicon.svg +0 -1
- 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 +0 -21
- package/packages/cli/template/apps/web/tsconfig.json +0 -23
- package/packages/cli/tsconfig.json +0 -10
- package/packages/core/package.json +0 -20
- package/packages/core/src/index.js +0 -1
- package/packages/core/src/index.test.ts +0 -27
- package/packages/core/src/index.ts +0 -61
- package/packages/core/tsconfig.json +0 -8
- package/packages/create-openadminjs/package.json +0 -25
- package/packages/create-openadminjs/src/index.ts +0 -122
- package/packages/create-openadminjs/src/package-name.test.ts +0 -13
- package/packages/create-openadminjs/src/package-name.ts +0 -8
- package/packages/create-openadminjs/src/render-files.test.ts +0 -26
- package/packages/create-openadminjs/src/render-files.ts +0 -21
- package/packages/create-openadminjs/template/.env.example +0 -7
- package/packages/create-openadminjs/template/README.md +0 -13
- package/packages/create-openadminjs/template/apps/web/README.md +0 -12
- package/packages/create-openadminjs/template/apps/web/app/globals.css +0 -12
- package/packages/create-openadminjs/template/apps/web/app/layout.tsx +0 -18
- package/packages/create-openadminjs/template/apps/web/app/page.tsx +0 -27
- package/packages/create-openadminjs/template/apps/web/app/posts/[slug]/page.tsx +0 -38
- package/packages/create-openadminjs/template/apps/web/app/posts/page.tsx +0 -20
- package/packages/create-openadminjs/template/apps/web/app/robots.txt/route.ts +0 -9
- package/packages/create-openadminjs/template/apps/web/app/sitemap.xml/route.ts +0 -20
- package/packages/create-openadminjs/template/apps/web/components/public-fields.tsx +0 -22
- package/packages/create-openadminjs/template/apps/web/lib/openadmin-client.ts +0 -71
- package/packages/create-openadminjs/template/apps/web/lib/seo.ts +0 -42
- package/packages/create-openadminjs/template/apps/web/next-env.d.ts +0 -2
- package/packages/create-openadminjs/template/apps/web/next.config.mjs +0 -5
- package/packages/create-openadminjs/template/apps/web/package.json +0 -29
- package/packages/create-openadminjs/template/apps/web/postcss.config.mjs +0 -6
- 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 +0 -1
- 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 +0 -21
- package/packages/create-openadminjs/template/apps/web/tsconfig.json +0 -23
- package/packages/create-openadminjs/template/package.json +0 -19
- package/packages/create-openadminjs/template/pnpm-workspace.yaml +0 -3
- package/packages/create-openadminjs/tsconfig.json +0 -10
- package/packages/mail/package.json +0 -18
- package/packages/mail/src/index.test.ts +0 -23
- package/packages/mail/src/index.ts +0 -246
- package/packages/mail/tsconfig.json +0 -5
- package/packages/notifications/package.json +0 -16
- package/packages/notifications/src/index.test.ts +0 -9
- package/packages/notifications/src/index.ts +0 -5
- package/packages/notifications/tsconfig.json +0 -5
- package/packages/payments/package.json +0 -15
- package/packages/payments/src/index.ts +0 -256
- package/packages/payments/tsconfig.json +0 -9
- package/packages/permissions/package.json +0 -17
- package/packages/permissions/src/blueprints.js +0 -57
- package/packages/permissions/src/blueprints.test.ts +0 -62
- package/packages/permissions/src/blueprints.ts +0 -89
- package/packages/permissions/src/index.js +0 -11
- package/packages/permissions/src/index.test.ts +0 -34
- package/packages/permissions/src/index.ts +0 -22
- package/packages/permissions/tsconfig.json +0 -8
- package/packages/plugin-sdk/package.json +0 -26
- package/packages/plugin-sdk/src/hooks.ts +0 -135
- package/packages/plugin-sdk/src/index.ts +0 -42
- package/packages/plugin-sdk/src/sdk.test.ts +0 -13
- package/packages/plugin-sdk/tsconfig.json +0 -8
- package/packages/plugin-sdk/vitest.config.ts +0 -5
- package/packages/queue/package.json +0 -16
- package/packages/queue/src/index.test.ts +0 -12
- package/packages/queue/src/index.ts +0 -6
- package/packages/queue/tsconfig.json +0 -5
- package/packages/resource/package.json +0 -17
- package/packages/resource/src/index.js +0 -177
- package/packages/resource/src/index.test.ts +0 -151
- package/packages/resource/src/index.ts +0 -344
- package/packages/resource/tsconfig.json +0 -8
- package/packages/storage/package.json +0 -16
- package/packages/storage/src/index.test.ts +0 -10
- package/packages/storage/src/index.ts +0 -23
- package/packages/storage/tsconfig.json +0 -5
- package/pnpm-workspace.yaml +0 -4
- package/prisma/migrations/20260505151751_baseline_init_all_tables/migration.sql +0 -371
- package/prisma/migrations/migration_lock.toml +0 -3
- package/prisma/schema.prisma +0 -291
- package/prisma/seed.ts +0 -210
- package/scripts/check-static-site.mjs +0 -17
- package/scripts/e2e-smoke.mjs +0 -17
- package/scripts/make-executable.mjs +0 -4
- package/site/.nojekyll +0 -0
- package/site/assets/brand/apple-touch-icon.png +0 -0
- package/site/assets/brand/favicon.svg +0 -1
- 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 +0 -1521
- package/site/assets/js/main.js +0 -193
- package/site/assets/partners/arcbyte.svg +0 -11
- package/site/assets/partners/gridstack.svg +0 -8
- package/site/assets/partners/nebula.svg +0 -12
- package/site/assets/partners/orbitlab.svg +0 -7
- package/site/assets/partners/pulseforge.svg +0 -11
- package/site/assets/partners/vertex.svg +0 -6
- package/site/docs.html +0 -1459
- package/site/index.html +0 -357
- package/tsconfig.base.json +0 -23
- /package/{packages/cli/template → template}/README.md +0 -0
- /package/{apps → template/apps}/web/README.md +0 -0
- /package/{apps → template/apps}/web/app/globals.css +0 -0
- /package/{apps → template/apps}/web/app/layout.tsx +0 -0
- /package/{apps → template/apps}/web/app/page.tsx +0 -0
- /package/{apps → template/apps}/web/app/posts/[slug]/page.tsx +0 -0
- /package/{apps → template/apps}/web/app/posts/page.tsx +0 -0
- /package/{apps → template/apps}/web/app/robots.txt/route.ts +0 -0
- /package/{apps → template/apps}/web/app/sitemap.xml/route.ts +0 -0
- /package/{apps → template/apps}/web/components/public-fields.tsx +0 -0
- /package/{packages/cli/template → template}/apps/web/lib/openadmin-client.ts +0 -0
- /package/{packages/cli/template → template}/apps/web/lib/seo.ts +0 -0
- /package/{packages/cli/template → template}/apps/web/next-env.d.ts +0 -0
- /package/{apps → template/apps}/web/next.config.mjs +0 -0
- /package/{packages/cli/template → template}/apps/web/package.json +0 -0
- /package/{apps/admin → template/apps/web}/postcss.config.mjs +0 -0
- /package/{apps/admin → template/apps/web}/public/brand/apple-touch-icon.png +0 -0
- /package/{apps/admin → template/apps/web}/public/brand/favicon.svg +0 -0
- /package/{apps/admin → template/apps/web}/public/brand/og-image.png +0 -0
- /package/{apps/admin → template/apps/web}/public/brand/openadminjs-icon-new.png +0 -0
- /package/{apps/admin → template/apps/web}/public/brand/openadminjs-logo-monochrome.png +0 -0
- /package/{apps/admin → template/apps/web}/public/brand/openadminjs-logo-new.png +0 -0
- /package/{apps → template/apps}/web/tailwind.config.ts +0 -0
- /package/{apps/admin → template/apps/web}/tsconfig.json +0 -0
- /package/{packages/cli/template → template}/package.json +0 -0
- /package/{packages/cli/template → template}/pnpm-workspace.yaml +0 -0
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@openadminjs/brand",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "src/index.ts",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"build": "node src/generate-assets.mjs",
|
|
8
|
-
"lint": "node src/generate-assets.mjs --check",
|
|
9
|
-
"typecheck": "node src/generate-assets.mjs --check",
|
|
10
|
-
"test": "vitest run"
|
|
11
|
-
},
|
|
12
|
-
"devDependencies": {
|
|
13
|
-
"typescript": "^5.7.2",
|
|
14
|
-
"vitest": "^2.1.8"
|
|
15
|
-
},
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"sharp": "0.33.5"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-label="OpenAdminJS icon"><rect width="64" height="64" rx="14" fill="#059669"/><path d="M17 21h30v22H17z" fill="#ECFDF5"/><path d="M23 27h8v4h-8zm12 0h6v4h-6zM23 35h18v4H23z" fill="#059669"/><path d="M47 21 32 12 17 21" fill="none" stroke="#A7F3D0" stroke-width="4" stroke-linejoin="round"/></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 630"><rect width="1200" height="630" fill="#0f172a"/><circle cx="980" cy="120" r="180" fill="#059669" opacity=".22"/><g transform="translate(120 150) scale(2)"><rect width="64" height="64" rx="14" fill="#059669"/><path d="M17 21h30v22H17z" fill="#ECFDF5"/><path d="M23 27h8v4h-8zm12 0h6v4h-6zM23 35h18v4H23z" fill="#059669"/><path d="M47 21 32 12 17 21" fill="none" stroke="#A7F3D0" stroke-width="4" stroke-linejoin="round"/></g><text x="120" y="350" fill="#f8fafc" font-family="Inter, ui-sans-serif, system-ui" font-size="76" font-weight="800">OpenAdminJS</text><text x="124" y="420" fill="#A7F3D0" font-family="Inter, ui-sans-serif, system-ui" font-size="34">Resource-driven admin platform</text></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-label="OpenAdminJS icon"><rect width="64" height="64" rx="14" fill="#059669"/><path d="M17 21h30v22H17z" fill="#ECFDF5"/><path d="M23 27h8v4h-8zm12 0h6v4h-6zM23 35h18v4H23z" fill="#059669"/><path d="M47 21 32 12 17 21" fill="none" stroke="#A7F3D0" stroke-width="4" stroke-linejoin="round"/></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 280 64" role="img" aria-label="OpenAdminJS"><rect x="0" y="0" width="64" height="64" rx="14" fill="#059669"/><path d="M17 21h30v22H17z" fill="#ECFDF5"/><path d="M23 27h8v4h-8zm12 0h6v4h-6zM23 35h18v4H23z" fill="#059669"/><path d="M47 21 32 12 17 21" fill="none" stroke="#A7F3D0" stroke-width="4" stroke-linejoin="round"/><text x="80" y="40" fill="#f8fafc" font-family="Inter, ui-sans-serif, system-ui" font-size="28" font-weight="700">OpenAdminJS</text></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 280 64" role="img" aria-label="OpenAdminJS"><rect x="0" y="0" width="64" height="64" rx="14" fill="#059669"/><path d="M17 21h30v22H17z" fill="#ECFDF5"/><path d="M23 27h8v4h-8zm12 0h6v4h-6zM23 35h18v4H23z" fill="#059669"/><path d="M47 21 32 12 17 21" fill="none" stroke="#A7F3D0" stroke-width="4" stroke-linejoin="round"/><text x="80" y="40" fill="#0f172a" font-family="Inter, ui-sans-serif, system-ui" font-size="28" font-weight="700">OpenAdminJS</text></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 280 64" role="img" aria-label="OpenAdminJS"><rect x="0" y="0" width="64" height="64" rx="14" fill="#18181b"/><path d="M17 21h30v22H17z" fill="#ECFDF5"/><path d="M23 27h8v4h-8zm12 0h6v4h-6zM23 35h18v4H23z" fill="#18181b"/><path d="M47 21 32 12 17 21" fill="none" stroke="#d4d4d8" stroke-width="4" stroke-linejoin="round"/><text x="80" y="40" fill="#0f172a" font-family="Inter, ui-sans-serif, system-ui" font-size="28" font-weight="700">OpenAdminJS</text></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 280 64" role="img" aria-label="OpenAdminJS"><rect x="0" y="0" width="64" height="64" rx="14" fill="#059669"/><path d="M17 21h30v22H17z" fill="#ECFDF5"/><path d="M23 27h8v4h-8zm12 0h6v4h-6zM23 35h18v4H23z" fill="#059669"/><path d="M47 21 32 12 17 21" fill="none" stroke="#A7F3D0" stroke-width="4" stroke-linejoin="round"/><text x="80" y="40" fill="#0f172a" font-family="Inter, ui-sans-serif, system-ui" font-size="28" font-weight="700">OpenAdminJS</text></svg>
|
|
@@ -1,182 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "openadminjs",
|
|
3
|
-
"version": "0.1.3",
|
|
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
|
-
}
|
|
@@ -1,316 +0,0 @@
|
|
|
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" | "mysql" | "sqlite";
|
|
14
|
-
|
|
15
|
-
export type CreateProjectOptions = {
|
|
16
|
-
projectName?: string;
|
|
17
|
-
cwd?: string;
|
|
18
|
-
packageManager?: PackageManager;
|
|
19
|
-
database?: DatabaseDriver;
|
|
20
|
-
superadminEmail?: string;
|
|
21
|
-
superadminPassword?: string;
|
|
22
|
-
databaseUrl?: string;
|
|
23
|
-
redisUrl?: string;
|
|
24
|
-
jwtSecret?: string;
|
|
25
|
-
jwtRefreshSecret?: string;
|
|
26
|
-
adminOrigin?: string;
|
|
27
|
-
apiPort?: string;
|
|
28
|
-
git?: boolean;
|
|
29
|
-
install?: boolean;
|
|
30
|
-
templateDir?: string;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export type CreateProjectResult = {
|
|
34
|
-
appName: string;
|
|
35
|
-
packageName: string;
|
|
36
|
-
targetDir: string;
|
|
37
|
-
packageManager: PackageManager;
|
|
38
|
-
database: DatabaseDriver;
|
|
39
|
-
superadminEmail: string;
|
|
40
|
-
git: boolean;
|
|
41
|
-
install: boolean;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const placeholderPattern =
|
|
45
|
-
/__APP_NAME__|__PACKAGE_NAME__|__DATABASE_URL__|__DATABASE_PROVIDER__|__REDIS_URL__|__JWT_SECRET__|__JWT_REFRESH_SECRET__|__ADMIN_ORIGIN__|__API_PORT__/g;
|
|
46
|
-
|
|
47
|
-
export function toPackageName(input: string): string {
|
|
48
|
-
return input
|
|
49
|
-
.trim()
|
|
50
|
-
.toLowerCase()
|
|
51
|
-
.replace(/[^a-z0-9-]+/g, "-")
|
|
52
|
-
.replace(/^-|-$/g, "");
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function defaultTemplateDir(): string {
|
|
56
|
-
return resolve(__dirname, "../template");
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function databaseUrl(packageName: string, database: DatabaseDriver): string {
|
|
60
|
-
if (database === "postgresql") {
|
|
61
|
-
return `postgresql://openadminjs:openadminjs@localhost:5432/${packageName}?schema=public`;
|
|
62
|
-
}
|
|
63
|
-
if (database === "mysql") {
|
|
64
|
-
return `mysql://openadminjs:openadminjs@localhost:3306/${packageName}`;
|
|
65
|
-
}
|
|
66
|
-
return "file:./prisma/dev.db";
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function renderFile(file: string, replacements: Record<string, string>): void {
|
|
70
|
-
const content = readFileSync(file, "utf8");
|
|
71
|
-
writeFileSync(file, content.replace(placeholderPattern, (key) => replacements[key] ?? key));
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function renderTemplateFiles(targetDir: string, replacements: Record<string, string>): void {
|
|
75
|
-
const stack = [targetDir];
|
|
76
|
-
while (stack.length) {
|
|
77
|
-
const current = stack.pop();
|
|
78
|
-
if (!current) continue;
|
|
79
|
-
for (const entry of readdirSync(current, { withFileTypes: true })) {
|
|
80
|
-
const path = resolve(current, entry.name);
|
|
81
|
-
if (entry.isDirectory()) {
|
|
82
|
-
stack.push(path);
|
|
83
|
-
} else if (entry.isFile()) {
|
|
84
|
-
renderFile(path, replacements);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function createProject(options: Required<CreateProjectOptions>): CreateProjectResult {
|
|
91
|
-
const appName = options.projectName;
|
|
92
|
-
const packageName = toPackageName(appName);
|
|
93
|
-
if (!packageName) throw new Error("Project name must contain at least one letter or number.");
|
|
94
|
-
|
|
95
|
-
const targetDir = resolve(options.cwd, appName);
|
|
96
|
-
if (existsSync(targetDir)) throw new Error(`${targetDir} already exists.`);
|
|
97
|
-
|
|
98
|
-
ensureDirSync(targetDir);
|
|
99
|
-
copySync(options.templateDir, targetDir, {
|
|
100
|
-
overwrite: false,
|
|
101
|
-
errorOnExist: true,
|
|
102
|
-
filter: (source) => !source.includes("node_modules") && !source.includes(".next") && !source.includes("dist")
|
|
103
|
-
});
|
|
104
|
-
renderTemplateFiles(targetDir, {
|
|
105
|
-
__APP_NAME__: appName,
|
|
106
|
-
__PACKAGE_NAME__: packageName,
|
|
107
|
-
__DATABASE_PROVIDER__: options.database,
|
|
108
|
-
__DATABASE_URL__: options.databaseUrl,
|
|
109
|
-
__REDIS_URL__: options.redisUrl,
|
|
110
|
-
__JWT_SECRET__: options.jwtSecret,
|
|
111
|
-
__JWT_REFRESH_SECRET__: options.jwtRefreshSecret,
|
|
112
|
-
__ADMIN_ORIGIN__: options.adminOrigin,
|
|
113
|
-
__API_PORT__: options.apiPort
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
if (options.git) {
|
|
117
|
-
spawnSync("git", ["init"], { cwd: targetDir, stdio: "ignore" });
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (options.install) {
|
|
121
|
-
const installArgs = options.packageManager === "yarn" ? [] : ["install"];
|
|
122
|
-
spawnSync(options.packageManager, installArgs, { cwd: targetDir, stdio: "inherit" });
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return {
|
|
126
|
-
appName,
|
|
127
|
-
packageName,
|
|
128
|
-
targetDir,
|
|
129
|
-
packageManager: options.packageManager,
|
|
130
|
-
database: options.database,
|
|
131
|
-
superadminEmail: options.superadminEmail,
|
|
132
|
-
git: options.git,
|
|
133
|
-
install: options.install
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export function printNextSteps(result: CreateProjectResult): void {
|
|
138
|
-
const pm = result.packageManager;
|
|
139
|
-
const installStep = result.install ? "" : `\n ${pm} install`;
|
|
140
|
-
outro(
|
|
141
|
-
`${pc.green("Project created.")}\n\nNext steps:\n cd ${result.appName}${installStep}\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>`
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export async function createProjectInteractive(options: CreateProjectOptions = {}): Promise<CreateProjectResult | undefined> {
|
|
146
|
-
intro(pc.green("Create OpenAdminJS"));
|
|
147
|
-
|
|
148
|
-
const projectName =
|
|
149
|
-
options.projectName ??
|
|
150
|
-
(await text({
|
|
151
|
-
message: "Project name",
|
|
152
|
-
defaultValue: "my-app",
|
|
153
|
-
placeholder: "my-app"
|
|
154
|
-
}));
|
|
155
|
-
if (isCancel(projectName)) {
|
|
156
|
-
cancel("Cancelled");
|
|
157
|
-
return undefined;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const packageManager =
|
|
161
|
-
options.packageManager ??
|
|
162
|
-
(await select<PackageManager>({
|
|
163
|
-
message: "Package manager",
|
|
164
|
-
options: [
|
|
165
|
-
{ value: "pnpm", label: "pnpm" },
|
|
166
|
-
{ value: "npm", label: "npm" },
|
|
167
|
-
{ value: "yarn", label: "yarn" }
|
|
168
|
-
],
|
|
169
|
-
initialValue: "pnpm"
|
|
170
|
-
}));
|
|
171
|
-
if (isCancel(packageManager)) {
|
|
172
|
-
cancel("Cancelled");
|
|
173
|
-
return undefined;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const database =
|
|
177
|
-
options.database ??
|
|
178
|
-
(await select<DatabaseDriver>({
|
|
179
|
-
message: "Database",
|
|
180
|
-
options: [
|
|
181
|
-
{ value: "postgresql", label: "PostgreSQL" },
|
|
182
|
-
{ value: "mysql", label: "MySQL" },
|
|
183
|
-
{ value: "sqlite", label: "SQLite" }
|
|
184
|
-
],
|
|
185
|
-
initialValue: "postgresql"
|
|
186
|
-
}));
|
|
187
|
-
if (isCancel(database)) {
|
|
188
|
-
cancel("Cancelled");
|
|
189
|
-
return undefined;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
const superadminEmail =
|
|
193
|
-
options.superadminEmail ??
|
|
194
|
-
(await text({
|
|
195
|
-
message: "Superadmin email",
|
|
196
|
-
defaultValue: "admin@localhost.dev",
|
|
197
|
-
placeholder: "admin@localhost.dev",
|
|
198
|
-
validate(value) {
|
|
199
|
-
return /^\S+@\S+\.\S+$/.test(value) ? undefined : "Enter a valid email address.";
|
|
200
|
-
}
|
|
201
|
-
}));
|
|
202
|
-
if (isCancel(superadminEmail)) {
|
|
203
|
-
cancel("Cancelled");
|
|
204
|
-
return undefined;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const superadminPassword =
|
|
208
|
-
options.superadminPassword ??
|
|
209
|
-
(await text({
|
|
210
|
-
message: "Superadmin password",
|
|
211
|
-
placeholder: "At least 8 characters",
|
|
212
|
-
validate(value) {
|
|
213
|
-
return value.length >= 8 ? undefined : "Password must be at least 8 characters.";
|
|
214
|
-
}
|
|
215
|
-
}));
|
|
216
|
-
if (isCancel(superadminPassword)) {
|
|
217
|
-
cancel("Cancelled");
|
|
218
|
-
return undefined;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
const selectedDatabaseUrl =
|
|
222
|
-
options.databaseUrl ??
|
|
223
|
-
(await text({
|
|
224
|
-
message: "Database URL",
|
|
225
|
-
defaultValue: databaseUrl(toPackageName(String(projectName)), database)
|
|
226
|
-
}));
|
|
227
|
-
if (isCancel(selectedDatabaseUrl)) {
|
|
228
|
-
cancel("Cancelled");
|
|
229
|
-
return undefined;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
const redisUrl =
|
|
233
|
-
options.redisUrl ??
|
|
234
|
-
(await text({
|
|
235
|
-
message: "Redis URL (optional for queues)",
|
|
236
|
-
defaultValue: "redis://localhost:6379"
|
|
237
|
-
}));
|
|
238
|
-
if (isCancel(redisUrl)) {
|
|
239
|
-
cancel("Cancelled");
|
|
240
|
-
return undefined;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
const jwtSecret =
|
|
244
|
-
options.jwtSecret ??
|
|
245
|
-
(await text({
|
|
246
|
-
message: "JWT secret",
|
|
247
|
-
defaultValue: "change-me-to-a-long-random-secret",
|
|
248
|
-
placeholder: "at least 32 chars recommended"
|
|
249
|
-
}));
|
|
250
|
-
if (isCancel(jwtSecret)) {
|
|
251
|
-
cancel("Cancelled");
|
|
252
|
-
return undefined;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
const jwtRefreshSecret =
|
|
256
|
-
options.jwtRefreshSecret ??
|
|
257
|
-
(await text({
|
|
258
|
-
message: "JWT refresh secret",
|
|
259
|
-
defaultValue: "change-me-too",
|
|
260
|
-
placeholder: "at least 32 chars recommended"
|
|
261
|
-
}));
|
|
262
|
-
if (isCancel(jwtRefreshSecret)) {
|
|
263
|
-
cancel("Cancelled");
|
|
264
|
-
return undefined;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
const adminOrigin =
|
|
268
|
-
options.adminOrigin ??
|
|
269
|
-
(await text({
|
|
270
|
-
message: "Admin origin",
|
|
271
|
-
defaultValue: "http://localhost:3000"
|
|
272
|
-
}));
|
|
273
|
-
if (isCancel(adminOrigin)) {
|
|
274
|
-
cancel("Cancelled");
|
|
275
|
-
return undefined;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
const apiPort =
|
|
279
|
-
options.apiPort ??
|
|
280
|
-
(await text({
|
|
281
|
-
message: "API port",
|
|
282
|
-
defaultValue: "4000"
|
|
283
|
-
}));
|
|
284
|
-
if (isCancel(apiPort)) {
|
|
285
|
-
cancel("Cancelled");
|
|
286
|
-
return undefined;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
const git = options.git ?? (await confirm({ message: "Initialize git?", initialValue: true }));
|
|
290
|
-
if (isCancel(git)) {
|
|
291
|
-
cancel("Cancelled");
|
|
292
|
-
return undefined;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
const install = options.install ?? true;
|
|
296
|
-
|
|
297
|
-
const result = createProject({
|
|
298
|
-
projectName: String(projectName),
|
|
299
|
-
cwd: options.cwd ?? process.cwd(),
|
|
300
|
-
packageManager,
|
|
301
|
-
database,
|
|
302
|
-
superadminEmail: String(superadminEmail),
|
|
303
|
-
superadminPassword: String(superadminPassword),
|
|
304
|
-
databaseUrl: String(selectedDatabaseUrl),
|
|
305
|
-
redisUrl: String(redisUrl),
|
|
306
|
-
jwtSecret: String(jwtSecret),
|
|
307
|
-
jwtRefreshSecret: String(jwtRefreshSecret),
|
|
308
|
-
adminOrigin: String(adminOrigin),
|
|
309
|
-
apiPort: String(apiPort),
|
|
310
|
-
git,
|
|
311
|
-
install,
|
|
312
|
-
templateDir: options.templateDir ?? defaultTemplateDir()
|
|
313
|
-
});
|
|
314
|
-
printNextSteps(result);
|
|
315
|
-
return result;
|
|
316
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
-
});
|