@base44-preview/cli 0.0.47-pr.435.27294cb → 0.0.47-pr.437.84c5dd7
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.
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
* - BASE44_APP_ID: App identifier from .app.jsonc
|
|
10
10
|
* - BASE44_ACCESS_TOKEN: User's access token
|
|
11
11
|
* - BASE44_APP_BASE_URL: App's published URL / subdomain (used for function calls)
|
|
12
|
-
* - BASE44_ADMIN: When "true", adds X-Bypass-RLS header for admin access
|
|
13
12
|
*/
|
|
14
13
|
|
|
15
14
|
export {};
|
|
@@ -18,8 +17,6 @@ const scriptPath = Deno.env.get("SCRIPT_PATH");
|
|
|
18
17
|
const appId = Deno.env.get("BASE44_APP_ID");
|
|
19
18
|
const accessToken = Deno.env.get("BASE44_ACCESS_TOKEN");
|
|
20
19
|
const appBaseUrl = Deno.env.get("BASE44_APP_BASE_URL");
|
|
21
|
-
const isAdmin = Deno.env.get("BASE44_ADMIN") === "true";
|
|
22
|
-
const dataEnv = Deno.env.get("BASE44_DATA_ENV");
|
|
23
20
|
|
|
24
21
|
if (!scriptPath) {
|
|
25
22
|
console.error("SCRIPT_PATH environment variable is required");
|
|
@@ -38,15 +35,10 @@ if (!appBaseUrl) {
|
|
|
38
35
|
|
|
39
36
|
import { createClient } from "npm:@base44/sdk";
|
|
40
37
|
|
|
41
|
-
const customHeaders: Record<string, string> = {};
|
|
42
|
-
if (isAdmin) customHeaders["X-Bypass-RLS"] = "true";
|
|
43
|
-
if (dataEnv) customHeaders["X-Data-Env"] = dataEnv;
|
|
44
|
-
|
|
45
38
|
const base44 = createClient({
|
|
46
39
|
appId,
|
|
47
40
|
token: accessToken,
|
|
48
41
|
serverUrl: appBaseUrl,
|
|
49
|
-
headers: customHeaders,
|
|
50
42
|
});
|
|
51
43
|
|
|
52
44
|
(globalThis as any).base44 = base44;
|
package/dist/cli/index.js
CHANGED
|
@@ -251703,7 +251703,7 @@ function getDevCommand() {
|
|
|
251703
251703
|
import { spawn as spawn3 } from "node:child_process";
|
|
251704
251704
|
import { copyFileSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
251705
251705
|
async function runScript(options8) {
|
|
251706
|
-
const { appId, code: code2
|
|
251706
|
+
const { appId, code: code2 } = options8;
|
|
251707
251707
|
verifyDenoInstalled("to run scripts with exec");
|
|
251708
251708
|
const cleanupFns = [];
|
|
251709
251709
|
const tempScript = await $file({ postfix: ".ts" });
|
|
@@ -251725,9 +251725,7 @@ async function runScript(options8) {
|
|
|
251725
251725
|
SCRIPT_PATH: scriptPath,
|
|
251726
251726
|
BASE44_APP_ID: appId,
|
|
251727
251727
|
BASE44_ACCESS_TOKEN: appUserToken,
|
|
251728
|
-
BASE44_APP_BASE_URL: appBaseUrl
|
|
251729
|
-
...admin ? { BASE44_ADMIN: "true" } : {},
|
|
251730
|
-
...dataEnv ? { BASE44_DATA_ENV: dataEnv } : {}
|
|
251728
|
+
BASE44_APP_BASE_URL: appBaseUrl
|
|
251731
251729
|
},
|
|
251732
251730
|
stdio: "inherit"
|
|
251733
251731
|
});
|
|
@@ -251754,7 +251752,7 @@ function readStdin() {
|
|
|
251754
251752
|
process.stdin.on("error", reject);
|
|
251755
251753
|
});
|
|
251756
251754
|
}
|
|
251757
|
-
async function execAction(
|
|
251755
|
+
async function execAction(isNonInteractive) {
|
|
251758
251756
|
const noInputError = new InvalidInputError("No input provided. Pipe a script to stdin.", {
|
|
251759
251757
|
hints: [
|
|
251760
251758
|
{ message: "File: cat ./script.ts | base44 exec" },
|
|
@@ -251770,29 +251768,21 @@ async function execAction(options8, isNonInteractive) {
|
|
|
251770
251768
|
if (!code2.trim()) {
|
|
251771
251769
|
throw noInputError;
|
|
251772
251770
|
}
|
|
251773
|
-
const { exitCode } = await runScript({
|
|
251774
|
-
appId: getAppConfig().id,
|
|
251775
|
-
code: code2,
|
|
251776
|
-
admin: options8.admin,
|
|
251777
|
-
dataEnv: options8.env
|
|
251778
|
-
});
|
|
251771
|
+
const { exitCode } = await runScript({ appId: getAppConfig().id, code: code2 });
|
|
251779
251772
|
if (exitCode !== 0) {
|
|
251780
251773
|
process.exitCode = exitCode;
|
|
251781
251774
|
}
|
|
251782
251775
|
return {};
|
|
251783
251776
|
}
|
|
251784
251777
|
function getExecCommand() {
|
|
251785
|
-
return new Base44Command("exec").description("Run a script with the Base44 SDK pre-authenticated as the current user").
|
|
251778
|
+
return new Base44Command("exec").description("Run a script with the Base44 SDK pre-authenticated as the current user").addHelpText("after", `
|
|
251786
251779
|
Examples:
|
|
251787
251780
|
Run a script file:
|
|
251788
251781
|
$ cat ./script.ts | base44 exec
|
|
251789
251782
|
|
|
251790
251783
|
Inline script:
|
|
251791
|
-
$ echo "const users = await base44.entities.User.list()" | base44 exec
|
|
251792
|
-
|
|
251793
|
-
Run with admin privileges (bypass RLS):
|
|
251794
|
-
$ echo "const all = await base44.entities.Task.list()" | base44 exec --admin`).action(async (options8, command2) => {
|
|
251795
|
-
return await execAction(options8, command2.isNonInteractive);
|
|
251784
|
+
$ echo "const users = await base44.entities.User.list()" | base44 exec`).action(async (_options, command2) => {
|
|
251785
|
+
return await execAction(command2.isNonInteractive);
|
|
251796
251786
|
});
|
|
251797
251787
|
}
|
|
251798
251788
|
|
|
@@ -256170,4 +256160,4 @@ export {
|
|
|
256170
256160
|
CLIExitError
|
|
256171
256161
|
};
|
|
256172
256162
|
|
|
256173
|
-
//# debugId=
|
|
256163
|
+
//# debugId=03E220E345F1F26964756E2164756E21
|