@base44-preview/cli 0.2.7-pr.687.f53a85d → 0.3.1-pr.681.2955317

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/cli/index.js CHANGED
@@ -228411,6 +228411,22 @@ class UserError extends CLIError {
228411
228411
 
228412
228412
  class SystemError extends CLIError {
228413
228413
  }
228414
+
228415
+ class AuthRequiredError extends UserError {
228416
+ code = "AUTH_REQUIRED";
228417
+ constructor(message = "Authentication required", options) {
228418
+ super(message, {
228419
+ hints: options?.hints ?? [
228420
+ {
228421
+ message: "Run 'base44 login' to authenticate",
228422
+ command: "base44 login"
228423
+ }
228424
+ ],
228425
+ cause: options?.cause
228426
+ });
228427
+ }
228428
+ }
228429
+
228414
228430
  class AuthExpiredError extends UserError {
228415
228431
  code = "AUTH_EXPIRED";
228416
228432
  constructor(message = "Authentication has expired", options) {
@@ -228814,13 +228830,19 @@ function findEnvDir(cwd) {
228814
228830
  const configDir = dirname3(found.configPath);
228815
228831
  return basename(configDir) === PROJECT_SUBDIR ? dirname3(configDir) : configDir;
228816
228832
  }
228833
+ var accessTokenFromEnvFile = false;
228834
+ function isAccessTokenFromEnvFile() {
228835
+ return accessTokenFromEnvFile;
228836
+ }
228817
228837
  function loadProjectEnvFiles(cwd = process.cwd()) {
228818
228838
  const root = findEnvDir(cwd);
228839
+ const ambientAccessToken = process.env.BASE44_ACCESS_TOKEN ?? process.env[`${STRIPE_ENV_PREFIX}BASE44_ACCESS_TOKEN`];
228819
228840
  import_dotenv.config({
228820
228841
  path: [join(root, ".env.local"), join(root, ".env")],
228821
228842
  quiet: true
228822
228843
  });
228823
228844
  normalizeBase44Env();
228845
+ accessTokenFromEnvFile = ambientAccessToken === undefined && process.env.BASE44_ACCESS_TOKEN !== undefined;
228824
228846
  }
228825
228847
  function normalizeBase44Env() {
228826
228848
  for (const bareKey of BASE44_ENV_KEYS) {
@@ -230833,6 +230855,7 @@ function getTestOverrides() {
230833
230855
  var TOKEN_REFRESH_BUFFER_MS = 60 * 1000;
230834
230856
  var WORKSPACE_API_KEY_PREFIX = "b44k_";
230835
230857
  var refreshPromise = null;
230858
+ var envAccessTokenAuth = null;
230836
230859
  function getWorkspaceApiKeyFromEnv() {
230837
230860
  const key = process.env.BASE44_API_KEY?.trim();
230838
230861
  return key ? key : null;
@@ -230854,7 +230877,20 @@ async function seedAuthFromEnv() {
230854
230877
  const payload = claims !== null && typeof claims === "object" ? claims : null;
230855
230878
  const sub = typeof payload?.sub === "string" ? payload.sub : undefined;
230856
230879
  const exp = typeof payload?.exp === "number" ? payload.exp : undefined;
230857
- if (!refreshToken || !sub || !exp) {
230880
+ if (!sub || !exp) {
230881
+ return;
230882
+ }
230883
+ if (!refreshToken) {
230884
+ if (isAccessTokenFromEnvFile()) {
230885
+ return;
230886
+ }
230887
+ envAccessTokenAuth = {
230888
+ accessToken,
230889
+ refreshToken: "",
230890
+ expiresAt: exp * 1000,
230891
+ email: sub,
230892
+ name: sub
230893
+ };
230858
230894
  return;
230859
230895
  }
230860
230896
  await writeAuth({
@@ -230866,6 +230902,9 @@ async function seedAuthFromEnv() {
230866
230902
  });
230867
230903
  }
230868
230904
  async function readAuth() {
230905
+ if (envAccessTokenAuth) {
230906
+ return envAccessTokenAuth;
230907
+ }
230869
230908
  try {
230870
230909
  const authData = await readJsonFile(getAuthFilePath());
230871
230910
  const result = AuthDataSchema.safeParse(authData);
@@ -230902,6 +230941,9 @@ function isTokenExpired(auth) {
230902
230941
  return Date.now() >= auth.expiresAt - TOKEN_REFRESH_BUFFER_MS;
230903
230942
  }
230904
230943
  async function refreshAndSaveTokens() {
230944
+ if (envAccessTokenAuth) {
230945
+ return null;
230946
+ }
230905
230947
  if (refreshPromise) {
230906
230948
  return refreshPromise;
230907
230949
  }
@@ -238253,7 +238295,7 @@ async function pullAllConnectors() {
238253
238295
  return connectors;
238254
238296
  }
238255
238297
  // src/core/resources/connector/push.ts
238256
- async function pushConnectors(connectors, { prune = true } = {}) {
238298
+ async function pushConnectors(connectors, { prune = false } = {}) {
238257
238299
  const stripeConnector = connectors.find((c) => c.type === STRIPE_CONNECTOR_TYPE);
238258
238300
  const oauthConnectors = connectors.filter((c) => c.type !== STRIPE_CONNECTOR_TYPE);
238259
238301
  const oauthResults = await syncOAuthConnectors(oauthConnectors, prune);
@@ -238674,7 +238716,8 @@ var BackendFunctionSchema = FunctionConfigSchema.extend({
238674
238716
  source: ResourceSourceSchema
238675
238717
  });
238676
238718
  var DeploySingleFunctionResponseSchema = object({
238677
- status: _enum(["deployed", "unchanged"])
238719
+ status: _enum(["deployed", "unchanged"]),
238720
+ warnings: array(string2()).optional().default([])
238678
238721
  });
238679
238722
  var FunctionInfoSchema = object({
238680
238723
  name: string2(),
@@ -238901,7 +238944,8 @@ async function deployOne2(fn) {
238901
238944
  return {
238902
238945
  name: functionWithCode.name,
238903
238946
  status: response.status,
238904
- durationMs: Date.now() - start
238947
+ durationMs: Date.now() - start,
238948
+ warnings: response.warnings
238905
238949
  };
238906
238950
  } catch (error) {
238907
238951
  return {
@@ -239387,7 +239431,7 @@ import { join as join13 } from "node:path";
239387
239431
  // package.json
239388
239432
  var package_default = {
239389
239433
  name: "base44",
239390
- version: "0.2.7",
239434
+ version: "0.3.1",
239391
239435
  description: "Base44 CLI - Unified interface for managing Base44 applications",
239392
239436
  type: "module",
239393
239437
  bin: {
@@ -246982,9 +247026,7 @@ async function deployAll(projectData, options) {
246982
247026
  await agentSkillResource.push(agentSkills);
246983
247027
  await agentResource.push(agents);
246984
247028
  await authConfigResource.push(authConfig);
246985
- const { results: connectorResults } = await pushConnectors(connectors, {
246986
- prune: false
246987
- });
247029
+ const { results: connectorResults } = await pushConnectors(connectors);
246988
247030
  const appUrl = await deployProjectSite(project, options);
246989
247031
  return appUrl ? { appUrl, connectorResults } : { connectorResults };
246990
247032
  }
@@ -247246,6 +247288,24 @@ async function getUserInfo(accessToken) {
247246
247288
  }
247247
247289
  return result.data;
247248
247290
  }
247291
+ async function getSessionUser() {
247292
+ let response;
247293
+ try {
247294
+ response = await base44Client.get("oauth/userinfo");
247295
+ } catch (error) {
247296
+ if (error instanceof HTTPError && error.response.status === 401) {
247297
+ throw new AuthExpiredError("Your session has expired or was revoked", {
247298
+ cause: error
247299
+ });
247300
+ }
247301
+ throw await ApiError.fromHttpError(error, "verifying the session with the server");
247302
+ }
247303
+ const result = UserInfoSchema.safeParse(await response.json());
247304
+ if (!result.success) {
247305
+ throw new SchemaValidationError("Invalid UserInfo response from server", result.error);
247306
+ }
247307
+ return result.data;
247308
+ }
247249
247309
  // src/cli/commands/auth/login-flow.ts
247250
247310
  async function generateAndDisplayDeviceCode(log, runTask) {
247251
247311
  const deviceCodeResponse = await runTask("Generating device code...", async () => {
@@ -247322,6 +247382,16 @@ async function ensureAuth(ctx) {
247322
247382
  await seedAuthFromEnv();
247323
247383
  const loggedIn = await isLoggedIn();
247324
247384
  if (!loggedIn) {
247385
+ if (ctx.isNonInteractive) {
247386
+ throw new AuthRequiredError("Not logged in", {
247387
+ hints: [
247388
+ { message: "Run 'base44 login' first", command: "base44 login" },
247389
+ {
247390
+ message: "Or set BASE44_API_KEY, or BASE44_ACCESS_TOKEN and BASE44_REFRESH_TOKEN"
247391
+ }
247392
+ ]
247393
+ });
247394
+ }
247325
247395
  ctx.log.info("You need to login first to continue.");
247326
247396
  await login(ctx);
247327
247397
  }
@@ -247853,6 +247923,11 @@ function formatDeployResult(result, log) {
247853
247923
  log.success(`${label} unchanged`);
247854
247924
  } else {
247855
247925
  log.error(`${label} error: ${result.error}`);
247926
+ return;
247927
+ }
247928
+ for (const warning of result.warnings ?? []) {
247929
+ const prefix = `${result.name}: `;
247930
+ log.warn(warning.startsWith(prefix) ? warning : `${prefix}${warning}`);
247856
247931
  }
247857
247932
  }
247858
247933
 
@@ -247875,9 +247950,6 @@ async function deployActorsAction({ log, jsonMode }, rawNames) {
247875
247950
  onResult: (result) => {
247876
247951
  completed++;
247877
247952
  formatDeployResult(result, log);
247878
- if (result.status !== "error")
247879
- for (const warning of result.warnings)
247880
- log.warn(`${result.name}: ${warning}`);
247881
247953
  }
247882
247954
  });
247883
247955
  const summary = {
@@ -250417,11 +250489,18 @@ async function whoami(_ctx) {
250417
250489
  outroMessage: `Using workspace API key: ${theme.styles.bold(workspaceApiKey.slice(0, 10))}`
250418
250490
  };
250419
250491
  }
250420
- const auth = await readAuth();
250421
- return { outroMessage: `Logged in as: ${theme.styles.bold(auth.email)}` };
250492
+ await seedAuthFromEnv();
250493
+ if (!await isLoggedIn()) {
250494
+ throw new AuthRequiredError("Not logged in");
250495
+ }
250496
+ const user = await getSessionUser();
250497
+ return { outroMessage: `Logged in as: ${theme.styles.bold(user.email)}` };
250422
250498
  }
250423
250499
  function getWhoamiCommand() {
250424
- return new Base44Command("whoami", { requireAppContext: false }).description("Display current authenticated user").action(whoami);
250500
+ return new Base44Command("whoami", {
250501
+ requireAuth: false,
250502
+ requireAppContext: false
250503
+ }).description("Display current authenticated user").action(whoami);
250425
250504
  }
250426
250505
 
250427
250506
  // src/cli/commands/branches/index.ts
@@ -251362,25 +251441,26 @@ function printSummary(results, oauthOutcomes, log) {
251362
251441
  }
251363
251442
  async function pushConnectorsAction({ isNonInteractive, log, runTask, jsonMode }, options) {
251364
251443
  const connectors = await readConnectorsToPush(options);
251444
+ if (connectors.length === 0) {
251445
+ return { outroMessage: "No local connectors found - nothing to push" };
251446
+ }
251365
251447
  if (!jsonMode) {
251366
- if (connectors.length === 0) {
251367
- log.info("No local connectors found - checking for remote connectors to remove");
251368
- } else {
251369
- const connectorNames = connectors.map((c) => c.type).join(", ");
251370
- log.info(`Found ${connectors.length} connectors to push: ${connectorNames}`);
251371
- }
251448
+ const connectorNames = connectors.map((c) => c.type).join(", ");
251449
+ log.info(`Found ${connectors.length} connectors to push: ${connectorNames}`);
251372
251450
  }
251373
- const proceed = await confirmPush({
251374
- isNonInteractive,
251375
- yes: options.yes,
251376
- log,
251377
- warning: "This will overwrite your app's connectors with your local copy and remove any not present locally."
251378
- });
251379
- if (!proceed) {
251380
- return { outroMessage: "Push cancelled" };
251451
+ if (options.force) {
251452
+ const proceed = await confirmPush({
251453
+ isNonInteractive,
251454
+ yes: options.yes,
251455
+ log,
251456
+ warning: "This will remove any connectors on Base44 that are not present locally."
251457
+ });
251458
+ if (!proceed) {
251459
+ return { outroMessage: "Push cancelled" };
251460
+ }
251381
251461
  }
251382
251462
  const { results } = await runTask("Pushing connectors to Base44", async () => {
251383
- return await pushConnectors(connectors);
251463
+ return await pushConnectors(connectors, { prune: options.force });
251384
251464
  });
251385
251465
  const needsOAuth = filterPendingOAuth(results);
251386
251466
  let outroMessage = "Connectors pushed to Base44";
@@ -251402,7 +251482,7 @@ async function pushConnectorsAction({ isNonInteractive, log, runTask, jsonMode }
251402
251482
  return { outroMessage };
251403
251483
  }
251404
251484
  function getConnectorsPushCommand() {
251405
- 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);
251485
+ return new Base44Command("push").description("Push local connectors to Base44 (adds and updates; --force also removes the rest)").option("--dir <path>", "Directory to read connector files from (default: ./connectors when using --app-id)").option("--force", "Remove connectors on Base44 not found locally").option("-y, --yes", "Skip the --force confirmation prompt").action(pushConnectorsAction);
251406
251486
  }
251407
251487
 
251408
251488
  // src/cli/commands/connectors/index.ts
@@ -252107,9 +252187,6 @@ ${summaryLines.join(`
252107
252187
  onActorResult: (result) => {
252108
252188
  actorCompleted++;
252109
252189
  formatDeployResult(result, log);
252110
- if (result.status !== "error")
252111
- for (const warning of result.warnings)
252112
- log.warn(`${result.name}: ${warning}`);
252113
252190
  }
252114
252191
  });
252115
252192
  const connectorResults = result.connectorResults ?? [];
@@ -252118,14 +252195,16 @@ ${summaryLines.join(`
252118
252195
  if (stripeResult?.action === "provisioned") {
252119
252196
  printStripeResult(stripeResult, log);
252120
252197
  }
252121
- for (const r of connectorResults) {
252122
- if (r.action === "error")
252123
- log.error(`Failed: ${r.type} - ${r.error}`);
252124
- }
252125
252198
  log.message(`${theme.styles.header("Dashboard")}: ${theme.colors.links(getDashboardUrl())}`);
252126
252199
  if (result.appUrl) {
252127
252200
  log.message(`${theme.styles.header("App URL")}: ${theme.colors.links(result.appUrl)}`);
252128
252201
  }
252202
+ const failedConnectors = connectorResults.flatMap((r) => r.action === "error" ? [`Connector ${r.type}: ${r.error}`] : []);
252203
+ if (failedConnectors.length > 0) {
252204
+ throw new ResourceDeploymentError("Some connectors failed to sync", {
252205
+ details: failedConnectors
252206
+ });
252207
+ }
252129
252208
  return { outroMessage: "App deployed successfully" };
252130
252209
  }
252131
252210
  function getDeployCommand3() {
@@ -274989,4 +275068,4 @@ export {
274989
275068
  runCLI
274990
275069
  };
274991
275070
 
274992
- //# debugId=4C75853E117A86FD64756E2164756E21
275071
+ //# debugId=DCA6666E6511D55264756E2164756E21