@base44-preview/cli 0.1.5-pr.570.f3b8004 → 0.1.5-pr.572.2976402
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/assets/deno-runtime/exec.ts +0 -14
- package/dist/cli/index.js +25 -19
- package/dist/cli/index.js.map +5 -5
- package/package.json +1 -1
|
@@ -9,8 +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_PRIVILEGED: When "true", adds the X-Bypass-RLS header (bypass RLS)
|
|
13
|
-
* - BASE44_DATA_ENV: When set, adds the X-Data-Env header (target data environment)
|
|
14
12
|
*/
|
|
15
13
|
|
|
16
14
|
export {};
|
|
@@ -19,8 +17,6 @@ const scriptPath = Deno.env.get("SCRIPT_PATH");
|
|
|
19
17
|
const appId = Deno.env.get("BASE44_APP_ID");
|
|
20
18
|
const accessToken = Deno.env.get("BASE44_ACCESS_TOKEN");
|
|
21
19
|
const appBaseUrl = Deno.env.get("BASE44_APP_BASE_URL");
|
|
22
|
-
const isPrivileged = Deno.env.get("BASE44_PRIVILEGED") === "true";
|
|
23
|
-
const dataEnv = Deno.env.get("BASE44_DATA_ENV");
|
|
24
20
|
|
|
25
21
|
if (!scriptPath) {
|
|
26
22
|
console.error("SCRIPT_PATH environment variable is required");
|
|
@@ -39,20 +35,10 @@ if (!appBaseUrl) {
|
|
|
39
35
|
|
|
40
36
|
import { createClient } from "npm:@base44/sdk";
|
|
41
37
|
|
|
42
|
-
const customHeaders: Record<string, string> = {};
|
|
43
|
-
if (isPrivileged) customHeaders["X-Bypass-RLS"] = "true";
|
|
44
|
-
// QUESTION(@netanelgilad): backend get_data_environment_from_request honors only
|
|
45
|
-
// "dev" and "prod" on X-Data-Env ("share" is host-derived, unknown values fall
|
|
46
|
-
// through to prod). It applies to entity CRUD, but for backend-function invocations
|
|
47
|
-
// a caller-supplied "dev" is dropped by trusted_request_data_env (prod/no-signal
|
|
48
|
-
// pass through). Intended scope for --data-env?
|
|
49
|
-
if (dataEnv) customHeaders["X-Data-Env"] = dataEnv;
|
|
50
|
-
|
|
51
38
|
const base44 = createClient({
|
|
52
39
|
appId,
|
|
53
40
|
token: accessToken,
|
|
54
41
|
serverUrl: appBaseUrl,
|
|
55
|
-
headers: customHeaders,
|
|
56
42
|
});
|
|
57
43
|
|
|
58
44
|
(globalThis as any).base44 = base44;
|
package/dist/cli/index.js
CHANGED
|
@@ -253457,9 +253457,22 @@ function printProjectSummary({ name: name2, dashboardUrl, appUrl }, log) {
|
|
|
253457
253457
|
}
|
|
253458
253458
|
|
|
253459
253459
|
// src/cli/commands/project/workspace-select.ts
|
|
253460
|
+
function isWorkspaceListForbidden(error48) {
|
|
253461
|
+
return error48 instanceof ApiError && error48.statusCode === 403;
|
|
253462
|
+
}
|
|
253460
253463
|
function fetchWorkspaces(ctx) {
|
|
253461
|
-
return ctx.runTask("Fetching workspaces...", () =>
|
|
253462
|
-
|
|
253464
|
+
return ctx.runTask("Fetching workspaces...", async (updateMessage) => {
|
|
253465
|
+
try {
|
|
253466
|
+
return await listWorkspaces();
|
|
253467
|
+
} catch (error48) {
|
|
253468
|
+
if (isWorkspaceListForbidden(error48)) {
|
|
253469
|
+
updateMessage("Using your default workspace");
|
|
253470
|
+
return null;
|
|
253471
|
+
}
|
|
253472
|
+
throw error48;
|
|
253473
|
+
}
|
|
253474
|
+
}, {
|
|
253475
|
+
successMessage: "Workspaces checked",
|
|
253463
253476
|
errorMessage: "Failed to fetch workspaces"
|
|
253464
253477
|
});
|
|
253465
253478
|
}
|
|
@@ -253475,6 +253488,10 @@ async function resolveWorkspaceId(ctx, flagWorkspaceId, isInteractive) {
|
|
|
253475
253488
|
return;
|
|
253476
253489
|
}
|
|
253477
253490
|
const workspaces = await fetchWorkspaces(ctx);
|
|
253491
|
+
if (workspaces === null) {
|
|
253492
|
+
ctx.log.warn("Couldn't list your workspaces with this login, so the default workspace will be used. Pass --workspace <id> to target a specific one.");
|
|
253493
|
+
return;
|
|
253494
|
+
}
|
|
253478
253495
|
if (workspaces.length <= 1) {
|
|
253479
253496
|
return;
|
|
253480
253497
|
}
|
|
@@ -258458,7 +258475,7 @@ function getDevCommand() {
|
|
|
258458
258475
|
import { spawn as spawn4 } from "node:child_process";
|
|
258459
258476
|
import { copyFileSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
258460
258477
|
async function runScript(options8) {
|
|
258461
|
-
const { appId, code: code2, local
|
|
258478
|
+
const { appId, code: code2, local } = options8;
|
|
258462
258479
|
verifyDenoInstalled("to run scripts with exec");
|
|
258463
258480
|
const cleanupFns = [];
|
|
258464
258481
|
const tempScript = await $file({ postfix: ".ts" });
|
|
@@ -258477,9 +258494,7 @@ async function runScript(options8) {
|
|
|
258477
258494
|
SCRIPT_PATH: scriptPath,
|
|
258478
258495
|
BASE44_APP_ID: appId,
|
|
258479
258496
|
BASE44_ACCESS_TOKEN: appUserToken,
|
|
258480
|
-
BASE44_APP_BASE_URL: appBaseUrl
|
|
258481
|
-
...privileged ? { BASE44_PRIVILEGED: "true" } : {},
|
|
258482
|
-
...dataEnv ? { BASE44_DATA_ENV: dataEnv } : {}
|
|
258497
|
+
BASE44_APP_BASE_URL: appBaseUrl
|
|
258483
258498
|
},
|
|
258484
258499
|
stdio: "inherit"
|
|
258485
258500
|
});
|
|
@@ -258544,20 +258559,14 @@ async function execAction({ app, isNonInteractive }, options8) {
|
|
|
258544
258559
|
throw noInputError;
|
|
258545
258560
|
}
|
|
258546
258561
|
const local = options8.local ? await resolveLocalTarget(options8.port !== undefined ? parsePort(options8.port) : DEFAULT_DEV_SERVER_PORT) : undefined;
|
|
258547
|
-
const { exitCode } = await runScript({
|
|
258548
|
-
appId: app.id,
|
|
258549
|
-
code: code2,
|
|
258550
|
-
local,
|
|
258551
|
-
privileged: options8.privileged,
|
|
258552
|
-
dataEnv: options8.dataEnv
|
|
258553
|
-
});
|
|
258562
|
+
const { exitCode } = await runScript({ appId: app.id, code: code2, local });
|
|
258554
258563
|
if (exitCode !== 0) {
|
|
258555
258564
|
process.exitCode = exitCode;
|
|
258556
258565
|
}
|
|
258557
258566
|
return {};
|
|
258558
258567
|
}
|
|
258559
258568
|
function getExecCommand() {
|
|
258560
|
-
return new Base44Command("exec").description("Run a script with the Base44 SDK pre-authenticated as the current user").option("--local", "Run against the local `base44 dev` server instead of the deployed app").option("--port <number>", `Port the local dev server is on (with --local; defaults to ${DEFAULT_DEV_SERVER_PORT})`).
|
|
258569
|
+
return new Base44Command("exec").description("Run a script with the Base44 SDK pre-authenticated as the current user").option("--local", "Run against the local `base44 dev` server instead of the deployed app").option("--port <number>", `Port the local dev server is on (with --local; defaults to ${DEFAULT_DEV_SERVER_PORT})`).addHelpText("after", `
|
|
258561
258570
|
Examples:
|
|
258562
258571
|
Run a script file:
|
|
258563
258572
|
$ cat ./script.ts | base44 exec
|
|
@@ -258566,10 +258575,7 @@ Examples:
|
|
|
258566
258575
|
$ echo "const users = await base44.entities.User.list()" | base44 exec
|
|
258567
258576
|
|
|
258568
258577
|
Against the local dev server (base44 dev must be running):
|
|
258569
|
-
$ echo "await base44.entities.Task.create({ title: 'seed' })" | base44 exec --local
|
|
258570
|
-
|
|
258571
|
-
With privileged access (bypass RLS):
|
|
258572
|
-
$ echo "const all = await base44.entities.Task.list()" | base44 exec --privileged`).action(execAction);
|
|
258578
|
+
$ echo "await base44.entities.Task.create({ title: 'seed' })" | base44 exec --local`).action(execAction);
|
|
258573
258579
|
}
|
|
258574
258580
|
|
|
258575
258581
|
// src/cli/commands/project/eject.ts
|
|
@@ -262963,4 +262969,4 @@ export {
|
|
|
262963
262969
|
CLIExitError
|
|
262964
262970
|
};
|
|
262965
262971
|
|
|
262966
|
-
//# debugId=
|
|
262972
|
+
//# debugId=9E1CC41992B39EA064756E2164756E21
|