@base44-preview/cli 0.3.1-pr.692.8cd7d7b → 0.3.1-pr.694.631024e

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.
@@ -8,7 +8,7 @@
8
8
  * - SCRIPT_PATH: Absolute path (or file:// URL) to the user's script
9
9
  * - BASE44_APP_ID: App identifier from .app.jsonc
10
10
  * - BASE44_ACCESS_TOKEN: User's access token
11
- * - BASE44_APP_BASE_URL: App's published URL / subdomain (used for function calls)
11
+ * - BASE44_APP_BASE_URL: App's published URL, or its preview URL before the first publish (function calls need an app host)
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
14
  * - BASE44_SERVICE_TOKEN: When set, passed as `serviceToken` (enables `base44.asServiceRole`)
package/dist/cli/index.js CHANGED
@@ -228514,6 +228514,21 @@ class DependencyNotFoundError extends UserError {
228514
228514
  });
228515
228515
  }
228516
228516
  }
228517
+
228518
+ class AppNotPublishedError extends UserError {
228519
+ code = "APP_NOT_PUBLISHED";
228520
+ constructor(message = "This app has not been published yet, so it has no site URL", options) {
228521
+ super(message, {
228522
+ hints: options?.hints ?? [
228523
+ {
228524
+ message: "Publish the app in the Base44 builder, or deploy its site with 'base44 deploy'",
228525
+ command: "base44 deploy"
228526
+ }
228527
+ ],
228528
+ cause: options?.cause
228529
+ });
228530
+ }
228531
+ }
228517
228532
  var MAX_RESPONSE_TEXT_CHARS = 500;
228518
228533
  async function readResponseText(response) {
228519
228534
  try {
@@ -266128,10 +266143,18 @@ function getSiteInstallCommand() {
266128
266143
  }
266129
266144
 
266130
266145
  // src/cli/commands/site/open.ts
266146
+ var isAppNotPublished = (error) => error instanceof ApiError && error.statusCode === 404;
266147
+ async function getPublishedSiteUrl() {
266148
+ try {
266149
+ return await getSiteUrl();
266150
+ } catch (error) {
266151
+ throw isAppNotPublished(error) ? new AppNotPublishedError : error;
266152
+ }
266153
+ }
266131
266154
  async function openAction({
266132
266155
  isNonInteractive
266133
266156
  }) {
266134
- const siteUrl = await getSiteUrl();
266157
+ const siteUrl = await getPublishedSiteUrl();
266135
266158
  if (!isNonInteractive) {
266136
266159
  await open_default(siteUrl);
266137
266160
  }
@@ -270697,6 +270720,17 @@ function inheritedEnv() {
270697
270720
  }
270698
270721
  return env;
270699
270722
  }
270723
+ var appPreviewUrl = (appId) => `https://preview--${appId}.base44.app`;
270724
+ async function resolveAppBaseUrl(appId) {
270725
+ try {
270726
+ return await getSiteUrl();
270727
+ } catch (error) {
270728
+ if (error instanceof ApiError && error.statusCode === 404) {
270729
+ return appPreviewUrl(appId);
270730
+ }
270731
+ throw error;
270732
+ }
270733
+ }
270700
270734
  async function runScript(options) {
270701
270735
  const { appId, code, local, privileged, dataEnv, serviceToken, sdkVersion } = options;
270702
270736
  verifyDenoInstalled("to run scripts with exec");
@@ -270705,7 +270739,7 @@ async function runScript(options) {
270705
270739
  cleanupFns.push(tempScript.cleanup);
270706
270740
  writeFileSync3(tempScript.path, code, "utf-8");
270707
270741
  const scriptPath = `file://${tempScript.path}`;
270708
- const [appUserToken, appBaseUrl] = local ? [local.token, local.serverUrl] : await Promise.all([getAppUserToken(), getSiteUrl()]);
270742
+ const [appUserToken, appBaseUrl] = local ? [local.token, local.serverUrl] : await Promise.all([getAppUserToken(), resolveAppBaseUrl(appId)]);
270709
270743
  const tempWrapper = await $file({ postfix: ".ts" });
270710
270744
  cleanupFns.push(tempWrapper.cleanup);
270711
270745
  writeFileSync3(tempWrapper.path, wrapperSource(sdkVersion), "utf-8");
@@ -275042,4 +275076,4 @@ export {
275042
275076
  runCLI
275043
275077
  };
275044
275078
 
275045
- //# debugId=B638BBD3E1A945A364756E2164756E21
275079
+ //# debugId=466212F1DC31ACE064756E2164756E21