openadminjs 0.2.0 → 0.3.0-rc.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/README.md +106 -151
- package/dist/adapt-package-manager.js +4 -1
- package/dist/create-project.d.ts +46 -0
- package/dist/create-project.js +417 -150
- package/dist/doctor.d.ts +13 -0
- package/dist/doctor.js +35 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +257 -39
- package/dist/render-schema.d.ts +0 -17
- package/dist/render-schema.js +25 -29
- package/dist/resource-slug.d.ts +1 -0
- package/dist/resource-slug.js +7 -0
- package/dist/runtime-mode.d.ts +16 -0
- package/dist/runtime-mode.js +138 -0
- package/dist/upgrade.d.ts +10 -0
- package/dist/upgrade.js +133 -0
- package/package.json +14 -11
- package/template/.dockerignore +15 -0
- package/template/.env.production.example +5 -0
- package/template/Dockerfile +12 -0
- package/template/README.md +4 -3
- package/template/apps/admin/app/api/auth/login/route.ts +9 -9
- package/template/apps/admin/app/api/auth/logout/route.ts +11 -3
- package/template/apps/admin/app/api/auth/oidc/callback/route.ts +19 -0
- package/template/apps/admin/app/api/auth/oidc/start/route.ts +11 -0
- package/template/apps/admin/app/api/auth/oidc/status/route.ts +6 -0
- package/template/apps/admin/app/api/auth/refresh/route.ts +18 -11
- package/template/apps/admin/app/api/backend/[...path]/route.ts +48 -0
- package/template/apps/admin/app/api-tokens/page.tsx +39 -39
- package/template/apps/admin/app/assistant/page.tsx +11 -0
- package/template/apps/admin/app/dashboard/page.tsx +45 -462
- package/template/apps/admin/app/globals.css +52 -16
- package/template/apps/admin/app/layout.tsx +1 -1
- package/template/apps/admin/app/login/page.tsx +13 -145
- package/template/apps/admin/app/plugins/page.tsx +16 -402
- package/template/apps/admin/app/profile/page.tsx +5 -2
- package/template/apps/admin/app/settings/page.tsx +14 -265
- package/template/apps/admin/components/ai-assistant-widget.tsx +3 -6
- package/template/apps/admin/components/app-shell.tsx +25 -373
- package/template/apps/admin/components/auth-guard.tsx +8 -28
- package/template/apps/admin/components/logo.tsx +1 -30
- package/template/apps/admin/components/resource-form.tsx +3 -3
- package/template/apps/admin/components/resource-table.tsx +12 -8
- package/template/apps/admin/lib/api.ts +45 -107
- package/template/apps/admin/lib/resource-table-prefs.ts +1 -57
- package/template/apps/admin/lib/server-api.ts +7 -0
- package/template/apps/admin/lib/tokens.ts +9 -81
- package/template/apps/admin/middleware.ts +9 -50
- package/template/apps/admin/next.config.mjs +4 -0
- package/template/apps/admin/package.json +2 -1
- package/template/apps/admin/public/brand/favicon.svg +4 -1
- package/template/apps/admin/tailwind.config.ts +9 -8
- package/template/apps/api/package.json +10 -6
- package/template/apps/api/src/access/catalog.ts +4 -0
- package/template/apps/api/src/admin/admin-ai.controller.ts +15 -125
- package/template/apps/api/src/admin/admin-analytics.service.ts +16 -148
- package/template/apps/api/src/admin/admin-logs.controller.ts +4 -1
- package/template/apps/api/src/admin/admin-plugins.controller.ts +8 -8
- package/template/apps/api/src/admin/admin-plugins.service.ts +15 -259
- package/template/apps/api/src/admin/admin-resource.service.ts +105 -254
- package/template/apps/api/src/admin/admin.controller.ts +17 -4
- package/template/apps/api/src/admin/admin.module.ts +2 -2
- package/template/apps/api/src/admin/resource-policy.ts +1 -0
- package/template/apps/api/src/admin/resource-query.ts +1 -0
- package/template/apps/api/src/admin/safe-ai.service.ts +43 -0
- package/template/apps/api/src/admin/validate-resource-payload.ts +2 -0
- package/template/apps/api/src/auth/auth.controller.ts +4 -2
- package/template/apps/api/src/auth/auth.service.ts +68 -83
- package/template/apps/api/src/auth/sso-oidc.controller.ts +12 -74
- package/template/apps/api/src/auth/sso-oidc.service.ts +51 -268
- package/template/apps/api/src/common/api-exception.filter.ts +1 -0
- package/template/apps/api/src/common/auth.guard.ts +66 -39
- package/template/apps/api/src/common/json-field-codec.ts +12 -13
- package/template/apps/api/src/common/prisma.service.ts +9 -17
- package/template/apps/api/src/common/request-logging.interceptor.ts +8 -3
- package/template/apps/api/src/graphql/graphql.module.ts +5 -4
- package/template/apps/api/src/health/health.controller.ts +6 -0
- package/template/apps/api/src/main.ts +11 -2
- package/template/apps/api/src/plugins/plugin-loader.ts +5 -3
- package/template/apps/api/src/resources/commerce.resource.ts +3 -34
- package/template/apps/api/src/resources/operations.resource.ts +1 -0
- package/template/apps/api/src/store/payment/payment.controller.ts +15 -92
- package/template/apps/api/src/store/payment/payment.module.ts +2 -3
- package/template/apps/api/src/store/payment/payment.service.ts +121 -227
- package/template/apps/api/webpack.config.cjs +2 -1
- package/template/apps/web/next.config.mjs +4 -0
- package/template/apps/web/public/brand/favicon.svg +4 -1
- package/template/compose.yaml +56 -0
- package/template/examples/crm-admin/README.md +31 -0
- package/template/examples/crm-admin/package.json +17 -0
- package/template/examples/crm-admin/prisma/models.fragment.prisma +50 -0
- package/template/examples/crm-admin/src/index.ts +7 -0
- package/template/examples/crm-admin/src/resources/activities.resource.ts +29 -0
- package/template/examples/crm-admin/src/resources/companies.resource.ts +21 -0
- package/template/examples/crm-admin/src/resources/contacts.resource.ts +24 -0
- package/template/examples/crm-admin/src/resources/deals.resource.ts +30 -0
- package/template/examples/crm-admin/tsconfig.json +7 -0
- package/template/package.json +6 -1
- package/template/packages/admin-client/package.json +18 -0
- package/template/packages/admin-client/src/contracts.ts +29 -0
- package/template/packages/admin-client/src/index.ts +2 -0
- package/template/packages/admin-client/src/preferences.ts +57 -0
- package/template/packages/admin-client/tsconfig.json +12 -0
- package/template/packages/auth/package.json +1 -1
- package/template/packages/brand/site/assets/brand/favicon.svg +4 -1
- package/template/packages/brand/src/generate-assets.mjs +17 -186
- package/template/packages/core/package.json +1 -1
- package/template/packages/mail/package.json +1 -1
- package/template/packages/nest/package.json +22 -0
- package/template/packages/nest/src/api-exception.filter.ts +23 -0
- package/template/packages/nest/src/index.ts +3 -0
- package/template/packages/nest/src/resource-policy.ts +64 -0
- package/template/packages/nest/src/resource-query.ts +103 -0
- package/template/packages/nest/tsconfig.json +12 -0
- package/template/packages/notifications/package.json +1 -1
- package/template/packages/payments/package.json +1 -1
- package/template/packages/permissions/package.json +1 -1
- package/template/packages/permissions/src/index.ts +2 -2
- package/template/packages/plugin-sdk/package.json +1 -1
- package/template/packages/plugin-sdk/src/index.ts +2 -2
- package/template/packages/prisma/package.json +21 -0
- package/template/packages/prisma/schema/ai.prisma +36 -0
- package/template/packages/prisma/schema/audit.prisma +13 -0
- package/template/packages/prisma/schema/commerce.prisma +79 -0
- package/template/packages/prisma/schema/content.prisma +27 -0
- package/template/packages/prisma/schema/core.prisma +106 -0
- package/template/packages/prisma/schema/header.prisma +8 -0
- package/template/packages/prisma/schema/jobs.prisma +9 -0
- package/template/packages/prisma/schema/media.prisma +9 -0
- package/template/packages/prisma/schema/modules.json +47 -0
- package/template/packages/prisma/schema/notifications.prisma +9 -0
- package/template/packages/prisma/schema/settings.prisma +8 -0
- package/template/packages/prisma/schema/tokens.prisma +10 -0
- package/template/packages/prisma/src/index.d.ts +12 -0
- package/template/packages/prisma/src/index.mjs +138 -0
- package/template/packages/queue/package.json +1 -1
- package/template/packages/resource/package.json +1 -1
- package/template/packages/resource/src/index.ts +1 -0
- package/template/packages/storage/package.json +1 -1
- package/template/packages/storage/src/index.ts +37 -0
- package/template/prisma/migrations/20261126130000_add_sessions/migration.sql +26 -0
- package/template/prisma/migrations/20261126140000_api_token_hash/migration.sql +3 -0
- package/template/prisma/migrations/20261126150000_payment_idempotency/migration.sql +6 -0
- package/template/prisma/schema.prisma +82 -54
- package/template/prisma/seed.ts +14 -38
- package/template/runtime-versions.json +15 -0
- package/template/scripts/db-init.mjs +33 -0
- package/template/scripts/install-crm.mjs +50 -0
- package/template/scripts/migrate-existing.mjs +65 -0
- package/template/scripts/schema.mjs +48 -0
- package/template/tsconfig.base.json +23 -5
- package/LICENSE +0 -21
- package/dist/adapt-package-manager.test.d.ts +0 -1
- package/dist/adapt-package-manager.test.js +0 -76
- package/dist/cli.e2e.test.d.ts +0 -1
- package/dist/cli.e2e.test.js +0 -87
- package/dist/create-project.test.d.ts +0 -1
- package/dist/create-project.test.js +0 -275
- package/dist/database-providers.integration.test.d.ts +0 -1
- package/dist/database-providers.integration.test.js +0 -64
- package/dist/db-commands.test.d.ts +0 -1
- package/dist/db-commands.test.js +0 -27
- package/dist/doctor.test.d.ts +0 -1
- package/dist/doctor.test.js +0 -102
- package/dist/index.test.d.ts +0 -1
- package/dist/index.test.js +0 -11
- package/dist/render-schema.test.d.ts +0 -1
- package/dist/render-schema.test.js +0 -57
- package/dist/resource-slug.test.d.ts +0 -1
- package/dist/resource-slug.test.js +0 -9
- package/dist/secrets.test.d.ts +0 -1
- package/dist/secrets.test.js +0 -36
- package/dist/security.test.d.ts +0 -1
- package/dist/security.test.js +0 -54
- package/dist/validate-name.test.d.ts +0 -1
- package/dist/validate-name.test.js +0 -63
- package/template/apps/admin/.storybook/main.ts +0 -12
- package/template/apps/admin/.storybook/preview.ts +0 -10
- package/template/apps/admin/app/login/page.test.tsx +0 -18
- package/template/apps/admin/components/auth-guard.test.tsx +0 -55
- package/template/apps/admin/components/logo.stories.tsx +0 -24
- package/template/apps/admin/lib/api.test.ts +0 -118
- package/template/apps/admin/lib/auth-flow.e2e.test.ts +0 -79
- package/template/apps/admin/vitest.config.ts +0 -7
- package/template/apps/api/src/access/derive-permissions.test.ts +0 -26
- package/template/apps/api/src/admin/admin-resource.service.test.ts +0 -118
- package/template/apps/api/src/admin/validate-resource-payload.test.ts +0 -44
- package/template/apps/api/src/app.module.test.ts +0 -12
- package/template/apps/api/src/auth/auth.service.test.ts +0 -78
- package/template/apps/api/src/auth/sso-oidc.service.test.ts +0 -84
- package/template/apps/api/src/common/auth.guard.test.ts +0 -62
- package/template/apps/api/src/common/casl-ability.factory.test.ts +0 -33
- package/template/apps/api/src/common/json-field-codec.test.ts +0 -76
- package/template/apps/api/src/common/prisma.service.test.ts +0 -19
- package/template/apps/api/src/common/request-logging.interceptor.test.ts +0 -39
- package/template/apps/api/src/graphql/admin-resources.resolver.test.ts +0 -45
- package/template/apps/api/src/graphql/ensure-gql-paramtypes.test.ts +0 -44
- package/template/apps/api/src/graphql/graphql-apollo-config.test.ts +0 -26
- package/template/apps/api/src/graphql/graphql-schema.test.ts +0 -26
- package/template/apps/api/src/plugins/manifest.schema.test.ts +0 -36
- package/template/apps/api/src/plugins/plugin-runtime.test.ts +0 -24
- package/template/apps/api/src/queue/queue.service.test.ts +0 -33
- package/template/apps/api/src/resources/resource-hooks.registry.test.ts +0 -72
- package/template/apps/api/vitest.config.ts +0 -21
- package/template/apps/web/lib/seo.test.ts +0 -41
- package/template/apps/web/vitest.config.ts +0 -19
- package/template/packages/auth/src/index.test.ts +0 -10
- package/template/packages/brand/src/index.test.ts +0 -9
- package/template/packages/core/src/index.test.ts +0 -27
- package/template/packages/core/vitest.config.ts +0 -9
- package/template/packages/mail/src/index.test.ts +0 -23
- package/template/packages/notifications/src/index.test.ts +0 -9
- package/template/packages/permissions/src/blueprints.test.ts +0 -62
- package/template/packages/permissions/src/index.test.ts +0 -34
- package/template/packages/plugin-sdk/src/sdk.test.ts +0 -13
- package/template/packages/plugin-sdk/vitest.config.ts +0 -5
- package/template/packages/queue/src/index.test.ts +0 -12
- package/template/packages/resource/src/index.test.ts +0 -196
- package/template/packages/storage/src/index.test.ts +0 -10
package/README.md
CHANGED
|
@@ -1,208 +1,163 @@
|
|
|
1
1
|
# OpenAdminJS CLI
|
|
2
2
|
|
|
3
|
-
**`openadminjs` is a CLI scaffold generator**, not a runtime library you import into React/Next/Nest apps. It creates a full
|
|
3
|
+
**`openadminjs` is a CLI scaffold generator**, not a runtime library you import into React/Next/Nest apps. It creates a full monorepo (NestJS API, Next.js admin/web, shared packages).
|
|
4
4
|
|
|
5
5
|
Full documentation: [https://js-senpai.github.io/open-admin-js/docs.html](https://js-senpai.github.io/open-admin-js/docs.html)
|
|
6
6
|
|
|
7
7
|
## Requirements
|
|
8
8
|
|
|
9
9
|
- **Node.js 20+**
|
|
10
|
-
- **pnpm 9
|
|
11
|
-
- **PostgreSQL 14
|
|
10
|
+
- **One of:** pnpm 9+ (recommended), npm 9+, or yarn 1.x / Berry
|
|
11
|
+
- **Database:** PostgreSQL 14+, MySQL 8+, or **SQLite 3** (local file, zero external DB)
|
|
12
|
+
- **Redis:** optional — background job queues are disabled when `REDIS_URL` is blank
|
|
13
|
+
- **Network:** Prisma downloads engine binaries on first install/generate (corporate proxies may need configuration)
|
|
12
14
|
|
|
13
|
-
The CLI verifies Node.js and
|
|
15
|
+
The CLI verifies Node.js before writing files and detects which package managers are installed.
|
|
14
16
|
|
|
15
|
-
## Quick start
|
|
17
|
+
## Quick start (interactive)
|
|
16
18
|
|
|
17
19
|
```bash
|
|
18
20
|
npx openadminjs create my-app
|
|
19
21
|
cd my-app
|
|
20
|
-
pnpm
|
|
21
|
-
pnpm db:migrate # skipped if install ran during create
|
|
22
|
-
pnpm db:seed # skipped if install ran during create
|
|
23
|
-
pnpm dev
|
|
22
|
+
pnpm dev # or: npm run dev / yarn dev
|
|
24
23
|
```
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
**SQLite**; the CLI fills `DATABASE_URL` for you. For MySQL/SQLite the Prisma schema
|
|
28
|
-
is adapted and the initial migration is created on first `db:migrate`. On SQLite the
|
|
29
|
-
API JSON-encodes `Json` columns into `String` fields at runtime. npm and yarn are
|
|
30
|
-
**not** offered.
|
|
25
|
+
If you skipped install during create:
|
|
31
26
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
The scaffold wizard asks for database access and writes ready-to-use values into
|
|
35
|
-
`apps/api/.env` (including `SUPERADMIN_EMAIL` / `SUPERADMIN_PASSWORD` for
|
|
36
|
-
non-interactive seed). **JWT secrets are generated with `crypto.randomBytes`** —
|
|
37
|
-
never predictable defaults. `ADMIN_ORIGIN` and `API_PORT` default to
|
|
38
|
-
`http://localhost:3000` and `4000`.
|
|
39
|
-
|
|
40
|
-
Every new project includes a root **`.gitignore`** (written before `git init`) that
|
|
41
|
-
excludes all `.env` files, plus a tracked **`.env.example`** with placeholders. Real
|
|
42
|
-
secrets live only in `apps/api/.env` and are never printed by the CLI.
|
|
43
|
-
|
|
44
|
-
Typical `apps/api/.env` keys (after create, edit as needed):
|
|
45
|
-
|
|
46
|
-
| Provider | `DATABASE_URL` example |
|
|
47
|
-
| --- | --- |
|
|
48
|
-
| PostgreSQL | `postgresql://USER:PASSWORD@localhost:5432/openadminjs?schema=public` |
|
|
49
|
-
| MySQL | `mysql://USER:PASSWORD@localhost:3306/openadminjs` |
|
|
50
|
-
| SQLite | `file:./dev.db` |
|
|
51
|
-
|
|
52
|
-
```env
|
|
53
|
-
REDIS_URL=redis://localhost:6379
|
|
54
|
-
JWT_SECRET=replace-with-a-long-random-string-at-least-32-chars
|
|
55
|
-
JWT_REFRESH_SECRET=another-long-random-string
|
|
56
|
-
ADMIN_ORIGIN=http://localhost:3000
|
|
57
|
-
API_PORT=4000
|
|
58
|
-
SUPERADMIN_EMAIL=admin@localhost.dev
|
|
59
|
-
SUPERADMIN_PASSWORD=your-secure-password
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
Optional (elsewhere / advanced):
|
|
63
|
-
|
|
64
|
-
```env
|
|
65
|
-
OPENADMIN_PLUGIN_PNPM_INSTALL=0
|
|
27
|
+
```bash
|
|
28
|
+
pnpm install && pnpm db:migrate && pnpm db:seed
|
|
66
29
|
```
|
|
67
30
|
|
|
68
|
-
|
|
31
|
+
During create, choosing **install** runs dependency install, schema apply, and seed automatically.
|
|
69
32
|
|
|
70
|
-
|
|
71
|
-
pnpm dev
|
|
72
|
-
```
|
|
33
|
+
### What `dev` starts
|
|
73
34
|
|
|
74
|
-
|
|
35
|
+
The root **`dev` script starts the admin UI and the API only** (not the public web app):
|
|
75
36
|
|
|
76
|
-
|
|
|
37
|
+
| Service | URL |
|
|
77
38
|
| ----------- | ------------------------------ |
|
|
78
39
|
| Admin | http://localhost:3000 |
|
|
79
40
|
| API | http://localhost:4000 |
|
|
80
41
|
| API Swagger | http://localhost:4000/api/docs |
|
|
81
|
-
| Web (demo) | http://localhost:3001 |
|
|
82
|
-
|
|
83
|
-
### Sign in
|
|
84
42
|
|
|
85
|
-
|
|
43
|
+
Optional public web app (port 3001):
|
|
86
44
|
|
|
87
|
-
|
|
88
|
-
|
|
45
|
+
```bash
|
|
46
|
+
pnpm --filter @openadminjs/web dev # npm: npm run dev --workspace=@openadminjs/web
|
|
47
|
+
```
|
|
89
48
|
|
|
90
|
-
##
|
|
49
|
+
## Non-interactive / CI
|
|
91
50
|
|
|
92
|
-
|
|
93
|
-
import { createProject, databaseUrl } from "openadminjs";
|
|
94
|
-
import { randomBytes } from "node:crypto";
|
|
51
|
+
When stdin is not a TTY (or you pass `--yes` / `--non-interactive`), the CLI uses flags and safe defaults — no prompts.
|
|
95
52
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
projectName: "my-app",
|
|
99
|
-
packageManager: "pnpm",
|
|
100
|
-
database: "postgresql",
|
|
101
|
-
databaseUrl: databaseUrl("my-app", "postgresql"),
|
|
102
|
-
// ...
|
|
103
|
-
});
|
|
53
|
+
```bash
|
|
54
|
+
export OPENADMIN_ADMIN_PASSWORD="$(openssl rand -base64 24)"
|
|
104
55
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
superadminPassword: "a-strong-password",
|
|
113
|
-
redisUrl: "redis://localhost:6379",
|
|
114
|
-
jwtSecret: randomBytes(48).toString("base64url"),
|
|
115
|
-
jwtRefreshSecret: randomBytes(48).toString("base64url"),
|
|
116
|
-
adminOrigin: "http://localhost:3000",
|
|
117
|
-
apiPort: "4000"
|
|
118
|
-
});
|
|
56
|
+
npx openadminjs create my-app \
|
|
57
|
+
--yes \
|
|
58
|
+
--package-manager npm \
|
|
59
|
+
--database sqlite \
|
|
60
|
+
--admin-email admin@example.com \
|
|
61
|
+
--admin-password-env OPENADMIN_ADMIN_PASSWORD \
|
|
62
|
+
--skip-redis
|
|
119
63
|
|
|
120
|
-
|
|
121
|
-
createProject({
|
|
122
|
-
projectName: "my-app",
|
|
123
|
-
packageManager: "pnpm",
|
|
124
|
-
database: "sqlite",
|
|
125
|
-
databaseUrl: "file:./dev.db",
|
|
126
|
-
superadminEmail: "admin@localhost.dev",
|
|
127
|
-
superadminPassword: "a-strong-password",
|
|
128
|
-
redisUrl: "redis://localhost:6379",
|
|
129
|
-
jwtSecret: randomBytes(48).toString("base64url"),
|
|
130
|
-
jwtRefreshSecret: randomBytes(48).toString("base64url"),
|
|
131
|
-
adminOrigin: "http://localhost:3000",
|
|
132
|
-
apiPort: "4000"
|
|
133
|
-
});
|
|
64
|
+
cd my-app && npm run dev
|
|
134
65
|
```
|
|
135
66
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
```bash
|
|
139
|
-
openadminjs doctor # verify the project is ready to run
|
|
140
|
-
openadminjs doctor --json
|
|
141
|
-
openadminjs security check
|
|
142
|
-
openadminjs security check --json
|
|
143
|
-
```
|
|
67
|
+
Prefer **`--admin-password-env`** over `--admin-password` so secrets are not stored in shell history.
|
|
144
68
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
`
|
|
69
|
+
| Flag | Description |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| `--package-manager`, `--pm` | `pnpm`, `npm`, or `yarn` |
|
|
72
|
+
| `--database`, `--db` | `postgresql`, `mysql`, or `sqlite` |
|
|
73
|
+
| `--admin-email` | Superadmin email |
|
|
74
|
+
| `--admin-password-env <VAR>` | Read password from environment (recommended) |
|
|
75
|
+
| `--admin-password <value>` | Password on CLI (discouraged) |
|
|
76
|
+
| `--db-url <url>` | Override `DATABASE_URL` |
|
|
77
|
+
| `--redis-url <url>` | Redis URL (blank disables queues) |
|
|
78
|
+
| `--skip-redis` | Disable background job queues |
|
|
79
|
+
| `--no-install` | Skip install / DB setup |
|
|
80
|
+
| `--no-git` | Skip `git init` |
|
|
81
|
+
| `-y`, `--yes` | Non-interactive with defaults |
|
|
82
|
+
|
|
83
|
+
## Package managers
|
|
84
|
+
|
|
85
|
+
| Manager | Notes |
|
|
86
|
+
| --- | --- |
|
|
87
|
+
| **pnpm** | Default; ships `pnpm-workspace.yaml` and `workspace:*` deps |
|
|
88
|
+
| **npm** | Adds npm `workspaces`; rewrites `workspace:*` → `*` for local linking |
|
|
89
|
+
| **yarn** | Adds `workspaces`; rewrites `workspace:*` → `*` |
|
|
148
90
|
|
|
149
|
-
|
|
91
|
+
If your preferred manager is missing, the interactive wizard offers installed alternatives or Corepack hints for pnpm.
|
|
150
92
|
|
|
151
|
-
|
|
152
|
-
- Auth, RBAC contracts, generic CRUD API, audit log and file/settings modules.
|
|
153
|
-
- Next.js admin shell with login, dashboard, resource screens and operational pages.
|
|
154
|
-
- Generated app `apps/web` for public frontend pages and SEO.
|
|
155
|
-
- CLI: `create`, `dev`, `build`, `db migrate|seed|studio|reset`, `generate resource|field|plugin`, `doctor`, `security check`.
|
|
93
|
+
## SQLite zero-setup
|
|
156
94
|
|
|
157
|
-
|
|
95
|
+
SQLite uses a local `file:./dev.db` — no PostgreSQL/MySQL server required. **Redis is optional** for SQLite: leave the Redis prompt blank or pass `--skip-redis`. The API starts without Redis; queue endpoints return a clear `503` until `REDIS_URL` is set.
|
|
158
96
|
|
|
159
|
-
|
|
97
|
+
Prisma Client is generated automatically before `dev`, `build`, and `db:seed` via lifecycle scripts.
|
|
160
98
|
|
|
161
|
-
|
|
162
|
-
- `api` hooks/routes
|
|
163
|
-
- `media` pipeline (upload transforms)
|
|
164
|
-
- `seo` metadata/sitemap contributors
|
|
165
|
-
- `jobs` handlers
|
|
166
|
-
- `adminUi` extensions (menus/pages/widgets/actions)
|
|
99
|
+
## Environment
|
|
167
100
|
|
|
168
|
-
|
|
101
|
+
Secrets are written to **`apps/api/.env`** (git-ignored). JWT keys are generated with `crypto.randomBytes`. A tracked **`.env.example`** contains placeholders only — the CLI never prints secret values.
|
|
169
102
|
|
|
170
|
-
|
|
103
|
+
```env
|
|
104
|
+
DATABASE_URL=file:./dev.db # or postgres/mysql URL
|
|
105
|
+
REDIS_URL= # blank = queues disabled
|
|
106
|
+
JWT_SECRET=<generated>
|
|
107
|
+
JWT_REFRESH_SECRET=<generated>
|
|
108
|
+
ADMIN_ORIGIN=http://localhost:3000
|
|
109
|
+
API_PORT=4000
|
|
110
|
+
SUPERADMIN_EMAIL=admin@localhost.dev
|
|
111
|
+
SUPERADMIN_PASSWORD=<your password>
|
|
112
|
+
```
|
|
171
113
|
|
|
172
|
-
|
|
173
|
-
- `api.hooks` / `api.routes` — request lifecycle hooks and custom API endpoints.
|
|
174
|
-
- `media.pipeline` — file/image transform pipeline.
|
|
175
|
-
- `seo.extend` — metadata + sitemap contributors.
|
|
176
|
-
- `jobs.run` — background job handlers.
|
|
177
|
-
- `admin.ui.extend` — admin menu/page/widget/action extensions.
|
|
114
|
+
## Sign in
|
|
178
115
|
|
|
179
|
-
|
|
116
|
+
After create (with install), use the superadmin email and password from the wizard or `apps/api/.env`.
|
|
180
117
|
|
|
181
|
-
|
|
118
|
+
## Health & troubleshooting
|
|
182
119
|
|
|
183
120
|
```bash
|
|
184
|
-
|
|
121
|
+
openadminjs doctor # verify install, env, Prisma client, scripts
|
|
122
|
+
openadminjs doctor --skip-network # offline-friendly
|
|
123
|
+
openadminjs security check
|
|
185
124
|
```
|
|
186
125
|
|
|
187
|
-
|
|
126
|
+
**Prisma Client not initialized:** run `pnpm db:migrate` (or `npm run db:migrate`) from the project root, or `prisma generate` from `apps/api`.
|
|
188
127
|
|
|
189
|
-
|
|
128
|
+
**Prisma engine download failed:** check network/proxy; retry install from the project root.
|
|
190
129
|
|
|
191
|
-
|
|
130
|
+
**Setup failed mid-create:** the project directory is preserved with a resume command in the error message.
|
|
192
131
|
|
|
193
|
-
|
|
132
|
+
**npm `EUNSUPPORTEDPROTOCOL workspace:*`:** upgrade to the latest `openadminjs` CLI — npm projects must use `*` not `workspace:*`.
|
|
194
133
|
|
|
195
|
-
|
|
196
|
-
|
|
134
|
+
## Commands
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
openadminjs create [name] [options]
|
|
138
|
+
openadminjs db migrate [dev|deploy] | seed | studio | reset
|
|
139
|
+
openadminjs generate resource <Model> | field <resource> <field> | plugin <id>
|
|
140
|
+
openadminjs doctor [--json] [--skip-network]
|
|
141
|
+
openadminjs security check [--json]
|
|
142
|
+
```
|
|
197
143
|
|
|
198
|
-
##
|
|
144
|
+
## Programmatic API
|
|
199
145
|
|
|
200
|
-
|
|
146
|
+
```ts
|
|
147
|
+
import { createProject, databaseUrl, generateSecret } from "openadminjs";
|
|
201
148
|
|
|
202
|
-
|
|
203
|
-
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
149
|
+
createProject({
|
|
150
|
+
projectName: "my-app",
|
|
151
|
+
packageManager: "npm",
|
|
152
|
+
database: "sqlite",
|
|
153
|
+
databaseUrl: "file:./dev.db",
|
|
154
|
+
redisUrl: "", // optional — blank disables queues
|
|
155
|
+
superadminEmail: "admin@localhost.dev",
|
|
156
|
+
superadminPassword: process.env.ADMIN_PASSWORD!,
|
|
157
|
+
jwtSecret: generateSecret(),
|
|
158
|
+
jwtRefreshSecret: generateSecret(),
|
|
159
|
+
adminOrigin: "http://localhost:3000",
|
|
160
|
+
apiPort: "4000",
|
|
161
|
+
install: true
|
|
162
|
+
});
|
|
163
|
+
```
|
|
@@ -106,7 +106,10 @@ export function adaptProjectForPackageManager(targetDir, packageManager) {
|
|
|
106
106
|
if (existsSync(pnpmWorkspaceFile)) {
|
|
107
107
|
rmSync(pnpmWorkspaceFile);
|
|
108
108
|
}
|
|
109
|
-
|
|
109
|
+
// Neither npm nor Yarn Classic understand pnpm's `workspace:` protocol
|
|
110
|
+
// (npm throws EUNSUPPORTEDPROTOCOL). Both resolve `"*"` to the local
|
|
111
|
+
// workspace package by name, so rewrite every `workspace:<range>` to `"*"`.
|
|
112
|
+
const workspaceReplacement = "*";
|
|
110
113
|
for (const file of findPackageJsonFiles(targetDir)) {
|
|
111
114
|
const pkg = readPackageJson(file);
|
|
112
115
|
replaceWorkspaceProtocol(pkg, workspaceReplacement);
|
package/dist/create-project.d.ts
CHANGED
|
@@ -11,7 +11,10 @@ export type CreateProjectOptions = {
|
|
|
11
11
|
superadminEmail?: string;
|
|
12
12
|
superadminPassword?: string;
|
|
13
13
|
databaseUrl?: string;
|
|
14
|
+
/** Empty string disables Redis-backed queues (see `skipRedis`). */
|
|
14
15
|
redisUrl?: string;
|
|
16
|
+
/** When true, force Redis (and background job queues) off. */
|
|
17
|
+
skipRedis?: boolean;
|
|
15
18
|
jwtSecret?: string;
|
|
16
19
|
jwtRefreshSecret?: string;
|
|
17
20
|
adminOrigin?: string;
|
|
@@ -19,6 +22,13 @@ export type CreateProjectOptions = {
|
|
|
19
22
|
git?: boolean;
|
|
20
23
|
install?: boolean;
|
|
21
24
|
templateDir?: string;
|
|
25
|
+
runtimeMode?: "source" | "registry";
|
|
26
|
+
/**
|
|
27
|
+
* Skip all interactive prompts. Missing optional values fall back to safe
|
|
28
|
+
* defaults; a missing superadmin password is generated (CSPRNG). Used for
|
|
29
|
+
* CI / scripting and auto-enabled when stdin is not a TTY.
|
|
30
|
+
*/
|
|
31
|
+
nonInteractive?: boolean;
|
|
22
32
|
};
|
|
23
33
|
export type CreateProjectResult = {
|
|
24
34
|
appName: string;
|
|
@@ -30,6 +40,10 @@ export type CreateProjectResult = {
|
|
|
30
40
|
git: boolean;
|
|
31
41
|
install: boolean;
|
|
32
42
|
dbInitialized: boolean;
|
|
43
|
+
/** True when a REDIS_URL was configured (background job queues enabled). */
|
|
44
|
+
redisEnabled: boolean;
|
|
45
|
+
/** True when the superadmin password was generated (non-interactive). */
|
|
46
|
+
passwordGenerated: boolean;
|
|
33
47
|
};
|
|
34
48
|
export declare function toPackageName(input: string): string;
|
|
35
49
|
export declare function defaultTemplateDir(): string;
|
|
@@ -49,6 +63,16 @@ export declare function resolveSuperadminEmail(value: string, fallback?: string)
|
|
|
49
63
|
* resolution), so pressing Enter to accept the default is always valid.
|
|
50
64
|
*/
|
|
51
65
|
export declare function validateSuperadminEmailInput(value: string, fallback?: string): string | undefined;
|
|
66
|
+
export declare const DEFAULT_REDIS_URL = "redis://localhost:6379";
|
|
67
|
+
export declare const PACKAGE_MANAGERS: readonly PackageManager[];
|
|
68
|
+
/** Returns the first package manager that is installed on PATH, or undefined. */
|
|
69
|
+
export declare function firstAvailablePackageManager(preference?: readonly PackageManager[]): PackageManager | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Validates a Redis URL. An empty value is VALID — it disables background job
|
|
72
|
+
* queues. A non-empty value must be a parseable redis:// (or rediss://) URL so
|
|
73
|
+
* pressing Enter on the shown default is always accepted.
|
|
74
|
+
*/
|
|
75
|
+
export declare function validateRedisUrlInput(value: string): string | undefined;
|
|
52
76
|
export declare function databaseUrl(packageName: string, database: DatabaseDriver): string;
|
|
53
77
|
/**
|
|
54
78
|
* Generates the scaffold into a sibling staging directory and atomically renames
|
|
@@ -58,7 +82,29 @@ export declare function databaseUrl(packageName: string, database: DatabaseDrive
|
|
|
58
82
|
export declare function createProject(options: CreateProjectOptions & {
|
|
59
83
|
projectName: string;
|
|
60
84
|
}): CreateProjectResult;
|
|
85
|
+
/**
|
|
86
|
+
* Thrown when the scaffold was generated successfully but a later step
|
|
87
|
+
* (install, migrate, seed) failed. Carries the exact command to resume so the
|
|
88
|
+
* user never has to guess, and signals that the directory was intentionally
|
|
89
|
+
* preserved (never auto-deleted).
|
|
90
|
+
*/
|
|
91
|
+
export declare class SetupIncompleteError extends Error {
|
|
92
|
+
readonly targetDir: string;
|
|
93
|
+
readonly resumeCommand: string;
|
|
94
|
+
constructor(message: string, meta: {
|
|
95
|
+
targetDir: string;
|
|
96
|
+
appName: string;
|
|
97
|
+
packageManager: PackageManager;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
61
100
|
export declare function printNextSteps(result: CreateProjectResult): void;
|
|
62
101
|
/** Warns where secrets live and that they must never be committed. Never prints secret values. */
|
|
63
102
|
export declare function printSecurityNotice(result: CreateProjectResult): void;
|
|
103
|
+
/** Generates a strong, human-usable password (used in non-interactive mode). */
|
|
104
|
+
export declare function generatePassword(): string;
|
|
64
105
|
export declare function createProjectInteractive(options?: CreateProjectOptions): Promise<CreateProjectResult | undefined>;
|
|
106
|
+
/**
|
|
107
|
+
* Validates a DATABASE_URL against the FINAL resolved value so pressing Enter to
|
|
108
|
+
* accept the shown default is always valid.
|
|
109
|
+
*/
|
|
110
|
+
export declare function validateDatabaseUrlInput(database: DatabaseDriver, value: string, fallback: string): string | undefined;
|