@base44-preview/cli 0.1.21-pr.642.259f7d0 → 0.1.22-pr.644.053dbd4
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.
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
* - BASE44_APP_BASE_URL: App's published URL / subdomain (used for function calls)
|
|
12
12
|
* - BASE44_PRIVILEGED: When "true", adds the X-Bypass-RLS header (bypass RLS)
|
|
13
13
|
* - BASE44_DATA_ENV: When set, adds the X-Data-Env header (target data environment)
|
|
14
|
+
* - BASE44_SERVICE_TOKEN: When set, passed as `serviceToken` (enables `base44.asServiceRole`)
|
|
15
|
+
*
|
|
16
|
+
* BASE44_SERVICE_TOKEN is removed from the environment before the user script runs.
|
|
14
17
|
*/
|
|
15
18
|
|
|
16
19
|
export {};
|
|
@@ -21,6 +24,8 @@ const accessToken = Deno.env.get("BASE44_ACCESS_TOKEN");
|
|
|
21
24
|
const appBaseUrl = Deno.env.get("BASE44_APP_BASE_URL");
|
|
22
25
|
const isPrivileged = Deno.env.get("BASE44_PRIVILEGED") === "true";
|
|
23
26
|
const dataEnv = Deno.env.get("BASE44_DATA_ENV");
|
|
27
|
+
const serviceToken = Deno.env.get("BASE44_SERVICE_TOKEN");
|
|
28
|
+
Deno.env.delete("BASE44_SERVICE_TOKEN");
|
|
24
29
|
|
|
25
30
|
if (!scriptPath) {
|
|
26
31
|
console.error("SCRIPT_PATH environment variable is required");
|
|
@@ -46,6 +51,7 @@ if (dataEnv) customHeaders["X-Data-Env"] = dataEnv;
|
|
|
46
51
|
const base44 = createClient({
|
|
47
52
|
appId,
|
|
48
53
|
token: accessToken,
|
|
54
|
+
...(serviceToken ? { serviceToken } : {}),
|
|
49
55
|
serverUrl: appBaseUrl,
|
|
50
56
|
headers: customHeaders,
|
|
51
57
|
});
|
package/dist/cli/index.js
CHANGED
|
@@ -239265,7 +239265,7 @@ import { join as join13 } from "node:path";
|
|
|
239265
239265
|
// package.json
|
|
239266
239266
|
var package_default = {
|
|
239267
239267
|
name: "base44",
|
|
239268
|
-
version: "0.1.
|
|
239268
|
+
version: "0.1.22",
|
|
239269
239269
|
description: "Base44 CLI - Unified interface for managing Base44 applications",
|
|
239270
239270
|
type: "module",
|
|
239271
239271
|
bin: {
|
|
@@ -251495,21 +251495,6 @@ function parseConcurrency(value) {
|
|
|
251495
251495
|
return parsed;
|
|
251496
251496
|
}
|
|
251497
251497
|
|
|
251498
|
-
// src/cli/dev/append-serve-args.ts
|
|
251499
|
-
var SHELL_SAFE = /^[\w@%+=:,./-]+$/;
|
|
251500
|
-
function quote(arg, platform) {
|
|
251501
|
-
if (SHELL_SAFE.test(arg)) {
|
|
251502
|
-
return arg;
|
|
251503
|
-
}
|
|
251504
|
-
if (platform === "win32") {
|
|
251505
|
-
return `"${arg.replace(/"/g, "\\\"")}"`;
|
|
251506
|
-
}
|
|
251507
|
-
return `'${arg.replace(/'/g, "'\\''")}'`;
|
|
251508
|
-
}
|
|
251509
|
-
function appendServeArgs(command, args, platform = process.platform) {
|
|
251510
|
-
return [command, ...args.map((arg) => quote(arg, platform))].join(" ");
|
|
251511
|
-
}
|
|
251512
|
-
|
|
251513
251498
|
// src/cli/dev/createDevLogger.ts
|
|
251514
251499
|
var colorByType = {
|
|
251515
251500
|
error: theme.styles.error,
|
|
@@ -251688,7 +251673,8 @@ async function siteDevAction(ctx, forwarded) {
|
|
|
251688
251673
|
if (!site) {
|
|
251689
251674
|
throw new InvalidInputError(`This project has no 'site' block in base44/config.jsonc, so there is no frontend to serve. Add one naming its serveCommand; site dev falls back to "npm run dev".`);
|
|
251690
251675
|
}
|
|
251691
|
-
const
|
|
251676
|
+
const serveCommand = site.serveCommand ?? DEFAULT_SERVE_COMMAND;
|
|
251677
|
+
const command = [serveCommand, ...forwarded].join(" ");
|
|
251692
251678
|
const runner = createServeCommandRunner({
|
|
251693
251679
|
serveCommand: command,
|
|
251694
251680
|
projectRoot: project.root,
|
|
@@ -256177,11 +256163,63 @@ function getDevCommand() {
|
|
|
256177
256163
|
return new Base44Command("dev").description("Start the development server").option("-p, --port <number>", "Port for the development server").option("--remote", "Serve the frontend against the production backend instead of a local one").hook("preAction", validateDevOptions).action(devAction);
|
|
256178
256164
|
}
|
|
256179
256165
|
|
|
256166
|
+
// src/core/exec/env-target.ts
|
|
256167
|
+
var ACCESS_TOKEN_VAR = "BASE44_EXEC_ACCESS_TOKEN";
|
|
256168
|
+
var SERVER_URL_VAR = "BASE44_EXEC_SERVER_URL";
|
|
256169
|
+
var SERVICE_TOKEN_VAR = "BASE44_EXEC_SERVICE_TOKEN";
|
|
256170
|
+
var EXEC_ENV_VARS = [
|
|
256171
|
+
ACCESS_TOKEN_VAR,
|
|
256172
|
+
SERVER_URL_VAR,
|
|
256173
|
+
SERVICE_TOKEN_VAR
|
|
256174
|
+
];
|
|
256175
|
+
var PRIVILEGED_ENV_VAR = "BASE44_EXEC_PRIVILEGED";
|
|
256176
|
+
var DATA_ENV_ENV_VAR = "BASE44_EXEC_DATA_ENV";
|
|
256177
|
+
function read3(env, name) {
|
|
256178
|
+
return env[name]?.trim() || undefined;
|
|
256179
|
+
}
|
|
256180
|
+
function hasExecEnvTarget(env = process.env) {
|
|
256181
|
+
return EXEC_ENV_VARS.some((name) => read3(env, name) !== undefined);
|
|
256182
|
+
}
|
|
256183
|
+
function readExecEnvTarget(env = process.env) {
|
|
256184
|
+
if (!hasExecEnvTarget(env)) {
|
|
256185
|
+
return;
|
|
256186
|
+
}
|
|
256187
|
+
const token = read3(env, ACCESS_TOKEN_VAR);
|
|
256188
|
+
const serverUrl = read3(env, SERVER_URL_VAR);
|
|
256189
|
+
if (!token || !serverUrl) {
|
|
256190
|
+
const missing = token ? SERVER_URL_VAR : ACCESS_TOKEN_VAR;
|
|
256191
|
+
throw new InvalidInputError(`${missing} is not set. ${ACCESS_TOKEN_VAR} and ${SERVER_URL_VAR} must be set together.`, {
|
|
256192
|
+
hints: [
|
|
256193
|
+
{
|
|
256194
|
+
message: `Set both ${ACCESS_TOKEN_VAR} and ${SERVER_URL_VAR}, or unset all of them to use your login`
|
|
256195
|
+
}
|
|
256196
|
+
]
|
|
256197
|
+
});
|
|
256198
|
+
}
|
|
256199
|
+
if (!URL.canParse(serverUrl)) {
|
|
256200
|
+
throw new InvalidInputError(`${SERVER_URL_VAR} is not a valid URL.`);
|
|
256201
|
+
}
|
|
256202
|
+
const serviceToken = read3(env, SERVICE_TOKEN_VAR);
|
|
256203
|
+
return { token, serverUrl, ...serviceToken ? { serviceToken } : {} };
|
|
256204
|
+
}
|
|
256180
256205
|
// src/core/exec/run-script.ts
|
|
256181
256206
|
import { spawn as spawn4 } from "node:child_process";
|
|
256182
256207
|
import { copyFileSync, writeFileSync as writeFileSync3 } from "node:fs";
|
|
256208
|
+
var SERVICE_TOKEN_ENV = "BASE44_SERVICE_TOKEN";
|
|
256209
|
+
function inheritedEnv() {
|
|
256210
|
+
const env = { ...process.env };
|
|
256211
|
+
for (const name of [
|
|
256212
|
+
...EXEC_ENV_VARS,
|
|
256213
|
+
PRIVILEGED_ENV_VAR,
|
|
256214
|
+
DATA_ENV_ENV_VAR,
|
|
256215
|
+
SERVICE_TOKEN_ENV
|
|
256216
|
+
]) {
|
|
256217
|
+
delete env[name];
|
|
256218
|
+
}
|
|
256219
|
+
return env;
|
|
256220
|
+
}
|
|
256183
256221
|
async function runScript(options) {
|
|
256184
|
-
const { appId, code, local, privileged, dataEnv } = options;
|
|
256222
|
+
const { appId, code, local, privileged, dataEnv, serviceToken } = options;
|
|
256185
256223
|
verifyDenoInstalled("to run scripts with exec");
|
|
256186
256224
|
const cleanupFns = [];
|
|
256187
256225
|
const tempScript = await $file({ postfix: ".ts" });
|
|
@@ -256194,9 +256232,10 @@ async function runScript(options) {
|
|
|
256194
256232
|
copyFileSync(getExecWrapperPath(), tempWrapper.path);
|
|
256195
256233
|
try {
|
|
256196
256234
|
const exitCode = await new Promise((resolvePromise) => {
|
|
256197
|
-
const child = spawn4("deno", ["run", "--allow-all", "--node-modules-dir=
|
|
256235
|
+
const child = spawn4("deno", ["run", "--allow-all", "--node-modules-dir=none", tempWrapper.path], {
|
|
256198
256236
|
env: {
|
|
256199
|
-
...
|
|
256237
|
+
...inheritedEnv(),
|
|
256238
|
+
...serviceToken ? { [SERVICE_TOKEN_ENV]: serviceToken } : {},
|
|
256200
256239
|
SCRIPT_PATH: scriptPath,
|
|
256201
256240
|
BASE44_APP_ID: appId,
|
|
256202
256241
|
BASE44_ACCESS_TOKEN: appUserToken,
|
|
@@ -256251,6 +256290,10 @@ async function execAction({ app, isNonInteractive }, options) {
|
|
|
256251
256290
|
hints: [{ message: "Usage: base44 exec --local --port <port>" }]
|
|
256252
256291
|
});
|
|
256253
256292
|
}
|
|
256293
|
+
const envTarget = readExecEnvTarget();
|
|
256294
|
+
if (envTarget && options.local) {
|
|
256295
|
+
throw new InvalidInputError("--local cannot be used when BASE44_EXEC_ACCESS_TOKEN and BASE44_EXEC_SERVER_URL are set.");
|
|
256296
|
+
}
|
|
256254
256297
|
const noInputError = new InvalidInputError("No input provided. Pipe a script to stdin.", {
|
|
256255
256298
|
hints: [
|
|
256256
256299
|
{ message: "File: cat ./script.ts | base44 exec" },
|
|
@@ -256266,13 +256309,14 @@ async function execAction({ app, isNonInteractive }, options) {
|
|
|
256266
256309
|
if (!code.trim()) {
|
|
256267
256310
|
throw noInputError;
|
|
256268
256311
|
}
|
|
256269
|
-
const local = options.local ? await resolveLocalTarget(options.port !== undefined ? parsePort(options.port) : DEFAULT_DEV_SERVER_PORT) : undefined;
|
|
256312
|
+
const local = envTarget ? { serverUrl: envTarget.serverUrl, token: envTarget.token } : options.local ? await resolveLocalTarget(options.port !== undefined ? parsePort(options.port) : DEFAULT_DEV_SERVER_PORT) : undefined;
|
|
256270
256313
|
const { exitCode } = await runScript({
|
|
256271
256314
|
appId: app.id,
|
|
256272
256315
|
code,
|
|
256273
256316
|
local,
|
|
256274
|
-
privileged: options.privileged,
|
|
256275
|
-
dataEnv: options.dataEnv
|
|
256317
|
+
privileged: options.privileged || process.env[PRIVILEGED_ENV_VAR] !== undefined,
|
|
256318
|
+
dataEnv: options.dataEnv ?? process.env[DATA_ENV_ENV_VAR],
|
|
256319
|
+
serviceToken: envTarget?.serviceToken
|
|
256276
256320
|
});
|
|
256277
256321
|
if (exitCode !== 0) {
|
|
256278
256322
|
process.exitCode = exitCode;
|
|
@@ -256280,7 +256324,7 @@ async function execAction({ app, isNonInteractive }, options) {
|
|
|
256280
256324
|
return {};
|
|
256281
256325
|
}
|
|
256282
256326
|
function getExecCommand() {
|
|
256283
|
-
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", `
|
|
256327
|
+
return new Base44Command("exec", { requireAuth: !hasExecEnvTarget() }).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", `
|
|
256284
256328
|
Examples:
|
|
256285
256329
|
Run a script file:
|
|
256286
256330
|
$ cat ./script.ts | base44 exec
|
|
@@ -260504,4 +260548,4 @@ export {
|
|
|
260504
260548
|
runCLI
|
|
260505
260549
|
};
|
|
260506
260550
|
|
|
260507
|
-
//# debugId=
|
|
260551
|
+
//# debugId=03B01903A1BCF87864756E2164756E21
|