@rebasepro/cli 0.9.1-canary.e2fc7b6 → 0.9.1-canary.eab7ae2

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.
@@ -20,13 +20,27 @@ export interface PMCommands {
20
20
  workspaceProtocol: string;
21
21
  }
22
22
  /**
23
- * Detect the package manager from the environment or the target directory.
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. Explicit override (if provided)
27
- * 2. `npm_config_user_agent` env var (set by npm/pnpm when running via `npx`/`pnpm dlx`)
28
- * 3. Lock-file presence in the target directory
29
- * 4. Default to pnpm (Rebase's recommended PM)
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.e2fc7b6",
3
+ "version": "0.9.1-canary.eab7ae2",
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.e2fc7b6",
35
- "@rebasepro/client": "0.9.1-canary.e2fc7b6",
36
- "@rebasepro/server": "0.9.1-canary.e2fc7b6",
37
- "@rebasepro/server-postgres": "0.9.1-canary.e2fc7b6",
38
- "@rebasepro/codegen": "0.9.1-canary.e2fc7b6",
39
- "@rebasepro/types": "0.9.1-canary.e2fc7b6"
34
+ "@rebasepro/agent-skills": "0.9.1-canary.eab7ae2",
35
+ "@rebasepro/codegen": "0.9.1-canary.eab7ae2",
36
+ "@rebasepro/server": "0.9.1-canary.eab7ae2",
37
+ "@rebasepro/server-postgres": "0.9.1-canary.eab7ae2",
38
+ "@rebasepro/client": "0.9.1-canary.eab7ae2",
39
+ "@rebasepro/types": "0.9.1-canary.eab7ae2"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/node": "^25.9.3",
@@ -7,7 +7,7 @@
7
7
  "scripts": {
8
8
  "dev": "tsx watch --include=\"./functions/**/*\" src/index.ts",
9
9
  "build": "tsc",
10
- "start": "node dist/backend/src/index.js"
10
+ "start": "node dist/index.js"
11
11
  },
12
12
  "dependencies": {
13
13
  "@rebasepro/server": "workspace:*",
@@ -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/**/*", "drizzle.config.ts"]
18
+ "include": ["src/**/*"]
18
19
  }
@@ -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
- dotenv.config({ path: path.resolve(__dirname, "../../.env") });
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({