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

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) {
@@ -238253,7 +238269,7 @@ async function pullAllConnectors() {
238253
238269
  return connectors;
238254
238270
  }
238255
238271
  // src/core/resources/connector/push.ts
238256
- async function pushConnectors(connectors, { prune = true } = {}) {
238272
+ async function pushConnectors(connectors, { prune = false } = {}) {
238257
238273
  const stripeConnector = connectors.find((c) => c.type === STRIPE_CONNECTOR_TYPE);
238258
238274
  const oauthConnectors = connectors.filter((c) => c.type !== STRIPE_CONNECTOR_TYPE);
238259
238275
  const oauthResults = await syncOAuthConnectors(oauthConnectors, prune);
@@ -238674,7 +238690,8 @@ var BackendFunctionSchema = FunctionConfigSchema.extend({
238674
238690
  source: ResourceSourceSchema
238675
238691
  });
238676
238692
  var DeploySingleFunctionResponseSchema = object({
238677
- status: _enum(["deployed", "unchanged"])
238693
+ status: _enum(["deployed", "unchanged"]),
238694
+ warnings: array(string2()).optional().default([])
238678
238695
  });
238679
238696
  var FunctionInfoSchema = object({
238680
238697
  name: string2(),
@@ -238781,8 +238798,11 @@ async function fetchFunctionLogs(functionName, filters = {}) {
238781
238798
  }
238782
238799
  // src/core/resources/function/config.ts
238783
238800
  import { basename as basename4, dirname as dirname8, join as join10, relative as relative3, resolve as resolve2 } from "node:path";
238801
+ function getSharedDir(functionsDir) {
238802
+ return resolve2(functionsDir, "..", "shared");
238803
+ }
238784
238804
  async function readSharedFiles(functionsDir) {
238785
- const sharedDir = resolve2(functionsDir, "..", "shared");
238805
+ const sharedDir = getSharedDir(functionsDir);
238786
238806
  if (!await pathExists(sharedDir)) {
238787
238807
  return [];
238788
238808
  }
@@ -238901,7 +238921,8 @@ async function deployOne2(fn) {
238901
238921
  return {
238902
238922
  name: functionWithCode.name,
238903
238923
  status: response.status,
238904
- durationMs: Date.now() - start
238924
+ durationMs: Date.now() - start,
238925
+ warnings: response.warnings
238905
238926
  };
238906
238927
  } catch (error) {
238907
238928
  return {
@@ -239387,7 +239408,7 @@ import { join as join13 } from "node:path";
239387
239408
  // package.json
239388
239409
  var package_default = {
239389
239410
  name: "base44",
239390
- version: "0.2.7",
239411
+ version: "0.3.1",
239391
239412
  description: "Base44 CLI - Unified interface for managing Base44 applications",
239392
239413
  type: "module",
239393
239414
  bin: {
@@ -246982,9 +247003,7 @@ async function deployAll(projectData, options) {
246982
247003
  await agentSkillResource.push(agentSkills);
246983
247004
  await agentResource.push(agents);
246984
247005
  await authConfigResource.push(authConfig);
246985
- const { results: connectorResults } = await pushConnectors(connectors, {
246986
- prune: false
246987
- });
247006
+ const { results: connectorResults } = await pushConnectors(connectors);
246988
247007
  const appUrl = await deployProjectSite(project, options);
246989
247008
  return appUrl ? { appUrl, connectorResults } : { connectorResults };
246990
247009
  }
@@ -247246,6 +247265,24 @@ async function getUserInfo(accessToken) {
247246
247265
  }
247247
247266
  return result.data;
247248
247267
  }
247268
+ async function getSessionUser() {
247269
+ let response;
247270
+ try {
247271
+ response = await base44Client.get("oauth/userinfo");
247272
+ } catch (error) {
247273
+ if (error instanceof HTTPError && error.response.status === 401) {
247274
+ throw new AuthExpiredError("Your session has expired or was revoked", {
247275
+ cause: error
247276
+ });
247277
+ }
247278
+ throw await ApiError.fromHttpError(error, "verifying the session with the server");
247279
+ }
247280
+ const result = UserInfoSchema.safeParse(await response.json());
247281
+ if (!result.success) {
247282
+ throw new SchemaValidationError("Invalid UserInfo response from server", result.error);
247283
+ }
247284
+ return result.data;
247285
+ }
247249
247286
  // src/cli/commands/auth/login-flow.ts
247250
247287
  async function generateAndDisplayDeviceCode(log, runTask) {
247251
247288
  const deviceCodeResponse = await runTask("Generating device code...", async () => {
@@ -247322,6 +247359,16 @@ async function ensureAuth(ctx) {
247322
247359
  await seedAuthFromEnv();
247323
247360
  const loggedIn = await isLoggedIn();
247324
247361
  if (!loggedIn) {
247362
+ if (ctx.isNonInteractive) {
247363
+ throw new AuthRequiredError("Not logged in", {
247364
+ hints: [
247365
+ { message: "Run 'base44 login' first", command: "base44 login" },
247366
+ {
247367
+ message: "Or set BASE44_API_KEY, or BASE44_ACCESS_TOKEN and BASE44_REFRESH_TOKEN"
247368
+ }
247369
+ ]
247370
+ });
247371
+ }
247325
247372
  ctx.log.info("You need to login first to continue.");
247326
247373
  await login(ctx);
247327
247374
  }
@@ -247853,6 +247900,11 @@ function formatDeployResult(result, log) {
247853
247900
  log.success(`${label} unchanged`);
247854
247901
  } else {
247855
247902
  log.error(`${label} error: ${result.error}`);
247903
+ return;
247904
+ }
247905
+ for (const warning of result.warnings ?? []) {
247906
+ const prefix = `${result.name}: `;
247907
+ log.warn(warning.startsWith(prefix) ? warning : `${prefix}${warning}`);
247856
247908
  }
247857
247909
  }
247858
247910
 
@@ -247875,9 +247927,6 @@ async function deployActorsAction({ log, jsonMode }, rawNames) {
247875
247927
  onResult: (result) => {
247876
247928
  completed++;
247877
247929
  formatDeployResult(result, log);
247878
- if (result.status !== "error")
247879
- for (const warning of result.warnings)
247880
- log.warn(`${result.name}: ${warning}`);
247881
247930
  }
247882
247931
  });
247883
247932
  const summary = {
@@ -250417,11 +250466,18 @@ async function whoami(_ctx) {
250417
250466
  outroMessage: `Using workspace API key: ${theme.styles.bold(workspaceApiKey.slice(0, 10))}`
250418
250467
  };
250419
250468
  }
250420
- const auth = await readAuth();
250421
- return { outroMessage: `Logged in as: ${theme.styles.bold(auth.email)}` };
250469
+ await seedAuthFromEnv();
250470
+ if (!await isLoggedIn()) {
250471
+ throw new AuthRequiredError("Not logged in");
250472
+ }
250473
+ const user = await getSessionUser();
250474
+ return { outroMessage: `Logged in as: ${theme.styles.bold(user.email)}` };
250422
250475
  }
250423
250476
  function getWhoamiCommand() {
250424
- return new Base44Command("whoami", { requireAppContext: false }).description("Display current authenticated user").action(whoami);
250477
+ return new Base44Command("whoami", {
250478
+ requireAuth: false,
250479
+ requireAppContext: false
250480
+ }).description("Display current authenticated user").action(whoami);
250425
250481
  }
250426
250482
 
250427
250483
  // src/cli/commands/branches/index.ts
@@ -251362,25 +251418,26 @@ function printSummary(results, oauthOutcomes, log) {
251362
251418
  }
251363
251419
  async function pushConnectorsAction({ isNonInteractive, log, runTask, jsonMode }, options) {
251364
251420
  const connectors = await readConnectorsToPush(options);
251421
+ if (connectors.length === 0) {
251422
+ return { outroMessage: "No local connectors found - nothing to push" };
251423
+ }
251365
251424
  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
- }
251425
+ const connectorNames = connectors.map((c) => c.type).join(", ");
251426
+ log.info(`Found ${connectors.length} connectors to push: ${connectorNames}`);
251372
251427
  }
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" };
251428
+ if (options.force) {
251429
+ const proceed = await confirmPush({
251430
+ isNonInteractive,
251431
+ yes: options.yes,
251432
+ log,
251433
+ warning: "This will remove any connectors on Base44 that are not present locally."
251434
+ });
251435
+ if (!proceed) {
251436
+ return { outroMessage: "Push cancelled" };
251437
+ }
251381
251438
  }
251382
251439
  const { results } = await runTask("Pushing connectors to Base44", async () => {
251383
- return await pushConnectors(connectors);
251440
+ return await pushConnectors(connectors, { prune: options.force });
251384
251441
  });
251385
251442
  const needsOAuth = filterPendingOAuth(results);
251386
251443
  let outroMessage = "Connectors pushed to Base44";
@@ -251402,7 +251459,7 @@ async function pushConnectorsAction({ isNonInteractive, log, runTask, jsonMode }
251402
251459
  return { outroMessage };
251403
251460
  }
251404
251461
  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);
251462
+ 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
251463
  }
251407
251464
 
251408
251465
  // src/cli/commands/connectors/index.ts
@@ -252107,9 +252164,6 @@ ${summaryLines.join(`
252107
252164
  onActorResult: (result) => {
252108
252165
  actorCompleted++;
252109
252166
  formatDeployResult(result, log);
252110
- if (result.status !== "error")
252111
- for (const warning of result.warnings)
252112
- log.warn(`${result.name}: ${warning}`);
252113
252167
  }
252114
252168
  });
252115
252169
  const connectorResults = result.connectorResults ?? [];
@@ -252118,14 +252172,16 @@ ${summaryLines.join(`
252118
252172
  if (stripeResult?.action === "provisioned") {
252119
252173
  printStripeResult(stripeResult, log);
252120
252174
  }
252121
- for (const r of connectorResults) {
252122
- if (r.action === "error")
252123
- log.error(`Failed: ${r.type} - ${r.error}`);
252124
- }
252125
252175
  log.message(`${theme.styles.header("Dashboard")}: ${theme.colors.links(getDashboardUrl())}`);
252126
252176
  if (result.appUrl) {
252127
252177
  log.message(`${theme.styles.header("App URL")}: ${theme.colors.links(result.appUrl)}`);
252128
252178
  }
252179
+ const failedConnectors = connectorResults.flatMap((r) => r.action === "error" ? [`Connector ${r.type}: ${r.error}`] : []);
252180
+ if (failedConnectors.length > 0) {
252181
+ throw new ResourceDeploymentError("Some connectors failed to sync", {
252182
+ details: failedConnectors
252183
+ });
252184
+ }
252129
252185
  return { outroMessage: "App deployed successfully" };
252130
252186
  }
252131
252187
  function getDeployCommand3() {
@@ -270417,14 +270473,16 @@ async function createDevServer(options) {
270417
270473
  emitEntityEvent = (appId, entityName, event) => {
270418
270474
  broadcastEntityEvent(io, appId, entityName, event);
270419
270475
  };
270476
+ const functionsDir = join40(dirname29(project.configPath), project.functionsDir);
270420
270477
  const base44ConfigWatcher = new WatchBase44({
270421
- functions: join40(dirname29(project.configPath), project.functionsDir),
270478
+ functions: functionsDir,
270479
+ shared: getSharedDir(functionsDir),
270422
270480
  entities: join40(dirname29(project.configPath), project.entitiesDir)
270423
270481
  }, devLogger);
270424
270482
  base44ConfigWatcher.on("change", async (name) => {
270425
270483
  try {
270426
270484
  const { functions, entities } = await options.loadResources();
270427
- if (name === "functions") {
270485
+ if (name === "functions" || name === "shared") {
270428
270486
  const previousFunctionCount = functionManager.getFunctionNames().length;
270429
270487
  await functionManager.reload(functions);
270430
270488
  const names = functionManager.getFunctionNames();
@@ -274989,4 +275047,4 @@ export {
274989
275047
  runCLI
274990
275048
  };
274991
275049
 
274992
- //# debugId=4C75853E117A86FD64756E2164756E21
275050
+ //# debugId=B298C98845AB73BC64756E2164756E21