@base44-preview/cli 0.1.5-pr.571.4d6a59e → 0.1.5-pr.571.7e17867
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 +9 -0
- package/dist/cli/index.js +68 -17
- package/dist/cli/index.js.map +9 -8
- package/package.json +1 -1
|
@@ -9,6 +9,8 @@
|
|
|
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)
|
|
12
14
|
*/
|
|
13
15
|
|
|
14
16
|
export {};
|
|
@@ -17,6 +19,8 @@ const scriptPath = Deno.env.get("SCRIPT_PATH");
|
|
|
17
19
|
const appId = Deno.env.get("BASE44_APP_ID");
|
|
18
20
|
const accessToken = Deno.env.get("BASE44_ACCESS_TOKEN");
|
|
19
21
|
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");
|
|
20
24
|
|
|
21
25
|
if (!scriptPath) {
|
|
22
26
|
console.error("SCRIPT_PATH environment variable is required");
|
|
@@ -35,10 +39,15 @@ if (!appBaseUrl) {
|
|
|
35
39
|
|
|
36
40
|
import { createClient } from "npm:@base44/sdk";
|
|
37
41
|
|
|
42
|
+
const customHeaders: Record<string, string> = {};
|
|
43
|
+
if (isPrivileged) customHeaders["X-Bypass-RLS"] = "true";
|
|
44
|
+
if (dataEnv) customHeaders["X-Data-Env"] = dataEnv;
|
|
45
|
+
|
|
38
46
|
const base44 = createClient({
|
|
39
47
|
appId,
|
|
40
48
|
token: accessToken,
|
|
41
49
|
serverUrl: appBaseUrl,
|
|
50
|
+
headers: customHeaders,
|
|
42
51
|
});
|
|
43
52
|
|
|
44
53
|
(globalThis as any).base44 = base44;
|
package/dist/cli/index.js
CHANGED
|
@@ -251342,6 +251342,25 @@ class Base44Command extends Command {
|
|
|
251342
251342
|
});
|
|
251343
251343
|
}
|
|
251344
251344
|
}
|
|
251345
|
+
// src/cli/utils/confirm-push.ts
|
|
251346
|
+
async function confirmPush({
|
|
251347
|
+
isNonInteractive,
|
|
251348
|
+
yes,
|
|
251349
|
+
log,
|
|
251350
|
+
warning
|
|
251351
|
+
}) {
|
|
251352
|
+
if (isNonInteractive && !yes) {
|
|
251353
|
+
throw new InvalidInputError("--yes is required in non-interactive mode");
|
|
251354
|
+
}
|
|
251355
|
+
if (yes) {
|
|
251356
|
+
return true;
|
|
251357
|
+
}
|
|
251358
|
+
log.warn(warning);
|
|
251359
|
+
const proceed = await Re({
|
|
251360
|
+
message: "Are you sure you want to continue?"
|
|
251361
|
+
});
|
|
251362
|
+
return !Ct(proceed) && proceed;
|
|
251363
|
+
}
|
|
251345
251364
|
// src/cli/utils/json.ts
|
|
251346
251365
|
function toJsonStdout(result) {
|
|
251347
251366
|
return `${JSON.stringify(result, null, 2)}
|
|
@@ -251634,12 +251653,18 @@ function getAgentsPullCommand() {
|
|
|
251634
251653
|
}
|
|
251635
251654
|
|
|
251636
251655
|
// src/cli/commands/agents/push.ts
|
|
251637
|
-
async function pushAgentsAction({
|
|
251638
|
-
log,
|
|
251639
|
-
runTask: runTask2
|
|
251640
|
-
}) {
|
|
251656
|
+
async function pushAgentsAction({ isNonInteractive, log, runTask: runTask2 }, options) {
|
|
251641
251657
|
const { agents } = await readProjectConfig();
|
|
251642
251658
|
log.info(agents.length === 0 ? "No local agents found - this will delete all remote agents" : `Found ${agents.length} agents to push`);
|
|
251659
|
+
const proceed = await confirmPush({
|
|
251660
|
+
isNonInteractive,
|
|
251661
|
+
yes: options.yes,
|
|
251662
|
+
log,
|
|
251663
|
+
warning: "This will replace all remote agent configs with your local agents and delete any not present locally."
|
|
251664
|
+
});
|
|
251665
|
+
if (!proceed) {
|
|
251666
|
+
return { outroMessage: "Push cancelled" };
|
|
251667
|
+
}
|
|
251643
251668
|
const result = await runTask2("Pushing agents to Base44", async () => {
|
|
251644
251669
|
return await pushAgents(agents);
|
|
251645
251670
|
}, {
|
|
@@ -251658,7 +251683,7 @@ async function pushAgentsAction({
|
|
|
251658
251683
|
return { outroMessage: "Agents pushed to Base44" };
|
|
251659
251684
|
}
|
|
251660
251685
|
function getAgentsPushCommand() {
|
|
251661
|
-
return new Base44Command("push").description("Push local agents to Base44 (replaces all remote agent configs)").action(pushAgentsAction);
|
|
251686
|
+
return new Base44Command("push").description("Push local agents to Base44 (replaces all remote agent configs)").option("-y, --yes", "Skip confirmation prompt").action(pushAgentsAction);
|
|
251662
251687
|
}
|
|
251663
251688
|
|
|
251664
251689
|
// src/cli/commands/agents/index.ts
|
|
@@ -253023,6 +253048,15 @@ async function pushConnectorsAction({ isNonInteractive, log, runTask: runTask2,
|
|
|
253023
253048
|
log.info(`Found ${connectors.length} connectors to push: ${connectorNames}`);
|
|
253024
253049
|
}
|
|
253025
253050
|
}
|
|
253051
|
+
const proceed = await confirmPush({
|
|
253052
|
+
isNonInteractive,
|
|
253053
|
+
yes: options.yes,
|
|
253054
|
+
log,
|
|
253055
|
+
warning: "This will overwrite your app's connectors with your local copy and remove any not present locally."
|
|
253056
|
+
});
|
|
253057
|
+
if (!proceed) {
|
|
253058
|
+
return { outroMessage: "Push cancelled" };
|
|
253059
|
+
}
|
|
253026
253060
|
const { results } = await runTask2("Pushing connectors to Base44", async () => {
|
|
253027
253061
|
return await pushConnectors(connectors);
|
|
253028
253062
|
});
|
|
@@ -253046,7 +253080,7 @@ async function pushConnectorsAction({ isNonInteractive, log, runTask: runTask2,
|
|
|
253046
253080
|
return { outroMessage };
|
|
253047
253081
|
}
|
|
253048
253082
|
function getConnectorsPushCommand() {
|
|
253049
|
-
return new Base44Command("push").description("Push local connectors to Base44 (overwrites connectors on Base44)").option("--dir <path>", "Directory to read connector files from (default: ./connectors when using --app-id)").action(pushConnectorsAction);
|
|
253083
|
+
return new Base44Command("push").description("Push local connectors to Base44 (overwrites connectors on Base44)").option("--dir <path>", "Directory to read connector files from (default: ./connectors when using --app-id)").option("-y, --yes", "Skip confirmation prompt").action(pushConnectorsAction);
|
|
253050
253084
|
}
|
|
253051
253085
|
|
|
253052
253086
|
// src/cli/commands/connectors/index.ts
|
|
@@ -253074,16 +253108,22 @@ function getDashboardCommand() {
|
|
|
253074
253108
|
}
|
|
253075
253109
|
|
|
253076
253110
|
// src/cli/commands/entities/push.ts
|
|
253077
|
-
async function pushEntitiesAction({
|
|
253078
|
-
log,
|
|
253079
|
-
runTask: runTask2
|
|
253080
|
-
}) {
|
|
253111
|
+
async function pushEntitiesAction({ isNonInteractive, log, runTask: runTask2 }, options) {
|
|
253081
253112
|
const { entities } = await readProjectConfig();
|
|
253082
253113
|
if (entities.length === 0) {
|
|
253083
253114
|
return { outroMessage: "No entities found in project" };
|
|
253084
253115
|
}
|
|
253085
253116
|
const entityNames = entities.map((e2) => e2.name).join(", ");
|
|
253086
253117
|
log.info(`Found ${entities.length} entities to push: ${entityNames}`);
|
|
253118
|
+
const proceed = await confirmPush({
|
|
253119
|
+
isNonInteractive,
|
|
253120
|
+
yes: options.yes,
|
|
253121
|
+
log,
|
|
253122
|
+
warning: "This will overwrite your app's entities with your local copy and delete any not present locally."
|
|
253123
|
+
});
|
|
253124
|
+
if (!proceed) {
|
|
253125
|
+
return { outroMessage: "Push cancelled" };
|
|
253126
|
+
}
|
|
253087
253127
|
const result = await runTask2("Pushing entities to Base44", async () => {
|
|
253088
253128
|
return await pushEntities(entities);
|
|
253089
253129
|
}, {
|
|
@@ -253102,7 +253142,7 @@ async function pushEntitiesAction({
|
|
|
253102
253142
|
return { outroMessage: "Entities pushed to Base44" };
|
|
253103
253143
|
}
|
|
253104
253144
|
function getEntitiesPushCommand() {
|
|
253105
|
-
return new Command("entities").description("Manage project entities").addCommand(new Base44Command("push").description("Push local entities to Base44").action(pushEntitiesAction));
|
|
253145
|
+
return new Command("entities").description("Manage project entities").addCommand(new Base44Command("push").description("Push local entities to Base44").option("-y, --yes", "Skip confirmation prompt").action(pushEntitiesAction));
|
|
253106
253146
|
}
|
|
253107
253147
|
|
|
253108
253148
|
// src/cli/commands/functions/delete.ts
|
|
@@ -258458,7 +258498,7 @@ function getDevCommand() {
|
|
|
258458
258498
|
import { spawn as spawn4 } from "node:child_process";
|
|
258459
258499
|
import { copyFileSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
258460
258500
|
async function runScript(options8) {
|
|
258461
|
-
const { appId, code: code2, local } = options8;
|
|
258501
|
+
const { appId, code: code2, local, privileged, dataEnv } = options8;
|
|
258462
258502
|
verifyDenoInstalled("to run scripts with exec");
|
|
258463
258503
|
const cleanupFns = [];
|
|
258464
258504
|
const tempScript = await $file({ postfix: ".ts" });
|
|
@@ -258477,7 +258517,9 @@ async function runScript(options8) {
|
|
|
258477
258517
|
SCRIPT_PATH: scriptPath,
|
|
258478
258518
|
BASE44_APP_ID: appId,
|
|
258479
258519
|
BASE44_ACCESS_TOKEN: appUserToken,
|
|
258480
|
-
BASE44_APP_BASE_URL: appBaseUrl
|
|
258520
|
+
BASE44_APP_BASE_URL: appBaseUrl,
|
|
258521
|
+
...privileged ? { BASE44_PRIVILEGED: "true" } : {},
|
|
258522
|
+
...dataEnv ? { BASE44_DATA_ENV: dataEnv } : {}
|
|
258481
258523
|
},
|
|
258482
258524
|
stdio: "inherit"
|
|
258483
258525
|
});
|
|
@@ -258542,14 +258584,20 @@ async function execAction({ app, isNonInteractive }, options8) {
|
|
|
258542
258584
|
throw noInputError;
|
|
258543
258585
|
}
|
|
258544
258586
|
const local = options8.local ? await resolveLocalTarget(options8.port !== undefined ? parsePort(options8.port) : DEFAULT_DEV_SERVER_PORT) : undefined;
|
|
258545
|
-
const { exitCode } = await runScript({
|
|
258587
|
+
const { exitCode } = await runScript({
|
|
258588
|
+
appId: app.id,
|
|
258589
|
+
code: code2,
|
|
258590
|
+
local,
|
|
258591
|
+
privileged: options8.privileged,
|
|
258592
|
+
dataEnv: options8.dataEnv
|
|
258593
|
+
});
|
|
258546
258594
|
if (exitCode !== 0) {
|
|
258547
258595
|
process.exitCode = exitCode;
|
|
258548
258596
|
}
|
|
258549
258597
|
return {};
|
|
258550
258598
|
}
|
|
258551
258599
|
function getExecCommand() {
|
|
258552
|
-
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", `
|
|
258600
|
+
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})`).option("--privileged", "Run with admin privileges (bypass RLS). Requires app owner/editor role.").option("--data-env <environment>", "Data environment to run against (e.g. dev, prod)").addHelpText("after", `
|
|
258553
258601
|
Examples:
|
|
258554
258602
|
Run a script file:
|
|
258555
258603
|
$ cat ./script.ts | base44 exec
|
|
@@ -258558,7 +258606,10 @@ Examples:
|
|
|
258558
258606
|
$ echo "const users = await base44.entities.User.list()" | base44 exec
|
|
258559
258607
|
|
|
258560
258608
|
Against the local dev server (base44 dev must be running):
|
|
258561
|
-
$ echo "await base44.entities.Task.create({ title: 'seed' })" | base44 exec --local
|
|
258609
|
+
$ echo "await base44.entities.Task.create({ title: 'seed' })" | base44 exec --local
|
|
258610
|
+
|
|
258611
|
+
With privileged access (bypass RLS):
|
|
258612
|
+
$ echo "const all = await base44.entities.Task.list()" | base44 exec --privileged`).action(execAction);
|
|
258562
258613
|
}
|
|
258563
258614
|
|
|
258564
258615
|
// src/cli/commands/project/eject.ts
|
|
@@ -262952,4 +263003,4 @@ export {
|
|
|
262952
263003
|
CLIExitError
|
|
262953
263004
|
};
|
|
262954
263005
|
|
|
262955
|
-
//# debugId=
|
|
263006
|
+
//# debugId=DCFE890E296DDFB064756E2164756E21
|