@rebasepro/cli 0.9.1-canary.7dddf96 → 0.9.1-canary.97e305f
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/dist/commands/cloud/context.d.ts +101 -5
- package/dist/commands/cloud/deploy.d.ts +2 -2
- package/dist/commands/cloud/deployments.d.ts +39 -0
- package/dist/commands/cloud/domains.d.ts +1 -0
- package/dist/commands/cloud/env.d.ts +6 -0
- package/dist/commands/cloud/extensions.d.ts +3 -0
- package/dist/commands/cloud/power.d.ts +4 -0
- package/dist/commands/cloud/projects.d.ts +2 -2
- package/dist/commands/cloud/settings.d.ts +8 -0
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/skills.d.ts +1 -1
- package/dist/index.es.js +3361 -1611
- package/dist/index.es.js.map +1 -1
- package/dist/utils/package-manager.d.ts +19 -5
- package/package.json +7 -7
- package/templates/overlays/baas/README.md +19 -1
- package/templates/overlays/baas/backend/package.json +1 -1
- package/templates/overlays/baas/backend/src/index.ts +23 -3
- package/templates/overlays/baas/backend/tsconfig.json +2 -1
- package/templates/template/.env.example +6 -3
- package/templates/template/backend/package.json +2 -1
- package/templates/template/backend/src/env.ts +30 -1
- package/templates/template/backend/src/index.ts +18 -2
- package/templates/template/config/collections/presets/blank/index.ts +3 -1
- package/templates/template/config/collections/presets/ecommerce/index.ts +3 -1
- package/templates/template/config/collections/users.ts +2 -0
- package/templates/template/gitignore +31 -0
- package/templates/template/npmrc +10 -0
|
@@ -20,13 +20,27 @@ export interface PMCommands {
|
|
|
20
20
|
workspaceProtocol: string;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Whether pnpm is runnable on this machine.
|
|
24
|
+
*
|
|
25
|
+
* Used to decide whether a fresh project can be scaffolded with pnpm. Kept
|
|
26
|
+
* cheap and non-interactive (short timeout, output discarded) so it never
|
|
27
|
+
* hangs detection if a corepack shim misbehaves.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isPnpmAvailable(): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Detect the package manager for a Rebase project.
|
|
32
|
+
*
|
|
33
|
+
* Rebase recommends pnpm, so detection prefers it. Crucially, *how the CLI was
|
|
34
|
+
* invoked* (`npx` vs `pnpm dlx`, i.e. `npm_config_user_agent`) is deliberately
|
|
35
|
+
* ignored: running `npx @rebasepro/cli init` says nothing about how the user
|
|
36
|
+
* wants to manage the project they're creating, and letting it pin the scaffold
|
|
37
|
+
* to npm is what made every `npx`-invoked project an npm project.
|
|
24
38
|
*
|
|
25
39
|
* Detection order:
|
|
26
|
-
* 1.
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
40
|
+
* 1. An existing lock file — an explicit choice we always respect
|
|
41
|
+
* (`pnpm-lock.yaml` wins over `package-lock.json` when both are present).
|
|
42
|
+
* 2. pnpm, whenever it is installed.
|
|
43
|
+
* 3. npm, only as a fallback when pnpm is genuinely unavailable.
|
|
30
44
|
*/
|
|
31
45
|
export declare function detectPackageManager(targetDir?: string): PackageManager;
|
|
32
46
|
/** Build the command helpers for a given package manager. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/cli",
|
|
3
|
-
"version": "0.9.1-canary.
|
|
3
|
+
"version": "0.9.1-canary.97e305f",
|
|
4
4
|
"description": "Developer tools for Rebase projects",
|
|
5
5
|
"main": "./dist/index.es.js",
|
|
6
6
|
"module": "./dist/index.es.js",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"execa": "^9.6.1",
|
|
32
32
|
"inquirer": "14.0.2",
|
|
33
33
|
"jiti": "^2.7.0",
|
|
34
|
-
"@rebasepro/agent-skills": "0.9.1-canary.
|
|
35
|
-
"@rebasepro/client": "0.9.1-canary.
|
|
36
|
-
"@rebasepro/codegen": "0.9.1-canary.
|
|
37
|
-
"@rebasepro/server": "0.9.1-canary.
|
|
38
|
-
"@rebasepro/server-postgres": "0.9.1-canary.
|
|
39
|
-
"@rebasepro/types": "0.9.1-canary.
|
|
34
|
+
"@rebasepro/agent-skills": "0.9.1-canary.97e305f",
|
|
35
|
+
"@rebasepro/client": "0.9.1-canary.97e305f",
|
|
36
|
+
"@rebasepro/codegen": "0.9.1-canary.97e305f",
|
|
37
|
+
"@rebasepro/server": "0.9.1-canary.97e305f",
|
|
38
|
+
"@rebasepro/server-postgres": "0.9.1-canary.97e305f",
|
|
39
|
+
"@rebasepro/types": "0.9.1-canary.97e305f"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "^25.9.3",
|
|
@@ -4,9 +4,27 @@ A headless Rebase backend: a REST API, auth, storage, realtime and backups over
|
|
|
4
4
|
your PostgreSQL database.
|
|
5
5
|
|
|
6
6
|
There are no collection files. The server reads your database schema at boot and
|
|
7
|
-
serves
|
|
7
|
+
serves your tables, so the API follows your migrations — change the schema and
|
|
8
8
|
the endpoints change with it.
|
|
9
9
|
|
|
10
|
+
## Serving a table
|
|
11
|
+
|
|
12
|
+
A table is served once it has an authorization model: row-level security enabled
|
|
13
|
+
plus at least one policy. Until then the server skips it — deliberately, so a new
|
|
14
|
+
table is never exposed just by existing — and logs each table it skipped and why.
|
|
15
|
+
|
|
16
|
+
```sql
|
|
17
|
+
ALTER TABLE your_table ENABLE ROW LEVEL SECURITY;
|
|
18
|
+
CREATE POLICY your_table_owner ON your_table
|
|
19
|
+
FOR ALL USING (user_id = auth.uid());
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`auth.uid()`, `auth.roles()` and `auth.jwt()` are provided by Rebase and read the
|
|
23
|
+
identity of the authenticated request.
|
|
24
|
+
|
|
25
|
+
To serve unprotected tables anyway (development only), set
|
|
26
|
+
`baas: { unprotectedTables: "serve" }` in `backend/src/index.ts`.
|
|
27
|
+
|
|
10
28
|
## Run it
|
|
11
29
|
|
|
12
30
|
```bash
|
|
@@ -36,10 +36,26 @@ const allowedOrigins = isProduction
|
|
|
36
36
|
})()
|
|
37
37
|
: [];
|
|
38
38
|
|
|
39
|
+
// In dev we still restrict which origins are reflected. Because `credentials`
|
|
40
|
+
// is enabled, reflecting an arbitrary Origin would let any website the
|
|
41
|
+
// developer happens to visit make credentialed cross-origin requests to this
|
|
42
|
+
// dev server (and read the responses) using the developer's session. So dev
|
|
43
|
+
// reflects only localhost origins; requests with no Origin (curl, same-origin)
|
|
44
|
+
// are unaffected.
|
|
45
|
+
const isLocalhostOrigin = (origin: string): boolean => {
|
|
46
|
+
try {
|
|
47
|
+
const { hostname } = new URL(origin);
|
|
48
|
+
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname === "[::1]";
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
39
54
|
app.use("/*", cors({
|
|
40
55
|
origin: (origin) => {
|
|
41
|
-
if (
|
|
42
|
-
|
|
56
|
+
if (isProduction) return allowedOrigins.includes(origin) ? origin : null;
|
|
57
|
+
if (!origin) return "*";
|
|
58
|
+
return isLocalhostOrigin(origin) ? origin : null;
|
|
43
59
|
},
|
|
44
60
|
credentials: true
|
|
45
61
|
}));
|
|
@@ -149,7 +165,11 @@ pass: env.SMTP_PASS! }
|
|
|
149
165
|
process.on("exit", cleanup);
|
|
150
166
|
|
|
151
167
|
logger.info(`API running at http://localhost:${actualPort}`);
|
|
152
|
-
|
|
168
|
+
// Docs are only mounted once there is something to document; with no
|
|
169
|
+
// servable tables the URL would 404, so don't advertise it.
|
|
170
|
+
if (backend.collectionRegistry.getCollections().length > 0) {
|
|
171
|
+
logger.info(`API docs at http://localhost:${actualPort}/api/swagger`);
|
|
172
|
+
}
|
|
153
173
|
} else {
|
|
154
174
|
server.listen(PORT, () => {
|
|
155
175
|
logger.info(`API running at http://localhost:${PORT}`);
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"moduleResolution": "node",
|
|
6
6
|
"lib": ["ES2022"],
|
|
7
7
|
"outDir": "./dist",
|
|
8
|
+
"rootDir": "./src",
|
|
8
9
|
"strict": true,
|
|
9
10
|
"esModuleInterop": true,
|
|
10
11
|
"allowSyntheticDefaultImports": true,
|
|
@@ -14,5 +15,5 @@
|
|
|
14
15
|
"declaration": true,
|
|
15
16
|
"sourceMap": true
|
|
16
17
|
},
|
|
17
|
-
"include": ["src/**/*"
|
|
18
|
+
"include": ["src/**/*"]
|
|
18
19
|
}
|
|
@@ -7,11 +7,14 @@
|
|
|
7
7
|
# Database connection string (required)
|
|
8
8
|
# You can use PostgreSQL (postgresql://) or MongoDB (mongodb:// or mongodb+srv://).
|
|
9
9
|
# The backend will automatically detect the database type.
|
|
10
|
-
|
|
10
|
+
# sslmode=disable matches the local docker-compose database, which has no TLS;
|
|
11
|
+
# schema tooling (atlas) would otherwise default to requiring SSL. Remove it
|
|
12
|
+
# when pointing at a managed/cloud database.
|
|
13
|
+
DATABASE_URL=postgresql://rebase:changeme@localhost:5432/rebase?options=-c%20search_path=public&sslmode=disable
|
|
11
14
|
# DATABASE_URL=mongodb://localhost:27017/rebase
|
|
12
15
|
#
|
|
13
|
-
# Seeing "SSL is not enabled on the server"?
|
|
14
|
-
#
|
|
16
|
+
# Seeing "SSL is not enabled on the server"? Something in your environment
|
|
17
|
+
# asks for SSL — almost always a global PGSSLMODE=require
|
|
15
18
|
# (set once for a cloud database, then inherited by every local project), or an
|
|
16
19
|
# sslmode=require copied in with a connection string.
|
|
17
20
|
#
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as dotenv from "dotenv";
|
|
2
|
+
import fs from "fs";
|
|
2
3
|
import path from "path";
|
|
3
4
|
import { fileURLToPath } from "url";
|
|
4
5
|
import { loadEnv } from "@rebasepro/server";
|
|
@@ -7,7 +8,35 @@ import { z } from "zod";
|
|
|
7
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
8
9
|
const __dirname = path.dirname(__filename);
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Locate the project's `.env` by walking up the directory tree.
|
|
13
|
+
*
|
|
14
|
+
* A fixed relative path can't work in both modes: in dev this file runs from
|
|
15
|
+
* source at `backend/src/env.ts`, but the compiled output lives at
|
|
16
|
+
* `backend/dist/backend/src/env.js` — two directories deeper — so
|
|
17
|
+
* `../../.env` points at a file that doesn't exist in production. Walking up
|
|
18
|
+
* finds the root `.env` from either location.
|
|
19
|
+
*/
|
|
20
|
+
function findEnvFile(startDir: string): string | undefined {
|
|
21
|
+
let dir = startDir;
|
|
22
|
+
// eslint-disable-next-line no-constant-condition
|
|
23
|
+
while (true) {
|
|
24
|
+
const candidate = path.join(dir, ".env");
|
|
25
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
26
|
+
const parent = path.dirname(dir);
|
|
27
|
+
if (parent === dir) return undefined;
|
|
28
|
+
dir = parent;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// `rebase start` sets DOTENV_CONFIG_PATH to the project's .env; honor it first,
|
|
33
|
+
// then fall back to searching up from this file. When neither is found (e.g. a
|
|
34
|
+
// production host that injects env vars directly), skip dotenv entirely and let
|
|
35
|
+
// the real process environment flow through.
|
|
36
|
+
const envPath = process.env.DOTENV_CONFIG_PATH || findEnvFile(__dirname);
|
|
37
|
+
if (envPath && fs.existsSync(envPath)) {
|
|
38
|
+
dotenv.config({ path: envPath });
|
|
39
|
+
}
|
|
11
40
|
|
|
12
41
|
export const env = loadEnv({
|
|
13
42
|
extend: z.object({
|
|
@@ -39,10 +39,26 @@ const allowedOrigins = isProduction
|
|
|
39
39
|
})()
|
|
40
40
|
: [];
|
|
41
41
|
|
|
42
|
+
// In dev we still restrict which origins are reflected. Because `credentials`
|
|
43
|
+
// is enabled, reflecting an arbitrary Origin would let any website the
|
|
44
|
+
// developer happens to visit make credentialed cross-origin requests to this
|
|
45
|
+
// dev server (and read the responses) using the developer's session. So dev
|
|
46
|
+
// reflects only localhost origins; requests with no Origin (curl, same-origin)
|
|
47
|
+
// are unaffected.
|
|
48
|
+
const isLocalhostOrigin = (origin: string): boolean => {
|
|
49
|
+
try {
|
|
50
|
+
const { hostname } = new URL(origin);
|
|
51
|
+
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname === "[::1]";
|
|
52
|
+
} catch {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
42
57
|
app.use("/*", cors({
|
|
43
58
|
origin: (origin) => {
|
|
44
|
-
if (
|
|
45
|
-
|
|
59
|
+
if (isProduction) return allowedOrigins.includes(origin) ? origin : null;
|
|
60
|
+
if (!origin) return "*";
|
|
61
|
+
return isLocalhostOrigin(origin) ? origin : null;
|
|
46
62
|
},
|
|
47
63
|
credentials: true
|
|
48
64
|
}));
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// Resolves after `rebase init` copies this file into config/collections/,
|
|
2
|
+
// next to the shared users.ts — not from inside presets/, which never runs.
|
|
3
|
+
import usersCollection from "./users.js";
|
|
2
4
|
|
|
3
5
|
export const collections = [usersCollection];
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import productsCollection from "./products.js";
|
|
2
2
|
import categoriesCollection from "./categories.js";
|
|
3
3
|
import ordersCollection from "./orders.js";
|
|
4
|
-
|
|
4
|
+
// Resolves after `rebase init` copies this file into config/collections/,
|
|
5
|
+
// next to the shared users.ts — not from inside presets/, which never runs.
|
|
6
|
+
import usersCollection from "./users.js";
|
|
5
7
|
|
|
6
8
|
export const collections = [productsCollection, categoriesCollection, ordersCollection, usersCollection];
|
|
@@ -66,6 +66,7 @@ roles: ["admin"] }
|
|
|
66
66
|
name: "Password Hash",
|
|
67
67
|
type: "string",
|
|
68
68
|
columnName: "password_hash",
|
|
69
|
+
excludeFromApi: true,
|
|
69
70
|
ui: {
|
|
70
71
|
hideFromCollection: true,
|
|
71
72
|
disabled: { hidden: true }
|
|
@@ -85,6 +86,7 @@ roles: ["admin"] }
|
|
|
85
86
|
name: "Email Verification Token",
|
|
86
87
|
type: "string",
|
|
87
88
|
columnName: "email_verification_token",
|
|
89
|
+
excludeFromApi: true,
|
|
88
90
|
ui: {
|
|
89
91
|
hideFromCollection: true,
|
|
90
92
|
disabled: { hidden: true }
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Dependencies
|
|
2
|
+
node_modules/
|
|
3
|
+
|
|
4
|
+
# Build output
|
|
5
|
+
dist/
|
|
6
|
+
build/
|
|
7
|
+
|
|
8
|
+
# Environment (secrets — .env.example is tracked)
|
|
9
|
+
.env
|
|
10
|
+
.env.local
|
|
11
|
+
!.env.example
|
|
12
|
+
|
|
13
|
+
# IDE
|
|
14
|
+
.idea/
|
|
15
|
+
.vscode/
|
|
16
|
+
*.swp
|
|
17
|
+
*.swo
|
|
18
|
+
|
|
19
|
+
# OS
|
|
20
|
+
.DS_Store
|
|
21
|
+
Thumbs.db
|
|
22
|
+
|
|
23
|
+
# Drizzle
|
|
24
|
+
drizzle/meta/
|
|
25
|
+
|
|
26
|
+
# Uploads
|
|
27
|
+
uploads/
|
|
28
|
+
|
|
29
|
+
# Rebase dev
|
|
30
|
+
.rebase-dev-url
|
|
31
|
+
.rebase-dev-port
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Ensure pnpm links local workspace packages when version specifiers
|
|
2
|
+
# like "*" are used (instead of the pnpm-specific "workspace:*" protocol).
|
|
3
|
+
# This makes the project compatible with both pnpm and npm workspaces.
|
|
4
|
+
link-workspace-packages=true
|
|
5
|
+
|
|
6
|
+
# Disable automatic dependency check before running scripts to prevent background install failures in read-only environments
|
|
7
|
+
verify-deps-before-run=false
|
|
8
|
+
|
|
9
|
+
# Prevent pnpm from prompting for confirmation when purging modules in non-TTY environments (e.g. Docker, CI)
|
|
10
|
+
confirm-modules-purge=false
|