openadminjs 0.1.2 → 0.1.3

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 CHANGED
@@ -2,28 +2,24 @@
2
2
 
3
3
  OpenAdminJS is an open-source, resource-driven admin platform for the Node.js ecosystem, built with Nest.js, Prisma, PostgreSQL, Next.js, TailwindCSS and shadcn/ui.
4
4
 
5
- ![OpenAdminJS logo](./site/assets/brand/openadminjs-logo-new.png)
5
+ ![OpenAdminJS logo](https://js-senpai.github.io/open-admin-js/assets/brand/openadminjs-logo-new.png)
6
6
 
7
- ## Quick start (this repository)
7
+ ## Quick start (for package users)
8
8
 
9
- Follow these steps in order the first time you clone the repo.
9
+ Full documentation: [https://js-senpai.github.io/open-admin-js/docs.html](https://js-senpai.github.io/open-admin-js/docs.html)
10
10
 
11
- ### 1. Prerequisites
12
-
13
- - **Node.js** 22+ (CI uses 22; newer LTS usually works).
14
- - **pnpm** 9 (`packageManager` in root `package.json`).
15
- - **PostgreSQL** reachable from your machine (local or Docker).
16
- - **Redis** (optional): queues and some health checks use `REDIS_URL`; the API can start without it for basic admin usage.
17
-
18
- ### 2. Install dependencies
11
+ ### 1. Create a new project
19
12
 
20
13
  ```bash
21
- pnpm install
14
+ npm create openadminjs@latest my-app
15
+ cd my-app
22
16
  ```
23
17
 
24
- ### 3. Configure the API environment
18
+ Use `npm create ...` for bootstrap. Global installation (`npm i -g openadminjs`) is not the recommended flow.
19
+
20
+ ### 2. Configure environment
25
21
 
26
- Create **`apps/api/.env`** (this file is gitignored). The API loads, in order, **`<repo>/.env`** and **`apps/api/.env`** so you can keep secrets next to the API or at the repo root.
22
+ Create `apps/api/.env` in the generated project.
27
23
 
28
24
  Minimal example:
29
25
 
@@ -36,9 +32,6 @@ JWT_REFRESH_SECRET=another-long-random-string
36
32
  ADMIN_ORIGIN=http://localhost:3000
37
33
  ```
38
34
 
39
- - **`JWT_SECRET`** is required for login. If it is missing, sign-in fails (previously surfaced as a generic “Internal server error”).
40
- - **`DATABASE_URL`** must point at an existing database the user can create schemas in.
41
-
42
35
  Optional:
43
36
 
44
37
  ```env
@@ -46,34 +39,14 @@ REDIS_URL=redis://localhost:6379
46
39
  OPENADMIN_PLUGIN_PNPM_INSTALL=0
47
40
  ```
48
41
 
49
- ### 4. Apply database schema and seed demo data
50
-
51
- From the repository root:
42
+ ### 3. Prepare database and run
52
43
 
53
44
  ```bash
54
45
  pnpm db:migrate
55
46
  pnpm db:seed
56
- ```
57
-
58
- `db:migrate` runs Prisma migrations against `DATABASE_URL`.
59
- `db:seed` creates permissions, roles, and demo users (including the admin below).
60
-
61
- ### 5. Configure the admin UI (optional)
62
-
63
- The admin defaults to **`http://localhost:4000`** for the API. If your API runs elsewhere, create **`apps/admin/.env.local`**:
64
-
65
- ```env
66
- NEXT_PUBLIC_API_URL=http://localhost:4000
67
- ```
68
-
69
- ### 6. Run everything in development
70
-
71
- ```bash
72
47
  pnpm dev
73
48
  ```
74
49
 
75
- This starts the API and the admin app in parallel (see root `package.json` `dev` script). To run the public `apps/web` app as well, use `pnpm --filter @openadminjs/web dev` in another terminal.
76
-
77
50
  Typical URLs:
78
51
 
79
52
  | App | URL |
@@ -83,59 +56,13 @@ Typical URLs:
83
56
  | API Swagger | http://localhost:4000/api/docs |
84
57
  | Web (demo) | http://localhost:3001 |
85
58
 
86
- ### 7. Sign in
59
+ ### 4. Sign in
87
60
 
88
61
  After a successful seed:
89
62
 
90
63
  - **Email:** `openadminjs@proton.me`
91
64
  - **Password:** `password`
92
65
 
93
- ### 8. Resources and data
94
-
95
- - **Built-in resources** live as Nest modules under `apps/api/src/resources` (e.g. `*.resource.ts`). They define list/create/edit metadata and permissions for Prisma models.
96
- - **Add a resource for a Prisma model** from the repo root (requires the CLI package in the workspace):
97
-
98
- ```bash
99
- pnpm exec openadminjs generate resource YourModelName
100
- ```
101
-
102
- This writes a starter file under `apps/api/src/resources`. Adjust fields, labels, and permissions, then restart or rely on hot reload depending on your setup.
103
-
104
- - **Fill tables with data** either through the admin UI (Resources menu) or with Prisma scripts, SQL, or your own seed files.
105
-
106
- ### 9. Static marketing site
107
-
108
- The hand-written site lives under **`site/`**. Sanity check:
109
-
110
- ```bash
111
- pnpm site:check
112
- ```
113
-
114
- ### 10. Quality commands
115
-
116
- ```bash
117
- pnpm lint
118
- pnpm typecheck
119
- pnpm test
120
- pnpm build
121
- pnpm security:check
122
- pnpm e2e
123
- ```
124
-
125
- `pnpm e2e` runs an auth regression scenario for admin session handling (invalid token + refresh fallback) and then the repository smoke checks.
126
-
127
- ## Scaffold a new project from npm
128
-
129
- ```bash
130
- npm create openadminjs@latest my-app
131
- cd my-app
132
- pnpm db:migrate
133
- pnpm db:seed
134
- pnpm dev
135
- ```
136
-
137
- Use the same demo credentials unless you change the seed.
138
-
139
66
  ## MVP scope
140
67
 
141
68
  - Resource-driven admin metadata with safe defaults.
@@ -152,13 +79,6 @@ Set `REDIS_URL` in your environment to enable queue processing (example: `redis:
152
79
 
153
80
  OpenAdminJS is community-powered and stays free thanks to partner support.
154
81
 
155
- <!-- - Nebula Systems (example)
156
- - Arcbyte (example)
157
- - Vertex Labs (example)
158
- - Gridstack (example)
159
- - Orbitlab (example)
160
- - Pulseforge (example) -->
161
-
162
82
  Want to become a partner and place your logo in the project materials?
163
83
  Email us at `openadminjs@proton.me`.
164
84
 
@@ -75,6 +75,6 @@ Use an automation token (`NPM_TOKEN`) in GitHub Actions with `npm publish` in a
75
75
 
76
76
  ---
77
77
 
78
- If you only want to **install** OpenAdminJS tooling from npm (not publish), use:
78
+ If you only want to **start a new project** from npm (not publish), use:
79
79
 
80
- `npm install -g openadminjs` then `openadminjs create`.
80
+ `npm create openadminjs@latest my-app`.
@@ -14,7 +14,7 @@ Minimal generated OpenAdminJS project with users, roles, posts, files, audit log
14
14
 
15
15
  ### Merge into your app
16
16
 
17
- 1. Run `openadminjs create` (or use your existing app).
17
+ 1. Run `npm create openadminjs@latest my-app` (or use your existing app).
18
18
  2. Append `prisma/models.fragment.prisma` to `prisma/schema.prisma`.
19
19
  3. Copy `src/resources/*.ts` into `apps/api/src/resources/`.
20
20
  4. Import resources in `registry.ts` and add them to the `resources` array (see `basicExampleResources` in `src/index.ts`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openadminjs",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Resource-driven admin platform for Node.js teams.",
5
5
  "license": "MIT",
6
6
  "packageManager": "pnpm@9.15.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openadminjs",
3
- "version": "0.1.0",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "openadminjs": "dist/index.js"
@@ -78,11 +78,43 @@ cli.command("create [projectName]", "Create a new OpenAdminJS project").action(a
78
78
  });
79
79
  cli.command("build", "Build all workspaces").action(() => runScript("build"));
80
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);
81
+ cli
82
+ .command("db <action>", "Run database helper commands")
83
+ .action((action?: string) => {
84
+ switch (action) {
85
+ case "migrate":
86
+ console.log("Run: pnpm --filter @openadminjs/api prisma migrate dev");
87
+ return;
88
+ case "seed":
89
+ console.log("Run: pnpm --filter @openadminjs/api prisma db seed");
90
+ return;
91
+ case "studio":
92
+ console.log("Run: pnpm --filter @openadminjs/api prisma studio");
93
+ return;
94
+ default:
95
+ console.error(pc.red("Unknown db action. Use: migrate, seed, studio."));
96
+ process.exitCode = 1;
97
+ }
98
+ });
99
+
100
+ function runResourceCommand(kind: string | undefined, modelName: string | undefined, options: { force?: boolean }): void {
101
+ if (kind !== "resource" || !modelName) {
102
+ console.error(pc.red("Usage: openadminjs generate resource <modelName> [--force]"));
103
+ process.exitCode = 1;
104
+ return;
105
+ }
106
+ generateResource(modelName, options);
107
+ }
108
+
109
+ cli
110
+ .command("generate <kind> <modelName>", "Generate safe resource config")
111
+ .option("--force", "Overwrite existing file")
112
+ .action(runResourceCommand);
113
+
114
+ cli
115
+ .command("make <kind> <modelName>", "Alias for generate resource")
116
+ .option("--force", "Overwrite existing file")
117
+ .action(runResourceCommand);
86
118
  cli.command("doctor", "Check generated project health").action(doctor);
87
119
  cli.command("security", "Run security checklist").action(securityCheck);
88
120
  cli.command("security check", "Run security checklist").action(securityCheck);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-openadminjs",
3
3
  "version": "0.1.0",
4
- "private": true,
4
+ "private": false,
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "create-openadminjs": "dist/index.js"
package/site/docs.html CHANGED
@@ -43,8 +43,7 @@
43
43
  <span>Quick install</span>
44
44
  <div class="docs-code-block docs-code-block--inline" data-language="bash">
45
45
  <div class="docs-code-toolbar"><span class="docs-code-lang">bash</span><button type="button" class="docs-code-copy" data-copy-code>Copy</button></div>
46
- <pre><code>npm install -g openadminjs
47
- openadminjs create my-app</code></pre>
46
+ <pre><code>npm create openadminjs@latest my-app</code></pre>
48
47
  </div>
49
48
  </div>
50
49
  </section>
@@ -164,8 +163,7 @@ openadminjs create my-app</code></pre>
164
163
  </p>
165
164
  <div class="docs-code-block" data-language="bash">
166
165
  <div class="docs-code-toolbar"><span class="docs-code-lang">bash</span><button type="button" class="docs-code-copy" data-copy-code>Copy</button></div>
167
- <pre><code>npm install -g openadminjs
168
- openadminjs create my-app
166
+ <pre><code>npm create openadminjs@latest my-app
169
167
  cd my-app
170
168
  pnpm db:migrate
171
169
  pnpm db:seed
@@ -240,30 +238,29 @@ pnpm test # all workspace tests
240
238
  pnpm --filter @openadminjs/api build</code></pre>
241
239
  </div>
242
240
  <p>
243
- The global CLI also prints equivalent commands for <code>openadminjs db migrate</code>, <code>db seed</code>, and <code>db studio</code>; those are thin wrappers that remind you which
244
- <code>pnpm</code> filter to use.
241
+ OpenAdminJS commands are run from your project workspace (for example via <code>pnpm exec openadminjs ...</code>).
242
+ Database shortcuts still map to the same underlying <code>pnpm</code> and Prisma commands.
245
243
  </p>
246
244
  </section>
247
245
 
248
246
  <section id="cli">
249
247
  <h2>CLI reference</h2>
250
- <p>Install <code>openadminjs</code> globally, then use <code>openadminjs</code> (short alias may be <code>oajs</code> depending on your install).</p>
248
+ <p>Use the packaged CLI from your project workspace via <code>pnpm exec openadminjs ...</code> (or through npm scripts).</p>
251
249
 
252
- <h3 id="cli-create">openadminjs create</h3>
250
+ <h3 id="cli-create">Project creation</h3>
253
251
  <p>Scaffolds a monorepo with <code>apps/api</code>, <code>apps/admin</code>, <code>apps/web</code>, shared packages, Prisma schema, and automatically installs dependencies with the selected package manager.</p>
254
252
  <div class="docs-code-block" data-language="bash">
255
253
  <div class="docs-code-toolbar"><span class="docs-code-lang">bash</span><button type="button" class="docs-code-copy" data-copy-code>Copy</button></div>
256
- <pre><code>npm install -g openadminjs
257
- openadminjs create # interactive prompts
258
- openadminjs create my-app # non-interactive project name</code></pre>
254
+ <pre><code>npm create openadminjs@latest my-app
255
+ cd my-app</code></pre>
259
256
  </div>
260
257
 
261
258
  <h3 id="cli-generate-resource">generate resource / make resource</h3>
262
259
  <p>Emits a starter <code>*.resource.ts</code> next to your other resources. Model name is PascalCase (Prisma model); the file uses <code>defineResource</code> with kebab-case <code>name</code> and permission keys.</p>
263
260
  <div class="docs-code-block" data-language="bash">
264
261
  <div class="docs-code-toolbar"><span class="docs-code-lang">bash</span><button type="button" class="docs-code-copy" data-copy-code>Copy</button></div>
265
- <pre><code>openadminjs generate resource Invoice --force
266
- openadminjs make resource Invoice # alias</code></pre>
262
+ <pre><code>pnpm exec openadminjs generate resource Invoice --force
263
+ pnpm exec openadminjs make resource Invoice # alias</code></pre>
267
264
  </div>
268
265
  <p>Always register the new file in <code>registry.ts</code>, extend Prisma if needed, then migrate.</p>
269
266
 
@@ -271,16 +268,16 @@ openadminjs make resource Invoice # alias</code></pre>
271
268
  <p>Runs quick health checks (env files, Prisma generate, lockfile) so CI or onboarding catches misconfiguration early.</p>
272
269
  <div class="docs-code-block" data-language="bash">
273
270
  <div class="docs-code-toolbar"><span class="docs-code-lang">bash</span><button type="button" class="docs-code-copy" data-copy-code>Copy</button></div>
274
- <pre><code>openadminjs doctor</code></pre>
271
+ <pre><code>pnpm exec openadminjs doctor</code></pre>
275
272
  </div>
276
273
 
277
274
  <h3 id="cli-db">db migrate | seed | studio</h3>
278
275
  <p>These commands print the exact <code>pnpm</code> / Prisma invocations to run from your project root so you do not guess package names.</p>
279
276
  <div class="docs-code-block" data-language="bash">
280
277
  <div class="docs-code-toolbar"><span class="docs-code-lang">bash</span><button type="button" class="docs-code-copy" data-copy-code>Copy</button></div>
281
- <pre><code>openadminjs db migrate
282
- openadminjs db seed
283
- openadminjs db studio</code></pre>
278
+ <pre><code>pnpm exec openadminjs db migrate
279
+ pnpm exec openadminjs db seed
280
+ pnpm exec openadminjs db studio</code></pre>
284
281
  </div>
285
282
  </section>
286
283
 
@@ -1368,7 +1365,7 @@ GET /store/orders/:id/status</code></pre>
1368
1365
  <ul class="docs-list">
1369
1366
  <li><strong>Partner applications</strong> — branding, sponsorship and collaboration requests.</li>
1370
1367
  <li><strong>Financial support</strong> — for direct support options, contact <a href="mailto:openadminjs@proton.me">openadminjs@proton.me</a>.</li>
1371
- <li><strong>Bug reports &amp; feature requests</strong> — open an issue on GitHub; include a reproduction case and the output of <code>openadminjs doctor</code>.</li>
1368
+ <li><strong>Bug reports &amp; feature requests</strong> — open an issue on GitHub; include a reproduction case and the output of <code>pnpm exec openadminjs doctor</code>.</li>
1372
1369
  <li><strong>Pull requests</strong> — all contributions welcome; check the <code>CONTRIBUTING.md</code> at the repo root before opening a PR.</li>
1373
1370
  </ul>
1374
1371
  </section>
@@ -1427,7 +1424,7 @@ GET /store/orders/:id/status</code></pre>
1427
1424
 
1428
1425
  <h3>Developer experience</h3>
1429
1426
  <ul class="docs-list">
1430
- <li>🟢 CLI scaffold with <code>openadminjs create</code></li>
1427
+ <li>🟢 CLI scaffold with <code>npm create openadminjs@latest</code></li>
1431
1428
  <li>🟡 VS Code extension — resource file type support, schema validation</li>
1432
1429
  <li>⚪ <code>openadminjs generate field</code> — append a field to an existing resource and emit a Prisma migration fragment</li>
1433
1430
  <li>⚪ Storybook integration — isolated UI component development</li>
package/site/index.html CHANGED
@@ -53,7 +53,7 @@
53
53
  </ul>
54
54
  <div class="command-chip command-chip-glow">
55
55
  <span>Quick start</span>
56
- <code>npm i -g openadminjs && openadminjs create</code>
56
+ <code>npm create openadminjs@latest my-app</code>
57
57
  </div>
58
58
  </div>
59
59