@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.
- package/dist/index.es.js +38 -20
- 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/backend/package.json +1 -1
- package/templates/overlays/baas/backend/tsconfig.json +2 -1
- package/templates/template/backend/src/env.ts +30 -1
package/dist/index.es.js
CHANGED
|
@@ -9,8 +9,8 @@ import { execa, execaCommandSync } from "execa";
|
|
|
9
9
|
import { cp } from "fs/promises";
|
|
10
10
|
import { fileURLToPath } from "url";
|
|
11
11
|
import crypto from "crypto";
|
|
12
|
+
import { execSync, spawn, spawnSync } from "child_process";
|
|
12
13
|
import os from "os";
|
|
13
|
-
import { execSync, spawn } from "child_process";
|
|
14
14
|
import { createRebaseClient } from "@rebasepro/client";
|
|
15
15
|
import { generateSDK } from "@rebasepro/codegen";
|
|
16
16
|
import { createRequire } from "module";
|
|
@@ -23,28 +23,45 @@ import { createRequire } from "module";
|
|
|
23
23
|
* the rest of the CLI never has to hardcode a specific PM.
|
|
24
24
|
*/
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Whether pnpm is runnable on this machine.
|
|
27
|
+
*
|
|
28
|
+
* Used to decide whether a fresh project can be scaffolded with pnpm. Kept
|
|
29
|
+
* cheap and non-interactive (short timeout, output discarded) so it never
|
|
30
|
+
* hangs detection if a corepack shim misbehaves.
|
|
31
|
+
*/
|
|
32
|
+
function isPnpmAvailable() {
|
|
33
|
+
try {
|
|
34
|
+
return spawnSync("pnpm", ["--version"], {
|
|
35
|
+
stdio: "ignore",
|
|
36
|
+
timeout: 3e3
|
|
37
|
+
}).status === 0;
|
|
38
|
+
} catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Detect the package manager for a Rebase project.
|
|
44
|
+
*
|
|
45
|
+
* Rebase recommends pnpm, so detection prefers it. Crucially, *how the CLI was
|
|
46
|
+
* invoked* (`npx` vs `pnpm dlx`, i.e. `npm_config_user_agent`) is deliberately
|
|
47
|
+
* ignored: running `npx @rebasepro/cli init` says nothing about how the user
|
|
48
|
+
* wants to manage the project they're creating, and letting it pin the scaffold
|
|
49
|
+
* to npm is what made every `npx`-invoked project an npm project.
|
|
27
50
|
*
|
|
28
51
|
* Detection order:
|
|
29
|
-
* 1.
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
52
|
+
* 1. An existing lock file — an explicit choice we always respect
|
|
53
|
+
* (`pnpm-lock.yaml` wins over `package-lock.json` when both are present).
|
|
54
|
+
* 2. pnpm, whenever it is installed.
|
|
55
|
+
* 3. npm, only as a fallback when pnpm is genuinely unavailable.
|
|
33
56
|
*/
|
|
34
57
|
function detectPackageManager(targetDir) {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (fs.existsSync(path.join(targetDir, "package-lock.json"))) return "npm";
|
|
40
|
-
if (fs.existsSync(path.join(targetDir, "pnpm-lock.yaml"))) return "pnpm";
|
|
58
|
+
const dirs = [targetDir, process.cwd()].filter((d) => !!d);
|
|
59
|
+
for (const dir of dirs) {
|
|
60
|
+
if (fs.existsSync(path.join(dir, "pnpm-lock.yaml"))) return "pnpm";
|
|
61
|
+
if (fs.existsSync(path.join(dir, "package-lock.json"))) return "npm";
|
|
41
62
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (fs.existsSync(path.join(cwd, "package-lock.json"))) return "npm";
|
|
45
|
-
if (fs.existsSync(path.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
46
|
-
}
|
|
47
|
-
return "pnpm";
|
|
63
|
+
if (isPnpmAvailable()) return "pnpm";
|
|
64
|
+
return "npm";
|
|
48
65
|
}
|
|
49
66
|
/** Build the command helpers for a given package manager. */
|
|
50
67
|
function getPMCommands(pm) {
|
|
@@ -118,7 +135,8 @@ function getPMCommands(pm) {
|
|
|
118
135
|
runWorkspace: (workspace, script) => [
|
|
119
136
|
"pnpm",
|
|
120
137
|
"--filter",
|
|
121
|
-
workspace
|
|
138
|
+
`./${workspace}`,
|
|
139
|
+
"run",
|
|
122
140
|
script
|
|
123
141
|
],
|
|
124
142
|
dlx: (pkg, args) => [
|
|
@@ -5665,6 +5683,6 @@ ${chalk.gray("Documentation: https://rebase.pro/docs")}
|
|
|
5665
5683
|
`);
|
|
5666
5684
|
}
|
|
5667
5685
|
//#endregion
|
|
5668
|
-
export { authCommand, buildCommand, buildInitQuestions, cloudCommand, configureEnvFile, createRebaseApp, dbCommand, detectPackageManager, devCommand, doctorCommand, entry, findBackendDir, findEnvFile, findFrontendDir, findProjectRoot, generateSdkCommand, getActiveBackendPlugin, getPMCommands, requireBackendDir, requireProjectRoot, resolveLocalBin, resolvePluginCliScript, resolveTsx, schemaCommand, startCommand, validateProjectName, validateTsxInstallation };
|
|
5686
|
+
export { authCommand, buildCommand, buildInitQuestions, cloudCommand, configureEnvFile, createRebaseApp, dbCommand, detectPackageManager, devCommand, doctorCommand, entry, findBackendDir, findEnvFile, findFrontendDir, findProjectRoot, generateSdkCommand, getActiveBackendPlugin, getPMCommands, isPnpmAvailable, requireBackendDir, requireProjectRoot, resolveLocalBin, resolvePluginCliScript, resolveTsx, schemaCommand, startCommand, validateProjectName, validateTsxInstallation };
|
|
5669
5687
|
|
|
5670
5688
|
//# sourceMappingURL=index.es.js.map
|